Skip to content

Instantly share code, notes, and snippets.

View jgauthi's full-sized avatar

jgauthi

  • France
View GitHub Profile
@jgauthi
jgauthi / Dockerfile
Last active September 21, 2023 09:32
Dockerfile php5.6 (with fix for old debian packages)
FROM php:5.6
# Update stretch repositories for old packages: https://stackoverflow.com/a/76095392
RUN sed -i -e 's/deb.debian.org/archive.debian.org/g' \
-e 's|security.debian.org|archive.debian.org/|g' \
-e '/stretch-updates/d' /etc/apt/sources.list
# Some libs
RUN apt-get update --fix-missing && apt-get install -y vim curl locales apt-utils git qrencode imagemagick memcached zip unzip
@jgauthi
jgauthi / twitter_ublock_filters.txt
Last active June 21, 2023 19:50 — forked from fanfare/gist:96da458bc902292542b836a682a4586a
[French version] uBlock filters to hide Twitter's "Discover More" feature (Découvrez plus)
twitter.com##div[data-testid="cellInnerDiv"]:has(h2):has-text(Découvrez plus) ~ *
twitter.com##div[data-testid="cellInnerDiv"]:has(h2):has-text(Découvrez plus)
@jgauthi
jgauthi / 1-Load_data.postman.js
Last active January 3, 2023 14:39
Postman: Example request body created in Javascript
// 1. First route: Get data and index them in Postman Variable
// Set this content in Request > "Tests" Tab
// Step: You can get barcode with Sale > Get by ID
var jsonData = JSON.parse(responseBody);
if (jsonData.data.idSale) {
postman.setEnvironmentVariable("saleId", jsonData.data.idSale);
}
@jgauthi
jgauthi / example.php
Created July 26, 2022 12:49 — forked from dunglas/example.php
A GraphQL client using the Symfony HttpClient component
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
@jgauthi
jgauthi / redis-glue-test.php
Last active June 23, 2021 13:25 — forked from raphaelstolt/redis-glue-test.php
Redis installation test script
<?php
const TEST_KEY = 'are_we_glued';
const REDIS_HOST = 'localhost';
const REDIS_PORT = 6379;
$redis = new Redis;
try {
$redis->connect(REDIS_HOST, REDIS_PORT);
$redis->set(TEST_KEY, 'yes');
$glueStatus = $redis->get(TEST_KEY);
@jgauthi
jgauthi / hCaptcha.php
Last active June 13, 2021 12:09
Form validation with HCAPTCHA (google recaptcha alternative)
<?php
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
// Complete configuration: https://hcaptcha.com
const HCAPTCHA_SECRET_KEY = '...';
const HCAPTCHA_API_KEY = '...';
/**
* @throws Exception
@jgauthi
jgauthi / AppFixtures.php
Last active February 12, 2024 12:43
[Symfony] Example of generation of fixture with yaml files (Nelmio Alice)
<?php
// src/DataFixtures/AppFixtures.php
namespace App\DataFixtures;
use App\DataFixtures\ORM\AppNativeLoader;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class AppFixtures extends Fixture
{
@jgauthi
jgauthi / fos_rest.yaml
Last active September 15, 2021 15:43
[Symfony] Example configuration bundle: Fos Rest
# config/packages/fos_rest.yaml
# Documentation: https://symfony.com/doc/master/bundles/FOSRestBundle/
fos_rest:
routing_loader: false
view:
view_response_listener: 'force'
formats:
json: true
xml: true
zone:
@jgauthi
jgauthi / CinemaController.php
Last active April 10, 2021 13:31
Nelmio api doc configuration example in symfony, with authentification schema and some refs.
<?php
// src/Controller/Api/CinemaController.php
namespace App\Controller\Api;
use App\Collection\CinemaCollection;
use FOS\RestBundle\Controller\{AbstractFOSRestController, Annotations as Rest};
use FOS\RestBundle\View\View;
use Nelmio\ApiDocBundle\Annotation\{Model, Security};
use OpenApi\Annotations as OA;
@jgauthi
jgauthi / CinemaController.php
Last active April 7, 2021 17:17
[Symfony] Nelmio Apidoc v4, OpenApi 3 example
<?php
namespace App\Controller\Api;
use App\Collection\CinemaCollection;
use FOS\RestBundle\Controller\{AbstractFOSRestController, Annotations as Rest};
use FOS\RestBundle\View\View;
use Nelmio\ApiDocBundle\Annotation\{Model, Security};
use OpenApi\Annotations as OA;
use Symfony\Component\HttpFoundation\Request;