Skip to content

Instantly share code, notes, and snippets.

Avatar

Nate Oostendorp oostendo

View GitHub Profile
View gist:abd08f4fba2c19eda872556e50098dc9
### Keybase proof
I hereby claim:
* I am oostendo on github.
* I am noostendorp (https://keybase.io/noostendorp) on keybase.
* I have a public key ASCgRplakofZfv-3ERk1uNTBsUUFNs4MWx_5joqaJxCfvwo
To claim this, I am signing this object:
View sslog2csv.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View fluidsynth.service
[Unit]
Description=Fluidsynth
[Service]
Type=forking
# The PID file is optional, but recommended in the manpage
# "so that systemd can identify the main process of the daemon"
PIDFile=/var/run/fluidsynth.pid
ExecStart=/home/pi/bin/fluidsynth_service.sh start
View fluidsynth_service.sh
#!/bin/sh
# start/stop service and create pid file for a non-daemon app
# from https://blog.sleeplessbeastie.eu/2014/11/04/how-to-monitor-background-process-using-monit/
# service command
service_cmd="nice -n -19 fluidsynth -is --audio-driver=alsa /usr/share/sounds/sf2/FluidR3_GM.sf2"
# pid file location
service_pid="/var/run/fluidsynth.pid"
View pip.conf
[global]
no-index = true ; comment this line out if you need to bypass the mirror
find-links = https://sm-mirror.s3-us-west-2.amazonaws.com/pip/index.html
View paypal_to_quickbooks_csv.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oostendo
oostendo / gist:6758300
Created Sep 30, 2013
quick python script for converting massive gmail contacts to iphone-friendly address book requires vobject (sudo easy_install vobject). Note this failed on a few unicode contacts which I had to remove from the VCF file manually.
View gist:6758300
import vobject
vcfdata = open("Downloads/00001.vcf").read()
out = open("Downloads/scrubbed.vcf", 'w')
contacts = vobject.readComponents(vcfdata)
done = False
while not done:
try:
contact = contacts.next()
@oostendo
oostendo / gist:6627956
Last active Dec 23, 2015
sip forwarding with twilio
View gist:6627956
# sip.php
#
# quick and dirty outbound routing for sip phones with Twilio
#
# in your twilio sip tab
# set up your sip domain (DOMAIN.sip.twilio.com)
# register credentials for the username as the callback number with no spaces or +1 eg "3135551212" and set password
# validate the callback number
# set this script to the voice url
# set your sip client to authenticate with CALLBACKNUMBER/PASSWORD and host DOMAIN.sip.twilio.com
@oostendo
oostendo / gist:5978514
Created Jul 11, 2013
Polygon approximation for a contour segement with a given number of sides
View gist:5978514
def fixedPoly(contour, polysides = 8):
opencv_contour = contour.reshape(-1, 1, 2)
higherr = 50.0
lowerr = 1.0
tryerr = 25.0
poly = []
#binary search polygon approximations until we get a 4 point polygon
maxiterations = 100
while len(poly) != polysides and maxiterations:
@oostendo
oostendo / gist:5901331
Created Jul 1, 2013
Earth mover distance for 2 numpy histograms (uses OpenCV's calcEMD2)
View gist:5901331
#extended from http://stackoverflow.com/questions/15706339/how-to-compute-emd-for-2-numpy-arrays-i-e-histogram-using-opencv
#Earth Mover Distance = histogram similarity metric. Weights are optional.
def histEMD(hist1, hist2, hist1weights = [], hist2weights = []):
if not len(hist1weights):
hist1weights = np.ones(len(hist1))
if not len(hist2weights):
hist2weights = np.ones(len(hist1))
a64 = cv.fromarray(np.dstack((hist1weights, hist1))[0].copy())