Skip to content

Instantly share code, notes, and snippets.

View kirbysayshi's full-sized avatar

Drew Petersen kirbysayshi

View GitHub Profile
@kirbysayshi
kirbysayshi / index.js
Last active September 21, 2015 01:09
requirebin sketch
var binaryxhr = require('binary-xhr');
var actx = null;
function kick () {
var audioContext = new webkitAudioContext()
var osc = audioContext.createOscillator()
var gain = audioContext.createGain()
gain.gain.value = 0
osc.connect(gain)
@kirbysayshi
kirbysayshi / multidimensional-dtw.js
Created September 15, 2015 21:09
override dtw's (https://github.com/langholz/dtw) silly 1-dimensional validation.
var DTW = require('./');
//var DTW = require('dtw');
var validate = require('./lib/validate');
// Monkey patch to allow for non-numeric input
validate.sequence = function() {};
var template = makeSeries([], 0, Math.PI*2);
@kirbysayshi
kirbysayshi / _README.md
Last active August 26, 2015 21:48
imports vs require

import is hoisted, meaning transition to import from require can be non-trivial if relying on app-wide dependencies to be initialized before use.

$ npm run import

> import-test@0.0.0 import /Users/drewp/GIT/import-test-gist
> babel-node index-import.js

exec a
exec c
@kirbysayshi
kirbysayshi / howhowhow.markdown
Last active August 29, 2015 14:28
Is any variant of this possible in ES6 modules / destructuring?

I have a big fat object that is structured like this (using CJS format to remove all ambiguity):

// big-fat-package.js
module.exports = {
  runtime: {
    compile: function() {},
    partials: {
      'non-valid-identifier-property-0': function() {},
      'non-valid-identifier-property-1': function() {},
@kirbysayshi
kirbysayshi / index.js
Last active August 29, 2015 14:27
requirebin sketch
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
global.moutdifference = require('mout/array/difference');
global.assert = require('assert');
function setup() {
destArr = [];
@kirbysayshi
kirbysayshi / index.js
Last active August 29, 2015 14:27
requirebin sketch
var undo = require('tap-browser-color')();
var test = require('tape');
var difference = require('mout/array/difference');
function diffN(out, a, b, n) {
out.push.apply(out, a);
for (var i = 2; i < arguments.length; i++) {
var arr = arguments[i];
for (var k = 0; k < arr.length; k++) {
var idx = out.indexOf(arr[k]);
@kirbysayshi
kirbysayshi / index.js
Created August 10, 2015 22:47
requirebin sketch
var nlp = require('nlp_compromise/src/methods/tokenization/sentence');
console.log(nlp('Working with and without his Mercury Music Prize-winning group <a href="spotify:artist:3iOvXCl6edW5Um0fXEBRXy">The M. Ward xx</a>, Jamie xx established himself as a forward-thinking beatmaker and producer. Born Jamie Smith in Putney, London, he began his musical career playing the drums, but after realizing he couldn\'t use his innovation skills on the instrument, he instead turned to the \'80s Media Production Centre, which programmed his computer-based sounds onto electronic percussion pads, allowing him to play both live and in the studio. In 2008, he teamed up with former school friends Oliver Sim, Romy Madley Croft, and Baria Qureshi to form <a href="spotify:artist:3iOvXCl6edW5Um0fXEBRXy">the xx</a>, who signed to XL subsidiary Young Turks a year later and went on to record one of the most well-received albums of the decade with their self-titled debut. As well as reworking his own band\'s tracks, he also became a so
@kirbysayshi
kirbysayshi / index.js
Created July 7, 2015 20:24
requirebin sketch
var jug = require('image-juggler');
var input = document.createElement('input');
input.type = 'file';
var output = document.createElement('canvas');
var outputCtx = output.getContext('2d');
var status = document.createElement('p');
document.body.appendChild(status);
document.body.appendChild(input);
@kirbysayshi
kirbysayshi / index.js
Last active August 29, 2015 14:24
requirebin sketch
var jug = require('image-juggler');
var Clusterer = require('ncolorpalette-clusterer');
var input = document.createElement('input');
input.type = 'file';
var output = document.createElement('canvas');
var outputCtx = output.getContext('2d');
var status = document.createElement('p');
document.body.appendChild(status);
@kirbysayshi
kirbysayshi / vash.typescript.js
Created March 24, 2015 06:38
prototype of typescript support for vash
This file has been truncated, but you can view the full file.
var Parser = require('vash/lib/parser');
var Lexer = require('vash/lib/lexer');
var codegen = require('vash/lib/codegen');
var ts = require('typescript');
var str = "@{\nvar x: string = 'string'; \n}";
var tpl = compileTS(str);
console.log(JSON.stringify(tpl))
function compileTS(markup, opts) {