Skip to content

Instantly share code, notes, and snippets.

View mr-moon's full-sized avatar

Alexander Moon mr-moon

  • Tallinn, Estonia, Europe
View GitHub Profile
@mr-moon
mr-moon / llm-wiki.md
Created May 9, 2026 14:52 — forked from rohitg00/llm-wiki.md
LLM Wiki v2 — extending Karpathy's LLM Wiki pattern with lessons from building agentmemory

LLM Wiki v2

A pattern for building personal knowledge bases using LLMs. Extended with lessons from building agentmemory, a persistent memory engine for AI coding agents.

This builds on Andrej Karpathy's original LLM Wiki idea file. Everything in the original still applies. This document adds what we learned running the pattern in production: what breaks at scale, what's missing, and what separates a wiki that stays useful from one that rots.

What the original gets right

The core insight is correct: stop re-deriving, start compiling. RAG retrieves and forgets. A wiki accumulates and compounds. The three-layer architecture (raw sources, wiki, schema) works. The operations (ingest, query, lint) cover the basics. If you haven't read the original, start there.

@mr-moon
mr-moon / json.d.ts
Created December 16, 2024 10:46
A TypeScript type to deserialize JSON in a semi-safe way.
type Primitive =
| bigint
| boolean
| null
| number
| string;
type JSONValue = Primitive | JSONObject | JSONArray;
type JSONArray = Array<JSONValue>;
@mr-moon
mr-moon / psqlerrors.json
Created July 4, 2024 13:20
PostgreSQL error codes with semantic identifier
{
"20000": "case_not_found",
"21000": "cardinality_violation",
"22000": "data_exception",
"22001": "string_data_right_truncation",
"22002": "null_value_no_indicator_parameter",
"22003": "numeric_value_out_of_range",
"22004": "null_value_not_allowed",
"22005": "error_in_assignment",
"22007": "invalid_datetime_format",
@mr-moon
mr-moon / coords.js
Created November 18, 2019 11:41
DOM element coordinate helpers
/**
* MIT License
* @author Alexander Moon mainarx@gmail.com
*/
/**
* An offset type definition
* @typedef {Object} Offset
* @property {number} top
* @property {number} left
@mr-moon
mr-moon / await.js
Created November 4, 2017 14:14
clean javascript API for waiting for some condition to be met
/**
* A helper that simplifies waiting for something to happen. It acts like an observer without any
* particular observable. So your 'evaluator' function may do anything, untill it's returns non-undefined value
*
* For example, you may want to "observe" a sessionStorage value regardless of browser support of the
* "storage" events.
*
* @example
* ```js
* var awaiter = await(
@mr-moon
mr-moon / gist:77c90944804f7da71ecd
Last active August 29, 2015 14:05
Doing supported browsers check with WhichBrowser.net library.
var
INTERNET_EXPLORER = 'Internet Explorer',
FIREFOX = 'Firefox',
CHROME = 'Chrome',
OPERA = 'Opera',
OPERA_MINI = 'Opera Mini',
SAFARI = 'Safari',
MAXTHON = 'Maxthon',
WEBKIT = 'WebKit',
TRIDENT = 'Trident',
/**
* Evaluates the given number against array of numbers, and returns
* the one that is the "closest"
* @param value Value to be tested
* @param array Array of numbers
* @param method uint a comparison method. 0 - round, 1 - ceil, 2 - floor
* @return The closest value from <code>array</code> parameter
*/
public static function closestAgainstArray(value:Number, array:Array, method:uint = 0):Number
{