In dial-up Internet days we surmised that a 56K modem transferred data at 56 000 bits per second (or 56 kbps). Dividing this speed by 10 gave a result of 5.6 kilobytes per second (or 5.6 kBps). Thus, it was easy to calculate download times for files with the following formula, given that their sizes …
Author Archives: Eddy Young
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 …
Continue reading “Trap with `gmtime` and other time functions”
ESP8266: Always call ‘wifi_wps_enable’ before ‘wifi_set_wps_cb’
For WPS to work on the ESP8266 and using the non-OS SDK, be sure to call wifi_wps_enable() before setting the callback function with wifi_set_wps_cb(). For example: In the callback itself, call wifi_wps_disable() before wifi_station_connect(). For example:
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 …
Continue reading “ESP8266: Flash images at more than 115200 bps”
ESP8266: Always call `uart_init` before `gpio_init`
I don’t remember if this information is in the documentation, but having spent a few hours to figure things out, I think it is important to record it here. For example:
ESP8266 ESP-01(S) requires CH_PD set to HIGH
On the ESP8266 ESP-01, CH_PD must be pulled HIGH at boot for the chip to work. A 10K resistor can be used for the pull-up. Some variants of the ESP-01 module already have CH_PD in the HIGH state.
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 …
Continue reading “Remember, C# does not have an exponent operator”
Convert a value from scientific notation to decimal in T-SQL
A VARCHAR value that is in scientific notation can be converted to a DECIMAL value by first converting it to a REAL value, then to the DECIMAL value. For example: This also works with CAST.
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 …
Continue reading “Caveat with AddInitialRequestCultureProvider() in ASP.NET Core”