Skip to content

Instantly share code, notes, and snippets.

View chaspy's full-sized avatar
💭
🤔

Takeshi Kondo chaspy

💭
🤔
View GitHub Profile
@chaspy
chaspy / how-to-add-a-new-lint-to-tflint-ruleset-aws.md
Last active May 14, 2022 06:20
How to add a new lint to tflint-ruleset-aws

How to add a new lint to tflint-ruleset-aws

tflint の aws 向けの rule set は pluggable になっており、新規 rule 追加がしやすくなっています。本発表では DB Instance の engine が valid のテストを追加する PR を元に、Contribution の方法と、その lint の仕組みを解説します。

Who am I

Lead Software Engineer, Site Reliability at Quipper

@chaspy
chaspy / retry.sh
Created January 7, 2019 01:47 — forked from sj26/LICENSE.md
Bash retry function
# Retry a command up to a specific numer of times until it exits successfully,
# with exponential back off.
#
# $ retry 5 echo Hello
# Hello
#
# $ retry 5 false
# Retry 1/5 exited 1, retrying in 1 seconds...
# Retry 2/5 exited 1, retrying in 2 seconds...
# Retry 3/5 exited 1, retrying in 4 seconds...
#!/bin/bash
# docker for ubuntu 18.04
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get remove docker docker-engine docker.io
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@chaspy
chaspy / gist:9211356ee3775c91363656c0dbaf659f
Last active September 16, 2018 01:27
isucon_addkey.sh
#!/bin/bash
set -eux
set -o pipefail
user=$1
# for ubuntu
adduser ${user}
gpasswd -a ${user} wheel
sudo -u ${user} mkdir /home/${user}/.ssh
@chaspy
chaspy / peco-kubectx
Created September 9, 2018 15:45 — forked from yuya-takeyama/peco-kubectx
Select Kubernetes context with peco
#!/bin/bash
PECO_CMD="peco"
KUBECTL_CMD="kubectl"
if ! hash "${PECO_CMD}" 2> /dev/null; then
>&2 echo "error: ${PECO_CMD} is not installed"
>&2 echo "see https://github.com/peco/peco"
exit 1
fi
#!/bin/bash
set -x
readonly URL="https://api.github.com/search/issues"
usage() {
cat <<EOS >&2
Usage: $0 -u <user> -s YYYY-MM-DD -e YYYY-MM-DD
-u: your github user name
-s: start date to get your contribution
@chaspy
chaspy / get_asg_instances_ip.sh
Last active August 30, 2018 15:32
get ip-addr of instances in ASG(searched by peco)
aws autoscaling describe-auto-scaling-groups |\
jq -r '.AutoScalingGroups[].AutoScalingGroupName' |\
peco |\
xargs -I{} aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names {} |\
jq -r '.AutoScalingGroups[]|.Instances[]|select(.LifecycleState == "InService")|select(.HealthStatus == "Healthy")|.InstanceId' |\
xargs aws ec2 describe-instances --instance-ids |\
jq -r '.Reservations[].Instances[]|select(.State.Name == "running")|.PrivateIpAddress'
@chaspy
chaspy / get_issues_for_release.sh
Last active September 3, 2018 15:10
for kamontia/qs release issue
#!/bin/bash
LABELS="enhancement improvement"
MILESTONE="v0.2.0"
REPO="kamontia/qs"
for LABEL in $LABELS
do
echo "# ${LABEL}"
curl -sS https://api.github.com/search/issues?q=repo:"$REPO"+label:"$LABEL"+milestone:"$MILESTONE" \
| jq -c '.items[] | {title,html_url} | .html_url |= . + "\n" ' \
#!/bin/bash
set -eux
set -o pipefail
if [ "$(id -un)" != "root" ]; then
echo "You should run with sudo." 1>&2
echo "-------------------------"
exit 1
fi
#!/bin/bash
touch /tmp/trap.$$
trap 'echo "trapped"; rm /tmp/trap.$$; exit 1' 2
while :
do
echo "loop"
sleep 10