I hereby claim:
- I am xetera on github.
- I am xetera (https://keybase.io/xetera) on keybase.
- I have a public key whose fingerprint is DE0C C5B3 7058 805B 8DD8 E306 7FB1 9FBF D8E5 BBED
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| makePattern :: [(a -> a)] -> a -> [a] | |
| makePattern funcs seed = scanl (\a f -> f a) seed (cycle funcs) | |
| -- makePattern [(*3), (+1)] 1 | |
| -- [1,3,4,12,13,39] |
| {- | |
| Using Optimal Stopping for finding the highest number in a list | |
| 1. Generate an integer list of N size | |
| 2. Reveal the numbers of the first N/e elements | |
| 3. Keep revealing numbers until you find one bigger than the biggest revealed number | |
| 4. The chances of the first matching number being the highest number in the list will consistently be 1/e | |
| -} | |
| -- Games played: 1000 | |
| -- Games Won: 358 |
| const chunk = (array, num) => array.reduce((array, current) => { | |
| const last = array[array.length - 1]; | |
| const init = array.slice(0, -1); | |
| if (!last) { | |
| return [...init, [current]] | |
| } | |
| if (last.length >= num) { | |
| return [...array, [current]] | |
| } | |
| return [...init, [...last, current]]; |
| import { CommandOptions, Command } from "discord-akairo"; | |
| interface CreateCommand extends CommandOptions { | |
| /** | |
| * The exec function can be called in 3 different ways, however, | |
| * Typescript doesn't seem to be able to support explicit `this` | |
| * coming from external types, union types or overloads. In order to | |
| * specify the `this` type the signature MUST be directly assigned | |
| * in the interface | |
| */ |
| const parallelMap = (arr, fn, max) => { | |
| const out = []; | |
| const initial = [...Array(max)]; | |
| const fired = initial.map(() => Promise.resolve().then(async function cb() { | |
| if (!arr.length) return | |
| const next = arr.shift(); | |
| out.push(await fn(next)); | |
| return cb(); | |
| })); |
| /** | |
| * (*) Due to the eager nature of promises, `items` must be an | |
| * array of promise returning functions and not an array of promises | |
| */ | |
| const batchProcess = (count, items) => { | |
| const chunked = R.splitEvery(count, items); | |
| const process = async ([head, ...tail]) => { | |
| const promises = head.map(func => func()); | |
| const results = await Promise.all(promises); |
| const partition = (func, array) => array.reduce(([pass, nopass], item) => { | |
| if (func(item)) { | |
| return [[...pass, item], nopass] | |
| } | |
| return [pass, [...nopass, item]] | |
| }, [[], []]); | |
| const glob = async (path, regex) => { | |
| const dirContent = await fsp.readdir(path, {withFileTypes: true}) |
| fromEven num = num `div` 2 | |
| fromOdd = (+1) . (*3) | |
| collatz :: Int -> [Int] | |
| collatz num | |
| | num == 1 = [1] | |
| | even num = next fromEven | |
| | odd num = next fromOdd | |
| where next func = num : (collatz $ func num) |
| /* 1. press ctrl + shift + i | |
| * 2. go to "Console" and find any log that starts with "###", click on its link | |
| * 3. pretty print the script | |
| * 4. search for "player.x = " | |
| * 5. put a breakpoint on the same line and move your character with your mouse (game is paused now) | |
| * 6. paste in the script | |
| * 7. remove breakpoint, continue game | |
| * 8. dab on the haters but enjoy knowing the fact you're so salty in a Facebook game that you search for hacks | |
| */ |