Chris Worfolk's Blog


Foursquare

June 5th, 2012 | Tech, Thoughts

Recently, I stopped using Foursquare.

I really like the concept. Making every day life a little more fun. It’s good because it encourages you to go out and do new things – if only to get the Foursquare points, and anything that encourages people to go out and explore the big wide world is a positive.

However, I found it was just taking over a little too much. The first thing I would do when arriving at somewhere new to check in, and it was just taking too much time to log onto my phone all the time and check in somewhere. So I decided to go cold turkey and remove it from my phone.

How do they keep getting away with it?

June 4th, 2012 | Humanism, Religion & Politics

The May meeting of the Humanist Society of West Yorkshire saw Mike Granville speak to us on the topic of “The Vatican: How Do They Keep Getting Away With It?”

It was a chilling reminder of the amount of outrageous things the Catholic church have done and gotten away with over the centuries, from the the Papal states, to the complicity in Hitler’s Nazi Germany and constantly covering up child abuse.

This also struck a chord with Alistair McBay’s recent article in NSS Newsline who commented that a certain “non-resident octogenarian” named Rupert Murdock was recently hauled up in front of a government committee to answer claims about his organisation covering up people’s phones being hacked and described as not being fit to lead such an organisation.

Yet, when another non-resident head of a multinational organisation arrives in the UK, someone we know covered up child abuse claims against priests and even resisted their removal from the priesthood, he is welcomed with open arms on what was described as a state visit.

Google wants your memory

June 3rd, 2012 | Tech

By this point, most developers have realised that Firefox is a cludgey pile of crap that eats up all your memory, and made the switch to Chrome, those developer tools long since surpassed Firebug.

Recently though, I’ve been running out or memory a lot and I don’t think it’s accurate to say Chrome isn’t to blame. As it runs everything in different processes, it’s easy to miss how much memory it is eating up, but I found it using 620MB of memory with just four tabs open.

Activity Monitor

Of course having Netbeans eating up so much clearly isn’t helping either, but IDEs are always a bag of crap (Eclipse is worse, I miss Notepad++).

Disabled parking

June 2nd, 2012 | Photos

You have to be a bit of a dick to park in a disabled bay when you’re not disabled. The same thing applies to parking over two parking spaces. But parking over two disabled spaces – that takes a special kind of asshole.

Parking

Compiling ImageMagick from source on Debian

June 1st, 2012 | Life, Tech

There is an RPM available for ImageMagick on Debian, but it isn’t the most update to date, so if you need all the new features, you’ll need to compile and install it from source. Luckily, it’s very easy to do.

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd 
./configure
make
make install
make check

Doctors’ pensions

June 1st, 2012 | Religion & Politics, Thoughts

Recently, Nicola said this…

Wow doctors are selfish or stupid. The rising life expectancy and massive deficit means they need to work longer and get a reduction in pension.
£68,000 on top of probably huge savings isn’t too shabby, but they’re striking!

I really rather wish she hadn’t, because it lead to a huge amount of comments, some of which were nonsense and as such, I am now unable to sleep because people are wrong on the internet and I can’t just let that be.

I don’t really have a problem with the strikes. They’re not putting people at much risk and they have a right to strike if they want to. But I don’t think they should expect a great deal of public sympathy for their cause.

While Nicola quoted £68,000. The BBC News article I read put the figure at £58,000. But that is still a huge amount of money. To retire on! That is more money than I earn while I’m still working. That is more money than my mum earns having spent twenty years tirelessly working as a teacher at an inner city school – surely an equally noble profession?

Ashwin chipped in…

Seriously though, speak to other Doctors and Medical students, and find out just how hard and long (that’s what she said!) a Doctor works and then you’ll appreciate our perspective much more.

But I probably won’t. Why? Because we don’t live in a society where hard work equals more money. You want to know about hard work? Go to my friend Eric who works 60 hours at week scrubbing floors at McDonald’s for a pitance. I’m sure a lot of doctors do more hours than that. But with the average GP earning a six figure salary, do they do ten times more hours than that? Of course not, because that is more hours than exist.

Paul I think you’re grossly confusing Doctors with Footballers. Also, this may be news to you, but Doctors do have loans and mortgages to pay off!

Which is probably true, as doctors are probably the only people who can afford to get on the property ladder these days. The rest of us have to rent.

Moz adds some good points…

I think the difficulty in debates like this is the gross inequality that people see between salaries across the various sectors. At the end of the day there are people in each sector who work just as hard as each other and do very difficult jobs, but receive vastly different salaries/pensions. In the private sector (e.g. bankers) you get people earning obscene salaries doing non-specialist jobs that don’t even benefit society that much. In the health sector you have people also earning obscene salaries, but at least doing a highly-skilled job that greatly benefits society (I wouldn’t include dentists in this – how they demand the salaries they receive is beyond me). Whereas in academia you have people earning very little to do a very difficult highly-skilled job. As an academic, I don’t moan about not being paid enough (well not much at least). But tbh I would love to see other people who have easier jobs than me earning less than I do. Its selfish but it would make me feel a lot better and more valued. Overall I think there should be a salary/pension cap that applies to everyone including doctors. Afterall no one person can be *that* much value to society.

But this just reinforces the point that you’re not paid in proportion to how much work you do, it’s how much value you are to society. In Moz’s case, that isn’t that much value. Not because Moz doesn’t do important stuff, he does. But because it would be fairly easy to replace him, because lots of people would like an academic research drop, which drives wages down.

But the important point here is that we live in a free market economy where you enjoy a choice of careers. If you don’t think you’re getting a fair deal, go do something else. If people vote with their feet, the government will be forced to offer higher wages. But actually almost nobody does, because people are actually still quite happy with the sweet deal they get as a doctor, so the government can cut their pensions.

No they are different points. How about going to a cornershop and buy a packet of sweets worth 50p and offer 45p. It’s only 5p difference. But you’ll probably be told to bugger off. Principles at stake

No, there isn’t a principle here. If everyone turned round and said “I’m only paying 45p” any half intelligent businessman would drop their prices. Similarly, if they were constantly selling out at 50p, they would put their prices up to 55p. That is how supply and demand works.

If doctors aren’t happy with their pay they need to vote with their feet – don’t work for the NHS (you can practice privately in the UK), go work in a different country (you have the right to work in any other EU country and as a doctor will get a visa for almost any other country too) or change career entirely (why not become a banker, for example).

In the IT industry we offer some really high wages (though not as high as doctors, I might add) because you simply can’t get the staff. They’re like gold dust, there just aren’t enough of them. That drives up wages. We can get the doctors (say what you want about the shortage, we still have a world class healthcare system and the government is so confident in our ability to retain them it’s even slashing pensions), but if there is some point where we can’t, we will have to start offering more money and benefits.

Strikers always make out they are the victim. But you’re never a victim in the free market unless you choose to be.

PHP Namespaces and Exceptions

May 31st, 2012 | Programming

Recently, I was trying to catch an exception that was raised when someone entered an invalid date string. Every time I tried it however, it would continue to throw the standard Symfony2 error information, rather than executing my catch block.

try {
    $date = new \DateTime($str);
    return $this->setDateOfWork($date);
} catch (Exception $e) {
    return false;
}

After a good thirty minutes of being puzzled, we eventually worked out what it was – because we were working within a namespace, we needed to call the Exception object, which is after all just another object, from the global namespace.

try {
    $date = new \DateTime($str);
    return $this->setDateOfWork($date);
} catch (\Exception $e) {
    return false;
}

This applies to any other types of Exceptions you’re trying to catch too – make sure you’re in the correct namespace!

Essential Drupal modules

May 30th, 2012 | Limited, Programming, Tech

Drupal is a great PHP-based CMS (content management system), but its true power is only unleashed when you use the modules system. Out of the box, Drupal provides basic functionality for creating and publishing content with additional functionality that can be added by installing modules, you have a far more powerful system.

In fact, most of the core functionality of Drupal is provided via modules as well. Drupal ships with a series of “core” modules which, should you wish to, you can disable. So if you don’t want the menu system, search, taxonomy or the help system, you can turn all of these off.

Beyond that though, Drupal can be extended significantly thanks to its reach ecosystem of modules (or plugins if you will) that provide significantly more functionality than the core system ships with. While you’ll need to find the right modules to match your needs, there are several that are considered the staple diet of Drupal developers.

Chaos Tool Suite
It may not look like anything special to get started with, but CT Tools provides an expensive range of APIs and systems which make developing with Drupal easier. It’s a platform to use when developing your own modules but also serves as a dependency for many other modules.

Views
The most installed module of any on the Drupal website, and it’s easy to understand why. Views is an incredibly powerful module which allows you to create custom pages that do various tasks – such as listing out a content type, sorting things a certain way, creating archives and many other tasks.

Entity Reference
At some point you will probably want to reference one entity to another. For example, on the Know Leeds website we have places and we have restaurant reviews. For each restaurant review we write, we want that to be linked to a certain restaurant (a place), and we do this with Entity Reference.

Pathauto
If you think you’re getting an exciting Greek named module, think again – it’s just the words path and auto put together. But it’s still a very useful module as it automatically creates friendly URLs without you having to type something in.

By default, Drupal won’t create a node reference for an article, it will just use the ID. You can override this by typing in something like article-title, but Pathauto will do this automatically. It’s good to install this from the start as it allows you to set up patterns for articles, categories and other systems so that you have uniform URLs across your site.

CAPTCHA and reCAPTCHA
reCAPTCHA is a fantastic took that stops spam and helps translate books at the same time. Using these two modules you can add reCAPTCHA to your site to stop spam bots registering accounts.

Taxonomy menu
This allows you to build an automatic menu out of a taxonomy set. So if you have categories as part of your taxonomy and you want to create a menu that automatically lists each category, this module will do it.

Drupal basics in under five minutes

May 29th, 2012 | Limited, Programming, Tech

Drupal is probably the best PHP-based CMS (content management system) on the market today. However, because it has a somewhat steeper learning curve than other systems, where you can just install and start creating content, it is easy to get frustrated with it and give up.

However, a short amount of time getting your head round the basics should be enough to show you that Drupal has some really powerful features which make it a far better CMS than those that simply allow you to drop text into pages.

We used Drupal to build Know Leeds and it allowed us to quickly and easily put together a functional site that allowed the non-technical contributors to get to grips with the system.

Content types
Because most people are familiar with WordPress, I’m going to use that as a comparison throughout this article. If you’re not familiar with WordPress, don’t worry, because most, if not all of the terms used are generic concepts that you will be able to understand anyway.

In WordPress, you have two types of content – posts and pages. Posts are the bread and butter of what was traditionally a blogging only system. Pages, are similar, but are static and don’t go into the date-based archives.

In Drupal, you get to define your own content types. It comes pre-configured with an article (similar to a post) and static page content types, but where you go from there is up to you. There are two good examples of where we used this in Know Leeds.

Firstly, we added a content type for “Restaurant Review”. This is similar to the Article content type, but we wanted to add some additional fields to Restaurant Review that didn’t want to be in Article – a star rating and a categorisation of what type of food the restaurant served.

Secondly, we added a content type for “Place”. We offer listings of local bars, clubs and restaurants on the website and if you think about it, an entry for one of these is basically just a piece of content. But with different needs than an article – we need address, phone number, email address, etc. So we created a custom content type for that too.

Fields
As I discussed with our custom content types, we wanted to customise the field types on our content types. In WordPress there are a number of fields – title, body, published date, categories, etc. In Drupal, you have the same thing, but you can create your own fields and match them to each content type.

So for the Restaurant Review content type we added a star rating field. This allows the editor to enter a numeric value between one and five. We also added a Cuisine content type which allows them to pick what kind of food it is. This works just like the WordPress categories system, except we can have multiple types of categories and we can pick which content types they apply to!

Taxonomy
In WordPress, there are two types of taxonomy – categories and tags. In Drupal, surprisingly enough, you can define your own. As I’ve already discussed, we created a Cuisine taxonomy and added a list of different terms (or categories if you will) such as French, Italian and Steak House.

Drupal allows you to create as many different categorisation systems as you wish and apply them to the content types as appropriate. We only wanted Cuisine to apply to the Restaurant Review content type for example, but Category might apply to both Article and Restaurant Review.

Blocks
Units of content which can be placed somewhere in your layout are called Blocks. The nearest equivalent to this in WordPress is the “widgets” system where you can drop widgets in and out of the sidebar.

Drupal comes with some standard blocks such as user login and search form, and many of the modules you can add into Drupal will add some blocks too – adding the forum module will add an “active forum topics” block for example. Of course, you can create your own custom blocks too.

You can then define where these appear – first sidebar, second sidebar, footer, navigation menu, etc, by selecting their position from the blocks menu. You can even do this on a theme by theme basis – on one theme you may want the search form to go in a sidebar for example, in another theme you may want it to go at the top or bottom of the page.

Unlike the widgets system in WordPress though, everything is a block in Drupal! Even the main page content so for some reason if you wanted to make your footer text display in the centre of the page and your main content display in your sidebar – you’re just a couple of clicks away from that!

Menus
Menus probably need the least explaining of all – it allows you to create menus which people can navigate around the site with. It is worth noting though, that items don’t appear in the menu automatically – you have to request that a piece of content (usually a static page) is given a menu link when creating or editing that piece of content.

Of course, you can create as many different menus as you want, assign different content (or any other links you want to add!) to different menus, and have the menus display in different places around your layout using the blocks system.

Conclusion
I hope this has presented you with a quick introduction to the fundamental concepts of Drupal. It is far more customisable that most other popular content management systems and as such has a steeper learning curve, but far more flexibility once understood.

Accepting praise

May 28th, 2012 | Success & Productivity

Reading Toastmasters International magazine is always an interesting experience. Nobody is using the world cult, but it’s so self congratulatory that as Elina points out, if you replace the word Toastmasters with the word Jesus most of the articles read as if they were specifically written to evangelise Christianity, without further modification.

Among the stories about just how brilliant a decision it was for Lenny from Texas to join his local group, was an interesting article accepting praise and comments after giving a speech.

Like I’m sure many people do, I try to be modest when receiving feedback after a speech. People often come up to you and tell you how good it is, and I always point out where I went wrong or which bits I didn’t think had really worked out.

However, the article suggests that this in fact a little impolite. After all, they are offering genuine feedback about how good they thought it was, and you’re contradicting them. It suggests a much better way to handle such comments is simply with a smile and a thank you.