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
// only polyfill .finished in browsers that already support animate() | |
if (document.body.animate) { | |
// Chrome does not seem to expose the Animation constructor globally | |
if (typeof Animation === 'undefined') { | |
window.Animation = document.body.animate({}).constructor; | |
} | |
if (!('finished' in Animation.prototype)) { | |
Object.defineProperty(Animation.prototype, 'finished', { |
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
extendsScope_module = angular.module 'classy-extends', ['classy-core'] | |
### | |
Note that this does NOT get the mixin class dependencies as of now. | |
### | |
extendsScope_module.classy.plugin.controller | |
name: 'extends' | |
localInject: ['$controller'] |
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
define [ | |
'base-ctrl' | |
], (BaseCtrl) -> | |
class AppController extends BaseCtrl | |
@register() | |
@inject('$scope') | |
init: -> | |
@$scope.foo = "bar" |
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
// Illustrative case | |
// YEAH -- ILLUSTRATIVE OF THE FACT THAT YOU CAN ISSUE PARALLEL QUERIES TO THE DATABASE INSTEAD OF SERIAL ONES LIKE A DUMB THREADED IMPLEMENTATION THAT IS INFERIOR FOR DOING WEB SERVERS | |
function (recentBlogPostIds, callback) { // obviously you need this, but use callback instead of return | |
var results = [], // Use array not object | |
, len = recentBlogPostIds.length; // Cache length since we'll be using it more than once | |
for (var i = 0; i < len; i++) { | |
var blogPostId = recentBlogPostIds[i]; |
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
function cacheOrDB (id, callback) { | |
asynchronousCache.get("id:"+id, function(err, myThing) { | |
if (myThing == null) { | |
asynchronousDB.query("SELECT * from something WHERE id = "+id, function(err, myThing) { | |
callback(err, myThing); | |
}); | |
} else { | |
callback(err, myThing); | |
} | |
}); |
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
// helper function that goes inside your socket connection | |
client.connectSession = function(fn) { | |
var cookie = client.request.headers.cookie; | |
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]); | |
redis.get(sid, function(err, data) { | |
fn(err, JSON.parse(data)); | |
}); | |
}; | |
// usage |