Skip to content

Instantly share code, notes, and snippets.

@gbarre
gbarre / gandi.sh
Created May 12, 2020 14:09
Update DNS A record with Gandi's API
#!/bin/sh
# Customize with your datas
APIKEY="secret_token"
DOMAIN="my_domain"
RECORD="my_record"
# DO NOT EDIT AFTER THIS LINE
CURRENTIP=$(curl -s ifconfig.co/ip)
IPLENGTH=$(echo -n ${CURRENTIP} | wc -m)
@GrzegorzBandur
GrzegorzBandur / Readme.md
Last active January 23, 2022 09:54
RESTful API with Symfony 4.4 + FOSRestBundle + FOSOauthServerBundle + FOSUserBundle

RESTful API with Symfony 4.4 + FOSRestBundle + FOSOauthServerBundle + FOSUserBundle

To start writing RestFull API in symfony we will need bundles:

        "friendsofsymfony/oauth-server-bundle": "^1.6",
        "friendsofsymfony/rest-bundle": "^2.7",
        "friendsofsymfony/user-bundle": "^2.1",
        "jms/serializer-bundle": "^3.5",
        "nelmio/api-doc-bundle": "^3.5",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/apache-pack": "^1.0",
@adamsafr
adamsafr / AbstractBySlugAndActiveSearcher.php
Last active March 31, 2023 09:03
Symfony: ParamConverter usage example
<?php
namespace FrontEndBundle\Request\ParamConverter;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Common\Persistence\ObjectRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
abstract class AbstractBySlugAndActiveSearcher
@cereal-s
cereal-s / ping.gs.php
Created September 8, 2017 13:44
Get number of pages from a PDF, using GhostScript.
<?php
/**
* Return the number of pages of a PDF.
*
* Imagick::pingImage() takes too much when dealing with big files.
*
* Command to execute:
*
* gs -q -dNODISPLAY -c "(%s) (r) file runpdfbegin pdfpagecount = quit"
@gnutix
gnutix / Fixture.yml
Last active March 14, 2024 04:53
Custom Faker Provider for generating Symfony encoded password using UserPasswordEncoderInterface.
Symfony\Component\Security\Core\User\User:
member:
__construct: ['member', '<symfonyPassword("Symfony\Component\Security\Core\User\User", "member", "salt")>', ['ROLE_USER']]
admin:
__construct: ['admin', '<symfonyPassword("Symfony\Component\Security\Core\User\User", "admin", "salt")>', ['ROLE_ADMIN']]
@nclavaud
nclavaud / MangoPayApiPhpUnitMock.php
Created April 20, 2017 17:14
MangoPay API PHPUnit mock
<?php
namespace Lrqdo\Tests;
use MangoPay\ApiWallets;
use MangoPay\MangoPayApi;
use MangoPay\Money;
use MangoPay\Wallet;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@treetop1500
treetop1500 / FlatpickerDateTimeType.php
Last active September 10, 2022 08:52
Symfony3 Form Extension for use with Flatpickr javascript date/time pickers
<?php
namespace MyBundle\Form\Extension;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
/**
* Class FlatpickrDateTimeType
* @package MyBundle\Form\Extension
@Seldaek
Seldaek / bench.php
Created December 8, 2015 10:33
strtr vs str_replace benchmark
<?php
$jobs = array(
'old/strtr' => function($args) {
$classes = [];
foreach ($args as $class) {
$classes[] = strtr($class, '\\', DIRECTORY_SEPARATOR);
}
return $classes;
},
@lumpysimon
lumpysimon / wp-disable-rest.php
Created November 26, 2015 22:44
Completely disable WordPress REST API
add_filter( 'rest_enabled', '_return_false' );
add_filter( 'rest_jsonp_enabled', '_return_false' );
@maxgalbu
maxgalbu / Switch_Node.php
Last active December 31, 2019 16:03
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*