Code Explainers
Browse the library
typescript
type CacheEntry<V> = { value: V; computedAt: number; };
A TTL cache keyed by object identity
caching
weakmap
generics
Intermediate
8 steps
rust
use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::Path;
Streaming lines from a gzip file in Rust
iterators
io-streaming
decompression
Intermediate
6 steps
ruby
module MarkdownHelper ALLOWED_TAGS = %w[ p br strong em del a ul ol li blockquote code pre h1 h2 h3 h4 h5 h6 hr img table thead tbody tr th td
Safely rendering Markdown in a Rails helper
sanitization
markdown
security
Intermediate
8 steps
php
<?php namespace App\Services;
Validating coupons before applying a discount in Laravel
validation
guard clauses
business rules
Intermediate
7 steps
python
import functools import time from flask import current_app
Retrying deadlocked DB writes in Flask
decorators
retry
exponential-backoff
Intermediate
6 steps
go
func HandleWebhook(store WebhookStore, dispatcher *EventDispatcher) gin.HandlerFunc { return func(c *gin.Context) { body, err := c.GetRawData() if err != nil {
Building a resilient webhook handler in Gin
webhooks
dependency-injection
signature-verification
Intermediate
9 steps
ruby
class ActivityFeed include Enumerable Entry = Struct.new(:record, :type, :occurred_at, keyword_init: true) do
Building a paginated activity feed in Rails
enumerable
pagination
composition
Intermediate
9 steps
python
import time import logging from threading import Lock
Rate-limiting noisy logs in Python
throttling
thread-safety
logging
Intermediate
6 steps
php
<?php namespace App\Services\Analytics;
Building a signup chart with Laravel's query builder
aggregation
date-ranges
query-builder
Intermediate
6 steps
rust
use axum::{ async_trait, extract::FromRequestParts, http::{request::Parts, StatusCode},
A proof-of-work extractor in Axum
proof-of-work
extractors
hashing
Advanced
9 steps
typescript
import { Injectable, Scope } from '@nestjs/common'; import DataLoader from 'dataloader'; import { InjectRepository } from '@nestjs/typeorm'; import { In, Repository } from 'typeorm';
Batching queries with DataLoader in NestJS
dataloader
batching
n+1
Intermediate
7 steps
javascript
const { z, ZodError } = require('zod'); function validate(schemas) { return (req, res, next) => {
A reusable Zod validation middleware for Express
middleware
validation
schema
Intermediate
8 steps
java
public record TimeSlot(LocalDate day, LocalDateTime start, LocalDateTime end) {} public class ScheduleAnalyzer {
Detecting calendar conflicts in Java
streams
sorting
sweep-line
Intermediate
8 steps
go
func StreamLogs(c *gin.Context) { path := c.Query("file") if path == "" { c.JSON(http.StatusBadRequest, gin.H{"error": "missing file parameter"})
Streaming a live log tail with SSE in Gin
server-sent-events
streaming
channels
Advanced
10 steps
ruby
class EditorHistory MAX_DEPTH = 100 def initialize(initial = "")
How undo/redo history works in Ruby
undo-redo
state-management
immutability
Intermediate
9 steps
python
import gzip from fastapi import FastAPI, Request, Response from starlette.middleware.base import BaseHTTPMiddleware from starlette.types import ASGIApp
Custom gzip middleware in FastAPI
middleware
http-compression
content-negotiation
Intermediate
9 steps
php
<?php function streamFileWithRanges(string $path, ?string $rangeHeader): void {
How HTTP range requests stream files in PHP
http-range-requests
streaming
partial-content
Intermediate
10 steps
rust
use std::collections::HashMap; use std::sync::Arc; use axum::body::Bytes;
A concurrent webhook dispatcher in Axum
trait-objects
concurrency
shared-state
Intermediate
9 steps