Skip to content

Instantly share code, notes, and snippets.

#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main(int argc, char *argv[])
{
struct timespec cur;
struct timespec prev;
unsigned int ticks;
docker ps -q | xargs docker kill
stop docker
cd /var/lib/docker/devicemapper/mnt
umount ./*
mv /var/lib/docker $dest
ln -s $dest /var/lib/docker
start docker
@x2c3z4
x2c3z4 / list_gcp_iprange.sh
Created December 28, 2016 09:03 — forked from n0531m/list_gcp_iprange.sh
Google Cloud Platform : ip address range
#!/bin/bash
# https://cloud.google.com/compute/docs/faq#ipranges
#nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`
do
dig txt $LINE +short
done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n
@x2c3z4
x2c3z4 / iptables.sh
Last active December 23, 2016 14:09
重定向google 的流量到其他的vps
#!/bin/sh
iptables -t nat -F
#create a new chain named SHADOWSOCKS
iptables -t nat -N SHADOWSOCKS
ips=(google.com www.google.com www.google.com.hk 74.125.203.0/24 64.233.188.0/24 114.134.80.0/24 64.18.0.0/20 64.233.160.0/19 66.102.0.0/20 66.249.80.0/20 72.14.192.0/18 74.125.0.0/16 108.177.8.0/21 173.194.0.0/16 207.126.144.0/20 209.85.128.0/17 216.58.192.0/19 216.239.32.0/19)
for ip in "${ips[@]}";do
iptables -t nat -A SHADOWSOCKS -p tcp -d $ip -j REDIRECT --to-ports 1081
done
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml
sudo bash -c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf'
sudo bash -c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf'
sysctl -p
lsmod | grep bbr
@x2c3z4
x2c3z4 / Find Google-IP
Created December 23, 2016 02:01 — forked from on195594/Find Google-IP
如何查找Google的IP地址段
一般查找域名对应的IP,可以用这个命令 nslookup <域名>,但这样找,返回的ip比较少,今天看到一条命令,可以批量查找Google当前的IP范围。
命令及返回的结果如下:
# nslookup -q=TXT _netblocks.google.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
_netblocks.google.com text = "v=spf1 ip4:64.18.0.0/20 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:207.126.144.0/20 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19 ~all"
[root]
path = /root
writable = yes
read only = no
create mask = 0644
directory mask = 0755
write list = root
@x2c3z4
x2c3z4 / stacktrace.cxx
Created December 16, 2016 10:06 — forked from fmela/stacktrace.cxx
A C++ function that produces a stack backtrace with demangled function & method names.
#include <execinfo.h> // for backtrace
#include <dlfcn.h> // for dladdr
#include <cxxabi.h> // for __cxa_demangle
#include <cstdio>
#include <cstdlib>
#include <string>
#include <sstream>
// This function produces a stack backtrace with demangled function & method names.
vnc4server -geometry 1920x1080 -geometry 800x600
#Xvnc4
@x2c3z4
x2c3z4 / fio.cfg
Last active December 11, 2016 07:18
fio --name=test --ioengine=libaio --iodepth=128 --rw=rw --bs=4k --direct=1 --size=20g --numjobs=1 --filename=/dev/vdb --runtime 100 --time_based --thread=1
[global]
invalidate=1
direct=1
group_reporting=1
ramp_time=5
exitall=1
loops=1
log_avg_msec=5000
ioengine=libaio