Skip to content

Instantly share code, notes, and snippets.

@hapticdata
hapticdata / package.json
Created April 11, 2014 18:03
hapticdata-playground package.json
{
"name": "hapticdata",
"version": "0.7.4",
"private": true,
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"domains": [
"haptic-data.com",
@hapticdata
hapticdata / hapticdata-playground-nodejitsu.log
Created April 11, 2014 18:17
hapticdata-playground-nodejitsu log
[04/11 00:16:26 PDT][out] [Fri Apr 11 2014 07:16:26 GMT+0000 (UTC)]KP-API: Update Services
[04/11 00:16:27 PDT][err] module.js:356
[04/11 00:16:27 PDT][err] Module._extensions[extension](this, filename);
[04/11 00:16:27 PDT][err] ^
[04/11 00:16:27 PDT][err] Error: ld.so.1: node: fatal: libpng15.so.15: open failed: No such file or directory
[04/11 00:16:27 PDT][err] at Module.load (module.js:356:32)
[04/11 00:16:27 PDT][err] at Function.Module._load (module.js:312:12)
[04/11 00:16:27 PDT][err] at Module.require (module.js:364:17)
[04/11 00:16:27 PDT][err] at require (module.js:380:17)
[04/11 00:16:27 PDT][err] at Object.<anonymous> (/opt/run/snapshot/package/node_modules/connect-favicon-canvas/node_modules/canvas/lib/bindings.js:2:18)
@hapticdata
hapticdata / Makefile
Created April 26, 2014 19:24
use a Makefile to run ssh commands on a vagrant box
SERVER_DIR=/var/www/host/server
CONSOLE=$(SERVER_DIR)/app/console
update:
vagrant ssh -- "cd $(SERVER_DIR) && \
sudo composer selfupdate -n -v && \
composer install -n -v"
cache:
vagrant ssh -- "$(CONSOLE) doctrine:migrations:migrate -n && \
@hapticdata
hapticdata / pluckRecursively.js
Last active August 29, 2015 14:03
pluck a property recursively from objects
/**
* @example
* var a = {
* foo: {
* foo: {
* foo: {
* foo: {
* num : 0
* },
* num: 1

#toxi.three - THREE.js support

The utilities found within toxi.three are simplified strategies for working between Toxiclibs.js and THREE.js types. The modules found in this package are native to javascript and toxiclibs.js.

##Convert toxi objects to THREE types

###toColor( tcolor, [color] ):THREE.Color

  • tcolor the toxi.color.TColor to convert to a THREE.Color
## The Problem
Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)
## The temptingly easy but ultimately wrong solution:
Alter the port the script talks to from 8000 to 80:
}).listen(80);
@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
{
"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",
/**
* 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(){
@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