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
callbacks = foo: true, bar: true | |
callback = (handle) -> | |
delete callbacks[handle] | |
if callbacks.foo and callbacks.bar | |
# do something after foo and bar | |
# do some foo | |
some_async_method 'some string', -> | |
callback 'foo' |
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
handler = (client, connection) -> | |
@log = (data, cb) -> | |
console.log data | |
node = dnode handler |
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
OptionParser = require('coffee-script/optparse').OptionParser | |
switches = [ | |
['-h', '--help', 'Displays this wonderful, elucidative help message'] | |
['-v', '--version', 'Shows zappa version'] | |
['-p', '--port [NUMBER]', 'The port(s) the app(s) will listen on. Ex.: 8080 or 4567,80,3000'] | |
['-n', '--hostname [STRING]', 'If omitted, will accept connections to any ipv4 address (INADDR_ANY)'] | |
['-c', '--compile', 'Compiles the app(s) to a .js file instead of running them.'] | |
['-w', '--watch', 'Keeps watching the file and restarts the app when it changes.'] | |
] |
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 escapeString(string) { | |
string = string.replace(/\\/g, "\\\\"). | |
replace(/\n/g, "\\n"). | |
replace(/\r/g, "\\r"). | |
replace(/\t/g, "\\t"); | |
if (string.indexOf("'") < 0) { | |
return "'" + string + "'"; | |
} | |
string = string.replace(/"/g, "\\\""); |
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
"#{"test" + a + "asdasd"}" |
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
# Establish the root object, `window` in the browser, or `global` on the server. | |
root = this | |
# Save any existing module | |
_previous = root.li | |
# Initialise the module | |
li = {} | |
# Export the module for server or browser |
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() { | |
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { | |
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } | |
function ctor() { this.constructor = child; } | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor; | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
window.modules = window.modules || {}; |
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
window.modules = {} | |
modules.test = (require, module) -> | |
module.exports = -> | |
console.log 'game created' | |
window.require = (-> | |
library = {} | |
require = (handle) -> |
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
getForks 'schacon', 'ruby-git', (callback) -> | |
count = 0 | |
forkedRepoCount = 0 | |
target = 0 | |
for fork in callback.network | |
createdDate = new Date(fork.created_at) | |
pushedDate = new Date(fork.pushed_at) | |
if createdDate > pushedDate |
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
// ================================================================== | |
// browser code in development | |
// locked into on of these options | |
// | |
// 1) using a special XHR synchronous script loader and | |
// a) seeing poor error messages with strange line numbering | |
// not corresponding with source code line numbering or | |
// b) using a JavaScript interpreter written in JavaScript | |
// to execute the code retrieved by the XHR. Line numbers |