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
| git config --global core.untrackedCache true && | |
| git config --global core.fsmonitor true && | |
| git config --global feature.manyFiles true && | |
| git config --global core.preloadIndex true | |
| core.untrackedCache=true | |
| Caches untracked file info between commands | |
| core.fsmonitor=true | |
| Uses built-in filesystem monitor (watches for changes instead of scanning) | |
| feature.manyFiles=true |
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
| map ::= map_name layer+ designer time_winner? EOF { ws=implicit } | |
| map_name ::= identifier | |
| layer ::= layer_id "=" layer_content | |
| layer_id ::= 'layer' digit+ | |
| layer_content::= map_symbol* | |
| designer ::= 'designer=' identifier | |
| time_winner ::= 'time_winner=' ('allies' | 'centrals' | 'no') | |
| map_symbol ::= terrain_char | special_symbol |
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
| // All parsers take in a string and return a tuple of [token, remainingString] | |
| // If a parser fails to match, it should return null | |
| const any = (parsers) => (str) => { | |
| for (const parser of parsers) { | |
| const result = parser(str); | |
| if (result) return result; | |
| } | |
| return null; | |
| }; |
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 promiseAllLimitedConcurrency<A, B>( | |
| maxConcurrency: number, | |
| f: (x: A) => Promise<B>, | |
| xs: A[] | |
| ): Promise< | |
| [ | |
| fulfilledValues: Array<PromiseFulfilledResult<B>['value']>, | |
| rejectedReasons: Array<PromiseRejectedResult['reason']> | |
| ] | |
| > { |
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
| type NestedGeneratorReturnType<T> = NestedGenerator<T> | T | |
| type NestedGenerator<T> = Generator<Promise<NestedGeneratorReturnType<T>>> | |
| async function* collectNested<T>(gen: NestedGenerator<T>) { | |
| const pool = new Map<number, Promise<readonly [number, NestedGeneratorReturnType<T>]>>() | |
| let key = 0 | |
| for (const p of gen) { | |
| const currentKey = key++ | |
| pool.set(currentKey, p.then(v => [currentKey, v] as const)) | |
| } |
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
| type TSettleResult<T> = [T, undefined] | [undefined, Error]; | |
| async function settle<T>(p: Promise<T>): Promise<TSettleResult<T>> { | |
| try { | |
| const x = await p; | |
| return [x, undefined]; | |
| } catch (e) { | |
| return [undefined, e]; | |
| } | |
| }; |
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
| type Pool<T> = Map<number, Promise<readonly [number, T]>>; | |
| async function* raceAll<T>(promises: Iterable<Promise<T>>): AsyncGenerator<T> { | |
| const pool: Pool<T> = new Map(); | |
| let key = 0; | |
| for (const p of promises) { | |
| const _key = key; | |
| pool.set( | |
| _key, |
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
| import * as R from 'ramda' | |
| const parse_csv_file = R.pipe( | |
| R.split('\n'), | |
| R.when(R.pipe(R.last, R.isEmpty), R.init), | |
| R.map(R.split(',')), | |
| R.converge( | |
| (headers: string[], rows: string[][]) => rows.map(R.zipObj(headers)), | |
| [R.head, R.tail] | |
| ) |
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 I = x => x | |
| const K = x => y => x | |
| const A = f => x => f (x) | |
| const T = x => f => f (x) | |
| const W = f => x => f (x) (x) | |
| const C = f => y => x => f (x) (y) | |
| const B = f => g => x => f (g (x)) | |
| const S = f => g => x => f (x) (g (x)) | |
| const S_ = f => g => x => f (g (x)) (x) | |
| const S2 = f => g => h => x => f (g (x)) (h (x)) |
NewerOlder