Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
andromedarabbit / rds.sh
Created October 22, 2019 03:14
AWS RDS CA 인증서 바꾸기
aws rds describe-db-instances | jq -r '.DBInstances[] | select(.CACertificateIdentifier == "rds-ca-2015") | .DBInstanceIdentifier' | xargs -I {} sh -c 'aws rds modify-db-instance --db-instance-identifier {} --ca-certificate-identifier=rds-ca-2019 --apply-immediately'
@andromedarabbit
andromedarabbit / open-firewall-of-my-digitalocean-droplet.sh
Last active March 12, 2019 09:29
Add external IP address of my Mac/Linux to the inbound rules of my DigitalOcean server
# Prerequisites: `doctl`, `curl` and `jq`
# See https://www.digitalocean.com/community/tutorials/how-to-use-doctl-the-official-digitalocean-command-line-client
# In this particular case, we are going to open the port 22 for ssh connection.
MY_IP=$(curl --silent ifconfig.io/ip) && doctl compute firewall add-rules $(doctl compute firewall list --output=json | jq -r '.[].id') --inbound-rules "protocol:tcp,ports:22,address:${MY_IP}/32"
Verifying my Blockstack ID is secured with the address 12fPpBGuz3WutxpmUMwRmSkAoEyrPLJwKv https://explorer.blockstack.org/address/12fPpBGuz3WutxpmUMwRmSkAoEyrPLJwKv
@andromedarabbit
andromedarabbit / backup-to-gdfs.sh
Last active August 6, 2018 00:39
Backup my local Mac to Google Drive File Stream
#!/bin/bash
if [ -n "${SKIP_BACKUPS}" ]; then
exit 0
fi
type pigz || brew install pigz
type rsync || brew install rsync
type rsync-time-backup.sh || brew install rsync-time-backup
SRC_DIRS=(
@andromedarabbit
andromedarabbit / awslogin.sh
Last active August 2, 2018 08:56
awslogin.sh
#!/bin/bash -e
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
err_report() {
echo ""
echo -e "${RED}USAGE: $(basename $0)${NC}"
echo -e "${RED}USAGE: AWS_LOGIN_PROFILE=my-profile AWS_PROFILE=my-profile-mfa $(basename $0) 123456${NC}"
echo -e "${RED}See${NC} https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/"
@andromedarabbit
andromedarabbit / dr-k8s-apps-per-az.sh
Last active July 29, 2018 14:58
Get a report on Kuberentes application deployment across multiple AZs
#!/bin/bash -e
type csvjson || brew install csvkit
type jq || brew install jq
RED='\033[0;31m'
NC='\033[0m' # No Color
OUTPUT_PODS=pods.csv
truncate -s 0 "${OUTPUT_PODS}"
@andromedarabbit
andromedarabbit / reclaim-policy.yaml
Created July 29, 2018 14:28
Kubernetes Cronjob to set PV's reclaim policy to Retain
kind: ServiceAccount
apiVersion: v1
metadata:
name: reclaim-policy
namespace: monitoring
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: reclaim-policy
@andromedarabbit
andromedarabbit / set-reclaimpolicy-to-retain.sh
Created July 29, 2018 14:16
kuberbetes-set-reclaimpolicy-to-retain.sh
#!/bin/bash
# See https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/
set -eo pipefail
echo ">>> BEFORE"
kubectl get pv
kubectl patch pv $(kubectl get pv -o json | jq -r '.items[] | select(.spec .persistentVolumeReclaimPolicy != "Retain") | .metadata .name') -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'

Article: http://mikegerwitz.com/papers/git-horror-story

Theory

  • faking other user's commits is easy with --author flag $ git commit --author='Foo Bar <foo@bar.com>' -m 'some commit'

  • signing commits ensures:

    • someone else can't commit as myself
  • I really commited all the commits I sign

@andromedarabbit
andromedarabbit / elasticsearch-x-pack-alerting-example.json
Created February 23, 2017 04:39
Elasticsearch X-Pack Alerting Example
PUT _xpack/watcher/watch/outofmemoryerror
{
"trigger" : {
"schedule" : { "cron" : "0 0/4 * * * ?" }
},
"input" : {
"search" : {
"request" : {
"indices" : [
"</logstash><logstash -{now-1h/d}t{now-1h{HH}}>",