1. nginx 图片缩放
location ~* "/(php|php1|php2|php3)/public/" {
default_type image/jpeg;
set $needCreateImg 0;
if (!-f $request_filename) {
set $needCreateImg "${needCreateImg}1";
}
if ($uri ~* "/(php|php1|php2|php3)/public/(.*)/([0-9a-zA-Z-]+).(gif|jpg|jpeg|png)_(\d+x\d+)") {
set $needCreateImg "${needCreateImg}2";
}
if ($needCreateImg = "012") {
set $v_path "$1/public";
set $filePath "$document_root/$v_path/$2/$3.$4_$5";
set $originalPath "$document_root/$v_path/$2/$3.$4";
set $fileSize "$5";
set $fileExt "$4";
rewrite_by_lua '
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
local image_sizes = {"80x40", "160x80","320x160","100x100","140x140","300x300","80x80","290x193","68x62"};
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
local is_auto=1;
local command="";
if table.contains(image_sizes, ngx.var.fileSize) and file_exists(ngx.var.originalPath) or is_auto==1 then
if ngx.var.fileSize == "999x999" then
command = "gm convert " .. ngx.var.originalPath .. " -scale %100 -quality 25 jpg:" .. ngx.var.filePath;
else
command = "gm convert " .. ngx.var.originalPath .. " -thumbnail " .. ngx.var.fileSize .. " -background white -gravity center -extent " .. ngx.var.fileSize .. " " .. ngx.var.filePath;
end
--ngx.header.content_type = "text/html";
--ngx.say(ngx.var.fileSize);
--ngx.exit(200);
os.execute(command);
else
ngx.exit(404);
end;
';
}
}
location ~* "/(php|php1|php2|php3)/public/(.*).(png|jpg|jpeg)$"{
rewrite "^/(php|php1|php2|php3)/public/(.*).(png|jpg|jpeg)$" "/$1/public/$2.$3_999x999" last;
}
gm convert 123.jpg -scale %100 -quality 8 out1.jpg
gm convert /data/www/svn/php/public/uploads/ta.jpg -scale %100 -quality 25 /data/www/svn/php/public/uploads/ta.jpg_999x999
2.wifipineapple 添加路由转发上网
iptables -A FORWARD -i eth1 -o wlan0 -s 172.16.42.0 -m state --state NEW -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
- USB网卡中继 有的网卡可能不认识 插入USB网卡后.要在networkmanager插件中看到多了一个wlan1或者在终端ifconfig中看到wlan1
iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o usb0 -j MASQUERADE
iptables -A FORWARD -s 172.16.42.0/24 -o usb0 -j ACCEPT
iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i usb0 -j ACCEPT
3. 添加路由表上网
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.1.1
echo nameserver 114.114.114.114 > /etc/resolv.conf
4. APP推送证书生成
openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in push.p12
openssl pkcs12 -nocerts -out apns-dev-key.pem -in push_key.p12
openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem
5. hostapd 伪AP (-e /dev/urandom 这个启动参数很重要)
apt-get install hostapd
sudo ifconfig wlan2 down
sudo iwconfig wlan2 mode monitor
sudo ifconfig wlan2 up
sudo iwconfig wlan2
ifconfig wlan2 10.0.0.1
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -s 10.0.0.0/24 -o eth0 -j ACCEPT
iptables -A FORWARD -d 10.0.0.0/24 -m conntrack --ctstate ESTABLISHED,RELATED -i eth0 -j ACCEPT
rfkill unblock all
ifconfig wlan0 10.0.0.1
ifconfig wlan0 up
hostapd /etc/hostapd/3.conf -e /dev/urandom
dhcpd -d -f -cf "/etc/dhcp/new.conf" wlan0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1
interface=wlan0
driver=nl80211
country_code=CN
ssid=omg-ap
hw_mode=g
channel=8
wpa=2
wpa_passphrase=123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
ddns-update-style none;
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.1;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option domain-name "";
option domain-name-servers 114.114.114.114;
default-lease-time 600;
max-lease-time 7200;
range 10.0.0.20 10.0.0.50;
}
6. grep说明介绍
grep说明介绍
7. mogilefs分布式文件系统
mogilefs分布式文件系统
8. 抓包工具
tshark -R 'http.request' -i eth1 -T fields -e text -e http.host
ngrep -d wlan0
tcpflow -i wlan0
urlsnarf -i eth0
9. python调用linux epoll编程指南
python调用linux epoll编程指南
10. svn ==创建==
svnadmin create php6
killall -9 svnserve
svnserve -d -r /var/svn/