Skip to content

Instantly share code, notes, and snippets.

View ahmed-bhs's full-sized avatar
👽

Ahmed EBEN HASSINE 脳の流れ ahmed-bhs

👽
View GitHub Profile
 this.queryField.valueChanges.pipe(
       filter(string => string.length > 0),
       debounceTime(200),
       switchMap(queryField =>
         this._searchService.search(queryField)
       )).subscribe((res: ItemResponse) => this.results = res._embedded.articles);
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.symfony-friendly.fr/$1 [R,L]
@ahmed-bhs
ahmed-bhs / rabbitmq.txt
Created December 15, 2018 09:53 — forked from sdieunidou/rabbitmq.txt
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"

Hydrator

Hydrators are simple objects that allow to convert an array of data to an object (this is called "hydrating") and to convert back an object to an array (this is called "extracting"). Hydrators are mainly used in the context of Forms, with the new binding functionality of Zend Framework 2, but can also be used for any hydrating/extracting context (for instance, it can be used in RESTful context). If you are not really comfortable with hydrators, please first read Zend Framework hydrator's documentation.

Basic usage

http://cronus.allowed.org works for me, 2018.1.6

Pour faire cela sous Symfony, il est possible d'utiliser le système d'event listeners.

1. Créer un listener CacheControlListener comme suit:
<?php

namespace App\EventListener;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@ahmed-bhs
ahmed-bhs / bootstrap.php
Last active November 13, 2018 13:29
Unit test bootstrap file
<?php
declare(strict_types=1);
if (!is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
throw new \LogicException('Run "composer install --dev" to create autoloader.');
}
require_once $autoloadFile;
<?php declare(strict_types=1);
namespace App\Controller\Article;
use App\Controller\AbstractRestController;
use App\Entity\Article;
use FOS\RestBundle\Controller\Annotations as FOSRest;
use FOS\RestBundle\Request\ParamFetcherInterface;
/**
* Class ArticleController.
@ahmed-bhs
ahmed-bhs / GIT.MD
Created November 3, 2018 13:30 — forked from jpchateau/GIT.MD
Git - Commandes / Configuration / Astuces

Commandes

git add -vA # ajoute tous les changements au commit, verbeux
git rm [fichiers] # supprime les fichiers du dépôt
git add -p [fichier] # permet de préciser quels morceaux de code d'un fichier sont à ajouter au commit
git pull # met à jour ses fichiers locaux à partir d'un dépôt distant (cela effectue un fetch puis un merge)
git pull -r
git push # Pousse les modifications locales sur un dépôt distant
git push -f # force à pousser ses modifications locales sur un dépôt distant. À utiliser avec précaution.
@ahmed-bhs
ahmed-bhs / auto-deploy.md
Created November 1, 2018 17:33 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.