03 January 2012

39. Opinion -- little annoyances regarding opinions about linux

I spend far too much time browsing the web, and I do often end up on linux-related sites. A fair number of sites are still dedicated to converting windows/osx users or helping new Linux users. In particular the latter aim is noble, of course.

At time it does get a bit tiring reading the comments sections though -- and that goes for both Linux advocates and their detractors.

Quotes collected from the web are given within "".

As an aside, most linux users, but perhaps not most windows and OSX users, are well aware of the difference between Learn-ability and Usability. A program may well be easy to LEARN how to use ('intuitive') but it may be a pain in the arse to actually USE. Most linux CLI tools require a bit of extra effort to learn, but once learned, are eminently usable.

0. Fewer than 1% use Linux or Ubuntu/Mint/X is the most popular distro
According to my blog, 55% of all visitors use linux (Win 40%, OSX 2%). This blog, given it's content has a positive bias towards Linux users.

According to my professional university homepage (I'm a chemist, not a Comp. Sci. person) about 11% use Linux, while 74% use Windows and 12% use OSX. My homepage, by virtue of being strictly related to my field of research, is biased towards users who are professional chemists.

So what to do?
For starters, what does 'use' mean? Do we only mean as a primary Desktop OS? Or do we include servers? Or even indirect use, such as visiting websites run on linux servers and using devices with embedded linux? These problems also apply to deciding which is the most popular distribution -- do we count embedded? Server installations? Or only Desktop usage?

The problem is compounded by the problem of measuring usage, regardless of definition. For commercial OS one might use the number of licenses sold as an indication, but that won't work for a Free OS. Same goes for number of downloads. Repo access sounds like a good idea, but in addition to most major universities (+ companies and kind individuals) running mirrors, a fair number of us use apt-cache to cut down on both our and server traffic. And what about people who, like me, have a large number of computers which they use each day (desktop at home for watching tv, laptop at home for work, desktop at work for...work, three desktops at work for number crunching, router at home with busybox/tomato)

There would of course also be the practical issue of compiling all the stats, so this approach isn't used today.

So...for OS share 'Net applications' statistics is often used, see discussion e.g. here. Website stat, however, do not adequately distinguish between Number of Users and Number of Visits. The selection of reporting sites also influences the results.

Still, the problem is even greater when it comes to crowning the reigning distro. Most of the time distrowatch data is quoted, and it really makes absolutely no sense. I use only linux, and I visit distrowatch less than once per year -- because why would I? I use Debian, I'm happy with Debian, and I have no longer any time to explore other distros without a bloody good reason, and even if I did, distrowatch wouldn't be the place I'd go looking for information. I really wish articles would stop quoting distrowatch data.

1. The year of the Linux Desktop/Focus on mobile devices
"That's why I feel it's more important to focus on how Linux performs in growth areas like mobile devices than on a desktop that's increasingly less relevant for content consumption."

This is, if not a meme, then at least a standing joke. However, there's still this idea that Linux NEEDS to become a big player on the desktop and that it has so far failed to achieve this. Alternative, Linux NEEDS to focus on mobile devices where they can grab a large market share.

Well, guess what -- for a lot of people every year is the year of the linux desktop -- we're using linux as our only, or primary, OS.

Also, there isn't a NEED for linux to become anything.

What most linux users feel is probably that rather than necessarily converting everyone to some flavour of linux, it would be nice of non-linux users would stop forcing proprietary formats on everyone.

At my current job people insist on emailing .docx files for some reason. This
   1.  more-or-less forces Windows users to upgrade their office versions (which is the real reason behind changing the file format)
   2. pisses off anyone who isn't using office --- such as linux users. A guess-timate would be that 80% of the documents emailed contain so little formatting that a plain ascii file would have been enough. For the rest, pdf would work just fine since editing isn't required.

Really, you can use office if YOU want to, but don't 1. pretend that it's superior to latex because you can click on things or 2. force it on other people.

2. 'obscure' terminal commands
"Look it's 2009. The public doesn't want to type in commands. GUI's have been around for how long? It's obvious by the success of Windows that users want an easier experience."

They are only 'obscure' if you are dead-set against learning what they do. There is no difference between typing in a command and looking through a graphical menu. You still need to be willing to dedicate at least a modicum of effort towards learning.

And guess what? There's a reason why the terminal/command line/cli is still around. In fact there are several. For a starter, it's a faster, easier and more convenient method once you've made a bit of effort of learning how to use the standard *NIX tools such as gawk, sed, vim etc. Not everyone uses their computer for data processing, or even work, and that's fine -- some people live their lives in the browser and won't benefit much from using the terminal (but they really shouldn't complain about its existence either).

Also, the idea of 'getting rid of the terminal' as one sees sometimes show s a complete lack of understanding of how a linux system works. GNOME/KDE/Xmonad/XFCE/LXDE etc. are just shells, interfaces on top of the linux kernel. They are like thin sheets of ice covering a deep sea -- most of the action is to be found underneath.

And that's a GOOD thing -- in windows there's little reward for making the effort to learn new things. In Linux, you can learn as little or as much as you want -- you'll get rewarded for any effort to learn that you make.

3. 'Too much' choice
"Fragmentation: 1% of the market split into 100+ distros. Divided they fall."

In the beginning I fretted a lot about choosing the 'right' distro -- after all you don't want to waste your time learning something that's obsolete or not as useful as the next thing around. As it turns out, there's little difference between different distros.

Well, the differences are there there, but they are typically down to philosophy, package management or number of packages in the repos.

I feel more at home using apt-get/aptitude than yum, but since a fair number of users use a graphical package manager, this really doesn't matter much.

Other than that, most distros are the same, and are derived from four or five main distros (the Debian and Fedora/Red Hat families probably being the largest ones). So, instead of 100+ distros you have 3-4 distros which are really not that different.

The differences between windows 2000 through Windows 7 are larger than the differences between any of the linux distros.

4. No drivers/hardware support
"The real killer with linux is using peripherals. Drivers suck if they exist at all."
To date I've only had one piece of hardware which didn't work immediately -- my Diamond ATI Wonder HD 750 USB TV card. And I blame ATI for that, not 'linux'.

5. No games means Linux sucks
"I gave Linux a shot. Despite the irritating little problems I encountered I tried. And then my nephew wanted to play a game and it became all too clear--Linux has no chance."

This is true. But are we discussing a system for casual gaming or are we talking about a computer OS? I'd hate to write articles or do modelling on XBOX or Playstation. If gaming is what you are after, then by all means, find a system where you can do it. Whether a publisher releases a game for a particular platform has little to do with the superiority of that platform and all to do with market share.


Anyway, people can use what they want -- what irks me is when they pretend they'd use Linux if only...and then some half-baked, poorly informed 'reason' is presented.

Use or Do Not Use -- but make no excuses.

38. How to install and/or compile wine on debian testing


UPDATE: See here for Wine 1.5.27 using a chroot
http://verahill.blogspot.com.au/2013/04/376-wine-1527-on-debian-i386-chroot.html


UPDATE: there are plenty of more up-to-date guides on this blog. See e.g. here for how to build v 1.5.6. Obviously, the instructions below are still valid, and will give you a working version of wine.


Original post:
Quite some time ago Wine was removed from Debian Testing/Wheezy. If you already had wine installed, this may not have caused any significant problems, but it did cause inconvenience when setting up a new computer.

There are three fairly easy ways of installing wine in Debian testing.

Update: See here for version 1.4-rc4: http://verahill.blogspot.com.au/2012/02/debian-testing-wheezy-64-compiling-wine.html

1. The simplest approach -- Using the Stable version of wine 
Simply add the stable repo to your /etc/apt/sources. list (add -- don't replace your testing repo)

i.e. if you sources.list looks like this:

deb ftp://ftp.au.debian.org/debian/ testing main contrib non-free


then add a line so that it looks like this:
deb ftp://ftp.au.debian.org/debian/ testing main contrib non-free
deb ftp://ftp.au.debian.org/debian/ stable main contrib non-free

Running

sudo apt-get update

followed by

aptitude search wine

should hopefully show wine, wine-bin etc. The current version in the Debian stable repos is 1.0.1-3.1.

You can now install wine by

sudo apt-get install wine


2. The ever so slightly more complex approach -- installing version 1.3.32-0.1
If you want a newer version -- and I'd say that you would since the debian wine packages are OLD -- you can at the moment pull .deb packages from http://dev.carbon-project.org/debian/wine-unstable/

Don't let the 'unstable' fool you -- these are NOT the packages in the debian SID/unstable repos.

Also, pay heed to the following text on the page above: "The amount of traffic this little sub-page generates is quite respectable. If you think this service helpful and want to help cover some of the attached costs, please donate a few Euros". Whether you donate or not, do not download the same packages over and over again.

Download all the .deb files (in my case for amd64) using the following command:

wget -r -l1 --no-parent -A amd64.deb http://dev.carbon-project.org/debian/wine-unstable/

This is an example of using something akin to wildcards in wget.

cd dev.carbon-project.org/debian/wine-unstable

sudo dpkg -i *.deb

You'll see a number of errors being reported and the packages will be left unconfigured -- this is due to missing dependencies. That's easy to fix though:

sudo apt-get -f install

The missing dependencies will now be pulled in and the installation finalised. It's as easy as that!

3. Building your own -- version 1.3.35
It's not as hard as it may look -- I'm not in the habit of compiling my own packages, and chances are that you aren't either, so I'll show the entire process.

Download the source
wget http://prdownloads.sourceforge.net/wine/wine-1.3.35.tar.bz2

Unpack:
tar -xvf wine-1.3.35.tar.bz2

You may have to
sudo apt-get install bzip2 
before running the tar command above if it complains about missing bzip2 etc.

Change to the directory where the files were unzipped
cd wine-1.3.35

Time to start trying to build -- the errors I get may not be the errors you get. The approach to solving them is the same though.

First we need a whole lot of packages:

sudo apt-get install bison flex gcc libc6-dev libfontconfig-dev libfreetype6-dev libglu-dev libgsm1-dev libice-dev libjpeg-dev libldap-dev libmpg123-dev libncurses5-dev libopenal-dev libpng-dev libsm-dev libssl-dev libusb-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libxrender-dev libxslt-dev libxt-dev libxxf86vm-dev make libcapi20-dev liblcms-dev libsane-dev libhal-dev libdbus-1-dev valgrind prelink libcups2-dev

sudo apt-get install lib32v4l-dev lib32ncurses5-dev lib32asound2-dev lib32z-dev ia32-libs-dev

Now start:
./configure

which gives**


configure: OpenCL 32-bit development files not found, OpenCL won't be supported.
configure: gstreamer-0.10 base plugins 32-bit development files not found, gstreamer support disabled
configure: OSS sound system found but too old (OSSv4 needed), OSS won't be supported.
configure: libgsm 32-bit development files not found, gsm 06.10 codec won't be supported.

configure: Finished.  Do 'make' to compile Wine.




Good enough for me. 

make

Building will take a good 20-30 minutes.

Finally, 'install' the binaries in their proper locations

sudo make install

The first time you start a program in wine you'll be asked to install the gecko engine, which you can go ahead and do.

** I initially had some problems -- one of them being


checking for X... no
configure: error: X 32-bit development files not found. Wine will be built without X support, which probably isn't what you want. You will need to install 32-bit development packages of Xlib/Xfree86 at the very least. Use the --without-x option if you really want this.

This was solved by installing ia32-libs-dev



21 December 2011

37. Making posters in latex


As a scientist you may have discovered how much less swearing occurs when writing articles in latex rather than MS Word or other What You See Isn't Quite What You Wanted  packages (WYSIQWYW -- I guess this is an acronym that won't be taking off anytime soon). The next step is to move from using powerpoint to make posters and presentations, to using latex.

It's never elegant to post the entire code in blog form, but what to do when you can't upload simple files?

The poster style is based on a theme by Rob J Hyndman and is an adapation of i6dv by David Vilar and edited by me.


Here's beamerthemeMyTheme.sty which you should put in the same folder as your post tex file:


\ProvidesPackage{beamerthemeMyTheme} % this style was created by Rob J Hyndman and is an adapation of i6dv by David Vilar. Edited by Someone Else

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\selectcolormodel{cmyk}
\selectcolormodel{rgb}
\mode<presentation>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% custom colors
%\definecolor{i6blue}{cmyk}{1,0.305,0,0.06}
\definecolor{i6bluedark}{rgb}{0.0156,0.2578,0.5625} 
\definecolor{i6colorscheme1}{HTML}{333333}  %333333 e.g. for block title
\definecolor{i6colorblockbg}{HTML}{555555}
\definecolor{i6colorblockfg}{HTML}{FFFFFF} %block title white
\definecolor{i6colorscheme2}{HTML}{000000}  % e.g. title in headline
\definecolor{i6colorscheme3}{HTML}{F0F0F0} % e.g. for poster background
\definecolor{i6colorscheme4}{HTML}{000000} 
\definecolor{i6colorschemeHeadline}{HTML}{000000}  % for headline bg
\definecolor{i6colorschemeFootline}{HTML}{101010}  % for headline bg

% headline colors and fonts
\setbeamercolor{headline}{fg=yellow,bg=i6colorschemeHeadline}
\setbeamercolor{title in headline}{fg=yellow}
\setbeamercolor{author in headline}{fg=white}
\setbeamercolor{institute in headline}{fg=lightgray}
\setbeamercolor{separation line}{bg=i6colorscheme1}

% footline colors and fonts
\setbeamercolor{footline}{fg=white,bg=i6colorschemeHeadline}
\setbeamerfont{footline}{fg=white, size=\normalsize}

% body colors and fonts
\setbeamercolor*{normal text}{fg=black,bg=i6colorscheme3}

% block environment
\setbeamercolor*{block body}{bg=white,fg=black}
\setbeamercolor*{block title}{fg=i6colorblockfg,bg=i6colorblockbg}
\setbeamerfont{block title}{size=\large,series=\bf}

% example environment
\setbeamercolor*{example title}{fg=white,bg=i6colorscheme1}
\setbeamerfont{example title}{size=\large,series=\bf,bg=i6colorscheme1,fg=white}

\setbeamercolor{alerted text}{fg=i6colorscheme1}

\setbeamertemplate{itemize items}[triangle]
\setbeamertemplate{navigation symbols}{}  % no navigation on a poster

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{block begin}{
  \vskip0.5ex %space between boxes
  \begin{beamercolorbox}[rounded=true,shadow=true,leftskip=1ex,colsep*=0.5ex]{block title}%colsep - height block title, leftskip - title text indent
    \usebeamerfont*{block title}{\Large \insertblocktitle}
  \end{beamercolorbox}%
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%space between head and block
  \usebeamerfont{block body}%
%  \begin{beamercolorbox}[rounded=true,shadow=true,colsep*=0.5ex,sep=0.5ex,vmode]{block body}%colsep, sep - vert margin top and bottom
  \begin{beamercolorbox}[rounded=true,shadow=true,colsep*=0.5ex,sep=0.5ex,vmode]{block body}%colsep, sep - vert margin top and bottom
   \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.5ex}\vbox{}%
  }
  \setbeamertemplate{block end}{
  \end{beamercolorbox}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{headline}{  
  \leavevmode

  \begin{beamercolorbox}[wd=\paperwidth]{headline}
\centering
        \vskip4ex % height above text
        \usebeamercolor{title in headline}{\color{fg}\textbf{\LARGE{\inserttitle}}\\[1ex]}
        \usebeamercolor{author in headline}{\color{fg}\large{\insertauthor}\\[1ex]}
        \usebeamercolor{institute in headline}{\color{fg}\large{\insertinstitute}\\[1ex]}
  \end{beamercolorbox}

  \begin{beamercolorbox}[wd=\paperwidth]{lower separation line head}
    \rule{0pt}{2pt}
  \end{beamercolorbox}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{
  \begin{beamercolorbox}[wd=\paperwidth]{upper separation line foot}
    \rule{0pt}{2pt}
  \end{beamercolorbox}
  
  \begin{beamercolorbox}[ht=5ex,leftskip=1cm,rightskip=1cm]{footline}% ht - thickness
    \hfill \raisebox{0.4cm}{\insertfooter} %raisebox - placement of text
    \vskip1ex
  \end{beamercolorbox}

  \begin{beamercolorbox}[wd=\paperwidth]{lower separation line foot}
    \rule{0pt}{0pt}
  \end{beamercolorbox}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<all>

\def\footer#1{\def\insertfooter{#1}}


and here's the poster.tex file:


\documentclass[final]{beamer}
\usetheme{MyTheme}
\usepackage[orientation=portrait,size=a1,scale=1.14,grid,debug]{beamerposter}
\usepackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1.0cm}
\setlength{\TPVertModule}{1.0cm}
\usepackage{ragged2e}
\usepackage{mhchem}
\usepackage{caption}
\captionsetup{labelformat=empty,labelsep=none}


\title{A hypothetical LaTeX poster}
\author{I Am Me\inst{*} \quad She S Someoneelsei\inst{\dag} \quad A. Third Party\inst{\dag}$^{,}$\inst{\ddag}}
\institute[School of Somethingorother]{
\inst{*}%
School of Somethingorother, My University \quad
\inst{\dag}%
Department of Haxx0r
\inst{\ddag}%
Department of 1337, UC Other
}
\footer{url: http://http://www.blogger.com/ \quad email: me@blogger.com}
\date{}

\begin{document}

\begin{textblock}{6}(0.6,0.6)
\includegraphics[height=4.0cm]{mylogo_light.eps}
\end{textblock}

\begin{textblock}{6}(54.9,0.6)
\includegraphics[height=4.0cm]{ucother_logo.eps}
\end{textblock}

\begin{frame}{} 
\begin{textblock}{28.5}(0.6,6.3)

\begin{block}{Introduction}
\justifying
\begin{center}\begin{minipage}{28cm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida nisi eget lectus commodo luctus. Pellentesque vitae velit ligula. Nullam diam enim.[1,2]
\end{minipage}\end{center}
\begin{center}
\begin{figure}
\includegraphics[width=23.9cm]{screenshot.eps}
\caption{A caption for  \ce{[Fe4(H2O)8L9]^{-}}}
\end{figure}
\end{center}
\begin{center}\begin{minipage}{28cm}
Integer nec felis massa, ac tincidunt tellus. Phasellus ornare urna nec erat eleifend eu egestas arcu sodales. Cras interdum, lectus vitae ultricies rutrum, orci sapien bibendum orci, ut facilisis lectus velit at risus. Maecenas ut nisi mi. Praesent in nunc vitae justo ullamcorper placerat nec id lectus.  \ce{[[Fe4(H2O)8L9]^{-}} cluster[3]ante ipsum primis {\sc nmr}.[4]\\
\tiny{
\begin{enumerate}
\item G. Romanum, J. Eunt, G. Ite, F. Sum, \emph{A. Journal. Int. Ed.} \textbf{2011}, \emph{8}, 1943--1946.\\
\item A. Graecum, D. Hispanum, F. Molybdenum, R. Verum, H. Ipsum, P. J. Consectetur, G. Lectus, R. Ligula, M. Diam, \emph{Science} \textbf{2011}, \emph{323}, 13--17.
\item A. Graecum, D. Hispanum, F. Molybdenum, R. Verum, H. Ipsum, P. J. Consectetur, G. Lectus, R. Ligula, M. Diam, \emph{Science} \textbf{2011}, \emph{323}, 13--17.
\item A. Graecum, D. Hispanum, F. Molybdenum, R. Verum, H. Ipsum, P. J. Consectetur, G. Lectus, R. Ligula, M. Diam, \emph{Science} \textbf{2011}, \emph{323}, 13--17.
\end{enumerate} }
\end{minipage}\end{center}

\end{block}

\begin{block}{Experimental} \justifying

\begin{center}
\begin{figure}
\includegraphics[width=23.6cm]{screenshot.eps}
\caption{Another figure caption}
\end{figure}
\end{center}

\begin{center}\begin{minipage}{28cm}
Integer nec felis massa, ac tincidunt tellus. In eget lectus a ante hendrerit gravida ut a massa. Nam euismod nisi vel nulla suscipit fermentum. Quisque vel nulla nibh, at bibendum quam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc tempor pretium blandit. Nulla vulputate odio quis tortor porttitor rhoncus. Vestibulum euismod purus non dolor pharetra non tempus diam pharetra. Nulla nec mauris vitae risus dapibus eleifend eget et ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec aliquam fringilla nulla, et ornare urna blandit id. In blandit lacinia massa quis tempus. Cras vel feugiat mi. Nullam risus nunc, aliquam non facilisis sit amet, condimentum id felis.  \end{minipage}\end{center}
\end{block}


\begin{block}{Data massage} \justifying
\begin{center}\begin{minipage}{28cm}
In eget lectus a ante hendrerit gravida ut a massa. Nam euismod nisi vel nulla suscipit fermentum. Quisque vel nulla nibh, at bibendum quam. Vestibulum ante ipsum primis in faucibus orci. In eget lectus a ante hendrerit gravida ut a massa. Nam euismod nisi vel nulla suscipit fermentum. Quisque vel nulla nibh, at bibendum quam. 

\end{minipage}\end{center}
\end{block}


\end{textblock}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{textblock}{28.5}(30,6.3)

\begin{block}{Data reduction} \justifying
\begin{center}\begin{minipage}{28cm}
 Donec aliquam fringilla nulla, et ornare urna blandit id. In blandit lacinia massa quis tempus. Cras vel feugiat mi. Nullam risus nunc, aliquam non facilisis sit amet, condimentum id felis.\end{minipage}\end{center}
 
\begin{table}
\begin{tabular}{c c}
\begin{minipage}{14cm} 
\begin{center}
\begin{figure}
\includegraphics[width=10.0cm]{adobe.eps}
\caption{A caption}
\end{figure}
\end{center}
\end{minipage} 
&
\begin{minipage}{14cm}
\begin{figure}
\includegraphics[width=10.0cm]{adobe.eps}
\caption{A caption.}
\end{figure}
\end{minipage}

\end{tabular} \end{table}  
\begin{center}\begin{minipage}{28cm}
Donec aliquam fringilla nulla, et ornare urna blandit id. In blandit lacinia massa quis tempus. Cras vel feugiat mi. Nullam risus nunc, aliquam non facilisis sit amet, condimentum id felis.\end{minipage}\end{center}  
 
\begin{center}
\begin{figure}
\includegraphics[width=12.6cm]{screenshot.eps}
\caption{Map of $\displaystyle \sum_{i}^{}(A(\lambda_{i})_{obs.}-A(\lambda_{i})_{calc.})^{2}$ as a function of pK$_{\textrm{a}}$s}
\end{figure}
\end{center}

\end{block}

\begin{block}{Fringilla nulla}
\justifying
Donec aliquam fringilla nulla, et ornare urna blandit id. In blandit lacinia massa quis tempus. Cras vel feugiat mi. Nullam risus nunc, aliquam non facilisis sit amet, condimentum id felis. $\displaystyle \frac{1}{T_{2r}}\approx\frac{C_{m}}{C_{aq}} \cdot k$:
\begin{eqnarray}
-\Delta H^{\ddag} \frac{1}{T} + \Delta S ^{\ddag}&=& R \cdot ln (\frac{\pi}{p_{m}}\frac{h}{k_{b}}\frac{1}{T}\Delta \nu) \nonumber
\end{eqnarray}

\begin{table}
\begin{tabular}{c c}
\begin{minipage}{14cm}
\begin{center}
\begin{figure}
\includegraphics[width=12.6cm]{screenshot.eps}
\caption{Observed $\Delta$H$^{\ddag}$ as a function of pH.}
\end{figure}
\end{center}
\end{minipage}
&
\begin{minipage}{14cm}
\begin{center}
\begin{figure}
\includegraphics[width=12.6cm]{screenshot.eps}
\caption{Observed $\Delta$S$^{\ddag}$ as a function of pH.}
\end{figure}
\end{center}
\end{minipage}
\end{tabular} \end{table}
\begin{center}\begin{minipage}{28cm}
 Ut ultrices ipsum vitae ipsum sagittis eget egestas dui interdum. 
\end{minipage}\end{center}
\end{block}

\begin{block}{Summary}
\begin{center}\begin{minipage}{28cm}
\begin{itemize}
\item Ut ultrices ipsum vitae ipsum sagittis eget egestas dui interdum. Phasellus nec nisl quam. 
\item Ut ultrices ipsum vitae ipsum sagittis eget egestas dui interdum. Phasellus nec nisl quam. 
\end{itemize}
\end{minipage}\end{center}
\end{block}

\begin{block}{Acknowledgements} \justify
\begin{center}\begin{minipage}{28cm}
Ut ultrices ipsum vitae ipsum sagittis eget egestas dui interdum. \\
Phasellus nec nisl quam. \\
\end{minipage}\end{center}
\end{block}


\end{textblock}
\end{frame}
\end{document}


36. PDF and annotation/editing under linux -- no solutions

Update: There are newer posts here and here.


Galley proofs of scientific articles are typically provided in the form of pdf files with ambiguous passages and editorial suggestions marked. You are then expected to add comments to the pdf indicating whether you agree to changes and/or clarifications. Well, good luck doing that.

It does appear that Acrobat Reader (9.4.x under linux, 10.1.1 under windows) does not support annotation/commenting anymore. See picture for security settings:

I fooled around with pdf2ps + ps2pdf, pdftk allow AllFeatures etc. No luck. Still no annotation in acroread.

PDFedit didn't help much. It looks like an advanced piece of software, but it offers no obvious way of making post-it type comments. The best approximation is adding text to the margins, but it's not what I set out to do.

Sadly, using wine + pdf x-change viewer (http://appdb.winehq.org/objectManager.php?sClass=application&iId=5549) is at the time of writing the best solution. You can download the free version here: http://www.tracker-software.com/product/pdf-xchange-viewer (there's also a 'pro' version)

It really is a straightforward piece of software, and does the trick, so no complaints there. However, it is very unfortunate that such a central piece of functionality is unavailable under linux.

Also, it does seem that acrobat reader is intentionally crippled -- from what I understand there is no obvious reason why commenting isn't allowed (i.e. not the fault of the authors of the pdf) other than because Adobe wants you to shill out money for their 'Pro' version (...interesting how FOSS normally doesn't market itself by adding X or Pro to the name...)


20 December 2011

35. Fixing: gnome alt+f2 broken, returns command not found -- debian testing current bug, description and solution

22/12/2011
An explanation and solution is here: http://forums.linuxmint.com/viewtopic.php?f=198&t=67502&p=510197#p512994

SOLUTION
--------------
My version of the solution above is a follows:

1. First, locate the file to edit

locate utils.js | grep misc

which returns

/usr/share/gnome-shell/js/misc/util.js

2. Next, confirm that argc is present (this is what's causing the problems)

cat /usr/share/gnome-shell/js/misc/util.js | grep argc

which returns

        let [success, argc, argv] = GLib.shell_parse_argv(command_line);
    let success, argc, argv;
        [success, argc, argv] = GLib.shell_parse_argv(command_line);

There are more elegant ways of doing this, but this is how I roll.

3. Edit /usr/share/gnome-shell/js/misc/util.js as root

sudo vim /usr/share/gnome-shell/js/misc/util.js (you can of course use gedit, nano, emacs etc.)

search for argc and remove all instances of of it, so that
[success, argc, argv] turns into to  [success, argv]
etc.

Once you've removed all argc, save and then hit alt+f2 in gnome, type r and enter to restart the shell. Then hit alt+f2 and type e.g. gedit to test it

It now works!

Reading through bug reports it seems it won't be fixed in Debian -- instead we'll have to wait until gnome 3.2 rolls out. Or just follow the instructions above.

-------------------------------
THE OLD POST
20/12/2011

(Current version of gnome-shell is 3.0.2-8+b1)


Hitting alt+f2 to start e.g. gedit or another program used to be straightforward.

During the past week it hasn't worked properly though -- instead the entry of any command has returned a 'command not found'. If you instead of simply typing in gedit type in /usr/bin/gedit, chances are the computer will experience an odd sort of freeze -- the top bar will be unresponsive, the black entry box will remain, the screen will be shaded, but gedit won't open. You will, however, be able to continue using your computer, but it'll be a dark experience.

Symptomatic descriptions of the bug and experiences are available here:
https://bugzilla.redhat.com/show_bug.cgi?id=719675
https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/816762


16 December 2011

32. Apt-pinning in Debian -- simple example


---------------------------------------------------------
Summary:
* create an /etc/apt/preferences files
* add the repos to /etc/apt/sources.list
* put a hold on packages if downgraded
---------------------------------------------------------


I'm not an expert at this. However, I managed to get apt-pinning to work using this approach. I wish I had a better grasp of how .d directories work, but I don't, which is why a monolithic /etc/apt/preferences files is used

Anyway, apt-pinning is an interesting approach to having a system in which some packages are pulled from stable, some from testing and some from unstable. For example, if the Evolution version in stable is missing what you consider critical functionality, and a better version is present in the testing repos, you can install the testing version of Evolution, while still running a mainly stable version of debian. In other words, apt-pinning allows you to pull single packages from other debian releases.

You need to add the repos to your /etc/apt/sources.list
e.g.

deb ftp://ftp.au.debian.org/debian/ testing main contrib non-free
deb ftp://ftp.au.debian.org/debian/ stable main contrib non-free
deb ftp://ftp.au.debian.org/debian/ unstable main contrib non-free


You also need to create a file called /etc/apt/preferences
e.g.

Package: *
Pin: release a=testing
Pin-Priority: 990

Package: *
Pin: release a=unstable
Pin-Priority: -10

Package: *
Pin: release a=stable
Pin-Priority: -10


The example preferences file prioritises testing over unstable and stable. Default apt behaviour is to use the highest version and revision of each package is there are several alternatives i.e. without /etc/apt/preferences you will end up with the unstable/sid release. The Pin-Priority values are a science onto themselves.

Here's what
 man apt_preferences
 says:


P > 1000
           causes a version to be installed even if this constitutes a downgrade of the package

       990 < P <=1000
           causes a version to be installed even if it does not come from the target release, unless the installed version is more recent

       500 < P <=990
           causes a version to be installed unless there is a version available belonging to the target release or the installed version is more recent

       100 < P <=500
           causes a version to be installed unless there is a version available belonging to some other distribution or the installed version is more recent

       0 < P <=100
           causes a version to be installed only if there is no installed version of the package

       P < 0
           prevents the version from being installed

I think negative values for the unwanted releases is a good place to start, or you may start automatically pulling over packages that depend on the one package which you want.

A way to see if it's working is to (for the package Evolution)
apt-cache showpkg evolution

Package: evolution
Versions: 
3.0.3-3+b1 (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_unstable_main_binary-amd64_Packages)
..
3.0.3-3 (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_testing_main_binary-amd64_Packages)
..
2.30.3-5 (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_stable_main_binary-amd64_Packages)
..

..

Provides: 
3.0.3-3+b1 - mail-reader imap-client 
3.0.3-3 - mail-reader imap-client 
2.30.3-5 - mail-reader imap-client 


Basically, it returns the different versions in the different release repos.

I've already described how to put a hold on a package so that it won't be upgraded, but here it is again (using the mpich2 package as an example):

sudo su
echo "mpich2 hold" | dpkg --set-selections

31. Update flash -- chrome on debian wheezy/testing 64 bit

You may have had problems playing flash videos recently and have been presented with a message saying that your player is out of date, and that you can either play (just this time) or upgrade. Clicking on upgrade takes you to the adobe website -- downloading the file is easy enough, but then what?

Well, here's how to upgrade.
Download the file install_flash_player_11_linux.x86_64.tar.gz
extract the libflashplayer.so file from the root of the compressed file

Figure out what files to replace:

locate libflashplayer.so
yields
/usr/lib/chromium-browser/plugins/libflashplayer.so
/usr/lib/flashplugin-nonfree/libflashplayer.so

So, in the directory where you put your new libflashplayer.so
sudo cp libflashplayer.so usr/lib/chromium-browser/plugins/libflashplayer.so
and
sudo cp libflashplayer.so /usr/lib/flashplugin-nonfree/libflashplayer.so


Restart your browser, and you should be good to go.

30. "Bench-marking" nwchem with mpich2 on debian wheezy

For various reasons my beowulf has been dismantled and in boxes for most of the year, with only the six-core node seeing use a normal work computer.

Anyhow, here's a very unscientific test of the performance of my six-core (phenom II, 2.8 GHz, 8Gb RAM) running the nwchem code compiled in the previous post.

The speed-tests were performed by starting up mpd
mpd --ncpus=6&
and then executing with
time mpdrun -n x ./nwchem input.nw
where x is an integer signifying the number of cores

The nwchem.nw files I used was

nwchem.nw
start benzene 

geometry units angstroms
C  0.100  1.396  0.000
C  1.209  0.698  0.000
C  1.209 -0.698  0.000
C  0.000 -1.396  0.000
C -1.209 -0.698  0.000
C -1.209  0.698  0.000
H  0.000  2.479  0.000
H  2.147  1.240  0.000
H  2.147 -1.240  0.000
H  0.000 -2.479  0.000
H -2.147 -1.240  0.000
H -2.147  1.240  0.000
end
basis
 H library sto-3g
 c library sto-3g
end
dft
    xc b3lyp
end
task dft optimize

Here are the results:


(x is number of cores; times in seconds)
x   Run 1   Run 2    Run 3   Run 4   Run 5
1* 40.8     37.9     40.7     40.3      39.9
1   22.2     40.7      40.6    44.8      38.2
2   22.8     22.4     16.3     23.5       21.5
3   14.1     12.3     15.7     15.5       15.1
4   14.5     11.5     12.0     14.9       14.7
5   11.4     11.5     8.9       11.9       12.5
6   16.0     12.2     13.4     9.9        9.6

* No mpd running; executed using time nwchem nwchem.nw



So here's the unscientific part -- the computer is running a full desktop environment with evolution, chrome etc open in the background so that each run sees a slightly different system. I've tried to vary the order in which the runs were made though.

 A guess would be that a longer run would yield more reproducible results. As it is now, the length of the runs vary significantly. The only lesson that can be obtained is that it doesn't help much throwing more cores at a problem as the optimisation times only drop off slowly past a certain point.

Edit: I've run the same file using an almost identical set-up on two more boxes
Don't compare the benchmarks when running at maximum numbers of cpu, since this will be heavily affected by other processes.

Optiplex 990 (Intel i5 2400, 4 cores @ 3.1 GHz, 8 Gb RAM)

x   Run 1   Run 2    Run 3   Run 4   Run 5
1   45.80   46.97  46.56   46.95   39.01
2   22.77  25.81   26.93  26.61   25.81
3   17.18  16.48   18.89  19.26  19.18
4   11.62  16.62   15.82  15.86   16.03

Homebuilt (3 core AMD Athlon 2 X3 @ 3.1 GHz, 4 Gb RAM)

x   Run 1   Run 2    Run 3   Run 4   Run 5   Run 6   Run 7
1   43.74   57.02   40.22   47.89   53.87
2   31.41   22.31   25.83   32.31   33.00
3   36.19   31.01   43.55   24.75   37.82   33.95   27.06


15 December 2011

29. Compiling/Building nwchem with mpich on debian testing 64 bit (Wheezy -- 15/12/2011)

So, as seen in the previous post, mpich2 ver 1.4 and nwchem 6.0 don't play nicely together.

Continuing with the virtual machine in the previous post, I added a line referencing the stable version to /etc/apt/sources.list:
deb ftp://ftp.au.debian.org/debian/ stable main contrib non-free

Important: I ADDED that line -- all lines referencing the testing version (or wheezy) are left untouched.
Do
sudo apt-get update
Since the versions in stable are older adding that line won't affect your system.

Now,
apt-cache showpkg mpich2

Under provides it should say:
1.4.1-1+b1
1.2.1.1-5

Now,
sudo apt-get install mpich2=1.2.1.1-5

You'll get a warning that you're about to downgrade, which is what we're trying to do.

sudo apt-get autoremove (will downgrade dependent packages. Just go with it)
aptitude search mpich2
check what's installed and what version
aptitude show libmpich2-dev
If it's 1.4.1 or not installed, make sure to set it to 1.2.1.1-5 just like for mpich2

Run sh myconfig.sh (see here for the script). Seems to build ok. All the mpd tools are where they should be.
NOTE: according to this post mpd isn't needed in newer (>=1.3) versions.

In summary, this seems to be the way to build nwchem on wheezy -- by downgrading the mpich2 and mpich2-dev packages. Since downgrading those packages may affect other packages as well, it may cause problems, but so far so good.

Testing the built binary:
mpd --ncpus=4 &
mptrace -l
mpdrun -n 4 ./nwchem ../../examples/dirdyvtst/h3/h3tr1.nw

All is good

EDIT (16/12/2011):
So, you've installed an older version of a package. apt-get will want to upgrade it, so you should put the packages on 'hold'. Every time you upgrade your system apt-get will warn you that there are packages on hold, so don't worry about forgetting about it

sudo su
echo "mpich2 hold"|dpkg --set-selections
echo "libmpich2-dev hold"|dpkg --set-selections

(taken from http://forums.debian.net/viewtopic.php?f=20&t=71448&start=15)

As an aside, you may want to downgrade gromacs-mpich to use mpich2-1.2 as well:
sudo apt-get install gromacs-mpich=4.0.7-3

28. Compiling/Building nwchem with mpich on debian 64 bit (15/12/2011) -- observations of squeeze, wheezy, sid and experimental

** NOTE: the nwchem build in the debian repos (6.0-1) does not support mpich. It will not run in parallel. It seems like 6.0-2 will, but it's not in the repos yet, and looking at the package status page I get a bit worried about the likelihood of seeing a finished build for amd64 **

** The solution to building on debian testing and above (and presumably ubuntu >10.10) is here: http://verahill.blogspot.com/2011/12/building-nwchem-on-debian-testing-64.html **

** NOTE: according to this post mpd isn't needed in newer (>=1.3) versions. It is needed -- and provided -- by mpich2 1.2**

So, I've had problems building nwchem on debian testing for about a year now. Actually, building nwchem is pretty straightforward, but building it with mpich2 support doesn't seem to work.

I also noted that mpd doesn't refer to an mpich daemon anymore, leading me to suspect that maybe the version of mpich2 (now at 1.4; was at 1.2 when I built on ubuntu early in the year) could be part of the problem.

Long story short: it builds with mpich2 support on debian stable (squeeze), but not debian testing (wheezy).


----------------------------------
SQUEEZE
----------------------------------
Here's what I did: I installed debian stable 64 bit in virtualbox from the business-card iso (standard tools + ssh. No desktop environment). I made sure the system (squeeze) was up to date, downloaded nwchem-6.0 and extracted it in /home/myhome/nwchem/nwchem-6.0  and create a build file, myconfig.sh, with the following content:
export LARGE_FILES=TRUE
export TCGRSH=/usr/local/bin/ssh
export NWCHEM_TOP=/home/myhome/nwchem/nwchem-6.0
export NWCHEM_TARGET=LINUX64
export NWCHEM_MODULES=all
export USE_MPI=y
export USE_MPIF=y
export MPI_LOC=/usr
export MPI_INCLUDE=$MPI_LOC/include/mpich2
export LIBMPI="-lfmpich -lmpich"
cd $NWCHEM_TOP/src
make nwchem_config
make FC=gfortran

Only thing remaining before building is:
sudo apt-get install mpich2 gfortran

mpich2: version 1.2

sh myconfig.sh then starts the build process which takes about 10-20 minutes in a virtual machine. Everything good. Works as should -- I only have one core in the virtual machine, so can't do much testing. It builds without a hitch though. In addition mpd, mpdtrace etc are all present.

 Time to take a snapshot. 1.7 Gb.
----------------------------------
WHEEZY
----------------------------------
I next edited /etc/apt/sources.list and replaced all instances of squeeze with wheezy (including commenting out the last two lines (wheezey-updates / squeeze-updates), did sudo apt-get update and sudo apt-get dist-upgrade

mpich2: version 1.4.1.
mpd and mpdtrace are now gone. Only mpi* around.

Tried sh myconfig.sh again (added a make clean before make nwchem_config). It builds for a long time - 10-20 minutes -- ultimately the build fails with
..
..
/usr/lib/libmpich.so: undefined reference to `MPL_trid'
..
..
/usr/lib/libmpich.so: undefined reference to `MPL_trinit'
collect2: ld returned 1 exit status
make: *** [all] Error 1

The undefined references are: MPL_trid, MPL_trvalid, MPL_env2int, MPL_trrealloc, MPL_trspace, MPL_trDebugLevel, MPL_TrSetMaxMem, MPL_trlevel, MPL_trmalloc, MPL_putenv, MPL_env2bool, MPL_env2range, MPL_trcalloc, MPL_trfree, MPL_en2str, MPL_trstrdup, MPL_trdump and MPL_trinit

So no luck with Wheezy, which is the system I run on all my computers. I've actually tried quite a few approaches under Wheezy and have managed to complete the odd build, but without getting proper functionality i.e. using mpiexec -n 6 six instances are created instead of one instance spread across six cores so that the system is solved six times instead of just one.


----------------------------------
SID.
----------------------------------
Time to take another snapshot followed by an upgrade.
The wheezy snapshot is 2.2 Gb -- wonder where the 0.5 Gb come from?

Replacing all instances of wheezy with sid using vim (:%s/wheezy/sid/g). Fails to fetch http://security.debian.org/dists/sid/updates/main/binary-amd64/Packages during sudo apt-get update. Oh well. Remove that line from sources.list. Now update works.
Then sudo apt-get dist-upgrade. 140 Mb of archives to get.


As a general thought -- maybe it'd be worth keeping a copy of sid in a virtual machine just to see what's around the corner?

Upgrade done, sudo shutdown -r now
mpich2: version 1.4.1, same as wheezy. No mpd or mpdtrace.

Try building and...starts at 14:17, fails at 14:45. Same errors as for Wheezy.

Last chance -- snapshot (1.9 Gb...), add a ref to experimental and...no updates. They are the same. Not worth trying thus.
------------------------------------


So there you go -- nwchem builds ok on Squeeze using mpich2 ver 1.2, but not on any of the more up-to-date distros. I also wonder about the lack of mpd/mpdtrace -- in Squeeze mpd is the mpich daemon, while in Wheezy and above it's the Music Player Daemon. Something is odd here.

Coming next: can you build nwchem on Wheezy if you pull mpich2 ver 1.2 from the archives? Of course you can. The answer and how-to is here: http://verahill.blogspot.com/2011/12/building-nwchem-on-debian-testing-64.html

11 December 2011

27. Linux: some applications

Here are some linux tools which I've found myself using:
_Terminal/cli_:
email -- mutt
chat -- mcabber
spreadsheet -- sc, sed + gawk, python
calculator -- bc
editing -- vim, nano
browser -- elinks
music -- cplay
plotting -- gnuplot
maths -- octave, maxima
Gnome (some of these I use only in the terminal, so I list them twice):
terminal -- guake
latex -- gvim, texmaker, latexilla
editing -- gvim, gedit
plotting -- gnuplot
maths -- octave, maxima
system stats -- conky
email -- evolution
chat -- gajim
browser -- chrome
video -- vlc
music -- mostly cplay in cli, but otherwise vlc
crypto -- truecrypt
password management -- keepassx
I probably spend 90% of my time using vim since, being a 'simple' editor, it's so versatile. Before taking the time to learn vim, I used gedit (and to a smaller extent nano) for the same purpose. Nano is fine, but vim is more ubiquitous (in the form of vi) and has an excellent tutorial included. I simply don't know what the full capabilities of nano are -- maybe it's only as powerful as, say, notepad, or maybe it can do everything vim can.
I gave emacs a serious try about a year ago, and it didn't suit me. I do appreciate that emacs can be considered as an OS almost in itself, but since I believe in the idea of one program - one task, and find vim more user-friendly (not meaning learner-friendly, although it is too) I felt more motivated to get serious with vim. Two weeks with emacs brought me to the same level as two rather relaxed evenings with vim.

26. Linux The Basics: the evolution of a user

I've used linux for a few years by now, and I find that how I do things have changed over this time. In other words, the way you use linux will change and evolve as you learn more. I never experienced this in windows -- there you click your way around, and you quite easily become stuck with a handful of applications and a way of doing things.

In the beginning, I dual-booted. Windows at work, where I would use originlab's origin, micromath scientist, excel etc. Linux at home where I'd browse the web, check email and chat. That lasted for a month or so, until I become confident that virtualbox could handle a copy of XP.

For about a year I persisted in doing most of my personal work in linux, and using virtualbox to run origin, use word to write articles etc. At least that way I only had to boot one operating system and could make the initially frightening step of removing windows for ever (you're a green linux user without anyone to help you, you have a paid job relying on you being able to use your computer, and you sever the ties with an OS which has been with you since 1993? It's frightening)

Making the transition complete required finding native ways of doing things. Instead of using origin I used gnuplot. I started using latex via texmaker. sed + gawk with a little bit of python has been a great stand-in for excel (there's always gnumeric as well). Latex has replaced powerpoint as well - I don't know why it never occurred to me before to use pdfs for presentation. I mean, it makes a whole lot more sense using something that's designed to be portable (fonts is the one theoretical issue) and which is pre-compiled. Rendering on the fly as powerpoint does is just asking for trouble (and as anyone who's ever been to a conference can confirm, a fair proportion of powerpoint presenters experience problems of some sort).

I've also slowly moved form using gnome with its tools, to using the terminal. Some things simply don't need a fancy gui. While at first I used gedit under gnome and nano in the terminal, I now use vim and gvim. While vim takes an hour or two to learn well enough to use, it is worth it for the convenience of a powerful keyboard-driven and ubiquitous editor. I also use vim for editing latex documents. Mutt is good enough for email when you don't need a gui, mcabber is less intrusive than gajim if you're busy, etc. And you can use them remotely. There's nothing that can be done in matlab (which exists for linux) that I can't do in octave. I don't need mathematica since I use maxima (they are not equivalent -- but I use maxima for symbolic math and octave for numerical stuff. I've dabbled in R as well, and while it's powerful I find the behaviour of it being a bit unpredictable -- R tries to second-guess what you want to do, and often gets it right. But not always).

There's no right way (but plenty of wrong ones -- if all you are doing in linux is installing explorer and msn in wine, then why bother?) of using linux, but what I do find satisfying is that you have the freedom to create your own workflow.

Where I am today: using Linux is no big deal. I don't think about it except when explicitly confronted with another OS. It's as second-nature as using windows once was -- you knew there were people out there using something infuriating and ridiculous-looking called MacOS  going 'eep' at inopportune moments, and that there was something hardcore called UNIX (Jurassic Park -- 'It's a UNIX system. I know this!'. That was 1993 btw.) Linux is just the way I do things, and I no longer evangelise. It might be age too -- you tend to be less religious about things as you get older. If people are willing to expand their horizons and feel that using linux makes sense, then I'm willing to help. If they are happy where they are today, that's fine too. Just don't email me any doc, docx or xls files where simple text files or a pdf would do -- that's just presumptuous in the other direction.

The main problem which hasn't been solved to this day is actually word. I can't stand the fetid piece of excrement (most people have at some point been frustrated by self-moving figures or odd formatting incidents), but if you collaborate with other people in writing articles and those people aren't willing to spend the time necessary to learn LaTex, you're pretty much stuck. Well, articles are better written by a single author anyway - writing by committee never flows. Anyway, turns out Office 2003 installs just fine in Wine. At this point, I find it difficult to understand why people insist on using binary formats like .doc and docx even for unformatted text. LaTeX works for me, and it suits my way of working.

Anyway, each to his or her own. The main challenge for a linux user isn't so much how to configure a certain piece of software as in finding out about the existence of the piece of software in the first place.

25. Linux The Basics: Google talk using Gajim or mcabber

Empathy is the stock gnome chat client, gajim is a REALLY versatile python-based chat client which integrates with gpg/pgp and mcabber is a command line chat client.

While I used empathy for a few years, I much prefer gajim. Partly it's the geek cred that comes with using something a bit less common, but mostly it's because it 1) supports gpg, 2) is highly configurable and 3) is easy to use. It's available in the debian repos. I like mcabber over centerim for the same reason - gpg support. Now, if I only had friends who were as paranoid as I...

[gajim]
Jabber ID: youruser@gmail.com
Resource: Gajim
Priority: adjust to status

Hostname: talk.google.com
Port: 5223

If you use gpg, go to the Personal information tab
You don't need to select 'Use gpg agent' (gpg agent segfaults on one of my boxes)


[mcabber]

The following goes into ~/.mcabber/mcabberrc

set color_background=default #allows transparent background

# Account
set jid = youruser@gmail.com
set password = areallylongandcomplicatedpasswordwhichyoullneverremember
set server = talk.google.com
set port = 5222
set ignore_self_presence = 1 #show self in list?

# GPG/PGP
set pgp = 1
set pgp_private_key = "01100110C1C1C1C1" # get the Key ID from seahorse 
set pgp_passphrase_retries = 3

set nickname = blofeld
set spell_enable = 1
set spell_lang = en_GB
set spell_encoding = UTF-8
set cmdhistory_lines = 250
set roster_display_filter = ofdna
set max_history_blocks = 8
set message_autoaway = Auto-away (idle)
set escdelay = 50

alias me = say /me
alias online   = status online
alias away     = status away
alias dnd      = status dnd
alias notavail = status notavail

bind 17 = roster unread_next
bind 24 = roster alternate
bind 269 = roster toggle_offline
bind 276 = roster toggle
bind 521 = buffer up
bind 514 = buffer down

24. Linux and The Basics: configuring Evolution for gmail or fastmail accounts

While it comes more naturally to post a blog entry when you've just managed to fix a problem which has been nagging you, it helps newcomers to the linux community if you post how-to guides for the more basic stuff.

Since I can see what search terms drive people to the blog, I get a very simplistic overview of what people are looking for but which the blog doesn't yet provide. So, here are the gmail and fastmail (http://www.fastmail.fm/) settings.

[gmail]

If you're using google apps with an address along the lines of user@domain.example, then keep the server names (i.e. smtp.gmail.com) but use the full address (user@domain.example) as the user name.


--Receiving email
server type: imap (or imap+)
server: imap.gmail.com
username youruser@gmail.com
Use secure connection: ssl
Authentication type: password

--Sending email
Server type: smtp
server: smtp.gmail.com:587
use secure: tls
type: login
username youruser@gmail.com

--Defaults
Drafts: youruser@gmail.com/Drafts
Sent: youruser@gmail.com/Sent
etc.
*******************************
[fastmail] -- fastmail has a lot of domains. Like for google apps this means you must include the domain name in the username. Here's how it's done for imap.cc


--Receiving email
server type: imap (or imap+)
server: mail.messagingengine.com
username youruser@imap.cc
Use secure connection: ssl
Authentication type: password

--Sending email
Server type: smtp
server: mail.messagingengine.com
server requires authentication: yes
use secure: tls
type: login
username youruser@imap.cc

--Defaults
Drafts: youruser@imap.cc/INBOX/Drafts
Sent: youruser@imap.cc/INBOX/Sent
etc.

06 December 2011

23. Configuring Mutt for two IMAP accounts

Edit: fastmail configuration added -- see beneath original post

Here's my situation: I have a personal gmail account, and a google apps gmail account via my job.

A lot of the configuration stuff (gpg in particular) was copy/pasted from some website a few years ago. Kudos to them. If I only remembered who they were, I'd give credit where credit is due.

Since I'm paranoid about protecting my identitity, let's say that the google apps account is vera@hill.com and my gmail account is verahill@gmail.com (it isn't).

Here's how it can be done:
1. create ~/.mutt
2. You want to create the following files in ~/.mutt :
private.account
work.account
muttrc


Optional:
aliases
signature.private
signature.work

3. Here are the contents of the files (the passwords are from http://xkcd.com/936/):

~/.mutt/private.account:
set from=verahill@gmail.com
set hostname="gmail.com"
unset folder
set folder="imaps://verahill@gmail.com@imap.gmail.com"
set postponed="=Drafts"
set record="=Sent"
set smtp_url="smtps://verahill@gmail.com@smtp.gmail.com"
set spoolfile="imaps://imap.gmail.com/INBOX"
set from='Vera Hill <verahill@gmail.com>'
set signature="~/.mutt/signature.private"

~/.mutt/work.account:
set from=vera@hill.com
set hostname="hill.com"
unset folder
set folder="imaps://vera@hill.com@imap.gmail.com"
set smtp_url="smtps://vera@hill.com@smtp.gmail.com"
set from='Vera Hill <vera@hill.com'
set realname='Vera Hill'
set postponed="=Drafts"
set record="=Sent"
set spoolfile="imaps://imap.gmail.com/INBOX"
set signature="~/.mutt/signature.private"

basic ~/.mutt/muttrc
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates

set sort='threads'
set sort_aux='last-date-received'
set imap_check_subscribed


auto_view text/html #needs ~/.mailcap and install elinks!
set attribution="* %n <%a> wrote\a ecrit:\n"

set pager_index_lines="15" #split view 

# Make sure the inbox updates and bind a key
set timeout=15
set mail_check=60
bind index "i" imap-fetch-mail

#dual boxes specific
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/private.account<enter><change-folder>!<enter>'
macro index <f4> '<sync-mailbox><enter-command>source ~/.mutt/work.account<enter><change-folder>!<enter>'

folder-hook 'verahill@gmail.com' 'source ~/.mutt/private.account'
folder-hook 'vera@hill.com' 'source ~/.mutt/work.account'

account-hook imaps://verahill@gmail.com 'set imap_user=verahill@gmail.com imap_pass=correcthorsebatterystaple smtp_pass=correcthorsebatterystaple'
account-hook imaps://vera@hill.com 'set imap_user=vera@hill.com imap_pass=Tr0ub4dor&3 smtp_pass=Tr0ub4dor&3'
source ~/.mutt/private.account # default account

~/.mailcap:

#allows viewing html, but requires that elinks is installed
text/html;                      elinks %s; nametemplate=%s.html
text/html;                      elinks -dump %s; nametemplate=%s.html; copiousoutput


You can do a lot more -- if you want to use an address book (aliases), create a file called ~/.mutt/aliases with each line having an alias of the format:
alias  Obama "Barak Obama" <potus@whitehouse.gov>

Add the following to the end of your muttrc:
 # Addressbook
set alias_file=~/.mutt/aliases
set sort_alias=alias
set reverse_alias=yes
source $alias_file

If you want to use GPG add this to your muttrc (anywhere) and the ID of your key is C1C2C3C4:
# GPG stuff - autosign


set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0xC1C2C3C4 -- -r %r -- %f"
set pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0xC1C2C3C4 -- -r %r -- %f"
set pgp_import_command="gpg --no-verbose --import -v %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r" 
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r" 
set pgp_autosign=yes
set pgp_sign_as=0xC1C2C3C4
set pgp_replyencrypt=yes
set pgp_timeout=1800
set pgp_good_sign="^gpg: Good signature from"

If you prefer vim to nano:
set editor="vim -c 'set tw=70 et' '+/^$' "
set edit_headers=yes

A colour-scheme which happens to work with my set-up for guake:
color index green black plain
color normal green black
color status white black
color body green black plain
color header cyan black plain
color quoted blue black
color tree green black

Not sure what this does (something to do with headers) but it's there in my file:

ignore "Authentication-Results:"

ignore "DomainKey-Signature:"

ignore "DKIM-Signature"

hdr_order Date From To Cc

EDIT:
If you want to add a fastmail account (in my case me@imap.cc), do this:
There's no free smtp service from fastmail, so I use the gmail smtp service

Create imapcc.account in ~/.mutt and fill it with

set from=me@imap.cc
set hostname="imap.cc"
unset folder
set folder="imaps://me@imap.cc@messagingengine.com"
set postponed="=Drafts"
set record="=Sent"
set smtp_url="smtps://verahill@gmail.com@smtp.gmail.com"
set spoolfile="imaps://messagingengine.com/INBOX"
set from='Me at gmail <verahill@gmail.com>'
set signature="~/.mutt/signature.private"


and edit ~/.mutt/muttrc to add the following lines:

macro index <f5> '<sync-mailbox><enter-command>source ~/.mutt/imapcc.account<enter><change-folder>!<enter>'

folder-hook 'me@imap.cc' 'source ~/.mutt/imapcc.account'
account-hook imaps://me@imap.cc 'set imap_user=me@imap.cc imap_pass=ashortpassword smtp_pass=correhorsebatterystaple'

05 December 2011

22. gnome-shell/GNOME3 -- acceptance

So after the turmoil of being thrown into a new desktop metaphor, I've finally reached a stage where I'd feel less at home in Gnome 2.3 than 3.0. Truth be told, the new gnome is both pretty and quite responsive. Key to making Gnome 3 usable is, however, that enough shell extensions are installed that it works similar to the old gnome. The application centric desktop may work for casual users (email/browser), but not for traditional linux/unix applications where different parts of a work flow is handled by different applications (e.g. latex -- scripting/composition in one application, compilation by another, inspection in a third; or gnuplot -- data preparation, gnuplot scripting, visualisation of output file).

But once all the shell extensions are installed, it's back to business as usual.

Even Linus seems to be coming around to Gnome 3 after mumbling about defecting to xfce4: https://plus.google.com/102150693225130002912/posts

So far I've only had one unresolved problem - an 'old' desktop with a radeon 5400 hd card won't run gnome-shell on debian testing. No acceleration. Oh well. At least all my other computers are reasonably happy so far.

26 November 2011

21. Current Bug -- gnome applications unresponsive to keyboard input

UPDATE 02/02/2012:
It seems like whatever the problem was, it's gone now. An up-to-date testing system with ibus runs smoothly.

26/11/2011
For some reason, after updating today I'm having a hard time entering input in various gnome applications, whereas non-gnome applications work fine.
E.g. I can't type certain letters, and in general it's difficult to provide any inpurt, in gnome-terminal and gnome-session-properties. lxterm and guake work completely normal though.

No sure what is causing this, but it's happening on my Thinkpad SL410 as well as on my Optiplex 910. The only thing they have in common is the operating system (up-to-date debian testing 64 bit).

Don't know enough about it to file a bug report.

Edit: the problem is present in Evolution as well. Still present as of 28/11/2011. Problem exists on a home-built six-core AMD with 1 GB graphics card.

Edit 2: It sounds a bit like this, which was reported in June (!).
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631116
It seems to be related to iBus/SCIM


Edit 3: Evolution is also affected, as is gEdit. Turning off iBus 'solves' the problem. Now, why does it affect the standard gnome applications, but not other packages?

At any rate, this bug has given me the incentive to leave gnome-terminal for guake, and to give alpine and thunderbird a try instead of evolution.

I tried
sudo apt-get install ibus-gtk3
sudo apt-get autoremove ibus-gtk

iBus still works. But unfortunately evolution is still way too slow to be useful.

25 November 2011

20. Is there no molecular weight calculator in the Debian repos?

UPDATE: see here for an isotopic calculator written in python -- it calculates mass as well: http://verahill.blogspot.com.au/2012/10/isotopic-pattern-caculator-in-python.html

The best molecular weight calculator which I've encountered is Matthew Monroe's Molecular Weight Calculator, which can be found at http://ncrr.pnnl.gov/software/

It does everything. Molecular weights. Isotopic patterns. And so, so, so much more.

It has one major drawback though - it's written for Windows. Luckily, it sort of works under Wine after you've done a bit of wine-trick-ery.

As great as the calculator is, sometimes you only need to calculate the molecular weight of something, and nothing else. Searching the debian repos I can' t find a single dedicated molecular weight calculator. In particular, a command-line driven calculator would be nice.

Seriously - it's a crying shame that the distribution with the largest repos, i.e. Debian, does not have a single passable molecular weight calculator. It is even more surprising given the number of chemistry-related packages which are present.

So, here's what I did:
a quick google on "python molecular weight calculator" brought me to http://pygments.org

A little bit of editing gave the code below, which was saved as molcalc, copied to /usr/bin, followed by sudo chmod +x /usr/bin/molcalc. It can now be called using
molcalc "(Co(CO)5)2"
and returns
The mass of (Co(CO)5)2 is 257.916890.

Here's the code, which is 99.9% the original and 0.1% my modification. All credit thus due to Lee, Freitas and Tucker.

NOTE: it doesn't handle layered parentheses. (Al(NO3)3)2 gets interpreted as Al2(NO3)3.

#!/usr/bin/python2.6
#########################################################################
# Author: Toni Lee with the help of Guilherme Freitas and Becky Tucker. Minor changes by Lindqvist
# Copyright: This module has been placed in the public domain
#########################################################################

#Import regular expressions
import re
import sys
try:
test=sys.argv[1]
except:
quit()

#Create the dictionary (From Becky with a value of 0 inserted for Uus(mass not measurable))
TableofElements ={ 'H':1.00794,'He':4.002602,'Li':6.941,'Be':9.012182,
                        'B':10.811,'C':12.0107,'N':14.0067,'O':15.9994,'F':18.9984032,'Ne':20.1797,
                        'Na':22.98976928,'Mg':24.3050,'Al':26.9815386,'Si':28.0855,
                        'P':30.973762,'S':32.065,'Cl':35.453,'Ar':39.948,'K':39.0983,'Ca':40.078,
                        'Sc':44.955912,'Ti':47.867,'V':50.9415,'Cr':51.9961,'Mn':54.938045,
                        'Fe':55.845,'Ni':58.6934,'Co':58.933195,'Cu':63.546,'Zn':65.38,'Ga':69.723,
                        'Ge':72.64,'As':74.92160,'Se':78.96,'Br':79.904,'Kr':83.798,'Rb':85.4678,
                        'Sr':87.62,'Y':88.90585,'Zr':91.224,'Nb':92.90638,'Mo':95.96,'Tc':98,
                        'Ru':101.07,'Rh':102.90550,'Pd':106.42,'Ag':107.8682,'Cd':112.411,
                        'In':114.818,'Sn':118.710,'Sb':121.760,'Te':127.60,'I':126.90447,
                        'Xe':131.293,'Cs':132.9054519,'Ba':137.327,'La':138.90547,'Ce':140.116,
                        'Pr':140.90765,'Nd':144.242,'Pm':145,'Sm':150.36,'Eu':151.964,'Gd':157.25,
                        'Tb':158.92535,'Dy':162.500,'Ho':164.93032,'Er':167.259,'Tm':168.93421,
                        'Yb':173.054,'Lu':174.9668,'Hf':178.49,'Ta':180.94788,'W':183.84,
                        'Re':186.207,'Os':190.23,'Ir':192.217,'Pt':195.084,'Au':196.966569,
                        'Hg':200.59,'Tl':204.3833,'Pb':207.2,'Bi':208.98040,'Po':210,'At':210,
                        'Rn':220,'Fr':223,'Ra':226,'Ac':227,'Th':232.03806,'Pa':231.03588,
                        'U':238.02891,'Np':237,'Pu':244,'Am':243,'Cm':247,'Bk':247,'Cf':251,
                        'Es':252,'Fm':257,'Md':258,'No':259,'Lr':262,'Rf':261,'Db':262,'Sg':266,
                        'Bh':264,'Hs':277,'Mt':268,'Ds':271,'Rg':272, 'Uus':0
}


#######################################
#Computes the MW of an atom-number pair
#######################################
def getMass(x):
    atom=re.findall('[A-Z][a-z]*',x)
    number=re.findall('[0-9]+', x)
    if len(number) == 0:
        multiplier = 1
    else:
        multiplier = float(number[0])
    atomic_mass=TableofElements[atom[0]]
    return (atomic_mass*multiplier)

################################################################
#Segments formula into atom-number sections (i.e. 'H3' or 'N10')
################################################################
def parseFormula(fragment):
    segments=re.findall('[A-Z][a-z]*[0-9]*',fragment)
    return (segments)

##################################################################################
#Computes total mass of both parenthetical and nonparenthetical formula components
##################################################################################
def molmass(formula):
    parenMass=0
    nonparenMass=0
    while (len(formula)>0):
        #First computes the molecular weight of all parenthetical formulas from left to right
        while (len(re.findall('\(\w*\)[0-9]+', formula))!=0):
            parenthetical=re.findall('\(\w*\)[0-9]+',formula)
            for i in range(0,len(parenthetical)):
                parenMult1 = re.findall('\)[0-9]+', parenthetical[i])
                parenMult2 = re.findall('[0-9]+', parenMult1[0])
                segments =parseFormula(parenthetical[i])
                for i in range(0, len(segments)):
                    parenMass= parenMass + ((getMass(segments[i]))*(float(parenMult2[0])))
            formula=re.sub('\(\w*\)[0-9]+', '', formula)
        #Sums nonparenthetical molecular weights when all parenthetical molecular weights have been summed
        segments = parseFormula(formula)
        for i in range(0, len(segments)):
            nonparenMass=nonparenMass + getMass(segments[i])
        formula=re.sub(formula, '', formula)

    Mass=parenMass+nonparenMass
    return Mass
     
if __name__ == '__main__':
test=test.split(',')
for element in test:
print ('The mass of %(substance)s is %(Mass)f.' % {'substance': \
element, 'Mass': molmass(element)})