Tag Archives: ruby

Experiments in metaprogramming

I’m having a go at metaprogramming in ruby. It started out simply enough. I wanted a module which had some custom assert methods in. Here’s the test: def test_matches assert_stderr_matches(/foo/) do warn "foo" end end And here are the custom assert methods. module AssertStderr def assert_stderr_matches(regex, message=nil) old_stderr = $stderr $stderr = StringIO.new yield assert_match(regex, […]

Coding Dojo 9

I’m just back from Dojo#9. We attempted Kata 4 again, but in Ruby this time. Even though I was the only one with much Ruby experience behind me, it still wasn’t much of a problem in practise. I did some cheat sheets, but they didn’t seem to be used much. Exactly the same as the […]


Last night was the 8th Coding Dojo. Joh kindly allowed myself and Jay to try out one based on Ruby instead of the usual Java. Sadly, Jay was ill and couldn’t make it. Get well soon, Jay. We started late because I was installing all the necessary bits (ruby + eclipse) on Joh’s laptop… Having […]

class methods in ruby modules

Modules in ruby are fairly simple to understand. You can add extra methods to a class by including a module. module Extras def say_hi puts "hello world" end end class Foo include Extras end Foo.new.say_hi But one thing that crops up reasonably often (particularly in rails) is the need add not just methods, but class […]

Brighton Ruby Users Group

Last night was the inaugural meeting of the Brighton Ruby User Group at the Eagle. I gave a (slightly) slimmer version of my Unicode for Rails talk1. I really should learn about code on slides though. Just because something looks good on screen, the lovely soft focus effect that projectors provide quickly turns it to […]

Brighton Ruby Users Group

James McCarthy is taking a stand! He’s started up Brighton Ruby. The first meet is 7pm, Jan 9th at the Eagle. Ideas are being solicited for talks. Do drop a comment onto the blog if you’re going to attend or even better are willing to talk! I’m really glad to see this happening. There seem […]

gdb ruby $pid

gdb is my “tool of last resort”. When all other online diagnostics have failed, I know enough gdb to pull out a C level stack trace. % gdb $SHELL $$ GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:06:22 GMT 2006) /Users/dom/320: No such file or directory. Attaching to program: `/bin/zsh’, process 320. Reading […]

Flickr Favorites

I have been steadily accumulating favorites in flickr for some time now, thanks to the lovely feeds that they offer. But I want them as backdrops for my desktop. I didn’t spot anything else with my 30s of googling, so I wrote a small script to dump my favorites into a directory. favsync.rb I was […]

del.icio.us api change

I’ve just been caught out by the del.icio.us api change (they’ve just switched off the old api). This broke the backup script I use. It’s a nice script, it downloads each days bookmarks into a sqlite database, ready for reuse. Anyway, this is the patch I wrote to make it use the new api (over […]

ruby postgres gem issues

I’m trying to install PostgreSQL support into Rails. This should be fairly simple. Unfortunately, there are a couple of “oopsies” along the way. First up, there are several gems to pick along the way: postgres postgres-pr ruby-postgres If you’ve a compiler installed, you want ruby-postgres. It’s a fork of the postgres gem, which knows how […]