Categories
Etc

Sorry bout the weirdness

Sorry for the feed weirdness today. I was moving hosts at Joyent and I borked things good and hard for a while. I also decided to tear down the Noise feed I had up for a while and I’ll just be polluting your world with this, my main feed. 

The party may now resume.

Categories
Etc

Baby X-Ray

deceptively calm baby

Kiddo went in for an x-ray today and was stuffed into the contraption above. What the picture doesn’t show is the flailing legs below the seat and the look of sheer horror on the kid’s screaming face.

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. :)