Skip to content

Instantly share code, notes, and snippets.

View mrjk's full-sized avatar

mrjk

  • Montréal
View GitHub Profile
@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 / 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 / cli-app2.bash
Last active May 1, 2024 05:30
Command based CLI bash framework
#!/bin/bash
# TEMPLATE_VERSION=2024-04-25
# 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 / clish.bash
Last active March 31, 2024 06:58
Clish - Bash Command Line App Framework
#!/bin/bash
# TEMPLATE_VERSION=2023-10-19
# 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 / README.md
Last active March 28, 2024 15:06
Ansible cheatsheet

Ansible Cheat Sheet

Installation

When working on complex project, always install your own version of ansible in a dedicated virtual environment:

virtualenv -p python3 .venv
. .venv/bin/activate

Normally, you have at least a requirements.txt file determining python dependencies versions:

@mrjk
mrjk / README.md
Created February 11, 2024 08:39
python tips

Print stack trace

import traceback 

traceback.print_stack()
@mrjk
mrjk / gist:5b302812a0a50760c18ed71cafa2ccff
Created January 2, 2024 00:24
Board settings are invalid on MR8300, there is a corrected version for switch
{
"model": {
"id": "linksys,mr8300",
"name": "Linksys MR8300 (Dallas)"
},
"network": {
"lan": {
"device": "eth0",
"protocol": "static"
},
@mrjk
mrjk / bash_lib_snippets.md
Last active January 2, 2024 00:36
Snippets for bash

Iterations

Loop line over lines, whatever spaces in it:

while IFS= read -r line; do
    echo "... $line ..."
done < <(printf '%s' "$list")
@mrjk
mrjk / cli-app.bash
Last active April 25, 2024 21:33
Command based CLI bash skeleton
#!/bin/bash
# TEMPLATE_VERSION=2024-04-25
# 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 / cli-basic.bash
Last active March 28, 2024 00:16
A simple template cli for bash
#!/bin/bash
# Utility to discover installed binaries
set -eu
path_list ()
{
tr ':' '\n' <<< "$PATH"