Skip to content

Instantly share code, notes, and snippets.

View parsley42's full-sized avatar

David Parsley parsley42

  • Welld Health
  • United States
View GitHub Profile
@parsley42
parsley42 / aws-session
Last active November 18, 2017 18:23
Using temporary credentials with AWS CLI and API
#!/bin/bash -e
# Usage: eval `aws-session <profile> <token>`
# Sets up environment variables for AWS temporary session credentials where
# MFA is required for API access.
# See: https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/
# https://mharrison.org/post/aws_mfa/
if [ $# -ne 2 ]
then
@parsley42
parsley42 / cloud9sg.rb
Last active April 30, 2018 15:13
Cloud9 SG generator
#!/usr/bin/ruby
require 'json'
require 'net/http'
require 'uri'
region = "us-east-1"
service = "CLOUD9"
r = Net::HTTP.get(URI::parse('https://ip-ranges.amazonaws.com/ip-ranges.json'))
@parsley42
parsley42 / goprof.txt
Last active March 27, 2018 11:56
profiling
# Check on running go routines:
[parse@parse lnxjedi]$ go tool pprof http://localhost:8888/debug/pprof/goroutine
Fetching profile over HTTP from http://localhost:8888/debug/pprof/goroutine
Saved profile in /home/parse/pprof/pprof.bot.test.goroutine.008.pb.gz
File: bot.test
Type: goroutine
Time: Mar 25, 2018 at 12:13am (UTC)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) list lnxjedi
Total: 11
@parsley42
parsley42 / README.md
Last active November 10, 2018 23:04
Git Scripting Cheatsheet

Handy git commands for scripting

Get the commit hash

$ git rev-parse HEAD
# Short version
$ git rev-parse --short HEAD
# Previous commit
$ git rev-parse HEAD~1
@parsley42
parsley42 / README.md
Last active June 23, 2024 13:12
Chromebook ssh-agent setup

Setting up ssh-agent in Linux/Crostini on Chromebook

  • Create your user systemd directory:
$ mkdir -p .config/systemd/user
  • Edit the unit file .config/systemd/user/ssh-agent.service:
[Unit]
Description=SSH key agent
@parsley42
parsley42 / bashrc
Created January 25, 2021 17:08
home bashrc
# User specific aliases and functions
source <(kubectl completion bash)
source <(helm completion bash)
source <(argocd completion bash)
complete -C '/usr/local/bin/aws_completer' aws
alias k=kubectl
complete -F __start_kubectl k
alias h=helm
complete -F __start_helm h
export PATH=$HOME/go/bin:/usr/local/go/bin:$PATH
@parsley42
parsley42 / delete-ns.sh
Last active January 25, 2021 19:09
Delete kubernetes namespace stuck in Terminating; quick and dirty, YMMV
#!/bin/bash
if [ ! "$1" ]
then
echo "Missing namespace"
exit 1
fi
NAMESPACE=$1
@parsley42
parsley42 / template.sh
Created May 18, 2021 14:11
Shell script template
#!/bin/bash -e
trap_handler()
{
ERRLINE="$1"
ERRVAL="$2"
echo "line ${ERRLINE} exit status: ${ERRVAL}"
# The script should usually exit on error
exit $ERRVAL
}
@parsley42
parsley42 / terraform_bash_completion.sh
Created August 12, 2021 15:42
Terraform Completion
# Bash Terraform completion
# Originally adapted from: https://gist.github.com/cornfeedhobo/8bc08747ec3add1fc5adb2edb7cd68d3
# Adapted from: https://gist.github.com/zish/85dccece461e050077997ff5d7d9c9d4 by Jeremy Melanson
#
#--- Get options listing from Terraform command.
_terraform_completion_get_opts () {
local CMD_EXEC="${1}"
local TF_OPT="${2}"
@parsley42
parsley42 / aws-session
Created August 31, 2021 20:25
AWS Session Script
#!/bin/bash -e
# Usage: aws-session <token> (account)
# Sets up aws configuration for API access using temporary credentials
# See: https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/
# https://mharrison.org/post/aws_mfa/
usage(){
cat <<EOF
Usage: aws-session [-r <region>] ([-i] | <token> (account))