Skip to content

Instantly share code, notes, and snippets.

View staabm's full-sized avatar
👋

Markus Staab staabm

👋
View GitHub Profile
@staabm
staabm / Linter.php
Last active December 10, 2023 08:40
fast-lint
<?php
declare(strict_types=1);
/*
* This file is part of the overtrue/phplint package
*
* (c) overtrue
*
* This source file is subject to the MIT license that is bundled
@staabm
staabm / test.php
Last active August 16, 2023 08:53
hoa regex capturing groups
<?php
use PHPStan\ShouldNotHappenException;
use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
require __DIR__ . '/vendor/autoload.php';
// 1. Read the grammar.
$grammar = new Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
@staabm
staabm / FileSessionHandler.php
Last active February 12, 2023 20:20
Drop in replacement for the native php file session handler with lock-timeout support. Work arround PHP Bug #72345.
<?php
class FileSessionHandler implements SessionHandlerInterface
{
/**
* time in milliseconds how fast to poll the filesystem for a file-lock
* in case it cannot be acquired / is (b)locked by other resources.
*
* @var int
* @internal
@staabm
staabm / test.php
Created September 2, 2022 15:17
slow phpstan analysis Bug #7901
<?php
namespace a\spaceX;
class MailAddressList
{
const MAIL_LIST = [
'a',
'b',
'c',
'd',
<?php
$queryString = '
SELECT
land.*,
COALESCE(NULLIF(landsprache.ort, ""), land.ort) AS ort
FROM land
INNER JOIN landsprache ON (land.landid=landsprache.landid and landsprache.spracheid = ?)
WHERE (webinaktiv = 0) ORDER BY COALESCE(NULLIF(landsprache.ort, ""), land.ort) ASC
🌞 Morning 62 commits ███████▋░░░░░░░░░░░░░ 36.5%
🌆 Daytime 32 commits ███▉░░░░░░░░░░░░░░░░░ 18.8%
🌃 Evening 70 commits ████████▋░░░░░░░░░░░░ 41.2%
🌙 Night 6 commits ▋░░░░░░░░░░░░░░░░░░░░ 3.5%
@staabm
staabm / maxpostsize.php
Last active July 30, 2020 14:16
Throw error when post_max_size was reached
<?php
function checkPostSizeExceeded() {
$maxPostSize = iniGetBytes('post_max_size');
if ($_SERVER['CONTENT_LENGTH'] > $maxPostSize) {
throw new Exception(
sprintf('Max post size exceeded! Got %s bytes, but limit is %s bytes.',
$_SERVER['CONTENT_LENGTH'],
$maxPostSize
@staabm
staabm / navigation_iterator.php
Last active July 30, 2020 14:07
redaxo navigation iterator
<?php
/**
* Klasse zum Erstellen von Navigationen, v0.1.
*
* benötigt PHP7!
*
* @package redaxo\structure
*/
@staabm
staabm / user-export.diff
Created June 1, 2020 07:00
redaxo example console command
$ git diff --staged
diff --git a/redaxo/src/addons/project/lib/user_export.php b/redaxo/src/addons/project/lib/user_export.php
new file mode 100644
index 000000000..26a85625e
--- /dev/null
+++ b/redaxo/src/addons/project/lib/user_export.php
@@ -0,0 +1,25 @@
+<?php
+
+use Symfony\Component\Console\Input\InputInterface;
@staabm
staabm / jquery.validate.js
Created March 29, 2016 08:21
jq-validate input event
/*!
* jQuery Validation Plugin v1.15.1-pre
*
* http://jqueryvalidation.org/
*
* Copyright (c) 2016 Jörn Zaefferer
* Released under the MIT license
*/
(function( factory ) {
if ( typeof define === "function" && define.amd ) {