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
| /** | |
| * Outputs something like: | |
| * | |
| * Top 5: | |
| * 1. 96282600 (36.5) — pair 00, palindrome 62826, ends-00, touches: pair 00 + palindrome 62826 | |
| * 2. 97557734 (32.3) — near-run 975, pair 55, pair 77, palindrome 7557, overlaps: near-run 975 ∩ pair 55, overlaps: near-run 975 ∩ palindrome 7557, touches: pair 55 + pair 77, overlaps: pair 77 ∩ palindrome 7557 | |
| * 3. 96699348 (31.6) — pair 66, pair 99, palindrome 9669, touches: pair 66 + pair 99, overlaps: pair 99 ∩ palindrome 9669 | |
| * 4. 96644427 (31.4) — triple 444, pair 66, touches: triple 444 + pair 66 | |
| * 5. 96332109 (27.9) — run4 3210, pair 33, start=end, overlaps: run4 3210 ∩ pair 33 | |
| * |
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
| esphome: | |
| ... | |
| on_boot: | |
| then: | |
| - script.execute: initialize_vectors | |
| - script.execute: update_ball_physics | |
| globals: | |
| # Ball constants | |
| - id: ball_radius |
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
| class ISO8601 { | |
| #originalString: ParsedISO["originalString"]; | |
| #repetitions?: ParsedISO["repetitions"]; | |
| #dates: | |
| | Readonly<[Readonly<ISOPart>, Readonly<ISODatePart>]> | |
| | Readonly<[Readonly<ISODatePart>, Readonly<ISOPart>]> | |
| | Readonly<[Readonly<ISOPart>]>; | |
| get originalString() { | |
| return this.#originalString; |
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 units = [ | |
| 'zero', 'one', 'two', 'three', 'four', | |
| 'five', 'six', 'seven', 'eight', 'nine', | |
| 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', | |
| 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', | |
| ]; | |
| const tens = [ | |
| '', 'ten', 'twenty', 'thirty', 'fourty', | |
| 'fifty', 'sixty', 'seventy', 'eighty', 'ninety', |
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 units = [ | |
| 'zero', | |
| 'one', | |
| 'two', | |
| 'three', | |
| 'four', | |
| 'five', | |
| 'six', | |
| 'seven', | |
| 'eight', |
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 byteNumber = () => Math.random() * 2 ** 8 >> 0; | |
| export const randomHex = () => | |
| '#' + (2 ** (2 ** 3 * 3) * Math.random() >> 0).toString(16).padStart(6,'0') | |
| ; | |
| export const randomRGB = () => | |
| `rgb(${[byteNumber(),byteNumber(),byteNumber()]})` | |
| ; |
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
| // TODO: output “required:” array correctly | |
| const payloads = [{ | |
| a: 'one', | |
| b: 2, | |
| c: { | |
| face: 'me' | |
| }, | |
| d: [1,2] | |
| },{ |
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
| async function getChanceOfMatchingBirthday({ | |
| numberOfPeopleInTheRoom = 23, | |
| howManyRoomsToAverageBetween = 1e5, | |
| } = {}) { | |
| let initDate = Date.now(); | |
| let testCount = 0; | |
| let matchCount = 0; | |
| while (testCount < howManyRoomsToAverageBetween) { | |
| if (!(testCount % 5e3) && Date.now() >= initDate + 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
| // To log the results: | |
| // | |
| // getFiles(__dirname, { ignore: ['node_modules'] }) | |
| // .then(files => console.log( | |
| // files | |
| // .flat(Infinity) | |
| // .filter(( Oo) => (Oo )) | |
| // )); | |
| // Available options: |
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 getYarnLockDupes(yarnLock) { | |
| return yarnLock | |
| .split('\n') | |
| .filter(a => !a.startsWith(' ') && !a.startsWith('#')) | |
| .map(a => a.replace(/[:"]/g, '')) | |
| .flatMap(a => a.split(/, ?/g)) | |
| .filter(a => a) | |
| .flatMap(a => { | |
| const versions = a.split(' || '); | |
| if (versions.length === 1) { return a; } |
NewerOlder