📝 Notes

93 articles

Shuffling with a random sort comparator is already unfair

To decide speaking order, picking one item from the remaining positions each time is uniform; giving a sort a random comparator does not even fix the number of comparisons. Enumerating every path quantifies the bias: with four elements the most and least likely outcomes differ by 12 times.

Two gallons, two horsepower ratings, two byte prefixes: ask which one first

US and imperial gallons, hp and PS, mmHg and Torr, KB and KiB are four pairs of units with the same name but different definitions. Pin down which one applies before converting; even the number of displayed digits is not always eight.

Extensions start at the last dot: why LICENSE, .gitignore and archive.tar.gz get missed

An extension is defined by the last dot: in a 27-line sample, UPPER changed 11 lines, lower 9 and Title 19; LICENSE and .gitignore came back untouched, archive.tar.gz only changed the gz, and paths could also rename directories.

SOS is 9 tones, the full alphabet is 104: how Morse timing is calculated

How the dot-to-dash ratio becomes milliseconds: the 1200 divided by speed formula, tone counts and durations for four samples, and three places where the code table and page copy disagree.

Batch folder scripts: zero-padding and CON are the two easiest traps to miss

For the same 150-line list, BAT produces 157 lines and 3,544 bytes while PowerShell produces 156 lines and 11,049 bytes. Zero-padding with too few digits avoids name collisions, while CON goes straight into the script unchanged.

One Chinese sentence: 12 bytes in UTF-8, 8 in GBK, and how encoding gets misjudged

The detection chain has just four steps: BOM, strict UTF-8 decode, strict GBK decode and fallback. Shift-JIS bytes that are also valid GBK get read as Chinese; three other measures are byte count, UTF-16 code units and line count, and the 50,000-paragraph render limit arrives before the size limit.

JSON exported to CSV loses a column in Excel: header union and flattening

Exporting API JSON to CSV: the header is the union of all record keys, nested objects collapse into [object Object] unless flattening is enabled, and the 3 BOM bytes are only added on the download path.

The User-Agent in your server logs: which fields are self-reported

Reading one UA line from an Nginx log: 32 browser entries, 21 crawler entries and 34 highlight entries each take the first match in order; engine and client are separate axes; only 7 NT mappings hit; and there are samples of fake spiders and uppercase bare-substring false positives.

What does a weight of 30 mean on a spinner? Sector angles and draws with or without replacement

What chance does a weight of 30 really represent? Starting from a total weight of 60, this note covers proportions, sector angles and frequencies from 300,000 simulated draws, then separates with-replacement and without-replacement probabilities and lists the input parsing rules.

Why white text on gradients is hard to read: checking WCAG contrast at every stop

White text on a gradient looks weak when one colour stop fails the contrast threshold. This note calculates white and black ratios at every stop, compares six output strings and three colour notations, and shows whether to change the text colour or add a midpoint stop.

Born on 29 February: which day you turn 18 in a common year

Born on 29 February, which day counts as your 18th birthday in a common year? Using a calculation date of 2026-10-21, this note sets full age, nominal age, total days and two anniversary conventions side by side, then explains leap-year rules and why the page uses 4 February for the zodiac sign.

What pace does a 3:30 marathon need? Nine segments, negative splits and the floor pace

A 3:30:00 marathon goal reduced to just run 5:00 per km? This note lists nine 5 km segments with progressive paces, segment and cumulative times, the first-half and second-half difference, and the extra seconds when segments get so short that pace hits its floor, all matching the page display conventions.

Previous 1 2 3 ... ... 7 Next