Code Explainers
Browse the library
typescript
interface JwtPayload { exp?: number; iat?: number; sub?: string;
Decoding a JWT to check expiry
jwt
base64url
type-guards
Intermediate
8 steps
go
package logbuffer import ( "bufio"
A buffered logger with background flushing in Go
concurrency
buffering
context
Intermediate
8 steps
python
from urllib.parse import urlparse class RobotsRules:
Parsing and applying a robots.txt file
parsing
longest-prefix-match
state-machine
Intermediate
10 steps
rust
use std::net::{IpAddr, SocketAddr}; use axum::extract::{ConnectInfo, FromRequestParts}; use axum::http::request::Parts;
How a custom ClientIp extractor works in Axum
extractor
http-headers
proxy-forwarding
Intermediate
8 steps
java
import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Currency;
A safe Money value type in Java
immutability
bigdecimal
value-object
Intermediate
10 steps
javascript
'use client'; import { useRouter } from 'next/navigation'; import Link from 'next/link';
Archiving with router.refresh in Next.js
client-component
data-mutation
transitions
Intermediate
7 steps
ruby
class ThumbnailPool def initialize(worker_count: 4, capacity: 100) @queue = SizedQueue.new(capacity) @running = true
A thread pool for thumbnail jobs in Ruby
concurrency
thread-pool
bounded-queue
Advanced
7 steps
php
<?php namespace App\Providers;
Defining feature flags with Laravel Pennant
feature-flags
service-provider
config-driven
Intermediate
6 steps
typescript
import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core'; interface Shortcut { key: string;
A keyboard shortcut directive in Angular
directives
event-handling
keyboard-shortcuts
Intermediate
9 steps
go
package handler import ( "net/http"
Custom time validation in Gin
validation
request-binding
struct-tags
Intermediate
8 steps
python
from pathlib import Path from django.contrib.auth.decorators import login_required from django.http import FileResponse, Http404, HttpResponseForbidden
Serving files with access checks in Django
authorization
http-caching
file-serving
Intermediate
7 steps
rust
use once_cell::sync::Lazy; use regex::Regex; static LOG_LINE: Lazy<Regex> = Lazy::new(|| {
Parsing access logs with a lazy regex in Rust
regex
lazy-initialization
parsing
Intermediate
7 steps
java
public class RequestCoalescer<K, V> { private final ConcurrentHashMap<K, CompletableFuture<V>> inFlight = new ConcurrentHashMap<>(); private final Function<K, V> loader;
Coalescing duplicate requests in Java
concurrency
caching
completablefuture
Advanced
6 steps
javascript
import { useState, useRef, useCallback } from "react"; export function MultiSelect({ options, value, onChange, placeholder = "Select…" }) { const [open, setOpen] = useState(false);
Building a keyboard-accessible MultiSelect in React
controlled-component
accessibility
keyboard-navigation
Intermediate
10 steps
java
public final class NaturalOrderComparator implements Comparator<String> { public static final NaturalOrderComparator INSTANCE = new NaturalOrderComparator();
Natural-order string sorting in Java
comparator
natural-sort
string-parsing
Intermediate
9 steps
rust
use axum::{ extract::State, response::sse::{Event, KeepAlive, Sse}, Json,
Proxying an SSE chat stream in Axum
server-sent-events
streaming
async-generators
Advanced
10 steps
go
package middleware import ( "net/http"
Localized validation errors in Gin
middleware
internationalization
validation
Intermediate
8 steps
php
<?php namespace App\Http\Controllers;
Email confirmation with signed URLs in Laravel
signed-urls
email-verification
middleware
Intermediate
6 steps