Skip to content

Instantly share code, notes, and snippets.

@woodb
woodb / tree.md
Created May 10, 2012 00:25 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@woodb
woodb / setup_flask_and_friends.sh
Created July 8, 2012 16:43
Shell script to get setup with Flask, nginx and uWSGI on an Amazon EC2 Linux image
#!/bin/bash
#
# Shell script to automatically configure a new Flask, nginx and uWSGI based blog
# on an Amazon EC2 instance.
#
# See http://bit.ly/MeGwjD for more information!
#
# If you are forking this for your own custom configuration script, see the following other gists:
# https://gist.github.com/3071737
# https://gist.github.com/3071739
@woodb
woodb / uwsgi.conf
Created July 8, 2012 16:46
Configuration file for uWSGI
description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn
env UWSGI=/usr/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log
exec $UWSGI --master --emperor /etc/uwsgi/apps-enabled --die-on-term --uid nginx --gid nginx --logto $LOGTO
@woodb
woodb / blog.ini
Created July 8, 2012 16:47
uWSGI configuration for simple blog
[uwsgi]
# Variables
base = /var/www/blog
app = simple
# Generic Config
plugins = http,python
home = %(base)/venv
pythonpath = %(base)
socket = /var/www/run/%n.sock
module = %(app)
@woodb
woodb / default.conf
Created July 8, 2012 16:48
nginx configuration for uWSGI
server {
listen 80;
server_name blog;
server_name blog.example.com;
root /var/www/blog;
location /static/ {
alias /var/www/blog/static/;
expires 30d;
access_log off;
@woodb
woodb / tweetku.py
Created March 17, 2013 20:01
Full script used in blog post at http://h6o6.com/2013/03/using-python-and-the-nltk-to-find-haikus-in-the-public-twitter-stream Not a perfect implementation (still pretty hacky), so if you have any improvements feel free to contribute!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Full script used in blog post at http://h6o6.com/2013/03/using-python-and-the-nltk-to-find-haikus-in-the-public-twitter-stream
4-clause license (original "BSD License")
Copyright (c) 2013, h6o6
All rights reserved.
@woodb
woodb / gzsync.sh
Created November 11, 2013 17:37
Command line utility to sync the current directory with an S3 bucket, compressing and metadata'ing files as we go...
#!/bin/bash
BUCKET=$1
TMP_DIR=`mktemp -d -t gzsync`
# check that we have a trailing slash
[[ $BUCKET != */ ]] && BUCKET="$BUCKET"/
printf "Copying files to temporary directory... "
cp -R . $TMP_DIR && cd $TMP_DIR
printf "Done\n"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
GLOB sdist-make: graphql-py/setup.py
py26 inst-nodeps: graphql-py/.tox/dist/graphql-py-0.1a0.zip
py26 installed: argparse==1.3.0,flake8==2.4.1,graphql-py==0.1a0,mccabe==0.3.1,pep8==1.5.7,py==1.4.30,pyflakes==0.8.1,pytest==2.7.3,wheel==0.24.0
py26 runtests: PYTHONHASHSEED='1943238851'
py26 runtests: commands[0] | py.test
============================= test session starts ==============================
platform darwin -- Python 2.6.9 -- py-1.4.30 -- pytest-2.7.3
rootdir: graphql-py, inifile:
collected 203 items
@woodb
woodb / pre-push
Created October 7, 2015 23:32
pre-push git hook to build and upload Sphinx documentation to gh-pages branch
#!/bin/bash
set -e
set -x
# Root path of the git repository that has this hook
LOCAL_CODE_PATH="/path/to/this/repository"
# Path to copy $LOCAL_CODE_PATH to for orphaned gh-pages branch
#
# See https://help.github.com/articles/creating-project-pages-manually/