Skip to content

Instantly share code, notes, and snippets.

Avatar

Tobias Schmidl schtobia

View GitHub Profile
View debdiffconf
#!/bin/bash
# Usage: debdiffconf.sh <filename>
# Produce on stdout, a diff of <filename> against the first installed Debian
# package found that provides it.
# Returns the exit code of diff if everything worked, 3 or 4 otherwise.
base_name=$(basename $0)
required=( apt-get apt-file diff dpkg-deb dpkg-query realpath)
@schtobia
schtobia / merge-pdfs.sh
Last active Jun 5, 2020
Merge PDFs with images in 300dpi
View merge-pdfs.sh
#! /bin/sh
[ "$#" -lt 2 ] && { echo "Usage: $0 <outputfile> <inputfile> ..."; exit 1; }
output_file="$1"
shift
gs -dBATCH -dNOPAUSE -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -o "$output_file" $@
@schtobia
schtobia / grep-https-user-rules.sh
Created Jun 22, 2018
Grep HTTPS user rules from firefox profile
View grep-https-user-rules.sh
#! /bin/sh
sqlite3 $HOME/.mozilla/firefox/*.default/storage-sync.sqlite 'select record from collection_data where record_id="key-userRules";' | jq .data
View adblock-sync.sh
#! /bin/sh
jq -c '[.selectedFilterLists[] as $selected | .availableFilterLists[$selected] | select(.hasRemoteURL == true) | .remoteURL]' \
$HOME/.mozilla/firefox/*.default/browser-extension-data/uBlock0@raymondhill.net/storage.js | xargs -0 \
gsettings set org.gnome.Epiphany adblock-filters
@schtobia
schtobia / regenerate-ctags
Last active Jul 2, 2018
regenerate ctags on edit
View regenerate-ctags
#! /bin/sh
watchmedo shell-command --patterns="*.cpp;*.hpp" --ignore-patterns='./__cmake_systeminformation*;./_build*;.' --wait \
--recursive --command="find . -path './_build' -prune -name '*.cpp' -or -name '*.hpp' -exec ctags --verbose=yes '{}' '+'"
@schtobia
schtobia / cleanup.sh
Last active Sep 24, 2021
cleanup a linux guest, shortlink is https://git.io/vhaoU
View cleanup.sh
#! /bin/sh
rm -rf /root/.cache /root/.rnd
find /tmp -type d -name 'systemd-*-systemd-timesyncd.service*' -exec rm -rf '{}' '+'
find /var/tmp -type d -name 'systemd-*-systemd-timesyncd.service*' -exec rm -rf '{}' '+'
find /var/lib/apt -type f -delete
find /var/cache/apt -type f -delete
find /var/log -type f -regextype posix-extended -regex '.*\.(gz|xz|[0-9])' -delete
truncate -s0 $HOME/.bash_history
[ -w $HOME/.zsh_history ] && truncate -s0 $HOME/.zsh_history
@schtobia
schtobia / usb-blockdev.sh
Last active Jan 8, 2020
Device HMAC from USB serial
View usb-blockdev.sh
#! /bin/sh
openssl dgst -hmac `< /sys/class/block/sdb/device/model` -binary keyfile | base64
View maint.cmd
@echo off
choco upgrade -y all
del C:\ProgramData\chocolatey\logs\chocolatey.log
del C:\ProgramData\chocolatey\logs\choco.summary.log
echo SageRun
cleanmgr /sagerun:1
dism /online /Cleanup-Image /StartComponentCleanup
set UD_DISABLE_REPORTS=1
udefrag %SystemDrive%
sdelete -z %SystemDrive%
@schtobia
schtobia / dex.md
Created May 29, 2018
Open .desktop files under bash
View dex.md
  1. check if dex is installed:

    vimes ~ » [ -x "$(which dex)" ] && echo "Dex is installed." || echo "Dex is not installed."
    Dex is not installed.
    vimes ~ » 
    
  2. so, install dex:

    vimes ~ » sudo apt install dex
    
@schtobia
schtobia / pratchett-quote-file.sh
Created May 11, 2018
convert the pratchett quote file to a fortune cookie
View pratchett-quote-file.sh
#! /bin/sh
sed '/^$/N;s/^\n/$/' "$1" > "$2"
strfile -rc '$' "$2"