Skip to content

Instantly share code, notes, and snippets.

Working from home

Joe Kington joferkington

Working from home
Block or report user

Report or block joferkington

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
joferkington /
Created Dec 27, 2014
Spießbürger's stereonet: Fixed coordinate conversions. See
import matplotlib
from matplotlib.axes import Axes
from matplotlib.patches import Circle
from matplotlib.path import Path
from matplotlib.ticker import NullLocator, Formatter, FixedLocator
from matplotlib.transforms import Affine2D, BboxTransformTo, Transform
from matplotlib.projections import register_projection
import matplotlib.spines as mspines
import matplotlib.axis as maxis
import matplotlib.pyplot as plt
joferkington /
Created Apr 22, 2012
Brute force memory monitor
# /bin/sh
# Setup
echo "ElapsedTime MemUsed" > $datfile
starttime=$(date +%s.%N)
# Run the specified command in the background
$@ &
Converts one or more zmap grids to ascii x,y,z tab-delimited files. Exported
files will be saved to the current directory with a ".xyz" extension and the
same file name as the original. Null grid values will not be included unless
the "--with_nulls" option is specified.
Usage: [options] INPUT_FILES...
joferkington /
Created Nov 30, 2018
How many MTG cards would not fit on a future sight border?
import json
with open('AllCards.json', 'r') as infile:
data = json.load(infile)
for name in data:
card = data[name]
cost = card.get('manaCost', '')
if cost.count('{') > 6:
joferkington /
Created Jan 22, 2012
Matplotlib data cursor
from matplotlib import cbook
class DataCursor(object):
"""A simple data cursor widget that displays the x,y location of a
matplotlib artist when it is selected."""
def __init__(self, artists, tolerance=5, offsets=(-20, 20),
template='x: %0.2f\ny: %0.2f', display_all=False):
"""Create the data cursor and connect it to the relevant figure.
*artists* is the matplotlib artist or sequence of artists that will be
import numpy as np
import scipy.sparse
import scipy.ndimage
import scipy.stats
import scipy.signal
import matplotlib.pyplot as plt
def main():
x, y = generate_data(int(1e7))
joferkington / data.csv
Last active Dec 8, 2017
Example of distributing a stand-alone executable with matplotlib and cx_freeze
View data.csv
931 Oxfordshire 9314125 123255 Larkmead School Abingdon 125 124 20 SUPP 8
931 Oxfordshire 9314126 123256 John Mason School Abingdon 164 164 25 6 16
931 Oxfordshire 9314127 123257 Fitzharrys School Abingdon 150 149 9 0 11
931 Oxfordshire 9316076 123298 Our Lady's Abingdon Abingdon 57 57 SUPP SUPP 16
joferkington /
Last active Oct 27, 2017
Correctly fix azimuths >360 or <0
import itertools
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib.collections import PatchCollection
import numpy as np
def main():
azi = np.random.normal(20, 40, 1000)
joferkington /
Created Oct 6, 2012
Arrows on the ends of spines for matplotlib
import matplotlib.pyplot as plt
def arrowed_spines(ax=None, arrow_length=20, labels=('', ''), arrowprops=None):
xlabel, ylabel = labels
if ax is None:
ax = plt.gca()
if arrowprops is None:
arrowprops = dict(arrowstyle='<|-', facecolor='black')
for i, spine in enumerate(['left', 'bottom']):
import sys
import h5py
def main():
data = read()
if sys.argv[1] == 'x':
elif sys.argv[1] == 'z':
You can’t perform that action at this time.