home / blog

Tag Archives: ruby

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

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

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

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) … Continue reading

Posted in geek | Tagged | Leave a comment

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 … Continue reading

Posted in geek | Tagged , | Leave a comment