Stuart Powers sente

View recommender.py
1 2 3 4 5 6 7 8 9 10
from collections import defaultdict
import operator
 
 
# Load data
f = open('data/user-brands.csv')
brand_users = defaultdict(list) # Given a brand, which users are followers
user_brands = defaultdict(list) # Given a user, which brands does the user follow
for line in f:
user, brand = line.strip().split(',', 1)
View example.py
1 2 3 4 5 6 7 8 9 10
# -*- coding: utf-8 -*-
 
 
from pandas.io.data import DataReader
import datetime
 
start_test = datetime.datetime(2005,1,1)
end_period = datetime.datetime(2005,12,31)
 
bars = DataReader("SPY", "yahoo", start_test, end_period)
View Data Analysis With Python.ipynb
1 2 3 4 5 6 7 8 9 10
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
View gist:8665191
1 2 3 4 5 6 7 8 9 10
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "joern.zaefferer@googlemail.com" ];
then
GIT_AUTHOR_EMAIL="joern.zaefferer@gmail.com";
GIT_COMMITTER_EMAIL="joern.zaefferer@gmail.com";
git commit-tree "$@";
View mongo_key_combination_counts.py
1 2 3 4 5 6 7 8 9
from events import events
import pprint
import operator
import collections
import datetime
 
secs = 24*60*60*15
now = int(datetime.datetime.now().strftime("%s"))
first_epoch = now - secs
View flask-uwsgi-nginx-primer.md

Flask + uWSGI + nginx Primer

I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

How this shit works

  • Flask is managed by uWSGI.
  • uWSGI talks to nginx.
View ipython_startup_script.py
1 2 3 4 5 6 7 8 9 10
from time import strftime
import os.path
import contextlib
import cStringIO
import sys
 
 
# create a context which we can use for any block which we can use for any
# block which we do not want to print stdout
# -- taken from http://stackoverflow.com/a/2829036/217652
View jsonplz.py
1 2 3 4 5 6 7 8 9
#!/usr/bin/python
 
import requests
import json
import sys
import lxml
import lxml.html
 
url = sys.argv[1]
Something went wrong with that request. Please try again.