Skip to content

Instantly share code, notes, and snippets.

@indefinit
indefinit / gist:4750403
Created February 10, 2013 17:49
JS: parseJsonResponse callback function
// A callback function for parsing json
function parseJsonResponse(json) {
for(var obj in json ) {
if (json.hasOwnProperty(obj)) {
var data = json[obj];
//have fun with your data object here.
@indefinit
indefinit / gist:7451808
Created November 13, 2013 16:20
Linear transformation (Math) - map a value from one range to another
//map a value from one range to another
function mapVal(value, start1, stop1, start2, stop2) {
return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
}
@indefinit
indefinit / grids.scss
Created April 23, 2014 11:27
Grids+Type+Queries - start of a micro css layout framework
@import "typography";
@import "mediaqueries";
$top-offset: 25%; //how much we want to offset our row from the top
/**
* From Nicolas Gallagher, "micro clearfix hack"
* http://nicolasgallagher.com/micro-clearfix-hack/
@indefinit
indefinit / SONO-README.md
Last active August 29, 2015 14:01
Generic Sound module for using the web audio api. A WIP. No guarantees :)

##To use: In your main script file (or inline HTML)

    //create new sound object
    var context = new SONO.ctx();
    var buffer = new SONO.BufferLoader(context, urls, onBufferLoaded);
    
    function onBufferLoaded(buffers){
      source = context.createBufferSource();
 source.buffer = buffer.bufferList[0]; //here only assigning 1 buffer to source
@indefinit
indefinit / shaderloader.js
Created July 22, 2014 02:45
Functional shader loader. Requires JQuery
var shadersHolder = { vertex: [], fragment: [] };
/**
* Fancy schmancy functional loading of Shaders
* @param {Array} shaders Object array of shaders
* @return {Jquery.Deferred}
*/
function loadShaders(shaders) {
return $.when.apply($, $.map(shaders, function(shader) {
var def = new $.Deferred();
$.ajax({url:shader.path, dataType: 'text', complete: function(resp){
@indefinit
indefinit / susy_breakpoint_setup.md
Last active August 29, 2015 14:04
Until I have time to refactor this into a bash script, here are the steps for setting up compass+susy+breakpoint

Dependencies:

  • bundler (gem install bundler)
  • susy (gem install susy)
  • breakpoint (gem install breakpoint)
  • compass (gem install compass --pre)
  • ruby vers: 2.0.*

$: bundle init #creates boilerplate Gemfile ...

@indefinit
indefinit / Gemfile
Created July 28, 2014 01:54
Snippets for using ruby gems as compass dependencies in Grunt
# A sample Gemfile
source "https://rubygems.org"
gem "breakpoint", "~>2.4.0"
gem "susy"
gem "compass", "1.0.0.alpha.21"
@indefinit
indefinit / animation.js
Created July 28, 2014 21:53
Animation snippets with a requestAnimationFrame flare
// Drop in replace functions for setTimeout() & setInterval() that
// make use of requestAnimationFrame() for performance where available
// http://www.joelambert.co.uk
// Copyright 2011, Joe Lambert.
// Free to use under the MIT license.
// http://www.opensource.org/licenses/mit-license.php
// requestAnimationFrame() shim by Paul Irish
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
@indefinit
indefinit / dragdrop.js
Last active August 29, 2015 14:05
drag&drop
/////////
/// HTML5 Drag and drop with Modernizr
/////////////////////////
function dragDrop(){}
if(Modernizr.draganddrop){
if (window.FileReader !== undefined) {
var container = document.getElementById('canvas-container');
container.ondragover = function () { this.className = 'drag-hover'; return false; };
container.ondragend = function () { this.className = ''; return false; };
container.ondrop = function (e) {
@indefinit
indefinit / OLA.md
Last active September 30, 2017 04:52
Random learnings from the project discovery phase

Learnings from working with Open Lighting Architecture for Mac OSX 10.9.5:

On compiling the OLA library from source

Getting the OLA c++ source, compiling it, and running the OLA daemon with Max/MSP to send pixel control data over E131.

  • I had a lot of initial trouble getting OLA to compile and run on my system. My goal was to eventually control LEDs with DMX/E131 protocol using Max or another client application (built in Openframeworks, Cinder, or Processing).
  • I found that my library compile problems were coming from Macports. The Official OLA documentation recommends installing with Macports but in practice Homebrew was a better option for me. Here is some info on Homebrew. http://brew.sh/ Once you have homebrew installed, you should be able to run the command brew install ola --universal in your terminal, which will install OLA to /usr/local/Cellar and symlink to /usr/local/lib directory. Sometimes homebrew installs the package but does not link it. You may have to run