Skip to content

Instantly share code, notes, and snippets.

View ianstormtaylor's full-sized avatar
🖖

Ian Storm Taylor ianstormtaylor

🖖
View GitHub Profile
@ianstormtaylor
ianstormtaylor / 0_reuse_code.js
Created August 10, 2016 16:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
void function() { //closure
var global = this
, _initKeyboardEvent_type = (function( e ) {
try {
e.initKeyboardEvent(
"keyup" // in DOMString typeArg
, false // in boolean canBubbleArg
, false // in boolean cancelableArg
, global // in views::AbstractView viewArg
@ianstormtaylor
ianstormtaylor / backbone_extensions.js
Created April 30, 2012 13:51 — forked from szimek/backbone_extensions.js
Mongo-style reduce for Backbone collections.
// Reduce collection using provided conditions
// e.g. FriendList.where({age: 30, gender: 'male'})
// Returns object of the same "class", so it's possible to chain methods
Backbone.Collection.prototype.where = function(conditions) {
return new this.constructor(_(conditions).reduce(function(memo, value, key) {
memo = _(memo).filter(function(model) {
return model.get(key) === value;
});
return memo;
}, this.models));