Skip to content

Instantly share code, notes, and snippets.

View vijinho's full-sized avatar

Vijay vijinho

  • England
View GitHub Profile
@vijinho
vijinho / 0make_uae_configs.php
Last active August 16, 2018 16:06
PHP script to generate FS-UAE .ini config files from folder/subfolders of Commodore Amiga .adf/.afz files
<?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]
@vijinho
vijinho / wipe-files.sh
Created August 26, 2018 14:33
overwrite files with random data and then remove
#!/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
@vijinho
vijinho / rsync-fast.sh
Last active January 6, 2025 10:56
fast rsync with an excludes file
time $(which rsync) \
--partial \
--delay-updates \
-aAHHSxXESy \
--stats \
--exclude-from=$HOME/.rsync-excludes
@vijinho
vijinho / jpeg-rename.sh
Last active August 31, 2018 04:34
jpeg image - add comment (and/or rename based on exif date setting file time if exif exists)
# 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}" {} \;
@vijinho
vijinho / all_dirs.php
Last active August 26, 2018 18:30
get all files (and optionally dirs) in a dir path
#!/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)) {
@vijinho
vijinho / jpeg_squares.php
Created August 30, 2018 17:42
find square images in a folder and list number per pixel width size and also which files
<?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);
@vijinho
vijinho / small_images.php
Created September 2, 2018 04:25
find small jpg images
<?php
// find small jpeg images
$cmd = 'find . -type f -iname "*.jp*" -print';
$files = cmd_execute($cmd);
$counts = [];
$by_size = [];
foreach ($files as $k => $path) {
$data = getimagesize($path);
@vijinho
vijinho / ytdlmp3.sh
Last active November 12, 2019 04:19
yt download to mp3 (use -s to test, remove caffeinate if not macos), post-processing with https://gist.github.com/vijinho/c8e2abd174d1d9ae71541c9007da701a
caffeinate -i youtube-dl --yes-playlist --download-archive archive.log -r 256k \
--skip-unavailable-fragments --playlist-random --write-info-json \
--write-description --no-check-certificate \
--sleep-interval 10 --max-sleep-interval 50 --merge-output-format mp4 \
--audio-format mp3 --audio-quality 0 --extract-audio --embed-thumbnail \
--ignore-errors \
$1
# see https://gist.github.com/vijinho/c8e2abd174d1d9ae71541c9007da701a for post-processing
@vijinho
vijinho / rsync-clone-system.sh
Last active January 6, 2025 11:01
rsync with the options I used to clone a root linux filesystem from one disk to another
time $(which rsync) \
--archive \
--checksum \
--super \
--stats \
--acls \
--hard-links \
--xattrs
@vijinho
vijinho / ytdlmp3-post-process.php
Last active September 6, 2018 13:21
post-processing of filenames into mp3 tags from download output of https://gist.github.com/vijinho/645786c3ab8133d49ca9ef9b50a3944f
#!/usr/bin/php
<?php
// counterpart to https://gist.github.com/vijinho/645786c3ab8133d49ca9ef9b50a3944f
// for post processing filenames
$cmd = 'find . -type f -iname "*.mp3" -depth 1 -print';
$files = cmd_execute($cmd);
sort($files);
$data = $tags = [];
foreach ($files as $j => $path) {