Skip to content

Instantly share code, notes, and snippets.

View acecconato's full-sized avatar
👨‍💻

Anthony Espasa acecconato

👨‍💻
View GitHub Profile
@acecconato
acecconato / client.js
Created May 23, 2019 12:51
npm ftp + npm util-promisifyall: Read directory and subfolders recursively
/**
* Install dependencies with npm:
* npm i ftp
* npm i util-promisifyall
*/
const promisifyAll = require('util-promisifyall');
const Client = require('ftp');
/**
* CONFIGURE YOUR OWN FTP !
@acecconato
acecconato / FileUploader.php
Last active October 10, 2020 21:30
Symfony + EasyAdmin: File upload system
/**
Due to best practices, we need to create a new service which is used by the ImageListener.
Its role is to upload files and generate an unique filename.
NOTA:
The default $uploadPath is autowired by argument binding inside services.yaml
but in this case, we override it with the $path argument of the upload method.
*/
<?php
@acecconato
acecconato / App\Entity\EntityMerger.php
Created December 6, 2019 10:52
EntityMerger for a simple Symfony 4 RESTful API. Created for handle PUT methods.
<?php
namespace App\Entity;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping\Id;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
@acecconato
acecconato / .htaccess
Last active April 27, 2023 09:55
.htaccess security rules
## Block base64 injections
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
@acecconato
acecconato / delete_old_users.php
Last active January 25, 2023 10:26
Useful scripts for Prestashop owners
<?php
/**
* @author - Mobiloweb - Anthony Cecconato
* @version 1.0
* @cms Prestashop
* @ps_version 1.7+
*
* Delete old users, without orders (+12month by default) by getting the /yoururl/cron/delete_old_users.php?s_key=SECRET url
*/
@acecconato
acecconato / convertTable.cfg
Last active July 9, 2024 14:31
PrestaShop: Generate webp thumbnails based on image types and sizes defined in a .cfg file
cart_default:125x125
small_default:98x98
medium_default:452x452
home_default:250x250
large_default:800x800
default_xs:120x120
default_s:160x160
default_m:200x200
default_md:320x320
default_xl:400x400