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
const dictionary = { | |
"one": 1, | |
"two": 2, | |
"three": 3, | |
"four": 4, | |
"five": 5, | |
"six": 6, | |
"seven": 7, | |
"eight": 8, | |
"nine": 9, |
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 getRandomInt(min, max) { | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
function roll20() { | |
return getRandomInt(1, 20); | |
} |
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
const Ops = { | |
CREATE: "CREATE", | |
UPDATE: "UPDATE", | |
DELETE: "DELETE", | |
KEEP: "KEEP" | |
}; | |
function constructTree(dom) { | |
if (dom.nodeType === document.TEXT_NODE) { | |
return dom.textContent; |
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
export function createElement(tagName, options, ...children) { | |
// If the "tagName" is a function, we assume it is a custom element and delegate element creation to it. | |
// Otherwise, we create a new Element ourselves. | |
const isCustomElement = typeof tagName === 'function' | |
const element = isCustomElement ? tagName(options) : document.createElement(tagName) | |
if (!options) { | |
return element | |
} |
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
Verse 1 | |
####### | |
E D A E | |
We’ve been gone for such a long time that I’m almost afraid to go home | |
E D A E | |
A long road is a long dragged out imagination with which to go wrong | |
E D A E | |
We keep rolling on |
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
(defn square [x] (* x x)) | |
(defn happy | |
"Given a number, returns a new number that is the result of summing | |
the squares of its digits" | |
[x] | |
(let [characters (map str (seq (str x))) | |
digits (map #(Integer/parseInt %) characters)] | |
(reduce + (map square digits)))) |
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 SelectThing = React.createClass({ | |
getInitialState: function() { | |
return { | |
chosenFirstValue: "", | |
chosenSecondValue: "" | |
} | |
}, | |
updateFirstSelectValue: function(e) { |
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 SelectThing = Backbone.View.extend({ | |
events: { | |
'input .select1': 'updateFirstSelect', | |
'input .select2': 'updateSecondSelect' | |
}, | |
template: _.template($('#select-thing-template').html()), | |
initialize: function(collection1, collection2) { |
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
(defn interleave [arrays] | |
(let [largest-length (apply max (map count arrays))] | |
(->> (for [i (range largest-length)] | |
(map #(nth % i nil) arrays)) | |
(flatten) | |
(remove nil?)))) | |
(interleave [[1 2 3] ["a" "b" "c"]]) |
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
class Matrix | |
attr_reader :elements | |
def initialize(elements) | |
@elements = elements | |
end | |
def dimensions | |
{ rows: @elements.first.count, cols: @elements.count } | |
end |
NewerOlder