1. counter_cache for MongoMapper

    I’ve started playing with MongoMapper, and it’s quite excellent, but it does suffer very much from being young. There are lots of pieces missing that veterans of ActiveRecord will take for granted. I’ve been working around or patching them, for the most part, but I felt that my solution to :counter_cache deserved a post. …


  2. Safe action caching with Memcached

    I’ve started using action caching more aggressively, to handle a large volume of not-signed-in search traffic. It composes a significant chunk of my site’s total traffic, but there’s no good reason to be recomputing full pages for all those long-tail hits. So, the obvious thing is to just implement a quick action cache. …


  3. Eight tips for getting the most out of your Rails app

    Rails does an awful lot to optimize page generation, but there are a number of hacks, tweaks, and usage patterns you should be using to get the most out of your app. …


  4. When you have to store user passwords...

    Today we got word of yet-another-database-hack-with-plaintext-passwords. This time, it’s RockYou, purveyor of many of those Facebook and Myspace apps you use. Oops. …


  5. Multibyte string slicing for fun and profit

    Ran into a small issue in one of my user models. I was using a helper to display a user’s first name, last initial. It looked something like this: …


  6. System date considered important

    I’ve been slamming my head against the wall for the past two hours. I had an OAuth connection to a remote service working just dandy in development, but as soon as I tried to use that exact same code with the exact same config and exact same gems in production…I was getting “401 unauthorized” errors back from the remote service when attempting to get a request token. …


  7. Sweet-ass performance hacks: better_assets

    HTTP overhead is expensive. DNS lookups are expensive. Start dropping a bunch of Twitter widgets, Google ads, and GetSatisfaction buttons into your killer new Web 2.0 social networking site and you’ll find that your painstakingly-optimized site has slowed to a crawl while the server sits there waiting on Amazon S3 to get its act together and serve you a 300-byte CSS file. …


  8. Fine tuning your garbage collector

    If you’re familiar with Ruby at all, you know that it can be a little wacky when it comes to memory usage. Most of us have observed a Mongrel/Passenger instance that starts out small and then grows by leaps and bounds, eventually settling on some uncomfortably high number. We’re going to fix that with Ruby Enterprise Edition and Scrap. …


  9. Quick tip: Strip URLs before parsing!

    Rather than roll my own URL regexes, I prefer to let the existing libraries do the heavy lifting. Ruby has a uri library which is fantastic for parsing (and validating) URLs. …


  10. Announcing Scrap

    I do a lot of memory and garbage analysis on my Rails apps, and in upgrading to Rails 2.3, I discovered a practical use for the new Rails Metal middleware. Dumping memory stats to my log was just sorta unreadable in a practical scenario, and was more or less entirely unusable in production. Fortunately, Metal provides a really easy way to output readable information to the browser without invoking the full Rails stack. (It’s also an excuse to write a Metal endpoint because it’s new and shiny, but that’s beside the point.) …


  11. Things to do when upgrading to Rails 2.3

    I’m upgrading blippr to Rails 2.3. Here are some of the things that had to be changed to upgrade: …


  12. Monitoring Rails: Getting instant monitoring alerts

    Monitoring is big. Having an automated daemon watch your stuff and make sure it's running properly can let you sleep at night, knowing that if something blows up, there's an ever-watchful guardian ready to wake you up so you can fix it. …


  13. Monitoring Rails: Getting instant monitoring alerts

    Monitoring is big. Having an automated daemon watch your stuff and make sure it’s running properly can let you sleep at night, knowing that if something blows up, there’s an ever-watchful guardian ready to wake you up so you can fix it. …


  14. Installing the fauna libmemcached gem on Fedora Core 6

    This is mostly for my own reference, but also because I couldn't find any great help while googling the problem. …


  15. Installing the fauna libmemcached gem on Fedora Core 6

    This is mostly for my own reference, but also because I couldn’t find any great help while googling the problem. …


  16. Syntactic sugar will occassionally kick your puppies.

    Ruby’s awesome. It has sweet, concise syntax that makes for clean, readable code. One of these constructs is the trailing condition. In most languages where you might have to write something like: …


  17. Powerful, easy, DRY, multi-format REST APIs: Part 2

    Back in September, I wrote about making your REST APIs more flexible and easier to maintain. I’ve been working with this code with great success for the past few months, and have improved and tweaked it. It’s changed enough that it’s time for another blog post about it. …


  18. Graceful degredation: Using Gravatar as a fallback avatar with Paperclip

    Lots of people use Paperclip for stuff like letting their users upload avatars. This is great - Paperclip is easy to use, quick to integrate, and painless to maintain. …


  19. Desuckifying Experts-Exchange

    If you’ve ever searched for an answer to a programming problem, chances are good that you’ve run into results from experts-exchange. Everyone hates them. The information usually isn’t that good, and even if it is, you have to scroll past sixteen pages of ads and spam to get to them. Unfortunately, there’s the occasional nugget of info that’s what you’re looking for. There’s just too much crap to dig through to get to it. …


  20. Mass inserting data in Rails without killing your performance

    Mass inserting is one of those operations that isn’t really well-supported by ActiveRecord, but which has to be done nonethless. You might say, “Well hey, I’ll just run a loop and create a bunch of AR objects, no sweat”. …