View mui-rte.tsx
This file contains 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 React, {type ReactNode} from 'react' | |
import {type CreateEditorStateProps} from 'remirror' | |
import { | |
BoldExtension, | |
ItalicExtension, | |
UnderlineExtension, | |
BulletListExtension, | |
OrderedListExtension, | |
HardBreakExtension, |
View lazy-swr.ts
This file contains 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 React from 'react' | |
import useSWR, { type Fetcher, type Key, type SWRConfiguration, type SWRResponse } from 'swr' | |
type ArgumentsTuple = [any, ...unknown[]] | readonly [any, ...unknown[]] | |
type StrictTupleKey = ArgumentsTuple | null | undefined | false | |
type StrictKey = StrictTupleKey | (() => StrictTupleKey) | |
type SetKey<T> = React.Dispatch<React.SetStateAction<T>> | |
export function useLazySWR< |
View gql-typegen-addon.ts
This file contains 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
/* eslint-env node */ | |
import ts from 'typescript' | |
import {TypeGenAddonFactory} from 'ts-graphql-plugin' | |
import {astf} from 'ts-graphql-plugin/lib/ts-ast-util' | |
const typedQueryDocumentAddon: TypeGenAddonFactory = ({source}) => ({ | |
operationDefinition({tsResultNode, tsVariableNode}) { | |
const lhs = astf.createIdentifier(`${tsResultNode.name.text}Document`) | |
const rhs = astf.createTypeReferenceNode( |
View use-search-param.tsx
This file contains 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 React, { type ReactNode } from 'react'; | |
import { useSearchParams } from 'react-router-dom'; | |
import { type QueryParamConfig } from 'serialize-query-params'; | |
export * from 'serialize-query-params'; | |
const SearchParamsContext = React.createContext<ReturnType<typeof useSearchParams> | null>(null); | |
interface SearchParamsProviderProps { | |
children?: ReactNode; |
View void-mirror.sh
This file contains 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 -S bash | |
## credits to https://paste.sh/1QS8Tgf6#aHTfRy1dOG4rcA5x_6kauwq3 | |
#pkg=current/xbps-0.59.1_6.x86_64.xbps | |
pkg=current/dolphin-22.08.2_1.x86_64.xbps | |
otime=current/otime | |
file="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-results" | |
mirrormsg() { printf '%s\n' "getting mirrors from void-docs..." ; } |
View attendance-count.js
This file contains 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
// This attendance counting function assumes the following: | |
// - You can attend multiple times in one day (and still be counted as one) | |
// - Attendance time is not counted, you can attend for several minutes and it still counts as one day | |
/** @typedef {string | number | Date} DateLike */ | |
/** | |
* @param {Array<{ start: DateLike, end: DateLike }>} attendances | |
* @param {Date} startDate | |
* @param {Date} endDate |
View iterable-reader.js
This file contains 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 {object} Reader | |
* @property {(p: Uint8Array) => Promise<number | null>} read | |
*/ | |
/** | |
* @typedef {object} Seeker | |
* @property {(offset: number) => Promise<number>} seek | |
*/ |
View chunked-iterator.js
This file contains 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
/** | |
* Create an async iterable for a readable stream | |
* @template T | |
* @param {ReadableStream<T>} stream | |
* @returns {AsyncIterableIterator<T>} | |
*/ | |
function createStreamIterator (stream) { | |
// return if browser already supports async iterator in stream | |
if (stream[Symbol.asyncIterator]) { | |
return stream; |
View bytereader.js
This file contains 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 assert (condition, message = 'Assertion failed') { | |
if (!condition) { | |
throw new Error(message); | |
} | |
} | |
export class ByteReader { | |
/** | |
* @param {ArrayBuffer} buffer | |
* @param {number} [offset] |
View tagged-vanilla-extract.js
This file contains 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 { style } from '@vanilla-extract/css'; | |
const NEW_RULE = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g; | |
const RULE_CLEAN = /\/\*[^]*?\*\/| +/g; | |
const RULE_NEWLINE = /\n+/g; | |
const EMPTY = ' '; | |
/** | |
* @param {string} val | |
* @returns {object} |
NewerOlder