Skip to content

Instantly share code, notes, and snippets.

View mrjk's full-sized avatar

mrjk

  • Montréal
View GitHub Profile
@mrjk
mrjk / cli-app-typer.py
Last active March 2, 2025 15:15
A quite complete example of python CLI Typer boilerplate [python] (Archive)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Version: 08-2024
# Migrated to: https://github.com/mrjk/python_snippets/blob/main/examples/typer/cli-app-typer.py
"""MyApp CLI interface
This CLI provides a similar experience as the git CLI, but in Python with Typer.
@mrjk
mrjk / cli-app-argparse-multilevel.py
Last active February 6, 2025 17:23
POC on how to do argparse multilevel CLIs [python] (Archive)
#!/usr/bin/python3
# Migrated to: https://github.com/mrjk/python_snippets/blob/main/examples/argparse/cli-app-argparse-multilevel.py
# Source: https://stackoverflow.com/questions/11760578/argparse-arguments-nesting
import argparse
parser = argparse.ArgumentParser(description='Deployment tool')
subparsers = parser.add_subparsers()
@mrjk
mrjk / cli-app-argparse.py
Last active February 6, 2025 17:23
Object oriented python command line with some examples (Archive)
#!/usr/bin/env python3
# Migrated to: https://github.com/mrjk/python_snippets/blob/main/examples/argparse/cli-app-argparse.py
# Run like this:
# python3 python_cli.py -vvvv demo
# Author: mrjk
import os
import sys
@mrjk
mrjk / slack_notify.py
Last active February 6, 2025 17:22
Portable python script to send Slack notifications (Archive)
#!/usr/bin/python3
#
# Migrated to: https://github.com/mrjk/python_components/blob/main/helpers/slack_notify.py
#
# Documentation
# =============================
#
# This little script to easily send slack notifications.
# Tiger's team webhooks are configured here: https://XXX.slack.com/apps/YYY-incoming-webhooks
#
@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 ()
{
# Common part
# ================
FROM debian:12 AS base
# Configuration
ENV ENTRYPOINT_INFINITE=false
ENV ENTRYPOINT_XTRACE=false
ENV ENTRYPOINT_ROOT=/docker-entrypoints
@mrjk
mrjk / vimrc.local
Last active November 13, 2024 15:43
System wide Debian sane vimrc for devops
" Source: https://gist.github.com/mrjk/1d146a701b201e77279ea4e7c5d075a5
" Last update: 2024/11/13
" Place this in /etc/vim/vimrc.local for debian based distros
" Place this in /etc/vimrc.local for rhel based distros
" Debian specifities
if filereadable("/usr/share/vim/vim80/defaults.vim")
source /usr/share/vim/vim80/defaults.vim
endif
" now set the line that the defaults file is not reloaded afterwards!
@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 / 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:
@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 ()