gpsTime

I think there is nothing more pleasing than having extremely precise measurements at your fingertips. Like time. While in the past it was quite problematic to measure time accurately (not talking about sundials, but... why not? ;)) - mankind has created one precise time source as the byproduct (read: "waste") for usage in accurate navigation: GNSS and their different kinds like GPS, Glonass, Galileo, BaiDou and others.

Taping into this time source and providing it to your local computer network via NTP has been done by countless people and is an extreme rewarding task. Is it necessary? Maybe not. Is it really cool? Yes. And now it is even easier as you don't need to configure it yourself, but can use the balenaHub and the preconfigured gpsTime project.

We do not waste time on fancy logos 😉

Basically you just need an RPi B+ (2/3/4), Micro SD Card, Powersupply and 3v3 TTL Level GPS Module with PPS Output. The rest is just done by going on the balenaHub entry shown above, creating a free account and flashing balenaOS onto your SD card, booting the RPi on the internet for the first time and let it get the needed containers. Afterwards you can use the RPi offline and still enjoy your precise time source.

A watterott CQM-M8Q Breakout and an good old RPi 2B+ are more than powerful enough

More details can be found in the Github Repo and you can work and improve that project to your hearts content. I am probably going to do an PiAndMore talk about it - and use the project myself as a block for precise timing in some support equipment.

[WSL2/Win10] Limit Resource Consumption of WSLv2

Windows Subsystem for Linux 2 has a big problem called "Vmmem" - it is the process WSL uses to allocate RAM for usage within its user context. That itself is all fine, however, there are many known issues that show that even after closing your e.g. Debian session, this memory is not returned to the system. This is also valid for usage of Docker for Windows within the WSLv2 context (meaning using Docker in the "new-style" install, not with the old HyperV machine).

The easy way to mitigate the pain (meaning RAM-being eaten up faster than a Chrome Engine spinning up ;)) is to just shutdown the WSL engine after usage, which you can do by opening up a Powershell or CMD with admin rights and enter

wsl --shutdown

This will shutdown WSL until you start it manually again. (Thanks smigel!)

A better way to work with this is to create a .wslconfig in your Windows User directory. Here is a short example.

[wsl2]
 memory=2GB # Limits VM memory in WSL 2 to 2 GB
 processors=2 # Makes the WSL 2 VM use two virtual processors
 swap=0 # Do not use a swap file

Anyway, the issue is still open and not yet fixed, even though a fix was promised on 17.06.2019. Worse, Microsoft locked the issue in July 2020 for "spam". Talking about bad customer experience...

[WSL2/Win10] Install WSLv2

1.) Open an administrative Powershell and activate the WSL feature

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

2.) Activate the Virtual Machine Platform, afterwards reboot your computer

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

3.) Download and install the WSLv2 Linux Kernel package from https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi - another Reboot is needed afterwards

4.) Set WSLv2 as default WSL - open an administrative Powershell and enter

wsl --set-default-version 2

5.) Install one or multiple operating systems in WSLv2 - you can find them here. You can also install these "offline", meaning without the need to use Windows Store. For the offline install, download the needed package from this link, then install it by doubleclicking on the Icon - or via Powershell with

Add-AppxPackage .\app_name.appx

You can then start and use it :).

Its also not a bad idea to install Windows Terminal.

Presentations with Markdown: revealjs

Being an active contributor to the PiAndMore and other conferences, I happen to make quite a few presentations a year. In the past I was using the good old Microsoft Powerpoint - which has its strengths, but also its drawbacks. Positioning text and graphics were never my taste (I use LaTeX, btw) - so I set out to find a new way to create presentations - and found revealjs back in 2018.

What is revealjs? Basically: Write your presentations in Markdown. Show in a Webbrowser - or export as PDF. TL;DR? Navigate through the demo.

However, using revealjs by its own was cumbersome, I was missing a live preview - and while all of this was available at its freemium service slides.com - I do not want to be dependant on online connection - nor share every presentation with the world (some might involve senstive data... so no).

That was when I started to use hacker-slides - a small Go implementation for all OS types, with a Live Preview, local/offline usage. It was near perfect, other than issues like having problems with carriage return and similar signs at some points (usage other Windows...) and some other stuff (I lost some presentations when I opened up too many at the same time and edited different presentations in different tabs). It was also the first project where I changed some Go code for my local copy. However, the final nail in the coffin was that this project is not really maintained anymore.

Enter vscode-reveal - it works in VSCode or Codium - has live preview and all the features you need. Your basic, local, revealjs powered, operating system independant presentation-making-machine.

I have used it for the latest PiAndMore - and I am not going back to anything else (at least for the time being) - so maybe you want to give it a try?

Use Sonarqube with sonar-cxx

Installation

  • Download SonarQube from https://www.sonarqube.org/downloads/
    • If you are using Java 8, you need to download SonarQube 6.7.x LTS (look for Historical Downloads on the website)
    • If you are using Java 11 - SonarQube 7.9.x LTS (look for Long term support area on the website)
  • Unpack the SonarQube ZIP file
  • Download the latest sonar-c-plugin.jar and sonar-cxx-plugin.jar from https://github.com/SonarOpenCommunity/sonar-cxx/releases
  • Insert both jar files into the SONARQUBE_HOME/extensions/plugins extensions directory (within the unpacked ZIP file)
  • Start SonarQube and Login
    • On Windows 10, e.g. via SONARQUBE_HOME/bin/windows-x86-64/StartSonar.bat
    • Go to http://127.0.0.1:9000 as soon as "SonarQube is up" is announced
    • Default login is user admin, password admin
  • Navigate to Administration -> Marketplace and make sure the plugins "C (Community)" and "C++ (Community)" are installed

Configuration - General

  • Additional configuration can be done under Administration -> Configuration -> General Settings within the "C (Community)" and "C++ (Community)" areas

Configuration - Quality Profiles

  • You need to enable for which kinds of problems both plugins should scan. This needs to be done initially, as otherwise they will not detect anything by default.
  • Example for C (Community)
    • Go to Quality Profiles, click on the downwards arrow next to the "Sonar way (Built-in)" profile within the "C (Community)" area. Click Copy. Give it a catchy name, like "Sonar way - C"
    • A new quality profile pops up, you see the Rules (Bugs, Vulnerabilities, Code Smells) in the left table. You can click "Activate more". In the next table, you see the rules sorted by the same types. You can click all three types on the left side and mark them this way - if you want and then click on "Bulk Change" and "Activate In "Sonar way - C"" to activate all rules within our newly created Quality Profile. You have to acknowledge the change and SonarQube will report back as soon as the changes are done.
    • You can now navigate back to Quality Profiles, click on the downwards arrow next to the "Sonar way - C" profile within the "C (Community)" area and click on "Set as Default".
    • With this change, your newly created profile will now be used for the next scans.

Prepare first scan of C Code

# must be unique in a given SonarQube instance
sonar.projectKey=TestApplication
# defaults to 'not provided'
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=.
#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
# project is c, please scan with c plugin (one needs to be enabled)
sonar.language=c
# project is c++, please scan with c++ plugin (one needs to be enabled)
#sonar.language=c++

First scan of C Code

  • Open up a shell within the project folder with the sonar-project.properties file
  • Within this shell, execute SonarScanner by starting its sonar-scanner exectubale, e.g. "D:\sonar-scanner-4.5.0.2216-windows\bin\sonar-scanner.bat"
  • The scanner will now work through the project and once its done, send the data to the SonarQube server, where it will be computed and shown as project

More infos

[Win10] Download Enterprise ISO with Media Creation tool / check ISO for available editions

Download latest Enterprise ISO

To download the latest Windows 10 Enterprise ISO:

.\MediaCreationTool20H2.exe /Eula Accept /Retail /MediaArch x64 /MediaLangCode en-US /MediaEdition Enterprise
  • You will need to enter the license key / serial to be able to download the Enterprise style ISO (you will not be able to chose any type, this is done by the /MediaEdition switch, as well as the language etc..)

Check ISO for version information and available editions

  • mount ISO in Windows 10 (here mounted as D:)
  • execute this
dism /Get-WimInfo /WimFile:D:\sources\install.esd
  • you will get infos about what is in the ISO (in old versions, the install.esd was known as install.wim, then you need to launch that tool with install.wim instead of install.esd at the end)
Deployment Image Servicing and Management tool
Version: 10.0.18362.1316

Details for image : D:\sources\install.esd

Index : 1
Name : Windows 10 Education
Description : Windows 10 Education
Size : 15.736.130.486 bytes

Index : 2
Name : Windows 10 Education N
Description : Windows 10 Education N
Size : 14.956.748.370 bytes

Index : 3
Name : Windows 10 Enterprise
Description : Windows 10 Enterprise
Size : 15.736.284.481 bytes

Index : 4
Name : Windows 10 Enterprise N
Description : Windows 10 Enterprise N
Size : 14.956.654.647 bytes

Index : 5
Name : Windows 10 Pro
Description : Windows 10 Pro
Size : 15.734.489.825 bytes

Index : 6
Name : Windows 10 Pro N
Description : Windows 10 Pro N
Size : 14.959.031.814 bytes

The operation completed successfully.
  • If you start the tool a second time with a specific index, you can find out more about that "shard", e.g.to find out more about the Enterprise version, launch the tool with
dism /Get-WimInfo /WimFile:D:\sources\install.esd /index:3
  • you will get these infos
Deployment Image Servicing and Management tool
Version: 10.0.18362.1316

Details for image : D:\sources\install.esd

Index : 3
Name : Windows 10 Enterprise
Description : Windows 10 Enterprise
Size : 15.736.284.481 bytes
WIM Bootable : No
Architecture : x64
Hal : acpiapic
Version : 10.0.19041
ServicePack Build : 631
ServicePack Level : 0
Edition : Enterprise
Installation : Client
ProductType : WinNT
ProductSuite : Terminal Server
System Root : WINDOWS
Directories : 24132
Files : 96485
Created : 19/11/2020 - 04:20:58
Modified : 10/02/2021 - 14:13:25
Languages :
        en-US (Default)

The operation completed successfully.

[Win10] Offline installation of FoD like OpenSSH Server without VLSC ISO

Windows 10 comes with a lot of additional options to install, which are not part of the "local" installationmedia.
That means things like e.g. the OpenSSH Server component. These options are called "Features on Demand" (FoD) and do need either an active internet connection to download and install, or a specializied FoD ISO which you only can download from the Microsoft Volume Licensing Service Center (VLSC). If you need to install these options for your Windows 10 Professional or similar offline - without having a valid subscription, you cannot get the needed offline files that way.

However, there is another option by using a second computer with the same Major Release (e.g. Windows 10 1909 / 2004 / or 20H2 aka 2009) and possible latest patches installed to grab those files from the internet and then use these for offline installation.

Example, we want to get the OpenSSH Server package for Windows 10 20H2 / 2009 and install it offline afterwards.

  1. Get a Windows 10 20H2 computer connected to the internet, patched to latest version
  2. Download Everything ( https://www.voidtools.com/ - the portable version will do ) - this is a tool to scan for changes in the windows filesystem
  3. Start it, if it asks for admininistrative rights, say yes
  4. Enter "C:\Windows\" in the search path, so that only changes in the Windows path will be shown in Everything, so that you don't drown in information

5. Open an admininistrative Powershell - you can know search for the latest version of the FoD package you want to install, like
Get-WindowsCapability -Online |? Name -like 'OpenSSH.Server*'

This will get us info like:

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
  1. Now, this is were it gets tricky. You need to start the download of the package, track it traversing through the filesystem with Everything and copy it before it gets deleted again by Windows after installation. You might need to repeat the process several times, but here it is in a full write up

6a. Enter
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
which will start the download & installation

6b. Watch the Everything window. At some point a cab file with OpenSSH will pop-up within the C:\Windows\SoftwareDistribution\Download folder. Select that file. And press CTRL+C to copy it.

6c. Move the focus of the mouse to your Desktop or other folder, at some point the file path of the selected file will change to C:\Windows\CbsTemp because it was done with downloading and will start to be installed. Your selection and copy will still be valid and now target this new file. Hence you need to hit CTRL+V to paste/copy it to your desktop fast, because it will disappear within seconds.

6d. If everything went ok, you will have the cab file with some MB size (in case of OpenSSH-Server-Package~31bf3856ad364e35~amd64~~.cab its just ~1.22 MB) and thats what we need. If you were to slow, you can try again by uninstalling the OpenSSH Server via powershell using
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
then start at 6a and repeat until it works

6e. One word of caution - the filename will stay the same for all Windows 10 Release Versions. So it would be wise to put it into a folder with the version name - so that you don't mix up differnt versions. Also don't change the filename of the cab file, otherwise it cannot be used for installation anymore.

  1. Move the file to your target / isolated system.
  2. Powershell with Admin Rights to the correct folder with e.g. OpenSSH-Server-Package~31bf3856ad364e35~amd64~~.cab in it, then execute the installation command:
    Add-WindowsCapability -Online -Name "OpenSSH.Server~~~~0.0.1.0" -Source "." -LimitAccess

It is going to be installed. But as additional stuff…

// Set Services to Autostart
Set-Service sshd -StartupType Automatic
Set-Service ssh-agent -StartupType Automatic
// Check if Firewall Rule is activated
Get-NetFirewallRule -Name *ssh*
// There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
// If the firewall does not exist, create one
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
// Configuration of OpenSSH Server
// You can set Powershell as default shell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
// Start Service 
Start-Service sshd
Start-Service ssh-agent

xkcdpass - secure passwords for transport

Passwords are problematic. Always. Especially during COVID-19 - were you have to securely transport data via insecure means. What I want to say: Sending confidential data via email. Actually, thats quite easy: (7)-zip everything with AES256 using a long enough key - transfer the key via additional, more secure lines of communication (e.g. phone) and you are ok for the most part.

However, spelling %-FoPN#~OeJQ0h9g3_JWrvnq9h^ip))srzg{\vnj via phone is "a bit cumbersome". Thats the moment you recall Randall Munroe's xkcd #936 Password strength:

And with this basic idea, xkcdpass was born. It can generate passwords from multiple dictonary entries, seperated by some symbols and generate things like showcase surging swoosh bakeshop smoked duffel - and you can also tweek the settings to change the amount of words used, length, delimters, etc.

It is written in python and can be installed via a quick pip install xkcdpass and then used with the command line paramter xkcdpass

All infos are in the Git repo found here.

Long enough sentences are good enough - and are awesome as "transfer keys" to secure the real data.