I mostly blog about solutions I’ve made for problems I’ve encountered during my workday. The stack we use at Wehkamp is huge, so there’s always an interesting topic to blog about and many programming challenges to deal with. My main specialty is backend (.NET Core / ASP.NET / C#), but I do my fair share of Node.js and Python.`
Solving Google Prettify Excessive DOM Size
Lately I’ve been tinkering around with my blog to see if I could get a better score in Google Web Vitals. The “Avoid Excessive DOM Size” attracted my attention. The details showed that my code fields were to blame. I use Google Prettify as it is lightweight and does a pretty good job, but… it renders way too much span elements. Let’s see if we can make it spit out less.
Dependency Injection based on request headers
Dependency Injection (DI) helps us to change the behavior of parts of our program on the fly. This is especially neat when you want to test your domain services against a mocked data-store. But what if you need to change the behavior of your API based on a request header?
Yesterday I had a discussion with my colleague Robert Kranenburg about this. He showed an example of a console application changing its behavior based on an argument. I took the idea and converted it into .NET Core 3.1 code to change behavior based on a cookie.
Cropping model images using PIL
Let’s see if we can use PIL to crop model images and resize them to a 2:3 ratio using Python Image Library (PIL). When all images on an overview are the same ratio, the overview looks way nicer. And… let’s try to make the model on the image, the center of the image.
Incorporate free ngrok in your Node.js application for local development
I’ve tried to use the ngrok npm package in my application, but as the documentation says: “The ngrok and all tunnels will be killed when node process is done.” I need the process to “survive” my application. Let’s see what we can do about that…
“Is One Of” and “Is Not One Of” validation attributes
I love attribute validation! They can be used for a myriad of things. In .NET Core MVC we use them to validate models that come into our controllers. In one of our projects we kept running into the same thing: we need to validate a value against an array of pre-defined values. So we wrote some base validation attributes.
Visual Studio Code + Docker + Python using WSL in Windows on Boot Camp
I imagine your first thought is: why? Well, at Wehkamp we do a lot of cross platform development, but sometimes we end up with shell scripts that do stuff with Docker and Python. Usually that’s not a problem for Mac, but for Windows it’s a different thing. I have a MacBook Pro, but I’m a .NET developer, that’s why I prefer Windows, so I run Bootcamp. This article will show how to do Python development in the Windows Subsystem for Linux (WSL) using Visual Studio Code and Docker.
Spark: replace array with IDs with values; or: how to join objects?
This week we’ve been looking at joining two huge tables in Spark into a single table. It turns out that it is not a straightforward exercise to join data based on an array of IDs. In this blog I’ll show one way of doing this.
Streaming a Kafka topic in a Delta table on S3 using Spark Structured Streaming
Our data strategy specifies that we should store data on S3 for further processing. Raw S3 data is not the best way of dealing with data on Spark, though. In this blog I’ll show how you can use Spark Structured Streaming to write JSON records of a Kafka topic into a Delta table.
Easy Spark optimization for max record: aggregate instead of join?
There is a lot of code that needs to make a selection based on a maximum value. One example are Kafka reads: we only want the latest offset for each key, because that’s the latest record. What is the fastest way of doing this?