Skip to content

Instantly share code, notes, and snippets.

View dserodio's full-sized avatar
🐕

Daniel Serodio dserodio

🐕
View GitHub Profile
@dserodio
dserodio / keybase.md
Last active October 14, 2020 12:00
Keybase proof

Keybase proof

I hereby claim:

  • I am dserodio on github.
  • I am dserodio (https://keybase.io/dserodio) on keybase.
  • I have a public key whose fingerprint is CFB1 D267 024B 720A F4F5 27AB 6C51 A8CC BB58 BCC8

To claim this, I am signing this object:

@dserodio
dserodio / psql_check_ssl.sql
Created August 20, 2020 14:53
Check if PostgreSQL is using SSL
SELECT s.pid, s.ssl, s.version, a.client_addr, a.usename, a.datname, a.query
FROM pg_stat_ssl AS s
JOIN pg_stat_activity AS a ON a.pid = s.pid;
-- You can see `t|f` in `ssl` field
@dserodio
dserodio / test-psql-connectivity.sh
Last active April 7, 2020 22:37
Useful for testing downtime while applying modifications in RDS
while true; do
date -Isec | sed -e 's/+00:00//' | tr '\n' ' '
pg_isready -h YOUR_RDS_INSTANCE.rds.amazonaws.com -U USER -d DB_NAME
sleep 1
done | tee connection-test-$(date -Imin).log
"""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 / git-tips.md
Last active December 17, 2018 12:50
Some git tips

Don't blame people for changing whitespaces or moving code

git blame will show the author of the last commit that modified the particular line. If whitespaces were removed or that piece of code was moved around, blame will show that commit and you might blame the wrong person.

git blame -w -M

-w will ignore whitespaces and -M will detect moved or copied lines.

Source: https://coderwall.com/p/x8xbnq/git-don-t-blame-people-for-changing-whitespaces-or-moving-code

@dserodio
dserodio / wait_for_line_in_log.sh
Last active November 29, 2018 15:29
Wait for some text in a log file
{ tail -n +1 -f file.log & } | sed -n '/Initialization finished/q'
@dserodio
dserodio / test_trap.sh
Created April 22, 2016 16:03
Bash script which traps some signals and prints the name of the received signal
#!/bin/bash
#
# http://stackoverflow.com/a/9256709/31493
trap_with_arg() {
func="$1" ; shift
for sig ; do
trap "$func $sig" "$sig"
done
}
@dserodio
dserodio / scrap.sh
Last active November 29, 2018 15:27
ps(1) tips and tricks
# show process start time for a give PID (GNU ps)
ps -o lstart= -p $PID
# show process start time for all processes (GNU ps)
ps ax -O lstart
# show process environment variables (BSD grep)
ps -Eww -p $PID
@dserodio
dserodio / minikube-on-xhyve.sh
Created November 29, 2016 16:20
Get native (no VM) Docker support for Kubernetes on OS X
# get native (no VM) docker support (see also Docker for Mac, but this is to support minikube)
brew install docker-machine-driver-xhyve
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
minikube start --vm-driver=xhyve
# or do this first
minikube config set vm-driver xhyve
minikube start