Skip to content

Instantly share code, notes, and snippets.

View gmolveau's full-sized avatar

Grégoire MOLVEAU gmolveau

View GitHub Profile
@gmolveau
gmolveau / embed_sub.md
Last active October 16, 2024 15:24
Embed subtitle (soft) in mp4/mkv file with ffmpeg without re-encoding

solution from https://stackoverflow.com/a/17584272/2627873

This solution adds the subtitles to the video as a separate optional (and user-controlled) subtitle track.

So you can choose the subtitle in VLC for example, it's not hard-coded or burned-in. And it won't re-encode the entire file so it's really fast.

  • ffmpeg is required
  • movie = great_movie.mp4 (works with mkv too)
  • subtitle = great_movie.english.srt
@gmolveau
gmolveau / solution1.go
Last active January 30, 2021 16:07
Go Tour concurrency crawler exercice with goroutines https://tour.golang.org/concurrency/10
/*
inspired by https://eduardolezcano.com/a-tour-of-go-web-crawler/
and https://github.com/fgrehm/go-tour/blob/master/73-web-crawler-golang-team-solution.go
solution with a "safe" map with mutex + a sub-function crawl with WaitGroup
this solution keeps the original signature of the Crawl function and does not change the main function
but does not use or store the body of the URL
*/
package main
@gmolveau
gmolveau / keys.pub
Created May 10, 2020 14:33
keys.pub
BEGIN MESSAGE.
8o3mgWotrroywzS RVaL38wKobUOT6c Oas28dxhlSMzzLl RFTZFgVphUkmvET
mY2wkhK2xFaDaYm RuJFJdXm3CaTCKq 6Xr2MZHgg6S28Sb LvgHLjzGU8qleX1
bAotlWyyjPBJ2JI 9ktFgUSHcGaCe9C oS5nzavJzY5aP4S JxZz8VUSYXDMVpq
yZfHNwlvZ0fNAd7 9HVPqcuUMhD92ql SE0050Qz5Z.
END MESSAGE.
@gmolveau
gmolveau / concurrency1.go
Created May 11, 2020 19:13
Golang concurrency examples
// https://play.golang.org/p/ez1HqUQe7W0
package main
import (
"fmt"
"time"
)
func main() {
done := make(chan int)
@gmolveau
gmolveau / test.py
Created May 26, 2020 18:01
Python module import error test pytest
# SOURCE : google and https://github.com/pytest-dev/pytest/issues/2421#issuecomment-403724503
# add those lines
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
@gmolveau
gmolveau / youtube-playlist-urls.js
Last active May 28, 2020 12:47
Youtube snippet js/javascript get url of each video in a playlist
// 2020-05-28 firefox 76 - youtube with dark-mode
let items = document.querySelectorAll("div#items.playlist-items ytd-playlist-panel-video-renderer > a");
items.forEach((item) => {
let href = item.href;
let title = item.querySelector("div#container > div#meta > h4 > span").title;
let url = new URL(href);
let params = new URLSearchParams(url.search.slice(1));
params.delete('list');
params.delete('index');
@gmolveau
gmolveau / mirrors.sh
Last active June 9, 2020 20:07
Set multiple git remotes github/gitlab mirroring
#!/usr/bin/env bash
set -euo pipefail
# inspiration : https://jigarius.com/blog/multiple-git-remote-repositories
###
# This script does not load the token via .env file
# This script does not check if the repos are available
# This script does not check if the tokens are valid
# This method is not ideal if you use private emails
# like : [email protected]
@gmolveau
gmolveau / gitlab_to_github.sh
Last active June 19, 2020 09:05
Gitlab to github push mirror shell script
#!/usr/bin/env bash
set -euo pipefail
# inspiration : https://jigarius.com/blog/multiple-git-remote-repositories
###
# This script does not check if the repos are available
# This script does not check if the tokens are valid
# This method is not ideal if you use private emails
# like : [email protected]
@gmolveau
gmolveau / gen_ssh_key_ed25519.sh
Last active July 7, 2020 08:48
Generate ed25519 ssh key with ssh-keygen - no passphrase prompt, no comment (no username)
ssh-keygen -q -C "" -N "" -t ed25519 -f <ABSOLUTE_PATH_TO_WHERE_YOU_WANT>
# example :
# ssh-keygen -q -C "" -N "" -t ed25519 -f ~/.ssh/id_ed25519
# docs :
# -q <quiet>
# -C <comment - like user@computer>
# -N <new_passphrase>
# -t <type>
@gmolveau
gmolveau / os.sh
Last active January 19, 2024 09:49
Bash/shell script detect/check OS and distribution (+WSL Windows Subsystem for Linux)
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
local DISTRIB=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
if [[ ${DISTRIB} = "Ubuntu"* ]]; then
if uname -a | grep -q '^Linux.*Microsoft'; then
# ubuntu via WSL Windows Subsystem for Linux
else
# native ubuntu
fi
elif [[ ${DISTRIB} = "Debian"* ]]; then
# debian