Scientific Computing

Linux no install recommends default

Linux package managers like Apt and DNF can be set to not install recommended packages by default, which can be useful for headless embedded systems or WSL. This can save 100s of MB or more, which can be important for embedded systems or WSL to save time and disk space. Saving of download/install time is often relevant to CI/CD systems. A caveat is that some expected features may be missing.

Apt

From the command line (without changing default):

apt install --no-install-recommends <package>

Create a file like “/etc/apt/apt.conf.d/95-no-install-recommends” with the following contents:

apt::install-recommends "false";

To override this setting at the command line, to install recommended packages add “–install-recommends” to the apt command line.

DNF

From the command line (without changing default):

dnf install --setopt=install_weak_deps=False <package>

Edit “/etc/dnf/dnf.conf” adding under [main]:

install_weak_deps=False

Locate Git submodule config file

Git submodules don’t put their individual Git config file under .git/config. This Git command issued from the Git submodule directory tells the file path to the Git submodule config file:

git rev-parse --git-path config

Say a repository “alpha” has submodule “beta”. Find the Git config file location of “beta” from “alpha” like:

git -C beta rev-parse --git-path config

# OR

cd beta
git rev-parse --git-path config

ImageMagick memory limits

NEXRAD preview PNGs are 12200 x 5400 pixels: example This takes over 650 MB of RAM to load each frame.

ImageMagick -limit option can be used to limit the amount of RAM and/or disk used by ImageMagick operations. For example, if processing images on an embedded systems like a Raspberry Pi, the limited RAM may lead to disk swapping, taking 1000x longer or failing anyway. Use combinations of -limit options to control RAM and disk usage.

magick -limit map 500MB -limit memory 500MB -limit disk 100MB in.png -scale 10% out.png

The -debug cache option show how ImageMagick is using memory for a magick command.

Install Anaconda Python in Windows PowerShell

On Windows, Miniconda can be installed from the Command Prompt or PowerShell:

winget install --id=Anaconda.Miniconda3 -e

Update conda from Command Prompt / Terminal:

conda update conda

Setup the new shell support (PowerShell, Bash, Command Prompt, etc.) with

conda init

Reopen Terminal to see new conda environment.


If message upon opening PowerShell like:

Documents\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system.

Consider ExecutionPolicy like:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

CTest WILL_FAIL segfault SIGABRT catch

By design, CTest WILL_FAIL test property does not handle segmentation faults and other unexpected terminations. That is, a failing test will also show as failed in CTest, when the desire may have been to show an intended failure as success via WILL_FAIL. A simple workaround for this is to make a wrapper call for the intentionally segfaulting executable and catch that result, as in example project.

Folder comparison with vscode

Visual Studio Code can compare folders via Extension Compare Folders. In Unix-like shells, an alias can be used to ease command line use:

alias vsdiff="COMPARE_FOLDERS=DIFF code"

Then, to compare two folders, use:

vsdiff folder1 folder2

vsdiff allows applying changes from the left to the right. To “swap sides” click the left-right arrow in the top right corner.

Apple Studio Display brightness adjust from Windows / Linux

The Apple Studio Display is designed for macOS brightness controls. A Linux or Windows computer has the brightness locked at the last setting. If the Studio Display power is reset, the brightness defaults to maximum.

Small open-source programs allow Linux and Windows computers to adjust the brightness of the Apple Studio Display.

Windows

studio-brightness.exe, is a C++ program downloaded from the Releases, or the program can be built from source. The keyboard uses the HID interface to adjust the brightness of the Apple Studio Display from Windows.

Twinkle Tray is a command-line or graphical brightness control that works for numerous external monitor models brightness control, including Apple Studio Display.

Linux

Choose from either of C++ HID interface asdcontrol or Rust asdbctl to adjust the brightness of the Apple Studio Display from Linux.

macOS

The complement of the above program is the MonitorControl macOS program that allows control of Apple and non-Apple displays from macOS.

Git submodule change remote

Git submodules can switch remotes. This is useful when making a pull request for a project that relies on another pull request submodule. Verify the change in the top project’s “.gitmodules” file.

Example: suppose the directory “subdir” is a Git submodule. In this command, do not put “./subdir” or “subdir/”, just “subdir” by itself. Suppose you also wish to change the branch to “feat1” in the submodule.

git submodule set-url -- subdir https://github.invalid/username/new

git submodule sync

git -C subdir pull

git -C subdir switch feat1

Xcode ld linker workaround

Whether using Clang / LLVM or Homebrew GNU GCC compiler, GNU ld is not supported on macOS. Only the Apple macOS Xcode ld is supported. The ld linker in Xcode 15 breaks numerous projects, including OpenMPI < 4.1.6. The workaround is to use the classic linker, which is still supported in Xcode 15.

Set in ~/.zshrc

export LDFLAGS="$LDFLAGS -Wl,-ld_classic"

or specify on the program command line like:

LDFLAGS="$LDFLAGS -Wl,-ld_classic" make

Note that for CMake, LDFLAGS environment variable is read only on the first CMake configure and cached.