Skip to content

Instantly share code, notes, and snippets.

@danfinlay
danfinlay / gist:4571184
Created January 19, 2013 07:13
My png-loading height map voxel generator for voxel.js, which would work except the pngjs module I chose to depend on won't build with browserify: throw moduleError('No wrapper for core module'); It's the kind of thing that makes me helplessly wonder about the depths of the system.
//Sample usage:
//var pngGen = require('./png-gen').loadImage('heightmap.png');
//Assign this as your voxel.js generate function.
var fs = require('fs'),
PNG = require('pngjs').PNG,
theImage,
heightMod = 32
function loadImage(url, cb){
@danfinlay
danfinlay / gist:4974178
Created February 17, 2013 23:45
There is a problem when I try to use my voxel-zigfu kinect puppetry with voxel-engine. This character isn't even visible.
var createGame = require('voxel-engine')
var voxel = require('voxel')
var texturePath = require('painterly-textures')(__dirname)
var game = createGame({
startingPosition: [0, 200, 0],
generate: voxel.generator['Valley'],
chunkDistance: 2,
texturePath: texturePath,
worldOrigin: [0, 0, 0],
@danfinlay
danfinlay / Voxel-playback
Created February 19, 2013 23:15
My playback method for voxel-recorder kinda sucks, and doesn't handle looping. Any better ideas than this?
for(var i=0; i<recording.length; i++){
var time = Math.ceil((recording[frame+i]['time']-recording[frame]['time'])/speed)
setTimeout(function(){
frame++
assumeFrame(frame)
if(frame===recording.length-1){
if(loop){
frame=0
i=1
}else{
@danfinlay
danfinlay / Lockpicking Statement
Last active December 14, 2015 10:10
This is my caricature of opportunism in light of the recent controversy surrounding the Mayor for advertising an event that features lockpicking classes at Oakland's new hackerspace "Sudoroom".
The admonition of lockpicking classes by the Mayor and Police Chief of Oakland are as unconscionable as the thefts they purport to be in fear of. While the alarmists claim that publicly available lockpicking classes may promote criminal activity, they lose sight that this class is in the context of a larger public enrichment.
Despite being only a few months old, Sudoroom has already made itself host to a wide variety of educational, cooperative, and even marketable skill-building classes and events for hundreds of local residents. From programming computers and 3-D printing to curing cheese and modifying DNA, Sudo Room is a free, community sponsored place for fostering the collaborative creativity that comes with groups full of intellectual curiosity in a time of as much change and development as this one.
In a time where people's opportunities might lead them to crime, perhaps we ought to provide better alternatives rather than stupefying the public as a form of self defense.
Let us address the cause of
@danfinlay
danfinlay / gist:5073527
Last active December 14, 2015 10:39
A question regarding socket.io
//I need to be handling an occasional data influx whether or not a client is connected,
//but if one is connected, I'd like them to be notified of it.
//The problem is I don't know how to do that with socket.io
//A simple example of how I wish I could write it would be:
//
occasionallyGetData(function(dataGot){
socket.emit('newData', dataGot)
regularlyHandle(dataGot)
})
@danfinlay
danfinlay / gist:5085227
Created March 4, 2013 20:14
A roadmap for voxel animation.
mikolalysenko: 1. bvh -> json parser to read/writer bvh files into some js parseable format
[12:08pm] mikolalysenko: 2. a motion interpolator, that can evaluate a pose at some intermediate frame
[12:08pm] mikolalysenko: 3. a motion retargetter that can take a motion, and retarget it to a different/smaller skeleton
[12:08pm] mikolalysenko: 4. an interface to apply a skelton to a voxel.js character
@danfinlay
danfinlay / gist:5273578
Last active December 15, 2015 14:19
My HTML5 Dev Conference Plans

Both Days Feature Sleeping In

Monday April 1

10:40am - 11:30am

  • **[Sane Async Patterns: PubSub, Promises, and AMD][1]
  • Speaker: [Trevor Burnham][2], HubSpot
  • Room: Twin Peaks ***|*
@danfinlay
danfinlay / gist:5535637
Created May 7, 2013 20:00
Trying to serve a video stream with low capacity to more users. I haven't really used streams before. This was my best guess, but I'm sure there's some fundamental problem. The error this throws is: "You cannot pipe after data has been emitted from the response."
var request = require('request')
var r = request('http://my-video-stream-url', function(err, response){
if(err){
console.log("Request had error: "+err)
}else{
http.createServer(function(request, response) {
response.setHeader('Content-Type', 'image/jpeg');
response.setHeader('Accept-Ranges', 'bytes');
@danfinlay
danfinlay / gist:5535710
Last active December 17, 2015 02:28
Webcam forwarder try #2, still not working...
var r = request('http://address')
http.createServer(function(request, response) {
response.setHeader('Content-Type', 'multipart/x-mixed-replace');
response.setHeader('Accept-Ranges', 'bytes');
r.pipe(response)
r.on('end', function(){
response.end()
@danfinlay
danfinlay / gist:5745718
Created June 9, 2013 23:35
How I installed drivers on a Sanguinololu reprap from Mac OS X running Arduino 1.0.5
There are a few changes here from the official doccumentation, I've noted them.
############################################################
atmega644.name=Sanguino W/ ATmega644P
atmega644.upload.protocol=arduino #this was the final change that made it work for me.
atmega644.upload.maximum_size=63488
atmega644.upload.speed=38400 #slower solved a programmer not responding issue