RSSAmplifier

Blog

Darwinweb

gabe@websaviour.com (Gabe da Silveira)

darwinweb.netRSS feed ↗10 posts

Latest posts

Convert Syck to Psych YAML format

If you deal with a lot of YAML in your Ruby code, especially migrating from Ruby 1.8.x to 1.9.2 and 1.9.3, then you may have run into some of the numerous issues with YAML incompatibility. I won t bore you with a lot of specifics, because most of these bugs are transient, but here are the basic facts: Syck is the antiquated builtin legacy YAML driver for Ruby. Psych is the new-fangled modern YAML…

Converting Hash to OrderedHash in Serialized ActiveRecord Column

Suppose you have an ActiveRecord class like this: class Report < ActiveRecord::Base serialize : options , Hash end And, because you are foolishly still using Ruby 1.8 and doing direct comparisons of the serialized format you need to change it to this: class Report < ActiveRecord::Base serialize : options , ActiveSupport::OrderedHash end The problem that you face is that the change will cause any…

Drupal vs Rails

During this discussion on HN , I was surprised to learn that Drupal—the high-level framework I left behind years ago in favor of Rails—has a high-octane elite consulting industry behind it with the same prestige and perhaps even more clout than the Rails community. This gave me pause, because for me Drupal was always the option for demanding clients with razor thin budgets—The type who waxes on…

The Problem with Rails' Catch-all Route

Today I am upgrading several hundred lines of Rails routes from the old pre 3.0 syntax to the new Rails 3.0 routing DSL . I do like the new syntax, though it is far from a trivial job as there are a number of subtle edge cases I ve been dealing with. As I meticulously considered and tested each route I discovered some route matches that I didn t think should have been covered. For example:…

In Defense of ORMs

Laurie Voss just posted an article that ORM is an anti-pattern in which he calls out ActiveRecord (although nothing about ActiveRecord is specifically cited) as doing more harm than good. Some of the flaws he mentions are real issues, but he hand-wavingly dismisses the benefits without any real analysis. Let s examine the claims: Some ORM layers will tell you that they eliminate the need for SQL .…

Aws::S3 Gem Bucket Does Not Exist Bug

I just spent two hours debugging the most banal bug. It eventually reduced to the following wtf moment: S3Object .store( ' a_key ' , ' some_content ' , ' a_bucket ' ) => success S3Object .find( ' a_key ' , ' a_bucket ' ) => AWS ::S3::NoSuchBucket: The specified bucket does not exist from ... / vendor / gems / aws - s3 - 0.6 . 2 / lib / aws / s3 / error.rb: 38 : in ` raise' from…

Configuring MySQL for utf8 under homebrew

Man, every time I set up mysql it takes me half an hour to google up all the documentation of how to make it just work™ with utf-8 instead of the god forsaken latin1 default. So here it is once and for all. Server my.cnf should contain: [mysqld] collation_server=utf8_general_ci character_set_server=utf8 The location of my.cnf varies depending on how you install it. dev.mysql.com has a nice summary…

The Case for Git Rebase

When you first sit down with git they tell you to watch out for rebase. Git is fast. Git is great. Git gets merging right. If you screw up git reflog has your back. But watch out for rebase , as long as you avoid rebase you ll never get in too far over your head. Okay, I can see the wisdom in that. In fact for the first year I avoided rebase almost entirely. I read Rebase Considered Harmful early…

Testing ThinkingSphinx with Test::Unit and Transactional Fixtures

I first started using Sphinx about a year ago. At The Auteurs we use it to solve some thorny localization and filtering issues, and we have been pushing its limits almost since the beginning. Our film index in particular is quite complex, hitting ten tables and defining two dozen attributes. I ve been impressed with how flexible it is with a pretty basic set of primitives. But one thing that never…

Benchmarking Rake Tasks and Trivial Rails Testing Optimizations

I ve been thinking a lot about testing recently. Perhaps the most inconvenient truth about automated testing is that even though it s many orders of magnitude faster than manual testing, it s not infinitely fast, and the marginal cost does add up. This is especially true in slower, interpreted languages like Ruby. Recently our test suite at The Auteurs has been approaching 15 minutes on a fast…