Skip to content

Instantly share code, notes, and snippets.

View Izhaki's full-sized avatar
💭
codinsky

Izhaki

💭
codinsky
View GitHub Profile
@Izhaki
Izhaki / CoreNLP-part-of-speech-Penn-Treebank-Project.js
Last active May 12, 2016 11:58
Part of Speech tokens used by CoreNLP, based on the Penn Treebank Project.
// 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" ];
@Izhaki
Izhaki / gqlFetch.spec.ts
Created May 5, 2017 14:58
Client GraphQL Fetch ( Typescript )
import * as nock from 'nock'
import {
use,
expect,
} from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
@Izhaki
Izhaki / imperative-vs-functional.md
Created July 15, 2018 22:21
Some examples of comparison between imperative and more function style - hinting the latter is not always better.

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;
}
@Izhaki
Izhaki / webdriverUpdate.js
Last active December 11, 2018 11:46
A small script to update webdriver if needed prior to running protractor.
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 = () => {
@Izhaki
Izhaki / memx.js
Last active March 20, 2019 11:11
My memx content
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',
},{
@Izhaki
Izhaki / globTest.js
Created August 31, 2019 15:50
Tiny script to test glob matches
var glob = require('glob');
const pattern = 'docs/**/*.js?(x)';
glob(pattern, function(er, files) {
console.log(files);
});
@Izhaki
Izhaki / UpdateYarnMac.md
Created September 13, 2019 19:48
Updating yarn on Mac

Ensure you have GPG installed:

brew install gpg
curl -o- -L https://yarnpkg.com/install.sh | bash
@Izhaki
Izhaki / setting.json
Created March 11, 2020 18:29
Formal Logical Operators in VSCode
// Use with https://marketplace.visualstudio.com/items?itemName=siegebell.prettify-symbols-mode
{
"prettifySymbolsMode.substitutions": [
{
"language": [
"javascript",
"typescript",
"javascriptreact",
"typescriptreact"
],
@Izhaki
Izhaki / useAutoScrollToBottom.ts
Last active June 27, 2021 22:24
React useAutoScrollToBottom.ts
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,