Pass rspec options from rake on command line

To pass rspec options from a rake task on command line,  use the env variable SPEC_OPTS. For example, to enable backtrace logging when running all spec tests:

rake SPEC_OPTS=-b



Git through SSH port forwarding (SSH tunneling)


A.  you are on a firewalled network, from where you can’t access github (remote port:9418 is not allowed)


B. you want to access a securized git server from home, but your IP is not on the git server’s whitelist.

and, of course, you have ssh access on a server that can do this.


A. Make a ssh tunnel to the git server

Me –> ServerWithSSHAccess –> GitServer

Continue reading

Advice on using Ruby, RVM, Passenger, Rails, Bundler, … in development (via Jérémy Lecour)

This article is the english version of “Conseils pour utiliser Ruby, RVM, Passenger, Rails, Bundler, … en développement”, originaly written in French. If you have a better translation, I’d be happy to use it (full or parts) and credit you. Introduction : Why this advice The dev team I’m working in is composed of 3 people who use Ruby. Besides me, who’s is spending the most part of my time on Ruby and became “the one who knows” about this stuff, m … Read More

via Jérémy Lecour

Ruby/Rails: Parse large XMLs (SAX parsers, Pull parsers) + example of Pull parser

When you have to parse huge XML files (hundreds of MB-like), loading the whole XML in memory is not an option.

Continue reading

Ruby on Rails interview questions – RoR test from PeopleCentric

One of the recruiting companies that I have collaborated with in the past decided to publish many of theirs IT tests . You can find, among others, a Ruby on Rails test. Enjoy 🙂

Free IATA + ICAO airport codes database

Parsed from: Wikipedia.

Available on YAML or JSON format.

Data example:

- :airport_name: Charles de Gaulle International Airport (Roissy Airport)
  :complete_location: Paris, France
  :city: Paris
  :country: "France"
  :iata_code: CDG
  :icao_code: LFPG

Continue reading

Fetch data from heterogenous tables(Rails SQL views, SQL Union)

Let’s say you have a ‘cars’ table and a ‘bikes’ table, and the schema can not be changed. Some fields are the same, and you want to display ( paginate, search etc) a list with products that are both cars and bikes (from both the car and the bike models), sorted by their creation date.

This post is about how this can be accomplished using sql views.

Continue reading

Phone calling codes (aka International Dialing codes) – DB Dump / YML format

Parsed from: with Hpricot:

doc = Hpricot(open(""))
table = (doc/"table")[4]
by_country = {}'/tr').each {|tr| tr0 ='/td')[0] ; tr1 ='/td')[1]; by_country[tr0.inner_html.gsub(/<.*>/,  "")] ='/a').inner_html.gsub(" ", '').split(/\+/).select{|val| !val.empty?}.map(&:to_i) if tr1  } ; nil

Phone calling codes (MySQL dump)

Phone calling codes by country (YML format)

Google Maps: Center map and automatic zoom on single address

Snippet to get an automatic zoom level for a geocoded address.

Why You Shouldn’t Use Float for Currency (floating point issues – explained for Ruby and RoR)

This article is a response to

It is a VERY BAD IDEEA to use floating point arithmetics to deal with currency. In most of the programming languages. Basically, because you’ll end up loosing money :). And this (on the great majority of cases) is not desirable 🙂 .

I’ll show you some magic (that you may try at home):
~$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
~$ irb
irb(main):003:0> (10.12*100).to_i
=>; 1011

So, what just happened? Continue reading