Skip to content

Instantly share code, notes, and snippets.

@ejb
ejb / .gitignore
Created May 15, 2018 19:37 — forked from starcalibre/.gitignore
Fast Interactive Canvas Scatterplot
.idea/
*.iml
@ejb
ejb / .block
Last active July 18, 2019 15:20
Structuring D3 code with ES6 classes
license: mit
@ejb
ejb / celebrate.js
Last active May 3, 2017 18:18
Fill an element with celebratory (financial) emojis. As seen on http://www.wsj.com/graphics/has-the-dow-hit-20000-yet/
function celebrate(el) {
if (doesSupportEmoji() === false) {
// browser does not support emoji, provide a fallback if you like
return;
}
var can = document.createElement('canvas');
var ctx = can.getContext('2d');
@ejb
ejb / .block
Last active August 2, 2016 19:35
Structuring D3 v4 code with constructor functions
license: mit
@ejb
ejb / perftest.js
Created June 30, 2016 17:14
Performance test: Loops versus array methods
// This script should be run with Node.js
var short = generateDummy(100);
var med = generateDummy(10000);
var long = generateDummy(1000000);
console.info('Big loop:');
test(short, bigLoop);
test(med, bigLoop);
@ejb
ejb / .block
Last active November 15, 2020 00:51
Structuring D3 code with constructor functions
license: mit
@ejb
ejb / index.html
Last active September 21, 2015 11:04 — forked from anonymous/index.html
JS Bin // source https://jsbin.com/baxoti
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.chapter-illo {
width: 100%;
}
@ejb
ejb / clickAnywhereElse.js
Created December 29, 2014 11:32
Tiny jQuery plugin for attaching a click event to everything except for the specified element (and its children). To use, just paste clickAnywhereElse.js into your JavaScript file.
// Written by Elliot Bentley, inspired by http://stackoverflow.com/a/3028037
$.fn.clickAnywhereElse = function(callback) {
var className = '.'+this.attr('class').replace(/ /g,'.');
$('html').click(function(event){
if ( !$(event.target).closest( className ).length ) {
callback();
}
});
};
var json = 'http://wsjgraphics.cartodb.com/api/v2/viz/8e5d6502-c098-11e3-8209-0edbca4b5057/viz.json';
m3({
mapId: 'nmap',
json: json,
center_lat: 49,
center_lon: 36,
zoom: 5,
maxZoom: 7,
minZoom: 4,