Ruby

http://s.erious.ly

Author Archive

Duck it.

Ruby is not a strongly typed language so we sometimes need to check types explicitly. In a ducktyped world this might be less obvious than you might think. In particular, testing code that is testing input types explicitly can be harder than needed. This morning I came to work with a bunch of spec failures...

ZOMG assembly metaprogrammin shitz!

Joe Damato over at timetobleed.com just let their new memory profiler out of the box.

Go read more about it here...and whoever is interested in Ruby internals and lowlevel x86 architecture, do take the time to read through the previous posts about the road to achieve unintrusive instrumentation to the...

[SOLVED] 64bit MySQL and 32bit Ruby: FAIL

For the people out there using RVM to rock multiple Ruby versions, here's a gotcha with REE and Snow Leopard that took me hours to solve: if you happened to boot your mac in 32-bit mode when building ree with the oh so awesome:

rvm install ree

And then install MySQL 64bit and try to install...

Good Ruby Times

In the last few weeks I've had the chance to glance into several different codebases, some written years ago by devs in their Rails-infancy (rainfancy?).

Doing the travelling codes-man like that is a golden opportunity to see what people's stumbling blocks are and how a few easy tricks can improve the code substantially. ...

Ruby Daemons and Angels

Unix is pretty good at managing processes. Fork is a simple yet powerful means of achieving parallelism for workloads that are reasonably well self-contained.

The web application development racket has a higher tier where the load can be so insane that the standard "receive request, process it, format a reply and...

Creating PDFs with MacRuby

Macs are cool. Cocoa is cool. Ruby is cool. Matz is nice so we are nice. Sansonetti&Co at Apple are like the master drinkmixers, joining together the best of the best in one neat package. I'm talking about MacRuby.

Also_cool_fu

The latest MacRuby dev branch, 0.5, is using LLVM and packs speed and...

Installing ruby-filemagic on MacOS X and Ubuntu

FileMagic is a Ruby extension that provides an interface to libmagic, i.e. the lib version of the *nix 'file' command and provides easy access to the system mime database along with some nifty heuristics to determine filetypes.

Checking that what-you-got-is-what-you-want is often important, especially when dealing with file uploads and/or third-party integration APIs providing file...

EBS striping: worthwhile?

A while back I discussed the performance on Amazon EC2 EBS volumes with some of my colleagues. The discussion went kinda like "yeah, I/O performance sure isn't stellar but striping disks really doesn't make much sense as EBS volumes are already striped by Amazon and in any case they're SAN drives, so the bottleneck...

Testing invocation of external executables, %x{}, `

If you ever found yourself trying to write tests for code that invokes an external executable, such as:

  class Beef < ActiveRecord::Base
    def diskspace(flags = 'sh')
      `du -#{flags} .
        

Stubbing a method for all tests

If you ever need to stub out a method for all tests in your test suite, for example a before filter in ApplicationController that goes takes a while to run, here's a neat trick.

Stick the following in your spec_helper:

Spec::Runner.configure do |config|
  config.before(:each, 
        

pdf2swf on Mac OS X and ASVM mismatch

EdgeThe current version of swftools in macports is 0.8.1 and for many cases it's not good enough. In particular, for pdf2swf to generate swf files that are recognized as ASVM3 (i.e. Flash version 7+ I think, but do correct me if I'm wrong) you need swftools 0.9.0 or greater. Loading an...

Ruby 1.9 isn’t always faster: rake tab-completion revisited

Rake is awesome in many ways and we're all using it for a plethora of tasks. It's easy to use, fast to code and reliable.

A while back I blogged about tab completion for rake tasks and the other day I set out to speed it up, as the project I...