Skip to content

Instantly share code, notes, and snippets.

wilson428 / number_sequences.js
Created June 13, 2018 20:46
Generate every sequence of K integers adding to N in any order, allowing for repeats
function generateSequences(n, k) {
var sequences = [];
function getSequences(n, k, sequence) {
// calculate the highest possible value of a number, such that it leaves at least enough left over to fill the rest with 1s
var upper = n - k + 1;
for (var c = 1; c <= upper; c += 1) {
var sub_sequence = sequence.slice(0);
wilson428 /
Last active April 13, 2017 16:56
Census Commuting Zones

This is a map of the USDA commuting zones, which are collections of counties last modified in 2000.

wilson428 / get_county_borders.js
Created February 1, 2017 18:00
Precompute the Cartesian length of shared borders in a topojson-powered map
var fs = require("fs");
var d3 = require("d3");
var topojson = require("topojson");
var point = require('point-at-length');
var ProgressBar = require('progress');
var us = require("./us-10m.v1.json");
var path = d3.geoPath().projection(null); // pre-projected
wilson428 / elasticSVG.js
Last active September 27, 2015 14:13
Internal topoJSON borders used .mesh vs .merge
(function() {
var root = this;
// create a new SVG element
var elasticSVG = function(selector, opts) {
opts = opts || {};
// containing DOM element, which defaults to body
var parent = document.querySelectorAll(selector || "body");
wilson428 /
Created September 27, 2015 12:41
Internal topoJSON borders used .mesh vs .merge
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
wilson428 /
Last active November 11, 2022 17:20
Fix Dropbox conflicts automatically.
#Point to where you want the script to look and where it should backup files it replaces
wilson428 / index.js
Last active August 29, 2015 14:09
requirebin sketch
var Raphael = require("raphael-browserify"),
shuffle = require('shuffle-array'),
domify = require('domify');
var body = "<div id='canvas'><div id='controls'><button>PLAY</button></div>";
// bag of marbles will be represented as an array of strings: ["green", "blue", "blue", ... ]
function makeMarbles(ratios) {
wilson428 / package.json
Created January 8, 2014 05:22
Recreate the Atlantic's Netflix category data using NodeJS. Requires a Netflix login.
"name": "netflix-category-scraper",
"version": "0.0.0",
"description": "Collect all categories from Netflix",
"dependencies": {
"cheerio": "*",
"sqlite3": "*",
"request": "*"
"author": {
wilson428 / index.html
Last active April 28, 2022 05:13
Digram frequency in a common word list
<!DOCTYPE html>
<html lang="en">
<title>The Word Stone</title>
<link rel="stylesheet" href="styles.css">
<div class="container">
<div class="canvas" id="canvas"></div>
<div id="wordlist" class="wordlist"></div>
wilson428 / coordinates.json
Last active December 16, 2015 20:39
Binify example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.