Daniel Keast

Stuff about programming

Jinja template as json

I found myself creating a mock web service for use in tests today. The idea was that during test setup I could post some json data that would then be returned during the test itself. Only a few parts of the response would change between tests, so I wanted to specify as little as possible to keep the tests descriptive.

Sum types and Rust

I’ve been listening to the Lambdacast podcast recently. During one episode they had a discussion about algebraic data types and the differences between product and sum types. I’d heard the term algebraic data types before, but had no idea what product or sum types are.

Jekyll

I have no need for dynamic content, and so much prefer the simplicity of having a static website. With a static site generator you can get some of the benefits of dynamic apps (automatically updated menus, avoiding duplication in markup) with much higher security and lower maintenance.

Python DocTest

Python has a module called doctest in it’s standard library that will search for usage examples in your documentation and check that they work as shown. This means you can copy and paste snippets from the interactive shell, and ensure that they’re kept up to date.

Git Commit Messages

I stumbled across this blog post by Chris Beams, it has a very clear explanation of the way git expects commit messages to be formatted. Being able to place explanatory paragraphs, links, pasted error output etc really improves the history of my repos. It was always a struggle with CVS and SVN choosing between an extremely long commit message or losing context. The tools are able to distinguish the title from the description too and so can choose how and where to display them as appropriate.

Python Decimal

The Decimal class in the standard library is the way to avoid double precision errors in Python.