the obligatory jekyll post

488 words

Saturday, February 11 2012

I remember when I was setting up this blog noticing the number of people who’d just switched to Jekyll and immediately produced a post about some neat trick they’d found in the process.

Well, I had something up my sleeve for a Jekyll-related post after I started this blog, but I’m only just posting it now.

Specs for any Jekyll site

I wrote up some nice generic specs for a Jekyll blog. You can see the source in this blog’s repo.

The specs check that… » continue

putting photos to work

409 words

Thursday, September 15 2011

You’ve taken thousands of stunning photos with your new, expensive camera and uploaded them to your Mac. So now what?

This is a very basic guide about how to use your favourite photos as rotating desktop wallpaper or in your screensaver. Rather than having to do something tedious like manually putting favourite photos in a special folder or a special album we’ll piggyback on iPhoto’s rating system… » continue

when to cuke

657 words

Friday, January 28 2011

Since getting into BDD and Cucumber I’ve been getting mixed messages about what should be covered by features and what shouldn’t.

Firstly, as with TDD, I’m told that BDD tests are so important they should be written before you touch the code. But then, conflictingly, I’ve had a number of people suggest that if a feature is mostly provided by a gem or plugin or Rails itself then you needn’t test it.

Now, granted, for TDD/Rspec I tend to agree - it’d be futile to go spec-ing every magic method provided by Rails or Devise.

In the case of BDD/Cucumber however, I disagree.

Some brief reasons… » continue

hacking capybara cookies

504 words

Friday, January 28 2011

I once tried and failed to write a cucumber test for a remember-me login feature. I was using Webrat to drive Cucumber interactions at the time and it just didn’t seem to provide the access to cookies I needed. So I logged a feature request with Webrat and left the test marked pending.

Fast forward to more recent times and I was cukeing login features but using Capybara to drive it. So when it came to the remember-me feature I tried again hoping that Capybara might be more supportive. It wasn’t directly, but thanks to this nifty little gist I was able to hack in what I needed.

The gist,… » continue

escaping bang in bash

1416 words

Monday, January 24 2011

Bash. A venerable language; ugly… like, I mean:

if [ -a file.txt ]; then echo "found file.txt"; fi 

ugly! - but workable… or so I thought.

Try this little exercise before you read further: try to get echo "Don't break on me!" to produce Don't break me! in Bash, that is without errors, extraneous backspaces or lost apostrophes or bangs.

Losing some hair?

Ok, first things first, ! has special meaning. It “starts a history substitution, except when followed by a space, tab, newline, equals or left bracket (when the extglob shell option is enabled, which it is by default in… » continue

patching devise

485 words

Friday, January 21 2011

I submitted my first patch to an open source Ruby project the other day.

I got interested in the HttpOnly flag on cookies and decided to check up on which cookies set it. After a little more fiddling than should have really been required (see the side note) I was able to establish that the Rails session cookie is HttpOnly by default (since about 2.2 or… » continue