Skip to content

Instantly share code, notes, and snippets.

@josuecau
josuecau / seedbox
Last active March 17, 2019 12:16
Select .torrent file to upload to seed box
#!/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
@josuecau
josuecau / flac2mp3.sh
Last active February 2, 2019 12:50
Convert FLAC to MP3 using ffmpeg(1)
#!/usr/bin/env bash
#
# Convert FLAC to MP3 using ffmpeg(1)
# Source: https://stackoverflow.com/a/26109838/2397516
set -e
if [ $# -lt 1 ]; then
echo "Usage: $(basename "$0") /files/to/convert"
exit 1
@josuecau
josuecau / certbot
Created May 19, 2018 08:25
Certbot with Docker and Cloudflare DNS Authenticator plugin
#!/usr/bin/env bash
#
# Certbot with Docker and Cloudflare DNS Authenticator plugin
# https://certbot.eff.org
# https://github.com/certbot/certbot/tree/master/certbot-dns-cloudflare
docker run -it --rm --name certbot \
-v '/etc/letsencrypt:/etc/letsencrypt' \
-v '/etc/cloudflare.conf:/etc/cloudflare.conf' \
-v '/var/lib/letsencrypt:/var/lib/letsencrypt' \
#!/usr/bin/env bash
input="${1:-/dev/stdin}"
awk '{s+=$1} END {print s}' "$input"
@josuecau
josuecau / json2csv
Last active May 26, 2018 09:27
Convert JSON to CSV using jq(1)
#!/usr/bin/env bash
#
# Convert JSON to CSV using jq(1)
# Source: https://stackoverflow.com/a/32967407
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' $input
#!/usr/bin/env bash
#
# Recursive search & replace
# Usage: search-replace SEARCH REPLACE [/path/to/search]
# Author: Josué Cau <me@josuecau.com>
# Version: v1.0.0
if [ $# -lt 2 ]; then
echo "Usage: $(basename "$0") SEARCH REPLACE [/path/to/search]"
exit 1
#!/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 ]
#! /usr/bin/env bash
sudo sntp -s 178.33.111.48 && date
#!/usr/bin/env bash
#
# Install rclone(1) binary
# More info: https://rclone.org/install/
set -e
echo 'Downloading archive…'
wget -q -O /tmp/rclone-current-linux-amd64.zip \
https://downloads.rclone.org/rclone-current-linux-amd64.zip
#!/usr/bin/env bash
#
# Permet d'utiliser PHP-CS-Fixer en mode stdin/stdout,
# par exemple dans Vim avec `equalprg`
#
cmd=php-cs-fixer
hash "$cmd" 2>/dev/null || exit 1
tmp=$(mktemp)
tee > "$tmp"