Code Explainers

Intermediate code explainers

java
@Service
public class PaymentGatewayClient {
 
    private static final Logger log = LoggerFactory.getLogger(PaymentGatewayClient.class);

Resilient payment calls with Spring Retry

retry backoff fault-tolerance
Intermediate 7 steps
php
<?php
 
namespace App\Models\Scopes;
 

How a tenant global scope works in Laravel

multi-tenancy global-scope query-builder
Intermediate 5 steps
go
package main
 
import (
	"net/http"

How route groups nest in Gin

routing middleware api versioning
Intermediate 6 steps
rust
use axum::{
    extract::{Query, State},
    http::StatusCode,
    Json,

Paginated, filtered product listing in Axum

pagination query-parameters sql-filtering
Intermediate 8 steps
python
from operator import itemgetter
 
 
def sort_employees(employees):

Multi-key sorting patterns in Python

sorting tuple-keys itemgetter
Intermediate 5 steps
java
public final class Debouncer<T> {
 
    private final ScheduledExecutorService scheduler =
            Executors.newSingleThreadScheduledExecutor(runnable -> {

How a debouncer collapses bursts in Java

debounce concurrency scheduling
Intermediate 9 steps
javascript
const express = require('express');
const Stripe = require('stripe');
 
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

Verifying Stripe webhooks in Express

webhooks signature-verification raw-body
Intermediate 7 steps
ruby
class Api::V1::ArticlesController < Api::V1::BaseController
  def index
    articles = Article
      .published

Building a JSON:API endpoint in Rails

serialization eager-loading pagination
Intermediate 7 steps
php
<?php
 
namespace App\Support;
 

Retry with exponential backoff in PHP

retry exponential-backoff error-handling
Intermediate 7 steps
typescript
import { inject } from '@angular/core';
import { ResolveFn, Router, ActivatedRouteSnapshot } from '@angular/router';
import { catchError, of, EMPTY } from 'rxjs';
import { Article } from './models/article';

Prefetching route data with an Angular resolver

route-resolver dependency-injection rxjs
Intermediate 6 steps
python
from itertools import islice
from typing import Iterable, Iterator, TypeVar
 
T = TypeVar("T")

Batching an iterable for bulk indexing

generators batching lazy-evaluation
Intermediate 7 steps
rust
use axum::{
    extract::FromRef,
    http::StatusCode,
    response::{IntoResponse, Redirect},

Signed cookie sessions in Axum

sessions cookies authentication
Intermediate 8 steps
java
package com.example.logs;
 
import java.io.IOException;
import java.io.UncheckedIOException;

Counting HTTP statuses with Java streams

streams regex file-io
Intermediate 6 steps
php
<?php
 
declare(strict_types=1);
 

Validating registration input with filter_var

validation sanitization filter_var
Intermediate 8 steps
typescript
interface Order {
  id: number;
  customerId: string;
  total: number;

A type-safe groupBy in TypeScript

generics reduce type-inference
Intermediate 6 steps
rust
use axum::{
    http::StatusCode,
    response::{IntoResponse, Response},
    Json,

How a custom error type maps to HTTP in Axum

error-handling enums trait-implementation
Intermediate 7 steps
java
@Service
public class GitHubClient {
 
    private final WebClient webClient;

Calling the GitHub API with Spring WebClient

reactive http-client dependency-injection
Intermediate 7 steps
javascript
import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';
import { SignJWT, jwtVerify } from 'jose';
 

JWT session cookies in a Next.js Route Handler

authentication jwt cookies
Intermediate 8 steps