Tags

Every post, snippet, cheatsheet and project — searchable, filterable, and sortable by tag or tool.

  • Two Writes, One Row: Who Wins?

    Post · Sep 26, 2026

    Two requests read the same row, both do their maths, both write back. One of them silently disappears. How the system should resolve that isn't one answer: it depends on whether the write is a delta, a quick piece of logic, or a human edit made minutes after the read.

  • Your Logging Sucks!

    Post · Sep 23, 2026

    A checkout endpoint with a log line at every step looks like good observability, right up until a customer says "my payment failed" and you have thirteen unrelated lines from thirteen unrelated requests to sort through. The fix isn't more logs, it's one wide event per request instead.

  • What Breaks From 1k to 1M Requests Per Second

    Post · Sep 17, 2026

    The same endpoint, run through four traffic tiers. At 1k req/s almost any design survives. At 10k the database and the single instance give first. At 100k the cache and the load balancer become the systems under test. At 1M the architecture itself has to change, because the failure mode is no longer capacity, it's correlated behavior across clients you don't control.

  • Migrating Schema-Per-Tenant Databases at Scale

    Post · Sep 12, 2026

    Choosing physical tenant isolation over a shared, RLS-scoped schema buys two new problems: knowing where a tenant's data actually lives, and running one migration correctly hundreds of times instead of once. Neither has an app-code fix, both need their own infrastructure.

  • Designing Multi-Tenant APIs That Scale

    Post · Sep 12, 2026

    A missing tenant filter is a data leak, not a crash. Row-level security fixes that structurally, but rate limits, connection pools, and error codes built for one instance break the same quiet way once the API runs as several.

  • Why Payment Retries Need Idempotency

    Post · Sep 11, 2026

    A plain payment endpoint looks correct until you trace what a double-click, a timed-out request, or a redelivered webhook actually does to it. Each one turns one payment into two. Idempotency keys are the fix, at two layers most write-ups skip.

  • Building a Typed Fetch Factory

    Post · Aug 25, 2026

    How a single createFetcher factory infers request/response types from an OpenAPI schema and layers in caching, retries, and cancellation, and why each piece is built the way it is.

  • Hashing and the Birthday Paradox

    Post · Aug 19, 2026

    A hash space that looks astronomically large can still produce collisions with a surprisingly small number of items, the same math behind the birthday paradox, applied to hashing.

  • Valid Triangle Number

    Post · Aug 15, 2026

    Sort the side lengths, fix the largest one at a time, and let the gap between two pointers count every valid pair against it in one step instead of testing them one by one.

  • 3Sum

    Post · Aug 14, 2026

    Sort the array, fix one value as a moving target, and reuse the exact two-pointer proof from Two Sum II to sweep the rest, with a couple of extra duplicate-skipping rules layered on top.

  • Two Sum II

    Post · Aug 13, 2026

    A sorted array, two pointers closing in from both ends, and a proof that whichever side is off-target can be ruled out entirely rather than retried against a smaller search space.

  • Container With Most Water

    Post · Aug 12, 2026

    A row of walls, two pointers starting at the widest container, and a proof that moving the taller wall can never beat what you already have, so only the shorter side is ever worth moving.

  • Two Pointers

    Post · Aug 11, 2026

    Two indices walking through one ordered structure, discarding the side that cannot improve the answer at every step and replacing a nested loop with a single pass.

  • AI Without Losing Judgment

    Post · Mar 17, 2026

    AI can speed up delivery, but engineers still own architecture, quality, and decisions. A simple workflow to ship faster without outsourcing judgment.

  • Plan for 2026

    Post · Jan 1, 2026

    It's 2026, and I'm still working as a Senior Software Engineer, setting some ambitious goals for myself and writing about it as tech keeps changing under our feet.

  • Disecting my portfolio

    Post · Apr 12, 2025

    It took me 3 years to build my portfolio. The process was bitter yet rewarding. Learnt many things and adopted good habbits.

  • 👋 Hello!

    Post · Apr 6, 2025

    The name's Nas. Software Engineer based in UK, with Computer Science degree from King's College London University.

  • Wide Event Logger

    Snippet · Sep 23, 2026

    A tiny `createEvent(name, seed)` that accumulates fields over the life of a request via `.set()` and emits exactly one structured log line via `.emit()`, so a request that touches ten steps still produces one row instead of ten.

  • Retry with Backoff & Jitter

    Snippet · Sep 1, 2026

    A generic `retry(task, options)` that re-runs a failing async task with exponential backoff and full jitter, an optional `shouldRetry` predicate, and a cap on any single delay.

  • Typed Event Emitter

    Snippet · Sep 1, 2026

    A ~20-line pub/sub where the event names and each event's payload type come from one map, so `on` and `emit` are fully checked against it and `on` returns its own unsubscribe.

  • assertNever

    Snippet · Sep 1, 2026

    A one-line helper that makes a `switch` over a discriminated union a compile error the moment a case is added and left unhandled, with a runtime throw as the safety net for data that violated the types at the edges.

  • Result & tryCatch

    Snippet · Sep 1, 2026

    A `Result<T, E>` union plus `tryCatch` wrappers that turn a throwing call into a value the caller has to inspect: the failure path becomes part of the return type instead of an invisible jump.

  • useLocalStorage

    Snippet · Sep 1, 2026

    A `localStorage`-backed `useState` built on `useSyncExternalStore`: no hydration mismatch under SSR, live updates when another tab writes, and live updates when another hook on the same page writes.

  • useControllableState

    Snippet · Sep 1, 2026

    One hook that lets a component be driven from outside (`value` + `onChange`) or manage its own state (`defaultValue`), the same two-mode contract a native `<input>` has, while the component body only ever reads one value and calls one setter.

  • A Readable useToggle

    Snippet · Sep 1, 2026

    A boolean `useState` that hands back `on` / `off` / `toggle` instead of a raw setter, so call sites read as intent. Every function, and the controls object itself, stays referentially stable, safe to pass as props or list as effect dependencies without retriggering anything downstream.

  • Typed Fetch Factory

    Snippet · Aug 25, 2026

    A reusable fetch factory that infers request/response types from an OpenAPI schema and adds in-memory caching, retry with backoff, and AbortController support, no per-endpoint boilerplate, no `any`.

  • Instrument a Service with Wide Events

    Cheatsheet · Sep 23, 2026

    You're about to add logging to a new service, or you're staring at an existing one where every incident turns into a grep-and-guess session across a dozen disconnected log lines. Replace the step-by-step logs with one wide event per request.

  • Cut a Slow N+1 Query Down

    Cheatsheet · Sep 18, 2026

    An endpoint that queries once per parent row instead of once per request looks fine with ten rows and falls over with ten thousand. Batch the per-row lookups into one query and the round trips disappear.

  • Pick a Rendering Strategy for a Next.js Route

    Cheatsheet · Sep 1, 2026

    An App Router route is prerendered by default and silently turns dynamic the moment you read something request-specific. Knowing which bucket a route belongs in (and what forces it out) is the difference between an instant page and a server render on every hit.

  • Make a Write Endpoint Safely Retryable

    Cheatsheet · Sep 1, 2026

    A client that retries a POST after a timeout can create the resource twice or charge a card twice. An idempotency key lets the server spot the retry and replay the first response instead of doing the work again.

  • First 15 Minutes of a Prod Incident

    Cheatsheet · Sep 1, 2026

    Something's on fire in production and you're the one holding it. Your job for the next fifteen minutes is to shrink the impact and coordinate the response, not to find the root cause.

  • Keep an AI Agent Grounded While It Builds a Feature

    Cheatsheet · Aug 26, 2026

    An AI agent produces plausible, well-formatted code that quietly drifts from what was asked. The fix is a loop with a durable spec: a real GitHub issue the agent must reference, and a two-axis review (standards vs. spec) that runs against it before the PR opens.

  • itsnas.me (external site)

    Project · Jan 12, 2025