Skip to content

Instantly share code, notes, and snippets.

@mpalet
mpalet / shell.sh
Created May 21, 2021 14:00
ffmpeg EBU R128 loudness measurement
ffmpeg -ss <skipseconds> -i <filename> -af loudnorm=print_format=summary -f null -
@mpalet
mpalet / gist:fb31428df4f59616d0ea20f0e18bbbc4
Last active January 4, 2020 19:44
Remove unicode diacritics

Removes UTF-8 NFD diacritics (osx) in path recursively replacing them for the simple ascii transliteration. Eg: À > A

find . -print | ggrep -P "[\x{00FF}-\x{FFFF}]" | while read f; do
  newfile="$(echo $f | sed -e 's/À/A/g;s/Á/A/g;s/Ä/A/g;s/à/a/g;s/á/a/g;s/ä/a/g;s/È/E/g;s/É/E/g;s/Ë/E/g;s/è/e/g;s/é/e/g;s/ë/e/g;s/Ì/I/g;s/Í/I/g;s/Ï/I/g;s/ì/i/g;s/í/i/g;s/ï/i/g;s/Ò/O/g;s/Ö/O/g;s/Ó/O/g;s/ò/o/g;s/ó/o/g;s/ö/o/g;s/Ù/U/g;s/Ú/U/g;s/Ü/U/g;s/ù/u/g;s/ú/u/g;s/ü/u/g' | iconv -f utf-8-mac -t ascii//TRANSLIT)"
  mv -v "$f" "$newfile"
done

Removes normalized UTF-8 diacritics (unix) in path recursively replacing them for the simple ascii transliteration. Eg: À > A

@mpalet
mpalet / bw_export_kp.py
Last active March 31, 2020 18:18 — forked from mohamedadaly/bw_export_kp.py
Export Bitwarden to KeePass 2 XML format
#!python
"""
Exports a Bitwarden database into a KeePass file (kdbx) including file attachments, custom fields and folder structure.
It can also export an unencrypted XML KeePass file conforming to KeePass 2 XML format.
It requires keepassxc-cli, if not available it can still export KeePass 2 XML
- https://github.com/keepassxreboot/keepassxc
Usage: bw_export_kp.py [-h] [-x] [-d] [-bw-password None] [-kee-password None]
@mpalet
mpalet / exiftool cheatsheet.md
Last active April 27, 2022 14:35
exiftool cheatsheet

EXIFTOOL CHEATSHEET

shift date

exiftool "-AllDates+=YY:MM:DD hh:mm:ss" -overwrite_original_in_place DIR

update file date to match exif date

exiftool "-DateTimeOriginal>FileModifyDate" "-DateTimeOriginal>DateCreated" -overwrite_original_in_place DIR
@mpalet
mpalet / timelapse.sh
Created May 31, 2019 09:19
create timelapse ffmpeg
#framerate 12 crop to 4k 16:9 from left top
ffmpeg -r 12 -f concat -safe 0 -i <(for f in DSCF*.JPG; do printf 'file '%q/%q'\n' "$PWD" "$f"; done;) -filter:v "crop=iw:iw*9/16:0:0,scale=3840:-2" -vcodec libx264 -crf 18 -preset slow timelapse.mp4
@mpalet
mpalet / gist:652127934cf2424689c8473cee71f76d
Created May 15, 2019 15:32
get integrated loudness EBU R128 from file
#!/bin/bash
function intloudness {
ffmpeg -nostats -i $1 -filter_complex ebur128 -f null - 2>&1 | awk '/I:/' | tail -n1
}
@mpalet
mpalet / gist:2ae30d6b284f91248284bcb58ca020bd
Created February 12, 2019 18:18
ffmpeg play side by side
ffmpeg -i "$f" -i "$f1" -filter_complex "[0:v]setpts=PTS-STARTPTS, yadif, pad=iw*2:ih[bg]; \
[1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=w" -f matroska - | ffplay -
ffmpeg -i "$f" -i "$f1" -filter_complex "[0:v]setpts=PTS-STARTPTS[bg]; \
[1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]blend=all_mode=difference" -f matroska - | ffplay -
ffmpeg -i "$f" -vcodec libx265 -crf 20 -x265-params "sao=0" -x265-params "aq-mode=3" -f matroska - | ffmpeg -i - -i "$f" -filter_complex "[0:v]setpts=PTS-STARTPTS[bg]; \
[1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]blend=all_mode=difference" -f matroska - | ffplay -
@mpalet
mpalet / gist:854c5faf70474f431ca6c7876784e4ab
Created December 17, 2018 20:10
compare files recursively
shopt -s globstar
for f in **/*.ptx; do for i in **/*.ptx; do if ! [[ $f -ef $i ]]; then cmp -s "$f" "$i" && echo "Files $f and $i are identical"; fi; done; done
@mpalet
mpalet / setup-sshpushnotifications.sh
Last active February 1, 2018 09:05
Setup ssh login push notifications with telegram bot
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
#create ssh wrapper to execute pushmessage
SSH_WRAPPER_PATH=/usr/local/sbin/ssh-wrapper
cat - > $SSH_WRAPPER_PATH <<'EOF'
@mpalet
mpalet / classlife-down-calendar.md
Last active January 23, 2018 11:28
Classlife download calendar

Classlife download calendari

Instruccions

  1. Crea un nou "preferit" (click-dret a la barra de preferits i click "Afegir Pàgina...")
  • Posa-li un nom
  • Copia el codi a sota, enganxa'l a la secció "URL".
javascript: (function() {