Code Explainers
Browse the library
go
package webhooks import ( "crypto/hmac"
Verifying GitHub webhooks in Gin
hmac
webhooks
middleware
Intermediate
6 steps
rust
use std::time::Duration; use axum::{routing::get, Router}; use tokio::net::TcpListener;
Graceful shutdown in an Axum server
graceful-shutdown
signal-handling
async
Intermediate
8 steps
python
from django.db import models from django.utils import timezone
How soft deletes work in Django
soft-delete
querysets
managers
Intermediate
10 steps
php
class PostController extends Controller { public function index(Request $request): AnonymousResourceCollection {
Filtered, paginated JSON APIs in Laravel
eloquent
query-builder
api-resources
Intermediate
8 steps
javascript
import { useState, useEffect, useMemo } from 'react'; function useDebounce(value, delay = 300) { const [debounced, setDebounced] = useState(value);
Debounced search with cancellation in React
custom-hooks
debounce
abortcontroller
Intermediate
9 steps
java
package com.example.payments.config; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank;
Type-safe config with Spring records
configuration
validation
records
Intermediate
6 steps
ruby
module SoftDeletable extend ActiveSupport::Concern included do
How a soft-delete concern works in Rails
concerns
soft-delete
scopes
Intermediate
8 steps
typescript
type CloneInput = Record<string, unknown> | unknown[] | Map<unknown, unknown> | Set<unknown>; export function deepClone<T>(value: T): T { if (typeof structuredClone === "function") {
Building a deepClone with cycle safety
recursion
deep-copy
cycle-detection
Intermediate
8 steps
rust
use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::Path;
Buffered log scanning in Rust
buffered-io
error-handling
streaming
Intermediate
9 steps
python
from functools import wraps def memoize(func):
Building a memoize decorator in Python
decorators
closures
memoization
Intermediate
5 steps
php
<?php namespace App\Support;
Grouping records with array_reduce in PHP
array-reduce
grouping
higher-order-functions
Intermediate
6 steps
java
@Component public class RequestTimingInterceptor implements HandlerInterceptor { private static final Logger log = LoggerFactory.getLogger(RequestTimingInterceptor.class);
How a Spring HandlerInterceptor times requests
interceptor
request-lifecycle
logging
Intermediate
6 steps
ruby
class Post < ApplicationRecord before_validation :generate_slug, on: :create validates :slug, presence: true, uniqueness: true
How a Rails model builds unique slugs
slugs
callbacks
validations
Intermediate
7 steps
go
package middleware import ( "errors"
Centralized error handling in Gin
middleware
error-handling
custom-errors
Intermediate
8 steps
typescript
import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, shareReplay } from 'rxjs';
Caching HTTP config in an Angular service
caching
observables
dependency-injection
Intermediate
6 steps
rust
use axum::{ extract::{Path, State}, routing::{get, post}, Json, Router,
Building a nested REST API router in Axum
routing
extractors
shared-state
Intermediate
8 steps
python
import os import tempfile from pathlib import Path from typing import Union
How atomic file writes work in Python
atomicity
filesystem
durability
Advanced
7 steps
php
<?php namespace App\Console;
How task scheduling works in Laravel
scheduling
cron
fluent-api
Intermediate
7 steps