Presentations with code that actually works

I don’t do presentations that often these days. And if I do, more often than not, they contain some form of source code. With most things you write, you refine it over and over. This is especially true with stuff that you present. Applied to code snippets, that can mean you test it initially, but once it is in the presentation it is a burden to copy it back and forth to verify every change, and then start over again with the formatting. So you often end up changing your code snippets in the presentation, without verifying if the code is still valid. Sometimes you find these errors during proof reading, but even famous presenters caught compile errors during the presentation. That’s how it works when you use the traditional PowerPoint style of products. As I expressed earlier, the Office suite and their opaque file formats doesn’t belong to my favourite tools.

Thus after I recently learned LaTex, I wondered if presentations could be done with it. Sure enough TexMaker offers a good set of templates for just that.

Next I wanted to see if I could link in code from external files, and sure enough, there is the listings package for LaTex. Now that enables me to have the code in files that I can actually compile.

But wouldn’t it be cool, if I could compile the code snippets for verification and generate a pdf file from the tex source all at one go? Sure enough there is a cmake UseLATEX package.

Now wouldn’t it be even cooler, if I could edit and generate all from within the same console window, without having to exit the editor, start the editor from a specific directory, or type complicated commands? Sure enough I found out how to write project specific .vimrc files. With everything prepared, I just have to type :make in vim to trigger the process, to get a new pdf file with all code snippets verifyed.

A small project to demonstrate the technique is at:

And you can find the resulting pdf file at:

Generating flight vouchers with LaTex

Learning LaTex was on my todo list for many years. Like most people of my generation, I learned wysiwyg text programs in school, and used them for a long time for most stuff that ended up on paper. Actually, to be exact, the first text processing program I learned in school didn’t fall into the wysiwyg category, but was DOS based. I think it’s name was “Farsight”, but I can’t find any information about it on the internet. Since I am no friend of proprietary lock-in systems, I switched from MS Word to OpenOffice a long time ago, and more recently to LibreOffice. But even though their file format is open, it’s still binary. I know, I know, Word and ODF offer textual formats. I think they are mostly XML based. But the last time, I looked at one of them, I could not believe how overloaded with useless trash they were. The most annoying limitation of binary formats, is when you want to store the documents in a version control system, and compare different revisions. I used html for a while for documentation purposes. Although it is very good for these textual diffs between revisions, I’m not artistic enough to make it good looking. Hence, I thought for a long time that LaTex would be worth learning.

Also, for a long time I wanted to automate the vouchers for our tandem flights at Even-though I knew that this was a perfect match, I had too many other things to do. As I’m currently reading a book about LaTex, I have my perfect hands on exercise. Hence, I prepared a template tex file for the vouchers and one for the invoices. Then I wrapped a python script around, that handles the rest.

The traditional way to keep track of which vouchers are active, and which ones were redeemed, is to keep a list. But after reading all the buzz about smart property, I figured that BitCoin is actually a perfect solution in itself. I generate a unique BitCoin address for each voucher, and load it with some coins. That way I can easily check, if the voucher is still valid. In fact, even other pilots that fly for us, can easily verify the validity of our vouchers. Now the perfect solution would be to load it with the full value, but since the BitCoin price is still quite volatile, the risk would be too high. After all, I need to be able to pay other pilots in case of a BitCoin crash. So I decided to load the voucher addresses with half the value. That way I can better tackle the risk.

As an opensource believer, I pushed my scripts to github, hoping they might be useful for somebody. I didn’t go to full lengths, in making it a configurable drop in solution. So, if you want to use it, leave me a message, and I will help you set it all up, and make it more configurable along the way.

Now, what happens if somebody orders a flight voucher on  After the customer fills in all the required fields, and presses submit, I receive an email with a html table containing all the information. I then save the mail with evolution to a folder as an mbox file. Next, I start the python script which performs the following:

  • Generates a new unique number for the voucher.
  • Parses the information from the mbox email file.
  • Generates a BitCoin address that contains the initials of the passenger.
  • Replaces the placeholders in the tex files with the actual information.
  • Generates a qr code with the relevant information, and a gpg signature thereof.
  • Generate pdf files for the voucher and invoice.
  • Add the new entry to the list of active vouchers.
  • Add the pdf files, the updated list as well as the encrypted private key for the BitCoin address to my private git repository.

The system is not finished yet, but it already looks like a big relief. In the future, it might also generate the email to send the pdf file back to the customer.