Code Explainers

Beginner code explainers

java
public class SortedListMerger {
 
    public static int[] merge(int[] a, int[] b) {
        int[] result = new int[a.length + b.length];

Merging two sorted arrays in Java

two-pointers merging arrays
Beginner 6 steps
java
public final class RegistrationValidator {
 
    private static final Pattern EMAIL = Pattern.compile("^[\\w.+-]+@[\\w-]+\\.[\\w.-]+$");
    private static final Pattern USERNAME = Pattern.compile("^[a-zA-Z0-9_]{3,20}$");

Accumulating validation errors in Java

validation regex error-accumulation
Beginner 9 steps
php
<?php
 
namespace App\Http\Middleware;
 

Enforcing a JSON Accept header in Laravel

middleware content-negotiation http-headers
Beginner 5 steps
go
package handlers
 
import (
	"net/http"

Rendering HTML pages with Gin handlers

http-handlers templating error-handling
Beginner 8 steps
go
package handlers
 
import (
	"net/http"

Reading path parameters in Gin

routing path-parameters wildcards
Beginner 7 steps
python
from collections import Counter
 
 
def word_frequencies(text):

Counting things with collections.Counter

counting multiset data-structures
Beginner 8 steps
go
package geometry
 
import "fmt"
 

Implementing fmt.Stringer in Go

interfaces stringer composition
Beginner 5 steps