Matlab can extract .zst Zstd files, assuming the Zstd program is installed.
Zstd is widely supported and available across operating systems.
Use
extract_zstd
Matlab function to extract Zstd files.
FFmpeg can
convert
audio files to
Opus
format.
Opus is playable in many web browsers and players in general.
Opus is highly effective across a wide range of bitrates, from low (≪ 64kbps) for speech and high music bitrates.
ffmpeg -i in.wav -codec:a libopus out.opus
Typically it’s desired to set a specific output bitrate.
The bitrate affects the audio quality–lower bitrate sounds more flat and mechanical.
Developers often use scripting languages for common tasks and utilities outside the main program language or compiled executables.
For example, Git is a popular C program that uses numerous Python scripts for utility functions.
Scripting is commonly used where it’s burdensome to implement non-core functionality in the main project language.
There can be a runtime speed penalty for scripts, which is why popular utilities may eventually be recoded in the compiled project language.
As in spoken and written language, there is no one scripting language that will suit all environments.
Nonetheless, there are scripting language choices that more closely meet universal applicability with today’s computing environments.
When thinking of long-term reproducibility, scripting is also a factor to consider.
For example, Perl, Python and Ruby are long-popular scripting languages that aren’t installed by default on Windows.
Powershell is installed by default on Windows and is available on macOS and Linux, but not installed on the latter two by default.
The
default shell
varies between operating systems and distros.
For development-oriented work we use CMake scripts instead of Python for tasks that CMake is a better fit for, such as finding and executing programs.
I don’t think there will practically ever be a universal scripting language, as the language would have to be universally installed by default across operating systems and distros to be immediately useful.
Instead, we can have practical scripting languages targeted toward specific communities.
For example, where a project already requires CMake and the scripting task is a good fit for CMake script, it may make sense to put utility scripts in CMake instead of Python for example.
This can be true even for mixed Python-CMake projects.
Sometimes we default to put every script in Python, when it may be easier and make more sense to put a subset of scripts in CMake instead.
CMake
scripts
are executed with (optional)
options
like:
Like with
shell scripts,
standalone CMake
scripts
can have a first-line shebang that tells the shell what program should execute the script.
#!/usr/bin/env -S cmake -P
While there’s no harm in adding this shebang to CMake scripts, is there a way to pass dynamic “-Dvar=value” to the script when using the shebang like “./myscript.cmake”?
If the script is OK without such parameters, then the shebang can be useful.
CMAKE_COMMAND
can be used to directly invoke CMake scripts with options.
This is particularly useful to chain CMake scripts during CTest runs with
fixtures.
It’s important to set the minimum CMake version in the CMake script file as otherwise CMake defaults to CMake < 2.6 policies.
That makes current CMake syntax fail in puzzling ways.
Example:
Suppose a test script that reads a file using regex.
This will fail without cmake_minimum_required() or cmake_policy().
I prefer cmake_minimum_required to make the script fail if someone uses the script directly with too-old CMake.
CMake can retrieve and use Git submodules as a regular subdirectory.
This is an alternative to using FetchContent when the project team decides to use Git submodules instead of FetchContent as in this
example:
Some CMake tests need to use shell redirection to input file content.
This is often done on Unix-like systems by invoking sh -c.
Powershell can also work (including on Windows) if proper escaping is used:
CMake
ExternalProject
builds arbitrary projects without interacting with the top level CMake project.
Via ExternalProject, CMake can build child projects for virtually any build system including Make, Autotools, Meson, CMake, etc.
A distinct technique is needed to pass a CMake
list
to ExternalProject.
As a reminder, CMake lists are defined as semicolon-separated strings.
In this example the CMAKE_ARGS are arbitrary, we just put some typical arguments.
The key syntax to observe are that CMAKE_CACHE_ARGS is used to pass any lists.
A reason this is necessary is that CMAKE_ARGS is passed as a command line.
CMAKE_ARGS can also have problems if many long arguments are used, particularly on Windows where the maximum command line length could be exceeded.
We don’t use CMAKE_CACHE_ARGS carte blanche because some arguments may not be intended to be cache variables.
NOTE: the variable type must be passed to CMAKE_CACHE_ARGS, as when setting any cache variable.
Securely connect to a
VNC server
tunneled over SSH from Windows with this procedure.
We use SSH tunneling for the insecure VNC protocol as for other insecure protocols like RDP.
This procedure works from a local Windows PC to a remote VNC server on Linux,
macOS,
etc.
We assume the remote server computer has an SSH server and VNC server already setup.
On the local client computer, add to the ~/.ssh/config for this Host a line like:
LocalForward 5990 localhost:5900
where 5900 is the VNC port on the remote PC, and 5990 is an arbitrary distinct port on the local PC to avoid clashes on 5900.
Note: the VNC server might use port other than 5900.
On Linux a common default VNC port is 5901.
To connect, ssh to the server as usual, then use VNC Viewer to connect to localhost::5990.
When the SSH connection (tunnel) is closed, so is the VNC connection.
While CMake binaries can be downloaded for most platforms, there are certain cases where one wishes to build CMake from source.
For example, when preparing a merge request to fix or enhance CMake.
Usually the computer will have at least an older version of CMake that can be used.
If so, we recommend using CMake to build the newer CMake, from the CMake source directory.
We recommend using
Ninja
in general for faster build and rebuild for any CMake project.
If an old CMake isn’t available on the computer, then use CMake bootstrap:
./bootstrap --prefix=$HOME/local/cmake-dev --parallel=4 -- -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON
make -j4
make install
The OpenSSL flag is particularly important for CMake use connecting to the internet.
This puts the compiled CMake under ~/local/cmake-dev, without disturbing the primary CMake install.
Upon making any CMake code changes, simply recompile the minimum needed bits by: