Scott Rutherford

Life on and off the Rails

 

So, I got a great email about an hour ago:

To the creative genius[es] behind TweetLists,

We'd like to congratulate you on being selected as our MASHUP OF THE DAY at MashupAwards.com for July 30, 2008.

Mashup of the Day

So, not all that familiar with The Mashup Awards, but others clearly are as the resulting traffic killed the site (not that that would of been hard)! I would like to say thank you to them for the award and also take this opportunity to thank my manager, parents, producer, jesus, god, twitter!, Tim Berners Lee, Matz........

Right then off to 'enjoy basking in the glow of my well deserved recognition' as suggested by 'The Mashup Awards Judging Panel'

So I needed to parse the log files for SlimTimer this weekend to correct a data loss issue due to a small issue with implementing https for subscribers. The issue required looking for requests that had returned something other than “200 OK” collecting the parameters and entering any data that had got lost. After a bit of messing around it occured to me the the format of the parameters string in the Rail’s logs was not a million miles from the JSON format, so I came up with this to turn the string into a useable hash:

params =~ /.*: Parameters: (\{.*\})$/
str_hash = JSON.parse(params.gsub('=>',':'))

This provides a hash of the parameters used in the request. Of course the keys here are strings so to convert to symbols we can then use:

def create_symbol_hash(input)
  ret = input
  if input.is_a? Hash
    ret = {}
    input.each do |k, v|
      ret[k.to_sym] = create_symbol_hash(v)
    end
    ret
  else
    ret
  end    
end

and simply pass in the output from the JSON library. Seemed quite neat to me anyway.

So just got back from a great 2 weeks in California, went to Foo camp, Social Media Camp, Mashable and a couple of other meetups – all excellent. One slight hiccup with the hire car…..... I claim it was the taxi’s fault (of course), although its a bit of a blur to be honest.

On the up side I can highly recommend Enterprise (and taking out the full coverage), they were very helpful and polite. Even offered me a new car – which would of seemed like a better idea if I could move properly!! At least no one was badly hurt.

This blog used the Shay theme as a base and is powered by Mephisto