The happiest man alive!

I had once read about a man who was celebrated as the happiest man alive. I was intrigued, how dd they decide it? What was the metric ?
Upon reading ore about the man, I discovered that he was suffering from a neurological disorder (i can’t pronounce or write the name of the disease as its super complex). I was shocked. So they claim that the happiest man alive is a man with a sick mind?
Upon further investigation, I figured that his actual problem was his mind was not able to comprehend that visual information it received. In short, he did not understand what he saw. Interestingly, one of the effect was that he was not able to recognise faces! But he was not mad so his mind, upon observing further details like a peculiarity on a face or voice of the person was able to recognise who the person was but never did his mind see the face of the person.
I felt interested as it was all very cool sounding but I still did not understand why was he the happiest man. I mean here is a man who cannot recognise his wife when he looked at her and he was the happiest man? But finally, I figured that the real problem was that he was fundamentally a machine. He felt no emotion when he saw his wife because he never saw!!! He recognised her when she spoke but he never saw. He can see the red color of the rose but never can exclaim at its beauty. He was a living machine with absolutely no emotions.

I felt terrible but still, why the happiest man? the answer was stunning, Here was a man who has lost emotions and cannot perceive faces,but he did not know it. He never knew that his eyesight or mind has as issue. He had lost so much that he failed to realise what he lost!! So he felt no regrets , no remorse and was super happy ever!!!
The happiest man alive!

Rails issues with Spring

So, I have been merrily using foreman in my development environment and have been very happy using the environment variables.
So recently I created a new rails project and followed the same mundane procedure and when I did the coveted

foreman start

it started working just fine and life went on!

Suddenly, I felt the urge to check something in the rails console and I called my friend

foreman run rails c

and it loaded. But when I queried, it gave me an error saying

"Permission denied for relation..."

After a bit of googling and a lot of swearing and cursing, I was filled with frustration as I had no clue what’s happening. Then, I realized that rails console was trying to access the DB not using the env variables I had set but using the default postgres user! Elementary, wasn’t it?
But the this was a shocker as I had no idea what to do now. I was almost ready to go to the church for solving this issue when spring came in my life! Not the season but the preloader gem which is now a default in rails.
As soon as I disabled spring using

spring stop

my rails console started working like before and life was happy again!

The correct way of solving the issue however is to create a `’config/spring.rb` file with contents

` '.env'`.

Hope it helps!

Rails 4 authenticy token issue


Recently I was working on a simple rails application (Rails 4) and I create a simple remote form for a model.

Things were fine but when I submit the form using javascript, it gave me an authenticity token error:


I read up(googled) a bit and figured that one has to set crsf_meta_tags in layout and not doing this creates the issue. I thought I had missed it somehow but to my dismay it was there but still I had the issue !

The problem was that in normal forms(remote => false) , rails automatically sets the authenticity token but not so in remote forms. Now there can be many work arounds like suggested here.

But the most rails way ! of doing it is adding the following in application.rb:

config.action_view.embed_authenticity_token_in_remote_forms = true

Once you restart your server, voila ! it will work.

A good reading can be found here

Hope it helps !

Keypress vs keydown in jquery

In todays web world, forms and input bars are very important. We all use searching and filtering in our applications. The easiest and obvious way to do this while using JS(jquery) is binding key events to the search bar.

The event I usually bound was ‘keypress’. This is fine and works good. But the actual meaning of keypress , in its original form in IE world (!!!!!) is the event which actually adds some value in the input field. Some keys like backspace, delete, clt etc do not add any value and hence are not detected by keypress event.

These are important keys as often in filtering when the input field is empty, we might want to show all results. The user might type some query and delete it and hence detection of such keys is important.

To avoid such confusion, one should always use keydown or keyup events. These events detect events where any key is pressed and one can use e.which to determine what key is pressed and perform action.


I personally like keyup becuase keydown event is called just after pressing the key and hence value of input field lags one character behind the actual input.


Hope it helps !

I have a question !!!

I of-course know the fact how unfortunate I am. It is something I do not think I can change. Its a quality I have , like my blood group !  Cannot do anything about it.  Do I regret it ? …

I clearly remember the precise moment when I realized the exact nature of of my misfortune. I was told the unfortunate news in front of the world ! Ofcourse, its my humble duty and desire to inform the user that world for me at that time was the class I was studying in. Admitted in a reputed university, I was merry making in the cold weather of this glorious and wonderful city.The lecture hall location in the university, I promise were built by a student as the view was impeccably astounding. Breathtaking I must say ! The glorious mountains stood on one side of the building and on the other side, was a vast and deep ocean. As enigmatic was its nature, it was mystifying. Who knew , what ,lies beneath the deep fathoms of the water body. I was wondering , the same thing as how the mountains must have risen and these enigma of the ocean , we see everyday ,created.

On this precise moment, a stern, knowledgeable  voice fell on my ear. He asked “Do you agree?” . As human instincts are, and more on work here were the student instincts and I gave the most obvious answer “yes…ofcourse sir”, fearful, that if I said otherwise, I have to answer many more questions !

But as brilliant these highly developed , all knowing beings called “teachers” are , they , like the elves , know whats in the subjects mind. So, this voice (more sarcastic than stern now), enquired in a very curious tone, “why so ?”( I wish teachers saw some movies, they would know how to act curious !). Having no clue what to say,I found myself doing the most polite and thinking voice acting I can  , and saying “because the book says so”. I think I mist have surpassed “tom and jerry” in making my audience laugh their hearts out ! I suddenly found myself, in the vast and luxurious office of the man having the stern voice and heard him “son , you are a good guy. But unfortunately, I do not find you curious for knowledge. To gain knowledge, one has to ask questions. Never take anything at face value. Ask whether what the author says, makes sense ?”. I was inspired ! I truly was. And that moment, in that office, I was a changed man ! I was a inquisitive person now.

I went home. Like my habit of many years, I started watching cartoon(yes, i love them!) and to my delight, tom and jerry was being aired. I , usually laughed and had a great time watching this show , till today. I asked myself, can a cat fly an aeroplane ? Can a mouse build a bed of matchstick ? Holy crap! Can a mouse and cat walk on 2 legs and smile and own flats ? Can there be a city where cats stay in hotels ? Frankly, It made no sense and I switched it off ! Worst meal in years for me !!!

I ofcourse had no intention of reading my favorite books as I had anticipated the questions my newly reformed, inquisitive brain would ask. Superman, how is the discovery of a planet possible. Aliens with super powers ,  na, current science does not approve of it. Similar cases with Batman, arabian nights and all other books and stories I loved ! Even the great Tolkien was not able to answer my questions like how can a wizard live forever and where are the hobbits now.

So, I thought about watching some movies. I saw some “philosophically heavy” movies. I had assumed that atleast Shakespeare wont disappoint  me. But alas! Richard , the third, never provides the answer to as how can a mother hate her own child, however he is. How can a hump back impress a beautiful lady and how the hell he can do his corrupt things without anyone knowing ?

Atlast, I went to my granny. I told her, I cannot sleep and tell me a story , as you did when I was a child, so I can sleep. She readily started,”once upon a time, there was a king”. I stopped and asked her, who was this king, where was he born,  where and how many years he reigned , how many queens she had, how was the political situation in his kingdom ? Needless to say, I was thrown out of the room !

Next day, I  was in the class of the same stern voiced “teacher”. He was teaching us mathematics and I interrupted him as asked “why is the number one written as 1 ?”. I can clearly see his puzzled face (with linearly growing anger and irritation!). But I never got an answer.

Years have passed since and I have never got an answer to any of the above question. But I have the answer to one thing. Sometimes, not asking question and believing the person is helpful and enjoyable. We all enjoy the fairy tales and cartoons without asking questions. Try asking and see how it ruins the show !

I personally think, knowledge is not about knowing the right answer but the is about believing. Understanding. Asking questions and gaining answer will only add to information we have. Believing the thing and enjoying it will give us happiness, enjoyment, satisfaction. Knowing this is what knowledge is. We often confuse knowledge with curiosity and feel , if all our questions are answered, I will be knowledgeable.

Sometimes, the most knowledgeable are the ones who know nothing !


Resetting a Database in Heroku application

Recently I faced an issue when  I wanted to delete an existing database in an application deployed in heroku and create a new one.

I tried using

heroku run rake db:drop


I got an error saying “USER does not have connect privilidges”

The way to solve it is

heroku pg:psql

This logs in to your database and then type:

drop schema public cascade;
create schema public;

After this exit the prompt and type:

heroku rake db:migrate:reset

Hope it helps.


Install apache web server and passenger on Ubuntu 11.04(Natty)

I just Installed apache and passenger on Ubuntu 11.04 to run and deploy my ruby on rails applications Passenger is a gem and can work with apache as well as nginx…

The reason for choosing apache is that its an industry standard.

Also one thing I did with apache was created virtual hosts and ran my apps on local machine with domains like

In this post I will list the steps I followed in order to setup apache web server and passenger.

Here is my stack:

  •  Ubuntu 11.04
  •  ruby 1.9.2 via rvm
  •  rubygems 1.8.10

I will be using rails 3.1.10(lastest this morning).!!

So lets start !!

  • Install rvm

To install rvm just type the following in the terminal(ctrl+alt+t)

 user$ bash < <(curl -s )

You can find more information about rvm on Here

  • Install ruby via rvm

Once rvm is installed you can install the latest or desired version of ruby by typing the following in terminal

rvm install 1.9.2

This will install ruby 1.9.2 on your system.

More information on how to make it your default ruby is available on here

  • Install rails.

just need to do

gem install rails

  • Install passenger

just do

gem install passenger

  • Install apache web server.

To install apache web server type:

sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev
  • Install passenger apache module.

Once this is done, we must install passenger , an apache module thats hepls us to rub rails apps on apache.

sudo passenger-install-apache2-module
  • Configure.

Finally everything is done.

When you run the passenger apache module, there would be some instructions that installer will give you.

The last thing it will tell is to paste some text in apache configuration file

The configuration file is located at /etc/apache2/apache2.conf

Now once this is done, we are ready to deploy.

This has a lot of information about deploying.

In my next post, I will show how to start rails apps on local machine with apache.

Hope it helps.!

A candid interview with Society !!

It feels so great !!! Amitabh bachchan in Hindi movies or clint eastwood in the 70s and 80s revolting against a society !!!

Wow, I hope I can be such a hero too ! Speak dialogues in front of an idol like vijay or fire a gun like eastwood does !!

Was it only the greatness of Salim-Javed and sergio leone( not related to sunny leone i presume!!) or we need such rebellions ??

I think like our economy , our society and our value system is at an all time low !!! We are  in midst of a moral recession.

Look in the mirror ! What are we doing ? Where are we headed ? Whats our objective ? whats with us ?? This is what I felt.

So, I decided to take an interview of the society on four basic factions of life. Childhood, youth, parents and old age. Here are the views of society on these factions in a summary:

We first talk about childhood. O ! childhood is an age of innocence. It is that period of life when everything is so beautiful. What are your views ?

O yes, child hood is a great phase of life. Probably the greatest. Now, what I do with childhood is very simple. For me , childhood is not a phase, to enjoy, childhood is a phase where I can impart value system in that small brain , or thats what people call that first floor of humans. I impart the knowledge like we believe in only a particular god. The choice of god varies depending on my wish. If I am Christian, I say, jesus is the true god and others are not. If I am a hindu, I say Shiv or Krishna is a true god nothing else. If I am islamic, I say Allah is path to salvation and nothing else. So I impart this invaluable knowledge to them. See, I am doing this for them . I am training them to fight for rest of their lives. If this is not taught, how will they fight ? What will they do ? Then I also somehow manage to convince them that the scriptures are very very true. They are very literal and you have to believe in miracles. That actually easy as they do not much about science at that time and to tell you a secret, I also tell them that of they ever ask me a question, they will be punished !! Isnt it cool ?  Then, I send them to school ! There I give information and tell them that this is knowledge. Those poor little beings believe it !! They actually think school and college is a place where they get knowledge. This is a greatest failure of knowledge isnt it ?? (hehe). Then when they say they have gained knowledge , I ask, how do I know. Prove it by getting good grades in the exams. Memory is the path way of knowledge for them and this I think is a very innovative idea by me. This is imparted in the human brain and is executed through out. Humans, stupid humans actually believe that intelligence is knowing things. In IO test, they ask some questions regarding who was who and who did what and when etc ! And they test their intelligence !!! (Hahahahahahha). Anyways, then is gradually expose them to outside world. I show them movies, give them books etc. I show them shows like “mahabharat” or “jesus story” and tell them television is true. But this has a side effect, when they see things like “original sin”, “ma mere” or “munni badnam” and “sheila jawan”, I scold them. I say thats not what you should learn. Though I allow the makers to make it and elders to watch it, but not for children.Some say what is does is confuses a childs mind, but I say, no, the only rule is follow my rules without question !! Thus, in childhood, I impart qualities like competition, rivalry, winning spirit and also gifts. I give gifts when you are successful and punish when you fail !!!

Then comes youth. Another good phase. Human at his/her prime in the life. Full of energy and enthusiam ! What about it.?

Well, yes, youth is a good stage. Its a good platform to teach advanced things now. Now, in this stage, I introduce them to money. I give them money but  not the permission to spend it. So, they are confused. Then I tell them whats good and whats bad without reasoning ! I say, drugs are bad. Not why are they bad. Ofcourse, as god has made humans curious , they wanna know why are drugs bad and hence consume it. Thats it, as soon as they consume it, I proclaim them as sinners. I punish them and I isolate them. The result, they take more drugs. And computer scientists thought recursion is their invention !!! Then for someone who has escaped this devious and brilliant plot, I surely trap them in marriage. See, I am a humanitarian, I allow you to love. But, as usual, the catch is you cant marry the person you love. There are things like cast and creed that I have to take care of. And then, I fill the human mind with the root cause of all troubles. “Expectations”. I teach them to expect from the person they wanna marry.I teach them:

We are the invincible ones. We are the most popular ones.Each and everyone needs us you see.But ofcourse, we are also humans and we have our requirements. We look into some basic qualities in our partner. Common, they are not very difficult. We are good people you see. All we expect is that the partner should be good looking. Have a good figure/physique. They should have style you see. We need it as when we introduce them to our friends, our style and status should be maintained. He/she should know how to behave in a 5 star hotel and  should know how to speak in english full of accent, How to drink wine and how to hold hands and dance in a party. He/she should like my friends and appreciate my habits. Even If I smoke, He/she should not. Even If I flirt with someone else, he/she should be faithful. Even if I do not give a damn about my parents, he/she should. Even If I courier her/him a gift, he she should be happy ! Thats all we ask for. Nothing more. And ya, ofcourse, they should not be married before. You see we need “fresh” people. And ofcourse, I many cultures, marrying a divorcee or widow is a crime. And kinda Post script: Their fathers must be rich. They should be able to fulfill our dreams ! I dream of buying a car and since I am a divine being, he should full-fill it as a duty !! Thats all, see how nice we are !!

See, isnt it good ?? Isnt it correct ?? I know I am a master, I can make it from your expression kid !!!

Then comes parenthood. gift of god! A birth of human life. How do you deal with that.

I start by seeing them cry. They cry when in the hospital, they hear the crying of the baby. But, for me , its an important phase. I start early. I say, if the baby is a girl, then you ought to cry you idiot ! How can you do this. Girls , I somehow manage to convince the people , are not creation of god. The idiots believe me.  They know their mother is a girl still in many times and cultures I have convinced man to kill girl !! I love it.  But I do not stop there.  Then there is a simple course for parents. Thats actually a result of what I thought in childhood. Rivalry, competition etc. Now the concepts are applied to children. The average guy is always told “learn from your brother/sister”. Isnt it ?? Now, I dont see anything wrong in it ! Ofcourse, studies and grades are everything ! People not good at studies or those who do not get good grades should understand that they have a responsibilities toward their parents ! What will their parents say to the relatives and neighbours ?? What do they talk if you do not top or you do not win a trophy on your sports day ??  ow will they say ” see this is my sons certificate” with a proud laugh on their face and a hidden feeling a achievement as the relatives son stood second !! Guys , we have to understand that world war 3 is all parallel ! Each house and family has its own version of world war 3 !!! Common, you cant be average !!   But what do we actually learn in school, college ? Its just information anyways. Knowledge is long lost when we used memory to test intelligence. How great of me that we expect our students to understand information !! One may ask how do you understand that a flight AI-103 is going from Bombay to London !! Isnt it same as teacher after teaching a chapter on Gandhi asks “Understood ” ???? Today I care more about translation of gita rather than understanding it !!

Then comes old age ! Probably the most difficult phase of life.

All traditions and religions in the world say we should respect our elders ! So I do. We make better old age homes ! I give them better facilities. I give them a garden to have an evening walk with those artistic looking sticks I gave them as birthday present and those arthritis inflicted legs which nature gave them. I give them library. Books to read with those armani glasses I  gave them and those eyes that cant see clearly which nature gave them. I give them cozy beds and heaters or Air conditioner so they can sleep properly forgetting that only closing eyes is not sleeping. I give them smart phones to stay in touch ! So they can contact us when in need ! Knowing that those shaking hands cannot dial or remember the number !! We give them good medical facilities so they do not feel any pain. I give them medicines  as their blood pressure increases when going to a doctor. They say, they need their children. Are they mad ? They are  busy ,they have a meeting to attend otherwise their company would go bankrupt. they have their car to be serviced,  they have wine to be purchased, they have extra language classes to attend, they have gym to go , they have to go to the temple or church for worship ! They are  so so busy! common, tell oldies to handle themselves. And then they say, all we need is your smile and I say, na I cant, I have to mourn for a train accident victim you see !. All they ask is can you spend one hour on a sunday and I say no,I have to go for mass and feed the homeless !! The old people must understand, I dont have time for their stupid emotions. I will talk to you only if the talking helps my bank balance in any way ! I do this much for them , be content with what you get. You get free money. What else do you need ??

Mr. Society, Arent you afraid of god ?

God ? Hahaha, tell me whats god? How did you came to know about the concept of god ? Its through me child. I created god. And god, where is he ? Can he do anything ? I am the one who stays with you everyday, every minute !! I am the one with you, always. I have been with you for ages and I will be with you forever. I am a parasite which eats you, which consumes you and you do not have a medicine for me. You cannot harm me. You cant live without me you see. After all, you are a social animal !!!

The Mayans said that world will end in 2012. While factually incorrect, I suppose they understood the parasite I am talking about.

A cancer, my interviewer friend kills you. I on the other hand give you life. Its true that I have now grown so so strong that living with a parasite like me is more difficult than getting killed by a cancer !!

Compiling a LaTeX Document.

So having prepared your first tex document I was pretty excited to see the out put. But there was one daunting question !!
Whats the next step ??

Fortunately , I was using KILE so I got my PDF in a click but I wanted to figure out how get the same pdf using command line.
So here is the procedure to do the same:



Suppose the file ``my_report.tex” is the file that contains all the author’s work, i.e., her actual typed words and formulae. It was typed using the text editor vi. Similar text editors include emacs, pico, Notepad (in Windows), and TextEdit (on Macs).

First navigate to the place where the tex file is located using terminal.

Then run the command:

latex my_report.tex

This produces a bunch of files. One of them would be my_report.dvi.
The dvi stands for “device independent”.

The file my_report.dvi is the same regardless of

(1) which computer is used to compile the document,

(2) what kind of printer it is headed for.

In fact, it is too universal to be printed in this form; it must still be translated to a form suitable for a specific kind of printer. (Different printers speak different languages…) You can’t even view the DVI file unless you use a special “DVI Viewer”, such as xdvi on ucsub.


The files“my_report.aux” and  “my_reoprt.log” are two by-products of the compiling command.
The aux file is used if the document contains more complicated stuff, like bibliography and cross-references.

The log file contains a full record of the compilation, including errors you need to correct, e.g., misspelled macros, missing bracket or parenthesis, missing references, etc.



The file “”, a PostScript file, the kind understood by most laser printers.
A printable PostScript file is created from the dvi file by the translating program dvips. On computer run the command

dvips my_report.dvi



The file ``my_report.pdf” is the PDF form of the document.
This is as web-friendly a document as possible. Using Acrobat Reader, any computer can be used to view the document and/or print it. On computer run the command the command

dvipdfm my_report.dvi

translated the DVI file to PDF form.


Thats it !!


Hope it helps. !!