Skip to content

Instantly share code, notes, and snippets.

View pounard's full-sized avatar
💭
What's happening?

Pierre pounard

💭
What's happening?
View GitHub Profile
@pounard
pounard / XmlRequestWriter.php
Created August 7, 2024 09:53
Quick & ugly PHP array to XML converter
<?php
declare(strict_types=1);
/**
* Crache du XML, yay.
*/
class XmlRequestWriter
{
/**
@pounard
pounard / duplicated_functions.php
Last active July 31, 2024 10:59
Finds duplicated functions names in PHP codebase
<?php
/**
* Run in folder where to scan:
* php -f /path/to/duplicated_functions.php
*
* For more detailed debug information:
* DEBUG=1 php -f /path/to/duplicated_functions.php
*/
declare (strict_types=1);
<?php
function usage($programeName) {
echo <<<EOT
Usage:
{$programeName} TRACE_FILE
EOT;
}
/**
* @see \Symfony\Component\HttpKernel\Controller\ErrorController
*/
final class ErrorController
{
private bool $debug = false;
private ErrorRendererInterface $errorRenderer;
private Environment $twig;
/**
@pounard
pounard / serializer-type-map.php
Last active May 22, 2024 11:04
Symfony serializer type map decorator
<?php
/**
* Maps PHP native types to normalized names
*/
interface TypeMap
{
const TYPE_ARRAY = 'array';
const TYPE_NULL = 'null';
const TYPE_STRING = 'string';
@pounard
pounard / user_rights.sh
Last active November 29, 2018 15:12
User rights restoration script for Symfony/D7/D8
#!/bin/bash
if [ "`id -u`" != "0" ]; then
echo "Script must be run as root"
exit 1
fi
IGNORE_BIN=0
ROOT_PATH=`pwd`
@pounard
pounard / iban-input-mask-not-working.js
Created October 18, 2018 09:51
IBAN input mask that does not work
function applyIBANMaks(input) {
var mask = '____ ____ ____ ____ ____ ____ ____'.split('');
var cursorPositionDelta = 0;
function strip(value) {
return value.split('').filter(function (chr) {
return /[a-zA-Z\d]/.test(chr);
});
}
@pounard
pounard / normalize-path.php
Last active June 26, 2018 11:24
Path normalization, equivalent of Python's os.path.normpath() and os.path.absath()
<?php
// Generate test data for performance test
$testData = [];
$words = ['..', 'test', 'pouet', '/', '..', '', 'usr', 'bin', 'firefox', 'do not', 'panic', 'secret', 'perso', 'private', 'foo', '/', '..', '', 'hyper long word', 'word with space', 'some56457', '@ert', '.ezrzer', 'cassoulet', '/', '..', ''];
for ($i = 0; $i < 100; ++$i) {
$value = [];
$count = rand(0, 20);
for ($j = 1; $j < $count; ++$j) {
$value[] = $words[rand(0, count($words) - 1)];
commit f3c67888421b31f71ae0a8cabb5259676150baa4
Author: Pierre Rineau <[email protected]>
Date: Wed Mar 28 22:24:01 2018 +0200
https://www.drupal.org/sa-core-2018-002 backport from Drupal 7
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 23179ca98d..c14d966d86 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc