Imperative:
export default expressions => mapIterator(row => {
const projection = {};
for (const colName in expressions) {
const expression = expressions[colName];
projection[colName] = expression(row);
}
return projection;
// Based on http://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html | |
// Note that CoreNLP sometimes emit POS that are not in this list, like "``" or "." | |
var iCoreNlpPos = [ "CC", "CD", "DT", "EX", "FW", "IN", "JJ", "JJR", "JJS", "LS", "MD", "NN", "NNS", "NNP", "NNPS", "PDT", "POS", "PRP", "PRP$", "RB", "RBR", "RBS", "RP", "SYM", "TO", "UH", "VB", "VBD", "VBG", "VBN", "VBP", "VBZ", "WDT", "WP", "WP$", "WRB" ]; |
import * as nock from 'nock' | |
import { | |
use, | |
expect, | |
} from 'chai' | |
import * as chaiAsPromised from 'chai-as-promised' |
Imperative:
export default expressions => mapIterator(row => {
const projection = {};
for (const colName in expressions) {
const expression = expressions[colName];
projection[colName] = expression(row);
}
return projection;
// Finds the insertion index for an item in an array. | |
// Uses compareFn (similar to that provided to array.sort()) | |
const getInsertionIndex = (arr, item, compareFn) => { | |
const itemsCount = arr.length; | |
// No items in array, so return insertion index 0 | |
if (itemsCount === 0) { | |
return 0; | |
} |
const isWebdriverUpToDate = () => { | |
const fs = require('fs'); | |
const path = require('path'); | |
const SeleniumConfig = require('webdriver-manager/built/lib/config').Config; | |
const updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json'); | |
return fs.existsSync(updateJson); | |
}; | |
const updateWebdriver = () => { |
var memxContent = [{ | |
title: 'Force Directed Graph', | |
links: [{ | |
title: 'Interactive & Dynamic Force-Directed Graphs with D3', | |
note: 'Simple Medium tutorial with code examples', | |
url: 'https://medium.com/ninjaconcept/interactive-dynamic-force-directed-graphs-with-d3-da720c6d7811', | |
},{ | |
title: 'Official D3 example', | |
url: 'https://observablehq.com/@d3/force-directed-graph', | |
},{ |
var glob = require('glob'); | |
const pattern = 'docs/**/*.js?(x)'; | |
glob(pattern, function(er, files) { | |
console.log(files); | |
}); |
Ensure you have GPG installed:
brew install gpg
curl -o- -L https://yarnpkg.com/install.sh | bash
// Use with https://marketplace.visualstudio.com/items?itemName=siegebell.prettify-symbols-mode | |
{ | |
"prettifySymbolsMode.substitutions": [ | |
{ | |
"language": [ | |
"javascript", | |
"typescript", | |
"javascriptreact", | |
"typescriptreact" | |
], |
import React from 'react'; | |
export default function useAutoScrollToBottom(deps) { | |
const paused = React.useRef(false); | |
const element = React.useRef<HTMLDivElement | null>(null); | |
const onWheel = React.useCallback(() => { | |
const { scrollTop, scrollHeight, offsetHeight } = element.current || { | |
scrollTop: 0, | |
scrollHeight: 0, |