Skip to content

Instantly share code, notes, and snippets.

## 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);

#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
@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
@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 / 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 / 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 / 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 / quickScene.js
Created October 29, 2013 23:28
A quick + consistent way to setup a three.js scene
define([
'three'
], function( THREE ){
/**
* quickly set up all of the basics of a THREE.js canvas
* @param {Object} [app] the settings for the app
* @param {Number} [app.width]
* @param {Number} [app.height]
* @param {Number} [app.fov]
@hapticdata
hapticdata / Gruntfile.js
Created October 15, 2013 22:25
Read all of the grunt tasks out of your devDependencies and load them
//load all of the Grunt NPM Tasks out of the package.json
Object.keys(require('./package.json').devDependencies).forEach(function(dep){
if( dep.match(/grunt-/) ){
grunt.loadNpmTasks(dep);
}
});
@hapticdata
hapticdata / toxiBufferGeometry.js
Created January 17, 2013 05:06
convert a toxiclibs.js trianglemesh into a three.js BufferGeometry, needs testing
define(function( require ){
var THREE = require('three');
/**
* take a toxiclibs.js mesh and turn it into a THREE.BufferGeometry
* @param {toxi.geom.mesh.TriangleMesh} mesh
* @type {THREE.BufferGeometry}
*/
return function( mesh ){
var geometry = new THREE.BufferGeometry();
//3 points per face, 3 axis per point