Skip to content

Instantly share code, notes, and snippets.

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.

@YuriyGuts
YuriyGuts / ballmer_guessing_game.py
Last active February 13, 2026 20:44
Optimal randomized binary search strategy for Steve Ballmer's guessing game (https://www.youtube.com/watch?v=svCYbkS0Sjk)
#!/usr/bin/env python3
"""
Optimal randomized binary search strategy for Steve Ballmer's guessing game.
Game: opponent picks `x` in `[1, 100]`, you guess with higher/lower feedback.
Payoff = $6 - (number of guesses). Profit if you find it in 5 guesses or fewer.
Solves the minimax LP over a pool of deterministic BST strategies to find
the optimal randomized mixture. Verifies via Monte Carlo.
@awni
awni / mlx_distributed_deepseek.md
Last active September 12, 2026 20:17
Run DeepSeek R1 or V3 with MLX Distributed

Setup

On every machine in the cluster install openmpi and mlx-lm:

conda install conda-forge::openmpi
pip install -U mlx-lm

Next download the pipeline parallel run script. Download it to the same path on every machine:

import claude from "@anthropic-ai/tokenizer/claude.json";
import { Tiktoken, TiktokenBPE } from "js-tiktoken";
export function countTokens(text: string): number {
const tokenizer = getTokenizer();
const encoded = tokenizer.encode(text.normalize("NFKC"));
return encoded.length;
}
@j3rr7
j3rr7 / get_system_info.sh
Created August 23, 2023 17:21
minimal bash script to get info from linux based server
#!/bin/bash
# System information
hostname=$(hostname)
kernel_version=$(uname -r)
uptime=$(uptime -p)
# Memory information
memory_total_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
memory_total_mb=$((memory_total_kb / 1024))
from django.core.management.base import BaseCommand
from rq.registry import FailedJobRegistry
from django_rq.queues import get_queue
from django_rq.utils import get_jobs
class Command(BaseCommand):
help = 'Delete failed jobs from Django RQ.'
@honi
honi / devrqworker.py
Last active June 4, 2025 18:27
RQ worker wrapper that autoreloads - use only during development
import os
import shlex
import subprocess
from django.core.management.base import BaseCommand
from django.utils import autoreload
class Command(BaseCommand):
def add_arguments(self, parser):
@0xpizza
0xpizza / async_tcp_scan.py
Last active February 19, 2025 14:58
TCP Network scanner using asyncio for Python 3.7
#!/usr/bin/python3.7
import asyncio
import ipaddress
import re
import sys
MAX_NUMBER_WORKERS = 200
@wowkin2
wowkin2 / client.py
Last active April 23, 2018 14:01
Solution to benchmark blocking and non-blocking http-requests using aiohttp session, requests and requests in async executor.
import time
import asyncio
import concurrent.futures
import requests
URL_SESSION = 'http://localhost:8061/session'
URL_REQUESTS = 'http://localhost:8061/requests'
URL_REQUESTS_EXECUTOR = 'http://localhost:8061/requests_executor'
// import_json_appsscript.js
// https://gist.github.com/allenyllee/c764c86ed722417948fc256b7a5077c4
//
// Changelog:
// (Oct. 16 2019) tag: allenyllee-20191016
// 1. Fixed google script error: urlfetchapp - service invoked too many times https://stackoverflow.com/questions/10598179/google-apps-script-urlfetchapp-service-invoked-too-many-times
// (Jul. 16 2018) tag: allenyllee-20180716
// 1. Fixed the issue "If you try to query /arrayA[k]/arrayB[n]/arrayC[m]/.../member, you will always get /arrayA[k]/arrayB[k]/arrayC[k]/.../member."
// (Nov. 30 2017) tag: allenyllee-20171130
// 1. Add the ability to query array elements by using xpath like "/array[n]/member" where "n" is array index