Coding

Notes from Real World OCaml, chapter 7, part 2

Published · 4min

Covering the second part of chapter 7, which deal with exceptions and backtraces.

Coding

Notes from Real World OCaml, chapter 7, part 1

Published · 4min

Covers the first prat of chapter 7: error-aware datatypes and exceptions.

Coding

Notes from Real World OCaml, chapters 4 and 5

Published · 2min

Covers records and program structure (files, modules, and programs).

Coding

Notes from Real World OCaml, chapter 3

Published · 2min

Covers lists and patterns.

Coding

Notes from Real World OCaml, first edition

Published · updated · 17min

Because it’s been so long since I’ve done anything in OCaml, I’m going through Real World OCaml. I have the first edition, and though the second edition came out earlier this month, it’s the original that I’m going through. I’m hoping this is useful …

Coding

Picking up Lua again

Published · 3min

I recently resurrected my old original Raspberry Pi B+ and installed NetBSD on it. Currently, it’s acting as a bastion for my local network, but I’ve been thinking of other projects I could do with it. One of those is to build something like Pi-Hole with it, as …

Coding

Creating AWS Lambda functions in Python with dependencies

Published · 1min

This assumes you have a package called mylambda and a requirements.txt file listing your dependencies.

build.sh:

#!/bin/sh

tmp_dir=$(mktemp -d)
trap "rm -rf '$tmp_dir'" EXIT

pip install -r requirements.txt -t "$tmp_dir"
cp -R mylambda "$tmp_dir/mylambda"

here=$(pwd)
(
    cd $tmp_dir
    zip -r -9 $here/lambda.zip …
Coding

Custom attribute values in Django form field widgets

Published · 1min

This has frustrated me for so long.

If you want to use checkboxes in a form in Django, the obvious choice is BooleanField. There are times it would be really useful to have the value attribute filled out, but by default, Django just checks for the presence of the field …

Coding

What monads are

Published · 2min

It’s almost like a rite of passage for a developer to write a monad tutorial.

Well, this isn’t a monad tutorial. This is simply an effort to put an end to some of the nonsense that leads to monad tutorials being written in the first place and all …

Coding

How I use git

Published · 3min

My git workflow for anything non-trivial is pretty straightforward, but a little different from what I’ve seen others describe. I’m almost certainly not the only person out there who uses this workflow, so I’m certainly not claiming any originality.

There seem to be two camps, both based …

Coding

type() vs. isinstance() in Python

Published · 1min

One elementary error people make is using the type() function where isinstance() would be more appropriate1.

If you’re checking to see if an object has a certain type, you want isinstance() as it checks to see if the object passed in the first argument is of the type …

Coding

Scoping and use of the ‘global’ keyword in Python

Published · 3min

[Here’s something I knocked up for one of my co-workers who’s an experienced developer, but a Python neophyte. It may be useful to others.]

As in PHP, the global keyword in Python declares that any reference to a given variable name within the scope of a function or …

Coding

Minesweeper Kata

Published · 2min

I did the minesweeper kata a few days back. It was a bit too easy, though it’s quite possible that this is more an artifact of how I approached it. Given that it’s a simple one, it might be an idea to see if I can take it …

Coding

Harry Potter Kata

Published · 4min

I did the Harry Potter Kata earlier because I was feeling a little bored. Here’s the result. I use cents rather than euros as my unit of currency here.

I’d a start when I was thinking about how I’d solve the problem. I thought that being greedy …

Coding

Quick hacks: Python netstring reader

Published · 2min

I’m writing a proof-of-concept server for a less jokey version of the SRGP. The protocol is more or less SRGP, but it doesn’t use MIME-style headers each request is made up of a series of netstrings. The header and body sections are terminated with empty netstrings, i …

Coding

A reasonable XML RPC envelope protocol, and asynchronous calls

Published · 11min

Note

This is juvenile, but it’s still better than XML-RPC. Here is the original post.

Sometimes something you do as a joke can yield interesting results.

About a year or so ago, I was feeling bored and decided to see how much of a diet I could put …

Coding

Messing with Standard ML and Moscow ML, part one: The core language

Published · 8min

Note

A cache of the original post is here.

I was playing with Moscow ML because I’ve wanted to give Standard ML a bash for a while now, but I could never get SML/NJ to play nice for me back when I tried it first on Windows. That …

Coding

A RELAX NG compact schema for RSD

Published · 1min

I was feeling a bit bored last night and decided to write a schema for RSD in RELAX NG compact syntax. RSD is about five years old at this point, and nobody ever seems to have got around to writing one, so this might help somebody who wanted to make …

Coding

Moving from SVK to Bazaar-NG

Published · 3min

I exported my projects from SVK‘s hidden Subeversion repository on Saturday using tailor. I was expecting it to be simple, but it was anything but! Mind you, this is probably my fault.

I just wanted to get it working, so I read the documentation accompanying tailor to figure out …

Coding

Formkeys

Published · 2min

Formkeys are something I first discovered when snooping around the source for Slashcode many, many moons ago. The idea is to embed a hidden field in a form that can be later used to check if a form has been submitted twice, or if somebody’s attempting to use it …

continue   →