在进行stat()相关操作的时候先运行一下clearstatcache。
受影响的函数: stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), and fileperms()。
博客
-
clearstatcache
-
在VirtualHost里设置RewriteCond中%{REQUEST_FILENAME}无效的问题
问题发生在将.htaccess里的rewrite规则转移到VirtualHost里之后。
原因是%{REQUEST_FILENAME}依然指向相对路径。RewriteCond %{REQUEST_FILENAME}
改为:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}
问题解决。Rewrite的调试可以开启RewriteLog来跟踪:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog参考文章:
http://lufei-99999.blog.163.com/blog/static/748495420115845922988/ -
Supervisord & monit
用monit监控系统关键进程
monit是一款功能强大的系统状态、进程、文件、目录和设备的监控软件,用于*nix平台, 它可以自动重启那些已经挂掉的程序,非常适合监控系统关键的进程和资源,如:nginx、apache、mysql和cpu占有率等。
http://feilong.me/2011/02/monitor-core-processes-with-monitSupervisord是用Python实现的一款非常实用的进程管理工具,类似于monit(关于monit见我的博客:用monit监控系统关键进程),monit和supervisord的一个比较大的差异是supervisord管理的进程必须由supervisord来启动,monit可以管理已经在运行的程序。
http://feilong.me/2011/03/monitor-processes-with-supervisord -
php5-fpm SIGBUS
child 19142 exited on signal 7 (SIGBUS) after 304.356752 seconds from start
做了两个设置:
php5-fpm : emergency_restart_threshold 设置一个合适的值
php.ini : cgi.fix_pathinfo = 0参考文章:http://blog.51osos.com/opensource/nginx-emergency-restart-threshold-sigsegv/
-
张生方案总结
Socks方案(Socks可以利用ssh tunnel来建立,不表)
1、利用squid来进行转发:
http://sudone.com/linux/squid_privoxy_tor.html2、利用redsocks(http://darkk.net.ru/redsocks/)来转发,相关链接:
Setup iptables for RedSocks in OpenWRT : https://gist.github.com/1097210/796886ba50978ca2426d7bedafd61076858b2c64
http://www.right.com.cn/forum/viewthread.php?action=printable&tid=40111
http://bjin.posterous.com/redsocks-on-android
http://shell909090.com/blog/ (这里有一些openwrt相关的东东)
http://blog.zhuli.name/archives/6690
http://www.wy182000.info/2011/08/05/socks%E4%BB%A3%E7%90%86%E7%9A%84%E9%80%8F%E6%98%8E%E5%8C%96%E5%92%8C%E5%8F%AF%E8%B7%AF%E7%94%B1/==openwrt相关==
http://shell909090.com/blog/2011/09/%E5%90%88%E7%94%A8%E4%B8%A4%E4%B8%AA%E8%B7%AF%E7%94%B1%E5%99%A8%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E6%A1%88/
http://penglei.name/html/100.html (tomato配置VLAN)其他参考资料:
Linux上iptables防火墙的基本应用教程
http://www.vpser.net/security/linux-iptables.html
单网卡Linux利用iptables做网关
http://linux.chinaunix.net/techdoc/net/2007/05/08/957205.shtml
Linux下使用单网卡实现nat共享上网
http://zhangruirong.blog.51cto.com/2098188/386947
Linux单网卡实现NAT路由
http://gsion.blog.163.com/blog/static/123056504201162111957875/
單網卡red hat 7.2 linux利用iptables作為簡單網關的配置
http://fanqiang.chinaunix.net/a1/b1/20020815/060200294_b.html -
hp palm veer
弄了一个veer玩。
通过novaterm https://developer.palm.com/content/resources/develop/sdk_pdk_download.html#linux
可以进入webos终端。。。
剩下的。。
想怎么折腾就怎么折腾吧。。
======
系统中自带一个从apt-get分支而来的ipkg包管理工具。
在使用之前需要用:
rootfs_open -w 设置rootfs可写。
======
相关资源链接:
http://www.zoopda.com/forum.php?mod=viewthread&tid=45662 -
Proxy auto config
土鳖了,今天才发现还有这个玩意儿:
http://en.wikipedia.org/wiki/Proxy_auto-config
这下方便多了,不用每次都往”No Proxy For”里添加条目了(-_-!)。。
我的PAC (Proxy_auto-config) 文件:
function isBlockedHost(host)
{
if (shExpMatch(host, “*google.*”) ||
shExpMatch(host, “*ggpht.*”) ||
shExpMatch(host, “*alexa.com*”) ||
shExpMatch(host, “*blogspot.com*”) ||
shExpMatch(host, “*facebook.com*”) ||
shExpMatch(host, “*twitter.com*”) ||
shExpMatch(host, “*youtube.com*”) ||
shExpMatch(host, “*appspot.com*”) ||
shExpMatch(host, “*fc2.com”) ) {
return true;
}
return false;
}// browser’s API
function FindProxyForURL(url, host)
{
var direct = “DIRECT”;
var socksProxy = “SOCKS5 127.0.0.1:9999”; // 注意这里需要指定为SOCKS5,才会进行remote dns resolveif (isBlockedHost(host))
{
return socksProxy;
}return direct;
}参考文章:
http://blog.solrex.org/articles/remote-dns-lookup.html
http://fanqiangchinagfw.blogspot.com/2010/08/dnsfirefox-dns-resolving.html -
《Entrepreneur》杂志发刊词 Entrepreneur’s Credo of the American
1776年,美国独立前夜,一本不到20页的小册子开始流传,小册子名为《常识》。
作者托马斯·潘恩用朴素的文字,激励人们反抗暴政和奴役。
北美独立战争期间,《常识》一书对民众的影响力仅次于《圣经》。
1904年,美国《企业家》杂志,选用《常识》中的一段话作为发刊词。
此后百余年中,沧海桑田,物是人非,但杂志扉页上的这段话,却从来没有改变,它被称为企业家誓言。I do not choose to be a common person.
It is my right to be uncommon—if I can.
I seek opportunity—not security.
I do not wish to be a kept citizen,
humbled and dulled by having the state look after me.
I want to take the calculated risk,
to dream and to build,
to fail and to succeed.
I refuse to barter incentive for a dole;
I prefer the challenges of life to the guaranteed existence;
the thrill of fulfillment to the stale calm of Utopia.
I will not trade my freedom for beneficence
nor my dignity for a handout.
I will never cower before any master
nor bend to any threat.
It is my heritage to stand erect, proud, and unafraid;
to think and act for myself;
to enjoy the benefit of my creations;
and to face the world boldly
and say:
“This, with God’s help, I have done.”——————————————-
我是不会选择做一个普通人的。
如果我能够做到的话,我有权成为一位不寻常的人。
我寻找机会,但我不寻求安稳,
我不希望在国家的照顾下成为一名有保障的国民,那将被人瞧不起而使我感到痛苦不堪。我要做有意义的冒险。
我要梦想,我要创造,我要失败,我也要成功。我拒绝用刺激来换取施舍;
我宁愿向生活挑战,而不愿过有保证的生活;
宁愿要达到目的时的激动,而不愿要乌托邦式毫无生气的平静。我不会拿我的自由与慈善作交易,也不会拿我的尊严去与发给乞丐的食物作交易。
我决不会在任何一位大师面前发抖,也不会为任何恐吓所屈服。我的天性是挺胸直立,骄傲而无所畏惧。
我勇敢地面对这个世界,自豪地说:在上帝的帮助下,我已经做到了。
=========================
书单:http://www.douban.com/group/topic/2164260/ -
Headless HTML rendering engines
http://www.holovaty.com/writing/headless-html-rendering-engine/
这篇文章的评论里讨论了各种解决方案。。Request: Headless HTML rendering engine?
Written by Adrian Holovaty on May 2, 2008
Warning: Seriously geeky request ahead!
I’m looking for a way to render arbitrary Web pages — including CSS and JavaScript — and access the resulting DOM tree programatically, i.e., in an automated/headless fashion. I want to be able to ask the following questions of the resulting DOM tree:
For a given element, what font family, size, and color is the text?
How tall and wide (in pixels) is a given,
, etc.? What are the x/y coordinates of a given element (from the upper-left corner of the page, or lower-left, or wherever)? For a given element, what is its text content?The rendering must be state-of-the-art, handling advanced CSS that Firefox, Safari and IE handle. It should work on Linux. Bonus points if there’s a Python API for this magical DOM tree.
This is all stuff that standard in-page JavaScript could accomplish, but the catch with me is that I need to be able to do it in a completely automated way, on arbitrary pages, on a headless server.
I know Gecko and Webkit provide this, but I’m not sure where to start with them. The docs and articles I’ve read seem to be focused more on embedding the full browser window in a GUI application than embedding the rendering engine itself and manipulating the resulting pages.
Help! If you have any clues, I’d be grateful if you left a comment or got in touch with me.
Comments
Posted by Andrew Sutherland on May 2, 2008 at 2:45 a.m.:PyXPCOM (http://developer.mozilla.org/en/docs/PyXPCOM) should handle the Python part of the Gecko equation.
I myself am no specific help on the gecko side of things, but I think the following post/thread on the PyXPCOM mailing list may be of assistance:
http://aspn.activestate.com/ASPN/Mail/Message/pyxpcom/3619998
Posted by Rene Dudfield on May 2, 2008 at 3:19 a.m.:You can set up a headless X server, then run firefox, or whatever browser with a standard build.
Posted by Michael Twomey on May 2, 2008 at 4:46 a.m.:If you want an example of using webkit to do headless stuff you could look at webkit2png which is a tool for taking screenshots of websites from command line. It uses webkit and pyobjc, so you’ll need a mac. It doesn’t do any DOM stuff that I can see but I might be a useful starting point for writing an automated tool.
Posted by Justin Mason on May 2, 2008 at 5:01 a.m.:http://khtml2png.sourceforge.net/ might be useful, if you’re doing this on a *NIX platform. Looks like it’s well-maintained, too, since the most recent release was only a couple of weeks ago.
Posted by Gábor Farkas on May 2, 2008 at 5:10 a.m.:in case of firefox, there are 2 issues:
1. run it somehow in a headless mode: for this, try Xvfb. it starts a headless X server. then you can run firefox in it.
2. communicate with the firefox instance. there is PyXPCOM, as others already mentioned, which could make it work.
Posted by Jason on May 2, 2008 at 7:04 a.m.:If you want to muck in C++ code you could look at RenderTreeAsText in Webkit. For actually setting up the rendering engine, there’s some relatively simple high-level apis in the wx and qt ports that seem pretty readable; the kind of api you’d use for those neat “write a web browser in 5 lines of code” demos. See WebFrame in particular. Disclaimer: I’ve never written anything with webkit, but it might be fun to learn.
Posted by anonymous on May 2, 2008 at 8:15 a.m.:What about Selenium? or Watir?
Posted by anonymous on May 2, 2008 at 8:50 a.m.:I haven’t tried this (but am planning to), so I don’t know if it really meets your needs, but HTMLUnit is a Java-based headless browser (designed for testing).
Posted by anonymous on May 2, 2008 at 10:15 a.m.:Attributes such as pixel width, height, font etc will either be determined by CSS, or they will be agent (and user setup) specific.
The pixel width of a div of width 50% will depend on the size of the viewport – which of course would be anything. Do you intend to ‘fake’ the settings of a user agent? If so, then a simple calculation would get the pixel width (as you would know your viewport dimensions).
I really would consider seeing how far you can get by simply manipulating the dom and parsing the css (both of which are easily achieved with the python libraries urllib, lxml / beautifulsoup and cssutils).
I know, I know; None of this helps with javascript dependent attributes.
RC
Posted by alan taylor on May 2, 2008 at 10:36 a.m.:Have you looked at JSSh? Not sure if it fits the bill, but it just might – it’s a “Mozilla C++ extension module that allows other programs (such as telnet) to establish JavaScript shell connections to a running Mozilla process via TCP/IP” I know it can return some parts of the DOM, but not sure how much detailed info you can get beack from it. http://www.croczilla.com/jssh
Posted by Matthew Marshall on May 2, 2008 at 10:42 a.m.:I’ve played with doing this a little. The best I came up with was using PyKDE and khtml. I’m pretty sure it requires an X server, but if nothing else you could use a vnc server.
MWM
Posted by Kumar McMillan on May 2, 2008 at 11:40 a.m.:There are probably several ways to do it, but the first that comes to mind is using the Python driver for Selenium RC …
from selenium import selenium
# with the selenium-rc (Java) proxy sever running at localhost:4444 …
selenium = selenium(“localhost”, 4444, “*firefox”, “http://thewebsite.com”)
selenium.open(“/”)
selenium.wait_for_page_to_load(‘30000’)
selenium.get_html_source() # this is includes any JavaScript DOM manipulations, of course
selenium.get_element_position_left(“xpath=//div[1]”)
selenium.get_element_position_top(“xpath=//div[1]”)
selenium.get_element_height(“xpath=//table[1]”)
selenium.capture_screenshot(‘/tmp/site.png’)
… but I’m not sure how you get the font/text info. Selenium RC is designed to run headless and also has a “grid” implementation so you can throw more hardware at it. Scaling up to the grid is very transparent — same code as above, more or less.
Links:
http://selenium-rc.openqa.org/
http://selenium-rc.openqa.org/python.html
http://selenium-grid.openqa.org/
Posted by anonymous on May 2, 2008 at 12:02 p.m.:seconding the jssh suggestion http://www.urbanhonking.com/ideasfordozens/archives/2008/03/automating_fire.html
Posted by Ryan Shaw on May 2, 2008 at 12:26 p.m.:You might want to check out Crowbar:
Crowbar is a web scraping environment based on the use of a server-side headless mozilla-based browser. Its purpose is to allow running javascript scrapers against a DOM to automate web sites scraping but avoiding all the syntax normalization issues.
Posted by mikeal on May 2, 2008 at 1:49 p.m.:I would go with windmill over Selenium if you’re going down that road. We have far more comprehensive javascript support, you can use execJS to get back the result of any arbitrary js.
http://windmill.osafoundation.org
And jssh is great, but MozRepl is jssh on crack.
http://hyperstruct.net/projects/mozrepl
The whole interface is much much nicer and I’m in the middle of a Python JavaScript bridge using MozRepl that I’ll be sure to send you a link to once it’s public.
Posted by Henning on May 2, 2008 at 2:29 p.m.:Qt 4.4 is available on all platforms and contains a WebKit port. Fortunately the newest PyQt snapshots also contain support for WebKit. Because Qt can render every widget to a pixmap, is should be fairly easy. To run Qt headless you could use xvfb.
To access the DOM you can query with Javascript.
The following is _not_ tested:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
import sys
app = QApplication(sys.argv)
browser = QWebView()
browser.show()
browser.resize(800,600)
#browser.setHtml(“Hello, world”)
browser.load(“http:///www.djangoproject.com”)
pm = QPixmap.grabWidget(browser)
pm.save(“website.jpg”)
body = browser().page().mainFrame().evaluateJavaScript(“getElementByName(‘body’)”)
Posted by anonymous on May 2, 2008 at 6:08 p.m.:HTMLUnit is a very good headless browswer implementation. It supports different browsers and Jacascript (using Rhino I think). And finally, is under active development.
http://htmlunit.sourceforge.net/
Unfortuantely, its a Java library but you could use jpython to access it.
Posted by anonymous on May 2, 2008 at 6:12 p.m.:I looked at a few open source projects to do headless rendering.
It’s tempting to use firefox/gecko but the learning curve is steep,
it’s 2 mln lines of netscape legacy C++ code.
But if you figure it out you’ll have a fine tool.
What is working for me now is lobo renderer (from cobra browser) (in java).
It’s not the best rendering engine, but it’s decent, and easy to program.
You can get rendered blocks and dom objects, and answer all the questions
as to block location, color, text etc.
It can be made to work on linux completely headless without an x server,
the way I have it working is it takes in a url or html, and saves to another
textual file format. What’s important is to encapsulate your choice
of rendering engine, because it will change.
Email me at dmitrim at yahoo dot com if you need help.
Posted by Phil on May 2, 2008 at 7:31 p.m.:Personally I’d try it with MozRepl and an X virtual framebuffer: http://emacspeak.blogspot.com/2007/06/firebox-put-fox-in-box.html
Posted by Daniel on May 2, 2008 at 7:46 p.m.:As suggested above, run firefox on a virtual X server. Use a firefox extension (mozrepl or jssh) to get automated control over the browser.
I set up a system doing exactly this (for taking screenshots) last summer. In the end it barely took any code, just a fair amount of faffing with config files. Happy to give more details if it’s helpful: (my first name) at ohuiginn.net
Posted by rex on May 3, 2008 at 8:44 a.m.:I went throught trying to work out a way to do this ages ago.
Not sure if you’re feeling the same, Adrian, but what bothered me (purely from a principle level) was that I really wanted to be able to do this on my server _without_ having to run a headless X server, or an instance of firefox or whatever.. i wanted a library that was able to do it.. and give back my responses without having the uneccessary overhead of a browser, x server etc running (i know very little about it… but i can’t help but feel that these are uneccessary elements in the equation).
Surely there is a way to do what you’re asking without having a program running that is designed to actually render the pictures on a screen… *shrug*
Posted by anonymous on May 5, 2008 at 4:55 a.m.:rex: Rendering HTML nowadays is a heavy complex task. So there is no light library, unfortunately. It sounds like using PyQt is the smartest approach because it does not load a full appliaction but only a rendering engine you can fully control. Having a dummy X-server on Unix seems to be a necessary evil.
Posted by Eric Moritz on May 5, 2008 at 3:50 p.m.:I was thinking of this very issue a while back:
http://eric.themoritzfamily.com/2008/02/08/python-interface-mozilla-dom/
I came across this guy’s post:
http://ejohn.org/blog/bringing-the-browser-to-the-server/
He’s using Rhino and some custom javascript to emulate the browser’s window object.
Posted by John Herren on May 13, 2008 at 1:20 a.m.:Rhino ftw
-
两个轻量的PHP框架
MicroMVC (PHP 5.3+)
Laravel (PHP 5.3+)
Slim : http://www.slimframework.com/
Fat-Free : http://fatfree.sourceforge.net/ (PHP 5.3+)