Skip to content

Instantly share code, notes, and snippets.

View tsaito-cyber's full-sized avatar

tsaito-cyber tsaito-cyber

View GitHub Profile
@tsaito-cyber
tsaito-cyber / gem-installer.sh
Created November 13, 2015 03:04
gem-installer
# client
gem lists > gem-lists.txt
# server
gem install -v $(cat gem-lists.txt | cut -d' ' -f1 | tr '\n' ' ')
@tsaito-cyber
tsaito-cyber / parallel-domain-checker.sh
Last active November 19, 2015 02:57
parallel domain checker
#!/bin/bash
SERVER='8.8.8.8'
cat $1 | sed -E 's;^https?://(.*)/;\1;g' | xargs -I{} dig +short +time=5 @$SERVER {}
@tsaito-cyber
tsaito-cyber / change-ip-by-eip.sh
Last active November 16, 2015 02:48
change-ip-by-eip.sh
#!/bin/zsh
InstanceId="$1"
# allocation id of current ip
OldAllocationId=$(aws ec2 describe-addresses |
jq -r '.Addresses[] | select(.InstanceId == "'$InstanceId'") | .AllocationId')
# create address
NewAllocationId=$(aws ec2 allocate-address | jq -r '.AllocationId')
@tsaito-cyber
tsaito-cyber / google-crawler.rb
Last active May 21, 2018 08:04
google-crawler
# coding: utf-8
require 'nokogiri'
require 'open-uri'
require 'uri'
instanceID = 'xxxxxx'
## if you are blocked by google, you have to change your ip address.
## You can change it with "elastic ip address" provided by ec2.
@tsaito-cyber
tsaito-cyber / create-instance-by-eip.sh
Last active November 16, 2015 02:48
create-instance-by-eip
#!/bin/zsh
AMI="ami-xxxxxxx" # Official CentOS 7.0 AMI in ap-northeast-1 region
ALOCID="eipalloc-xxxxxxx" # Allocating ip address
SIZE="m3.large"
KEYNAME="jobfind"
SEC_GROUP="default"
InstanceId=$(aws ec2 run-instances \
--count 1 \
@tsaito-cyber
tsaito-cyber / gist:1b531593bfc99a245f91
Last active March 3, 2016 08:36
並列化クローリングのメモ.txt
* GIL (Global Interepter Lock) が存在するために ruby, python ではマルチコアを生かせない(コア数に比例してクローリングの数が増えない)
⇒ 対策: マルチコアを生かすには GIL が存在しない java や C++ か、メッセージバッシングの行える Scala, Go, Closure を使う
⇒ 今回はあまり癖がなく Garbage Collector が付いている Go を選択する
### 20 (page/second) の壁
* ファイルディスクリプタの枯渇で死ぬ
⇒ 対策
* ulimit -u 40000
dnsperf -d domain-1000000.txt -s 127.0.0.1 -p 53 -c 128 -t 10 -q 5000 -Q 150000 -S 1 2>&1 | grep -v -E 'Timeout|Warning'
@tsaito-cyber
tsaito-cyber / google-public-dns-benchmark.sh
Last active August 10, 2016 13:25
benchmark of google public cache DNS server
curl 'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip' | zcat -d | awk -F',' '{print $2}' | paste -d' ' - <(yes A | head -n 200000) > queries-200000.txt
dnsperf -d queries-10000.txt -s 8.8.8.8 -p 53 -c 128 -t 10 -q 1000 -Q 1500 -S 1 2>&1 | grep -v -E 'Timeout|Warning'
dnsperf -d queries-200000.tx -s 127.0.0.1 -p 53 -c 120000 -t 10 -q 20000 -Q 20000 -S 1
@tsaito-cyber
tsaito-cyber / tech.txt
Last active October 18, 2018 02:17
useful shell commands
** メモ **
# コメント付きで keygen
$ ssh-keygen -C taku@hacker -t rsa -f ~/.ssh/github
# 通信している ARP アドレスの確認
$ arp -a
# ネットワークの統計