Skip to content

Instantly share code, notes, and snippets.

@josuecau
josuecau / gpx-routes-to-tracks.sh
Last active Mar 8, 2021
Convert GPX routes (rte) into tracks (trk) using gpsbabel (https://www.gpsbabel.org)
View gpx-routes-to-tracks.sh
#!/usr/bin/env bash
#
# Convert GPX routes (rte) into tracks (trk) using gpsbabel.
# (https://www.gpsbabel.org/)
set -e
if ! type gpsbabel >/dev/null 2>&1; then
echo 'gpsbabel not found'
exit 1
@josuecau
josuecau / ffmpeg_add_srt.sh
Last active Aug 20, 2020
Using ffmpeg in Docker to add srt subtitle files to mp4 files
View ffmpeg_add_srt.sh
#!/usr/bin/env bash
#
# Using ffmpeg in Docker to add srt subtitle files to mp4 files
#
# https://mutsinzi.com/add-srt-subtitles-to-quicktime/
# https://hub.docker.com/r/jrottenberg/ffmpeg
# Given the following directory structure:
# .
# ├── in
View wordfreq.sh
#!/usr/bin/env bash
# List the most frequently used words in a text.
[ $# -ge 1 ] && [ -f "$1" ] && input="$1" || input="-"
# shellcheck disable=SC2002
cat "$input" |
tr -cs '[:alpha:]' '\n' | # Split words and drop non-alphabetic characters.
tr '[:upper:]' '[:lower:]' | # Put it all to lowercase.
@josuecau
josuecau / options-avanced.sh
Last active Dec 25, 2019
Parse bash command options with getopt(1)
View options-avanced.sh
#!/usr/bin/env bash
# “a” and “arga” have optional arguments with default values.
# “b” and “argb” have no arguments, acting as sort of a flag.
# “c” and “argc” have required arguments.
# getopt bin
getopt=/usr/local/opt/gnu-getopt/bin/getopt
# set an initial value for the flag
@josuecau
josuecau / wait.js
Created Dec 2, 2019
JavaScript setTimeout as a Promise
View wait.js
module.exports = delay => new Promise(resolve => setTimeout(resolve, delay))
@josuecau
josuecau / gist:756ae0369d0016b965f1e55e0f73ce93
Created Nov 5, 2019
Nommage des fichiers avec MusicBrainz Picard
View gist:756ae0369d0016b965f1e55e0f73ce93
$if2(%albumartist%,%artist%)/$if($ne(%albumartist%,),%album%/,)$if($gt(%totaldiscs%,1),%discnumber%/,)$if($ne(%albumartist%,),$num(%tracknumber%,2) ,)%title%
View colors-64.json
[
"000",
"005",
"00A",
"00F",
"050",
"055",
"05A",
"05F",
"0A0",
@josuecau
josuecau / Makefile
Last active May 4, 2019
A Makefile for Rust projects
View Makefile
build:
cargo build --release
check:
cargo check && cargo clippy
fmt:
cargo +nightly fmt
doc:
View markdown
#!/usr/bin/env bash
#
# Description: convert a Markdown file to a HTML file using pandoc(1)
# Usage: markdown INPUT_FILE.md"
# Version: 1.0.2
# Author: Josué Cau <me@josuecau.com>
set -e
if [ $# -eq 0 ]
@josuecau
josuecau / seedbox
Last active Mar 17, 2019
Select .torrent file to upload to seed box
View seedbox
#!/usr/bin/env bash
#
# Description: Select .torrent file to upload to seed box.
# Usage: $ seedbox
# Author: Josué CAU <me@josuecau.com>
# Version: v0.1.1
# Dependencies: fzf(1)
# Env: SEEDBOX_ADDRESS
set -e