FIND YOUR NEXT FEW LINES

Results for “du”

Small, practical examples. Search by task or narrow things down below.

410 snippets foundClear filters
TypeScriptGetting Started

Count the items in a collection

TypeScript: Read the collection’s length instead of hard-coding the loop limit.

TypeScript✓ Tested
TypeScriptText handling & Unicode

Count Unicode code points in a string

TypeScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.

TypeScript✓ Tested
TypeScriptCollections & records

Count words using a Map

Update a keyed counter without losing its value type.

Map✓ Tested
Docker / ComposeGetting Started

Create a small file at build time

Docker / Compose: Create a small file at build time with a complete introductory Dockerfile.

Docker / Compose✓ Tested
TypeScriptArray restructuring

Create independent rows in a matrix

TypeScript: Use a mapping function to create each row instead of sharing one array with fill.

TypeScript✓ Tested
Arduino / CTiming & control

Debounce a button with a stable-time check

Accept an input change only after it stays stable for 30 ms.

debounce✓ Tested
HTMLMetadata & document links

Declare a preferred canonical URL

HTML: A canonical link identifies the preferred public URL for duplicate representations of a document.

HTML✓ Tested
TypeScriptRegular expressions & URL encoding

Decode a percent-encoded URL component

TypeScript: decodeURIComponent reverses percent encoding and throws for malformed sequences.

TypeScript✓ Tested
TypeScriptPromises & iteration protocols

Delegate iteration to another iterable

TypeScript: yield-star forwards items from another iterable while retaining generator composition.

TypeScript✓ Tested
TypeScriptTypes & functions

Describe an object with an interface

Require named fields on a reusable object shape.

interface✓ Tested
TypeScriptUTC date operations

Detect an invalid Date object

TypeScript: An invalid Date has a NaN time value.

TypeScript✓ Tested
TypeScriptNumbers & numeric validation

Detect NaN without converting the input

TypeScript: Number.isNaN tests the special numeric value instead of applying string-to-number conversion.

TypeScript✓ Tested