Skip to content

Instantly share code, notes, and snippets.

void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
}
int lasta=0, lastb=0;
int dira=0, dirb=0;
int peaka=346, peakb=349;
int position = 0;
int cycle = 0;
@tmpvar
tmpvar / opengl-learning.md
Created August 13, 2011 23:00
Opengl factoids
@tmpvar
tmpvar / .gitignore
Created July 12, 2011 07:19
A console.log implementation that plays "nice" with large amounts of data. It Keeps node alive until the output has flushed to the screen.
gmon.out
v8.log
@tmpvar
tmpvar / 2d-pbd.js
Last active September 16, 2019 04:02
2d-pbd experiment - run with budo
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
tmpvar / managing-dependencies.md
Last active October 17, 2018 00:20
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 http://npmjs.org or http://npmsearch.com to find modules that may fit what you need.

some advice for choosing modules

@tmpvar
tmpvar / flasher.js
Created August 11, 2012 04:26
quick and dirty .hex -> avr programmer using nodejs and node-serialport
var
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
tmpvar / v8-external.cpp
Last active May 27, 2018 11:27
Basic usage of v8::External in a node addon
#include <node.h>
#include <v8.h>
using namespace v8;
using namespace node;
struct Obj {
int x;
};
@tmpvar
tmpvar / AO.frag
Created March 19, 2014 17:43
a few raymarching fx that I've found
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:
// http://www.iquilezles.org/www/material/nvscene2008/rwwtt.pdf
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
tmpvar / chainhull.js
Created March 3, 2014 21:26
chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm
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: http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain
// 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)
@tmpvar
tmpvar / keybase.md
Created September 19, 2017 14:59
keybase.md

Keybase proof

I hereby claim:

  • I am tmpvar on github.
  • I am tmpvar (https://keybase.io/tmpvar) on keybase.
  • I have a public key ASDnoLe66_72oRYokyihcVYh5fOCT6WzjzKDPNYZPT-QXQo

To claim this, I am signing this object: