<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0"><channel><title>KishoreLive</title><link>http://kishorelive.com</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/kishorelive" /><description>A blog on code, design and chaotic life.</description><language>en</language><lastBuildDate>Mon, 06 Feb 2012 10:11:04 PST</lastBuildDate><generator>http://wordpress.org/?v=3.3.1</generator><sy:updatePeriod xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">hourly</sy:updatePeriod><sy:updateFrequency xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">1</sy:updateFrequency><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/kishorelive" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="kishorelive" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Currying in JavaScript using bind()</title><link>http://kishorelive.com/2012/02/06/currying-in-javascript-using-bind/</link><category>Uncategorized</category><category>bind</category><category>javascript</category><category>node.js</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Mon, 06 Feb 2012 03:26:00 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=1105</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>Currying, or more accurately, partial application is the process of breaking down a function that takes multiple arguments into a series of functions that take parts of the arguments. It comes in handy whenever you don&#8217;t have <strong>all</strong> the required arguments to a function at the present time. </p>
	<p>For example, consider a function <code>add</code> that takes 3 integers, and returns their sum. Using partial application, you can do this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">intermediate = add<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># .. do some other calculations ..</span>
&nbsp;
result = intermediate<span style="color: black;">&#40;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span>  <span style="color: #808080; font-style: italic;"># 6</span></pre></div></div>

	<p>So, currying simply allows you to apply the arguments to a function in multiple steps. Some languages support curried functions out-of-the-box (like OCaml), while in other languages like JavaScript, you need to use a helper function to achieve this (side note: <a href="http://osteele.com/sources/javascript/functional/">Functional.js</a> and <a href="http://documentcloud.github.com/underscore/">Underscore</a> are both terrific libraries that offer various functional extensions to JavaScript, including currying).</p>
	<p>ECMAScript 5 introduced <code>bind()</code> which brings (among other things) native currying to JavaScript. Once again, let&#8217;s take the <code>add</code> function.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span>b<span style="color: #339933;">,</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> a<span style="color: #339933;">+</span>b<span style="color: #339933;">+</span>c<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

	<p>This is how you curry it using <code>bind()</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> intermediate <span style="color: #339933;">=</span> add.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>undefined<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> intermediate<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">// 6</span></pre></div></div>

	<p>The first argument to <code>bind()</code> actually sets the infamous <code>this</code> context of the function. We can leave it <code>undefined</code> here, since it has no effect.</p>
	<p>So, why curry? Currying is both elegant and useful when you want to cache re-usable computations. I am going to steal this <a href="http://stackoverflow.com/a/6861858/131050">converter example</a>, which I have refactored to use <code>bind()</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> converter<span style="color: #009900;">&#40;</span>toUnit<span style="color: #339933;">,</span> factor<span style="color: #339933;">,</span> offset<span style="color: #339933;">,</span> input<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    offset <span style="color: #339933;">=</span> offset <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>offset<span style="color: #339933;">+</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>factor<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toFixed</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> toUnit<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> milesToKm <span style="color: #339933;">=</span> converter.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>undefined<span style="color: #339933;">,</span> <span style="color: #3366CC;">'km'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1.60936</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> poundsToKg <span style="color: #339933;">=</span> converter.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>undefined<span style="color: #339933;">,</span> <span style="color: #3366CC;">'kg'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0.45460</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> farenheitToCelsius <span style="color: #339933;">=</span> converter.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>undefined<span style="color: #339933;">,</span> <span style="color: #3366CC;">'degrees C'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0.5556</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
milesToKm<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            <span style="color: #006600; font-style: italic;">// returns &quot;16.09 km&quot;</span>
poundsToKg<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          <span style="color: #006600; font-style: italic;">// returns &quot;1.14 kg&quot;</span>
farenheitToCelsius<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">98</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">// returns &quot;36.67 degrees C&quot;</span></pre></div></div>

	<p>You can follow me on Twitter <a href="http://twitter.com/kishorelive">right here<a/>.</p>

 ]]></content:encoded><description>Currying, or more accurately, partial application is the process of breaking down a function that takes multiple arguments into a series of functions that take parts of the arguments. It comes in handy whenever you don&amp;#8217;t have all the required arguments to a function at the present time. For example, consider a function add that [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2012/02/06/currying-in-javascript-using-bind/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>Thoughts on Socket.IO</title><link>http://kishorelive.com/2012/01/30/thoughts-on-socket-io/</link><category>Uncategorized</category><category>javascript</category><category>node.js</category><category>socket.io</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Mon, 30 Jan 2012 06:29:30 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=1097</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>I have been hacking away with <a href="http://socket.io/">Socket.IO</a> for the past few months. My initial goal was to explore how Node.js/Socket.IO scales when you need to support a largish audience, when compared to my previous solutions involving Erlang/OTP and a handmade <a href="http://en.wikipedia.org/wiki/Comet_(programming)">COMET</a> library. </p>
	<p>I have built these COMET based streaming solutions by hand a few years ago. Back then, there was no HTML5 or websockets, and most off-the-shelf COMET &#8220;solutions&#8221; were bloated Java-based solutions. We had to roll out our own client side COMET library, because there were no standalone or decoupled open source alternatives. And, boy was it hard, especially when it came to supporting support IE (as always). I mention some of the elaborate client side techniques involved on <a href="http://speakerdeck.com/u/kishore/p/scalable-real-time-web-applications">these slides</a>. The guys at <a href="https://www.learnboost.com/">LearnBoost</a> have not only come up with a completely transparent solution that degrades gracefully all the way down to IE 5.5, but have also decoupled the client and server side components. There are third-party server-side bindings for plenty of <a href="https://github.com/learnboost/socket.io/wiki/">other languages</a> too. Having said that, the Erlang implementation (and quite a few other languages as well) seems to be supporting only version 0.6.x of Socket.IO. It looks like it will remain that way for a while, as Socket.IO v0.8 is almost a complete rewrite and breaks backward compatibility.</p>
	<p>I wrote a simple application using Node.js and Socket.IO that covered most of the basic &#8220;features&#8221; you would expect in a typical chat/pubsub system. This involves stuff like: detecting online/offline status of users, sending messages to a single user, broadcasting messages to everyone in a group/room, handling users who use multiple tabs etc. The code is up on <a href="http://github.com/kishorenc/NodeSocks">GitHub</a>.</p>
	<p>If you&#8217;re not already familiar with Socket.IO, I urge you to <a href="http://github.com/kishorenc/NodeSocks">check it out</a>, because I couldn&#8217;t believe that I ended up doing all of that in just about 100 lines of code &#8211; client and server-side combined! I have always loved JavaScript, but the absolute joy of sharing the same paradigm and code conventions across both the client-side and server-side is just amazing. </p>
	<p>Socket.IO provides a lot of things you need out of the box. Consider for example, sending a message to a group of people. Socket.IO allows you to make a user join a channel/room and once you do that, it also allows you to send messages to only that specific channel:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// make the user's socket join a room called &quot;foo&quot;</span>
socket.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// send message only to &quot;foo&quot;</span>
sio.<span style="color: #660066;">sockets</span>.<span style="color: #000066; font-weight: bold;">in</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">emit</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'new_message'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'message'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'hello'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'from'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'bar'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

	<p>Want to send a message to everyone else, <em>except</em> the current user (say, when &#8220;Jack&#8221; comes online)?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">socket.<span style="color: #660066;">broadcast</span>.<span style="color: #660066;">emit</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'user.online'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'username'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jack'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

	<p>To do these by hand, it would involve writing boiler-plate code that will deal with storing the user sockets in a map, iterating over it etc. which Socket.IO handles for you.</p>
	<p><strong>What about scaling?</strong></p>
	<p>Of course, we all need <a href="https://twitter.com/#!/mozlabs/status/161930528159830017">planet scale</a>, don&#8217;t we? The single threaded nature of Node.js does limit the default Socket.IO set-up, which in my crude benchmarks seemed to be a few thousand moderately active connections. If you are interested in seeing actual benchmark numbers, Drew Harry has an <a href="http://drewww.github.com/socket.io-benchmarking/">excellent write-up</a> on that. </p>
	<p>To get around the limitation imposed by a single core, you can load balance multiple node processes with <a href="https://github.com/nodejitsu/node-http-proxy">node-http-proxy</a> or <a href="http://blog.mixu.net/2011/08/13/nginx-websockets-ssl-and-socket-io-deployment">HA Proxy</a>. Unfortunately, we can&#8217;t use Nginx for load-balancing as the current stable version does not support reverse-proxying of HTTP/1.1 connections used by Websockets.</p>
	<p>Alternatively, you can use Redis pubsub to allow you to scale past a single process. But even that has <a href="https://github.com/LearnBoost/socket.io/issues/686">some limitations</a> due to the current chatty nature of Socket.IO. I&#8217;m sure that this is already something that the LearnBoost guys are looking to address. </p>
	<p>Another idea which I had which I have not explored fully is to use Node&#8217;s <a href="http://nodejs.org/docs/v0.6.9/api/cluster.html">cluster module</a> and its message passing API to synchronize between multiple Socket.IO processes. </p>
	<p>It should be noted here that 3-4k <strong>concurrent</strong> users is still more than sufficient for a lot of web applications, and when you are looking to support hundreds of thousands of users, you are looking at a different problem space altogether. The approach to take also depends on the specific needs of your application. Socket.IO with Node.js offers a ridiculously simple way to get off the blocks for building web applications with soft real-time elements, but I wish it was as simple to scale it to multiple cores or machines. For example, in our Erlang/OTP solution, we had the ability to scale past multiple machines as Erlang handled that layer of abstraction for us very well. So, going forward, I really wish Node would allow robust process synchronization and message passing. Perhaps the current work being done on <a href="http://groups.google.com/group/nodejs/browse_thread/thread/79504e62223f3bf0/e20ec4dcd3c6a85f?lnk=gst&#38;q=isolate#e20ec4dcd3c6a85f">isolates</a> would allow Node applications to scale past a single core and perhaps even machine. </p>
	<p>You can follow me on Twitter <a href="http://twitter.com/kishorelive">right here<a/>.</p>

 ]]></content:encoded><description>I have been hacking away with Socket.IO for the past few months. My initial goal was to explore how Node.js/Socket.IO scales when you need to support a largish audience, when compared to my previous solutions involving Erlang/OTP and a handmade COMET library. I have built these COMET based streaming solutions by hand a few years [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2012/01/30/thoughts-on-socket-io/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>First element of an object in JavaScript</title><link>http://kishorelive.com/2012/01/17/first-element-of-an-object-in-javascript/</link><category>Uncategorized</category><category>javascript</category><category>programming</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Tue, 17 Jan 2012 05:38:44 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=1055</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>This one will go into the bag of clever hacks which you should use sparingly, if not ever. Given an object like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> a<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;foo&quot;</span><span style="color: #339933;">,</span> b<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;bar&quot;</span><span style="color: #339933;">,</span> c<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;baz&quot;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

	<p>Here&#8217;s how we get the &#8220;first&#8221; property of the object/dict:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> first <span style="color: #000066; font-weight: bold;">in</span> obj<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;First property is: &quot;</span><span style="color: #339933;">+</span>first<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

	<p>We&#8217;re assuming here that the enumeration order matches the insertion order. Since ECMAScript standard itself does not specify any enumeration order, most browsers I have tested this in defaults to the insertion order. However, there is a catch: as explained in <a href="http://code.google.com/p/v8/issues/detail?id=164#c1">this discussion</a>, if any of the property names can be parsed as an integer (e.g. 123), then V8 (Chrome&#8217;s JS engine) does not give any guarantee on the ordering of the keys. </p>
	<p>There is lots of debate on that thread on the merits and demerits of preserving the order of insertion. Although, the V8 guys are pushing back on this on the basis of performance implications, Firefox 7.0 on my mac always preserves the order of insertion.</p>
	<p>If you want to try it out on your browser, the following snippet</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;foo&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;bar&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;3&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;3&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

	<p>should print</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">foo
3
2
1</pre></div></div>



 ]]></content:encoded><description>This one will go into the bag of clever hacks which you should use sparingly, if not ever. Given an object like this: var obj = &amp;#123; a: &amp;#34;foo&amp;#34;, b: &amp;#34;bar&amp;#34;, c: &amp;#34;baz&amp;#34; &amp;#125; Here&amp;#8217;s how we get the &amp;#8220;first&amp;#8221; property of the object/dict: for &amp;#40;var first in obj&amp;#41; break; console.log&amp;#40;&amp;#34;First property is: &amp;#34;+first&amp;#41;; We&amp;#8217;re [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2012/01/17/first-element-of-an-object-in-javascript/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">2</slash:comments></item><item><title>Git bisect</title><link>http://kishorelive.com/2012/01/14/git-bisect/</link><category>Uncategorized</category><category>git</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Sat, 14 Jan 2012 08:22:05 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=1013</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>You are part of a large team, and a bug has secretly crept into your codebase. You are on a mission to find out which exact commit caused that bug. I found myself on such a mission recently, and I thought I will write a quick post on how I used the awesome <code>bisect</code> command to identify the faulty commit quickly.</p>
	<p>Let&#8217;s assume that the latest git commit id on your master branch is <code>abcd</code>. Let&#8217;s say that you do know that this bug did not exist in the previous release, whose last git commit id is <code>wxyz</code>. To identify the git commit which introduced this bug, and which lies between <code>wxyz</code> and <code>abcd</code>, do this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> bisect start
$ <span style="color: #c20cb9; font-weight: bold;">git</span> bisect good wxyz
$ <span style="color: #c20cb9; font-weight: bold;">git</span> bisect bad abcd</pre></div></div>

	<p>You are essentially telling Git to bisect the commits between <code>wxyz</code> and <code>abcd</code>. Git will temporarily move you to a new branch called <code>bisect</code> and will now point to a commit that&#8217;s in the middle of both commits.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">Bisecting: 34 revisions left to test after this
[25d71758dd0e131e9409f3896416eabc81d69ec8] Search field fixes</pre></div></div>

	<p>Verify whether the bug exists at this state. If it still does, type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> bisect bad</pre></div></div>

	<p>Once again, Git will halve the number of commits needed to test by pointing you to a commit that&#8217;s right in the middle, between the previous bad commit and the good commit. Continue this process, telling git at each stage, whether a commit is &#8220;good&#8221; or &#8220;bad&#8221;, and git will eventually identify the first bad commit.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">5bc592ab9065b12bf1bc516ab9e0fe461699971b is the first bad commit</pre></div></div>

	<p>Once you are done figuring out what changes caused the bug, you can return back to your original working state by:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> bisect reset</pre></div></div>



 ]]></content:encoded><description>You are part of a large team, and a bug has secretly crept into your codebase. You are on a mission to find out which exact commit caused that bug. I found myself on such a mission recently, and I thought I will write a quick post on how I used the awesome bisect command [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2012/01/14/git-bisect/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>Where I use HTML5 the most – admin interfaces</title><link>http://kishorelive.com/2012/01/04/where-i-use-html5-the-most-admin-interfaces/</link><category>Uncategorized</category><category>css3</category><category>html5</category><category>technology</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Tue, 03 Jan 2012 20:30:23 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=1047</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>Both HTML5 and CSS3 have constantly evolving specs. With browser vendors going ahead and implementing new features using vendor prefixes, and long before they get accepted as part of the standard, we&#8217;re faced with a dilemma: We have all these cool toys which we can play with, but can&#8217;t really put them to use immediately in production because it&#8217;s going to take time for the rest of the world to upgrade their browsers. </p>
	<p>What I have been doing lately is using admin interfaces as a ground for testing and learning about these new features. So long you get your clients to use the latest build of Firefox or Chrome, you are good to go. With Chrome, that&#8217;s pretty easy with the automatic rolling updates, and Firefox will soon be doing the same. Of course, this is not going to happen with every client, but it&#8217;s not that hard to make them use a better browser by just telling them how it can save them development cost. And, that&#8217;s true. </p>
	<p>The other day, I had to get color alternating rows of a table &#8211; grey, white, grey, white, and so on. With an older browser, you have to resort to first modifying your code to give alternate rows <code>class="odd"</code> and then specifying a different color for this class in the CSS file. With CSS3, you can just do:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">tr<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>odd<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span></pre></div></div>

	<p>Want to highlight only the first child of a parent?</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#parent-id</span><span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

	<p>Quick form validation on an internal admin tool? HTML5 form validators FTW.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; pattern=&quot;[-0-9]+&quot; required /&gt;</pre></div></div>

	<p>Those are admittedly trivial examples, but the fact is knowing these little shortcuts quickly add up and help you get stuff done faster. As an added bonus, you also keep your presentation and code separated. The next time you look at a CSS3 or HTML5 feature and think that you can only use them in 2015, think again! </p>

 ]]></content:encoded><description>Both HTML5 and CSS3 have constantly evolving specs. With browser vendors going ahead and implementing new features using vendor prefixes, and long before they get accepted as part of the standard, we&amp;#8217;re faced with a dilemma: We have all these cool toys which we can play with, but can&amp;#8217;t really put them to use immediately [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2012/01/04/where-i-use-html5-the-most-admin-interfaces/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>ECMAScript harmony features in Chrome Canary</title><link>http://kishorelive.com/2011/12/26/ecmascript-harmony-features-in-google-chrome-canary/</link><category>Uncategorized</category><category>javascript</category><category>programming</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Mon, 26 Dec 2011 05:18:59 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=1005</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>The latest Canary build of Google Chrome allows you to unlock some new features from ECMAScript Harmony. However, they are disabled by default, so to enable them you have to type <code>about:flags</code> into your address bar, and turn on &#8220;Enable Experimental JavaScript&#8221; which is found right at the bottom of the page. </p>
	<p>Now, you have access to <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Proxy">proxies</a>, <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/WeakMap">weak maps</a>, <a href="http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets">maps, and sets</a>!</p>
	<p><strong>Proxies</strong></p>
	<p>I am very excited about the Proxy API &#8211; it will allow you to create objects whose properties can be computed at run-time dynamically, and for hooking into other objects for auditing and logging purposes. A simple example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> proxyObj <span style="color: #339933;">=</span> Proxy.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  get<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> propertyName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'Hello, '</span><span style="color: #339933;">+</span> propertyName<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>proxyObj.<span style="color: #660066;">John</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;Hello, John&quot;</span></pre></div></div>

	<p>You can do all kinds of meta programming stuff using Proxies (that&#8217;s probably another blog post).</p>
	<p><strong>Maps and Weak Maps</strong></p>
	<p>The use of <code>Map</code>s and <code>WeakMap</code>s allows you to create dicts where the keys are objects.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> m <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Map<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>foo<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;bar&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
m.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;baz&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
m.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">// &quot;baz&quot;</span></pre></div></div>

	<p>The difference between a <code>WeakMap</code> and <code>Map</code> is that the <code>WeakMap</code> is not enumerable. Although the <code>Map</code> is enumerable, it relies on the <a href="http://wiki.ecmascript.org/doku.php?id=harmony:iterators">iterator</a> proposal, which is yet to be implemented in V8. So for all practical purposes, the <code>Map</code> and <code>WeakMap</code> are essentially the same for now.</p>
	<p><strong>Set</strong></p>
	<p>Again, you can add, delete and check for existence of a value in a <code>Set</code>, but cannot yet iterate through it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Set<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s.<span style="color: #660066;">has</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
s.<span style="color: #660066;">had</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span></pre></div></div>

	<p>Finally, there was is a small but significant change in the way <code>typeof</code> operates on <code>null</code>. In ES3:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'object'</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// true</span></pre></div></div>

	<p>But in ES5:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'null'</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// true</span></pre></div></div>

	<p><a href="http://wiki.ecmascript.org/doku.php?id=harmony:typeof_null">This page</a> from ECMAScript Harmony Wiki talks more about this semantic change, and how to support both ES5 and ES3 when writing code.</p>
	<p>The immediate value of any of these features to browser-side JavaScript development is probably none, but nevertheless I&#8217;m excited to see the roll out of ES5 and ES6 features into V8, so we can start using them soon on atleast node.js.</p>
	<p>You can follow me on Twitter <a href="http://twitter.com/kishorelive">right here</a>.</p>

 ]]></content:encoded><description>The latest Canary build of Google Chrome allows you to unlock some new features from ECMAScript Harmony. However, they are disabled by default, so to enable them you have to type about:flags into your address bar, and turn on &amp;#8220;Enable Experimental JavaScript&amp;#8221; which is found right at the bottom of the page. Now, you have [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2011/12/26/ecmascript-harmony-features-in-google-chrome-canary/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>Abusing Scala’s anonymous argument</title><link>http://kishorelive.com/2011/12/07/abusing-scalas-anonymous-argument/</link><category>Uncategorized</category><category>programming</category><category>scala</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Wed, 07 Dec 2011 05:35:45 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=983</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>In Scala, you can use the underscore (<code>_</code>) to refer to an argument you are lazy to name.</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> numbers <span style="color: #000080;">=</span> List<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">1</span>,<span style="color: #F78811;">2</span>,<span style="color: #F78811;">3</span>,<span style="color: #F78811;">4</span><span style="color: #F78811;">&#41;</span>
numbers.<span style="color: #000000;">map</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">2</span> <span style="color: #000080;">*</span> <span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span>  <span style="color: #008000; font-style: italic;">// List(2, 4, 6, 8)</span></pre></div></div>

	<p>You can go a step further.</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> numbers <span style="color: #000080;">=</span> List<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">1</span>,<span style="color: #F78811;">2</span>,<span style="color: #F78811;">3</span>,<span style="color: #F78811;">4</span><span style="color: #F78811;">&#41;</span>
numbers.<span style="color: #000000;">map</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">2</span><span style="color: #000080;">*</span><span style="color: #F78811;">&#41;</span></pre></div></div>

	<p>You can completely omit the _ as well, because <code>*</code> is actually a method on <code>2</code>. Scala is smart enough to understand that it requires one parameter, and automatically passes it each element of the list. </p>
	<p>In my <a href="http://kishorelive.com/2011/11/27/thoughts-on-scala-from-a-newcomer/">last post on Scala</a>, I mentioned how Scala&#8217;s power can be easily abused. This is one instance where it&#8217;s easy to end up abusing the convenience offered by the language. Let&#8217;s look at another code snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #008000; font-style: italic;">// constant defined somewhere</span>
<span style="color: #0000ff; font-weight: bold;">val</span> photoPath <span style="color: #000080;">=</span> <span style="color: #6666FF;">&quot;photos/&quot;</span>
&nbsp;
<span style="color: #008000; font-style: italic;">// in another file</span>
<span style="color: #0000ff; font-weight: bold;">val</span> memberIds <span style="color: #000080;">=</span> List<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;abc&quot;</span>,<span style="color: #6666FF;">&quot;def&quot;</span>,<span style="color: #6666FF;">&quot;ghi&quot;</span>,<span style="color: #6666FF;">&quot;jkl&quot;</span><span style="color: #F78811;">&#41;</span>
<span style="color: #0000ff; font-weight: bold;">val</span> photoUrls <span style="color: #000080;">=</span> memberIds.<span style="color: #000000;">map</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;http://example.com/member/&quot;</span>+photoPath+<span style="color: #F78811;">&#41;</span></pre></div></div>

	<p>See that innocuous looking <code>+</code> operator at the end of the last line? It&#8217;s very easy for someone who is tired at the end of a long day to just delete that, thinking that it&#8217;s a stray operator left behind by some lazy developer. Ouch. </p>
	<p>Having said that, the use of anonymous arguments is elegant in some cases. Consider this:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">def</span> complicatedLogic<span style="color: #F78811;">&#40;</span>x<span style="color: #000080;">:</span>Int<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
  <span style="color: #008000; font-style: italic;">// do something complicated</span>
  x<span style="color: #000080;">*</span><span style="color: #F78811;">2</span>
<span style="color: #F78811;">&#125;</span>
<span style="color: #0000ff; font-weight: bold;">val</span> input <span style="color: #000080;">=</span> List<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">1</span>,<span style="color: #F78811;">2</span>,<span style="color: #F78811;">3</span>,<span style="color: #F78811;">4</span><span style="color: #F78811;">&#41;</span>
<span style="color: #0000ff; font-weight: bold;">val</span> output <span style="color: #000080;">=</span> input.<span style="color: #000000;">map</span><span style="color: #F78811;">&#40;</span>x <span style="color: #000080;">=&gt;</span> complicatedLogic<span style="color: #F78811;">&#40;</span>x<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span></pre></div></div>

	<p>We can rewrite that last line this way:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> output <span style="color: #000080;">=</span> input.<span style="color: #000000;">map</span><span style="color: #F78811;">&#40;</span>complicatedLogic<span style="color: #F78811;">&#41;</span></pre></div></div>

	<p>P.S: I have taken the liberty to use the term &#8220;anonymous argument&#8221; here to refer to this handy trick &#8211; but I will update the post if someone can tell me what this behavior is referred actually as. </p>
	<p>You can follow me on Twitter <a href="http://twitter.com/kishorelive">right here</a>.</p>

 ]]></content:encoded><description>In Scala, you can use the underscore (_) to refer to an argument you are lazy to name. val numbers = List&amp;#40;1,2,3,4&amp;#41; numbers.map&amp;#40;2 * _&amp;#41; // List(2, 4, 6, 8) You can go a step further. val numbers = List&amp;#40;1,2,3,4&amp;#41; numbers.map&amp;#40;2*&amp;#41; You can completely omit the _ as well, because * is actually a method [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2011/12/07/abusing-scalas-anonymous-argument/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>Printing colors in the terminal</title><link>http://kishorelive.com/2011/12/05/printing-colors-in-the-terminal/</link><category>Uncategorized</category><category>programming</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Mon, 05 Dec 2011 05:11:59 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=940</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>If you fancy adding a bit of color to your console print statements, you can do that by using the <a href="http://en.wikipedia.org/wiki/ANSI_escape_code">ANSI escape sequences</a>. Pasting the following in a Python console (Linux/Mac) will get you some green text!</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>33[0;32mGREEN TEXT<span style="color: #000099; font-weight: bold;">\0</span>33[0m&quot;</span></pre></div></div>

	<p>Although that looks gibberish, the format can be broken down like this:</p>
	<p><span class="red">START_SEQ</span><span class="green">x;y;zm</span><span class="blue">DISPLAY_TEXT</span><span class="red">END_SEQ</span></p>
	<p><strong>Starting sequence</strong>: \033[<br />
<strong>x;y;z</strong>:  ANSI color codes<br />
<strong>Display text</strong>: Text you want to display<br />
<strong>Ending sequence</strong>: \033[0m</p>
	<p>You can mix and match <code>x;y;z</code> combinations to get a variety of effects! For example, this will print a blinking green text on red background:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>33[5;41;32mGREEN TEXT<span style="color: #000099; font-weight: bold;">\0</span>33[0m&quot;</span>  <span style="color: #808080; font-style: italic;"># oh the horror!</span></pre></div></div>

	<p><strong>ANSI color codes for your pleasure<strong>:</p>
<table>
  <thead>
  <tr>
  <th>Text color</th>
  <th>Code</th>
  <th>Text style</th>
  <th>Code</th>
  <th>Background color</th>
  <th>Code</th>
  </tr>
  </thead>
  <tr>
    <td>Black</td>
    <td>30</td>
    <td>No effect</td>
    <td>0</td>
    <td>Black</td>
    <td>40</td>
  </tr>
  <tr>
    <td>Red</td>
    <td>31</td>
    <td>Bold</td>
    <td>1</td>
    <td>Red</td>
    <td>41</td>
  </tr>
  <tr>
    <td>Green</td>
    <td>32</td>
<td>Underline</td>
    <td>4</td>
    <td>Green</td>
    <td>42</td>
  </tr>
  <tr>
    <td>Yellow</td>
    <td>33</td>
    <td>Blink</td>
    <td>5</td>
    <td>Yellow</td>
    <td>43</td>
  </tr>
  <tr>
    <td>Blue</td>
    <td>34</td>
    <td>Inverse</td>
    <td>7</td>
    <td>Blue</td>
    <td>44</td>
  </tr>
  <tr>
    <td>Purple</td>
    <td>35</td>
    <td>Hidden</td>
    <td>8</td>
    <td>Purple</td>
    <td>45</td>
  </tr>
  <tr>
    <td>Cyan</td>
    <td>36</td>
    <td><del></td>
    <td></del></td>
    <td>Cyan</td>
    <td>46</td>
  </tr>
  <tr>
    <td>White</td>
    <td>37</td>
    <td><del></td>
    <td></del></td>
    <td>White</td>
    <td>47</td>
  </tr>
</table>
	<p>Use it wisely. Please don&#8217;t pollute the screen.</p>
	<p>You can follow me on Twitter <a href="http://twitter.com/kishorelive">right here</a>.</p>

 ]]></content:encoded><description>If you fancy adding a bit of color to your console print statements, you can do that by using the ANSI escape sequences. Pasting the following in a Python console (Linux/Mac) will get you some green text! print &amp;#34;\033[0;32mGREEN TEXT\033[0m&amp;#34; Although that looks gibberish, the format can be broken down like this: START_SEQx;y;zmDISPLAY_TEXTEND_SEQ Starting sequence: [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2011/12/05/printing-colors-in-the-terminal/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments></item><item><title>Simple design tips for non designers</title><link>http://kishorelive.com/2011/12/02/simple-design-tips-for-non-designers/</link><category>Uncategorized</category><category>design</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Fri, 02 Dec 2011 07:19:38 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=909</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>A friend of mine recently mentioned to me that he is not able to look at his own applications, and wished that he had better &#8220;design skills&#8221;. I have heard similar statements from other programmers and business folks. It&#8217;s a common misconception that you need to be gifted, or as they say, have &#8220;an eye for design&#8221; to be able to produce elegant applications. For those of us who can&#8217;t stand looking at what we develop, I have put together some simple rules. These rules won&#8217;t make you a rockstar designer overnight, but they can help you avoid eye sore!</p>
	<p><strong>Good design is not about aesthetics</strong><br />
Let&#8217;s first start off with what good design is not. It&#8217;s not about rounded corners, glossy buttons, text shadows or gradient backgrounds. These are called aesthetics, and the presence of these do not necessarily equate to a good design. Good design is about structure, order and clarity. Ultimately, you want your applications to be intuitive. Your design should be the vehicle that drives home this intuitiveness. So, if all you know is good old HTML and CSS, don&#8217;t despair. Much can be done with just those two.</p>
	<p><strong>Colors come last</strong><br />
Sometimes we are just too eager to jump in and start coding. When you are designing an interface, it will be worth to start off with a pencil and paper. Visualize what you want to build as a simple sketch first. If things already look broken in black and white, the chances of them looking any better with some colors thrown in are remote. As I said earlier, design is more about structure and order than decoration. </p>
	<p><strong>Keep it white</strong><br />
Ever seen fluorescent text on a black background? I have seen lots of those! Black is a difficult color to work with, and it&#8217;s not too difficult to end up with something that&#8217;s either jarring or simply unreadable. If you want to play it safe &#8211; a simple rule of thumb is to always go for a whitish background. </p>
	<p><strong>Use lots of white space</strong><br />
Packing your screen with more and elements contributes to visual clutter. Ample use of white space gives importance to the elements on the page.  Using whitespace you can group or separate blocks of content on the page elegantly, instead of relying on decorative borders or boxes with rounded corners! If there is just too much to fit into one screen, consider using tabs or moving them below the fold (in the case of web applications).</p>
	<p><strong>Meaningful words, and legible typography</strong><br />
Words are a powerful element of design. Avoid using clichés like &#8220;Simplest way to do X&#8221;. Instead, use short, simple sentences that convey what you are trying to say without resorting to a flowery marketing speak. Make sure you use legible fonts. </p>
	<p><strong>Cut down on the variations</strong><br />
Use minimum number of fonts, colors and styles. With just two fonts and three colors, you should be able to design clean and uncluttered interfaces. Be consistent in whatever you do. For instance, don&#8217;t have your headers using a different font and color in every other page. </p>
	<p><strong>Stick to the Grid</strong><br />
One way to an impose order on the elements on your page is by using a <a href="http://en.wikipedia.org/wiki/Grid_(page_layout)">grid</a> to break down your layout into finite blocks. There are even some grid systems available, like <a href="http://960.gs/">960</a>, which help you do this. Often just splitting up your layout into a 3&#215;3 area is enough to get a rough grid going. Although using grids can be restrictive, it&#8217;s a safe bet against chaos. </p>
	<p><strong>Use icons sparingly</strong><br />
Using <a href="http://www.iconfinder.com/">icon finder</a>, you can find simple icons that can complement your headings and actions. However, always use icons along with meaningful text. Also, if you are planning to use icons &#8211; make sure all the icons come from the same icon set or theme! </p>
	<p><strong>Imitate, but don&#8217;t steal</strong><br />
Stumble on something that you find stunning? Try to ask questions as to why you find it that way. It could very well boil down to using one or more of the above things effectively. Take a mental (or physical) note of it so that you can bring in such elements into your own work. However, remember that there is a fine line between imitating and stealing. </p>
	<p><strong>When all else fails</strong><br />
If, for some reason, you are still against a dead wall and still end up producing eye sore &#8211; consider using Twitter <a href="http://twitter.github.com/bootstrap/">bootstrap</a>. </p>
	<p>If you have any other suggestions or tips, please share them in the comments. </p>
	<p>You can follow me on Twitter <a href="http://twitter.com/kishorelive">right here</a>.</p>

 ]]></content:encoded><description>A friend of mine recently mentioned to me that he is not able to look at his own applications, and wished that he had better &amp;#8220;design skills&amp;#8221;. I have heard similar statements from other programmers and business folks. It&amp;#8217;s a common misconception that you need to be gifted, or as they say, have &amp;#8220;an eye [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2011/12/02/simple-design-tips-for-non-designers/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments></item><item><title>The future of education</title><link>http://kishorelive.com/2011/11/30/the-future-of-education/</link><category>Uncategorized</category><category>education</category><category>learning</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kishore Nallan</dc:creator><pubDate>Wed, 30 Nov 2011 07:17:40 PST</pubDate><guid isPermaLink="false">http://kishorelive.com/?p=893</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[	<p>I have been watching excitedly as Stanford rains down free online courses left, right and center. I don&#8217;t really know what prompted this sudden onpour of online courses. What I do know is that this very well could turn out to be the future of education. </p>
	<p>Stanford might just be doing this with an eye towards a global market, and could be giving away these courses freely only for a limited amount of time as they go about testing the waters. I am not worried about these courses becoming paid in future. So long the price is reasonable, I am willing to pay for them. One drawback of keeping them free is that I see plenty of people signing up for all of them, and in the end, not doing justice to any of them. </p>
	<p>Watching these videos give me the urge to consider going back to the college to learn more. However, access to good educational materials should not necessarily be confined to the physical walls of an intuition. Even though there are plenty of online and offline resources available for us to learn from, there is definitely a need for structured courses, videos, learning materials and assignments. Stanford and the Khan Academy have set a precedent for world class education to be available to those who want to learn new things throughout their life and at their own pace. It will now be interesting to see if other universities like MIT follow. I hope they do. </p>

 ]]></content:encoded><description>I have been watching excitedly as Stanford rains down free online courses left, right and center. I don&amp;#8217;t really know what prompted this sudden onpour of online courses. What I do know is that this very well could turn out to be the future of education. Stanford might just be doing this with an eye [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://kishorelive.com/2011/11/30/the-future-of-education/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">4</slash:comments></item></channel></rss>

