Skip to content

Instantly share code, notes, and snippets.

View Immolare's full-sized avatar

Pierre Viéville Immolare

View GitHub Profile
@Immolare
Immolare / merge-zip-files-to-folder-script.php
Last active April 23, 2024 13:01
Merge files from zip archive to a destination folder
const ZIP_FILEPATH = '/path';
const ZIP_FILENAME = 'archive.zip';
const ZIP_SUBDIRNAME = 'subdir'; // Folder inside archive
const ZIP_MAINDIRNAME = "maindir"; // Target folder containing files
/* If small archive folder use PHP. Note, on some big archives it doesn't extract all subfolders and files */
function mergeFromZipPHP()
{
$zip = new ZipArchive; // need to be isntalled on server
$zipPath = self::ZIP_FILEPATH.'/'.self::ZIP_FILENAME;
@Immolare
Immolare / composer-memory-limit-vagrant.sh
Last active December 12, 2022 10:19
Facing Composer memory limit on Vagrant
Potential issue on big projects. Composer can't require or update due to Vagrant's memory limits
$ /bin/dd if=/dev/zero of=/var/swap.1 bs=4096k count=1024
$ chmod 600 /var/swap.1
$ /sbin/mkswap /var/swap.1
$ /sbin/swapon /var/swap.1
$ COMPOSER_MEMORY_LIMIT=-1 composer require librairie/yours
@Immolare
Immolare / queuing-large-amount-of-tasks
Last active April 4, 2020 15:34
[TIP] Process large amount of bulk tasks
# Queuing process vs one call :
## One call :
How to finish a server. Could result by an execution time exception, not optimised for large amount of tasks and very bad for user experience
## Queuing :
The tasks will be added to a queue and treated one by one with a cron job : this save user experience and performance
# For each task generate 1 .json/.txt file in a directory