Skip to content

Instantly share code, notes, and snippets.

View thejefflarson's full-sized avatar
👨‍👩‍👧‍👦
being a dad

Jeff Larson thejefflarson

👨‍👩‍👧‍👦
being a dad
View GitHub Profile
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);
}});
}
});
$ 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
// 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.
var events = {
e : {},
register : function(key, fn) {
this.e[key] = fn;
},
trigger : function(key){
this.e[key]();
}
}
var events = {
e : {},
register : function(key, fn) {
this.e[key] = fn;
},
trigger : function(key){
try {
this.e[key]();
} catch(e) {
if(key != "error")
$('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");
});
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);
});
var A = Backbone.Model.extend({
constructor: function(){
console.log('hello');
/* init */
}
});
var B = A.extend({
constructor : function(){
@thejefflarson
thejefflarson / bb.js
Created October 20, 2010 02:15
model validations on create
// 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);
};
@thejefflarson
thejefflarson / elections.rb
Created November 2, 2010 22:19
2010 Midterms Election App
exit 1