Skip to content

Instantly share code, notes, and snippets.

View mrkschan's full-sized avatar
😀

KS Chan mrkschan

😀
View GitHub Profile

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@karpathy
karpathy / microgpt.py
Last active August 29, 2026 11:09
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@mrkschan
mrkschan / collision.py
Last active February 2, 2022 12:38 — forked from zadam/collision.py
Calculate birthday paradox (chance of collision) for very large numbers
#!/usr/bin/python3
# This is used for calculating of birthday paradox for large values
# We're using approximation explained here: http://preshing.com/20110504/hash-collision-probabilities/
# Beware that approximation isn't very precise at smaller params N and K, but gets more precise with large numbers
# see https://docs.python.org/3/library/decimal.html#module-decimal
from decimal import *
# setting decimal precision
python3 -c 'import math; yr=3; rate=1.75; print(math.exp(math.log(rate)/yr))'
docker run -e HOME -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e SSH_AUTH_SOCK -v /tmp:/tmp -v "/run/user/$UID":"/run/user/$UID" -v "$HOME":"$HOME" -w "$(pwd)" --rm -i -t <image> <command>
@mrkschan
mrkschan / fcgi.py
Last active February 5, 2021 04:27
fastcgi client in python
'''
Modified from https://github.com/wuyunfeng/Python-FastCGI-Client
'''
from urlparse import urlparse as parse_url
import random
import socket
import sys
@mrkschan
mrkschan / Dockerfile
Last active December 6, 2018 03:06
docker build -t sandpit:stretch
FROM debian:stretch
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
build-essential \
curl \
python-pip python-setuptools python-virtualenv \
; \
rm -rf /var/lib/apt/lists/*
@mrkschan
mrkschan / timedlock.go
Created November 5, 2018 03:48
Self expirying lock in golang
package main
import (
"fmt"
"sync"
"time"
)
type TimedLock struct {
mutex chan (uint)
@mrkschan
mrkschan / httpecho.py
Last active September 15, 2022 09:33
import http.server
import socketserver
PORT = 8080
class H(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
@caseywatts
caseywatts / 0 push to talk.md
Last active December 7, 2025 19:07
Push To Talk - Google Meet Bookmarklet

Short link to this page: http://caseywatts.com/ptt

Other gists & tricks: http://caseywatts.com/gists-and-tricks

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Push To Talk in a Google Hangout (Meet)

  1. Save this bookmarklet. Right-click on boomarks toolbar Add Page...
  • Name: PTT (push to talk) or whatever you'd like (maybe short so it stays on your bookmarks toolbar)