Skip to content

Instantly share code, notes, and snippets.

View eczn's full-sized avatar
Star

eczn* eczn

Star
View GitHub Profile
@eczn
eczn / llm-wiki.md
Created April 21, 2026 11:10 — 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.

@eczn
eczn / option.enum.ts
Created February 1, 2025 20:07
TypeScript Option<T>
enum TypeNone { }
export type None = { type: typeof TypeNone };
function None<T>(d: T): None { return { type: TypeNone } };
function isNone(x: any): x is None { return !!(x && x.type === TypeNone) };
enum TypeSome { }
export type Some<T> = { type: typeof TypeSome, data: [_: T] };
function Some<T>(d: T): Some<T> { return { type: TypeSome, data: [d] } };
function isSome(x: any): x is Some<unknown> { return !!(x && x.type === TypeSome && x.data) };
@eczn
eczn / 手动覆盖 VSCode 主题的配色.md
Created November 27, 2024 07:44
手动覆盖 VSCode 主题的配色

有时候对主题各方面都感觉很好,但是有一两个地方的颜色感觉还是不太好,此时又不想太麻烦可以通过 vscode 的 workbench.colorCustomizations 项进行覆盖配置:

"workbench.colorCustomizations": {
    "[Popping and Locking]": { // ⬅️ 用中括号括起来 主题名字
        "tab.border": "#484a5c",
        "tab.activeBackground": "#484a5c",
        "tab.activeBorder": "#ed0a0a"
    }
},
@eczn
eczn / latency.txt
Created June 9, 2024 15:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@eczn
eczn / mac-disable-swap.md
Created May 16, 2024 14:20
mac 禁用 swap 交换

参考自 https://github.com/digoal/blog/blob/master/202212/20221207_01.md 这里备份记录一下


第零步:关闭 SIP

SIP 会导致你即使是 root 用户也会出 operation not permitted 的情况出现,尤其是操作一些系统底层的时候(比如 nvram、系统目录/服务等)

关闭方式(只测了我的 m1 mac,需要进入恢复模式):

  1. 关机
@eczn
eczn / GetOptimizationStatus.md
Created May 15, 2024 05:24 — forked from justjavac/GetOptimizationStatus.md
V8 %GetOptimizationStatus

%GetOptimizationStatus return a set of bitwise flags instead of a single value, to access the value, you need to take the binary representation of the returned value. Now, for example, if 65 is returned, the binary representation is the following:

(65).toString(2).padStart(12, '0');
// 000001000001

Each binary digit acts as a boolean with the following meaning:

@eczn
eczn / gist:6232302380fe5defffb0f4cca00a283b
Created May 15, 2024 05:07 — forked from totherik/gist:3a4432f26eea1224ceeb
v8 --allow-natives-syntax RuntimeFunctions
Per https://code.google.com/p/v8/codesearch#v8/trunk/src/runtime.cc
%CreateSymbol
%CreatePrivateSymbol
%CreateGlobalPrivateSymbol
%NewSymbolWrapper
%SymbolDescription
%SymbolRegistry
%SymbolIsPrivate
@eczn
eczn / lexer.mbt
Last active May 3, 2024 04:32
parser combinator 词法解析器
enum Token {
Value(Int)
LParen;
RParen;
Plus;
Minus;
Multiply;
Divide;
} derive(Debug)
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)
@eczn
eczn / scale-canvas.ts
Created January 19, 2024 09:59 — forked from callumlocke/scale-canvas.ts
How to fix a canvas so it will look good on retina/high-DPI screens.
/*
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed.
The following code makes an 800×600 canvas that is always as sharp as possible for the device.
You still draw on it as if it's the logical size (800×600 in this case), but everything just
looks sharper on high-DPI screens. Regular non-sharp screens are not affected.
*/
const width = 800