Skip to content

Instantly share code, notes, and snippets.

View asevos's full-sized avatar

Artem Sevostianov asevos

View GitHub Profile
search = {
pattern = [[(?:\/\/|--(\[\[)?|\*|#\|?|%\{?|;|\{-)[\t ]*(?:(KEYWORDS):)]],
--[[
Regex explanation:
1. (?:...) - non-capture group for comment tokens:
\/\/ - matches // , used in lots of languages
--(\[\[)? - matches -- and --[[ , -- used in SQL, Haskell, Lua,
Ada, AppleScript, VHDL, --[[ used in Lua multiline, also
matches <!-- for HTML, XML, Markdown
\* - matches various formats ( /* /** (* ), lines starting
@asevos
asevos / persistent.svelte.ts
Created November 6, 2025 14:45
An attempt to implement persistent store using localStorage in SvelteKit
import { browser } from '$app/environment'
export type PersistentStore<T> = ReturnType<typeof newPersistentStore<T>>
export function newPersistentStore<T>(key: string, initial: T) {
let value = $state<T>(initial)
let mounted = $state(false)
const storeName = `Persistent store '${key}'`
function mount() {