Ctrl + , Collapse all code recursively
Ctrl + . Expand recursively
| #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' |
| #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') |
| import redis | |
| import time | |
| import twitter | |
| twitter = twitter.Twitter() | |
| R = redis.Redis() | |
| while True: | |
| for tweet in twitter.statuses.public_timeline(): |
| 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'), ) | |
| """ | |
| 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 | |
| #----------- |
| BeautifulSoup==3.0.7a | |
| -e svn+http://python-lastfm.googlecode.com/svn/trunk/#egg=lastfm |