Skip to content

Instantly share code, notes, and snippets.

@karpathy
karpathy / microgpt.py
Last active February 14, 2026 20:02
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@pagelab
pagelab / gsd.sh
Created January 20, 2026 21:26
Sync all Claude Code commands with Google Antigravity workflows
# --- Sync commands from all subfolders in .claude/commands ---
GEMINI_WORKFLOWS="/Users/mac/.gemini/antigravity/global_workflows"
CLAUDE_COMMANDS="/Users/mac/.claude/commands"
if [ -d "$CLAUDE_COMMANDS" ]; then
# Iterate through each subfolder (1 level deep)
for cmd_dir in "$CLAUDE_COMMANDS"/*/; do
[ -d "$cmd_dir" ] || continue
prefix=$(basename "$cmd_dir")
@weshoke
weshoke / codebase-analyzer.py
Created February 8, 2026 21:34
dspy.RLM analyzing a code base with a rules file
#!/usr/bin/env python3
"""
Codebase analyzer using Recursive Language Models (RLM) via DSPy.
Based on: https://kmad.ai/Recursive-Language-Models-Security-Audit
Usage:
python analyze-codebase.py --mode security --output report.md
python analyze-codebase.py --mode documentation --exclude tests,vendor
python analyze-codebase.py --mode quality --max-iterations 50
@ljw1004
ljw1004 / learning-hook.py
Created February 12, 2026 00:39
Claude reminder hook, that works within subagents and within agentic loops
#!/usr/bin/env python3
"""
PostToolUse hook: periodic LEARNINGS.md reminder.
On first invocation for an agent/subagent, outputs the full LEARNINGS.md
instructions. Thereafter, outputs a short reminder about every 10 assistant turns.
Does nothing if no LEARNINGS.md exists in the project root.
This works on a per-agent or per-subagent basis. This is tricky because
hooks don't tell us who they fired for. We work around this by looking for
@its-coder-guy
its-coder-guy / README.md
Created February 14, 2026 19:41
Memory-Optimized Bracket Validator: Counting Runs + Parallel Stacks (Python)

Bracket Validator Optimization 🔥

Classic stacks blow up on extreme nesting like 50k (((...))).

My solutions compress consecutive repeats:

  • counting_compressed.py → Original idea (list of [char, count])
  • parallel_stacks.py → Refined (separate lists → faster)

Both with interactive tester + ignore noise.

@arch1t3cht
arch1t3cht / renderer_internals.md
Last active February 14, 2026 19:50
What Every Typesetter Should Know about Renderer Internals

What Every Typesetter Should Know about Renderer Internals

ASS subtitle rendering is seen by many people as some arcane black magic. That's because it is. Luckily, you do not need to understand most of the black magic to learn many meaningful lessons about both the behavior and performance of renderers.

Let's get it over with right away and post the diagram:

A Venn diagram showing two completely disjoint circles. One circle is labeled "What typesetters think is bad for performance." The other circle is labeled "What's actually bad for performance."