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
| /* jshint node: true */ | |
| "use strict"; | |
| var Promise = require('bluebird'); | |
| var crypto = require('crypto'); | |
| var dgram = require('dgram'); | |
| var events = require('events'); | |
| var fs = require('fs'); | |
| var srp = require('srp'); | |
| var util = require('util'); |
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 Transform = require('stream').Transform, | |
| inherits = require('util').inherits; | |
| var noBuf = new Buffer(0); | |
| module.exports = LineStream; | |
| function LineStream(opts) { |
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 Transform = require('stream').Transform, | |
| inherits = require('util').inherits; | |
| module.exports = ThrottleStream; | |
| function ThrottleStream(opts) { | |
| if (!(this instanceof ThrottleStream)) | |
| return new ThrottleStream(opts); |
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
| return Promise.promisify(fs.readdir)(config.path).filter(function (fileName) { | |
| return config.mask.test(fileName); | |
| }).map(function (fileName) { | |
| var fullPath = path.join(config.path, fileName); | |
| return Promise.promisify(fs.stat)(fullPath).tap(function (stat) { | |
| stat.fullPath = fullPath; | |
| stat.fileName = fileName; | |
| }); | |
| }).filter(function (stat) { | |
| return stat.isFile(); |
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 |
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
| '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
| '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
| 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
| var prompt = require('promised-prompt'), | |
| Promise = prompt.Promise; | |
| prompt({ | |
| required: true | |
| }).ask('db type?', { | |
| key: 'db', | |
| type: 'multi', | |
| default: 'pg', | |
| validator: [ 'pg' ] |