This file contains hidden or 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
// version 1 | |
function A() { | |
this.init(); | |
} | |
A.prototype = { | |
init: function () { | |
A.inits.forEach(function (item) { | |
item.call(this); | |
}, this); |
This file contains hidden or 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
pjs.addSuite({ | |
url: 'http://ithaca.craigslist.org/apa/', | |
scraper: function () { | |
var listings = []; | |
$('blockquote p a').each(function () { | |
var item = $(this); | |
listings.push({url: item.attr('href'), text: item.text()}); | |
}); | |
return listings; | |
} |
This file contains hidden or 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
(function (_, slice) { | |
_.filterAll = function (data) { | |
var filters = slice.call(arguments, 1); | |
return _.filter(data, function (item) { | |
var found = true; | |
for (var i = 0, l = filters.length; i < l; i++) { | |
found &= filters[i](item); | |
} | |
return found; | |
}); |
This file contains hidden or 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
(function (b2d, L) { | |
// Box2d shortcuts | |
var b2Vec2 = b2d.Common.Math.b2Vec2, | |
b2BodyDef = b2d.Dynamics.b2BodyDef, | |
b2Body = b2d.Dynamics.b2Body, | |
b2FixtureDef = b2d.Dynamics.b2FixtureDef, | |
b2Fixture = b2d.Dynamics.b2Fixture, | |
b2World = b2d.Dynamics.b2World, | |
b2PolygonShape = b2d.Collision.Shapes.b2PolygonShape, |
This file contains hidden or 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
function profile(methods, ctx) { | |
ctx = ctx || this; | |
for (var i = 0, l = methods.length; i < l; i++) { | |
(function(name) { | |
var method = ctx[name]; | |
ctx[name] = function () { | |
console.time(name); | |
method.apply(this, arguments); | |
console.timeEnd(name); | |
} |
This file contains hidden or 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 Resource = (function () { | |
// static API | |
var api = (function () { | |
this.models = []; | |
this.add = function (model) { | |
// TODO: make model a real model | |
this.models.push(model); |
This file contains hidden or 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
(function ($) { | |
var matchers = { | |
'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/, | |
'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/ | |
}; | |
var defaults = { | |
x: 0, | |
y: 0, |
This file contains hidden or 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
// server | |
// redis client | |
var redisClient = redis.createClient(process.env.REDIS_PORT, process.env.REDIS_HOST); | |
redisClient.auth(process.env.REDIS_PASS); | |
// redis session store | |
var session = { | |
secret: 'your_secret', | |
store: new RedisStore({ client: redisClient }) |
This file contains hidden or 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
(function ($) { | |
$.elementFromPoint = function (x, y) { | |
var moved = false; | |
var yo = window.pageYOffset; | |
var xo = window.pageXOffset; | |
var w = window.innerWidth; | |
var h = window.innerHeight; | |
if (yo > 0) { |
This file contains hidden or 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
if ('ontouchstart' in window) { | |
// turn off click event | |
$(document) | |
.on('click', 'a', function(e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
}) | |
.on('tap', 'a', function(e) { | |
window.location.href = $(e.currentTarget).attr('href'); | |
}); |