.

Coffee Powered

code and content

Category Archives: Uncategorized

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: require ‘uri’ def validate_url(url) parsed_uri = URI::parse(url) rescue URI::InvalidURIError errors.add :url, "Sorry, [...]

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 ActiveSupport::XmlMini.backend = ‘LibXML’ This means that the faster_xml_simple monkeypatch is no longer needed. I don’t think we’re doing much [...]

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: cannot open shared object file: No such file or directory – /opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/memcached-0.13/lib/rlibmemcached.so libmemcached.so.2 was [...]

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. First off, the render method signature has [...]

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. However, Gravatar has a great selling point: The user gets an avatar without ever having to go set one on your site. They have an identity [...]

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

Quick tip – use anonymous blocks!

In tracking down a memory leak in one of our Rails apps today, I ran across an interesting post detailing the difference between anonymous and named blocks in Ruby, and the performance differences therein. It’s definitely worth a look, especially if you’re running in a complex environment, where new closures will be large and unwieldy. [...]

Your friendly neighborhood DNS man

So there’s been this gossipy story making the rounds on the social news sites, that the McCain camp has unbelievably registered voteforthemilf.com and are redirecting it to their site! They’ve got traceroutes and everything! Oh! The sexism! Oh! The gall! Oh! The huge manatee! Or, wait, no, maybe everyone running around screaming about this just [...]

Stop using social information as passwords and security questions!

I have a friend who recently had several of his online accounts compromised. The attackers weren’t particularly clever, didn’t use any special tools, didn’t install any viruses on his computer. All they needed was to see his public Facebook profile. From that, they were able to divine his birthday and security question answer – all [...]