Skip to content

Instantly share code, notes, and snippets.

SRC Example

This is an example of loading a markdown file from a remote location into the `` element.

@hapticdata
hapticdata / MouseOrbit.cs
Created October 3, 2017 17:53
orbit controls for Unity, modified to only work during mouse interaction
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Orbit with zoom")]
public class MouseOrbit : MonoBehaviour {
public Transform target;
public float distance = 5.0f;
public float xSpeed = 120.0f;
public float ySpeed = 120.0f;
import animitter from 'animitter';
import * as THREE from 'three';
import * as webvrui from 'webvr-ui';
const OrbitControls = require('three-orbit-controls')(THREE);
window.THREE = THREE;
require('./three-extras/vr-controls');
require('./three-extras/vr-effect');
@hapticdata
hapticdata / walk-equals.js
Created January 19, 2017 02:14
safely walk an objects hierarchy returning false if any step doesnt exist and assert the final value is equal to other paramter
/**
* a utility method that will walk the object for the provided properties
* safely asserting if the final property is equal to `other`
* @param {Object} obj
* @param {Array} steps
* @param {Object} other
* @returns {boolean} true only if properties exist for object to
* be walked and final prop is equal to `other`
*/
function walkEquals(obj, steps, other){
@hapticdata
hapticdata / array-depth.js
Created September 16, 2016 18:16
calculate the depths of nested arrays
/**
* Operations to calculate the depths of a nested array
* @author Kyle Phillips
* @module 'array-depth'
*/
const maxDepth = (a)=>{
let maxVal = Number.MIN_VALUE
let item
var css = require('dom-css'),
tmpl = require('../../views/client/object-list.jade'),
watchProperty = require('watch-property');
class ObjectListView {
constructor(title){
this.title = title;
@hapticdata
hapticdata / unique-colors.js
Last active March 18, 2016 21:33
extract the unique colors out of an image
module.exports = uniqueColors;
var _canvas;
/**
* Collect all of the unique colors within an image,
* all pixel values are returned as [ red, green, blue, alpha ] between 0 - 255
* @param {Image|HTMLCanvasElement} image
* @param {Number} [x] to start sampling
* @param {Number} [y] to start sampling
/**
* create a function that will return true once any time the value changes
* @param {Object} object
* @param {String} key
*/
function watchProperty(object, key){
var value = object[key];
return function(){
{
"name": "template-budo",
"version": "1.0.0",
"description": "Enter your description here",
"main": "javascripts/index.js",
"author": "Kyle Phillips <kyle@haptic-data.com> (http://hapticdata.com/)",
"browserify": {
"transform": [
[
"jadeify",
@hapticdata
hapticdata / ViewContainer.js
Last active August 29, 2015 14:10
A Backbone View container, using Q for promises. Expects children with a `transitionIn` and `transitionOut` function that return promises.
define(function( require, exports, module ){
var _ = require('underscore'),
Backbone = require('backbone'),
Q = require('q');
/**
* This is a generic view that manages additional children views
* use `addChild` and `removeChild` to nest a view within