Skip to content

Instantly share code, notes, and snippets.

View vanxh's full-sized avatar
👨‍💻
vanxh.dev

Vanxh vanxh

👨‍💻
vanxh.dev
View GitHub Profile
@vanxh
vanxh / og-image.tsx
Created July 29, 2025 22:35
Tanstack start dynamic OG image creation
import { api } from "@connectlabs/backend/convex/_generated/api";
import type { Id } from "@connectlabs/backend/convex/_generated/dataModel";
import { Resvg } from "@resvg/resvg-js";
import { createServerFileRoute } from "@tanstack/react-start/server";
import { ConvexHttpClient } from "convex/browser";
import satori from "satori";
import sharp from "sharp";
type AgentData = {
name: string;
@DistractionBoy
DistractionBoy / createCtx.tsx
Last active August 11, 2022 19:39
quick react context with reducer
export function createCtx<StateType, ActionType>(
reducer: React.Reducer<StateType, ActionType>,
initialState: StateType,
) {
const defaultDispatch: React.Dispatch<ActionType> = () => initialState // we never actually use this
const ctx = React.createContext({
state: initialState,
dispatch: defaultDispatch, // just to mock out the dispatch type and make it not optioanl
})
function Provider(props: React.PropsWithChildren<{}>) {