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
{ | |
"name": "Attach", | |
"type": "chrome", | |
"request": "attach", | |
"port": 9222, | |
"url": "https://mixpanel.com/*", | |
"webRoot": "${workspaceRoot}", | |
"diagnosticLogging": false, | |
"sourceMapPathOverrides": { | |
"webpack:///./~/*": "${workspaceRoot}/node_modules/*", |
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
def inspect_module(module_name): | |
module = importlib.import_module(module_name) | |
print('inspect: ' + module_name) | |
for name in dir(module): | |
if name[:2] != '__': # Ignore internals | |
print(' %s: %s' % (name, getattr(module, 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
printDiff(expected, encoded_actual, referencePath(relativeFileName), actualFileName); | |
/** | |
* Prints a nice diff that is useful for debugging baseline failures | |
* It doesn't print the most optimum diff but does it in O(n) time and gives a `good enough` diff for humans | |
* It also emits a `cp tests/baselines/local/<file> tests/baselines/reference/<file>` | |
* Which makes experience of updating basefiles case by case much more bearable | |
*/ | |
export function printDiff(expectedText: string, actualText: string, expectedFileName: string, actualFileName: string) { | |
type LineNumMap = { [line: string]: number[] }; |
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
/* | |
Write a method that returns a string representing the state of a pagination nav bar | |
# rule 1: the number of pages returned should not exceed the value of the "numVisiblePages" parameter | |
# rule 2: always show the first page | |
# rule 3: always show the last page | |
# rule 4: put ellipses where appropriate | |
# rule 5: place [] around the selected page and, if possible, center it | |
currentPage = 5 |
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. | |
# 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
// Usage: copy(dom2jade($0, 0)) | |
// copy copies to clipboard, $0 is selected elem in dev tools, 0 is pre-indent needed | |
// The beauty about this is that it lets the browser handle quirky html | |
const dom2jade = function(elem, numIndents = 0) { | |
const dom2tree = function(elem) { | |
let text; | |
if ((elem.nodeType === document.TEXT_NODE) && (elem.nodeValue.trim() !== "")) { | |
text = elem.nodeValue.trim(); |
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
[ | |
{"key": "shift+cmd+k", "command": "workbench.action.tasks.terminate" }, | |
{"key": "cmd+r", "command": "workbench.action.debug.restart", "when": "inDebugMode" }, | |
{"key": "alt+s", "command": "workbench.action.gotoSymbol" }, | |
{"key": "cmd+[", "command": "workbench.action.navigateBack" }, | |
{"key": "cmd+]", "command": "workbench.action.navigateForward" }, | |
{"key": "alt+[", "command": "editor.action.outdentLines", "when": "editorTextFocus && !editorReadonly"}, | |
{"key": "alt+]", "command": "editor.action.indentLines","when": "editorTextFocus && !editorReadonly"}, | |
{"key": "ctrl+]", "command": "editor.action.dirtydiff.next", "when": "editorTextFocus"}, | |
{"key": "ctrl+[", "command": "editor.action.dirtydiff.previous", "when": "editorTextFocus"}, |
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
#!/usr/local/bin/bash | |
USAGE=$'Usage: sync.sh <user@host> <dest_dir> e.g ./sync.sh user@host \'~/dest_dir\'' | |
SSH_HOST=${1:?$USAGE} | |
DEST_DIR=${2:-"~/`basename $PWD`"} | |
sync_files() { | |
declare -A file_hash_map | |
while IFS= read -r file; do | |
file=${file#"$PWD/"} # get relative path |