Skip to content

Instantly share code, notes, and snippets.

View codecakes's full-sized avatar
💭
I may be slow to respond.

codecakes codecakes

💭
I may be slow to respond.
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.

"""
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
@codecakes
codecakes / designing_ha_systems.md
Created April 5, 2024 15:11
How to design Horizontally scalable distributed systems?

HA principles: CAP done right

  • Design in isolation (Partition)
    • 2 business modules must communicate over message pattern. They are not considered business modules if one requires the other, in which case they don’t need to communicate over messages if a business process has to die, all interconnected business modules must die
    • process are stateless
    • fault tolerant implies scalability implies concurrency and concurrent business processes
  • Availability
    • its better to die on fault and restart, then drag and build up the pile of error
  • when a process dies, fault detection and communicating fault is important
@PJUllrich
PJUllrich / big-o.md
Last active March 21, 2026 16:40
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@kerr-bighealth
kerr-bighealth / config.tf
Created January 28, 2020 20:08
iam-user module
terraform {
required_version = ">=0.12, <0.13"
}
def answer(map, git_gud=True):
"""Find the shortest path in a binary 2D map where a wall can be removed.
The algorithm uses a modified Dijstra's algorithm to find the shortest path
from the start vertex (0,0) to the end vertex (w-1,h-1) in a 2D binary map.
A single wall can be removed from the map to make the shortest path, if
necessary. The first wall in any path can be ignored easily, but if a wall
is necessary to be removed for a valid solution to exist the simple
algorithm does not remember the minimum path that does not pass through a
wall to arrive at the mandatory wall vertex. Therefore we modify the
@comalex
comalex / mock.md
Last active February 12, 2020 07:41
Mock python cheatsheet

Python unittest.mock Cheat Sheet

Basic usage

mock.Mock()
mock.MagicMock()

Asserts

assert_called_with: This method asserts that the last call was made with the given parameters

@mtrunkat
mtrunkat / docker-mongo-repair
Last active March 19, 2024 06:28
Run "mongo --repair" in Docker container that cannot start because of MongoDB error
#!/bin/bash
# See https://github.com/docker-library/mongo/pull/63
docker run --rm --volumes-from my-mongo-server mongo unlink "/data/db/mongod.lock"
docker run --rm --volumes-from my-mongo-server mongo --repair
@emilsoman
emilsoman / phoenix_to_umbrella
Last active July 13, 2024 21:50
How to move an existing phoenix app under an umbrella app
How to convert existing phoenix app to an umbrella app.
https://elixir-lang.slack.com/archives/phoenix/p1472921051000134
chrismccord [10:14 PM]
@alanpeabody yes, it's straightforward
[10:14]
1) mix new my_umbrella --umbrella
@codecakes
codecakes / url_param.js
Created August 6, 2016 21:08
Simple Url Parameter extraction from DOM
"use strict";
let paramRegex = /([a-zA-Z0-9]+\=[a-zA-Z0-9]+)/ig;
location.search.match(paramRegex);