Sometimes I finish itty-bitty projects and put them here! These are the one-night projects; the beautiful i-just-thought-of-something-fun-to-make creations; the sorts of projects I used to make all the time when I was younger but now that I'm all mature and adulty I don't usually have time to complete.

If these are the sorts of projects that you like, follow along with me via Twitter. (Psst... Check out my portfolio for less-mini projects)

All Mini Projects


The log viewers we use at Khan Academy usually show tracebacks in some kind of escaped format (with newlines replaced with \n, or the whole thing getting embedded into a large JSON object), so quickly formatting tracebacks has become a pastime for me.

Yesterday I got tired of formatting though, so now I have a fancy tool that can turn the most heinously encoded tracebacks into beautifully formatted emeralds.


'{"test_data": "{\\"data\\": \\"$ tools/
PASSING!!\\\\n^CTraceback (most recent call last):\\\\n
File \\\\\\"tools/\\\\\\", line 145, in
<module>\\\\n    from devshell_eval import *\\\\n  File \\
y\\\\\\", line 4, in <module>\\\\n    from
assessment_items.models import *\\\\n  File \\\\\\"khan27/lib/python2.7/sre_parse.p
y\\\\\\", line 126, in __len__\\\\n    def
\\"type\\": \\"traceback\\"}", "test_result": "aborted"}'

Beautiful emerald:

Traceback (most recent call last):
  File "tools/", line 145, in <module>
    from devshell_eval import *
  File "webapp/tools/", line 4, in <module>
    from assessment_items.models import *
  File "khan27/lib/python2.7/", line 126, in __len__
    def __len__(self):
\\"type\\": \\"traceback\\"}", "test_result": "aborted"}'
Simple Frontmatter Parser

I wonder how many people have implemented a simple frontmatter parser... Judging by the volume of static site generators out there I bet there's a bunch.

I made one for Phial that was totally over-engineered awhile ago, but then for the KA Engineering blog and this site I went with a simpler version. I doubt it'd be useful, but just in case I figured I should release it under the UNLICENSE.

Here's a document that the parser could handle:

# post.rst
title: The best post ever
author: John

This really is the best post ever

I assure you.

And here's some code that uses the parser:

>>> import simple_frontmatter
>>> with open("post.rst") as f:
...     frontmatter, contents = simple_frontmatter.load(f)
>>> frontmatter
{'title': 'The best post ever', 'author': 'John'}
>>> contents
'\nThis really is the best post ever\n=================================\n\nI assure you.\n'
Die Simulator

Ever play D&D, realize you forgot your dice, and decide to write up a script to roll dice for you? Me too! I made it in Python and didn't spend a ton of time adding features, so its understanding of dice-rolling syntax (like 2d10+8) is pretty minimal, but it works great!

A demo of the die simulator

My initial version of this program had an off by one error which prevented me from ever getting a 20 when rolling a d20! I was upset.

Different Logger

I wanted Python's logging library to give me pretty output and highlight the substituted values. So I made a little library that'd make it do all those things! Here's some output:

Various log messages printed by the logger. A log message with a stack trace printed by the logger.

You don't need to do anything special to use it, just use the Python logging library like normal (ex: logging.error("%s foobars received, expected 17", num_foobars)).