Skip to content

Instantly share code, notes, and snippets.

@indefinit
indefinit / c++14_quick_tip_compiler
Created December 30, 2014 14:49
C++14 in XCode 6+
If you want to use the nifty std::make_unique<T> or any other fancy c++14 feature, you'll need to enable it in XCode's "language dialects" preference dropdown.
@indefinit
indefinit / mayacam_zoom
Created December 26, 2014 16:37
Cinder glNext: Mapping mousewheel/scroll to Cinder's CameraPersp zoom
// CameraPersp mCameraPersp;
// float newEyeZ; //holds our current eye Z point
//
void mouseWheel(MouseEvent event)
{
float mouseDelta = event.getWheelIncrement() *5.f;
float newCOI = powf( 2.71828183f, -mouseDelta / 500.0f ) * mCameraPersp.getCenterOfInterest();
vec3 oldTarget = mCameraPersp.getCenterOfInterestPoint();
vec3 newEye = oldTarget - mCameraPersp.getViewDirection() * newCOI;
newEyeZ = newEye.z;
@indefinit
indefinit / of-bundle-app.md
Last active September 20, 2017 20:54
Openframeworks: bundle app resources inside packaged contents

So you want to bundle your openframeworks app and not have to worry about that pesky "data/" directory... follow this stack overflow article:
http://stackoverflow.com/questions/4882572/how-to-bundle-an-openframeworks-application-in-xcode-relative-resource-linking

TLDR: First you need to tell xCode to copy your /bin/data directory into your application bundle by adding a build phase:

  1. Click on your project in the Project Navigator
  2. Select "Build Phases"
  3. Toggle open the "Run Script" section and paste in the following:
@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
@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 / 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 / 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 / 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 / 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 / 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