Programming Leftovers
-
Luke Harris ☛ Advent of Code ’24: Day Three
Started this one the day after Xmas and wrote most of it before NYE, but I kept putting off the regular expression part because that’s always a headache. Messed with it today and got the regex figured out and the right answer to part one within 15 minutes, followed by part 2 in about half that time. Figures.
-
Fernando Borretti ☛ Implementing FSRS in 100 Lines
So I put everything I could find together, and cleaned it up. The implementation turned out to be just 100 lines, though much of it remains cryptic: while SM-2 was intelligently designed, FSRS was evolved by training a model on a dataset of Anki reviews. But you don’t need a PhD in machine learning to understand the implementation.
The rest of this post explains the theory of FSRS, with equations interleaved with Rust code. If you just want the code, scroll to the end. The repository is here.
-
Anton Zhiyanov ☛ Gist of Go: Context
In programming, context refers to information about the environment in which an object exists or a function executes. In Go, context usually refers to the Context interface from the context package. It was originally designed to make working with HTTP requests easier. However, contexts can also be used in regular concurrent code. Let's see how exactly.
-
Sandor Dargo ☛ C++26: a placeholder with no name
Let’s continue exploring C++26. In this post, we are going to discuss a core language feature proposed by Corentin Jabot and Micheal Park in P2169R4. With the new standard we get a cool unnamed placeholder.
-
Kevin Boone ☛ Technical writing: what do we lose, when we write more readably?
It’s easy, especially in science and technology, to write text that nobody wants to read. Scientific writing is often over-long, over-reliant on the passive voice, and full of vague abstractions. We often avoid referring to specific individuals, even to ourselves, the writers. Generality and objectivity are worthy goals in science, but readers prefer the specific and the personal.
You don’t have to look very far to find guidance on how to write readable English text. There was an explosion of publication on this subject between the end of the 19th and the mid-20th centuries. It’s still worth reading early examples like Mark Twain’s Fenimore Cooper’s Literary Offenses (1895), and the Fowler brothers’ The King’s English (1908). This eventually became Fowler’s Dictionary of Modern English Usage, which is still in print. Of course, there are modern books on writing style too, including some for scientists, like Anne Greene’s Writing Science in Plain English.
-
Rlang ☛ Little useless-useful R functions – QR-Code Clock
Ever wanted to have a clock on the wall or in the office, that is not binary. But it is QR-Code clock 🙂🙂 Well, now you can have it.
This useless R function generates new QR Code for every given period and tells the time. Run this function: [...]
-
Matt Keeter ☛ Fidget
Fidget is a library for representing, compiling, and evaluating large-scale math expressions, i.e. hundreds or thousands of arithmetic clauses. It's mainly designed as a backend for implicit surfaces, but the library is flexible enough for many different uses!
-
Jasper Tandy ☛ Jasper is blogging Aegir shared this post on Mastodon earlier and I think it's an interesting take on something I've...
I learned to debug really early on in my career. My first job where I wasn't a junior, I worked on a codebase that had been maintained by someone who was always 100% sure that they were right (this isn't an exaggeration - I've genuinely never met or known someone so arrogant in my entire life), and that had resulted in so many incredibly confusing things that were an example of that "misaligning a single pair of flippers" mentality. Some people have an idea of how they're going to implement something and they will not deviate from it (or consider deviating from it), even if they meet with substantial resistance.
-
Rlang ☛ Your Classifier Is Broken, But It Is Still Useful
When you run a binary classifier over a population you get an estimate of the proportion of true positives in that population. This is known as the prevalence.
But that estimate is biased, because no classifier is perfect. For example, if your classifier tells you that you have 20% of positive cases, but its precision is known to be only 50%, you would expect the true prevalence to be $0.2 \times 0.5 = 0.1$, i.e. 10%. But that’s assuming perfect recall (all true positives are flagged by the classifier). If the recall is less than 1, then you know the classifier missed some true positives, so you also need to normalize the prevalence estimate by the recall.
-
Scott Redig ☛ Zig's Comptime is Bonkers Good
Programming has obvious abilities to increase productivity through automated manipulation of data. Metaprogramming allows code to be treated as data, turning programming’s power back onto itself. Programming close to the metal has perhaps the most to gain from metaprogramming as high level concepts need to be mapped precisely to low level operations. Yet outside of functional languages I’ve always found the metaprogramming story to be a disappointment. So when I saw that Zig lists metaprogramming as a major feature, I took interest.
-
Dirk Eddelbuettel ☛ Dirk Eddelbuettel: RcppGetconf 0.0.4 on CRAN: Updates
A minor package update, the first in over six years, for the RcppGetconf package for reading system configuration — not unlike
getconf
from the libc library — is now on CRANThe changes are all minor package maintenance items of keeping URLs, continuous integration, and best practices current. We had two helper scripts use
bash
in their shebangs, and we just got dinged in one of them. Tedious as this can at times seem, it ensures CRAN packages do in fact compile just about anywhere which is a Good Thing (TM) so we obliged and updated the package with that change—and all the others that had accumulated over six years. No interface or behaviour changes, “just maintenance” as one does at times. -
Michael Lynch ☛ if got, want: A Simple Way to Write Better Go Tests
There’s an excellent Go testing pattern that too few people know. I can teach it to you in 30 seconds.
Instead of writing Go tests like this: [...]
-
Education
-
Rlang ☛ Top 5 Books to Learn Data Engineering
Top 5 Books to Learn Data Engineering, Data Engineering is a critical field within the broader scope of data science and analytics that focuses on designing, constructing, and managing systems and processes that enable the collection, storage, processing, and analysis of large volumes of data.
As organizations increasingly rely on data to drive decision-making and strategy, data engineering has become crucial in ensuring that data is accessible, reliable, and usable.
-
Rlang ☛ Spatial modelling with GAMs in R workshop
This workshop introduces generalised additive models (GAMs) as a method for generating the underlying spatial structure needed to define spatially structured random effects. We will see how penalised smoothing splines can be applied to coordinates to generate a spatial plane with minimal user assumptions. This ensures the spatial model is relevant and unique to the setting being studied. Using the mgcv package in R, we will apply this approach to real-world data, incorporating the flexible spatial structure into a random effects model, which then can be interpreted similarly to any other spatial model.
-
-
Python
-
Juha-Matti Santala ☛ Advent of Code 2024 retrospective
For me, this year’s Advent of Code was less about solving puzzles and writing Python. It was more about writing explanations, teaching Python, showcasing how to get started with blogging as a developer and experimenting with the tooling to build websites out of Obsidian notes.
-