Skip to content

Instantly share code, notes, and snippets.

View nkabrown's full-sized avatar

Nathan Brown nkabrown

View GitHub Profile
@nkabrown
nkabrown / index.html
Last active June 7, 2016 18:03
selection ui
<!DOCTYPE html>
<meta charset="utf-8">
<title>D3 Selection UI</title>
<style>
html,
body {
margin: 0;
padding: 0;
}
@nkabrown
nkabrown / modulo.md
Last active May 12, 2016 15:21
short discussion of modulo

Modulo

Wolfram defines the modulo operation as "m mod n is the remainder on division of m by n. The sign of m mod n for real m, n is always the same sign of n."

Python has a true modulo operator.

-5 % 2
# => 1
@nkabrown
nkabrown / document-height.js
Created April 5, 2016 18:17
document height dimension
// jquery's method to get total document height dimensions
const height = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight,
document.documentElement.scrollHeight, document.documentElement.offsetHeight);
@nkabrown
nkabrown / index.html
Last active March 29, 2016 15:59
d3 date icons
<!DOCTYPE html>
<meta charset="utf-8">
<title>D3 Date</title>
<style>
.dates {
margin-left: 200px;
}
}
.entry-date {
@nkabrown
nkabrown / dedupe.js
Created March 22, 2016 15:14
dedupe arrays in javascript
// deduplicate array of primitives
let deduped = arr.filter((el, i, arr) => arr.indexOf(el) === i);
// or
deduped = Array.from(new Set(arr));
// deduplicate array of ojects using a hash table
function dedupe(arr) {
let hashTable = {};
return arr.filter(function(el) {
@nkabrown
nkabrown / index.html
Last active March 15, 2016 19:42
d3 date icons
<!DOCTYPE html>
<meta charset="utf-8">
<title>D3 date</title>
<link href='https://fonts.googleapis.com/css?family=Fira+Sans' rel='stylesheet' type='text/css'>
<style>
.date-row {
margin-left: 100px;
}
.date-area {
@nkabrown
nkabrown / explanation.js
Last active March 14, 2016 19:53
replace label with explanation on hover
// function to replace label with label's explanation on hover.
function mouseover() {
const s = d3.select(this)[0][0];
s.innerHTML = 'true positive rate';
s.className = 'explanation';
}
function mouseout() {
const s = d3.select(this)[0][0];
s.innerHTML = 'Sensitivity';
@nkabrown
nkabrown / index.html
Last active March 4, 2016 15:03
d3 geojson map of allegheny county pa polling stations
<!DOCTYPE html>
<meta charset="UTF-8">
<title>D3 GeoJSON</title>
<style>
html,
body {
background-color: #000;
}
</style>
<div class="container">
@nkabrown
nkabrown / index.html
Last active March 3, 2016 14:18
d3 contour map
<!DOCTYPE html>
<meta charset="UTF-8">
<title>D3 Contour Map</title>
<style>
html,
body {
background: #000;
}
.container {