Skip to content

Instantly share code, notes, and snippets.

View atillay's full-sized avatar

Alexandre Tillay atillay

View GitHub Profile
@atillay
atillay / post-commit.sh
Last active April 6, 2018 14:25
Git post-commit hook to save daily activity into a file
#!/bin/sh
# Setup : https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook
today=$(date +%d-%m-%Y)
log_file_name=”git-commits-$today.txt”
log_dir=”$HOME/Desktop”
log_file_path=”$log_dir/$log_file_name”
remote=$(git config — get remote.origin.url)
@atillay
atillay / parseGoogleMapsAddressComponents.js
Last active April 20, 2018 15:45
Google Maps API address components parser
/**
* parseGoogleMapsAddressComponents
*
* Converts the addressComponents sent by GoogleMaps into a clean object
* The precision value allows to know what is the precision level of the address (one point per component)
* Ex: If the street number is available, then the precision value would be 6.
*
* @param addressComponents
* @returns object
*/
@atillay
atillay / DemoController.php
Last active July 24, 2024 17:19
Symfony 4 Pagination Service
<?php
namespace App\Controller;
use App\Entity\Demo;
use App\Service\PaginationService;
use Symfony\Component\HttpFoundation\Request;
class DemoController extends AdminController
{
@atillay
atillay / yolo.php
Last active May 27, 2018 19:39
yolo
<?php
define('PATTERN', '*.{jpg,jpeg,gif,png}');
function getFilesIn(string $path): array
{
$files = glob($path . '/' . PATTERN, GLOB_BRACE);
foreach (glob($path . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $subDir) {
$files = array_merge($files, getFilesIn($subDir));
@atillay
atillay / doc.md
Last active August 22, 2018 07:37
Setup PHPCS, PHPMD and PHP-CS-FIXER with Intellij globally

Run the following commands :

  • $ composer global require phpmd/phpmd
  • $ composer global require squizlabs/php_codesniffer
  • $ composer global require friendsofphp/php-cs-fixer
  • $ nano ~/.bash_profile and put export PATH=~/.composer/vendor/bin:$PATH (make sure path is correct)
  • $ source ~/.bash_profile

Go to Intellij > Preferences > Languages & Frameworks > PHP and add path for Mess Detector and Code Sniffer (ex: ~/.composer/vendor/bin/phpmd)
Go to Intellij > Preferences > Editor > Inspections and enable PHP Mess Detection validation + PHP Code Sniffer validation

@atillay
atillay / gitlab-ci.yml
Last active October 29, 2024 14:58
Deploy to Gandi Simple Hosting with Gitlab CI (and build assets with NPM)
image: node:lts-slim
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
stage_deploy:
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* @ApiResource(
* collectionOperations={
* "get"={
<?php
namespace App\Serializer;
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class GroupsContextBuilder implements SerializerContextBuilderInterface
{
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* @ApiResource(
* collectionOperations={
* "get",
<?php
declare(strict_types=1);
namespace App\Validator;
use Symfony\Component\HttpFoundation\RequestStack;
final class ValidationGroupsGenerator
{