Tech Notes
115 articlesEnter the same number twice and the LCM becomes 94906266.99999999
Entering the same number twice exposes it: with 94906267, 94906267 the LCM becomes 94906266.99999999. In multiply-before-divide, the intermediate value hits the limit, not the result.
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.
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.
sin(pi) returns 0.0548, not 0: degrees, radians and calculator precedence
The screen shows sin(pi) = 0.0548036651488 instead of 0. This note separates mode, expression syntax and double-precision representation, with a raw-versus-shown table and a checklist for factorials, precedence and precision limits.
Why one ad campaign shows up as two rows: UTM parameters, case and encoding
Why does one batch of campaign links produce two rows in a report? This note checks real character counts across the five utm parameters, same-name parameters overwriting rather than appending, percent-encoding bloat for Chinese and spaces, and parameter order changing the string.
What is inside the three parts of a JWT: reading header, payload and exp
Taking over a login API, a packet capture yields only three strings: when does it expire, and what does role contain? This note decodes a sample section by section, with character counts, byte counts and UTC times, and explains the difference between encoding and signing.
Which part of a URL reaches the server? Six parts, %20, + and double encoding
This note splits a URL into scheme, host, port, path, query and fragment, then uses local tests to show that fragments stay in the browser, plus signs mean spaces, and double encoding leaves percent signs after one decode.
Why the last digit of a Chinese ID is sometimes X: weighted modulo 11
Why does X appear at the end of a Chinese ID number? This note gives the full algorithm in three steps: 17 weights, modulo 11 and a lookup table, plus the boundary where a check digit catches typos but not fabrication.
How many hosts fit in a /22? Host bits, network and broadcast addresses
Why do 256 addresses support only 254 hosts? This note shows how host bits, the network address and the broadcast address subtract from the total, with a /16 to /30 block table and mask conversion method.