iftop
is a handy utility on macOS, Linux and other Unices for a live Terminal graph of network data flow to particular addresses.
On computers with many network interfaces, including virtual interfaces such as on macOS, it is handy to set a default interface in a config file.
iftop uses the file ~/.iftoprc.
For example, on macOS you may be interested in interface “en1”.
To help determine the desired interface, use ifconfig or ip a to find the interface with the public IP address.
Then create ~/.iftoprc containing like:
interface: en1
where “en1” is your desired interface determined as per above.
RHEL uses
firewalld
to provide network firewall.
firewalld has the concept of
runtime vs. permanent rules,
which help avoid getting the firewall into an unusable state.
Permanent rules become live at next restart/reboot, while runtime rules disappear at restart/reboot.
Suppose one wishes to put the SSH server on a non-default port 12345 to mitigate auth log clutter.
First configure the SSH server in /etc/ssh/sshd_config, then restart SSH and verify the SSH configuration is working by adding the port to firewalld (here, 12345):
firewall-cmd --add-port=12345/tcp
If this works, make the firewalld rule permanent:
firewall-cmd --permanent --add-port=12345/tcp
SELinux will also need an updated policy to allow the SSH port change, like:
To have the most reliable path operations in CMake, it’s typically best to resolve paths to the full expanded path.
Note: there are a few CMake functions that desire relative paths, but those are clearly spelled out in the docs.
expanduser.cmake for CMake expands the ~ tilde character to the user home directory on all operating systems, including Windows.
As a CMake project grows, increasing complexity can make it hard to discern what tests are to be run and their properties.
Perhaps the project logic is unexpectedly omitting necessary tests.
The CI system or human can verify the list of tests by:
ctest -N
For machine parsing and human-readable verbose details including fixtures and labels, output
JSON:
ctest --show-only=json-v1
To ensure an accurate test list, the project must first be configured and built as usual:
In many cases, using the Unix-type slash file separator / will work even on Windows.
Trying to manually specify backslash Windows file separator \ can cause problems in CMake and many other languages.
Thus in CMake and other languages like Python, we always use / as path separator, and only transform to backslash for the rare cases it’s needed.
That switches backslash \ file separators to Unix slash / file separators.
This becomes relevant if manually adjusting Include paths by appending to lib_INCLUDE_DIRS or similar.
If backslashes sneak through, unexpected build-time errors can result, and even configure-time errors with “check_source_compiles()” and similar.
As the docs note, put
quotes"${mypath}" around the variable expansion to ensure CMake doesn’t mangle the path.
Transform to
native file separator
is generally more rarely used.
CMake can transform paths to native file separator, with the caveat that this can cause unpredictable Windows-specific backslash problems, as with any program.
Note: it may be necessary to reinstall
Miniconda
from scratch if packages break during a Python version upgrade.
Consider this before attempting an in-place Python upgrade.
There is often a couple month delay between a major Python release and Anaconda defaulting to the new version.
Use the new Python version in a new conda environment by:
conda create -n py3x python=3.x
switch to this environment by
conda activate py3x
Legacy hard-coded GUIs using external libraries have considerable overhead to maintain, and suffer bit rot far faster than the underlying code.
At the very least, be sure your code is usable from the command line and/or as a plain importable module without requiring a graphics library.
In stripped-down cloud / embedded applications, unused graphical imports cause stability problems and considerable startup lag.
If too few ticks are displayed, as per the
Matplotlib MaxNLocator,
you must have “at least min_n_ticks integers…found within the view limits.”
Set “MaxNLocator(nbins=5,integer=True)” or similar if the defaults aren’t forcing integer ticks.
PyTest flips on DeprecationWarning and PendingDeprecationWarning as typically those running PyTest are a developer or advanced users.
When the package uses warnings.warn to emit a DeprecationWarning, it can be hard to know from where in the tested package a warning is coming from.
To turn on a large amount of warnings, similar to what might be seen on CI:
python -Walways::DeprecationWarning -m pytest
If there is only one type of DeprecationWarning being omitted, a simple way to find the source of the warning is
Python warning control-W.
This will raise an exception at the warning with traceback:
python -Werror::DeprecationWarning -m pytest
However, often there are multiple DeprecationWarning emitted from different sources, and chances are the one of interest isn’t the first.
Perhaps the warning comes from the Python distribution (e.g. Miniconda) itself.
In that case, one can insert temporary
warning trap
into the test function or the user function:
This might have to be done iteratively to get past the point where the uninteresting DeprecationWarning happen until you home in on the location of the DeprecationWarning of interest.
Git 2.31 added the ability to
maximally resolve
the parts of a merge commit, where some parts could not be auto-merged.
This workflow isn’t good for some types of project, but a lot of projects and devs use this setting.
Set this globally (it can also be set per-repo and/or per merge tool):
This procedure works for Matlab on most Linux systems including Ubuntu and RHEL.
Extract all files from the Matlab installer archive, and run (without sudo)
./install
Install Matlab under “/home/username/.local/” since Matlab is tied to the Linux username anyway.
The user will have problems updating Matlab or installing Add-On Toolboxes if Matlab is installed outside the user home directory.
Install Symbolic Links to “/home/username/.local/bin/” when asked by the GUI.