Skip to content

Instantly share code, notes, and snippets.

View dentarg's full-sized avatar
🌦️
=:D><!

Patrik Ragnarsson dentarg

🌦️
=:D><!
View GitHub Profile

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.

# frozen_string_literal: true
require "fileutils"
# Helper for Git worktree-aware behavior
class GitWorktree
PROJECT_ROOT = File.expand_path("..", __dir__)
def self.instance = new
def self.name = instance.name
@jjb
jjb / file.md
Last active April 14, 2026 22:58
Using Jemalloc 5 with Ruby.md

For years, people have been using jemalloc with ruby. There were various benchmarks and discussions. Legend had it that Jemalloc 5 didn't work as well as Jemalloc 3.

Then, one day, hope appeared on the horizon. @wjordan offered a config for Jemalloc 5.

Ubuntu/Debian

FROM ruby:3.1.2-bullseye
RUN apt-get update ; \
@chrisbloom7
chrisbloom7 / slack_ruby_client_websockets.rake
Last active September 20, 2024 18:43
Basic implementation of a websocket connector for Slack using slack-ruby-client and async-websockets gems
# frozen_string_literal: true
# Basic implementation of a websocket connector for Slack using the slack-ruby-client gem
#
# Run this rake task in a virtual container that is set to automatically restart on failure; this
# will help deal with disconnects from Slack since socket URLs are temporary.
# https://api.slack.com/apis/connections/socket-implement#disconnect
#
# This rake task can be called in multiple virtual containers to help with resilliancy and rolling restarts
# https://api.slack.com/apis/connections/socket-implement#connections
@dentarg
dentarg / .zshenv
Last active October 26, 2022 18:38
How to Ruby on Apple silicon
# Need to use ~/.zshenv, ~/.zprofile is not sourced when doing "arch -x86_64 /bin/zsh"
#
# From 'man zsh' (zsh 5.8.1 (x86_64-apple-darwin21.0))
#
# Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login
# shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile.
# Then, if the shell is interactive, commands are read from /etc/zshrc and
# then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell,
# /etc/zlogin and $ZDOTDIR/.zlogin are read.
class MyEnumerator
attr_reader :scope, :block, :opened, :headers
def initialize(scope, headers, &block)
@scope = scope
@block = block
@opened = false
@cursor = PostgreSQLCursor::Cursor.new(scope.send(:to_unprepared_sql))
@headers = headers
@headers_provided = false
# INFO: works well with Ruby 3.0.1
# hangs on any Ruby including https://github.com/ruby/ruby/commit/f9196de1dee6f5ab8b6fe115070b92775a3500fe
# since the yielding code in each method is running in different Fiber (due to be wrapped into Enumerator and next is used)
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
@otavioschwanck
otavioschwanck / install rails 7 m1.md
Last active April 26, 2022 19:44
Rails 7 on m1 mac

Why install in this way?

To fix some problems with the arm version, like puma SSL.

if you problem is only SSL, try it:

Remove gem puma: gem uninstall puma

And run bundle with DISABLE_SSL=1 bundle install

#!/usr/bin/env ruby
if %w(-h --help).include?(ARGV.first)
abort <<~USAGE
#{__FILE__} <FILE> to count IPs in given file
#{__FILE__} to count IPs using latest file on disk
DL=1 #{__FILE__} to download the AWS IP ranges
USAGE
end
@dhh
dhh / pagination_controller.js
Last active January 11, 2026 06:01
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>