Skip to content

Instantly share code, notes, and snippets.

View gtzilla's full-sized avatar
🎯
Focusing

gregory tomlinson gtzilla

🎯
Focusing
View GitHub Profile

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@gtzilla
gtzilla / regex_compile_test2.js
Created October 26, 2011 07:49
Regex Test, consistent fail on every other when matching - or !
var raw_str_regex = "-([a-zA-Z0-9_]+)$";
var regex = new RegExp(raw_str_regex, "gm");
var lst = [
"this is -not",
"this is -not",
"this is -not",
"this is -not",
"this is -not",
"this is -not"
var raw_str_regex = "(?:\\s|^)((?:\!|\-)\\w+)";
var regex = new RegExp(raw_str_regex, "gm");
var lst = [
"this is !not",
@gtzilla
gtzilla / arity_check.js
Created September 28, 2011 07:55 — forked from j2labs/arity_check.js
Node.js friendly form of the arity checking decorator for javascript
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;
}
@gtzilla
gtzilla / gist:1247115
Created September 28, 2011 06:10 — forked from j2labs/gist:1247091
> 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
/*
*
*
* file: raft.js
* R.A.F.T.
*
* Request
* Animation
* Frame
* Timer/Template
/*
*
*
* 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
// 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;
}
/*
*
* 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 July 7, 2011 05:53
Just a call queue based around the webkit animation frame
/*
* 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,