Skip to content

Instantly share code, notes, and snippets.

View vjandrea's full-sized avatar

Andrea Bergamasco vjandrea

View GitHub Profile
@vjandrea
vjandrea / git-config.sh
Last active March 17, 2025 13:47
git-config.sh
#!/bin/sh
git config --global init.defaultBranch main
git config --global merge.ff only
git config --global alias.l "log --pretty=format:'%C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(7,trunc)%aN%C(auto,reset)%s%C(auto,red)% %C(auto)%gD %D' --date=relative --decorate -20"
git config --global alias.last "log --oneline -1"
git config --global alias.s "status -s -b"
git config --global alias.a "add ."
git config --global rerere.enabled 1
git config --global core.pager 'less -FRX'
git config --global push.autoSetupRemote true
@vjandrea
vjandrea / phpversion.sh
Last active January 29, 2025 14:28
Change php cli version in plesk
#!/bin/sh
printf "Switching php to version 5.6 with symlinks.\n"
printf "Press any key to continue...\n"
read CONTINUE
printf "Creating backups..."
# Backup original binaries
@vjandrea
vjandrea / artboard_sort.js
Created April 22, 2020 14:06
Sort Illustrator artboards alphabetically - by OMOTI
/**
Kudos to OMOTI
https://community.adobe.com/t5/illustrator/script-to-sort-artboard-list-alphabetically/m-p/9558396?page=1#M77799
*/
function sortArtboard() {
var doc = app.activeDocument,
properties = [],
i,
max;
@vjandrea
vjandrea / controller_inheritance_and_extension.md
Created March 15, 2022 06:25
Controller inheritance and extension
<?php
# src/Controller/ParentController.php

namespace App\Controller;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@vjandrea
vjandrea / AccessChecker.php
Last active July 29, 2021 12:04 — forked from leotiger/allowed_roles_for_route.md
Symfony 4: Check if a route is accessible to a User based on their roles
<?php
/**
* @Author Andrea Bergamasco <andrea@bergamasco.me>
* Inspired by @leotiger: https://gist.github.com/leotiger/ca496d1b16c30afea060904bd5e78714
*
* Usage:
* $token = $this->security->getToken();
* $this->accessChecker->userTokenCanAccessRoute($token, 'admin.index');
*/
@vjandrea
vjandrea / workflow.yaml
Created January 6, 2020 14:29
workflow.yaml - testing double "from" marking
# Entity workflow - object names redacted
# A SuperUser can send an Entity to an Evaluator
# The Evaluator decides to optIn or optOut the request. They can change their mind until a timeout defined in the Entity.
# If Evaluator opts in, the Entity is then sent to the Recipient.
# The Recipient finally decides to accept or refuse
framework:
workflows:
Entity:
type: workflow
metadata:
@vjandrea
vjandrea / SymfonyExtension debugging
Last active September 11, 2019 05:14
FriendsOfBehat-SymfonyExtension_debug.md
$ composer require --dev friends-of-behat/symfony-extension:^2.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.3.*"
Nothing to install or update
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [OK]
@vjandrea
vjandrea / snipe-it-api-map.md
Created February 23, 2017 12:05
API Map for Snipe-IT

Snipe-IT API Map

Domain Method URI Name Action Middleware
GET/HEAD api/v1/accessories api.accessories.index App\Http\Controllers\Api\AccessoriesController@index auth:api
POST api/v1/accessories api.accessories.store App\Http\Controllers\Api\AccessoriesController@store auth:api
GET/HEAD api/v1/accessories/{accessory} api.accessories.show App\Http\Controllers\Api\AccessoriesController@show auth:api
PUT/P
@vjandrea
vjandrea / cleanup.bat
Created May 20, 2019 11:08
Clean Mac folders on Windows
@echo Removing .DS_STORE...
DEL /S ".DS_STORE"
@echo ...OK
@echo.
@echo Removing Thumbs.db...
DEL /S /AH "Thumbs.db"
@echo ...OK
@echo.
@echo Removing __MACOSX...
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d __MACOSX') do ( rd /s /q "%%i")
@vjandrea
vjandrea / charconv.py
Last active May 20, 2019 11:00
Correct the filenames of files extracted in Windows from archives compressed on Mac OS
import glob
import re
import os
path = 'puntata*/**/BLOCCO*/*.mp3'
def repair_filename(filename):
repair = {
'´╝ê': '(', # U+0028 LEFT PARENTHESIS