Skip to content

Instantly share code, notes, and snippets.

View andrewodri's full-sized avatar
😍

Andrew Odri andrewodri

😍
View GitHub Profile
@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 / Dockerfile
Last active December 22, 2023 20:56
Connect Fargate instance to SSM Session Manager
FROM debian:10-slim
RUN apt-get update -y && \
apt-get install -y awscli curl gnupg && \
apt-key adv --fetch-keys "https://nginx.org/keys/nginx_signing.key" && \
echo "deb http://nginx.org/packages/debian buster nginx" > /etc/apt/sources.list.d/nginx.list
RUN curl --silent --show-error --location --output /tmp/amazon-ssm-agent.deb "https://s3.us-east-1.amazonaws.com/amazon-ssm-us-east-1/latest/debian_amd64/amazon-ssm-agent.deb" && \
dpkg -i /tmp/amazon-ssm-agent.deb
@andrewodri
andrewodri / README.md
Last active November 16, 2023 06:53
Download specific macOS version and create USB installer from the CLI

I always seem to forget how to download the macOS version I need by the time I need it again, so here is a quick and nasty guide on how to download a properly signed *.dmg file to build a USB installer.

If you don't want to download the tool or monkey around with permissions, give this a shot: (Provided you are dumb enough to pipe unknown code off the internet in sudo python of course):

  • sudo curl -s https://raw.githubusercontent.com/grahampugh/macadmin-scripts/master/installinstallmacos.py | sudo python - --help

If you're downloading an installer for your current machine, do the following:

@andrewodri
andrewodri / README.md
Last active November 10, 2023 14:12
Install .NET SDK 5.0 on macOS one-liner

Based on the official Microsoft documentation with a bit of sketchiness added in for convenience:

echo -ne "\033[0;31mdotnet-install:\033[0m Enter the .NET Core SDK channel (i.e. n.n, not n.n.n) you would like to install: " && read CHANNEL; curl -sSL https://dot.net/v1/dotnet-install.sh | bash -s -- --channel "${CHANNEL}" && grep -qxF 'export PATH=$PATH:$HOME/.dotnet' ~/.zshrc || echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.zshrc && source ~/.zshrc

This does the following:

  • Prompt the user to enter a .NET Core SDK version to install
  • Install the entered .NET Core SDK version
@andrewodri
andrewodri / launch.json
Created September 12, 2023 23:30
VSCode task to close an external Terminal on macOS when debugging in Node
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "npm-run-build",
"group": "build",
"type": "shell",
"hide": false,
@andrewodri
andrewodri / lifecam.sh
Created January 25, 2021 13:19
Fix overexposure on Microsoft LifeCam in macOS
#!/bin/zsh
cat "alias brew='arch -x86_64 brew'" > ~/.zshrc
brew install nvm
cat EOM > ~/.zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
@andrewodri
andrewodri / dotenv-to-ssm.sh
Last active July 27, 2023 16:18
Get and set SSM parameters from Bash and/or .env
#!/bin/bash
# set_parameter() { aws ssm put-parameter --overwrite --name "${1}" --value "${2}" --type String --query "''" --output text; }
# set_secure_parameter() { aws ssm put-parameter --overwrite --name "${1}" --value "${2}" --type SecureString --query "''" --output text; }
set_parameter() { aws ssm put-parameter --overwrite --query "''" --output text --cli-input-json '{"Name":"'${1}'","Value":"'$(echo -ne "${2}" | perl -pe 's/(\\(\\\\)*)/$1$1/g; s/(?!\\)(["\x00-\x1f])/sprintf("\\u%04x",ord($1))/eg;')'","Type": "String"}'; }
set_secure_parameter() { aws ssm put-parameter --overwrite --query "''" --output text --cli-input-json '{"Name":"'${1}'","Value":"'$(echo -ne "${2}" | perl -pe 's/(\\(\\\\)*)/$1$1/g; s/(?!\\)(["\x00-\x1f])/sprintf("\\u%04x",ord($1))/eg;')'","Type": "SecureString"}'; }
if [[ "${1}" = "-h" || "${1}" = "--help" || ( -z "${1}" && -z "${2}" ) ]]
then
echo -e 'Example usage:\n ./dotenv-to-ssm.sh [INPUT_FILE] [SSM_PARAMETER_PREFIX]'
@andrewodri
andrewodri / bytes.sql
Created May 23, 2023 17:45
Convert SQLite TEXT to underlying binary representation of unicode data as INTEGER
WITH RECURSIVE bytes(i, byte) AS (
VALUES(1, 0)
UNION ALL
SELECT i + 1, (
WITH code_points(code_point) AS (
VALUES(0)
UNION ALL
SELECT (UNICODE(
SUBSTR('hey', i * -1, 1)
) << (i - 1) * 8) FROM code_points LIMIT 2
@andrewodri
andrewodri / remove.sql
Created February 26, 2020 18:44
Remove all users from Wordpress Multisite that do not belong to other sites
SET @site_id = 1;
SELECT user_id
FROM wp_usermeta
WHERE meta_key = CONCAT('wp_', @site_id, '_capabilities')
AND meta_value LIKE 'a:1:{s%'
HAVING user_id NOT IN (
SELECT user_id
FROM wp_usermeta
WHERE meta_key LIKE CONCAT('wp_', @site_id, '_capabilities')
@andrewodri
andrewodri / obs-virtualcamera.sh
Created October 3, 2022 14:47
Fix for OBS Virtual Camera with common apps
#!/bin/sh -e
sudo codesign --remove-signature /Applications/Discord.app/Contents/Frameworks/Discord\ Helper\ \(GPU\).app /Applications/Discord.app/Contents/Frameworks/Discord\ Helper\ \(Plugin\).app /Applications/Discord.app/Contents/Frameworks/Discord\ Helper\ \(Renderer\).app /Applications/Discord.app/Contents/Frameworks/Discord\ Helper.app