Skip to content

Instantly share code, notes, and snippets.

@mperlet
mperlet / parentHeight.js
Created December 17, 2020 07:28
jQuery calculate parent height by sum up childrens height
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 December 10, 2020 13:19
Shell function to read Ostsee-Zeitung Plus articles
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 / Google Meet Focus And Toggle Mic
Created May 26, 2020 10:54
I use that script for a gnome keyboard shortcut
xdotool search --name 'Meet' | xargs xdotool windowactivate;sleep 0.2; xdotool key Ctrl+d
# 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 January 4, 2019 11:29
Check python files in pwd
function pycheck() {
echo
echo
echo
find . -name "*.py" | xargs mypy --ignore-missing-imports
echo
echo
@mperlet
mperlet / imagediff.sh
Created September 6, 2018 10:32
Diff two images with imagemagick without saving them
#!/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
@mperlet
mperlet / Abfall_LRO_iCal_Api.sh
Created February 20, 2018 09:39
Abfall LRO iCal API
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'
@mperlet
mperlet / vcy
Created February 11, 2018 09:49
vlc player chromecast youttube-dl
#!/bin/bash
# v - VLC Player
# c - chromecast
# y - youttube-dl
CHROMECASTIP="192.168.178.39"
STREAMURI="$1"
CERTDIR="$HOME/.vcy"
mkdir -p "$CERTDIR"
@mperlet
mperlet / yt2mp3.sh
Created August 23, 2017 06:48
Convert Youtube-Videos or Playlists to mp3
#!/bin/bash
# Example: $ yt2mp3 "https://www.youtube.com/playlist?list=PL63F1E17EE312CC7D"
function yt2mp3 () {
youtube-dl -i -t --extract-audio --audio-format mp3 "$1"
}
#!/bin/bash
echo "Start random stress"
while true; do
RANYES=$[ ( $RANDOM % 4 ) + 1 ]
RANSTR=$[ ( $RANDOM % 300 ) + 1 ]s
RANSLEEP=$[ ( $RANDOM % 3000 ) + 1 ]s
echo "Start $RANYES proccess for $RANSTR seconds"
c=1