Adam Carlile
Heroku Airbrake post deploy hook

After a lot of trawling around the internet I couldn’t find any reference as to how to set up a post deploy hook for heroku. Even the airbrake:heroku:add_post_deploy_hook rake task didn’t seem to work, so I have managed to piece together my own custom post deploy hook

I hope this can help someone!

Queuing Sunspot indexing jobs with Resque

I’m currently working on a social networking platform(very beta!) for London, and we use Resque to handle all of our background jobs, sending outbound mail, image processing etc.

We recently implemented Sunspot and Solr for indexing our models to allow rapid full text searching. Now Sunspot is awesome, has a great DSL and makes indexing and searching super easy, it also has great built in support for DelayedJob, which is another awesome background processing framework.

However since we’ve already implemented Resque it seemed the logical choice to integrate it with Sunspot. But documentation seems to be patchy at best as to how to implement the queue with Resque.

Enter SunspotSessionProxy

SunspotSessionProxy is a class that sits between the Sunspot interface and the Solr server, allowing you to change the behaviour of certain actions that Sunspot will perform, such as indexing, searching etc.

So through this class we can modify the default behaviour of the index action to route it via a Resque worker.

This class delegates all of it’s methods to the Session class, apart from the index method, which we have rewritten to include a call to Resque to enqueue the job.

We also keep hold of the original session so that we can call it from inside the Resque worker, so we can actually run the original indexing method, instead of our modified index method

Work, Work, Work

Here’s the code for the Resque worker.

Very simple, just takes the arguments passed by the ResqueSessionProxy#index, gets all the AR objects, and then runs the original sessions index method from inside the worker thread

The Final Piece

Finally we have to tell Resque to use this new session proxy, so just a simple line an in initialiser will do it

That’s it! Hopefully that has helped some of you, as I’ve not seen any documentation on this subject

If I could turn back TIME

Time, we can all agree, is an incredibly useful concept, unfortunately the recent decision to drop <time> from the HTML5 spec is not useful.

After all every website that I’ve recently developed has made use of the <time> element, inside <article>, making publish dates something that hold semantic meaning in relation to the <article> in question.

The decision to remove it has been wholeheartedly rejected by the developer community.

Along with a new website, http://whynotime.com/, and a trending hashtag #occupyhtml5

Github and Twitter both use the <time> tag extensively, it seems to me to be incredibly short sighted to remove such a useful element and replace it with something vague and totally meaningless, <data>. <data> can contain anything, and has no meaning to the <article> in question.

It seams like a real step backwards to the days of endless <div> and <span> elements, except this time endless <data> elements with all sorts of meaningless data within, holding no semantic value whatsoever.

I can only hope that the W3C reverse this decision for the good of the HTML5 spec.

Meta programming, serialization

Oh wow, has it been that long already, I need to force myself to post something at least once a week, even if it’s just posting pictures of cats!

So I’m currently working on a social media platform for London, with it’s main purpose being to promote a wellbeing lifestyle in a hectic city. I wrote this handy little utility module for creating methods from serialized data.

Say, for example you have an object, but it can have serialized data stored within a hash in the database, instead of getting the data through the hash notation, you can now access it directly as Object.first.hash_key_name instead of Object.first.hash[:hash_key_name]

This is handy in two ways, you can access serialized data directly as methods of the class instance. Plus you can use the serialized fields directly in a form, as the module automatically creates the setters for the hashes keys. Pretty handy, you just have to specify in an array of serialized field symbols as a private method in the parent class.

Rupert Murdoch of the Galactic News Empire, just something I knocked up watching Mr Murdoch talk garbage!

Rupert Murdoch of the Galactic News Empire, just something I knocked up watching Mr Murdoch talk garbage!

This is a little something I made up for my good friend Alex Goy and the @Podisode boys. If you’re ever stuck for clichés to use in your writing never fear, the cliché-o-matic is here.

For those that are interested it’s a simple Sinatra app, pulling quotes from a YAML file

Wow, It’s been a while

It’s been a while since I posted last, I really need to post at least once a week. Not a lot has happened really. I’m still unemployed, even though I think I’m pretty good at what I do it’s starting to grate on my confidence. I guess I’ll just keep slogging on.

I’m keeping myself afloat with some freelance jobs, however chasing invoices is not something I enjoy doing. And why should I have to chase the money that is owed to me for work that I did in good faith anyway? It’s not like this is a one off, I feel like I should name and shame but I can’t quite bring myself to do it.

In other news I managed to smash my MacBook Pro up. The machine was over four years old, and it was only a matter of time, so I think the logic board has burnt out, or something equally expensive. Problem being that I need a Mac in order to make money, so I had to bite the bullet and order another one from Apple. On the plus side I ensure I back up everything using Time Machine, so fortunately all of my work was backed up. If you don’t back up, you need to start now! Data is so much more valuable then hardware!

My contribution to the Royal Wedding hysteria!

My contribution to the Royal Wedding hysteria!

Back to the UK

So after four months in Canada I’ve finally made it home and I’m settling back in to work after having so much time off. I’ve been all over the country in the past week attending interviews for various positions.

I attended an interview in Manchester to work as a volunteer for the London 2012 Olympics, I probably talked far too much, but it was great fun to talk to a bunch of people who were really passionate about what the Olympics is going to bring to the UK. I’ve heard nothing but negative reaction in the press regarding the 2012 games, but I think it’s going to be a fantastic festival of sport for the UK. I for one cannot wait if I’m involved or not, it’s just going to be a fabulous summer!

I also attended an interview for a Ruby on Rails developer position in Covent Garden, It was such a beautiful day, and confirmed everything I have thought about working in London, the buzz of the place and the cosmopolitan lifestyle is something that really appeals to me. I really hope I get the job!

So accurate it&#8217;s untrue!

So accurate it’s untrue!