Uncategorized

Airplay with Raspberry Pi

I bought a Raspberry Pi this week. For those who don’t know this is a tiny ARM-based computer, the size of a credit card, which is supplied as a board without case, power supply or mass storage, for £30 (delivered). It’s been in the media and is being described as a universally affordable spiritual successor to the popular 1980s BBC Micro, as it has been designed with the purpose of teaching school kids how to program computers in mind.

It ships with 256Mb of RAM, an SD card slot, two USB ports, an ethernet port and an HDMI port. It’s powered via micro-USB and so will work with any micro-USB cable (and therefore many phone chargers). You then have to add a SD card for mass storage, onto which the operating system is installed. You then also need to connect it to an HDMI display and plug in a USB keyboard. You can easily spend as much as the original purchase price again on accessories, but that still doesn’t make it expensive.

Raspberry Pi running RISC OS 5

The primary intention of its manufacturers is for it to run a special Linux distribution called Raspbian, which is based on Debian, but it is by no means limited to this. In theory it can run anything that’s compiled for the ARM architecture, although in practise this is different. Already a group is working on a port of Android, an obvious choice, since this operating system is designed for ARM-based smartphones and tablets. Someone has even made a RISC OS 5 distribution available (RISC OS 5 is the older fork of RISC OS which was open-sourced, RISC OS 6 remains a commercial product and is not available in the same way). This gave me a few hours of delightful nostalgia as I lived and breathed RISC OS for 5 years back in the early 1990s. I’m hoping I’m going to be able to use it to recover some of my old files and convert them to PDF.

But this isn’t the real reason why I’ve bought my Raspberry Pi. Nor have I bought it, as many will, just to dick about with it. Unlike some others I don’t have any grand delusions that it will replace either my desktop computer or my home server, because it’s frankly not up to either task. Its low cost and the fact that you can run it off a USB port means that it’s actually rather slow, but that’s fine, it’s not designed as nor was it ever meant to be a fast computer. But it is small, cheap and perfect for what I want to use it for.

Alternative Airplay device

Airplay is the system through which Apple devices can play music through remote speakers connected to devices on the local network. These can be Apple TVs or an Airport Express. The Apple TV represents great value at £99, but the Airport Express is less so at £80, which is an increase on the previous price since they brought out the new model. Most people already have a wireless network and so £80 just to connect your stereo to your network is a little steep if you don’t need the wireless features of an Airport Express.

Here’s how the budget stacks up: Raspberry Pi is £29.95 delivered from Farnell. On top of that you’ll need an SD card (£3.38 delivered from Play.com), a case (various options on eBay, I found one for £4.23 delivered), and if you don’t have a spare already then a micro-USB charge (£2.40 delivered from Play.com). This all comes to £40.00 delivered, exactly half the cost of an Airport Express.

You will also need an audio cable and an ethernet cable but I’m not including these in the budget since neither is not included with an Airport Express. What I would point out, however, is that the Raspberry Pi solution is not a wireless solution without the addition of a USB wireless dongle, themselves no more than a fiver from eBay.

Instructions

  1. Install Raspbian. You can do this using one of the pre-built images if you want, but if you’re capable I recommend that you install it using the network installer so you can control what goes on and it uses as little space as possible (you will however find this method much slower). You’ll need at least a 2Gb SD card for either method. I tried to shoehorn an install on a 1Gb card by removing the swap partition, but it didn’t boot. You need only the default options if using the network installer, no extras required.
  2. I recommend that you update the firmware and the operating system (using aptitude) at this point. There have been some recent improvements to the firmware which bring performance increases and better wireless support.
  3. Log in as root and run the following commands:

  1. Add these lines to /etc/rc.local. The second line forces the audio through the 3.5mm jack rather than the HDMI port. If for some reason you require the latter then omit the second line.
modprobe snd_bcm2835
amixer cset numid=3 1
  1. Change this line in /etc/init.d/shairport, starting DAEMON_ARGS, so that it reads the following (you can change “Raspberry-Pi” to a string of your choice):
DAEMON_ARGS="-w $PIDFILE -a Raspberry-Pi"

Reboot, and you should now see a new entry in your Airplay menu on your device. At this point my SD card was using 783Mb on its root partition. I’ve made an image of this with a view to making it available for download, but even compressed it came out at 658Mb and I pay for my bandwidth by the Gb, so I won’t be uploading it, not when the instructions are so easy.

I would note that if you are geeky enough to achieve this then think twice before building them for your friends in order to save them a few quid. If you build and supply it you will have to support it, and you won’t have the option of sending them to the Apple Store should it go wrong. I speak as a reluctant Apple help desk for many of my friends and family; certainly I will not be making any of these little rods for my own back for anyone who can’t do it themselves :)

Portable wireless boombox

Despite this little triumph I actually don’t require an Airplay device at the moment. I have two already and no requirement for a third, so while this is useful it’s not especially useful for me as a home device at this time. What I want to do is take this project further and build a portable wireless boombox.

This would be a self-contained system which doesn’t depend on anything other than a 12 volt power source (so, car battery, boat, caravan, solar panels, mains adaptor or a collection of D-cell batteries). It would provide its own wireless network to which users can connect their Airplay devices and then use wirelessly. It would contain a small power amplifier and a pair of speakers. I’ve found a power amplifier that even has a USB port from which I can power the Raspberry Pi, saving me having to worry about a step-down from 12 volts to 5 volts.

Not intended for connection to an existing wireless infrastructure this would mean that it could be used anywhere, as long as there’s a 12 volt power source. Great for camping, barbecues, boats, festivals or simply down at the bottom of the garden. I’ve identified the parts that I will need (and indeed ordered most of them), but my biggest challenge still remains and that is what sort of box to build to house them and how to manufacture it. I’ve a feeling that my prototype won’t be particularly pretty, if entirely functional.

I’ll keep you posted on this project as I make progress.

Uncategorized

Python SimpleHTTPServer

I don’t use Python on a daily basis, barely at all in fact (knowingly), but I stumbled across a handy purpose for it today which I see myself using. Type this command in a Linux shell or a Mac OS terminal and it will start a local web server on port 8000 using the current working directory as the document root and sending access requests to STDOUT:

python -m SimpleHTTPServer 8000

Potential uses include:

  1. Developing local web applications on the local filesystem which use no server-side processing but do use Javascript and AJAX calls that a web browser would not normally allow without starting it with special flags (anyone who’s seen “XMLHttpRequest cannot load $RESOURCE. Origin null is not allowed by Access-Control-Allow-Origin” in their error console will know what I’m talking about).
  2. Quickly sharing a directory with a colleague on the same network rather than uploading files to a shared resource such as a file server or e-mail system. Obviously you’d need to ensure that whatever port you choose is allowed in your local incoming firewall if you have one.

There’s even better news for PHP users. PHP 5.4, released this week, includes a built-in web server which can be started with an equivalent command. The advantages of this of course is that it’ll also process PHP scripts instead of being limited to static files.

Uncategorized

New life for old Mac mini

Mac Mini (original case)

18 months ago I replaced my aged 2006 Mac Mini with an up to date model, which is still my main desktop computer today. The old Mac Mini was relegated to being a quasi-media centre, but of course because it was actually a desktop computer it really wasn’t a very good media centre, but due to its age nor was it a very good desktop computer, hence why I replaced it.

I never used it as a media centre beyond the odd occasion and it’s spent the last 18 months mostly consuming enough power to sleep and collecting dust. Until this evening, that is. I’m moving again soon (which I’ll cover in full in a different post) and I’m trying to take as little as possible with me. I was using an old Dell PC as a local Linux development server, which isn’t anything special but did the job nicely. There were three problems with it, however, specifically that it’s as ugly as hell, chews through electricity because it was manufactured at a time when computer manufacturers thought it grew on trees, and it belongs to my housemate.

I don’t really want to take it with me when I move because of all of those reasons, although I’m sure the last one could be eliminated with £30 or so. Then I remembered that I had this entirely idle old Mac Mini tucked away on a corner of my network doing nothing. I wondered if it would accept an installation of Ubuntu Server, given that it’s an Intel-based Mac (the original Intel Core Solo model, no less). Sure enough, it turns out that it can, and it works a treet.

My old Mac Mini has a 60Gb hard disk and 1.25Gb of RAM. It’s not going to break any records with its single-core 1.5Ghz processor, but for running a local Apache2 server it’s nothing less than what I need. The only caveat is that it won’t boot on its own into Linux straight from the hard disk, I have to keep an CD with rEFIt on it in the CD drive for it to do that; it’s certainly not the end of the world.

From a cold-boot to getting a login prompt with all services started it uses just 85Mb of RAM and with all the software I need on it and my Git repositories in place it’s using just 2.5Gb of it’s hard disk. All this on a 65 watt power supply. In addition to this, and despite the fact that it’s very different internally to my new Mac Mini, the two look identical from the outside and so look pretty good stacked on top of each other.

So don’t throw out your old Mac Mini, give it a proper job to see out its old age! The only thing I can’t do with this which I was thinking about doing with the Dell PC was putting an x100P card in it. I’ll live.

Uncategorized

PHP Vacancy

We’re hiring for a Software Engineer at work to join our technical team based in Birmingham city centre (Jewellery Quarter). If you’re looking for a challenging PHP role and you think you might fit the bill, please do drop me a line with your current CV. Full job specification below. Please don’t be put off by the crappy website, we’re literally just about to launch its replacement :)

Glide is a rapidly growing energy and telecommunications company specialising in looking after tenants, landlords, letting agents and property investors across the UK. They supply gas, electricity, telephony and broadband services to residential and commercial customers.

About Glide

They believe in hard work in an informal atmosphere that encourages people to express their ideas. They look for talented people who want to work with technology and can tackle problems in a smart and creative way. Their employees enjoy working in a challenging environment that brings out the best in them. Customers and customer service are at the heart of everything they do – their business revolves around their customers.

They have their own in-house development, customer support and sales teams and remain focused on keeping their costs low through automation and keeping customers informed through good communication. As technology evolves, they aim to bring new and improved services to their customers as early as possible.

About The Role

They currently have an opportunity for a full-time senior software engineer, starting immediately, as part of their in-house software team.

The role will focus on developing their bespoke systems. Their systems are written in object-orientated PHP with a SQL database. You will need to be a highly competent programmer  in PHP, SQL, Javascript, AJAX, Smarty templates, Model-View-Controller and in documenting your work. Good familiarity with Ubuntu/Debian based systems is required. Experience with invoicing routines, SVN or accountancy systems would be useful.

The role will involve working on projects to develop existing products, launch new products and services, improve internal customer service systems, update and maintain accountancy systems and invoicing scripts, debugging and diagnosing problems with their existing code base and working closely with their customer service teams. The role also includes integrating their system with multiple third party suppliers, redeveloping customer portals and revamping their website.

You will be enthusiastic about new technology, eager to learn, and will hold a degree in Computer Science or equivalent. You will be capable of managing your own time.

Application Details

The company is a place where everyone can be heard. If you like the sound of this opportunity, they’d love to hear from you. Please direct your communication and correspondence through my team or direct to me. Please view the website at www.glide.uk.com for more background information to assist you with your response.

Uncategorized

Command line Twitter script

I mentioned on Twitter the other day that I have a relatively basic but functional command line Twitter script, for use when you can’t or just don’t want to load the full-fat Twitter site in your web browser or you don’t want to use a third party GUI client. I received much more interest in this than I thought I would (i.e. more than zero) and so after some thought* I’ve decided to make it available to anyone who wants it.

The script, which supports a single Twitter account, supports the following actions:

  • Update (tweet), with option to specify an existing update ID to reply to.
  • Retrieve your public timeline (your tweets and those of who you follow).
  • Retrieve your own timeline.
  • Retrieve the public timeline.
  • Retrieve your recent mentions.
  • Retrieve recent re-tweets of your updates.
  • Search Twitter.

In order to work, you must authorise your Twitter account with SuperTweet, and provide the script with the username and secret that you specify in your SuperTweet account. This is because the script does not support oAuth (at least, not yet). Also, if you use Twitter to post URLs (and you probably do) you will also require a Bit.ly API key. Edit the script and provide both sets of credentials at the top.

The script is self contained, containing all the various classes that it depends on in the same file. I’ve verified that it works “out of the box” on Ubuntu Linux 10.04 and Mac OS 10.6. It will probably work on many other systems too, assuming they have PHP installed. With a small modification to the first line you can probably get it to work on Windows too, but that’s as far as I can advise, you’re on your own from there. The version I use doesn’t contain the included classes as I link it to my local class library.

To get started, download the script, unpack it with gzip -d, add execute permissions with chmod +x and then type ./twitter.php commands for a usage summary. Some commands when called without arguments will present further usage summaries which will tell you how to use them. You’ll probably want to start with something like:

./twitter.php update "Testing @stuartford's pitiful command line Twitter script."

Don’t forget to add your Twitter and Bit.ly credentials to the top of the script otherwise it definitely won’t work first time for you and I’d rather that didn’t happen.

If you don’t understand most of this post then this script probably isn’t for you, sorry, it is what it is, no warranty, etc.

* I say it required some thought because it’s rare that I make my code available for public use. I don’t know why, because I believe I am a talented software developer, I guess it might be the slight family creative gene within me that might be forcing a behaviour equivalent to an artist who’s perpetually reluctant to show people his work, who knows, that’s one for the shrink’s chair. Certainly the script isn’t my best work, it grew out of something quick and dirty, and as any developer will tell you, anything that grows out of something quick and dirty will always be quick and dirty at its heart.

Uncategorized

Back in the saddle

I  started my new job in Birmingham city centre (specifically, the Jewellery Quarter) on Monday, for Glide Utilities, a firm that sells household utilities (gas, electricity, telephone, broadband and TV licence) as a package to renting house-sharers, passing on a portion of the cost-savings brought about by bulk deals made with suppliers.

As I mentioned in my previous post, instead of paying separate suppliers directly, who will insist that accounts held with them are in one name only, house-sharers all pay a fixed sum every month to Glide who then handle the rest. It makes for easy budgeting and reduces household administration which can otherwise be a bit bewildering to people who are living separately from their parents and not in university halls for the first time. Glide is currently unique in its market and by all accounts seems to be doing very well.

My job is, with another member of technical staff, to maintain and enhance the somewhat complex software system that runs the company, which does virtually everything from internal company administration, accounting and billing right through to live ordering and status checking of utilities from suppliers. As with any existing system being started on by a new developer I will need a suitable gear-up period, but I’m making great inroads into it and I reckon that by the end of the week I’ll be able to make some initial recommendations as to procedure and future development.

It’s really good to be doing what I do full time again. It occurred to me on Monday morning that the last time I got up in the morning to go to a full time job in an office somewhere my life was very different, better in some ways and worse in others. It’s very different now, still a long way from ideal, but I do know that I’m going in the right direction to get to where I want to be. Doing what I am good at every day is a critically important step towards my goals rather than wasting time on the amount of sales and marketing that self employment demands of me, because I’m absolutely hopeless at both. I’m creative and technical, always have been, always will be.

I’ve been told to get the train in on Friday and not drive in. I can only assume that this means there’s going to be some sort of new-starter party in the afternoon/evening. It’s a young company and everyone who works there is around my age or younger, so I think it’s a fair bet that that’s what it’s going to be.

Uncategorized

Gainful employment

I’m delighted to report that on Monday I start a new job as a Software Engineer for a utilities management company in the Jewellery Quarter in central Birmingham. The reality of being self employed is quite different to what is perceived and I was very much struggling with the sales and marketing side of working for myself, so I decided to move back in to full time employment in order that I may concentrate on and spend my time on what I’m actually good at rather than incur frustration at spending time on having to do things that I’m not so hot at. I’ve never been a salesperson and I never will be. You have to be a certain type of person to do that I’m just not that person. I’m creative and technical, always will be.

The company is unique in its market. It provides a service to landlords and tenants whereby all members of a shared rented household pay one fixed monthly sum for all their utilities, including gas, electricity, water, telephone and broadband. Primarily aimed at the student market where house-sharing is most common, the company uses its buying power to negotiate cheaper rates from utilities providers and passes a portion of those savings on to their customers. It’s an exciting young company and I believe that I can make a difference to their operation and improve it through the ongoing enhancement of their existing software systems.

It’s an 11 mile commute into central Birmingham every day, which is fine, it should take me around 45 minutes each way. I don’t have to be in the office until 10.00am each day so that should allow me to avoid the worst of the traffic, which is ironically enough on the roads leading into and out of Sutton Coldfield rather than central Birmingham itself, once I’m past Sutton it becomes a lot easier. The equivalent train journey is less pleasant at 90 minutes in each direction including the two walks from the start and destination stations, so using the car is the way to go.

I’m looking forward to it.

Uncategorized

Ubuntu trial over

The Ubuntu trial is over, and I regret to say to all Ubuntu fans that I have returned to Windows. I have reasons, make no mistake, and my time with Ubuntu isn’t over.I really wanted Ubuntu to work for me full time, and I tried my hardest with it, but I was pushing it to the limit and it couldn’t cater for me in the end. Reasons in a pinch:

  • Whilst Ubuntu could connect to various sorts of network drives (SMB and SFTP), accessing those drives was frustratingly slow and more often than not, access to them was not offered by applications when loading and saving data. This meant that I frequently had to copy a file from the network drive to the local filesystem, do whatever I needed to do to it, then copy it back. Most inconvenient.
  • Ricey pointed out Crossover Office to me, which allows certain Windows applications to run under Linux, including Internet Explorer, Microsoft Word, Microsoft Excel and Adobe Photoshop. They all installed and ran, but were very slow due to the emulation engine under which they ran (WINE, one assumes). They also suffered from the inability to access my network drives.
  • Crossover Office also did not support Adobe Illustrator or Quark Xpress, so I was still missing my vector graphics and DTP software.
  • The whole system seemed slower. Memory usage wasn’t a problem, so it wasn’t swapping that was slowing it down. Programs seemed to take a long time to load and the processor fan always seemed to be working hard, even when I wasn’t doing anything in particular. The kernel that shipped with Ubuntu didn’t recognise my hyperthreading processor (probably because it wasn’t an SMP kernel), although I don’t know if that had anything to do with it. People call Windows a processor hog, but it seems to give my CPU much less of a hard time in comparison.
  • The iTunes equivalent “RhythmBox” software really couldn’t get its act together. Once I’d convinced it to recognise my MP3 stash, it then went overboard and indexed it twice. It would also frequently lock up, sending the CPU fan spinning into oblivion.
  • The open source office suite OpenOffice.org shows promise, but did not properly display 80% of the office documents that I opened with it. This was particularly prevalent in the word processor; the spreadsheet software wasn’t so bad.
  • I had to go through a complex process just to get it to play MP3s. Apparently, because the MP3 codec isn’t “free”, it doesn’t come with Ubuntu by default, and you have to install it separately, but that means adding unsupported repositories and other such nonsense. It seemed an unnecessary bit of red tape just so that I could play my Massive Attack album. I know all the arguments about “free” codecs versus those encumbered by patents, but this is supposed to be an out of the box OS, and what’s one of the most popular things that people use their computers for these days? That’s right.

Like I say, I really wanted this to work out for me, because Linux on the desktop has come a very long way from the days when you needed to be a sorcerer to even have a hope of getting a half-decent graphical desktop setup on a Linux machine, but unfortunately, it’s still not come far enough, at least not for my day to day work requirements. I will however attempt to get it onto my laptop and use it on there. I only use my laptop for web browsing, e-mail and SSH access, and Ubuntu can do all that just fine.

Other good points that I really liked:

  • Seems to support my laptop’s wireless network adaptor out of the box, but I can’t get it to display all the networks available, including my own. I expect I’ll be able to do it via some command line tool, but I shouldn’t have to do this.
  • This isn’t down to Ubuntu, but I was impressed at the ease of which I downloaded and installed the manufacturer supplied graphics card drivers, which allowed me to use my multi monitors with no fuss.
  • 98% of the system management functions are available using the graphical user interface, which is good. There is, however, still the 2% remaining. I suspect that use of the command line will never be fully eliminated, since at the end of the day it’s a UNIX-like operating system, and that means commands.
  • I liked the range of “familiar” looking software that shipped with it. For example, evolution looks like Outlook, RhythmBox looks like iTunes and OpenOffice.org did its best to use the good parts of Microsoft Office’s interface. The developers have made a very good attempt at trying to cover all the bases and not scare newcomers by inflicting unfamiliar software on them.
  • The installation procedure is marvelous. It’s quick, doesn’t ask any complicated questions, and seems to have no trouble in detecting and installing drivers for most if not all hardware that’s thrown at it. This is crucial if it wants to poach Windows users, newcomers won’t accept anything less.

Ubuntu is a very solid, if relatively limited, operating system distribution, and it’ll work a treat for the likes of my laptop and my Dad’s PC. The developers have done a fantastic job, especially as it’s been made available for free, and must keep up the good work.

Unfortunately, in my case, it can’t support my day to day work, and I don’t have endless time to hack it and tweak it, and even if I did I would still have to make compromises. I don’t expect it to 100% look and act like Windows, not only is that unrealistic but it would completely defeat the object of offering an alternative operating system. Windows, for all its fault and reputation, is fast, responsive and very well supported in terms of software, and that’s what I need, at least at work.

1 2