Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
import pandas as pd
import datetime
DATA_INPUT = 'data/nonpivoted_data.csv'
EPISODE_INPUT = 'data/toy_relabeled_episodes.csv'
def date(string):
@erochest
erochest / install.md
Last active October 18, 2016 18:36
Setting up
@erochest
erochest / hw1.py
Last active August 16, 2016 14:32
def square(number):
number = int(number)
return number**2
def findall(haystack, needle):
i = 0
while True:
j = haystack.find(needle, i)
if j is -1:
break
yield j
i = j + 1
@erochest
erochest / start-rserve.sh
Created February 17, 2013 23:12
A simple shell script to start Rserve.
#!/bin/sh
R -e 'library(Rserve)' -e 'Rserve(args="--vanilla")'
@erochest
erochest / di.py
Created October 5, 2011 19:54
Dependency Injection (DI) or Inversion of Control (IoC) in Python
#!/usr/bin/env python
"""\
A short explanation of dependency injection and how to use to make testing
easier.
Maybe this should be a mocking guide, because everything's going to be a mock
object.
import nltk
from nltk.corpus import brown
fd = nltk.FreqDist(brown.words(categories='news'))
cfd = nltk.ConditionalFreqDist(brown.tagged_words(categories='news'))
avgs = []
#!/usr/bin/env python
"""Run a command and generate an alert when it's done."""
import argparse
import subprocess
@erochest
erochest / get_data.py
Last active December 28, 2015 17:59
A script for scraping enrollment race data from the MD Report Card site.
#!/usr/bin/env python
# Dependencies:
# - pip install lxml
# - pip install cssselect
# - pip install requests
import collections
import csv
@erochest
erochest / cabal-brew
Created November 2, 2013 02:12
Using `cabal-install` to generate installable package for [brew](http://brew.sh/).
#!/bin/bash
USAGE=<<EOF
cabal-brew PACKAGE VERSION
EOF
CABAL=cabal
package="$1"
keg="cabal-$package"
version="$2"