A dumping ground for shell commands and regular expressions that should be POSIX-compliant and portable, as well as some bash stuff that should be portable across bash versions (>= 2).
read -r -d '' -a arr < <( command && printf '\0' )| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = [ | |
| # "boto3" | |
| # ] | |
| # /// | |
| from __future__ import annotations | |
| import argparse | |
| import base64 |
| # ====== Options ====== | |
| setopt NO_CASE_GLOB | |
| setopt SHARE_HISTORY | |
| setopt EXTENDED_HISTORY | |
| setopt APPEND_HISTORY | |
| setopt HIST_VERIFY | |
| setopt HIST_EXPIRE_DUPS_FIRST | |
| setopt HIST_IGNORE_DUPS | |
| setopt HIST_FIND_NO_DUPS | |
| setopt HIST_REDUCE_BLANKS |
| AWSTemplateFormatVersion: "2010-09-09" | |
| Description: Creates a Step Functions State Machine that is executed when new items are added to a DynamoDB Table. | |
| Resources: | |
| Table: | |
| Type: "AWS::DynamoDB::Table" | |
| Properties: | |
| AttributeDefinitions: | |
| - AttributeName: "PK" | |
| AttributeType: "S" | |
| KeySchema: |
| #!/usr/bin/env bash | |
| # | |
| # Utility script for creating an empty GitHub dependency graph snapshot for a given <detector>-<job-correlator> combination. | |
| # This can be useful to update your dependency graph in GitHub if you've used Syft or similar to manually publish | |
| # dependency graph snapshots for artifacts that have been removed from the codebase. | |
| # | |
| # The script asks for confirmation before actually making the POST request to GitHub's Dependency Submission API. | |
| set -euo pipefail | |
| IFS=$'\n\t' |
| #!/usr/bin/env bash | |
| # | |
| # Script that uses the AWS CLI to list all active CloudFormation stacks | |
| # in all enabled regions. | |
| # | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| regions="$(aws account list-regions --region-opt-status-contains "ENABLED" "ENABLED_BY_DEFAULT" --query "Regions[].[RegionName]" --output text && printf '\0')" | |
| read -r -d '' -a regions < <(aws account list-regions --region-opt-status-contains "ENABLED" "ENABLED_BY_DEFAULT" --query "Regions[].[RegionName]" --output text && printf '\0') |
| # NOTE: In order for IAM users and roles to have access to AWS billing and cost management, | |
| # you'll first need to activate IAM access using your AWS root user. You can follow the guide | |
| # at the link below if you haven't already configured this. | |
| # https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_billing.html?icmpid=docs_iam_console#tutorial-billing-step1 | |
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: | | |
| Creates an AWS Budgets Budget that notifies you by email once you're on track to exceed the monthly budget." | |
| Parameters: | |
| Email: |
| #!/usr/bin/env bash | |
| # | |
| # Experimental shell script for downloading files from S3 and | |
| # skipping local files with the same filenames. | |
| # | |
| # Example usage: bash shell.sh --bucket-name "my-bucket" --target-dir "./my-local-dir" --prefix "my-prefix/" --flatten "true" | |
| set -euo pipefail | |
| IFS=$'\n\t' |
| #!/usr/bin/env bash | |
| # | |
| # Helper functions for replacing placeholders in files. | |
| # | |
| # Distributed under terms of the MIT license. | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| # Print example usage of the script. |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| read -r -d '' -a regions < <(aws ec2 describe-regions --query "Regions[].[RegionName]" --output text && printf '\0') | |
| for region in "${regions[@]}"; do | |
| echo "[$region] Finding CloudFormation stacks deployed using CDK" | |
| read -r -d '' -a stacks < <(aws cloudformation list-stacks --region "$region" --query "StackSummaries[?!contains(keys(@), 'DeletionTime')].[StackName]" --output text && printf '\0') | |
| test -z "${stacks:-}" && continue |