Skip to content

Instantly share code, notes, and snippets.

@tlevine
tlevine / gist:8200901
Last active January 1, 2016 20:59
Decoding hex strings in python
In [76]: content_disposition = 'attachment;filename="Liste des pr\xe9noms 2004-2012.ods"'
In [77]: print(content_disposition)
attachment;filename="Liste des proms 2004-2012.ods"
In [78]: print eval("u'''%s'''" % content_disposition)
attachment;filename="Liste des prénoms 2004-2012.ods"
In [79]: u'How do I do this without eval?'
@tlevine
tlevine / README.md
Last active December 21, 2015 18:19 — forked from mbostock/.block
Map Zooming (Doin’ It Right)

For best viewing experience, please play “Doin’ It Right (feat. Panda Bear)” off the latest Daft Punk album while watching this animation.

<iframe width="560" height="315" src="//www.youtube.com/embed/RA5PRj7KPkE" frameborder="0" allowfullscreen></iframe>
@tlevine
tlevine / gist:6149026
Created August 4, 2013 03:43
Set up an SSH key so you can clone a Git repository from GitHub and not type your password every time you need to fetch or push.
# Create an SSH key.
ssh-keygen
# Copy this to the GitHub SSH key page.
cat ~/.ssh/id_rsa.pub
# Clone a git repository with SSH.
git clone git@github.com:tlevine/foobar.git
@tlevine
tlevine / index.js
Created August 1, 2013 18:45 — forked from max-mapper/index.js
requirebin sketch
/*
Data music ideas
https://data.baltimorecity.gov/Government/Minority-and-Women-s-Business-Enterprises-Certific/us2p-bijb?
https://data.illinois.gov/Environment/IEPA-Leaking-Underground-Storage-Tank-Incident/2kz4-t22j?
*/
var master = new (webkitAudioContext || AudioContext)
var jsynth = require('jsynth')
var term = require('hypernal')()
var tablify = require('tablify').tablify
var jsonp = require('jsonp')
term.appendTo(document.body)
// style fake terminal
var termEl = term.term.element
termEl.style['font'] = '13px Monaco, mono'
termEl.style.height = '100%'
@tlevine
tlevine / index.js
Created July 8, 2013 21:28
made with requirebin.com
var term = require('hypernal')()
var tablify = require('tablify').tablify
var jsonp = require('jsonp')
term.appendTo(document.body)
// style fake terminal
var termEl = term.term.element
termEl.style['font'] = '13px Monaco, mono'
termEl.style.height = '100%'
@tlevine
tlevine / index.js
Created July 8, 2013 21:28
made with requirebin.com
var term = require('hypernal')()
var tablify = require('tablify').tablify
var jsonp = require('jsonp')
term.appendTo(document.body)
// style fake terminal
var termEl = term.term.element
termEl.style['font'] = '13px Monaco'
termEl.style.height = '100%'
@tlevine
tlevine / asthma.sh
Last active June 4, 2017 22:56
Asthma
pip install querycsv
curl --compressed rows.appgen.me/fabj-6qv3 > /tmp/fabj6qv3.csv
querycsv.py -i /tmp/fabj6qv3.csv -o asthma.csv "SELECT [ASTHMA2], [Shape] FROM [fabj6qv3] WHERE [BOROUGH] = 'Brooklyn';"
sed -i -e '1 s/"Shape"/"Latitude","Longitude"/' -e 's/"(//' -e 's/ //' -e 's/)".*$//' asthma.csv
less asthma.csv
@tlevine
tlevine / fun.js
Created March 1, 2013 03:20 — forked from lfborjas/fun.js
//The fun solution: using array methods
var ary = [];
for(var i = 1; i <= 1000; i++){ ary.push(i); }
console.log(
ary.filter(function(item){
return (item % 3 == 0 || item % 5 == 0)
}).reduce(function(memo, current){
return memo + current
}, 0)
);
@tlevine
tlevine / exclaim.r
Created November 8, 2012 13:32
Fibonacci exclamations
paste(unlist(sapply(rev(c(0, 1, 1, 2, 3, 5, 8, 13, 21, 34)), function(n) {c(rep('!', n), ' ')})), collapse='')