Skip to content

Instantly share code, notes, and snippets.

View usefulthink's full-sized avatar

Martin Schuhfuss usefulthink

  • Hamburg / Germany
  • 03:57 (UTC +02:00)
View GitHub Profile
@usefulthink
usefulthink / fivetwelve-driver-node-dmx.js
Created March 11, 2017 14:45
A fivetwelve-driver that uses the node-dmx module to send data.
/**
* A fivetwelve-driver that uses a node-dmx instance to send data.
* It is assumed that fivetwelve will have full control over the node-dmx
* instance, concurrent changes via the node-dmx interface are not supported
* and probably wont do anything useful.
*
* @example
* import fivetwelve from 'fivetwelve';
* import DMX from 'dmx';
*

Keybase proof

I hereby claim:

  • I am usefulthink on github.
  • I am usefulthink (https://keybase.io/usefulthink) on keybase.
  • I have a public key whose fingerprint is 58B4 6BDF 0508 84EA DF09 DA10 9B79 D213 41A8 EA31

To claim this, I am signing this object:

@usefulthink
usefulthink / ObjectLoader.js
Created September 6, 2016 10:12
patched THREE.ObjectLoader to support multi-materials
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.ObjectLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
this.texturePath = '';
};
@usefulthink
usefulthink / worker-transfer-test.js
Created March 1, 2016 23:30
short test to compare performance of transfers vs regular value-passing to and from workers
function createWorker(mainFn) {
var blob = new Blob(['(' + mainFn.toString() + ')()']);
var blobURL = window.URL.createObjectURL(blob);
return new Worker(blobURL);
}
var typedArray = new Float32Array(100000);
var plainArray = [];
@usefulthink
usefulthink / createWorkerUrl.js
Last active March 2, 2016 12:37
Quick and tiny implementation of a promise-based worker-pool in ES6
/**
* creates a worker url from an existing function.
* The passed function will run in the worker global scope and will be called with two
* arguments - the message-data and a callback - whenever the worker receives a message.
* The function has to invoke the callback with any resulting data to send data back to
* the UI-Thread.
*/
function createWorkerUrl(onMessage) {
const code = `
const onMessage = ${onMessage.toString()};
@usefulthink
usefulthink / workerpool.js
Created February 12, 2016 16:40
Quick and tiny implementation of a promise-based worker-pool in ES6
/**
* more or less generic minimal static worker-pool implementation.
* In order to not need any bookkeeping going on, workers must accept tasks
* exactly as they are passed to `run()` and must respond with a single message
* with the result.
*/
class WorkerPool {
constructor(url, size) {
this.workers = [];
this.jobQueue = [];
@usefulthink
usefulthink / commit-timesheet.js
Created May 5, 2014 18:03
practicing node streams – script generates a git commit-log, parses it and reformats into a day-by-day-log useful for time-tracking.
#!/usr/bin/env node
var fs = require('fs'),
util = require('util'),
spawn = require('child_process').spawn,
stream = require('stream');
function dateString(date) { return date.toISOString().split('T')[0]; }
function timeString(date) { return date.toTimeString().slice(0,5); }
@usefulthink
usefulthink / Gruntfile.js
Last active August 29, 2015 13:57
grunt-task lazyloading
module.exports = function (grunt) {
grunt.initConfig({
// as usual, just make sure that – for multitasks – there always needs to be
// an `options`-entry to correctly detect them
copy: {
options: {},
dist: {
files: [{
// ....
}]
@usefulthink
usefulthink / README.md
Created March 12, 2014 11:10
Beispiele zu der Session "EVENT-LOOPS UND 
ASYNCHRONE PROGRAMMIERUNG*" (JSdays München 2014)

... Will update this page soon ...