Learn | Explore | Share | Challenge Yourself | Enjoy | Make This World Beautiful Place To Live For Everyone|

Slow down .. its okay

I’ve been longing to write this piece for me .. yes, you heard me right, for ME. This is a post to remind myself again and again to slow down, to breathe. Because I am one of the guy, who is obsessed with speed. And if you can resonate with it. This is for you as well. Remember I include you when I say ‘we’.

Why? why we want everything to be quicker, more efficient and more productive. We rush and cram things just to accomplish more in a day. But what happens instead is you (atleast I) lose sanity over time. Our culture of urgency needs some sedative.

If you are in the midst of losing your mind. Your work is driving you crazy. Go relax, take a chill-pill. This is not fatal. Give yourself some break. Look around. Listen to birds chirping. Reflect. Appreciate. Show gratitude. Look back, remember how strong have you been. Nothing is fatal but worry. Slow down and make mindful plan B, in the end you will be sorted. Good luck!




Insertion sort in Javascript

These days, i am on spree to dive deep into javascript. As this is the exciting time for Javascript and it is finally getting accepted as full-fledged language, i thought to explore it at low level. How its basic predefined functions work. So i thought why not implement basic data structures and algorithms in javascript.

I’ll start with Sorting algorithms and first in the series is Insertion sort. Read more about insertion sort here.

Fun fact: The javascript V8 engine, virtual machine for Chrome browser uses Insertion sort for sorting objects with less than 23 elements and for more than that it uses Quick sort.

Note: Insertion sort performs well for sorting array with small number of elements.
Complexity: O(n*n) — worst case

function insertionSort(arrayOfNumbers){
	for(var i = 1; i < arrayOfNumbers.length; i++){

		var temp = arrayOfNumbers[i];

		var j = i-1;

		while(arrayOfNumbers[j] > temp && j >= 0){

			arrayOfNumbers[j+1] = arrayOfNumbers[j];

		arrayOfNumbers[j+1] = temp;

Things i learned … the hard way

1. Life is not fair.

Believe me, you’ll be knocked down on your face, several times. Choose to dust yourself up. keep moving. You are not the only one, life f**ks us all. Some come out strong, some choose to blame. who you want to be?

Don’t try to get mercy. Stand up. Walk to rule the world.

2. No one cares about you.

Trust me. The world won’t care about your self-esteem. The world will expect you to accomplish something BEFORE you feel good about yourself. It is you, who you should depend on.

Invest in yourself. Prove it you matter.

3. Stand up for yourself.

This was hardest. Why it is that we stop loving ourself. Learn to stand up for yourself and what you believe in. It is important for your being. You are important to yourself. Don’t eat yourself away, by demeaning your Self.

Love yourself. Love should come naturally. Start with yourself.

4. Small is Great.

Does magic. Think of your next big goal – the whole thing, all at once. What happens to you sanity?. Instead Start small. Do it everyday little by little. There are no shortcuts for being awesome and sane. small will become big one day. Believe that.

Advice to my younger college mates …

This was the advice i gave to some of my college mates who were struggling to get started with computer science and be placed in a startup. This is what i wrote to them …

I was a non-programmer and turned myself into one. It was hard but not impossible. During that phase i learned one thing ‘how to learn’. I tried numerous ways to teach myself. I can say one thing for sure. ANYTHING CAN BE LEARNED.
I call you people to do the same. Stop bothering about placements for sometime and instead focus on polishing your skills. Whatever your dream job be, its a skill market now, skills will earn you respect as well as money.

So my way is little bit twisted and I have a PLAN for you all .

But this plan will work for those who are determined enough to execute it honestly.

Before i tell you the plan, if you aspire to do MBA or IAS or anything NON-CS , don’t feel guilty of not doing justice to your major, just trust your gut and if you feel that MBA or IAS is for you. Go for it. Commit to it. Stop worrying about placement. There is nothing like backup plan.

My plan is for CS and its simple:

1. Build 2 small apps (full blown apps) every month, for 4 months which makes it to 8 apps. 15 days a app. i repeat SMALL WORKING APPS.

2. Do not focus on building a ‘million dollar idea’. Just focus on building any app like twitter clone, small chat app or anything which exist in the market and you love it. Idea here is to explore your P-Creativity. Believe it does wonders.

3. Apps can be any web apps, mobile apps or desktop app, whatever you like. And in any language i.e Java, PHP, C, C++, C#, PYTHON, JAVASCRIPT, NODEJS and any Database MYSQL, MONGODB, ORACLE, POSTGRES, CASSANDRA etc. Catch is to build anything which makes you learn a concept and overcome your hesitation of creating.

In case of web app, try free web hosting site and host them.

4. Embrace the Internet, the most Democraticized system ever created. A laptop and a decent internet connection can change everything, you just need a curious mind. Use it for inspiration for building apps and find numerous tutorials.

5. Include a sport activity in your daily routine. Trust me … will calm you.

6. Meanwhile, make a crisp resume and prepare a impressive cover letter. It will be good if you make your online portfolio. Portfolio can be one of your app.

7. Make a spreadsheet of companies you want to apply to. Include email id, contact name, company and DO NOT APPLY before 4 months. Just keep filling your spreadsheet with the names of startups you come across.

8. Brush up your Data structures and Algorithm concepts on daily basis, one by one.

9. After 4 months, dump all your app to Github or you can start committing your code as you start. Include all links in your cover letter.

10. AND APPLY TO ALL COMPANIES in your spredsheet .. atleast to 30-40 companies. Research properly about each company before applying and remember to modify your cover letter accordingly.

Thats it.

In 99% case , you’ll land a job respectfully but in case you do not. Believe me, sense of able to build something will change a lot in you.

The gap b/w taste and skill …

Believe me it is the most inspiring piece of work, for the people who are trying to be the Best. I watched it over and over again. If you are a hustler, you’ll fall in love with the process of building your creative genius, from novice to expert. Hustle  more, do lot of work … close the gap. Thank you Ira Glass, for telling learners, which nobody else does.


Power of data…

I saw this  ted talk a year back and i was amazed with the possibilities data provide us to explore. I have never seen such kind of presentation of data. I was like ‘amazing amazing amazing’.  I suppose that is why people call him statistics guru, hats off to you sir Hans Rosling, you are an inspiration.



Why, How, What…

I believe these are the most important three words which can effect our approach towards product development. If you can answer them, they can make process of building anything purposeful. This is my take on it, you can have yours.

Simon Sinek  explains it with golden circle. I simply love the idea.

Automate Backup of MongoDB.

I work with MongoDB  in day today basis and one of the challenge is taking backup of different DB’s deployed. Taking backup is important for recovery in case of  mishap. Mostly there are enormous write operations and database size keeps growing so the chances of failure. Initially we started to do this manually which was okay till we had limited traffic but as  registration and engagement increased so we started looking for automating this process. Cron job scheduler in Linux and Amazon S3 came to the rescue. 


  • MongoDB 2.33 or higher deployed on Linux Environment.
  • Amazon S3 account to store all backup data.


Tools Required(or their alternatives):

  • S3cmd – S3cmd is a free command line tool and client for uploading, retrieving and managing data in Amazon S3.
  • Linux Cron utility
  • Mongodump utility provided by MongoDB
  • Tar archiving utility– GNU version.
  • Command Line Interpretor(CLI).


Installation and Configuration of S3cmd:

  1. Run to install in CLI or Shell
    sudo su
    sudo yum –enablerepo epel install s3cmd
  2. configure
    s3cmd –configure
  3. Display all buckets in your Amazon S3 account
    s3cmd ls


Writing a Shell Script to Backup MongoDB:

  1. Force file syncronization and lock writes on MongoDB using fsync
    mongo admin –eval “printjson(db.fsyncLock())”
  2. Declare some variables
    TIMESTAMP=`date +%F-%H%M` // use as it is. S3_BUCKET_NAME=”name-of-s3-bucket”
  3. Take mongoDB dump using mongodump utility
  4. Unlock database writes
    mongo admin –eval “printjson(db.fsyncUnlock())”
  5. Add timestamp to backup folder name
    mv dump mongodb-$HOSTNAME-$TIMESTAMP
  6. Compress the folder
    tar cf mongodb-$HOSTNAME-$TIMESTAMP.tar mongodb-$HOSTNAME-$TIMESTAMP
  7. Upload to S3
    /usr/local/bin/s3cmd put mongodb-$HOSTNAME-$TIMESTAMP.tar s3://$S3_BUCKET_NAME/$S3_BUCKET_PATH/mongodb-$HOSTNAME-$TIMESTAMP.tar
  8. Delete local dump folder
    /bin/rm -r mongodb-$HOSTNAME-* // to delete all use *

Find full bash script here


Run this script at a particular time using crontab

If You Can…

Here is a poem which is very close to my heart and usually i get scarce with words to describe its power, its charm. Effect it had on me when i first read it, I cried. Ya its weird:P but beauty often brings tears of fulfillment and satisfaction. Having read this poem, i thought life can be lived as a warrior, not with sword, but with self mastery.

Hats off for Rudyard Kipling—–

If you can keep your head when all about you
Are losing theirs and blaming it on you;
If you can trust yourself when all men doubt you,
But make allowance for their doubting too:
If you can wait and not be tired by waiting,
Or, being lied about, don’t deal in lies,
Or being hated don’t give way to hating,
And yet don’t look too good, nor talk too wise;

If you can dream—and not make dreams your master;
If you can think—and not make thoughts your aim,
If you can meet with Triumph and Disaster
And treat those two impostors just the same:.
If you can bear to hear the truth you’ve spoken
Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to, broken,
And stoop and build’em up with worn-out tools;

If you can make one heap of all your winnings
And risk it on one turn of pitch-and-toss,
And lose, and start again at your beginnings,
And never breathe a word about your loss:
If you can force your heart and nerve and sinew
To serve your turn long after they are gone,
And so hold on when there is nothing in you
Except the Will which says to them: “Hold on!”

If you can talk with crowds and keep your virtue,
Or walk with Kings—nor lose the common touch,
If neither foes nor loving friends can hurt you,
If all men count with you, but none too much:
If you can fill the unforgiving minute
With sixty seconds’ worth of distance run,
Yours is the Earth and everything that’s in it,
And—which is more—you’ll be a Man, my son!

Zuckerberg, The Hacker

As Facebook gears for IPO, filed on 1st feb, 2012 to raise $5 billion in an initial public offering. CEO Mark Zuckerberg offered a letter to potential investers. Values and mission statement of facebook are worth eyeing on. Money should be treated as side-effect not as the ultimate goal. When you strive for changing something or making an impact, everything else follows. This is what facebook, stands on.

Here is a snippet from the letter which i loved:

The Hacker’s Way

As part of building a strong company, we work hard at making Facebook the best place for great people to have a big impact on the world and learn from other great people. We have cultivated a unique culture and management approach that we call the Hacker Way.

The word “hacker” has an unfairly negative connotation from being portrayed in the media as people who break into computers. In reality, hacking just means building something quickly or testing the boundaries of what can be done. Like most things, it can be used for good or bad, but the vast majority of hackers I’ve met tend to be idealistic people who want to have a positive impact on the world.

The Hacker Way is an approach to building that involves continuous improvement and iteration. Hackers believe that something can always be better, and that nothing is ever complete. They just have to go fix it — often in the face of people who say it’s impossible or are content with the status quo.

Hackers try to build the best services over the long term by quickly releasing and learning from smaller iterations rather than trying to get everything right all at once. To support this, we have built a testing framework that at any given time can try out thousands of versions of Facebook. We have the words “Done is better than perfect” painted on our walls to remind ourselves to always keep shipping.

Hacking is also an inherently hands-on and active discipline. Instead of debating for days whether a new idea is possible or what the best way to build something is, hackers would rather just prototype something and see what works. There’s a hacker mantra that you’ll hear a lot around Facebook offices: “Code wins arguments.”

Hacker culture is also extremely open and meritocratic. Hackers believe that the best idea and implementation should always win — not the person who is best at lobbying for an idea or the person who manages the most people.

To encourage this approach, every few months we have a hackathon, where everyone builds prototypes for new ideas they have. At the end, the whole team gets together and looks at everything that has been built. Many of our most successful products came out of hackathons, including Timeline, chat, video, our mobile development framework and some of our most important infrastructure like the HipHop compiler.

To make sure all our engineers share this approach, we require all new engineers — even managers whose primary job will not be to write code — to go through a program called Bootcamp where they learn our codebase, our tools and our approach. There are a lot of folks in the industry who manage engineers and don’t want to code themselves, but the type of hands-on people we’re looking for are willing and able to go through Bootcamp.

To read full letter, download below doc:

Post Navigation