Code Explainers

Browse the library

javascript
class Sheet {
  constructor() {
    this.cells = new Map();
    this.computing = new Set();

Building a reactive spreadsheet engine

reactivity dependency-tracking graph-traversal
Advanced 9 steps
rust
use axum::{
    body::Body,
    extract::Request,
    http::{header::SET_COOKIE, HeaderValue},

Flash messages via Axum middleware

middleware shared-state cookies
Intermediate 8 steps
javascript
const express = require('express');
const router = express.Router();
 
router.get('/exports/orders', async (req, res) => {

Streaming a large JSON export in Express

streaming backpressure cursors
Advanced 9 steps
typescript
type ToastVariant = "info" | "success" | "warning" | "error";
 
interface Toast {
  id: string;

A self-dismissing toast store with dedup

observer-pattern deduplication timers
Intermediate 10 steps
php
<?php
 
namespace App\Services;
 

A cached settings service in Laravel

caching memoization cache-invalidation
Intermediate 8 steps
go
package config
 
import (
	"os"

Layered config resolution in Go

configuration closures higher-order-functions
Intermediate 8 steps
rust
use std::collections::HashSet;
use std::fs;
use std::path::{Path, PathBuf};
use std::thread;

Polling a directory for new files in Rust

polling filesystem callbacks
Intermediate 6 steps
python
import asyncio
import logging
from dataclasses import dataclass
 

A concurrent batch geocoder in asyncio

asyncio producer-consumer rate-limiting
Advanced 8 steps
ruby
require "erb"
 
class TemplateRenderer
  class MissingVariableError < StandardError; end

A safe ERB template renderer in Ruby

metaprogramming method_missing binding
Intermediate 10 steps
java
public final class RetryExecutor {
 
    private final int maxAttempts;
    private final Duration baseDelay;

Retry with exponential backoff in Java

retry exponential-backoff jitter
Intermediate 7 steps
javascript
const crypto = require('crypto');
 
function idempotency({ store, ttlMs = 24 * 60 * 60 * 1000 }) {
  return async function idempotencyMiddleware(req, res, next) {

Idempotent POST requests in Express

idempotency middleware caching
Advanced 8 steps
typescript
type Doc = { id: string; title: string; body: string };
 
type Posting = { docId: string; frequency: number; positions: number[] };
 

Building a TF-IDF search index

inverted-index tf-idf tokenization
Advanced 9 steps
go
package routing
 
import (
	"net/http"

Region-aware upstream routing in Gin

middleware concurrency load-balancing
Advanced 8 steps
rust
use axum::{
    extract::{FromRef, FromRequestParts, State},
    http::{header::ACCEPT_LANGUAGE, request::Parts, StatusCode},
    response::{IntoResponse, Response},

A custom Accept-Language extractor in Axum

extractors internationalization http-headers
Advanced 8 steps
python
import functools
import inspect
from typing import get_type_hints, get_origin, get_args, Union
 

A runtime type checker from annotations

decorators runtime-validation type-hints
Advanced 8 steps
ruby
class ReverseGeocodeSignupJob < ApplicationJob
  queue_as :default
 
  retry_on Geocoder::OverQueryLimitError, wait: 5.minutes, attempts: 3

How Rails jobs handle reverse geocoding

background-jobs error-handling geocoding
Intermediate 7 steps
java
@Service
public class ProductLookupService {
 
    private final ProductRepository productRepository;

How Spring caching layers a product lookup

caching cache-eviction fallback
Intermediate 8 steps
javascript
import type { MetadataRoute } from 'next'
import { db } from '@/lib/db'
 
const URLS_PER_SITEMAP = 50_000

Sharding a large sitemap in Next.js

sitemap pagination seo
Intermediate 6 steps