I got an e-ink display

A Muni bus tracker for several local bus lines

I am fortunate enough to live near several (fully funded!) bus lines in San Francisco. When running out the door in the morning, knowing which ones are coming first is really handy. E-ink displays are fairly affordable and require no power to display static content, so one of those seemed perfect to mount in my hallway that happened to contain no wall outlets at all. So, I picked one up and got to work on it.

After a couple days of remembering how C works, I got it looking great and working well. Unfortunately, parsing 30 MB of JSON on an embedded CPU is very hard on the battery, and it only lasted a couple days before needing a charge. A proxy to filter out the irrelevant parts of the response helped, but I could still only get a week or two out of it before it needed charging. It was much more efficient than an LCD, but even with partial updates this use case just does not work well for this hardware. So, my thoughts turned to other ways to make it truly useful.

Full post >

A diagram of Yelp's temporary Flow/TypeScript interop Complete with real diagrams!

Despite my blog being almost entirely empty recently, I have actually been doing things. Check out this post I wrote for Yelp's engineering blog about migrating our large Flow monorepo to TypeScript!

An encounter in Pokémon Emerald Oh, come on.

I was playing through Pokémon Emerald recently, but got really turned off by the sheer volume of random encounters. It was way higher than I remembered as a wee elementary school kid, but I couldn't find any hard data on how the encounter rate was determined. Not even on Bulbapedia, a Pokémon wiki with ridiculously detailed documentation of every last aspect of every game.

That's when I stumbled upon a GitHub project that hosts a disassembly of Pokémon Emerald. I can read code, I'm stuck inside indefinitely due to a global catastrophe, and I need something to do. Let's read some 16-year-old C code!

Today a colleague and I were building out our frontend experiment framework. The idea was simple -- a static object, initialized on page load with a JS object containing a mapping of experiment names to cohorts, and a few convenience methods to see if the user was in a given cohort for an experiment. Easy enough, but we decided to take it a step further and use Flow to make sure of a few things:

  1. All experiment names passed into our convenience functions are valid.
  2. All cohort names are similarly valid.
  3. Ensure that all requests to see if the user is in cohort x for experiment y are valid; in other words, that x is one of the cohorts registered for experiment y.
  4. All of the above should be done statically by Flow.

This turned out to be surprisingly tough. The main issue we ran into is that it wasn't possible to type one argument based on another. In Flow-ish pseudocode, I wanted something like this:

/** * Determine if the user is in cohort `experimentCohort` * of experiment `experimentName`. */ function experimentInCohort( experimentName: ExperimentName, experimentCohort: ExperimentCohorts[ExperimentName], ): boolean {...}

But of course, that's not remotely valid Flow! I'd have to think of something a little cleverer.

Hitman Bingo!

Screenie

I couldn't sleep on an international flight so I made a bingo card generator for HITMAN 2016. The code quality is garbage, it's pretty ugly, and there's no fanfare when you win, but it's cool.

Check it.