Skip to content

Instantly share code, notes, and snippets.


Melody funfunction

View GitHub Profile
View genRandNums.js
generate an arr of random nums
- containing numbers only between the supplied min and max
@param {number} min - smallest num in arr
@param {number} max - largest num in arr
@param {number} len - length of the arr to create
@return {number[]}
View bstClass.js
n = node
minnode method is missing
View timeInLoop.js
log how long it takes to run a block of code
- for a supplied number of times
the supplied func runs in a loop
- so first make sure there are no log statements in the func
- either comment them out, or replace them with lMock...
- const l = s => undefined; //lMock
View isNotObj.js
@func complement
confirm that the supplied value is not an obj
@param {*} v expect anything but an obj
@return {boolean}
export const isNotObj = v => !isObj(v);
View lruCacheMap.js
Map object factory
@return {Map}
export const createLruMap = () => new Map();
View VisualStudioCode_settings_editorFontColors.js
// place this into your Visual Studio Code (VSC) settings json file (I have it in my Workspace settings, not User settings)
// res: explanation and contact here...
//colors ////////////////////////////////////////////////////////
"workbench.colorTheme": "Default High Contrast",
// "workbench.colorTheme":"Default Dark+",
//already black, but as an example
"workbench.colorCustomizations": {
"sideBar.background": "#000",
"editorLineNumber.foreground": "#203752",
"terminal.background": "#07000c",
View isNil.js
true if var is null or undefined
@param {*} v
@return {boolean}
export const isNil = v => v === undefined || v === null;
View logForeachParam.js
with a supplied func and a supplied arr of args
- the func will invoke once for each arg in the arr
apply the func to each arg in the arr
this variant only supports funcs that are unary (argument count of one)
@param {(v: *) => *} fn - the func to be invoked for each elem in the arr
View isCcValidLuhn.js
calculate if credit card number is valid
@param {number|string} ccn Credit Card Number
@return {boolean}
const isCcValidLuhn = ccn => {
const sum = ccn