Chris Worfolk's Blog


Vitamin D supplements

November 16th, 2020 | Health & Wellbeing

Typically, we only want to supplement when we cannot build a diet that provides enough nutrients. But, in the case of vitamin D, we get it mostly from exposing our skin to the sun, rather than from food, so it is difficult to get additional vitamin D from your diet.

Given that many of us do not get outside enough in normal times and that we’re all inside because of the pandemic and lockdowns, vitamin D deficiency is probably pretty common right now, And there is some evidence that it is a good idea to supplement. So, I thought I would give it a go.

Labelling can often be a little confusing, but a typical adult intake should be around 600 IU (international units) which is 15 µg (micrograms). However, we can safely tolerate up to 4,000 UI (100 µg).

I picked up some vitamin D gummies from Boots. These contain 25 µg per gummy so one per day should provide plenty of vitamin D (and I will still get some from going outside, and a little through diet) and yet be safely within the tolerable limit.

I probably won’t let you know how I get one because I’m not expecting a vitamin D gummy per day to make any noticeable changes. If I don’t report back, assume it went fine (or I’ve exploded).

Yoga teacher training

November 15th, 2020 | Life

I was planning to do yoga teacher training with my local studio. Unfortunately, I held off to see what was happening with COVID as I didn’t really want to do it online, and by the time lockdown ended the course was full. So, I enrolled with the Yoga and Ayurveda Center which was online, but so affordable that I thought if it’s rubbish, I can just do the training with my local studio and I haven’t lost much.

As it happens, the course was great.

They have spent the money in the right places. The video quality isn’t perfected or edited down to a T. But there are about ten hours of contact time with tutors every week. And I would much rather interact, learn and practice teach over Zoom than have fancy transitions and perfect lighting in the video lectures.

In fact, there was so much contact time that I could often pick and choose what type of class I wanted to attend. With the lunch time ones (early morning in the US) I often had one-to-one attention with the tutor, or if I wanted a larger group to practice teach to, I could go to the evening groups.

Steph and her team have put together an excellent programme and it was wonderful to be a part of it.

Anxiety Leeds online trial

November 12th, 2020 | Foundation

Anxiety Leeds has been running face-to-face groups since 2013. However, as we are based at the hospital, our meetings have been suspended since the pandemic arrived to ensure we keep both our clients and vulnerable hospital patients safe (from COVID, not from mental health problems, unfortunately).

So far, we have been referring people to other organisations who are better equipped to handle digital events and services. However, due to high demand, we are now trialling on an online community that allows attendees of Anxiety Leeds to interact digitally, hopefully providing the same level of warmth and support we were able to achieve in the group.

Run coaching

October 29th, 2020 | Sport

I have been coaching triathlon for a while now, but recently I started coaching with the run club, too. The key thing is to remember to take the group photo. Keeping runners alive and injury-free is great, too, once you’ve got the photo.

Upgrading LAC to Slim 4

October 28th, 2020 | Programming

Last month, I published an upgrade guide to Slim 4 covering the changes that most people will need to make.

I recently upgraded the Leeds Anxiety Clinic and this project has some further complexities, so this post will elaborate on all of the changes I made, in case my original blog post did not cover some of the issues that you are also running into.

Things to do in advance

The old service layer calls no longer work:

$db = $this->ci->db;

And need to be updated to:

$db = $this->ci->get('db');

However, Slim 3’s service container already supports this syntax, so you can go ahead and update your code in advance.

If you are passing the container into controller functions, you need to typecast it.

use Psr\Container\ContainerInterface;

class Controller {
    __construct(ContainerInterface $ci) {}
}

If you pull the request out from the service container, you cannot do that in Slim 4. For example, if you have a render helper that relies on the request being in the container, you will have to start manually passing that into your render help from the page route closure.

Dependencies

You will want all of these:

"slim/slim": "4.*",
"slim/psr7": "1.*",
"slim/http": "1.*",
"php-di/php-di": "^6.1",

I did wonder if I could remove my other PSR-7 library that I use for Mailgun, nyholm/psr7, but the answer is no.

Instanciating the app

We now create the container and then the app, and you can recursively pass in the container.

$container = new \DI\Container;

$container->set('serviceA', function() use ($container) {
    return new ServiceA($container->get('serviceB'));
});

\Slim\Factory\AppFactory::setContainer($container);
$app = \Slim\Factory\AppFactory::create();

Throwing not found exceptions

If you manually throw not found exceptions or other HTTP exceptions, Slim 3 has them located here:

Slim\Exception\NotFoundException

Slim 4 moves it to here:

Slim\Exception\HttpNotFoundException

Error handling

If you want Slim 4’s default error handling, you need:

$errorMiddleware = $app->addErrorMiddleware(true, true, true);

And if you want to handle HTTP errors (such as not found), you can use:

$errorMiddleware->setErrorHandler(
    Slim\Exception\HttpNotFoundException::class,
    function (Psr\Http\Message\ServerRequestInterface $request) use ($container) {
        $controller = new App\Controller\ExceptionController($container);
        return $controller->notFound($request);
    });

You can also set your own error handling:

$errorMiddleware->setDefaultErrorHandler(
        function (Psr\Http\Message\ServerRequestInterface $request,
        Throwable $exception) use ($container) {
            $controller = new App\Controller\ExceptionController($container);
            return $controller->error($request, $exception);
        });

This means you will need to create your own response object in any exception controller you use.

public function notFound(Request $request)
{
    $response = new \Slim\Psr7\Response;
    return $this->render($response, 'not-found.html');
}

Custom middleware

The way we pass through middleware has changed. The old way:

public function __invoke($request, $response, $next)
{
    $response = $next($request, $response);
    return $response;
}

The new way:

public function __invoke($request, $handler)
{
    return $handler->handle($request);
}

That change alone probably won’t do what you want it to do out-of-the-box, so you might need to do some reading up and adapt it to your specific middleware depending on function.

Custom middleware wants to go towards the bottom after you define your routes, but before the error middleware.

Birthday meal

October 27th, 2020 | Life

This may be the only meal we have inside a restaurant in 2020, but having a voucher to spend before it expires (or all the restaurants go bust), we decided to brave it and have a birthday meal for two at Gaucho. There was a slight mix up and we ended up with a cake with “happy anniversary” written on it, but it still tasted good! :D.

Best winter cycling socks

October 20th, 2020 | Reviews, Video

How do you keep your feet warm during winter cycling? In this video, I will compare regular socks with the Pactimo wool winter socks and Rapha winter socks, as well as discussing what else I do to keep my feet warm when the temperature gets down towards zero.

Mavic Crossmax cycling shoes review

October 19th, 2020 | Reviews, Video

The Mavic Crossmax SL Pro Thermo shoe is a winter cycling boot. It supports SPD (mountain bike) cleats but Mavic also produces a road version named Ksyrium Pro Thermo that supports SPD-SL cleats.

My hands and feet get very cold on the bike so I have been on a long quest to work out how to keep them warm. These shoes are the closest I have come so far. They do an excellent job of keeping the wind and rain out so when coupled some winter socks your feet should stay toasty.

They have a lot of fastenings. There is a zip along the front and velcro around the ankle. You can tighten it using a boa dial. Once you have the boots on, you can ignore the zip and velcro and just tighten using the dial. My socks do sometimes get caught in the velcro when putting them on.

They are reasonably light. I measured one shoe at 582 grams, which is only 10 grams more than my summer Mavic shoes. That said, my summer Mavic shoes (573 grams) are heavy compared to non-cycling shoes or even my Shimano triathlon bike shoes which come in at around 350 grams each. For a boot, they feel pretty reasonable.

I am a size 11 in a running shoe and I go for an 11.5 when I buy Mavic. That said, they are generously sized, allowing me to get my big socks in them, so I could probably have gone with an 11 as well. They are pricy, so it depends on how much you value warm feet.

Roka Pro Swim pull buoy review

October 18th, 2020 | Reviews, Video

A pull buoy is designed to keep your legs floating while doing swim drills so that you can work on improving your arm stroke. In this video, I will review the Roka Pro Swim pull buoy.

What can I say? It’s a pull buoy. It is a good size: maybe slightly larger than the typical pull buoy you get at a pool but not so big that it will not fit in your bag. It has good buoyancy and allowed me to get into my stroke on pull drills. It is symmetrical so you cannot adjust the buoyancy based on its orientation but I never actually do that anyway.

Yoga Sutras of Patanjali

October 17th, 2020 | Books

The Yoga Sūtras of Patañjali is a religious text on the practice of yoga. By yoga, I am referring to the full definition of yoga in the Hindu tradition and not merely the asana practice that is popular in the West.

It is made up of 196 verses. I read the longer version that has been translated into English by Sri Swami Satchidananda who also provides extensive commentary on the verses. This was very helpful to understanding. The text is broken down into four books and his commentary on the first two books made them reasonably accessible whereas the second two books, where commentary is limited, were more challenging.

My favourite concept from the book is the idea that anger is a package that you have to accept delivery of. And if you choose not to accept the delivery, the sender is stuck with it. If only it was that simple in real life, of course, but certainly an attitude I would like to cultivate.