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 Octet = | |
| | `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | |
| | `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | |
| | `1${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | |
| | `2${0 | 1 | 2 | 3 | 4 }${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | |
| | `2${5 }${0 | 1 | 2 | 3 | 4 | 5}` | |
| type Protocol = 'tcp' | 'tcps'; | |
| type QuasiIPv4 = `${bigint}.${bigint}.${bigint}.${bigint}` | |
| type QuasiBindingString = `${Protocol}://${'*' | QuasiIPv4}:${bigint}` | `${'ipc' | 'ipcs'}://${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
| // HIGHLY inefficient, since it generates the entire union ahead of time | |
| // https://gist.github.com/webstrand/5a5df9e63d5646f045a8871f11cb5b6f#file-generic-validator-object-paths-ts | |
| // is far more efficient, though it only works inside of a function to _validate_ | |
| // paths provided by the user at the callsite. | |
| interface I { | |
| x: { | |
| z?: { | |
| a?: { | |
| b?: { |
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 sublime | |
| import sublime_plugin | |
| import weakref | |
| from weakref import WeakValueDictionary | |
| view_selection_iterators = WeakValueDictionary() | |
| class ViewSelectionIterator(sublime_plugin.ViewEventListener): | |
| current_item = None |
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 U2T< | |
| U, | |
| UF extends () => U = U extends U ? () => U : never, | |
| IF = (UF extends UF ? (x: UF) => any : never) extends (x: infer IF) => any ? IF : never | |
| > = | |
| IF extends () => infer W ? [...U2T<Exclude<U, W>>, W] : []; |
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 scriptisto | |
| // scriptisto-begin | |
| // script_src: main.c | |
| // build_cmd: gcc -O2 -Wall -Werror main.c -o ./script | |
| // scriptisto-end | |
| #define _GNU_SOURCE 1 | |
| #include <stdlib.h> |
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://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c | |
| CREATE SEQUENCE IF NOT EXISTS object_id_seq AS smallint | |
| MINVALUE 0 | |
| MAXVALUE 1023 | |
| CYCLE; | |
| CREATE OR REPLACE FUNCTION object_id_epoch() | |
| RETURNS bigint | |
| LANGUAGE sql |
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 perl | |
| use utf8; | |
| use strict; | |
| use warnings; | |
| use v5.26; | |
| use experimental 'signatures'; | |
| use AnyEvent::I3 qw(TYPE_GET_WORKSPACES TYPE_COMMAND i3); | |
| my $i3 = i3(); |
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 anySignal(...signals: (AbortSignal | undefined | null)[]): AbortController { | |
| const controller = new AbortController(); | |
| for(const signal of signals) { | |
| if(signal == null) continue; | |
| if(signal.aborted) { | |
| handleAbort(); | |
| break; | |
| } | |
| signal.addEventListener("abort", handleAbort); |
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
| export type Split<T extends string, Acc extends string[] = [], Alt extends string = never> = | |
| T extends `${infer U}${infer V}` | |
| ? {} extends Record<U, 0> | |
| ? Split<V, U extends `${number | bigint}` ? [...Acc, string] : Acc, string> | |
| : Split<V, [...Acc, U | Alt], Alt> | |
| : T extends "" | |
| ? [Alt] extends [never] | |
| ? Acc | |
| : [...Acc, ...(Alt | undefined)[]] | |
| : T extends `${number | bigint}` // `${number | bigint}` is at least 1 character |
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 Expand<T> = T extends T ? { [P in keyof T]: T[P] } : never; | |
| type UnionToIntersection<U> = (U extends U ? ((x: U) => any) : never) extends (x: infer I) => any ? I : never; | |
| type Flatten<T, Z extends string = ""> = T extends object | |
| ? Expand<UnionToIntersection<{ | |
| [P in keyof T]: P extends string | number | |
| ? T[P] extends object | |
| ? Flatten<T[P], `${Z}${P}.`> | |
| : { [Q in `${Z}${P}`]: T[P] } | |
| : never | |
| }[keyof T & (T extends readonly unknown[] ? number : unknown)]>> |