Skip to content

Instantly share code, notes, and snippets.


Taylor Manderson TRManderson

View GitHub Profile
TRManderson /
Last active August 22, 2017 01:56
Cache decorator and cached property decorator
from functools import wraps
def cache(fn):
cache_dict = {}
def result(*args, **kwargs):
# can't cache kwargs
assert not kwargs
if args not in cache_dict:
cache_dict[args] = fn(*args)
TRManderson /
Created July 1, 2017 02:21
Verifying myself on Keybase

Keybase proof

I hereby claim:

  • I am trmanderson on github.
  • I am trm ( on keybase.
  • I have a public key whose fingerprint is 2EF6 0F25 F529 D0CE FD37 1095 E056 0B6E A3AB FDFD

To claim this, I am signing this object:

TRManderson /
Created May 26, 2017 13:33
Handy decorator for exception logging using `logging`
import logger
from functools import wraps
def log_exc(fn=None, reraise=None, msg=None, exc=None, logger=None):
Decorator to log exceptions in a function.
TRManderson / .gitignore
Last active February 8, 2017 00:37
Testing the new metaclass support for mypy in Py2
View .gitignore
TRManderson / index.html
Last active October 5, 2016 02:27
Example jquery.load
View index.html
<!DOCTYPE html>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
TRManderson /
Created May 19, 2016 01:36
Recursively download everything from a start page, so long as it starts with a given root url
import mechanize, os, errno
from urlparse import urldefrag
from time import sleep
def recursive_download(root, page, browser=mechanize.Browser(), visited=set()):
if page in visited or not page.startswith(root):
View oil_blending.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Farmer Jones (integer).ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
TRManderson / Makefile
Created February 20, 2016 09:52
My AVR makefile for a uni course last year
View Makefile
# Name: Makefile
# Author: Tom Manderson
# Based on
DEVICE = atmega324a
CLOCK = 8000000
PROGRAMMER = -c avrispmkii
OBJECTS = project.o buttons.o game.o ledmatrix.o score.o scrolling_char_display.o serialio.o spi.o terminalio.o timer0.o
AVRDUDE = avrdude $(PROGRAMMER) -p m324pa -F
COMPILE = avr-gcc -Wall -Os -std=c99 -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
TRManderson /
Last active January 28, 2016 02:50
Repeatedly hit the Github status API to see if it's down or not (py2/3 compatible and cross-platform)
from __future__ import print_function
import requests
import os
import time
if == "posix":
def sound():
os.system("play --no-show-progress --null --channels 1 synth 5 sin 440")