Skip to content

Instantly share code, notes, and snippets.

@juozaspo
juozaspo / chroot-wrapper.sh
Last active December 3, 2020 13:34
Wrapper for automating various common jobs while chrooting offline debian based system
#!/bin/bash
target="${1%/}"
[ -z "$target" ] && {
echo "Wrapper for chroot to set up variables and after use cleanup."
echo "Usage: $0 target"
exit 1
}
target="$(realpath "$target")"
[ -d "$target" ] || {
@juozaspo
juozaspo / random.sh
Last active August 5, 2020 14:17
Generating html from 100 random images in a folder
#!/bin/bash
jpg=$(find -maxdepth 1 -type f -iname "*.jpg" -printf '%P\n')
gif=$(find -maxdepth 1 -type f -iname "*.gif" -printf '%P\n')
png=$(find -maxdepth 1 -type f -iname "*.png" -printf '%P\n')
random=$(echo -e "$jpg\n$gif\n$png" | sort | shuf -n100 | sed "s/'/\\\'/g" | xargs -I{} sh -c 'echo "<img title=\"{} $(du -h "{}"|cut -f 1)\" src=\"{}\"><br>"' | tr -d '\n')
echo -e "<html><head><title>Random Images</title></head><style>img {margin:.5em;max-width:100%}img:first-child{margin-top:0}body{text-align:center;}</style><body>$random<body></html>"