Raspberry Pi, and Raspberry Pie

:(

I went to bed early last night cos I knew I had to be up early this morning. Getting up at 05:30 is something that is incredibly rare for me. Unfortunately, it was a bit pointless this time around.

I was trying to get one of these:

Copyright 2011-2012, Raspberry Pi Foundation

It’s called a Raspberry Pi, and it’s essentially a computer the size of a credit card. With an ARM11 processor manufactured by Broadcom, 256M RAM, HDMI/RCA video output, 2 USB ports and Ethernet, powered by micro-USB, with SD for storage. What more could you want for a basic computer system?

Initially, it’ll run a variant of either Debian or Fedora Linux, and my plan is to use it either as a local web server/proxy server/dns server, or maybe running XBMC as a low-power media frontend. It’ll also be good for simply messing about with.

Oh, did I mention the price of this thing? No?

$35 (USD).

In the process of trying to order one, we (everyone who wanted one) brought down not only RS Components’ website, but Premier Farnell too in mere seconds. They were warned about the traffic, but seemingly thought the warning a bit frivolous since both of them didn’t adequately prepare for a HUGE traffic surge.

And now I have a craving for raspberry pie.

My Development Environment

I thought I’d share my development environment with you, the basic tools and computer systems I use to develop software.

Most of my development is done on a Core2Duo 2×2.26GHz 4G RAM 1280×800 Win7 machine (taurus), occasionally using an Atom 2×1.6GHz 2G RAM 1024×600 Win7 netbook (orion) if I need portability, sometimes even testing on a Motorola Xoom (gemini).

My web production environment is a Linode 512 running Ubuntu (latest) hosted in London (blastoise), just the standard LAMP stack. Database hosting is done on a different machine, another Linode 512 also in London (metapod), which jointly serves as a code-review host. CI is hosted (spearow) on a Linode 1024 (you guessed it, in London), using Atlassian Bamboo as the software in question.

Source control is github, and I can’t say how awesome git (and the GUI tool Git Extensions) actually is! :D

As most of the development I do is either PHP-based or C#-based, these are the two areas I’ll cover.

If I’m working at home, I’ll write PHP code with Notepad++, and test it on my local server, IIS (yuk, but it does the job). I’ll still use the database server sat on metapod. If I’m not at home, and have an internet connection, I’ll do most of my work directly on one of my servers using GNU nano, and a plethora of GNU screen sessions. Everything still goes into git, and pushed to github.

Unfortunately, this tends to end up with hacks such as:

if(WebRequest::serverOS() == "WINNT")
{
   /* something specifically silly for windows */
}
else
{
   /* something posix-compliant, like sensible stuff */
}

Most of the time I try and keep most of that stuff confined to a file or two though, or try to find other ways of doing what I want without depending on OS-specific stuff.

C#.NET

Visual Studio 2010 Ultimate. Thanks, MSDNAA. Oh, Git Extensions too, but standalone cos the VS integration is annoying.

Progress reports really do slow things down!

This is something I’ve known for quite a long time, but if you’re ever thinking “it’s not that much extra power to add progress reports”, just make a mental note of exactly how many progress reports you’re making, and try commenting them all out.

BeebMaze generated a new maze in mere seconds, but at the same time, that was seconds too long. As part of refactoring, I took out the progress reports with the intent of putting them back in, since there wasn’t that many.

It now generates a new maze in about the time it takes to paint the screen once. :D

(Download this build from the build server now: Build #18)

Multi-lingual interfaces for a website

One of the uni projects I’m doing is a Hotel Management system for “The Blackfish Hotel”, as part of the third-year group project. Part of this is an online booking system, where customers can book rooms in the hotel.

Our “customer”, the manager of the hotel, has asked for the website to have a version in Finnish as well as English, as apparently a large percentage of his customers are from Finland. This posed a challenging problem for us to solve… well… sort of.
Continue reading

Regular Expressions Tester Engine

I’ve actually taken a bit of time to fix up, make user friendly, and publish a tool that I wrote a little while ago, and has been very useful to me.

The regular expressions tester engine basically provides a front-end to the Microsoft .NET Framework Regular Expressions engine, allowing you to test regular expressions you’ve written to your hearts content.

As usual, I’m releasing it as-is under the MIT licence, and as usual the source can be found on GitHub.

For a page which might have more information on it at some distant point in the future, but more importantly has a download and bugtracker link, see this page on my main website.

ACCBot’s recent breakage

A couple of weeks ago, the IRC bot that we use over at Wikipedia’s Account Creation Assistance project decided it would stop giving notifications to the IRC channel. Previously, it used UDP as the transport between the web interface and the IRC bot. However, for some unknown reason, this stopped working.

After seemingly endless messing around with PHP, netcat, more PHP and a bit of telnet, I came to the conclusion that it was fucked, and there was no way to recover it with any ease.

Previously, the code looked something like this:

For receiving notifications over UDP, that was all we needed – it worked and was semi-secure. However, when it stopped working, I took a more radical approach.

You’ve probably heard of Amazon Web Services (AWS) by now, if you haven’t then I recommend you take a look.

One of the AWS services is something called the Simple Notification Service, which seems to be exactly what I want – a notification system. However, the only notification endpoints are HTTP pings, e-mail, or an SQS endpoint.

SQS is what I chose eventually – it’s another of Amazon’s services, the Simple Queue Service. This has the “advantage” of queuing all the notifications so if you’re offline you will still get them all. However, for our case this isn’t ideal, but the bot isn’t usually down for long if it goes down. So, I decided to go for SNS->SQS over HTTPS as the transport for the notifications, rather than UDP.

Of course, code needed changing – at first I thought drastically, but it turned out to be a much smaller change than I anticipated:

It looks small, just another explicit check to see if we actually received anything. That’s until you realise that I wrote another function to take some of the work off to one side.

There’s not much that’s changed, but it was an interesting technical challenge :P The only thing that has noticeably changed is the lag from notification generation to display on IRC – can be anywhere up to about 5s if you’re unlucky!

Strobe Light

Growing tired of the poor strobe light applications available on Android Market, I decided to build my own.

Lots of the so-called strobe light apps which already exist on Market seem to be of the type which use the phone screen as the “strobe” – this isn’t good cos it takes a while to update the screen, and it isn’t as bright as the camera flash led.

My app is a very simple one – a quick loop to set the flash on, wait a while, set the flash off, and wait a while.

The two waits are configurable with sliders, with values of anything from 0 (theoretically) to 500ms.

The only problem is the fact that developing camera-based applications on Android is a bit of a dark art – not all manufacturers seem to use the Camera API to access their camera. Therefore, camera-based apps can be a bit hit-and-miss as to whether or not they will work. As I only have the HTC Desire, I can’t test it on anything other than the Android Emulators, and my actual phone. I have, however, had reports of it working on a number of devices, including the Samsung Galaxy S2, HTC Incredible, and the HTC Evo 4G. There have also been reports of it NOT working on the Galaxy Tab, Droid X, and the XT720 Milestone.

As all the flashing takes place in an infinite loop, there’s no time to handle GUI events. Therefore I branch out the flashing bit to a separate thread, and use Handlers to make the necessary calls back to the main thread to update the GUI as necessary.

The main reason to update the GUI is to make sure that should the strobe thread get stopped in any way, such as on activity changes or screen re-orients (currently disabled) etc, the GUI “enable” toggle button actually shows the correct status, as well as to easily display any error messages as necessary.

There’s still a few outstanding bugs (screen orientation!), and there’s a few changes I’d love to make to it, but it’s coming along quite nicely, I just need more time to actually work on it!