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
Tag: ruby
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
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 Ruby, but wasn’t as straightforward as I had hoped… The site is otherwise static so… Continue reading AJAX contact form with Ruby CGI backend
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
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