Skip to content

Instantly share code, notes, and snippets.

View romaricdrigon's full-sized avatar

Romaric Drigon romaricdrigon

  • Lausanne, Switzerland
View GitHub Profile
@romaricdrigon
romaricdrigon / docker-compose.override.yaml
Created August 27, 2020 14:36
Using Mutagen Compose
version: '3.7'
volumes:
appdata: ~
code: ~
services:
php:
volumes:
- code:/var/www/html
<?php
namespace App\User\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
@romaricdrigon
romaricdrigon / .zshrc
Created January 8, 2020 15:09
My ZSH config (with Oh-my-ZSH)
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@romaricdrigon
romaricdrigon / fiddle.php
Created December 4, 2019 09:01
Reproducing crash caused by "clear()" in webdriver 1.8.x
<?php
namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once('vendor/autoload.php');
// Start Chrome in headless mode
@romaricdrigon
romaricdrigon / EmailFileHelper.php
Last active September 17, 2019 06:51
FileTransport to store sent emails on disk
<?php
namespace App\Email;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Mime\Email;
/**
* Helper to deal with messages as dumped by FileTransport.
<?php
namespace App\Filter;
use App\Entity\Blog;
use App\Entity\User;
use Doctrine\ORM\Mapping\ClassMetaData;
use Doctrine\ORM\Query\Filter\SQLFilter;
class BlogFilter extends SQLFilter
@romaricdrigon
romaricdrigon / AuthenticatorInterface.php
Last active January 17, 2020 13:36
Commented Symfony Guard
<?php
namespace Symfony\Component\Security\Guard\Firewall;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
@romaricdrigon
romaricdrigon / client.html
Created May 17, 2019 15:41
Exemple d'utilisation de Mercure pour un widget affichant des scores en temps réel
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Score en temps réels</title>
</head>
<body>
<div id="scoreBoard"></div>
<script>
@romaricdrigon
romaricdrigon / ChangePasswordCommand.php
Last active July 10, 2019 13:59
Commandes pratiques portées du FOSUserBundle: créer un utilisateur, changer un mot de passe
<?php
namespace App\Command;
// Adapter App\Entity\User selon la classe réelle de votre utilisateur
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@romaricdrigon
romaricdrigon / AppController.php
Last active July 10, 2019 13:56
Comment protéger un contrôleur Symfony d'attaques CSRF
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;