Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
tkuchiki / bulk_insert.sh
Last active November 1, 2017 02:11
MySQL bulk insert
# mysql -u root -e "CREATE DATABASE testdb"
# mysql -u root testdb -e "CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY, c1 INT, c2 INT, c3 INT)"
for i in $(seq 0 999); do
{ echo "INSERT INTO t1 (c1, c2, c3) VALUES "
for j in $(seq 1 1000); do
ii=$(( ($i * 1000) + $j ))
iii=$(( $ii + 10000000))
iiii=$(( $ii + 100000000))
echo -n " (${ii}, ${iii}, ${iiii}),"
@tkuchiki
tkuchiki / install.sh
Last active October 20, 2016 03:56
install miruo for Ubuntu
cd /usr/local/src
git clone https://github.com/KLab/miruo
cd ./miruo/
apt-get install -y libpcap-dev
./configure --prefix=/usr
make
make install
@tkuchiki
tkuchiki / install.sh
Last active January 15, 2025 01:08
nutcracker(twemproxy) for systemd
curl -L "https://drive.google.com/uc?id=0B6pVMMV5F5dfb1YwcThnaVZXbjg" -o nutcracker-0.4.1.tar.gz
tar zxf nutcracker-0.4.1.tar.gz
cd nutcracker-0.4.1
./configure --prefix=/usr
make
make install
mkdir /etc/nutcracker
cp conf/nutcracker.yml /etc/nutcracker
cat << 'EOC' > /lib/systemd/system/nutcracker.service
@tkuchiki
tkuchiki / install.sh
Last active October 19, 2016 05:09
nginx-build で Mac OSX に openresty をインストールする
mkdir -p /usr/local/src/nginx/modules /usr/local/openresty/{cache,luajit,sbin,bin,tmp}
brew install pcre openssl
cd /usr/local/src/nginx/modules
git clone https://github.com/cubicdaiya/ngx_dynamic_upstream
nginx-build -d /usr/local/src/nginx -openresty -c nginx.configure --verbose
cd /usr/local/src/nginx/openresty/1.11.2.1/openresty-1.11.2.1/
make install
@tkuchiki
tkuchiki / mcrouter.md
Last active October 6, 2016 05:56
mcrouter の設定例
@tkuchiki
tkuchiki / memcached_keys.sh
Last active October 8, 2016 13:23
memcached の key 一覧を出力する
for item in $(echo "stats items" | nc localhost 11211 | grep number | tr ':' ' ' | awk '{print $3"_"$5}'); do echo "stats cachedump $(echo $item | awk -F '_' '{print $1, $2}')"; done
@tkuchiki
tkuchiki / slack_post_msg.sh
Created October 6, 2016 02:49
Slack の API で DM を送る
#!/bin/bash
TOKEN="your api token"
# channel=@SLACK_USERNAME で DM を送れる
SLACK_USERNAME="@SLACK_USERNAME"
MSG="${1}"
curl -XPOST "https://slack.com/api/chat.postMessage?token=${TOKEN}&channel=${SLACK_USERNAME}&text=${MSG}&username=notify"
@tkuchiki
tkuchiki / install.sh
Created October 5, 2016 06:46
Ubuntu 16.04 に mcrouter をインストールする
apt-get update
apt-get upgrade -y g++
apt-get upgrade -y autoconf
apt-get upgrade -y pkg-config
git clone https://github.com/facebook/mcrouter /usr/local/src/mcrouter
cd /usr/local/src/mcrouter/mcrouter
bash scripts/install_ubuntu_16.04.sh /opt/mcrouter
@tkuchiki
tkuchiki / install.sh
Last active October 3, 2016 04:46
Ubuntu 16.04 に Erlang 17.5 + Riak 2.1.4 をインストール
apt-get install -y build-essential libncurses5-dev libssl-dev git libpam0g-dev curl
# install Erlang 17.5
cd /usr/local/src
curl -L http://erlang.org/download/otp_src_17.5.tar.gz -O
tar zxf otp_src_17.5.tar.gz
cd otp_src_17.5
./configure --prefix=/opt/erlang/17.5 --enable-smp-support --enable-threads --enable-m64-build --enable-kernel-poll --enable-hipe --without-javac --enable-dirty-schedulers --enable-sha
ring-preserving
make install
@tkuchiki
tkuchiki / autoscaling.tf
Last active July 17, 2017 00:04
terraform 設定例 (v0.7.9)
resource "aws_launch_configuration" "test" {
name = "test"
image_id = "${var.ami}"
instance_type = "t2.micro"
associate_public_ip_address = true
security_groups = ["${aws_security_group.internal.id}"]
}
resource "aws_autoscaling_group" "test" {
name = "test"