Skip to content

Instantly share code, notes, and snippets.

@shazow
shazow / facebookapi.py
Created August 8, 2011 21:08
Make good HTTP API libraries really easily using urllib3.
from simpleapi import SimpleAPI
class FacebookError(Exception):
def __init__(self, type, message, response=None):
self.type = type
self.message = message
self.response = response
def __str__(self):
return "%s (%s)" % (self.type, self.message)
@shazow
shazow / create_project.sh
Created September 11, 2011 19:58
Setup deployment target for Nginx + Python/uWSGI + Supervisor + Git (for a Linode Stackscript)
#!/bin/bash
# Setup deployment target for Nginx + Python/uWSGI + Supervisor + Git
# From: https://gist.github.com/1210041
function usage() {
cat << EOF
Usage: $0 PROJECT_NAME [DOMAIN] [OPTIONS]
Options:
-y No prompts, assume yes to all.
@shazow
shazow / build-latest.sh
Created March 4, 2012 20:45
Build my latest symlinked kernel and inject it into my bootloader.
#!/bin/sh
mount /boot
cd /usr/src/linux
make clean; make; make modules_install
NEW_KERNEL=$(readlink /usr/src/linux)
echo "Copying kernel: ${NEW_KERNEL}"
@shazow
shazow / types-of-lists.md
Created April 22, 2012 22:28
Catalogue of the different kinds of lists we compose in our day-to-day lives.

Types of lists

Catalogue of the different kinds of lists we compose in our day-to-day lives

  • Bucket list

    Such as "Things to do before you die". Typically aspirational, completeable. Manual sorting (usually importance or desired completion order).

@shazow
shazow / objects.py
Created May 5, 2012 20:09
Listopi snippets
# listopi/test/__init__.py
from unittest import TestCase
from pyramid import testing
from sqlalchemy import create_engine
from listopi.model import metadata, Session
class TestModel(TestCase):
def setUp(self):
@shazow
shazow / role-models.md
Last active October 13, 2023 16:55
List of my role models

List of my role models

People I want to be more like at this point in my life, in ambition, style, or personality.

  • gaben
  • @BillNye
  • @snowden
  • @jessfraz
  • @vitalikbuterin
@shazow
shazow / test_util.py
Created June 10, 2012 19:49
split_first
class TestUtil(TestCase):
def test_split_first(self):
test_cases = [
(
('abcd', ['b']),
('a', 'cd')
),
(
('abcd', ['c', 'b']),
('a', 'cd')),
@shazow
shazow / Makefile
Created September 21, 2012 04:37
pip install requirements only when they've changed.
requirements: requirements.txt.out
requirements.txt.out: requirements.txt
pip install -r requirements.txt | tee requirements.txt.out
@shazow
shazow / gist:3928595
Last active November 18, 2022 14:24
Makefile which handles Python requirements.txt and *.egg-info (with optional virtualenv checking).
REQUIREMENTS_FILE=requirements.txt
REQUIREMENTS_OUT=requirements.txt.log
SETUP_OUT=*.egg-info
all: setup requirements
requirements: $(REQUIREMENTS_OUT)
$(REQUIREMENTS_OUT): $(REQUIREMENTS_FILE)
pip install -r $(REQUIREMENTS_FILE) | tee $(REQUIREMENTS_OUT)
def brandon_rhodes():
"""Complete the foo of the 1st argument.
Completing the foo is always difficult, you know?
But this function does it, else raises ValueError.
"""
pass