Skip to content

Instantly share code, notes, and snippets.

@nicholasjackson
nicholasjackson / deregister.sh
Last active August 24, 2023 17:38
Boundary Worker Registration
#!/bin/sh -e
echo "[$(date +%T)] Deregister boundary worker"
# Read the worker id from the file written on startup
worker_id=$(cat ./worker_id)
# Base url for the HCP cluster
base_url="https://${cluster_id}.boundary.hashicorp.cloud/v1"
auth_url="${base_url}/auth-methods/${auth_method_id}:authenticate"
dereg_url="${base_url}/workers/${worker_id}"
@mamiu
mamiu / K3D_EXEC_AS_ROOT_INTO_CONTAINER.md
Created October 5, 2020 03:45
k3d exec as root user into pod / container

k3d exec as root user into pod / container

Let's assume we have a pod called nginx running in the namespace nginx-test.

kubectl create namespace nginx-test
kubectl run nginx --image=nginx -n nginx-test

1. Check if the current cluster is a k3d cluster

@straubt1
straubt1 / get-airgap-versions.sh
Last active July 7, 2022 15:07
TFE Download Airgap
#!/bin/bash
# export LICENSE_ID=""
# export PASSWORD=""
[[ -z "$LICENSE_ID" ]] && echo "Please Set LICENSE_ID Environment Variable" && exit 1
[[ -z "$PASSWORD" ]] && echo "Please Set PASSWORD Environment Variable" && exit 1
b64_password=$(echo -n ${PASSWORD} | base64)
@mazenovi
mazenovi / vault-tree
Last active November 2, 2023 18:49
explore recursively your vault by HashiCorp
#!/usr/bin/env bash
function walk() {
for secret in $(vault list $1 | tail -n +3)
do
if [[ ${secret} == *"/" ]] ; then
walk "${1}${secret}"
else
echo "${1}${secret}"
fi
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active June 1, 2024 08:46
set -e, -u, -o, -x pipefail explanation
@480
480 / gist:3b41f449686a089f34edb45d00672f28
Last active May 6, 2024 19:52
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings

MacOS X + oh my zsh + powerline fonts + visual studio code (vscode) terminal settings

Thank you everybody, Your comments makes it better

Install oh my zsh

http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@angelo-v
angelo-v / jwt-decode.sh
Last active June 3, 2024 01:01
Decode a JWT via command line
# will not work in all cases, see https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#gistcomment-3439904
function jwt-decode() {
sed 's/\./\n/g' <<< $(cut -d. -f1,2 <<< $1) | base64 --decode | jq
}
JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
jwt-decode $JWT
@dcode
dcode / set_proxy.sh
Created July 12, 2016 17:06
Sets environment variables to use curl and other command line utilities w/ a proxy.
# /usr/local/bin/set_proxy.sh
# Sets proxy env vars.
# To use, source this into your shell:
#
# . /usr/local/bin/set_proxy.sh
PROXY_HOST=my-company-proxy.example.com
PROXY_PORT=3128
read -p "Enter your username: " PROXY_USER
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active May 30, 2024 17:11
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@daveadams
daveadams / acl-vault-tests.sh
Created December 19, 2015 13:30
ACL policy and tests for Hashicorp Vault
#!/bin/bash
echo -n "Starting vault... "
vault server -dev &> vault-server.log &
vault_pid=$!
echo OK
shutdown() { trap "" EXIT; echo -n 'Shutting down... '; kill -9 $vault_pid; echo OK; exit $1; }
trap "shutdown 0" EXIT
trap "echo; echo 'Got interrupt signal!'; shutdown 255" INT