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 requireQueue = function(modules, callback) { | |
function load(queue, results) { | |
if (queue.length) { | |
require([queue.shift()], function(result) { | |
results.push(result); | |
load(queue, results); | |
}); | |
} else { | |
callback.apply(null, results); | |
} |
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 can = Backbone.Role.can; | |
var EntitiesController = Backbone.Controller.extend({ | |
before: { | |
index: function() { | |
return can('read', 'entities'); | |
} | |
} | |
}); |
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
// Handlebars helper | |
var ViewsCache = Backbone.View.ViewsCache = {}; | |
Handlebars.registerHelper('view', function(view, options) { | |
var id = _.uniqueId('view-'); | |
views[id] = { view: view, options: options.hash }; | |
return new Handlebars.SafeString('<script type="text/view" data-view-id="' + id + '"></script>'); | |
}); |
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
module.exports = function(grunt) { | |
grunt.loadNpmTasks('grunt-bower-task'); | |
grunt.initConfig({ | |
bower: { | |
install: { | |
options: { | |
verbose: true, | |
cleanup: true | |
} |
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
rails_apps_composer new APP_NAME -r core frontend init railsapps setup |
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 flattenObj = function (object, target, prefix) { | |
prefix = prefix || ''; | |
return _(object).inject(function(result, value, key) { | |
if (_.isObject(value)) { | |
flattenObj(value, result, prefix + key + '.'); | |
} else { | |
result[prefix + key] = value; | |
} |
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
{ | |
"name": "the-web-app", | |
"version": "0.0.1", | |
"dependencies": {}, | |
"devDependencies": { | |
"grunt": "0.4.0", | |
"grunt-contrib-copy": "0.4.0", | |
"grunt-contrib-sass": "0.2.2", | |
"grunt-contrib-connect": "0.1.2", | |
"grunt-contrib-watch": "0.2.0", |
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
"Hello world".replace(/[aeoiu]/g, function(match, matchIndex) { | |
console.log(match, matchIndex); | |
}); | |
// -> e, 1 | |
// -> o, 4 | |
// -> o, 7 |
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
NSMutableDictionary *requestConfig = [NSMutableDictionary dictionaryWithObjectsAndKeys: | |
@"GET", @"method", | |
@"/", @"path", | |
[[NSMutableDictionary alloc] init], @"params", | |
^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"[Request] Success: %@", responseObject); | |
}, @"success", | |
^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSLog(@"[Request] Failure: %@", error); | |
}, @"failure", |
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
require "sinatra" | |
require "sinatra/async" | |
require "em-synchrony" | |
require "em-synchrony/em-http" | |
class App < Sinatra::Base | |
register Sinatra::Async | |
aget "/" do | |
Fiber.new { |