Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / bullet-collision.cpp
Created January 9, 2015 05:25
testing bullet physics collision in Cinder
Voxel* VoxelMapperApp::findVoxel(btRigidBody* pBody) {
// search through our list of gameobjects finding
// the one with a rigid body that matches the given one
for (std::vector<Voxel>::iterator iter = mVoxels.begin(); iter != mVoxels.end(); ++iter) {
if ((iter)->getPhyObj().get()->getRigidBody().get() == pBody) {
// found the body, so return the corresponding Voxel object
return &(*iter);//this feels janky!
}
}
return 0;