Archive for March, 2008

Offline Mac HTML validator

Friday, March 28th, 2008

If you’re a Mac web developer, get “Validator S.A.C.“.  Despite the weird name, it’s pretty neat.  It’s the W3’s HTML validator, but as a Mac app that runs offline.  The entire interface looks (almost) identical to the online validator, so you already know how to use it, even though it’s not the nicest interface.

The advantage is that  I can validate localhost:3000 even though I’m behind a firewall, or without network access at all.  How did I not know about this before?

(Yes, I know clayvalet.com doesn’t validate.  It’s getting better, though.)

String searching in MySQL

Tuesday, March 25th, 2008

So today I ran across a line that looked like:

Merchant.find(:first, :conditions => [”LOWER(url) = ?”,  …])

Since I’m kind of on an optimization binge, I decided to make sure this was indexed.  No point in sucking down an entire table if we just want to look up one word.

We have an index on merchants.url, but if you know SQL, you already know the answer: no, it doesn’t use the index for this.  I ran EXPLAIN to verify that, and then looked up the general rule: apparently if you use an expression, it doesn’t use an index.

No big deal: just make an index on LOWER(url), right?  Sorry, no, SQL doesn’t allow indexes on functions of columns.  (Actually, it’s a trick question: SQL itself doesn’t have indexes at all.  PostgreSQL can create an index on an expression, but support for this is not at all consistent across databases.)

It turns out the answer is really simple: MySQL is case-insensitive by default.  Removing the LOWER() call returns the same result, but using the index, at least for the things I tried.

But what about non-ASCII characters?  We do go to the trouble to say “DEFAULT CHARSET=utf8″, because we don’t want to exclude, say, people with Japanese names.  Then it gets more complicated.  MySQL has “collators” which seem to be responsible for determining how to case-insensitively compare strings.  By default, it’s … “latin1_swedish_ci”.

So if you’re wondering why you’re typing in a Turkish name and it’s not quite working as you expect, that’s because we’re assuming you’re Swedish.  Nothing personal.

As Found on ClayValet, part quatre

Thursday, March 20th, 2008

Pumpikseed Oil

Ah yes, they take the pumpkin seed oil for a cluster of consonants. Well they are not even wrong!

Last November spawned a monstrously pricey interest in pumpkins. Well last October really but I didn’t act on it until November by making a request to ClayValet for pumpkin seed oil. It was pricey so I decided not to order it. But then a few days ago I thought I was really in the mood for pumpkin seeds. I really, really like them. So I order this, from a mushroom dealer of all things, JR Mushrooms and Specialties, and lo and in the West really it arrives.

Oh so very tasty, just like pumpkin seeds. Vaguely somewhat like sesame oil or peanut oil, but pumpkin, which trumps on coolness points. And it’s incredibly dark. Adds a lot to anything. I never cared for that truffle oil phase, all those slimey bottles in people’s kitchens from Trader Joe’s next to Chardonnays no one wants to drink (Belinda Carlisle walked away from Chardonnay, and so should we all). I associate pumpkins with a most wonderful seasonal beer (Night Owl Pumpikn Ale) from a local pub (Elysian), a pumpkin beer with an owl for a mascot (we must approve).

Also I happen to have become enamored of something which is not a markup language (YAML ain’t markup language, so it is said). It rhymes with camel, although camels are associated with Perl (why on earth? the ship of the desert?) very well then. I associate perl with oysters, and it’s not as though they are over-used as mascots. YAML is excellent.

Cool rake tricks

Wednesday, March 19th, 2008

Type “rake –tasks” to see what tasks you have available.  Rails (or maybe plain Ruby) gives you all kinds of neat things by default.

My favorites:

  • rake routes (list rails routes)
  • rake stats (show a table of LOC-style stats)
  • rake db:migrate:redo (undo/redo the last migration)
  • rake notes:fixme or notes:todo (list all FIXME or TODO comments, grouped by file)

As Found on ClayValet, part trois

Tuesday, March 18th, 2008

bee gobletPerigord GobletVersailles goblet

And we see le raison de le francais.. The royal we had requested some goblets from les valets du Clay. La Rochere Perigord was suggested, a nice, goodly-sized drinking orb which could double in movies for all sorts of things. We had not heard of La Rochere before, but it is a very old glass outfit (founded late 15th century). Thick, heavy glasses. They have seams. We had not seen seams on glasses before, but have started noticing them. This is called ‘pressed glass’. Nevertheless a variety of sizes and designs were ordered (ah, variegated drinking glasses) and they have arrived and are very nice, casual glasses, catch the light very well, have not leaked so far, and only one managed to get chipped (presumaby in shipping). We used ChefTools.com which, being a Seattle outfit, had to charge tax and shipping and waited some time to ship. Alas. Said glasses are not all about in the states and sometimes there is a wait. Still, commendable use of sand et al.

As Found on ClayValet, part deux

Tuesday, March 11th, 2008

A red kitchen cart

If only I had a horse…

The very same kitchen cart was found on ClayValet, although I actually got it from all Kitchen Carts rather than the recommended merchant. It passed through Tennessee and Indiana and Missouri but it arrived. Assembly required. Unpacking required. I should win a prize except that a certain someone else pried apart the tenacious wooden clutches gripping furiously the granite top. A victory which ought to be recorded by a bard or medieval scribe.

Well it has been assembled. It was very heavy. Still is very heavy. Lot of packaging, my word. But it’s red and very nice and I’ve put lots of things in it now and this has cleared up surface area, and the cart has its own surface area. Of granite! Therefore I would recommend this or similar carts. A little shipping damage, some assembly issues, but by and large a fine find.

And it coordinates with my paprika collection, color-wise anyway. Otherwise it just sits there and doesn’t seem to do very much of its own accord. I did lock the wheels, perhaps that is why.

Friday at ClayValet HQ

Wednesday, March 5th, 2008

There are many great things about working with Mikhail, but one of the best is that fact that, when you’re working with somebody who was born in Soviet Russia, really stupid Yakov Smirnoff-style jokes actually kind of make sense.

Bottle Before OpeningBottle After Opening

In Soviet Russia, alcohol gets smashed by you!