Rob Lacey

Brighton, UK -

Software Engineer specialising in Ruby on Rails. I do occasional freelance work, I love working for SARD JV Ltd, they are awesome and give me my pocket money every month. By all means dangle a carrot.

Oooh....erb templates in javascript

Found this ERB for jQuery script this morning from Dan Webb

// ERB style templates for jQuery in hardly any code.
// Based on
// A tiny and simple plugin to allow erb style template rendering within jQuery.
// Make a template:
// <script type="text/html" id="template1">
// <% $.each(items, function(i, image) { %>
//   <p><img src="<%= %>" alt="<%= image.title %>"></p>
// <% }); %>
// </script>
// Render the template into the dom with some data:
// <script type="text/javascript">
// jQuery(function($) {
//   $.getJSON("", function(data) {
//     $('#test').render('template1', data);
//   });
// });
// </script>
// Alternatively, you can load templates from files:
// $('#test').render('template.ejs', data);

jQuery(function($) {
  var cache = {};
  function compile(source) {
    return new Function("obj",
          "var p=[],print=function(){p.push.apply(p,arguments);};" +
          "with(obj){p.push('" +
            .replace(/[\r\t\n]/g, " ")
            .replace(/((^|%>)[^\t]*)'/g, "$1\r")
            .replace(/\t=(.*?)%>/g, "',$1,'")
        + "');}return p.join('');");
  function load(template) {
    if (!(/\W/).test(template)) {
      return compile($("#" + template).html());
    } else {
      var source;
        async: false,
        url: template,
        dataType: 'text',
        success: function(data) {
          source = data;
      return compile(source);
  $.template = function(template, data) {
    var fn = cache[template] = cache[template] || load(template);
    if (data) return fn(data);
  $.fn.render = function(str, data) {
    return this.each(function() {
      $(this).html($.template(str, data));

Lazarus, pimping up music since 2009

Rails Way - Das magazin fur Ruby on Rails

I found this little gem in a bog standard boring, run of the mill newsagents in Berlin, Zoologischer Garten. Perhaps Germany is more tech friendly but having monthly Ruby on Rails, PHP, .Net and Java monthlies is is quite crazy for what would be a small readership.

Available at

Git remote branches

Nice little and verbose script to aid with the creation of remote git repos.

git-remote-branch create sv1.8

or to track an already existing remote branch

git branch --track sv1.8 origin/sv1.8


Why does IE8 ignore this, grrrrrrrrr.

<!--[if lt IE 8]>
<script src="" type="text/javascript"></script>

It seems that the ie8.js script doesn’t like being used inside a frame.

Hi dean,

First of all great work. I have a problem when I use your script inside a frame (ugly, I know). I get a permission denied on ‘if(/ie7_off/.test(||k<5)’.

Any thoughts on a quick fix?

Thanks, Ronald Moolenaar 

YAML defaults

I really do love the way you can add defaults in YAML

development: &defaults
  consumer_key: randomzombieaction
  consumer_secret: morerandomzombieaction
  <<: *defaults
  <<: *defaults
  <<: *defaults

Stewie Vs Zombie

Who will win?

Donkey Kong Vs. Stewie

Who will win?

jQuery, Nano and Songkick

Knocked this one up earlier today to get my Songkick gig listings on this here blog. Maybe its just the novelty of having some gigs to go to and a bit of showing off that we’re running off to Germany for 11 days of mayhem and we’ve not learned how to speak the language yet.

$(document).ready(function () {

  var template = "<li><a href='{uri}'>{displayName}</a></li>";
  var apikey = '<your apikey>';
  var container = $("ul#concerts");

  $.getJSON('<your songkick username>/events.json?apikey=' + apikey + '&jsoncallback=?', function(data) {
    events = data["resultsPage"]["results"]['event'];
    $.each(events.reverse(), function() {
      container.append($.nano(template, this));


Pledge Music Alpha Launch

Our new project Pledge Music went into Alpha just over a week ago and by all accounts its been a success.

“Pledge Music is a way for fans to help their favourite artists make records and raise money for charity. By combining new social networking technology, fan incentives and old school music biz know how, fans can visit the site to not only hear great new music, but also share the experience with friends and get actively involved in what they are listening to.”

We launched on two platforms Facebook and Pledge Music with our first project Another Last Goodbye by Marwood. The project aimed to raise $5000 in order record a CD with a percentage of the profits going to Amnesty International and met its target with 7 days of launch which we’re very pleased with.

Now we have a successful Alpha test, Marwood are entering the studio to record their album over the next few weeks and we look forward to hearing the album very soon.

Now the real work begins as we do a last push to move through Beta and into a full release over the next month with another 9 projects already in the pipeline. Go team.