.

Coffee Powered

code and content

Author Archives: Chris Heald

Chris is 25 year-old a web developer and entrepreneur. He is Chief Architect for Mashable. He’s been in the web development business for about 8 years, and dabbles in about as many languages as he can get his hands on. He began working in Ruby and Rails in late 2006.

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. Every time this comes up, everyone says “How naive! They should have been using salted hashed passwords!” This is true in any case where you don’t need to use the password again on [...]

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: Seems innocent enough, sure. Except…it doesn’t work in multibyte character sets. The first Cyrillic speaker to sign up blew that all up. When parsing an XML [...]

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 [...]

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 [...]

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 [...]

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. For example, something like this might be used in a model validation: I noticed a bit ago that I started getting invalid URL errors [...]

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 [...]

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: Switch the application entirely to LibXML for all its XML parsing needs In config/environment.rb: Add the following This means that the faster_xml_simple monkeypatch is no longer needed. I don’t think we’re doing much else with XML [...]

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. There are a number of monitoring solutions that are popular these days, such [...]

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. I’m working on switching from memcache-client to Evan Weaver’s libmemcached gem, and it’s gone well, except for one nagging error: libmemcached.so.2 was absolutely there, in my /usr/local/lib path. However, ldd was showing that rlibmemcached.so wasn’t [...]