Skip to content

Instantly share code, notes, and snippets.

View jhamfler's full-sized avatar

Johannes Hamfler jhamfler

View GitHub Profile
# get path of script
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# pass exit status to parent shell if anything fails
set -eEo pipefail
shopt -s inherit_errexit >/dev/null 2>&1 || true
@jhamfler
jhamfler / vm
Created June 22, 2020 11:14
VM commands
# change time offset to HW clock [ms] to -1day
VBoxManage modifyvm 'vmname' --biossystemtimeoffset -86400000
# hosts by manufacturer
arp-scan -l
# small http upload server
webfsd -F -d -p 55555
@jhamfler
jhamfler / pdf
Last active June 11, 2020 08:48
PDF commands
# split all A3 pages into A4 except first and last
a=($(ls -d *.pdf))
for f in ${a[@]} ;do
[ "${a[1]} " != "$f " ] && [ "${a[-1]} " != "$f " ] && pdfposter -m a4 -p 2x1a4 "$f" "$f.cut"
done
# rotate +90° (mathematical) and split all pages
b=($(ls -d *.cut))
for f in ${b[@]} ;do
pdftk $f cat 1-endwest output "$f.pdf"
@jhamfler
jhamfler / regexe
Last active October 16, 2019 09:15
# IPv4 is inside a String
echo "address is 127.0.0.1 ." | grep -Eo '((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])'
# IPv4 string can only be an IPv4-address
echo "127.0.0.1" | grep -Eo '^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$'
# replace \n with " "
sed ':a;N;$!ba;s/\n/ /g'
# ENCODE
# AUDIO
# upmix stereo to 5.1
ffmpeg -i sound.opus -filter_complex "[0:a]pan=5.1(side)|FL=FL|FR=FR|LFE<FL+FR|FC<0.5*FR+0.5*FL|SL=FL|SR=FR[a]" -map 0 -map -0:a -map "[a]" -c copy -c:a flac output.flac
# convert any audio in current dir to mp3 in parallel
ls -1 --file-type | parallel --max-args 1 ffmpeg -i "{}" -vn -ar 44100 -ac 2 -b:a 192k "/path/{.}.mp3"
# VIDEO
# 4k h264/5, practical, small, ok
# Erste Schritte
Kommandozeile öffnen und Git konfigurieren:
```
git config --global user.name "Vorname Nachname"
git config --global user.email "vorname.nachname@stud.htwk-leipzig.de"
```
Repository clonen:
```