Monthly Archives: December 2007

Moron no more : I can Git !

Since Linus said we’re all morons ’cause we use Subversion and the like, lots of people started to migrate to his new faster, better, stronger, cooler and geekier revision control system Git.


Installation for Subversion morons like me

Get the latest stable source from

tar xzf git-
cd git-
make prefix=/usr/local all
sudo make prefix=/usr/local install

Create your own little repo

mkdir moron
cd moron
git init

Congrats, you just created your first Git repo!

Most common commands looks like Subversion ones. add, rm, mv and commit. But you gotta remember that there’s no such thing as a working copy in Git. It’s a distributed revision control system. Which means that your local copy is a repository. In fact, with Git you do not checkout (in the Subversion sense) a copy of the repo, you clone it. That’s why Git is so much faster. Most of the commands: history browsing, local commits, reverting, etc, are done locally, without talking to the server. Check the official guide for Subversion morons.

Try adding a file:

echo "I'm no longer a moron Linus" > moron-no-more.txt
git commit -a

The -a ensures that all new files are added, you can do this manually with the git add command.
You then commit you change as you would do in Subversion, with the difference that it’s all done locally:

git commit -m "Take that Linus!"

All is not lost for us poor Subversion mortals

The cool thing about Git is it has builtin support for playing nicely with Subversion. Which ease the migration and can even let you use Git side by side with Subversion. So you can import a Subversion branch like this:

git svn init http://repo/url/trunk
git svn fetch

You Git repo now has all the revisions of you Subversion branch. Try running git log.
You can even send you changes back to Subversion:

git svn dcommit

Create your central repo

mkdir mah-repow.git
cd mah-repow.git
git --bare init-db
git-repo-config remotes.origin.url; # notice trailing slash!

Upload that directory to your public server. Like Subversion, Git supports various ways of serving a remote repo, I chose WebDAV because it’s the simpler one on DreamHost.

To send your changes to the server with Git you push your changes to the server and pull changes from others. With our previous examples, to push a series of commits to the server you’d do:

git repo-config remotes.origin.url; # once to setup the default server url
git push

Happy Gitting!


Filed under tips, tutorial

yu can has a mery Crismus


It beez dat tiem of teh yeer agin, lol
Hai! Kittehs luv Crismus Trees very much! Dey liek to play wit dem, an eet dem, an mak tinsul hang out of der butt. But we mus remembah teh troo reesun we haf Crismus is cuz Ceiling Cat luv pien trees and he mak a holaday for dem. Srsly.
See dis piktur? Ceiling Cat in high plases cuz dat be wer he belong, srsly. Ceiling Cat don haf to stay in teh tree tho! He can has plases everywhar! Ceiling Cat can has part in ur Crismus? Uplaod yer pikturs or send dem to his proffet an show everywun wer Ceiling Cat hangz out in yer holiday decerashuns! Invisible sanity!
Yu can has a mery Crismus!


If you’re looking for something to do this holidays, I’d suggest renewing with The Bible.

Merry Christmas and happy new year to all my readers.

Leave a comment

Filed under Misc

Getting TextMate ready for Rails 2.0

After updating a couple of existing Rails app to 2.0, I found out some of TextMate sugar was out of date. Here’s 2 things I did to put the hot and sweet sugar back into TextMate.

Update the bundle

TextMate bundles are under heavy development all the time, get the latest version from their repo:

svn export

Then double-click on the downloaded Ruby on Rails.tmbundle.

Fix the test commands

I’m a heavy user of Run (command+R), Run Focused Unit Test (shift+command+R) and the Rails menu (shift+ctrl+\) but that do not work with Rails 2 because of a conflict with the builder module.

Rob Sanheim explain how to solve this very easily, just rename the Builder.rb in the Rails bundle.

Hope this helps!


Filed under rails, tips, tutorial

Rack, the frameworks framework

RackWith all the Ruby frameworks popping up, we’re starting to see some similarities. All of them provide something new or unique but one part of their code is always the same. The part that plugs it into a web server. Ultimately, all web servers have to support all frameworks and vice-versa. That is a lot of duplicated code! That makes me yell, running in circles, waving my arms: not DRY, not DRY, not DRY!


Rack (not the iRack) by Christian Neukirchen, solves this problem.

From Rack website:

Rack provides an minimal interface between webservers supporting Ruby and Ruby frameworks.

Rack looks like this in my head:

Handlers on the left (web servers) serve requests to Adapters (frameworks) on the right.
(Don’t ask me what the rabbit is doing there, must be important)

Run Forest!

But Rack can do a lot more then plug Ruby framework into webservers. It is a framework in itself.

When you install it:

sudo gem install rack

You get the rackup command. Which lets you start your app on any supported web server.

require 'rack/lobster'



Start your app: rackup -p3000 then browse to http://localhost:3000, oh the cute lobster!

To run it on other web servers (mongrel by default) play with the -s option.

It’s a framework I said

The Handler API is only 1 method: call(env). Which allows you to use proc as application.

app = proc do |env|
  [200, { 'Content-Type' => 'text/html' }, 'no pepper plz!']
run app


That will return a 200 OK response with the text/html content type and the body no pepper plz!. env contains the request parameters, so you could play with the QUERY_STRING or wrap it inside a Rack::Request and get a request param value with request.params['name'].


You can use middlewares to filter the process. For example, you can add logging and detailed exception support with those 2 lines in your file:

use Rack::CommonLogger, STDOUT
use Rack::ShowExceptions

You can also validate your application, the requests and responses according to the Rack spec automatically using the Rack::Lint middleware.

(There’s also a Reloader, Static, Cascade, File and much more middlewares, check the doc)

You can also have fun with urls:

map '/files' do

map '/lobster' do

Check it out!

Rack is the best example of a very well design Ruby library. The code is simple, well separated and yet, easily extensible, it’s beautiful! I encourage you to check out the code but mostly to use it if you’re building any Ruby web framework (like we need other one!).


Filed under rails, ruby, tutorial

Rontreal On Mails is torromow

Snow make use slowMontreal is white and snowy
Ruby is red and pretty
Rails is red (also) so lets party


Filed under montreal, rails, ruby, StandoutJobs