Skip to content

Instantly share code, notes, and snippets.

@emilbayes
emilbayes / capped-array.js
Created March 24, 2015 21:52
Capped Array with equivalent API to Array
'use strict';
/*
var a = cappedArray(3); //limited to 3 items
var b = cappedArray(1, 2, 3); //limited to 3 items, populated with [1, 2, 3]
a.concat(b, 10); //deepEqaul to `cappedArray(2, 3, 10);`
*/
module.exports = function cappedArray(size) {
var self = [];
@emilbayes
emilbayes / index.js
Created May 8, 2015 12:37
requirebin sketch
'use strict';
//Inspired by http://bl.ocks.org/mbostock/517fdb49f959cb1461e2
var poissonDiscSampler = require('poisson-disc-sampler');
var d3 = require('d3');
var raf = require('raf');
var width = window.innerWidth;
var height = window.innerHeight;
var drift = 30;
@emilbayes
emilbayes / bundle.js
Created September 18, 2015 10:03
Poisson disc sample test
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var d3 = require('d3')
var c = require('d3-convention')()
var prng = require('xorshift').constructor([172, 26, 125, 42])
var sample = require('poisson-disc-sampler')(c.innerWidth, c.innerHeight, 4, prng.random.bind(prng))
var ctn = 0
d3.timer(function () {
for (var i = 0; i < 10; i++) {
@emilbayes
emilbayes / index.js
Last active October 5, 2015 10:41
requirebin sketch
'use strict'
var d3 = require('d3')
var speakerInput = window.document.getElementById('speaker')
var dateInput = window.document.getElementById('date')
var wordInput = window.document.getElementById('words')
var speechInput = window.document.getElementById('speech')
var csvOutput = window.document.getElementById('output')
@import 'normalize.css';
@emilbayes
emilbayes / .block
Last active February 22, 2016 12:28 — forked from mbostock/.block
N-Body Problem
license: gpl-3.0
@emilbayes
emilbayes / README.md
Last active March 4, 2016 18:00
multi-duplex-stream
@emilbayes
emilbayes / regexp.txt
Created May 11, 2016 08:26
CSS Selector for HTML RegExp
^([a-z]+)? #Element
(?:(\.-?[_a-zA-Z]+[_a-zA-Z0-9-]*)| #classes
(?:#[A-Za-z][-A-Za-z0-9_:.]*)| # Id
(\[[a-zA-Z-]+(?:=["']?.*["']?)?\]))* #Attribute
(\{.*\})? #Text Content
const html = require('yo-yo')
const struct = require('observ-struct')
const value = require('observ')
const list = require('observ-array')
const EventEmitter = require('event').Emitter
function autocomplete () {
var state = struct({
name: value(Math.random().toString(16)),
const hyperdrive = require('hyperdrive')
const level = require('level-party')
const raf = require('random-access-file')
const path = require('path')
const chokidar = require('chokidar')
const swarm = require('discovery-swarm')()
const archiveSwarm = require('hyperdrive-archive-swarm')
const lpm = require('length-prefixed-message')