December 2011
2 posts
Serving Ember.js with Rails 3.1's asset pipeline
Last week I spent some time modifying Kisko Labs’ sproutcore-rails gem to use the latest build of Ember.js. emberjs-rails is a fairly simple wrapper that add’s support for serving Handlebars templates from the asset pipeline using a hjs file extension. It also serves Ember’s html5 boilerplate template as a layout called ember. Here’s a quick run through:
First, start with...
Properly validating email addresses.
There seems to be a lot of chit chat in the rails world about correctly validating email addresses. The main problem is the compromise between speed and correctness, observe:
The examples above illustrate the possible methods of email validation ranging from pathetic to extreme. Given the average response speed of DNS, I think it’s legitimate to attempt a DNS lookup of the addresses...
August 2011
1 post
"no reply": it's just not cricket
You know what I’m talking about. Businesses all over the world send out emails, whether they’re some sort of notification, invoice or marketing communication and they disallow direct replies, either by explicitly asking you not to or using a dead-end email address such as “no-reply@idontvaluemycustomers.com”.
This totally disrespects your customer, and devalues their time....
May 2011
1 post
Doing AVR development on a Mac?
Yeah, I know. The Arduino development environment is quite limiting - especially if you are using an AVR chip that is not supported or you don’t have room for the bootloader in your project.
Something you might not have realised is that the Arduino environment comes with all the development tools needed (avr-gcc, etc) needed to build and burn firmwares for a large number of AVR based MCUs....
February 2011
1 post
axe.io: Welcome to axe.io →
axeio:
Here’s the thing; I’m in this band, and due to the terrible prog rock nature of this band I needed more control over my tone than I was able to get just from my amplifier, so I invested in an iRig and a copy of Amplitube for iPhone. I was blown away by the quality of simulation available on…
December 2010
1 post
November 2010
3 posts
Serve GridFS files directly from rack.
Kimono is using Carrierwave to handle image attachments and save them into GridFS - MongoDB’s built-in filesystem. GridFS is great because you get the benefits of MongoDB’s replication and sharding. Putting files into GridFS is pretty straight forward, and I won’t waste time getting into that here, Jeremy Weiland has written an excellent post on using Rails 3, Carrierwave and...
Start and stop Delayed::Workers with daemonizer
Delayed::Job comes out of the box with a startup script that relies on the daemons gem. to start and stop worker processes. Problem is, I’ve never actually had it work. After browsing around my options I decided to give daemonizer a go. The main advantage I saw to daemonizer is that you simply define a single “Daemonfile” in your project’s root (similar to a Gemfile or...
Automatic rebuild of HAML and SASS.
I love HAML. I love SASS. They’ve both saved me a heap of time writing view code in Rails, but what if you’re throwing together some static HTML and CSS to mock out an interface? This is where the Travis Tilley’s excellent file system state monitor gem comes in:
Boom!
October 2010
1 post
Patch Rails3 route helpers to use STI base class.
If you’ve perused the source of any moderately complicated Rails application you are likely to have come across the Single Table Inheritance (STI) pattern. STI allows you to have polymorphic models all stored in the same table or collection. It may be best to give you an example:
As you can see from the example, we have three models, Meat, Bacon and ChunkyBacon all using the...
September 2010
1 post
Dynamic finders for Mongoid →
I’ve been busy over the last while switching a Rails 3 application over from ActiveRecord to Mongoid. In a lot of ways it has gone a lot less painfully than I expected, however one of the main problems I ran into was the common use of dynamic finders in controllers:
Mongoid (at the time of this writing) doesn’t officially support dynamic finders, so I have done one of my...
July 2010
2 posts
Our Rails3 Presentation from Barcamp Auckland 4. →