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 Procedure = (...args: any[]) => any; | |
type Methods<T> = keyof { | |
[K in keyof T as T[K] extends Procedure ? K : never]: T[K]; | |
}; | |
type Properties<T> = { | |
[K in keyof T]: T[K] extends Procedure ? never : K; | |
}[keyof T] & | |
(string | symbol); | |
type Classes<T> = { |
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
// #region Utility types | |
type RequiredKeysOf<TType extends object> = TType extends any | |
? Exclude< | |
{ [Key in keyof TType]: TType extends Record<Key, TType[Key]> ? Key : never }[keyof TType], | |
undefined | |
> | |
: never; | |
type HasRequiredKeys<TType extends object> = RequiredKeysOf<TType> extends never ? false : 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
type Middleware<TParams extends any[], TReturn> = ( | |
...params: [...TParams, next: (...params: TParams) => TReturn] | |
) => TReturn; | |
const exhausted = () => { | |
throw new Error('middleware chain exhausted'); | |
}; | |
export const createMiddlewareRunner = <TParams extends any[], TReturn>( | |
middlewares: [...Middleware<TParams, TReturn>[], Middleware<TParams, TReturn>], |
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 split = (str: string, delimiter: string, limit: number): string[] => { | |
const result: string[] = []; | |
let last = 0; | |
while (--limit > 0) { | |
const index = str.indexOf(delimiter, last); | |
if (index === -1) { | |
break; | |
} |
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
! disable rails turbolinks/hotwire turbo | |
! page load via turbo is considerably slower than html streaming | |
! this won't affect the file explorer as the nav is handled in react (which is fine) | |
github.com##+js(set-attr, body, data-turbo, false) | |
! font adjustments | |
github.com##body:style(--fontStack-system: sans-serif; --fontStack-sansSerif: sans-serif; --fontStack-monospace: monospace) | |
github.com##:is(body, .markdown-body, .PageHeader .PageHeader-titleWrap.PageHeader-titleWrap--medium):style(font-family: var(--fontStack-sansSerif) !important) | |
github.com##:is(tt, pre, code, samp, .text-mono, .react-code-text, .react-blob-print-hide, .blob-code-inner, .blob-num, .input-monospace, .file-info, .commit .sha-block, .commit .sha):style(font-family: var(--fontStack-monospace) !important) | |
github.com##:is(.markdown-body .highlight pre, .markdown-body pre):style(font-size: 12px !important) |
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
! remove `session_id` tracking parameter from videos | |
! | |
! ideally this would've been a redirect from `video.bsky.app/watch/<did>/<cid>/playlist.m3u8` | |
! to `video.cdn.bsky.app/hls/<did>/<cid>/playlist.m3u8`, as the latter is the actual CDN while | |
! the former is the middleware, however: | |
! | |
! - the raw playlist will not contain webvtt, that's added in by the middleware | |
! - ublock doesn't have a rule that allows redirecting to non-local neutered resource | |
! | |
||video.bsky.app$removeparam=session_id |
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 { PiniaPlugin, StateTree } from "pinia"; | |
const PREFIX = "pinia:"; | |
export interface PersistenceOptions<S extends StateTree> { | |
validate?: (state: StateTree) => state is S; | |
} | |
declare module "pinia" { | |
// eslint-disable-next-line no-undef, @typescript-eslint/no-unused-vars |
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 isEqual from "fast-deep-equal"; | |
import { PiniaPlugin, StateTree } from "pinia"; | |
import { onScopeDispose } from "vue"; | |
// Web Locks API have very good support at this point, but it's disabled by | |
// Safari when lockdown mode is disabled. Let's gracefully handle this by not | |
// doing any of that initialization broadcast when it's not present. | |
const locks = navigator.locks as LockManager | undefined; | |
const PREFIX = "pinia-broadcast:"; |
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 { type JSONContent } from '@tiptap/core'; | |
import { graphemeLen } from '~/api/richtext/intl.ts'; | |
import { type Facet, type FacetLink } from '~/api/richtext/types.ts'; | |
const encoder = new TextEncoder(); | |
type SerializedMarks = NonNullable<JSONContent['marks']>; | |
const findFeature = (marks?: SerializedMarks): FacetLink | undefined => { |
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": "object", | |
"properties": { | |
"lexicon": { "type": "number", "const": 1 }, | |
"id": { | |
"type": "string", | |
"pattern": "^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\.[a-zA-Z]([a-zA-Z]{0,61}[a-zA-Z])?)$" | |
}, | |
"revision": { "type": "integer", "minimum": 0 }, | |
"description": { "type": "string" }, |