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 | |
// find square jpeg images | |
$cmd = 'find . -type f -iname "*.jp*" -print'; | |
$files = cmd_execute($cmd); | |
$counts = []; | |
$by_size = []; | |
foreach ($files as $k => $path) { | |
$data = getimagesize($path); |
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 | |
// get all files in a dir path, | |
function get_all_files($dir, $ignore_dirs = true) { | |
static $alldirs = array(); | |
$dirs = glob($dir . '/*'); | |
if (count($dirs) > 0) { | |
foreach ($dirs as $newdir) { | |
if (!array_key_exists($newdir, $alldirs)) { |
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
# jpeg image - add comment (and/or rename based on exif date setting file time if exif exists) delete thumb | |
export JHEAD_FILE_ARGS="%Y-%m-%d-%a-%H%M%S" | |
export COMMENT="image use allowed only by permission of vijay mahrra <[email protected]> - all rights reserved" | |
# add comment, auto-rotate, rename files with exif tags, set file date | |
find . -type f -iname "*.jp*" -exec jhead -cl "${COMMENT}" -exonly -zt -di -dt -ft -autorot -n${JHEAD_FILE_ARGS} {} \; | |
# add comment, set file date to all files - will skip existing | |
find . -type f -iname "*.jp*" -exec jhead -cl "${COMMENT}" {} \; |
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
time $(which rsync) \ | |
--partial \ | |
--delay-updates \ | |
-aAHHSxXESy \ | |
--stats \ | |
--exclude-from=$HOME/.rsync-excludes |
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
#!/bin/sh | |
files=$@ | |
for file in $files; | |
do | |
set `du $file`; | |
size=$1 | |
for times in 0 1 2; | |
do | |
dd if=/dev/urandom of=$file count=$size conv=notrunc | |
done |
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 | |
// script to generate fs_uae configs for amiga floppies on mac os x or linux (.fs-uae files) as a zip archive | |
// | |
// first organise games with more than one disk into a subfolder containing the disks | |
// this will auto-load each extra floppy drive drive with each floppy (up to 4) | |
// e.g. make a folder 'alien_breed' containing abreed1.adz and abreed2.adz, config created is: Alien_Breed.fs-uae | |
// run 'php 0make_uae_configs.php' in Floppies folder to generate .fs-uae configs in folder 0configs to manually copy/move | |
// | |
// place games with multiple floppies under a subfolder per game | |
// author: [email protected] |
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 | |
// Implement a memoization function to cache results of expensive function calls. | |
$timer = function ($function) { | |
// Create an array to store cached results based on function arguments. | |
$cache = []; | |
// Return a closure that wraps the original function. | |
return function (...$args) use ($function, &$cache) { | |
// Generate a unique key for the cache based on function arguments. |
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 | |
// https://www.youtube.com/watch?v=M3_xnTK6-pA?t=44m18s | |
// http://eddmann.com/posts/implementing-and-using-memoization-in-php/ | |
//$memoize = function ($function) { | |
function memoize($function) { | |
return function () use ($function) { | |
static $cache = []; | |
$args = func_get_args(); | |
$key = md5(serialize($args)); | |
if (empty($cache[$key])) { |
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('VERBOSE', 1); | |
define('DEBUG', 1); | |
//----------------------------------------------------------------------------- | |
// required commands check | |
$commands = get_commands([ | |
'find' => 'System command: find', | |
'curl' => 'https://curl.haxx.se', | |
'wget' => 'https://www.gnu.org/software/wget/' |
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 | |
/** | |
* url_resolve.php - CLI script for resolving url | |
* | |
* @author Vijay Mahrra <[email protected]> | |
* @copyright (c) Copyright 2018 Vijay Mahrra | |
* @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) | |
*/ |