Skip to content

Instantly share code, notes, and snippets.

gregory tomlinson gtzilla

View GitHub Profile
@gtzilla
gtzilla / arity_check.js
Created Sep 28, 2011 — forked from j2labs/arity_check.js
Node.js friendly form of the arity checking decorator for javascript
View arity_check.js
exports.arity_decorator = function(fun) {
function wrapped() {
if(arguments.length != fun.length)
throw new Error("Y U NO USE RIGHT?!")
fun.apply(this, arguments)
}
return wrapped;
}
View gist:1247115
> function foo(x,y) {
if(arguments.length > 2) throw new Error("Stupid no method overloading lameness error");
... args = Array.prototype.join.call(arguments, ",");
... console.log('X:' + x + ' Y:' + y + ' Args:' + args)
... }
> foo(1,2)
X:1 Y:2 Args:1,2
> foo(1,2,3,4,5)
X:1 Y:2 Args:1,2,3,4,5
View raft.js
/*
*
*
* file: raft.js
* R.A.F.T.
*
* Request
* Animation
* Frame
* Timer/Template
View animator.js
/*
*
*
* file: animator.js
* author: gregory tomlinson
* desc: handy scaffolding for doing continous animations
*
* the requestion animation frame works very well as a lazy timer
* it's cpu cycles are low and it informs the browser the
* intention is to change the DOM
View gist:1096293
// utility string parse function
function out( str, options ) {
for(k in options) {
str=str.replace(/%\{([a-zA-Z0-9-]{1,}?)\}/mi, function(m, key ){
return options[key];
});
}
return str;
}
View setTimeoutArgs.js
/*
*
* setTimeout can take more than 2 arguments. args > 2 will be passed to method in arg position 1
* setTimeout(myMethod, 10, "one", { "foo" : "bar" }
*
* */
function myMethod( param1, param2 ) {
console.log(arguments);
}
@gtzilla
gtzilla / SeriesQueue.js
Created Jul 7, 2011
Just a call queue based around the webkit animation frame
View SeriesQueue.js
/*
* SeriesQueue
* author: gregory tomlinson
* */
(function(window, undefined) {
// If a method returns true, the motion queue continues animation
// by default, functions return null, meaning empty funcs
// will not animate, instead, they will execute once,
View BitsMetaMetric.js
//
// BitsMetaMetric.js
// bitly2
//
// Created by gregory tomlinson on 2011-05-11.
// Copyright 2011 the public domain. All rights reserved.
//
/*
View BitsMetricViews.js
//
// BitsMetricViews.js
// bitly2
//
// Created by gregory tomlinson on 2011-05-12.
// Copyright 2011 the public domain. All rights reserved.
//
/*
Usage:
View rokuAttack.js
//
// rokuAttack.js
// 7codes
//
// Created by gregory tomlinson on 2011-05-08.
// Copyright 2011 the public domain. All rights reserved.
//
/*
Dependency
You can’t perform that action at this time.