Skip to content

Instantly share code, notes, and snippets.

View mafredri's full-sized avatar

Mathias Fredriksson mafredri

View GitHub Profile
@mafredri
mafredri / llm-wiki.md
Created June 30, 2026 23:49 — 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.

@mafredri
mafredri / Dockerfile
Created September 26, 2021 21:27
Restic backup from ZFS dataset snapshots mounted via Docker to mirror real directory structure
FROM alpine:3.14.2
LABEL maintainer="Mathias Fredriksson <mafredri@gmail.com>"
RUN apk add --no-cache \
bzip2 \
ca-certificates
ARG RESTIC_VERSION='0.12.1'
RUN wget -O - https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_amd64.bz2 \
| bzip2 -d >/usr/local/bin/restic \
@mafredri
mafredri / timemachine-zfs-snapshot
Last active May 20, 2025 17:44
Time Machine backup snapshotting on ZFS using zrepl for snapshot purging (for Samba server)
# /etc/cron.d/samba-timemachine-zfs-snapshot
# Create snapshots after completed Time Machine backups.
# Runs every two minutes to allow creating backups only after cleanup is
# completed.
*/2 * * * * root /usr/local/bin/timemachine-zfs-snapshot.sh rpool/share/timemachine
@mafredri
mafredri / zsh-histdb-tabulation.zsh
Last active December 21, 2021 18:36
Custom tabulation command for zsh-histdb
# This is a custom tabulation command implemented fully in zsh that
# produces simple output suitable for zsh-histdb.
#
# The `column` command on macOS has a silly limitation max 2048 line
# length, it's unsuitable for tabulating long paths and commands. It
# also produces somewhat unexpected results with regards to column
# length and placement.
#
# Features:
# - Right indent for number columns
@mafredri
mafredri / smb.conf
Last active July 4, 2026 07:12
Samba config for Open PS2 Loader (PlayStation 2)
# This setup works pretty well for OPL with a network link that travels through
# two UniFi switches and connects to a Samba server running inside Docker. The
# host OS is Debian with a ZFS filesystem and the container OS is also Debian.
# Latest Samba (4.11+).
[global]
# ======================
# General Samba settings
# ======================
log level = 1
@mafredri
mafredri / usg_wireguard_upgrade.expect
Created March 1, 2019 11:57
Expect script to automate WireGuard upgrade on UniFi Security Gateway
#!/usr/bin/env expect -f
# Description: Expect script to automate WireGuard upgrade on UniFi Security Gateway
# Author: Mathias Fredriksson <mafredri@gmail.com>
# This script assumes non-interactive ssh login.
# Usage upgrade.expect <[user@]usg> <https://github.com/Lochnair/vyatta-wireguard/releases/download/${RELEASE}/wireguard-${BOARD}-${RELEASE}.deb>
set timeout 60
@mafredri
mafredri / gpg-yubikey-sign.sh
Last active December 17, 2018 10:14
gpg-yubikey-sign: Sign Git commits with any of your valid GPG subkeys
#!/usr/bin/env zsh
# gpg-yubikey-sign
#
# This script lets you use any of your unexpired subkeys connected to
# your public key (0xDEADBEEFCAFEBAAD) to sign git commits. It will also
# display "Waiting for YubiKey touch..." to remind you that an action is
# required.
#
# Add this script to your PATH and configure git to use it for gpg
# signing.
// This example gives permission to access geolocation
// and fetches the current position via JavaScript.
// Tested on: cdp v0.18.7 and Chrome Canary 70.0.3532.0,
// and seems to work in both headless and headfull mode.
package main
import (
"context"
"fmt"
"log"
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
"github.com/mafredri/cdp"
@mafredri
mafredri / translate-bookmarklet.js
Created August 11, 2018 10:03
A bookmarklet to quickly translate the current webpage using Google Translate
javascript:(function(){window.location='https://translate.google.com/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&edit-text=&u='+encodeURIComponent(window.location.href)})();void(0);