Dragoon’s Markov Chain

Dragoon is a simple Markov-chain based post generator for App.net. At a high level, it loads recent posts by the current user from App.net until there’s at least 201 posts loaded, or no more to load. It then builds up a chain and generates a string from it that’s no more than 247 characters if ‘Include #Dragoon in the posts?’ is selected or 256 characters otherwise.

Depending on how the process was instigated, it is then either displayed to the user or directly posted to App.net. Then hilarity happens.

There are two main parts to the post generation: creating the markov chain and creating the actual post. I’m going to provide code and details on most of those parts. The glue code is left as an exercise for the reader.
Continue reading

Racing the cache

There was a rather annoying bug discovered at work that we could only trigger in the live environment, but never reproduce it ourselves. The gist of it was that a group was created, but didn’t exist in the cached group tree leading to an uncaught exception when trying to go up the tree from the group.

Since the cache was being properly invalidated on group creation, and given our inability to reproduce the bug, we eventually narrowed it down to a race condition between two of the most annoying parts of a system to debug — the cross-request cache and database transactions.
Continue reading

A year of learnings

This year, I’m hoping to get into posting more frequently, while still having some notion of quality. To that extent, I’m planning on starting a weekly series of posts in which I go over something I’ve found interesting or a clever little trick I’ve discovered/written or just something I’ve been thinking about recently. I will be aiming to have the posts go out every Tuesday at 11am local (Canberra) time.

These things are likely to be coding related, to fit the theme of this site, though I won’t be limiting myself to that if I come across something simply amazing I want to share. If you just want to check out my general thoughts, there’s my Twitter and App.net accounts. I tend to post links I find interesting via Pocket, so there’s that feed too.

All the posts will be tagged with “Year of Learnings“, so will be easy to find and there’s even an RSS feed for just that tag if you don’t want to see all my other posts.