突然收到一封邮件,来自linode。。
Your Linode, linode????, has exceeded the notification threshold (90) for CPU Usage by averaging 111.6% for the last 2 hours. The dashboard for this Linode is located at: <https://manager.linode.com/linodes/dashboard/????>
This is an automated message, please do not respond to this email. If you have questions, please open a support ticket.
You can view or change your alert thresholds under the "Settings" tab of the Linode Manager.
This is not meant as a warning or a representation that you are misusing your resources. We encourage you to modify the thresholds based on your own individual needs.
-----------
上去一看,果然:

现在开始怀疑,burst的服务器挂掉是不是也是因为这个原因。但,一点不通知也不应该啊。看LOG也看不出什么原因,真纠结啊
最近在使用phpQuery处理xml的时候发生了一点小问题。由于xml还算是比较规范,但我又不想用simplexml_load_string,所以就偷懒用phpQuery处理了。
但在处理的时候发现一个问题,比如我要处理的内容是:
XML/HTML代码
- <title>揭秘日本巨型OLED地球仪:实时显示地球变化</title>
- <link>http://news.dili360.com/gclw/xxjs/2012/0312/32136.shtml</link>
- <description><a href='http://news.dili360.com/gclw/xxjs/2012/0312/32136.shtml'><img src='http://image.dili360.com/news/gclw/xxjs/2012/0312/36_5132136203_20120312094816.jpg' style='border: 1px solid #000000;'/></a> 新浪科技讯 北京时间3月12日消息,据国外媒体报道,如果你前往日本东京,别忘了去参观一下“未来科学馆”(Miraikan),这里展示着一些最尖端的技术成就。就在去年年中,这里揭幕了全世界首个大型OLED显示屏,直径超过19英尺(约合5.8米)。尽管名叫“Geo-Cosmos”,但这并非一般的地球仪,它几乎能实时显示我们这颗星球上正在发生的一切!全球各地的科学家和研究机构将数据发送给Geo-Cosmos,后者将其呈现给观众。 这..</description>
- <category>中国国家地理网地理资讯频道</category>
- <author>dili360.com</author>
- <pubdate>2012-03-12 09:48:16</pubdate>
请看加红的那一段。
当我用phpQuery处理完后,发现,右边的</link>不见了。其他元素都正常。我的心一下子就碎了。
开始以为页面有问题,但怎么处理都是这样,最终只能将link换成了url来 进行处理。说实话,心是哇凉哇凉的。。
但是,同事在win下面就没有这个问题,我在ubuntu下就有这个问题。(我现在不知道是否我的PHP版本有问题,还是平台的问题,也没有心思深究了)【同事是5.3.9,我是5.3.6】,
本文内容来自官方的wiki,一来是做备份,二来自己查询起来也会快一点,毕竟yiiframework官网经常抽风,当然它的抽风不是因为自己,而是因为GFW,说来也可怜,好象很多技术网站都被墙了。
不过想想也正常,如果一个搞技术的,连翻墙也不会,还搞个毛技术啊。
OK,上正菜:http://www.yiiframework.com/wiki/44/behaviors-events/#hh1
These features provide endless possibilities and unbelievable flexibility, but as current documentation does not give more than a few examples, it might be difficult to fully understand their internals and requirements.
It should be noted that they do mostly the same thing. You can attach behaviors and event handlers to components to modify the components' behavior.
Events
It is useful when you want to interrupt the normal application flow without extending base classes.
For example, enabling gzip compression on the output could be done via extending CWebApplication. But because there are entry points for event handlers, one can do this:
PHP代码
- Yii::app()->onbeginRequest = create_function('$event', 'return ob_start("ob_gzhandler");'),
- Yii::app()->onendRequest = create_function('$event', 'return ob_end_flush();'),
You can create an event handler -- which is simply a method in some class with a specific signature -- and attach it to the event of an object. You can add as many event handlers as you wish, from as many objects as you wish. If the event handler is, effectively static, then you can create the object as you assign it:
PHP代码
- $test_comp->onSomethingGoesOn = array(new SomeClass, 'eventHandler1');
- $test_comp->onSomethingGoesOn = array(new SomeOtherClass, 'eventHandler2');
- $test_comp->onSomethingGoesOn = array(new YetAnotherClass, 'eventHandler3');
As long as you have a handle on the object, then you can add an event handler to it.
At some point, you can then raise the event with something like one of these:
PHP代码
- $test_comp->onSomethingGoesOn(new CEvent($this));
- $test_comp->onSomethingGoesOn(new CEvent());
So, basically, it allows you to build a list of function calls that can later be executed, in the order they were added. It can save you passing around a lot of object refs and building conditional code, since you can still raise the event, even if it doesn't do anything.
Behaviors
Behaviors are simply a way of adding methods to an object.
Take this scenario: You have 2 classes: MySuperClass1, MySuperClass2. There might be lots of methods from MySuperClass1 & 2 that you want in some new class, say MyBoringClass. Unfortunately, php does not allow for this:
PHP代码
- class MyBoringClass extends MySuperClass1, MySuperClass2 {
- }
This is where behaviors come in. Instead, you can go:
PHP代码
- class MyBoringClass extends MySuperClass1 {
- }
-
- $classInstance = new MyBoringClass();
- $classInstance->attachbehavior('uniqueName', new MySuperClass2);
Now $classInstance has all the methods from MySuperClass1 and MySuperClass2. Since MySuperClass2 is being used as a behavior, it has to extend CBehavior. The only caveat to this is an attached behavior cannot override any class methods of the component it is being attached to. If a method already exists, if it be from the original class or already added by a previously attached behavior, it will not be overwritten.
In an OO language like Ruby, it's quite possible to start with a completely empty object and simply build its behavior as you go along. Yii provides this behavior with a little magic. The key is that the class you wish to add the behavior from must extend Cbehavior.
PHP代码
- class SomeClass extends CBehavior
- {
- public function add($x, $y) { return $x + $y; }
- }
Then use with:
PHP代码
- $test_comp = new TestComponent();
- $test_comp->attachbehavior('blah', new SomeClass);
- $test_comp->add(2, 5);
So, in this case, you are extending the functionality of an object with functionality of another object.
After studying this cookbook page you are encouraged to reread the corresponding guide page as it contains advanced information (for example, if you are familiar with interfaces, you might find it enough to implement IBehavior before extending CBehavior).
-------------
behavior和Event在model里用的会相对较多一点,不过,其他地方也可以一用。如果你真的不明白这一块的逻辑,那还是用其他方式替代吧。
是的,你没有看错,这次的标准居然是一个URL。
如果尝试在IE下打开,可能你看到的页面都不正常,左下角的感叹号一定会让你震惊。嗯,你还是用Firefox或者Chrome(safari)打开看一下吧。
效果很多哦,很多特效可以让你感觉很爽。有一些效果你也可以尝试用到你的项目里。
---
最后插一个小广告,关于BitCoin(比特币)的事情,内容来自云风的BLOG,URL是:http://blog.codingnow.com/2011/05/bitcoin.html
--------
昨天读到了 Bitcoin 的中文介绍,觉得非常有意思。不过上面这篇文章解释的非常不靠谱,我花了一晚上去Bitcoin的官方网站 仔细研究了一下,总算理解了其原理。感觉非常有启发,尤其是对虚拟货币的流通和发行有许多借鉴意义。今天写这篇 Blog 理一下。
-------------
更多请看云风的BLOG,或者就看上面的链接bitcoin看一下这玩意的由来。
说实话,我本来不是特别想转这篇文章,毕竟我也不希望我的博客能够成为别人的战场,因此在yhustc让我转载这篇文章的时候,我犹豫了。但是为什么今天我又转载呢?是因为实在受不了了。。。
1、昨天下午开始,QQ有弹窗说是装360不安全,QQ不能在装有360的机器上运行
2、每天一次的360弹窗说是QQ不安全(我不知道他在说别人的时候,有没有想过自己的弹窗是那样的大,还是居中的。人家QQ再怎么样,也是在右下角。事实上,360平时也在右下角经常弹窗。。。)
拜托2位,发起战争的时候,不要在用户的电脑上折腾行不?你们的公关战、软件战能不能不要影响我们的正常电脑使用?基于此,我转了这篇博客(顺便而已),毕竟只要是文章,就会带有立场,所以本文不代表我的意见(突然想起来,昨天的新闻晚报上,把360与QQ之间的战争写成3Q之战,所以我的标题就是3Q大战)
原文在:http://www.yhustc.com/360vsQQ.html,顺便。如果你去他的首页,你会发现,他又写了两篇。yhustc也是一个忍不住寂寞的人啊。
请围观内容:
XML/HTML代码
- 本文思维混乱,谢绝不看全文的小白直接评论。
-
- 网络调查,先卸载谁(网易科技)。从“公园门”里被曝光的360网络水军,不知道有没有参与投票。总之结果是支持360的远远高于QQ。
-
- 去cnbeta上面看评论,或者一些新闻网站的评论,支持360的大多就是一个中心点:免费的就是好,就应该支持。不知道红卫兵们是不是该问问自己,QQ是不是免费的。评论的一点技术含量都没有。那些开一大堆业务然后说又贵又费钱,说腾讯黑的找抽货,还是滚一边去吧。没有用过任何业务,然后说 XX业务要钱黑的很的货,更加可以无视。
-
- 继360官方提供工具屏蔽各大门户的广告后,又把屏蔽的大斧砍向了QQ。当然,赢得了一篇欢呼。我想问一下欢呼的小白们,你们看着门户,用着 QQ,不点击广告没有人说你什么,连展示都不让,你们不是想让他们去死吗?将心比心,你自己是门户的老板,你会一个广告不放,白掏钱给别人服务?用了十年 QQ不花一分钱,你连广告都不让人展示?
-
- 扣扣保镖就更不靠谱了。把所有东西做成开关,这样就能把责任转移到用户身上,因为他们只提供工具,用不用是用户的事情。结果吧,QQ一升级,不让用扣扣保镖了,昨天就看到有新闻出现了,说是QQ这么竞争有失公平。我就问360枪手:你要强奸别人,还不让别人跑?
-
- 当然,小白们的另外一个声音是:一家独大不好,干倒QQ最好不过。典型的仇富心理,不管是社会还是网络上,这种小白都只能沦为别人的棋子而已。干倒了一个,会有下一个出现,这是历史必然。除非哪个傻不垃圾的老板说保持份额就停止不动,跟大家相安无事,可能吗?当然了,那个时候估计小白们又开始不遗余力的喷XX不好用,不如当年的QQ等等。
-
- 今天早上还看到中国青年报关于网络打手公司的报道。他们的工作,就是引导互联网的舆论,干掉对自己不利的,发布大量引导话题的。不知道先卸载谁的投票里面,有没有打手的身影啊。
Over....不知道这场战争会有多久。反正,我现在是用UBUNTU了。。linux下的QQ也没有广告,安心了。
最后上张图。。。有意思:
