Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
╔═══════════════════════════════════════════════════════════════════════════╗
║ ║
║ 🎓 LLM PRE-TRAINING FROM SCRATCH - COMPLETE JOURNEY ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════╝
═══════════════════════════════════════════════════════════════════════════
WHAT WE ACCOMPLISHED
═══════════════════════════════════════════════════════════════════════════

Datasette Allow Block Matching - Pure SQLite Implementation

Overview

This prototype demonstrates how Datasette's permission checking logic (allow blocks) can be implemented entirely in SQLite using JSON functions, without requiring Python logic for the core matching algorithm.

The Problem

Datasette uses "allow blocks" to control permissions. An allow block is a JSON object that specifies which actors can perform an action:

@simonw
simonw / claude-code-devcontainer.md
Created September 30, 2025 18:33
Docs generated using Claude Code against its own repo

Claude Code Devcontainer

A secure, isolated development environment for Claude Code with network restrictions and pre-configured development tools.

Overview

This devcontainer provides a sandboxed environment for Claude Code with:

  • Network firewall restrictions limiting outbound connections to approved domains
  • Pre-installed development tools (git, gh CLI, zsh, fzf)
  • VS Code extensions (Claude Code, ESLint, Prettier, GitLens)
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "click",
# ]
# ///
import os
import json
import re
uv run --with pillow --with google-genai python -c '
import os
from google import genai
from google.genai import types
from io import BytesIO
from PIL import Image

GEMINI_API_KEY = os.environ["GEMINI_API_KEY"]
@simonw
simonw / speak.py
Last active February 12, 2025 15:07
Simple script to try out https://github.com/hexgrad/kokoro
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "click",
# "kokoro",
# "misaki[en]",
# "soundfile",
# ]
# ///
import click
@simonw
simonw / geocode.py
Created January 26, 2025 16:49
Geocode using the API bulit into macOS CoreLocation
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "pyobjc-core",
# "pyobjc-framework-CoreLocation",
# "click"
# ]
# ///
"""Basic geocoding using CoreLocation on macOS."""
# /// script
# dependencies = [
# "pyobjc-core",
# "pyobjc-framework-CoreLocation"
# ]
# ///
"""Get named timezone for a location on macOS using CoreLocation
To use this script, you need to have pyobjc-core and pyobjc-framework-CoreLocation installed:
@simonw
simonw / response.json
Created January 1, 2025 16:04
GPT-4o audio response
This file has been truncated, but you can view the full file.
{
"id": "chatcmpl-AkvTd3qWivjaB4rHJUSMAu7UJRTsM",
"object": "chat.completion",
"created": 1735747393,
"model": "gpt-4o-audio-preview-2024-12-17",
"choices": [
{
"index": 0,
"message": {