Skip to content

Instantly share code, notes, and snippets.

View jseabold's full-sized avatar

Skipper Seabold jseabold

View GitHub Profile
@jseabold
jseabold / wiki_scrape_papal.py
Last active December 14, 2015 10:39
Tutorial-style replication of Scraping portion of Papal Conclave forecasting by dmasad
{
"metadata": {
"name": "wiki_scrape"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@jseabold
jseabold / spirals.py
Created January 30, 2013 00:51
draw a spiral in matplotlib
import numpy as np
import matplotlib.pyplot as plt
#As a path collection
from matplotlib.collections import LineCollection
fig, ax = plt.subplots()
r = np.arange(0, .075, 0.00001)
nverts = len(r)
/* hack to clear screen in stata */
program define cls
di _newline(`=c(pagesize)')
end
@jseabold
jseabold / smb_share.sh
Created December 7, 2012 14:50
Mount a samba share for streaming music
# Provided you have set up the remote machine to share the folder you want
# You can do this
# get the IP address for the machine
nmblookup -I skipper-desktop
# cd to mount point
cd /media
# make a directory, if you need to
@jseabold
jseabold / ungoogle.py
Last active October 13, 2015 07:08
ungooogle
import urllib
import re
def ungoogle(url, type="pdf"):
try:
return urllib.unquote(re.search("(?<=url=).+"+type, url).group())
except:
return urllib.parse.unquote(re.search("(?<=url=).+"type, url).group())
@jseabold
jseabold / example_regression_plots.ipynb
Created October 31, 2012 14:41
Regression Diagnostics - Plotting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jseabold
jseabold / state_abbrevs.py
Created October 18, 2012 15:24
State abbreviation-names dictionary to use with loadpy
states_abbrev_dict = {
'AK': 'Alaska',
'AL': 'Alabama',
'AR': 'Arkansas',
'AS': 'American Samoa',
'AZ': 'Arizona',
'CA': 'California',
'CO': 'Colorado',
'CT': 'Connecticut',
'DC': 'District of Columbia',
@jseabold
jseabold / get_poll_data.py
Created October 2, 2012 21:13
Download presidential poll data into a DataFrame
"""
Download all the Presidential Poll Data from Real Clear Politics and
put it in a DataFrame then put a bird on it.
Usage:
data2012_state_recent = download_latest_state_polls()
data2004, data2008, data2012 = download_national_polls()
data2012_state = download_state_polls()
@jseabold
jseabold / octal_to_unicode.py
Created September 25, 2012 19:12
octal to unicode and beyond the infinite
"""
I received a file that had octal characters as ascii. Needed to map them to latin-1 unicode and be able to go back again to latin-1 octal.
Might not be completely general, but it works for me.
E.g.,
name = 'Duchy of Zweibr\\374cken'
octalchar_to_unicode(name)
unicode_to_octalchar(octalchar_to_unicode(name))
http://www.utoronto.ca/web/HTMLdocs/NewHTML/iso_table.html
@jseabold
jseabold / gist:3757398
Created September 20, 2012 18:01
Perron-Frobenius theorem
T = np.array([[0,1,0],[0, .1, .9],[.6, .4, 0]])
p = np.array([.5, .2, .3])
ps = [np.inf, p]
while np.all(np.abs(ps[-1] - ps[-2]) > 1e-8):
ps.append(np.dot(ps[-1], T))
from scipy import linalg
# get the spectrum
eigs, evecs = linalg.eig(T, left=True, right=False)