Some useful Bash commands

youtube-dl

# Batch download
youtube-dl -i -F -a ~/Desktop/list.txt # Get the format
youtube-dl -i -f <format> -a ~/Desktop/list.txt # Use the format

# Automagically download the desired resolution
youtube-dl -i -f "bestvideo[height<=720]+bestaudio/best[height<=720]" -a ~/Desktop/list.txt

## Avoid throttling
youtube-dl -i --external-downloader aria2c --external-downloader aria2c --external-downloader-args "-j 8 -s 8 -x 8 -k 5M" -f mp4-240p -a ~/Desktop/list.txt
youtube-dl -f 18 -4 -i https://www.youtube.com/watch?v=uhikhkih # Use IPv4

## Rate limit
youtube-dl -i -r 120k -a ~/Desktop/list.txt

wget

# Batch download
wget -r -H -nc -np -nH --cut-dirs=1 -e robots=off -l1 -i ~/Desktop/list.txt

# Rate limit
wget --no-check-certificate --limit-rate 60k https://trucmuche.com/truc.mp3
wget --no-check-certificate --limit-rate 20k -i ~/Desktop/list.txt # Batch download

# Recursively fetch a directory
wget -r --no-parent --reject "index.html*" -e robots=off  http://example.com/configs/.vim/

## To avoid downloading the directory structure as well
wget -r -nH -nd -np -R index.html* -e robots=off http://example.com/configs/.vim/

# Avoid the robots.txt issue
 -e robots=off  (See http://www.krazyworks.com/wget-and-user-agent-header/)

# Download one type only
 -A jpeg,jpg,bmp,gif

# Use a user-agent
 -U -U "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8"

# So, get only fonts in an entire site
wget -r --no-parent --reject "index.html*" -e robots=off --limit-rate 60k -A otf,ttf,ttc,dfont 

Batch stuff

# Convert multiple video to audio
for i in *.mp4; do ffmpeg -i "$i" -vn "${i%mp4}mp3"; done
# Convert avi to mp4
for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 23 -preset fast -profile:v baseline -level 3.0 -threads 2 "${i%avi}mp4"; done
# Convert mkv to mp4
for i in *.mkv; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 23 -preset fast -s 720x480 -threads 2 "${i%mkv}mp4"; done
# Convert .png to .jpg
for i in *.png; do mogrify -format jpg "$i" && rm "$i"; echo "$i converted to ${i%.*}.jpg"; done
# Same, but recursive
find . -iname '*.png' | while read i; do mogrify -format jpg "$i" && rm "$i"; echo "Converted $i to ${i%.*}.jpg"; done

# Randomize name
for i in *.mp4; do mv -i "$i" "${RANDOM}.mp4"; done

# Recursive copy
find . -name "*.zip" -exec cp -t ./direction_dir {} +
find . -type f -name "*.mp3" -exec cp {} /tmp/MusicFiles \ # Alternative
# Recursive deletion
find . -name "*.*" -print0 | xargs -0 rm -rf
# Recursive md5sum
find -type f -exec md5sum "{}" + > checklist.chk

# Recursive rename with modified date
j=1; for i in `find . -type f`; do mv -- "$i" "$(date +%Y-%m-%d_%H\'%M\'%S -r $i)_$j.${i##*.}"; j=$((j + 1)); done
## Will output: 2021-02-01_15'16'06_foo.webm
## Note: use IFS=$'\n' before the loop, for find to understand space in filename (mandatory on Windows)

# Recursive move from multiple folder, renaming the files to add the folder they was in
ls . > list; while read LINE <&3; do for i in `find $LINE -name "*.svg"`;do filename=$(basename -- "$i"); cp $i "$LINE-$filename"; done; done 3< list; rm list;

# Recursive move in folders
for j in {01..31}; do for i in `find . -name "*\-$j\_*"`; do mkdir -p "$j" && cp "$i" "$j/"; done; done
## Use case: we have a bunch of files named 2021-02-01_15'16'06_bar.webm, we want them to be moved into the folder corresponding to their month (01 to 31)

Video to gif

# Simple
for i in *.mp4; do ffmpeg -i "$i" -an -s 320x240 -pix_fmt rgb24 -r 10 "${i%mp4}gif"; done
# Optimal with compression
for i in *.webm; do ffmpeg -i "$i" -vf fps=10,scale=320:-1:flags=lanczos,palettegen "$i.png"; ffmpeg -i "$i" -i "$i.png" -filter_complex 'fps=10,scale=320:-1:flags=lancz os[x];[x][1:v]paletteuse' "${i%webm}gif"; rm "$i.png"; done
# Recursive on the first 15 seconds with deletion of step's products
for i in `find . -name "*.webm"`;do ffmpeg -ss 0 -t 15 -i "$i" -vf fps=10,scale=320:-1:flags=lanczos,palettegen "$i.png"; ffmpeg -ss 0 -t 15 -i "$i" -i "$i.png" -filter_complex 'fps=10, scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse' "${i%webm}gif"; rm "$i.png"; rm "$i";done

Other

# Get filename and extension
filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"

Changer la piste de sous-titres par défaut d'un mkv

for i in *.mkv; do mkvpropedit "$i" --edit track:s1 --set flag-enabled=0 --set flag-default=0 --edit track:s12 --set flag-enabled=1 --set flag-default=1; done

Changer la piste audio par défaut d'un mkv

for i in *.mkv; do mkvpropedit "$i" --edit track:a1 --set flag-enabled=0 --set flag-default=0 --edit track:a2 --set flag-enabled=1 --set flag-default=1; done

Ffmpeg: How to delay (sync with video) audio channel in video file

Delay by 5 seconds (the audio starts 5 seconds after the video):

ffmpeg -i in.mp4 -itsoffset 5 -i in.mp4 -map 1:v -map 0:a -c copy out.mp4

Trim by 5 seconds using negative number. Remember: it's the opposite way of how VLC displays this (negative is positive).

Autologin Windows 10

netplwiz

Puis, il suffit de sélectionner l'utilisateur, décocher la case Les utilisateurs doivent entrer un mot de passe, et Appliquer. Entrer le mot de passe deux fois sur la fenêtre qui s'ouvre.

Si la case à cocher n'est pas présente, c'est que Windows emmerde le monde. Il faut regedit puis :

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device

Il faut que DevicePasswordLessBuildVersion soit à 0.

Activer Office sans KMS

Il est possible d'activer Office définitivement et plus proprement qu'avec le KMS intégré ici. Il faut :
1) Ouvrir PowerShell
2) Entrer cette commande : irm https://massgrave.dev/get | iex
3) Naviguer dans l'outil qui s'ouvre, aller dans la section Activation d'Office
4) Trouver "Ohook activation", et valider.
Voilà, pas de KMS, et c'est banco

SSL - Convert PEM and private key to PKCS#12 - Mkyong.com

openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem

Use ~ in file paths to avoid the .bib file being different on different computers :: Better BibTeX

if (Translator.BetterTeX && !Translator.options.exportFileData && zotero.attachments && zotero.attachments.length) {
  for (const att of zotero.attachments) {
    if (att.localPath) {
      att.localPath = att.localPath.replace(RegExp("^\/.*?\/.*?\/"), "~/")
    }
  }
  tex.add({ name: 'file', value: zotero.attachments, enc: 'attachments' })
  return { cache: false }
}

Export Zotero items keys with BetterBibTeX

It is possible to export Zotero items keys while using BetterBibTeX with this little postscript:

if (Translator.BetterBibLaTeX || Translator.BetterBibTeX || Translator.BetterTeX) {
    reference.add({ name: 'key', value: item.itemKey});
}

So the .bib will contain key = ITEMKEY so we can reconstruct a Zotero URI: zotero://select/library/items/ITEMKEY

Toolbar not fully themed in tab mode on Linux · Issue #1999 · zotero/zotero

You might find this workaround useful:

  1. Close Zotero.
  2. Open your Zotero profile folder.
  3. Inside this folder, create a sub-folder named chrome.
  4. Inside the folder chrome, create a file named userChrome.css with the content below.
  5. Save. Reopen Zotero and enjoy.

Tested on Linux Mint 21.2 with the default dark theme.

Tab bar fixed

.tabs::before,
.tabs::after {
    border-color: var(--tabs-border-color, rgba(0,0,0,.3)) !important;
}

.tab {
    background: inherit !important;
    color: inherit !important;
}
#tab-bar-container .tab:not(:last-child) {
    border-color: var(--tabs-border-color, rgba(0,0,0,.3)) !important;
}

#tab-bar-container .tab.selected {
    background: inherit !important;
    border-color: var(--tabs-border-color, rgba(0,0,0,.3)) !important;
    border-top-color: var(--tabline-color, #0a84ff) !important;
}

#tab-bar-container .tab:not(.selected) {
    border-bottom-color: var(--tabs-border-color, rgba(0,0,0,.3)) !important;
}

#tab-bar-container .tab:not(:first-child) .tab-close {
  filter: invert(0.7);
}

#zotero-toolbar {
    background: inherit !important;
    border-bottom: inherit !important;
}

jannessm/joplin-zotero-link

Since I had to dig the code to understand how the plugin works, here is a little how-to:

  1. Install MunGell/ZotServer on Zotero. It will launch a local server with a search endpoint at http://localhost:23119/zotserver/search
  2. Open a note and type z@. A little search bar will appear to let you select the document needed.
  3. Done.

Calendrier jours fériés

https://www.thunderbird.net/media/caldata/autogen/France-Holidays.ics

Un clavier pour écrire en français sous Windows : É Ç Œ et trucs dans le genre... - Mon coin du web...

How to add konami code in a website

function onKonamiCode(cb) {
  var input = '';
  var key = '38384040373937396665';
  document.addEventListener('keydown', function (e) {
    input += ("" + e.keyCode);
    if (input === key) {
      return cb();
    }
    if (!key.indexOf(input)) return;
    input = ("" + e.keyCode);
  });
}

onKonamiCode(function () {alert('\o/')})

Liste des fichiers à avoir sur son site - Le Hollandais Volant

/favicon.ico
/robots.txt
/humans.txt
/sitemap.xml
/manifest.xml
/opensearch.xml
/.well-known/security.txt
/ads.txt
/pubkey.txt

Free Mobile : bloquer tous les démarcheurs - Le Hollandais Volant

Liste des numéros :

01 62 ** ** **
01 63 ** ** **
02 70 ** ** **
02 71 ** ** **
03 77 ** ** **
03 78 ** ** **
04 24 ** ** **
04 25 ** ** **
05 68 ** ** **
05 69 ** ** **
09 48 ** ** **
09 49 ** ** **

PHP display errors

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

FFmpeg: 10 bits HEVC vers 8 bits en préservant les couleurs

ffmpeg -i input.mkv -map 0 -c:v libx264 -crf 18 -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:a copy output.mkv

Virer VLC de l'applet de son Cinnamon

VLC fait régulièrement planter l'applet de son de Cinnamon : une fois fermé, il reste indéfiniment, comme si un processus fantôme nommé VLC.instance# s'accaparait l'applet même après un killall.

Ouvrir /usr/share/cinnamon/applets/sound@cinnamon.org/applet.js et modifier :

let players_with_seek_support = [
    'clementine', 'banshee', 'rhythmbox', 'rhythmbox3', 'pragha', 'quodlibet',
    'amarok', 'xnoise', 'gmusicbrowser', 'vlc', 'qmmp', 'deadbeef', 'audacious'];

Mastodon share & DM with inline javascript

<!-- Share -->
<a href="javascript:var server=prompt('Instance ?').replace(/(http(s)?:\/\/)/g,'').replace(/\/$/,'');window.location.href=`https://${server}/share?visibility=public&text=%20via%20@yomli@mastodon.xyz%20%3A%20&url={racine_du_site}{lien_permalink}`;void 0;">Share</a>
<!-- Direct message -->
<a href="javascript:var server=prompt('Instance ?').replace(/(http(s)?:\/\/)/g,'').replace(/\/$/,'');window.location.href=`https://${server}/share?visibility=direct&text=@yomli@mastodon.xyz%20%3A%20&url={racine_du_site}{lien_permalink}`;void 0;">DM</a>