Skip to content

Instantly share code, notes, and snippets.

View robert-spurrier's full-sized avatar

Robert Spurrier robert-spurrier

View GitHub Profile
@robert-spurrier
robert-spurrier / index.html
Last active June 24, 2016 19:13
Ohio, rendered by Clojurescript and d3
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#map {
width: 1200px; height: 600px;
}
#states {
fill: none;
stroke: #555555;
stroke-width: 0.5px;
@robert-spurrier
robert-spurrier / aucroc.py
Created February 25, 2016 19:03
Generate AUCROC in Python with scikit-learn (sklearn)
from sklearn.metrics import roc_curve, auc
import matplotlib.pyplot as plt
import random
import csv
actual = []
predictions = []
with open('scores_and_outcomes.tsv','rb') as tsvin:
tsvin = csv.reader(tsvin, delimiter='\t')
for row in tsvin:
@robert-spurrier
robert-spurrier / confusion_matrix_derivations.cljs
Created February 17, 2016 21:15
Planck Script (ClojureScript) To Generate Common Confusion Matrix Derivations
#!/usr/local/bin/planck
(ns confusion_matrix_derivations.core
(:require [planck.core :refer [*command-line-args*]]
[cljs.reader :refer [read-string]]
[cljs.pprint :refer [pprint]]))
(defn sensitivity
"Sensitivity, or True Positive Rate"
[tp fln]
(/ tp (+ tp fln)))
@robert-spurrier
robert-spurrier / random_album_copy.sh
Created January 15, 2016 13:35
Copy a given number of random directories to another directory
# Script I use to copy random albums to my mp3 player
# OS X, requires GNU coreutils
ls "$1" | gsort -R | tail -n $3 | while read file; do
cd "$1"; cp -R "$file" $2
done
@robert-spurrier
robert-spurrier / sample_fiddlin.clj
Created January 11, 2016 14:20
Using Clojure with Java interop to play a sample (javax.sound.sampled)
(ns sample-fiddlin.core
(import javax.sound.sampled.AudioSystem
javax.sound.sampled.DataLine$Info
javax.sound.sampled.Clip)
(:gen-class))
;; (play "clap/clap-808.wav")
(defn play [sound]
(let [audio-file (java.io.File. (str "dev-resources/" sound))
audio-stream (AudioSystem/getAudioInputStream audio-file)