Skip to content

Instantly share code, notes, and snippets.

@palewire
palewire / Hartnett Command Performance
Created September 30, 2011 20:40 — forked from ryanpitts/Hartnett Command Performance
Let Ubuntu read you the latest @wmhartnett updates from Twitter
curl https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=wmhartnett | grep '<description>.*</description>' | sed -e 's/<\/*description>//g' -e 's/ \/ wmhartnett//g' -e 's/wmhartnett: //g' | espeak
@palewire
palewire / eagle
Created November 2, 2011 21:44
Eagle
. ,
'. '. \ \
._ '-.'. `\ \
'-._; .'; `-.'.
`~-.; '. '.
'--,` '.
-='. ;
.--=~~=-, -.; ;
.-=`; `~,_.; /
` ,-`' .-; |
@palewire
palewire / eagle.cow
Created November 2, 2011 21:59
eagle.cow
#
# Caw! I'm an eagle!
#
$the_cow = <<EOC;
. , $thoughts
'. '. \ \ $thoughts
._ '-.'. `\ \ $thoughts
'-._; .'; `-.'. $thoughts
`~-.; '. '. $thoughts
'--,` '. $thoughts
@palewire
palewire / roundint2precision.py
Created November 15, 2011 20:31
Rounding an integer to precision of "significant digits"
def roundint2precision(value, count):
"""
Accepts an integer and rounds it to the nearest number
at the specified precision, measured in "significant digits."
Example usage:
>> roundint2precision(1211111, 2)
1200000
>> roundint2precision(1211111, 3)
import csv
from googlegeocoder import GoogleGeocoder
geocoder = GoogleGeocoder()
data = list(csv.DictReader(open('/home/ben/Downloads/latest.csv', 'r')))
outfile = open("out.csv", "w")
s = "%s, %s"
for row in data:
a = s % (row['Address'], row['Zip'])
@palewire
palewire / golive.py
Created January 4, 2012 18:36
A quick Python script for rolling through the DcoumentCloud error attachment and setting everything live.
"""
Before you can use this, install the @LATdatadesk DocumentCloud wrapper for Python. Like so:
$ sudo pip install python-documentcloud
"""
import csv
from documentcloud import DocumentCloud
path = '/home/ben/Desktop/docs.csv'
data = csv.DictReader(open(path, 'r'))
@palewire
palewire / fabfile.py
Created January 17, 2012 03:30
fab bootstrap
from fabric.api import *
from openstack.compute import Compute
def bootstrap():
install_chef()
update_chef()
def install_chef():
"""
Install Chef on your server
@palewire
palewire / pgfail.log
Created January 24, 2012 10:06
Weird postgres errors
In my Django error messages...
File "/apps/projects/lib/django/db/models/sql/query.py", line 2347, in execute_sql
cursor.execute(sql, params)
OperationalError: could not write block 341 of temporary file: No space left on device
HINT: Perhaps out of disk space?
...
@palewire
palewire / vacuumdb.sh
Created February 10, 2012 20:50
vacuumdb.sh
/bin/su postgres -c "/usr/bin/vacuumdb --analyze --dbname <dbname>"
@palewire
palewire / WTF.py
Created February 20, 2012 19:24
WTF.py
File "/home/ben/Code/.../lib/python2.7/codecs.py", line 984, in getreader
return lookup(encoding).streamreader
LookupError: unknown encoding: r