Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Sephton gingerbeardman

View GitHub Profile
@gingerbeardman
gingerbeardman / gif-opt-2x.sh
Last active May 5, 2022
Scale a GIF @2x and Optimise using gifsicle
View gif-opt-2x.sh
FILE=`basename "$@" .gif`
PARENT=`dirname "$@"`
/usr/local/bin/gifsicle -O1 -Okeep-empty --careful --scale 2 "$@" > "$PARENT/$FILE.opt.gif"
@gingerbeardman
gingerbeardman / timemachine-network.sh
Created May 5, 2022
Restore the most recent copy of a file from Time Machine
View timemachine-network.sh
#!/bin/bash
# by Matt Sephton, @gingerbeardman
currentFile="$@"
backupRoot=`cd "/Volumes/Backups of matt/";cd *.previous;pwd`
localData="/System/Volumes/Data"
backupData="$backupRoot/Mac mini - Data"
@gingerbeardman
gingerbeardman / pac-yahoo-japan.js
Last active Apr 17, 2022
Example PAC file to route only access to Yahoo! Japan for the website and app
View pac-yahoo-japan.js
function FindProxyForURL(url, host) {
if (
dnsDomainIs(host, "storage-yahoo.jp") ||
dnsDomainIs(host, "yahooapis.jp") ||
dnsDomainIs(host, "yimg.jp") ||
dnsDomainIs(host, "yahoo.co.jp")
) return "PROXY 12.34.56.78:8888";
return "DIRECT";
}
@gingerbeardman
gingerbeardman / page.auctions.yahoo.co.jp.css
Last active Apr 7, 2022
dot files for Safari extension "PageExtender" to redirect Yahoo! Japan Auctions item pages to an equivalent of your choice
View page.auctions.yahoo.co.jp.css
* {
display: none !important;
}
@gingerbeardman
gingerbeardman / import_bookmarks.php
Last active Feb 23, 2022
import browser bookmarks.html FAST using a regex with optional named groups
View import_bookmarks.php
// href and title are required
// everything else is an optional named group, using format \s*(ATTR="(?P<attr>.*?)")?
$pattern = '|<DT><A HREF="(?P<href>.*?)"\s*(ADD_DATE="(?P<add_date>.*?)")?\s*(LAST_MODIFIED="(?P<last_modified>.*?)")?\s*(ICON_URI="(?P<icon_uri>.*?)")?\s*(ICON="(?P<icon>.*?)")?\s*(PRIVATE="(?P<private>.*?)")?\s*(TOREAD="(?P<toread>.*?)")?\s*(TAGS="(?P<tags>.*?)")?>(.*?)</A>|';
$string = file_get_contents("bookmarks.html");
preg_match_all($pattern, $string, $matches, PREG_PATTERN_ORDER); // all pattern matches get their own sub-array
$array_filtered = array_filter($matches, "is_string", ARRAY_FILTER_USE_KEY); // keep only named arrays (our groups)
echo count($array_filtered[href]); // show count
@gingerbeardman
gingerbeardman / hoyoyo.js
Last active Jan 30, 2022
PAC to route some content used by world.hoyoyo.com through secure HTTPS proxy to increase loading speed
View hoyoyo.js
function FindProxyForURL(url, host) {
// send hoyoyo requests to the proxy
if (shExpMatch(host, "*.hoyoyo.com|*.hoyoyo-cache.com")) return "PROXY 12.34.56.78:90";
// leave all other accesses untouched
return "DIRECT";
}
@gingerbeardman
gingerbeardman / faststart.sh
Last active Feb 21, 2022
Synology DSM Task Scheduler custom script to set faststart movflag on all mp4 files
View faststart.sh
#!/usr/bin/env bash
# by Matt Sephton @gingerbeardman
# requires SynoCommunity ffmpeg to be installed
log="/volume1/video/Scripts/faststart.log"
work="/volume1/video/Scripts/"
start="../"
export log
@gingerbeardman
gingerbeardman / remux.sh
Last active Feb 21, 2022
Synology DSM Task Scheduler custom script to remux any mkv files as mp4, moving old files to Recycle Bin
View remux.sh
#!/usr/bin/env bash
# by Matt Sephton @gingerbeardman
# requires SynoCommunity ffmpeg to be installed
log="/volume1/video/Scripts/remux.log"
bin="/volume1/video/#recycle/"
work="/volume1/video/Scripts/"
export log
@gingerbeardman
gingerbeardman / extract-and-bake-order.sh
Last active May 24, 2022
Extract a zip and bake original sort order as Finder comments and last modified date
View extract-and-bake-order.sh
#!/bin/bash
# by Matt Sephton @gingerbeardman
# dependencies: p7zip, pipx, osxmetadata
# $ brew install p7zip
# $ brew install pipx
# $ pipx install osxmetadata
# check your PATH and confirm operation
@gingerbeardman
gingerbeardman / cat.sh
Last active Dec 2, 2021
Shell script to generate directory listings of old HFS CD-ROMs using my fork of hfsutils/hls and my convert2unicode.tcl script
View cat.sh
#!/usr/bin/env zsh
autoload colors; colors
cd "~/Documents/CD-ROMs"
rm *.txt
catalogue() {
while read -r iso; do
directory=$(dirname "$iso")