Skip to content

Instantly share code, notes, and snippets.

View cam8001's full-sized avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Amazon Web Services
  • Wellington, New Zealand
  • 06:35 (UTC +13:00)
View GitHub Profile
@cam8001
cam8001 / 20241029-eaton5e-ubuntu-README.md
Last active October 29, 2024 08:53
Set up Eaton 5e UPS on Ubuntu Noble 24.04

Ubuntu uses a service, Network UPS Tools (NUT), to monitor UPSes and take given actions when they send signals.

The Eaton 5e is not a network UPS, its USB. This is what I needed to do to set it up.

$ sudo apt install nut nut-client

For whatever reason, I didn't have USB libraries on my install of 24.04. So:

$ sudo apt install libusb-1.0-0-dev

@cam8001
cam8001 / flash-sas2008-README.md
Created October 27, 2024 07:11
Flash LSI 9210-8i Host Bus Adapter (HBA) with SAS2008 chipset to Initiator Target (IT) mode so that you can use SATA instead of SAS drives, on a Supermicro motherboard
@cam8001
cam8001 / quick-aliases.sh
Last active October 29, 2024 08:15
Add quick aliases to current session
# Current session:
# echo `curl -fsSL https://https://gist.githubusercontent.com/cam8001/c1eaf86f01f3b31b15dc8dd5ae803b37/raw/e5749b7f29b3952f067aaa14008e098a730f43f6/quick-aliases.sh`
# Permanent:
# echo `echo `curl -fsSL https://https://gist.githubusercontent.com/cam8001/c1eaf86f01f3b31b15dc8dd5ae803b37/raw/e5749b7f29b3952f067aaa14008e098a730f43f6/quick-aliases.sh` >> .zshrc
alias l='ls -lash'
alias ..='cd ..'
@cam8001
cam8001 / goonsay.sh
Created September 7, 2023 02:17
goonsay.sh
echo " ___________ $@"
echo " (--)[ .]-[ .] /"
echo " (________O__)"
@cam8001
cam8001 / role-instructions.md
Last active May 22, 2023 22:50
`Failed to delete stack: Role <role> is invalid or cannot be assumed` Assume this role from the cli if your cloudformation stack can't delete

Create a role with a trust policy that can be assumed by Cloudformation. Trust policy looks like this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
 "Effect": "Allow",
@cam8001
cam8001 / http-apigw-log-format.json
Created May 13, 2023 07:43
Logging config for API Gateway JSON format with all variable included
{ "accountId": "$context.accountId", "apiId": "$context.apiId", "authorizer.error": "$context.authorizer.error", "authorizer.principalId": "$context.authorizer.principalId", "authorizer.property": "$context.authorizer.property", "awsEndpointRequestId": "$context.awsEndpointRequestId", "awsEndpointRequestId2": "$context.awsEndpointRequestId2", "customDomain.basePathMatched": "$context.customDomain.basePathMatched", "dataProcessed": "$context.dataProcessed", "domainName": "$context.domainName", "domainPrefix": "$context.domainPrefix", "error.message": "$context.error.message", "error.messageString": "$context.error.messageString", "error.responseType": "$context.error.responseType", "extendedRequestId": "$context.extendedRequestId", "httpMethod": "$context.httpMethod", "identity.accountId": "$context.identity.accountId", "identity.caller": "$context.identity.caller", "identity.cognitoAuthenticationProvider": "$context.identity.cognitoAuthenticationProvider", "identity.cognitoAuthenticationType": "$context.ident
@cam8001
cam8001 / .zshrc
Created May 6, 2023 02:29
aws cli autocompletions for zsh
# after doing `brew install awscli`, add the following to the bottom of your .zshrc:
autoload bashcompinit && bashcompinit
source /opt/homebrew/share/zsh/site-functions/aws_zsh_completer.sh
@cam8001
cam8001 / etcher.md
Created February 6, 2023 20:55
balena-etcher-cli
# connect your flash drive
# make sure it is visible to etcher

$ balena util available-drives
@cam8001
cam8001 / service-regions.sh
Last active December 20, 2023 19:41
One liner to get list of services keyed to AWS region
#!/bin/bash
curl -s 'https://api.regional-table.region-services.aws.a2z.com/index.json' \
| jq '.prices[] | .attributes | .["aws:region"], .["aws:serviceName"]' \
| sed '$!N;s/\n/,/'
@cam8001
cam8001 / export-contact-list.sh
Created September 15, 2022 00:18
Export a contact list from SES, with pagination
#!/bin/bash
# Specify contact list name here
CONTACT_LIST_NAME=''
OUTPUT_FILE="./contact-list_$CONTACT_LIST_NAME-$(date +%s).csv"
AWS_CLI_COMMAND="aws sesv2 list-contacts --contact-list-name $CONTACT_LIST_NAME --filter FilteredStatus=OPT_IN --page-size 1000 "
function cli_call() {
if [ ! -z NEXT_TOKEN ]; then
cli_output=$($AWS_CLI_COMMAND)