Skip to content

Instantly share code, notes, and snippets.

View juliangruber's full-sized avatar

Julian Gruber juliangruber

View GitHub Profile
// Javascript Doubly Ended Queue
var Dequeue = function() {
this._head = new Dequeue.Node();
this._tail = new Dequeue.Node();
this._head._next = this._tail;
this._tail._prev = this._head;
}
Dequeue.Node = function(data) {
this._data = data;
@creationix
creationix / component-build.js
Created October 25, 2012 16:27
architect http plugin for dynamic component building
module.exports = setup;
setup.consumes = ["http"];
function setup(config, imports, register) {
imports.http.wrap(require('./middleware')(config));
register();
}
@Marak
Marak / 0-primeFactor.js
Last active October 12, 2015 03:58
Experimenting with new process.prevTick() API
//
// Calculating prime factors in polynomial time using node.js process.prevTick()
//
// see: http://en.wikipedia.org/wiki/Prime_factor
// see: http://en.wikipedia.org/wiki/Novikov_self-consistency_principle
//
// Authors:
// http://jesusabdullah.net/
// http://marak.com
//
@tj
tj / in.js
Last active December 11, 2015 08:38
quick hack of an example of how to add some type enforcement via pre-processing
def greet(first:string, last:string) {
ret "Hello " + first + " " + last
}
# setup fd 3 as udp connection to drone
exec 3<>/dev/udp/192.168.1.1/5556
# takeoff
echo -e "AT*REF=1,512\r" >&3
# landing
echo -e "AT*REF=2,0\r" >&3
...
# profit?
@tj
tj / example.js
Created July 31, 2013 18:48
console.api()
function params(fn) {
var str = fn.toString();
var sig = str.match(/\(([^)]*)\)/)[1];
if (!sig) return [];
return sig.split(', ');
}
console.api = function(obj){
console.log();
var proto = Object.getPrototypeOf(obj);
@tj
tj / lambda.rb
Created August 3, 2013 19:37
Luna
tobi = { name = 'tobi' }
loki = { name = 'loki' }
# equality
same = |a, b| a.name == b.name
print(same(tobi, loki))
# greeting
greet = |user| 'Hello ' .. user.name
@tj
tj / config.js
Last active December 27, 2015 14:49
/**
* Module dependencies.
*/
var pkg = require('../package');
var env = process.env.NODE_ENV || 'development';
/**
* Return setting `name`.
*

Disclaimer: I work for Mozilla and am a Node.js core maintainer. The opinions expressed here do not reflect those of Mozilla or the Node.js project.

After watching the events unfold the last 2 days I decided to sit down, with my two cartons of Trader Joe's eggnog, and simply express with all humility and confidence what libuv@47d98b6 definitely was not.

Over the last year I have had the pleasure of being mentored by Ben. He is largely responsible for my initial major involvement writing performance improvements for Node, and has easily surpassed

@max-mapper
max-mapper / index.js
Created April 20, 2014 20:03
requirebin sketch
var term = require('hypernal')()
var tablify = require('tablify').tablify
var request = require('browser-request')
var url = require('url')
term.appendTo(document.body)
// style fake terminal
var termEl = term.term.element
termEl.style['font'] = '13px Monaco, mono'