other
Uncategorized
ปิดระบบ Revision ใน WordPress
1แก้ wp-config.php เติมลงไปว่า
define ('WP_POST_REVISIONS', 0);
ไปที่ db ของ WordPress แล้วรัน SQL ต่อไปนี้
DELETE FROM wp_posts WHERE post_type='revision'
ป.ล. ชื่อ table (wp_posts) อาจแตกต่างกันไป แล้วแต่ prefix ที่ตั้งค่าไว้
TwitterFox 1.7.7.1: HTTPS tab opening + Copy with Name
0ใครสงสัยว่ามันคืออะไร ลองอ่าน โม TwitterFox ให้เปิด tab ด้วย https และเพิ่มเมนู Copy with Name
คราวนี้มันออกรุ่นใหม่อีกแล้ว 1.7.7.1 แต่ขี้เกียจทำเลยดองไว้สักพักก่อน
Download: http://rtsp.us/files/twitterfox-1.7.7.1-fx-https+copyname_rtsp.xpi
ถ้าติดตั้งไม่ได้ก็ดาวน์โหลดไปแล้วค่อยลากลง Firefox นะครับ
เล่นกับ .htaccess
2จดไว้กันลืม ลอกมาจาก askapache.com
Require password for 1 file only
<Files login.php> Order deny,allow Deny from all AuthName "htaccess password prompt" AuthType Basic AuthUserFile /home/askapache.com/.htpasswd Require valid-user </Files>
Protect multiple files:
<FilesMatch "^(exec|env|doit|phpinfo|w)\.*$"> Order deny,allow Deny from all AuthName "htaccess password prompt" AuthUserFile /.htpasswd AuthType basic Require valid-user </FilesMatch>
Using the Apache Allow Directive in htaccess
network/netmask pair
Order deny,allow Deny from all Allow from 10.1.0.0/255.255.0.0
IP address
Order deny,allow Deny from all Allow from 10.1.2.3
More than 1 IP address
Order deny,allow Deny from all Allow from 192.168.1.104 192.168.1.205
Partial IP addresses, first 1 to 3 bytes of IP, for subnet restriction
Order deny,allow Deny from all Allow from 10.1 Allow from 10 172.20 192.168.2
network/nnn CIDR specification
Order deny,allow Deny from all Allow from 10.1.0.0/16
IPv6 addresses and subnets
Order deny,allow Deny from all Allow from 2001:db8::a00:20ff:fea7:ccea Allow from 2001:db8::a00:20ff:fea7:ccea/10
Deny subdomains
Order Allow,Deny Allow from apache.org Deny from wireshark.apache.org
Allow from IP without password prompt, and also allow from any address with password prompt
Order deny,allow Deny from all AuthName "htaccess password prompt" AuthUserFile /home/askapache.com/.htpasswd AuthType Basic Require valid-user Allow from 172.17.10.1 Satisfy Any
Skeleton .htaccess file to start with. Ultimate htaccess file sample
#
# DEFAULT SETTINGS
#
Options +ExecCGI -Indexes
DirectoryIndex index.php index.html index.htm
ErrorDocument 400 /cgi-bin/error.php
ErrorDocument 401 /cgi-bin/error.php
ErrorDocument 403 /cgi-bin/forbidden.cgi
ErrorDocument 404 /404.html
ErrorDocument 405 /cgi-bin/error.php
ErrorDocument 406 /cgi-bin/error.php
ErrorDocument 409 /cgi-bin/error.php
ErrorDocument 413 /cgi-bin/error.php
ErrorDocument 414 /cgi-bin/error.php
ErrorDocument 500 /cgi-bin/error.php
ErrorDocument 501 /cgi-bin/error.php
### DEFAULTS
ServerSignature Off
AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf
AddType image/x-icon .ico
AddDefaultCharset UTF-8
AddLanguage en-US .html .htm .txt .xml .php
SetEnv TZ America/Indianapolis
SetEnv SERVER_ADMIN webmaster@askapache.com
### PHPINI-CGI
#AddHandler php-cgi .php
#Action php-cgi /cgi-bin/php5.cgi
### FAST-CGI
#AddHandler fastcgi-script .fcg .fcgi .fpl
#AddHandler php5-fastcgi .php
#Action php5-fastcgi /cgi-bin/fastcgi.fcgi
#
# HEADERS and CACHING
#
# 1 YEAR
<FilesMatch "\.(flv|ico|pdf)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 3 HOUR
<FilesMatch "\.(txt|xml|js|css)$">
Header set Cache-Control "max-age=10800"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"NOI DSP COR NID CUR ADM DEV OUR BUS\""
Header set imagetoolbar "no"
</FilesMatch>
#
# REWRITES AND REDIRECTS
#
### SEO REDIRECTS
#Redirect 301 /ssl-ns.html /2006/htaccess/apache-ssl-in-htaccess-examples.html
#Redirect 301 /ht.tml
#Redirect 301 /index.html /
#RedirectMatch 301 /2006/htaccess-forum/(.*) /2006/htaccess/$1
#RedirectMatch 301 /(.*)rfc2616(.*) http://rfc.askapache.com/rfc2616/rfc2616.html
#RedirectMatch 301 /phpmanual(.*) /manual/en/$1
### REWRITES
RewriteEngine On
RewriteBase /
### WORDPRESS
#<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
#</IfModule>
### REQUIRE WWW
#RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
#RewriteRule ^(.*)$ /$1 [R=301,L]
### STOP LOOP CODE
#RewriteCond %{ENV:REDIRECT_STATUS} 200
#RewriteRule ^.*$ - [L]
### REDIRECT BLOG FEED TO FEEDBURNER
#RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator|Recent) [NC]
#RewriteRule ^feed/?.*$ http://feeds.feedburner.com/apache/htaccess [L,R=302]
### BLOCK WGET
#RewriteCond %{HTTP_USER_AGENT} ^Wget.* [NC]
#RewriteRule .* /cgi-bin/forbidden.cgi [L]
#
# AUTHENTICATION
#
### BASIC PASSWORD PROTECTION
#AuthName "Prompt"
#AuthUserFile /home/askapache.com/.htpasswd
#AuthType basic
#Require valid-user
### UNDER CONSTRUCTION PROTECTION
#AuthName "Under Development"
#AuthUserFile /home/askapache.com/.htpasswd
#AuthType basic
#Require valid-user
#Order Deny,Allow
#Deny from all
#Allow from 23.23.23.1 w3.org googlebot.com google.com google-analytics.com
#Satisfy AnyLinux – ลบไฟล์เล็กๆจำนวนมหาศาล
0เรื่องมันมีอยู่ว่า Hosting ที่ดูแลอยู่โดน spam mail มหาศาลเข้าไป โฟลเดอร์ spool เลยเต็มไปด้วยเมล์ นับๆแล้วรวมกันได้ 530,367 ฉบับ แปลว่ามีไฟล์อยู่ 530,367 ไฟล์ แต่ละไฟล์ขนาดไม่เกิน 1 KB
ทีนี้ปัญหามันเกิดเมื่อต้องการลบโฟลเดอร์นี้ทิ้ง ทีนี้ partition แบบ ext3 มันจัดการไฟล์แบบนี้ได้ห่วยแตกมากๆ ลองลบด้วยหลายๆวิธีก็ไม่สำเร็จ
rm -rf dirname# ลองรันทิ้งไว้ชั่วโมงนึง (ไปกินข้าวมา) กลับมาเช็คจำนวนไฟล์ยังเท่าเดิมเป้ะfind dirname -delete# ลองรันทิ้งไว้ 5 นาที ผลคือจำนวนไฟล์เท่าเดิมเช่นเคย
นั่งงมๆอยู่นาน เลยลองถามไปใน twitter ได้ @sourcode มาร่วมปวดหัวด้วยกัน จนสุดท้ายลองเล่นกับ shell script แทน ได้ผลแฮะ
# ls -1 dirname > list # for i in `cat list`; do rm -f dirname/$i; done
ขอบคุณ bash อีกครั้ง อันที่จริงยังลบไม่เสร็จนะครับ ตอนนี้รันมา 15 นาที ไฟล์หายไป 100,000 กว่าๆแล้ว เหลืออีก 400,000 กว่าไฟล์เอง
ป.ล. @manatsawin ได้ส่งโค้ด python มาให้ลองเหมือนกัน พอดีผมลอง shell script อันบนแล้วสำเร็จซะก่อนเลยไม่ได้ลอง ยังไงก็ขอบคุณเช่นกันครับ
import glob,os; for i in glob.glob("*"): os.remove(i)
ดูแล้วสั้นกว่า bash เยอะเลย
โม TwitterFox ให้เปิด tab ด้วย https และเพิ่มเมนู Copy with Name
8เอามาโมด้วยความอยากส่วนตัวครับ
แก้อะไรไปบ้าง?
- เวลาเปิดแทบอะไร Firefox จะเป็น https://…. หมด
- เวลาคลิกขวาข้อความจะมีเมนู Copy with Name เพิ่มขึ้นมา เอาไว้เวลาจะ copy ข้อความให้คนอื่นดูแล้วรู้ด้วยว่าใครเป็นคนพิมพ์
ใครสนใจโหลดไปลงได้้เลยครับ แต่ถ้า TwitterFox มีอัพเดทมันก็จะโหลดทับไปนะครับ ไว้ตอนนั้นค่อยแก้ใหม่ ฮ่าๆ
Download: http://rtsp.us/files/twitterfox-1.7.6-fx-https+copyname_rtsp.xpi

ป.ล. ถ้าไม่ไว้ใจ โหลดไปแล้วเปิดดู source code ด้วย 7-Zip, WinRAR ก่อนติดตั้งนะครับ