Skip to content

Instantly share code, notes, and snippets.

@qustosh
qustosh / gist:5294401
Created April 2, 2013 17:42 — forked from mkuklis/gist:5294248
auto curry in JavaScript
function toArray(args) {
return [].slice.call(args);
}
function autocurry(fn) {
var len = fn.length;
var args = [];
return function next() {
args = args.concat(toArray(arguments));
return (args.length >= len) ?
@qustosh
qustosh / backbone.super.js
Created February 21, 2013 18:13
backbone extend with super
// Extend Backbone Classes with a 'super' function to execute a method of an instance's superclass
_.each(['Collection', 'Model', 'View', 'Router'], function(className) {
Backbone[className].prototype.super = function(funcName) {
var parentPrototype = this.constructor.__super__;
if (parentPrototype && typeof parentPrototype[funcName] === 'function') {
return this.constructor.__super__[funcName].apply(this, _.rest(arguments));
}
};
});
/**
* Simple localStorage with Cookie Fallback
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve:
* store('my_key');