Snippets

A small gallery of theme-aware, syntax-highlighted code. Highlighting is computed at build time with Shiki, and every token color resolves through CSS variables -- so the code flips cleanly between light and dark. Hit copy to grab the raw source.

Debounce a function
typescript
export function debounce<T extends (...args: any[]) => void>(fn: T, ms: number) {
	let timer: ReturnType<typeof setTimeout> | undefined;
	return (...args: Parameters<T>) => {
		clearTimeout(timer);
		timer = setTimeout(() => fn(...args), ms);
	};
}
Typed fetch JSON helper
typescript
export async function fetchJson<T>(url: string): Promise<T> {
	const res = await fetch(url);
	if (!res.ok) {
		throw new Error(`Request failed: ${res.status} ${res.statusText}`);
	}
	return (await res.json()) as T;
}
Svelte 5 counter
svelte
<script lang="ts">
	let count = $state(0);
	const doubled = $derived(count * 2);
</script>

<button onclick={() => count++}>
	Clicked {count} times (doubled: {doubled})
</button>
Build and start (adapter-node)
shell
# Install, build, and run the production server.
npm ci
npm run build
PORT=3000 node build

© 2026 Startino — testing sandbox.

SvelteKit + Tailwind v4 + shadcn-svelte GitHub