Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
andromedarabbit / dl_hankyung.sh
Last active Oct 31, 2021
한경컨센서스에서 보고서 다운로드 받기
View dl_hankyung.sh
#!/bin/bash -e
TODAY=$(date '+%Y-%m-%d')
DOWNLOAD_DIR="${HOME}/Downloads/${TODAY}"
mkdir -p "${DOWNLOAD_DIR}"
type qpdf &>/dev/null || brew install qpdf
type recode &>/dev/null || brew install recode
curl -H 'Accept-Charset: euc-kr' --silent "http://consensus.hankyung.com/apps.analysis/analysis.list?&pagenum=800" | iconv -f euc-kr -t utf-8 | grep report_idx | while IFS= read -r LINE; do
View debug-github-actions.sh
#!/bin/bash -ex
if (! which sshd) ; then
sudo apt-get update -y
sudo apt-get install -y openssh-server
sudo mkdir /run/sshd
sudo /usr/sbin/sshd -d &
fi
if [[ -z "$NGROK_TOKEN" ]]; then
@andromedarabbit
andromedarabbit / rds.sh
Created Oct 22, 2019
AWS RDS CA 인증서 바꾸기
View rds.sh
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'
View gist:28c116d5a5f63a69ed80e1a6a2b9e329
Verifying my Blockstack ID is secured with the address 12fPpBGuz3WutxpmUMwRmSkAoEyrPLJwKv https://explorer.blockstack.org/address/12fPpBGuz3WutxpmUMwRmSkAoEyrPLJwKv
@andromedarabbit
andromedarabbit / Dockerfile
Last active Nov 16, 2021
Create or modify the AWS security group, which only allows GitHub servers to access to our services
View Dockerfile
FROM python:3.7
# Set the timezone to KST
RUN cat /usr/share/zoneinfo/Asia/Seoul > /etc/localtime
RUN set -ex \
&& apt-get clean && apt-get update \
&& apt-get install --no-install-recommends -y groff \
&& rm -rf /var/lib/apt/lists/*
@andromedarabbit
andromedarabbit / backup-to-gdfs.sh
Last active Aug 6, 2018
Backup my local Mac to Google Drive File Stream
View backup-to-gdfs.sh
#!/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 / dr-ec2-instances-per-az.sh
Last active Jun 3, 2021
Get a report on How EC2 instances are deployed across multiple AZs
View dr-ec2-instances-per-az.sh
#!/bin/bash
type csvsql || brew instal csvkit
type jq || brew install jq
type aws || brew intall awscli
TABLE_NAME=tmp
TMP_FILE=${TABLE_NAME}.csv
OUTPUT_FILE="output.csv"
truncate -s 0 "${OUTPUT_FILE}"
@andromedarabbit
andromedarabbit / dr-k8s-apps-per-az.sh
Last active Jul 29, 2018
Get a report on Kuberentes application deployment across multiple AZs
View dr-k8s-apps-per-az.sh
#!/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 Jul 29, 2018
Kubernetes Cronjob to set PV's reclaim policy to Retain
View reclaim-policy.yaml
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 Jul 29, 2018
kuberbetes-set-reclaimpolicy-to-retain.sh
View 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"}}'