Using a Kindle as a monitoring tool (or not)

I had an old Kindle 3 lying around and really wanted to do something fun with the e-ink display in it, especially since its Linux underneath anyway.

If you browse around the web you'll find plenty of information to get you started with the prerequisite steps of rooting the device, enabling network and ssh. Since a lot of the information is hidden in forums (ugh), I'll point to Liraz Siri's tutorial which covers all important points.

Developing a kindlet

Unless you want to directly work on the framebuffer you will want to create a java application which the Kindle can run, called a kindlet. I strongly suggest you follow David Given's guide. Getting his Hello World to run consistently is a good starting point for everyone like me who only dabbles with Java. Additionally, the MobileRead wiki has additional information.

Since developing a kindlet without any resources from Amazon basically amounts to compiling, copying, opening and repeating that process it's essential to automate that process, thus I recommend ammending Given's excellent makekindlet script with the following  two lines (for OS X):

jarsigner -keystore $KEYSTORE -storepass password $JAR dn$USER

cp $JAR /Volumes/Kindle/documents/
diskutil eject /Volumes/Kindle 

Network communication in a Kindlet

To do anything useful in a Kindlet apparently requires one to have the ability to work with sockets, so the security settings need to be adjusted. A blog post by Alex Hutter explains how, i.e. add the following in external.policy:

grant signedBy "Kindlet" {
 permission "*:443-", "accept,connect,listen,resolve";
 permission "*:80-", "accept,connect,listen,resolve";

If you are stuck at such a point it's often helpful to visit the crash.log in developer/APPNAME/work to point you in the right direction of the problem.

Rendering content

Now, the rest should be easy, right? Well, rendering local images worked fine with this example snippet, however any permutation of loading network resources into images went exactly nowhere, getWidth() returns 0 and no image can be rendered and that's where I'm currently stuck and discontinuing this project.


The Kindle is NOT intended as a general use computing device. 

The quote above is from Hutter's blog post, I don't have much to add to that. This was a fun project but it became clear that without getting to know Java a lot better this would not be worth the effort, compared to solving the problem with an Android app, no matter how nice the display is.

Track when you lock your desktop

a stopwatch
Photo CC-BY by Jerry

If you do any sort of work where you have to report your activities in 15-minute increments, you have probably experienced that it is very easy to miss things, especially if you often have to deal with interruptions.

There are numerous solutions to parts of this problem such as apps which continuously poke you to update a tracker, to ones which simply log everything and sum it up. I use some of them but I also add another check to my routine to have more accurate timing information when I wasn't paying attention. What I'm doing is writing timestamps to a file which register screen locks/unlocks as well as suspend and it has in the past year helped me to significantly become more accurate in my tracking by having reference timestamps such as the following excerpt:

Thu Jan 23 09:53:48 CET 2014: SCREEN_UNLOCKED
Thu Jan 23 10:02:21 CET 2014: SCREEN_LOCKED
Thu Jan 23 10:18:16 CET 2014: SCREEN_UNLOCKED
Thu Jan 23 10:27:02 CET 2014: SCREEN_LOCKED

If you want to do this, too, just follow one of the examples below. If you want to do something similar and customize it, the problem is rather trivial if you break it down into a trigger and an action. The first is heavily dependent on your environment, the latter could be anything.


To react to events you'll have to run a command at login which then continuously monitors DBUS to see if the relevant event has fired. Here is a working example:

$ #!/bin/bash

function write_log {
  if [ -z $1 ]; then
  echo -e "$1\t$(date)" >> "/home/youruser/time.log"

write_log "LOGGED_IN"

# Monitor gnome for screen locking. Log these events.
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | \
    while true; do
      read X;
      if echo $X | grep "boolean true" &> /dev/null; then
        write_log "SCREEN_LOCKED"
      elif echo $X | grep "boolean false" &> /dev/null; then
        write_log "SCREEN_UNLOCKED"


The only decent trigger method I found (albeit after only 15 minutes of googling) is the paid app Scenario. The app itself should be self-explanatory and allows you to put one or several scripts into the respective folders for sleep, lock, log out, etc. Since I'm much more familiar with shell scripting than Applescript, I'm just using the later to call the former. Obviously, this could be simplified.

Applescript in Scenario:

do shell script "~/.bin/ unlock"

Shell script:


if [ $1 = "lock" ]
  echo -e "`date`: SCREEN_LOCKED" >> ~/time.log
elif [ "$1" = "unlock" ]
  echo -e "`date`: SCREEN_UNLOCKED" >> ~/time.log
  echo -e "`date`: UNKNOWN_ACTION" >> ~/time.log


Have a better way to do this? Let me know in the comments.

Running Drupal on a proper PHP version with IUS

I recently read Thijs Feryn post on the maturity of PHP and he makes a convincing argument for actually using what PHP provides with 5.5 now being stable.

Drupal 7 has seen many improvements over the past year in regards to 5.4 compatibility and as it turns out, it now runs pretty smoothly, though many modules still create E_NOTICEs due to legacy code. The breakage which 5.4 caused in many places when Drupal 7 (and let's not even talk about a 6 site) came out is not comparable with upgrading from 5.4 to 5.5, which is mostly harmless.

Managing PHP versions

You have basically two options for upgrading PHP on your server: find some pre-compiled packages or build from source. The latter should be avoided by nearly everyone, unless you're willing to diligently subscribe to a release mailing list and compile again and again.

On CentOS/RHEL, which is my preferred hosting platform at the moment one can rely on the excellent IUS repository. It makes switching between 5.3, 5.4 and 5.5 extremely easy. Once you have IUS installed, you can select your packages via the name php5Xu. Which means you can switch between 5.3 and 5.5 simply by removing the packages installed from php53u and installing again with php55u. All I needed afterwards to get PHP running again was copying the /etc/php-fpm.d/www. conf.rpmsave over www. conf and so 15 minutes later this blog is running on 5.5:

# yum list installed | grep php
php55u-cli.x86_64 5.5.5-2.ius.centos6 @ius
php55u-common.x86_64 5.5.5-2.ius.centos6 @ius
php55u-fpm.x86_64 5.5.5-2.ius.centos6 @ius
php55u-gd.x86_64 5.5.5-2.ius.centos6 @ius

An additional benefit is that IUS provides packages in sync with the latest released package. This is very helpful in determining what you are actually running. For example, your server might report that you are running 5.3.3 (as stock CentOS 6.4 does), even if critical fixes have been backported by RedHat, Fedora, et al from later versions, with IUS you'll get a proper 5.3.27.

Caveat: Of course, don't try this on production if you don't know what you're doing.

Sterling's Dark Euphoria

Photo CC BY/SA by Matt Biddulph

Bruce Sterling has struck again. At the Webstock '13 conference he gave a talk (as he is prone to do) in which he looked at the web and society in 2013 and produced a fascinating narrative around it.


The first important point I took away from his talk is how critically divergent the global online companies we depend on have become from traditional 20th century corporations as well as from the open web itself. He calls these vertically-integrated, global organizations stacks and identifies key factors in their difference to the web, such as a a proprietary operating system and a post-Internet, non-jailbrakeable stack-device (tablets, phones, e-books, et al) and much much more. How does he put it?

The Internet had users, stacks have livestock.

Interestingly, the stacks are highly unstable, he says, and he believes they shouldn't outlive the Arpanet in the long-run, proves it by cat, and you feel a kind of dark euphoria for what's to come.

In sum, just go watch his talk, I couldn't fit this into 140 characters.

Webstock '13: Bruce Sterling - What a feeling! from Webstock on Vimeo.

A commercial marketing database lets you peak inside

aboutthedata's categories
Screenshot of's categories, not covered under blog license.

There is an old entry in my backlog of ideas for the blog which went along the lines of try to get a copy of what data mining marketing firms have on file for you. Nothing ever came of that until I saw Ed Felten's post on one of those companies doing just that, with a spiffy site to boot, and I'm really surprised about this.

A quick primer

Most everyone knows that companies as a whole are tracking purchasing habits and customer preferences and correlating them with socio-demographic information to sell you more stuff. The who and what is much less widely know though.

Most often these collection companies are specialized businesses, which sell subscriptions to their databases, which they feed from multiple sources, especially in the U.S. private as well as public sources. At the time I jotted down a few notes on the topic ChoicePoint was one of them.

Most of these companies do not simply stop at providing information on marketing data to business and government (yes, the U.S. government is not prohibited from using private databases, even if they are not allowed to create those on citizens in the first place). They often have a close relationship to data based on or provided by credit scoring agencies, such as Altegrity, TransUnion or ISU; which are listed as direct competitors of ChoicePoint by Hoovers. The differences in their aggregate datasets are probably small, the impact of the result on individuals often not. ChoicePoint was later acquired by LexisNexis, which primarily focuses on publication databases,  and some divisions by Acxiom. It shows the further agglomeration of databases of different types within these data brokers.


If I had been asked a week ago, I would have concluded that such data brokers have no interest in providing a site such as It seems intuitive that such brokers would want to collect as much data as possible on their subjects without giving them reason to share less data with them. Ideally, to not be noticed at all.

This could be an initiative of Acxiom to improve the public perception of data mining firms such as themselves. It could be an attempt to preempt any negative coverage on data brokers due to the continuing public discourse on surveillance et al. Or it could just be an attempt to further improve their data.

Let's try it out

Since I did spent several years in the U.S. I figured that they should have at least something on me. I entered my personal data from my last residence and was surprised to find that in the categories shown above they had basically nothing, except for an inferred marital status and income bracket, which matched, but that would have been possible to extrapolate from the address and age itself I entered to register. Ed Felten was more successful but also apparently underwhelmed by the level of detail shown.

My speculations on why this is so fall into two basic groups:

1. They are only showing a minimal set

It's possible that Acxiom is only providing their basic result data and keeping any other further (and more creepy) analysis results to themselves and their clients, but since that's pure speculation I'm going to ignore this avenue for now.

Also, I have become in general skeptical of the predictive power of big data in shaping or determining customer behavior, which is in my opinion often at best on par with a trained sales representative.

2. I didn't provide enough data

Two of the primary categories provided by Acxiom are basically public databases with vehicle and house ownership, neither applied to me at the time. Also, I generally did not sign up to loyalty cards. It's possible and likely that Acxiom then either really does not have much more information on myself or that they are unable to merge incomplete datasets on my person into a consistent record.

The latter case highlights the main problem with  Basically, I can be pretty certain that I'm not seeing the full list of entries Acxiom has on me, simply due to the fact that a human operator would have to make a judgment call, whether a fragment refers to the same canonical person or not. They are unlikely to be able to manually merge a significant number of entries, which would mean that there are have to be significant numbers of entries in their database which they cannot bring together in this web application by algorithm alone. They cannot ask me "is this you as well" without accidentally disclosing data from someone else in many cases, they have to err on the side of caution, more so than is probably necessary for most of their customers.

Thus, I'm still left wondering what the site is supposed to accomplish. Calm me? Improve the paper spam selection? Not sure.

Bulk create searchable PDF from paper documents in Linux

For some documents you have to retain the original in dead tree storage format. For most documents which arrive in the mail, however, a digital copy is just fine and there really isn't any need to retain the paper version, especially if your computer can store millions of them in the space needed for one paper binder.

To archive such documents one could now buy a scanner, maybe even an ADF office appliance which spits out a searchable PDF and all that and let the device collect dust for the next few months until another batch is processed. However, you can also achieve nearly the same result with your phone and a Linux desktop.

Step 1: Capture

Firstly you will need to actually digitize your documents, you can of course use any scanner for this but a phone can be the perfect device to quickly capture dozens of documents, often vastly faster than with a flatbed scanner optimized for photos.

I personally am using the Scanbox to do this but any contraption which can hold your phone or digital camera steady such as a tripod mounted at similar distance to the document should do the trick. Speed is the important factor in my solution, not accurately capturing 6pt legalese in the footer.

Step 2: Format

After capturing you might need to rotate your photos first to get the page into portrait mode. Watch out though that the generic image preview in Gnome might rotate on-the-fly from EXIF data and not tell you. If you were to OCR those files, you would not get any text from it. You can check if your files still need to be rotated by opening them in GIMP, which will ask you if you want to rotate. You can bulk-rotate according to the camera setting with:

mogrify -auto-orient *.jpg

If your camera orientation did not match your document orientation, you'll have to convert by hand, the latter will do so 90 degress clockwise:

mogrify -rotate 90 *.jpg

Step 3: Process

Now you are ready to convert your images to PDF with text in them, basically, all you need to do is to call hocr2pdf and tesseract, the rest of the script below is only concerned with naming things and cleaning up. Thus the packages tesseract-ocr-eng, imagemagick and exactimage should be all that's needed on Debian-based systems, it worked flawlessly for myself with Ubuntu 13.04. Essentially, it's a cruder version of Konrad Voelkel's solution.

for f in *.jpg
  localname=$(basename "$f")
  tesseract $f $filename -l eng hocr
  hocr2pdf -i $filename.jpg -s -o $filename.pdf < $filename.html
  rm $filename.html
  # I wouldn't do this, but you could...
  # rm $filename.jpg


Et voilà, you have a searchable PDF which you can locate with the desktop search of your choice, for example Recoll.


Subscribe to Front page feed