Quick, simple and easy idea for automatic versioning in azure pipelines

Here are two straightforward steps for automatic versioning of a .NET application when using azure pipelines.

First step is to add -p:Version=$(date).$(buildCounter) switch to the dotnet publish (or dotnet build if you don't use publishing) step:

- script: dotnet publish --output $(Build.ArtifactStagingDirectory) -p:Version=$(date).$(buildCounter)
  displayName: 'dotnet publish'

The second one is to declare the variables used in the previous step in variables section. First one is the current date in yyyy.MM.dd format and the second is a build counter (for given date) that is reset everyday.

variables:
  buildConfiguration: 'Release'
  date: $[format('{0:yyyy}.{0:MM}.{0:dd}', pipeline.startTime)]
  buildCounter: $[counter(variables['date'], 0)]

Thanks to that msbuild will put a version in current date + build counter format in the assembly (e.g., 2021.7.12.2) that guarantees it will always be unique and incrementing with every build. If that's a Blazor application then you can display this value by using this code:

<span class="small">MyBlazorApp @($"v{GetType().Assembly.GetName().Version}")</span>

Windows reports no internet connection after connecting to a VPN and Microsoft applications don't work

When, after connecting to a VPN (like NordVPN), your Internet connection is fine (e.g., you can browse the Internet using a web browser) but Windows reports "No internet connection" and some Microsoft/Windows applications doesn't work (e.g., XBOX app) then here is what helped me.

Figure 1. Steps to fix the issue

Follow the steps as on the above image:

  1. Click on the network status icon
  2. Click on the "Network & Internet settings" option
  3. Click on the "Change adapter options" option
  4. Right click on your VPN ethernet connection and select Properties from the list
  5. Select "Internet Protocol Version 4 (TCP/IPv4)" on the list
  6. Click "Properties" button
  7. Click "Advanced" button
  8. Click "Add" button to add the default gateway
  9. Put your gateway IP address
  10. Click "Add" button and close all other windows by using "OK" button

If you do not know what is your gateway IP address then disconnect VPN for a while and open command line (press Windows key + R and type cmd and press enter). In the command line window write ipconfig and press enter. Find your non-vpn adapter in the results and under it there should be default gateway IP addres. Use that one.

Easy way to download all your photos and videos from Google Photos at once

Some time ago Google introduced a new website called Takeout where you can download all your data stored by Google at once.

It is enough to go to the Takeout page and select the data you are interested in. For example, unselect everything except Google Photos. Click "Next step" button and wait for an email with a link to your download. I got my link after 2-3 minutes. The link takes you to a zip package containing all the data you requested.

Transmission daemon doesn't create a log file nor a pid file

So you edited default transmission-daemon settings file (/etc/default/transmission-daemon) then restarted the daemon and nothing happened? Well... thanks to this thread on unix.stackexchange.com I learned that transmission-daemon is managed by systemctl and because of that init.d scripts that use mentioned default config are ignored.

To tell the daemon that you want him to create a pid and a log files you need to edit /lib/systemd/system/transmission-daemon.service file to look like this:

[Unit]
Description=Transmission BitTorrent Daemon
After=network.target

[Service]
User=debian-transmission
Type=notify
RuntimeDirectory=transmission-daemon
LogsDirectory=transmission-daemon
ExecStart=/usr/bin/transmission-daemon -f --log-error --log-debug --logfile /var/log/transmission-daemon/transmission.log --pid-file /run/transmission-daemon/transmission.pid
ExecStop=/bin/kill -s STOP $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID

[Install]
WantedBy=multi-user.target
Where:
  • RuntimeDirectory tells systemd to create transmission-daemon folder inside /run owned by daemon's user. We want this because the daemon runs under debian-transmission username which doesn't have access to the /run so it won't be able to write to this directory.
  • LogsDirectory tells systemd to create transmission-daemon folder inside /var/log. Reasoning is the same as above.

Now you can restart the daemon (don't forget about systemctl daemon-reload before restarting) and the log and the pid files should be in place.

Intel Pentium Silver J5005 supports 16GB of RAM

I finally got my ASRock J5005-ITX motherboard and can confirm that it is able to handle 16GB of RAM. Although Intel's web page says this CPU supports up to 8GB, I have successfully installed Ballistix 2x8GB SODIMM kit (model BLS2C8G4S240FSDK) and it has got correctly recognized by BIOS and Ubuntu OS.

16GB of ram discovered correctly by Ubuntu System Information
Figure 1.

There are also other people reporting that this CPU supports 16GB. For example in this review Intel's NUC built on J5005 works with 16GB of RAM. There's statement that RAM modules need to be 2400MHz ones. This not necessarily has to be true as ASRock maintains RAM compatibility table for mentioned motherboard where 2133MHz modules are also listed.

Edit note: A reader contacted me regarding compatibility issues with his Kingston HyperX Impact 8GB - HX424S14IB2/8. He bought two pieces for dual-channel but motherboard behaved like the RAMs were damaged. Even when using only one of them. Finally what helped for him was the BIOS upgrade. Now they run smoothly in dual-channel. So keep that in mind that flashing the newest one to your J5005-ITX can add support for your RAMs.

Internet wifi drops/disconnects. Connected to wifi but no internet.

After migrating to Windows 10 from 7 I had Wi-Fi internet issue. After some time (e.g., 5 minutes) my WiFi connection was reporting "No Internet". Reconnecting manually to the WiFi was fixing the issue. After digging some time in the internet I found out that this has something to do with IPv6 address assignment. If you don't need it you can disable it using the "Disable IPv6" tool from microsoft site.

Mirror on my site in case mentioned site is down: download.

People also reports that in some cases that helped to solve Ethernet issues in Windows 10.

Additionally I have installed the newest Broadcom drivers I could find for my bcm94313hmgb chip. It was broadcom_bcm_5.10.97.7 from this site: Broadcom BCM943XX/BCM43XX WLAN Driver 5.10.91.4 for Vista

Convert any TypeScript value to Enum string value

Enum conversions in TypeScript are a bit tricky. You can't be sure what will you receive when converting from your Enum. Let's take following enum as an example:
enum Categories {
drawing = 1,
painting
}
When you take a look at the output of below conversions:
var str: string = "painting";
var num: number = 2;
var numStr: string = "2";
var category: Categories = 2;

console.log(Categories[str]);
console.log(Categories[num]);
console.log(Categories[numStr]); //The most interesting case
console.log(Categories[category]);

Enum Conversion Output

You will notice that generally converting from number gives a string and converting from string gives... number or string.

I was trying to solve a scenario where I had an unknown value (enum number value as a string or as a number or just an enum string value but I didn't know which one at the moment) and I needed to map it to the enum string value. I end up with below function. It's pretty generic because it can map any value to any enum.
function varToEnumStringVal(value: any, enumerator: any): string {
var en: { [index: string]: any } = enumerator;

if (!isNaN(parseInt(value)))
return en[value];

var num = en[value];

return en[num];
}
Usage:
var str: string = "painting";
var num: number = 2;
var numStr: string = "2";
var category: Categories = 2;

console.log(varToEnumStringVal(str, Categories));
console.log(varToEnumStringVal(num, Categories));
console.log(varToEnumStringVal(numStr, Categories));
console.log(varToEnumStringVal(category, Categories));
And now you can be sure that you will receive enum string value:

Enum Function Conversion Output