Last Friday ended up being a pretty solid day. But it didn’t start off that way. I woke up late with a headache, worsened by the seemingly endless construction in Lower Haight.

I guess I deserved the headache. The previous evening I elected myself Secretary and Treasurer of the Night of June 26 Lower Haight Temporary Bar Crawl Association. Others were present, but I created the agenda, and dutifully celebrated each milestone.

I started to feel right again by lunchtime, and it was then that I remembered I still needed to make the day’s open source contribution. See, I’m doing this thing where I commit to an open source project at least once a day for a year.

Open Source Tweet

As of this writing I’m 12 days in, with 353 to go. I’ve been really energized by the response I’ve gotten, and I hope I can support others who decide to embark on this journey.

Hacking the chain

One thing I’ve learned already is that one commit leads to another. Seriously. This is a powerful realization, because I have to make at least one commit every day to keep my streak alive.

But sitting down to write code can be hard. It requires an expensive context shift out of the noisy office world and into a quiet text editor. The cost of this shift has consequences, some bad and some good.

One bad consequence is that my brain — a very lazy brain — tries to drum up other work to do instead that has a lower switching cost. Email, Twitter, and yo-ing other co-workers are obvious temptations. So are cookies.

Nom nom nom

Bar crawl association officers are allowed unlimited cookies no questions asked

There are good consequences too. If I can actually make the shift into The Land of Context-Heavy Abstract Reasoning, my brain will want to stick around for a while. It’s paid the steep cognitive cost of admission and it wants to get its money’s worth.

My open source contribution pledge is a hack to get me over this high context-switching barrier at least once a day. Because fulfilling my promise requires just 1 commit, the barrier feels lower. And once I’m over it, I get to reap the benefit of my brain wanting to hang out there for a while.

I’ve made 66 public-facing commits in the last 12 days, so I think it’s working so far. At this pace I’ll make over 2,000 commits before Day 365, a.k.a. #oss365. (Today is #oss012, you get the idea.)

Snowflakes can turn into snowballs (which is good)

After lunch on Friday I decided to immediately get my 1 commit in, because there was at least a 50% chance I would decide to take a “nap” and wake up at 6am the next day. That’d put me back to 0/365. No thanks.

One thing I’ve wanted for a while is the ability to open a Keen IO project page in a browser from the command line. I have over 50 projects that use Keen IO, and each of them has a file called .env that contains the project’s KEEN_PROJECT_ID. This .env file pattern is codified by dotenv and is used in some Keen IO SDKs like keen-gem.

From any directory with a .env file containing KEEN_PROJECT_ID I want to be able to type:

$ keen project:open

and it should just open that project’s overview page on That seemed like a simple enough thing to knock out. A tiny snowflake. No snowballs in the forecast, right?

Wrong. This turned into a 5-hour coding marathon that turned into A CLI for Keen IO. But this was good snow. Like the kind I always wish for up in Lake Tahoe, not the kind I never wanted in Chicago.

Bad snow

Bad Snow

One simple “project:open” command turned into eight, providing decent API coverage for commonly used features. It was pleasantly unexpected, and wouldn’t have happened if I thought I had to Write a Whole CLI that day.

It happened because I just needed to make my one commit. The pre- and post- context switch worlds turned out to be very different, and there was not 1 but some 17 commits hiding on the other side.

Quick tour of keen-cli

If you have a working Ruby environment, installing keen-cli is as simple as running one command:

gem install keen-cli

Once that completes, you’ll have a powerful keen command in your shell. Powerful, but simple by design.

Here’s how to run a count query over a ‘logins’ collection:

$ keen queries:run --analysis-type count --collection logins

Like any good CLI, there are shorter ways to express parameters:

$ keen queries:run -a count -c logins

keen-cli can also record events, and supports a few different methods for doing so:

  • JSON on the command line
  • Key=Value pairs on the command line
  • Either JSON or key value pairs from STDIN, or piped in from a file

To see the full set of comands and their parameters, see the Usage section of the README.


As a terminal junkie I’m really excited to keep evolving keen-cli over time with the help of others at Keen and our friends out in the community. I’m also excited that I’m only 12 days into my Open Source 365 mission and already have a lot to show for it.

PS: Two hours ago I sat down to write a very short note to the developer group about keen-cli. Now I have a blog post 🙂