RSSAmplifier

Blog

Archive Fever by Edwin Wenink

Recent content on Archive Fever by Edwin Wenink

edwinwenink.xyzRSS feed ↗10 posts

Latest posts

Idiot's guide to resource migration in Terraform

Sometimes we need to migrate resources that are managed in Terraform. Terraform is a declarative language to manage cloud infrastructure from code, which allows you to reliably automate your deployments and put your infrastructure configuration under version control. We call this Infrastructure as Code (IaC). When moving resources in your IaC, Terraform will by default delete the resource and…

Self portraits using stable diffusion

I was in need of a head shot, but I don’t like taking pictures. Being a programmer I figured, why not let AI magically turn a messy selfie into a proper professional head shot? As it turns out, there’s quite a market for AI tools that generate professional portraits that are suitable for LinkedIn and such, but they were requesting fees I wasn’t willing to pay. I hoped to do some…

My Vinyl Record Collection

Analog example I added a digital vinyl record display to this website, have a look! The idea was to digitally reproduce one of those fancy wall mounts for displaying records in your room. You can click on each record to see some basic information. All vinyl records I physically own are registered on Discogs . I used the Discogs API to automatically retrieve my collection, parse the information I…

Version control on notebooks using pre-commit and Jupytext

Notebooks have a place and a time. They are suitable for sharing the insights of an exploratory data analysis, but not so convenient for collaborating with multiple people whilst having the notebook code under version control. Generally speaking notebooks do not promote good coding habits, for example because people tend to duplicate code by copying cells. People typically also don’t use…

Overgeven of Sneuvelen: De Atjeh-oorlog

In 1873 valt Nederland de zelfstandige staat Atjeh binnen, gelegen op de noordpunt van Sumatra. De Nederlanders verwachten Atjeh snel te kunnen onderwerpen. Dat blijkt een illusie te zijn. Ze belanden in een oorlog die de langste en bloedigste uit de Nederlandse koloniale geschiedenis zal worden: de Atjeh-oorlog. Overgeven of sneuvelen is de enige roman in de Nederlandse literatuur die de…

On circular imports in Python

It has happened in the past that I’ve been sloppy with programming and took some shortcuts just to “get things done,” and that I encountered an error like the following: AttributeError: module 'X' has no attribute 'call' . This was quite baffling because module X did have the attribute call . It turned out that I had accidentally did a very bad thing, namely to use a circular…

Initializing nested lists correctly

If you want to initialize a list with a certain size in Python, you can use the following clean syntax: >>> arr = [ None ] * 3 >>> arr [ None , None , None ] We can then fill the list with elements: >>> arr[ 1 ] = 1 >>> arr [ None , 1 , None ] But watch what happens when we try to use the same syntax for declaring a 2D dynamic array: >>> arr2 = [[]] * 3 >>> arr2 [[], [], []] >>> arr2[ 1 ] .…

Regular expressions with optional starting or ending groups

I’m currently working on a classifier that can extract punishments from Dutch criminal law decisions. One of those punishments is called “TBS”, which is assigned in severe cases where it is shown that the suspect was under the influence of a psychiatric condition at the time of committing the crime. There’s two types of TBS in the Netherlands: with “verpleging”…

Stemming and lemmatizing with sklearn vectorizers

One of the most basic techniques in Natural Language Processing (NLP) is the creation of feature vectors based on word counts. scikit-learn provides efficient classes for this: from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer If we want to build feature vectors over a vocabulary of stemmed or lemmatized words, how can we do this and still benefit from the ease and…

Applying operations on grouped dataframes in Pandas

I have the following use case: I have legal text data that is stored on section level, so a single document with multiple sections will provide multiple rows to the data set. These sections have a particular type. For example, a case is typically concluded with a section where the judges offer their final ruling. I want to investigate the hypothesis that each case has indeed a single section of…