Skip to content

Instantly share code, notes, and snippets.

@heiglandreas
heiglandreas / install.sh
Last active February 13, 2024 16:43
Set up an ubuntu docker container with google-authenticator so that you can get a 2FA config file
docker run -it --rm ubuntu
apt update
apt install curl build-essential autoconf libtool vim libpam-dev
curl -LO https://github.com/google/google-authenticator-libpam/archive/refs/tags/1.09.tar.gz
tar xvzf 1.09.tar.gz
cd google-authenticator-libpam-1.09/
./bootstrap.sh
./configure
# This will break at some points. Check the script and fix it.
<?php
namespace Test;
enum Locale: string
{
case en_GB = 'en_GB';
case de_DE = 'de_DE';
case fr_CA = 'fr_CA';
{
"require": {
"symfony/security-bundle": "^6.3"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1"
}
}
Calendar buddhist
Calendar chinese
int(1)
int(1)
Calendar coptic
Calendar dangi
int(1)
int(1)
Calendar ethiopic
Calendar ethiopic-amete-alem
@heiglandreas
heiglandreas / expected result
Last active April 19, 2023 18:58
SImple test of Intl-Calendar feature set(month)
Chinese Calendar
int(1)
int(0)
Islamic Calendar
int(8)
int(0)
Gregorian Calendar
int(3)
int(0)
<?php
use Org_Heigl\Holidaychecker\Holidaychecker;
use Org_Heigl\Holidaychecker\HolidayIteratorFactory;
$factory = new HolidayIteratorFactory();
$iterator = $factory->createIteratorFromISO3166('DE');
$checker = new Holidaychecker($iterator);
$startDate = new DateTimeImmutable('2022-10-10');
@heiglandreas
heiglandreas / ci-fail.yml
Last active March 26, 2023 13:03
Patch-Coverage as GitHub Action
jobs:
patch-coverage:
# Fail when untested lines are found
steps:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
tools: "phive"
coverage: "xdebug"
- name: "Install tools"
<?php
class ClassToTestA
{
public function __construct(private ClockInterface $clock) {}
public function do(): void
{
$a = $this->clock->now();
sleep(6);
@heiglandreas
heiglandreas / demo.php
Created April 11, 2022 07:55
Never use "unicode" as Content-Type
<?php
declare(strict_types=1);
$string = <<<'EOF'
Bar
<meta content="text/html; charset=unicode" http-equiv="Content-Type">
Foo
EOF;