Skip to content

Instantly share code, notes, and snippets.

@justinpaulson
justinpaulson / microgpt.rb
Last active February 20, 2026 21:29
MicroGPT in Ruby — a complete GPT training and inference implementation in pure, dependency-free Ruby. Re-creation of @karpathy's microgpt.py
# frozen_string_literal: true
# MicroGPT in Ruby — optimized version
# Original Python by @karpathy, Ruby port + optimizations
require 'open-uri'
srand(42)
unless File.exist?('input.txt')
names_url = 'https://raw.githubusercontent.com/karpathy/makemore/988aa59/names.txt'
@justinpaulson
justinpaulson / _message.html.erb
Last active October 28, 2024 18:52
turbo-rails Prepend bug in broadcastable
<p id="<%= dom_id(message) %>">
<%= message.body %>
</p>