Ubuntu and the X220T Touch Screen

I have a thinkpad laptop with a touchscreen and a swivel so it can fold up and pretend to be an oversized tablet. I like it a lot, but the touch screen interface hasn’t been all that useful since I normally use this machine docked and then it maps the whole of one screen as a touch interface across my multiple monitors as a desktop space!

I recently sorted this out, so I thought I’d share the scripts that worked for me on Saucy Salamander Ubuntu 13.10 with Unity.

First, work out which device you actually want:


$ xsetwacom --list
Wacom Bamboo stylus id: 11 type: STYLUS
Wacom ISDv4 E6 Pen stylus id: 13 type: STYLUS
Wacom ISDv4 E6 Finger touch id: 14 type: TOUCH
Wacom Bamboo eraser id: 19 type: ERASER
Wacom Bamboo cursor id: 20 type: CURSOR
Wacom Bamboo pad id: 21 type: PAD
Wacom ISDv4 E6 Pen eraser id: 22 type: ERASER

Then, use xsetwacom to get the right touch input relating to the correct screen, even with multiple monitors:


$ xsetwacom set "Wacom ISDv4 E6 Finger touch" MapToOutput LVDS1

At this point I should point out that my touch screen is incorrectly configured and therefore needs the script above running every time I plug or unplug an external display. Since I dock my machine, move it almost daily, and regularly present … that’s kinda irritating. Any solutions on improving that are welcome.

Splitting And Combining Odd/Even Pages With Pdftk

I’m working on a fun printable project at the moment, but part way through I realised I would need to process odd and even pages of the document separately. So separately, that I split the doc into two separate ones, with odd pages in one and event pages in another – and then had to recombine them. Here’s the commands that I used, with an excellent tool called pdftk. Continue reading

Upcoming Git Courses

Three git courses are coming up in the next few weeks, and a few people have asked me which courses I’m running, so here’s a quick roundup (feel free to drop me a line if you need any more detail):

  • Dublin, 30th January: Git and GitHub Foundations
  • Dublin, 31st January: Git and GitHub Advanced
  • London, 6th February: Git for Teams

I have fantastic partners for these events: the Dublin ones are with Github and the London ones with FLOSSUK, and I look forward to both. Right now they all do still have places remaining, visit my courses page for the links you need to book. Training days are a great opportunity to boost your skills and discuss specific aspects of technology that you can’t really get from a textbook – hope to see you at one of these sessions, I am standing by for difficult questions :)

Git, Vimdiff, and Merge-Base

git merge-base is this week’s favourite git command. I use it to show me in a vimdiff everything that has changed on a particular branch since it was created. This took a little bit of looking around to find how to combine the tools, so I thought I’d write it all down in one place. Continue reading

Hiding Sections With Rst2pdf

I’ve been using rst2pdf for slides for a year or so, but recently I’ve been converted to using it for everything from documents to emailed reports to handouts. Along the way there were a couple of cases where I wanted to create two similar documents, but one needed to omit some details. A great example is my ZCE questions pack, which when updated to PHP 5.5 I converted to restructuredText. By showing/hiding different sections of the document when I generate the PDF, I can maintain the questions and their answers side-by-side, then create the documents containing questions and answers separately. You could do the same with adding a notes field to slides that are hidden when presenting, but available for handouts. Continue reading

Printing Many PDFs Per Page

Much of my work revolves around documents or slides, and I use PDF format for pretty much everything I do. In the last year or so I’ve developed a love affair with rst2pdf which means I’m doing more PDF now than ever.

This weekend I was working on a project which needed a programatically-generated PDF file to be many-slides-per-page – and for this I adopted a tool I haven’t used before: pdfjam (installed straight from apt on Ubuntu).

In fact it was pretty easy to get going with it: to print my existing PDFs at 4-per-page, I used this command:

pdfjam --landscape --nup 2x2 --a4paper -q slides.pdf -o handout.pdf

The slides themselves were already landscape so I specified the target document should also be landscape. The --nup 2x2 is the magic that prints many slides per page, and it seems like it can do various nice tricks with handouts. Running through the other arguments that I used: --a4paper for the paper size, -q to stop it from chattering (which it does by default, even when everything worked), slides.pdf was my input file and -o handout.pdf the target file to put the new layout into.

Until now I’ve mostly worked with pdftk for everything, but I couldn’t find a way to do this using it. Pdfjam is now a welcome addition to my PDF toolchain, so I thought I’d share.

DimpleJs Bubble/Scatterplots and Joind.in Data

DimpleJs is a wrapper for d3, the javascript charting library, which makes beautiful charts but is way more complicated than I want to cope with, so I was looking for a helper toolkit. I’ve been using dimplejs lately and wanted to write down what I did while I can remember, but I didn’t think my clients would thank me for publishing their data! Instead, I made some graphs using Joind.in‘s data, just pulling what I needed over the API and producing something like this:



Continue reading

Open a GitHub Pull Request with Hub

Both in my professional life and in my personal life as an open source project lead, I spend a lot of time working with git in general, and GitHub in particular. GitHub publishes a command line tool called hub, which is a more convenient way than the website for doing a few specific tasks and in particular I’ve been using it more and more for opening pull requests. Continue reading

Doing Google Custom Search via API

I’m working on a project that uses a search engine to show images on a particular topic … but I need my search to be localised since I’m in the UK and so “football” doesn’t mean what a generic search engine thinks it means. Getting this working was MUCH harder than I expected, so here’s a quick post on what I did so that I can remember for next time – and if this helps you as well, then great :)

Google Custom Search Engine

It’s possible to set up and configure a custom search engine in Google, so you can configure some settings and the search will always use those settings. To begin, go to http://www.google.com/cse. Here you can create a search engine, give it a name and description, and then set some options. You can choose whether to search for images, or not, or images only. You can include or exclude certain sites, or search everywhere and just prefer certain sites. Continue reading

Git Add Interactive

In common with most development projects these days, I’m using git more and more. It’s interesting though that the way that I use this tool just keeps on changing and evolving even after about 4 years of regular use. Today I thought I’d share a new habit that I’ve developed: using git’s ability to stage changes interactively. Continue reading