Syntax:
This file contains hidden or 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() { | |
const c = confirm("again?") | |
if (!c) return; | |
if (c === true) { | |
eval(`(${arguments.callee.toString()})()`) | |
} | |
})() |
This file contains hidden or 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 randomRange(min=0, max=100, dec=0) { | |
const mag = 10 ** dec; | |
return Math.floor( (Math.random() * (max - min) + min) * mag ) / mag; | |
} | |
function randomLetter(uppercase = false) { | |
return String.fromCharCode(randomRange(uppercase ? 65 : 97, uppercase ? 90 : 122)) | |
} | |
function randomString(minLength=8, maxLength=16) { |
This file contains hidden or 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 generateCsv(params) { | |
const { colsDef, rowsDef, withHeaders, asString } = params || {}; | |
const formatNumber = (val, intDigits = 1, decDigits = 0) => { | |
if (isNaN(val)) return ""; | |
return (+val).toLocaleString(undefined, { | |
minimumIntegerDigits: intDigits, | |
minimumFractionDigits: decDigits, | |
}); |
This file contains hidden or 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
/** | |
* Receives a part of the document and returns a validation digit | |
* Used mostly for CPF or CNPJ | |
* | |
* Ex.: | |
* getVerificationDigit("000000001") // 9 | |
* getVerificationDigit("0000000019") // 1 | |
* getVerificationDigit("100200300") // 8 | |
* getVerificationDigit(1, 9) // 9 | |
* getVerificationDigit(19, 9) // 1 |
This file contains hidden or 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 */ dotsMadeStoreArr = []; | |
function attachOnClickMakeDotsListener(elm) { | |
function onClickMakeDotsListener(evt) { | |
onClickMakeDots(evt); | |
} | |
elm.addEventListener("click", onClickMakeDotsListener); | |
return function detachOnClickMakeDotsListener() { | |
elm.removeEventListener("click", onClickMakeDotsListener); |
This file contains hidden or 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
/** | |
* Create a function that transforms an index into an pseudo-random value, where the values are tied to a string | |
* @param salt string, must have at least one [a-z0-9] character | |
* @param parseVal [optional] function(val: number, i: number, saltRange: [number, number]) to transform the salt result | |
* @returns function(idx: number, skipParse: boolean = false), will always return the same value for the specific SALT and IDX | |
*/ | |
const getSaltedRandomFn = (salt, parseVal) => { | |
const safeSalt = (salt || "").replace(/[^a-z0-9]/gi, "").toLowerCase(); |
This file contains hidden or 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
// Main "Lib" function | |
/** | |
* Executes a flow of callbacks passing inputs and storing outputs | |
* Example: jsAirflow( | |
* [ | |
* { fn: 'sum', in: ['v1', 'v2'], out: ['result'] }, | |
* { fn: 'power', in: ['result', 'power'], out: ['result'] }, |
This file contains hidden or 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
#!/bin/ksh | |
# | |
# @(69)$Id$ | |
# | |
# Helpful functions for your terminal | |
function git_branches() | |
{ | |
if [[ -z "$1" ]]; then | |
git_branches . |
This file contains hidden or 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 getKey = inputName => (inputs[namedIndexesMap[inputName]] || {value:null}).value | |
//TODO gamepad | |
class InputMap { | |
constructor(inputName, type='', assignedKeyboardKeys=[], assignedGamepadButtons=[], assignedGamepadAxis=[]) { | |
const strArrayToKeyObj = arr => arr.reduce( (all,curr) => ({...all, [curr]: true}),{}) | |
if (inputName == null) { | |
throw TypeError("Input Name cannot be null or undefined ") | |
} |