Skip to content

Instantly share code, notes, and snippets.

View juliangruber's full-sized avatar

Julian Gruber juliangruber

View GitHub Profile
@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`.
*
@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 / 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);
# 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?
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.fork();
cluster.fork();
cluster.on('disconnect', function(worker) {
@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
}
@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
//
@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();
}

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@chalmerj
chalmerj / gist:1492384
Created December 18, 2011 04:39
Init script for Graphite carbon-cache
#! /bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: carbon-cache init script
# Description: An init script for Graphite's carbon-cache daemon.
### END INIT INFO