Skip to content

Instantly share code, notes, and snippets.

View tdsmith's full-sized avatar

Tim D. Smith tdsmith

View GitHub Profile
#!/usr/bin/python
from BeautifulSoup import BeautifulStoneSoup
f = open('VCH Restaurant Data.kml', 'r')
buf = f.read()
f.close()
soup = BeautifulStoneSoup(buf)
for placemark in soup.findAll('placemark'):
@tdsmith
tdsmith / gist:762846
Created January 2, 2011 21:41
eatsure-van data formats
restos.tab
# tab-separated values
# now we have the restaurant list in a table
# the table has, in tab-separated columns:
# 0: restaurant name
# 1: unit, street address
# 2: jurisdiction (not quite city)
# 3: date of last inspection (DD-Mon-YYYY)
# 4: Restaurant GUID
darkside:Desktop tim$ python uh2.py
outer
inner
inner
inner
outer
inner
inner
inner
@tdsmith
tdsmith / gist:2266841
Created March 31, 2012 17:13
UC Irvine library proxy bookmarklet
javascript:(function(){l=document.location;rot13=function(str){return str.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<='Z'?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});};url='https://vpn.nacs.uci.edu/+CSCO+'+'00'+rot13(l.protocol+'//'+l.host).replace(/[\s\S]/g,function(s){return parseInt(s.charCodeAt()).toString(16);})+'++'+l.pathname+l.search+l.hash;window.location.href=url;})()
@tdsmith
tdsmith / gist:4085621
Created November 16, 2012 08:55
double and numeric are not synonyms
> a <- c(1,2)
> b <- as.integer(a)
> is.numeric(a)
[1] TRUE
> is.numeric(b)
[1] TRUE
> is.double(b)
[1] FALSE
@tdsmith
tdsmith / gist:4085743
Created November 16, 2012 09:12
chain assignment with = works
> a <- 1
> b <- 2
> a = b = 3
> a
[1] 3
> b
[1] 3
@tdsmith
tdsmith / gist:4223645
Created December 6, 2012 10:55
Rooting your first-gen Kindle Fire from OS X

You don't need some stupid collection of batch files; this isn't that hard.

  1. Set up the Android SDK with Kindle Fire add-ons so that adb devices shows the Kindle in your list, like so: https://developer.amazon.com/sdk/fire/connect-adb.html
  2. Attain bootloader access per http://forum.xda-developers.com/showthread.php?p=24129239 -- go only as far as flashing the bootloader and recovery with fastboot. Do not use a version of twrp newer than 2.2.2.0: http://techerrata.com/file/twrp2/blaze/openrecovery-twrp-2.2.2.0-blaze.img or else a process named zygote will continuously segfault when you try to boot and all you will see is spinning triangles. If fastboot seems to hang without printing output, it hasn't done anything; you can safely hit Ctrl+C and force-reboot your Kindle.
  3. Boot in to twrp, Wipe Fucking Everything, and sideload and install your ROM of choice (I am partial to this one: http://forum.xda-developers.com/showthread.php?t=1765288 -- do not unzip it before copying it to your Kindle). Make sur
@tdsmith
tdsmith / twevernote.py
Created December 24, 2012 21:45
A little script to dump your Twitter .zip archive into an Evernote notebook on OS X. For, you know, cloudiness. Loads tweets at about one per second, so don't expect it to be super-zippy. pip install appscript if you haven't, yet, which will give you aem.
#!/usr/bin/env python
import json, appscript, aem, sys, os, glob, datetime
def usage(called_name):
print 'Usage: %s <path to unzipped twitter archive> <name of Evernote notebook>' % called_name
print 'e.g., %s tweets/ "My Tweets"' % called_name
def main(tweet_path, notebook_name):
if not os.path.isdir(tweet_path):
@tdsmith
tdsmith / gist:4478232
Last active December 10, 2015 18:58
QMJC planning meeting

Quantitative Microdevice Journal Club

Attending: Siavash Ahrar, David Li, Tim Smith; Kamran wandered in at some point

Unable to attend: Mindy Simon

Schedule

Once a month, in the third week? TBD.

Siavash will present first, since he has Feelings about how these should work so he can serve as a model.

@tdsmith
tdsmith / list.py
Last active December 12, 2015 03:08
A tool to help with Twitter list management. Shows you: a) people who are in your list who you don't follow and b) who you follow (newest first-ish), and whether your follows are in your list or not. To start, go to https://dev.twitter.com/apps, create a new app, and get app tokens. Use the dev web interface to create an OAuth token. Put those i…
#!/usr/bin/env python
import twython, secrets
from math import ceil
def cursored_request(method, sequence, *args, **kwargs):
myseq = []
nextCursor = -1
while nextCursor != 0:
kwargs['cursor'] = nextCursor