Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
andromedarabbit / dl_hankyung.sh
Last active October 31, 2021 13:17
한경컨센서스에서 보고서 다운로드 받기
#!/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
#!/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 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'
Verifying my Blockstack ID is secured with the address 12fPpBGuz3WutxpmUMwRmSkAoEyrPLJwKv https://explorer.blockstack.org/address/12fPpBGuz3WutxpmUMwRmSkAoEyrPLJwKv
@andromedarabbit
andromedarabbit / Dockerfile
Last active March 26, 2024 04:34
Create or modify the AWS security group, which only allows GitHub servers to access to our services
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 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 / dr-ec2-instances-per-az.sh
Last active June 3, 2021 01:54
Get a report on How EC2 instances are deployed across multiple AZs
#!/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 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"}}'