Skip to content

Instantly share code, notes, and snippets.

View mattjj's full-sized avatar

Matthew Johnson mattjj

View GitHub Profile
@mattjj
mattjj / qq.py
Created April 11, 2012 01:31
Q-Q plots
from __future__ import division
import numpy as np
import scipy.stats as stats
from matplotlib import pyplot as plt
def plot(data,cdf=stats.norm.cdf):
plt.figure()
plt.plot(np.cumsum(1./len(data) * np.ones(data.shape)),cdf(np.sort(data)),'bx')
plt.plot((0,1),(0,1),'r-')
@mattjj
mattjj / arxiv-export.sh
Created September 8, 2012 20:10
arXiv export
#!/bin/bash
usage()
{
echo "usage: ${0##*/} source-path exported-archive-name.tgz"
}
if [ $# -ne 2 ]
then
usage
@mattjj
mattjj / tunnelr.sh
Created September 11, 2012 14:35
OS X tunnelr script
#!/bin/bash -e
USERNAME=mitmatt
NODE=seattle
INTERFACE=AirPort
LOCAL_PORT=1080
CONTROL_SOCKET=~/.ssh/control-tunnelr
CONNECT_COMMAND=connect
DISCONNECT_COMMAND=disconnect
@mattjj
mattjj / ipcluster_runner.sh
Created September 11, 2012 15:01
Starter/stopper script for iPython clusters
#!/bin/bash
usage()
{
echo "usage: ${0##*/} [--reuse]"
}
if [ $# -gt 1 -o "$1" = "--help" ]
then
usage
@mattjj
mattjj / setup.sh
Last active October 10, 2015 13:48
my setup script
#!/bin/bash -ev
hash git 2>&- || { echo >&2 "You must install git first."; exit 1; }
cd
git clone https://github.com/mattjj/dotfiles.git ./.dotfiles
bash .dotfiles/links.sh
cd
git clone https://github.com/mattjj/config-vim.git ./.vim
@mattjj
mattjj / adp_vs_bls.py
Created October 4, 2012 01:45
ADP vs BLS
from __future__ import division
from matplotlib import pyplot as plt
import numpy as np
na = np.newaxis
# I got ADP historical data from the "Historical Data" link here:
# http://www.adpemploymentreport.com/
# I got BLS data here:
# http://data.bls.gov/timeseries/CES0000000001?output_view=net_1mth
# I munged the two into text files for the same dates by hand (copy/paste into vim)
@mattjj
mattjj / inner.py
Created October 16, 2012 18:37
hn wes benchmark followup
import numpy as np
cimport numpy as np
ctypedef np.float64_t float64_t
def inner(np.ndarray[float64_t] x, np.ndarray[float64_t] y):
cdef Py_ssize_t i, n = len(x)
cdef float64_t result = 0
for i in range(n):
result += x[i] * y[i]
return result
@mattjj
mattjj / dateplotter.py
Last active October 11, 2015 21:18
simple dateplotter
#!/usr/bin/env python
from __future__ import division
import sys, dateutil
from matplotlib import pyplot as plt
def main(sep='\t'):
dates, vals = [], []
for line in sys.stdin:
try:
datestring, valstring = line.strip().split(sep)
@mattjj
mattjj / websocketcat-receive.js
Created October 27, 2012 20:47
a tiny node.js server that routes stdin to a websocket
var socket = io.connect(window.location.host);
var received;
socket.on('data', function (data) {
received = JSON.parse(data);
});
@mattjj
mattjj / tweetscrape.sh
Created November 5, 2012 22:34
twitter scraping
#!/bin/bash -e
baseurl='http://search.twitter.com/search.json?q=sandy&rpp=100&since=2012-10-27&until=2012-10-30&callback=?'
touch allresults.json
curl -s $baseurl | jq '.results | .[]' >> allresults.json
maxid=$(<allresults.json jq '.id' | tail -1)
while [ $maxid -gt 0 ]
do