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
// | |
// check that the user has the correct role for access to the route. | |
// to use, ensure that user has a roles array then add the following to routes | |
// | |
// app.get('/admin-route', app.authorise('admin', 'super-admin'), function (req, res) { ... }) | |
// | |
app.authorise = app.authorize = function () { | |
var roles = Array.prototype.slice.call(arguments) | |
return function (req, res, next) { | |
if (req.user && _.any(roles, function (role) { |
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
// use NuGet to add BundleTransformer to your project | |
// add ember.js and handlebars.js to the /Scripts folder | |
// in bundle config add something like this | |
bundles.Add(new ScriptBundle("~/bundles/templates").IncludeDirectory( | |
"~/templates", "*.handlebars")); | |
// or like this | |
bundles.Add(new ScriptBundle("~/bundles/teamplates").Include( | |
"~/templates/application.handlebars", |
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 path = require('path') | |
var vm = require('vm') | |
var handlebarsjs = fs.readFileSync(__dirname + '/vendor/handlebars.js', 'utf8') | |
var emberjs = fs.readFileSync(__dirname + '/vendor/ember/ember.js', 'utf8') | |
browserify.register('handlebars', function (body, file) { | |
//dummy jQuery | |
var jQuery = function () { return jQuery } | |
jQuery.ready = function () { return jQuery } | |
jQuery.inArray = function () { return jQuery } |
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
require 'execjs' | |
class HandlebarsFilter < Filter | |
class << self | |
def contents | |
@@contents ||= [File.read("headless-ember.js"), File.read("ember.js")].join("\n") | |
end | |
def context | |
@@context ||= ExecJS.compile(contents) |
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
/*global phantom:true, console:true, WebPage:true, Date:true*/ | |
(function () { | |
var url, timeout, page, defer; | |
if (phantom.args.length < 1) { | |
console.log("Usage: phantomjs run-mocha.js URL [timeout]"); | |
phantom.exit(); | |
} | |
url = phantom.args[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
/// <summary> | |
/// Creates a fast lookup for auto complete lists | |
/// </summary> | |
/// <typeparam name="T">Object type to to lookup</typeparam> | |
public class AutoComplete<T> { | |
private Dictionary<int, List<KeyValuePair<T, int>>> directory = new Dictionary<int, List<KeyValuePair<T, int>>>(); | |
private int minMatchLength; | |
private bool enableSoundexMatching; | |
/// <summary> |
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 winston = require('winston') | |
require('winston-mongodb') | |
// prepare some custom log levels | |
var customLevels = { | |
levels: { | |
debug: 0, | |
info: 1, | |
warning: 2, | |
error: 3 |
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
<configuration> | |
<system.webServer> | |
<handlers> | |
<add name="iisnode" path="app.js" verb="*" modules="iisnode" /> | |
</handlers> | |
<!-- stop IIS from replacing non 200 response bodies --> | |
<httpErrors existingResponse="PassThrough" /> | |
<!-- send all incoming requests to nodejs --> |
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 fs = require('fs') | |
var vm = require('vm') | |
var handlebarsjs = fs.readFileSync('path/to/handlebars.js', 'utf8') | |
var emberjs = fs.readFileSync('path/to/ember.js', 'utf8') | |
var templatesDir = 'path/to/template/dir' | |
desc('Compile all .handlebars templates') | |
task({ 'handlebars': [] }, function () { | |
process.stdout.write('Compiling .handlebars templates') |
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
// only output the block if the object property exists/is defined | |
// | |
// {{#defined property}} | |
// Property exists | |
// {{/defined}} | |
Handlebars.registerHelper('defined', function(property, block) { | |
return typeof(this[property]) !== 'undefined' ? block(this) : ''; | |
}); |