Scientific Computing

Git commit PGP signing

Git signed commits help verify the Git author’s identity using PGP. Optionally, a user or organization can set rules requiring Git PGP signed commits on Git hosting providers such as GitHub and GitLab

PGP public keys can help verify author identity of Git commits, social media, website, etc. Setup GPG on the laptop:

  • Linux: apt install gnupg
  • macOS: brew install gnupg
  • Windows: winget install gnupg.Gpg4win

Generate a GPG keypair if one doesn’t already exist for yourself.

Export the GPG public and private key and import into GPG:

gpg --full-generate-key
gpg --armor --export-secret-keys > private_key.asc
gpg --armor --export > public_key.asc

Verify PGP key:

gpg --list-secret-keys --keyid-format LONG

The first lines will be like:

sec   rsa4096/<public_hex>

The hexadecimal part after the / is a public reference to the GPG keypair.


Add Git provider such as GitHub or GitLab verified email address to the PGP key. To make commits “Verified” with the Git provider, at least one of the Git provider verified email addresses must match:

git config --get user.email

Use the GPG public ID below:

gpg --edit-key <public_hex>

In the interactive GPG session that launches, type

adduid

and enter Name and the Email address–which must exactly match the GitHub verified email address. I also add the @users.noreply.github.com fake email that I always use to avoid spam. Do adduid twice–once for the real GitHub verified email address and again for the github_username@users.noreply.github.com fake email.

Add “trust” from the GPG> prompt:

trust

Since it’s you, perhaps a trust level of 5 is appropriate. type

save

to save changes, which may not show up until exiting and reentering the GPG> prompt.

Configure Git to use the GPG public hex ID like:

git config --global user.signingkey <public_hex>

git config --global commit.gpgsign true

Add the GPG public key to the Git provider. Copy and paste the output from this command into GPG Key of GitHub or GitLab. This is done only once per human, not once per device.

gpg --armor --export <public_hex>

Windows

On Windows, additionally do

git config --global gpg.program "$Env:ProgramFiles (x86)\GnuPG\bin\gpg.exe"

macOS

On macOS, additionally do

brew install pinentry-mac

and add to ~/.zshrc:

export GPG_TTY=$TTY

Usage

GPG can be used to sign Git commits and tags, and can also be disabled per commit.

Verify Git PGP commit sign

Make a git commit after the procedure above, and see the signature notes:

git log --show-signature

it will start with

gpg: Signature made

Temporary disable Git commit sign

If you temporarily lose access to the GPG password, you won’t be able to git commit. A temporary workaround is to set

git config commit.gpgsign false

or simply add the --no-gpg-sign option like:

git commit -am "msg" --no-gpg-sign

If not signing as default, sign only certain commits by

git commit -S

Note that’s a capital “S”.

Keybase.io PGP key export

Public PGP IDs can help verify author identity of Git commits, social media, website, etc. A popular free service to share PGP IDs is Keybase.io. Below we demonstrate using Keybase.io PGP ID with Git with the keybase.io client.

Setup GPG on the laptop:

  • Linux: apt install gnupg
  • macOS: brew install gnupg
  • Windows: winget install gnupg.Gpg4win Keybase.Keybase

Export Keybase.io public & private key and import into GPG:

keybase pgp export | gpg --import

keybase pgp export --secret | gpg --pinentry-mode=loopback --allow-secret-key --import

Verify PGP key:

gpg --list-secret-keys --keyid-format LONG

The first lines will be like:

sec   rsa4096/<public_hex>

The hexadecimal part after the / is a public reference to keybase.io keypair. It’s shown on the keybase.io public profile, next to the key icon.

CB radio base / mobile antenna

An affordable base station antenna for GMRS, MURS, or CB radio can be made from a mobile antenna at roof or balcony level. Be sure the antenna is well away from power lines for safety and noise. It’s important to get the tip of the antenna higher above ground level vs. antenna length. That is, a shorter antenna up high is often better than a longer antenna at ground level.

A mobile antenna near the roof peak using half a mirror mount can screw into the metal eaves for groundplane. A satellite TV dish mount can also be used, assuming a lightweight CB antenna that doesn’t significantly exceed the weight or wind load of the dish mount.

Groundplane

If the antenna is not mounted to metal, a counterpoise / groundplane can be employed at least by drooping a wire or wires 1/4 wavelength long (27 MHz CB ~ 9 feet) from the ground of the antenna base, connected to the coax cable shield.

For higher frequency MURS and GMRS or as a compromise at CB 27 MHz, a magnet mount antenna could be attached to a large dog kennel or magnetic baking sheet. A mobile antenna on the roof will perform poorly without a large magnetic surface to attach to. For safety, put weight on the groundplane or screw it into the balcony or roof to prevent it from blowing off in the wind.

Maximum communications range

Important factors for maximizing communications range include:

  • antenna tip height above average terrain
  • freedom from interference (noise, undesired signals)
  • antenna efficiency – 1/4 wavelength radiating element is desired – balancing length, weight and aesthetics. The mobile antenna should be of a type at least 3 feet long to be worthwhile as a base antenna for effective communication range.
  • antenna blockage by the roof or adjacent structures
  • ensure the power supply is linear to avoid noise–especially important at 27 MHz CB.

Depending on favorable terrain, base-to-base communication range on CB using omnidirectional antennas with at least 1/4 wavelength antenna with base (bottom) height of the antenna about 20 feet above ground, in clear terrain, and with clear channels can legally reach using various emissions modes:

  • AM: 20+ miles
  • FM: 15+ miles
  • SSB: 30+ miles

In contrast, a base station antenna in an urban area on a first-floor deck (say 5 feet above ground) may have only 1/2 mile to 3/4 mile range on CB, MURS, or GMRS to mobile or portable units–similar to simply having a portable unit at the base location.

Estimate communications range using a voice activated recorded at the base station and drive around, giving location on each transmission. Compare CB range to MURS or GMRS range with multiple radios near the recorder.

FM and CTCSS

FM mode is strongly preferred for family and neighborhood communications. For CB radios capable of FM and CTCSS, the squelch can be set to only open for the group’s chosen CTCSS tone. The choice of FM mode and CTCSS is not about maximum communication range, but about reducing interference from other users on the same channel. If the family members or group turns off the radio because of static and interference, that’s no radio at all. Better to have shorter range village communication than no communication at all. CTCSS on CB radio finally largely levels the playing field with other license-free radio bands like MURS and GMRS that could always use FM and CTCSS.

A CB radio gives a heads up when members of a family or group are coming back home. This gives some peace of mind in case of a breakdown, in that the home base or another base station can be reached on the local channel.

Git difftool / mergetool with Visual Studio Code

Many developers already use Visual Studio Code, which is a free open-source program available for Linux, macOS and Windows. VS Code can do Git 3-way merge.

VS Code for Git difftool and mergetool:

git config --global diff.tool vscode

git config --global merge.tool vscode

git config --global difftool.vscode.cmd "code --wait --diff \$LOCAL \$REMOTE"

git config --global mergetool.vscode.cmd "code --wait --merge \$REMOTE \$LOCAL \$BASE \$MERGED"

Note the backslashes so that the shell doesn’t gobble the “$” variables before they’re saved to user global ~/.gitconfig.

This process assumes that VS Code shell command is setup.


Alternative: Meld

Intel oneAPI / Visual Studio debug library build

On Windows, when building an executable target in Debug mode using Visual Studio or Intel oneAPI, it may be necessary to also have the libraries linked by the target to have Debug symbols. For example, when building in CMake:

cmake -B build -DCMAKE_BUILD_TYPE=Debug

cmake --build build --config Debug

This may be indicated by messages like:

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.cpp.obj

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.cpp.obj

The solution is to build the libraries with Debug mode as well.

Homebrew vs. MacPorts package managers

macOS package managers allow easy download, build and install of developer programs and libraries.

Homebrew is by far the most popular macOS package manager. Homebrew has a large number of packages and the ability to create unofficial “taps” to easily distribute software. Homebrew taps allow distributing binaries via Homebrew before going to include in the main homebrew package repo, which takes time and justification. Homebrew distributes per-OS compiled binaries, so package install time is almost instant. It is possible to also download source and build locally with Homebrew if desired.

MacPorts generally distributes source code that is compiled on install, although it can also use precompiled binaries. Macports installs packages under a prefix.

Homebrew is much more popular than MacPorts or Fink.

Package popularity comparison:

CMake find with Homebrew

Anaconda Python puts itself first on PATH when activated. This can become a problem for libraries like HDF5, where “conda install h5py” puts compiler script h5cc on environment variable PATH before the intended script path. For systems where Homebrew is used to provide packages to find from CMake, tell CMake to prefer a package location with CMAKE_PREFIX_PATH.

export CMAKE_PREFIX_PATH=$(brew --prefix)

CMake Git inactivity timeout

CMake Git operations such as shallow clone can cause unexpected failures due to too small INACTIVITY_TIMEOUT in ExternalProject or FetchContent. Be sure to set INACTIVITY_TIMEOUT to a large enough value. 15 seconds is too short a timeout for Git shallow clone, for example. Consider 60 seconds or larger INACTIVITY_TIMEOUT.

Check for timeout in:

git config --get http.lowSpeedLimit
git config --get http.lowSpeedTime

lowSpeedLimit might be set to 1000 (bits/second) or as appropriate for the network. If lowSpeedTime is too short, this download failure can also occur. Set to 60 seconds or more.

CMake generator full path

Normally it is not necessary to specify the path to the CMake generator backend, assuming the generator executable is in environment variable $PATH or CMAKE_PROGRAM_PATH. For special use cases such as testing CMake with different versions of a generator the generator executable absolute path may be specified via CMAKE_MAKE_PROGRAM. The absolute path to the generator is necessary or CMake will not find it.

Suppose a GitHub Actions Linux image has ninja-linux.zip containing executable file “ninja”. Get the absolute path using realpath.

    - run: unzip ninja-linux.zip

    - name: CMake configure
      run: cmake -G Ninja -DCMAKE_MAKE_PROGRAM=$(realpath ./ninja) -Bbuild