Skip to content

Instantly share code, notes, and snippets.

View ajgarlag's full-sized avatar

Antonio J. García Lagar ajgarlag

View GitHub Profile
@ajgarlag
ajgarlag / migrator.php
Last active April 13, 2021 09:08 — forked from mindplay-dk/migrator.php
Migrate a PHP codebase to use namespaces.
<?php
/**
* Namespace Migration Script
*
* @author Rasmus Schultz <rasmus@mindplay.dk>
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*
* This script will scan through an entire PHP codebase and rewrite the
* scripts, adding a namespace clause based on the directory structure,
@ajgarlag
ajgarlag / 39733.diff
Last active February 8, 2021 08:24
Backport symfony/symfony:#39733
diff --git a/Mime/BodyRenderer.php b/Mime/BodyRenderer.php
index 5e75a69..ed105cf 100644
--- a/Mime/BodyRenderer.php
+++ b/Mime/BodyRenderer.php
@@ -46,6 +46,14 @@ final class BodyRenderer implements BodyRendererInterface
}
$messageContext = $message->getContext();
+
+ $previousRenderingKey = $messageContext[__CLASS__] ?? null;
<?php
/* composer.json
{
"require": {
"symfony/security-core": ">=3.4"
}
}
*/
require 'vendor/autoload.php';
@ajgarlag
ajgarlag / DecisionController.php
Last active May 28, 2021 15:56
Simple trikoder/oauth2-bundle decision flow
<?php
//src/Controller/DecisionController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\UriSigner;
use App\EventListener\SignedAuthorizationRequestSubscriber;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
@ajgarlag
ajgarlag / 79DCD2BD-transition-statement.txt.asc
Last active May 31, 2018 09:05
gpg-key-transition-statements
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Thu May 31 10:26:33 CEST 2018
For a number of reasons, I've recently set up a new PGP key
and will be transitioning away from my old one.
The old key will continue to be valid for a short period after
@ajgarlag
ajgarlag / guzzle-allow-invalid-cookie.patch
Created April 18, 2017 07:55
Allow cookies with invalid data
@ajgarlag
ajgarlag / figcookies.diff
Created April 18, 2017 07:20
Patch to disable urlencoding in dflydev/fig-cookies
diff --git a/src/Dflydev/FigCookies/Cookie.php b/src/Dflydev/FigCookies/Cookie.php
index cb50fc1..16de9a2 100644
--- a/src/Dflydev/FigCookies/Cookie.php
+++ b/src/Dflydev/FigCookies/Cookie.php
@@ -60,7 +60,7 @@ class Cookie
*/
public function __toString()
{
- return urlencode($this->name).'='.urlencode($this->value);
+ return $this->name.'='.$this->value;
@ajgarlag
ajgarlag / 50-ruabove-paas-log.conf
Created June 24, 2016 07:38
How to log your Linux to RunAbove PaaS Log with rsyslog 8.0+
$DefaultNetstreamDriverCAFile /etc/ssl/certs/ca-certificates.crt
template(
name="PaaSLog"
type="list"
) {
constant(value="<")
property(name="pri")
constant(value=">1")
constant(value=" ")
@ajgarlag
ajgarlag / gzip.php
Created June 24, 2015 12:26
Gzip seekable stream with zlib.deflate filter
<?php
$fp = fopen("/tmp/example", "rb+");
$fz = fopen("php://temp", "wb+");
fwrite($fz, "\x1f\x8b\x08\0\0\0\0\0\0\xFF", 10);
$fltr = stream_filter_append($fz, "zlib.deflate", STREAM_FILTER_WRITE, -1);
$size = stream_copy_to_stream($fp, $fz);
stream_filter_remove($fltr);
@ajgarlag
ajgarlag / test.php
Last active August 29, 2015 14:16
Problem with ValueObjects\DateTime\DateTime
<?php
require 'vendor/autoload.php';
function it($m,$p){echo "\033[".($p?"32m✔":"31m✘")." It $m\033[0m\n"; if(!$p)register_shutdown_function(function(){die(1);});}
$nativeDateTime1 = new \DateTime('2015-02-23 20:30:00', new \DateTimeZone('Europe/Madrid'));
$nativeDateTime2 = new \DateTime('2015-02-23 20:30:00', new \DateTimeZone('Europe/London'));
it('should be different', $nativeDateTime1 != $nativeDateTime2);