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
// Log uncaught exceptions | |
process.on('uncaughtException', function(err) { | |
console.log(err.message.red); | |
if(err.stack) console.log(err.stack.split("\n").splice(1).join("\n")) | |
}); |
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
onChange = (path, event) -> | |
takeAction = (action) -> | |
if (Date.now() - lastRun[action]) > 1000 # Reload browser max once per second | |
console.log('✎'.green, consoleMessage[action].grey) | |
ss.publish.all('__ss:' + action) | |
lastRun[action] = Date.now() | |
action = if pathlib.extname(path) in cssExtensions then 'updateCSS' else 'reload' | |
if event is 'added' or event is 'changed' | |
fs.readFile path, (err, data) -> | |
if data.toString() != '' then takeAction(action) |
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
insertBeforeTag = (html, tag, toInsert) -> | |
pos = html.indexOf(tag); | |
return html if pos != -1 | |
return html.slice(0, pos) + toInsert + html.slice(pos) |
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 ensureDirectoryExists( path, fn ) { | |
fs.exists( path, function( exists ) { | |
if( exists ) { | |
fn(); | |
} else { | |
var parent = path.replace( /(\/|\\)[^\/\\]+$/, '' ); | |
ensureDirectoryExists( parent, function() { | |
fs.mkdir( path, fn ); | |
}); | |
} |
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 mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, ObjectId = mongoose.SchemaTypes.ObjectId | |
module.exports = function(schema, options) { | |
var options = options || {} | |
, historySchemaDefinition = {} | |
, historySchema | |
, HistoryArchive |
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 ballots = [ | |
[ ['A'], ['B', 'C'], ['D'], ['E', 'F', 'G', 'H', 'I', 'J'], ['K'] ], | |
[ ['A', 'B'], ], | |
[ ['A', 'B'], ['D'], ], | |
[ ['A', 'B'], ], | |
[ ['A', 'B'], ], | |
[ ['D'], ['B'], ], | |
[ ['D', 'A'], ['C'], ], | |
[ ['C', 'D'], ['B'], ], | |
[ ['C', 'D', 'A'], ], |
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 = [ | |
// Existing Keywords | |
"break", | |
"case", | |
"catch", | |
"class", | |
"const", | |
"continue", | |
"debugger", | |
"default", |
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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var htmlStream = getHTMLStream() | |
var targetEl = document.querySelector('#target') | |
renderStream(htmlStream, targetEl) | |
/// RENDER STREAM /// |
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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var htmlStream = getHTMLStream() | |
var targetEl = document.querySelector('#target') | |
renderStream(htmlStream, targetEl) | |
/// RENDER STREAM /// |
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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var htmlStream = getHTMLStream() | |
var targetEl = document.querySelector('#target') | |
renderStream(htmlStream, targetEl) | |
/// RENDER STREAM /// |
OlderNewer