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 are laid out horizontally. This has always worked fine for Desktop browsers with plenty of… Continue reading Responsive 2D table

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 with configuration… So I wondered if I could knock something cheap and cheerful using RMagick… Continue reading CSS spriting using RMagick

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 = 0; i < this.length; i++) { callback.apply(context, [ this[i], i, this ]); } }; }… Continue reading Assorted IE8 polyfills: forEach, trim, placeholders

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 123 get location 123 from database if last forecast retrieved more than N seconds ago… Continue reading Rails, active record, concurrency and scaling

“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) but if deflate is sent it blows up. # broken – defaults to “Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3″… Continue reading “unknown compression method” with open-uri

Published
Categorized as geek

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

Published
Categorized as geek

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 the Nth cell from each row concurrently. Firstly create an empty selector $([]). Apparently $()… Continue reading jQuery building array selector

Published
Categorized as geek

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; SV1)” “http://hellomynameis.org.uk/” –2014-04-09 11:31:18– http://hellomynameis.org.uk/ HTTP request sent, awaiting response… 503 Service Temporarily Unavailable 2014-04-09… Continue reading HTTP 503 from IE6 on dreamhost

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 problem” Cause avast email virus scanner. Solution. Disable email virus scanner.

Published
Categorized as geek