Simple sets in JavaScript

One of my favourite JavaScript features is its literal object notation. It allows you to declare data structures in JSON, which is a very succinct, C-like syntax. You can use this notation to declare SETs, and the a in b syntax to verify a variable is in a set: /* Declare your set as a JSON constant */ var valid_widgets = { 'widget-viewer': 1, 'special-viewer': 1, 'widget-editor': 1 }; /* Fail if something isn't in the set */ if ( ! (options.widget in valid_widgets) ) return false; /* Profit! */ As the in keyword operates on the index of the referred object, we set the value of the constants to 1 (true). A bit of a hack, but it results in a very clean way of checking if something is part of a set of valid values.

May 29, 2012 · Bruce Alderson

Giga-boxels, the future is big

Somehow I missed the recent larger EC2 unit sizes: When I saw this, I immediately thought: these numbers will have K, M, and G suffixes within the next 5 years. Compute units will be sold as 88 mega-ECUs. Imagine 88 giga-ECUs? The ECU is similar to our old measure of computing: boxen (except more virtual). The idea of giga-boxen boggles, but is inevitable (boxen is so much more inspiring than ECUs), or maybe it should be boxels? ...

April 8, 2012 · Bruce Alderson

Do just one more thing

You start the day finding consciousness. Slowly or quickly, it doesn’t matter … you become aware of the world incrementally. Maybe you hit the snooze button once? Twice? Or maybe you wish you did. If you’re like me, you’ll find some caffeine and make the trek to work. And if you’re lucky you will find yourself in your office quickly, alert, and ready to go. You work your way down your list of tasks until your customers, coworkers, or biology interrupt you. It may be minutes. It may be hours. The question is, what do you do when you’re interrupted? ...

March 28, 2012 · Bruce Alderson

The facade of uptime

While writing a spec earlier today the last few years of progress in server land hit me: uptime is a facade. In the early days, server resources were expensive and scarce. Uptime was sacred. Long running hardware was celebrated, UNIX tools were born, beer was consumed. The problem of focusing on the hardware is that it detracts from the time you spend developing software. Remember those late nights configuring RAID setups? What about hunting down faster drives, or terminating SCSI cables? ...

February 10, 2012 · Bruce Alderson

Tables versus CSS, redux

I’m a bit surprised that the argument over tables versus semantic layout is still floating around. It ignores the obvious: Any set of nodes can be rendered like a table Any table node can be rendered like a non-table node There is no difference between a <div> and a <td>, except for the default layout settings and nesting. The major browsers support the distinction with the display: table-cell; and its important variants, so it’s a matter of how you want to organize your data. ...

January 9, 2012 · Bruce Alderson