Skip to content

Instantly share code, notes, and snippets.

View faridlab's full-sized avatar
🍀
Luck is the only skill

Farid Hidayat faridlab

🍀
Luck is the only skill
View GitHub Profile
// insertion sort
var insertionSort = function (str) {
var str = str.split(''),
result = [],
swap = [];
for (var i = 0; i < str.length; i++) {
var chr = str[i],
@faridlab
faridlab / gist:3126880
Created July 17, 2012 03:41
Make backbone.js inhertance work for you! (or make view inheritance work in general)
/**
* Give backbone an easier way to access super properties and methods.
*/
Backbone.View.prototype.parent = Backbone.Model.prototype.parent = Backbone.Collection.prototype.parent = function(attribute, options) {
/**
* Call this inside of the child initialize method. If it's a view, it will extend events also.
* this.parent('inherit', this.options); <- A views params get set to this.options
*/
if(attribute == "inherit") {