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
Can2D.prototype.C_Error = function(msg, fileName, lineNumber){ | |
return Error("Can2D: "+msg, fileName,lineNumber); | |
} | |
Can2D.prototype.CError.prototype = Error.prototype; |
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
Can2D.prototype.C_Error = function(msg, fileName, lineNumber){ | |
var e = Error.call(this, msg, filename, lineNumber) | |
e.name = 'C_Error' | |
return e | |
} | |
Can2D.prototype.C_Error.prototype = Object.create(Error.prototype) |
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 p1 = getMetadata(key, EPID) | |
var p2 = getStreams(key, EPID) | |
var p3 = Promise.make().waitFor(p1, p2).bind(p1, p2) | |
.ok( function(metadata, streams) { doSomething(metadata.value, streams.value) }) | |
.failed(function(metadata, streams) { doStomethingElse(metadata.value, streams.value) }) | |
.done( function(metadata, streams) { next() }) |
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 last(xs){ return xs[xs.length - 1] } | |
function split(predicate, xs) { | |
return reduce( xs | |
, function(rv, x, i) { return predicate(x, i)? rv.concat([[x]]) | |
: /* otherwise */ (last(rv).push(x), rv) } | |
, [[ ]]) } | |
function splitEvery(n, xs) { return split(function(x, i){ return i > 0 && i % n == 0 }, xs) } |
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
(data "title" "My Story") | |
(data "author" "Mortchek") | |
(start-page "foo") | |
(page "foo" | |
(text "You are in a place.\n") | |
(choice (go "bar") "Do a thing!\n") | |
(choice (go "baz") "Do a different thing!\n") | |
(choice (give "sword") "Pick up a sword!\n") | |
(choice (give "shield") "Pick up a shield!\n") |
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 fun(yes) { | |
return yes? { foo: 'hello' | |
, bar: false | |
, quux: 10 | |
} | |
: /* otherwise */ { foo: 'hey' | |
, bar: true | |
, quux: 20 | |
} |
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
/* | |
[DESAFIO / LANGUAGE WAR] Implemente um programa na sua linguagem favorita onde o usuário digita um número x, e o programa calcula o somatório dos x primeiros números pares da sequência fibonacci, e imprime a soma dos algarismos desse número. | |
Por exemplo, quando x = 5, a resposta é 17, pois: | |
1. A sequência fibonacci é 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,... | |
2. Os 5 primeiros números pares são 0, 2, 8 e 34, 144. | |
3. O somatório disso é 188. | |
4. Somando os algarismos, 1+8+8 = 17 |
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 models = [{ | |
name: 'Jonathan', | |
location: 'Earth' | |
}, { | |
name: 'Joe', | |
location: 'Mars' | |
}] | |
var ps = models.map(function(model) { |
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 pipeline(fs, val, done) { | |
if (fs.length === 0) done(null, val) | |
else fs[0](val, function(err, val) { | |
if (err) done(err) | |
else pipeline(fs.slice(1), val, done) | |
}) | |
} | |
pipeline([ | |
asyncFunctionOne, |
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
exports.commands = { | |
mb: 'musicbox', | |
musicbox: function (target, room, user) { | |
if (!this.canBroadcast()) return; | |
var parts = target.split(','); | |
if (!target) return this.sendReply("/musicbox link, link, link - parses it to be in a music box"); | |
var parsedParts = parts.map(parse); | |
Promise.all(parsedParts).then(function(parts) { | |
var str = parts.join(''); | |
this.sendReply('str is ' + str); |