screenshotmultilingo

Android touch-typing

How many times did you see phone users cursing their tiny buttons of phone keyboards or their strange sent messages or e-mails ending with ‘Love’ instead of the intended ‘Sincerely yours’?

One of the most widespread solution to this problem is ‘smart guessing’ of what you wanted to write either by pushing the virtual keyboard buttons or by gesturing over them. This solution is great both for the developpers – it requires an expert system to work – and for many users who did not find something better.

An alternative keyboard system, which with some training allows almost blind touch typing on a phone, was developed well before the current smartphones and is called MessageEase. The ME keyboard served me to a fantastic extent in the past 3 years and was never challenged by any other tool (even if I tried every released Android keyboard under the sun). It works by reducing the number of buttons on a keyboard to 9 main ones. Each button corresponds to a main letter, with 8 other possible characters that can be obtained by sliding the finger from the center towards the 4 sides or the 4 corners of the square forming the button. My current layout, helpful for both French and English, is shown below.

screenshotmessageease
MessageEase key layout, for French.

What will happen if, for some reason, ME development stops some day? Having alternatives is good and, as long as it allows one to explore some new ways to do the same things differently, it can be fun. I was thus happy to see the very active development of Han Honso’s Multiling O keyboard for Android. One of the customization modes, obtained by starting on the ‘space’ key and going to ‘Layouts’ is called Do It Yourself (DIY). A simple text description allows one to change all the keys to your liking, including a ‘4D’ mode that givest to any key 9 possible values (center and 8 directions).

A very usable implementation of a MessageEase-like layout is obtained with the code found at the end of this post, that you can paste afte choosing the DIY+ option: The keyboard will look similar to the next picture, depending on the theme settings:

screenshotmultilingo
Multiling O keyboard, ME-layout

The current version of the layout I’m using is not perfect, especially the position of numbers. 8, for example, is not easy to obtain as it involves an unnatural positioning of the fingers. Still a lot of fun.

{“title”:”mesgease1″,”onScreen”:{“main”:[“[4D:0 1234][4D:a -â àv ][4D:n+^!l][4D:i?_ = x][4D:5 [COPY] [PASTE]6789]”,”[LEFT][4D:u(ôkç][4D:ochbdqpjg][4D:rm*) @][RIGHT]”,”[SHIFT][4D:t<êè/ y][4D:eéwz. ‘:,][4D:s# > f ;][DEL]”,”[TOOL][ALTGR:,][SPACE][][SYM:.][ENTER]”]}}

sozi presentation image

Svg based presentations with Inkscape and Sozi

Have you ever heard of deck.js, Impress or Reveal ? These are tools that allows one to create nice web-based presentations with plenty of animations. As strange as it may sound, I first looked at these apps because I wanted some smooth drop shadows for the pictures in my own LibreOffice presentations. CSS can be used to get that effect. I tried all the above mentioned libraries and tools and was disappointed by the fact that adding images and graphics seems to be an after-thought. These tools are excellent for text-based presentations but placing vector graphics, like svg, in a particular position and making graphically-rich presentations is not their main domain of use. Users circumvented these limitations by writing extensions, see examples for deck.js here.

Wandering on the web led me to a tool that allows graphic rich presentations to be made with the best open source tool for vector graphics creation: Inkscape. One of the integrated plug-ins, called JessyInk, allows one to use a succesion of layers to create an svg file that, when opened with a web browser, are shown one after the other. JessyInk is an impressive tool, allowing one to annotate ‘live’ the presentation or to show an overview by clever keyboard shortcuts, but I did not like the fact that the original svg had to superpose all the layers. Additionally, the svg file is modified by JessyInk with some elements not being rendered at all in the obtained presentation. Not good.

In search for an alternative, I found Sozi, an application that takes a different approach from JessyInk. It allows something that I did not thought possible – take a poster, done with Inkscape or other svg creator, and make a presentation based on succesive views of different parts of the large image. Everything is integrated in a html/json pair of files that integrate the original svg with JavaScript magic. While the Sozi interface is in need of some ergonomy improvements, the tool is robust enough to allow me to create a 60 slides presentations in an evening, from a large svg file that I already had in Inkscape. A few of the slides  can be viewed on my bitbucket site (although some images lack from the presentation). Scrolling allows zooming in and out of the slides and clicking on the slide number opens a nice menu with all the slide titles, for fast navigation. The first slide, as a screenshot of my current Ubuntu desktop (clicking on the image goes to the presentation page):

sozi presentation image
Sozi presentation, first slide

I would very likely use Sozi and Inkscape for presentations in the future. There are a few things to consider though:

  1. Images inserted in the SVG file are better handled through relative links and should be kept in a directory that is close to the svg file itself. Moving the presentation around becomes possible if the html, json and img folder are moved together.
  2. Sozi does not allow for the moment to easily have several versions of the presentation based on the same svg but this feature might come in the future. It will be also very useful to allow the existence of svgs where text was converted to paths, so that one does not need to carry some exotic fonts around just to be able to show a presentation. If you want to duplicate a presentation, you have to duplicate the html, json and original svg and change their name so that they match each other.
  3. One has to be familiar with Inkscape and its quirks.
  4. Web browsers are not exactly familiar to the idea of presentations, the mouse pointer, for example, insists on showing the title of the web page.
  5. Do not use layers in the original Inkscape presentation. Somehow, Sozi becomes confused and might transform the layers differently, giving a very strange result. Better to use blocked elements, if you want to make a pattern of rectangular regions as template for the graphical elements of the presentation.
  6. Always do a backup of your presentation in PDF – sozi-to-pdf does it gracefully. It is a module that has to be installed separately. It generates a rather large pdf file because it is composed of high quality graphic png. While it is large, it will not depend on locally installed fonts or any additional resources to be displayed as you expect it to be.

 

unity

Customize Ubuntu 14.04 on a HP Zbook

A few notes about things I did to be able to work with Linux on a HP Zbook 14 G2. Dual boot was problematic because gparted had difficulties with the M.2 SATA SSD. In the end, Linux lives happily on the HDD and a NTFS partition ensures bidirectional communication with Windows.

Once Ubuntu LTS 14.04 was installed, several changes were needed to adapt the display resolution (920×1080 pixels), adjust battery usage, add some useful utilities and hide or show disk partitions at will:

1. Make fonts larger on high dpi screen for the grub menu (from http://b.wardje.eu/2014/08/increase-font-in-grub-for-high-dpi.html):
sudo grub-mkfont --output=/boot/grub/fonts/DejaVuSansMono24.pf2 --size=24 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

Add the following lines to the grub configuration file (can be edited with “sudo gedit /etc/default/grub”):
## More readable font on high dpi screen, generated with
## sudo grub-mkfont --output=/boot/grub/fonts/DejaVuSansMono24.pf2 \
## --size=24 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
GRUB_FONT=/boot/grub/fonts/DejaVuSansMono24.pf2

Update grub to take into account the new configuration:
sudo update-grub

2. Install LibreOffice 5:
sudo add-apt-repository ppa:libreoffice/libreoffice-5-0
sudo apt-get update
sudo apt-get dist-upgrade

3. Install a very capable FTP client (lftp) and an alternative file manager (Double Commander):
sudo apt-get install lftp
sudo add-apt-repository ppa:alexx2000/doublecmd
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install doublecmd-gtk

4. Install exFAT support
sudo apt-get install exfat-fuse exfat-utils

5. Command line information on battery usage:

upower -i /org/freedesktop/UPower/devices/battery_BAT0

Get information on battery usage (11.5 W average):
sudo apt-get install powerstat
powerstat -d 1

Test if hibernate works; no it does not work well, forget about it.
sudo pm-hibernate

6. Optimize energy consumption with tlp:

Install tlp from ppa (will be included in the main repository for further versions of ubuntu)
sudo apt-add-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp

Configure TLP:
cd /etc/default/
cp tlp ~/tlpconfig.backup
sudo gedit tlp
# modify SATA option, from http://refugeeks.com/use-tlp-to-optimize-the-power-consumption-in-ubuntu/
# modify SATA_LINKPWR_ON_BAT=min_power to max_performance

7. Hide windows partitions from XFCE and Unity and automount partitions:
cd /etc/udev/rules.d/
sudo gedit 99-hide-disks.rules
# use the right names for the disks or their identifiers
#KERNEL=="sda1", ENV{UDISKS_IGNORE}="1"
#KERNEL=="sdb2", ENV{UDISKS_IGNORE}="1"
# at reboot the sda1 and sdb2 partitions will not be visible any more
# inactivate fast boot option in Windows, otherwise shared disks are unmountable in Linux

# Automatically mount removable partitions
# https://help.ubuntu.com/community/AutomaticallyMountPartitions
# First, get the identifier of the partition with "mount" -> /dev/sda3
# Get the uiid:
ls -al /dev/disk/by-uuid/
# lrwxrwxrwx 1 root root 10 mars 2 08:31 someuiid...
# Add to startup items:
/usr/bin/udisksctl mount --block-device /dev/disk/by-uuid/someuiid

8. Packages required to install R on Ubuntu:
# Various packages required for installation of R parts, if packages complain about missing libraries:
sudo apt-get install libxml2-dev
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-gnutls-dev

9. Display customization and other tricks:

Change dpi settings in the “Displays” preference > scale 1.38
Install Unsettings to change Unity settings
sudo add-apt-repository ppa:diesch/testing
sudo apt-get update
sudo apt-get install unsettings

Change the brown color of selected item to something else (blue)
sudo apt-get install gtk-theme-config

Make text and other things larger on high dpi for Firefox
Write: *about:config* in the address bar
Then change the layout.css.devPixelsPerPx value to 1.4 (user set string)
The same can be done for Thunderbird (Preferences > Advanced > Edit config)

 

VirtualBox Linux shared folders how-to

Switching from Ubuntu/Debian to Manjaro/Arch linux as VirtualBox guest operating systems has consequences.

First, Manjaro/Arch already has the virtualbox guest extensions pre-installed, which is very convenient. These extensions allow running the virtual machine full screen with adjusted resolution and mounting shared folders with the host OS.

Second, an additional manipulation is required for Ubuntu to make shared folders accesible (as described here):

Question: I configured a shared folder between the Windows host and Ubuntu guest. The folder mounts at start up but its empty. It also has a padlock sign.

Answer: You, as a user, were not added to the vboxsf group, to which the mounted share folder belongs. To allow access to the shared folders permanently, in a Terminal window on the new Ubuntu:

sudo usermod -G vboxsf -a username

where you replace username with your own user name. This command appends the user “username” to the vboxsf group, which is the owner of the shared folders (found in /media/ on the Ubuntu box). You won’t need to run a script at startup once you own the mounted shared folder.

On Manjaro/Arch Linux (with LXDE), the mount does not happen automagically. I created a ‘shared’ folder in my user home directory. Next, I mounted the shared folder using the virtualbox mount command:

sudo mount.vboxsf temporary /home/myusername/shared

EDIT: the command allows some read access but no write access. To have access in both directions as a user follow the instructions detailed in a superuser answer:

sudo mount.vboxsf -o gid=1000,uid=1000,rw temporary /home/myusername/shared

I wrote this blog post as a reminder for myself and in the hope that it could be useful for someone else (even if I already wrote some of this information in a previous blog post)

Column order and decimal point changes with awk and sed

Recently, I’ve been confronted with a simple problem that I usually solve in a spreadsheet application. In a text file, change the order of columns and shift from “,” to “.” as a decimal point separator. However, since I had many similarly formatted text files and did want to speed up the conversion, I searched for tools that could help me do theses simple tasks without too much hassle. Welcome awk, a programming language and tool for text processing and sed, a line-by-line editor, both available by default in MacOS X and Linux. As usual, stackexchange answers and question were extremely useful to quickly find a solution.

While I was awking happily around, I became aware of a problem that I did not expect – it uses line feed characters (LF) as line terminator and if the file comes from Window, it has carriage return (CR) and LF at the end of lines. Thus, the first step needed to get a clean file, was to remove those annoying CR (well visible in the following screenshot, on Geany, a fantastic text editor):

inputfile

This can be done with the following awk command that removes CR characters while leaving LF in the file:

awk '{ sub(/\r$/,""); print }' infile.txt >outfile.txt

The result is, as expected:

crremoved

Now, we can proceed with the following step, which is a change in column order. What I needed was to move 4th column in second position. Awk comes to the rescue here as well:

awk -F\t '{print $1,$4,$2,$3}' OFS=$'\t' infile.txt > outfile.txt

The result looks good, no more CRs and the order of columns is fine:

columnorderchanged

Finally, the numeric values that used “,” as decimal separator were not correctly interpreted by the clustering program. However, changing all the commas to dots was not very nice, because column 2 now contains useful text commas. Sed provided a very simple command to do that:

sed 's/\([0-9]\)\,\([0-9]\)/\1.\2/g' < infile.txt > outfile.txt

To understand how sed does its thing, one must be familiar with regular expressions.

In the end, the file looks exactly as I wanted it to be:

commadotchanged

There is no need to keep intermediate files and these commands can be chained using the “|” pipe operator. Alternatively, they can be put together in a small shell script.

Any alternatives to LaTeX for collaborative manuscript writing in science ?

In a world in which we read mostly on screens and in which unprintable data like videos or high resolution images are part of published papers, it makes sense to think of new ways of producing, sharing and reading research results. Finding ways to easily collaborate with co-workers and to be able to keep a manuscript in a shareable and flexible format is an ongoing quest (see for example, datacite).

When trying to see what online tools allow to write manuscripts in a collaborative way, I was very much impressed by Overleaf‘s interface and gave it a try for a real manuscript writing. While some of my colleagues had no problem in working with the system, it is still a little odd that, for example, including citations requires uploading a file in the .bib format. Some ‘infinite compiling’ errors scared one of my collaborators and were perceived as a lack of robustness of the system. Adding references and cross-references remains quite involved and one needs some time spent in LaTeX innards to be able to get to a nice end result.

Lens Writer screenshot
An image of Lens Writer in action. Installing the package from github and launching a local server is very simple.

This post was motivated by my recent enthusiasm when reading about a JavaScript library called Substance that serves as a basis for several projects, including one that is designed to allow easy writing and sharing of scientific data:  Lens Writer. The philosophy of this way of writing a scientific report is, from my very limited understanding of it, that everything revolves around web-based technologies, running with JavaScript. An early version of the editor, working with Node.js, provides a play ground for those curious to test its capabilities. Definitely a project that will be very interesting to follow and see its evolution!

LabKey – manage shared lists of reagents, oligos, strains

LabKey is a very friendly system for lab scale, or larger, sharing of common data. In our own hands, LabKey replaced a series of spreadsheets giving a much better way to edit and view things; mostly lists of reagents. The software can be obtained from:

https://www.labkey.org/

Nelson EK, Piehler B, Eckels J, Rauch A, Bellew M, Hussey P, Ramsay S, Nathe C, Lum K, Krouse K, Stearns D, Connolly B, Skillman T, Igra M. LabKey Server: An open source platform for scientific data integration, analysis and collaboration. BMC Bioinformatics 2011 Mar 9; 12(1): 71.

http://www.biomedcentral.com/1471-2105/12/71

LabKey works on on an Apache tomcat java server and it’s mostly Java on server side with some JavaScript enhanced pages on the user side. A working relational database server is also required. Not perfect but better than shared Excel files.

The installation we use is on a Windows machine with VirtualBox on which a Ubuntu 12.04 is installed. Installation was not painless but I followed the steps detailed in the python file: install-labkey.py. I had some problems with showing the Apache server to the outside world from within the virtual machine. A short description of how to install a Ubuntu machine on a Mac is here:
http://aboutfoto.bitbucket.org/rggobi_macosx.html

I just found a few notes on steps taken to configure a working LabKey on Linux (Ubuntu). These are useful especially if you are doing the install in a VirtualBox machine:

sudo apt-get install build-essential 
#installs compilers
>sudo usermod -G vboxsf -a yourusername 
#adds a user to the group -vboxsf to allow sharing of a folder
#install the server and database system (adjust numbers to actual versions)
>sudo apt-get install sendmail tomcat6 postgresql xvfb graphviz r-base
>cd /usr/local/
>sudo cp -R ~/Downloads/jre1.7.0_21 ./
>sudo ln -s /usr/local/jre1.7.0_21/ /usr/local/java
#configure the database user
>sudo -s -u postgres
>createuser -P
>sudo service tomcat6 stop
#help labkey user get access to the configuration in the tomcat server folder
>sudo chown -R tomcat6:tomcat6 labkey/
#make logs position a little bit easier to find.
>sudo ln -s /var/log/tomcat6/ /usr/share/tomcat6/logs

I’ve updated the LabKey server to the latest version (14.2, as of July 2014). While I thought it would be easy, I ended up by upgrading:
– Java (to 1.7 OpenJDK and Sun – I don’t really know which one is used – the system reports Oracle but the tomcat7 user has apparently a mind on its own),

– PostgreSQL (to 9.3 from 9.1 and kept the database safe using a script from postgres-contrib, pg_update, and indications from this blog post). The update failed if launched from the home directory. Worked if started from the /var directory because the script wants to write a log file and needs write permissions.
– Tomcat from 6 to 7 (relatively painless). Works very nicely as a service and can be stopped started at will with >sudo tomcat7 start (or stop or restart).
With the update, I changed also the way I remotely backup the data from the labkey database. Getting json files is good, but a pg_dump is much better. The only problem was that I did not know how to talk to the database – two configuration files needed to be changed to allow remote connection (postgresql.conf and pg_hba.config, as explained here.) In addition, another port forwarding needs to be added to the VirtualBox configuration.
The new LabKey version is improved compared to the older one. I feel more confident now about upgrading the thing.