Skip to content

Instantly share code, notes, and snippets.

@cobysy
cobysy / llm-wiki.md
Created April 30, 2026 10:34 — 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.

@cobysy
cobysy / DeepFreeze.cs
Last active March 17, 2026 17:53
DeepFreeze.cs
public interface IFreezable
{
bool IsFrozen { get; }
void Freeze();
void Unfreeze();
void DeepFreeze();
void DeepUnfreeze();
}
public abstract class FreezableBase : IFreezable
// HashUtils to compute Hash on a complex document
var doc = new Document
{
Title = "Hash Test",
Links =
[
new() { Url = "https://b.com", Text = "B" },
new() { Url = "https://a.com", Text = "A" }
]
// see https://learn.microsoft.com/en-us/rest/api/aiservices/document-models/analyze-document-from-stream?view=rest-aiservices-v4.0%20(2024-11-30)&tabs=HTTP
// for parameters
var analyzeDocumentOptions = new AnalyzeDocumentOptions(
"prebuilt-layout",
binaryData)
{
OutputContentFormat = DocumentContentFormat.Markdown
};
public sealed class AzureCliCredentialProxy(IHttpClientFactory httpClientFactory)
: DefaultAzureCredential
{
public override AccessToken GetToken(
TokenRequestContext requestContext,
CancellationToken cancellationToken = default)
{
return this.GetTokenAsync(
requestContext,
cancellationToken).GetAwaiter().GetResult();
@cobysy
cobysy / .editorconfig
Created May 23, 2025 13:27 — forked from niclaslindstedt/.editorconfig
ReSharper-compatible editorconfig for C# projects
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
[*.yml]
indent_size = 2
@cobysy
cobysy / Moving Files And History Between Git Repos.md
Last active April 24, 2025 17:28
Moving Files And History Between Git Repos

Setup

To begin with, we're going to fetch a copy of the source repo. We're potentially going to be making changes in it that we don't want accidentally pushed back to the origin, so it's much safer to use a copy

Clone the source repo into a directory called source_repo and then cd into it:

git clone https://example.invalid/myrepo.git source_repo
cd source_repo
@cobysy
cobysy / QueryInterceptor.cs
Last active November 25, 2024 10:18
QueryInterceptor for Ef Core to apply SQL hints (Sql Server)
public static class QueryTableHintInterceptorExtensions
{
public static IQueryable<T> WithTableHint<T>(
this DbSet<T> source,
string? hints) where T : class
{
if (hints == null)
{
return source;
}
@cobysy
cobysy / PublicClientApplicationBuilder
Created August 5, 2022 11:01
PublicClientApplicationBuilder - get token for current user msal.net
var result = await PublicClientApplicationBuilder.CreateWithApplicationOptions(options: new()
{
ClientId = "8bxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
TenantId = "1exxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
})
.WithRedirectUri(redirectUri: "http://localhost")
.Build()
.AcquireTokenInteractive(scopes: "api://7fxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/some.web.api openid profile offline_access".Split(separator: ' '))
.WithAccount(account: PublicClientApplication.OperatingSystemAccount)
.WithPrompt(prompt: Prompt.NoPrompt)
@cobysy
cobysy / deploy.sh
Created September 24, 2018 19:42
ghpages
git init
git add .
git commit -m "Initial commit"
git remote add origin git@github.com:cobysy/somerepo.git
git push --force origin master:gh-pages