Skip to content

Instantly share code, notes, and snippets.

View sillvva's full-sized avatar

Matt DeKok sillvva

View GitHub Profile
@intrnl
intrnl / App.svelte
Last active July 2, 2024 13:50
Svelte 5 deep reactivity
<svelte:options runes />
<script>
import { store, increment } from './reactive.js';
const deep = store.deep;
const remaining = $derived(store.items.filter((item) => !item.done).length);
function push() {
store.items.push({ text: 'bar', done: false });
@kidqueb
kidqueb / json-agg.ts
Last active October 10, 2024 09:16
json agg for drizzle
export function jsonAgg<T extends Record<string, AnyColumn>>(select: T) {
const chunks: SQL[] = [];
Object.entries(select).forEach(([key, column], index) => {
if (index > 0) chunks.push(sql`,`);
chunks.push(sql.raw(`'${key}',`), sql`${column}`);
});
return sql<InferColumnsDataTypes<T>[]>`
coalesce(
@sillvva
sillvva / useTimer.tsx
Last active August 24, 2022 03:14
Zod-validated, query-based useTimer Hook
import qs from "qs";
import { z, ZodSchema } from "zod";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { useEffect, useRef, useState } from "react";
dayjs.extend(duration);
const parseObjectPrimitives = (obj: Record<string, any>): any => {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => {