January 25, 2013
"A man who becomes conscious of the responsibility he bears toward a human being who affectionately waits for him, or to an unfinished work, will never be able to throw away his life. He knows the “why” for his existence, and will be able to bear almost any “how."

Man’s Search for Meaning

April 29, 2012
Press Esc to exit full screen mode.

This is simply not required. 

And if it is, then it’s safe to hide it after the viewer has watched a couple of full screen videos.

I fail to understand why this is acceptable.

March 4, 2012
"Why keep a dog and bark yourself? Back-seat driving knocks the stuffing out of good creative men; if you do that, God help you."

David Ogilvy (Confessions of an Advertising Man)

March 3, 2012
"I notice increasing reluctance on the part of the marketing executives to use judgement; they are coming to rely far too much on research, and they use it as a drunkard uses a lamp post, for support rather than for illumination."

— David Ogilvy (Confessions of an Advertising Man)

November 20, 2011
Counter Caching Multiple Columns in Rails

Counter caching single columns is an excellent feature in Rails [1]. However, the need to counter cache values from multiple columns occurs frequently in complex real world applications. Let’s explore a non database solution.

Here’s a toy example :


To keep track of all the products in a store we have the products_count column which rails automatically updates because we set :counter_cache => true


Counter caching quickly becomes inadequate if we have to store the total price of all products in a store.  Of course, we can easily implement our own.


Now, suppose we have to keep track of the total price and total count of products in every category in every store. It’s a nightmare to develop and maintain if each value is kept in the database.

Enter caching. I recommend Amazon’s ElastiCache [2] or any implementation of memcached. Though, Rails can cleanly accomodate most caching solutions [3].

But first, make sure you have indexes.


Then, convert counter caches into queries and place them in cache blocks.


And, of course delete cache entries in a product observer.


That’s it. By using cache storage instead of database storage for complex counter caching the code becomes simpler, maintainable and scalable. 

[1] Counter Cache Column (Railscasts)

[2] Amazon ElastiCache

[3] Caching in Rails (Railscasts)

November 13, 2011
"What is interesting is that ancient Mediterraneans may have understood the trade-off very well and may have accepted religion partly as a tool to tame the illusion of control."

— The Black Swan (Nassim Nicholas Taleb)

October 29, 2011
Can Do Much Better

The past is hard to escape and impossible to change but nevertheless, thought provoking.

One of the best memories of school was walking back home after getting a good score on a test, knowing it’ll make my parents happy. Sharing good news still makes me happier than the news itself. Though, beyond a few bright sparks I was consistently above average but never the best. 

I remember my year end report cards saying, rather tersely, “Siddharth has potential and can do much more” or simply “Can do much better.” 

The feeling of not being good enough has stuck with me.

Over the years, I understood, how powerful this feeling is. It doesn’t result in the best of sleep but it means never being complacent about your abilities.

Not feeling good enough is a part of who I am and so even today when I look into a mirror, all I can think of is - “Can do much better.

8:10pm
(View comments
Filed under: life 
December 27, 2010
"Well, every man has a religion; has something in heaven or earth which he will give up everything else for—something which absorbs him—which may be regarded by others as being useless—yet it is his dream, it is his lodestar, it is his master. That, whatever it is, seized upon me, made me its servant, slave—induced me to set aside the other ambitions—a trail of glory in the heavens, which I followed, followed with a full heart… . When once I am convinced, I never let go …"

Walt Whitman

12:43am
(View comments
Filed under: quotes 
October 27, 2010
"I think there comes a time when a man has to ask himself, whether he wants a life of happiness or a life of meaning…To be truly happy a man must live, absolutely in the present, no thought of what’s gone before, and no thought of what lies ahead; but, a life of meaning, a man is condemned to wallow in the past, and obsess, about the future."

— Mr. Linderman (Heroes)

12:17am
(View comments
Filed under: quotes 
Liked posts on Tumblr: More liked posts »