Skip to content

Instantly share code, notes, and snippets.

View mmckegg's full-sized avatar

Matt McKegg mmckegg

  • Wellington, New Zealand
View GitHub Profile
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()
}
// 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])
}
}
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)
}
@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){
@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"],
### 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 / gist:44c31fa6c51ed15b06ad
Created August 2, 2014 03:50
observable array
var mutators = [
'fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'
]
function ObservableArray(onChange){
var array = []
array.set = set
array.onchange = onChange
@mmckegg
mmckegg / raf.js
Created December 9, 2013 00:27
cross browser requestAnimationFrame that works like setInterval (returns a function that will stop loop if called)
module.exports = animate
var requestAnimationFrame =
global.requestAnimationFrame ||
global.webkitRequestAnimationFrame ||
global.mozRequestAnimationFrame ||
global.msRequestAnimationFrame ||
global.oRequestAnimationFrame ||
function(fn, el) {
setTimeout(fn, 1000/60)
@mmckegg
mmckegg / bouce.sh
Created November 15, 2013 02:45
bounce local port off ssh server
ssh -R *:1234:localhost:9966 user@server.com
# http://server.com:1234
function rgb(hex){
if (hex.charAt(0) == '#'){
var color = hex.slice(1)
var splitter = color.length/3
var value = []
for (var i=0;i<3;i++){
var part = parseInt(color.slice(i*splitter, (i+1)*splitter), 16)
if (splitter == 1){
value[i] = ((part+1)*16)-1
} else {