Skip to content

Instantly share code, notes, and snippets.

View andrewodri's full-sized avatar
😍

Andrew Odri andrewodri

😍
View GitHub Profile
@andrewodri
andrewodri / sns-to-slack.js
Last active December 1, 2021 21:27
AWS SNS to Slack Lambda Function
const https = require('https')
const url = require('url')
const slackWebhookUrl = process.env.slackWebhookURL
const slackChannel = process.env.slackChannel
const postMessage = message => new Promise((resolve, reject) => {
const data = JSON.stringify(message)
const slackRequest = Object.assign(url.parse(slackWebhookUrl), {
@andrewodri
andrewodri / replace-background.sh
Created September 6, 2018 23:22
Replace Lock Screen Image in macOS
#!/bin/bash
sudo cp /Library/Caches/com.apple.desktop.admin.png /Library/Caches/com.apple.desktop.admin.png.bak
sudo sips -s format png --resampleHeightWidth 1800 2880 $@ --out /Library/Caches/com.apple.desktop.admin.png
sudo chmod 644 /Library/Caches/com.apple.desktop.admin.png
sudo chown $(whoami):admin /Library/Caches/com.apple.desktop.admin.png
@andrewodri
andrewodri / is-container-healthy.sh
Last active November 6, 2018 21:41
Check Docker Container Health
#!/bin/bash
function is_container_healthy {
INSTANCE_ID=$(docker ps --filter "name=$1" --format "{{.ID}}")
IS_HEALTHY=$(docker inspect -f '{{if eq "healthy" .State.Health.Status}}0{{else}}1{{end}}' "${INSTANCE_ID}")
return "${IS_HEALTHY}"
}
@andrewodri
andrewodri / install.sh
Created October 20, 2018 19:59
One-line installs for amazonlinux:1
#!/bin/bash
curl --silent --show-error --location "https://github.com/jpignata/fargate/releases/download/v0.2.3/fargate-0.2.3-linux-amd64.zip" | bsdtar -xf - -C /usr/local/bin && chmod +x /usr/local/bin/fargate
curl --silent --show-error --location "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" | bsdtar -xf - -C /tmp && chmod 755 /tmp/awscli-bundle/install && /tmp/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && rm -rf /tmp/awscli-bundle
@andrewodri
andrewodri / download.ps1
Last active November 16, 2018 16:30
Download Chrome on Windows 7 without a browser
(New-Object System.Net.WebClient).DownloadFile('https://dl.google.com/chrome/install/latest/chrome_installer.exe', 'C:\Temp\chrome_installer.exe');
@andrewodri
andrewodri / README.md
Last active January 8, 2024 08:00
Create and Validate an ACM Certificate

This script performs the following actions:

  1. Creates a TLS certificate in ACM
  2. Upserts a validation CNAME record in Route 53
  3. Waits for the validation CNAME record to complete/update
  4. Waits for the certificate to validate and issue
  5. Outputs a description of the certificate

This obviously assumes that your domain's DNS is hosted on Route 53. It also uses the AWS credentials and region for the environment it is executed in.

@andrewodri
andrewodri / install.sh
Last active December 16, 2020 20:25
Default applications for macOS
#!/bin/bash
# Enable "Allow apps to be installed from: Anywhere" option in System Preferences > Security & Privacy...
sudo spctl –master-enable
# Enabled the startup chime for newer Mac models that come with it disabled by default...
sudo nvram StartupMute=%00
# Disabled ejection buttons in Finder to mitigate accidentally ejecting permanent media...
defaults write com.apple.finder ProhibitEject -bool true
# Display all hidden files and folders...
defaults write com.apple.finder AppleShowAllFiles -bool true
@andrewodri
andrewodri / install.sh
Last active May 23, 2022 18:15
Force dark mode in High Sierra
#!/bin/bash
# https://www.howtogeek.com/fyi/enable-dark-mode-in-high-sierra-sort-of/
# https://medium.com/@n1kk/how-to-tweak-macos-mojave-dark-mode-per-app-a5fab0574691
# https://stackoverflow.com/questions/52562383/is-there-a-way-to-toggle-dark-mode-on-off-for-individual-apps-in-macos-mojave
defaults write -g NSWindowDarkChocolate -bool TRUE
defaults write -g NSRequiresAquaSystemAppearance -bool FALSE
defaults write com.google.Chrome NSRequiresAquaSystemAppearance -bool FALSE
defaults write com.google.Chrome _NSSystemAppearanceOverride DarkAppearance
@andrewodri
andrewodri / resize.sh
Created August 7, 2019 02:18
Resize partition within disk image file
#!/bin/bash
DATA_SIZE=$(du -s \
--exclude="*_[A-Z][A-Z].*" \
--exclude="*_[A-Z][A-Z]_*" \
--exclude="*_[A-Z][A-Z][A-Z].*" \
--exclude="*_[A-Z][A-Z][A-Z]_*" \
/data/ | cut -f1)
#########################################################################
@andrewodri
andrewodri / generate.sh
Last active November 8, 2019 01:11
Generate host file compatible syntax from Docker Network
#/bin/bash
docker network inspect $(docker network ls --format '{{ .ID }}') --format '{{ if (index .Labels "media.promoto.host") }}{{ range (split (index .Labels "media.promoto.host") ",") }}{{ printf "%s %s\n" (index $.IPAM.Config 0).Gateway . }}{{ end }}{{ end }}' | sed '/^$/d'