Faker 1.0 released

10 September 2011

Earlier this week I released version 1.0 of the Faker gem. It's been about 4 years since the initial release of the gem, and the API has been fairly stable for the last couple of years, so I figured it was a good time to make the jump to 1.0. :)

This release finishes the conversion to I18n. Just about everything is in the locale files now, including the ability to define custom formats for everything -- company names, street addresses, etc. And, with the magic of method_missing, you can add new items to your locale file and have them show up as methods in the Faker classes.

The 1.0 release also settles some long-standing issues people have had with bad interaction between Faker, Rails 2.3, and locales (especially fallbacks). Though I'm not actively seeking to support Rails 2.3, I at least don't want it to be broken, so this release should cover that. Both Ruby 1.9.2 and 1.8.7 are fully supported.

Finally, I want to send out a big "thank you" to everyone (and there are a lot of them) who contributed code and ideas to this release. I really appreciate the interest shown and the work done by so many people who use and love Faker. According to rubygems.org, it has been installed over 400,000 times — over 1,000 times in the past few days!

Of course, I'm not done yet... next on the feature list is Faker::Image, which will provide an interface to all those cool fake image generator services out there. :)



Jekyll: Pagination, Archives, and Excerpts

23 May 2011

I recently converted this blog to jekyll — I figured since I had to move my slicehost slices elsewhere anyway, I might as well ditch wordpress and play with something new. It's been a bit of adventure getting the site rendered by jekyll to match the URL structure I had in place with wordpress, so I thought I'd share some of the code I found and wrote to make it work.

Read the rest of this entry »



Auto-spawning Delayed Job Workers

12 April 2011

I've been interested in simplifying lately.... using Chef (solo) to configure boxes, switching to Postgres from MySQL to get decent text search without having to run sphinx, etc. My goal recently has been to cut down the number of moving parts in my deployments to make my life a little easier. So when a client project required background processing, I re-evaluated my stock approach to see if I could simplify a bit.

Read the rest of this entry »



Unwrapping UploadJuicer

20 July 2010

It says something about the sorry state of my blogging lately that my blog is the last place I'm announcing my latest project, Juicer. :) It's a handy service for offloading image uploading and resizing from your web app. Now you don't have to tie up your server to handle long uploads or to do a bunch of thumbnails. You can keep your app super-responsive for the core of what it does, and leave the uploads and resizes to us.

Though my blog is the last place I announced the project, it'll be the first place I announce the Ruby gem that goes along with it. :) I just published a gem that uses the Juicer API (via RestClient) and makes it pretty easy to integrate Juicer with a Rails 3 app. I've done the hard work of getting the direct-to-s3 upload with swfupload working for you, so all you have to do is make a few tweaks to your model and you have uploads and thumbnails done for you. You can get at the gem (and a sample Rails 3 app) at Github.

We'll be posting more about Juicer at the Juicer blog, but I imagine I'll mention things about it here from time to time. :) And hopefully I'll get around to posting some of the fun code-related things that make up the service.



Drag and Drop Sorting with JQuery and Rails

31 October 2008

I decided to switch to JQuery recently, and I've been enjoying it. Part of the fun is trying out all the plugins that are available. :) This past week I needed to do drag and drop reordering for the first time since moving over to JQuery, so I thought I'd share some of the code that makes this really easy.

With Prototype, you can use the javascript that comes with the Rails distribution, but for this case I decided to go with the Table Drag and Drop JQuery plugin, as it had the right combination of functionality and ease of use. Once the plugin is in your project, getting a sortable table is very simple.

First up is the view, with the javascript injected into the head section of the document by using content_for. You'll note that for this simplified example an unordered list actually would have been better than a table, but in the original app I wanted to use a table for this list of items, so I wanted to make sure to use a plugin that supported that.

After creating the table, we simply use the document ready event to add some behavior to it. The plugin serializes the ids of the table rows in an array and sends that array, named after the table id, as a parameter to the controller. I add the authenticity token to the parameters sent via AJAX, and if the action was successful I just pop up an alert.

The controller iterates over all the specifications, checking the position in the db (see the acts_as_list plugin) versus the position in the array that was sent in the request. For the items that are affected, it updates the position in the db. Since we are only calling this action via AJAX, we just render nothing and indicate a successful status.

Of course there are few bits you can pretty up, both in the view and the controller, but that's the basic approach. Fast, easy, and client-approved. :)