👨👩👧👦
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.readdirSync(__dirname + '/middleware').forEach(function(filename){ | |
if (/\.js$/.test(filename)) { | |
var name = filename.substr(0, filename.lastIndexOf('.')); | |
Object.defineProperty(exports.middleware, name, { get: function(){ | |
return require('./middleware/' + name); | |
}}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ab -n 1000 -c 20 http://127.0.0.1:9187/pixel.gif?key=test☃http://www.example.com | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The primary function of a **Model** is to manipulate and query data. For example filtering | |
// an array-type object should happen in a subclass of Model. Another great candidate | |
// for a **Model** is any object that requires an external resource such as an ajax call. | |
// | |
// Basically, any long running or long blocking operation should happen in a model. | |
// | |
// **Models** are bindable as well, so you can subscribe to notifications by calling | |
// `bind` with a callback and an event to subscribe to to recieve events in another object. | |
// | |
// **Models** are usually encapsulated in **Views** and rarely, if ever, stand alone. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = { | |
e : {}, | |
register : function(key, fn) { | |
this.e[key] = fn; | |
}, | |
trigger : function(key){ | |
this.e[key](); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = { | |
e : {}, | |
register : function(key, fn) { | |
this.e[key] = fn; | |
}, | |
trigger : function(key){ | |
try { | |
this.e[key](); | |
} catch(e) { | |
if(key != "error") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('twitter-link').click(function(e){ | |
e.preventDefault(); | |
var url = "http://twitter.com/share?url="+ self.short_url + "&text=" + encodeURIComponent(article.headline.text()) + "&via=propublica&related=propublica"; | |
window.open(url, "pp-twitter", "menubar=1,status=1,scrollbars=1,resizable=1,width=535,height=535"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ArrayProto = Array.prototype | |
, ObjProto = Object.prototype | |
; | |
// Array Tests | |
["forEach", "map", "reduce", "reduceRight", "filter", "every", "some", | |
"indexOf", "lastIndexOf"].forEach(function(key){ | |
var d = document.createElement("div"); | |
d.textContent = key + ": " + ArrayProto[key]; | |
document.body.appendChild(d); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var A = Backbone.Model.extend({ | |
constructor: function(){ | |
console.log('hello'); | |
/* init */ | |
} | |
}); | |
var B = A.extend({ | |
constructor : function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in Model: | |
Backbone.Model = function(attributes, options) { | |
this.attributes = {}; | |
this.cid = _.uniqueId('c'); | |
options = _.extend({silent:true}, options || {}); | |
this.set(attributes || {}, options); | |
this._previousAttributes = _.clone(this.attributes); | |
if (this.initialize) this.initialize(attributes); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exit 1 |