Skip to content

Instantly share code, notes, and snippets.

View dewomser's full-sized avatar
😎
leisure at work

Stefan Höhn dewomser

😎
leisure at work
View GitHub Profile
View firefox_text_wieder_herstellen.txt
FYI, when a website erases your text that you just spent an hour writing, you can use this little trick to recover it 99% of the time:
1. find the firefox pid
$ pgrep -l firefox
2. attach gdb to firefox and dump its core
$ sudo gdb -p <pid>
gcore firefox.dump
@dewomser
dewomser / firefox_copy_url.sh
Last active August 26, 2023 15:34
copy URL from Firefox to Bash
View firefox_copy_url.sh
#!/bin/bash
# xdotool is necessary
# Search for the visible Firefox window(s) and get its window ID
window_id=$(xdotool search --onlyvisible --class "firefox")
# Send the keyboard shortcut to open the URL bar, copy the URL to clipboard and then close the URL bar by sending the Escape key.
# The command is sent to the Firefox window with the specified ID using the --window option.
xdotool key --window $window_id --delay 20 --clearmodifiers ctrl+l ctrl+c Escape
@dewomser
dewomser / videocut.sh
Created August 10, 2023 08:43
Videoclip ausschneiden mit ffmpeg , Von Sekunde 7 , Länge 1.26 Minuten
View videocut.sh
fmpeg -i porn.mp4 -ss 7 -t 01:26 porn_xxx.mp4
@dewomser
dewomser / google_search.sh
Created July 15, 2023 16:55
google search CLI
View google_search.sh
#!/bin/bash
# /usr/bin/shellcheck "${0##*/}"
echo -e '\e[38mG\e[m' '\e[31mo\e[m' '\e[33mo\e[m' '\e[38mg\e[m' '\e[32ml\e[m' '\e[31me\e[m'
if [[ -z $1 ]] ; then
read -p "Suche: " query ;lynx -dump --display_charset=utf-8 "http://google.com/search?q=$(echo $query | sed 's/ /+/g')"|grep '^[[:blank:]][[:blank:]].[[:digit:]][[:punct:]]'| grep http://www.google.com/url\?q=http | sed -e 's/http:\/\/www.google.com\/url?q=//g' |sed -e 's/&sa=.*$//g'|grep -v google | cut -c5- | sed -rn "=;p;"| sed -r "N;s/\n//" | sed -e "s/\<\([0-9]\{1,2\}\)\>/0000\1/; s/\<0*\([0-9]\{2\}\)\>/\1/" |sed -e "s/^/ /g"
else
query="$1";lynx -dump --display_charset=utf-8 "http://google.com/search?q=$(echo $query | sed 's/ /+/g')"|grep '^[[:blank:]][[:blank:]].[[:digit:]][[:punct:]]'| grep http://www.google.com/url\?q=http | sed -e 's/http:\/\/www.google.com\/url?q=//g' |sed -e 's/&sa=.*$//g'|grep -v google | cut -c5- | sed -rn "=;p;"| sed -r "N;s/\n//" | sed -e "s/\<\([0-9]\{1,2\}\)\>/0000\1/; s/\<0*\([0-9]\{2\}\)\>/\1/" |sed -e "s/^/ /g
@dewomser
dewomser / luftqualitaet.sh
Created June 22, 2023 13:31
API Luftqualität deutsche Messstationen der Länder
View luftqualitaet.sh
#!/bin/bash
ba=https://www.umweltbundesamt.de
readarray -td ";" lq <<< $(curl "$ba/api/air_data/v3/airquality/csv?date_from=$(date -d 'yesterday' +%F)&time_from=24&date_to=$(date +%F)&time_to=24&station=1460&lang=de" |grep -E x\|$(date -d '1 hours ago' +%H))
echo ${lq[1]}:${lq[7]};echo ${lq[2]}:${lq[8]};echo ${lq[3]}:${lq[9]};echo ${lq[4]}:${lq[10]};echo ${lq[5]}:${lq[11]};echo ${lq[6]}:${lq[12]}
#Messtationen gibts hier:
#https://www.umweltbundesamt.de/daten/luft/luftdaten/stationen/
#Messtationcode kopieren und in Zeile 3 ersetzen
@dewomser
dewomser / text_erkennen.sh
Last active June 8, 2023 15:47
OCR kopiert Text in die Zwischenablage . Ein Bashscript
View text_erkennen.sh
!/usr/bin/bash
/usr/bin/import "$HOME"/bin/text_erkennen.png
wait
tesseract -l deu "$HOME"/bin/text_erkennen.png "$HOME"/bin/text_erkennen
#eng
wait
text=$(cat "$HOME/bin/text_erkennen.txt")
dbus-send --type=method_call --dest=org.kde.klipper /klipper org.kde.klipper.klipper.setClipboardContents string:"$text"
@dewomser
dewomser / google_query_csv.sh
Last active September 22, 2023 00:50
Googlequery output as csv a Bash 1-liner
View google_query_csv.sh
# mit http
# funktioniert sofort.
query="linux%20worms";lynx -dump -cookies="" --display_charset=utf-8 "http://google.com/search?q=$(echo $query | sed 's/ /+/g')"|grep '^[[:blank:]][[:blank:]].[[:digit:]][[:punct:]]'| grep http://www.google.com/url\?q=http | sed -e 's/http:\/\/www.google.com\/url?q=//g' |sed -e 's/&sa=.*$//g'|grep -v google | cut -c5- | sed -rn "=;p;"| sed -r "N;s/\n//" | sed -e "s/\<\([0-9]\{1,2\}\)\>/0000\1/; s/\<0*\([0-9]\{2\}\)\>/\1/" |sed -e "s/^/ /g"| sed -e "s/\./;/1" > googlequery.csv
# mit https und cookies.
# Damit die Zeile funktioniert:
# zuerst "lynx-cookies -accept_all_cookies https://www.google.com"
# dann das Zeugs bestätigen damit alle Cookies persistent gesetzt sind
# danach funktioniert diese Zeile solange die Cookies nicht gelöscht werden.
@dewomser
dewomser / umweltdaten.sh
Last active May 6, 2023 17:22
Aktuelle Umweltdaten Luft für deutsche Städte
View umweltdaten.sh
#!/bin/bash
#Daten werden mit > 1h < 2h Zeitverzögerung angegben
# Hier gibts die URL https://www.umweltbundesamt.de/daten/luft/luftdaten/luftqualitaet/ -> Stadt auswählen -> die URL ist der Link unter "Als CSV herunterladen"
# -> Stationsnummer In die nächste Teile kopieren
readarray -td ";" lq <<< $(curl "https://www.umweltbundesamt.de/api/air_data/v3/airquality/csv?date_from=$(date -d 'yesterday' +%F)&time_from=24&date_to=$(date +%F)&time_to=24&station=1460&lang=de" |grep -E x\|$(date -d '1 hours ago' +%H))
echo ${lq[1]}:${lq[7]};echo ${lq[2]}:${lq[8]};echo ${lq[3]}:${lq[9]};echo ${lq[4]}:${lq[10]};echo ${lq[5]}:${lq[11]};echo ${lq[6]}:${lq[12]}
@dewomser
dewomser / toot_a_photostream.sh
Last active May 1, 2023 13:45
mastodon toot a photostream make and destroy toots in a time intervall
View toot_a_photostream.sh
#!/bin/bash
#crontab
#for crontab use always full path or EXPORT
#crontabline : */15 * * * * /full/path/toot_a_photostream.sh >/full/path/error.txt 2>&1
toottext="Your text at $(date +%H:%M) . New snapshot every 15 minutes!"
tootid="$(cat /full/path/tootid.txt)"
sleep 120
if [ -z "$tootid" ]; then
echo "still no ID"
@dewomser
dewomser / mastodon_user.sh
Created March 6, 2023 04:20
List all mastodon user who contains "bash" in name or address . A Bash 1-liner
View mastodon_user.sh
# userlist only address :
toot search bash | grep ^* |awk '{print $2}'
# userlist and profile advanced :
readarray -t tooter_array <<<"$(toot search bash | grep ^* |awk '{print $2}')" && for i in "${tooter_array[@]}"; do echo -e "$(toot whois $i) \n ------------------\n";done