Skip to content

Instantly share code, notes, and snippets.

@neocotic
neocotic / .gitconfig
Last active March 28, 2024 00:55
Git Config
[alias]
co = checkout
cob = "!f() { git checkout -B $1; }; f"
br = branch
ci = commit
sh = stash
st = status
unstage = reset HEAD --
last = log -1 HEAD
undo = checkout -- .
@neocotic
neocotic / average-sampler.js
Last active April 27, 2022 11:19
Average Sampler
/**
* Generates sample data based on the `options` provided and then calculates the average based on the sample count.
*
* @param {Object} options - The options to be used.
* @param {function(): *} options.generator - The function to be used to generate data per round.
* @param {number} [options.roundsPerSample=1000] - The number of rounds in which `options.generator` is to be called per sampling.
* @param {function(value: *): boolean} options.sampler - The function to be used to filter samples from the generated data.
* @param {number} [options.samples=100] - The number of times samples should be run.
* @return {number} The calculated average.
*/