Skip to content

Instantly share code, notes, and snippets.

View alexstorer's full-sized avatar

Alex Storer alexstorer

View GitHub Profile
@alexstorer
alexstorer / pipeline.ipynb
Created October 3, 2014 16:39
The basic processing pipeline for Python.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexstorer
alexstorer / regression.ipynb
Created September 18, 2014 21:58
Regression in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
-0.574901563748935 -1.91351072377587 -3.39301871349422
0.655986027503778 0.220724693194496 1.4738500103463
0.43658005390081 -0.476355454977761 -2.60489562791407
0.099374580513502 -0.396758936664661 4.29225965568818
-1.47921372248279 -0.527718540432289 -6.01904146953318
0.0243374519880853 0.454875581575341 0.614373820102557
0.923520996394134 1.03720212890223 -0.191288298190668
1.87006442549162 1.47769286649867 6.15090212082468
-2.0959671116286 -1.24400997743216 -1.70133111996927
-0.443773871294626 0.0603246194061315 0.395098150135329
df <- read.csv('~/Work/dkupor/hover/data.csv',header = F,stringsAsFactors=F)
sumdf <- data.frame(rownum=numeric(),
colheadtimes=numeric(),
colheadnumber=numeric(),
rowheadtimes=numeric(),
rowheadnumber=numeric(),
celltimes=numeric(),
cellnumber=numeric()
)
@alexstorer
alexstorer / gsb_faculty.py
Last active August 29, 2015 13:59
Download the GSB profiles and then look at the intersection of their research terms to get a basic idea of whether they are connected. The scraping is in the first half of the document, and the processing is in the second half.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time, csv
def isReady(browser):
return browser.execute_script("return document.readyState")=="complete"
browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://www.gsb.stanford.edu/facultyprofiles") # Load page
function [ d ] = measurepxdist( imloc )
%MEASUREPXDIST Measure distance between pixels in an image
% Returns distance in pixels.
% Shows line between left-click and right-click.
imshow(imloc)
im = gcf();
hold on
title('Click the two points, left click and right click, q to quit','FontSize',16)
q = 113;
@alexstorer
alexstorer / edges.py
Created February 1, 2014 00:26
County - Respondent Data Processing
import csv
f = open('Fin02.csv','r')
dr = csv.DictReader(f, delimiter='|')
respondents = {}
fips = {}
rf = {}
for d in dr:
@alexstorer
alexstorer / colfromxml.py
Last active December 31, 2015 04:39
Sloppy undocumented way to maybe get column names from an XML file.
import urllib, os, sys, re, glob, pickle
import xml.etree.ElementTree as ET
import csv
# use a dictionary to hold on to each entry. we can define all the dictionary elements and the xml keys that take us there.
def main(argv):
print argv
allNames = set()
for xmlname in glob.glob(sys.argv[1]+'*.xml'):
import json
f = open('persona.json','r')
j = json.loads(f.read())
s = set()
dlist = list()
for k in j:
print k
@alexstorer
alexstorer / dtp.R
Last active December 30, 2015 00:39
h<-c(1,2,10)
j<-c(1,2,9)
foo <- cbind(h,j)
h<-c(1,2,10,9)
j<-c(1,2,9,10)
foo2 <- cbind(h,j)
foo3 <-