Subscribe

New plugins

0

Written on September 26, 2008 by george

I’ve just pushed two plugins to github. The first is an improvement on the standard Defensio plugin that only checks the validity of your API key when posting articles or comments. This is better than checking each time a model that uses the plugin is instantiated as it doesn’t require contact with the Defensio API (so is faster) and also won’t bring your site to a standstill if someone is just viewing a page and the Defensio service is down.

The second updates the highly useful timed fragment cache plugin by Richard Livsey to support Rails 2.1

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • LinkedIn

Wordia – an online dictionary

0

Written on September 26, 2008 by george

For the last 6 weeks I’ve been head deep coding for a new startup wordia.com The idea is rather fresh – to allow people to learn the meaning of words by watching videos of people saying what the word means to them. So far my favourites include invention by Nikki Grahame of big brother fame, bannana by two randoms at Edinburgh festival and, as everybody looked up rude words when they first got access to a real dictionary, incest.

Dictionary past and present It’s been a really hard few work so was very rewarding on launch day (after 4.5 hours of sleep) to see London’s press arrive at our launch event (see photo left). The site went down well and we featured in most the major newspapers in the following days. It was also great to meet our backer Michael Birch in person having recently exited from Bebo

In the coming months we’ve lot of new features planned and exciting people lined up to film with. I’ll also be dropping back down to 3 days per week so I can get working on my own projects again. It should be an exciting 3 months.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • LinkedIn

Who really won the olympics?

0

Written on August 27, 2008 by george

Olympic rings I’ve just finished the excellent Freakonomics book. If you’ve not heard about the book the authors, an economist who dislikes Maths and a Journalist, ask unusual questions about everyday situations – does abortion effect crime rates, are estate agents telling you the truth about your house price and what really makes a good parent. On the back of such an enjoyable read I also subscribed to their blog, which although a little post heavy, does offer some good insights. One that I found of particular interest was regarding Olympic medals. Comically the American media used the total number of the medals as the medal table ranking system, and not the official number of golds, then silver, then bronze system. This of course ensured they *beat* the Chinese.

Of more interest though was this later post about calculating the medal table by country population (I have long used this argument to explain why America gets more medals than us). Pretty interesting I thought, but of course this goes deeper. There are other factors that would truly measure a nations athletic talent – national expenditure on sport and maybe even climate are two that spring to mind.

Australia, one of the best sporting nations, is still considering a review of the way they fund sport after such a dismal performance though. Using the freakonomics chart they shouldn’t be so disappointed (even if they did get beaten by New Zealand)!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • LinkedIn

ActiveRecord outside of Rails (and YAML)

0

Written on July 16, 2008 by george

Lately I’ve been working on a stock trading program that automatically trades and saves the results to a database (more details to follow in the not too distant future…)  Naturally the choice of language was ruby, and for the front end, a rails application.  Once coded, I bundled the stock trading program into the rails lib folder and reused the rails model for saving to the database.

I ran into a slight problem doing this though as ActiveRecord needs configuring manually outside the rails framework but I wanted to follow best practices and keep my code DRY. After a quick search I found a clean solution that allows you to re-use the database.yml configuration file from the rails application:

dbconfig = YAML::load(File.open('config/database.yml'))
ActiveRecord::Base.establish_connection(dbconfig["development"])

This snippet got me thinking about YAML which I use a lot but have never played with in Ruby. It turns out the YAML class is basically a hash that uses strings (gotcha not keys) to access a simple hierarchy:

dbconfig = YAML::load(File.open('config/database.yml'))
dbconfig["development"]["adapter"] # = mysql

All very simple stuff but if its never crossed your mind before, you yet again appreciate the elegance of ruby.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • LinkedIn

Testing your rake tasks

0

Written on June 28, 2008 by george

This week I’ve been working on a client project where I needed to import a massive XML dataset into a database.  The XML was non-standard and broke its own rules in several places.  Consequently my rake task quickly become very complicated and I needed some tests to ensure I wasn’t breaking previous work.  This leads to a rather interesting question: how do you test rake tasks?  After a bit of googling I found a rather neat solution of simply pulling out the rake code to a class. For example, rather than:

desc "Import the XML"
task :import => :cleanup do
  File.open(XML_FILE) do |file|
    # Do importing here...
  end
end

do something more like

desc "Import the XML"
task :import => :cleanup do
  File.open(XML_FILE) do |file|
    XMLImporter.parse_lines(file)
  end
end

XMLImporter can then be tested in the normal way. Good ruby – clean and effective.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • LinkedIn