Skip to content

Instantly share code, notes, and snippets.

Elijah Insua tmpvar

Block or report user

Report or block tmpvar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tmpvar / .gitignore
Created Jul 12, 2011
A console.log implementation that plays "nice" with large amounts of data. It Keeps node alive until the output has flushed to the screen.
View .gitignore
tmpvar /
Last active Sep 17, 2019
how to create your very first node.js module and publish it to the npm registry

building your first node module

This is pretty simple, lets dive in!

choose a name

Find a name that isn't taken and clearly describes what your module is doing

$ npm view your-first-node-module
tmpvar / 2d-pbd.js
Last active Sep 16, 2019
2d-pbd experiment - run with budo
View 2d-pbd.js
const ctx = require('fc')(render, 1)
const center = require('ctx-translate-center')
const {vec2, vec3, mat2, mat3 } = require('gl-matrix')
const renderGrid = require('ctx-render-grid-lines')
const segseg = require('segseg')
const ndarray = require('ndarray')
const raySlab = require('ray-aabb-slab')
const particles = []
const constraints = []
tmpvar /
Last active Oct 17, 2018
using modules in your new nodejs module

Managing dependencies

Ok, so you've built your first module, but now you want to make it use one of the many libraries available via the npm registry.

finding modules

There are a few ways to find a module. You can use or to find modules that may fit what you need.

some advice for choosing modules

tmpvar / flasher.js
Created Aug 11, 2012
quick and dirty .hex -> avr programmer using nodejs and node-serialport
View flasher.js
serialport = require('serialport'),
intelHex2Binary = require('./intelhex'),
fs = require('fs'),
sp = new serialport.SerialPort('/dev/tty.usbmodemfd121'),
argv = require('optimist').argv,
debug = 1,
s = function(d, fn) {
if (fn) {
cmds.push(function() {
tmpvar / v8-external.cpp
Last active May 27, 2018
Basic usage of v8::External in a node addon
View v8-external.cpp
#include <node.h>
#include <v8.h>
using namespace v8;
using namespace node;
struct Obj {
int x;
tmpvar / AO.frag
Created Mar 19, 2014
a few raymarching fx that I've found
View AO.frag
uniform float aoIntensity; // {"label":"AO intensity", "min":0, "max":1, "step":0.01, "default":0.15, "group":"Shading", "group_label":"Ambient occlusion"}
uniform float aoSpread; // {"label":"AO spread", "min":0, "max":20, "step":0.01, "default":9, "group":"Shading"}
// Ambient occlusion approximation.
// Based upon boxplorer's implementation which is derived from:
float ambientOcclusion(vec3 p, vec3 n, float eps)
float o = 1.0; // Start at full output colour intensity
eps *= aoSpread; // Spread diffuses the effect
tmpvar / chainhull.js
Created Mar 3, 2014
chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm
View chainhull.js
var isLeft = function(p1, p2, p3) {
return (p2.position[0] - p1.position[0])*(p3.position[1] - p1.position[1]) - (p3.position[0] - p1.position[0])*(p2.position[1] - p1.position[1]);
// chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm
// see:
// Input: P[] = an array of 2D points
// presorted by increasing x- and y-coordinates
// n = the number of points in P[]
// Output: H[] = an array of the convex hull vertices (max is n)

Keybase proof

I hereby claim:

  • I am tmpvar on github.
  • I am tmpvar ( on keybase.
  • I have a public key ASDnoLe66_72oRYokyihcVYh5fOCT6WzjzKDPNYZPT-QXQo

To claim this, I am signing this object:

You can’t perform that action at this time.