Skip to content

Instantly share code, notes, and snippets.

@hydra35
hydra35 / batch-strace.sh
Created February 23, 2012 14:31
strace all the php-fpm worker processes
#!/bin/bash
additional_strace_args="$1"
MASTER_PID=$(ps auwx | grep php-fpm | grep -v grep | grep 'master process' | cut -d ' ' -f 6)
while read -r pid;
do
if [[ $pid != $MASTER_PID ]]; then
nohup strace -r -p "$pid" $additional_strace_args >"$pid.trc" 2>&1 &
@hydra35
hydra35 / nginx.conf
Last active May 14, 2021 03:51
to gray, for Ya'An, Si Chuan earthquake
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
@hydra35
hydra35 / create_gw.sh
Created August 24, 2012 03:28
create NAT gateway on OSX
#!/bin/bash
# Get the interface name for the gateway
gwdev=`netstat -nr | grep default | awk '{ print $6 }' | head -1`
# If none are found, set the gateway to en1 (generally Wifi on OS X)
if [ -z "$gwdev" ]; then
gwdev=en1
fi
@hydra35
hydra35 / switch_java6.sh
Last active September 14, 2016 05:18
java7仅有64位版, Chome不支持64位Java. 可通过切换回系统自带的java6解决. 每次升级Java后执行一遍此脚本. 重新安装java即能升级到java7
#!/bin/bash
[[ -d /Library/Internet\ Plug-Ins/disabled ]] || sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
sudo rm -rf /Library/Internet\ Plug-Ins/disabled/JavaAppletPlugin.plugin
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
echo "Switched to Java6, exit"
@hydra35
hydra35 / named.conf
Created January 8, 2014 11:01
bind con
options {
listen-on port 53 { 127.0.0.1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
forwarders { 114.114.114.114; 114.114.115.115; };
forward only;
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "./enable_alternative_gw.sh original_gw alternative_gw"
exit 1
fi
original_gw=$1
gw=$2
#!/bin/bash
ip_file=$1
if [[ -s $ip_file ]]; then
iptables -F -t nat
while read ip
do
iptables -t nat -A POSTROUTING -s $ip -j MASQUERADE
done <$ip_file
else
#!/bin/bash
host=$1
port=$2
rc=$(curl -I http://$host:$port/stats 2>/dev/null | grep -c 'HTTP/1.1 200 OK')
if [[ $rc -eq 1 ]]; then
exit 0
else
w32tm /config /update /manualpeerlist:121.9.243.170
w32tm /resync
@hydra35
hydra35 / gfw.txt
Created May 1, 2013 16:03
翻墙的域名
t.co
j.mp
twitter.com
google*