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
Account customer image |
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
subArrayProto = { | |
__proto__ : Array.prototype, | |
evenElements : function() { | |
return this.filter(function(el) { | |
return el % 2 === 0; | |
}); | |
} | |
}; | |
function makeSubArray() { |
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 marked = require('marked'); | |
var highlight = require('my-code-highlighter'); | |
exports.render = function(el, text) { | |
el.innerHTML = marked(text, { highlight: highlight }); | |
}; |
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
(defprotocol Shape | |
(perimeter []) | |
(draw [scene x y])) | |
(defrecord Square [s] | |
Shape | |
(perimeter [] | |
(* s 4)) | |
(draw [scene x y] | |
(draw-polygon scene |
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
// Wraps multiple audioNodes into one node | |
function wrapNodes(context, inputNodes, outputNodes) { | |
var wrapper = context.createGain(); | |
inputNodes.forEach(function(node) { | |
wrapper.connect(node); | |
}); | |
wrapper.connect = function(node) { | |
outputNodes.forEach(function(outputNode) { | |
outputNode.connect(node); | |
}); |
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
; Clojure doesn't have bags (multi-sets) natively. | |
; Here are a few utility functions that let you use maps as bags | |
(defn bag-conj | |
"Adds an item to a bag" | |
([bag item] | |
(if-let [n (get bag item)] | |
(assoc bag item (inc n)) | |
(assoc bag item 1))) | |
([bag item & items] |
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
// JavaScript's strings aren't multiline by default | |
var poem = "old pond . . . | |
a frog leaps in | |
water’s sound"; | |
// SyntaxError: unterminated string literal | |
// You can get multiline strings by escaping the newline... | |
var poem = "old pond . . . \ | |
a frog leaps in \ | |
water’s sound"; |
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 inherit(proto, literal) { | |
var result = Object.create(proto); | |
for (var prop in literal) { | |
if (literal.hasOwnProperty(prop)) { | |
result[prop] = literal[prop]; | |
} | |
} | |
return result; | |
} |