On Leaving Medium

by Liam Hammett · 6 minute read · #blogs

As you can see because you’re already on it, I have a new site that I’ll be posting blog content to at liamhammett.com!

My reason for this change was pretty simple; I want more control over my content.

Medium seems to be given a lot of shit lately, but it holds a special place in my heart for getting me interested in writing. Here I’m going to talk about some pros and cons with the platform that made me come to my decision to move away from it.

Read more…

A Look At PHP's isset()

by Liam Hammett · 9 minute read · #php

isset() is one of the most important tools at your disposal to validate data in PHP. Like the name implies, it is designed to verify if a variable given to it is set, returning a boolean value based on the result.

However, it has some quirks and behaviours that are very much worth knowing as they can easily catch out even experienced developers.

Let’s take a look through how it behaves and what’s so special about it. Even if you’re a veteran PHP developer, hopefully, you’ll pick up something new here.

Read more…

PHP Wishlist: Typing

by Liam Hammett · 10 minute read · #php #wishlist

PHP is a loosely typed language. It doesn’t care what types you throw around. Unless you want it to care.

The language has come a long way in the last several years to bring in a robust type system, allowing developers to enforce types in both function parameters and what a function’s return value is.

For everything else, there’s docblocks, ugly sanitisation and assertion code, and crossing your fingers to hope your function’s API holds up in practice.

Read more…

Supercharge GitHub.com with Browser Extensions

by Liam Hammett · 6 minute read · #github #browser-extensions

As a commercial software developer, my day-to-day work for the last several years has involved working on closed-source software on private GitLab and BitBucket repositories, but that doesn’t mean GitHub has become a stranger to me.

I still spend a good portion of each week on the GitHub website, both for hosting my own personal repositories and looking into open source projects’ code, issues and documentation.

GitHub’s user experience is already pretty great and has only been getting better and better since Microsoft purchased it last year. That said, there are still a few things that are a bit lacklustre and could be improved — but that’s where browser extensions come in!

Read more…

If Your Blog Doesn't Have an RSS Feed, Don't Have a Blog

by Liam Hammett · 2 minute read · #opinion #blogs

It’s becoming increasingly common lately that people I want to follow are rolling out their very own blog platforms, in an effort to move away from WordPress and centralised platforms like Medium.com.

That’s perfectly commendable, and it often has some fascinating results, but there’s one thing that I come across all the time that destroys people’s chance of me reading their newer content — no RSS feeds.

I use Feedly as my daily RSS reader, and it keeps me up-to-date with hundreds of blogs so I can skim over them and pick out the titles I do want to read. I don’t read every article that comes into it, but I still get to enjoy the content that I like from a variety of writers.

Read more…

Make Infinite Gmail Addresses For One Inbox

by Liam Hammett · 3 minute read · #productivity

Google’s Gmail allows people to get a free email account—but it seems that a lot of people aren’t aware that this gives you access to almost unlimited unique email addresses that will all point to the same inbox, just by making a couple of simple tweaks to it.

Here’s how you can make use of this yourself:

Read more…

My MacOS Shortcuts

by Liam Hammett · 6 minute read · #macos #productivity

I use shortcuts on my devices all the time. Shortcuts are great, they let you perform complex actions in a fraction of the time — time that adds up a lot over time when you’re using the device for 10 hours a day.

In this post, I’ll be going over some of the typical shortcuts I have set up and use on a daily basis, and some of the applications I use to get them working.

Popups & Modals

Read more…

Laravel Blade Helpers

by Liam Hammett · 3 minute read · #open-source #laravel

Laravel’s Blade templating engine offers a ton of convenient directives you can use to make your view files beautiful and abstract anything that may be too complex or verbose to live inside HTML. It even gives a really handy way to add your own custom directives using the Blade::directive(…) method.

However, the callback in custom directives only receives a single parameter - the raw string expression from the view file. It seems to be rare that developers actually parse the contents of the expression itself within the directive, opting instead to pass the entire expression as arguments to a helper function or a method on another class. For example:

BladeHelper::directive('uppercase', function($expression) {
    return "<?php echo strtoupper($expression); ?>";
});

Read more…

Black Friday 2018 Deals for Laravel Developers

by Liam Hammett · 6 minute read · #laravel

It’s that time of the year again, and over the next few days there will be some awesome deals in all sorts of areas - retail and tech especially. As a Laravel developer, there’s a lot of goodies to get your hands on for some insanely discounted prices!

Here I’ll try to sum up some of the great deals you might want to get your hands on.

Laravel Nova - 30% off

Read more…

Why I Prefer Discord Over Slack

by Liam Hammett · 8 minute read · #opinion #discord #slack #chat

I’ve used more than my fair share of chat apps and solutions in the past, for both personal and professional use. AIM, MSN, Skype, IRC, Pidgin, HipChat, and Mattermost — to name the few that I’ve used for at least a year.

But over the years, they’ve all mostly faded away with two standing at the forefront: Slack for professional use, and Discord for gaming and casual use.

I use both on a daily basis, but strongly prefer Discord out of these two options, for both general use and coding discussion. Here I’m going to explain why Discord is better.

Read more…

CSS Filter Utility Classes

by Liam Hammett · 4 minute read · #css

(Ab)using CSS variables to apply multiple filters with one utility

Note: This article has a CodePen demo with inline examples, check it out towards the end.

The filter property is a bit of an oddity when it comes to CSS.

Read more…

Catching an exit(); in PHP

by Liam Hammett · 1 minute read · #php

What do you do when something goes wrong in your PHP application? Probably throwing an exception, so it can be caught at a higher level and handled appropriately.

What happens when instead of throwing an exception, an exit(); is executed? Can you catch it?

Read more…

Bitmask Constant Arguments in PHP

by Liam Hammett · 6 minute read · #php

PHP has a handful of core functions that can accept boolean arguments in the form of constants that have a binary value.

These can be combined together in a single function argument, essentially passing multiple boolean flags in a very compact manner.

They work a bit differently to how most people implement options in their userland functions, so let’s take a look at how they work.

Read more…

Throttle Simultaneous API Requests with Laravel

by Liam Hammett · 2 minute read · #open-source #php #laravel

Laravel comes with a handy ThrottleRequests middleware out-of-the-box that blocks users of an API from being able to send more than a particular amount of requests within a defined amount of time.

This is extremely useful for preventing an API from being abused by spammed requests, but isn’t suitable for every use case.

What about an API call that takes a lot of limited processing power, or performs an action that simply can’t be running twice at the same time?

Read more…

Laravel Set .env File Variable

by Liam Hammett · 2 minute read · #open-source #php #laravel

Use Operator on Any Website

by Liam Hammett · 3 minute read · #typography #css

Operator is a beautiful monospaced typeface that took the world by storm as it proved that coding typefaces can be both elegant and functional.

One way it helped stand out from the crowd is how certain italic glyphs take inspiration from script typefaces, making them distinct from the ordinary characters.

Improve it again by adding coding ligatures to it with Operator Mono Lig and you’ve got one swish font to code in!

Read more…

PHP Shareable Social Media Links

by Liam Hammett · 2 minute read · #open-source #php

I recently had the need to generate various “shareable” links to help share a particular URL to different social media platforms. The problem is that every platform requires information in a slightly different way.

Lo and behold, just a few days later, Dennis Smink shared their method of doing so in their article “Laravel Shareable Trait” that covers the few biggest platforms.

Read more…

Cenafy For Bash

by Liam Hammett · 2 minute read · #open-source #bash

Based on the wonderful Chrome extension of the same name that lets you know who the champ is, this is a version for Bash that lets an unsuspecting victim who left their terminal open know about the champ via the magic of ASCII art (and even some killer singing, if they have the say command like on Mac OS).

You can install it as a command with wget:

Read more…

Lua Collections

by Liam Hammett · 2 minute read · #open-source #lua

When working on Lua code bases, I frequently find that the code gets more difficult to read as the project gets more complex, partially due to how almost everything in Lua is an iterable table which allows for some extremely powerful functionality.

Introducing Lua Collections.

Read more…