Creates a resuable rules that can validate multiple inputs, returning a valid and cleaned-up value or an accumlation of errors.
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
| declare const IDBrand: unique symbol; | |
| type ID = string & { [IDBrand]: void }; | |
| /** | |
| * Allows for each property’s original type or string. | |
| * This is useful for accepting values from HTML forms, | |
| * which only allow string inputs. | |
| */ | |
| type Stringish<T> = { | |
| [p in keyof T]: T[p] | string; |
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
| -- PostgreSQL syntax | |
| DROP TABLE IF EXISTS revenue; | |
| CREATE TABLE revenue ( | |
| month TEXT, | |
| customer INT, | |
| channel TEXT, | |
| list NUMERIC | |
| ); |
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
| /** @typedef {{name: string; title: string; description: string; sets: any[]; }} Workout */ | |
| /** @typedef {{name: string; instructions: string;}} Exercise */ | |
| /** @typedef {"en" | "fr" | "de" | "jp" | "zh" | "he"} Lang */ | |
| /** @typedef {string | {[L in Lang]?: string}} Message */ | |
| /** @typedef {{for: string, message?: Message}} ValidationResult */ | |
| /** | |
| * @template Entity | |
| * @typedef {{(condition: {(entity: Entity): boolean}, id: string, message: Message): {(entity: Entity): ValidationResult[]}}} RuleCreator<Entity> |
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
| svg { | |
| display: inline-block; | |
| height: 90px; | |
| width: 90px; | |
| } | |
| svg.timer { | |
| transform: rotate(-90deg); | |
| overflow: visible; | |
| } | |
| circle.gague { |
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
| ="FY"&IF(MONTH(G2)=1, YEAR(G2), YEAR(G2)+1) & "Q"&IF(MONTH(G2)=1, 4, FLOOR((MONTH(G2)+1)/3,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
| #!/usr/bin/env bash | |
| # Splits a file that contains a top-level JSON Array | |
| # into individual files, one per item, named sequentially | |
| # https://stedolan.github.io/jq/download/ | |
| jq -c .[] "$1" | awk '{print > (NR ".json")}' |
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
| #!/usr/bin/env node | |
| /** | |
| * Depth-first copy with selective transformation. | |
| * For each of the `Iterable` selected by the selector function, it | |
| * applies the `visitor` function and continues recursively. | |
| * | |
| * | |
| * @param {object} node the tree structure | |
| * @param {function} [visitor] the function to apply to selected children |
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
| // https://github.com/jmakeig/iterant/issues/30 | |
| function head(itr) { | |
| if (itr[Symbol.iterator]) return itr[Symbol.iterator]().next().value; | |
| } | |
| function* values(ref, options) { | |
| const sequence = cts.values(ref, options); | |
| for (const value of sequence) { | |
| yield { | |
| value: value.valueOf(), |
NewerOlder