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
/** Consider the interface | |
interface Mappable<A> { | |
map: (A → B) → Mappable<B> | |
} | |
*/ | |
function Identity(value) { |
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 ConcatChurch is | |
import Prelude | |
# -- Helpers --------------------------------------------------------- | |
export $a get => match $a with | |
| $a' :: _ => $a' | |
end | |
export $a to-number => $a depth-start: 0 | |
where |
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 models = [{ | |
name: 'Jonathan', | |
location: 'Earth' | |
}, { | |
name: 'Joe', | |
location: 'Mars' | |
}] | |
var ps = models.map(function(model) { |
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 id(a) { | |
return a | |
} | |
function compose(f, g){ return function(x) { | |
return f(g(x)) | |
}} | |
function partial(f, x) { | |
return function(y) { |
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 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 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); |
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
/** | |
* Object.keys(object) -> Array of String | |
* | |
* List the keys that belongs only to the given object. | |
**/ | |
(function() { | |
function list_keys(object) { | |
var prop | |
, keys = []; |
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
/** | |
* preload(urls[, wait=10][, callback]) | |
* - urls (Array): a list of all image urls to preload | |
* - delay (Number): how much time to wait for an image before | |
* flagging it as unreachable, in seconds. | |
* - callback (Function): optional function to call after all images | |
* are preloaded. | |
**/ | |
function preload(urls, wait, callback) { | |
var timer_id; // id of the last timer event |
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
// The outrageous totally awesomely unoptimized and hard way of doing | |
// the stuff :D | |
(function() { | |
var c, list | |
, letters = {} | |
, str = "ah, yes, for all the letters, you'll need" | |
+ "a loop... i read it wrong." | |
; | |
str.replace(/\s|\S/g, function(match) { |
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
// --[ main.js ]--------------------------------------------------------------- | |
require('A.js', function cba() { /* A.js was loaded */ }); | |
// --[ A.js ]------------------------------------------------------------------ | |
require('B.js', function cbb() { /* B.js was loaded */ }); | |
// --[ B.js ]------------------------------------------------------------------ | |
/* dummy file */ | |
// ---------------------------------------------------------------------------- |