Skip to content

Instantly share code, notes, and snippets.

@jiffyclub
jiffyclub / imhead.py
Created November 28, 2011 19:39
Python 2.3+ script for printing a FITS header. Accepts multiple files and, optionally, keywords. This is a wrapper around pyfits.getheader to make it accessible from the command line.
#!/usr/bin/env python
"""
Print a FITS header or keyword. Type imhead.py -h for help.
Requires pyfits.
Author
------
@jiffyclub
git.io/jiffyclub
@jiffyclub
jiffyclub / aiclass_nlp1.py
Created December 18, 2011 04:13
Python decoder for part one of the www.ai-class.com Natural Language Processing problem.
"""
This code is for part one the AI Class optional Natural Language Processing
programming assignment. See youtu.be/KuSg1wcty3s for the complete problem
definition.
We are given a string which has been encoded with a Caesar cipher:
http://en.wikipedia.org/wiki/Caesar_cipher, and our job is to decode it.
You could do this by brute force, simply print out each shift of the letters
and look for the correct one by eye.
@jiffyclub
jiffyclub / aiclass_nlp2-1.py
Created December 20, 2011 02:31
Python, grammar based solution for part two of www.ai-class.com Natural Language Processing problem.
"""
This code is for part two of the AI Class optional Natural Language Processing
programming assignment. See youtu.be/KuSg1wcty3s for the complete problem
definition.
We are given a sentence that spans several lines and has been shredded
vertically so that there are 2 characters in each column. The columns are
arranged in random order and it's our job to assemble them into the correct
order.
@jiffyclub
jiffyclub / aiclass_nlp2-2.py
Created December 20, 2011 02:32
Python, dictionary based solution for part two of www.ai-class.com Natural Language Processing problem.
"""
This code is for part two of the AI Class optional Natural Language Processing
programming assignment. See youtu.be/KuSg1wcty3s for the complete problem
definition.
We are given a sentence that spans several lines and has been shredded
vertically so that there are 2 characters in each column. The columns are
arranged in random order and it's our job to assemble them into the correct
order.
"""
Check helmet test data for Software Carpentry.
"""
import sys
from collections import namedtuple
HelmetTest = namedtuple('HelmetTest', ['temp', 'time', 'brittle'])
@jiffyclub
jiffyclub / NumpyLesson.ipynb
Created June 1, 2012 00:50
NumPy IPython Notebook - 31 May, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / temperatures.txt
Created June 7, 2012 19:59
SWC Tutorial Data - June 7, 2012
YEAR,AUS Temp,CAN Temp
1901,21.357021,-7.672419
1902,21.382462,-7.862711
1903,20.936884,-7.910783
1904,20.791357,-8.155729
1905,20.954510,-7.547311
1906,21.767315,-7.684103
1907,21.051441,-8.413553
1908,20.649048,-7.790929
1909,20.812077,-8.239306
@jiffyclub
jiffyclub / tutorial_2012-06-07.ipynb
Created June 7, 2012 20:30
SWC Tutorial Notebook - June 7, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / fuzzy_between.py
Created June 7, 2012 21:49
Test whether a value is within some range with some fuzziness at the edges to allow for floating point noise.
import numpy as np
def fuzzy_between(val, minval, maxval, fuzz=2, inclusive=True):
"""
Test whether a value is within some range with some fuzziness at the edges
to allow for floating point noise.
The fuzziness is implemented by expanding the range at each end `fuzz` steps
using the numpy.nextafter function. For example, with the inputs
minval = 1, maxval = 2, and fuzz = 2; the range would be expanded to
@jiffyclub
jiffyclub / ProfileDemo.ipynb
Created July 6, 2012 19:57
Examples of timing and profiling Python code using built-in tools and IPython. Requires IPython 0.13+.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.