Open Source Photoblog Workflow with phpGraphy

As I am lucky enough to be able to travel a bit in the near future, I thought of blogging a few pictures en route. I wanted to do this from my Androidphone (2.3) without the hassle of logging in some software or website, let alone to use some BS like Instagram. I’ll try to explain in all briefness.

The main idea behind this is to have some sort of sync-mechanism between the phone and the blog which automatically renders directories and pictures as HTML. I choose phpGraphy as my main tool. It supports a flat file database and renders any content in its /pictures/ folder based on date of creation.

Since I had some concerns to put the password for my main webspace into the hands of some random Android-app I created a uberspace for my pictures. If you’re in or near Germany I highly recommend these guys – great support, incredible features, almost anonymous. The next was to get BotSync on my phone which enables uploads via SSH. You just specify directory on your phone to be uploaded and the destination on the server – a very slim & fast app. So, I can take a picture, organize it via some file management app and upload it to my picture-uberspace.

To get it on my main webspace I used rsync with SSH. You can find plenty of tutorials on the net regarding this.

rsync -avze 'ssh -i /home/user/.ssh/id' /home/user/html/phpgraphy/pictures

Since phpGraphy sometimes messes up the thumbnail creation with the original pics of my phone’s camera, I run mogrify to resize them. Because I want to resize every picture in any directory the ‘find’ will look for any file with a jpeg-extension; the mogrify will set any side of the pic to 1400px which is more than enough.

find /home/user/html/phpgraphy/pictures/ -name "*.jpg" -exec mogrify -resize '1400x1400>' {} \;

Of course, these tasks need to be automated. Cron will take over and run these two commands every morning at six o’clock.

crontab -e
0 6 * * * /home/user/

phpGraphy supports furthermore a cool feature concerning the naming convention. You can set it up to use a EXIF field for the image’s name. A few apps like Photo Editor allow to edit the EXIF metadata on Android. So I edit the User Comment EXIF field and tell phpGraphy to use this field as title. Works!

The workflow:

Take picture --> (Edit EXIF data) --> Put into upload directory on phone --> run BotSync --> done.

The good thing is I can change this workflow really easy. I can log on my picture-uberspace from any computer without worrying about giving away important credentials and just put some pics in the upload-folder. Then, my main uberspace will fetch the pictures via rsync and puts them in phpgraphy/pictures.

Of course, one could say: just use some service other than Instagram if you don’t like it. But this way I can control my data w/o worry about some TOS, pricing plans or whatnot. And it’s more fun to use something you set up.

Crunchbang Keyboard Layout

I looked for a simple way to change my keyboard layout on crunchbang linux (Waldorf) and found a post by Bogdan Costea and a thread in the FreeBSD forums. Following their information I did this:

sudo gedit /etc/default/keyboard

Besides XKBLAYOUT you add the desired languages (do ls -la /usr/share/X11/xkb/symbols/ for list of available languages). And XKBOPTIONS sets the keyboard shortcut. The FreeBSD-thread lists these possible shortcuts:

grp:toggle – Right Alt
grp:shift_toggle – Two Shift
grp:ctrl_shift_toggle – Ctrl+Shift
grp:alt_shift_toggle – Alt+Shift
grp:ctrl_alt_toggle – Ctrl+Alt
grp:caps_toggle – CapsLock
grp:lwin_toggle – Left "Win"
grp:rwin_toggle – Right "Win"
grp:menu_toggle – Button "Menu"

So my keyboard file looks currently like this:


Bogdan suggests using the small program fbxkb to visualize the current layout. Just add the following to ~/.config/openbox/autostart:

## Run indicator for keyboard layout
fbxkb &

This will show little language indicating png-graphics in the taskbar which look like text. To replace them with actual flags go to /usr/share/fbxkb/images and overwrite the png-files (need to be superuser). One convenient way are the famfamfam flags which use the same naming convention. Just overwrite everything inside the fbxkb-folder.

Note: this still looks somehow crappy since fam³ flags are in 16×16 px and fbxkb displays in 24×24 px – but good enough for me.

And btw: if you are looking to do a ç (cedille) or other special characters without big hassle check out the German Ubuntu wiki. To enter the french ligatures like ɶ or Æ press and hold Ctrl + Shift + u and enter the hexdecimal unicode – see selfhtml or shapecatcher for info on the codes.

Set GPS update rate on Arduino Uno + Adafruit Ultimate GPS Logger Shield

Just in case someone wants to alter the GPS update rate on a Adafruit Ultimate GPS Logger Shield. This may come in handy if you want to reduce the power consumption of your board. According to a datasheet of the GPS-chip the max update rate is 10000ms/10sec. So how do you set it?

Relatively simple: go to your Adafruit_GPS-library, open Adafruit_GPS.h and look for these lines:

#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"

So this will define the name of the method/function/whatever which will be called in your Arduino-sketch, e.g. PMTK_SET_NMEA_UPDATE_1HZ. PMTK220 is the chip-internal code for update rate. So we say: Hey, I want to alter the update rate. The value after the comma is the update rate in milliseconds. We set it to 10000 (or whatever you like). The value behind the * is the checksum which the chip requires. Thanks to Stevens post about reading GPS data with bash I stumpled upon the MTK NMEA checksum calculator. So you put in PMTK220,10000 and get back $PMTK220,10000*2F. That’s it. Our new line would read:

#define PMTK_SET_NMEA_UPDATE_10SEC "$PMTK220,10000*2F"

Just set PMTK_SET_NMEA_UPDATE_10SEC in your sketch and upload it.

PirateBox – some tipps

PirateBox is, without a doubt, a great project. Nevertheless there are some things to consider and also some things to improve. I’ll just make a short list of what I learnt. You are warmly invited to comment. I used the OpenWrt-version of Piratebox.

1) This might be obvious but I never conceived the notion of it until I worked with PirateBox and the TP-Link MR3020-Router: you’re just dealing with linux. After SSH-ing into the router just be free to explore and play around. cd and ls the hell outta this thing.

2) Simplest mode of operating the box is either via wall socket or a battery. Note there are premade affordable 12V to 5V USB-converters available. Just search for ‘12v 5v usb‘ on ebay or somewhere else. 12V (car) batteries are available in your local electronics store (maybe even the converter). A 7000 mAh battery should give you about a day of operating off-grid. This will vary of course due to wireless usage, router type and battery quality.

3) Tech and ‘open something’ people like the word ‘pirate’ – it’s freedom, it’s controlling your destingy, taking what’s yours, operating outside of incrusted structures. For other people it may be – at best – adventure tales and the pirate party (which has a arguable reputation) or – worse – illegal activity, stealing, hacking and so on. So, I decided to alter the SSID of my PirateBox. I called it Open Library – Share freely (instead of PirateBox – Share freely). To do this SSH into the router and follow these instructions. To mirror this information:

Edit the wireless file on the router by

vi /etc/config/wireless (vi cheatsheet)

Look for the SSID option and alter the string (allowed chars), save it and type

/etc/init.d/network reload

You should now be able to use your new SSID. I’d always choose something welcoming; ‘NSA-surveillance van’ maybe not a good idea. 😉

4) Furthermore, I altered the landing page of PirateBox. For two reasons; first, the PirateBox logo without explanation may be intimidating for some people. Second, not everyone is able to read English on a level which is sufficient to be comfortable in this new context. So I changed to PirateBox logo to a pictogram I found on the PLA blog (Number 42). Less intimidating while preserving the notion of sharing.

To change the logo as well as the text on the landing page you cd to

ls -a (shows all (hidden) contents in the folder)

You’ll find index.html (landing page), piratebox-logo-small.png (the logo on the landing page) and .READ.ME.htm (the about page). Code snippets for German ‘customisation’ are below this post. The big logo on the about page stayed the same, since I wanted to give credit to the project.

But how do you get this stuff on your computer to edit it? scp will help you. The article on scp explains it quite well, but just for the record:

scp source target (the general idea behind scp)

scp /opt/piratebox/www/index.html user@yourhost:/home/user/ (this will copy index.html into your home directory; of course, if you’re already in the directory, just put the filename as source; you’ll need the password for ‘user’ on your local machine)

scp user@yourhost:/home/user/index.html /opt/piratebox/www/ (and copy the file back to the router; overwrites without warning!)

Of course, you can edit all the files on the router with vi but it’s more comfortable this way, I guess. So, edit the files the way you want – all you need is a bit HTML knowledge. I started with a little disclaimer that nobody is trying to hack the users computer or will try to do something illegal. But I think the localisation is the important part; make PirateBox accessible by using your local language. (Though, I’d leave the english version as it is to honour the work of David and to be accessible for international folks.)

Well, that’s it. Have fun with shared information on PirateBox and leave a comment. 🙂



<div><img src="/lib.jpg"/></div>
<div id="message">
<b>1.</b> Was ist das hier alles? <a href="/.READ.ME.htm" target="_parent"><b>Antworten hier</b></a>.<p>
<b>2.</b> Lade etwas hoch. :) Einfach unten Datei auswaehlen und los geht's.</p>
<b>3.</b> Anschauen und Runterladen des Vorhandenen kannst du <a href="/Shared" target="_parent"><b>hier</b></a>.<br>


<table border=0 width=50% cellpadding=0 cellspacing=0 align=center>
  <td width="75"><br></td>
  <td><p>Erstmal: keine Angst - niemand hat vor dich zu hacken oder illegalem Treiben zu verleiten. :)</p>
  <p>PirateBox entstand aus den Ideen des Piratenradios und 'free culture movements' - Artikel darueber findest du auf Wikipedia. Ziel ist dabei ein Geraet zu erschaffen, welches autonom und mobil eingesetzt werden kann. Dabei setzt PirateBox auf freie Software (FLOSS) um ein lokales, anonymes Netzwerk zum Teilen von Bildern, Videos, Dokumenten, Musik usw. bereit zu stellen.</p>
<p>PirateBox ist dafuer gemacht sicher und einfach zu funktionieren: keine Zugangsdaten, keine Mitschnitte wer wann auf was zugegriffen hat. PirateBox ist nicht mit dem Internet verbunden, sodass niemand (Nein, nicht mal die NSA) mitbekommt was hier geschieht.</p>
<p>PirateBox wurde von David Darts erschaffen und steht unter einer Free Art License (2011). Mehr ueber das Projekt und wie Du dir einfach eine eigene PirateBox bauen kannst, findest du hier:</p>
<p>Mit der Partei hat dies hier uebrigens nichts zu tun. ;)</p>
<hr />
  <td width="25"><br></td>