Skip to content

Instantly share code, notes, and snippets.

View unbracketed's full-sized avatar

Brian Luft unbracketed

View GitHub Profile
unbracketed / yyyymmdd.js
Last active August 29, 2015 14:06
Javascript date formatter YYYYMMDD
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();
unbracketed /
Created November 26, 2014 18:04
Heroku copy config
set -e
while read key value; do
echo "Setting $key=$value"
unbracketed / Matches.jsx
Last active August 29, 2015 14:17
Riff on Omniscient-style component
// content component (pure)
var Match = React.createClass({
render: () => {(
<a href="{this.props.url}">{this.props.title}</a>
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'
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 = ""
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 /
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 / 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 ='^\|\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(('table_name'),'row_count'),'data_length'),'index_length'), )
unbracketed /
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/
source ~/.mybash/
#load Firefox with a development profile
alias ffdev="firefox -no-remote -P dev"
#Commands that can be handy when working in Python environments