Trap with `gmtime` and other time functions

From man gmtime: The gmtime() function converts the calendar time timep to broken-down time representation, expressed in Coordinated Universal Time (UTC). It may return NULL when the year does not fit into an integer. The return value points to a statically allocated struct which might be overwritten by subsequent calls to any of the date …

ESP8266: Flash images at more than 115200 bps

If esptool is limited to 115200 bps when flashing your firmware to an ESP8266, you can try to change this by following these instructions. Locate esptool.py for your installation. On Debian and Ubuntu, this file is located in /usr/share/esptool. Edit esptool.py and change the value on the line starting with ESP_ROM_BAUD from 115200 to the …

Remember, C# does not have an exponent operator

This is a cautionary tale for developers who switch between programming languages often. Whilst reviewing some logs, I noticed that durations of pauses between API requests were incorrect. They were expected to double on every subsequent attempt, starting from a fixed base interval; for example, 5 seconds, 10 seconds, 20 seconds, 40 seconds, and so …

Avoiding time drift in virtual machines

If you use a virtual machine, you might have noticed that its system time starts to lag after it has been in the ‘powered on’ state for some time. To address this, it is useful to run an NTP (Network Time Prococol) client within the VM to have its time synchronised regularly. On Windows, this …

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 is a blog response to 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 have implemented the solution in the purest form of OOP that is possible with C#. (Note: The implementation of the factory and persistence classes is …