Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Serodio dserodio

View GitHub Profile
@dserodio
dserodio / Vagrantfile
Last active Oct 14, 2020 — forked from lorn/Vagrantfile
Vagrantfile
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb|
vb.name = "ubuntu.local"
vb.customize [ 'modifyvm', :id, '--memory', '512' ]
vb.customize [ 'modifyvm', :id, '--cpus', '1' ]
end
@dserodio
dserodio / keybase.md
Last active Oct 14, 2020
Keybase proof
View keybase.md

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 / aws.sh
Last active Sep 16, 2020
AWS snippets
View aws.sh
# 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 / psql_check_ssl.sql
Created Aug 20, 2020
Check if PostgreSQL is using SSL
View psql_check_ssl.sql
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 / toggle_zero_columns.gs
Created Aug 12, 2020
Hide Google Sheets columns with zeros
View toggle_zero_columns.gs
/*
* https://stackoverflow.com/a/13591754/31493
*/
function onOpen() {
// get active spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
// create menu
var menu = [{name: "Hide columns", functionName: "hideColumns"},
@dserodio
dserodio / test-psql-connectivity.sh
Last active Apr 7, 2020
Useful for testing downtime while applying modifications in RDS
View test-psql-connectivity.sh
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
@dserodio
dserodio / history.sh
Last active Sep 13, 2019
Misc bash snippets
View history.sh
# Show timestamp for history output
export HISTTIMEFORMAT="%d/%m/%y %T "
View rename_lambda_tags.py
"""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 Apr 12, 2019
Dockerfile for multi-stage build of a Ruby app which needs Node at build time (credits: https://github.com/gomex)
View Dockerfile
# 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 Dec 17, 2018
Some git tips
View git-tips.md

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

You can’t perform that action at this time.