How I use Ansible’s roles, tags, and dependencies to organize my playbooks.
I wanted a way to see production S3 assets in development when using a production database export.Abusing Rails' Middleware to Remove Google Ads in Development
I finally snapped and no longer wanted to see Google ads while developing my Rails app.PostgreSQL's JSON vs Rails' Serialize
A recent article on persisting hashes in Rails using PostgreSQL made me curious about performance.Broken Images in Emails Sent via Sidekiq?
Images broken in email when sent via Sidekiq? Make sure your assets are compiled.My Bash Prompt
I spend most of my day in the shell. This is my bash prompt with support for RVM and git branch information.
I use Pow to manage my Rails applications. I have quite a few and sometimes forget what I’ve named them. Here’s my solution.Make Zeus work from any subdirectory of Rails.root
Zeus is great for speeding up various Rails commands like console and tests, but it must be run from Rails root. Here’s a way to get around that.CGI.escape and "Undefined method 'bytesize' for nil:NilClass"
How to solve this annoying error once and for all.Build your own Ruby and Rails Searchable API Docs
Online docs are nice, but having a local, searchable copy is even nicer.
Given a HATBM relationship, the use of the ‘association_ids=’ setter can lead to a very unintuitive error.In Ruby, dividing by zero doesn't always raise a ZeroDivisionError
Sometimes it raises “ArgumentError: comparison of Fixnum with Float failed” instead.
I ended up with a little too much free time the other day and was curious to see what would happen if I fed the entire history of Rails' commit history through the visualization tool glTail.Use AppleScript to automatically close Safari's Downloads window
For whatever reason, Safari has no option to automatically close it's "Downloads" window after a download completes. There are some older plugins that do it, but they tend to have a lot of other features I don't want. AppleScript can do it in use with Folder Actions.Speeding up thumbnail generation with Paperclip
On the heels of my other Paperclip patch I noticed that generating four styles from a large original and auto orienting them takes a lot of time (about 12 seconds on average). Trying to cut that time down I wondered if it would be possible to generate the smaller thumbnails from the larger ones.Rails, Paperclip, -auto-orient, and resizing...
I recently had a situation in which I wanted to generate thumbnail images and have them constrained to 67x50 (specifically "67x50>"). No problem so far, but I also wanted to auto rotate (via Imagemagick's -auto-orient option) the images as they all come from a digital camera that provides this information. This causes a problem. Namely that some images ended up being 50x67 instead of 67x50.Hanger9 FS One Running in Parallels 5 on Mac OS X
MuPromo has a software bundle containing Parallels 5. Tempting. Wondered if I could run Hanger9 FS One in it so I wouldn't have to use Bootcamp like I have been doing. The answer is yes, I can!Another Reason People Prefer Macs to PCs
Yet another unscientific reason people prefer macs over PCs. Just look at these instructions.
This may not be very scientific, but perhaps this is why Ruby is such a wonderful language.Sphinx Search 0.9.8.1 Debian Packages
There's no (to my knowledge) package of Sphinx Search for Debian. Following some instructions I went ahead and built some for Debian 5.0. Feel free to use them.Facebook Connect + Safari + Click to Flash = No Work
If you're developing a Facebook Connect application, using Safari, and have installed the ClickToFlash plugin to stop flash from loading automatically, none of your FBML tags will be parsed. This is a known issue with ClickToFlash and apparently fixed in HEAD. But until that's released watch out.Hanger9 FS One Review
I just bought Hanger9 FS One and wanted to quickly say that it's awesome and runs great on a Macbook Pro via Bootcamp.RadiantCMS Extension for Syntax Highlighting via CodeRay
I recently converted this website to using RadiantCMS. Many of my articles include code samples. In the past I had written a plugin for webgen to use CodeRay to provide syntax highlighting. I've now done the same for RadiantCMS.Creating an Audit Log in Rails
Someone just asked how to track changes via an audit log in Rails. They wanted more than just model observers however -- they wanted to track the logged in user and some other session related data. I recently did something just like this.Manually Invoking a Rails Sweeper
Let's say you have a Rails app, and that app has a Photo model, and that photo model has many Destinations, and the destination pages are cached to disk, and when you update a photo you need to expire all of the destination pages that photo is currently associated with.New Toy - Mini Super Cub RC Airplane
I've always loved remote control machines and two days ago I got the new Mini Super Cub. It's awesome :-)Rails, Exceptions, Hoptoad, and Annoying User Agents
Hoptoad is an excellent service that allows you to funnel all of your Rails exceptions to a central location so you can splice, dice, and fix them. I've noticed however that some web spiders mangle valid URLs into invalid ones and rather than deal with all the possible permutations it would be a lot nicer to simply have Hoptoad ignore them completely.
A friend just complained that he'd setup a server with all his gems and it would be nice if there was an easy way to do the same install on another server without having to retype everything. He wanted something like: gem install -l from_file.txtOSX + iTerm + screen + vim + 256 colors
I've used vim for a long long time. A couple of years ago I enabled syntax coloring, but the defaults aren't that attractive and recently I've begun to envy some of the Textmate color themes, particularly the theme used in Ryan Bate's Railscasts.Rails - hash_for_named_url goodness
It's well documented that if you use named routes in Rails you get the benefit of saying things like 'faq_url' and 'faq_path' in your code. But what if you want the hash that makes up that named route?Verizon, LG VX5400, OSX, Addressbook, Bluetooth
I recently switched to Verizon because TMobile had horrific reception where I now live. I got the LG VX5400 cause they were on sale, have good battery life and had bluetooth which as it turns out works with OSX.
I implemented page caching in a recent Rails project along with the necessary cache sweeper to keep everything nice and tidy. However, now I needed a way to expire pages outside of the web application - that is, from "script/console" and "script/runner".OpenAds - clientid vs. campaignid
We use openads at work and needed to directly target a client's banner. Any of their banners from any of their campaigns. You can't do "?what=clientid:123" since clients don't have any relation to banners. Campaigns do.LiteSpeed, Rails, and Rewriting URLs
I had a situation today in which I wanted to turn a url such as "/foo/bar/12345" into "/foo/bar/5/4/3/12345.html" and pass that into Rails.Alternating Row Colors in Apple Mail
By default there is no row divider in the message list of Apple Mail. No alternating colors, no divider. That's annoying.Patches to RoundCube Webmail
I had to setup a new webmail system for work and we picked RoundCube which has the best web UI for webmail I've ever seen. There were some features it didn't have however so I added those in. I think they might be useful to other folks so am helping google find them here...How to Extract a Thumbnail from an FLV File
I recently had a need to extract a thumbnail graphic from an FLV file in order to use it as a placeholder graphic. Found some help and pointers to ffmpeg and with some fiddling found a solution.Ubuntu Server 6.0.6 LTS and Parallels Hanging - FIX
I recently setup Ubuntu Server 6.0.6 LTS under Parallels just because. But it would hang while uncompressing the kernel.Ruby - Native MySQL Gem vs. Pure Ruby Version
I recently discovered that while I had installed the native mysql gem for ruby that it wasn't being used by my ruby (and rails) scripts. It turned out that even those the mysql.so was being generated correctly, it wasn't being copied into the right location.Bulk Deactivation of Banners in OpenAds 2.0
OpenAds is an open source ad serving software package. It's pretty nice too, but one thing it won't let you do is easily deactivate all banners belonging to a specific client. This can be a pain when those banners are remotely hosted and that host goes down, bringing your site along with it (well, not down, but making it less attractive).Swords for the Boys
I have two small boys who have recently been watching the BBC version of The Chronicles of Narnia and there's a lot of sword play so instantly every cooking utensil in the house and stick outside became a sword. Figuring they would want to really bash on each other I thought it would be fun to make them each a sword with a bit of padding.Litespeed, OSX, and Disk Scratching
I recently setup litespeed] on my OSX machine for development. Everything works great except that it writes to the hard drive every second. Turns out litespeed writes out it's status once a second to "/tmp/lshttpd/status" and that for some reason OSX doesn't cache that in memory. This can be fixed by mounting a RAM disk at "/tmp/lshttpd".Nginx and Cronolog
I recently setup Nginx for one of our webservers and needed to hook cronolog up to it for all the normal reasons you want cronolog. But Nginx doesn't support piped logging yet :( We can use fifo's though to accomplish the same thing :)Backups with Rsync
The following are the scripts I use to backup various servers that support rsync/ssh to a central server, automatically, keeping a couple week "change log", with minimal fuss. There are many other backup programs out there that are much more sophisticated, but they are also more work, and I'm not interested in archiving my backups for years and years and years. I just don't have that type of data nor a tape drive :)Building Rails and its friends on OSX
I recently switched to a mac and wanted to get our production environment running completely on my macbook so I could work remotely. This post is step by step (almost pastable) to get the following installed on OSX: MySQL, Subversion, ruby, ImageMagick, memcache, mongrel, and capistrano (as well as any dependencies).
Integrating OpenAds and Rails isn't that painful. Adding the code to the right spots will let you do something like this in your views "<= render_ad_banner('728x90') %>".Mongrel Rails Dashboard Widget
I've recently switched over to using a MacBook Pro for work. One of the nice things about that is the ability to run all my Rails projects locally. So I've got several different projects and branches of projects checked out and was getting tired of starting/stopping individual mongrels depending on which one I wanted to work on. So, I've written my first dashboard widget - Mongrel Rails.