Skip to content

Instantly share code, notes, and snippets.

@mperlet
mperlet / check_iban.py
Created Apr 5, 2017
Python IBAN Checker
View check_iban.py
# Based on http://codereview.stackexchange.com/questions/135366/python-iban-validation
import string
def is_iban(unchecked_iban):
LETTERS = {ord(d): str(i) for i, d in enumerate(string.digits + string.ascii_uppercase)}
def _number_iban(iban):
@mperlet
mperlet / parentHeight.js
Created Dec 17, 2020
jQuery calculate parent height by sum up childrens height
View parentHeight.js
var parentHeight = $.map($('.parent > *'), function (i) {
return ($(i).height())
}).reduce(function (accumulator, currentValue) {
return accumulator + currentValue;
}, 0);
$('.parent').height(parentHeight);
@mperlet
mperlet / ostseezeitung-plus.sh
Created Dec 10, 2020
Shell function to read Ostsee-Zeitung Plus articles
View ostseezeitung-plus.sh
function oz {
# bash> oz "https://www.ostsee-zeitung.de/Nachrichten/MV-aktuell/MV-plant-kompletten-Corona-Lockdown-in-wenigen-Tagen"
echo "{ $(curl -s "$1" | grep -o '\"description\":\".*')" | jq .articleBody
}
@mperlet
mperlet / python_port_open.sh
Created Mar 24, 2017
python port check one line bash
View python_port_open.sh
python -c "import socket;print(True) if 0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('127.0.0.1',8000)) else False"
@mperlet
mperlet / change_none_unique_minidlna_title.sh
Created Aug 18, 2015
Problem: minidlna use the title from the metadata, sometimes its better when the title = the filename. This script change the title from "'HERE THE NONE UNIQUE TITLE'" to the filename.
View change_none_unique_minidlna_title.sh
for line in $(sqlite3 /root/minidlna/files.db "SELECT ID,PATH FROM DETAILS WHERE TITLE='HERE THE NONE UNIQUE TITLE';");
do
id=$(echo $line | cut -d"|" -f1);
path=$(echo $line | cut -d"|" -f2);
echo $id;
echo $path;
sqlite3 /root/minidlna/files.db "UPDATE DETAILS SET TITLE='$(basename $path)' WHERE ID=$id;";
done;
@mperlet
mperlet / Google Meet Focus And Toggle Mic
Created May 26, 2020
I use that script for a gnome keyboard shortcut
View Google Meet Focus And Toggle Mic
xdotool search --name 'Meet' | xargs xdotool windowactivate;sleep 0.2; xdotool key Ctrl+d
View record_mp3_and_split.sh
# record from soundcard
parec -d 1 | lame -r -V0 - my.mp3
# split file by silence
ffmpeg -i my.mp3 -af silencedetect=noise=-30dB:d=0.5 -f null - 2>&1 | grep silence_end | cut -d" " -f 5 | xargs -L 2 | nl | xargs -l bash -c 'ffmpeg -i my.mp3 -acodec copy -ss $1 -to $2 my$0.mp3'
@mperlet
mperlet / pycheck.sh
Created Jan 4, 2019
Check python files in pwd
View pycheck.sh
function pycheck() {
echo
echo
echo
find . -name "*.py" | xargs mypy --ignore-missing-imports
echo
echo
@mperlet
mperlet / imagediff.sh
Created Sep 6, 2018
Diff two images with imagemagick without saving them
View imagediff.sh
#!/bin/bash
# TODO: Add Readme
# TODO: Add Example
# TODO: Check if imagemagick is installed
IMG_A="$1"
IMG_B="$2"
convert "$IMG_A" "$IMG_B" <(compare "$IMG_A" "$IMG_B" -) +append - | display
View Abfall_LRO_iCal_Api.sh
curl 'https://www.abfall-lro.de/wp-content/themes/abfall_lro/ical.php?letters=B_K_D_P&year=2018&black=4w&green=&yellow=y&blue=y'