Skip to content

Instantly share code, notes, and snippets.

View bitti's full-sized avatar

David Ongaro bitti

  • SAP Concur
  • United States
View GitHub Profile
@bitti
bitti / kctx.bash
Last active June 20, 2023 10:26
Set a current kubeconfig context only for the current shell session
bash_setup() {
cat <<SETUP
alias kctx='. $(readlink -f "$0")'
__kctx () { mapfile -t COMPREPLY < <(compgen -W "\$(kubectl config get-contexts -o name) --help --unset" -- "\${COMP_WORDS[1]}"); }
complete -F __kctx kctx
SETUP
}
usage() {
cat <<EOF
@bitti
bitti / kubectl-v
Last active June 19, 2024 01:06
kubectl plugin/wrapper to match kubectl binary version to current cluster version
#!/bin/bash
set -e
cache=${XDG_CACHE_HOME:-$HOME/.cache}/kubectl-v
errors="$cache/errors-$$"
mkdir -p "$cache"
[[ $1 = "v" ]] && shift # Avoid recursive calls
get_sys() {
@bitti
bitti / gfm-render
Created May 20, 2022 23:29
Offline renderer for GitHub flavoured markdown
#!/usr/bin/ruby
require 'redcarpet'
require 'erb'
input = ARGV[0] && ARGV[0] != "-" && File.open(ARGV[0]) || STDIN
output = ARGV[1] && File.open(ARGV[1], "w") || STDOUT
File.join(ENV["XDG_CACHE_HOME"] || "#{ENV['HOME']}/.cache", "gfm-render")
class RenderWithTaskLists < Redcarpet::Render::HTML