Skip to content

Instantly share code, notes, and snippets.

View notFloran's full-sized avatar

Floran Brutel notFloran

View GitHub Profile
@Ocramius
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
<?php
declare(strict_types=1);
namespace Core\Domain\Time;
use DateTimeImmutable;
use DateTimeZone;
use Generator;
use Iterator;
@mickaelandrieu
mickaelandrieu / AppBundle.php
Last active November 21, 2018 14:37
Enable an event subscriber dynamically (the right way)
<?php
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
#!/bin/bash
# Original: http://steve-jansen.github.io/blog/2014/11/20/how-to-use-jenkins-to-monitor-cron-jobs/
# example cron script to post logs to Jenkins
# exit on error
set -e
log=`mktemp tmp.XXX`
timer=`date +"%s"`
jenkins_job=my_monitoring_job
@stof
stof / TwigRenderer.php
Last active September 16, 2020 07:46
Rendering twig blocks directly from outside a twig render call, for email purpose
<?php
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)
{
$builder
->add('amount', 'integer')
->add('currency', 'string')
->setDataMapper($this)
;
}
@tentacode
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)
<?php
namespace Context;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Testwork\Tester\Result\TestResult;
use Behat\Mink\Driver\Selenium2Driver;
class ScreenshotContext extends RawMinkContext
{
@jfornoff
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
mgirouard / QA.md
Last active April 29, 2016 17:55
99 QA Points for Symfony projects, via https://insight.sensiolabs.com/what-we-analyse

Critical Checks

Security

  • 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
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
<?php
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
jeremeamia / Twilio_Client.php
Last active May 15, 2018 21:45
The beginnings of a Guzzle-based, PHP Twilio client.
<?php
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;