Skip to content

Instantly share code, notes, and snippets.

@hapticdata
hapticdata / debug-node
Last active August 29, 2015 13:56
easy node and node-global debugging. 2 functions for your .bashrc
# put these in your ~/.bashrc and start a new shell to receive these commands
# requires node-inspector, install: npm install -g node-inspector
# start node-inspector and debug node app
# example: debug-node --open app.js --port=3000
function debug-node () {
# start node-inspector as a background-process
node-inspector &
# grab last PID to kill process later
INSPECTOR_PID=$!
@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 / 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",
@hapticdata
hapticdata / animator.js
Created March 29, 2012 15:50
simplified animation using requestAnimationFrame with onComplete, stop and resume
/**
* animator factory for creating requestAnimationFrame callbacks
* and simplifying their cancellation. Includes Erik Moller polyfill
* @author Kyle Phillips
* @example
* animator(function(){
* //do this every time
* if(Math.random() > 0.9){
* this.complete();
* }
@hapticdata
hapticdata / watch-less.js
Created August 10, 2012 01:14
Watches all .less files and renders css with every change
#!/usr/bin/env node
/**
* Watches all project .less files,
* automatically renders css with every change
* usage: $watch-less ~/Sites/myProject1 ~/Sites/myProject2
*/
var less = require('less'),