Skip to content

Instantly share code, notes, and snippets.

@amiel
Created July 20, 2010 20:03
Show Gist options
  • Save amiel/483480 to your computer and use it in GitHub Desktop.
Save amiel/483480 to your computer and use it in GitHub Desktop.
if (!$.isFunction(Array.prototype.rand)) {
Array.prototype.rand = function() {
function rand(n) { return Math.floor(Math.random() * n); }
return this[rand(this.length)];
};
}
$.konamiRand = (function() {
var fns = [], konami = function() { fns.rand()(); };
$.konami(konami);
return function(fn) {
fns.push(fn);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment