Skip to content

Instantly share code, notes, and snippets.

View tdegrunt's full-sized avatar

Tom de Grunt tdegrunt

View GitHub Profile
@tdegrunt
tdegrunt / ssdp.node.js
Created January 15, 2012 13:11 — forked from chrishulbert/ssdp.node.js
Service discovery using node.js and ssdp / universal plug n play
var dgram = require('dgram'); // dgram is UDP
// Listen for responses
function listen(port) {
var server = dgram.createSocket("udp4");
server.on("message", function (msg, rinfo) {
console.log("server got: " + msg + " from " + rinfo.address + ":" + rinfo.port);
});
@tdegrunt
tdegrunt / get_barcode_from_image.js
Created January 15, 2012 21:43 — forked from tobitailor/get_barcode_from_image.js
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@tdegrunt
tdegrunt / linux-node-joystick.js
Created January 28, 2012 23:17 — forked from creationix/linux-node-joystick.js
Basic Linux Joystick support.
var FS = require('fs');
var EventEmitter = require('events').EventEmitter;
// http://www.mjmwired.net/kernel/Documentation/input/joystick-api.txt
function parse(buffer) {
var event = {
time: buffer.readUInt32LE(0),
number: buffer[7],
value: buffer.readInt16LE(4)
}
@tdegrunt
tdegrunt / example.js
Created January 29, 2012 20:41 — forked from Gozala/example.js
Workaround for lack of "tail call optimization" in JS
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
events =
events: {}
bind: (topic, handler, context = this) ->
(@events[topic] ||= []).push { handler, context }
trigger: (topic, args...) ->
if @events[topic]?
event.handler.apply event.context, args for event in @events[topic]
@tdegrunt
tdegrunt / gist:1883433
Created February 22, 2012 08:30
testling dependencies
substack : testling-server $ npm ls
testling-server@0.0.0 /home/substack/projects/testling-server
├─┬ JSONStream@0.1.1
│ └── jsonparse@0.0.1
├─┬ bouncy@1.3.1
│ ├── morestreams@0.0.2
│ └── parsley@0.1.0
├─┬ browserify@1.9.2
│ ├── coffee-script@1.1.3
│ ├── commondir@0.0.1
@tdegrunt
tdegrunt / gist:1923565
Created February 27, 2012 12:59 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@tdegrunt
tdegrunt / Gemfile
Created April 5, 2013 15:18 — forked from gorenje/Gemfile
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "quantal64_vb428"
config.vm.customize ["modifyvm", :id, "--memory", 512]
config.ssh.forward_agent = true
config.vm.provision :chef_solo do |chef|
//
// Copyright (c) 2012-2013 Cédric Luthi / @0xced. All rights reserved.
//
#if TARGET_IPHONE_SIMULATOR
static const char *fakeCarrier;
#import <objc/runtime.h>