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 increase the bitrate by following the steps below. 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 …

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 …