Split a Ruby Enumerable into chunks

Now and again I've had a need to split an array of strings into chunks divided by certain boundary patterns. Kind of like String.split, but for an array, and with multiple boundary patterns. The problem is something akin to splitting the different sections of a MIME multipart message.

In the latest instance, I wrestled with Ruby's takewhile and dropwhile for a bit, before giving in and kludging together an ugly state machine solution, which I shipped. However, I wasn't happy with it, so I went back and built a better solution.

Click to read more ...


Adding no-default, non-NULL columns to an existing ActiveRecord model

Recently I had to add a new property to an existing ActiveRecord model. The model represents periodic invoices issued to electricity customers and the new property described the time covered by the invoice in days. The new property is mandatory, but there is no sensible default that can be filled in for new records. However, for legacy records it was deemed acceptable to set a length of 31 days.

Click to read more ...


On Future-Proofing

I know he means well, but every time my boss talks about future-proofing, I cringe. On the face of it, future-proofing your software, that is, building your code in such a way as to allow it to meet future requirements with minimal refactoring, sounds like a worthy ambition, but in my experience it's always disaster.

Click to read more ...


5by5 Radio App

A few months ago I discovered and have since become quite a fan, so I was quite excited when the 5by5 Radio iOS app was released late last week. The thing I like about this app is that it does exactly what it says and no more - it lets you listen to 5by5 programmes live. In particular, it does not attempt to enter the already-crowded podcast client space. Beyond the basic streaming function, it offers push notifications to let you know when your favourite shows are about to come on, and a recording schedule for upcoming shows. That's it. Satisfyingly simple.

Click to read more ...

Page 1 2