Skip to content

Instantly share code, notes, and snippets.

View simongong's full-sized avatar
🏠
Working from home

simongong

🏠
Working from home
View GitHub Profile
@simongong
simongong / llm-wiki.md
Created April 14, 2026 02:11 — 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.

function downloadIamge(imageSrc, name) {
var image = new Image()
image.setAttribute('crossOrigin', 'anonymous')
image.onload = function () {
var canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
var context = canvas.getContext('2d')
context.drawImage(image, 0, 0, image.width, image.height)
@simongong
simongong / cloudSettings
Created May 31, 2017 01:35
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-05-31T01:35:50.116Z","extensionVersion":"v2.8.1"}
@simongong
simongong / camelSnake.js
Created May 10, 2016 06:40
JavaScript: convert format of object keys between camel-case and snake-case
/**
* @param {Object|String} data string or keys of object are named in form of snake
* @param {number} depth to which level of keys should it process
* @return {Object|String} string or keys of object are named in form of camel case
*/
exports.snakeToCamel = function(data, depth) {
if (Util.isObject(data)) {
if (typeof depth === 'undefined') {
depth = 1;
}
@simongong
simongong / customeError.js
Created May 10, 2016 06:38
JavaScript: a customized error class
const Util = require('util');
module.exports = function AlpOpenError(message, extra) {
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
Util.inherits(module.exports, Error);
@simongong
simongong / decodeEntities.js
Created May 10, 2016 06:36
JavaScript: decode a string in browser which is html-entity-encoded
// originally from: http://stackoverflow.com/questions/5796718/html-entity-decode/27385169
function(str) {
var element = document.createElement('div');
// regular expression matching HTML entities
var entity = /&(?:#x[a-f0-9]+|#[0-9]+|[a-z0-9]+);?/ig;
function decodeHTMLEntities() {
// find and replace all the html entities
str = str.replace(entity, function(m) {
element.innerHTML = m;
return element.textContent;
@simongong
simongong / addDispalyName.js
Created May 10, 2016 06:35
Add display name for functions in a commonJS module
for(var func in module.exports) {
if (typeof module.exports[func] === 'function') {
module.exports[func].displayName = func;
}
}
@simongong
simongong / css-class-name.js
Created May 10, 2016 06:33
JavaScript: Operate on class name of dom elements
module.exports = {
hasClassName: function(element, name) {
return new RegExp('(?:^|\\s+)' + name + '(?:\\s+|$)').test(element.className);
},
addClassName: function(element, name) {
if (!this.hasClassName(element, name)) {
element.className = element.className ? [element.className, name].join(' ') : name;
}
},
@simongong
simongong / getDispositionHeader.js
Last active May 10, 2016 06:34
JavsScript: get disposition header for response
function(userAgent, fileName) {
var suffix = '.zip';
if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
return 'attachment; filename=' + encodeURIComponent(fileName) + suffix;
} else if(userAgent.indexOf('firefox') >= 0) {
return 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileName)+'"' + suffix;
} else {
return 'attachment; filename=' + new Buffer(fileName).toString('binary') + suffix;
}
}
@simongong
simongong / react-component.sublime-snippet
Last active September 18, 2015 08:13
sublime-snippet: React component snippet
<snippet>
<content><![CDATA[
import React from 'react';
let ${1:componentName} = React.createClass({
propTypes: {
},
getInitialState() {
return {};