Test internet speed using Cloudflare and curl

The script tests download of 5MB file and upload of 1MB file using speed.cloudflare.com.

#!/bin/sh

set -e

curl -L -o /dev/null -s -w \
'Download: %{speed_download} B/s' \
'https://speed.cloudflare.com/__down?bytes=5000000' |
    awk '/^Download:/ { printf "Download (5MB): %.2f Mbit/s\n", $2 * 8 / 1000000; next } { print }'

dd if=/dev/zero bs=1000000 count=10 2>/dev/null |
    curl -sS -o /dev/null -w 'Upload: %{speed_upload} B/s'  \
        --data-binary @- https://speed.cloudflare.com/__up |
    awk '/^Upload:/ { printf "Upload (1MB): %.2f Mbit/s\n", $2 * 8 / 1000000; next } { print }'

Connect to macOS from Windows

I used to connect to MacOS remote desktop using RealVNC.

I create a local port forward:

ssh -L 25900:127.0.0.1:5900 username@MAC_IP

I was than able to connect using 127.0.0.1:25900. But that stopped working after macOS upgrade. I started getting Key Length Too Large error. RealVNC does not seem to fix it event in latest version 8.5.

So I was looking for alternative client that supports macOS username login. Most clients only seem to support password only login. What worked for me was gvncviewer in WSL. The only problem is that it does not seem to support port change, so I have to use 5900 instead of 25900 for local connection.

sudo apt install gvncviewer
ssh -L 5900:127.0.0.1:5900 username@MAC_IP
gvncviewer 127.0.0.1

Get list of uninstall strings for installed Windows applications using PowerShell

$paths = @(
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*",
    "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
)

Get-ItemProperty $paths -ErrorAction SilentlyContinue |
    Where-Object DisplayName |
    Select-Object DisplayName, UninstallString, QuietUninstallString |
    Format-List

Convert Windows 7 VM from VirtualBox to Hyper-V

I used qemu utils in WSL for the disk conversion:

sudo apt install qemu-utils
qemu-img convert -f vdi -O vhdx "Windows 7.vdi" "Windows 7.vhdx"

VM in Hyper-V has to be created as Generation 1 with disk in IDE controller. The problem is that VirtualBox uses SATA driver by default. So after VM started I got BSOD 0X0000007B. I had to load PCI driver after start of Windows. To do it I have used startup repair to get into the command prompt and executed the following commands. It assumes that the original Windows system disk is mounted as D:.

reg load HKLM\OFFLINE D:\Windows\System32\Config\SYSTEM

reg add "HKLM\OFFLINE\ControlSet001\Services\atapi" /v Start /t REG_DWORD /d 0 /f
reg add "HKLM\OFFLINE\ControlSet001\Services\intelide" /v Start /t REG_DWORD /d 0 /f

reg unload HKLM\OFFLINE

MacOS lock / unlock times

You can find lock / unlock times in log using terminal. The script below searches for records in last 8 hours, but you may change it using --last parameter. See lockunlock for details.

log show --last 8h --style syslog \
  --predicate 'process == "loginwindow"' | grep -iE "user is active, releasing the activity semaphore|going inactive, create activity semaphore"