Programming Leftovers
-
Is Open Graph Protocol dead?
Meta - like many other tech titans - has institutional Shiny Object Syndrome. It goes something like this:
Launch a product to great fanfare Spend a few years hyping it as ✨the future✨ Stop answering emails and pull requests If you're lucky, announce that the product is abandoned but, more likely, just forget about it.
Open Graph Protocol (OGP) is one of those products. The value-proposition is simple.
-
A case for Go code generation: testify
If you’ve been using Go for a while, you’re probably familiar with the testing library stretchr/testify. It makes it easy to write tests and provides several assertion functions, such as Equal, Contains, Greater, and many more. Assertion functions behaves differently depending on the scope. For example, when called from the assert or require package. The former logs the error and continue, while the latter stops the test immediately.
[...]
I think the biggest trade-off here is: complexity shifted from the testify package to the client test code. Writing tests using testify is extremely simple. I’ve rarely opened their documentation after the first few times I wrote tests. Which is a unique experience compared with other test libraries. For example with JavaScript’s chai, where often I forgot the order and idiomatic ways I should write assertions.
This is a great trait of testify. Good libraries are the ones you don’t have to think too much about them, and they just work.
The code generation path leaves a burden for the library developer to maintain, but it might simplify the package API, which makes adoption faster. I think testify developers probably made the right call here in making this simpler for the user, even if it risks complicating the maintainability of their tool.
After all, it’s better to have all complexity in a single place than a little complexity everywhere.
-
npm Dependency Queries and the Cross-Pollination of Ideas
I found out about npm dependency queries by reading Pawel’s post on the subject (and following links to the RFC). It’s an intriguing idea: discover information about your project and its dependencies by querying for it with selectors informed by CSS!
-
How To Simplify Kubernetes Configuration Using Custom Resources And Controllers
Kubernetes is a powerful container orchestration tool that can help you manage your microservices. Often when you have a microservice setup, each microservice requires it’s own set of configuration in the Kubernetes cluster that makes it run. The problem is, maintaining closely similar configurations for your microservices, particularly those that use similar tech stacks, can lead to repetitive code that becomes a cumbersome to maintain.
This can be made simpler if all your microservices are managed by a single configuration template. Changes made to this configuration template are easily applied to all the microservices using it. In addition to the maintenance ease, a configuration template can also make it easier to collaborate with other developers because all your microservice configurations and setup are in one place.
-
Golang Workspaces
In a previous article, we wrote about how you should be using replace in go.mod files for modules local to the repository, like in a large monorepo This works because we can safely make assumptions about the organization of the checked-out directory structure. But what to do when you are working on dependant modules spread across multiple repos?
For example, say you are working on a project that uses several Golang modules. Each will have their own go.mod and their own dependencies. Furthermore, each may have their own repository. Within your project you have a library, maybe a parser for example, that is used in several other modules in your project. You want to do some work on the parser, and then you want to also start using these updates in other modules in your project.
Before Go version 1.18, you’d need to pull the repos locally and then edit each module’s go.mod with a replace to be able to use and test the local changes. That might look something like this:
-
Go's sync.Pool has (undocumented) 'thread' locality
First, let's say the obvious thing: this sync.Pool behavior is undocumented and so may change at any time, if the Go developers feel that it should be done a different way or just if they get annoyed at people building code around it. The second thing to say is that this doesn't mean what you want and it's not necessarily predictable, although it's more predictable than I initially thought.
Go (currently) uses an M:N work stealing scheduler to multiplex goroutines on to OS threads. The scheduler has three important sorts of entities: a G is a goroutine, an M is an OS thread (a 'machine'), and a P is a 'processor', which at its core is a limited resource that must be claimed by an M in order to run user-level Go code. What sync.Pool is (currently) doing in its local pools is 'P-local pools' (as far as I can tell).
-
Addenda to recent articles 202210
I haven't done one of these in a while. And there have been addenda. I thought hey, what if I ask Git to give me a list of commits from October that contain the word ‘Addendum’. And what do you know, that worked pretty well. So maybe addenda summaries will become a regular thing again, if I don't forget by next month.
-
The essence of Reed-Solomon coding
Let’s say we want to store some data on multiple drives, so that we can recover from drive failures.
One obvious (and valid!) first attempt is to just store everything multiple times – usually called “mirroring”. The most common form of mirroring is to store things twice: if one drive fails, the data is still in the other.1
Reed-Solmon coding gives us much more flexibility, allowing us to store our data over n = k + t drives, so that any t drives can fail while still not losing data.
-
Saturn Elephant - The lazy numbers in R
My new package lazyNumbers is a port of the lazy numbers implemented in the C++ library CGAL. The lazy numbers represent the real numbers and arithmetic on these numbers is exact.
-
The giant French Olympic-size swimming pool - r.iresmi.net
What if all private swimming pools could be merged into one 25 m width pool? OSM is not just a map, it’s a database, so ask OSM… I know that not all swimming pools are present in OSM, but it’s just an exercise and it can give us an order of magnitude or at least a minimum.
-
Use data from Wikipedia - r.iresmi.net
Scrape and geolocate data from Wikipedia. We will map the active space launch sites.
-
Scaling Shiny Apps for Python and R: Sticky Sessions on Heroku
Scaling Shiny apps requires load balancing with session affinity which is not a trivial matter. Read on to see how to do that on Heroku.
Shiny for R and Python can be deployed in conventional ways, using RStudio Connect, Shiny Server Open Source, and Shinyapps.io. These hosting solutions are designed with scaling options included and are the officially recommend hosting options for Shiny apps.
-
How to use nflfastR with Google BigQuery? - rstats-tips.net
Lately I wanted to play around with nflfastR. That’s a great package giving you access to NFL’s play-by-play data since 1999. It let’s you download all the data and store it in several different databases.
-
Use data from data.gouv.fr
Using GIS data directly from data.gouv.fr : railways network of France.
-
A web application for forecasting in Python, R, Ruby, C#, JavaScript, PHP, Go, Rust, Java, MATLAB, etc.
In this post, I’ll describe an (work-in-progress) Application Programming Interface (API) for time series forecasting. An API is a system that can receive requests from your computer, to carry out given tasks on given resources, and return a response. This type of system is programming-language-agnostic. That means: it can be used with Python, JavaScript, PHP, R, Go, C#, Ruby, Rust, Java, MATLAB, Julia, and any other programming language speaking http. And therefore, it could be relatively easily integrated into existing workflows for uncertainty forecasting. I’ve used the following tools for building it:
-
How do I count thee? Let me count the ways?
-
Extract POIs from a Suunto watch - r.iresmi.net
The Suunto watches (Spartan, Suunto 9,…) can record waypoints (or POIs) but although they can be visualized in the Suunto app (or on the watch), they cannot be exported to be used with other tools. It used to be possible to access them from the Movescount website but it was discontinued a few months ago.
-
Perl performance evolution over the last decade | Dimitrios Kechagias [blogs.perl.org]
I was reading recently about some significant Python 3.11 performance improvements, and I was wondering whether Perl 5 still gets significant performance improvements on each version - even though it might be more mature, thus more optimized in the first place.
I thought I'd compare the final releases of alternating versions starting with 5.12.5 released 10 years ago, using a benchmark I made for a cloud vm comparison. As is the case with any benchmark, it might not be representative of your own workloads - it benchmarks things that are relevant to me and also some things that I would avoid, but are used by many modules and are notoriously slow (mainly DateTime and Moose). However, it is more representative of "real-life", with results that are not lost in noise, than say, PerlBench (which has a different purpose of course).
-
Pushing the limits - DEV Community 👩💻👨💻
This is the second part of the "A gaze of iterators!" series.
-
The Rise of Rust, the ‘Viral’ Secure Programming Language That’s Taking Over Tech | WIRED
WHETHER YOU RUN IT for a massive organization or simply own a smartphone, you're intimately familiar with the unending stream of software updates that constantly need to be installed because of bugs and security vulnerabilities. People make mistakes, so code is inevitably going to contain mistakes—you get it. But a growing movement to write software in a language called Rust is gaining momentum because the code is goof-proof in an important way. By design, developers can't accidentally create the most common types of exploitable security vulnerabilities when they're coding in Rust, a distinction that could make a huge difference in the daily patch parade and ultimately the world's baseline cybersecurity.
-
Workshop: Deep Dive on Accessibility Testing - Manuel Matuzović
I’ve teamed up with my friends at Smashing Magazine 😻 to share with you everything I know about web accessibility testing! In this smashing workshop we’ll talk about automatic and manual testing, screen reader basics, Single Page Applications, Dev Tools, and more.
-
Xess 2: CSS variable edition
As a hacker with too many side projects, I like to have a certain look to my websites that makes it instantly identifiable. I have a very brutalist approach to web design that makes it very easy to get things off the ground and get hacking.
One of my longer-standing projects is a CSS framework called Xess. Xess is my go-to CSS file when I just need to throw some words on a page.
-
6 Steps to Improve HTML Images For Users & Developers
On a large screen, this image would be just fine, but for users with small screen devices, a 1200px wide image means they’ll have to to download a larger image than they need. That could take longer to download and it could cost them money on their data plan.