Skip to content

Instantly share code, notes, and snippets.

View idmillington's full-sized avatar

Ian Millington idmillington

View GitHub Profile
"""
Import hook extending pytz package with usable, generic timezones:
GMT-14 up to GMT+12.
Note that pytz already has Etc/GMT+X timezones, but
(quoting Wikipedia):
"In order to conform with the POSIX style, those zones beginning with "Etc/GMT"
have their sign reversed from what most people expect. In this style,
zones west of GMT have a positive sign and those east have a negative sign."
@idmillington
idmillington / minimal.tex
Created December 6, 2013 15:55
Minimal example of Plain TeX recipe, with rules that are too large.
\def\reciperule{
\vskip0.5em\hrule\vskip0.5em
}
\def\beginrecipe{
\par
\begingroup
\leftskip=\baselineskip
\multiply\leftskip by 2
\rightskip=\leftskip
\parindent=-\baselineskip
@idmillington
idmillington / Push Me, Pull Me
Last active March 17, 2018 06:23
Push Me, Pull Me is a game written for Stephen Lavelle's PuzzleScript system (puzzlescript.net).
title Push Me / Pull Me
author Ian Millington
homepage idm.me.uk
key_repeat_interval 0.25
========
OBJECTS
========
@idmillington
idmillington / pushme-pullme.puzzlescript
Created October 19, 2013 19:48
The source code for a first little game in the neat little online game development tool PuzzleScript (http://www.puzzlescript.net/), made in a couple of hours. This game can be played at http://agon.com/games/pushme-pullme/
title Push Me / Pull Me
author Ian Millington
homepage agon.com
key_repeat_interval 0.25
========
OBJECTS
========
Background1
@idmillington
idmillington / naivebayes.py
Created November 21, 2011 01:10
Simple NaiveBayes Classifier
import collections
import re
import math
class NaiveBayesClassifier:
"""
A simple naive bayes classifier that can classify any items into
any number of categories based on training data. The core
algorithms in this class are generic, but `split_into_features` is
specific for analysing words in a message, and the data functions
@idmillington
idmillington / separated-list.py
Created April 27, 2011 21:47
Separates a list of strings with the given separator.
def sep(text_list, mid_sep=', ', last_sep=' and '):
"""
Separates a list of strings or unicode with the given separator,
adding a different separator at the end.
This allows the simple generation of strings such as:
"A, B, C and D"
>>> sep([])
@idmillington
idmillington / node-uuid.js
Created May 7, 2010 14:04
A function for returning a UUID (of any kind) in its canonical string form from within the node.js server-side javascript system. It uses a command-line OSSP uuid program to generate the UUIDs and caches them to avoid constantly spawning new processes.
/**
* Generates a new UUID and passes it to the given callback function.
*
* Uses the a command-line uuid generator. Caches UUIDs to avoid
* unneccessary spawning of new processes.
*
* You can easily adjust the script used to create the UUID. By
* default I am using the OSSP uuid program, which is available in
* most linux distro's package managers (e.g. `sudo apt-get install
* uuid` on ubuntu).