
I had a thought while I was heading out to RubyConf 2008. I’m currently looking for more contract Ruby work and so I was planning to noise up a few folks and see if there was anything going.
What I hadn’t realised is that I (and other UK developers) are particularly attractive to US companies [...]...

I had a real “Doh!” moment today. I’m in Florida for RubyConf 2008 this week (which is going to be awesome!). Unfortunately my luggage fared even worse than I did on its journey here and hasn’t yet made it. I have no transport, so I decided to go for a walk from [...]...

Last year over 100 attendees and speakers from around the UK, Europe and US came together in Edinburgh for what keynote speaker and RailsCore member Michael Koziarski recently described on stage as “the best small conference” he’d attended.
Scotland on Rails is pleased to announce the Conference will be running again in 2009 and the call [...]...

Sun and Amazon recently announced the Launch of OpenSolaris on Amazon
EC2 and I’ve
just taken the opportunity to test drive the OpenSolaris (Solaris eXpress
Community Edition b79) image. I’m planning to fire up some notes here as I
discover various aspects of the platform.
First of all, and nothing to do with the title of the post, it takes [...]...

When I first started with git, like most folks, I suspect, I came from a
subversion background. And most of the repositories I interacted with on a
daily basis were subversion repositories which weren’t going to change any
time soon. To be honest, I didn’t get a great impression of git and git-svn
from that experience.
What really convinced me [...]...

While I was writing a bit of code today (which smells a bit and so I suspect needs revisiting in the future, but anyway) I found myself writing the equivalent of:
object.respond_to?(method) ? object.send(method, args) : nil
that is, if a particular object implements a method then please call it and let me know what it returns, [...]...

I may seem somewhat git-obsessed lately. That’s probably because I am. It’s
awesome. But mostly it’s because I have finally made the jump and I’m
having to re-learn the techniques I have been making use of for years in
subversion.
First up: looking at the changes between two branches. I often work with a
‘master’ branch, which is effectively [...]...

In a previous post, Using git submodules to track plugins
I introduced the idea of using git submodules as part of your workflow in
developing Rails applications. At the time, Rails itself wasn’t using git, but
that has finally happened. You can find the official Ruby on Rails source code
repository at http://github.com/rails/rails. So, how to we track Rails [...]...

I often come across this particular use case and it’s probably easiest to
explain with an example. Take an ActiveRecord model called Book which
represents a book in Amazon’s catalogue. In addition to books which are
already published, we collect information about books which are going to be
released at some point in the future. We store the publication [...]...

One of the huge wins for me with git is that it’s very cheap to set up a repository, even for a small, transient task. Here’s a story of how I used git this morning. I was having trouble installing the oniguruma ruby gem on my laptop. Oniguruma itself was installed on [...]...

I’m in the process of developing a new Ruby on Rails training course. While I personally abhor every full-blown IDE I’ve tried (intelligent code completion’s all well and good, but it has to be faster than just looking up the documentation!), I can see a few advantages for basing it around an IDE:
Everybody is [...]...

Registration for Scotland on Rails has now opened! With Keynotes from Michael Koziarski (nzkoz) and David A Black, along with another 15 Rails luminaries doing talks on bleeding-edge topics, it’s set to be the best Rails conference this side of the pond!
The conference is on Friday 4th April - Saturday 5th April, with a [...]...

I’ve been a happy user of acts_as_authenticated, and its lazy cousin restful_authentication for, well, it must be years now. But lately it hasn’t quite satisfied me. (Which is a good reason auth shouldn’t go into core, BTW: there’s more than one way to do it and it’s not a one-size-fits-all situation.)
Anyway, so I’ve basically written my own plugin to do authentication. It’s not ready for public consumption yet. Apart from anything else, it depends not only on acts_as_state_machine but the patches I’ve got kicking around to make its behaviour more consistent. It also requires edge Rails. But I wanted to show off a wee preview, which I think sums how it wins over its predecessor.
In a controller, which looks clearer?
before_filter...

Finally, I’ve gotten around to booking up everything for RailsConf Europe — flights, hotel, the conference itself. I’m signed up for the all-day charity tutorial because, well, it’s just a fundamentally good idea and well worth supporting/encouraging. Though I hope Dave doesn’t go quite as overboard about charitable donations as he did at RailsConf — I’m paying a lot of money to go and talk to people about Rails, not to be lectured at about the money I give to charity! I already give as much as I feel I can afford, thank you very much!
Anyway.
I’ve been plotting my plans for the time I’m in Berlin on Google Maps, messing around with creating my own map:
View Larger Map
I’ll be arriving at the hotel around 14:00 local...

I have a whole pile of rspec specs in one particular application. I’ve been really good with this one and stuck to working in a behaviour-driven manner. Well, mostly, I’m still not perfect, sometimes I go fill in the gaps later when I feel I’m under pressure.
Anyway. One particular aspect of this application is an HTML page scraper. That part is particularly well specified because it is necessarily fragile. We’re scraping HTML pages from another site that’s rather popular, has lots of interesting data to mine and has no API. And has really butt-ugly HTML. (Guess right, you win a prize, which is probably getting first dibbs on the YouTube video of my client beating me up for spilling his uber-secrets!)
So started out by having the specs scrape the...

OK, lazyweb time. I’ve got this application which has several widgets. So I have a resource WidgetsController which maps to /widgets in the normal RESTful Rails fashion. That’s lovely. We can create, read, update & destroy widgets to our heart’s content.
We have users too. Users are on a resourceful UsersController which maps to /users. Users both have and belong to many widgets (actually, a user has_many :widgets, :through => :membership).
Now here’s the thing. How do we represent the list of widgets that a user has. It seems to me the natural place to put it is /users/username/widgets. We’re only ever interested in the list of widgets that a user owns, since we have a canonical place to perform most of the rest of the operations, /widgets....

It’s weird when you’re reading through your RSS feeds and come across your own name in a screenshot. Apparently I’m one of the top ten contributors to Rails this month: Working with Rails July Hackfest (currently at no. 7). Not quite sure how I managed that, it’s just been pure coincidence that I’ve been hacking on edge with a new project lately. So, what do you reckon I could do to get #8830, #8831, #8832, #9051 or #9051 accepted?
In other news, I learned something interesting this morning. I was doing something that boiled down to:
irb(main):001:0> a = Array.new(3, [])
=> [[], [], []]
irb(main):002:0> a[0] << 3
=> [3]
irb(main):003:0> a
=> [[3], [3], [3]]
and wondering what on earth was going on! Turns out that when...

Back in RailsConf Europe last year, at David’s Keynote, it was said that:
There are unresolved decisions with respect to the restful controllers. In particular, what should the convention be for searching? A separate action? Or parameters passed to the index action?
I don’t suppose a convention has been adopted for this yet? I’m just about to implement search in an application I’m working on and I’d rather go with the 2.0 convention now, rather than fight against it with my wrong decision later....

It’s not the first time I’ve found myself writing something akin to the following:
BandPages = YAML::load(IO.read(”#{RAILS_ROOT}/test/fixtures/myspace_band_pages.yml”))
BandDoms = Hash[*BandPages.map do |k, v|
[
k,
Hpricot.parse(v)
]
end.flatten]
OK, so what I’m actually doing in this case is loading a bunch of HTML pages I’ve cached as a YAML file (for testing) and parsing their HTML dom using Hpricot. (Don’t ask!) But what I’m doing in the general case is:
new_hash = Hash[*old_hash.map do |k, v|
[
k,
mutate_value(v)
]
end.flatten]
Wouldn’t it be a lot clearer if I did something along the lines of:
new_hash = old_hash.mutate_values do |v|
mutate_value(v)
end
instead? So that it feels...

I seem to have been sucked into Facebook. I don’t know quite what it is, but it does seem to be addictive. My theory is that it’s the news feed, telling you what new things your friends are up to and who/what they’ve discovered on the site, which allows you to discover new things too. That’s definitely a concept I’ll be incorporating into a couple of web apps I’m currently working on.
Anyway, you can find my Facebook profile here: Graeme Mathieson’s Facebook Profile. And for business networking, you can find my LinkedIn profile here: Graeme Mathieson’s LinkedIn profile. Feel free to connect to me on either if you feel you know me....

Last night I gave a wee presentation to the Scottish Ruby User Group about Capistrano 2, and some of the ways I’ve been working with it over the last couple of weeks, since for some reason I seem to have been immersed in it for a couple of different projects. It’s nothing particularly groundbreaking, but I figured it was useful to demonstrate some of the things it’s capable of, and how much easier it makes my life on a daily basis. You can find a copy of the slides here, complete with my speaker notes:
Capistrano 2 Rocks My World (Keynote format)
Capistrano 2 Rocks My World (PDF format)
The speaker notes are probably completely different from what I actually talked about because it turned out that the way I was setup, I couldn’t read my notes! Hey ho, you...

At this month’s Scottish Ruby User Group meeting, I’ll be talking about some of the neat things I’ve been doing with Capistrano 2 lately and how it totally rocks my world. Chances are (can you tell I haven’t finished writing it yet?!?) we’ll cover:
What’s new and exciting in Capistrano 2.
Creating and bundling your own recipes into plugins.
Some of the stuff I’ve already bundled up, including:
Managing Rails apps with the Solaris Service Management Framework refactored to cope with other ‘daemon strategies’ (as I decided to call them).
Staging deployment, complete with release management. This one is pretty cool, IMHO, the core of which was stolen from Jamis Buck’s Harnessing Capistrano tutorial, but I’ve tweaked it...

I’ve been lusting after a lens that will give me wide angle shots on an APS-C sized sensor for a while. There’s just something wonderful to me about the effect it has on clouds in a landscape shot. And being able to photos of a room is a great bonus.
It’s also the first time I’ve really played with Lightroom’s develop settings, turning the image into black & white, boosting the blues to get a really impressive looking sky. And, err, using the spot tool to hide a couple of blemishes. (Don’t tell Annabel I said that!)
I’m quite please with how, what was effectively a quick snapshot to try the new lens, has turned out....

One of the companies I’m contracting for just now (which is actually nearing the stage where I might be able to talk about some of our fun, exciting work over the past several months!) has an editorial aspect to the business. They receive manuscripts from authors and they are passed through an Editor who copy-edits and proofs them before they go much further.
It turns out that the editorial policy in the office is to have a single space between sentences instead of a double space. I personally always use a double space and thought that was the accepted standard — you learn something new every day! Like me, most of the authors submit their manuscripts with double spaces. We were talking about ways to automate the replacement (mostly with find-and-replace in Word for now),...

Inspired by PJ’s Err the Blog post Cappin’ the Stat, I decided to put together a similar recipe of my own. Sometimes I want to know which version was actually deployed and when. This is more useful when I’m working in a team and there are a couple of people who are allowed to deploy the app, but sometimes it’s just handy to know that the current live version is r73 from Subversion and that it was deployed at 3am.
So, I present a task that works nicely with Capistrano 2:
namespace :rubaidh do
# Tag the layout with the current release revision and date
task :tag_layout_with_release_info, :roles => :app do
release_info = <<-HTML
<!-- #{application} subversion revision r#{real_revision},
from #{repository}
deployed by...

I’ve got a new application I’m in the process of deploying in order to demo for a client (no, it’s not ready for everybody else to have a nosy at just yet!) and figured I’d take the opportunity to learn two things:
What’s new and shiny about Capistrano 2. Most of that was putting what I learned at Harnessing Capistrano into practice.
How to make the Solaris Service Management Facility (SMF) manage all my mongrel processes for me.
And I think I’ve pulled the right bits together to make it work rather well. If I do say so myself.
First up I got the basic project running and deploying. I decided to work with, rather than against, capistrano as much as possible. So that meant using script/spin and script/process/* instead of messing around with...

I should probably be ashamed that it’s taken me this long to notice: I don’t have a compiler installed in my zones! I discovered this afternoon while I was trying to build mongrel for an app I was about to deploy! I had assumed that Sun Studio 11, which is installed in the global zone would be automatically available to the other zones.
Apparently not. I don’t know if it’s a quirk of my installation, or whether I’ve screwed something up, but Sun Studio doesn’t appear to be managed by the packaging system. pkginfo|grep SUNWspro doesn’t show up anything. Well, I suppose that’ll explain why it’s not being copied across to the zones as it should… So, let’s get it installed properly, and let’s upgrade to Sun Studio...

I’ve just done a piston update on a project I’m doing that’s using edge Rails and was reviewing the changes. Apart from the lovely documentation that ActiveResource appears to have been donated, there’s another exciting change I spotted:
irb(main):002:0> 'cow'.pluralize
=> "kine"
which is a change in behaviour from stable:
irb(main):001:0> 'cow'.pluralize
=> "cows"
It turns out that ‘kine’ really is an archaic plural of cow. So if you have an application modeling cattle, beware!...

I had a little difficulty Googling for this one, so I thought I’d share. I’m sure you’ve all seen the following in /etc/syslogd.conf on Solaris:
auth.debug ifdef(`LOGHOST', /var/log/authlog, @loghost)
and wondered how LOGHOST gets defined so that you get to change the behaviour with minimum effort. Well, I think I’ve finally figured it out. By default, in /etc/inet/hosts and /etc/inet/ipnodes your local machine is given the alias loghost. It would appear that if you assign this alias to another host, it will receive the log messages instead. So, on one of my zones, I now have the hosts file:
#
# Internet host table
#
127.0.0.1 localhost
213.166.22.198 tobermory.rubaidh.com
213.166.22.196 kilchoman.rubaidh.com loghost
Save...

Well, for me, at least. After I mentioned my experiences with Splunk recently, a couple of Splunk’s folks got in touch with me by email, asking for my address. No, it wasn’t because they were going to send round “the boys” to teach me better ways of submitting bugs reports, it was to send me a t-shirt. A parcel arrived for me yesterday morning containing not just one, but two t-shirts, all the way from Splunk HQ in San Fransisco!
So, I’d just like to say two things: first of all, thank you very much for the lovely t-shirts, Splunk!
Secondly, my wardrobe could do with a refresh. Does anybody else want to send me t-shirts? (I’m an XL, and you can easily figure out my address.) I’d really love an OpenSolaris one, for example…...