This repository contains code samples for articles on my blog. It is easier to keep the code up to date when all of the items are grouped.
When you are used to building web applications, you kind of get hooked to the
ease of Dependency Injection (DI) and the way settings can be specified in a
JSON file and accessed through DI (IOptions<T>). It's only logical to
want the same features in your Console app.
- 01.dependency-injection-with-ioptions-in-console-apps
- Dependency injection (with IOptions) in Console Apps in .NET
Services can use their private key to communicate with our service. We can configure the access for each issuer using standard .NET claims.
- 02.simple-jwt-access-policies-for-api-security-in-net
- Debug a JWT token expiration locally with bash or PowerShell
- Simple JWT Access Policies for API security in .NET
Options themselves can be collections as well. This
project shows how to use a Dictionary<string, string> and a
List<string> as base classes for options. Both are supported
by default.
How to use System.CommandLine to build a CLI with commands and
dependency injection.
Parsing Roman Numerals in C# is a good way to explore (implicit) operator overloading.
I ❤️ Handlebars! So I was very very very happy to see that Handlebars was ported to .NET! It is a mega flexible templating engine as it can easily be extended. I'm working on a project where I need to parse objects via JSON templates to JSON strings. This blog will show how to instruct Handlebars to parse into JSON and add some nice error messages if your template fails.
All my applications run in Docker. Having a fast CI is paramount. As Docker is not unline a layered cake, it is important to understand how to build your images in such a way that you can cache the layers.
Looks like my organization wants to manage my background picture. But I'm a local admin, so let's see if we can still change that background picture. When I go to Setting > Personalization > Background, I see the message: "Some of these settings are managed by your organization." If you are an admin, you might be able to (temporarily) override the wallpaper, by editing your registry and triggering a refresh of the wallpaper. If you can, you can automate it using PowerShell.
The Slack API is so simple, that you don't really need a package to post a simple message to a Slack channel. This simple Python code will show you how!
When working with images in a Python notebook I like to visualize them on a grid. Just calling
display is not enough as it renders the images underneath each other. Let's use Matplotlib to
generate a grid of PIL images.
My new years resolution for 2025 is not to write a custom implementation if I have an Open API specification availabe. Now, let's test how to create a resilent setup without any client generation, with a Kiota client.
- 12.http-and-resilience
- Implementing HTTP Resilience by Microsoft
- Kiota, dependency injection and resilience
With the Chocolatey Package Manager for Windows, it is super easy to install software from the command-line. This makes your installs scriptable and thus repeatable. In this article, I'll show you how to render installation instructions from a machine and how to use the Windows Task Scheduler to update your packages regularly.
Let's explore validation using .NET Data Annotations and FluentValidation.