Skip to content

Instantly share code, notes, and snippets.

Tom Paton tompaton

Block or report user

Report or block tompaton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tompaton
tompaton / process-podcasts-Makefile
Last active Aug 26, 2017
Makefile to pre-process downloaded podcasts
View process-podcasts-Makefile
# process podcasts
MP3S = $(filter-out $(wildcard *.64kbit.mp3),$(wildcard *.mp3))
PROCESSED = $(patsubst %.mp3,%.64kbit.mp3,$(MP3S))
.PHONY: process
process: videos $(PROCESSED)
@echo Done.
.PHONY: videos
@tompaton
tompaton / svn_diff_defs.py
Created Sep 20, 2011
Get SVN diff and summarise added/removed/changed function definitions
View svn_diff_defs.py
#!/bin/env python
"""get svn diff and compare added functions to removed functions,
command line args passed through to svn diff, e.g. use -r nnn:nnn to filter a specific revision."""
import sys, subprocess, re
from collections import defaultdict
svn_diff = subprocess.Popen(['svn', 'diff'] + sys.argv[1:], stdout=subprocess.PIPE).communicate()[0]
defn1 = "\W((?:def|class)\s+\w+)[:\(]" # python def and class
@tompaton
tompaton / backup.py
Created Sep 10, 2011
Python backup script
View backup.py
#!/usr/bin/env python
"""
backup.py
Create an archive which will be suitable for rsyncing to a remote backup.
- will not copy data unnecessarily for common operations such as
renaming a file or reorganising the directory structure.
(assumes large files are generally going to be immutable, e.g. audio/video)
- doesn't try to do anything fancy with permissions etc.
@tompaton
tompaton / apm_osd.py
Created May 2, 2011
Python script to add an OSD to a video based on ArduPilotMega log file
View apm_osd.py
#!/usr/bin/env python
# add OSD from ArduPilotMega log file to a video
import sys
from path import path
from datetime import datetime, timedelta
from PIL import Image, ImageDraw
from math import sin, cos, radians
# STEP 1: use mplayer to extract jpgs and wav
@tompaton
tompaton / kdtree.py
Created Mar 10, 2011
Python kd-tree spatial index and nearest neighbour search
View kdtree.py
#!/usr/bin/env python
# kd-tree index and nearest neighbour search
# includes doctests, run with: python -m doctest kdtree.py
class KDTree(object):
"""
kd-tree spatial index and nearest neighbour search
http://en.wikipedia.org/wiki/Kd-tree
"""
@tompaton
tompaton / trueskill.py
Created Dec 22, 2010
Version of true_skill() Python algorithm that handles draws.
View trueskill.py
#!/usr/bin/env python2.6
from __future__ import print_function
import sys
from scipy.stats.distributions import norm as scipy_norm
beta = 25/6
gamma = 25/300
epsilon = 0.08
You can’t perform that action at this time.