Mitch Crowe

On web development, robotics, and being a nerd

Form Extensions: A Form Object’s Skinny Little Brother

| Comments

You have a form who’s fields don’t match up to a model. What do you do?

Ask any web developer, and they will confidently defend one of three patterns: fat controllers, callbacks, or form objects. It’s an on-going, heated, debate.

I would like to propose a fourth pattern, form extensions, which I will argue is often the most pragmatic approach. It is probably not a new idea, but it certainly doesn’t get the lip-service it should. It deserves a name, and a first-class position in a web-developer’s toolbelt.

Roleable Roles for Ruby on Rails

| Comments

I was searching for just the right roles system to go with my cancan authorized, ActiveRecord-backed Rails app, and didn’t find anything I liked. There are at least a dozen gems out there, but they were all either too simple, too complex, or too ugly for my liking. So, like any good open-sourcer, I wrote my own after my biased taste. And, roleable was born. Check out the project page, and the API documentation.

roleable is deliberately simple in it’s implementation. It allows you to add user roles scoped to a instance of another model (e.g. make a use an author of a given article), or global roles (e.g. an admin role).

Soulmate.js—A jQuery Front-end to the Soulmate Auto-suggestion Gem

| Comments

Soulmate is an excellent auto-suggestion gem built for speed on sinatra and redis. I recently switched a project’s auto-suggestion engine to it from sphinx, and saw 200ms average response times drop to 10ms. Aside from speed, another huge boon was being able to completely separate the auto-suggestion engine from the main app. This allows it to get overwhelmed with a huge number of requests without significantly affecting the user’s experience. (Decoupling is good!).

Easy Rails Debugging in IE With a Mac and VirtualBox

| Comments

Internet Explorer is still more than 60% of my traffic, and I need to do a lot of feature testing on it. A lot of folks push up to a staging server then point a virtual machine to that server. This is too slow for me. Especially when I’m hunting down and fixing particularly pernicious css bugs, there is a lot of tweaking involved, and re-deploying for each test just doesn’t cut it.

Rubynu—A Scaffold Generator for Ruby Projects

| Comments

Creating my preferred scaffolding for new ruby projects by hand has gotten old. Sure, there are tools out there like bundler’s bundle gem to do this for you, but they aren’t flexible enough to meet everybody’s preferences. I want something as flexible as my tastes are fickle, something I can change the template to on a whim.

Paranoid - a Backup Script for When the World’s Out to Get You

| Comments

When I’ve put a ton of effort into a personal project, I tend to get paranoid that I’ll somehow find a way to toast it. I know, I know, git, github, and time machine already have my back. Sometimes that’s just not enough, though, and I find myself periodically making manual copies of important projects to a backup directory. Whether I need it or not, having hardcopy snapshots just makes me feel better.

Filtering Pop-ups From Embedded Scripts

| Comments

Recently I had a problem where a creative embedded on my site was periodically opening pop-ups on my users without my consent. The agency’s team assured me this shouldn’t be happening, but claimed they couldn’t re-create the issue. In truth, they just sell too many third-party ads to verify all of them.

I Was Framed!

| Comments

Patrolling the SERPs for a website I was working on one day, I came across something odd: An exact duplicate of my site at a different domain, startlingly high in the rankings. Here is its source:

Javascript Templates to the Rescue

| Comments

I’m a huge fan of ajax requests which simply return json, letting the client decide what it wants to do with the data. Formatting that data into html client-side, however, has always felt ugly as sin to me. So, we revert to rendering the html on the server and sending that html as an ajax response. This model is fine for simple pages, especially when all we want to do is display data asynchronously. Once we want to interact with this new data, do calculations on it, manipulate it further, things start to get ugly. In the end, I strongly believe that when the client requests data via ajax, it should get data, and not display logic, back.