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 _moduleRegistry = {}; | |
// Adds a module to _moduleRegistry | |
function _addModule(name, deps) { | |
const module = { name, deps }; | |
module.load = () => { | |
console.log(`'${name}' loaded`); | |
return module; | |
} | |
_moduleRegistry[name] = module; |
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
/** | |
* ********** | |
* ** TIPS ** | |
* ********** | |
* Please write high level pseudocode approach before writing actual code. | |
* Use meaningful variables, comments and indent your code. | |
* Your code should compile, run and produce the correct output. | |
* Don't need to test extensively but describe what kind of tests you'll add as 'TODO:' comments | |
* You are totally free to use google and stackoverflow. | |
* Talk about O(n) CPU and memory requirements. Best case and worst case. |
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
# TIPS: | |
# Please write high level pseudocode approach before writing actual code. | |
# Use meaningful variables, comments and indent your code. | |
# Your code should compile, run and produce the correct output. | |
# Write some tests | |
# You are totally free to use search engines and stackoverflow. | |
# Talk about O(n) CPU and memory requirements. Best case and worst case. | |
# Talk about what things you'll still need to do for your code to be production ready at the end. | |
num2words_map = { |
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
import codecs | |
import json | |
import os | |
import sys | |
from os import path | |
from urllib import urlopen | |
asset_diff_dir = '/tmp/_asset_diff' | |
def load_file(file): |
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
/* eslint-env node */ | |
const fs = require(`fs`); | |
// Generated using: node node_modules/eslint/bin/eslint.js -c .eslintrc.js media/**/*.es5.js -f json > _errors.json | |
const errors = JSON.parse(fs.readFileSync(`_errors.json`)); | |
for (const error of errors) { | |
const {filePath, messages, source} = error; | |
const fileRuleTally = {}; | |
const undefs = new Set(); |
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 $bbSetElement = Backbone.View.prototype.setElement; | |
Backbone.View.prototype.setElement = function setElement(element) { | |
if (this.el && this.el !== element) { | |
delete this.el.$bbView; | |
} | |
const domElem = element.jquery ? element[0] : element; | |
domElem.$bbView = this; | |
domElem.setAttribute(`data-backbone-view`, `true`); | |
return $bbSetElement.apply(this, arguments); |
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
/* eslint-env node */ | |
const fs = require(`fs`); | |
const path = require(`path`); | |
const filePaths = fs.readFileSync(`${__dirname}/file_list.txt`, `utf-8`).trim().split(`\n`); | |
console.log(`Total files`, filePaths.length); | |
for (let i = 0, len = filePaths.length; i < len; ++i) { | |
const filePath = filePaths[i]; | |
let lines = null; |
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
/* | |
Problem: Write a class that implements the following iterator interface: | |
bool hasNext() | |
int next() | |
The iterator is used to sequentially iterate over a collection. Given an implementation of this iterator MyIterator, its usage can be summarized by the following snippet: | |
input = [1,2,3] |
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
/** | |
* A simple helper for creating nested dom tree inspired by snabbdom-jsx syntax | |
* @param {string} name | |
* @param {{[attr: string]: any}} attrs | |
* @param {Array<HTMLElement | string>} children | |
* @returns {HTMLElement} | |
*/ | |
export function createElem(name, attrs, children) { | |
const elem = document.createElement(name); |
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 wordsToNumMap = { | |
zero: 0, | |
one: 1, | |
two: 2, | |
three: 3, | |
four: 4, | |
five: 5, | |
six: 6, | |
seven: 7, | |
eight: 8, |