Code I Write


I spend a large part of my work day writing JavaScript that runs on other people’s websites. I cannot defend this.

For years I’ve been a contributor and maintainer for Prototype, the venerable JavaScript toolkit. Years ago jQuery ate all the other general JS libraries, but I still put out the occasional new release for fun.

I also contributed a bit of code to scripty2 — namely its UI library and its support for hardware‐accelerated animation.

I wrote Fluorescence, the code highlighting script that makes the code blocks on this blog look pretty. Before D3 existed, I wrote a thing called Krang for drawing SVG charts, but now that D3 exists you should really just use D3.


I started playing around with Ruby sometime in 2004 when Rails was a brand‐new thing. It’s still my preferred language for most scripting tasks.

For large projects, Rails is my go‐to web framework. For small projects, I use Sinatra and pull in ActiveRecord if I need to. For projects that don’t need a relational database, I use Redis enthusiastically.


I’ve been using TextMate since 2005 or so. I still use it, long after most people moved on to Sublime Text or Atom. It’s not that TextMate can do things other IDEs can’t; it’s that I am a slave to my own IDE customizations, many of which are written in Ruby or shell scripts, and I’d have to rewrite them in Python or JavaScript if I wanted to switch.

I’ve written a few TextMate bundles, though most of them are for my own use to fit my weird brain.

Raspberry Pi

I caught the Raspberry Pi bug a couple years ago. There are a half‐dozen or so around the house employed in various ways:

Arduino & ESP8266

Once you get over the initial learning curve, microcontrollers are great for single‐purpose tasks. I don’t know much about electrical hardware, but I can solder and follow directions.

I’ve got a couple Arduino Unos that I use for prototyping; when it’s time to finish, I flash my code onto an Arduino Nano knockoff — their size and low cost makes them easy to put just about anywhere.

The ESP8266 is a workhorse MCU from China that costs a few bucks and does Wi‐Fi. They are cheap enough that it’s feasible to buy them a dozen at a time — they’ll take a month to arrive, but when they do you’ll already have twelve projects in mind.

Thanks to work done by enthusiasts since late 2014, they can be programmed within the Arduino IDE, and most Arduino libraries will work as‐is on the ESP.

For only slightly more than the bare MCU, you can get an ESP with a built‐in voltage regulator and USB connector. My favorite is the Wemos D1 Mini, but NodeMCU hardware is far easier to find and nearly as good.

I’ve got a few microcontrollers around the house doing basic things:

  • A Nano inside my bartop arcade cabinet is responsible for turning on the monitor and the marquee light when it senses that the Raspberry Pi has power. This lets me control all three with one switch.
  • A Nano drives a pair of outlets on my desk. When I press a button on the box, the outlets turn on for ninety minutes. I made this after the tenth time I realized I had left my soldering iron plugged in all day.
  • An ESP8266 lives on the wall in our laundry room. It connects to two accelerometers, one on our washer and one on our dryer, and monitors the acceleration values that they report. This lets it detect when one of the machines is vibrating. After some trial‐and‐error with force thresholds and waiting periods, the result is that we get a notification on our phones when a laundry cycle is done. (The ESP is only responsible for publishing the washer/dryer states to an MQTT topic; the RPi that runs Node‐RED reacts to that state to send notifications via Pushover.)
  • A few ESPs have been made into simple temperature sensors that plug into wall outlets in various rooms of my house. They, too, publish to MQTT topics. This was a silly project that I only did because I had the hardware lying around.
  • If you’re a skinflint and willing to wait a few weeks for your order to arrive, you can do what I did and get a handful of Sonoff smart outlets for the same price as a single smart outlet from your local hardware store. These are driven by ESPs, which means that their firmware can be replaced. I use Tasmota. One of these switches powers the lamps above my girlfriend’s vanity.
  • An ESP controls my outdoor string lights. After failing to find a Wi‐Fi enabled smart outlet that was rated for outdoor use, I bought one that worked via RF, and then Frankenstein‐globbed an ESP onto its remote to make it smart whether it wanted to be or not. The monstrosity sits in a box that I placed on the other side of the wall from the outdoor outlet. It reports its status via MQTT topic and can be toggled on/off by publishing to that same topic. It’s pretty strange, but it works. Eventually I’ll replace this with a Sonoff in a waterproof case.