Skip to content

Instantly share code, notes, and snippets.

@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
@josuecau
josuecau / flac2mp3.sh
Last active Feb 2, 2019
Convert FLAC to MP3 using ffmpeg(1)
View flac2mp3.sh
#!/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
Certbot with Docker and Cloudflare DNS Authenticator plugin
View certbot
#!/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' \
View somme
#!/usr/bin/env bash
input="${1:-/dev/stdin}"
awk '{s+=$1} END {print s}' "$input"
@josuecau
josuecau / json2csv
Last active May 26, 2018
Convert JSON to CSV using jq(1)
View json2csv
#!/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
View search-replace
#!/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
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 ]
View sync-date.sh
#! /usr/bin/env bash
sudo sntp -s 178.33.111.48 && date
View install-rclone.sh
#!/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
View php-format.sh
#!/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"