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 / SF2-VAGRANT.md
Created November 16, 2013 11:37
Adds Vagrant support to any standard Symfony 2 Framework app.

SF2 VAGRANT

This is a simple patch to add Vagrant support to any standard Symfony 2 Framework app.

It will create a Debian Wheezy box and the project files will be shared with NFS so you must have the NFS server installed in your host machine. If you want to access to your dev machine with a domain name, insted of the default IP (192.168.10.33), you should add an entry to your /etc/hosts file:

192.168.33.10 sf2.localdomain

The XDebug extension is available and the config param xdebug.remote_connect_back enabled +info.

@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);
@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 / 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 / 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 / guzzle-allow-invalid-cookie.patch
Created April 18, 2017 07:55
Allow cookies with invalid data
@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 / 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;
<?php
/* composer.json
{
"require": {
"symfony/security-core": ">=3.4"
}
}
*/
require 'vendor/autoload.php';
@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;