## Monitoring your unit tests without lifting a finger

I love unit testing. First of all, I think it is a good idea to test separate units of the code, but after doing so for some time, I’ve come to realize that unit tests are great for managing the software development cycle too. It all boils down to the idea that you should write tests before you write your code.

Now, this is something that I and others apparently struggle a lot with. How do you write a test for some code that doesn’t even exist yet? Even worse, how do you write a test for a piece of software that you’re not yet sure how will be used?

In computational physics, this problem arises often because we are writing code at the same time as we are trying to understand the physics, mathematics and algorithms at hand. And this is a good thing. You might want to think that one should structure all code before it is written, but this is generally a bad approach in computational physics. Especially if you’re working on something new. The reason is that you will often understand the problem and algorithms better while developing, rather than just reading about them and trying to analyze them blindly.

## Keeping the tests and code healthy

But enough with the talk, let’s just assume that you are convinced that you should (or have to) implement some unit tests. At one point you are likely to be in a position where you find it tiresome to have to go into that folder where the tests are defined and run them manually. This is where Jenkins comes in to play.

## Using Wacom tablet with dual monitors (TwinView) in Ubuntu

I have a setup with two monitors on my computer and wanted to restrict my Wacom tablet to only one of the screens. Otherwise, the tablet is expanded to the entire two screens, making any drawing stretched.

This has shown to be quite simple to fix if you can live with a script doing the job for you. First, type the following in a terminal and note the output:

xinput --list

You will see a bunch of names for you peripheral devices. You should look for anything that has to do with “Wacom”. For instance, on my machine, I see these names:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Wacom Graphire4 4x5 eraser              	id=12	[slave  pointer  (2)]
⎜   ↳ Wacom Graphire4 4x5 cursor              	id=13	[slave  pointer  (2)]
⎜   ↳ Wacom Graphire4 4x5 pad                 	id=14	[slave  pointer  (2)]
⎜   ↳ Wacom Graphire4 4x5 stylus              	id=15	[slave  pointer  (2)]

Now, create a file somewhere on your computer. I’ve put mine in a subdir of my home directory, naming it “wacom-settings.sh”. Add these contents to the file and change the name of each “Wacom…” to whatever you received as output above:

#!/bin/sh
xsetwacom --set "Wacom Graphire4 4x5 stylus" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 stylus" Screen_No 0x001
xsetwacom --set "Wacom Graphire4 4x5 cursor" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 cursor" Screen_No 0x001
xsetwacom --set "Wacom Graphire4 4x5 pad" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 pad" Screen_No 0x001
xsetwacom --set "Wacom Graphire4 4x5 eraser" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 eraser" Screen_No 0x001

Then you’ll just have to make the file executable. This could be done from terminal by issuing the command

chmod +x wacom-settings.sh

in the same directory as the file.

You could also right-click the file, select Properties > Permissions tab and check “Allow executing this file as a program”.

You might either add this file to your startup applications under System > Preferences > Startup Applications (this will only work if your tablet is connected when logging in) or you could add a launcher on either your desktop or in one of your panels by dragging the file there.

This should be it. To test that the configuration really works, double click the file and click “Run in Terminal”. If the tablet appears on the wrong screen, change the Screen_No above from  0x001 to 0x000.

Good luck with your notes and drawings!