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.prototype.curry = function(...args) { | |
const fn = this; | |
return function (...additional) { | |
return fn.apply(this, args.concat(additional)); | |
}; | |
}; | |
// examples | |
function greet(word, name) { | |
console.log(word, 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
let log = console.log.bind(console); | |
let test1 = "(asf(s)f)jkl(kl)l)l"; | |
let test2 = "(hf)fh()(h(hf()h)gh)fffh"; | |
log(validate(test1)); // --> false | |
log(validate(test2)); // --> true | |
function validate(str) { | |
str = str.replace(/[^\(\)]/g, ""); | |
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 NdArray(...args) { // n-1 args are dimensions, last argument is the fill value | |
if(args.length === 2) { | |
return new Array(args[0]).fill(args[1]); | |
} | |
let arr = []; | |
let newArgs = args.slice(1); | |
for(let i = 0; i < args[0]; i++) { | |
arr.push(NdArray(...newArgs)); | |
} | |
return arr; |
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
"use strict"; | |
function freeze(obj) { | |
if(typeof obj !== "object") { | |
return; | |
} | |
Object.freeze(obj); | |
for (let prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
freeze(obj[prop]); |
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
"use strict"; | |
function FSM(states, start, accepting) { | |
function _accepts(state, word) { | |
if (word === "") { | |
return accepting.indexOf(state) !== -1; | |
} | |
return _accepts(states[state][word[0]], word.slice(1)); |
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 createStore(reducer) { | |
const store = { | |
state: {}, | |
reducer, | |
dispatch(action) { | |
this.state = this.reducer(action, this.state) | |
} | |
} | |
store.dispatch({}) |
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
// ==UserScript== | |
// @name Smart Recruiters | |
// @version 1 | |
// @match https://www.smartrecruiters.com/app/jobs/details/* | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
const BASE_URL = "https://www.smartrecruiters.com" | |
const CANDIDATE_LIST = "sr-list-content ul.st-candidate-list" |