Skip to content

Instantly share code, notes, and snippets.

View HeahDude's full-sized avatar

Jules Pietri HeahDude

View GitHub Profile
@HeahDude
HeahDude / Makefile
Created October 15, 2018 12:22 — forked from B-Galati/Makefile
Rebuild docker images only when they are modified
DOCKER_FILES=$(shell find ./docker/dev/ -type f -name '*')
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
##
## Project setup
##---------------------------------------------------------------------------
@HeahDude
HeahDude / run.php
Created July 18, 2018 12:13 — forked from lyrixx/run.php
Slack delete all your files (rewrite of https://gist.github.com/jamescmartinez/909401b19c0f779fc9c1)
<?php
<<<CONFIG
packages:
- "kriswallsmith/buzz: ^0.15.0"
- "symfony/console: ^3.2@dev"
CONFIG;
// Find you token on https://api.slack.com/docs/oauth-test-tokens
use Buzz\Message\Response;
author: heah
questions:
- question: |
What will be the result of the following code?
```yaml
// config/routes.yaml
some_route:
path: /some-path/{param}
controller: 'Some\Controller::action'
user: heah
questions:
- question: "What keys can be passed to `Response::setCache($array)`"
answers:
- OK etag
- OK last_modified
- OK public
- OK private
- OK maxage
@HeahDude
HeahDude / ChoiceTypeExtension.php
Created February 5, 2018 18:14
Strict ChoicesToValuesTransformer
<?php
namespace App\Form\TypeExtension;
use App\Form\DataTransformer\StrictChoicesToValuesTransformer;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Compoennt\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;
use Symfony\Compoennt\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@HeahDude
HeahDude / 1_security.yml
Created January 27, 2018 00:23 — forked from 77web/1_security.yml
How to switch user accounts between two(or more) different firewalls when using Symfony\Bundle\SecurityBundle
//you may have some more configs here...
providers:
user:
entity: { class: MyAppBundle:User, property: loginEmail }
admin:
entity: { class: MyAppBundle:Admin, property: username }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
@HeahDude
HeahDude / collection_type-options.rst
Last active February 29, 2016 08:50
CollectionType refactoring

In those examples, we assume calling the builder from a form type class definition or a controller, using help of this closure :

$class = function ($object) {
    $FQCN = get_class($object);
    $class = explode('\\', $FQCN);

    return end($class);
@HeahDude
HeahDude / MacroAutoloadTwigExtension.php
Last active March 23, 2018 22:54
MacroTwigExtension - Autoloading macro in templates for symfony 2.3+
<?php
// src/AppBundle/Twig/MacroTwigExtension.php
namespace AppBundle\Twig;
class MacroAutoloadTwigExtension extends \Twig_Extension
{
public function getFunctions()
{
@HeahDude
HeahDude / CustomServiceProvider.php
Last active January 27, 2016 16:14
Silex skeleton
<?php
/* /src/DevTeam/Providers/CustomServiceProvider.php */
namespace DevTeam/Providers;
use DevTeam\Debug\SomeDebugClass;
use DevTeam\Listeners\MyListenerClass;
use DevTeam\Listeners\MyDebugListenerClass;
use DevTeam\Utils\SomeServiceClass;
use DevTeam\Utils\CallableService;