The GitHub iOS app

Wed 18, Mar 2020

The GitHub iOS app is finally available! It's pretty cool imo (and has multiple icons you can choose from!)

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4 Screenshot 5 Screenshot 6

New in PHP: str_contains

Mon 16, Mar 2020

RFC str_contains has been merged into PHP:

str_contains checks if a string is contained in another string and returns a boolean value (true/false) whether or not the string was found.

It's basically just a shorter way of writing strpos($haystack, $needle) !== false. It will be available in PHP 8.

Example (taken from the RFC page):

str_contains('abc', 'a'); // true
str_contains('abc', 'd'); // false

// $needle is an empty string
str_contains('abc', '');  // true
str_contains('', '');     // true

Sierra code snippets for VS Code and Sublime Text

Mon 16, Mar 2020

Hi!

I just created some code snippets for Sierra for use with VS Code and Sublime Text. You can get them from GitHub (sierra-project/ide-snippets).

There are only two snippets for now: ctrl and mdl. You already guessed it: the first one sets a new controller up and the second one sets a new model up. If you've got any improvements or more Sierra-related code snippets, drop me a PR.

Time Machine backups on regular SMB drive

Fri 13, Mar 2020

I just set up my Mac to save Time Machine backups to a regular SMB share. Doing this is actually quite easy:

Step 1: Create a .sparsebundle

Open Disk Utility and choose File => New Image => Blank Image.

Give the image a name and size (check the Time Machine settings first to see how large your backups will be).

IMPORTANT:

Now click Create.

Step 2: Copy the .sparsebundle to your server

Unmount the .sparsebundle by clicking the eject icon next to the image's name in the Finder sidebar. Now copy the .sparsebundle onto your server. You can now delete the original version from your Mac, just make sure that the copy is on your server.

Step 3: Configure Time Machine

Open up a new Terminal window and type

sudo tmutil setdestination "/Volumes/NameOfYourImage"

(replace NameOfYourImage with the name of your .sparsebundle image)


Congratulations, you're done! Now you can start a new backup in the Time Machine settings.

Git: Deleting the last pushed commit

Wed 11, Mar 2020

This is something I really gotta remember:

git push origin +abcd1234^:master

The above example deletes the commit abcd1234 (the newest one) on the branch master and pushes it to origin.

JSON responses, redirects and cookies in Sierra

Mon 09, Mar 2020

Just wanted to show you some cool new features in Sierra:

  1. JSON responses
  2. Redirect responses
  3. Cookies

JSON responses

Just create a new Sierra\HTTP\JSONResponse and pass it some data:

<?php
use Sierra\MVC\Controller;
use Sierra\HTTP\JSONResponse;

class Home extends Controller {

    public function index() {
        new JSONResponse(array(
            'hello' => 'world'
        ));
    }

}

Redirect responses

Redirecting a user has never been easier:

<?php
use Sierra\MVC\Controller;
use Sierra\HTTP\RedirectResponse;

class Home extends Controller {

    public function index() {
        # Will redirect the user to /new/target/
        new RedirectResponse('/new/target/');
    }

}

Constructing this class will also print some HTML containing a <meta http-equiv="refresh">.

Cookies

Cookies can now be set using $this->res->set_cookie() in controllers:

<?php
use Sierra\MVC\Controller;
use Sierra\HTTP\Cookie;

class Home extends Controller {

    public function index() {
        $this->res->set_cookie(new Cookie('name', 'value'));
        echo 'Cookie has been set!';
    }

}

Docs

Releasing my PHP framework

Fri 06, Mar 2020

Hi!

I've just released my PHP MVC framework on GitHub. It's a rewrite with a lot of newly added extensions of the framework I'm using on this and many other sites.

You can check it out at sierra-project/sierra. Feedback is highly appreciated! :)

Lazy loading images in Parsedown

Thu 13, Feb 2020

Parsedown is probably the most used Markdown engine for PHP (it also powers this site!). I wanted to integrate loading="lazy" into Parsedown, as it's now part of the HTML standard.

This is my approach:

class ParsedownLL extends Parsedown {

    protected function inlineImage($excerpt) {
        $image = parent::inlineImage($excerpt);

        if (!isset($image)) {
            return null;
        }

        $image['element']['attributes']['loading'] = 'lazy';

        return $image;
    }

}

Keep in mind to use ParsedownLL instead of Parsedown, but include both.

Native lazy loading is part of the HTML specification

Thu 13, Feb 2020

Loading images just as soon as they get into the viewport has been a thing for some time. It is used for performance reasons, as the page loads faster this way. There was no way to do this with plain HTML, though. Now there is! Chrome's loading attribute on <img> tags has made it into the HTML standard.

All you have to do to lazy load an image:

<img src="..." alt="..." loading="lazy">

Keep in mind that only a small number of browsers actually support this feature at the moment!

HTRoute v0.1.0

Sat 01, Feb 2020

Hi!

I'm very excited to release my Node.js HTTP routing library HTRoute (HyperTextRoute). Its goals are to be very easy to use and to provide very good routing functionality while mainting a small overall package size and absolutely amazing speed.

Examples and some docs are available in its GitHub repository. You can download it from npm by typing npm i htroute into your Terminal.

Feedback and bug reports are very appreciated! :)

You are on page 2 right now.


Back to top