Category: linux

Preparing for the Collapse of Digital Civilization

While visiting the USA, I came across a delightfully bizzare TV show - Doomsday Preppers.

For those who don't know, this pseudo-documentary follows the lives of certain... eccentric... families who believe that the end of civilization is coming and they better get busy preparing for that eventuality.

Whereas you and I might keep a bit of spare cash hidden away, along with some out-of-date cans of food, these guys go the whole hog. Vast basements packed with food, gallons of oil to run generators, bomb-proofing their buildings, and training with guns. Lots of guns.

It's easy to laugh at these folk - their paranoia seems completely off the scale compared with the likelihood of the threat. And yet - I find them admirable. Come the apocalypse, I would likely last all of five minutes - whereas the "preppers" could survive indefinitely. They have the resources, the training, the experience, and the mental fortitude which comes from relentless preparation for the collapse of their world.

Which, naturally, brings me on to Google Reader.

Whither Google Reader

Last week, Google announced that it was killing off its popular Reader product. Howls of anguish from the loyal users of Reader - it was as if someone had announced the collapse of civilization.

As we come to rely more and more on the Internet, it's becoming clear that there is a real threat posed by tying oneself to a 3rd party service. The Internet is famously designed to route around failures caused by a nuclear strike - but it cannot defend against a service being withdrawn or a company going bankrupt.

It's tempting to say that multi-billion dollar companies like Apple and Google will never disappear - but a quick look at history shows Nokia, Enron, Amstrad, Sega, and many more which have fallen from great heights until they are mere shells and no longer offer the services which many people once relied on.

See, for example, this article from 2007 - Will MySpace Ever Lose Its Monopoly.

Even if the company survives - and there are remarkably few 100+ year old companies - we are at the mercy of third party services being shut down - witness Ping, Mobile Me, Buzz, Wave, Reader, etc. etc. ad mortem.

There are two questions that we need to ask when considering whether to adopt a new service.

Firstly - can I export my data? Secondly - is there an alternative which I control and therefore isn't at risk of collapse?

Export

I like to pose this question to my photography friends - "What would you do if Yahoo! suddenly decided to delete all your Flickr photos?"
Some of them have backups - most faint at the thought of all their work vanishing.

Luckily, services like Google, Facebook, Flickr and Twitter offer users a way to export their data. This is something you should do regularly - because you may not get much notice that a service is disappearing.

FormSpring recently announced that they were shutting down. They said:

Sunday, March 31st will be the last day you’ll be able to ask questions or post content on Formspring. You’ll be able to export your responses from now through Monday, April 15th, after which the site and apps will go offline, and any content will be permanently deleted.

That's a month to grab your stuff and go. Are you on a long vacation? In hospital? In prison? Otherwise without Internet access? Tough - your data is toast.

Avoid

Now we come to the "digital preppers" section. What can you do to ensure you never need to rely on anyone else?

Here's my rough guide to how you can self host many of your essential digital services.

RSS Reading

Before Google Reader, we had RSS readers running on our computers. We can now recreate the Google Reader experience by running Tiny Tiny RSS on your server.
TT-RSS screenshot
TT-RSS is a web app just like Google Reader - it fetches your feeds, lets you read them, share them, save them, etc. The only difference is that it runs on your server rather than Google's.

It's open source - so it will keep working even long after the original coders have left the project.

Run this on your server and never worry about the bottom dropping out of your world.

Photo Sharing

The Open Photo Project is the perfect resilient replacement for Flickr and other image sharing services. Indeed, you can export your photos, tags, and comments from most major platforms. You can host your photos - and a community - on you very own server.

openphoto web-home

OpenPhoto also has smartphone apps and is open source.

Mapping

Google offer Maps - for now. There are other mapping providers out there, but they are all at risk of companies going bust or deciding that they no longer want to provide a service.

Enter OpenStreetMap - think of it as Wikipedia for maps. A crowd sourced map - continually updated, with mobile apps, navigation, and beautiful imagery.
OSM
There are multiple providers who use OSM as their back end. If you are really paranoid, you can download the entire planet's map. A mere 27GB (compressed). Not an insignificant download - but manageable. Subsequent downloads are much smaller.

File Storage and Sharing

This is where we start moving off the beaten path and head into the wilderness.
One of the lovely things about DropBox is that they provide a very simple way to synchronise multiple computers - complete with a range of apps for mobile phones.
newrsynclogo
Rsync is exactly the same as DropBox - only a lot more complicated. You can use it to keep multiple computers in sync with each other. When files change on one machine, those changes are securely pushed to another machine.

There are limitations - few mobile clients, and no easy way to share files with others, for example.

What Else?

There are a huge range of services we use which are operated under the capricious whims of distant companies. This is by no means an exhaustive list of every option available to you. What services do you use which you would like to see decentralised?

Inkscape - cropping SVG files on the Command Line

A little post as an aide-mémoire.

I've found a lovely set of SVG playing cards. The only problem is each image is displayed within a page. This means the relatively small cards have an enormous white margin.

Within Inkscape (the vector image editor for Linux) it's possible to crop the margins by going to:

File > Document Properties > Resize Page To Content > Resize page to Drawing or Selection 

That's a pain in the arse for adjusting 52 images. Luckily, Inkscape will take command line arguments (called verbs). This means we can point it to all SVG files in a directory, instruct it to Fit to Drawing, and save the file again.

It all takes place on one line.

inkscape --verb=FitCanvasToDrawing --verb=FileSave --verb=FileClose *.svg

Run that, the Inkscape window will pop up for each file, and automatically close once saved. I'm not sure if there's a way to do it on a headless install.

Controlling Android Using A MakeyMakey

I recently got a MakeyMakey. It's a sort of ersatz USB keyboard that can be plugged into anything electrically conductive. I blogged about using it to control my Raspberry Pi using fruit and veg.

I also blogged about controlling Android using a USB keyboard and mouse via a USB OTG cable.

Hang on... the MakeyMakey is USB... Android can be controlled via USB... CAN I CONTROL MY ANDROID WITH FRUIT?!?!?!?

Why yes! Yes I can. Watch and learn, young grasshopper.

I couldn't find any games which said they could be controlled by a USB keyboard. Luckily, the mouse click on Android is interpreted as a tap on the screen - so any single tap games work well. I used the delightful Whale Trail, but other endless running games like the popular Canabalt also work well.

If you know of any Android games which can be controlled with just the arrow keys and spacebar - please let me know in the comments. I'd love to build a banana joystick!

3G Internet on Raspberry Pi - Success!

This is a bit of a brain dump of how I got a 3G USB dongle working on the Raspberry Pi. Following on from getting the Raspberry Pi to send SMS.

That's The Power Of Love

The first thing to say is use a powered USB hub! I had lots of problems getting the modem working when it was plugged directly into the Pi. A 3G signal takes more power than the Pi's USB sockets can supply.

3G Raspberry Pi

In the above image, you can see that the Raspbery Pi is plugged into the mains - via a 1.8A plug.
The USB cable has two male ends. The black plug goes directly into the Pi for data. The red plug goes into the mains via a 1A plug (an Amazon Kindle adapter).

I used a USB Y Cable to supply power and data.

I also tried plugging both plugs into the Pi - that didn't work either. You need a separate powered hub.

Rather than use two plugs, I'm going to try to find a mains plug with two USB sockets. Each socket needs to supply at least 1A. Something like this looks like it should do the trick.

Or, you can use a cable like this.

Put one male USB plug into the PI and the other into a power supply. The dongle fits into the female USB socket.

P-p-p-p-pick Up A PPPD

In order to get our network connected, we need to install the ppp package.

sudo apt-get install ppp

If You Think I'm Sakis, And You Want My Body...

I tried using wvdial and numerous other ways to connect to 3G. None of them worked reliably. In the end, I turned to sakis - the All-In-One script for connecting 3G modem.

Sakis says it is:

"The easiest way to have your 3G/UMTS/GRPS connection up and running."

I can't argue with that!

Installation is very simple:

First, download the latest version. The Raspberry Pi runs on an ARM processor, so this is the version we download.

wget "http://www.sakis3g.org/versions/latest/armv4t/sakis3g.gz"

The script is compressed. Unzip it.

gunzip sakis3g.gz

Finally, we want to make the file executable so that we can run it.

chmod +x sakis3g

Running sakis is quite straightforward. It has a basic GUI which will work even if you're just using the command line.

sudo ./sakis3g --interactive

sakis3g interface

Sakis has a fairly comprehensive list of connection details - it should find yours automatically and present you with this screen.
sakis3g interface APN

If it doesn't know your connection settings (if you're on GiffGaff for example) you can manually enter them.

All being well, after a few seconds, you should see this screen.
sakis3g interface connected

You can now exit sakis. You will stay connected.

To check the details of your connection, run the following command:

sudo ./sakis3g connect info

You'll get back something like this:

K3565 connected to giffgaff (23410).
Connection Information
 
Interface: P-t-P (ppp0)
 
Connected since: 2012-07-13 07:36
Kilobytes received: 2
Kilobytes sent: 2

Network ID: 23410
Operator name: giffgaff
APN: giffgaff.com
 
Modem: K3565
Modem type: USB
Kernel driver: option
Device: /dev/ttyUSB0
 
IP Address: 10.136.6.52
Subnet Mask: 255.255.255.255
Peer IP Address: 10.64.64.64
Default route(s): 10.64.64.64

That's it! You can now access the Internet via your 3G modem.

Surfin' Safari

One last tip for you! There's no need to start your window manager to surf the web. There's a brilliant lo-fi web browser called Lynx.

You install it by typing:

sudo apt-get install lynx

You run it by typing:

lynx http://www.bbc.co.uk/news

(or whatever website you want to visit).
lynx on the Raspberry Pi

So, that should be everything you need to get the Raspberry Pi connected over a USB 3G dongle. Have fun!

Authentec Fingerprint Scanners - Full Specifications (AES2810 & AES2550)

Last year, I wrote about how Authentec wouldn't support their fingerprint readers on Linux. I've been chatting to the good folk at Authentec, and they've agreed to release the specification documents!

So if you want to code up an interface for the AES2810 or AES2550 you can!

A word of note, the best way to get the latest version of these documents is to register for the Authentec Developer Program. You then need to drop the team a note asking to get access to these specific documents - devportal AT authentec.com

That way you will get informed when there is a new release of other sensor's specs or updates.

So, here are the documents :-)

NB, I specifically asked the development team about sharing these files. They said:

Since we have released the documents without requiring any NDA or other such agreement signing we can't prevent you from sharing them.