Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import json
import os
import selectors
import subprocess
import sys
from pathlib import Path
ALL_HOSTS = ("newton", "spinoza", "kant", "gauss", "aristo")
# frozen_string_literal: true
# Hash-backed, dot-accessible options object. A field name that would
# collide with a real method on this object raises instead of silently
# becoming unreachable via dot-notation.
class DotHash
# Raised when a field name collides with an existing method.
class ReservedNameError < NameError
end
@roktas
roktas / method_accessible_hash.rb
Created August 5, 2026 18:15 — forked from kalsan/method_accessible_hash.rb
MethodAccessibleHash, a possible replacement for OpenStruct
# OpenStruct has caveats and security problems and even leads to a rubocop offense:
# https://ruby-doc.org/stdlib-3.1.0/libdoc/ostruct/rdoc/OpenStruct.html#class-OpenStruct-label-Caveats
# https://msp-greg.github.io/rubocop/RuboCop/Cop/Style/OpenStructUse.html
#
# It's time to replace it. The feature I loved most about OpenStruct was being able to retrieve
# values by calling a method instead of having to use hash access syntax.
# The recommended way to go is Struct, but it is much more cumbersome than OpenStruct was.
# So here's MethodAccessibleHash that allows to do that, but without OpenStruct's security problems.
#
# This revision adds writers, direct creation from Hash, as well as enhanced merging.
@roktas
roktas / llm-wiki.md
Created June 12, 2026 17:00 — 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.

" ----------------------------------------------------------------------------------------------------------------------
" Settings
" ----------------------------------------------------------------------------------------------------------------------
set confirm=permdelete
set history=500
set hlsearch
set ignorecase
set incsearch
set nofollowlinks
local wezterm = require("wezterm")
------------------------------------------------------------------------------------------------------------------------
-- Constants and helpers
------------------------------------------------------------------------------------------------------------------------
local FONT_FAMILY = wezterm.font("Spleen 32x64")
local FONT_SIZE = 16
local CHAR_SOLID_LEFT = wezterm.nerdfonts.pl_right_hard_divider
local COLOR_BACKGROUND = "#2e3440"
# frozen_string_literal: true
require "sevgi/sundries/printer"
module Sevgi
module Graphics
module Mixtures
module Print
EXT = ".svg"
#!/usr/bin/env bash
declare -gr ROOT=~/Dropbox/src/strokes
alef() {
local P
echo >&2 "alef"
for P in g i; do
@roktas
roktas / base.sevgi
Last active February 14, 2026 15:13
Old Strokes base
# frozen_string_literal: true
module Base
module Header
def call(page)
n = 3
width = page.grid.width / n.to_f
rect id: "Header-Cell-Left", x: 0, y: 0, width:, height: 9, class: %w[ header ]
rect id: "Header-Cell-Center", x: width, y: 0, width:, height: 9, class: %w[ header ]