Theme No. 07 — Kiln & Ember

Code that feels fired, not printed.

A syntax theme drawn from wood-fired ceramics: iron-red slips, celadon glaze, brass and bone. Three languages, one palette — the same clay, shaped differently.

Rs cache.rs · Rust · 34 lines
// A tiny LRU cache backed by a HashMap and a doubly-linked list.
// Built for the Kiln runtime — evicts cold entries first.
use std::collections::HashMap;
use std::hash::Hash;

#[derive(Debug)]
pub struct LruCache<K, V> {
    capacity: usize,
    store: HashMap<K, V>,
    order: Vec<K>,
}

impl<K: Eq + Hash + Clone, V> LruCache<K, V> {
    pub fn new(cap: usize) -> Self {
        assert!(cap > 0, "capacity must be > 0");
        Self { capacity: cap, store: HashMap::new(), order: Vec::new() }
    }

    pub fn put(&mut self, key: K, value: V) {
        if self.store.contains_key(&key) {
            self.order.retain(|k| k != &key);
        } else if self.store.len() >= self.capacity {
            if let Some(oldest) = self.order.first().cloned() {
                self.store.remove(&oldest);
                self.order.remove(0);
            }
        }
        self.order.push(key.clone());
        self.store.insert(key, value);
    }

    pub fn get(&mut self, key: &K) -> Option<&V> {
        self.order.retain(|k| k != key);
        self.order.push(key.clone());
        self.store.get(key)
    }
}
Py pipeline.py · Python · 35 lines
"""
Streaming ingestion pipeline for sensor telemetry.
Drops malformed rows, coerces units, and yields tidy records.
"""
from dataclasses import dataclass, field
from typing import Iterator, Optional
import math

FAHRENHEIT_OFFSET = 32.0
MAX_REASONABLE_TEMP_C = 125

@dataclass
class Reading:
    sensor_id: str
    celsius: float
    tags: list[str] = field(default_factory=list)

    def is_valid(self) -> bool:
        # NaN readings come from disconnected probes.
        return not math.isnan(self.celsius) and self.celsius < MAX_REASONABLE_TEMP_C


def to_celsius(value: float, unit: str) -> Optional[float]:
    match unit.lower():
        case "c" | "celsius":
            return value
        case "f" | "fahrenheit":
            return (value - FAHRENHEIT_OFFSET) * 5 / 9
        case _:
            return None


def ingest(rows: Iterator[dict]) -> Iterator[Reading]:
    for row in rows:
        temp = to_celsius(row.get("value", math.nan), row.get("unit", "c"))
        if temp is None:
            continue
        reading = Reading(sensor_id=row["id"], celsius=temp)
        if reading.is_valid():
            yield reading
Css kiln.module.css · CSS · 36 lines
/* Kiln & Ember — surface tokens for the editor shell */
:root {
  --clay: #e8dccb;
  --ember: oklch(0.68 0.14 45);
  --celadon: #9cc08a;
  --radius: 14px;
}

/* Code surface with a warm, kiln-fired backdrop */
.editor {
  background: linear-gradient(180deg, #28201b 0%, #1e1814 100%);
  color: var(--clay);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.55);
  padding: 1.25rem 1.5rem;
}

.editor .line:hover {
  background: color-mix(in oklch, var(--ember) 8%, transparent);
}

.editor .token-keyword { color: var(--ember); font-weight: 500; }
.editor .token-string  { color: var(--celadon); }

@media (max-width: 720px) {
  .editor {
    font-size: 12.5px;
    padding: 1rem;
  }
}

@supports (background: oklch(0 0 0)) {
  .editor { accent-color: var(--ember); }
}

The Palette

— nine token roles, one fired clay body
Keyword iron red
String celadon
Number ember
Function brass
Type patina
Property plum glaze
Variable bone
Operator stoneware
Comment ash