5-line Random Password generator

I needed to generate a random password. There’s plenty of scripts out there for doing this, but most involve creating a dictionary of characters, then looping for a given number of times generating a random number and picking out a character based on the number. I wanted a more compact solution so here’s what I came up with:

$chars = str_split(sha1(rand()),2);
foreach ($chars as $k => $char) {
    $chars[$k] = chr((hexdec($char)/255*95)+31);
$password = implode($chars);

It’s PHP, but can probably be replicated easily in other languages. Here’s what it does:

  1. Generates an SHA1 hash of a random number, then splits the hash into groups of 2 characters (each is a hexadecimal number =<255).
  2. Converts each hex number into decimal, scales it to value between 32 and 127, then converts that number to an ASCII character
  3. Creates a string from the array of characters

More Oggcamp Tickets (get ’em while they’re hot!)

Never mind hot, get then while they’re still there!
OggCamp tickets have been flying out the door as fast as we can release them, and we’ve just released another batch of 100!

About 45 of those have already gone at the time of writing, so if you want to come, you’d better get in quick! It’s awesome to see that there’s such a buzz around our little event that we do for the fun of it (we’re not making any money out of it, it’s purely for the giggles).

If the tickets are already gone by the time you read this, please do add yourself to the waiting list. You may be lucky enough that there’ll be returns, and if we know that demand is outstripping supply, we can look at which rooms we’ve got in the venue and possibly make more room.

If you’ve got a ticket and need a place to stay, we’re recommending the Premier Inn, Aldershot. It’s a pretty good deal and not too far away.

See you there!

Is Yes to AV “Yes To Fairer Votes”?

While the No Campaign have been trying to confuse and mislead the public by painting elections as a literal race and ensuring voters that they’re far too stupid to understand the Alternative Vote system even though they have no problem voting on the X Factor every week, the Yes campaign has had 1 clear message: “Yes to Fairer Votes”. They say that AV will give voters more power, and make peoples’ votes worth more. Given that this in the only point they’re arguing on, you’d hope that they’re correct.

Voter Power Index was set up before last year’s general election to show people what their vote was “worth”, i.e. how much their vote counted towards the overall decision of who governs. Under a pure system of Proportional Representation, everybody’s vote would be worth 1. Due to the nuances of our current system (such as the sizes and demographics of each consistency creating “safe” and “marginal” seats), votes in each constituency will have a different effect on the overall result. For example, I live in Southampton Test, a Labour safe seat, so my vote is worth just 0.128 by Voter Power Index’s calculations. In a highly marginal seat where no party has particular loyal support, their votes may be worth more than 1.

Voter Power Index’s site has just been updated to take the Alternative Vote system into account. The Yes campaign claim that AV will increase the power of each vote, since the ability to rank candidates in order of preference gives you more of a say in the outcome.
Voter Power Index agrees. Their findings:

Analysis from [the new economics foundation] suggests that switching from First Past the Post to the Alternative Vote would have the following effects across the UK:

  • An increase in the average power of UK voters from 0.285 of a vote to 0.352 of a vote (where a score of 1 is a fair vote).
  • An increase in the number of very marginal seats from 81 to 125, an increase of 44 seats.
  • A reduction in the number of very-safe seats from 331 to 271 a reduction of 60 seats.
  • A small reduction of inequality in the power of votes with the most powerful fifth of electors going from having 21 times the power of the least powerful fifth down to 18 times.

That gives an average increase of 24% to the power of the vote. In my constituency, it increases 31% to 0.168. So the Yes campaign, if nothing else, is absolutely correct.

But wait a minute, my vote will still be worth less than 1/5 of a vote under AV? Unfortunately, Yes. AV is still a majoritarian system, so it wont bring about the equality of votes that Proportional Representation would. However, it does make votes fairer, and is a step in the right direction. Even if you don’t think PR is a good idea, it’s hard to argue that we should keep a less fair majoriatian system over a fairer one.

Alternative Vote – If you vote No, you’re answering the wrong question

On the 5th of May there’s a referendum. The question posed is thus:

At present, the UK uses the “first past the post” system to elect MPs to the House of Commons. Should the “alternative vote” system be used instead?

The campaigns for and against are currently in full swing, and there’s something quite striking about the “No” campaign: it’s saying No to the wrong question. The question is answers is this:

Is the Alternative Vote the best system we could have to elect MPs to the House of Commons.

The answer to that is clearly No. The Alternative vote isn’t a great system at all. It has it’s merits, but it’s certainly not a a good example of Proportional Representation. Even Nick Clegg called it “a miserable little compromise” and he’s the one pushing the damn thing. The No campaign has focused on this and are demonising AV like it’ll herald the end of democracy, while neglecting to defend the system they’re trying to make us stick with for all eternity.

However, read the question being posed again. It’s not “Should we use the Alternative Vote?”, it’s “Should we use the Alternative vote instead of First Past The Post?”. Both systems are, broadly speaking, majoritarian systems (that is, they’re designed to give the winning party a significant majority). Neither system is ideal when you’re considering fair representation of the people’s views across the whole country, but in a >2 party system (like we have in the UK), First Past the Post (FPTP from now on) simply doesn’t make sense.
The key difference between to 2 systems is this: Under FPTP, a candidate can win without the support of the majority of voters in their constituency. In fact, the more candidates who stand, the less support they need to win due to the vote being split (see, the BNP winning council seats, which is why they’re against the change). Under AV, 50% of voters must vote for a candidate in some capacity for them to win. With only 2 parties, FPTP is fine as one candidate will always have a majority (unless its a dead heat). With more than 2, AV is the clear choice to keep voting fair and results meaningful.

Until a better option comes along, let’s snap it up. Vote yes.

Come to OggCamp… Oh.

So, this was going to be my blog post to promote OggCamp and tell everyone to come. However, just 5 days after the event was announced, the 200 tickets have sold out.

So what the hell is OggCamp?

OggCamp is an annual celebration of Open Technology, including Creative Commons music, art, literature, Open Source software, open data, and anything else that’s generally geeky and hackable. It’s organised by The Ubuntu UK Podcast and Linux Outlaws. This year will be the third that the event has run, and the first one I’m involved in organising, and it looks like it’s going to be a blast.

When/Where is it?

The event’s being held at the Farnham Maltings in Farnham, Surrey on the 13th and 14th of August. The “official” hotel is the Aldershot Premier Inn, which is a short drive, train ride or a very long drunken stumble away.

It sounds amazing, but I don’t have a ticket! What do I do now?

As I mentioned, the event is now sold out. All ticket registrations are handled through EventBrite. I’d suggest watching the page like a hawk for any cancellations, and snap up the tickets. Did I mention that the event is free for all attendees?

Ubuntu UK Podcast Season 4

Last September I recieved a Tweet from my friend/former boss and LUGmaster Tony Whitmore asking me if I was free that evening. Tony is one of the founding presenters of the Ubuntu UK Podcast and it was recording night. 3 out of 5 members of the team weren’t available, leaving just him and Laura, his girlfriend and co-presenter. Suffice to say “The Laura and Tony Show” wasn’t the sound they were after, so they asked me if I’d be up for popping down the road and joining it.

Being a fan of the show, I jumped at the chance.

After what must only have been 6 or 7 episodes (although it was so much fun it felt like a lot more), it was Christmas and time to call and end to season 3 of the show. However, after a couple of months off we’re rested and we’re back, this time doing things a little differently…

The big change we’re making is the move to an official live stream of the show. There’ll be details of how to listen on the Live page with links to how you can get involved during and after the show, via IRC, Twitter or Identica. Of course, if you want to get in touch in between shows you can still use email and voicemail, just like before.
The show will go live on Tuesday evenings, from about 8.30 until 9.30 PM UK time, which is another change for us. We used to record on Monday, edit on Tuesday, and release on Wednesday. Now the plan is to stream and record on Tuesday, and release a relatively un-edited recording on the Wednesday as before. The first show is this tuesday, 1st of March.

The other major change is the website. We had a brilliant theme designed for us by Andrew Higginson, the man responsible for the Kazam Screencasting tool among other things. He even designed us a cool new logo, what a nice guy! If you see him, buy him a beer.

So tune in to us at about 8.30 this tuesday. All details will be on The Website. And if you’ve not listened before, well this is the perfect time to give it a go! Even if you’re not an Ubuntu user, it’s certainly not all we talk about – if you’re at all interested in computers and technology, have a listen. Go on, if you’ve read this far, you totally want to.

Using Dropbox as a DNS server

So at Dev8D we had a session on sharing handy hints and tips to save time and effort. The subject of Dropbox came up, so here’s one of my favourite Dropbox hacks.

At home I have about 4 devices on my network. I like to refer to each by hostname rather than IP address (I SSH a lot), but I dont want to have to run my own DNS server.

The solution to this is pretty simple (and very hacky). On one machine, I configured /etc/hosts to map each hostname to their IP address. Once I had it all set up correctly, I moved hosts to my Dropbox folder, and created a symlink in it’s place (so /etc/hosts points to /home/mark/Dropbox/hosts). I then set up the same symlink on my other machines. Now updating the hosts file on one machine will sync the changes to all other machines, giving me hostname to IP address resolution without DNS.

Standard – A new tool for creating slideshows


I’ve given a few presentations in my time. At University, at work, at conferences and barcamps, and recently to some students at the University of Portsmouth. They’ve all had one thing in common: a slideshow.

Slideshows Suck

There’s no reason that a presentation has to include a slideshow, but it can help focus the audiences attention on what you’re saying at a particular point. The problem I’ve found is that the most pervasive format for slideshows (PowerPoint) sucks, and the main alternative (OpenDocument) isn’t a lot better. They both rely on you having a local copy of the slideshow file, and having the appropriate software (and often the correct version) to display your slides as intended.

S5 Sucks Less

Recently, I started using a format called S5 (Simple Standards-based Slideshow System), created by Eric Myer. Eric was inspired by the Opera Show Format which allows you to create slideshows in XHTML to run in the Opera browser. S5 extends this idea using some simple Javascript and CSS to enable slideshows to run in any Standards-supporting browser. This eliminates the need for presentation software to be installed, meaning you don’t have to worry if your laptop dies and you’re presenting from another machine. It also makes it super-portable – you can run it from the local filesystem, upload it to some web hosting, or I just stick my slideshow in my public Dropbox folder, and present it from there. This gives me the double-whammy of being able to give a URL to my slides straight away.

Standard Makes Slideshows

The problem presented (ho, ho) by S5 is that it lacks the familiar editing tools of current formats. The easiest way to create one is to hand-code an HTML file, which is likely to be beyond the vast majority of presenters. Even WYSIWYG HTML editors aren’t ideal, as you’d have to edit the slideshow as a linear page, which is confusing unless you understand exactly how S5 works.

So here we reach the purpose of this post. Last night I released the first product of the Standard project, a new open source project I’ve started to produce tools for creating S5 slideshows. The key to these products is that you won’t need them to present the slideshow – you can use a web browser of your choice. The current editor is a plugin for Moodle 2, which I decided to create after using an S5 slideshow at work and seeing the potential for the format in a web-based Virtual Learning Environment. I also plan to create a simple desktop application that can be downloaded and run, and am looking at options for the best platform (I’ve had AIR suggested, but would prefer an open source solution, I’m currently looking at Ruby/Qt).

The first release is now in Moodle Contrib CVS, and the latest code will always be available from Github. If you want to keep track of the project, I’ll be blogging here with the Standard tag, Tweeting about it, and you can email me on mark at this domain.

Rock and roll!

Shuttleworth’s Law

On the last episode of UUPC, we mentioned “Shuttleworth’s Law” our very own adaptation of Godwin’s Law. In a nutshell, Shuttleworth’s Law is

As a discussion about Ubuntu grows longer, the probability of a user threatening to stop using the distribution approaches 1

Ciemon described the concept of Shuttleworth’s Law as “the mark of the bug” that sets it apart from others, in a similar way that Godwin’s Law suggests a conversation should probably be stopped (or already have been) once a comparison to Nazis or Hitler occurs.

Let’s look at some examples!
In the show, we mentioned 2 current discussions where the Law rings true. The first is during Popey‘s post on askubuntu.com, the new StackExchange site for Ubuntu-related questions. Popey wanted more information on why Ubuntu 10.04 would be switching to Unity for the default interface rather than working with the GNOME project to develop the desktop environment. Popey got his answer in the form of references to an ArsTechnica interview with Mark Shuttleworth. However, the conversation didn’t stop there. People took the question as an opportunity to vent their feelings about the announcement, and before long, we saw this post from Scott Evans. This may not be a perfect example of the Law as he talks about why he stopped using Ubuntu, rather than threatening to stop. However, the fact that he’s reading and posting on an Ubuntu Q&A site leads be to believe that he hasn’t stopped entirely.

The second example that we found on the show was during a discussion about the Launchpad trademark. Canonical hold a trademark over the Launchpad name, which is used for it’s open source bug tracking/project hosting site. Apple has recently announced that Mac OSX Lion will ship with a product called Launchpad, an iPad-style full screen application launcher. A bug was filed on Launchpad stating that Canonical should sue Apple for infringing the trademark. Canonical responded stating that the legal team was aware of the issue, and since it wasn’t a bug in the Launchpad software, the bug was marked as invalid. However, the responses continued, and yes, the user Tralalalala threatened they would “immediately remove Ubuntu from [their] PC and won’t use it again.” if Canonical were to sue.

Shuttleworth’s Law certainly isn’t a recent phenomenon. Shortly after Launchpad was open-sourced following pressure from the Ubuntu community, a bug was filed against the Ubuntu One Server project, stating that the server component of Canonical’s cloud storage service should also be open sourced. It was stated that Ubuntu One would remain a proprietary product, and that Canonical was doing so in the interests of getting a commercial return. This concluded, the bug was marked as Won’t Fix. Job done, right? Wrong. The comments continued, and sure enough user balleyne chimed in with this gem: “Ubuntu One makes me want to leave Ubuntu.

As for the reasons behind this pattern, I’d suggest a few hypotheses. An obvious one is simple Internet trolls who rock up to a controversial discussion and like to stir the pot a bit.
A second and slightly more worrying possibility is that it’s a desperate cry to be heard. If the community really feels that Canonical doesn’t listen to the needs of the users, is the only way they can get them to pay attention by threatening to vote with their feet?
Personally, I suspect it’s more a show of immaturity and arrogance than anything else, if there’s a belief that a company (or indeed a community) is going to change it’s strategy because one user is throwing its toys out of the pram. Once a decision’s been made, we need to live with it. If you don’t like it, voting with your feet is fine, but just do it! Popping your head round the door afterwards to make sure everyone knows your leaving is akin to threatening to go home and take your football with you if your team isn’t winning.

If you’ve seen another example of Shuttleworth’s Law in action, please post a comment. I might be fun to do some analysis of the occurrences (or is that just me?).

GuruPlug – Part 3

Now my GuruPlug was working again, it was time to set up the software.
The 3 functions wanted the ‘Plug to perform if possible are:

  • A web server
  • A bit torrent client
  • A UPnP Media Server

To start with, I wanted a nicer interface. I’m happy using the command line, but a default shell is a bit dull, and not very flexible. Using Ubuntu I’ve become a fan of byobu, a set of config profiles for GNU Screen which allows you to have a “tabbed” interface to within a shell and have useful system information displayed. Being built on Screen, it also leaves your session (and any commands) running when you log out, waiting to re-attach when you log in again.
Byobu isn’t currently in Debian Stable, so I found the package for Unstable, installed the dependencies with apt-get, and installed the package manually.

$ sudo apt-get install debconf gettext-base python python-newt screen
$ wget http://ftp.uk.debian.org/debian/pool/main/b/byobu/byobu_2.80-1_all.deb
$ sudo dpkg -i byobu_2.80-1_all.deb

Bit Torrent

Next I looked for a bit torrent client. I had the following criteria for a client:

  • It needed to run headless/daemonised
  • It needed a web interface
  • It needed to support encryption

After a bit searching and an abortive attempt at setting up rtorrent, I settled on Transmission, which aside from having the GTK-based GUI used as Ubuntu’s default client, also runs as a daemon with a web interface. The transmission-daemon package was only available to install from the lenny-backports repository, which caused a few dependency issues, but forcing install of the packages from backports with apt-get install -t lenny-backports did the job nicely.

UPnP Server

My plan was to share media from the ‘Plug’s external hard drive to other machines on my network (particularly my Wii, running GeeXboX). I installed MediaTomb from APT and set it up to share the files, but when testing with XMBC on another machine, I couldn’t find them. Unfortunately, there seems to be very little in the way of troubleshooting documentation or other readily-available clients to test with, so I don’t know if I’d mis-configured MediaTomb or XMBC, or my network.
In the end, I decided to switch to using Samba.


Setting up samba was a doddle. The GuruPlug comes preconfigured to share anything in /media, so I just needed to set it to allow guest access by adding some bits to /etc/samba/smb.conf:

security = share
guest user = nobody
map to guest = bad user
guest ok = yes

Another snag was that GeeXboX for Wii doesn’t support the Wii’s Wireless, which means I needed to plug it in to my network. This meant moving my router to be near my TV, and thus moving the Plug as well. Here’s the new setup.
That’s the guruplug on the left, connected to the router behind the TV, and the hard drive is now in the shelf under the Wii.
There’s the router behind the TV, with the Wii and GuruPlug connected.

Unfortunately, having the router behind the TV meant that the WiFi signal screws up the picture. Luckily, the ‘Plug acts as a Wireless Access Point!

Wireless Access Point

The ‘Plug comes pre-configured as an open access point, and routes traffic through the Ethernet interface. I just needed to make a few changes to enable WPA2 encryption. The script /root/init_setup.sh is run on boot to set up the access point among other things, so I just had to add a few commands from this guide.

ifconfig uap0 up
/usr/bin/uaputl sys_cfg_ssid $SSID
/usr/bin/uaputl sys_cfg_protocol 32
/usr/bin/uaputl sys_cfg_wpa_passphrase "passphrase_here"
/usr/bin/uaputl sys_cfg_cipher 8 8
/usr/bin/uaputl bss_start

Web Server

The GuruPlug comes with Lighttpd installed and running to serve some CGI scripts used for some simple configuration tasks, like switching the WiFi to client mode. To keep these scripts intact in case I needed them, I fiddled with lighttpd.conf to create Lighttpd’s equivalent of a vhost in Apache, letting me have the main site served when the server’s accessed by the hostname (and eventually, domain name), and the config scripts when it’s accessed by it’s private IP address. This prevents access to the config scripts from outside, while still having the main site available to the world.

server.document-root       = "/var/www/sites"

$HTTP["host"] == "" {
        server.document-root    = "/var/www/setup"

I’ve got some additional ideas for things to do with the Plug, but it’s certainly served very well so far, so that’s all for now. If you’re interested in the resource usage, Byobu currently reports that RAM usage is at 13% after all the above setup. I’ll probably make a few smaller posts as I experiment some more!