Code Snippet
A production function displayed in a mono bg-muted editor panel with a filename tab, gutter line numbers, and a caption explaining the technical tradeoff the snippet demonstrates.
A production function displayed in a mono bg-muted editor panel with a filename tab, gutter line numbers, and a caption explaining the technical tradeoff the snippet demonstrates.
The Portfolio Collection unlocks the source for every Portfolio block. All Access unlocks every Collection.
Already purchased? Log in
Code Snippet presents a single production function in a full-width bg-muted panel styled like an editor window, with a filename tab (src/lib/rate-limit.ts), traffic-light dots, a language label, and gutter line numbers. The shipped snippet is a sliding-window rate limiter using a Redis sorted set and an atomic Lua script; the caption below the panel explains what it demonstrates: keeping the check-and-increment as a single round trip so it works correctly under concurrent load.
The snippet is a const object with a lines array; the panel is theme-token only, no syntax-color literals. The caption is the critical third element: a code block without commentary forces the reader to evaluate the code themselves.
Reach for this block when a developer portfolio needs a concrete technical proof point, one piece of production code that shows how you approach correctness and performance at the edges. The installer swaps the filename, language label, lines array, and caption with their own snippet.
A natural flow around it on a Portfolio Pro page:
Before
After
One strong use is the production utility function showcase. Other snippet uses:
Tip: the caption carries as much weight as the code; a snippet without a sentence about the tradeoff it solves is just showing off syntax.