Skip to content

Instantly share code, notes, and snippets.

View unbracketed's full-sized avatar

Brian Luft unbracketed

View GitHub Profile
@unbracketed
unbracketed / gist:228457
Created November 7, 2009 01:45
Django virtualenv postactivate hook
#I usually drop something like this into my virtualenv's postactivate for some
#quick and handy shortcuts to common Django commands.
#This way dropping in to do some work on any arbitrary project is as easy as:
# 1. workon <project name>
# 2. djr
cd /path/to/site/root
#Django command shortcuts
alias dj='python manage.py'
@unbracketed
unbracketed / gist:228472
Created November 7, 2009 01:59
Hook for new virtualenvs
#I like to use something like this as the global mkvirtualenv new environment hook.
#This drops a few libs and tools that I tend to lean heavily on into the new environment.
easy_install pip
pip install ipython
pip install pudb
#Django command shortcuts
alias dj='python manage.py'
alias djr='dj runserver'
alias djrp='dj runserver_plus'
alias djdb='dj dbshell'
alias djs='dj shell'
alias djsp='dj shell_plus'
alias djt='dj test'
alias djm='dj migrate'
alias djsm='dj startmigration'
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
url = "http://www.radioparadise.com/content.php?name=Playlist"
soup = BeautifulSoup(urlopen(url))
playlist_table = soup.findAll('table')[2]
track_rows = playlist_table.findAll('tr', attrs={'class':['shade', 'noshade']})
f = open('radioparadise_playlist.txt', 'w')
@unbracketed
unbracketed / twitter_golden_ratios.py
Created May 29, 2010 06:17
A quick and dirty script that aggregates Twitter account golden ratios using Redis to store data.
import redis
import time
import twitter
twitter = twitter.Twitter()
R = redis.Redis()
while True:
for tweet in twitter.statuses.public_timeline():
@unbracketed
unbracketed / gist:457758
Created June 29, 2010 20:20
Parsing columns out of MySQL table status dump
import re
tables = open('path/to/table_status_dump').readlines()
for table in tables:
mo = re.search(r'^\|\s(?P<table_name>[\w_]+)\s+\|\s(InnoDB|MyISAM)\s?\|\s+\d+\s+\|\s(Compact|Fixed|Dynamic)\s+\|\s+(?P<row_count>\d+)\s+\|(\s+\d+\s+)\|\s+(?P<data_length>\d+)\s+\|(\s+\d+\s+)\|\s+(?P<index_length>\d+)\s+\|', table)
print ','.join((mo.group('table_name'), mo.group('row_count'), mo.group('data_length'), mo.group('index_length'), )
@unbracketed
unbracketed / virtualenv_komodo_project.py
Created July 2, 2010 04:42
Util for generating a Komodo project file that works with virtualenv
"""
A sample utility for customizing virtualenv creation based
on the postmkvirtualenv hook provided by virtualenvwrapper.
This script will generate a Komodo project file suitable for
use in Komodo Edit (and presumably Komodo IDE). The project preferences
are automatically customized so that the Python path contains the
new virtualenv's site-packages directory.
(Project Properties -> Languages -> Python in the GUI)
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
source ~/.mybash/django_bash_completion.sh
#load Firefox with a development profile
alias ffdev="firefox -no-remote -P dev"
#Commands that can be handy when working in Python environments
#-----------
@unbracketed
unbracketed / requirements.pip
Created July 10, 2010 05:05
LastFM scrobbler for Radio Paradise favorites
BeautifulSoup==3.0.7a
-e svn+http://python-lastfm.googlecode.com/svn/trunk/#egg=lastfm
@unbracketed
unbracketed / README.rst
Created July 10, 2010 05:43
My Komodo Edit key binding and syntax color preferences files

Keyboard Binding Customizations

Ctrl + , Collapse all code recursively

Ctrl + . Expand recursively