Skip to content

Instantly share code, notes, and snippets.

@nsonnadsnip
nsonnadsnip / parentData.js
Created November 29, 2013 10:28 — forked from nsonnad/parentData.js
d3: access parent data
(function(d, i, j){
console.log('Method A: Parent data: ', data[j], 'Parent index: ', j);
console.log('Method B: Parent data: ', this.parentNode.__data__);
return d;
});
@nsonnadsnip
nsonnadsnip / HTML skeleton
Created November 29, 2013 10:28 — forked from nsonnad/HTML skeleton
html: an html skeleton
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>blah</title>
</head>
<body>
</body>
</html>
@nsonnadsnip
nsonnadsnip / allButThis.js
Last active December 11, 2018 01:29 — forked from nsonnad/D3: Select all but this
d3: select all but this
function mouseOn () {
var circleUnderMouse = this;
d3.selectAll('.rectGroup').transition().style('opacity',function () {
return (this === circleUnderMouse) ? 1.0 : 0.5;
});
}
@nsonnadsnip
nsonnadsnip / tsv2csv.py
Created November 29, 2013 10:26 — forked from nsonnad/tsv2csv.py
python: convert a tsv to a csv
import sys
import csv
tabin = csv.reader(sys.stdin, dialect=csv.excel_tab)
commaout = csv.writer(sys.stdout, dialect=csv.excel)
for row in tabin:
commaout.writerow(row)
@nsonnadsnip
nsonnadsnip / iterate_csv.py
Created November 29, 2013 10:26 — forked from nsonnad/iterate_csv.py
python: use itertools to iterate over rows in a csv.reader obj
import csv
import itertools
f = csv.reader(open('file.csv'))
for row in itertools.islice(f, 0, 50):
print row
@nsonnadsnip
nsonnadsnip / slice_rows.sh
Created November 29, 2013 10:25 — forked from nsonnad/slice_rows.sh
shell: use sed to slice out rows from a file
sed -n 16224,16482p filename > newfile