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 Promise = require('bluebird'); | |
Promise.extend = function(method, fn) { | |
var Promise = this; | |
Promise.prototype[method] = function Promise$_Proxy() { | |
var $_len = arguments.length; | |
var args = new Array($_len + 1); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i + 1] = arguments[$_i];} | |
var bound = this._isBound() ? this._boundTo : null; | |
return this._then(function(obj) { |
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 makeOutputDir(inWC, outWC, dir) { | |
if (outWC.indexOf('/**/') === -1) return outWC; | |
var outMask = path.basename(outWC); | |
inWC = path.dirname(inWC)+'/'; | |
outWC = path.dirname(outWC)+'/'; | |
dir = path.normalize(dir); | |
var inSplit = inWC.split('/**/'), |
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 strict'; | |
var fez = require('fez'); | |
module.exports.default = function (rule, done) { | |
setImmediate(function () { | |
rule.each('src/*.js', fez.mapFile('dst/*.js'), function () {}); | |
done(); | |
}); | |
}; |
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 strict'; | |
var assert = require('assert'); | |
var regex = /^(\/?(([^/*]+\/)*(\*\*(\/|$))?)?)?([^/*]*(\*([^*/]*))?)$/; | |
regex.verify = function () { | |
var success = [ | |
'/foo/bar', | |
'/foo/bar/', |
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 prompt = require('promised-prompt'), | |
Promise = prompt.Promise; | |
prompt({ | |
required: true | |
}).ask('db type?', { | |
key: 'db', | |
type: 'multi', | |
default: 'pg', | |
validator: [ 'pg' ] |
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 Promise = require('bluebird'), | |
ie = require('int-encoder'), | |
crypto = require('crypto'); | |
var alpha = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()[{]}/?=+\\|-_\'",<.>;:'; | |
function getRandomPass(len) { | |
var deferred = Promise.defer(); | |
var bytes = Math.ceil(Math.log(alpha.length)/Math.log(256)*len); |
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 strict'; | |
module.exports = function (app, opts) { | |
var fs = require('fs'), | |
path = require('path'), | |
join = path.join, | |
Promise = require('bluebird'), | |
extend = require('jquery-extend'), | |
dust = opts.helpers ? | |
require('dustjs-helpers') : |
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 strict'; | |
var Promise = require('bluebird'); | |
module.exports = getStreamData; | |
// return ascii character value from two ascii character values in hex representation | |
function fromHex(b1, b2) { | |
b1 -= 48; if (b1 > 9) { b1 -= 7; } // A -> 10 | |
b2 -= 48; if (b2 > 9) { b2 -= 7; } |
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
// in the app setup: | |
dust.helpers.config = function (chunk, ctx, bodies, params) { | |
var data = ctx.get('config'); | |
if (!data) return chunk; | |
var str = JSON.stringify(data).replace("</script>", "<'+'/script>"); | |
str = "<script>function CONFIG() { return JSON.parse('"+str+"'); }</script>"; | |
return chunk.write(str); | |
}; |
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
/* Call initially with arguments as a path from this.state | |
* to the key you want a callback to update: | |
* | |
* this will return a function to update this.state.foo: | |
* this.update('foo') | |
* | |
* and this will return one to update this.state[0].bar: | |
* this.update('state', 0, 'bar') | |
* | |
* All arguments are optional; this returns a callback |