Skip to content

Instantly share code, notes, and snippets.

View rizumu's full-sized avatar
:octocat:

Thomas Schreiber rizumu

:octocat:
View GitHub Profile

Should probably be in every virtualenv, and always kept up to date:

  • Pip
  • Werkzeug
  • PIL
  • yolk

Packages that may not be in virtualenv, but still installed via pip:

  • ipdb ipython
#!/usr/bin/env bash
find . \( -name "*.pyc" -o -name "*.pyo" \) -exec rm -v {} \;
diff -r 832f7d4a6f4c deploy/gunicorn_conf.py
--- a/deploy/gunicorn_conf.py Thu Oct 28 14:29:39 2010 +0200
+++ b/deploy/gunicorn_conf.py Thu Oct 28 13:36:19 2010 -0400
@@ -1,16 +1,31 @@
import sys
-from os import sysconf
+import os
from pkg_resources import load_entry_point
def numCPUs(default=1):
@rizumu
rizumu / translate.py
Created August 31, 2011 22:49
translate
"""A management command for extracting translation messages for the whole project."""
import glob
import os
from django.conf import settings
from django.core.management.base import NoArgsCommand
class Command(NoArgsCommand):
@rizumu
rizumu / fab.py
Created September 21, 2011 23:50
install irssi
def install_irssi():
sudo("apt-get install -y screen irssi bitlbee libcrypt-dh-perl libcrypt-openssl-bignum-perl libcrypt-blowfish-perl")
# libtime-duration-perl libnotify-bin irssi-plugin-otr bitlbee-plugin-otr")
server_ip = env.host_string.split(":")[0]
local("rsync --links -e 'ssh -p {0}' -avzp ~/.irssi/ {1}@{2}:{3}.irssi/ \
--exclude='*.log'".format(settings.SSH_PORT, settings.DEPLOY_USERNAME, server_ip, settings.DEPLOY_HOME))
sed("{0}.irssi/config".format(settings.DEPLOY_HOME), "BITLBEE_PASSWORD", os.environ["BITLBEE_PASSWORD"])
with fab_settings(warn_only=True):
put("~/.screenrc", os.path.join(settings.DEPLOY_HOME, ".screenrc"))
put("~/dotfiles/bitlbee.conf", "/etc/bitlbee/bitlbee.conf", use_sudo=True)
@rizumu
rizumu / university_locator.py
Created October 22, 2011 16:30
university_locator.py
from BeautifulSoup import BeautifulSoup
from urlparse import urlparse
import re
import urllib2
if __name__ == "__main__":
""" driver code """
# extract html
url = 'http://www.utexas.edu/world/univ/alpha/'
usock = urllib2.urlopen(url)
""" Python Command and Character list
(from Learn Python the Hardway by Zed Shaw)
expanded from Lesson 22
"""
#Character / Command What it's called What it does example example2
pydoc <something> #pydoc gives you the manual page for something you want to know about in python pydoc sys
help() #help function use when running python to find help on an object
print() #print function prints to the console whatever is next print(“Hello World!”) print(1 + 2)
@rizumu
rizumu / pre-commit
Created July 8, 2013 15:21
pep8 git pre-commit hook
#!/bin/sh
# Auto-check for pep8 so I don't check in bad code
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.py$')
if [ -n "$FILES" ]; then
flake8 --max-line-length=100 $FILES
fi
from datetime import timedelta
from time import sleep
from celery.task import task
from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
@task
def add(x, y):
import os
import envdir
from pathlib import Path
from celery import Celery
from django.conf import settings
from configurations import importer