Skip to content

Instantly share code, notes, and snippets.

View andrewssobral's full-sized avatar
🔴
I may be very slow to respond.

Andrews Cordolino Sobral andrewssobral

🔴
I may be very slow to respond.
View GitHub Profile
@andrewssobral
andrewssobral / llm-wiki.md
Created April 4, 2026 20:45 — 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.

#!/usr/bin/env python3
"""
TinyAdder: 36-parameter hand-crafted transformer for 10-digit addition.
Parameter counting:
- Identity mappings (direct copy): 0 params
- Broadcast (1 value to N outputs): 1 param
- Distinct values: count each
"""
import torch
"""
Dynamic NanoGPT Adder: 130 params + 0 buffers
transformer.wte.A [10, 1] = 10
transformer.wte.B [1, 4] = 4
transformer.h.0.attn.c_attn.weight [12, 4] = 48
transformer.h.0.attn.c_proj.weight [4, 4] = 16
transformer.h.0.mlp.c_fc.weight [4, 4] = 16
transformer.h.0.mlp.c_fc.bias [4] = 4
transformer.h.0.mlp.c_proj.u [4, 1] = 4
@andrewssobral
andrewssobral / microgpt.py
Created February 12, 2026 21:24 — forked from karpathy/microgpt.py
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
@andrewssobral
andrewssobral / settings.json
Created October 21, 2025 19:38 — forked from rekram1-node/settings.json
OpenCode agent server (zed)
{
"agent_servers": {
"OpenCode": {
"command": "opencode",
"args": ["acp"]
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewssobral
andrewssobral / claude_code_hooks_for_uv.md
Created July 26, 2025 20:59 — forked from glennmatlin/claude_code_hooks_for_uv.md
Claude Code hooks for working with `uv`

Claude Code Hooks for working with uv

by Glenn Matlin / glennmatlin on all socials

Installation

  1. Download and copy all files in this gist to ~/.claude/
  2. Move the .py files to ~/.claude/hooks
  3. Restart Claude Code.
import os
from google import genai
from google.genai import types
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY","xxx"))
# Repalce with the youtube url you want to analyze
youtube_url = "https://www.youtube.com/watch?v=RDOMKIw1aF4"
# Prompt to analyze and summarize the Youtube Video

Code Bash command prefix detection

This defines risk levels for actions that the ${K4} agent may take. This classification system is part of a broader safety framework and is used to determine when additional user confirmation or oversight may be needed.

Command prefix extraction examples

Examples:

  • cat foo.txt => cat
  • cd src => cd
@andrewssobral
andrewssobral / micro_events.py
Created March 9, 2025 17:06 — forked from tarruda/micro_events.py
Micro event loop library to teach the basic concepts of python coroutines and how event loop libraries might be implemented
"""
A micro event loop library implementation from scratch.
This library provides a minimal but feature-complete asynchronous event loop
implementation for educational purposes. It demonstrates the core concepts of
asynchronous programming including:
- Task scheduling and management
- I/O multiplexing with non-blocking sockets
- Timeouts and sleep functionality