Skip to content

Instantly share code, notes, and snippets.

@gholker
gholker / download-aws-logs.sh
Last active November 28, 2023 11:01
Script that uses the aws cli to download cloudwatch logs to a file
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
LOG_GROUP_NAME=""
LOG_STREAM_NAME=""
REGION=""
OUTPUT_FILE="$(date +"%Y%m%d").log"
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 7, 2024 16:31
set -e, -u, -o, -x pipefail explanation
@xiongchiamiov
xiongchiamiov / why.sh
Last active March 14, 2023 04:19
Use this when Amazon gives you an "Encoded authorization failure message" and you need to turn it into something readable. If you only get a request id... you're out of luck.
function decode-authorization-failure-message {
if [ $# -ne 1 ] || [ "$1" = -h ] || [ "$1" = --help ]; then
cat <<'EOT'
Usage: decode-authorization-failure-message <message>
Use this when Amazon gives you an "Encoded authorization failure message" and
you need to turn it into something readable.
EOT
return 1
fi
@phips
phips / hosts.yml
Last active August 2, 2021 19:59
Ansible setting of hostname from inventory, but ignoring IP addresses
- name: Ensure hostname set
hostname:
name: {{ inventory_hostname }}
when: not inventory_hostname|trim is match('(\d{1,3}\.){3}\d{1,3}')
- name: Ensure hostname is in /etc/hosts
lineinfile:
dest: /etc/hosts
regexp: "^{{ ansible_default_ipv4.address }}.+$"
line: "{{ ansible_default_ipv4.address }} {{ ansible_fqdn }} {{ ansible_hostname }}"
@rbf
rbf / README.md
Last active March 28, 2024 08:04
Script to recursively generate PDF files from markdown files in the current directory and its subfolders using "pandoc".

%process-md % https://gist.github.com/rbf/6064734

Description

process-md is a bash tool to recursively generate files from markdown files in other formats using pandoc, which is assumed installed. By default (i.e. calling command tool with no arguments) it processes all markdown files in the current directory and places the resulting PDF files in a ./target directory.