Skip to content

Instantly share code, notes, and snippets.

View aleclarson's full-sized avatar

Alec Larson aleclarson

View GitHub Profile

This gist is a further condensed version of https://svelte.dev/llms-small.txt from https://svelte.dev/docs/llms

Removed sections

These sections were removed to optimize the context window. Each section was deemed non-critical for MVP purposes or its use cases were deemed too niche. When developing a brownfield Svelte app, many of these sections should not be removed.

  • Overview
  • Getting Started
  • Accessibility
  • SEO
@aleclarson
aleclarson / query.pgsql
Last active November 25, 2024 19:55
Postgres – get public dependencies
SELECT DISTINCT
d.deptype,
from_table.relname AS classid,
COALESCE(from_class.relname, from_type.typname, from_proc.proname) AS objid,
from_attr.attname AS objsubid,
to_table.relname AS refclassid,
COALESCE(to_class.relname, to_type.typname, to_proc.proname, to_ext.extname, to_con.conname) AS refobjid,
to_attr.attname AS refobjsubid

Sunil Pai once said on Bluesky:

A simple question to ask yourself (/myself): what are you doing actively/ regularly to become

  • healthier
  • stronger but also
  • smarter
  • funnier
  • friendlier
import { withCapacity } from 'radashi'
export function keyedCapacity<TKey, TResult>(capacity: number) {
const queue = withCapacity(capacity)
const jobs = new Map<TKey, Promise<TResult>>()
return {
keys: (): IterableIterator<TKey> => jobs.keys(),
get: (key: TKey): Promise<TResult> | undefined => jobs.get(key),
run(key: TKey, job: () => Promise<TResult>): Promise<TResult> {
@aleclarson
aleclarson / mergeGenerators.ts
Created November 21, 2024 22:27
Combine one or more async generators in TypeScript
/**
* Merge multiple generators into a single generator.
*/
function mergeGenerators<T>(generators: AsyncGenerator<T>[]): AsyncGenerator<T>
/**
* Merge multiple generators into a single generator. Whenever a generator
* yields, the `{done, value}` object is passed to `mapResult` to transform the
* value that will be yielded.
/*
* API struct for a table AM. Note this must be allocated in a
* server-lifetime manner, typically as a static const struct, which then gets
* returned by FormData_pg_am.amhandler.
*
* In most cases it's not appropriate to call the callbacks directly, use the
* table_* wrapper functions instead.
*
* GetTableAmRoutine() asserts that required callbacks are filled in, remember
* to update when adding a callback.
@aleclarson
aleclarson / permutations.ts
Created November 6, 2024 19:17
Get the permutations of a union type
export type Permutations<T, TInitial = T> = T extends infer TSingle
?
| [TSingle]
| (Permutations<Exclude<TInitial, TSingle>> extends infer TPermutation
? TPermutation extends any[]
? [T | TPermutation[number]]
: never
: never)
: never
import { FileSystemHost, RuntimeDirEntry } from '@ts-morph/common'
class MemfsFileSystemHost implements FileSystemHost {
constructor(private readonly root: string) {}
isCaseSensitive(): boolean {
return true
}
readDirSync(dirPath: string): RuntimeDirEntry[] {
import { vol } from 'memfs'
import vfs from 'node:fs'
import path from 'node:path'
import { isMatch } from 'picomatch'
const fixturesDir = new URL('__fixtures__', import.meta.url).pathname
const nodeModulesDir = path.join(fixturesDir, 'node_modules')
const fromNodeModulesDir = new URL('../../node_modules', import.meta.url)
.pathname
import { RealFileSystemHost } from '@ts-morph/common'
import { JumpgenFS } from 'jumpgen'
export class JumpgenFileSystemHost extends RealFileSystemHost {
constructor(private fs: JumpgenFS) {
super()
}
readFile(filePath: string, encoding?: string): Promise<string> {
notImplemented('readFile')
}