Ubuntu 14.04: stop Octave 3.8.1 autoload all packages

The current default setup for Octave 3.8.1 on Ubuntu 14.04 is to load all install packages at startup. I find this irritating and a not recommended practice by the Octave creator JWE.

Instead of starting up in 0.1 seconds, Octave takes 5 seconds to start — really annoying, especially when using oct2py in Python!

Here’s the error I get on startup with the octave-specfun package installed:

$ time octave --eval 'exit'
warning: function /usr/share/octave/packages/specfun-1.1.0/ellipke.m shadows a core library function
warning: function /usr/share/octave/packages/specfun-1.1.0/erfcinv.m shadows a built-in function
warning: function /usr/share/octave/packages/specfun-1.1.0/expint.m shadows a core library function
warning: function /usr/lib/x86_64-linux-gnu/octave/packages/specfun-1.1.0/x86_64-pc-linux-gnu-api-v49+/ellipj.oct shadows a built-in function

real 0m4.904s
user 0m4.570s
sys 0m0.096s

Solution: comment out the octaverc line that’s calling all these packages at startup.


sudo nano /usr/share/octave/3.8.1/m/startup/octaverc

comment out the line

pkg ("load", "auto");

then I get the result:

time octave --eval 'exit'

real 0m0.072s
user 0m0.055s
sys 0m0.016s

802.1x wireless WPA2-Enterprise without certificate: Ubuntu 14.04

NetworkManager in Ubuntu 14.04 has an issue with 802.1x networks that don’t require the laptop to have a .cert file. A bug report has been launched in regards to this.

Note: the following discussion can subject your laptop to “man-in-the-middle” attacks by disregarding the need for a .cert file. However, if your network IT dept. doesn’t provide you a .cert file and their policy is not to, you might discuss with them if the following is an appropriate solution.

1) find the name of the wireless network you want to connect to by typing in Terminal:
ls /etc/NetworkManager/system-connections
let’s assume your network SSID is “sortOfSecureWifi”.
Then type
sudo nano /etc/NetworkManager/system-connections/softOfSecureWifi
and it will look like (note the ?yourdata? is specific to your PC, don’t change it)

Note: In particular, if there is a line system-ca-certs=true, change it to

system-ca-certs=false

WARNING: This configuration can impact network security. Discuss this with the responsible network admins for your network FIRST! However, many networks don’t currently use certificates, yet Ubuntu 13.04/13.10/14.04 keep trying to look for a certificate via NetworkManager

[ipv6]
method=ignore

[connection]
id=?yourdata?
uuid=?yourdata?
type=802-11-wireless

[802-11-wireless-security]
key-mgmt=wpa-eap

[802-11-wireless]
ssid=?yourdata?
mode=infrastructure
mac-address=?yourdata?
security=802-11-wireless-security

[802-1x]
eap=peap;
identity=?yourdata?
phase2-auth=mschapv2
password-flags=2

[ipv4]
method=auto

then reboot and see if you can connect. A sign that system-ca-certs=true is happening is by:

grep "TLS: Certificate verification failed, error 19 (self signed certificate in certificate chain)" /var/log/syslog

Spyder 2.3 Python3 installation on Ubuntu 14.04

Note: Now that Spyder 2.3 has been officially released for Ubuntu 14.04, you can just do
sudo apt-get install spyder3

Note finomdq comment that you need the backports repository.

If you would like the newest Spyder 2.3.3 with bugfixes for Pandas Series and Dataframes, then consider doing

pip install --upgrade spyder

Prerequisities:
ipython3 ipython3-qtconsole python3-pyside.qtcore python3-pyside.qtgui python3-pyside.qtsvg python3-pyside.qtwebkit python3-psutil python3-pep8 python3-sphinx

0) download and extract the ZIP file of the latest Spyder 2.3 from https://bitbucket.org/spyder-ide/spyderlib/downloads
I extracted it to ~/spyder-2.3.0/
1) change to that directory and type
python3 bootstrap.py --no-apport
2) nano ~/.bash_aliases
and add the line
alias spyder23="python3 ~/spyder-2.3.0/bootstrap.py --no-apport"

Then you can start Spyder 2.3 from Terminal just by typing
spyder23 &

Note, you might see errors in Terminal like
“X Error: BadCursor (invalid Cursor parameter) 6
Major opcode: 2 (X_ChangeWindowAttributes)”
That is a known nuisance message:
https://code.google.com/p/spyderlib/issues/detail?id=1727

Matplotlib Python3: fixing pyplot.imshow()

I have noticed on my Ubuntu 14.04 PCs and have seen other OSs having issues with python3 and matplotlib.pyplot.imshow().

Errors like:
backend_gtk3cairo.RendererGTK3Cairo

NotImplementedError: Surface.create_for_data: Not Implemented yet.

and getting blank images.

I fixed the problem by switching the matplotlib backend as follows:
1) placing a file named “matplotlibrc” in the directory of my Python .py code (current working directory), with the contents
backend : qt4agg
2) installing the prerequisities:
sudo apt-get install python3-pyqt4 python3-sip

GoToMeeting.com Windows client under Wine / Linux

So far, the webcam doesn’t work, but the send/receive audio does work on a test call. I didn’t test receiving video.

NOTE: in an actual conference, I wasn’t able to get sound, and so had to use a telephone. I have also seen problems with this for people using Windows and Mac at a large conference–leading the remote speaker to call in.

I personally avoid using GoToMeeting and would recommend using Google Hangouts or Skype instead of GoToMeeting for desktop sharing, video and audio between Mac/Linux/Windows/Android/iOS.

I tested this on Ubuntu 14.04 with wine 1.7.18. Again, this ultimately failed in a real conference. I don’t recommend GoToMeeting at this time for Linux or any operating system where you have a lot of people counting on it actually working..

Installation:
1) Get the latest MSI file for GoToMeeting — I used V6.2.1 build 1350 from

http://support.citrixonline.com/en_us/gotomeeting/all_files/gtm020012

2) in Terminal, type
wine msiexec /i ~/Downloads/G2MSetup6.2.1350_IT.msi
3) You may not have sound by default. To fix this, start GoToMeeting, right-click the flower toolbar icon, select Preferences, Audio, and select the Pulseaudio device for each.
Uncheck the “Automatically adjust my system mixer settings” and “Use automatic volume and noise processing” boxes.

Removing line numbers from text file

Suppose you want to reuse code from an OCR’d book or a text file, that has line numbers embedded in the file. For example say you had a file neat.py:

1 # cool program
2 import sys
3 def howneat():
4     sys.exit('Thanks for visiting')

You can remove the line numbers by typing in Terminal:

perl -pe 's/^[ \t]+\d+//' neat.py > neater.py

The regular expression
^[ \t]+\d+
says:
^ at the beginning of the line
[ \t]+ match space or tab (one or more)
\d+ match one or more digits

The -p to perl means to implicitly loop over (read each line of) the file neat.py. The -e means here is the PCRE to consider.

And we replace with nothing. This leaves alone the indentation of the code (relevant for Python).

I could have used the -i flag to edit in place, but I instead redirected STDOUT to the file neater.py in case I made a mistake (inputting the wrong file, for example).

Matlab R2013b C++ MEX on Ubuntu 14.04

Ubuntu 14.04 comes with GCC 4.8, but Matlab R2013b wants GCC 4.8.
The error you will get includes.
Warning: You are using gcc version ‘4.8.2’. The version of gcc is not supported.

Note that Matlab R2014a uses a new system for MEX configuration. You should not use this process for R2014a and newer. For Matlab R2014a I don’t have a solution for specifying gcc-4.7 besides taking the output of mex -v and editing the commands to use gcc-4.7 manually. Yikes!

http://www.mathworks.com/matlabcentral/answers/67521-32bit-and-64bit-compilations#comment_216789

http://www.mathworks.com/help/matlab/release-notes.html

This example is for R2013b and OLDER

Resolution:
sudo apt-get install gcc-4.7 g++-4.7

cp /usr/local/MATLAB/R2013b/bin/mexopts.sh ~/.matlab/R2013b/mexopts.sh

chmod 644 ~/.matlab/R2013b/mexopts.sh

nano ~/.matlab/R2013b/mexopts.sh
there will be one instance each of:
CC=’gcc’ change to –> CC=’gcc-4.7′
CCX=’g++’ change to –> CCX=’g++-4.7′
5) restart Matlab

Matlab: imwarp over 3x faster than imtransform

In Matlab R2013a, imwarp was brought in, and by R2013b the Lint warning tells you to use imwarp instead of imtransform.

On my simple test (a horizontal linear shift) imwarp was 3.4 times faster than imtransform.

I had this inside a for loop (first I loaded an image to variable ‘bg’)

bg = imread('myimage.jpg');
[nRow,nCol] = size(bg);
...
for ....
if ~oldWay % newway: Matlab R2013 and newer
tform = affine2d(T);
RA = imref2d([nCol,nRow],[1 nCol],[1 nRow]);
data(:,:,i) = imwarp(bg,tform,'outputView',RA);
else % old way Matlab R2012b and older, and Octave
tform = maketform('affine',T);
data(:,:,i) = imtransform(bg,tform,...
'Udata',[1 nCol],...
'Vdata',[1 nRow],...
'Xdata',[1 nCol],...
'Ydata',[1 nRow]);
end %if
end %for

Results:
% oldway: 14.30 sec. octave 3.8.1 using 1 CPU core
% oldway: 14.24 sec. R2013b using 4 CPU cores
% newway: 4.19 sec. R2013b using 1 CPU core

Note how Octave is as fast as Matlab imtransform, but Octave only uses 1 CPU core instead of 4!