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 / install_granted.sh
Created August 3, 2023 10:34
Install (Common Fate) granted on Mac or (Amazon) Linux
#!/usr/bin/env bash
set -e
# See:
# - https://docs.commonfate.io/granted/getting-started/
# - https://docs.commonfate.io/granted/usage/automatic-config-generation
# Remember to update MY_ORG_NAME!
SSO_URL=https://MY_ORG_NAME.awsapps.com/start/
SSO_ORG=$(echo $SSO_URL | awk -F. '{print $1}' | awk -F/ '{print $NF}')
@huevos-y-bacon
huevos-y-bacon / convert_mp3_to_mp4.sh
Created July 31, 2023 18:01
CONVERT ALL MP3 FILES IN CURRENT DIRECTORY TO MP4 FILES WITH IMAGE AS BACKGROUND
#!/usr/bin/env bash
# CONVERT ALL MP3 FILES IN CURRENT DIRECTORY TO MP4 FILES WITH IMAGE AS BACKGROUND.
# See https://www.bannerbear.com/blog/how-to-convert-audio-to-video-for-youtube-upload-using-ffmpeg/#convert-mp3-to-mp4-with-an-image
# (Tested on MacOS)
ext=mp3
image=image.jpg
mkdir -p mp4 log
@huevos-y-bacon
huevos-y-bacon / Makefile
Last active July 17, 2023 10:27
CloudFormation Makefile template
AWS_ARGS:=--profile $(AWS_PROFILE) --region $(AWS_REGION)
STACK_NAME:=some-infra
TEMPLATE_FILE:=some-infra.yaml
OWNER:="My Team"
CFN_TAGS:=--tags \
Key=Owner,Value='$(OWNER)' \
Key=DeployedBy,Value=CloudFormation
@huevos-y-bacon
huevos-y-bacon / ssmsm
Last active February 23, 2023 07:35
SSM Session Manager connection by tag:key=Name or instance-id. ssmsm is a straight cli session, while ssmsmwin does port forwarding to use RDP via localhost.
#!/usr/bin/env bash
# shellcheck disable=SC2086
ssm_sm(){
[[ -n $DEBUG ]] && set -x
ARG1="$1"
get_name(){
INSTANCENAME=$(aws ec2 describe-tags \
--filters \
# 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
@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
@huevos-y-bacon
huevos-y-bacon / Brewfile
Last active August 17, 2022 21:50
MacOS: bulk install apps via Homebrew, including App Store apps. Edit the various Brewfiles and run `brew-bundle.sh`
# BASE
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
# BASE Apps
cask "joplin"
cask "bettertouchtool"
cask "visual-studio-code"
cask "bitwarden"
@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 / 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 / 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