Skip to content

Instantly share code, notes, and snippets.

View mikemcbride's full-sized avatar
🍪
accepting cookies

Mike McBride mikemcbride

🍪
accepting cookies
View GitHub Profile
@mikemcbride
mikemcbride / _get.js
Created November 14, 2019 14:22
Like _get from lodash but with zero dependencies
const _get = function(object, path, defaultVal) {
const _path = Array.isArray(path)
? path
: path.split('.').filter(i => i.length)
if (!_path.length || object === undefined) {
return object === undefined ? defaultVal : object
}
return _get(object[_path.shift()], _path, defaultVal)
@mikemcbride
mikemcbride / vmrss
Last active May 8, 2023 15:30
Bash implementation of the vmrss linux util
#!/usr/bin/env bash
if [[ "${1}" == "" ]]; then
echo "must provide a process"
exit 1
fi
while :
do
ps -o rss "${1}" | tail -1 | numfmt --to=si
@mikemcbride
mikemcbride / compress.fish
Last active June 25, 2025 05:22
Compress Video Files
# This script will loop through all files in the current directory and its subdirectories,
# and then will use ffmpeg to compress them using the H.265 codec.
# It will output the compressed files to a new directory called "optimized".
# This will retain the original directory structure, which is ideal for modifying video libraries like Plex.
for f in **/*;
if test -d $f;
mkdir -p optimized/$f;
else if test -f $f;
ffmpeg -i $f -vcodec libx265 -c:a copy -crf 28 -tag:v hvc1 optimized/$f;