Skip to content

Instantly share code, notes, and snippets.

View tjsingleton's full-sized avatar

TJ Singleton tjsingleton

View GitHub Profile
@tjsingleton
tjsingleton / llm-wiki.md
Created June 9, 2026 15:14 — forked from karpathy/llm-wiki.md
llm-wiki

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.

@tjsingleton
tjsingleton / mysql-to-csv.rb
Created January 13, 2017 17:34
Reads from STDIN or a file, converts \G mysql formatted results to csv, and writes to STDOUT
require "csv"
# Reads from STDIN or a file, converts \G mysql formatted results to csv, and writes to STDOUT
#
# STDIN Usage:
# mysql ... | ruby mysql-to-csv.rb
#
# File Usage:
# ruby mysql-to-csv.rb results.txt
#
@tjsingleton
tjsingleton / delete-instance.rb
Last active May 12, 2016 03:09
For a list of instances returned from a chef search, terminate instances, release any elastic ips, and delete any attached volumes.
require 'time'
require 'json'
require 'pp'
require 'open3'
class DeleteShare
def initialize
@instances = Hash.new {|h,k| h[k] = [] }
@public_ips = Hash.new {|h,k| h[k] = [] }
@volumes = Hash.new {|h,k| h[k] = [] }
# swap loops so we can exit early from the inner loop once we've searched the valid range
require "pp"
require "minitest/autorun"
class StockTest < Minitest::Test
attr_accessor :loops
def pick_best_time_to_buy(stock)
best_value = 0
route: 66.249.64.0/20
descr: Google
origin: AS15169
notify: noc@google.com
mnt-by: MAINT-AS15169
changed: noc@google.com 20110301
source: RADB
route: 66.249.80.0/20
descr: Google
@tjsingleton
tjsingleton / create-feature-branch
Last active December 27, 2015 09:39
Git helpers I install to ~/bin
#!/usr/bin/env bash
usage (){
echo "Usage: $0 new-branch-name"
exit 1
}
[[ $# -eq 0 ]] && usage
git fetch origin
_ = nil
scope = binding
loop do
print "> "
code = gets.chomp
_ = eval(code, scope)
puts "=> #{_.inspect}"
end
@tjsingleton
tjsingleton / config.ru
Created July 9, 2013 14:30
require_relative in config.ru
require_relative './mylib'
run ->(env){ [200, {}, ['']] }
last_line = nil
index = 0
ARGF.each_line do |line|
index += 1
next if index < 35
puts last_line if last_line # skip last line
line.gsub!("#{0x01}\\#{0x01}", "#{0x01}#{0x01}")
line.gsub!("\\", "\\\\")
{"resource":"Orders","http_method":"POST","route":"/orders","description":"Creating an order","explanation":"First, create an order, then make a later request to get it back","parameters":[{"name":"name","description":"Name of order","required":true,"scope":"order"},{"name":"paid","description":"If the order has been paid for","required":true,"scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"request_method":"POST","request_path":"/orders","request_body":"{\"order\":{\"name\":\"Order 1\",\"paid\":true,\"email\":\"email@example.com\"}}","request_headers":{"Accept":"application/json","Content-Type":"application/json","Host":"example.org","Cookie":""},"request_query_parameters":{},"request_content_type":"application/json","response_status":201,"response_status_text":"Created","response_body":"{\"email\":\"email@example.com\",\"name\":\"Order 1\",\"paid\":true}","response_headers":{"Content-Type":"application/json; charset=utf-8","Location":"http:/