Skip to content

Instantly share code, notes, and snippets.

@wilson428
wilson428 / number_sequences.js
Created Jun 13, 2018
Generate every sequence of K integers adding to N in any order, allowing for repeats
View number_sequences.js
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);
sub_sequence.push(c);
@wilson428
wilson428 / README.md
Last active Apr 13, 2017
Census Commuting Zones
View README.md

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

@wilson428
wilson428 / get_county_borders.js
Created Feb 1, 2017
Precompute the Cartesian length of shared borders in a topojson-powered map
View get_county_borders.js
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
wilson428 / elasticSVG.js
Last active Sep 27, 2015
Internal topoJSON borders used .mesh vs .merge
View elasticSVG.js
(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
wilson428 / counties.preprojected.topo.data.json
Created Sep 27, 2015
Internal topoJSON borders used .mesh vs .merge
View counties.preprojected.topo.data.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wilson428
wilson428 / dropbox.sh
Last active Nov 21, 2017
Fix Dropbox conflicts automatically.
View dropbox.sh
#!/bin/bash
#Thx, http://stackoverflow.com/questions/20723868/batch-rename-dropbox-conflict-files
#Point to where you want the script to look and where it should backup files it replaces
folder=~/Dropbox/Private
backup=~/Desktop/Dropbox.backup
#colors
red='\033[0;31m'
@wilson428
wilson428 / index.js
Last active Aug 29, 2015
requirebin sketch
View index.js
var Raphael = require("raphael-browserify"),
shuffle = require('shuffle-array'),
domify = require('domify');
var body = "<div id='canvas'><div id='controls'><button>PLAY</button></div>";
document.body.appendChild(domify(body))
// bag of marbles will be represented as an array of strings: ["green", "blue", "blue", ... ]
function makeMarbles(ratios) {
@wilson428
wilson428 / package.json
Created Jan 8, 2014
Recreate the Atlantic's Netflix category data using NodeJS. Requires a Netflix login.
View package.json
{
"name": "netflix-category-scraper",
"version": "0.0.0",
"description": "Collect all categories from Netflix",
"dependencies": {
"cheerio": "*",
"sqlite3": "*",
"request": "*"
},
"author": {
@wilson428
wilson428 / index.html
Last active Feb 6, 2016
Digram frequency in a common word list
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Word Stone</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="canvas" id="canvas"></div>
<div id="wordlist" class="wordlist"></div>
View coordinates.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.