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

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

Ruby – latitude/longitude from start point, bearing and distance

class CoordinatesCalc def CoordinatesCalc.offset_coordinate(lat_deg, lon_deg, distance_m, bearing_deg) r = 6371000.0; lat = lat_deg * Math::PI / 180 lon = lon_deg * Math::PI / 180 bearing = bearing_deg * Math::PI / 180 distance_by_r = distance_m / r lat2 = Math.asin( Math.sin(lat) * Math.cos(distance_by_r) + Math.cos(lat) * Math.sin(distance_by_r) * Math.cos(bearing) ) lon2 = lon + Math.atan2(Math.sin(bearing) *… Continue reading Ruby – latitude/longitude from start point, bearing and distance

Published
Categorized as geek Tagged

Rails 4.0.0 with Ruby 2.0 on a Dreamhost shared server

Build ruby from source. RVM won’t work out of the box because it tries to use sudo. It’s quite easy. cd mkdir build cd build http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz tar xzf ruby-2.0.0-p247.tar.gz cd ruby-2.0.0-p247 ./configure –prefix /home/adamish/ruby # <=== make sure you install to your own home directory make install Make your custom ruby default. Add the following… Continue reading Rails 4.0.0 with Ruby 2.0 on a Dreamhost shared server