A simple scraper that sends a message on Slack when iPhones are available in Portland.
The default channel on Slack I used was #technology
, but feel free to change that.
I put the iphone.txt
template in a templates
directory, too.
from math import sqrt | |
def confidence(ups, downs): | |
""" | |
Wilson Score Interval: http://stackoverflow.com/questions/10029588 | |
""" | |
n = ups + downs | |
if n == 0: | |
return 0 |
import copy | |
from scrapy import Item | |
class ModelItem(Item): | |
""" | |
Make Peewee models easily turn into Scrapy Items. | |
>>> from models import Player | |
>>> item = ModelItem(Player()) | |
""" |
""" | |
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 | |
""" |
#!/usr/bin/env python | |
""" | |
Turn CSV input into TSV output. | |
""" | |
import csv, sys | |
for row in csv.reader(sys.stdin): | |
print("\t".join(row)) |
""" | |
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 |
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'] |