Skip to content

Instantly share code, notes, and snippets.

View sydlawrence's full-sized avatar

Syd Lawrence sydlawrence

View GitHub Profile
@sydlawrence
sydlawrence / app.js
Last active August 29, 2015 13:56
The basic launchpad node app
var midiConnector = require('midi-launchpad').connect(midiport);
// wait for the connector to be ready
midiConnector.on("ready",function(launchpad) {
launchpad.on("press", function(button){
button.light(launchpad.colors.green.high);
});
launchpad.on("release", function(button) {
button.light(launchpad.colors.off);
});
@sydlawrence
sydlawrence / .gitignore
Created June 18, 2014 16:19
.gitignore
# Mac OSX Specific
# ----------------
.DS_Store
._*
.Spotlight-V100
.Trashes
# Windows Specific
# ----------------
Thumbs.db
{
"requireCapitalizedConstructors": true,
"requireMultipleVarDecl": true,
"disallowEmptyBlocks": true,
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"requireParenthesesAroundIIFE": true,
"disallowKeywords": [
"with"
],
@sydlawrence
sydlawrence / musicviz.pde
Created October 3, 2014 15:30
Simple music viz
//import Minim library
import ddf.minim.*;
//for displaying the sound's frequency
import ddf.minim.analysis.*;
Minim minim;
//to make it play song files
AudioPlayer song;
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
function Object() {
this.runMethod = function(callback) {
var data = "world";
callback(data);
}
}
var object = new Object();
// $product
$medias = array();
foreach ($product->medias as $m) {
$medias[] = $m->filename;
}
@sydlawrence
sydlawrence / turntable.fm.rave.public
Created June 20, 2011 23:19
turntable.fm RAVE Public
(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseIn
@sydlawrence
sydlawrence / gist:1036897
Created June 20, 2011 23:46
turntable.fm dj auto poll
var become_active = false;
var become_txt = $('<div>Waiting for DJ Slot</div>');
become_txt.css('position','fixed').css('bottom',0).css('left',0).css('z-index',9999).css('color','#fff');
$('body').append(become_txt);
var _oldhide = $.fn.hide;
$.fn.hide = function(speed, callback) {
if ($(this).hasClass('become_dj')) {
(function () {
var v = 0,
q = [],
o = {},
s = {},
A = {
"<": "lt",
">": "gt",
"&": "amp",
'"': "quot",