More from Nelson's Weblog
I took an amazing trip to SE Asia last month, including Angkor Wat. I had a hard time finding good reading or other resources to learn from before I went, in part because Amazon is awash in AI garbage. Here’s some books and podcasts I found useful about the Khmer empire in general and Angkor in particular: Ancient Angkor by Michael Freeman and Claude Jacques. The closest thing to a coffee-table book to preview what you will see. The practical information is outdated but the pictures and descriptions are good. Empire Podcast #185: The God Kings of Angkor Wat by William Dalrymple and Anita Anand. An entertaining and fully detailed account of the Khmer empire. It’s basically an excerpt from Dalrymple’s new book The Golden Road: How Ancient India Transformed the World. Fall of Civilizations Podcast #5: The Khmer Empire by Paul Cooper. Another history, not quite as magically well told as Dalrymple but full of good information. Angkor and the Khmer Civilization by Michael D. Coe. A highly recommended history of the Khmer region. Honestly I found this very dry and too detailed, but I did learn from it. Lonely Planet Pocket Guide: Siem Reap & the Temples of Angkor. We didn’t use this much but it seemed like a useful practical guide. OTOH it dates to 2018 so things have changed. My other advice for visiting Siem Reap and Angkor is: go. It is amazing. Plan for at least two full days of touristing there. Hire a private guide and driver if you can, it is absolutely worth it. (Email me for a recommendation.)
I’ve been doing Dry January this year. One thing I missed was something for apéro hour, a beverage to mark the start of the evening. Something complex and maybe bitter, not like a drink you’d have with lunch. I found some good options. Ghia sodas are my favorite. Ghia is an NA apéritif based on grape juice but with enough bitterness (gentian) and sourness (yuzu) to be interesting. You can buy a bottle and mix it with soda yourself but I like the little cans with extra flavoring. The Ginger and the Sumac & Chili are both great. Another thing I like are low-sugar fancy soda pops. Not diet drinks, they still have a little sugar, but typically 50 calories a can. De La Calle Tepache is my favorite. Fermented pineapple is delicious and they have some fun flavors. Culture Pop is also good. A friend gave me the Zero book, a drinks cookbook from the fancy restaurant Alinea. This book is a little aspirational but the recipes are doable, it’s just a lot of labor. Very fancy high end drink mixing, really beautiful flavor ideas. The only thing I made was their gin substitute (mostly junipers extracted in glycerin) and it was too sweet for me. Need to find the right use for it, a martini definitely ain’t it. An easier homemade drink is this Nonalcoholic Dirty Lemon Tonic. It’s basically a lemonade heavily flavored with salted preserved lemons, then mixed with tonic. I love the complexity and freshness of this drink and enjoy it on its own merits. Finally, non-alcoholic beer has gotten a lot better in the last few years thanks to manufacturing innovations. I’ve been enjoying NA Black Butte Porter, Stella Artois 0.0, Heineken 0.0. They basically all taste just like their alcoholic uncles, no compromise. One thing to note about non-alcoholic substitutes is they are not cheap. They’ve become a big high end business. Expect to pay the same for an NA drink as one with alcohol even though they aren’t taxed nearly as much.
The Trump administration has made aggressive threats against immigrants in the US. It’s not clear what’s coming, my biggest fear is a violent display of fascism. (Don’t call them camps!) But even if it’s a polite legal process it will be chaotic and disruptive to many neighbors. Back in 2018 I donated reactively to the Trump administration’s cruelty to immigrant families. This time I’m trying to get ahead of it. The need for the money is now, no matter what happens it is going to be a bad few years for immigrants in the US. To that end I asked on Metafilter about charities to donate to. I got back a remarkable reply listing 18 charities that all have some California focus. I donated to most of them. I want to highlight two groups in particular. One is RAICES. They work in Texas, not California, but they are well organized and effective. The other is KIND. They have a simple mission. They try to ensure every unaccompanied minor has legal representation in immigration court (something not guaranteed.) The other groups on the list are all also deserving of consideration.
LLMs are good search helpers. Here’s three search tools I use every day. All of these use an AI to synthesize answers but also provide an essential feature: specific web search results for you to verify and further research. I use these for conversational inquiries in addition to more traditional keyword searches. Phind is an excellent free LLM + search engine. The AI writes an answer to your query but is very careful to provide footnotes to a web-search-like list of links on the right. I use this mostly for directed search queries, things like “what’s an inexpensive TV streaming device?” where I might have used keyword search too. The Llama-70b LLM that powers the free version is quite good, sometimes I have general conversations with it or ask it to generate code. Bing CoPilot has a very similar output result to Phind. I find it a little less useful and the search result links are less prominent. But it’s a good second opinion. Bing has been a very good search engine for 10+ years, I’m grateful to Microsoft for continuing to invest in it. CoPilot results are sometimes volunteered on the main Bing page but you often have to click to get to the ChatGPT 4 Turbo enhanced pages. Kagi is what I use as my general search engine, my Google replacement. It mostly gives traditional keyword search results but sometimes it will volunteer a “Quick Answer” where Claude 3 Haiku synthesizes an answer with references. You can also request one. I think Phind and CoPilot do a better job but I appreciate when Kagi intercepts a keyword search I did and just gives me the right answer. Google has tried various versions of LLM-enhancement in search, I think the current version is called AI Overviews. It’s not bad but it’s also not as good as the others. Not mentioned here: ChatGPT or Claude. Those are general purpose LLMs but they don’t really give search results or specific references. In the old days they’d make up URLs if you asked but that’s improving.
8BitDo makes good game controllers. A wide variety of styles from retro to mainstream, with some unusual shapes. And wide compatibility with various systems: PC, Macs, Switch, Android. They’re well built, work right, and quite inexpensive. A far cry from the MadCatz-style junk we used to get. The new hotness is the Ultimate 2C, an Xbox-style wireless controller for the very low price of $30. But it works great, doesn’t feel cheap at all. The fancier mainstream choice is the Ultimate 2.4g at $50 which includes a charging stand and extra reprogrammability. But what’s really interesting to me are the odd layouts, often small or retro. The SN30 Pro is particularly interesting as a portable controller. SNES-styling but a full XBox style modern controller with two analog sticks, easy to throw in a suitcase. There’s a lot of fiddly details for this class of device. Controller type (XInput, DInput, switch, etc), wireless interface (Bluetooth or proprietary), etc. 8BitDo makes good choices and implementations for all that stuff I’ve tested. They seem to work well with Steam. They’re a popular brand so well tested. It helps that PC game controllers have mostly standardized around the Xbox layout and XInput. Steam can patch over any rough spots for older games.
More in programming
by Roy Keur The hidden attribute has always been an odd way of hiding elements. It allows a developer to hide elements with HTML and this by itself has been a source of debate since it was introduced. A couple of years ago, this attribute was already discussed over here, but what has been predicted as the future has turned into a reality today. hidden is no longer truly hidden since the introduction of until-found as a new value for this attribute. From the beginning, we were promised in the specs that when you add hidden to an element, you make it hidden from all presentations. Since until-found has been implemented, I feel a bit lied to, as this new value seems to break that promise. I would say it is a good idea to revisit this nefarious attribute to see what has actually changed and what we can learn from it. Hiding important content with display:none (and hidden) has shortcomings Let's start with a brief reminder of why hidden="until-found" was introduced in the first place. The very basics are that hidden applies display: none to an element, as defined in the user agent stylesheet, but using display: none can lead to some shortcomings. Some years ago, various news media found it a good idea to cut stories on their websites in two parts by inserting a 'Continue reading' button at some point in their articles, especially on mobile devices. Below is a simplified snippet of how this concept is applied today: <p> You could either take a boat or fly to Lorem Ipsum Island, but the flights are all cancelled due to a lack of available aircraft, so you will have to take a boat. </p> <button type="button" aria-expanded="false"> Continue reading this article </button> <p data-readmore-hidden="1" style="display: none;"> You can either use a catamaran, which takes one hour and fifteen minutes with departure time at 11:30, or take the slower cruise ship which takes two hours and 30 minutes, with departure time at 9:30. </p> Note: the original code in this snippet uses display: none, not hidden, and I have retained this. In the chapter about the specs later on, I will discuss why display: none might indeed be a better choice than hidden in this context. If you want to search for "departure time" in this snippet, you have got two choices: either read the whole article or use the in-browser find-in-page functionality that can for instance be triggered by pressing CMD+F or CTRL+F on a keyboard. If you try to use find-in-page, however, you will get zero (0) results. Why? If you hide content with display: none, you render it not only invisible and inaccessible to the user, but also to the user agent and that is what tries to search for any matches. What also will not work with hidden content is linking to a page anchor (think of website.test/some-page#paragraph-1) and using text fragments in the URL to highlight text (think of website.test/some-page#:~:text=departure%20time). How hidden="until-found" fixes these shortcomings To make hidden content searchable by the user agent, we can now use hidden="until-found", which uses content-visibility: hidden instead of display: none. By using content-visibility, the element keeps its box, but its contents are not rendered, and the browser retains its state (for example, scroll positions) instead of throwing it away like display: none does. It allows a browser to tell content that should really be hidden apart from content that is hidden but should still be searchable. Note: just using content-visibility on an element by itself does not make the element searchable. Using hidden="until-found" does. Also, it is worth mentioning that using until-found still does not make content available to screen readers: hidden is meant to hide content from all presentations (see below) and a user agent is not a presentation. In practice, hidden="until-found" works like this: when a user searches for a term with find-in-page or text fragments, the browser searches through all searchable content. In case of a match, the browser triggers an associated beforematch event on the element that contains the match and hidden="until-found" will be removed from the element, before scrolling to the newly revealed match. The removed attribute will not be re-added to the element, even when closing find-in-page, so the element will not be hidden again in the currently active browser session. Notes on what specs state about hidden The specs state the following about the hidden attribute: "if something is marked hidden, it is hidden from all presentations, including, for instance, screen readers". It is fairly strict on what you should use hidden for. Using hidden on elements that "could legitimately be shown in another presentation" (for example, in a tabs pattern) is deemed 'incorrect' because "the tabbed interface is merely a kind of overflow presentation", explaining you could "equally well" have "one big page with a scrollbar". I tend to agree with the principle of this statement from a vision of "(information on) the internet should be available to all" and "important information should not be hidden anyway", but what if when we do want to temporarily hide content? We should apparently not use hidden, but should we also not use display: none since that is essentially what hidden does? That would be strange, as we all use display: none to hide elements in all kinds of use-cases, such as this previous snippet, but also accordions, tabs, header navigation menus, etc. Even a closed native <dialog> uses display: none internally. Is that supposed to be different, then? The mysterious Hidden state Interestingly, the specs also state (no pun intended) this: "User agents should not render elements that are in the Hidden state". This state is what sets hidden apart from display: none semantically: applying display: none to an element does not give an element the Hidden state. This Hidden state is only relevant for the browser, as it is the browser that uses this state to determine the relevance of the content. A user will not notice the visible difference between hidden and display: none. There can be cases, however, where states do get relevant for the user. I will talk about such a case in the final chapter of this article. So, elements with the hidden attribute get the Hidden state, but didn't until-found explicitly enable user agents to actually make elements visible? Perhaps surprisingly, elements with hidden="until-found" do not get the Hidden state. Instead, a special Hidden Until Found state is introduced, which allows an element to be accessible to find-in-page and fragment navigation, although conditionally an element "needs to be affected by layout containment" (essentially if display is not none, contents or inline). It appears hidden="until-found" is more different from hidden than I thought. Comparison with <details> hidden="until-found" works similarly to <details>. Both use content-visibility to hide content. However, <details> was not meant to work like this when it was introduced. Its original purpose was simply to allow a user to toggle the visibility of content without having to resort to using JavaScript or CSS and its original implementation worked with a display: none toggle too. Only when content-visibility arrived in browsers was display: none replaced by it. Notable differences to hidden="until-found" are that you will be able to collapse <details> natively after a match has caused it to expand and <details> has user interface additions like a (native) marker, suggesting there is hidden content to expand, while hidden="until-found" does not give any visual clues. An accordion use-case with hidden="until-found" Let us make an accordion where we can search in collapsed content, using hidden="until-found". As a base, we can take this Accordion Example in the ARIA Authoring Practices Guide. That example already makes use of hidden="" – the attribute the specs kind of told us not to use here! – to hide content, so to make the content available for find-in-page is as simple as adding until-found as a value to that same attribute. Consider the following HTML snippet, where JavaScript has been omitted for brevity: <div id="accordionGroup" class="accordion"> <h3> <button type="button" aria-expanded="false" class="accordion-trigger" aria-controls="sect1" id="accordion1id"> <span class="accordion-title"> Some title <span class="accordion-icon"></span> </span> </button> </h3> <div id="sect1" role="region" aria-labelledby="accordion1id" class="accordion-panel" hidden="until-found"> Some hidden content. </div> </div> Here we manage to more or less replicate <details>, as we can expand the content by searching inside the hidden content, while also being able to collapse it, but there are notable differences. Firstly, headings keep their semantic meaning consistently. <details> has a limitation Scott O'Hara elaborates on in more detail, but the core issue here is that when you place a heading inside the compulsory <summary>, browsers and screen readers could interpret this heading as presentational, which messes up the intended semantics of the page. Secondly, we do need JavaScript to control the visibility state of the content and the state of aria-expanded. Using JavaScript allows us to let hidden="until-found" truly shine here, as we can listen for the beforematch event to fire and use that to toggle the visibility state. Interestingly, just like how you can't just place content-visibility: hidden somewhere and an element will be searchable for the user agent, you cannot just place a beforematch event listener on an element with visually clipped content and expect it to fire. You must use hidden="until-found" for this to work. About browser support Chromium has shipped hidden="until-found" since 2022 (Chrome 102), Firefox followed in February 2026 (Firefox 148), and Safari 26.2 (December 2025) shipped it as well, together with the beforematch event. Safari's support still counts as partial because it does not yet scroll to the revealed match (WebKit bug 304174). If a browser does not support until-found, it falls back to using display: none, as if it were a plain hidden attribute, which makes this a neat progressive enhancement. Instead of using the regular fallback, I would rather show the content by default by applying display: block. The same principle applies when JavaScript is disabled, except here we need to additionally declare content-visibility: visible. With JavaScript disabled, consider hiding the toggle button too, as the content will be visible anyway. Nowadays applying CSS when JavaScript is disabled is easy, since @media (scripting: none) is widely available. A cursed thought experiment In case <details> is not a viable option, we need to use JavaScript and that means a screen reader user will need to use a button to toggle the visibility of hidden content, whether it has until-found or not. There are ways to work around this need to toggle. I have come up with a cursed way of implementing hidden="until-found" by actually not hiding its contents by default. Consider this CSS snippet: [hidden='until-found'] { content-visibility: visible; display: block; contain: strict; contain-intrinsic-height: 1px; } Some key points here: content-visibility: visible is applied to override the default browser implementation of hidden="until-found"; display: block is applied to override any odd [hidden] { display: none } in case of a normalise/reset file; contain-intrinsic-height must be at least 1px, as otherwise NVDA or the in-browser speech functionality will not announce the hidden content. Compared to a regular accordion where you deliberately hide content and render it inaccessible, here, the mindset is the opposite. Content is accessible by default, albeit visually hidden; it is accessible to screen readers without the need to toggle (I was able to verify this with recent versions of VoiceOver, NVDA and JAWS); one can browser-search within the hidden content; one can interact with interactive elements (links, buttons) within the hidden content and by adding a focusin event listener, you can even toggle the visibility state when a user focuses on such an item. Below is a snippet that implements this experiment. It is simplified to leave only the relevant parts in, including a minimum bit of JavaScript to make the toggle work both on click (on the button), on beforematch and on focusin. See the Pen Hidden until-found in use as an accordion by Roy (@roye7777777) on CodePen. There is much to think of here, but there are a few things I want to mention. The toggle button is still present, even when the visually hidden content is accessible to screen readers. It will still toggle the visibility. For screen reader users, this makes no difference, since all content is readily available to them. To then still find a button that suggests an element is still collapsed, while it actually is not, is wrong and one reason not to use this altogether. You could try to hide the button from screen reader users, but there is not much you can do, really. Applying aria-hidden="true" onto a button is wrong as hiding a focusable element from assistive technology is an accessibility failure in itself. Also: what would happen if you use a screen reader in combination with a magnifier? Content could probably be announced, but the user would not be able to see where this text is coming from, since it is visually hidden. Although it is not uncommon to see this in practice (particularly in these 'read more' articles), it is potentially confusing. Final notes on reader mode There's one more thing I mentioned earlier in this article that I want to discuss, and it is the Hidden state. Browsers have a reader mode functionality these days, and their intention is to make content-heavy articles easier to read with less noise. Those who have been testing with this know that reader mode in each browser behaves differently. Each browser engine has a different implementation of this non-standardised concept, and their specific rules and guidelines are often undocumented. Unlike print or noscript, there is not something like a media query to override a certain undesired state within reader mode and I suppose this restrictiveness is intentional to keep it as clean as possible (read: to prevent developers spamming reader mode with noise anyway). Rules of thumb for reader mode are generally: let the HTML be semantically correct, have enough content for reader mode to become active, and most importantly in this context: any hidden content will stay hidden. Any element with the hidden attribute set, even with until-found as its value and even when overridden with display: block, will always be hidden in reader mode. To me, when using specifically hidden="until-found" and <details>, this principle feels wrong. I expect content in hidden="until-found" and <details> to be visible in reader mode. Yes, these elements are hidden, but they all can natively become visible and that ability, together with this special so-called Hidden Until Found state, has been implemented in browsers for a reason after all! Why would in a group of <details> all <details> be hidden except for the first as it contains an open attribute? I hope this behaviour will change in browsers in the future, or at least there will be an option where one can express a desire to show a collapsible element in reader mode. So, important to remember here is this: if you were to use hidden="until-found" in a content-heavy article, you deny users the ability to read all content in reader mode. There is no way to work around this without resorting to duplicating content and rendering it invisible differently by means of opacity: 0, clipping, positioning it out of view or whatever nonsense, as then this duplicated content is semantically not hidden. Now that is hell!
A former Amazon engineer sees signs that the ‘six-pager’ documents used to promote good decision making are increasingly AI-generated and AI-read, and warns it’s not a positive development.
In October 2026 Jenni was acquired by Digital Science. A personal reflection on four years as founding designer, from $4k to $730k in monthly revenue.
In 1978, the ACM published an algorithm by Robert Morris for counting large numbers of events in small registers. It uses one byte to keep track of the approximate logarithm of the count, and randomly increments the logarithm with a probability that scales with the value of the count. You can tune the range and precision of the counter by adjusting the base of the logarithm. Morris suggests pre-calculating a table of probabilities so that no difficult calculations are needed at runtime. Recently I learned from emsenn about a 2009 paper by Miklós Csűrös titled approximate counting with a floating-point counter. It changes Morris’s algorithm to use a binary log-linear counter instead of a pure logarithm. It reminded me of my hg64 log-linear histograms, so I thought it would be fun to implement, especially since the algorithm can be made shorter and faster. representing a counter We need to choose the number of bits to use for the exponent and mantissa of each approximate floating point counter. Typically the exponent will be 5 or 6 bits, corresponding to an unpacked exact counter of 32 or 64 bits. The mantissa will typically be the rest of an 8 or 16 bit integer (though languages such as Zig and C23 allow more adventurous integer sizes). I’ll call the approximate counter type usmol and the unpacked counter type ubig. #define EXPBITS 5 #define SIGBITS 3 typedef unsigned _BitInt(EXPBITS+SIGBITS) usmol; typedef uint32_t ubig; static_assert(sizeof(ubig) * 8 == 1 << EXPBITS, "ubig must match EXPBITS"); It’s straightforward to extract the exponent and mantissa from a usmol counter. Unpacking a usmol into a ubig is slightly tricky. Like hg64 and IEEE754, normal numbers (with a nonzero exponent) have an implicit leading bit, and denormal numbers (exponent is zero) do not. The effect is that small counts are represented exactly in a usmol (up to 2*MANTISSA, covering denormal numbers and exponent == 1), and larger counts are shifted by the exponent. (I don’t need the inverse conversion here, but it is used by hg64 to map a sample to a histogram bucket, truncating the value by shifting right.) #define MANTISSA (1 << SIGBITS) static inline ubig exponent(usmol approx) { return(ubig)(approx / MANTISSA); } static inline ubig mantissa(usmol approx) { return(ubig)(approx % MANTISSA); } static inline ubig unpack(usmol approx) { ubig e = exponent(approx) - 1; ubig m = mantissa(approx) | MANTISSA; return(approx < MANTISSA ? approx : m << e); } bumping a counter Because binary floating point uses logarithms in base 2, we need the probability of incrementing the counter to scale with 2^-e. Specifically, we want the probability of increasing the counter to be 100% when its exponent is 0 or 1, 50% when the exponent is 2, 25% when it is 3, etc. Csűrös does this by getting a random bit e times in a loop and incrementing the counter if they are all zero. A more efficient way to do this on a computer is to get a ubig word full of random bits and count the leading or trailing zeroes. There are a variety of bit scan functions that differ in how they number bits and what they do when the word is entirely zero. The POSIX ffs() family has the advantage of no undefined behaviour, but it weirdly counts from one. However this oddity turns out to match the way denormal numbers give our exponent an off-by-one bias. So for instance, when our exponent is 2 and we want a 50% probability, we want ffs() to return 2 or more. OK, that determines when to increment the mantissa given a particular exponent. But how does the exponent get incremented? Like Csűrös, we put the exponent immediately to the left of the mantissa; when the mantissa overflows, it rolls over to zero and the exponent ticks up. No special cases are needed. The resulting code is short: usmol bump(rng_t *rng, usmol approx) { ubig r = ubig_random(rng); ubig z = (ubig)ffsll((long long)r); ubig e = exponent(approx); return(approx + (z >= e)); } considerations Morris allows you to smoothly tune the allowable range and precision of a counter by adjusting the base of the logarithm. By contrast, Csűrös has very lumpy 2^2^n choice of ranges; that isn’t necessarily bad because it’s normal for programmers to have to choose between uint32_t and uint64_t. Morris uses a lookup table to determine the probability of incrementing, which is tolerable for an 8 bit counter, but it can get large for wider counters. Csűrös just uses a few instructions and bigger counters don’t need much more. So I don’t think either algorithm is clearly better than the other, except that Csűrös has the winning fun factor of bithacking a bespoke floating point format.
Parallelize discovery and execution, but serialize judgement.