Skip to content

Instantly share code, notes, and snippets.

View tdsmith's full-sized avatar

Tim D. Smith tdsmith

View GitHub Profile
@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: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: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;})()
darkside:Desktop tim$ python uh2.py
outer
inner
inner
inner
outer
inner
inner
inner
@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
#!/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'):