Skip to content

Instantly share code, notes, and snippets.

View tomcatzh's full-sized avatar

Zhang Xiaofeng tomcatzh

  • Amazon Web Service
  • Guangzhou, China
View GitHub Profile
@tomcatzh
tomcatzh / llm-wiki.md
Created April 30, 2026 04:01 — 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.

@tomcatzh
tomcatzh / parseHumanSize.c
Created June 15, 2019 10:05
parseHumanSize #c #atoi
uintmax_t parseHumanSize (const char* s) {
char *endp = (char *)s;
int sh;
errno = 0;
uintmax_t x = strtoumax(s, &endp, 10);
if (errno || endp == s) {
errno = EINVAL;
goto ERROR;
}
@tomcatzh
tomcatzh / cue_to_mp3.py
Created December 9, 2017 02:30 — forked from bancek/cue_to_mp3.py
CUE splitter using ffmpeg (to mp3)
cue_file = 'file.cue'
d = open(cue_file).read().splitlines()
general = {}
tracks = []
current_file = None
@tomcatzh
tomcatzh / gzip_compress_reader.go
Last active April 3, 2024 09:30
Wrap a reader to a gzip compress reader using gzip writer :-P
func NewGzipReader(source io.Reader) io.Reader {
r, w := io.Pipe()
go func() {
defer w.Close()
zip, err := gzip.NewWriterLevel(w, gzip.BestSpeed)
defer zip.Close()
if err != nil {
w.CloseWithError(err)
}
#!/bin/bash
if [ -z $1 ]; then
FILTER='Name=instance-state-code,Values=16'
else
FILTER=$1
fi
IDs=`aws ec2 describe-instances --filters "$FILTER" | jq '.Reservations[].Instances[].InstanceId' -r`
#!/bin/sh
yum update -y
yum --enablerepo=epel install jq bash-completion -y
cat <<EOT >> /etc/profile.d/aws-cli.sh
if [ $SHELL = "/bin/bash" ]; then
complete -C '/usr/bin/aws_completer' aws
fi
@tomcatzh
tomcatzh / auto.pac
Last active October 10, 2015 08:37
iOS Shadowsocks chinese website white list pac
// Based on whitelist v1.2 by https://github.com/n0wa11
function FindProxyForURL(url, host) {
var PROXY = 'SOCKS 127.0.0.1:1983';
if (isPlainHostName(host)) return 'DIRECT';
if (/^\d+\.\d+\.\d+\.\d+$/g.test(host)) return 'DIRECT';
var rules = [
[
'cn',
'lan',
@tomcatzh
tomcatzh / auto.pac
Created October 10, 2015 07:42
iOS Shadowsocks chinese website white list pac
// Based on whitelist v1.2 by https://github.com/n0wa11
function FindProxyForURL(url, host) {
var PROXY = 'SOCKS 127.0.0.1:1983';
if (isPlainHostName(host)) return 'DIRECT';
if (/^\d+\.\d+\.\d+\.\d+$/g.test(host)) return 'DIRECT';
var rules = [
[
'cn',
'lan',
@tomcatzh
tomcatzh / readwrite.go
Created April 1, 2015 06:35
Golang readline and writeline
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
@tomcatzh
tomcatzh / json_example.go
Last active August 29, 2015 14:17
How to using json parser in golang
package main
import (
"encoding/json"
"fmt"
"time"
)
// The custom time format for json
type MyTime time.Time