Ubuntu Unity desktop more usable

Unity, the new standard desktop for Ubuntu Linux, doesn’t seem to be as popular as the makers of Ubuntu hope to be. I gave it a try and liked it, except for one thing. When browsing the web with firefox at maximized window mode, the launcher appears when the mouse pointer comes anywhere near to the back- button. Instead of navigating one site back the unity- dashboard opens. This is quite annoying. There is no easy way to configure the behaviour of unity without additional configuration tools. Apparently this is yet to be developed by Ubuntu.

However, with the CompizConfig Settings Manager, you can change some settings. The program has to be installed in the ubuntu software center first.

In the Settings Manager, choose “Ubuntu Unity Plugin” at the category “Workspace”. I set “Hide Launcher” to never. This costs a few pixels, but it is convenient to always have the most used programs ready in the sidebar. If you want to save space, you can decrease the launcher icon size on the “experimental” tab.

R packages for backtests of trading strategies

Recently I upgraded my R installation on my Ubuntu 10.04LTS notebook to the actual version. According to CRAN only the last LTS version of Ubuntu is fully supported. On this site there is a tutorial of how to configure the system in order to have the most recent packages installed.

Here is in short what I did on my system:

Add entries to /etc/apt/sources.list:

sudo vi /etc/apt/sources.list

deb http://cran.r-project.org/bin/linux/ubuntu lucid/
deb http://mirrors.mit.edu/ubuntu/ lucid-backports main restricted universe

Import key:

gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-key add key.txt

Installation of basis system:

sudo apt-get update
sudo apt-get install r-base r-base-dev

I don’t install additional packages from debian- packages. Instead I install them from a root session of R. In order to always use the main repository server for packages downloads I specified that in my .Rprofile:

vi ~/.Rprofile

.First <- function() {
    options("repos" = c(CRAN = "http://cran.r-project.org/"))
}

Install packages

sudo R

install.packages("quantmod")   # installs defaults, xts, zoo, TTR, quantmod
install.packages("PerformanceAnalytics")
install.packages("blotter", repos="http://R-Forge.R-project.org") #installs zoo, FinancialInstrument, blotter
install.packages("FinancialInstrument", repos="http://R-Forge.R-project.org")
install.packages("quantstrat", repos="http://R-Forge.R-project.org")
install.packages("RTAQ", repos="http://R-Forge.R-project.org")

More information about the packages on R-Forge are here.

linux nohup command

When you connect to a linux pc with ssh or run a command in a terminal, the process will quit work after you close the ssh session/terminal.

e.g.

cp myverylargefile.zip /path/to/targetdirectory/

or

cp myverylargefile.zip /path/to/targetdirectory/ &

It doesn’t matter if you run it in background or not. If you close the terminal while the job is still working, the copy process will stop and leave a useless half copied file in the target directory.

By using the nohup command the process will remain active

nohup cp myverylargefile.zip /path/to/targetdirectory/ &

The command creates a file “nohup.out”. This file contains whatever output the process delivers.

The man page of nohup says:

If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to `nohup.out’ if possible, `$HOME/nohup.out’ otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use `nohup COMMAND >FILE’.

Installing R on Ubuntu

First, read this tutorial on the R wiki.

Many, but not all R packages are available as Debian packages. For others, you should run R as root, and then use the install.package command.

List all available debian packages:

sudo apt-cache search '^r-'

Install base packages and documentation

sudo apt-get install r-base-dev r-base-html r-doc-pdf

If there is plenty of free disk space, it’s possible to install all packages using this command

sudo apt-cache search '^r-' | awk '{print $1}' | xargs apt-get --yes install

As mentioned above, packages can also be installed while running a R session as root:

sudo -E R
> install.packages("plotrix")

a window opens where you should choose a download server. Everything else is being installed automatically. In my case I needed the -E parameter for sudo to have my environment (include proxy settings) taken to the sudo session. Otherwise it can’t connect to the repository behind the proxy at work.

Remove old and unused kernel in Ubuntu

On my laptop there is Ubuntu 10.04 and Windows installed. The grub menu allows the user to choose the operating system at boot time. Each time Ubuntu installs a new Linux kernel, it leaves the old one installed. It means if you update/upgrade regularly, the Grub boot menu will be filled with all the Linux kernels you installed on your system, even those you no longer need.

On the web one can find many tutorials about how to remove old, unused kernels from the harddisk and the list in grub-menu. The best I found is here

Here is the explaination why Ubuntu handles it that way.

CSharp Windows Forms Show HTML Help when pressing F1

For a windows forms application I have to implement a help page that contains html code. The page should open when the user presses F1 while the main window is active. I didn’t want the help page being opened in a browser. Instead I used a new windows form that contains a web browser element.

Here is how I implemented it in Visual Studio 2010.

  • add new element to the project: HTML file help.htm
  • alter the properties of the new HTML file. build = embedded resource
  • ensure that the main form has the property “key preview” set to true. The form won’t listen to keystrokes otherwise
  • add a new windows form to the project. This form will contain the HTML- help information. Set dimensions to 800*600 or any other size that makes sense
  • add a web browser element to the newly created windows form. In my case it uses the whole area of the windows form
  • add a event handler for the form-closed event
  • Here is my code of the help- windows form.

    [..]
    using System.IO;
    using System.Reflection;
    
    namespace MyProgram
    {
        public partial class FormHelpWindow : Form
        {
            private static FormHelpWindow currentHelpWindow =null;
    
            public FormHelpWindow()
            {
                InitializeComponent();
    
                Assembly _assembly = Assembly.GetExecutingAssembly(); ;
                StreamReader _textStreamReader;
    
                //reading html content from embedded resource
                using (_textStreamReader = new StreamReader(
                    _assembly.GetManifestResourceStream("MyProgram.help.htm")))
                {
                    ((WebBrowser)webBrowser1).DocumentText = _textStreamReader.ReadToEnd();
                }
            }
    
            //opens the help window; bring to front if help window is open already
            public static void ShowHelp()
            {
                if (currentHelpWindow == null)
                {
                    currentHelpWindow = new FormHelpWindow();
                }
                currentHelpWindow.Show();
                currentHelpWindow.BringToFront();
            }
    
            private void FormHelpWindow_FormClosed(object sender, FormClosedEventArgs e)
            {
                currentHelpWindow = null;
            }
    
        }
    }
    
  • In the main form, a event handler has to be created to handle the F1- keystroke. Add a eventhandler for KeyDown.
  • use this code in the newly created method
  •         private void FormMain_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.F1 && e.Modifiers == Keys.None)
                {
                    FormHelpWindow.ShowHelp();
                }
            }
    

    Installing Octave on Ubuntu 10.04 Lucid Lynx

    re-read package informations and list all available octave- packages

    sudo apt-get update
    sudo apt-cache search '^octave'
    

    Install basic packages and gnuplot

    sudo apt-get install octave3.2-info octave3.2-doc octave3.2-htmldoc octave3.2-headers gnuplot
    

    verify installed packages

    dpkg --get-selections | grep octave