Skip to content

Instantly share code, notes, and snippets.

@za3k
za3k / onerng.sh
Last active June 6, 2021 23:57
onerng.sh
#!/bin/bash
ONERNG=/dev/ttyACM0
t=onerng.out
stty -F $ONERNG raw -echo clocal -crtscts
echo "cmd0" >$ONERNG # standard noise
echo "cmdO" >$ONERNG # turn it on
stty -F $ONERNG raw -echo clocal -crtscts
gone() {
echo "cmdo" >$ONERNG # turn it off
@za3k
za3k / download-e621.bash
Last active May 26, 2021 03:08
download-e621.bash
#!/bin/bash
#
# e621 downloader. maintains a mirror of e621 (just DB export+images, not the HTML)
# suggested use is to run this from crontab once per day.
# this maintains an infinite number of database snapshots and also keeps deleted images forever (in a separate directory) because I'm a packrat. feel free to modify to delete old stuff.
#
# written by zachary "za3k" vance. released in the public domain
#
# dependencies: csvtools (davylandman), chronic (joeyh's moreutils, optional), wget, gzip, coreutils
#
[18Mar2020 18:25:33.052] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, Za3k, --version, 1.15.2-forge-31.1.25, --gameDir, /home/games-x11/.minecraft, --assetsDir, /home/games-x11/.minecraft/assets, --assetIndex, 1.15, --uuid, 497ab4c654ef4664a8a498c161941088, --accessToken, ❄❄❄❄❄❄❄❄, --userType, legacy, --versionType, release, --launchTarget, fmlclient, --fml.forgeVersion, 31.1.25, --fml.mcVersion, 1.15.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20200307.202953]
[18Mar2020 18:25:33.057] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 5.0.0-milestone.4+67+b1a340b starting: java version 13.0.2 by Oracle Corporation
[18Mar2020 18:25:33.323] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust
[18Mar2020 18:25:33.367] [main/WARN] [net.minecraftforge.fml.loading.FMLConfig/CORE]: Configuration file /home/games-x11/.minecraft/config/fml.toml is not correct. Correcting
[1
@za3k
za3k / combine_pbm.py
Created December 22, 2019 10:29
pbm layout
import os.path, sys
memory_available = 4 * (10**9)
outfile = "out.pbm"
default_tsv_file="image_lookup_table.tsv"
DEBUG = False
def debug(*x):
if DEBUG:
print(*x)
@za3k
za3k / git-objects-du
Created May 4, 2017 19:06
Print the size breakdown of git objects
#!/bin/sh
NUMFORMAT=cat
for program in numfmt gnumfmt
do
if which "${program}" 2>/dev/null >/dev/null
then
NUMFORMAT="${program} --to=si"
break
fi
done
@za3k
za3k / keybase.md
Last active November 5, 2015 20:32

Keybase proof

I hereby claim:

  • I am za3k on github.
  • I am za3k (https://keybase.io/za3k) on keybase.
  • I have a public key whose fingerprint is 4F92 E819 BBDB 4225 ABE6 9043 7DA2 C164 1594 B27F

To claim this, I am signing this object:

@za3k
za3k / md5sum_dir
Last active August 29, 2015 14:12
md5sum expanded to work for directories
#!/bin/bash
md5_folder() {
{
# Print md5 hash of every file
find "$1" -type f -print0 | sort -z | xargs -0 md5sum
# Print the names of all files and directories
find "$1" -printf %P\\0
} | md5sum | awk '{print $1}'
}
RESTORE_DIR="/home/zachary/annex-documents-restored"
cat annex-unused-keys | tail -n +4 | head -n -5 | awk -e '{print $2}' | while read shasum; do
cd /shared
if git log --oneline -1 --stat -S"${shasum}" | grep "^ documents/" >/dev/null ; then
#echo "Object: ${shasum}"
document="$(git log --oneline -1 --stat -S"${shasum}" | head -n 2 | tail -n 1 | sed -e 's/|.*//' | sed -r -e 's/^ +//' | sed -r -e 's/ +$//')"
#echo "Document: ${document}"
source_file="$(git annex examinekey ${shasum} --format='/shared/.git/annex/objects/${hashdirmixed}${key}/${key}')"
#echo "File location: ${source_file}"
target="$RESTORE_DIR/$document"
@za3k
za3k / gist:6337391
Last active May 4, 2017 19:07
Copy chromium's URL history to a logfile, and delete the original history if possible (e.g. if chromium is not running). Logfile is in the line-based format "<windows timestamp>|<url>".
#!/bin/bash
DATABASE=$(mktemp)
CHROMEDB=~/.config/chromium/Default/History
ISLOCKED=$(sqlite3 ~/.config/chromium/Default/History "SELECT COUNT(*) from urls" 2>&1 1>/dev/null)
EXPORT_FILE=~/.visited_urls
if [ ! -f "${CHROMEDB}" ]
then
echo "Chrome database \"$CHROMEDB\" is missing. This may be normal behavior if the history is cleared."
exit 0