Skip to content

Instantly share code, notes, and snippets.

View dserodio's full-sized avatar
🐕

Daniel Serodio dserodio

🐕
View GitHub Profile
"""Replace 'name' tag with 'Name' and 'application' with 'Application'
"""
import boto3
def uppercaseTagKeys(arn, name, application=None):
tags = {}
if name:
tags['Name'] = name
@dserodio
dserodio / Dockerfile
Last active April 12, 2019 16:44
Dockerfile for multi-stage build of a Ruby app which needs Node at build time (credits: https://github.com/gomex)
# Dockerfile for a multi-stage build of a Ruby app which needs Node at build time
#
# Thanks to https://github.com/gomex for sharing
FROM ruby:2.5.1 as builder
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - &&\
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
@dserodio
dserodio / say.sh
Created November 12, 2018 16:36
Using Google Text to Speech (TTS) in Linux CLI
# gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API
# https://github.com/pndurette/gTTS
pipsi install gTTS
sudo apt install mpg123
say() {
gtts-cli "$@" | mpg123 -
}
@dserodio
dserodio / history.sh
Last active January 11, 2023 13:34
Misc bash snippets
# Show timestamp for history output
export HISTTIMEFORMAT="%d/%m/%y %T "
@dserodio
dserodio / README.md
Created September 24, 2018 21:06
Config. AWS PostgreSQL RDS to use pgbadger

Set the following properties in RDS:

log_min_duration_statement = 250
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0
@dserodio
dserodio / dropdown.md
Created August 9, 2018 16:57 — forked from citrusui/dropdown.md
"Dropdowns" in Markdown
How do I dropdown?
This is how you dropdown.

<details>
<summary>How do I dropdown?</summary>
<br>
This is how you dropdown.
// https://github.com/isaacs/github/issues/514#issuecomment-408216389
Array.from(document.getElementsByClassName('js-details-target')).forEach(function(element){element.click()})
@dserodio
dserodio / date.py
Last active February 27, 2023 17:29
Python snippets
# Parse date
# $ pip install python-dateutil
from dateutil import parser
begin = parser.parse("Aug 28 1999 12:00AM")
end = parser.parse("2013-09-11")
# Print duration
delta = end - begin
print str(delta)
@dserodio
dserodio / aws.sh
Last active June 21, 2022 17:50
AWS snippets
# find the owner of an AWS access key
# https://stackoverflow.com/a/31275655
for user in $(aws iam list-users --output text | awk '{print $NF}'); do
aws iam list-access-keys --user $user --output text
done
# alternative that uses jq(1) insteaed of awk(1)
for user in $(aws iam list-users --query 'Users[*].UserName' --output text); do
@dserodio
dserodio / get-tags.sh
Created June 26, 2018 22:31
Get EC2 instance tags
# See https://stackoverflow.com/a/24549602/31493 and
# https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-tags.html
TAG_NAME="Name"
INSTANCE_ID=$(wget -qO- http://instance-data/latest/meta-data/instance-id)
REGION=$(wget -qO- http://instance-data/latest/meta-data/placement/availability-zone | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:')
TAG_VALUE="`aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" "Name=key,Values=$TAG_NAME" --region $REGION --output=text | cut -f5`"