Code Explainers
Browse the library
javascript
const express = require('express'); const multer = require('multer'); const path = require('path'); const crypto = require('crypto');
Safe image uploads with Multer in Express
file-upload
multer
validation
Intermediate
7 steps
go
type PostCursor struct { CreatedAt time.Time ID int64 }
Keyset pagination with cursors in Go
pagination
keyset-cursor
database
Intermediate
8 steps
java
@Configuration @EnableWebSecurity public class ResourceServerConfig {
Configuring a JWT resource server in Spring
oauth2
jwt
authorization
Intermediate
8 steps
ruby
require "openssl" require "json" require "base64"
Building signed session tokens in Ruby
hmac
authentication
cryptography
Intermediate
8 steps
php
<?php namespace App\Http\Requests;
A validated date-range value object in PHP
value-object
validation
immutability
Intermediate
7 steps
python
import wave import os from dataclasses import dataclass
Reading WAV metadata into a dataclass
dataclass
audio
file-io
Beginner
5 steps
rust
use std::collections::VecDeque; #[derive(Debug)] pub struct Hunk {
Applying a diff hunk in Rust
enums
error-handling
pattern-matching
Intermediate
8 steps
typescript
import { Component, input, computed } from '@angular/core'; function toNumber(value: number | string): number { return typeof value === 'number' ? value : parseFloat(value);
Signal inputs and computed in Angular
signals
reactivity
derived-state
Intermediate
5 steps
javascript
const express = require('express'); const jwt = require('jsonwebtoken'); const crypto = require('crypto');
Refresh token rotation in Express
jwt
token-rotation
authentication
Advanced
9 steps
go
package config import ( "fmt"
Parsing timeout config in Go
configuration
validation
error-wrapping
Intermediate
7 steps
java
@Configuration public class OrderConsumerConfig { @Bean
Wiring a resilient Kafka consumer in Spring
kafka
deserialization
error-handling
Intermediate
8 steps
ruby
class Product < ApplicationRecord belongs_to :category, touch: true has_many :reviews, dependent: :destroy
How Rails models wire up associations
active record
associations
validations
Intermediate
7 steps
typescript
import sanitizeHtml from "sanitize-html"; interface RichTextOptions { allowImages?: boolean;
Building a configurable HTML sanitizer allowlist
sanitization
xss-prevention
allowlist
Intermediate
7 steps
go
func (h *WebhookHandler) HandleBatch(c *gin.Context) { var payload BatchWebhookPayload if err := c.ShouldBindJSON(&payload); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "invalid payload"})
Handling batched webhooks in Gin
webhooks
signature-verification
job-queue
Intermediate
7 steps
ruby
require "net/http" require "json" require "uri" require "base64"
Paginating an HTTP API with a Ruby enumerator
pagination
http
enumerator
Intermediate
7 steps
javascript
class StarRating { constructor(container, { max = 5, value = 0, onChange } = {}) { this.container = container; this.max = max;
Building an accessible star-rating widget
dom
event-handling
accessibility
Intermediate
7 steps
python
from pathlib import Path from collections import defaultdict from PIL import Image
Finding near-duplicate images by perceptual hash
perceptual-hashing
clustering
hamming-distance
Intermediate
9 steps
rust
use axum::{ body::Body, http::{Method, StatusCode, Uri}, response::{IntoResponse, Response},
Nesting routers and JSON fallbacks in Axum
routing
http
json-responses
Intermediate
7 steps