Munin plugin: Copenhagen gasoline prices

Introduction

It is no secret that I am very fond of Munin and since I recently bought a car I wanted to know cheapest gasoline price. I chose to write a munin-plugin to find the optimal time on the day to buy gasoline. Luckily the Danish organization called FDM (United Danish Automobile owners) maintain a user/operator updated list of gasoline prices from all the gas stations in Copenhagen (or any other area of Denmark). These prices are the actual prices at the gas stations and are thus more accurate than the list-prices maintained by the operators themselves. The list can be seen here:
http://www.fdmbenzinpriser.dk/searchprices/2/K%C3%B8benhavn

Update
I have updated the article with a plot of the mean prices per vendor to see if there were some vendors that would be consistently more or less expensive.

Munin plugin

Munin is the perfect platform to sample these prices and show the time trends, so I wrote a simple python based plugin that scrapes the page for prices and calculates the min, max and mean prices.

gasoline_blyfri95_2_py-week
Continue reading Munin plugin: Copenhagen gasoline prices

Compressing PDFs using Ghostscript under Linux

Introduction
I had to email a PDF with several high-resolution images embedded. The original file size was 7.31 MB and this was unnecessary large for a single page PDF. I did not need the very high-resolution of the pictures, but only that the PDF would look good on-screen and in print on a normal inkjet printer.

The magic of Ghostscript
Googling the terms “compressing pdf” revealed several online options for uploading and compressing PDFs, but since I was sitting in front of a Linux computer and didn’t really trust any of these unknown providers I ended up using Ghostscript instead. The following command compressed my PDF from 7.31MB to 674KB in about a second:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

From the Ghostscript manual it can be seen that there are several qualities to choose from:

  • /screen – selects low-resolution output similar to the Acrobat Distiller “Screen Optimized” setting.
  • /ebook – selects medium-resolution output similar to the Acrobat Distiller “eBook” setting.
  • /printer – selects output similar to the Acrobat Distiller “Print Optimized” setting.
  • /prepress – selects output similar to Acrobat Distiller “Prepress Optimized” setting.
  • /default – selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.

Continue reading Compressing PDFs using Ghostscript under Linux