Skip to content

Instantly share code, notes, and snippets.

View kevzettler's full-sized avatar

kev zettler kevzettler

View GitHub Profile
@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
Handle<Value> params[2] = {
String::New("child"), // event name
String::New("somevalue") // event name
};
v8::Local<v8::Object> ctx = Context::GetCurrent()->Global();
MakeCallback(ctx, "emit", 2, params);
@unsetbit
unsetbit / Quadtree
Created February 4, 2013 04:37
Near-infinitely scaling quadtree
/* Quadtree by Ozan Turgut (ozanturgut@gmail.com)
A Quadtree is a structure for managing many nodes interacting in space by
organizing them within a tree, where each node contains elements which may
interact with other elements within the node. This is particularly useful in
collision detection, in which a brute-force algorithm requires the checking of
every element against every other element, regardless of their distance in space.
This quadtree handles object in 2d space by their bounding boxes. It splits
a node once it exceeds the object limit per-node. When a node is split, it's

The Three.js Blender exporter has been broken for at least the last 10 releases of Three.js. It's had at least 20 individual authors and contributors, most of whom have left the project never to return. Nevertheless, I have successfully imported animated (both with rigging and morph target) meshes into Three.js. Here's all the things I've encountered which you need to know about:

  • The exporter flips all vertices, faces, etc in the mesh you export. There used to be a "Flip Y/Z" option in the exporter, but it was removed when the exporter was rewritten. Since then speculation is the Blender API changed, or some other change after this one mangled the faces on export. For now we're stuck with it until we track it down.
  • mrdoob/three.js#8723 Invalid json is exported for all files with animations, so you have to delete a key manually from the json
  • mrdoob/three.js#8710 morph target exporting doesn't work with "a
@throughnothing
throughnothing / instapaper epub download
Created April 26, 2011 00:52
script to download instapaper feed in epub format
#!/usr/bin/env perl
use v5.10;
use DateTime;
use HTTP::Request;
use LWP::UserAgent;
use HTTP::Cookies;
my $user = '';
my $pass = '';
@bryzettler
bryzettler / firstArgSelector.js
Created September 18, 2017 20:35
First Arg Reselect
/* eslint-disable import/prefer-default-export */
// @flow
import { createSelectorCreator } from 'reselect';
const defaultEqualityCheck = (a, b) => (a === b);
/**
* A selector that will only change the output if the first argument has changed.
*/
export const firstArgSelector = createSelectorCreator(
@davemackintosh
davemackintosh / Array.prototype.recursiveArrayIterator.js
Created December 10, 2012 11:06
JavaScript recursive array iterator
/**
* Prototype for recursively iterating over an array of
* arrays.
* @author Dave Mackintosh
* @param callback function
*/
Array.prototype.recursiveArrayIterator = function (cb) {
this.forEach(function (obj, inx) {
// If it's an array we want to fire another iterator
// with our parent array as a separate argument
@twolfson
twolfson / README.md
Created February 2, 2017 03:20
Proof of concept for splitting UUID ranges

We are processing items in bulk and want to have multiple jobs running for them without double sending emails or the like. We can't use offset without potentially having that problem so we are considering splitting UUID ranges.

It should work like:

  • Count total amount of items present
  • Calculate how many batches we'll need for items present
  • Divide UUID range (i.e. 0000... to FFFF...) into potential values
    • For 2 batches, this would be (0000... - 7777...F and 8888... - FFFF...)
  • Kick off jobs with these given ranges so they can process in parallel without potential collision
@ManasJayanth
ManasJayanth / canvas-immediate.js
Created April 19, 2017 05:50
Canvas Immediate mode rendering using React
import type { HostConfig, Reconciler } from 'react-fiber-types';
import type { ReactNodeList } from 'react-fiber-types/ReactTypes';
import DOMPropertyOperations from './DOMPropertyOperations';
import type {
Props,
Container,
Instance,
TextInstance,
OpaqueHandle,
const util = require('util');
const Transform = require('stream').Transform;
function Slicer (options) {
if (!(this instanceof Slicer)) {
return new Slicer(options);
}
Transform.call(this, options);
}