Sleeping – what I have learned

Time for a new episode of what I have learned! 🎬


Wanna be better? Sleep more 💤 During the last few years, I discovered that sleeping eight hours works best for me.
Focused more and much more productive I am 💪
I have tried sleeping less than six hours plus naps. It worked well till I missed the nap. Waking up was hard 😓
Monitoring your sleep is vital. Many researchers say that it is easiest to wake up in the REM, and I can confirm that ✅
That is why I switched recently from 7.5 to 8 hours. I missed the zone.
Now I can wake up and almost instantly jump into the action.


Sleep well 🙂

Improving the tests with try-finally block

This week I have learned a neat trick that you can apply to your test cases. You are testing an edge case. The system under test is expected to throw an exception. But, after the exception, you need to do a few assertions. Usually, I did it this way:

/**
 * @dataProvider markAsUndeliverableFailDataProvider
 */
public function testMarkAsUndeliverableFail(Order $order): void
{
    $exception = null;

    try {
        $order->markAsUndeliverable();
    } catch (\Throwable $exception) {
    }

    self::assertInstanceOf(OrderStatusChangeFailed::class, $exception);
    self::assertTrue($order->isAlreadySentToProduction());
}

But, there is a better way to do it! Check out the much more readable version with try-finally:

/**
 * @dataProvider markAsUndeliverableFailDataProvider
 */
public function testMarkAsUndeliverableFail(Order $order): void
{
    $this->expectException(OrderStatusChangeFailed::class);

    try {
        $order->markAsUndeliverable();
    } finally {
        self::assertTrue($order->isAlreadySentToProduction());
    }
}

Viola! Look how clean this is 🔥

Sytuacja w IT a COVID – przemyślenia

Cześć! Żyjemy już dość długo w świecie pandemicznym. Tym razem opiszę swoje przemyślenia o tym jak COVID wpłynął na branżę IT. W tym wpisie przedstawię moje obserwacje oraz przemyślenia w trzech etapach. Na końcu znajdziesz podsumowanie, gdzie subiektywnie podsumowuję całość.

Świat IT przed pandemią

Jeśli pracujesz/pracowałeś w IT to wiesz jak to było. Zdecydowana większość pracodawców nie zgadzała się na pracę zdalna. Czemu? Bo przecież pracownik w domu, zamiast pracować, będzie zajmować się wszystkim, byle nie pracą.

Continue reading Sytuacja w IT a COVID – przemyślenia

Wpływ silence operatora na error reporting w PHP

Hej, w dzisiejszym krótkim wpisie bierzemy na tapet słynny i jakże często używany operator @ tzw. STFU. Czy wiesz że jego użycie ma wpływ na error_reporting w PHP? Weźmy pod lupę ten przykład:

<?php declare(strict_types=1);

error_reporting(E_ALL);

set_error_handler(
    function () {
        // int(0) [PHP <= 7.4]
        // int(4437) [PHP >= 8.0]
        var_dump(error_reporting());
    },
    E_ALL
);

// int(32767) [E_ALL]
var_dump(error_reporting());

@trigger_error('warning', E_USER_WARNING);
Continue reading Wpływ silence operatora na error reporting w PHP

Moje dwa lata z Huel – subiektywna recenzja

Hej! Dzisiaj temat kompletnie niezwiązany z programowaniem, czy IT. W kwietniu 2021 minęło dokładnie dwa lata od kiedy pierwszy raz zamówiłem Huel. Produkt, który zmienił moje nawyki żywieniowe, i pozwolił mi prowadzić zdrowszy tryb życia. Postaram się opisać wszystkie swoje spostrzeżenia. Myślę, że przez ponad dwa poznałem produkt dobrze.

Continue reading Moje dwa lata z Huel – subiektywna recenzja