Code Explainers
Intermediate code explainers
python
import json import logging import stripe
Handling Stripe webhooks in Django
webhooks
signature-verification
idempotency
Intermediate
7 steps
javascript
import { useState, useEffect, useCallback, useRef } from "react"; export function usePersistentForm(storageKey, initialValues) { const [values, setValues] = useState(() => {
A React hook that persists form state to localStorage
custom-hooks
localstorage
debounce
Intermediate
9 steps
rust
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; use serde::{Deserialize, Serialize}; use uuid::Uuid;
Building a typed create_user handler in Axum
serde
extractors
sqlx
Intermediate
7 steps
java
@Component public class JwtAuthenticationFilter extends OncePerRequestFilter { private final JwtTokenProvider tokenProvider;
How a JWT auth filter works in Spring
authentication
jwt
servlet-filter
Intermediate
8 steps
typescript
function throttle<T extends (...args: any[]) => void>( fn: T, limit: number ): (...args: Parameters<T>) => void {
Building a trailing-edge throttle in TypeScript
throttling
closures
generics
Intermediate
7 steps
go
package store import ( "database/sql"
Wrapping and inspecting errors in Go
error-handling
error-wrapping
sentinel-errors
Intermediate
8 steps
php
<?php namespace App\Support;
Building a URL slug from any title in PHP
regex
transliteration
string-processing
Intermediate
8 steps
python
from collections import deque class RollingAverage:
A rolling average over a fixed window
sliding-window
running-sum
deque
Intermediate
7 steps
javascript
function groupBy(items, keySelector) { const resolveKey = typeof keySelector === 'function' ? keySelector : (item) => item[keySelector];
Building a flexible groupBy in JavaScript
higher-order-functions
reduce
data-transformation
Intermediate
6 steps
typescript
interface TokenBucketOptions { capacity: number; refillPerSecond: number; }
How a token bucket rate limiter works
rate-limiting
token-bucket
lazy-evaluation
Intermediate
7 steps
go
package main import ( "context"
Graceful HTTP shutdown in Go
graceful-shutdown
signals
goroutines
Intermediate
8 steps
php
<?php declare(strict_types=1);
Streaming file lines with a PHP generator
generators
lazy-evaluation
file-io
Intermediate
7 steps
ruby
class SessionsController < ApplicationController MAX_ATTEMPTS = 5 THROTTLE_WINDOW = 15.minutes
Throttling failed logins in Rails
rate-limiting
authentication
caching
Intermediate
7 steps
python
from collections import OrderedDict from typing import Callable, Hashable, Iterable, Iterator, TypeVar T = TypeVar("T")
Two ways to dedupe while keeping order
deduplication
generators
ordered-data
Intermediate
7 steps
javascript
function makeReorderableList(listEl, onReorder) { let draggedItem = null; listEl.addEventListener('dragstart', (e) => {
Drag-to-reorder lists with the HTML5 drag API
drag-and-drop
event-delegation
dom-manipulation
Intermediate
8 steps
go
package handlers type SignupRequest struct { Email string `json:"email" binding:"required,email"`
Validated signup handler in Gin
request validation
error handling
http status codes
Intermediate
7 steps
rust
use std::net::SocketAddr; use std::time::Duration; use axum::{routing::get, Json, Router};
Per-IP rate limiting in Axum with tower-governor
rate-limiting
middleware
tower
Intermediate
7 steps
php
<?php namespace App\Providers;
Binding a payment gateway in Laravel
dependency-injection
service-container
interface-binding
Intermediate
7 steps