Safely ejecting USB flash thumb drives in Linux

In Windows, we use safely remove devices when removing USB drives, as typical inexpensive flash drives write data quite slowly (less than 5MB/sec). This is because by default, Windows “write caches”, that is, Windows uses RAM to temporarily store files — making the copy/write operation appear done faster than it actually is.

In Linux, the write caching is used as well, and you should verify writing to a flash drive is completed by typing sync at Terminal and waiting for the $ prompt to come back up. You can watch the writing progress with iotop or the graphical indicator-multiload. You then click the Eject icon next to the flash drive’s name in your File Manager (in Ubuntu, it’s nautilus)

Consider that your flash drive only writes at say 2MB/sec. to be “safe”. Then, writing a 1GB file will take 1000/2=500 seconds = 8.3 minutes!

Compiling Octave 3.8 for Ubuntu 12.04 – 13.10

Looking to compile Octave 4.0?
—————–
For those looking for 64-bit Octave, which is not currently available in the PPA (As of Jan 2015), please examine:

http://calaba.tumblr.com/post/107087607479/octave-64

————————————————————————–

Note: The octave stable PPA finally (Apr 20 2014) has Octave 3.8.1.

https://launchpad.net/~octave/+archive/stable

I would recommend the normal user on Ubuntu 12.04 to consider using the PPA above, it will be much easier than the manual process below.
——————————————————————————————————————–
Download source:
wget -P ~/Downloads http://ftp.gnu.org/pub/gnu/octave/octave-3.8.2.tar.bz2

Extract to directory:
tar -C ~/Downloads -xvf ~/Downloads/octave-3.8*.tar.bz2

Prerequisites  (Ubuntu 13.10):
sudo apt-get install gfortran debhelper automake dh-autoreconf texinfo texlive-latex-base texlive-generic-recommended epstool transfig pstoedit libreadline-dev libncurses5-dev gperf libhdf5-serial-dev libblas-dev liblapack-dev libfftw3-dev texi2html less libpcre3-dev flex libglpk-dev libsuitesparse-dev gawk ghostscript libcurl4-gnutls-dev libqhull-dev desktop-file-utils libfltk1.3-dev libgl2ps-dev libgraphicsmagick++1-dev libftgl-dev libfontconfig1-dev libqrupdate-dev libarpack2-dev dh-exec libqt4-dev libqscintilla2-dev default-jdk dpkg-dev gnuplot-x11 libbison-dev libxft-dev llvm-dev

Prerequisites (Ubuntu 12.04.4):
sudo apt-get install gfortran debhelper automake dh-autoreconf texinfo texlive-latex-base texlive-generic-recommended epstool transfig pstoedit libreadline-dev libncurses5-dev gperf libhdf5-serial-dev libblas-dev liblapack-dev libfftw3-dev texi2html less libpcre3-dev flex libglpk-dev libsuitesparse-dev gawk ghostscript libcurl4-gnutls-dev libqhull-dev desktop-file-utils libfltk1.3-dev libgl2ps-dev libgraphicsmagick++1-dev libftgl-dev libfontconfig1-dev libqrupdate-dev libarpack2-dev dh-exec libqt4-dev libqscintilla2-dev default-jdk dpkg-dev gnuplot-x11 libbison-dev libxft-dev

Note: for Ubuntu 12.04, you will have to get LLVM 3.2 Binaries and extract somewhere — you’ll manually link to these in the configure step below.
E.g.
wget -P ~/Downloads http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz
tar -C ~/Downloads xvf ~/Downloads/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz

——–


cd ~/Downloads/octave-3.8.1

 

(Ubuntu 13.10)

./configure --enable-jit --prefix=/opt/octave3.8

(Ubuntu 12.04.4)
./configure --enable-jit --prefix=/opt/octave3.8 LLVM_CONFIG=~/Downloads/clang+llvm-3.2-x86_64-linux-ubuntu-12.04/bin/llvm-config

You may get the error:
configure: WARNING: JAVA_HOME environment variable not initialized. Auto-detection will proceed but is unreliable.
On my Ubuntu 13.10 PCs, Java was found automatically despite this error.


make

This takes about 30 minutes to compile on a Sandy Bridge i7-2600 CPU.


make check

I get:
PASS 11503
FAIL 0
XFAIL 7


sudo make install
sudo ln -s /opt/octave3.8/bin/octave /usr/local/bin/octave3.8

Now to run Octave 3.8 with GUI, at Terminal type:
octave3.8 --force-gui

You can of course make a bash alias to always add that –force-gui for you.

nano ~/.bash_aliases
and add the line
alias octave38="octave3.8 --force-gui"

Notes re: LLVM version:
Ubuntu 13.10 llvm-dev is currently LLVM 3.2. As of this comment from mtmiller on January 2014, Octave 3.8 requires LLVM 3.2 or 3.3 to compile:

https://savannah.gnu.org/bugs/?41061#comment9

Ubuntu 12.04 defaults to LLVM 2.9, which is now too old for Octave 3.8. I would suggest considering the Pre-Built Binaries

Note: Ubuntu 14.04 has Octave 3.8 by default – yay!

Note: As Ian notes in the comments, surf() seems to be broken with the otherwise fast and great FLTK plotting. As Ian notes, when you need surf(), circumvent this problem by falling back to gnuplot by typing in Octave:
graphics_toolkit('gnuplot')

Reference (Jordi G. H.):

http://octave.1599824.n4.nabble.com/Please-release-RC1-to-octave-unstable-PPA-td4659924.html

Converting AVI to grayscale PNG for easier analysis/viewing

An example of a large pixel-count AVI is the Dahlgren et al 2013 article on auroral bursts. This was taken with a 2560×2160 Andor Neo sCMOS camera and this video has 351 frames.

You can try this process to keep in a more widely-compatible MJPEG motion JPEG AVI format, or alternatively you can convert each frame to PNG and use Irfanview or your favorite image browser to flick back and forth between frames. The conversion occurs using ImageMagick (which itself calls ffmpeg in this case).


convert -verbose CMOSvideoshorter_halfspeed.avi -type Grayscale CMOSvideo_%03d.png

in this example, 351 PNGs will be created of about 1MB size each.

Cinepak videos in ImageJ

If someone has sent you an AVI file with Cinepak compression, you may find that ImageJ/FIJI and other contemporary software cannot read the AVI file.

There are two plugins that attempt to address this for ImageJ:

http://rsb.info.nih.gov/ij/plugins/jmf-player.html

http://rsb.info.nih.gov/ij/plugins/jmf.html

But I found neither of them to work for me on the particular AVI Cinepak video I was given.

Instead, I used FFMPEG to convert to a more modern widely-compatible Motion JPEG format by typing:
ffmpeg -i video1990s.avi -vcodec mjpeg -qscale 1 test.avi

If you need no loss, you can do uncompressed AVI, but note the output file size could be a factor of 10 larger than the Cinepak version:

ffmpeg -i video1990s.avi -vcodec rawvideo out.avi

You can compress to LOSSLESS FFV1 by typing:

ffmpeg -i video1990s.avi -vcodec ffv1 out.avi

You can also convert the AVI to a series of PNG images.

hamlib: Stopping/starting rigctld and rotctld via Bash script

Stopping rigctld and rotctld:


#!/bin/bash

# finds rigctl and rotctl PIDs and SIGTERMs them
# Michael Hirsch

RigPID=$(pgrep rigctld)
RotPID=$(pgrep rotctld)

if [[ -n $RigPID ]]; then
echo "Stopping rigctld PID $RigPID"
kill $RigPID
fi

if [[ -n $RotPID ]]; then
echo "Stopping rotctld PID $RotPID"
kill $RotPID
fi

Starting rigctld and rotctld: for Kenwood TS-2000 on /dev/ttyS0 and Yaesu GS-232B rotor controller on /dev/ttyS1


RigPID=$(pgrep rigctld)
RotPID=$(pgrep rotctld)

if [[ -z $RigPID ]]; then
echo "Started rigctld"
rigctld --model=214 --rig-file=/dev/ttyS0 --serial-speed=57600 -C serial_handshake=Hardware,post_write_delay=10 &
fi

if [[ -z $RotPID ]]; then
echo "Starting rotctld"
rotctld --model=603 --rot-file=/dev/ttyS1 --serial-speed=9600 -C serial_handshake=Hardware,post_write_delay=10 &
fi

Remember: if using GPredict with Hamlib, do not use -v verbose options, since the extra text output will confuse Gpredict.

Changing serial RS-232 COM port baud rate of Kenwood TS-2000 remotely

To change the baud rate of the Kenwood TS-2000 over the RS-232 serial COM port, you can do this locally or remotely.

Locally, you go into menu 56, and select your baud rate. Hamlib/rigctl recommends using the highest possible baud rate i.e. 57600 baud. Then power cycle the radio.

Remotely, look at the CAT EX menu item 56. You can read the current baud rate by sending
EX0560000;
The radio will answer back
EX05600004; which implies 57600 baud since the last digit is 4. The last digit to baud is:
0: 4800
1: 9600
2: 19200
3: 38400
4: 57600

To set, send the corresponding command. E.g. to set 57600 send:
EX05600004;
and turn off the TS-2000 by sending
PS0;
Now disconnect, and reconnect at the new baud rate (here, 57600) and turn the radio on by sending:
PS1;

Note: You can lose communication with your TS-2000 requiring a site visit. Be prepared.

Which format to use for sharing USB flash thumb drives and USB HDD

I have found that EXFAT is the most convenient format for sharing files between Mac/Linux/Windows/Android.
EXFAT is supported from Windows XP through Windows 8.1 and beyond.
EXFAT is supported on Mac OS X from 10.6.3 and newer [1].
EXFAT is supported on Linux from CentOS 5 and Ubuntu 10.04 and newer.
EXFAT is supported from at least Android 4 onward.

NTFS is not writeable on Mac OS X by default, in Mavericks I have read that one must either go into Terminal and use Homebrew or edit your /etc/fstab and make some manual changes. I.e. something not easy to do at a conference or casual meeting quickly. NTFS is NOT supported on Android.

FAT32 is also readable by Windows/Mac/Linux/Android, but is limited to 4GB file size. Sometimes I share large raw/compressed data files that are larger than this, especially if using a USB HDD. With many USB HDDs over 2TB, you would have to break up your HDD into multiple partitions for FAT32 — quite inconvenient. You could use FAT32 for a small USB flash drive. Note, I have found that when using a USB flash thumb drive to plug into a printer to “USB Direct Print” that single partition FAT32 is supported, but not EXFAT. So I keep a small USB drive formatted to FAT32 for this purpose.

Summary:
In my opinion, EXFAT is the best choice for universal support on USB HDD
For USB flash thumb drives, I format most to EXFAT–keeping a small flash drive formatted to FAT32 in case I need to quickly use the USB port on a USB direct print printer (Dell, Brother, etc.)

Important note: As I was reminded in the comments by Bob Foss, there are a variety of devices such as in-car entertainment, printers, Agilent test equipment, etc. that require only a single FAT32 partition. Since USB drives are so small and inexpensive, I keep an old USB flash drive formatted to FAT32 for these special cases.

Also, for SD cards, many devices expect still expect FAT32, so you may need to use FAT32 for SD cards just for compatibility reasons.

References:
[1] https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/fsck_exfat.8.html

pdflatex error: epstopdf Output filename not allowed in restricted mode.

you may get this error if you include .eps files that are not in the same directory or a subdirectory of your .tex file. E.g. a file that is in a directory above or adjacent to your current level.

The “fix” is to include the
-shell-escape
option in your pdflatex command.

E.g.

pdflatex -shell-escape myfile.tex

For example, in TexMaker, click Options>Configure and add -shell-escape right after pdflatex in the PdfLaTeX command box.

Example of problem situation:
I have files:
~/work/report.tex
~/matlab/plot.eps

then
\includegraphics{../matlab/plot.eps}
will trigger this error until -shell-escape is used.

Stop MATLAB high CPU usage on Idle (Windows/Mac/Linux)

For at least Matlab R2013a and R2013b, you may find that after opening the Matlab Help Browser (and even after closing just the Help Browser while keeping Matlab itself open), that Matlab uses 100% of one CPU core at about 25% duty cycle.

You can try pasting this command into Matlab (it will persist, you do NOT have to put this in startup.m).

com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLRENDERER');

Then restart Matlab, you should see the CPU is not hanging at 100% after closing the Help Browser. Matlab will remember this setting.

However, this simpler Help Browser is not as graphically nice as the default Java Help Browser; sometimes clickable links are broken in the help files. You can thus revert back to the default Java Help Browser by pasting into Matlab command line:

com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLPANEL');

and restart Matlab. Matlab will remember this setting too.