Chris Worfolk's Blog


That golden Eurovision moment

June 7th, 2016 | Distractions

eurovision-2016-scoreboard

Remember that for a short few minutes during Eurovision 2016, the UK was on the left-hand side of the scoreboard.

SAL May 2016

June 7th, 2016 | Humanism, Video

The May 2016 Sunday Assembly Leeds had a theme of “friendship”. The Assembly Line performed two songs, I’ll Be There For You by The Rembrandts and With a Little Help From My Friends by The Beatles.

I’ll Be There For You

With a Little Help Frm My Friends

Combining arrays in PHP

June 6th, 2016 | Programming

html-code

If you need to combine two arrays in PHP, you first thought might be to use the + operator. However, this is unlikely to do what you want it to to. If we look at the following example, you might expect it to output an array with all three elements.

<?php

$listA = ['banana'];
$listB = ['apple', 'pear'];
$listC = $listA + $listB;

var_dump($listC);

However, what you will actually get back is an array containing two elements: banana and pear. This is because when you use the + operator in PHP it combines it using array keys. Even though these are non-indexed arrays, PHP looks at them like this:

[0 => 'banana']
[0 => 'apple', 1 => 'pear']

Therefore when you add them together, it combines the keys, taking the earliest. In this case, to get the result you want, you want to use the array_merge function. For other scenarios, PHP has a range of different functions to combine arrays in different ways.

Word Search, a PHP library

June 5th, 2016 | News, Programming

Have you ever been working on a PHP project and found yourself thinking “what I really need is a way to quickly and easily drop a word search in to this code”? The answer is almost certainly, no.

However, while working on Learn Finnish I found myself in exactly this situation. Being unable to find a good library, I wrote one and published it on GitHub. It is freely available under the MIT license and registered with Composer:

composer require xmeltrut/WordSearch "^1.0"

All you have to do is pass in some words and it will generate a puzzle. It supports horizontal and vertical words, intersecting words and comes with two alphabets by default: English and Finnish.

If you’re feeling generous, head over to GitHub and star it.

word-search

Autoprefixer

June 4th, 2016 | Programming

html-code

Web browsers come in various shapes and sizes: different users will have different ones, and inevitably different versions of the same one. When CSS3 arrived browsers began adding support for it before the specification had been finalised and so used vendor prefixes.

The result, now we have a standardised CSS3, is that some users have proper CSS3 support and some have the support, but only behind a complicated series of vendor names. Therefore, if you want to use flexbox for example, you cannot just rely on display: fiex; as for some users it will only work with the appropriate vendor prefix.

This means you have to tediously insert all of these vendor prefix statements to get cross-browser compatibility. However, there is a tool called Autoprefixer that takes this hassle away. It is an NPM module that converts your regular CSS into CSS with vendor prefixes. You write:

display: flex;

And you get:

display: -webkit-flex;
display: -ms-flexbox;
display: flex;

This means you have to compile your CSS. However, if you are already compiling from LESS or SASS, it’s really easy to integrate it. On one of my current projects I already had Gulp compiling SASS, so it was one-liner to add the step in. SitePoint have a tutorial on how to set it up.

Harrogate pubs

June 3rd, 2016 | Friends

A few years ago, while I was working up in Harrogate, my friend Alan and I refined the art of pub lunch. At Buzz, Jason and I achieved pub week, which was no mean feet. However, we could only dream of the system Alan and I put in place. Sometimes with other colleagues, sometimes not, we got it down to a schedule.

Day Pub Notes
Monday Smiths Arms Nice way to start the week. Food was okay. Mostly, it was close.
Tuesday Squinting Cat Quiet, plenty of tables, big range of food and the barman was a character.
Wednesday Black Swan, Fat Badger Usally Black Swan, but occasionally we would drive into the centre for the Fat Badger.
Thursday Old Spring Well, Pine Martin Good specials, though roadworks severely hampered our journey times, in which case we would fall back to the Pine Martin.
Friday Square & Compass Bit of a drive to North Rigton, but worth it for the food.

This went on for months. We managed two team lunches in my current team this week. That was great, but I can only dream of the glory days…

old-spring-well

Mary Berry’s Absolute Favourites

June 2nd, 2016 | Books, Food

Absolute Favourites is 2015 cookbook by Mary Berry. It ties in to a TV show that I haven’t seen.

One of the things that Elina always comments on is how practical Mary is, especially in comparison to Paul Hollywood. Hollywood will insists on all kinds of different kitchen implements, whereas Mary will usually find a way to re-use the same bowl. This shines through in the book. Most of the recipes have a “you can do this bit in advance” or “make this and freeze it for later” section.

I was very much amused by comments such as “teenagers will love this”. It is organised by meal time and does classic dishes: steak with peppercorn sauce, meatballs in tomato sauce, fish pie. It still feels contemporary though: chilli burgers, sticky chicken and tapas all put in an appearance. The dishes are easy to make too.

Where perhaps it falls down in our kitchen is that perhaps the quintessentially English dishes are just a little bit boring. I felt like I was going easy on myself when I picked one of these up. The food does not suffer because of it though: everything we did was reasonably tasty or better.

My two favourite dishes were the lentil shepherd’s pie, a great alternative if you want to cut down on your meat intake, and the fish pie (shown below).

fish-pie

This is a super recipe that uses chunks of bread as croutons that you sit on top and toast slightly, revealing a sea of fish pie underneath.

This isn’t the most adventurous cookbook I have had but it has a lot going for it: the recipes are simple, easy to get right, have scope for pre-paring many of them and produce lovely results. Well worth investing in if you want to cook some English.

mary-berry-absolute-favourites

Warehouse of Gifts

June 1st, 2016 | Public Speaking, Video

Two days after I delivered Speak from the Heart at Leeds City, I delivered a speech called “Warehouse of Gifts” at Asselby Speakers. It was another speech I had written to try and develop my personal stories and improve the emotion in my speeches.

I did not go there with high hopes. The speech was rough, the idea was clichéd, and I was doing the whole thing in a Finland hockey jersey. However, it actually went a lot better than the other one did. People liked it.

Asselby Speakers is a great place to take a speech. It is an advanced club, only open to Competent Communicators. The result is that you get unparalleled feedback. Speeches that regular clubs fail to give any suggestions, Asselby will give you an A4 page full, which is what you want at this level.

Speak from the Heart

May 31st, 2016 | Public Speaking, Video

Recently, I’ve been working on including more personal stories and emotion in my speeches. Some have gone better than others. This speech, for example, was a failure. Sort of.

Feedback was very positive. One of our members stopped me in the bathroom to tell me that he had never written a feedback slip before, but had tonight, because my speech was “perfect”. In fact, all the feedback slips were positive, which is frustrating because you can’t improve when nobody call tell you what was wrong. This was extra frustrating, because I failed to win best speaker.

Looking back at the video though, I can see why it wasn’t a winner. It doesn’t have the emotion in that I wanted it to have. I just didn’t express it. In fact, I think my trademark humour, as everyone refers to it, probably detracted from the speech because it took the edge off the emotion, and maybe I shouldn’t have done that.

Travis CI

May 30th, 2016 | Programming, Tech

travis-ci

Travis CI is a cloud-based continuous integration tool. Notably, it is also free for open source projects. They do paid subscriptions as well if there is a private repo you want to test. If you just want to test a public GitHub project though, it’s free and really easy to set up.

You can log in with your GitHub account. Once you have done this, you are given a list of your projects and you can turn on Travis CI for each one individually. Using the GitHub hook, you can configure Travis CI to automatically run a build every time code is pushed to the repo.

It supports an array of different languages and platforms. To get up-and-running, you need to add a config file into your repo. This is pretty simple. Here one I am using for a PHP project:

language: php

php:
– ‘5.5’
– ‘5.6’
– ‘7.0’

install: composer install

This configures it to run it on three different versions of PHP, and install the dependencies before starting the test. It comes with many of the common PHP extensions already enabled, and an additional list of ones you can enable if you need them.