home / blog

Category Archives: geek

Responsive 2D table

For WeatherSupermarket I need to layout a grid forecasts for five days for up to six providers, Met Office, AccuWeather etc. I have the providers vertically, each with the location, and a dropdown box to change the location. The days … Continue reading

Posted in geek | Tagged , | Leave a comment

CSS spriting using RMagick

I wanted to give CSS spriting a go – i.e. one large image montage and then using background-position to ‘see-through’ to the correct image. The best off the shelf solution looks like SmartSprites but this requires you annotate your CSS … Continue reading

Posted in geek | Tagged , , | Leave a comment

Assorted IE8 polyfills: forEach, trim, placeholders

I ended up using all of the following during recent development of weathersupermarket 2.0 and another site. Array.prototype.forEach() implemented using a for loop and fn.apply if (typeof Array.prototype.forEach !== ‘function’) { Array.prototype.forEach = function(callback, context) { for (var i = … Continue reading

Posted in geek | Tagged , , | Leave a comment

Rails, active record, concurrency and scaling

Coming from a Java background I’m confused by ruby’s poor support for concurrency The problem… I’m rewriting weathersupermarket, a screen scraper for weather forecasts using Rails. This is the basic logic of server forecast service. user requests forecast for location … Continue reading

Posted in geek | Tagged , | Leave a comment

“unknown compression method” with open-uri

In my local build of ruby 2.1.1 I see “unknown compression method” when calling open on certain URLs… net/http/response.rb:357:in finish’: unknown compression method (Zlib::DataError) It looks like open-uri adds the header saying it can accept gzip and deflate (Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3) … Continue reading

Posted in geek | Leave a comment

Simulating a server with netcat

Note use of \r\n. and echo -n, i.e. no automatic new line and -e escape chars echo -ne “HTTP/1.1 200 OK\r\nContent-Encoding: gzip$(echo hello-world | gzip)\n” | netcat -l 4000

Posted in geek | Leave a comment

jQuery building array selector

I’ve just been working on code to dynamically show/hide columns in a horizontal table to fit the width of the browser, i.e. show 1 column on 320px mobile, but all on desktop etc. To support this I need to animate … Continue reading

Posted in geek | Leave a comment

HTTP 503 from IE6 on dreamhost

It seems that dreamhost somehow returns HTTP 503 if the user agent is exactly “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)”. This is from the modern.ie IE6 windows XP build. wget –user-agent “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; … Continue reading

Posted in geek | Tagged | Leave a comment

AJAX contact form with Ruby CGI backend

In 2013 I vowed never to write a line of PHP again, it’s dirty and bad for your CV. When it came to implementing a basic AJAX form for a small campaign website I decided to use my new friend … Continue reading

Posted in geek | Tagged , | Leave a comment

Thunderbird: “The server may have gone down or there may be a network problem” [SOLVED]

Bizare issue on OS X 10.6 effecting both Mail and Thunderbird. Mail simply fails to download inbox, silently without error – helpful. Thunderbird reports “server email@example.org has disconnected. The server may have gone down or there may be a network … Continue reading

Posted in geek | Leave a comment