Postgres Error On Heroku

Recently, I ran into an error while deploying an application(redmine to be specific) on heroku.
I followed all steps listed on the wiki page, remove the required files from gitignore etc but when I did git push, I kept on getting the error:

Please configure your config/database.yml first
remote: rake aborted!
remote: URI::InvalidURIError: bad URI(is not URI?): ://user:pass@

Since Heroku generates database.yml file itself, I had no clue what to do.
So in the gemfile, I deleted the following block:
# database_file = File.join(File.dirname(__FILE__), "config/database.yml")
# if File.exist?(database_file)
# database_config = YAML::load(
# adapters = {|c| c['adapter']}.compact.uniq
# if adapters.any?
# adapters.each do |adapter|
# case adapter
# when 'mysql2'
# gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw, :x64_mingw]
# gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
# when 'mysql'
# gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
# when /postgresql/
# gem "pg", "~> 0.17.1", :platforms => [:mri, :mingw, :x64_mingw]
# gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
# when /sqlite3/
# gem "sqlite3", :platforms => [:mri, :mingw, :x64_mingw]
# gem "jdbc-sqlite3", "< 3.8", :platforms => :jruby
# gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
# when /sqlserver/
# gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw, :x64_mingw]
# gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw]
# else
# warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
# end
# end
# else
# warn("No adapter found in config/database.yml, please configure it first")
# end
# else
# warn("Please configure your config/database.yml first")
# end

and added

group :production do
# gems specifically for Heroku go here
gem "pg", ">= 0.11.0"

Also in config/environments/production.rb,I added the following line:

config.assets.initialize_on_precompile = false

Once I pushed, the above error went away but I got the following error:

Running: rake assets:precompile
remote: rake aborted!
remote: PG::ConnectionBad: could not connect to server: Connection refused
remote: Is the server running on host "" and accepting

The problem here was I didn’t pre-provision my database before pushing to heroku.

So solve this, one can run the command:

heroku addons:create heroku-postgresql

So know about the issue, one can always use:

heroku config

Before running the command, heroku config, returned DATABASE_URL as blank and that was the issue.

Hope it helps !!

Modifying the “PATH” variable in MAC

This is probably the most important thing one can do in a UNIX based system- Modify the PATH variable.

I recently installed Libreoffice on my mac for using its command line tools. It was working fine in the applications folder and showing up on spotlight as well as dock but the command line tool was not working

After some time , I figured that in Linux, I used “libreoffice ….” but in Mac I had to use “soffice…”. soffice command was not directly available to me on terminal and I had to specify the whole path to use it:

/Applications/ –help

To use soffice without the whole path, I modified my PATH variable :

nano ~/.bash_profile

(create this file using touch ~/.bash_profile if your system doesn’t have one!!)

Include the lines:

export PATH=”/Applications/$PATH”

Save it and enter the command:

source ~/.bash_profile

And wallah ! The Path variable is modified and we can now use soffice directly in command line.

soffice –help

This way, we can include any application in command line.

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 !

WiFi issues on Ubuntu 12.04

Hey ,

Recently installed ubuntu 12.04 on a fresh and clean system. While it works like a charm, a very irritating issue was that the inbuilt wireless card was not working. The ethernet connection using wire worked fine. Googled a lot and wasnt able to figure things out. Finally, backports saved my day. Here is the procedure I followed incase someone finds it useful.


Installing backports:

sudo apt-get install  linux-backports-modules-cw-3.8-precise-generic 

Some generic headers and libraries:

sudo apt-get install linux-headers-generic build-essential

Download this file and extract it at a location of your choice.
Navigate to the extracted directory using terminal and try:

make defconfig-ath9k
sudo make install

Reboot the system and ideally wireless should work!

Hope it helps.

Guake – Annoying feature of renaming tabs

I am a huge fan of guake terminal and after having used it for quite a while, I am literally addicted to it.

Recently, I encountered a very annoying feature which is when I rename a tab and perform any operation on that tab, the name I gave disappears and the absolute path is shown.

This was very painful because I am used to work with multiple tabs open and naming helps navigation.

After some googling, I found a solution which I present below.

Install gconf-editor.

sudo apt-get install gconf-editor

Start gcong-editor


Browse to apps/general/guake/general.

On the right hand side, uncheck the “use_vte_titles” item and close it and restart guake.

All tabs would be named “Terminal” and renaming would preserve it.

The technical reason for doing this is the following piece of code:

def on_terminal_title_changed(self, vte, box):
    use_them = self.client.get_bool(KEY("/general/use_vte_titles"))
    if not use_them:
    page = self.notebook.page_num(box)

As we can see ‘use_vte_titles' key prevents the autorenaming feature

Hope this helps and enjoy using guake.

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 !