Yes, PHP is like that

12 Jun 2016

I think it was Rasmus Lerdorf who once quipped PHP is like English. I can’t find the exact quotation, but it went something like “Yeah, PHP has quirks and isn’t the most elegant, but it’s simple overall and easy to get started. Look at English. Full of exceptions! But having a lot of exceptions and grammatical inconsistencies didn’t prevent English from becoming the dominant natural language.”

The analogy stuck with me. Like PHP, English is a relentlessly pragmatic language that’s relatively simple with a ton of gotchas.

From What do non-native English speakers think of the English language?

Root is no longer all powerful

7 May 2016

Basically, root is no longer all powerful – there are some things even root account cannot do! Official name is “System Integrity Protection” I’m writing all this down so next time I run into the problem and start googling, I’ll find my own notes.

I was trying to rename / remove the previous version of php

  sudo mv /usr/bin/php /usr/bin/php55

This failed with the error “Operation not permitted”

When I try ls -lO /usr/bin/php I get:

  -rwxr-xr-x 1 root wheel restricted,compressed 10577504 3 Dec 06:35 /usr/bin/php

restricted is a new flag for El Capitan. Basically Apple has added a whole new layer of security in OS X. They have taken away some privileges from root. If a file has a restricted flag, only restricted processes which are signed by Apple will be able to modify them. However, you can disable this security system by booting in recovery mode and disabling it in a Terminal by running the command:

  csrutil disable

And for all the exciting details:

Pigeon Contamination Plan

1 Apr 2016

I have been reading Double Cross: The True Story of The D-Day Spies by Ben Macintyre and the thing I am going to remember the best is … The Pigeon Contamination Plan

Flight Lieutenant Walker was head of ‘The Pigeon Service Special Section, B3C’, charged with disrupting the enemy’s use of pigeons, and deploying Allied pigeons for passing on secret intelligence.

Walker was convinced that Nazi pigeons were now pouring into Britain, by parachute, high-speed motor launch and by U-boat, providing enemy spies in Britain with an undetectable method of sending information to occupied Europe.

Read More

Screenshots in Firefox

9 Mar 2015

I have only recently learnt about this – it’s a nice trick available from the Firefox Developer Toolbar

The Developer Toolbar is NOT the same as the Web Developer menus – it’s a command-line which gives you access to a number of developer options from within Firefox.

Press SHIFT+F2 to open the Developer Toolbar.

Once the toolbar is open, you can tell Firefox to take a screenshot of the current viewport with this command:

    screenshot homepage.png

You can pass an additional argument to get a screenshot of the entire page:

    screenshot homepage.png --fullpage

All images are saved to the browser’s default download directory.

The Wind Rises – a film about work

11 Nov 2014


wind also rises

This animated film is a tribute to Jiro Horikoshi, who designed the Zero fighter plane used in the second world war. (I’m assuming that tribute means you don’t have to worry too much about historical accuracy). It ends before Pearl Habour, but there are some flash-forwards and we the audience all know how it ends, but this film isn’t about the glories or the horrors of war.

It’s about aeroplanes, and learning things, and being in love with your work, and the joys of making something beautiful. There is a romantic love story (the love interest has consumption and dies beautifully and it’s all very heart-breaking), but it’s really not the heart and soul of the film. The heart and soul is work. There aren’t enough films about work and what people do all day.

Also we have the immortal line “Gentlemen, behold the miracle that is extruded aluminium”.

However, there is one change I’d like to make: in the film Horikoshi is in love with aeroplanes from childhood onwards; in real life Horikoshi studied aeronautical engineering because it seemed like a good idea at the time (I paraphrase slightly from wikipedia), and I’d really have liked to have seen this happen in the film.

Very few adolescents have any idea what they want to do in life, and having a career advisor or a motivational speaker tell you to “do what you love” is really not helpful at all. I’m much more about the “do something, get good at it, love it”.

It’s not how programmers are normally portrayed

11 Sep 2014


One 2013 study of Indian engineering students asked whether they ever felt left out in an academic setting. About 8 percent of female engineers reported such feelings, while almost 20 percent of male engineers sometimes felt left out.

In another study [of Indian engineering students] female students described the culture of computing as one that prizes meticulousness, intelligence, sociability, and mutual assistance.

A culture of computing which prizes sociability, and mutual assistance. Oh.

PHP – This is not a bug, it’s a feature

11 Jun 2014

Type-juggling can go so wrong. Try this:

echo in_array(0, array('foobar')) ? 'true' : 'false' ;

It will output true, which seems so very very wrong. PHP indeed tries to convert ‘foobar’ to a number, and because that is not really possible, it becomes 0. So in_array returns true.

$array = array('1','2');
echo in_array( 0, $array ) ? 'true ' : 'false ' ; // false
echo in_array( '0', $array ) ? 'true ' : 'false ' ; // false

$array = array('this is a string);
echo in_array( 0, $array ) ? 'true ' : 'false ' ; // true
echo in_array( '0', $array ) ? 'true ' : 'false ' ; // false

$array = array(1,2,'string');
echo in_array( 0, $array ) ? 'true ' : 'false ' ; // true
echo in_array( '0', $array ) ? 'true ' : 'false ' ; // false


Smartwatch Prototype – 1981

11 Apr 2014


This image was designed by Robert Tinney, an artist who designed many magazine covers for Byte back in its prime. A “master of the airbrush”, his work helped give the sci/tech magazine some of its voice in the 70s and 80s.

This particular cover was designed for the April 1981 issue (April Fools) and was a tongue-in-cheek look at the future of computers.

A copy can be bought from Robert Tinney’s website

Securing phpMyAdmin

30 Apr 2013


I run phpMyAdmin for a number of websites and (thanks StackOverflow), this is my check list for phpMyAdmin Security.

What gets done depends a lot on the client’s webhost and how much control I have, but this is a short list of things which can be done.

  1. Change the folder location
    I’ve changed the application folder the obvious ones such as phpMyAdmin or pma to something a little less predictable; databaseliveshere or folder name of your choice.
  2. Passwords
    This is rather duh, but no harm in stating the obvious. Secure passwords which are proof against a brute-force attack
  3. Limit Access by IP Address
    This depends on how many people are accessing phpMyAdmin, and whether everyone has a static IP address, but I like to setup .htaccess so it restricts access to a subset of IP addresses.
    <limit GET> 
        order deny,allow 
        deny from all 
        allow from 
  4. Root shouldn’t have access to phpMyAdmin
    I edit the config file for phpMyAdmin and set AllowRoot to false
  5. HTTPS
    I set up a self-signed security certificate so I can access phpMyAdmin via https. This way the login and password can’t be leaked to an attacker.

Banned Words

5 Feb 2013

I've been working at a small software company recently, where the customer support team is three young guys who spend a lot of time of the phone.

I was really tickled to find this list of BANNED words, and had to ask for an explanation.

  • Mate
    It's a little too friendly. A lot of our customers are over sixty and they don't want to be matey with some young guy on the phone.
  • Bug
    We don't have bugs. Sometimes we have undocumented features, or unexpected outcomes. And sometimes we have to say "We'll get the developer to have a look at that" but we don't have any bugs. Bugs worry people.
  • Colleague
    Customer support are not allowed to say "I'll refer that to my colleague" because it makes us sound like some enormous heartless call centre in Swindon. We're small, and we want to make a feature out of being small and personal. So the support guys don't "refer the matter to a colleague"; instead they say "I'll ask Wes (or whoever) to take a look at this"
  • Obviously
    As soon as you say "Well, obviously..." you make people feel stupid. Obviously.