Scottish Blogs.com


Dropping Daily Rates via Notes from a messy desk November 13th, 2008 at 12:50

image 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 [...]...

Hobbling the iPhone via Notes from a messy desk November 5th, 2008 at 22:46

image 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 [...]...

Scotland on Rails 2009: Call for Proposals via Notes from a messy desk September 19th, 2008 at 10:20

image 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 [...]...

Finding the extra disk space on your OpenSolaris EC2 Image via Notes from a messy desk May 21st, 2008 at 12:35

image 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 [...]...

Coming back to git-svn via Notes from a messy desk April 25th, 2008 at 10:41

image 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 [...]...

Objective-C message passing semantics for Ruby via Notes from a messy desk April 15th, 2008 at 16:11

image 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, [...]...

Some new git techniques for your arsenal via Notes from a messy desk April 12th, 2008 at 16:45

image 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 [...]...

Using git submodules to track vendor/rails via Notes from a messy desk April 11th, 2008 at 11:57

image 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 [...]...

Timestamps that can behave like booleans via Notes from a messy desk April 10th, 2008 at 17:25

image 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 [...]...

Using git to fix up other projects via Notes from a messy desk March 29th, 2008 at 12:54

image 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 [...]...

Ruby on Rails IDEs via Notes from a messy desk March 4th, 2008 at 09:53

image 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 [...]...

Scotland on Rails Registration Open! via Notes from a messy desk February 17th, 2008 at 10:56

image 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 [...]...

Authentication plugins via Notes from a messy desk September 23rd, 2007 at 11:03

image 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...

RailsConf Europe via Notes from a messy desk August 22nd, 2007 at 12:45

image 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...

Profiling your rspecs via Notes from a messy desk August 4th, 2007 at 13:27

image 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...

Resources, resources everywhere (and not a drop to consume?) via Notes from a messy desk July 24th, 2007 at 15:47

image 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....

Accidental Placing via Notes from a messy desk July 23rd, 2007 at 12:11

image 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...

Convention for RESTful search in Rails? via Notes from a messy desk July 22nd, 2007 at 18:12

image 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....

Mutating all the values of a hash via Notes from a messy desk July 22nd, 2007 at 14:49

image 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...

Social Networking via Notes from a messy desk July 21st, 2007 at 14:15

image 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....

Capistrano 2 Rocks My World via Notes from a messy desk July 20th, 2007 at 09:27

image 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...

ScotRUG Meeting: Capistrano 2 rocks my world via Notes from a messy desk July 18th, 2007 at 08:49

image 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...

Shiny new Canon EF-S 10-22mm lens via Notes from a messy desk July 15th, 2007 at 08:32

image 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....

Double space vs. Single space via Notes from a messy desk July 3rd, 2007 at 11:00

image 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),...

Tracking which deployment you’re looking at via Notes from a messy desk June 26th, 2007 at 02:15

image 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...

Integrating capistrano with SMF via Notes from a messy desk June 24th, 2007 at 21:11

image 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...

Solaris: Upgrading to Sun Studio 12 via Notes from a messy desk June 24th, 2007 at 16:57

image 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...

New in Edge Rails: Kine! via Notes from a messy desk June 24th, 2007 at 11:22

image 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!...

Solaris: Logging to a separate loghost, the easy way via Notes from a messy desk June 17th, 2007 at 10:20

image 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...

Free t-shirts! via Notes from a messy desk June 14th, 2007 at 13:26

image 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…...