Skip to content

Instantly share code, notes, and snippets.

View leozhang2018's full-sized avatar
:electron:
Focusing

leozhang leozhang2018

:electron:
Focusing
View GitHub Profile
@leozhang2018
leozhang2018 / ChromeCacheintoShm.sh
Created May 30, 2016 06:22
Chrome Cache into /dev/shm
# Chrome Cache
mkdir -p "/dev/shm/Chrome" -m 1777
[ -d "$HOME/.cache/google-chrome" ] && [ ! -h "$HOME/.cache/google-chrome/Defau$
rm -fR "$HOME/.cache/google-chrome/Default"
ln -s "/dev/shm/Chrome" "$HOME/.cache/google-chrome/Default"
}
# Get CN_IPv4 from APNIC
function CurlIptable(){
## 指定作用域分隔符为 '|',同时计算子网掩码位数之后进行拼接(http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html)
curl $Delegated_apnic_latest_URL | grep 'apnic|CN|ipv4' | awk -F '|' '/CN/&&/ipv4/ {print "iptables -t nat -I SHADOWSOCKS -d " $4 "/" 32-log($5)/log(2) " -j RETURN" }'|cat > $save_to_file
}
@leozhang2018
leozhang2018 / gist:253153a920373e55aa52f8a65d156250
Created August 15, 2016 06:25
Parsing-ping-results-php (Linux version:icmp_seq)
<?php
$pingTarget = "baidu.com";
$pingCount = 4;
//It's very important to escape shell arguments to avoid injection attacks.
$output = shell_exec('ping -c'.escapeshellarg((int)$pingCount).' '.escapeshellarg($pingTarget));
if(empty($output))
{
echo "An error occured. Most likely an invalid or unreachable domain.";
exit(1);
}
@leozhang2018
leozhang2018 / css-border-transitions.markdown
Created September 18, 2016 11:24
CSS Border transitions

CSS Border transitions

Animated CSS borders.

Firefox is doing weird things with the box-shadow, making one side thicker than the others.

A Pen by leozhang on CodePen.

License.

@leozhang2018
leozhang2018 / diskstat
Created September 20, 2016 12:48
diskstat in cat
cat /proc/diskstats | awk '$3 !~ /loop*|ram*/ {print $3 " " $6 " " $9 " "}'
@leozhang2018
leozhang2018 / setup_proxychains-ng.sh
Created February 13, 2017 03:53 — forked from marcinwol/setup_proxychains-ng.sh
Setup and test proxychains-ng on Ubuntu 14.04
# if you havent done it yet, please download the tor-browser and start it
# https://www.torproject.org/download/download-easy.html.en
wget https://www.torproject.org/dist/torbrowser/5.0/tor-browser-linux64-5.0_en-US.tar.xz
tar xf tor-browser-linux64-5.0_en-US.tar.xz
# download the source of proxychains-ng
git clone https://github.com/rofl0r/proxychains-ng.git
cd proxychains-ng
## 当前可用环境变量如下,你可在编译脚本里进行引用使用
## WORKSPACE 工作目录,即流水线名称
## IMAGE 输出镜像名称
## PKG_FILE 编译出的 tar 包名称
## DIST_DIR 编译出 tar 包的目的目录
## SERVICE 编译的服务名称
#!/bin/bash
set -e
@leozhang2018
leozhang2018 / gist:3d348528f8f9c54be9d901f444b622a0
Created May 14, 2018 11:03
Auto update aria2 tracker from github
#!/bin/bash
killall aria2c &>/dev/null
list=`wget -qO- https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt|awk NF|sed ":a;N;s/\n/,/g;ta"`
if [ -z "`grep "bt-tracker" /aria/aria2.conf`" ]; then
sed -i '$a bt-tracker='${list} /aria/aria2.conf
echo add......starting
sleep 3
sudo -u www-data aria2c --conf-path=/aria/aria2.conf -D
ps -aux|grep aria
else
initOS() {
OS=$(uname | tr '[:upper:]' '[:lower:]')
if [ -n "$DEP_OS" ]; then
echo "Using DEP_OS"
OS="$DEP_OS"
fi
case "$OS" in
darwin) OS='darwin';;
linux) OS='linux';;
freebsd) OS='freebsd';;
function Queue(){
var items = [];
function Stack() {
var item = [];
this.push = function (elem) {
item.push(elem);
return item;
};
this.pop = function () {
return item.pop();