Categories
Etc

Fundamentals vs. Finesse

I was reading The Elements of Cooking last night and ran across a statement that resonated with me. According to Ruhlman, there are two stages to learning to cook. First you learn the fundamentals, then you learn the finesse, and without the fundamentals, all the finesse in the world won’t do you any good. Fancying up a sauce that was prepared incorrectly won’t help; only once you have a good base can you start to experiment with variations to come up with something you can call your own.

I find the same is true in programming; you need a good solid foundation to build upon. If you understand how languages and compilers work, it’s generally not too difficult to pick up another one, or even to write your own little mini-language. If you understand how language constructs map to memory allocation, you can make better design decisions when building your program. Without that base, it’s hard to understand why doing things one way is preferable to doing them another.

Categories
Etc

Object cannot be created in this context, Code: 9

We’d been running into this wonderfully informative error message from Firefox recently and finally found some time to track it down. If you’re running into it, check your code to see if you’re trying to grab a reference to the computed style on a null reference. So code like this:

function foo() {
  var n = dojo.byId("a-bad-id");
  console.log(dojo.getComputedStyle(n));
}

Here’s a simple repro case. If you’re using dojo, you can tickle this a number of ways as a bunch of functions use dojo.getComputedStyle under the hood, like marginBox, contentBox, style when used as a getter, and others.

So the moral of the story: make sure you’re passing a valid node reference or a valid node id to functions that work with computedStyle objects.

Categories
Etc

Finding those damn trailing commas

Internet Explorer has this wonderful behavior where it completely refuses to load a JavaScript file when it encounters a trailing comma. That is, something that looks like this:

var f = { foo: "bar", baz: { go: "yes" }, };

I got sick of trying to find these beasties and came up with this regex instead:

}[\s\n]*,[\s\n]*[^\[{\w\n\s/\*\"]

Works like a charm in TextMate. Might work in grep too? Anyway, it’s a good way to find your headache quickly. :)

Categories
Etc

Grand Valley State’s New Music Ensemble

Today I stumbled into something new. On NPR (via Dave Winer), I found a wonderful recording of Steve Reich’s Music for 18 Musicians by the Grand Valley State New Music Ensemble.

GVSU is on west side of Michigan and not that well known for their music program, but this recording and the amount of time they put into perfecting it is rather astounding. It’s a bit like listening to live ambient, but amazingly rich and textured. I’m not usually into this kind of thing, but this particular composition is just wonderful. There’s also a much higher quality Quicktime of the trailer available if you’re interested.

Categories
Etc

Noise

In an attempt to cut down on the noise on this blog, I’m starting another one based on Chyrp for all the random crap I find.

Update: I pulled noise back down. Everything is back to living right here in the main blog.