Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Millington idmillington

View GitHub Profile
View pytz_patch.py
"""
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 Dec 6, 2013
Minimal example of Plain TeX recipe, with rules that are too large.
View minimal.tex
\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 Mar 17, 2018
Push Me, Pull Me is a game written for Stephen Lavelle's PuzzleScript system (puzzlescript.net).
View Push Me, Pull Me
title Push Me / Pull Me
author Ian Millington
homepage idm.me.uk
key_repeat_interval 0.25
========
OBJECTS
========
@idmillington
idmillington / pushme-pullme.puzzlescript
Created Oct 19, 2013
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/
View pushme-pullme.puzzlescript
title Push Me / Pull Me
author Ian Millington
homepage agon.com
key_repeat_interval 0.25
========
OBJECTS
========
Background1
@idmillington
idmillington / naivebayes.py
Created Nov 21, 2011
Simple NaiveBayes Classifier
View naivebayes.py
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 Apr 27, 2011
Separates a list of strings with the given separator.
View separated-list.py
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
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.
View node-uuid.js
/**
* 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).