Skip to content

Instantly share code, notes, and snippets.

View K-Mistele's full-sized avatar
🏴‍☠️

Kyle Mistele K-Mistele

🏴‍☠️
View GitHub Profile
name no-use-effect
description Enforce the no-useEffect rule when writing or reviewing React code. ACTIVATE when writing React components, refactoring existing useEffect calls, reviewing PRs with useEffect, or when an agent adds useEffect "just in case." Provides the five replacement patterns and the useMountEffect escape hatch.

No useEffect

@K-Mistele
K-Mistele / issue.ts
Created September 4, 2025 17:33
Opencode Zod schema validation issue
import { createOpencodeClient, createOpencodeServer } from "../packages/sdk/js/src"
const server = await createOpencodeServer({ port: 9090 })
try {
const client = await createOpencodeClient({ baseUrl: server.url })
const { data: session } = await client.session.create({ body: { title: "test session" } })
if (!session) throw new Error("Unable to create new session")
const { data: result, error } = await client.session.prompt({
path: { id: session.id },
@K-Mistele
K-Mistele / Dockerfile
Created March 31, 2025 22:27
Dockerfile for a single package/service in a bun monorepo
FROM oven/bun:latest AS base
WORKDIR /usr/src/app
# install dependencies into a temporary directory to cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY . /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile --filter ./services/agent-executor
@K-Mistele
K-Mistele / Dockerfile
Last active January 16, 2025 18:36
Dockerfile for pgvector (postgres 16) + vectorscale by Timescale DB. Only what you need, no other timescale stuff.
FROM pgvector/pgvector:pg16
# install prerequisites
## rust
RUN apt-get update
RUN apt-get install -y build-essential curl git jq make gcc pkg-config clang postgresql-server-dev-16 libssl-dev
RUN apt-get update
# Get Rust
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
@K-Mistele
K-Mistele / tool_chat_template_llama31_json.jinja
Created September 12, 2024 23:26
Llama 3.1 JSON Tool Calling Chat Template
{%- if messages[0]["role"] == "system" %}
{%- set system_message = messages[0]["content"] %}
{%- set messages = messages[1:] %}
{%- else %}
{%- set system_message = "" %}
{%- endif %}
{%- if not tools is defined %}
{%- set tools = none %}
{%- endif %}
{%- if not date_string is defined %}
@K-Mistele
K-Mistele / useBroadcastChannel.ts
Created February 7, 2024 16:59 — forked from KristofferEriksson/useBroadcastChannel.ts
A React hook that allows you to send and receive messages between browser tabs or windows
import { useCallback, useEffect, useRef, useState } from "react";
interface UseBroadcastChannelOptions {
name: string;
onMessage?: (event: MessageEvent) => void;
onMessageError?: (event: MessageEvent) => void;
}
interface UseBroadcastChannelReturn<D, P> {
isSupported: boolean;
@K-Mistele
K-Mistele / Dockerfile
Last active March 29, 2024 19:09
Use a multi-step build to obtain a smaller final image size
# use a builder for all your dependencies including Typescript compilation
FROM node:18.17.1 as builder
WORKDIR /opt/app
# Install dependencies
COPY package*.json .
RUN npm install
# receive secrets using the --build-arg command e.g. from github actions secrets
@K-Mistele
K-Mistele / Dockerfile
Last active March 29, 2024 19:11
Trivially Dockerizing a Next.js Application
FROM node:18
WORKDIR /opt/app
COPY package*.json ./
RUN npm install
# use --build-arg=example_api_key=1234 to set the API_KEY env var. repeat as necessary
# in your github action or other CI/CD, set the arguments from your secrets store.
ARG example_api_key
@K-Mistele
K-Mistele / Invoke-RunAsUser.ps1
Created June 28, 2021 13:40
Schedule a task as another user with PowerShell
$action=New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-windowstyle hidden -ep bypass C:\path\to\script.ps1';
$trigger=New-ScheduledTaskTrigger -Once -At 'MM/DD/YYYY HH:MM:SS PM';
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName 'Launch' -User 'DOMAIN\username'
@K-Mistele
K-Mistele / DumpChromePasswords.ps1
Created June 24, 2021 15:56
@0gtweet's DumpChromePasswords.ps1
$sqlitedll = ".\System.Data.SQLite.dll"
if (!(Test-Path -Path $sqlitedll))
{
Write-Host "Grab your copy of System.Data.SQLite.dll. " -ForegroundColor Yellow
Write-Host "Most likely from https://system.data.sqlite.org/downloads/1.0.113.0/sqlite-netFx40-static-binary-bundle-x64-2010-1.0.113.0.zip" -ForegroundColor Yellow
Write-Host "Your bitness is:" (8*[IntPtr]::Size) -ForegroundColor Yellow
Write-Host "Your .Net version is:" $PSVersionTable.CLRVersion -ForegroundColor Yellow
Write-Host 'No installation needed. Just unzip and update the $sqlitedll variable above.' -ForegroundColor Yellow
return