This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
// Script example.php | |
// check CLI commands are available | |
$commands = getCommands(); | |
if (empty($commands)) exit; | |
// see https://secure.php.net/manual/en/function.getopt.php | |
// : - required, :: - optional |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Clear an array of empty values and specified keys | |
* | |
* @param array $keys array keys to explicitly remove regardless | |
* @return array the trimmed down array | |
*/ | |
function array_clear($array, $keys = []) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Clear an array of empty values | |
* | |
* @param array $keys array keys to explicitly remove regardless | |
* @return array the trimmed down array | |
*/ | |
function array_clear($array, $keys = []) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DEBUG', 1); | |
define('VERBOSE', 1); | |
// Output verbose message if VERBOSE constant is set | |
function verbose(string $message, mixed $data = ''): bool { | |
if (VERBOSE && !empty($message)) { | |
echo trim('[V ' . memoryUsage() . '] ' . $message) . "\n"; | |
if (!empty($data)) { | |
print_r($data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caffeinate -i youtube-dl --yes-playlist --download-archive archive.log -r 768k \ | |
--skip-unavailable-fragments --playlist-random --write-info-json \ | |
--write-description --no-check-certificate --prefer-insecure \ | |
--sleep-interval 10 --max-sleep-interval 50 \ | |
--ignore-errors \ | |
$1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* pdf-compress.php - re-compress PDFs, shrinking if possible | |
* WARNING: May run extremely slowly due to very large file sizes generated on pdf2ps | |
* | |
* relies on command-line tools, tested on ubuntu. | |
* | |
* @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* pdf-compress.php - re-compress PDFs, shrinking if possible | |
* WARNING: May run extremely slowly due to very large file sizes generated on pdf2ps | |
* | |
* relies on command-line tools, tested on ubuntu. | |
* | |
* @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* pdf_rename_metadata.php - get metadata from files readable with exiftool and rename | |
* creates 2 cache files, metadata.ser and metadata.old.ser | |
* where old.ser is the old version of metadata.ser for comparison | |
* | |
* https://www.sno.phy.queensu.ca/~phil/exiftool/#filename | |
* see https://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html | |
* | |
* relies on command-line tools, tested on MacOS. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* get-metadata.php - get metadata from files readable with exiftool | |
* creates 2 cache files, metadata.ser and metadata.old.ser | |
* where old.ser is the old version of metadata.ser for comparison | |
* | |
* https://www.sno.phy.queensu.ca/~phil/exiftool/#filename | |
* see https://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html | |
* | |
* relies on command-line tools, tested on MacOS. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* get-rename.php - get metadata from files readable with exiftool | |
* and presents options for renaming | |
* creates cache files, metadata.ser | |
* | |
* https://www.sno.phy.queensu.ca/~phil/exiftool/#filename | |
* see https://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html | |
* | |
* relies on command-line tools, tested on MacOS. |