Skip to content

Instantly share code, notes, and snippets.

View joefutrelle's full-sized avatar

Joe Futrelle joefutrelle

  • Falmouth, MA
View GitHub Profile
@Iristyle
Iristyle / Start-Vagrant.bat
Created March 15, 2013 18:35
Windows startup script to fire up a Vagrant VM safely on boot (using Run registry key for instance)
ECHO OFF
cd /d %~dp0
for /f "tokens=2* delims= " %%F IN ('vagrant status ^| find /I "default"') DO (SET "STATE=%%F%%G")
ECHO Close this window if it remains open, and http://localhost:8081 is responsive
IF "%STATE%" NEQ "saved" (
ECHO Starting Vagrant VM from powered down state...
vagrant up
) ELSE (
@joefutrelle
joefutrelle / grosser.sc
Last active November 10, 2017 16:44
Supercollider patch named for Ben Grosser (2004)
(
Routine({
SynthDef("buzz", {arg bufnum;
var dust, pitch, density, amp, env, pan, osc, gate;
var brown1, brown2, brown3, brown4, brown5;
var pitch1, pitch2;
pitch1 = IRand(10,128);
pitch2 = IRand(10,128);
brown1 = LFNoise2.kr(LFNoise2.kr(0.1, 10).abs + 0.1, LFNoise2.kr(0.1, 1.0).abs).abs;
brown2 = LFNoise2.kr(LFNoise2.kr(0.1, 10).abs + 0.1, LFNoise2.kr(0.1, 1.0).abs).abs;
@joefutrelle
joefutrelle / ifcb_segmentation.ipynb
Last active August 29, 2015 13:57
H. Sosik image segmentation workflow, Octave implementation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / state2dot.sed
Created July 22, 2014 18:02
take a file where each line is "state action state" and turn it into a Graphviz .dot file
#!/bin/sed -e
1i digraph foo {
s/\([[:alnum:]]*\) \([[:alnum:]]*\) \([[:alnum:]]*\)/\1 -> \3 [label="\2"];/
$a }
@joefutrelle
joefutrelle / par.cpp
Last active August 29, 2015 14:18
Simple Boost ASIO based parallelization template
#include <iostream>
#include <string>
#include <boost/thread.hpp>
#include <boost/asio.hpp>
#define N_THREADS 4
#define N_JOBS 10
/* compile on Ubuntu using
g++ par.cpp -lboost_thread -lboost_system
@joefutrelle
joefutrelle / webapp.py
Created April 2, 2015 17:56
Flask webapp template
from flask import Flask, Response
app = Flask(__name__)
@app.route('/')
def index():
return Response('<h1>Hello, world.</h1>',mimetype='text/html')
if __name__=='__main__':
app.run(host='0.0.0.0',port=8080,debug=True)
@joefutrelle
joefutrelle / Decision tree cubism.ipynb
Created May 3, 2016 13:58
Cubism using decision tree
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / basic multiprocessing.ipynb
Created August 10, 2016 15:23
Introduction to multiprocessing in iPython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jakebrinkmann
jakebrinkmann / connect_psycopg2_to_pandas.py
Created July 3, 2017 14:19
Read SQL query from psycopg2 into pandas dataframe
import pandas as pd
import pandas.io.sql as sqlio
import psycopg2
conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
sql = "select count(*) from table;"
dat = sqlio.read_sql_query(sql, conn)
conn = None
@joefutrelle
joefutrelle / dir_rate.py
Created August 9, 2017 13:09
computes rate of mods to files in a directory and reports in files/hr
from __future__ import print_function
import os
import sys
DIR=sys.argv[1]
times = []
for fn in os.listdir(DIR):
path = os.path.join(DIR, fn)