Skip to content

Instantly share code, notes, and snippets.

// Based on Brian Grinstead's console.save()
// http://bgrins.github.io/devtools-snippets/#console-save
(function(console){
console.saveCsv = function(data, filename){
if(!data) {
console.error('Console.saveCsv: No data')
return;
@ericsoco
ericsoco / eslint-config.json
Created September 5, 2019 19:11
Generated via `eslint --print-config file-causing-lint-crash.js`
{
"globals": {
"afterAll": false,
"afterEach": false,
"beforeAll": false,
"beforeEach": false,
"describe": false,
"expect": false,
"fit": false,
"it": false,
@ericsoco
ericsoco / multi-series.json
Created October 10, 2018 19:46
Vega: Multi-series line chart w/ tooltips
// The spec below creates a dataset, `tooltip_0_0`,
// that contains pivoted values for each groupby.
// These key:value pairs can be fed into a tooltip implementation
// to display the value of each line at each timestep.
{
"$schema": "https://vega.github.io/schema/vega/v4.0.json",
"description": "",
"width": 800,
"height": 600,
@ericsoco
ericsoco / gist:72538faae3587fe117c5f094248bb79c
Created August 24, 2018 05:38
Immutable splice (Javascript / ES6)
const merge = (arr, val, i) => [
...arr.slice(0, i),
val,
...arr.slice(i + 1)
];
const arr1 = ['a', 'b'];
console.log(merge(arr1, 'foo', 1));
console.log(merge(arr1, 'foo', 0));
console.log(merge(arr1, 'foo', 2));
@ericsoco
ericsoco / gist:91d1833600bbec99725809a3762ffb0a
Created August 2, 2018 22:48
exploring multiple y-axis series in Vega
{
"$schema": "https://vega.github.io/schema/vega/v4.json",
"width": 500,
"height": 200,
"padding": 5,
"signals": [
{
"name": "interpolate",
"value": "linear",
@ericsoco
ericsoco / .block
Last active September 6, 2017 22:34
contour blob
license: mit
@ericsoco
ericsoco / .block
Last active August 30, 2017 04:01
contour blob
license: mit
@ericsoco
ericsoco / .block
Created May 26, 2017 20:08
K-Means as a force, slo-mo
license: gpl-3.0
height: 960
@ericsoco
ericsoco / desaturate.js
Last active February 9, 2017 22:33 — forked from doctyper/desaturate.js
desaturate canvas image
// Usage:
// let ctx = canvas.getContext("2d");
// let data = desaturate(0.5, ctx, canvas.width, canvas.height);
// ctx.putImageData(data);
function desaturate (amount, ctx, w, h) {
let imgData = ctx.getImageData(0, 0, w, h),
x, y, i,
grey;
@ericsoco
ericsoco / .block
Last active January 18, 2017 18:57
Multitouch tester
license: mit