Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import serial, sys
DEVICE='/dev/cu.usbserial-A7006gOH'
IDS={
'28001D71E1': 'Ross',
'0800D9D1AB': 'Steve',
}
#!/usr/bin/env python
import datetime, serial, subprocess, sys, time
DEVICE='/dev/cu.usbserial-A7006gOH'
IDS={
'28001D71E1': 'Ross',
'0800D9D1AB': 'Steve',
'2200562718': 'Edd',
'2500718C43': 'Danny',
#!/usr/bin/env python
import csv
def tsv_to_csv(filename="data.tsv", output="data.csv"):
f = open(filename)
out = csv.writer(open(output, "wb"))
for line in f:
out.writerow(line.strip().split("\t"))
f.close()
#!/usr/bin/env python
import csv
def fill_in_blanks(filename="data.csv", output="data-no-blanks.csv", interval=60):
f = csv.reader(open(filename))
out = csv.writer(open(output, "wb"))
last = None
# Deal with headers
out.writerow(f.next())
#!/usr/bin/env python
import csv
from sqlalchemy import *
def csv_to_mysql(filename="data-no-blanks.csv"):
# Prepare db connection (SQLAlchemy stuff)
db = create_engine("mysql://root:root@localhost/datacopter_thepromise")
metadata = MetaData(db)
/*
For more detailed instructions on how to use this script, sign up with your email here:
http://adamloving.com/internet-programming/how-toexport-facebook-page-fans
DISCLOSURE: This javascript runs in your browser pretending to be you
looking through your page fans. Facebook should have no problem with this,
but who knows if they will think it is strange to see you looking through
all your fans so quickly (the script waits 3s before requesting each page).
I've had no problem running this so far for 1000s of page fans, but I
// TODO: remove spaces and newlines
javascript:(function(){
s=document.createElement('script');
s.type='text/javascript';
s.src='http://closure-compiler.appspot.com/code/jscc3f366b3fa0cbd851abb5b804192c398/default.js';
document.body.appendChild(s);
})();
// Via http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
(function() {
var el=document.createElement('div'),
b=document.getElementsByTagName('body')[0],
otherlib=false,
msg='';
el.style.position='fixed';
el.style.height='32px';
el.style.width='220px';
el.style.marginLeft='-110px';
@swinton
swinton / combine.py
Created September 7, 2011 15:34
Simple script to combine a bunch of GeoJson files that each specify a single Polygon into a MultiPolygon GeoJson object.
#!/usr/bin/env python
"""
Simple script to combine a bunch of GeoJson files that each specify a single Polygon into a MultiPolygon GeoJson object.
"""
import json, sys
def combine(*args):
combined = {"type": "MultiPolygon", "coordinates": []}
@swinton
swinton / record_djangocon_track_2.sh
Created September 8, 2011 22:26
Recording DjangoCon 2011 in the cloud!
#!/bin/bash
curl http://www.nextdayvideo.com:8000/room_2.ogv > stream2.ogv &
sleep 4500
kill $! 2>/dev/null && echo "finished! :)"