Programming Leftovers
-
James G ☛ Advent of Patterns: Status indicators
The indicator can then be accompanied by a more detailed description if required. For example, if a task fails, a reason should be given that is in a place intuitive to the user (i.e. next to the failed task in a list, via notification).
Below, I am going to walk through three examples of status indicators, then talk about some ways in which status can be conveyed.
-
Perl Data Language ☛ Day 20: Perl Data Language internals - PDL Advent calendar 2024
The first one came to light in January, when Karl Glazebrook, the inventor of PDL, emailed to the pdl-general list that he'd discovered a problem with clump. Some clever-ish finagling with git bisect discovered when the problem had occurred. That finagling in full, to help others another time: [...]
-
Daniel Xu ☛ Application blackbox
In aviation, a “black box” is the colloquial term for the flight recorder, a device that records the recent history of a flight. This device is designed to be robust to a potential crash such that the recovered data can be later used during investigation.
blackbox applies this idea to software. The principle goal of blackbox is to enable applications to save arbitrary (but structured) data during runtime and allow that data to survive any kind of crash, even SIGKILL. In addition, the blackbox can be extracted from outside the application (live or post-mortem) without introducing any blocking in the application.
-
MaskRay ☛ Simplifying disassembly with LLVM tools
Both compiler developers and security researchers have built disassemblers. They often prioritize different aspects. Compiler toolchains, benefiting from direct contributions from CPU vendors, tend to offer more accurate and robust decoding. Security-focused tools, on the other hand, often excel in user interface design.
For quick disassembly tasks, rizin provides a convenient command-line interface.
-
Redowan Delowar ☛ Function types and single-method interfaces in Go
People love single-method interfaces (SMIs) in Go. They’re simple to implement and easy to reason about. The standard library is packed with SMIs like io.Reader, io.Writer, io.Closer, io.Seeker, and more.
One cool thing about SMIs is that you don’t always need to create a full-blown struct with a method to satisfy the interface. You can define a function type, attach the interface method to it, and use it right away. This approach works well when there’s no state to maintain, so the extra struct becomes unnecessary. However, I find the syntax for this a bit abstruce. So, I’m jotting down a few examples here to reference later.
-
Daniel Doubrovkine ☛ Do Not Fix Bugs Reported in Your Open Source Projects – code.dblock.org
Here’s my structured approach for any bug being reported in my open-source projects.
-
[Repeat] Ruben Schade ☛ Some of my ancient forks
I’m continuing to move my stuff over to Codeberg. I believe in self-hosting what you can, but my repos are a form of remote backup for me.
-
Perl / Raku
-
Perl Data Language ☛ Day 23: Generic, general random number simulation using the Inverse CDF method in PDL - PDL Advent calendar 2024
While one can use custom algorithms to simulate numbers from such distributions, there is one truly general method to accomplish this task, the inverse CDF method. Given a random variable X with CDF , the method is based on the principle that if U is a uniform random variable on (0,1), then has the same distribution as X. This method requires that the CDF is invertible, which is the case for most continuous distributions. For discrete distributions, the method can be adapted by using the inverse of the discrete CDF. Here is what is the inverse CDF algorithm looks like: [...]
-
Perl Data Language ☛ Day 22: Clearing the Runway - PDL Advent calendar 2024
First we need to setup the environment to do everything we need: read images, processing them with some filters, and then plot the results. Since image processing requires frequent visualisation, this work is being done in Jupyter Notebook via Devel::IPerl, but the setup below allows for display of plots both in a notebook, but also as a regular Perl script. You can download the notebook here.
-
Perl Data Language ☛ Day 21: Fun and Games with Images - PDL Advent calendar 2024
If you are manipulating images, you need PDL!
For years, I've had this urge to use PDL to take a bitmap image and trace the outlines to make an SVG file that I could scale up to A0 poster size without the resulting pixelation. Yes, there are already tools that do that, but where's the fun in that? It's Christmas, the time for Fun and Games!
-
Perl Data Language ☛ Day 19: Twinkle, Twinkle Little Star - PDL Advent calendar 2024
Well, these things stack. The end of one light ray path is the beginning of the next. You follow the path from element to element until you get to the end of your optical system. Even better, the calculation in PDL is in the same order as the written mathematics; start with the vector on the right and work through the elements in the path from right to left in the code.
-
-
Python
-
University of Toronto ☛ Two views of Python type hints and catching bugs
I recently wrote a little Python program where I ended up adding type hints, an experience that I eventually concluded was worth it overall even if it was sometimes frustrating. I recently fixed a small bug in the program; like many of my bugs, it was a subtle logic bug that wasn't caught by typing (and I don't think it would have been caught by any reasonable typing).
-
Adnan Siddiqi ☛ Detecting the Hammer Candlestick Pattern Using Pythons
In the previous post, we discussed creating your custom signal generation pattern. In this post, we will discuss a famous candlestick pattern called the Hammer pattern. We will discuss the pattern, what it is all about, and how it helps traders to earn money.
-
-
Go
-
Anton Zhiyanov ☛ Gist of Go: Time
This is a chapter from my book on Go concurrency, which teaches the topic from the ground up through interactive examples.
In this chapter, we'll look at some techniques for handling time in concurrent programs.
-
-
Rust
-
David Teller: What would it take to add refinement types to Rust?
A few years ago, on a whim, I wrote YAIOUOM. YAOIOUM was a static analyzer for Rust that checked that the code was using units of measures correctly, e.g. a distance in meters is not a distance in centimeters, dividing meters by seconds gave you a value in
m / s
(akam * s^-1
).YAIOUOM was an example of a refinement type system, i.e. a type system that does its work after another type system has already done its work. It was purely static, users could add new units in about one line of code, and it was actually surprisingly easy to write. It also couldn’t be written within the Rust type system, in part because I wanted legible error messages, and in part because Rust doesn’t offer a very good way to specify that
(m / s) * s
is actually the same type asm
.Sadly, it also worked only on a specific version of Rust Nightly, and the code broke down with every new version of Rust. It’s a shame, because I believe that there’s lots we could do with refinement types. Simple things such as units of measure, as above, but also, I suspect, we could achieve much better error messages for complex type-level programming, such as what Diesel is doing.
It got me to wonder how we could extend Rust in such a way that refinement types could be easily added to the language.
-