Skip to content

Instantly share code, notes, and snippets.

@nsonnad
nsonnad / iterate_csv.py
Created November 22, 2013 11:59
Iterate over specific range of rows with python csv.reader()
import csv
import itertools
f = csv.reader(open('file.csv'))
for row in itertools.islice(f, 0, 50):
print row
@nsonnad
nsonnad / .block
Last active July 18, 2022 14:49
Object constancy with multiple sets of time-series
license: gpl-3.0
@nsonnad
nsonnad / README.md
Last active August 11, 2021 04:38
Circle-bound D3 force layout

Circle-bound nodes in d3.layout.force(), using a variation of Mike Bostock's rectangular Bounded Force Layout. Here we calculate the maximum and minimum x for a given y in the circle, and vice versa.

@nsonnad
nsonnad / tsv2csv.py
Created November 22, 2013 11:38
Python script for converting tsv to 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)
@nsonnad
nsonnad / .block
Last active January 6, 2017 19:52 — forked from mbostock/.block
Ordinal line chart
license: gpl-3.0
vol () {
osascript -e "set volume output volume $*";
}
@nsonnad
nsonnad / index.html
Last active May 26, 2016 01:03
Playing around with d3's transition easing options.
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>d3.transition.ease()</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h2>d3.transition().ease("<span id="easeId"></span>")</h2>
eftInt :: Int -> Int -> [Int]
eftInt x y
| x <= y = x : eftInt (succ x) y
| otherwise = []
@nsonnad
nsonnad / slice_rows.sh
Created November 28, 2013 10:51
shell: print specific rows of file from terminal
sed -n 16224,16482p filename > newfile
@nsonnad
nsonnad / seriesLib.js
Created November 16, 2013 09:23
control flow library, from mixu's node book
function series (callbacks, last) {
var results = [];
function next () {
var callback = callbacks.shift();
if(callback) {
callback(function() {
results.push(Array.prototype.slice.call(arguments));
next();
});