Skip to content

Instantly share code, notes, and snippets.

@vioan
vioan / rds_to_docker.md
Created April 6, 2022 21:21 — forked from herval/rds_to_docker.md
Moving a Postgres db from RDS to a Docker container

Make a backup from RDS

pg_dump -h <rds host> -p 5432 -F c -O -U <rds user> <db name> > db.dump

Restore the backup into a Docker container

docker run --rm --interactive --link <postgres container id>:postgres --volume $PWD/:/tmp/ postgres:latest /bin/bash -c 'pg_restore --verbose --clean --no-acl --no-owner -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -d <db name> /tmp/db.dump'
@vioan
vioan / rw_ro_access.sql
Created May 19, 2021 17:05 — forked from checco/rw_ro_access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
--
-- Read only
--
-- Create a group
CREATE ROLE postgres_ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO postgres_ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group;
@vioan
vioan / create_user_for_namespace.sh
Created March 16, 2021 22:39 — forked from steimntz/create_user_for_namespace.sh
Script to create user with permission for a specific namespace.
#!/bin/bash
#
# Script based on https://jeremievallee.com/2018/05/28/kubernetes-rbac-namespace-user.html
#
# In honor of the remarkable Windson
#/bin/bash
namespace=$1
if [[ -z "$namespace" ]]; then
echo "Use "$(basename "$0")" NAMESPACE";
@vioan
vioan / get_history.sh
Created February 19, 2021 21:58 — forked from TravelingTechGuy/get_history.sh
Get your Chrome history as a CSV file
#!/bin/bash
# Locate the history file in your profile, and copy it to the same folder as this script.
# On Mac: ~/Library/Application\ Support/Google/Chrome/Default/History
# On Windows: C:\Users\YOUR USER NAME\AppData\Local\Google\Chrome\User Data\Default\History
sqlite3 History <<!
.headers on
.mode csv
.output out.csv
@vioan
vioan / LC_CTYPE.txt
Created June 13, 2020 19:24 — forked from thanksdanny/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
#!/bin/bash
# assign env var, if set
HB="${HOMEBREW_PREFIX:=/usr/local}"
find -L "${HB}/opt" -name 'INSTALL_RECEIPT.json' -maxdepth 2 -print > /tmp/homebrew-installed.txt
printf '' > /tmp/homebrew-installed-w-options.txt
NAME=''
@vioan
vioan / Terraform-Blue-Green-AWS.md
Created May 22, 2020 09:14 — forked from ryan0x44/Terraform-Blue-Green-AWS.md
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.

@vioan
vioan / VirtualBox Guest Settings.md
Created April 20, 2020 17:53 — forked from zapstar/VirtualBox Guest Settings.md
My Dnsmasq configuration on OSX. This acts as both DNS & DHCP server for my VirtualBox host-only network
  • First create a host-only network if not already done so. Use the IP Address 192.168.56.1 with the netmask 255.255.255.0. Don't enable DHCP server (next tab), it should be unchecked.

  • Make sure two network interfaces are assigned to the VM. The first being a NAT interface (note: NOT NAT Network). The second being a Host-Only Adapter.

  • In the Ubuntu guest the /etc/network/interfaces file should look something similar to below.

# This file describes the network interfaces available on your system
@vioan
vioan / generate-self-signed-certificate-with-custom-CA.md
Created April 18, 2020 20:52 — forked from Kmaschta/generate-self-signed-certificate-with-custom-CA.md
How to generate a self-signed that is valid for your browser (by creating your custom certificate authority)

If you're using self-signed certificate for your web server on development, you might know the browser warning saying that your certificate isn't valid. If like me you had manually added an exception for this certificate error each time it showed up, this gist is for you.

Properly Configure OpenSSL with your DNS aliases

You'll have to create a self-signed certificate with a custom SubjectAltName.

  1. Find your openssl config. find /usr/lib -name openssl.cnf
#!/bin/sh
MANAGER_COUNT=1
WORKER_COUNT=1
MANAGER_NAME=swarm-manager
WORKER_NAME=swarm-worker
MANAGER_LIST=""
for i in `seq 1 $MANAGER_COUNT`;