Remember, C# does not have an exponent operator

I want to share an anecdote of confusing programming language features as a caution to my fellow programmers. Reviewing our application logs, I noticed that the API requests were interspersed with pauses of irregular durations. The interval between each successful request is supposed to be fixed; and the interval between each failed request, exponentially growing …

Avoiding time drift in virtual machines

If you use a virtual machine, you might notice that its system time starts to lag after it has been powered on for a while. To solve this problem, it is useful to run an NTP (Network Time Prococol) client within the VM to have its time synchronised regularly. On Windows, automatic time synchronisation is …

Caveat with AddInitialRequestCultureProvider() in ASP.NET Core

AddInitialRequestCultureProvider() in ASP.NET Core localisation seems to have an undefined behaviour when it is used in both services and application builder configurations to add a custom RequestCultureProvider. If you want to use a custom RequestCultureProvider to customise how the applicable culture is determined for an incoming HTTP request (for example, by looking up the chosen …

How can you minimize the impact of the persistence layer on your domain models?

This post answers the question ‘How can you minimize the impact of the persistence layer on your domain models?’ posted on reddit /r/dotnet, showing how I would implement a solution in the purest OOP [sic] possible with C#. (Note: The factory and persistence classes are simplified for demonstration purposes.) So here is the code. It …

Disabling Bluetooth auto-suspend with module options

In my previous post I showed how to restart Bluetooth on Debian Linux. Here I explain how to disable Bluetooth auto-suspend with a kernel module option. The behaviour of kernel modules can be controlled with parameters. The command modinfo shows information about a module and lists its parameters. In the example below, modinfo btusb shows …

Restarting Bluetooth on Debian Linux

On my laptop I use a Bluetooth keyboard and a Bluetooth mouse. Occasionally the Bluetooth adapter in the laptop shuts off completely, meaning that it becomes impossible to restart the Bluetooth service with sudo systemctl restart bluetooth.service. My troubleshooting points to powersaving as the cause of this intermittent failure, but the TLP setting that is …

Centrino Ultimate N-6300 slow to connect to WiFi network

WiFi connections from my laptop became unstable after I upgraded it to Ubuntu 19.04. To get them to work, I had to turn the WiFi adapter on and off several times, which quickly became annoying. The following attempts to fix the problem were unsuccessful: disabling IPv6 disabling power-saving on the WiFi adapter setting bt_coex_active=0 during …