Skip to content

Instantly share code, notes, and snippets.

@dgoade
dgoade / parse_args.sh
Last active November 4, 2015 14:55
Automation Scripting Essentials, Bash: Combine positional args with options
#!/bin/bash
# Automation Scripting Essential Skills: https://github.com/dgoade/ase
# Bash
# Input: Getting command line paramaters
echo "======================="
logMsg="Third technique -- combine positional args and emulate getoptslong"
echo "${logMsg}"
echo "args: ${@}"
@dgoade
dgoade / ase_input_conf_2.py
Created May 2, 2015 12:52
Automation Scripting Essentials, Python: Parsing command line parameters using getopt
#!/usr/bin/python
# Automation Scripting Essential Skills https://github.com/dgoade/ase
# Python
# Input: Parsing command-line parameters
# Technique1 -- Use getopt
import getopt
import sys
@dgoade
dgoade / ase_exec.py
Last active August 29, 2015 14:20
Automation Scripting Essentials, Python: Execute external command or script
#!/usr/bin/env python
"""
Automation Scripting Essential Skills (https://github.com/dgoade/ase)
Python
Execution: Execute an external command or script
Technique1 -- Use python2.7's core logging and configDict with yaml,
and fabric to execute an external command or shell script and
@dgoade
dgoade / scope.sh
Created May 2, 2015 13:01
Bash Cookbook: Use declare to scope variables in Bash
#!/bin/bash
# The declare builtin allows you to limit the scope of variables in bash
BAZ="OTHER"
foo ()
{
declare BAZ="THIS"
echo "Inside foo(), BAZ=${BAZ}"
@dgoade
dgoade / utils_trace_on.sh
Created May 2, 2015 13:13
Bash Cookbook: Debugging
#!/bin/bash
# From: https://github.com/dgoade/bat/blob/master/lib/utils.sh
##== FUNCTION ==========================================================================
: <<='cut'
=head2 B<utils_trace_on()>
Debugging tool. Toggle-on Bash x-trace with a special prompt that shows
the script name, function name and line number along with the output.
@dgoade
dgoade / ase_input_params_2.pl
Created May 2, 2015 13:16
Automation Scripting Essentials, Perl: Getopt::Long
#!/usr/bin/perl
use strict;
# Automation Scripting Essential Skills (https://github.com/dgoade/ase)
# Perl
# Input: Parsing command-line parameters
# Technique #1 -- Use getopt or getoptlong
use Getopt::Long;
# cool git aliases from Larry Defauw
[user]
name = David Goade
email = dgoade@gmail.com
[core]
autocrlf = false
[alias]
co = checkout
ci = commit
st = status
resource "aws_ecr_repository" "repo" {
name = "mycompany"
}
resource "aws_ecr_lifecycle_policy" "expire_policy" {
repository = aws_ecr_repository.repo.name
policy = <<EOF
{
"rules": [
@dgoade
dgoade / k8aliases
Last active October 11, 2022 17:22
#!/usr/bin/env bash
##==================================
## Common K8s Functions and Aliases
##==================================
##---------------------------------
## Recommended usage
##---------------------------------
# Add the following to your zsh aliases:
# source "${THIS_REPO}/k8s_aliases.zsh"