Traceability of a binary artifact such as an executable or library can be improved by writing information about the Git repository status into the artifact itself.
This is a finer-grained implementation of the version number we are accustomed to seeing in the command line interface of executables.
This example doesn’t cover every possible thing to be traced, for example non-version controlled artifacts that are linked in.
This example just covers the Git repo of the current CMake project.
Nonetheless, those needing more advanced traceability can build upon this example.
Usually for easier reuse across projects, we put this in a separate CMake script file like gitrev.cmake and include it from the main CMake project.
allows specifying details options to control HTTP behavior via
Typical options that are modified include Timeout and SSL Certificate checking bypass.
While SSL certificate checking adds security to web operations, some HPC systems have old or broken certificates.
Other systems may simply need environment variable SSL_CERT_FILE set to tell Matlab’s vendored cURL where the cert file is.
As a last resort, certificate checking can be turned off, but this opens up code / file integrity and concomitant security issues.
A generally better solution than disabling certificate checking is to configuration your user profile to tell cURL and Git the location of the system certificates.
For this example we assume the certificate file is at “/etc/ssl/certs/ca-bundle.crt”.
cURL SSL config
set environment variable by editing ~/.bashrc
This for example can fix issues with Matlab websave() that uses Matlab’s vendored cURL.
Matlab on Travis-CI
is useful to automatically unit test Matlab code on each git push as with other coding languages.
As typical for CI, we use a “.travis.yml” file in the Git repo to control Travis-CI behavior.
Concurrency is built into Python via
AsyncIO generators are implemented with yield much like synchronous generators.
also simplifies expression of asynchronous for loops.
As in Julia, the expression of asynchronous structures in Python does not implement concurrent execution.
Concurrent execution in Python is governed by collections of tasks or futures such as
and initiated by a runner such as
asyncio.run() doesn’t handle all use cases.
may need specific
asyncio loop configuration.
The options needed are not the same for every project, depending on the asynchronous functions used.
uses AsyncIO subprocess, which needs ProactorEventLoop on Windows in project __init__.py:
if os.name =="nt":
For networking apps using
the ProactorEventLoop emits numerous warnings with trapped RuntimeError.
A workaround is to not use the ProactorEventLoop.
Do this by adding to project __init__.py:
if os.name =="nt":
Matlab users can share code projects as toolboxes and/or packages.
work for Matlab ≥ R2008a as well as GNU Octave.
Matlab toolboxes work for Matlab ≥ R2016a and not GNU Octave.
The packages format brings benefits to toolboxes as well.
A key issue with Matlab vs. Python arise from that Matlab users often add many paths for their project.
If any function names clash, there can be unexpected behavior as it’s not immediately clear which function is being used without further investigation of path ordering.
As in Python and other languages, there is considerable benefit for using a package format where the function names are specified in their namespace.
To enable Matlab package format, we explain by example. Suppose a project directory structure is like:
To use these functions, the end users do:
This is where the namespace can have clashes, and with large projects it’s not clear where a function is without further introspection.
To make this project a Matlab / Octave package, change the subdirectories containing .m files to start with a “+” plus symbol:
Then multiple subdirectories can have the same function name without clashing in the Matlab namespace.
Suppose the function “mem1” is used frequently in another function.
To avoid typing the fully resolved function name each time, use the
Matlab packages can have
that are only accessible from functions in that level of the namespace.
Continuing the example from above, if we added function:
then only functions under +utils/ can see and use mysecret.m function.
mysecret() is used directly, without import since it’s only visible to functions at that directory level.
Matlab toolbox .mltbx
Matlab .mltbx toolboxes became available in R2016a.
The Matlab-proprietary toolbox format also allows end users to create their own packages containing code, examples and even graphical Apps.
In effect .mltbx provides metadata and adds the package to the bottom of Matlab path upon installation.
The installation directory is under (system specific)/MathWorks/MATLAB Add-Ons/Toolboxes/packageName.
Whether or not the project uses .mltbx, the namespace of the project is kept cleaner by using a Matlab package layout.
A software package may have Matlab and Python functions.
Plain Matlab code can be included via Pytest for Matlab and GNU Octave.
To test the Matlab functions from Pytest, create a test_matlab.py file like:
from pathlib import Path
R = Path(__file__).parent
OCTAVE = shutil.which('octave-cli')
MATLAB = shutil.which('matlab')
@pytest.mark.skipif(not MATLAB, reason="Matlab not available")
subprocess.check_call([MATLAB, '-batch', 'assertSuccess(runtests)'],
@pytest.mark.skipif(not OCTAVE, reason='octave not found')
This assumes the Matlab test script resides in the same directory as the test_matlab.py file, and is named like test_api.m.
NOTE: Be sure that Matlab “runtests()” actually picks up the desired tests.
We do not want the Matlab output to say
The Fitbit app on certain phones with certain devices can sometimes fail to sync.
This might happen multiple times a month.
To workaround this issue, try force stopping the Fitbit app.
This normally shouldn’t lose any data, and reopening the Fitbit app and dragging down should re-sync in a few seconds.
Also, check that Bluetooth is enabled on the Android device.
Finally, try rebooting the phone and watch if the previous steps don’t help.
Force stop Android app
Force stop an Android app by:
Settings → Apps and Notification → Sell all apps → scroll to app name and click → click Force Stop