Skip to content

Instantly share code, notes, and snippets.

View amatiasq's full-sized avatar

A. Matías Quezada amatiasq

View GitHub Profile
@amatiasq
amatiasq / Handlebars- Backbone.js
Created February 5, 2013 00:06
This allow Handlebars to look up Backbone Model's attributes: {{ user.address.street }} If user is a Backbone Model this will become user.get("address").street And if user.get("adress") is also a Backbone Model this will be produced: user.get("address").get("street")
Handlebars.JavaScriptCompiler.prototype.nameLookup = function(parent, name, type) {
var result = '(' + parent + ' instanceof Backbone.Model ? ' + parent + '.get("' + name + '") : ' + parent;
if (/^[0-9]+$/.test(name)) {
return result + "[" + name + "])";
} else if (Handlebars.JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
return result + "." + name + ')';
} else {
return result + "['" + name + "'])";
}
};
@amatiasq
amatiasq / Preferences.sublime-settings
Created November 16, 2012 15:08
My Sublime Text configuration
{
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"rulers": [ 80, 120 ],
"highlight_line": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"auto_complete_commit_on_tab": true,
"shift_tab_unindent": true,
@amatiasq
amatiasq / extend.base.js
Last active October 12, 2015 14:07
Simple base class with this.base() to call parent mehtod
/**
* Provides:
* Function extend(Function parent, Object config);
*
* It extends constructors with it's methods
* Also provides to every method who overwrites another one
* with a this.base() method to invoke overwrote method.
*
* Created constructor has methods
* .extend(Object config)
@amatiasq
amatiasq / HurdlesHack.js
Created August 7, 2012 13:50
Hack today's Google's Doodle (press numpad 0 to start)
function press(key) {
document.getElementById("hplogo").onkeydown({
keyCode:key,
preventDefault:function() { }
});
}
var interval;
document.addEventListener('keydown', function(e) {
if (e.keyCode !== 96)
@amatiasq
amatiasq / advice.js
Created June 11, 2012 13:46 — forked from angus-c/advice.js
simplest advice functional mixin
// usage
withAdvice.call(targetObject);
var withSomething = function() {
this.wrap('walk', function() {
// before
this.base();
// after
});
};