Chris Worfolk's Blog


Best before dates

July 23rd, 2012 | Religion & Politics, Thoughts

In recent years, there has been a lot made of food waste, and some of this has been attributed to supermarkets putting very conservative “best before” dates on products that result in people throwing perfectly editable food away.

This might be down to a combination of supermarkets protecting themselves from lawsuits if anyone gets food poisoning, and encouraging people to throw food away early so they will buy more. But I don’t know, maybe they have some other reason. Maybe they genuinely believe their best before dates are appropriate. In any case, it’s not important to this post.

As a solution, why don’t we just ban supermarkets putting best before dates on things?

Surely that would solve the problem, forcing people to use their own common sense. You could argue that relying on common sense is an issue, but any common sense people are lacking is almost certainly down to the nanny state situation of having too many best before dates to rely on in the first place. But even if you consider that a problem, which I don’t think it is, it’s pretty easy to work out when bread is past its best.

I often find that, on some occasions, the law works very well as a blunt instrument. Remember when they banned smoking in pubs, and lots of people said there should be lots of complicated rules and exceptions, but instead they just banned everything, and now everyone is much happier because it worked really well? To be clear, I’m not being sarcastic there, that is actually what happened. Clamping is another good example.

Just tell producers they’re not allowed, people use their common sense and food stops getting wasted. Problem solved.

Olympic torch celebration

July 22nd, 2012 | Life

Last month, I went to Temple Newsam to see my mum perform at the Olympic torch celebration. The choir were fantastic, well done to everyone involved!

Getting in was a struggle. After the padding down and the cavity search you then have to have a long argument about whether the folding furniture you have brought counts as genuine folding furniture. No prizes for guessing who was sponsoring the event either…

Flood

July 21st, 2012 | Life, Photos

All the heavy rain last month caused the River Aire to just about reach its banks.

From my cold dead hands

July 20th, 2012 | Religion & Politics

Another month goes by, and, as usual, another senseless gun-related massacre occurs in the United States. Around 50 people in total were shot, 12 of them are already dead.

I was going to say “with another 12 people dead” but this would simply be nieve. Based on the statistical average, somewhere in the region of 33 people were gunned down across the United States today anyway. And yesterday. And there will be another 33 victims tomorrow.

Surely it is time to adopt a more progressive attitude towards guns? To be clear, by progressive attitude, I mean get rid of them all.

The sadistic irony of this video increases with every victim.

Loserville

July 20th, 2012 | Distractions, Life

Last month, we went to see the new musical Loserville, at the West Yorkshire Playhouse. While the play itself was very entertaining, I have to say that I’m really not comfortable about them making a musical about my life without offering me any royalties, or even asking my permission.

Install APD on CentOS 5

July 19th, 2012 | Life, Tech

Here is how to install APD (Advanced PHP Debugger) on CentOS 5. Lets start by creating a directory for it to log files to.

cd /tmp
mkdir apd
chown apache:apache apd

We need to remove ioncube, or it will cause errors.

rpm -e php-ioncube-loader

Now we can install APD, via PECL.

pecl install apd

Add the following to php.ini.

[apd]
zend_extension=/usr/lib64/php/modules/apd.so
apd.dumpdir=/tmp/apd
apd.statement_tracing=0

My PHP binary was in a different location, so I had to alter the script too.

cd /usr/bin/
vim pprofp

Change /usr/local/bin to /usr/bin and save the file.

You also need to ensure PEAR is in your include path (/usr/share/pear) for the script to work.

LESS & SASS

July 19th, 2012 | Limited, Programming, Tech

Still writing regular CSS? Pfft, you’re living in the dark ages! These days it’s all about two new technologies that are almost identical, so I’m going to discuss them in the same post.

The idea is dynamic stylesheets – bringing concepts we use every day in regular programming and implementing them in stylesheets to avoid duplication and make everything cleaner, nicer and more up to update with current paradigms.

So what can you do with these tools? Here is a quick overview…

Variables

Using a colour everywhere that you might want to change later? No worries, just save it as a variable and if you do need to change it at a later date, you just update the variable and it will be changed everywhere.

@myColour: #FFCC00;

.header { background: @myColour; }
.footer { background: @myColour; }

Mixins

Inheritance! What a sexy thing to have in CSS. No longer do you have to place loads of DOM references in lots of different places. Now you can just write it once and included it wherever else you need it.

.bigBorder { border: #FF99CC 10px solid; padding: 5px; }
.header { .bigBorder; background: @myColour; }
.footer { .bigBorder; background: @myColour; }

Nested rules

This one is a huge time saver! How many times have you had to reference half a dozen elements in one DOM reference? Probably very rarely, but certainly two or three tags is the every day reality. No longer though, because you can now nest your rules.

.header {
	.bigBorder
	
	a {
		font-size: 200%;
	}

In this example, the 200% font size will only apply to a tags inside .header, just as if you had done .header a in your DOM reference.

Operations

Want to make a header colour slightly darker? No worries, just add two colours together.

@mainColour: #FFCC00;

.header { background: @mainColour + #333333; }

But these are just a few of the features of these languages. They allow you to do a lot more – including things like full blown functions that you can pass parameters into, guards and much more.

The main difference between LESS and SASS is that LESS is a client-side JavaScript library (although has now been ported to Node) – you send the browser your .less file and include a JavaScript library that converts it. Meanwhile, SASS is a Ruby Gem that compiles a stylesheet to send to the client each time you edit your .sass file.

To find out more, visit the LESS and SASS websites.

Authority Forums relaunch

July 18th, 2012 | Limited, News

Authority Forums

I’m pleased to announce the relaunch of Authority Forums.

Founded in 2005, AF tracks the biggest message boards and forums on a particular topic. So, for example, if you wanted to find out what the biggest Futurama fan forum on the internet was, you would browse to Futurama where you can see each forum ranked according to size, with graphs and historical stats available too.

Over the past month the site has been re-built from the ground up to be faster and easier to use, the design has been overhauled so that it looks much pretty and all the content has been updated too – as you can imagine, over seven years a lot of forums close down and new ones open, so we’ve taken care of all of that.

Lithium

July 17th, 2012 | Programming

Recently, I’ve been re-developing Authority Forums and as part of the re-development, the site has been re-built from the ground up, using the Lithium framework.

Lithium, which bills itself as “the most RAD framework for PHP” is a spin-off from CakePHP. I’ve used the CakePHP framework for previous projects, and it’s an OK framework, but I didn’t find it to be something special. Neither did some of the core developers apparently, who left to start Lithium. It’s also contributed to by Richard McIntyre, who gave the talk on The Future of PHP that I blogged about last month.

It is an easy framework to get started with. I say that; it took me twenty minutes to work out that I needed to download both the Lithium and framework packages to get started. But once I had stopped missing the obvious, everything was up and running very smoothly.

In particular, creating models was very easy. All you do is create a class with the name of your database table and have it extend the Lithium base model. That’s it! You don’t have to tell Lithium what the content of the table is, it figures all of that out by itself and gets you up and running with a CRUD-supporting model immediately.

Of course, this isn’t always ideal for performance and security reasons, but you have significant customisation options that you can dig into to tweak things as you need them. Or, if Lithium just isn’t doing the trick to you, you can easily replace it with Doctrine, or any other ORM of your choice.

It also comes with a good range of built-in libraries. Perhaps not quite as comprehensive as Symfony2, but certainly easy to get started to and that just turn on and off as you wish – most are off by default but can be turned on my uncommenting a few lines. It also has ground-up support for MongoDB.

Deploying was easy too. Lithium automatically figures out whether the current install is dev, test or production and adjusts everything appropriately, so all you do is enter the connection details for databases on each environment and Lithium intelligently figures out which ones to use without you having to tell it, removing the need for slightly different code or a non-writable configuration file.

That said, deployment wasn’t quite as smooth as it could have been, and resulted in a bit of last minute panic. Lithium’s major weakness right now is the lack of community support and documentation. The documentation they provide is fairly good, but unless you’re doing exactly what the example is showing you will run into problems.

I would say I spent more time digging around the API documentation than I did the manual. This isn’t the case with Symfony2 (though I’m not a fan of the Symfony2 documentation either), so if you’re not comfortable doing this, it’s a tough framework to work with. More importantly, though, there just doesn’t seem to be other users doing real-world stuff, and so on several occasions, I had to find myself guessing at how to use functionality.

A good example of this is how to filter a query based on a range. It is easy to do a “I need this column to equal this” for example, but what happens when you want to do “I need this column to be greater than this.” In the end I guessed you could supply a sub-array with the value and the operator – and it turns out you can! But I couldn’t find any documentation for this, even though the functionality clearly is there. What they really need is a user forum (and users! It could just be on Stack Overflow like every other piece of knowledge you ever need).

Overall, I’m really enjoying using the Lithium framework. Its lack of user community is a massive drawback, but wider adoption will solve that and it should be more widely adopted because it’s a great framework.

My kingdom for an internet connection

July 16th, 2012 | Life

It’s been over four months since we moved into our new apartment and we still don’t have our own internet connection.

Having originally placed our order with o2, they failed to turn up to install the phone line and then insisted that they had turned up, even though Norm was there, with his phone turned up and got neither a knock on the door nor a phone call, we cancelled with them and re-ordered with BT.

This meant waiting another four weeks for an appointment, but when the time came George managed to book a day of work to sort everything out. But BT never turned up.

I phoned them to ask what was happening. They said they would go away and investigate and phone me back. Five minutes later they did. They said that they didn’t have our address in their engineer’s database, so couldn’t turn up and had to wait 24 hours for the database to update before they could say when they could come.

That is one of the craziest things I have ever heard. But even if you find that credible, I then enquired why they hadn’t even notified us when they realised they couldn’t turn up. They said they had my number down incorrectly – this would be slightly more believable if it wasn’t for the case that they were telling me this after phoning me back! How exactly did they have my number down incorrectly if they’ve just called me on it?

They promised they would phone me back after 3pm the next day to arrange a new appointment.

At 2pm the next day, I got an email from our landlady asking if one of us could call her ASAP. I did, and she said a BT engineer was trying to get into our apartment. Obviously, having not been told he was coming, we weren’t home. I said it was OK to let him in, but by the time I had done that, he had already left.

I phoned BT to see what was going on, but having left me on hold for a few minutes to investigate they told me that the engineers’ reports don’t come in until 6pm so they didn’t know what was happening and promised they would ring me back the next day.

They didn’t phone me, so that afternoon I phoned them and had a long conversation about what was going on. By this point the issue was deemed so serious that I was transfered to someone based in the UK, who actually spoke fluent English.

He said that they simply couldn’t install a line if our address wasn’t in the Royal Mail database. So even though they had been to our property the day before to install the line, they couldn’t install the line because they didn’t believe that our property existed.

At this point, I decided on a new strategy. I told them that they had our address wrong. We actually lived in apartment 14 (actually, I tried 13 first but because of superstitious nonsense, there is no apartment 13), so they should install it to that property. I also explained that for unknown reasons apartment 14 would be labelled “303” on the door, even though it definitely was apartment 14. They updated their records and scheduled a new appointment in two weeks time.

The appointment arrived and the engineer turned up to install our line. After a frantic twenty minutes trying to find the housekeeper to let us into the comms room (we don’t have any contact details for her, so we have to phone the landlady, who phones the housekeeper), the engineer finally got access and began surveying the situation. It turned out the only way we could get it working was to use the existing network because the building had never given any consideration to people actually wanting a phone line (the alternative was to run a new line in, up the side of the building – that was my preference to avoid all this nonsense but it would inevitably incur other nonsense instead).

Ok, so we just need to work out how we’re plugged in at the moment. Easy enough? Not quite. The comms room has a series of 10 48-port switches, none of which had any labelling on. I’m sure you can do the maths but to be clear, that makes 480 ports, one of which was our apartment – but we had no idea which.

The engineer began investigating. With some further surprise restrictions now being enforced by the building management, we were now running into an extended appointment which the engineer said it would have to bill us extra for. We told him that if such a bill would be under £100 then we would pay it, otherwise he could get on his bike.

Luckily, the bill suddenly did come in at “under £100”, so by lunch time we had a phone line we were assured would soon be working. We had no phone to plug into it, so no way to verify said claim, but I’m sure BT wouldn’t let us down. Now just to order the actual internet…