Some code snippets from my home page: Part 1

About 6 months ago i reorganized my website, this included a new homepage ( here ). A lot of the code was borrowed from a friends web page ( here ), recently a friend who likes it asked me how the code worked, and to go through it, so i thought it might be worth making a blog post on it.

All the code is under the license “Creative Commons Attribution-Noncommercial 2.0 UK: England & Wales License” and is copyright to Tom Brearley.

I assume a basic knowledge of HTML / JavaScript.

There are 4 parts to the web page in question, the tag line, recent blog posts (items from an RSS feed), recent tweets(items from twitter), recent music (from

All of the code requires jQuery, i used it from the Google CDN but you can use it locally. The code to use it from the Google CDN is:


Simply place this in the header of your HTML.

The Tag Line

This is rather simple. We have an array of tag lines, and we pick on random when the page loads.

The first this we need is a placeholder for the final message. Insert it in to the body of the page. Also include a fall-back message, which will be displayed if for some reason the JavaScript fails.

[javascript]is awesome[/javascript]

Then the code which will actually pick a tag line and insert it correctly into the document. In the head of the document, create a script tag, and insert the following function (modifying the tags to your taste). This simple function just creates an array called “phrases”. Then using the jQuery notation, sets the HTML property of the tag with the name “tagline” with a random phrase.
function go(){
var phrases = Array(
“uses <a href=””>Bing!</a>”,
“loves <a href=””>Windows</a>”,
“uses <a href=””>Internet Explorer 9</a>”,
“loves <a href=””>Windows Phone 7</a>”,
“uses <a href=””>Visual Studio 2010</a>”,
“is a <a href=””>Conservative</a>”,
“reads <a href=””>Conservative Home</a>”,
“dislikes <a href=””>OS X</a>”,
“loves his <a href=””>MacBook Pro</a>”,
“used to be a <a href=””>Scout</a>”,
“programs in <a href=””>C#</a>”,
“prefers <a href=””>dogs</a> over <a href=””>cats</a>”
$(“#tagline”).html( phrases[ Math.floor(Math.random() * phrases.length) ] )

Finally we need to call this function once the page is loaded. To do this insert the following code just before the “go()” function.
And that is Part 1, watch out soon for the final 3 parts.

Windows and Software Installation

In a number of recent discussions with some of my friends at university they complained that installing software on Windows is hard or complicated, or more so than it needs to be, or compared to their favorite operating system.

So in this post i aim to see if i can uncover what the issue is, and possible fixes for this issue. I will also look at the common ways of installing software on other platforms, and if they are better, or if they have similar issues.

Windows – The Process (and Issues)

Installers on Windows generally work using a Wizard interface (Nullsoft, MSI), that after a sequence of steps, it then copies files to an appropriate place (hopefully %programfiles%) and registers its self with the system so it appears in Add/Remove programs.

One of the advantages of MSI is that it does a good job of managing upgrading previously installed software, without simply overwriting the old files (it will detect if a previous was installed, then remove the old version and install the new version), it can also be installed without a GUI which is good for corporate usage and systems management.

A few years ago Microsoft introduced a new system called Click Once. This installs an application in the users personal %appdata% directory which ensures security to an extent, due to this most applications can be installed by the user, without the help of an administrator. The final benefit to this new system is that it can do automatic application updates. Unfortunately very few developers have taken advantage of this method, although notable developers who have are Google who use it for chrome, and a large number of Twitter applications.

Uninstalling an application is rather simple, you just find it in Add/Remove Applications, then click uninstall. This can be slightly painful when it comes to big complex bits of software like Visual Studio that have a large number of different components to be un-installed in turn.

The only other time un-installation can be a problem, is if an older application uses an installer that does not register its self properly, it can sometimes be a bit of a pain to find the uninstaller.

There are a number of issues when it comes to software installation on Windows. The first is that there are a large number of inconsistent installation systems that developers use, and they all provide a number of different features and work in slightly different ways, but the key here is that there is no consistency in what the user can expect.

One thing that i must mention here is that now most installation systems actually use MSI (Windows Installer or Microsoft Installer) underneath but present the user with a special GUI, but there are still plenty of developers using the Nullsoft system especially in the open source arena.

General – Good management of Uninstallers
Click Once – Automated Updater, Simple only a few clicks, doesn’t require administrator permissions
MSI – Scriptable, Software versioning

General – Inconsistent UI, a large number of legacy installers, complex software can make uninstalling painful having to uninstall each sub package manually.

Mac OS X – The Process (and Issues)

OS X is actually very similar to Windows but i will just go through it, but there are a number of ways.

The first way, that is most widely used is a .app file(although its actually a folder) for distribution, this can be downloaded directly, or be distributed in a .dmg file, then drag it into the “Applications” folder (or any where else if the user does not have permission to the Applications folder). The App Store automates this process even further.

The second method is to use a .pkg or .mpkg installer. From my research this is simply a modified .tar.gz file, with a special folder structure. .mpkg installers can also be used to install a number of .pkg’s. The way its done means that Apple provide the installer GUI so it is always consistent, but it can also be scripted.

The final way you can install software is the “Unix” from source way. You can do your usual “./configure && make && make install”.

Un-installation and clearing up from some programs can be a bit problematic though. To remove a .app installed program you just delete the .app file, although this will leave the application preferences behind which you may want to manually clean up. To uninstall a .pkg or .mpkg it can be slightly more problematic, generally having to find and execute a script to do the heavy lifting for you and the same for reversing the “Unix” way of installing software.

None of their installers have a way for automated updating, but there is a 3rd party library that is widely used called Sparkle. The new App Store also handles updating automatically.

.app – Simple Install / Uninstall
.pkg/.mpkg – Consistent UI

.app – Uninstall leaves user specific application data behind
.pkg/.mpkg – Needs a script to uninstall

Linux – The Process (and Issues)

On Linux you generally have three options. Install the “Unix” way from source, which we have already discussed with OS X. Install using the package manager from repositories OR install using a package manager and a manually downloaded package.

The later two ways make installation and un-installation fairly easy (through command line or a GUI). They are also a good way to distribute updates.

But there are problems with this, the repositories do not tend to stay up to date with the latest versions of the software, but may be a few versions behind. This leads to using the other installation options to get the latest versions, which complicate the management of installed software. Although this is not so much of an issue where servers are concerned where stable software is ensured through the repositories. The other problem left is that the “official” methods of installing software is restricted to users with root permissions although they can install and setup software manually within their own directories, although this can be very complicated.

Stability, security.

Out of date locked down to just users with root/sudo permissions

What can Microsoft do?

So Microsoft and Windows is actually already in pretty good shape, and with the Windows App Store, this should solve a large number of the inconsistencies, and it should also handle updating.

But there is more Microsoft can do. They need to really push tools and software to work with Click Once and MSI with detailed documentation on why developers should use them, and which one is suitable for their particular application.

It should be a rather simple sell and distinction between what to use for different programs.

Click Once should be used for utility applications, so twitter clients, irc clients, ftp, paint (yes you Paint.Net), notepad, putty (just putty, not the rest of the suite)

MSI’s should be used for software that requires to be installed system wide, larger installations, and software which requires background services, system services, or have some complexity which means they might not be suitable for Click Once, so for example, Office, Visual Studio, Putty (with pageant)

They should enforce a single consistent UI for MSI’s which would help users, and provide some consistency for the user.

They also need to have a global update center, where everything installed can register itself (including MS software updated through Windows Update) so that all updates are centralized, and easy for the user to access, and the developers to take advantage of.

Finally they should improve the Add/Remove Programs files, so that when applications like Visual Studio is installed all the sub-packages are hidden beneath the top level as to simply the window. It might also be beneficial to separate applications into just the Click Once ones they installed, and the applications which are installed globally.

Website Reorganisation

So i have decided to annoy everyone by breaking all my permalinks and moving everything around. Here’s the new layout of the sub domains:

  • www – A page about me covering everything i do
  • blog  The new home of my blog
  • projects – Where all my projects resources will be hosted
  • repos – Where all my repositories will be hosted
  • yusu – Where my YUSU Reform Wiki is hosted

I have also set myself up a new better Open ID Server with 1.1 and 2.0 support called Simple ID.

I have also decided to put everything into Git Repositories and am currently experimenting on how best to set these up on the server, if you can make any recommendations on how best to do that, please leave a comment about it.

I have modified the blog theme a bit to make it more to my liking, i hope you all like it as well.

I suspect it will take me a while to get everything back up and running, but it should be really good once its done.

Digital Economy Bill #debill

There has been an over reaction to the bill. I understand how some people were annoyed at:

  1. How fast it was rushed through.
  2. The number of MPs who turned up to debate it.

For the first point, i fully agree, it was rushed through when it shouldn’t have been, a number of amendments could even be debated for this reason, and there are some slight issues that were raised in the debates about the bill, and i think this is going to lead to a number of amendments to it afterwards.

The second point is not valid, that’s the average number of people who turn up to debate a bill, sometimes its even less (yes i know I’m sad, but i watch a fair bit of BBC Parliament, its interesting honest 🙂 ) and 650 people debating the bill would have been overkill, it would have been overkill if 100 people had been debating it.

Now before i go any further lets just make this clear: Piracy is wrong, it is stealing, and that most users of sites like the pirate bay, are breaking the law.

Now i have pirated stuff before, sometimes in a legitimate reason, like when I’m repairing a laptop or pc for someone, they have valid license codes, but they no longer have the disks, i have to download them, and i think that while it is technically illegal, its a fair use in my opinion.

The other things i pirate are music and TV shows, and the odd movie, now my reasoning about this:

  1. There is not an affordable, convenient, preferably DRM free service that i can access. Yes there is Spotify and iTunes, but these have their issues. iTunes and its store are not affordable. Spotify is closer, you can pay for premium features, and to have adverts but it is streaming and doesn’t work so well with portable, and multiple devices. I have seen the Zune subscription and it is closer to what i want, but its not in UK
  2. Convenience and getting what i want. As a student in the UK i cannot get access to many American channels to watch American TV shows (not to mention the time zone issues), i also cannot download them, and why should i have to wait a year or so for the DVDs or even longer for them to be aired somewhere in the UK, what i want is a service that will let me download each episode as close to when it is aired as possible, for a reasonable price (maybe £1 for a 20-30 minute episode like the Simpsons, and more for longer episodes like CSI), if i could do this, i would.
  3. Non physical mediums, i do not want to have to buy a DVD, i don’t want the trailers, adverts, the special DVD extras, or copyright warnings, i just want the film, in a format that i can transfer across my many devices which can be used without a internet connection.
    If those services described existed, i wouldn’t pirate, i wouldn’t need to pirate, now while i suspect this is true for a number of pirates i would suspects that a fair number of pirates do it because they don’t want to pay for the content.
    Now lets get onto the serious issues in the bill that its opponents pick on. There is the “Clause 18” which allows with a Court Injunction to block a website, where it is begin used to infringe on copyright. People worry that this will be abused, but it requires consideration by a court (as far as i can understand from the rewritten clause, I’m not a lawyer), and the impact on legitimate users is to be taken into account. I think this part of the bill is reasonable, if you remove the sources of the illegal material, it makes it harder for people to pirate, if you remove the opportunity less people will do it.
    The other issue is the blocking people from the internet, in a 3 strikes type of law. People say this is unfair to people who don’t know what their kids do on the internet or don’t have properly protected wifi. There are ways of blocking P2P traffic, and as long as the first notifications of an infringement, include sources of information on how to do this, and i believe by the third letter, they will face more serious penalties, like having their connection restricted or even disconnected

I think this is fair, but only if they are treated as innocent, and a court finds them guilty before the measure takes place.

So yes i have a few minor objections but overall the bill generally makes good sense in my opinion.

On a side note, i saw a number of tweets this morning saying that that democracy had not been served, but in all honest there was not enough public action about the bill in its early stages, only in its final few days, also only 19,000 emails and letters sent to MP’s is not good enough, the top petitions on the goverments website get upto 200k+ supporters.

Hopefully the above post is fairly interesting and incite full, (i apologise for any grammar / spelling mistakes that i missed)