04 11 / 2013


There is an obvious tradeoff between video viewing and bandwidth costs. i.e. The quality of video viewing, and the bandwidth costs increase proportionately with the amount of video buffered by the video player.

This is something, the Youtube team has, most likely, spent a ton of time, thinking about.

The above video seems to be buffered 45 seconds. I tried a bunch of other videos, and also throttled my networks speed. The buffer was, almost always, about 45 seconds. At lower network speeds, (counter-intuitively) the buffer length was shorter. 

Some quick math on what this means for serving costs:

  • Average length of a YouTube video is 4 minutes and 12 seconds.
  • 4 billion video views per day. 
  • i.e 30.42 Trillion minutes, or 266 hours played per day.
  • Per some back-of-the-envelope math (see references), Youtube is saving atleast 15% of their serving costs because of the buffer optimization.


1, 2, 3, 4

14 10 / 2013

I want this.

14 10 / 2013

06 6 / 2013

Don’t even know where to begin! So bizarre, and yet i can’t turn away!


Don’t even know where to begin! So bizarre, and yet i can’t turn away!

04 6 / 2013

This is the YUI way of doing it. YUI has a namespace function.

This is the JQuery way of doing it.

Also read up on…

31 5 / 2013

So, stretching a background image to fill your entire page should be a simple task., but thanks to IE (and users who insist on using IE), it isn’t. 

I’ve looked at quite a few options. the most simple one being 

But most of them fail on IE. So, here is a solution that works for everything, including IE. (thanks Louis-Remy). Checkout the demo

28 5 / 2013


Often, i’m just mucking around with code on github, and unwilling/unprepared to open it to the world. I realize that i could keep my repository private by just paying for a private repository. But i can’t be asked to pay for some of the stuff i have up on Git.

So, long story short, i’ve encrypted my files on Git. Here is a great “transparent” solution for encrypting files on Git. I made one minor modification to it.

Although file content is encrypted, file names and issue lists are still human readable. I think i might have a solution for this (which the margin of this blog is too narrow to contain)

23 5 / 2013

The best reference i’ve found on Git. here

22 5 / 2013

For the last 2 years, i’ve had the marked misfortune of using Maven [1, 2, 3]. To quote kent spilner, “Maven is a horrible implementation of bad ideas”. But underlying the whole Maven vs Ant squabble, lies a deeper question, of whether your code should be explicit or implicit.  Let me explain this with an example, entirely outside of the software development realm.

Lets say you want to make eggs. The old fashioned way of making eggs, say an omelette,  will be

  1. Crack 2 eggs, Whisk them till they turn yellow
  2. Heat a pan
  3. Add butter
  4. Pour eggs into pan, and let heat till it resembles a pancake.

In the process of making an omelette, you have also now familiarized yourself with a few basic tools and techniques of cooking.

  • Cracking an egg
  • Using whisks
  • Using frying pans
  • Flipping omelettes/pancakes 

Each of these techniques, individually is easy to master. When you use them together they can be applied to other recipes scrambled eggs, pancakes, toast, etc. 

This is the “ant” way of doing things. Each individual ant directive is simple. Yet, once you’ve understood them, you can build, package or deploy almost anything. If you write bad ant scripts, things could go horribly wrong. But, no build platform is idiot proof enough to protect against bad engineering.

Maven on the other hand is like a “magic omelette maker”. Insert eggs, salt, butter in the correct order; set dial to “omelette” and you get an omelette. Using an omelette maker, teaches you nothing about the basics of cooking.

But there is another problem. It promises to “just work” and hence requires no deliberate though. So when your omelette does not turn out right, you have no clue as to what to change. And lets face it, no one reads manuals.

In reality, not everyone wants an omelette; not everyone likes their eggs done the same way. IMO, when it comes to cooking, or build scripts or anything else, you are better of learning the basics in small steps, and building upon your skills. 

21 5 / 2013

This is a handy little script that tells you when your DOM has completely loaded. There is lengthy detail about it here and here. But, essentially “DomContentLoaded” fires when your browser has constructed the entire DOM tree, but hasn’t yet finished fetching images, CSS etc.

I’m using this script, with one small exception.

  window._AMITS_ON_LOAD_FUNCTION_ = $;

})( window );
     console.log('DOM is ready');

I’m renaming the function “$” to “_AMITS_ON_LOAD_FUNCTION_”, so that it does not clash with any existing jquery on the page.