Archive for February, 2008

Guitar Loser

Thursday, February 28th, 2008

My neighbors, it seems, are Guitar Hero connoisseurs. Tonight they’re rehearsing “Kokomo”.

I really wish they wouldn’t.

La vie, c’est une beach!

Thursday, February 28th, 2008

Or le valet clay anyway.

It transpires that we are (re)designing the site. Aesthetically, anyway. And we need a new color scheme. I am dandily in favor of a beach theme. I had advocated starfish for buttons, and it was suggested that a turtle would make an appropriate ’submit request’ icon. Nevertheless I was vetoed.

Yet in defeat I may triumph! How so? Ah, because the beach color scheme is very pleasant, even without little sea creatures. We have already been experimenting white and blue, but this is just a little cold and harsh. The blue should be darker, like navy or the sea, the white could be tempered with the tan of sand, the whole place organified with a little kelp green. And coral red, which is a little pink.

So dreams of beaches live on. I always liked that ’sandwish’ theme for sawfish (((which I used for years out of lisp loyalty))).

Things I learned about fixtures the hard way

Wednesday, February 27th, 2008

0. “rake db:fixtures:load” will empty your dev db and fill it with your fixture data. If you’re wondering what’s going wrong with your fixtures, this can be a huge help.

1. The AR fixtures code does not check to see if a record is valid before inserting it. And it only checks validity on save (mostly), so it’s quite possible to get an error in testing (but not dev) that’s due to an invalid fixture record.

If you can’t get something to work quite right, it may be due to a bad fixture, and your code and test may be correct.  Something as simple as an omitted field in a fixture you haven’t touched can be enough to ruin your whole afternoon.

2. Another thing that doesn’t check for validity is Foo.delete_all. This is a quick and easy way to kill referential integrity. It’s generally a bad idea in tests, even if you’re using transactional fixtures.

3. With new “foxy fixtures”, you can say “mission: foo” to hook mission_id to foo[:id], but this doesn’t work through a belongs_to link that uses :foreign_key. I mentioned it to somebody at seattle.rb who claims to work with Fixtures Guy, so maybe it’ll get fixed someday.

Foxy fixture links aren’t checked for validity, either, BTW. It just hashes the name you pass, so if you say “mission: bogus”, and there’s no mission fixture called “bogus”, it’ll still insert a value, and you’ll get a weird error. (Or worse, “mission: threee”.)

4. (Not related to fixtures at all) In Rails, “.” in a (URL) path is a “route separator“, so it doesn’t behave like you expect by default. The fix is to add something like:

:requirements => {:id => /[a-zA-Z0-9_@\.]+/}

to the map.connect call in routes.rb.

As Found on the ClayValet

Monday, February 11th, 2008

Last December I requested a paprika sampler set on ClayValet, because paprika is my favorite spice. Paprika sampler sets evidently do not really exist, but a certain someone assembled one for a certain me as a Christmas present. Most excellent..

Part Deux. Cuisine sometimes has bland recipes, and this one was a chili with hominy which should have been outstanding but was incredibly bland. Well, a tablespoon of spanish smoked (hot) paprika changed that.

ruby-debug saved me some time today

Thursday, February 7th, 2008

I’m probably late to the party, but I just discovered Rails 2.0’s debugger and it’s pretty rad. Basically you do:

1. sudo gem install ruby-debug

and then you

2. put a ‘debugger’ statement somewhere in your controllers or models, as a breakpoint


def add_comment
debugger
...

3. start the server with the debug flag

script/server -u

4. Go to the appropriate page in the browser and when the “debugger” statement is executed it’ll break and you’ll be able to evaluate local vars, etc.

(rdb:9) self.class.name
"Shopperview::RequestController"
(rdb:6) request.request_uri
"/request/create"
(rdb:6) request.request_method
:post
(rdb:6) request.path
"/request/create"

More falsehoods, this time biological

Sunday, February 3rd, 2008

When a medical professional tells you you have a “24-hour” bug, they are, of course, lying.

I appreciate that you guys stitch me up when I tear myself open, and give me drugs when I’m in pain, and generally try to make me feel better.  But your predictive abilities regarding illness are right up there with the weatherman.

Or, I guess, my estimates about how long my (software) bugs will take.  Hmm.

SQL portability: indexes

Saturday, February 2nd, 2008

Anybody who told you that SQL is portable was lying.

I always understood that SQL wasn’t the best language in the world, and that if I went poking into obscure corners, I would be in trouble. But this week my world-view was shattered.

SQL does not include indexes.

Yep. Even the newer versions like SQL-2003 don’t contain “CREATE INDEX” anywhere in them. So while your SELECTs might be generally portable across databases, your INDEXes are anybody’s guess. As just one example I ran into: MySQL index names only need to be unique per-table, but SQLite index names must be globally-unique.

When I manage to get all of our tests running on SQLite, I’ll list all of the things I needed to change.