Skip to content

Instantly share code, notes, and snippets.

View huevos-y-bacon's full-sized avatar

Huevos y Bacon huevos-y-bacon

View GitHub Profile
@huevos-y-bacon
huevos-y-bacon / aws_classic_elb_reg.sh
Last active March 29, 2022 16:23
REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
#!/usr/bin/env bash
# REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
## SANDBOX/PLAY ACCOUNT
ELBNAME=23feb22
INSTANCES=(
i-0673baad826269229 # Name: dummy1
i-0a72c8136b4ee5042 # Name: dummy2
)
@huevos-y-bacon
huevos-y-bacon / nuke-helix-native.sh
Created February 26, 2022 19:23
Simple script to nuke Line 6 Helix Native and all Native user settings for the current user (OS X). See https://line6.com/support/topic/53283-helix-native-code-1116-could-not-decrypt-the-asset/.
#!/bin/bash
[[ "$1" == "yes" ]] || { echo "Specify \"yes\" to nuke Helix Native"; exit 0; }
echo
echo "NUKING HELIX NATIVE!"
echo
FOLDERS=(
"${HOME}/Library/Application Support/Line 6"
@huevos-y-bacon
huevos-y-bacon / aws_check_configservice.sh
Last active March 29, 2022 16:22
Check if AWS Config is enabled in all regions
#/bin/bash
# Check if AWS Config is enabled in all regions
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --out text); do
aws configservice describe-configuration-recorder-status --region $r --out yaml --query \
'ConfigurationRecordersStatus[].{name:name,recording:recording,lastStatus:lastStatus}';
done
@huevos-y-bacon
huevos-y-bacon / bash_bulk_ext_rename.sh
Last active March 29, 2022 16:45
Bulk rename given file extension to another
#!/usr/bin/env bash
# Bulk rename given file extension to another
ext_before=txt
ext_after=extend
for file in *.${ext_before}; do mv "$file" "${file%."${ext_before}"}.${ext_after}"; done
@huevos-y-bacon
huevos-y-bacon / bash_prepend_lines.sh
Last active March 29, 2022 16:45
Insert lines at top of all files of specified extension
#!/usr/bin/env bash
# Insert lines at the top of a file
ext=sh
for f in *.${ext}; do
# e.g. add shebang and shellcheck disable
printf '%s\n%s\n' "#shellcheck disable=1072,1073,1035,1020" "$(cat ${f})" >${f}
printf '%s\n%s\n' "#\!/usr/bin/env bash" "$(cat ${f})" >${f}
done
@huevos-y-bacon
huevos-y-bacon / tf-destroy-backend
Last active April 29, 2022 14:52
Based on given strings, destroy Terraform remote backend config (DDB table, S3 buckets, SSM Parameters)
#!/usr/bin/env bash
# shellcheck disable=1091,2068,2162
SSMSTRING=backend
BUCKSTRING=state
DDBSTRING=locks
if command -v colours &> /dev/null; then source colours; fi
unset COUNT
[[ $* == *"--force"* ]] && FORCE=yes
@huevos-y-bacon
huevos-y-bacon / std-pipeline-destroy
Created April 29, 2022 14:54
check/delete terraform standard pipeline resources, incl codebuild projects, iam roles + policies
#!/usr/bin/env bash
# shellcheck disable=1091,2068,2086,2162,2016
STRING=pipeline
if command -v colours &> /dev/null; then source colours; fi
unset COUNT
[[ $* == *"--force"* ]] && FORCE=yes
[[ $* == *"--check"* ]] && CHECK=yes
@huevos-y-bacon
huevos-y-bacon / git_author_rewrite.sh
Last active July 25, 2022 10:16
*GIT AUTHOR REWRITES* - use at your own risk
#!/bin/bash
exit
# GIT AUTHOR AND COMMITTER REWRITES - !!!DANGEROUS!!!
# Sources:
# - https://stackoverflow.com/a/1566833
# - https://www.git-tower.com/learn/git/faq/change-author-name-email/
## REWRITE COMMITTER - BY EMAIL
@huevos-y-bacon
huevos-y-bacon / aws_global_disable_security_hub.sh
Created August 19, 2022 09:51
Disable AWS SecurityHub in all regions
#!/bin/bash
for r in `aws ec2 describe-regions --query 'Regions[].RegionName' --out text`; do
echo $r;
aws securityhub disable-security-hub --region $r;
done
# Source: https://missionimpossiblecode.io/building-a-best-practice-cloudformation-custom-resource-pattern
Parameters:
SpecifyVPCToUse:
Description: >
DefaultVPC - finds the VPC and configures all of its subnets for you. Otherwise type
in the VPC id of a VPC in the same region where you run the template.
All subnets and azs of the chosen vpc will be used.
The VPC and chosen subnets must be setup in a way that allows the runner instances
to resolve the DNS name and connect to port 443 on the GitLab instance URL you provide.
Default: DefaultVPC