This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
from scipy import spatial | |
def compare_year(d, y1, cluster, y2): | |
dist = [] | |
for vec in d[y2]: | |
dist.append(spatial.distance.cosine(d[y1][cluster], vec)) | |
best = [(score, i) for (i, score) in enumerate(dist)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import os | |
def add_all(path, prefix): | |
rows = [] | |
first = True | |
for fname in os.listdir(path): | |
if fname.startswith(prefix): | |
with open(os.path.join(path, fname)) as inf: # join path and filename | |
c = csv.reader(inf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def timeto(nguys, nwins): | |
guys = [0] * nguys | |
i = 0 | |
while True: | |
i += 1 | |
j = random.randrange(0, nguys) | |
guys[j] += 1 | |
if guys[j] == nwins: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- See http://gnaural.sourceforge.net --> | |
<schedule> | |
<gnauralfile_version>1.20101006</gnauralfile_version> | |
<gnaural_version>1.0.20110606</gnaural_version> | |
<date>Mon Jan 28 15:15:33 2013 | |
</date> | |
<title>Quick meditation</title> | |
<schedule_description>15 min isochronic 4 Hz meditation followed by 45 minutes 35 Hz</schedule_description> | |
<author>David Fendrich</author> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <string> | |
#include <map> | |
#include <iostream> | |
using namespace std; | |
/* | |
d = {"primes" : [2, 3, 5, 7], | |
"fib": [1, 1, 2, 3]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Having to include so many different header files to do basic | |
//things like open a file, use strings, vectors and tuples, etc, | |
//is still annoying. | |
#include <fstream> | |
#include <vector> | |
#include <map> | |
#include <tuple> | |
#include <string> | |
//To use C++11 lambdas with Boost lambdas we define this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="gurgeh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prompt_char { | |
git branch >/dev/null 2>/dev/null && echo '±' && return | |
hg root >/dev/null 2>/dev/null && echo '☿' && return | |
echo '%(!.!.➜)' | |
} | |
function parse_hg_dirty { | |
if [[ -n $(hg status -mard . 2> /dev/null) ]]; then | |
echo "$ZSH_THEME_HG_PROMPT_DIRTY" |