Skip to content

Instantly share code, notes, and snippets.

View oostendo's full-sized avatar

Nate Oostendorp oostendo

View GitHub Profile
### 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:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[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
#!/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"
[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
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 September 30, 2013 01:30
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.
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 December 23, 2015 11:19
sip forwarding with twilio
# 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 July 11, 2013 19:33
Polygon approximation for a contour segement with a given number of sides
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 July 1, 2013 14:31
Earth mover distance for 2 numpy histograms (uses OpenCV's calcEMD2)
#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())