With the current trend of using microservices chances are that the majority of your projects either perform http calls, or use one or more packages that do so. And thus chances are that you are either using Guzzle or another http request library or abstraction, directly or via a package. This causes a hard dependency to this library and maybe even to multiple libraries. You might even run into the issue of being unable to use or upgrade a package due to a version mismatch. The [PHP-FIG][php-fig] was founded with the intent to handle these kind of situations. And with the introduction of [PSR-18][psr-18] the entire HTTP stack was "standardized" via PSR's; with [PSR-7][psr-7], [PSR-15][psr-15], [PSR-17][psr-17] and PSR-18 it is now possible to make completely framework agnostic packages and applications. And for us the introduction of PSR-18 came at the ideal moment as we were preparing to migrate from [Guzzle][guzzle] 5 to Guzzle 6. When we learned about
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<title>Tokenize</title> | |
<style> | |
span.token:hover { | |
background: powderblue; | |
} | |
pre { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mb_ucfirst($string) { | |
return mb_convert_case(mb_substr($string, 0, 1), MB_CASE_UPPER) . mb_substr($string, 1); | |
} | |
function mb_ucwords($string) { | |
return mb_convert_case($string, MB_CASE_TITLE); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
UPSTREAM="upstream" # Could come from env | |
CHANGED_FILES=`git diff --name-only --diff-filter=ACM HEAD $UPSTREAM/master --raw` | |
PHP_SOURCE_FILES="" | |
PHP_TEST_FILES="" | |
TWIG_FILES="" | |
for file in $CHANGED_FILES |
I typically find myself struggling when doing some more complex expectations using Prophecy. To make things easier for myself I decided to create this cheatsheet.
$ObjectProphecy->method(
'value'
);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
use PHPUnit\Framework\TestCase; | |
use Prophecy\Argument; | |
use Psr\Http\Client\ClientInterface; | |
use Psr\Http\Message\RequestInterface; | |
use Psr\Http\Message\ResponseInterface; | |
final class ApiKeyMiddlewareTest extends TestCase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In the current solution we have three separate interfaces. This allows for a clean separation of functionality: | |
interface QueryExecutorInterface | |
{ | |
public function execute(QueryInterface $query): array; | |
} | |
interface QueryMetadataServiceInterface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is very, very heavily inspired by the [video](https://www.youtube.com/watch?v=8OK8_tHeCIA) and | |
// [code](https://github.com/OneLoneCoder/videos/blob/master/OneLoneCoder_Tetris.cpp) of One Lonely Code. | |
// Big thanks to him. | |
import { stdout, stdin } from 'process'; | |
import { WriteStream } from 'tty'; | |
const keypress = require('keypress'); | |
class PlayingField { | |
private readonly width: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installing Unreal Tournament GOTY on MacOS Catalina and up | |
- Buy game on GoG via https://www.gog.com/game/unreal_tournament_goty | |
- Download archive set up - Not the download the GoG installer, but download the Unreal Tournament installer (302MB). | |
- Unpack with `innoextract` (`brew install innoextract`) - Move installer to folder first for scoping. | |
- Install [UnrealTournamentPatches](https://github.com/OldUnreal/UnrealTournamentPatches/releases) - don't forget to drag the executable to Applications | |
- In Finder, go to Applications, right click `UnrealTournament` and click `Show package contents` | |
- Inside the package contents navigate to `Contents` > `MacOS` | |
- Copy the folders `Maps`, `Music`, `Sounds` and `Textures` from the unpacked Unreal Tournament installer and paste them in the `Contents` > `MacOS` folder. | |
- Profit! |
I wanted to combine some old fashioned MP3 files and I did not want to download a separate application. Only thing necessary when combining MP3 files is stripping the ID3 tags - if present.
php -f join_mp3.php {destination} [{source}]
Edit: Turned out I has some multidisc mixtapes with .cue
files lying around as well. So I wrote a joiner script for that as well:
php -f join_cue.php {destination} [{source}:{duration_of_source}]
OlderNewer