Ruby or Rails

Category: Ruby or Rails

ruby + grep = rak

Monday, December 3rd, 2007

Daniel Lucraft recently released Rak, a ruby powered grep replacement.

To install: gem install rak

Rak is useful for searching Rails code through the console. Search results are displayed with the search terms highlighted, which is very useful.

Go ahead, give it a spin!

Campfire activity notifier for KDE

Thursday, September 13th, 2007

Campfire is a web-based chat product from 37Signals. One thing bothered me with using it as a development chat channel: I want to be notified of messages visually instead of checking for them.

Kathy Sierra once wrote an excellent post on the addiction to email-checking. The same goes for Campfire, constantly checking it for new messages can drive you insane.

Solution? Tinder.

Install Tinder and run the following ruby script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'rubygems'
require 'tinder'
campfire = Tinder::Campfire.new 'your_domain'
campfire.login 'your_login', 'your_password'
room = campfire.find_room_by_name 'Development'
def self.knotify title, msg
  # shows message on screen
  system "dcop knotify default notify eventname \'#{title}\' \'#{msg}\' '' '' 16 2"
  # plays alarm sound
  system "dcop knotify default notify eventname \'#{title}\' \'#{msg}\' '/usr/share/sounds/KDE_Error_2.ogg' '' 1 2"
end
room.listen do |m|
  if !m.nil? and m[:message].size > 1
    knotify(m[:person], m[:message].gsub("'",""))# knotify doesn't like this character
  end
end

Note that the script currently works for KDE only, but the knotify method could be replaced with a call to Growl for Apple users. Also, it’s best to use a login name that is already on the channel so the bot doesn’t get kicked out of the chat room after being inactive.

We’ve also used Tinder to hook Campfire up with Subversion, Trac and Capistrano.

Sweet.

Scalable web sites

Saturday, June 23rd, 2007

Cal Henderson’s Building Scalable Web Sites is a must read for anyone in the business of developing for the web.

The author is a PHP hacker and it was interesting to see that according to him, PHP has had it’s fair share of the same question people keep asking about Rails: “Does it scale?”

The distinction between performance and scalability is made very clearly in the book and a scalable system is defined as one that has thee characteristics:

  • It can accommodate increased usage.
  • It can accommodate an increased dataset.
  • It is maintainable.

Rails passes all these tests for the same reasons PHP does. An increased dataset is accommodated in the database layer, an increased user-base is accommodated though the “share nothing” architecture and as for maintainability, Rails passes with flying colours.

OpenID and Rails

Wednesday, February 28th, 2007

Before going to the Future of Web Apps conference last week, I’d become aware of some buzz about OpenID on sites such as Tech Crunch, Slashdot and in the blogosphere in general.

Simon Willisson’s talk on FOWA (slides, video) was an eye opener and OpenID seems close to reaching a tipping point.

David Heinemeier Hansson has recently shown interest, Dan Webb posted the Rails based The No Shit Guide to Supporting OpenID in your Applications and East Media Group have made a plugin available.

Following the Rails community’s reaction to this will be interesting. It wouldn’t surprise me if OpenID support becomes native to Rails in the near future.

Last.fm hack presented on FOWA: IRCCat

Monday, February 26th, 2007

In my last post I mentioned a hack that was featured in a presentation made by Matthew Ogle and Anil Bawa-Cavia of Last.fm at The Future of Web Apps conference last week. Anil has blogged about the presentation and the hack which has just been open sourced by their CTO, Richard Jones.

The hack is basically an IRC bot, called IRCCat (as in cat to IRC), that listens to messages on some port and sends them to an IRC channel the developers are logged onto. This can be used to make commits to Subversion, ticket changes on Trac or any other event in a development environment become part of a chat conversation.

Now that IRCcat has been open sourced, implementing this for Capistrano deploys will be very straight forward.

Ruby search on Firefox

Thursday, October 26th, 2006

Google is now allowing the creation of custom search engines via personalised search. At the Ruby Inside blog, Peter Cooper has provided a much needed service with Google Ruby Search.

Extremely useful.