Grimoire-Command.es

To content | To menu | To search

Tag - optimize

Entries feed

2018-01-24

Optimize execution time of repeated commands

Optimiser l'exécution de commandes répétées

Notes

[1] Locally recompile the package from sources, could be any other package, hence command

[2] Prelink ELF shared libraries and binaries to speed up startup time

2018-01-17

Recompress images JPEG / PNG at equal quality

Recompresser des images JPEG / PNG sans perte de qualité

  • JPG monotask : find . -name \*.jpeg -exec jpegoptim -pt
  • JPE?G multitask : find . -regextype posix-extended -iregex '.*(jpeg|jpg)' -print0 | xargs -0 -P $((`nproc` / 2)) jpegoptim -pt [1]
  • PNG multitask : find . -name \*.png -print0 | xargs -0 -P $((`nproc` / 2)) -I {} zopflipng -m --lossy_8bit --lossy_transparent -y {} {} [2]

Notes

[1] find can accept regex ; See Rip music CD to MP3 or FLAC for -print0 / -0

[2] -I {} permit to choose a replacement token for file names ; here we explicitely set zopflipng calls to overwrite files

2017-12-16

Rip music CD to MP3 or FLAC

Copier un CD de musique en MP3 ou Flac

CD -> WAV : cdparanoia -d /dev/hda -B
WAV -> MP3 : lame --vbr-new --preset extreme a_file.wav a_file.mp3
*.WAV -> MP3 : for x in `ls *.mp3`; do lame --vbr-new --preset extreme $x "`basename ${x} .wav`.mp3"; done; [1]
*.WAV -> MP3 in parallel : find . *.wav -print0 | xargs -0 -P $((`nproc` / 2)) -I {} lame --vbr-new --preset extreme {} {}.mp3 rename 's/\.wav\.mp3$/\.mp3/' *.mp3 [2]
*.WAV -> FLAC : flac --replay-gain --best *.wav
*.WAV -> FLAC in parallel : find . *.wav -print0 | xargs -0 -P $((`nproc` / 2)) -I {} flac --replay-gain --best "{}"

Notes

[1] --print0 / -0 options replace space by zeros at file name ends to deal with spaces in file names ; backticks call a sub-command ; basename isolate main part of name from extension

[2] $(()) for math operations ; backticks nproc for CPU number ; rename files in a second time

2017-11-16

Check, repair and clean databases

Vérifier, réparer et nettoyer des bases de données

  • MySQL : mysqlcheck ( --check | --auto-repair | --repair | --optimize ) --all-databases
  • PostgreSQL : vacuumdb -a -z
  • SQLite : for z in `/bin/ls *.sqlite`; do sqlite3 $z VACUUM; done