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.
Connect to AWS ElastiCache (Redis) with redis-cli
This week I needed to query an ElastiCache instance on AWS – which is Amazons version of Redis. I could not find a decent free client to query this remote dictionary, so I ended up using redis-cli on Ubuntu. Turns out: Redis is a wonderful and powerful system to work with.
Resetting the terminal colors on Windows
I have no idea how I came to this point, but the yellow colors in my terminal (both cmd and PowerShell) are not bright yellow anymore. So I want to reset my colors back to the old values! Turns out that getting them back is not as straightforward as I had hoped…
Poll JSON endpoint until value changes with bash & curl
Today I had some data coming into our event driven landscape, so I needed to know when my data was processed. As it constituted the processing of 400.000+ records (and I had more things to do), I needed a small script that kept an eye on my JSON API endpoint to see if the values are changed.
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.