Skip to content

Instantly share code, notes, and snippets.

View joneath's full-sized avatar

Jonathan Eatherly joneath

View GitHub Profile
var MyView = new Backbone.View.extend({
render: function() {
$(this.el).html(this.template());
}
});
// In real code, use DOM element
new MyView({el: $(“#my_target”)});
// In test code, use in memory element
@joneath
joneath / gist:1680062
Created January 26, 2012 00:43
Global jQuery Query
// Global jQuery query
$(“#something_i_care_about”);
@joneath
joneath / gist:1680068
Created January 26, 2012 00:45
Scoped jQuery Query
// Scoped jQuery query
$(view.el).find(“#something_i_care_about”);
@joneath
joneath / gist:1680082
Created January 26, 2012 00:48
Basic Backbone View Jasmine Test
describe("NotesView", function() {
beforeEach(function() {
var notes = new NotesCollection();
spyOn(notes, "fetch");
var view = new NotesView({collection: notes});
});
describe("#initialize", function() {
it("should fetch the notes", function() {
for (var i = 0; i < collection.length; i++) {
var record = collection[i];
}
collection.each(function(record) {
});
@joneath
joneath / jasmine_skip_render.js
Created April 12, 2012 05:20
This gist can be ran before the jasmine runner starts to stop rendering of successful specs descriptions. This is important in a large test suite as the large amount of DOM manipulation slows down the suite. This will not effect the reporting of failed sp
var specViewProto = jasmine.HtmlReporter.SpecView.prototype;
jasmine.HtmlReporter.SpecView = function(spec, dom){
this.spec = spec;
this.dom = dom;
this.symbol = this.createDom('li', { className: 'pending' });
this.dom.symbolSummary.appendChild(this.symbol);
this.detail = $("<div class='description'></div>").get(0);
};
@joneath
joneath / Preferences.sublime-settings.json
Created May 3, 2012 18:47
Sublime Text 2 User Preferences
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 16.0,
"save_on_focus_lost": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"spell_check": true,
"fade_fold_buttons": true,
"highlight_line": false,
@joneath
joneath / Default (OSX).sublime-keymap.json
Created May 3, 2012 18:49
Sublime Text 2 Key Bindings
[
{ "keys": ["super+shift+y"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+shift+n"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["super+y"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["super+v"], "command": "paste_and_indent" }
]
@joneath
joneath / compiled.js
Created May 6, 2012 05:28
Crazy CoffeeScript compiled returns
this.destroy = function() {
return $target.off("scroll", _this.watchScroll);
};
this.enableFetch = function() {
return fetchOn = true;
};
this.disableFetch = function() {
return fetchOn = false;
};