Benchmarking in Rails console - Know performance of a code snippet

Lets say we need to benchmark and evaluate the performance of code snippet. This is how we can easily do on Rails console using "Benchmark.ms" require 'benchmark' 1.9.3-p392 :001 > Benchmark.measure do 1.9.3-p392 :002 > "john mark McMillan".split(" ").collect{|word|word[0] = word[0].upcase; word}.join(" ") 1.9.3-p392 :003?> end => #<Benchmark::Tms:0x00007ff6cd8face8 @label="", @real=1.600012183189392e-05, @cstime=0.0, @cutime=0.0, @stime=2.9999999999960614e-06, @utime=1.8999999999991246e-05, @total=2.1999999999987307e-05 1.9.3-p392 :004 > Benchmark.

Migrating (export and import) PostgreSQL database from Heroku to SoftLayer (or dedicated server)

Recently we had requirement in one of the project to migrate Heroku PostgreSQL database to SoftLayer (dedicated server) psql database. One major issue we faced during migration i.e. import Heroku pg database to SoftLayer database using pg_restore is the version conflict between the dump file that Heroku generates (for psql backups) and the old version 8.4. of PostGreSQL that SoftLayer instance has. We upgraded PostgreSQL to version 9.1 on SoftLayer. Remember to upgrade version above Heroku dump file or use same version but not below versions as pg_restore doesn't handle backward compatibility properly for dump

Git - Branch merging process

Pretty often we are in situation where we need to merge branches especially while using "branch per feature" pattern to push our changes to repo. You may follow these simple yet very important steps to merge your branches. Assuming that you are on "master" branch on your local repo, do this to check the branch. git branch Expected output master Checkout the branch you want to merge, example you want to merge branch "feature-devise", So do this git checkout feature-devise Expected output master feature-devise Come back on master branch to start merge process git

Rails Initialization Process

I have drafted this rails initialization process after thorough understanding and debugging rails lib code. I have also referred rails initialisation guide present here - Initialization guide so I tried make it simpler to understand for all of us. Here is a step by step rails initialization process. (specifically for Rails 3.1.1) Perform following steps before you start learning and understanding this process git clone https://github.com/rails/rails.git cd rails git checkout v3.1.1 Initialization Process When you do "rails s" from inside your rails app folder, it will load "script/