Adding the -f option to pgrep and pkill searches the whole command line, instead of the default first 15 characters.
This is useful for example with chromium-browser that actually lists in ps as /usr/lib/chromium-browser/chromium-browser–too long for pgrep and pkill default to find.
pgrep -f chromium
works, while
pgrep chromium
does not work with default settings.
Make this change persistent by adding these lines to ~/.bash_aliases
aliaspgrep="pgrep -f"aliaspkill="pkill -f"
Examples for Chromium:
find running process by name: pgrep chromium returns the PID (integer).
The
PiCamera Python module
acquires RAW Bayer masked data from the color Raspberry Pi camera module.
Getting raw Bayer images from the camera into 2592 x 1944 pixels for the V1 camera, 3280 x 2464 for the V2 camera requires a program as simple as:
importpicameraimportpicamera.arraywith picamera.PiCamera() as cam:
with picamera.array.PiBayerArray(cam) as stream:
cam.capture(stream, 'jpeg', bayer=True)
img = stream.array
If a remote PC with the graphical Dropbox client isn’t syncing, it may be due to a reboot where the Dropbox dæmon didn’t restart because there was no remote login to the graphical desktop. Dropbox can be remotely restarted over SSH with the command
Format a micro SD card to FAT32 (find the SD card device name from df – be sure you don’t overwrite your hard drive!).
Let’s suppose you found your SD card at /dev/mmcblk0, then:
Setup Red Pitaya NMR image: format a micro SD card to FAT32 (find the SD card device name from df – be sure you don’t overwrite your hard drive!). Let’s suppose you found your SD card at /dev/mmcblk0, then:
cd ~
git clone https://github.com/pavel-demin/red-pitaya-notes
Run the NMR control program
cd red-pitaya-notes/projects/pulsed_nmr/client
python3 pulsed_nmr.py
You should see some perturbation (even if essentially zero amplitude) in the NMR trace plot.
If “start” button doesn’t change to “stop” when clicked, that can indicate that the Red Pitaya NMR dæmon is not running. Be sure you copied over the correct image to the SD card when you did the unzip step.
pulsed-nmr consumes about 8% CPU when generating a waveform and 5% CPU when idle.
Recompile server code: this is precompiled and running as a service in Pavel’s image.
TODO: Does it take rewriting the image since the SD card filesystem is read-only?
Matlab and Octave are popular for machine learning prototypes due to their easier to learn (vs. R) interface.
Python via scikit-learn is also a top choice for machine learning.
Here’s how to install LibSVM for Matlab and GNU Octave.
Prereqs:
apt install make git g++
Compile LibSVM
git clone https://github.com/cjlin1/libsvm
cd libsvm
make
Creates executables svm-train svm-predict svm-scale.
Compile the Matlab/Octave and Python modules, for which the API is similar.
Compile LibSVM Matlab/Octave module
cd libsvm/matlab
Open Matlab or Octave, and from that internal Terminal, type (this uses make.m)
make
which creates a few .mex files.
See the matlab/README for examples of using LibSVM from Matlab and Octave.
Compile LibSVM Python module
cd libsvm/python
make
See the python/README for examples of using LibSVM from Python.
The authors estimate about 75% of PMTK3 is available from Octave, while Matlab support is comprehensive.
PMTK3 has been in maintenance mode for a few years, as the world has moved on Python in significant numbers.
Nonetheless, PMTK3 should not be neglected for easy access to a wide variety of machine learning methods.
Install PMTK3:
git clone https://github.com/probml/pmtk3
cd pmtk3
From Matlab or Octave:
initPmtk3
which downloads supplementary files (one-time).
Run programs like demos/bigO.m