:::: MENU ::::
Posts tagged with: linux

Reading PHP serialized data quickly in a Linux Terminal

Here’s a quick script for reading a data file containing serialized data generated by PHP, and outputting it in a human readable format to a Linux command line interface. A short web search found no existing utilities for achieving this, so hopefully it will be useful.

You must use absolute paths (using tilde also expansion works, of course). Save this as a file called deserialize-php, make it executable, and move it into your /usr/bin folder to make it universally accessible.

#!/usr/bin/env php
// Enable error reporting
error_reporting(E_ALL | E_STRICT);
// Get command line arguments
$userArgs = $argv;
// Check that an argument was provided
if ( !isset( $userArgs[1] ) ) {
    echo "\nNo path submitted: a path to a serialized PHP data file is required'\n\n";
} elseif ( '/' == substr( $userArgs[1], 0, 1 ) ) {
    // The supplied path is absolute
    $serializedPath = $userArgs[1];
} else {
    // If the supplied path is relative
    echo "\nRelative path supplied but not supported, please provide an absolute path\n\n";
// Get the serialised data for processing
$serialized = file_get_contents( $serializedPath );
// Unserialize the data
$unserialized = unserialize( $serialized );
// Print the data array in readable form
print_r( $unserialized );

Then you should be able to use it like this:

$ unserialize-php serialized-data.php

VJ tools for GNU/Linux

Today I tried to install all the different Free Software VJ tools that I could find for GNU/Linux (VJ = video jockey, like DJing vith video). I was using my favorite distribution, Fedora, version 16, which I installed at the weekend on the laptop of a new friend of mine, Federica, who came to a Manchester Free Software meeting the week before. I tried:

I failed. I didn’t manage to install a single one. None of the four applications that I tried had packages for Fedora, or even .rpm files available for other distributions. Finding no easy way to install them, I undertook compiling them, with a beer in hand at a table at Kim By the Sea – a well loved bar next to my co-working office.

I failed. I followed the instructions for Veejay, but unfortunately they were outdated, not geared towards Fedora (just finding the names of the package dependecies took half an hour), and ultimately ended with a cul-de-sac of a compile error (“VEEJAY is unset”). After a couple more results like that, and after more than two hours, I gave up.

Although VJing is well represented in GNU/Linux by the number and apparent features of applications available, currently significant technical knowledge is required in order to actually get them working. Of course, most fashionable VJs are not UNIX experts, and so the attractive interfaces of the likes of FreeJ remain useful to only a tiny number of people.

This is where GNU/Linux packaging really falls down. Programs that are only important to one particular community that isn’t intrinsically technical often end up going unpackaged. It often takes years of an application being stable and widely used before it arrives in the repositories of mainstream distributions like Debian and Fedora. That means people wanting to try out cutting edge Free Software alternatives to proprietary apps first have to learn to cope with a less user friendly distribution. This presents a major barrier to getting new non-technical people into the fold, and makes the spread of FS applications for things like VJing very slow.

My experience today tells me that VJing on GNU/Linux has a great deal of potential, and has already attracted some movers and shakers, but currently is largely unavailable for anyone who isn’t a.) a distro hacker or b.) prepared to switch distros to whatever the developers of FreeJ etc. are using (often Ubuntu, unfortunately).

Dynebolic – a distribution specialising in support for performance arts software, may present an easier path to Free Software VJing. I shall first have to wipe the encrypted hard drive of Federica’s laptop however in order to repartition and make space for it. If that goes to plan then hopefully in January will have at least one Free Software VJer in Manchester!

Easy OCR on GNU/Linux with gImageReader

UPDATE: I can now confirm that gImageReader also works well on Windows.

Today I discovered gImageReader – really easy OCR software for GNU/Linux. It uses Tesseract as its back-end, and the interface is very intuitive, with straightforward instructions at the bottom of the window letting you know what to do next at each stage of the OCR process.

I haven’t tried complicated structures (like tables or indenting), but for uncomplicated blocks of printed text it worked perfectly, correctly identifying each word.

Tesseract has multiple international dictionaries available, and gImageReader allows you to choose which one to use before you scan. Tesseract is under active development, with the upcoming 3.0 release scheduled to include page layout analysis; automatic page orientation and script detection capability; special modes for single column, line, word and even character; and many more languages, including Chinese.

gImageReader isn’t in my repositories (Fedora 14), but packages are available as .deb and .rpm.