Skip to content

Instantly share code, notes, and snippets.

View andyreagan's full-sized avatar

Andy Reagan andyreagan

View GitHub Profile
@andyreagan
andyreagan / Philanhtropy-dist-testing.ipynb
Created October 8, 2013 02:44
Fitting data to a power law, computing statistics and testing against other distributions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyreagan
andyreagan / gist:7905737
Last active December 31, 2015 00:09
just took the derivative of rk4 by hand...
L = L*(eye(dim) + h/6*(feval(J,t,y,params)+2*feval(J,t+h/2,y+h/2*s1,params)*(eye(dim)+h/2*feval(J,t,y,params))+2*feval(J,t+h/2,y+h/2*s2,params)*(eye(dim)+h/2*feval(J,t+h/2,y+h/2*s1,params))*(eye(dim)+h/2*feval(J,t,y,params))+feval(J,t+h,y+h*s3,params)*(eye(dim)+h*feval(J,t+h/2,y+h/2*s2,params))*(eye(dim)+h/2*feval(J,t+h/2,y+h/2*s1,params))*(eye(dim)+h/2*feval(J,t,y,params))));
%% BETTER
L1 = feval(J,t,y,params);
L2 = feval(J,t+h/2,y+h/2*s1,params)*(eye(dim)+h/2*L1);
L3 = feval(J,t+h/2,y+h/2*s2,params)*(eye(dim)+h/2*L2);
L4 = feval(J,t+h,y+h*s3,params)*(eye(dim)+h*L3);
L = L*(eye(dim) + h/6*(L1 + 2*L2 + 2*L3 + L4));
@andyreagan
andyreagan / daily-steal.sh
Created September 26, 2014 00:43
Leveraging the phantom-crowbar to steal vector graphics, on the daily
# index
phantom-crowbar http://hedonometer.org/index.html timeseries $(gdate +%Y-%m-%d -d "today")/index-timeseries.svg
phantom-crowbar http://hedonometer.org/index.html?date=$(gdate +%Y-%m-%d -d "yesterday") modalsvg $(gdate +%Y-%m-%d -d "today")/index-shift.svg
# books
phantom-crowbar http://hedonometer.org/books.html?book=frankenstein booktimeseriessvg $(gdate +%Y-%m-%d -d "today")/books-timeseries-frankenstein.svg
phantom-crowbar http://hedonometer.org/books.html?book=frankenstein shiftsvg $(gdate +%Y-%m-%d -d "today")/books-shift-frankenstein.svg
# us maps
phantom-crowbar http://hedonometer.org/maps.html?time=Last%207%20Days mapsvg $(gdate +%Y-%m-%d -d "today")/maps-map.svg
for PARAM in 1 5 10 15
do
mkdir results_of_lda_${PARAM}
./lda est 1 ${PARAM} settings.txt sandyCorpus3.txt random ./results_of_lda_${PARAM}
done
@andyreagan
andyreagan / gist:dddabe583e223b929f9c
Last active August 29, 2015 14:16
get the google books corpus
for corpus in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o other p pos punctuation q r s t u v w x y z
do
wget http://storage.googleapis.com/books/ngrams/books/googlebooks-eng-all-1gram-20120701-${corpus}.gz
done
@andyreagan
andyreagan / gist:af62a2dd3b5c6f93ea48
Created March 9, 2015 18:39
core trie code in new labMTsimple
# self.data is a tuple of 2 items
# the first is trie for the non-regex (fixed) words
# and the second for the regex (stem) words
# matching on prefix mimins the [a-z]* match for the stems
# also, this was stolen from an internal function, so
# wordDict is a hash (dict) or "word": count
# for a corpus being scores
totalcount = 0
totalscore = 0.0
for X in {1..10}
do
for Y in 1 2 3 4 5 6 7 8 9 10
do
echo "${X} ${Y}"
done
done
@andyreagan
andyreagan / style.css
Created March 17, 2015 00:54
how to put an image before page title in wordpress, with just css!
header.entry-header {
display: table;
padding-bottom: 20px;
}
header.entry-header:before {
content: url(https://wildflowerstudiobtv.files.wordpress.com/2015/03/flower.png?w=778);
display: table-cell;
vertical-align: middle;
}
@andyreagan
andyreagan / backupcron.cron
Created March 25, 2015 19:13
backup crontab to a file!
# make a file, call it backupcron.cron
# make sure it's executable (chmod +x backupcron.cron)
# put just this line in it
crontab -l > /users/a/r/areagan/crontab.out
@andyreagan
andyreagan / flowify.py
Created March 27, 2015 15:40
Inspired by my neurotic need to keep my downloads folder clean, naming via Peter Dodds
import os
import datetime
if __name__ == '__main__':
for file in os.listdir('.'):
if not file == 'flowify.py':
t = os.path.getmtime(file)
d = datetime.datetime.fromtimestamp(t)
if not os.path.isdir(d.strftime('/Users/andyreagan/flow/%Y/%m')):
os.mkdir(d.strftime('/Users/andyreagan/flow/%Y/%m'))