Skip to content

Instantly share code, notes, and snippets.

View bernard-ng's full-sized avatar
🎯
Focusing

Bernard Ngandu bernard-ng

🎯
Focusing
View GitHub Profile
@bernard-ng
bernard-ng / tailwind_2_form.twig
Created December 3, 2021 20:28
symfony tailwind 2 form layout
{# @experimental in 5.3 #}
{% use 'form_div_layout.html.twig' %}
{%- block form_row -%}
{%- set row_attr = row_attr|merge({ class: row_attr.class|default(row_class|default('mb-6')) }) -%}
{{- parent() -}}
{%- endblock form_row -%}
{%- block widget_attributes -%}
@bernard-ng
bernard-ng / countries.php
Created June 8, 2021 11:48
french african countries list - symfony
<?php
$countries = [
Countries::getName('BJ') => 'BJ',
Countries::getName('BF') => 'BF',
Countries::getName('BI') => 'BI',
Countries::getName('CM') => 'CM',
Countries::getName('CF') => 'CF',
Countries::getName('CG') => 'CG',
Countries::getName('CD') => 'CD',
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\DisallowCountry;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Exception;
@bernard-ng
bernard-ng / GoogleDorking.md
Created February 28, 2021 18:59 — forked from sundowndev/GoogleDorking.md
Google dork cheatsheet

Google dork cheatsheet

Search filters

Filter Description Example
allintext Searches for occurrences of all the keywords given. allintext:"keyword"
intext Searches for the occurrences of keywords all at once or one at a time. intext:"keyword"
inurl Searches for a URL matching one of the keywords. inurl:"keyword"
allinurl Searches for a URL matching all the keywords in the query. allinurl:"keyword"
intitle Searches for occurrences of keywords in title all or one. intitle:"keyword"
<?php
declare(strict_types=1);
namespace App\Entity;
use App\Repository\DisallowCountryRepository;
use Doctrine\ORM\Mapping as ORM;
/**
<?php
declare(strict_types=1);
namespace App\DataFixtures;
use App\Domain\Application\Entity\DisallowCountry;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Intl\Countries;
<?php
declare(strict_types=1);
namespace App\EventListener;
use App\Repository\DisallowCountryRepository;
use GeoIp2\Database\Reader;
use GeoIp2\Exception\AddressNotFoundException;
use MaxMind\Db\Reader\InvalidDatabaseException;
<form method="POST" action="/profile">
@csrf
...
</form>
<?php
use Symfony\Component\HttpFoundation\Request;
// ...
public function delete(Request $request)
{
$submittedToken = $request->request->get('token');
// "delete-item" est la même valeur que celle utilisée dans le modèle pour générer le jeton
if ($this->isCsrfTokenValid('delete-item', $submittedToken)) {
<form action="{{ path('admin_post_delete', { id: post.id }) }}" method="post">
{# l'argument de csrf_token() est une chaîne arbitraire utilisée pour générer le toke #}
<input type="hidden" name="token" value="{{ csrf_token('delete-item') }}"/>
<button type="submit">Delete item</button>
</form>