Skip to content

Instantly share code, notes, and snippets.

View mrjk's full-sized avatar

mrjk

  • Montréal
View GitHub Profile
@mrjk
mrjk / cli-app2.bash
Last active November 8, 2024 15:17
Command based CLI bash framework
#!/bin/bash
# TEMPLATE_VERSION=2024-11-08
# Basic bash template for command/resource based CLI.
# Features:
# * Automatic command discovery and help generation
# * Logging and traces
# * Application dependency checker
# * Support for getopts
# * Return code support
@mrjk
mrjk / docker-credential-helper
Last active April 26, 2024 16:18
Generic docker-credential-helper
#!/bin/bash
# TEMPLATE_VERSION=2024-04-25
set -eu
# App Global variable
# =================
APP_NAME="${0##*/}"
APP_AUTHOR="mrjk"
@mrjk
mrjk / dotenv.sh
Created May 15, 2024 18:51
Simple shell script that generate env vars from files
#!/bin/bash
#
# Read one or more dotfiles, and load
#
# Author: mrjk
set -euo pipefail
_log ()
@mrjk
mrjk / direnvrc
Created August 19, 2024 06:19
Direnv with recurive parent loading support
# This snippet allow recurive loading of parent .envrc files
# To put in your: ~/.config/direnv/direnvrc
# Direnv Recursive mode
# =========================
# Disable existing source_up commands
source_up ()
{
@mrjk
mrjk / listener.py
Created October 10, 2024 14:55
Stage listener for supervisord
#!/usr/bin/python
"""
Listener for supervisord
How it works?
It will wait all process_names (aka `program:NAME` sections) have reach the same state. Then
it run another command. Its main use case is to allow supervisord services dependencies.
Example configuration:
# Common part
# ================
FROM debian:12 AS base
# Configuration
ENV ENTRYPOINT_INFINITE=false
ENV ENTRYPOINT_XTRACE=false
ENV ENTRYPOINT_ROOT=/docker-entrypoints
@mrjk
mrjk / id_gen.sh
Last active August 26, 2025 07:19
How to generate ssh_keys with comprehensive comments
_IDENT="USER_HOST"
_IDENT=$(id -un)_$(hostname -f)
_DATE=$(date +'%Y%m%d')
_OUT="$(id -un)/.ssh/"
_OUT="$(getent passwd "${USER}" | cut -d: -f6)/.ssh/"
echo "Ident=$_IDENT, date=$_DATE out=$_OUT"