<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Kaushik Sathupadi</title>
 <link href="http://ksat.me/atom.xml" rel="self"/>
 <link href="http://ksat.me/"/>
 <updated>2022-01-15T07:22:36+00:00</updated>
 <id>http://ksat.me/</id>
 <author>
   <name>Kaushik Sathupadi</name>
   <email>kaushik.sathupadi@gmail.com</email>
 </author>

 
 <entry>
   <title>Dear everyone, stop setting focus on "username" field if i am already on "password" field</title>
   <link href="http://ksat.me/stop-setting-focus-on-username-field-on-page-load"/>
   <updated>2012-07-04T00:00:00+00:00</updated>
   <id>http://ksat.me/stop-focus-on-username-field</id>
   <content type="html">&lt;h1 id=&quot;stop-setting-focus-on-username-field-if-i-am-already-on-password-field&quot;&gt;Stop setting focus on “username” field if i am already on “password” field&lt;/h1&gt;

&lt;p&gt;This is a problem with twitter, gmail, everything (including a few apps
I’ve developed :).&lt;/p&gt;

&lt;p&gt;So you go to twitter.com. The page appears but still seems to be loading
something in the background. You click on the username field and type
the username, tab-out to the password field but just as you are typing
the password the page loads completely and the focus is set back on
username field. Before you understand what has happened and react, half
of the password gets typed in the username field. This does not happen
very often, but when it does its embarrassing especially if someone is
sitting besides you.&lt;/p&gt;

&lt;p&gt;I imagine the solution should be simple. Set focus to “username” field
on load, but don’t set it if&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The username field is already filled in&lt;/li&gt;
  &lt;li&gt;The focus is currently on the password field&lt;br /&gt;
 &lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Chrome plugin to deal with the Hacker News 'unknown or expired link'</title>
   <link href="http://ksat.me/chrome-plugin-to-fix-hn-unknown-or-expired-link"/>
   <updated>2012-07-02T00:00:00+00:00</updated>
   <id>http://ksat.me/fixing-hn-Unknown-or-expired-link</id>
   <content type="html">&lt;h1 id=&quot;chrome-plugin-to-deal-with-hacker-news-unknown-or-expired-link&quot;&gt;Chrome plugin to deal with Hacker News ‘unknown or expired link’&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://news.ycombinator.com&quot;&gt;Hacker news&lt;/a&gt; has one minor irritation -
The ‘unknown or expired link’ thing. Happens when&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You spend some time on a page checking out the links and then click
the “more” link at the bottom of the page. By then fnid has expired
and you have to go back to homepage, refresh it and start from there&lt;/li&gt;
  &lt;li&gt;You write a thought-out comment(taking enough time) and then press
the “comment” button only to see a ‘unknown or expired link’. Then
you have to hit the back button, copy the text, hit refresh, paste
the text and then “comment” again.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s a chrome plugin I just wrote that’ll automate these two&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;
&lt;h2&gt;

&lt;a href=&quot;/hackerreload.crx&quot; style=&quot;font-weight:normal;text-decoration:underline&quot;&gt;Install
Plugin&lt;/a&gt;

&lt;/h2&gt;

&lt;a href=&quot;https://bitbucket.org/ksat/hackerreload/src&quot;&gt;source&lt;/a&gt;

&lt;/div&gt;
&lt;h2 style=&quot;color:#666;font-weight:bold;&quot;&gt;

Here’s what it looks like

&lt;/h2&gt;

&lt;p&gt;For fixing “more” pages, the plugin adds an anchor #n to the link that
tells us the page’s location from homepage. When a page gets loaded with
“unknown or expired link”, the plugin goes back to the homepage and
fetches until the nth page. (Note: Due to the way voting works links are
constantly rearranged and for example the 3rd page now might have links
you have just read in the 2nd page)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/hnreload/shot1.png&quot; width=&quot;500px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For the comment page, it adds one more “comment” button&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/hnreload/shot2.png&quot; width=&quot;500px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The new comment button refreshes this page in background, fetches the
new fnid , updates the current page’s form, then submits the comment.
Since this is a little slower, you can always try the regular “comment”
button first and if it doesn’t work, hit back button and then hit the
new comment button.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Fanbatis 0.4 is here!</title>
   <link href="http://ksat.me/fanbatis-0-4-is-here"/>
   <updated>2012-06-30T00:00:00+00:00</updated>
   <id>http://ksat.me/fanbatis-04-is-here</id>
   <content type="html">&lt;h1 id=&quot;introducing-fanbatis-04&quot;&gt;Introducing Fanbatis 0.4&lt;/h1&gt;

&lt;p&gt;The biggest change is on Sqlmaps which have been enhanced to make the
DSLs do more work.&lt;/p&gt;

&lt;p&gt;This was the old way to query&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;class BlogSqlMap : SqlMap{
  @Select
  Blog getBlogBySubject(Str subject){
    one(sql&amp;lt;|
        select * from blog where subject = #{subject}
    |&amp;gt;)
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here’s the new and sexy way&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;class BlogSql {
  Blog getBlogBySubject(Str subject){
    S&amp;lt;|
       select * from blog where subject = #{subject}
    |&amp;gt;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;There is no need to extend SqlMap&lt;/li&gt;
  &lt;li&gt;There is no need to mark your methods &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Select (or &lt;/code&gt;Insert,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Update or &lt;/code&gt;Delete)&lt;/li&gt;
  &lt;li&gt;Methods can be static or not&lt;/li&gt;
  &lt;li&gt;There is no need to call methods like one(), list(), insert(),
delete()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want you can embed sqlmaps directly in the domain object, for
eg.,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;class Blog{
  ...
  static Blog findById(Int id){S&amp;lt;|
      select * from blog where id = #{id}
  |&amp;gt;}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and call it like&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Blog.findById(1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note: This however might or might not be a good idea. If for example you
are using fanquery and Fantom on client, this might not be really good
idea since these methods doesn’t make much sense in Javascript.&lt;/p&gt;

&lt;p&gt;The Filter class has been removed and you and write any custom where
clause directly in the Db.one or Db.list methods. eg&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Blog[] blogs := Db.list(Blog#, &quot;subject = #{param.subject}&quot;, [&quot;subject&quot;, &quot;My Blog&quot;])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Apart from these big changes, there are few performance improvements and
some bug fixes.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.talesframework.org/fanbatis/&quot;&gt;Read Fanbatis docs&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Here's one patch that'll make your life easy</title>
   <link href="http://ksat.me/patch-that-will-make-your-life-easy"/>
   <updated>2012-06-20T00:00:00+00:00</updated>
   <id>http://ksat.me/one-path-that-will-make-your-life-easy</id>
   <content type="html">&lt;h1 id=&quot;heres-one-patch-thatll-make-your-life-easy&quot;&gt;Here’s one patch that’ll make your life easy&lt;/h1&gt;

&lt;p&gt;Accept &lt;a href=&quot;https://bitbucket.org/ksat/wasmydaygood/changeset/36693671d4d9&quot;&gt;this
patch&lt;/a&gt;
and your life will be easy forever. Gaurenteed.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/patch-to-fix-life.png&quot; /&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Introducing SafariShot – Wrap your screenshot on a safari running on OSX</title>
   <link href="http://ksat.me/safarishot-your-webpage-on-safari-on-osx"/>
   <updated>2012-06-16T00:00:00+00:00</updated>
   <id>http://ksat.me/safarishot-your-webpage-running-on-osx</id>
   <content type="html">&lt;h1 id=&quot;safarishot---your-screenshots-like-its-running-on-safari-on-osx&quot;&gt;SafariShot - Your screenshots like it’s running on safari on OSX&lt;/h1&gt;

&lt;p&gt;The world is fucked up - Only Screenshots taken on a mac is considered
“Professional”.&lt;/p&gt;

&lt;p&gt;If you use one of the other operating systems use this tool to showcase
your website like it is running on safari on a mac. Plus even if you
have osx, you can use this to generate a full-length-safari-window
screenshot (without scrollbars).&lt;/p&gt;

&lt;p&gt;Works best on firefox. File apis does not work on safari. Style your
buttons and input elements. &lt;strong&gt;For a demo, skip everything and click
“show my screenshot”&lt;/strong&gt;.&lt;/p&gt;

&lt;div id=&quot;all-input&quot;&gt;
&lt;div style=&quot;min-width:900px; overflow:hidden; font-size:14px;margin-top:20px;&quot;&gt;
&lt;div style=&quot;float:left; width:700px;&quot;&gt;
&lt;div style=&quot;overflow:hidden;width:700px;&quot;&gt;
&lt;div class=&quot;num&quot; style=&quot;font-size:14px;&quot;&gt;

1

&lt;/div&gt;
&lt;div style=&quot;float:left; line-height:30px;&quot;&gt;

Take a screenshot of your webpage(any os) using a tool like
&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/fireshot/&quot;&gt;fireshot&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;overflow:hidden; margin-top:20px;&quot;&gt;
&lt;div class=&quot;num&quot; style=&quot;font-size:14px;&quot;&gt;

2

&lt;/div&gt;
&lt;div style=&quot;float:left; line-height:30px;&quot;&gt;

Choose the screenshot  
&lt;input type=&quot;file&quot; id=&quot;files&quot; /&gt;

&lt;div align=&quot;left&quot; style=&quot;padding-left:30px&quot;&gt;

↑

&lt;/div&gt;
&lt;div&gt;

If you leave this blank,
&lt;a href=&quot;/images/safari/google.png&quot; target=&quot;_blank&quot;&gt;this default
image&lt;/a&gt; will be used instead

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;overflow:hidden; margin-top:20px;&quot;&gt;
&lt;div class=&quot;num&quot; style=&quot;font-size:14px;&quot;&gt;

3

&lt;/div&gt;
&lt;div style=&quot;float:left; line-height:30px;&quot;&gt;

Type in a title and Url  
Page Title :
&lt;input id=&quot;page-title&quot; type=&quot;text&quot; class=&quot;big&quot; value=&quot;Google&quot; /&gt; &lt;br /&gt;  
  Page Url :
&lt;input id=&quot;page-url&quot; type=&quot;text&quot; class=&quot;big&quot; value=&quot;http://www.google.com&quot; /&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;show-screenshot-div&quot; style=&quot;overflow:hidden; margin-top:20px;padding-left:40px;&quot;&gt;
&lt;div style=&quot;float:left; padding-top:10px;padding-right:10px;&quot;&gt;

&lt;input id=&quot;generate&quot; type=&quot;button&quot; value=&quot;Show my screenshot&quot; /&gt;

&lt;/div&gt;
&lt;div style=&quot;float:left; font-size:12px;&quot;&gt;

&lt;img src=&quot;http://www.kloudo.com/res/images/home/reg_small_arrow.png&quot; /&gt;
Go on try now, default values are on

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>What Can you do before your battery runs out?</title>
   <link href="http://ksat.me/what-can-you-do-before-your-battery-runs-out"/>
   <updated>2012-06-14T00:00:00+00:00</updated>
   <id>http://ksat.me/what-can-you-do-before-your-battery-runs-out</id>
   <content type="html">&lt;h1 id=&quot;what-can-you-do-before-your-battery-runs-out&quot;&gt;What can you do before your battery runs out?&lt;/h1&gt;

&lt;p&gt;I mean like literally.&lt;/p&gt;

&lt;p&gt;It was almost an &lt;a href=&quot;https://twitter.com/_ksat/status/2054851273957376&quot;&gt;year
ago&lt;/a&gt;. I was working
at Oracle. One day before leaving for work I check my mail. Nothing
special. There was one mail though from my manager(Mike) asking me if I
can get something done by end of the day. I remember replying to him
“I’ll try”, packed my bag and left to office.&lt;/p&gt;

&lt;p&gt;I live in Bangalore. In some ways it rocks. The morning traffic is
definitely not one of them. It took me 1.5 hours to reach office - No
worries. It was common. I reach my desk , take out the laptop and go ..
shit, forgot to bring the laptop charger. Everybody else in my team was
working from home and I was too shy to ask help from strangers. I
briefly contemplate going back home but that’ll waste too much time. I
decide - fuck it, let me try what I can do as long as the battery lasts.&lt;/p&gt;

&lt;p&gt;Turns out that it was the most productive day as far I remembered. The
battery going down was a real motivator. I wouldn’t waste my time on
hacker news or keep logging into my gmail, twitter, reddit or even
&lt;a href=&quot;http://dontevenreply.com/&quot;&gt;dontevenreply&lt;/a&gt; :). Not only did I finish my
work in a couple of hours, but also returned home at noon with a
satisfaction that only comes after a good day’s work. Before coming home
I also took my wallpaper and added text “What can you do before your
battery runs out?”&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;

&lt;a href=&quot;/images/wood.jpg&quot;&gt;  
&lt;img src=&quot;/images/wood.jpg&quot; style=&quot;max-width:200px;&quot; /&gt;  
&lt;/a&gt;

&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;So try this now. Unplug your laptop charger. put it back in the
backpack. What can you do now before your battery runs out?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Fantom Puzzlers</title>
   <link href="http://ksat.me/fantom-puzzlers"/>
   <updated>2012-06-11T00:00:00+00:00</updated>
   <id>http://ksat.me/fantom-puzzler</id>
   <content type="html">&lt;h1 id=&quot;fantom-puzzlers&quot;&gt;Fantom Puzzlers&lt;/h1&gt;

&lt;p&gt;Here are 6 simple but slightly tricky Fantom questions. For each program
on the left select the answer on the right and click next. Try these
without actually executing the code :). Safely assume that&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Logging at all levels is on for every problem.&lt;/li&gt;
  &lt;li&gt;Logging prints just what’s passed and does not print anything else
like current time, level etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>The literally sexy, sexy password field</title>
   <link href="http://ksat.me/the-literally-sexy-sexy-password-field"/>
   <updated>2012-06-08T00:00:00+00:00</updated>
   <id>http://ksat.me/really-sexy-sexy-password-field</id>
   <content type="html">&lt;h1 id=&quot;the-literally-sexy-sexy-password-field&quot;&gt;The Literally Sexy, Sexy Password Field&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/visual-hashing/&quot;&gt;Color
hashing&lt;/a&gt;
the password field is nice, but then it’s a little difficult to remember
the color. What was the color of my password on gmail again? “Purple
yellow”?&lt;/p&gt;

&lt;p&gt;This is an alternative:&lt;/p&gt;

&lt;div style=&quot;overflow:hidden; border:1px solid #ccc; padding:5px 20px 20px 20px; &quot;&gt;
&lt;div style=&quot;float:left; margin-top:25px;margin-right:10px;&quot;&gt;

Type Password:

&lt;/div&gt;

&lt;input id=&quot;pass&quot; type=&quot;password&quot; style=&quot;float:left;margin-top:20px; width:200px; height:30px;font-size:16px;&quot; /&gt;

&lt;div id=&quot;girl&quot; style=&quot;float:left; margin-left:20px;&quot;&gt;
&lt;/div&gt;
&lt;div id=&quot;copy&quot; style=&quot;float:left; width:200px; margin-left:20px; margin-top:25px; text-decoration:underline;&quot;&gt;

Copy To Clipboard

&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:none&quot;&gt;

&lt;img src=&quot;/images/sexy.png&quot; /&gt;

&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Passwords always hash to same dancing step so you know you have typed
the right password.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, isn’t that more easy remember guys? If this were implemented on
twitter my password would make her bend over. What would she do on your
twitter, gmail and facebook? Leave a comment.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Parse, Firebase and the comeback of Two Tier</title>
   <link href="http://ksat.me/comeback-of-thick-clients"/>
   <updated>2012-06-04T00:00:00+00:00</updated>
   <id>http://ksat.me/the-comeback-of-thick-clients</id>
   <content type="html">&lt;h1 id=&quot;parse-firebase-and-the-comeback-of-two-tier&quot;&gt;Parse, Firebase and the comeback of Two-Tier&lt;/h1&gt;

&lt;p&gt;At my first company, our Job was to migrate applications developed in
Oracle Forms(client-server) to Java. To me it was always confusing why
such a migration is necessary. If your application mostly just baby-sits
the database(and certainly our application did) Oracle Forms looked like
the simplest possible solution. All the code remained in one place. The
client talked to the database using Sql. Pl/Sql if you need if and for
loops. To avoid latency, you write optimized queries and in some cases
write a stored procedure. This looked much simpler than dabbling with
server configurations, writing servlets, deploying ejbs, doing code that
oracle forms gives for free and then `still write optimized queries and
in some cases write a stored procedure`.&lt;/p&gt;

&lt;p&gt;I discussed this with my Project lead and he forwarded me a presentation
that was used by the company to persuade clients to migrate. The
presentation mostly talked about how n-tier-architecture was cooler. How
it allows you to make modular, more maintainable, more secure and better
performing apps. I stored that PPT thinking that it’ll be useful one day
if I start my own company that’ll be into such migration projects.&lt;/p&gt;

&lt;p&gt;Forward seven years, two tier is the new “cool” again. Just write your
javascript, Store the data in &lt;a href=&quot;http://www.firebase.com/&quot;&gt;firebase&lt;/a&gt; or
&lt;a href=&quot;https://parse.com/docs/js_guide&quot;&gt;parse&lt;/a&gt; and forget Servers. Now, Since
old is the new new, it might be interesting to take the old problems
again and provide new solutions. If you are looknig for ideas these
might be interesting:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Stored Javascript:&lt;/strong&gt; To reduce latency, you can for example think
of a stored-java-script that will reside near parse or firebase
servers and execute a set of queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- --&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Bring your own Database Schemes:&lt;/strong&gt; If I am just writing the
javascript for my app I might as well ask the customers to bring
their own database. This would be as simple as creating a
firebase/parse account and giving me the API key. And very cheap
since all these services provide a “free-to-start package” that will
be good enough for most customers. That can bring in the requirement
of more services. For examples a service that backs-up the data from
firebase/parse or a service that migrates objects from old schema to
new one.&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- --&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Standard Javascript Query Language:&lt;/strong&gt; How about a service that
will provide &lt;a href=&quot;http://xkcd.com/927/&quot;&gt;one standard set of Apis&lt;/a&gt; to
query different services?&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- --&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;FireBaseBootStrap:&lt;/strong&gt; Just like sql was never enough, I think we
would see projects like FirebaseBootStrap or ParseBootStrap that
will take away the pain of doing forms with these. Think Oracle
Forms for these new services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’ll be cool when these happen. ’cause by then maybe we could turn over
and discuss how n-tier is actually better again and I could use that
damn ppt.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>When the drawing board screws you over</title>
   <link href="http://ksat.me/when-the-drawing-board-screws-you-over"/>
   <updated>2012-05-30T00:00:00+00:00</updated>
   <id>http://ksat.me/when-the-drawing-board-screws-you-over</id>
   <content type="html">&lt;h1 id=&quot;when-the-drawing-board-screws-you-over&quot;&gt;When the drawing board screws you over&lt;/h1&gt;

&lt;p&gt;I clearly remember this one time when I gave an interview. It was a
Sunday afternoon.&lt;/p&gt;

&lt;p&gt;To my surprise, people in the company were friendly, cheerful and in
general - awesome. The moment I entered the office the CTO came out to
meet me, shook hands and took me around the office. Pretty cool.&lt;/p&gt;

&lt;p&gt;After 20 minutes, the actual interview started in a room with me, the
CTO and 3 more. They asked me a few questions on my earlier projects,
things related to scaling, technologies I would choose and I was
answering them pretty well. Half an hour later, the CTO said, “very
well, let’s do some real coding stuff now”. I said “yeah sure”. After
all I’ve been coding for 6 years and If there is only one thing that I
could do well it was coding. At least my wife thinks that.&lt;/p&gt;

&lt;p&gt;It was not a very complex problem. Something about building a simple
“web browser” where divs are to be aligned without overlapping. After
hearing the question I promptly started to pick out my laptop to start
to code, when the CTO said &lt;em&gt;“For the benefit of all of us in the room,
can you please try and solve it in the drawing board? Besides it’ll take
a long time to actually code, so just explain us the logic”&lt;/em&gt;. So I
walked over to the drawing board.&lt;/p&gt;

&lt;p&gt;And everything fucked up. I was like &lt;em&gt;“hmm. ok.. so I’ll create a map to
hold the positions and then..”&lt;/em&gt; when somebody would interrupt and say
&lt;em&gt;“Can you think about it? A map would be terrible choice, since you have
to iterate over it”&lt;/em&gt;. Later I was like &lt;em&gt;“On the third iteration of the
loop the value of ‘i’ will be 4 so the div.. umm.. hold on one second..
”&lt;/em&gt;. I was loosing control. Sweating. “How can I be this dumb?”. I had
faced dozens of problems like this in my projects and I knew I could
solve this. But not now. Was it because everyone was staring at me?.
Every other 5 minutes, I would say “ok, lets start over guys, let me
start from the beginning”. After like 30 minutes I was able to
articulate something that was “acceptable”. But in my heart I knew : I
would never accept that solution if I were them.&lt;/p&gt;

&lt;p&gt;On my way home, I felt devastated. I wasn’t as good as I thought I was.
That or something was totally wrong. On an instinct I picked up the
laptop from my bag right there on the auto-rickshaw I was traveling,
opened textmate and started coding &lt;em&gt;Browser.java&lt;/em&gt;. What happened then
was totally insanely awesome. The code was flowing through my hands into
the text editor. I wasn’t even thinking about things like “What’ll be
the value of i on this iteration”, I just knew it would work. I finished
the entire code and tested it during the journey of 30 minutes. Before I
reached home I took out my data card and mailed the code to the CTO.&lt;/p&gt;

&lt;p&gt;It was a revelation. The more I thought about it the more it made sense.
I did best what I was trained to do and I was never trained to explain
to code. Two takeaways:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you are giving interviews: Understand that Coding is one thing,
and explaining how you would code is quite another. Prepare for the
latter&lt;/li&gt;
  &lt;li&gt;If you are conducting interviews: Don’t ask the candidate to explain
the code on the drawing board. At least not before they have coded
once on a computer. I’d say the best way would be to give the
candidates a question, a laptop and get the hell out of the room
until the candidates finish coding. Then discuss the code with them.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>What is Evented IO and why does it scale?</title>
   <link href="http://ksat.me/what-is-evented-io-and-why-it-scales"/>
   <updated>2012-05-25T00:00:00+00:00</updated>
   <id>http://ksat.me/why-evented-programming-scales</id>
   <content type="html">&lt;h1 id=&quot;what-is-evented-io-and-why-does-it-scale-explained-in-plain-english&quot;&gt;What is evented IO and why does it scale? Explained in plain English.&lt;/h1&gt;

&lt;p&gt;If you are one of them who don’t “get” why eventing scales, that’s ok.
When I first saw evented programming, I din’t get it too. I’ll try to
this explain as simple as I can. But first read this line: “Evented
servers usually share one thread for all requests unlike threaded
servers that spawn one thread per request”. Read that last line one more
time. But what’s the big deal with this? Nothing. Now forget that and
read on.&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-1-a-cool-business-opportunity-knocks-your-door&quot;&gt;Chapter 1: A cool business opportunity knocks your door&lt;/h2&gt;

&lt;p&gt;You get a mail from a leading movie theater in your city regarding a
business opportunity:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Hi,
We at AA-Theater want get out of the damn-internet and sell all movie tickets at the counter. We want to outsource the business of selling offline tickets to you. To test how this would work we want to start with one show. The Evening show. Since the evening show is the most watched of all shows, you can assume unlimited people and unlimited tickets(as much as you can sell). The only problem is, you can sell tickets only between 5:30 PM to 6:00 PM(Government rules). You can have as many counters as you want. You take a 50% cut in all the tickets you sell. 
President, The AA-Theater
p.s: Customers will be mostly ladies
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;50% cut and unlimited tickets to sell?! Put that in perspective. If you
manage to sell only 10 tickets at $10 in that 30 minutes, you make $50.
But if you manage to sell a 1000 tickets you make $5000. Awesome!. Plus,
“this is non-technology” you think. No coding. No Servers. No database.
No scaling. No nightmares. No running behind investors. You only have
one easy-to-define goal. You must sell as much as possible in that
30-minute time frame.&lt;/p&gt;

&lt;p&gt;Next day you start your work and it goes like this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You setup a counter and people queue up in a never-end line starting
from 5:30&lt;/li&gt;
  &lt;li&gt;You sit behind the counter and ask one simple question “How many
tickets do you want to buy?”, the customer answers and you sell him
that many tickets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2 id=&quot;chapter-2-a-fat-lady-spoils-the-day&quot;&gt;Chapter 2: A fat lady spoils the day&lt;/h2&gt;

&lt;p&gt;You made one interesting observation on your first day of selling. The
time it takes for a lady to think and answer the simple question “How
many tickets do you want?” is directly proportional to their weight.
Like that fat lady wearing a brown blouse, she took almost 5 minutes to
answer. And that pretty thin girl in pink, you din’t even had to ask.
That’s quite an insight.&lt;/p&gt;

&lt;p&gt;Before we see how put this insight to use, lets try to correlate. Back
in the time when you did server coding, your server received requests.
Many requests. Some requests took a lot of time to complete
(fat-lady-requests) like the report which needed to execute a 100 sql
queries. And some requests were small(thin-lady-requests). Your job was
scale the server so it serves the maximum no of requests within a given
time. Exactly like selling the max no of tickets within 30 minutes
“Similarity” you think “Just when I thought those pesky coding days we
over for good” .&lt;/p&gt;

&lt;p&gt;The next day something goes terribly wrong. Your first customer is a
really-fat lady who takes 30 minutes just thinking how many tickets to
buy and finally says “Hmm. forget it, I left my purse at home”.
Nightmare! Even though there were like a 1000 more people behind her in
the queue, you managed to sell Zero tickets.&lt;/p&gt;

&lt;p&gt;“I’ve got to do something”, you declare, “But what?”. You correlate back
to your coding days and it strikes you. All this time You’ve just been
using one thread(One counter) and queueing all requests(people) into
that one queue. That sucks. Your mind starts racing. “I need a counter
pool” and evenly distribute the people among all these counters.&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-3-you-create-more-threads-err-counters&quot;&gt;Chapter 3: You create more threads. err.. counters&lt;/h2&gt;

&lt;p&gt;It’s day 3 and you start with a smile. Now you have like 10 counters.
Your customers queue up evenly. This is fine, you think, because, even
if a fat lady causes a bottle neck on one queue, on the other queues,
you can still sell. Hm.. But something still feels wrong. You know this
feeling is related to something your algorithm professor told you. What
was it.. Order of n. Worst case. “I’ve got to get my mind off the
coding” you decide. and move on. On day 3 you sell a record no. of
tickets.&lt;/p&gt;

&lt;p&gt;Then, on day 4, the nightmare repeats. The first set of people to enter
your counters that day were a group 10 fat ladies. You watch bewildered
as these 10 ladies distribute and take each of the counters, spoil the
30 minutes and then leave of with just 10 tickets total.&lt;/p&gt;

&lt;p&gt;“This is disaster”, you think, “Tomorrow I could have a 100 counters but
if the ‘first’ 100 people who enter my counters took a long time to buy,
I am still doomed”&lt;/p&gt;

&lt;p&gt;You think hard again, and it strikes you. You come up with a simple but
very effective solution. In fact the solution is so simple that it
doesn’t event need these 10 counters.&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-4-back-to-one-counter-but-with-a-super-awesome-strategy&quot;&gt;Chapter 4: Back to one counter. But with a super awesome strategy&lt;/h2&gt;

&lt;p&gt;On day 5 when customers come in to buy tickets, they find a board that
you have hung up near the counter. And it says&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Here's the deal. Stand in the queue. When you are at the counter, we ask you 'How many tickets you want to buy?'. If you can't answer that immediately, step out of the queue, think about it and join the queue back.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Think about how will this solve your problems. It doesn’t matter who
comes first. Say A fat lady comes in first. You ask “how many tickets?”,
she steps out of the queue to think, and while she is thinking, you sell
more tickets to other ladies and when the fat lady has thought about it
she joins back queue.&lt;/p&gt;

&lt;p&gt;This is exactly what evented architectures lets you do. Instead of
spawning one thread for every request they run all requests on one
thread. But, every time the program execution stops to think(when doing
an IO), it is pushed out of the queue. When it has the result, it can
come back.&lt;/p&gt;

&lt;p&gt;Congratulations. You did evented ticket distribution. How cool is that?
Now you can hope to become a millionaire without ever applying to
Y-combinator :)&lt;/p&gt;

&lt;p&gt;s.1: The totally-worst case remains same with the two strategies. For
eg., if all your customers were fat ladies you could still end up not
selling anything. But with the first strategy, if the “first n
customers” were fat ladies you are doomed. With the latter that is not
the case.&lt;/p&gt;

&lt;p&gt;s.2: Think about how you can still have multiple counters along with
this strategy&lt;/p&gt;

&lt;p&gt;s.3: If you are a fat lady and you are hurt with this post. Good. Try
and get slim :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Automation is not always Scalable</title>
   <link href="http://ksat.me/automation-is-not-always-scalable"/>
   <updated>2012-05-24T00:00:00+00:00</updated>
   <id>http://ksat.me/automation-is-not-always-scalable</id>
   <content type="html">&lt;h1 id=&quot;automation-is-not-always-scalable&quot;&gt;Automation is not always Scalable&lt;/h1&gt;

&lt;p&gt;As a coder-founder, you are obsessed with automation. You will have a
100 problems in your startup and you want to solve all of them by
writing code. That, however might not always be the right choice. In
fact, sometimes, not automating and being crude and manual will help you
scale better.&lt;/p&gt;

&lt;p&gt;Lets take for example support calls. Your product is steadily picking up
and you are answering around 10-15 support calls everyday. As you scale
up and have two choices. a) Keep hiring more support engineers as you
scale - or - b) Build a cool IVR that will automagically ‘answer’ most
of your customer’s problems and throttle only the rest to your team.&lt;/p&gt;

&lt;p&gt;Option b) is far-far cooler, AND, you think, that way, on the long run
you save cost by hiring less support engineers. But is it really worth
it? Do the math, you might not have considered the following&lt;/p&gt;

&lt;p&gt;* Support-engineer-time usually costs less than developer-time hence it
might take years to just compensate for the lost ‘developer time’ with
the saved ‘support engineer’ time&lt;br /&gt;
* The developer time might have been spent on actually improving the
core product&lt;br /&gt;
* If it’s something that’s easily looked up by the IVR system, the
support engineers themselves will invent ways to make it quick(like
having an excel and searching in it).&lt;br /&gt;
* Customers might not use the IVR and still prefer to directly talk to
support engineers&lt;/p&gt;

&lt;p&gt;But the most important of all is the fact that such an ‘automated’
system is never ‘done’. It becomes a product in itself. You need to
depend on the developer for every “new feature” causing a vicious
circle. If it we all manual with only support engineers and no code, all
it takes is sending a mail - “Hey guys, from now on if the customer asks
for the annual price, it is $200 and not $150”.&lt;/p&gt;

&lt;p&gt;I understand as a coder it feels just wrong to not automate. But hold
back. Not everything that can be automated is your cup of tea.
Sometimes, crude, manual and redundant means cheap, easy and less
expertise, hence easily distributable and thus more scalable.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>A plain English introduction to CAP theorem</title>
   <link href="http://ksat.me/a-plain-english-introduction-to-cap-theorem"/>
   <updated>2012-02-20T00:00:00+00:00</updated>
   <id>http://ksat.me/a-plain-english-introduction-to-cap-theorem</id>
   <content type="html">&lt;h1 id=&quot;a-plain-english-introduction-to-cap-theorem&quot;&gt;A plain english introduction to CAP Theorem&lt;/h1&gt;

&lt;p&gt;You’ll often hear about the CAP theorem which specifies some kind of an
upper limit when designing distributed systems. As with most of my other
introduction tutorials, lets try understanding CAP by comparing it with
a real world situation.&lt;/p&gt;

&lt;h2 id=&quot;chapter-1-remembrance-inc-your-new-venture-&quot;&gt;Chapter 1: “Remembrance Inc” Your new venture :&lt;/h2&gt;

&lt;p&gt;Last night when your spouse appreciated you on remembering her birthday
and bringing her a gift, a strange Idea strikes you. People are so bad
in remembering things. And you’re sooo good at it. So why not start a
venture that will put your talent to use? The more you think about it,
the more you like it. In fact you even come up with a news paper ad
which explains your idea&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Remembrance Inc! - Never forget, even without remembering!  
Ever felt bad that you forget so much? Don’t worry. Help is just a phone
away!  
When you need to remember something, just call 555—55-REMEM and tell us
what you need to remember. For eg., call us and let us know of your
boss’s phone number, and forget to remember it. when you need to know it
back.. call back the same number\[(555)—55-REMEM \] and we’ll tell you
what’s your boss’s phone number.  
Charges : only $0.1 per request
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, your typical phone conversation will look like this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Customer : Hey, Can you store my neighbor’s birthday?&lt;/li&gt;
  &lt;li&gt;You: Sure.. when is it?&lt;/li&gt;
  &lt;li&gt;Customer : 2nd of jan&lt;/li&gt;
  &lt;li&gt;You: (write it down against the customer’s page in your paper note
book )Stored. Call us any time for knowing your neighbor’s birthday
again!&lt;/li&gt;
  &lt;li&gt;Customer : Thank you!&lt;/li&gt;
  &lt;li&gt;You: No problem! We charged your credit card with $0.1&lt;br /&gt;
 &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;chapter-2--you-scale-up&quot;&gt;Chapter 2 : You scale up:&lt;/h2&gt;

&lt;p&gt;Your venture gets funded by YCombinator. Your Idea is so simple, needs
nothing but a paper notebook and phone, yet so effective that it spreads
like wild fire. You start getting hundreds of call every day.&lt;/p&gt;

&lt;p&gt;And there starts the problem. You see that more and more of your
customers have to wait in the queue to speak to you. Most of them even
hang up tired of the waiting tone. Besides when you were sick the other
day and could not come to work you lost a whole day of business. Not to
mention all those dissatisfied customers who wanted information on that
day.&lt;br /&gt;
You decide it’s time for you to scale up and bring in your wife to help
you.&lt;/p&gt;

&lt;p&gt;Your start with a simple plan:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;You and your wife both get an extension phone&lt;/li&gt;
  &lt;li&gt;Customers still dial (555)–55-REMEM and need to remember only one
number&lt;/li&gt;
  &lt;li&gt;A pbx will route the a customers call to whoever is free and
equally&lt;br /&gt;
 &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;chapter-3--you-have-your-first-bad-service-&quot;&gt;Chapter 3 : You have your first “Bad Service” :&lt;/h2&gt;

&lt;p&gt;Two days after you implemented the new system, you get a call from you
get a call from your trusted customer Jhon. This is how it goes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Jhon: Hey&lt;/li&gt;
  &lt;li&gt;You: Glad you called “Remembrance Inc!”. What can I do for you?&lt;/li&gt;
  &lt;li&gt;Jhon: Can you tell me when is my flight to New Delhi?&lt;/li&gt;
  &lt;li&gt;You: Sure.. 1 sec sir&lt;br /&gt;
(You look up your notebook)&lt;br /&gt;
(wow! there is no entry for “flight date” in Jhon’s page)!!!!!&lt;/li&gt;
  &lt;li&gt;You: Sir, I think there is a mistake. You never told us about your
flight to delhi&lt;/li&gt;
  &lt;li&gt;Jhon: What! I just called you guys yesterday!(cuts the call!)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How did that happen? Could Jhon be lying? You think about it for a
second and the reason hits you! Could Jhon’s call yesterday reached your
wife? You go to your wife’s desk and check her notebook. Sure enough
it’s there. You tell this to your wife and she realizes the problem too.&lt;/p&gt;

&lt;p&gt;What a terrible flaw in your distributed design! &lt;strong&gt;Your distributed
system is not consistent! There could always be a chance that a customer
updates something which goes to either you or your wife and when the
next call from the customer is routed to another person there will not
be a consistent reply from Remembrance Inc!&lt;/strong&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-4-you-fix-the-consistency-problem&quot;&gt;Chapter 4: You fix the Consistency problem:&lt;/h2&gt;

&lt;p&gt;Well, your competitors may ignore a bad service, but not you. You think
all night in the bed when your wife is sleeping and come up with a
beautiful plan in the morning. You wake up your wife and tell her:&lt;/p&gt;

&lt;p&gt;” Darling this is what we are going to do from now”&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Whenever any one of us get a call for an update(when the customer
wants us to remember something) before completing the call we tell
the other person&lt;/li&gt;
  &lt;li&gt;This way both of us note down any updates&lt;/li&gt;
  &lt;li&gt;When there is call for search(When the customer wants information he
has already stored) we don’t need to talk with the other person.
Since both of us have the latest updated information in both of our
note books we can just refer to it..&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is only one problem though, you say, and that is an “update”
request has to involve both of us and we cannot work in parallel during
that time. For eg. when you get an update request and telling me to
update too, i cannot take other calls. But that’s okay because most
calls we get anyway are “search” (a customer updates once and asks many
times) . Besides, we cannot give wrong information at any cost.&lt;/p&gt;

&lt;p&gt;“Neat” your wife says, “but there is one more flaw in this system that
you haven’t thought of. What if one of us doesn’t report to work on a
particular day? On that day, then, we won’t be able to take “any” Update
calls, because the other person cannot be updated! We will have
&lt;strong&gt;Availability problem , i.e, for eg., if an update request comes to me
I will never be able to complete that call because even though I have
written the update in my note book, I can never update you. So I can
never complete the call!”&lt;/strong&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-5-you-come-up-with-the-greatest-solution-ever&quot;&gt;Chapter 5: You come up with the greatest solution Ever:&lt;/h2&gt;

&lt;p&gt;You being to realize a little bit on why distributed system might not be
as easy as you thought at first. Is it that difficult to come up with a
solution that could be both &lt;strong&gt;“Consistent and Available”&lt;/strong&gt;? Could be
difficult for others, but not for you!! Then next morning you come up
with a solution that your competitors cannot think of in their dreams!
You wake your wife up eagerly again..&lt;/p&gt;

&lt;p&gt;” look” , you tell her.. “This is what we can do to be consistent and
available” . The plan is mostly similar to what I told you yesterday:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;i) Whenever any one of us get a call for an update(when the
customer wants us to remember something) before completing the call,
if the other person is available we tell the other person. This way
both of us note down any updates&lt;/li&gt;
  &lt;li&gt;ii) But if the other person is not available(doesn’t report to
work) we send the other person an email about the update.&lt;/li&gt;
  &lt;li&gt;iii) The next day when the other person comes to work after taking
a day off, He first goes through all the emails, updates his note
book accordingly.. before taking his first call.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Genius! You wife says! I can’t find any flaws in this systems. Let’s put
it to use.. Remembrance Inc! is now both &lt;strong&gt;Consistent and available!&lt;/strong&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-6-your-wife-gets-angry-&quot;&gt;Chapter 6: Your wife gets angry :&lt;/h2&gt;

&lt;p&gt;Everything goes well for a while. Your system is consistent. Your system
works well even when one of you doesn’t report to work. But what if Both
of you report to work and one of you doesn’t update the other person?
Remember all those days you’ve been waking your wife up early with your
Greatest-idea-ever-bullshit? * What if your wife decides to take calls
but is too angry with you and decides not to update you for a day? Your
idea totally breaks! Your idea so far is good for consistency and
availability but is not Partition Tolerant!*&lt;br /&gt;
You can decide to be partition tolerant by deciding not to take any
calls until you patch up with your wife.. Then your system will not be
“available” during that time…&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-7-conclusion-&quot;&gt;Chapter 7: Conclusion :&lt;/h2&gt;

&lt;p&gt;So Let’s look at CAP Theorem now. Its states that, when you are
designing a distributed system you can get cannot achieve all three of
Consistency, Availability and Partition tolerance. You can pick only two
of:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Consistency: You customers, once they have updated information with
you, will always get the most updated information when they call
subsequently. No matter how quickly they call back&lt;/li&gt;
  &lt;li&gt;Availability: Remembrance Inc will always be available for calls
until any one of you(you or your wife) report to work.&lt;/li&gt;
  &lt;li&gt;Partition Tolerance: Remembrance Inc will work even if there is a
communication loss between you and your wife!&lt;br /&gt;
 &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;bonus--eventual-consistency-with-a-run-around-clerk-&quot;&gt;Bonus : Eventual Consistency with a run around clerk :&lt;/h2&gt;

&lt;p&gt;Here is another food for thought. You can have a run around clerk, who
will update other’s notebook when one of your’s or your wife’s note
books is updated. The greatest benefit of this is that, he can work in
background and one of your or your wife’s “update” doesn’t have to
block, waiting for the other one to update. This is how many NoSql
systems work, one node updates itself locally and a background process
synchronizes all other nodes accordingly… The only problem is that you
will lose consistency of some time. For eg., a customer’s call reaches
your wife first and before the clerk has a chance to update your
notebook , the customer’ calls back and it reaches you. Then he won’t
get a consistent reply.. But that said, this is not at all a bad idea if
such cases are limited. For eg., assuming a customer won’t forget things
so quickly that he calls back in 5 minutes.&lt;/p&gt;

&lt;p&gt;That’s CAP and eventual consistency for you in simple english :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>MacSequel – A native MAC OSX GUI query tool for Oracle</title>
   <link href="http://ksat.me/macsequel-a-native-osx-gui-query-tool-for-oracle"/>
   <updated>2011-08-15T00:00:00+00:00</updated>
   <id>http://ksat.me/macsequel-a-native-osx-gui-query-tool-for-oracle</id>
   <content type="html">&lt;h1 id=&quot;macsequel--a-native-mac-osx-gui-query-tool-for-oracle&quot;&gt;MacSequel – A native MAC OSX GUI query tool for Oracle&lt;/h1&gt;

&lt;p&gt;Introducing &lt;a href=&quot;http://www.macsequel.com/&quot;&gt;MacSequel – a made-for-mac-osx query tool for
oracle.&lt;/a&gt; This is my first experience writing
objective-C code. This is how MacSequel looks:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/macsequel-thumb.png&quot; alt=&quot;Macsequel - a native mac osx query tool for oracle&quot; title=&quot;Macsequel - a native mac osx query tool for oracle&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I am recently working on a web-project backed primarily by Oracle
Database. Though most of my earlier projects used MySql, this is not the
first time I am working with Oracle. I’ve had so many times in the past
where a client has demanded that an app to be run on Oracle. One of the
biggest troubles I’ve had in working with Oracle is the lack of a decent
native osx client(a query tool).&lt;/p&gt;

&lt;p&gt;During such times, every other day I actively google for a few minutes
looking for a simple native-mac GUI for oracle and then after failing to
find one, get back to SQLDeveloper. And SQLDeveloper sucks. At least on
my mac. At least for the simple things I do everyday. Takes a long time
load, consumes huge memory and just dosen’t have that “Something” that
other native Sql tools have(For eg., &lt;a href=&quot;http://www.sequelpro.com/&quot;&gt;Sequel
Pro&lt;/a&gt; which is a great for mysql).&lt;/p&gt;

&lt;p&gt;So I decided to make one. I’ve been a Java(and swing) developer all my
life, so the first step was to convince myself to move away from java
for this project. Once I did that, it wasn’t that difficult. I will try
to post a few more articles or the troubles I faced which might be
useful to someone trying to write objective-c code for the first time.&lt;/p&gt;

&lt;p&gt;I’d love your feedback. [ kaushik dot sathupadi at gmail.com ]&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Why You’ll like Fantom -part 1 – The compiler</title>
   <link href="http://ksat.me/why-fantom-matters-1-the-compiler"/>
   <updated>2011-06-09T00:00:00+00:00</updated>
   <id>http://ksat.me/why-fantom-matters</id>
   <content type="html">&lt;h1 id=&quot;why-youll-like-fantom--part-1--the-compiler&quot;&gt;Why You’ll like Fantom -part 1 – The compiler&lt;/h1&gt;

&lt;p&gt;The benefit of the compiler(and static typing) has always been a topic
of hot debate. People love it, with passion. And people hate it, with
passion. Have you thought about what is it with the compiler that brings
people into a love/hate relationship with it?&lt;/p&gt;

&lt;h2 id=&quot;compilers-you-cant-live-with-them-you-cant-live-without-them&quot;&gt;Compilers. You can’t live with them.. You can’t live without them&lt;/h2&gt;

&lt;p&gt;Sounds familiar? That’s because compilers are like your wife. They
complain .. let you know when you suck. And that’s a good thing. Wait..
is it?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/compiler2.png&quot; width=&quot;500&quot; height=&quot;608&quot; alt=&quot;(Compiler vs Your wife)!&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;whats-jacks-solution&quot;&gt;What’s Jack’s solution?&lt;/h2&gt;

&lt;p&gt;How do you fix your wife? Here are a few suggestions&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Make her responsible for the things she asks ‘you’ to do..&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(# “Honey, can you make sure you cut my nails every weekend”&lt;br /&gt;
(# “Oh i am so careless baby.. Things will be way better if someone
more dependable(looking at her) took care of all the bills”&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Agree on signals that indicate the times when she is not allowed
to complain&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(# “When I am wearing a red T-shirt .. it means i am in a really bad
mood, so you are not allowed to complain. Other days you can.”&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2 id=&quot;like-thats-going-to-happen&quot;&gt;Like that’s going to happen&lt;/h2&gt;

&lt;p&gt;Well who are we kidding. that’s not going to happen. In your dreams
Jack. But James might try his luck with the Fantom Compiler..&lt;/p&gt;

&lt;h2 id=&quot;make-the-compiler-do-more-work&quot;&gt;Make the compiler do more work.&lt;/h2&gt;

&lt;p&gt;Here are a few examples&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;” Hey compiler can you try and figure out the type when I don’t type
it”&lt;br /&gt;
and then do a..&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;pre. a := 3&lt;/p&gt;

&lt;p&gt;instead of&lt;/p&gt;

&lt;p&gt;pre. Int a := 3&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“All those +s drive me crazy, so can you handle String interpolation
for me”?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and then do a..&lt;/p&gt;

&lt;p&gt;pre. s = “My color is $color and My age is $age”&lt;/p&gt;

&lt;p&gt;instead of&lt;/p&gt;

&lt;p&gt;pre. String s = “My color is ” + color + “ and My age is “ + age&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“And BTW.. i don’t really like putting semi colons .. so put them
for me at the end of each line and can you handle that multi line
strings for me too..”&lt;br /&gt;
And so the list can go on..&lt;br /&gt;
 &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;agree-on-signals-that-indicate-the-times-when-the-compiler-is-not-allowed-to-complain&quot;&gt;Agree on signals that indicate the times when the compiler is not allowed to complain&lt;/h2&gt;

&lt;p&gt;*( “When I use a ‘-&amp;gt;’ instead of “.” to call a method, just don’t
check if the method actually exists or do any sort of type checking”.
check an example&lt;/p&gt;

&lt;p&gt;pre. blogOrAnimal := getEitherABlogOrAnAnimalFromDatabase()&lt;br /&gt;
blogOrAnimal-&amp;gt;save&lt;/p&gt;

&lt;p&gt;“getEitherABlogOrAnAnimalFromDatabase” returns either a blog or an
animal. Both of them have a save method. You just want this time, this
one time, to treat them equally and call the freaking save method
instead of “ifs-and-casts-and-then-calls”&lt;/p&gt;

&lt;p&gt;*( ” When I declare a type, I mean I want that type, don’t need to me
cast”. so..&lt;/p&gt;

&lt;p&gt;pre. Blog b := getObject(“blog”)&lt;/p&gt;

&lt;p&gt;instead of..&lt;/p&gt;

&lt;p&gt;pre. Blog b := (Blog) getObject(“blog”)&lt;/p&gt;

&lt;p&gt;(assuming that getObject is “declared” to return “Object” but returns
the correct type of object depending on a parameter at runtime)&lt;/p&gt;

&lt;p&gt;So .. that’s the thing about the Fantom compiler. It provides the
benefits of static type checking but shuts itself up when you ask it to.
Go to &lt;a href=&quot;http://fantom.org&quot;&gt;fantom.org&lt;/a&gt; to learn more.. or &lt;a href=&quot;http://www.fanzy.net&quot;&gt;play with it
online&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>First, Save your Ass</title>
   <link href="http://ksat.me/first-save-your-ass"/>
   <updated>2011-02-26T00:00:00+00:00</updated>
   <id>http://ksat.me/first-save-your-ass</id>
   <content type="html">&lt;h1 id=&quot;first-save-your-ass&quot;&gt;First, Save your Ass&lt;/h1&gt;

&lt;p&gt;I’ve seen managers always quoting Mahatma Gandhi :&lt;br /&gt;
“A customer is the most important visitor person on our premises..”&lt;/p&gt;

&lt;p&gt;MG got it almost right when he said that. The truth is The Customer is
the second most important visitor in your premises. The most important
is you. Your team. If you die, your customer dies with you.&lt;/p&gt;

&lt;h2 id=&quot;learn-from-the-airplane-stewardess&quot;&gt;Learn from the Airplane Stewardess:&lt;/h2&gt;

&lt;p&gt;Remember what the airplane stewardess teaches you? In an event that the
flight goes bonkers and the oxygen level goes down the oxygen masks will
drop above your seats. You are supposed to first put on the masks then
put the masks on your children. You, then your children. In that order.
Why do they tell that? Because the logic is so simple, yet so many don’t
realize it. If you die trying to save your children, you’re helping
nobody. There is a better chance to save your children if you are alive
in the first place. Isn’t that true for your team too? If you allow your
code to rot, overwork your developers all in the excuse of “doing it for
the customers” you’re no helping nobody.&lt;/p&gt;

&lt;h2 id=&quot;what-kind-of-people-are-we&quot;&gt;What kind of people are we?&lt;/h2&gt;

&lt;p&gt;Let’s be honest. In most industries having software is not mandatory.
People can do without it. We sell our software but on one premise.
Making the life of customer easy. What kind of people are we if we don’t
buy in to the same philosophy? The truth is “software” can not only make
our customer’s life easy, but also ours.&lt;br /&gt;
Look within your company. There will be so many places where software
can help you. Take time off writing that. Ask your developers what’s
irritating them. there are always some. May be the manual build process?
Give them time off to automate it. May be the “dirty” code and design
that encourages copy paste more than reuse? Give them time to write
utility classes and refractor the code. Give them time to learn new
technologies. Get them the mac that they always wanted.&lt;/p&gt;

&lt;p&gt;Doing all this is not a “nice-to-have”. It’s priority-1-code-red-issue.
And make sure you let your team know of this. Tell them it’s okay to
delay the feature, in exchange for doing it right. Don’t file these work
under “when-you-get-time”. That way you will never get time. Don’t treat
these as “extra” work, this is a part of “the” work.&lt;br /&gt;
Keep looking for ways to make your team’s life easier. Ask them how can
things be improved. Don’t expect your team to come and tell you about
every problem. Make a culture out of “Helping themselves first”. Don’t
let this process get lost in the “customer want’s this” hoopla.&lt;/p&gt;

&lt;p&gt;Think about it this way. Wouldn’t you rather eat in a hotel that serves
you nicely cooked food with a clean kitchen even if they delay a bit?
Same with your customers. Keep your “internals” clean. Keep your
developers happy. In turn, they will delight your customers. Isn’t that
what you want anyway? :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Curing yourself off Addiction</title>
   <link href="http://ksat.me/curing-yourself-off-addiction"/>
   <updated>2010-11-09T00:00:00+00:00</updated>
   <id>http://ksat.me/curing-yourself-off-addiction</id>
   <content type="html">&lt;h1 id=&quot;curing-yourself-off-addiction&quot;&gt;Curing yourself off Addiction&lt;/h1&gt;

&lt;p&gt;I always wondered why its so difficult to cure people out of addiction.
It was put very accurately in a movie I saw on HBO yesterday.. “Curing
yourself off addiction is same as curing yourself off ‘desire’ itself.
And no one wants to be cured off ‘desire’”.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Backspace Hell</title>
   <link href="http://ksat.me/backspace-hell"/>
   <updated>2010-11-05T00:00:00+00:00</updated>
   <id>http://ksat.me/backspace-hell</id>
   <content type="html">&lt;h1 id=&quot;backspace-hell&quot;&gt;Backspace Hell&lt;/h1&gt;

&lt;p&gt;I don’t have a problem with my typing. In fact I type really fast. I’ve
one small problem however. When I type a line and notice a mistake in
the beginning of the line, I backspace until I get to the error, then
fix it and type the rest again. I can’t seem to get out this habit. May
be because backspace involves less movement of fingers than reaching the
arrow buttons or mouse.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>The Tales Web Framework for Fantom</title>
   <link href="http://ksat.me/tales-framework"/>
   <updated>2010-11-04T00:00:00+00:00</updated>
   <id>http://ksat.me/tales-framework</id>
   <content type="html">&lt;h1 id=&quot;tales-framework&quot;&gt;Tales Framework&lt;/h1&gt;

&lt;p&gt;OK. Finally got to launch the Tales Framework. Have a look at it and let
me know. I will write more about it in the comming posts. For now here’s
a video of what it can do:&lt;/p&gt;

&lt;p&gt;
&lt;iframe src=&quot;http://player.vimeo.com/video/16453080?byline=0&amp;amp;portrait=0&quot; width=&quot;400&quot; height=&quot;225&quot; frameborder=&quot;0&quot;&gt;
&lt;/iframe&gt;
&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Not all engineers carry a pen</title>
   <link href="http://ksat.me/not-all-engineers-carry-a-pen"/>
   <updated>2010-10-02T00:00:00+00:00</updated>
   <id>http://ksat.me/not-all-engineers-carry-a-pen</id>
   <content type="html">&lt;h1 id=&quot;not-all-engineers-carry-a-pen&quot;&gt;Not all engineers carry a pen&lt;/h1&gt;

&lt;p&gt;If you are a software engineer in India you know this problem. There is
a huge difference between the previous generation “Engineers” and the
new ones. Leading that difference is the thought that Engineers always
carry a pen. Laptops and smart phones have spoiled me to the point that
I don’t think of taking a pen anymore. Add the fact that I am usually
careless.&lt;/p&gt;

&lt;p&gt;I’ve never felt guilty about it. That is, Until I meet one of the
previous generation Engineers. They could just kill you will a single
“What? Don’t have a pen?”&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Map Reduce - A really simple introduction</title>
   <link href="http://ksat.me/map-reduce-a-really-simple-introduction-kloudo"/>
   <updated>2010-09-28T00:00:00+00:00</updated>
   <id>http://ksat.me/map-reduce-a-really-simple-introduction-kloudo</id>
   <content type="html">&lt;h1 id=&quot;map-reduce-a-really-simple-introduction&quot;&gt;Map Reduce: A really simple introduction&lt;/h1&gt;

&lt;p&gt;Ever since google
&lt;a href=&quot;http://labs.google.com/papers/mapreduce.html&quot;&gt;published&lt;/a&gt; its research
paper on map reduce, you have been hearing about it. Here and there. If
you have uptil now considered map-reduce a mysterious buzzword, and
ignored it, Know that its not. The basic concept is really very simple.
and in this tutorial I try to explain it in the simplest way that I can.
Note that I have intentionally missed out some deeper details to make it
really friendly to a beginner.&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-1-your-ceos-strange-itch&quot;&gt;Chapter 1: Your CEO’s Strange itch:&lt;/h2&gt;

&lt;p&gt;Imagine this. You work in a really big company. Your company is planning
to launch the next big “Blogging platform”. Tommorow morning you go to
your office and there’s a mail from your CEO regarding a new work:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Dear  &amp;lt;Your Name&amp;gt;,
 As you know we are building the blogging platform blogger2.com, I need some statistics. I need to find out, Acorss all blogs ever wrriten on blogger.com, how many times 1 character words occur(like 'a', 'I'), How many times two character words occur (like 'be', 'is').. and so on till how many times do ten character words occur.

 I know its a really big job. So, I will assign, all 50,000 employees working in our company to work with you on this for a week.  I am going on a vacation for a week, and its really important that I've this when I return. Good luck.

regds,
The CEO

P.s : and one more thing. Everything has to be done manually, except going to the blog and copy pasting it on notepad. I read somewhere that if you write programs, google can find out about it
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Picture yourself in that position for a moment. You have 50,000 people
to work for you for a week. And you need to find out the number of 1
character words, No. of 2 character words etc., covering the maximum
number of blogs in blogspot. Finally you need to give a report to your
CEO with something like this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Occurance of one character words – Around 937688399933&lt;/li&gt;
  &lt;li&gt;Occurance of two chracter words – Around 23388383830753434&lt;/li&gt;
  &lt;li&gt;.. hence forth till 10&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If homicide, suicide or resigining the job is not an option, how would
you solve it? How would you avoid the chaos of so many people working.
How will you co-ordinate those many since the output of one has to be
merged with another?&lt;/p&gt;

&lt;p&gt;You decide to take leave for the day, go home, sleep over it, and the
next day wake up with the greatest Idea ever. “S**t! i wasted a
day!”&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-2-your-proclamation-let-there-be-caste&quot;&gt;Chapter 2: Your proclamation: Let there be caste&lt;/h2&gt;

&lt;p&gt;The next day, You stand with a mike on the dias before 50,000 and
proclaim. For a week, you will all be divided into many groups:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Mappers (tens of Thousands of people will be in this group)&lt;/li&gt;
  &lt;li&gt;The Grouper (Assume just one guy for now)&lt;/li&gt;
  &lt;li&gt;The Reducers( Around 10 of em.) and..&lt;/li&gt;
  &lt;li&gt;The Master(That’s you).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then you talk to each one of the groups.&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-3-your-talk-with-the-mappers&quot;&gt;Chapter 3: Your talk with The Mappers&lt;/h2&gt;

&lt;p&gt;Each mapper will get a set of 50 blog urls and really Big sheet of
paper. Each one of you need to go to each of that url. and for each word
in those blogs, write one line on the paper. The format of that line
should be the number of characters in the word, then a commna, and then
the actual word.&lt;/p&gt;

&lt;p&gt;For example, if you find the word “a”, you write “1,a”, in a new line in
your paper. since the word “a” has only 1 character. If you find the
word “hello”, you write “5,hello” on the new line.&lt;/p&gt;

&lt;p&gt;Each take 4 days. So, After 4 days, your sheet might look like this&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“1,a”&lt;/li&gt;
  &lt;li&gt;“5,hello”&lt;/li&gt;
  &lt;li&gt;“2,if”&lt;/li&gt;
  &lt;li&gt;.. and a million more lines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;At the end of the 4th day. each one of you will give your sheet
completely filled to the Grouper&lt;/strong&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-4-your-talk-with-the-grouper&quot;&gt;Chapter 4: Your talk with the Grouper&lt;/h2&gt;

&lt;p&gt;I will give you 10 papers. The first paper will be marked 1, the second
paper will be marked 2, and so on, till 10.&lt;/p&gt;

&lt;p&gt;You collect the output from mappers and for each line in the mapper’s
sheet, if it says “1,&lt;something&gt;”, your write the &lt;something&gt; on sheet
1, if it says “2, &lt;something&gt;”, you write it on sheet two.&lt;/something&gt;&lt;/something&gt;&lt;/something&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example, if the first line of a mapper’s sheet says “1,a”, you
write “a” on sheet 1. if it says “2,if”, your write “if” on sheet 2. If
it says “5,hello”, you write hello on sheet 5.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So at the end of your work, the 10 sheets you have might look like this&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Sheet 1: a, a ,a , I, I , i, a, i, i, i…. millions more&lt;/li&gt;
  &lt;li&gt;Sheet 2: if, of, it, of, of, if, at, im, is,is, of, of … millions
more&lt;/li&gt;
  &lt;li&gt;Sheet 3 :the, the, and, for, met, bet, the, the, and, … millions
more&lt;/li&gt;
  &lt;li&gt;..&lt;/li&gt;
  &lt;li&gt;Sheet 10: ……&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;once you are done, you distribute, each sheet to one reducer. For
example sheet 1 goes to reducer 1, sheet 2 goes to reducer 2 and so
on.&lt;/strong&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-5-your-talk-with-the-reducers&quot;&gt;Chapter 5: Your talk with the Reducers:&lt;/h2&gt;

&lt;p&gt;Each one of you gets one sheet from the grouper. for each sheet you
count the number of words written on it and write it in big bold letters
on the back side of the paper.&lt;/p&gt;

&lt;p&gt;For ex, if you are reducer 2. You get sheet 2 from the grouper that
looks like this:&lt;br /&gt;
“Sheet 2: if, of, it, of, of, if, at, im, is,is, of, of …”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You count the number of words on that sheet, say the number of words
is 28838380044, You write it on the back side of the paper , in big bold
letters and give it to me(the master).&lt;/strong&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;chapter-6-the-controlled-chaos-and-the-climax&quot;&gt;Chapter 6: The controlled Chaos and the climax:&lt;/h2&gt;

&lt;p&gt;At the end of this process you have 10 sheets, Sheet 1, having the count
of the number of words with 1 character on the back side. Sheet2, having
the count of the number words with 2 characetrs on the back side. You
did it. Genius.&lt;/p&gt;

&lt;p&gt;You essentially did map reduce. The greatest advantage in your approach
was this&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The mappers can work independently&lt;/li&gt;
  &lt;li&gt;The reducers can work independently&lt;/li&gt;
  &lt;li&gt;The Grouper can work really fast, because, he din’t have to do any
counting of words, all the had to do was to look at the first number
and put that word in the appropriate sheet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The process can be easily applied to other kinds of problems. In such a
case :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The work of the Master(dividing the work) and the Grouper(Grouping
the values by key[the value before commna]), remains the same.
This is what any map-reduce library provides.&lt;/li&gt;
  &lt;li&gt;The work of the mappers and reducers differ according to the
problem. This is what you should write.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can optimize this a little bit. And I am skipping those. For
example, you don’t even have to mention the words, every where, you
could have just written down “x”, instead of the actual word, since in
the end, we are just counting. And everything need not happen in a
sequence like First Mapper, the Grouper and then reducer. Moreover, one
person can be sometime do the job of a mapper and some other time the
job of a grouper. Give all this a thought and you will get more answers.&lt;/p&gt;

&lt;p&gt;So You solve the biggest challenge ever posed to you. After a week You
collect the sheet of papers from the reducers. The back side of sheet 1
will have the number of occurences of words with 1 character. The back
side of sheet 2 will have the number of occurances of words with 2
characters and so on..&lt;/p&gt;

&lt;p&gt;You put this information in a excel, Take a printout in a neat sheet of
paper and take it to your CEO with a big smile. “Good job “, he says,
“put it on the desk, I will take a look at it in a month” :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Jargon’s a Jargon</title>
   <link href="http://ksat.me/jargons-a-jargon"/>
   <updated>2010-09-27T00:00:00+00:00</updated>
   <id>http://ksat.me/jargons-a-jargon</id>
   <content type="html">&lt;h1 id=&quot;jargons-a-jargon&quot;&gt;Jargon’s a Jargon&lt;/h1&gt;

&lt;p&gt;I din’t know the word Jargon for a long time. Wikipedia says Jargon is
.. “any talk or writing that one does not understand.” So the word
Jargon is a jargon for me. Is there any other simpler word that is less
of a Jargon than Jargon still meaning jargon?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Its the same.. only different</title>
   <link href="http://ksat.me/win7-its-the-same-only-different"/>
   <updated>2010-09-25T00:00:00+00:00</updated>
   <id>http://ksat.me/win7-its-the-same-only-different</id>
   <content type="html">&lt;h1 id=&quot;its-the-same-only-different&quot;&gt;Its the same.. only different&lt;/h1&gt;

&lt;p&gt;Upgraded to windows 7 some time back. Whenever you do upgrade to a new
operating system, the new user interface gives you a high.&lt;/p&gt;

&lt;p&gt;The win 7 UI, is pretty neat especially considering that I am moving
from XP.. Until I open one of the inner dialogs. like “Internet
options”. Those just look the same! except a translucent title bar. I
feel cheated. :(. Oh wait, there are other things apart from UI, I
should see before I declare that. or Should I?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Nobody to kill.</title>
   <link href="http://ksat.me/nobody-to-kill"/>
   <updated>2010-09-24T00:00:00+00:00</updated>
   <id>http://ksat.me/nobody-to-kill</id>
   <content type="html">&lt;h1 id=&quot;nobody-to-kill&quot;&gt;Nobody to kill.&lt;/h1&gt;

&lt;p&gt;Upgraded to windows 7 recently. One of the biggest problem I see is the
CPU goes to 100% usage sometimes and when I open Task Manager Process
window, I can’t find the bloody culprit. Chrome 5, iexplore 8, explore&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Then how is my CPU bloody 100?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that I am being conscious of my behavior, I used to derive a
pleasure in killing processes whenever this happens. CPU goes to 100%,
the system becomes slow, your mouse movement is impaired.. You open the
task manager with great difficulty, then Kill the culprit. and wow!
Everything is normal again, your dual core is up on full throttle. Your
mouse is smooth as cake. You hit the caps lock and the indicator light
comes up in a flash. all By the act of your killing. What a
satisfaction!&lt;/p&gt;

&lt;p&gt;Now , I can’t seem to find any culprit to kill in windows 7. and that
makes me sad. Is that bad?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>A really Simple introduction to Actors for a Java Programmer</title>
   <link href="http://ksat.me/introduction-to-actors-for-a-java-programmer"/>
   <updated>2010-09-23T00:00:00+00:00</updated>
   <id>http://ksat.me/introduction-to-actors-for-a-java-programmer</id>
   <content type="html">&lt;h1 id=&quot;a-really-simple-introduction-to-actors-for-a-java-programmer&quot;&gt;A really Simple introduction to Actors for a Java Programmer&lt;/h1&gt;

&lt;p&gt;Modern languages, like Fantom and Scala are ditching the Java like
Threading model for an Actor based model. So is there something wrong
with Threads? Why do we need actors? Turns out that it’s really simple.&lt;/p&gt;

&lt;h2 id=&quot;the-curse-of-shared-state&quot;&gt;The Curse of Shared State&lt;/h2&gt;

&lt;p&gt;There is nothing wrong with threads in java. Its just that variables are
shared between threads. Each thread can see and modify the same
variables. To prevent accidental corruption you need to “synchronize”
blocks of your code so only one thread can access it at a time.&lt;/p&gt;

&lt;p&gt;With actors, its sort of like each thread gets its own variables.(its
own state). Each actor can only see and modify these.&lt;/p&gt;

&lt;p&gt;Remember Object Oriented encapsulation? – Where each function in a class
can only see and modify variables(if its private) in its class? Think of
Actors as applying the same principles to Threads. Its a new Level of
encapsulation for Threads.&lt;br /&gt;
 &lt;/p&gt;

&lt;h2 id=&quot;its-just-a-slight-change-in-the-point-of-view&quot;&gt;It’s Just a slight change in the point of view&lt;/h2&gt;

&lt;p&gt;Imagine you and your friend decide to write this post down on a piece of
paper, each willing to write half of it. The problem is, you have a
shared paper to write down to. Now if both of you keep writing in the
paper at the same time, you corrupt the paper. So you need to take
turns(A.K.A synchronize). You do it this way because that’s the simplest
way. While one of you holds the paper and writes to it, the other waits.
But this way you aren’t really working in parallel, are you? This how
threads work. Lets see actors.&lt;/p&gt;

&lt;h2 id=&quot;rule1-nobody-shares-papers&quot;&gt;Rule#1: Nobody shares papers&lt;/h2&gt;

&lt;p&gt;Now imagine there’s a rule that no body shares papers. So, each one of
you is forced to get a piece of paper to write to. You are not allowed
to write on (or even see) others paper. Now, since you have your own
papers to write to, you can work independently, even on separate rooms.&lt;/p&gt;

&lt;h2 id=&quot;rule-2-no-tapping-on-the-back-or-phone-calls-you-can-send-emails-though&quot;&gt;Rule #2: No tapping on the back or phone calls. You can send Email’s though&lt;/h2&gt;

&lt;p&gt;There’s Another rule, you are not allowed to talk to each other
synchronously. No tapping on your friends back or giving him a phone
call, thus disturbing him while he is writing. But you are allowed to
send him email. The difference is, he decides when to check the email.
If he wants to complete something, and then check the email, his choice.
And how does he give an answer to your question? By sending back a reply
through email. You get the point.&lt;/p&gt;

&lt;h2 id=&quot;rule-3-you-cant-change-the-massages-content-once-you-have-sent-it&quot;&gt;Rule #3: You can’t change the massage’s content once you have sent it.&lt;/h2&gt;

&lt;p&gt;You don’t have any control on when, if at all your partner will see your
message. So you can’t guarantee the systems behaviour if you were
allowed to change the message after you sent it. Luckily, email doesn’t
allow you to do that. So Email’s Perfect.&lt;/p&gt;

&lt;h2 id=&quot;now-lets-see-the-definition-of-actors-again&quot;&gt;Now lets see the definition of Actors again:&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Actors can execute in parallel (Just like you and your friend can
write at the same time, on different papers)&lt;/li&gt;
  &lt;li&gt;Actors dont’ share state (You and your friend, never write on the
same paper)&lt;/li&gt;
  &lt;li&gt;They communicate asynchronously (send Email, Don’t call or tapp his
back with a ‘hey’)&lt;/li&gt;
  &lt;li&gt;Each actor has a queue to receive messages from other actors(Just
like your email inbox)&lt;/li&gt;
  &lt;li&gt;The messages sent must be immutable ( Nobody should be able to
modify the email after its sent)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s all. You got it, din’t you? :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Thread Local variables in plain English</title>
   <link href="http://ksat.me/thread-local-variables-in-plain-english"/>
   <updated>2010-09-21T00:00:00+00:00</updated>
   <id>http://ksat.me/thread-local-variables-in-plain-english</id>
   <content type="html">&lt;h1 id=&quot;thread-local-variables-in-plain-english&quot;&gt;Thread Local variables in plain English&lt;/h1&gt;

&lt;p&gt;Thread Locals is a little less known feature in Java. If you din’t know
about Thread Local variables, or din’t care yet, here’s a basic
tutorial. (If you did know, this article is pretty basic and you can
skip)&lt;/p&gt;

&lt;p&gt;Thread locals are used, simply, when you want hold values for a variable
per thread. Now, why would you need that? You need that To Pass values
down to methods without explicitly passing them as method arguments.
Think about that line for a second. Two questions can come to your mind&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What’s the problem with passing them as methods arguments? A few.
First, the method that requires the parameter can be well down the
chain and each intermediate method has to be “dirtly” modified to
get the value to the target method. second, in some cases, you
wouldn’t even have control on modifying the intermediate methods if
the code flow passes through a 3rd party library and finally comes
back to your code.&lt;/li&gt;
  &lt;li&gt;What’s the problem with just storing it as an instance variable?
Turns out that it’s not thread safe. What the heck is thread safety
here? Its when another thread comes and mysteriously modifies the
value before it reaches the target method.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consider this example. You want to write some utility code that your
team should be able to use like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Transaction.init( //initializes a &quot;db connection&quot;
  new Runnable(){
     public void run(){
      Transaction.execute(&quot;update stmt&quot;); //uses the connection
      Transaction.execute(&quot;update stmt&quot;);
     }
  }
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You need to write the “Transaction” class. This class initializes a db
“connection” object before calling the run method and closes it after
run() finishes executing. So the question is, where do you “store” the
connection object that’s initalized in the constructor and “use” it in
the “execute” method?&lt;/p&gt;

&lt;p&gt;This demonstrates 2 problems, first you might not want to pass the
connection object around just for the heck of thread safety. Besides you
don’t have any control on the Runnable classes’s run() method anyway, to
add a parameter there.&lt;/p&gt;

&lt;p&gt;So you use thread locals. The init() method intializes the connection
and stores it on ThreadLocal variable, then calls the run() method. The
executeQuery() method takes the value from the ThreadLocal variable and
uses it to execute query. After calling the run() method the we “commit”
the connection if there were no exceptions or rollback if there were and
closes the connection in a finally block. Simple?&lt;/p&gt;

&lt;p&gt;Now that you know what are ThreadLocals, Here is a snippet how to use
ThreadLocals. You can download a source code of Transaction.java over
here, if you want to have a look at the code.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  //To create a thread local variable
  static ThreadLocal&amp;lt;Connection&amp;gt; threadLocal
                          = new ThreadLocal&amp;lt;Connection&amp;gt;(); 

  //To set the connection object in the init method
  threadLocal.set(con);

  //To get the connection object in the execute method
  Connection con = threadLocal.get();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;..And ofcourse ThreadLocals are not without problems. Threre are some
known performance issues, the code becomes difficult to test and Just
won’t work if your target method is called in another thread.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Kloudo.com – A Fantom Success story</title>
   <link href="http://ksat.me/kloudo-a-fantom-success-story"/>
   <updated>2010-09-21T00:00:00+00:00</updated>
   <id>http://ksat.me/kloudo-a-fantom-success-story</id>
   <content type="html">&lt;h1 id=&quot;kloudocom--a-fantom-success-story&quot;&gt;Kloudo.com – A Fantom Success story&lt;/h1&gt;

&lt;p&gt;Well, You don’t know me. I am sure. So, Hey! I am kaushik. Programmer. I
usually freelance. And this is my first blog.&lt;/p&gt;

&lt;p&gt;Yesterday we launched &lt;a href=&quot;http://www.kloudo.com&quot;&gt;kloudo.com&lt;/a&gt; – A Integrated
business organizer. Obviously I think it’s pretty awesome. That’s not
the point of this post, however.&lt;/p&gt;

&lt;p&gt;What better way to start to blog than by thanking the open source
projects that has helped you to get your things done. I’ve my share of
list to thank. Including Mysql, redis, ngnix and fantom. Yeah
&lt;a href=&quot;http://www.fantom.org&quot;&gt;Fantom&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Kloudo.com was built mostly-completely written on the Fantom programming
language. Ofcourse since its pretty easy to use Java libraries from
inside fantom, I’ve done that too.&lt;/p&gt;

&lt;p&gt;Why Fantom? fantom.org has a &lt;a href=&quot;http://fantom.org/doc/docIntro/WhyFantom.html&quot;&gt;page on
that&lt;/a&gt; .And one more point
they missed over there. The developers(Brian and Andy) are pretty damn
amazing. So is the community. The language is beautiful. APIs are
elegant. Has Actors. Ruby like closures . Runs on JVM. And very
attractive to a Java Programmers.&lt;/p&gt;

&lt;p&gt;So the point of this post, mostly, is to let you know, if you din’t know
already, that Fantom is mature and usable right now. I made an entire
product on it and loved every second programming with it. So will you.
So go give it a try.&lt;/p&gt;

&lt;p&gt;Hopefully, I will write more about my experiences with Fantom.&lt;/p&gt;

&lt;p&gt;And, Andy,Brian, tactics, tcolar, xored and every one else in the Fantom
community, if you are reading this. Thank You! You made my life easier
and fun and so you will for a lot of other people. Love you guys and
will try to contribute back in ways that I can&lt;/p&gt;
</content>
 </entry>
 
 
</feed>