Skip to content

Instantly share code, notes, and snippets.

View copyleftdev's full-sized avatar

Don Johnson copyleftdev

View GitHub Profile
@copyleftdev
copyleftdev / Dockerfile
Created May 26, 2026 19:58
micro-containers: WASM/WASI Dockerfile — scratch base + wasip1 binary
# WASM image — compiled to WASI preview1 target (Go 1.21+).
# The resulting container holds a single .wasm binary on a scratch base.
# Run via Docker+Wasm (experimental) or directly with wasmtime/wasmedge.
# Build (from repo root): docker build -f runtimes/wasm/Dockerfile -t micro-containers-wasm .
FROM golang:1.24 AS builder
WORKDIR /src
COPY go.mod ./
RUN go mod download
COPY cmd/wasm/ ./cmd/wasm/
@copyleftdev
copyleftdev / Dockerfile
Created May 26, 2026 19:58
micro-containers: distroless OCI Dockerfile — same image for runc, gVisor, Kata, Firecracker
# OCI image — works with runc, gVisor (runsc), Kata (QEMU), and Kata (Firecracker).
# The runtime is injected via RUNTIME_NAME at `docker run` time.
# Build: docker build -t micro-containers .
FROM golang:1.24-alpine AS builder
WORKDIR /src
COPY go.mod ./
RUN go mod download
COPY cmd/server/ ./cmd/server/
RUN CGO_ENABLED=0 GOOS=linux go build \
@copyleftdev
copyleftdev / main.go
Created May 26, 2026 19:58
micro-containers: WASI preview1 variant — JSON to stdout (no net/http in wasip1)
// WASI preview1 target — compiled with GOOS=wasip1 GOARCH=wasm.
// net/http is not available in wasip1; this demonstrates env access,
// stdout, and runtime introspection inside a WASM container.
// The wasi-http proposal (https://github.com/WebAssembly/wasi-http)
// will bring full HTTP support to WASI in a future Go release.
package main
import (
"encoding/json"
"fmt"
@copyleftdev
copyleftdev / main.go
Created May 26, 2026 19:58
micro-containers: Go HTTP server — runtime metadata at GET /health
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"runtime"
"time"
)
@copyleftdev
copyleftdev / linux-archaeology.md
Created May 25, 2026 20:44
linux-archaeology Claude Code skill — reasoning chains for pipe & stream primitives

linux-archaeology

Reason through shell pipeline problems and surface the right forgotten Linux command. Each section maps a real situation to a specific tool with concrete invocations.

TRIGGER

Invoke this skill when the user:

  • Wants to monitor a running process, file, or resource without modifying the process
  • Needs to send output to both the screen and a file at the same time
@copyleftdev
copyleftdev / linux-parallel.sh
Created May 25, 2026 20:44
parallel — run many independent tasks concurrently with job control
# parallel — GNU parallel: xargs -P with sane defaults
# sudo apt install parallel
# Basic concurrent execution:
cat tasks.txt | parallel <command> {}
ls *.sh | parallel bash {}
# Control concurrency:
cat tasks.txt | parallel -j4 <command> {} # max 4 jobs
cat tasks.txt | parallel -j0 <command> {} # one per CPU core
@copyleftdev
copyleftdev / linux-vidir.sh
Created May 25, 2026 20:44
vidir — rename or delete a batch of files in your text editor
# vidir — edit a directory listing in $EDITOR (from moreutils)
# sudo apt install moreutils
vidir directory/ # open all files in editor
ls *.sh | vidir - # open a specific subset
# In your editor:
# - Edit a path → renames the file
# - Delete a line → deletes the file
# - Change directory prefix → moves the file
@copyleftdev
copyleftdev / linux-tac.sh
Created May 25, 2026 20:44
tac — reverse line order of any file or stream
# tac — cat backwards: last line first
# (tac is cat spelled backwards)
tac logfile.log # reverse entire file
tac logfile.log | head -20 # last 20 lines, newest-first
tac logfile.log | grep -m1 'ERROR' # last occurrence of ERROR
# Process a JSONL file newest-first:
tac data.jsonl | head -5 | python3 -c "
import sys, json
@copyleftdev
copyleftdev / linux-comm.sh
Created May 25, 2026 20:44
comm — compare two sorted files: unique to each and shared
# comm — line-by-line comparison of two sorted files
# Input must be sorted. Use: sort file | sponge file
comm a.txt b.txt # 3 columns: only-A | only-B | both
comm -23 a.txt b.txt # only in A (suppress cols 2 and 3)
comm -13 a.txt b.txt # only in B (suppress cols 1 and 3)
comm -12 a.txt b.txt # in both (suppress cols 1 and 2)
# Sort on the fly with process substitution:
@copyleftdev
copyleftdev / linux-column.sh
Created May 25, 2026 20:44
column — format delimited text into aligned tables
# column — align delimited input into a readable table
# TSV file:
column -t -s $'\t' models.tsv
# CSV:
column -t -s ',' data.csv
# Colon-separated:
column -t -s ':' /etc/passwd