Skip to content

Instantly share code, notes, and snippets.

View notFloran's full-sized avatar

Floran Brutel notFloran

View GitHub Profile
Ocramius / Day.php
Created April 3, 2020 14:13
Example abstraction that only allows a resolution of "day" for time inside a specific business domain
namespace Core\Domain\Time;
use DateTimeImmutable;
use DateTimeZone;
use Generator;
use Iterator;
mickaelandrieu / AppBundle.php
Last active November 21, 2018 14:37
Enable an event subscriber dynamically (the right way)
namespace AppBundle;
use AppBundle\DependencyInjection\Compiler\SecureApplicationPass;
use Symfony\Component\DependencyInjection\Compiler\PassConfig
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
# Original:
# example cron script to post logs to Jenkins
# exit on error
set -e
log=`mktemp tmp.XXX`
timer=`date +"%s"`
stof / TwigRenderer.php
Last active September 16, 2020 07:46
Rendering twig blocks directly from outside a twig render call, for email purpose
namespace Incenteev\MailerBundle\Mailer;
class TwigRenderer implements RendererInterface
private $twig;
private $styleInliner;
class MoneyType extends AbstractType implements DataMapperInterface
public function buildForm(FormBuilder $builder, array $options)
->add('amount', 'integer')
->add('currency', 'string')
tentacode / ScreenshotContext.php
Created February 6, 2015 13:33
After a Behat javascript scenario fails, taking a screenshot then sending it to wsend as an anonymous user. (could be improved, juste a POC really)
namespace Context;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Testwork\Tester\Result\TestResult;
use Behat\Mink\Driver\Selenium2Driver;
class ScreenshotContext extends RawMinkContext
jfornoff / Authentication.js
Created October 17, 2014 06:41
Angular.js Authentication Error Handling with HTTP Interceptor
app.factory('Authentication', function($http, $rootScope, $location, $timeout){
var Auth = {};
Auth.unsetUser = function() {
$rootScope.user = {};
Auth.setUser = function(data) {
$rootScope.user = data;
mgirouard /
Last active April 29, 2016 17:55
99 QA Points for Symfony projects, via

Critical Checks


  • Projects must not depend on dependencies with known security issues
  • Database queries should use parameter binding
  • PHP debug statements found
  • eval() should never be used
cystbear / DynamicRoleHierarchy.php
Last active March 6, 2018 14:53
Example of DynamicRoleHierarchy, how to fetch roles stored in DB and use them in regular Symfony2 security component
namespace Acme\SecurityBundle\Role;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Acme\SecurityBundle\Entity\RoleRepository;
class DynamicRoleHierarchy implements RoleHierarchyInterface
jeremeamia / Twilio_Client.php
Last active May 15, 2018 21:45
The beginnings of a Guzzle-based, PHP Twilio client.
namespace Twilio;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Collection;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Command\Guzzle\Description;
use GuzzleHttp\Command\Model;
use GuzzleHttp\Subscriber\Retry\RetrySubscriber;