Skip to content

Instantly share code, notes, and snippets.

View zachwill's full-sized avatar

Zach Williams zachwill

View GitHub Profile
@zachwill
zachwill / items.py
Last active April 1, 2025 13:28
An easier way to meld Peewee models and Scrapy items.
import copy
from scrapy import Item
class ModelItem(Item):
"""
Make Peewee models easily turn into Scrapy Items.
>>> from models import Player
>>> item = ModelItem(Player())
"""
@zachwill
zachwill / 538_colors.py
Created October 10, 2015 21:20
A simple FiveThirtyEight palette for Seaborn plots.
"""
A simple FiveThirtyEight palette for Seaborn plots.
"""
import seaborn as sns
import matplotlib.pyplot as plt
five_thirty_eight = [
"#30a2da",
"#fc4f30",
"""
Multiclass SVMs (Crammer-Singer formulation).
A pure Python re-implementation of:
Large-scale Multiclass Support Vector Machine Training via Euclidean Projection onto the Simplex.
Mathieu Blondel, Akinori Fujino, and Naonori Ueda.
ICPR 2014.
http://www.mblondel.org/publications/mblondel-icpr2014.pdf
"""
@zachwill
zachwill / csv2tsv
Created December 6, 2014 07:54
Turn CSV input into TSV output.
#!/usr/bin/env python
"""
Turn CSV input into TSV output.
"""
import csv, sys
for row in csv.reader(sys.stdin):
print("\t".join(row))
@zachwill
zachwill / geomean.py
Last active August 29, 2015 14:07
Geometric Mean
"""
Geometric mean calculation in Python.
"""
import math
import operator
from random import randint
from timeit import timeit
" Vim color file
" Converted from Textmate theme Monokai using Coloration v0.3.2 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
import requests as req
response = req.get("http://api.stlouisfed.org/fred/releases?api_key=CHYEA")
print response.content
@zachwill
zachwill / observations.py
Created March 23, 2013 23:16
FRED API observations
import fred
fred.key('my_fred_key')
data = fred.observations('AAA', limit=10, frequency='q', units='ch1')
for obs in data['observations']['observation']:
print obs['value']
"""
Example taken from:
http://scikit-learn.org/dev/auto_examples/plot_digits_pipe.html
"""
import numpy as np
import pylab as pl
from sklearn.datasets import load_digits
import three
three.city('macon')
# This works
three.post('123', address='123 Any St', name='Zach Williams',
phone='555-5555', description='My issue description.')
# And, this works.
three.post(status_code='123', address='123 Any St', name='Zach Williams',