Blog

email2pdf - "Automatic" Conversion of Emails to PDFs

Like many folks, I am increasingly trying to go paperless, and am basing this strategy around the PDF format. I already have some good workflows set up with my network scanner to scan documents to PDF, which get automatically transferred to the desktop of my Mac for myself to file using rsync.

However, I also get a lot of emails which I’d like to capture in PDF format. Currently, for each one, I have to go into my email program, and ‘print them out’ using a PDF printer. It’s not too difficult, but it can still be a hassle when there are several to process.

What I’ve done, therefore, is begun to build a different workflow, centred around a separate email address I’ve set up on my domain. The idea is that I forward emails there that I wished to PDF-ized, and they are periodically retrieved by getmail (which I have running from a cronjob on an Ubuntu machine I have). I’ve then written another utility, which I am calling email2pdf, which acts as an MDA to “deliver” the mail into PDF format.

So far it can process basic text and HTML email (the latter using wkhtmltopdf), or can retrieve a single individual PDF document that’s attached. I’ve got a list of enhancements and other issues that I’d love to work on when I have time.

You are welcome to use or modify email2pdf (it’s MIT-licensed); I would welcome any pull requests for improvement.

Getting Logitech Presenter R800 Working with Keynote on Mac

Recently I attempted to get my Logitech Presenter R800 working with Keynote on my Mac. I swiftly discovered that although it works with PowerPoint for Mac out-of-the-box, in Keynote the ‘start/stop presentation’ and ‘blank presentation screen’ keys didn’t work.

After a bit of investigation, I found the solution, which was to use KeyRemap4MacBook. The presenter tool behaves like a USB keyboard, and uses  for blank screen, and F5 for show/hide presentation. I installed KeyRemap4MacBook, and installed a private.xml based on the one on this page for a slightly different presentation tool. I’ve uploaded the one I used to github. Tip: Don’t forget to read the KeyRemap4MacBook manual. You need to explicitly reload the private.xml once it’s in place (you’ll also need to rename it to that name when you download from github), as well as tick the ‘R800 for Keynote’ checkbox on the Change Key tab in the KeyRemap4MacBook settings.

Fixing initrd to Regain Ubuntu Encrypted Root Prompt on Boot

Recently, I upgraded my Ubuntu 12.04 server, which uses an encrypted root directory (with LVM and LUKS). Unfortunately, somewhere along the way the upgrade broke the boot process - next time I booted, it hung for 5 seconds, then timed out and dropped to a BusyBox prompt. I quickly found a workaround which allowed me to manually intervene and continue the boot each time:

cryptsetup luksOpen /dev/sda5 root
exit

Of course, however, I didn’t want to intervene on every boot, especially since this is normally a headless server. To fix it longterm, I eventually found this link, which hinted at the problem. Essentially, I had to locate the mapper name for the partition containing my LVM physical volume which contained the boot logical volume. I found this in /etc/crypttab, and in my case it was flash_crypt:

flash_crypt UUID=xxxxx none luks
...

So I rebooted, and used the workaround above with the correct name:

cryptsetup luksOpen /dev/sda5 flash_crypt
exit

Once I’d booted the system, I regenerated the initrd image:

update-initramfs -u -k all

I knew it worked successfully, because I didn’t see this error, which I had seen before when running update-initramfs:

cryptsetup: WARNING: invalid line in /etc/crypttab -

Rebooting the system, everything now went back to normal.

Correcting iPhone photo filenames

Sometimes, when uploading photos from my iPhone’s camera roll (for example, when using Dropbox), the photo filename format ends up looking like this:

Photo 16-03-2012 21 21 10.jpg

This isn’t very nice. Much better to have something in ISO-8601 format, which sorts nicely in file listings, and so on. So I wrote a quick bash script to search for all the files in the current directory (and subdirectories), and rename them to this style:

Photo-2012-03-16-21-21-10.jpg

You can find it on github.

Please note that the script renames files immediately, with no confirmation. It depends on Perl’s rename under the covers, and if you pass in the -n flag, it does a dry run so it shows you the renames that would be done, but doesn’t actually do them.

(It also handles video files with similar names).

Compiling FlightGear 2.4.0 for Ubuntu Linux 10.04 (Lucid)

Update 2011-08-26: If you are using Ubuntu 11.04 or later, it looks like this is now packaged as a .deb by PlayDeb. This post may still be of interest to those using earlier versions of Ubuntu.

I recently had cause to install FlightGear 2.4.0 on Ubuntu 10.04. It’s not packaged in the form of a deb yet, so I’ve documented the commands I used. No guarantees this’ll work for you, as I haven’t tested them rigorously; and I’m assuming some Linux and command-line knowledge.

  • Install some dependencies (this may not be a complete list; it’s simply the set I was missing). If you get warnings below about missing libraries, hunt around for them in the Ubuntu archives.
sudo apt-get install libboost-graph-dev libopenal-dev libalut-dev libopenscenegraph-dev libjpeg62-dev libplib-dev zlib1g-dev
  • Get SimGear 2.4.0, unpack it into a temporary directory, and install it (checkinstall will create a deb for you as a side-effect, and install that so you can uninstall with apt if necessary). I’m using -j10on make as I have many CPU cores; you may want to tune this to match your number, although it will only affect the speed of build.
./configure --with-jpeg-factory ; make -j10 ; sudo checkinstall
./configure ; make -j10 ; sudo checkinstall
  • Get the 2.4.0 “Base” package and unpack it to /usr/share/local/flightgear. The tarball contains a data/ directory at the top level; you need to move directories around after unpacking so that the flightgear/directory contains direct subdirectories:
ls -1 /usr/local/share/flightgear/
AI
Aircraft
Airports
Astro
ATC
AUTHORS
etc...
  • You’re done! Run fgfs to launch Flightgear (there’s no GUI so you’ll have to become familiar with the command-line switches).
subscribe via RSS