Skip to content

Instantly share code, notes, and snippets.

View thearn's full-sized avatar

Tristan Hearn thearn

  • NASA Glenn Research Center
  • Cleveland, OH
View GitHub Profile
os:
- linux
- osx
sudo: false
language: generic
env:
- PY=2.7
import autograd.numpy as np
from autograd import grad
def f(A):
B = np.zeros((4,4))
B[:2, :2] = A
Abraham Gotthelf Kästner \nUniversität Leipzig (1739) -> Bernhard Friedrich Thibaut \nGeorg-August-Universität Göttingen (1796)
Abraham Gotthelf Kästner \nUniversität Leipzig (1739) -> Georg Christoph Lichtenberg \nGeorg-August-Universität Göttingen (1765)
Abraham Gotthelf Kästner \nUniversität Leipzig (1739) -> Heinrich Wilhelm Brandes \nGeorg-August-Universität Göttingen (1800)
Abraham Gotthelf Kästner \nUniversität Leipzig (1739) -> Johann Friedrich Pfaff \nGeorg-August-Universität Göttingen (1786)
Abraham Klein (Calovius) \nUniversität Rostock (1632) -> Aegidius Strauch \nMartin-Luther-Universität Halle-Wittenberg (1657)
Adolph Vorstius \nUniversità di Padova (1622) -> Franciscus de le Boë Sylvius \nUniversiteit Leiden and Universität Basel (1634)
Adriaan van den Spieghel \nUniversità di Padova and Université Catholique de Louvain (1603) -> Adolph Vorstius \nUniversità di Padova (1622)
Adriaan van den Spieghel \nUniversità di Padova and Université Catholique de Louvain (1603) -> Werner Rolfinck \nMartin-L
@thearn
thearn / pprocess_test.py
Created April 20, 2013 01:07
An experiment with pprocess
import pprocess
import time
import numpy as np
# Define a function to parallelize:
def takeuptime(x):
"""A function to waste CPU cycles"""
time.sleep(0.1)
return x[-1]
@thearn
thearn / brew.py
Last active December 16, 2015 10:59
A simple command-line app to help profile homebrew'ed beer. User inputs starting temperature, starting original gravity, and the app will compute and print temperature-adjusted original gravity and max potential ABV. Final (post-fermentation) temperature and specific-gravity can also be input to calculate effective ABV, calories per serving, and…
def adjust(t, og):
t2 = 1.34722124e-4 * t
t3 = 2.04052596e-6 * t ** 2
t4 = 2.32820948e-9 * t ** 3
sgcf = 1.00130346 - t2 + t3 - t4
sg = og * sgcf
adjusted_og = sg
OE = -668.962 + 1262.45 * sg - 776.43 * sg * sg + 182.94 * sg * sg * sg
abv_max = (sg - 1) * 105 * 1.25
@thearn
thearn / fft_series.py
Last active December 16, 2015 11:49
Class for buffering an incoming data series and computing an FFT
import numpy as np
import time
class bandProcess(object):
"""
Component to isolate specific frequency bands
"""
@thearn
thearn / ip.py
Last active December 16, 2015 11:59
A python code to determine a computer's external IP address, which is then written to a text file. Run from a dropbox folder (or something similar), this provides a very simple way to determine your home's dynamic external IP address remotely.
import urllib
import re
import time
import datetime
def get_ip():
group = re.compile(u'(?P<ip>\d+\.\d+\.\d+\.\d+)').search(
urllib.URLopener().open('http://jsonip.com/').read()).groupdict()
return group['ip']
@thearn
thearn / microscope.py
Last active December 17, 2015 09:29
Code to operate USB microscope, with selectable contrast correction
import cv2
# Create object to read images from camera 0
cam = cv2.VideoCapture(1)
class imgSlice(object):
def __init__(self):
self.x = 0
@thearn
thearn / sklearn_example.py
Last active December 19, 2015 01:39
Scikit-learn example
import random
from sklearn import svm
from sklearn.grid_search import GridSearchCV
import pylab
import numpy as np
data = []
labels = []