This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.prototype.yyyymmdd = function() { | |
var yyyy = this.getFullYear().toString(); | |
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based | |
var dd = this.getDate().toString(); | |
return yyyy + '-' + (mm[1]?mm:"0"+mm[0]) + '-' + (dd[1]?dd:"0"+dd[0]); | |
}; | |
d = new Date(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
sourceApp="$1" | |
targetApp="$2" | |
while read key value; do | |
key=${key%%:} | |
echo "Setting $key=$value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://omniscientjs.github.io/playground/02-search/ | |
// content component (pure) | |
var Match = React.createClass({ | |
render: () => {( | |
<li> | |
<a href="{this.props.url}">{this.props.title}</a> | |
</li> | |
)} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
import time | |
import twitter | |
twitter = twitter.Twitter() | |
R = redis.Redis() | |
while True: | |
for tweet in twitter.statuses.public_timeline(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), ) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
#----------- |
OlderNewer