Skip to content

Instantly share code, notes, and snippets.

View mmckegg's full-sized avatar

Matt McKegg mmckegg

  • Wellington, New Zealand
View GitHub Profile
### Keybase proof
I hereby claim:
* I am mmckegg on github.
* I am mmckegg (https://keybase.io/mmckegg) on keybase.
* I have a public key whose fingerprint is 3D78 1FBE 44A0 7704 4C88 FE38 4100 3FA0 D8A3 AA97
To claim this, I am signing this object:
@mmckegg
mmckegg / upgrade.js
Created November 18, 2014 00:46
Upgrade Loop Drop 0.x kits to 1.x chunks and setups
var ArrayGrid = require('array-grid')
var fs = require('fs')
var map = {
"Floating.json": [
{ "from": "Meowra-Floating A.json",
"chunks": {
"Spit on a stranger": [0,0, 3,3, "A"],
"Crunk Bass": [2,4, 3,6, "C"],
"Overdrum": [6,0, 7,3, "B"],
@mmckegg
mmckegg / bundle-setup.js
Created December 23, 2014 09:02
loop drop script for bundling up specified setups (and related chunks, samples)
var fs = require('fs')
var source = '/Users/matt/Documents/Loop Drop'
var output = '/Users/matt/Projects/Destroy With Science/Drop'
exportSetup('DWS-Time Travellers Die')
function exportSetup(name){
var data = JSON.parse(fs.readFileSync(source + '/setups/' + name + '.json'))
data.chunks.forEach(function(chunk){
function monitor(node){
var j = node.context.createScriptProcessor(4096, 1, 1)
j.onaudioprocess = function(e){
console.log(e.inputBuffer.getChannelData(0)[0])
}
node.connect(j)
j.connect(node.context.destination)
}
// see https://msdn.microsoft.com/en-gb/goglobal/bb895996.aspx
var exec = require('child_process').exec
exec('reg query "HKEY_CURRENT_USER\\Keyboard Layout\\Preload"', {encoding: 'utf8'}, function(err, result) {
if (result) {
var match = result.match(/\s1\s+REG_SZ\s+0000([A-F0-9]+)/i)
if (match) {
console.log(match[1])
}
}
var Event = require('geval')
var Observ = require('observ')
var event = Event(function(broadcast) {
var releases = []
state.items(rebind)
function handle (event) {
if (event.event === 'start') {
broadcast()
}
@mmckegg
mmckegg / create-loop.js
Last active November 12, 2015 09:41
experiment with another form of grid looping
var ArrayGrid = require('array-grid')
var deepEqual = require('deep-equal')
var unwrap = require('./unwrap')
module.exports = createLoop
function createLoop (frames, startTime, loopLength) {
if (frames.length) {
var shape = frames[frames.length - 1].value.shape
var length = shape[0] * shape[1]
module.exports = bindWatch
function bindWatch (obs, handler) {
if (typeof handler === 'function') {
return obs(handler.bind(obs))
} else if (handler instanceof Object) {
var removeListeners = Object.keys(handler).map(watchKey, {
obs: obs,
handlers: handler
})
@mmckegg
mmckegg / find-trailing-commas.regexp
Created May 30, 2013 03:05
Regexp to find trailing commas in javascript files that throw errors in IE and destroy everything!
,\s*\n+(\s*\/\/.*\n)*\s*[\}\)\]]