Showing posts from 2012

rails 3.2 with jruby and mysql with rvm in ubuntu

If was trying to migrate one of the app from ruby to jrby to try out the threading benifits.

this wasn't an easy task :D

well the gem dependency did not create a big issue.

the problem came when connecting to mysql with jdbc driver
I had replaced

 gem 'mysql2'

gem 'activerecord-jdbcmysql-adapter'

in Gemfile

But it refused to load the driver saying :

"The driver encountered an unknown error: cannot load Java class com.mysql.jdbc.Driver'

I searched but Google could not answer me :(
then I started looking into activerecord-jdbsmysl-adapter gem and came upon the the file 
activerecord-jdbc-adapter / activerecord-jdbcmysql-adapter / lib / active_record / connection_adapters /jdbcmysql_adapter.rb 

I just copy pasted the code in a application.rb config with a condition if jruby used just after the bundler code

if defined?(JRUBY_VERSION)
  require 'jdbc/mysql'
  Jdbc::MySQL.load_driver(:require) if Jdbc::MySQL.respond_to?(:load_driver)

and boom it worked…

Send devise compatible forgot password mail through action mailer in rails

To have multiple forgot password templates and send it through mailer in rails it is quite easy



Using rvm in Kde Konsole

rvm (ruby version manager) needs a small change in konsole setting to make rvm use work

right click on the terminal and select 'edit current profile'

change the command from



/bin/bash --login

Apply and boom you are ready to use rvm in terminal.

Install Multimedia codec (offline) without internet connection in Ubuntu

Recently I have been encouraging desktop users to use ubuntu and enjoy a virus free also virus fear free desktop experience.

Without internet connection enabling restricted codes or any other install has been always a feary tasks for managing dependencies.

Links to almost all Multimedia codec and vlc player offline install.

Thanks to sundar_ima for creating and uploading all the archives for offline install.

Add Pidgin to Ubuntu 12:10 notification menu

I upgraded my ubuntu 12:04 to 12:10  couple of days
And to my surprise the pidgin integration in notification menu had disappeared.

I couldn't figure out why this people f**ked up such an important integration.

After some research and logic I was able to do some juggad and get my original gnome 2 notification style menu in notification bar .

Here are the steps I followed

I did not want Empathy or gwibber so I removed then

Now follow these steps carefully.

Open dconf-editor

Add 'pidgin.desktop' to applications in  com > canonical > indicator > messages  

Change value to 'all' in system-whitelist in  com > canonical > unity > panel  

Now Logoff and Login again and you will be able to see the Pidgin in messages notification menu.

Also it now shows the gnome classic style chat notification in notification tray..

Wohhoo..!!! , and now I am connected to the world in real-time again hehe ..

Hope this helps you too.

Indian Independence day...!!!

Celebrating independence day is not merely remembering the brave one who fought for it.. it a day to keep remembering the pledge to make it better.

A Warm Salute for all the one who contributed to the freedom and also salute to all the people with all their deeds (great or even small) feel to make it better.....!! 


ProxyPass issue

I was trying to ProxyPass the app to another server
But ran into a strange problem.

ProxyPass worked when I called but failed when any uri was added to root(

Like gave

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /login.

Reason: DNS lookup failure for:

Where we find the problem is:

Code for ProxyPass:

ProxyPass               /
ProxyPassReverse        /

Solution, I needed another slash at the final, so, it should be:


ProxyPass               /
ProxyPassReverse        /

Now it works \m/ .

rails migration like filename in linux

Creating files with date like rails migrations with datetime in file name in linux

Modulo operation in Ruby

Today I was stumped by a very simple yet awesome problem by my friend Sandip

What is the answer of  :  7 % -2 
and to the surprise ruby irb printed it as : -1 

After some research I what I found about this and why here is explanation and links

From Ruby Programming Language, O,really

Division, Modulo, and Negative Numbers

When one (but not both) of the operands is negative, Ruby performs the integer division and
modulo operations differently than languages like C, C++, and Java do (but the same as the
languages Python and Tcl). Consider the quotient -7/3. The floating-point result is –2.33. The
result of integer division must be an integer, however, so this number must be rounded. Ruby
rounds toward negative infinity and returns –3. C and related languages round toward zero
instead and return –2. (This is just one way to characterize the results; no floating-point division
is actually done, of course.)

An important corollary of Ruby's definition of integer division is that, in Ruby,…

Intalling and using rvm

I have been using ruby from a while and like every other I find  rvm as a awesome tool to manage various ruby version in one system.

Optional: You many need to install all libs not all but many of these will be need but its better to get installed in the system

This is a very small explanation for rvm but I feel this is very enough to get kick started and enjoy coding .....

More help:

Italic font rendering issue in Ubuntu 11 04

In Ubuntu 11.04 I had to install ttf-dejavu-extra fonts for rendering italic fonts properly

$ sudo apt-get install ttf-dejavu-extra

This helped me find the solution -
After installing it is now rendering italic characters properly :)

Rails 3 with aws s3

Send emails with Amazon SES in Rails 3I have been using aws-ses gem quite successfully in Production env.
In your Gemfile add:

create an initializer in config/initializers
Configure ActionMailer
Set delivery mehtod to amazon ses in environment.rb or in a specific environment as needed
eg. config/environments/production.rb

Very good post to understand basic regex Expressations


Here is a wonderful post to understand how regex can be used for most basic matches and valiadations in general.

This can help better understanding for making more complex use

In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters.

Changing session to database based in Rails 3

In config/initializers/session_store.rb:

Difference between rake db:migrate db:reset and db:schema:load

db:migrateruns (single) migrations that have not run yet.
db:createcreates the database
db:dropdeletes the database
db:schema:loadcreates tables and columns within the (existing) database following schema.rb
db:setupdoes db:create, db:schema:load, db:seed
db:resetdoes db:drop, db:setup
Normally, db:migrate used after having made changes to the schema via new migration files after creating db i.e when db already exists.
db:schema:load is used when you setup a new instance of your app.

Basic Linux survial commands list

The humble Linux cheat sheet > A small Linux cheat sheet, introducing the very basic and very essential commands for surviving at the Linux CLI.
Moving around in the file systemCommandActionpwd"Print working directory" - show what dir you're in.lsList the contents of a -lList the contents of a dir and show additional info of the -aList all files, including hidden files.cdChange ..Go to the parent directory.Examining filesCommandActionfileDetermine the type of a file.catConcatenate a file.lessView text files and paginate them if needed.Manipulating files and directoriesCommandActioncpCopy a file.cp -iCopy a file and ask before overwriting.

Extract uri from String in ruby

URI.extract makes it easy to find links in pages.

"Extracts URIs from a string. If block given, iterates through all matched URIs. Returns nil if block given or array with matches."

Some good tech websites to follow

This is just a small list of tech website I personally found worth following.
Ars Technica – This site caters to computer enthusiasts and covers a wide array of technology, science and gaming news. It is one of the sites most-linked-to by tech blogs and news sites. – This site is the one which we consider to be Engadget’s counterpart in the business-oriented world of tech reporting. It’s stable of reliable news and rumor sources still deliver breaking news and exclusives reported in a professional, business-like style of writing. Computer World – The site is one of the tech industry’s oldest and leading source of technology news and information for IT influencers. It is still one of the leading source for breaking news, industry analysis and opinions. Droid Life – Another Android-centric tech news site. The site covers anything and everything about the Android platform including lineups of DROID phones, apps, reviews and videos. Electronista - The general tech and gadget arm of th…