Home

王者禁地-自己的生活自己主宰

自己该记住的16条

1.事业永远第一
虽然金钱不是万能的,但没有钱是万万不能的,虽然这句话很俗,但绝对有道理,所以30岁之前,请把你大部分精力放在你的事业上.
2.别把钱看得太重
不要抱怨自己现在工资低,银行存款4位数以下,看不到前途,现在要做的就是努力学习,即使你文凭再高,怎么把理论运用到实践还是需要一个很长的锻炼过程,社会永远是一所最博大的大学,它让你学到的知识远比你在学校学到的重要得多,所以同样,你也别太介意学历低.30岁之前靠自己能力买车买房的人还是极少.
3.学会体谅父母
别嫌他们唠叨,等你为人父了你就知道可怜天下父母心,在他们眼里你还是个孩子,但他们真的老了,现在得你哄他们开心了,也许只要你的一个电话,一点小礼物,就可以让他们安心,很容易做到.
4.交上好朋友
朋友对你一生都影响重大,不要去结识太多酒肉朋友,至少得有一个能在关键时刻帮助你的朋友,如果遇到这么一个人,就好好把握,日后必定有用,不管他现在是富还是穷.
5.别太相信爱情
心中要有爱,但请别说也别相信那些琼瑶阿姨小说里面的山盟海誓,世上本无永恒,重要的是责任,但女人心海底针,心变了,一切都成枉然,你要做的就是该出手时就出手,该放手时别犹豫.30岁之前的爱情不是假的,但只是大多数人都没有能真正把握好的能力,所以学会量力而行.
6.别担心至今还保留初吻
爱情不在多而在精,别以为自己20多岁还没碰过女孩子就害怕自己永远找不到老婆.以后你会有很多机会认识女孩子,要知道这个社会虽然男人多于女人,但现实是女人其实比男人更担心这个问题.男人30一枝花,你在升值而不是贬值,成熟的爱情往往更美丽更长久,所以不要像疯狗一样看到女孩就想追,学会品味寂寞.
7.不要沉迷于任何东西
所谓玩物而丧志,网络游戏是你在出校门之前玩的,你现在没有多余的时间和精力花费到这上面,否则你透支的东西以后都得偿还.一个人要有兴趣,爱好,但请分清楚轻重.
8.年轻没有失败
不要遇到挫折就灰心,年轻人要时刻保持积极向上的态度.失败了,重来过;失去了,再争取别的。错过了,要分析,下次来,要把握;幼稚了,下次,成熟点。不要紧,会好的,哪怕到了极点,也不要放弃,相信一定可以挺过去。不要消极,会好的。曾经的错,过去了,总不能回味在过去。现在的,很好,累完了,很舒服。不要伤,总会有人在支撑你。
9.不要轻易崇拜或者鄙视一个人
人都有偶像,但请拥有你自己的个性.不要刻意去模仿一个人,因为你就是你,是唯一的,独一无二的,要有自信.也不要全盘否定一个人,每个人是有价值的,如果你不能理解他,也请学会接受.
10.要有责任心
不管你曾经怎样,但请从现在开始做一个正直的人.男人要有责任心,无论是工作还是生活上,一个有责任心的人才能让别人有安全感,才能让别人觉得你是一个值得信赖的人.我们不要懦弱,但请不要伤害爱你的人和你爱的人,尤其是善良的女孩,因为这个世界善良的女孩不多了,即使不想拥有,但也请让她保持她美丽的心.
11.男人的外貌并不重要.
不要为自己的长相身高而过分担心,一个心地善良,为人正直的男人远比那些空有英俊相貌,挺拔身材但内心龌龊的男人要帅得多.如果有人以貌取人,请不要太在意,因为你不用去为一个低级趣味的人而难过.
12.学会保护身体
不要以为现在抽烟喝酒,熬夜通宵也没什么事.那是因为你的身体正处于你一生的黄金时段.30岁以后你就能明白力不从心这个词的意义了,身体是革命的本钱,没有好的身体什么也做不了,所以要尽量让自己过有规律的健康生活.
13.别觉得一事无成.
你现在还没有资格谈成功,当然如果你有千万资产的除外.一开始太固定的职业并不一定是好事,或许在不断的改行当中,你会学到更丰富的知识,而且可以挖掘出自己的潜能,找到最适合你的工作.
14.请认真工作
即使你现在的工作再怎么无聊再怎么低级,也请你认真去对待,要知道任何成功人士都是从最小的事做起,或许你现在学不到多么了不起的知识,但起码你要学会良好的工作态度和工作方法,这对以后很重要.
15.请认真对待感情.
不要羡慕那些换女人像换鞋一样的花花公子,逢场作戏的爱情只是让你浪费时间浪费精力,一个人最痛苦的不是找不到爱人,而是心中没有了爱,当你把我爱你3个字变成你最容易说的一句话时,那么你在爱情的世界里已经很难找到真正的幸福了.爱情没有公平,总有一个人比对方付出得多,即使没有结果,也别觉得不值,因为你的付出不光是为了她,也是为了你自己的爱,为爱付出是很可贵的,赞自己一下.
16.请留一点童心
在内心深处,哪怕只是一个很小的角落里,请保持一份童心,不是幼稚,但有的时候单纯一点会让你很快乐.所以不要太计较得失,生活本无完美.

优化PHP代码的40条建议

40 Tips for optimizing your php Code
原文地址:http://reinholdweber.com/?p=3
英文版权归Reinhold Weber所有,中译文作者yangyang(aka davidkoree)。

1. If a method can be static, declare it static. Speed improvement is by a factor of 4. 如果一个方法可静态化,就对它做静态声明。速率可提升至4倍。
2. echo is faster than print. echo 比 print 快。
3. Use echo’s multiple parameters instead of string concatenation. 使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接。
4. Set the maxvalue for your for-loops before and not in the loop. 在执行for循环之前确定最大循环数,不要每循环一次都计算最大值。
5. Unset your variables to free memory, especially large arrays. 注销那些不用的变量尤其是大数组,以便释放内存。
6. Avoid magic like __get, __set, __autoload 尽量避免使用__get,__set,__autoload。
7. require_once() is expensive require_once()代价昂贵。
8. Use full paths in includes and requires, less time spent on resolving the OS paths. 在包含文件时使用完整路径,解析操作系统路径所需的时间会更少。
9. If you need to find out the time when the script started executing,?br> SERVER[’REQUEST_TIME’] is preferred to time() 如果你想知道脚本开始执行(译注:即服务器端收到客户端请求)的时刻,使用
SERVER[‘REQUEST_TIME’]要好于time()。
10. See if you can use strncasecmp, strpbrk and stripos instead of regex. 检查是否能用strncasecmp,strpbrk,stripos函数代替正则表达式完成相同功能。
11. str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4. str_replace函数比preg_replace函数快,但strtr函数的效率是str_replace函数的四倍。
12. If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments. 如果一个字符串替换函数,可接受数组或字符作为参数,并且参数长度不太长,那么可以考虑额外写一段替换代码,使得每次传递参数是一个字符,而不是只写一行代码接受数组作为查询和替换的参数。
13. It’s better to use select statements than multi if, else if, statements. 使用选择分支语句(译注:即switch case)好于使用多个if,else if语句。
14. Error suppression with @ is very slow. 用@屏蔽错误消息的做法非常低效。
15. Turn on apache’s mod_deflate 打开apache的mod_deflate模块。
16. Close your database connections when you’re done with them. 数据库连接当使用完毕时应关掉。
17. $row[’id’] is 7 times faster than $row[id]. $row[‘id’]的效率是$row[id]的7倍。
18. Error messages are expensive. 错误消息代价昂贵。
19. Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time. 尽量不要在for循环中使用函数,比如for ($x=0; $x < count($array); $x)每循环一次都会调用count()函数。
20. Incrementing a local variable in a method is the fastest. Nearly the same as calling a local variable in a function. 在方法中递增局部变量,速度是最快的。几乎与在函数中调用局部变量的速度相当。
21. Incrementing a global variable is 2 times slow than a local var. 递增一个全局变量要比递增一个局部变量慢2倍。
22. Incrementing an object property (eg. $this->prop++) is 3 times slower than a local variable. 递增一个对象属性(如:$this->prop++)要比递增一个局部变量慢3倍。
23. Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one. 递增一个未预定义的局部变量要比递增一个预定义的局部变量慢9至10倍。
24. Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var). PHP probably does a check to see if the global exists. 仅定义一个局部变量而没在函数中调用它,同样会减慢速度(其程度相当于递增一个局部变量)。PHP大概会检查看是否存在全局变量。
25. Method invocation appears to be independent of the number of methods defined in the class because I added 10 more methods to the test class (before and after the test method) with no change in performance. 方法调用看来与类中定义的方法的数量无关,因为我(在测试方法之前和之后都)添加了10个方法,但性能上没有变化。
26. Methods in derived classes run faster than ones defined in the base class. 派生类中的方法运行起来要快于在基类中定义的同样的方法。
27. A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. A similar method call is of course about 15 $localvar++ operations. 调用带有一个参数的空函数,其花费的时间相当于执行7至8次的局部变量递增操作。类似的方法调用所花费的时间接近于15次的局部变量递增操作。
28. Surrounding your string by ‘ instead of ” will make things interpret a little faster since php looks for variables inside “…” but not inside ‘…’. Of course you can only do this when you don’t need to have variables in the string. 用单引号代替双引号来包含字符串,这样做会更快一些。因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会。当然,只有当你不需要在字符串中包含变量时才可以这么做。
29. When echoing strings it’s faster to separate them by comma instead of dot. Note: This only works with echo, which is a function that can take several strings as arguments. 输出多个字符串时,用逗号代替句点来分隔字符串,速度更快。注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中说echo是语言结构,不是真正的函数,故把函数加上了双引号)。
30. A PHP script will be served at least 2-10 times slower than a static HTML page by Apache. Try to use more static HTML pages and fewer scripts. Apache解析一个PHP脚本的时间要比解析一个静态HTML页面慢2至10倍。尽量多用静态HTML页面,少用脚本。
31. Your PHP scripts are recompiled every time unless the scripts are cached. Install a PHP caching product to typically increase performance by 25-100% by removing compile times. 除非脚本可以缓存,否则每次调用时都会重新编译一次。引入一套PHP缓存机制通常可以提升25%至100%的性能,以免除编译开销。
32. Cache as much as possible. Use memcached - memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load. OP code caches are useful so that your script does not have to be compiled on every request. 尽量做缓存,可使用memcached。memcached是一款高性能的内存对象缓存系统,可用来加速动态Web应用程序,减轻数据库负载。对运算码(OP code)的缓存很有用,使得脚本不必为每个请求做重新编译。
33. When working with strings and you need to check that the string is either of a certain length you’d understandably would want to use the strlen() function. This function is pretty quick since it’s operation does not perform any calculation but merely return the already known length of a string available in the zval structure (internal C struct used to store variables in PHP). However because strlen() is a function it is still somewhat slow because the function call requires several operations such as lowercase & hashtable lookup followed by the execution of said function. In some instance you can improve the speed of your code by using an isset() trick. 当操作字符串并需要检验其长度是否满足某种要求时,你想当然地会使用strlen()函数。此函数执行起来相当快,因为它不做任何计算,只返回在zval结构(C的内置数据结构,用于存储PHP变量)中存储的已知字符串长度。但是,由于strlen()是函数,多多少少会有些慢,因为函数调用会经过诸多步骤,如字母小写化(译注:指函数名小写化,PHP不区分函数名大小写)、哈希查找,会跟随被调用的函数一起执行。在某些情况下,你可以使用isset()技巧加速执行你的代码。
Ex.(举例如下)
if (strlen($foo) < 5) { echo “Foo is too short”; }
vs.(与下面的技巧做比较)
if (!isset($foo{5})) { echo “Foo is too short”; }
Calling isset() happens to be faster then strlen() because unlike strlen(), isset() is a language construct and not a function meaning that it’s execution does not require function lookups and lowercase. This means you have virtually no overhead on top of the actual code that determines the string’s length. 调用isset()恰巧比strlen()快,因为与后者不同的是,isset()作为一种语言结构,意味着它的执行不需要函数查找和字母小写化。也就是说,实际上在检验字符串长度的顶层代码中你没有花太多开销。
34. When incrementing or decrementing the value of the variable $i++ happens to be a tad slower then ++$i. This is something PHP specific and does not apply to other languages, so don’t go modifying your C or Java code thinking it’ll suddenly become faster, it won’t. ++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend’s PHP optimizer. It is still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer. 当执行变量$i的递增或递减时,$i++会比++$i慢一些。这种差异是PHP特有的,并不适用于其他语言,所以请不要修改你的C或Java代码并指望它们能立即变快,没用的。++$i更快是因为它只需要3条指令(opcodes),$i++则需要4条指令。后置递增实际上会产生一个临时变量,这个临时变量随后被递增。而前置递增直接在原值上递增。这是最优化处理的一种,正如Zend的PHP优化器所作的那样。牢记这个优化处理不失为一个好主意,因为并不是所有的指令优化器都会做同样的优化处理,并且存在大量没有装配指令优化器的互联网服务提供商(ISPs)和服务器。
35. Not everything has to be OOP, often it is too much overhead, each method and object call consumes a lot of memory. 并不是事必面向对象(OOP),面向对象往往开销很大,每个方法和对象调用都会消耗很多内存。
36. Do not implement every data structure as a class, arrays are useful, too. 并非要用类实现所有的数据结构,数组也很有用。
37. Don’t split methods too much, think, which code you will really re-use. 不要把方法细分得过多,仔细想想你真正打算重用的是哪些代码?
38. You can always split the code of a method later, when needed. 当你需要时,你总能把代码分解成方法。
39. Make use of the countless predefined functions. 尽量采用大量的PHP内置函数。
40. If you have very time consuming functions in your code, consider writing them as C extensions. 如果在代码中存在大量耗时的函数,你可以考虑用C扩展的方式实现它们。
41. Profile your code. A profiler shows you, which parts of your code consumes how many time. The Xdebug debugger already contains a profiler. Profiling shows you the bottlenecks in overview. 评估检验(profile)你的代码。检验器会告诉你,代码的哪些部分消耗了多少时间。Xdebug调试器包含了检验程序,评估检验总体上可以显示出代码的瓶颈。
42. mod_gzip which is available as an Apache module compresses your data on the fly and can reduce the data to transfer up to 80%. mod_zip可作为Apache模块,用来即时压缩你的数据,并可让数据传输量降低80%。
43. Excellent Article (http://phplens.com/lens/php-book/optimizing-debugging-php.php)about optimizing php by John Lim 另一篇优化PHP的精彩文章,由John Lim撰写。

mysql检索小体验

最近开始接手BMS(Business Management System),相比之前的CMS(Content Management System)数据量大了很多很多,本来就很菜的me,总喜欢写完一小段就刷新查看效果,但是现在如果要这样做的话,无疑是在考验自己的耐性[每刷新一次需要等待很长的时间...]。按要求给加了段时间的检索,仔细一看就发现数据量虽大,但数据时间都是集中在一个时间段的。试了一下where 时间 between … and …(之前是where 别的条件 and 时间 between … and … ),果然速度快多了。看来where之后是按顺序执行的?

无聊行为

虽然玩php也有很长时间了,因为比较懒得原因,自己在windows下手动安装还算是第一次吧,凭着感觉走,但是出现了错误-_-!
当配置完apache重启时就出现了The requested operation has faild.哎呀,妈呀,这咋回事呢。
回首一下配置文件,因为改的地方不是很多,若是一个一个撤销回去也挺麻烦的,先用apache的Test Configuration,发现无法提示无法加载php5apache2.dll。哎呀,哎呀……
不是很熟悉嘛,回头看了看php目录下dll文件还不少。找到问题了,里面有php5apche.dll,php5apche2.dll,php5apache2_2.dll,为了防止错误,网上找了一下,答案出来了:
apache1.*的用php5apahce.dll,apache2.0.*一般选phpapache2.dll,apache2.2.*一般要用php5apache2_2.dll
重启,It works! phpinfo(); successful….

Protected:

This post is password protected. To view it please enter your password below:


php:Problem with socket communication

failed to open stream: HTTP request failed!

Maybe you have experienced some issues with HTTP communication within PHP scripts, that are running through the web server. The same script does work through the CLI from command line.
This happens on setups when you have a really a lot of IP or name based virtual hosts in your Web server (about 1000 and more). This causes that your web server use a lot of file descriptors, which seems to be the main problem here. Well, the default value of FD_SETSIZE is 1024 and it seems like it isn’t enough for such setups.
You can experience errors like:
fsockopen(): unable to connect to …file_get_contents(): failed to open stream: HTTP request failed!fopen(): failed to open stream: HTTP request failed!main(): Failed opening ‘index.html’ for inclusion …
Actually, there are two ways how to fix this problem:
a) You can upgrade to latest PHP5, where this problem should be already fixed. b) You can recompile your PHP4 with larger FD_SETSIZE (For example 4096). On FreeBSD, you can add to the lang/php4/Makefile line similar to below to do so: — Makefile.origTue Sep 27 20:26:44 2005+++ MakefileTue Sep 27 21:55:50 2005@@ -172,6 +172,8 @@ .endif .endif +CFLAGS+=-DFD_SETSIZE=4096+ _PORTSDIR!= ${REALPATH} ${PORTSDIR} PHP_PORT= ${.CURDIR:S|^${_PORTSDIR}||:S|^/||}
and just reinstall your php4 installation.

Little more Information
http://bugs.php.net/bug.php?id=29939
http://bugs.php.net/bug.php?id=24189

今天搬家了,我的东西倒不是很多,陈涛过来帮忙了,不是很远,但还是挺累的。房子也不咋样,到了晚上才听说有更好的选择,后悔了。
看来迟早还是得再搬的。先将就着一个月吧。如果到那个时候还有好的选择就可以换地方了。

下午2点多,人事部的叫我过去谈了一下关于签合同的问题,原本不想这么快就签合同的。可是又不知道为什么最后还是签了。可能是因为一句话吧:公司的合同没有违约赔偿这项。
签合同的时候我最后还是没问起工资的问题,部门的头曾给我的承诺我想可能失效了吧,虽然少了1K多,但是最近不想换,而且别的待遇也还可以,先再呆阵子吧。。。
最近又要招一大批人进来…
老余把合同拿回去叫我等他抽烟,结果我就先回座位了,没想到一会就叫我来了-_-!!!!

合同截至日期08年11月20日 希望我能有颗坚强的心等在此公司呆到那个时候

浩方启用名字限制了?太神奇了,不过可惜的是我的[禁卫军团]不知道让谁给抢去用?是不是在浩方上NB了,名字就被占用了?不过没关系,俺就用仔仔多年未用的[寂寞舞神]

特地回来记录一下,呵呵……
哇靠 发现浩方自己下载装好,别的也都弄好了就他妈魔没有?操,摆那么大一个图标居然是假的

经过三十多个小时的列车,终于到达了漳州东站,本来是11:57从北京西站发车,结果晚点了,到14:50才发车,路上又晚点了好几个小时,原本今天18:50就到站,结果到快0点了才到,唯一感到欣慰的是这次是我来来回回那么多次是最不挤的一回,一路过来江西路段是很漫长的,而且雪还下的很大,到福建就更漫长了,唯一区别的是见不着雪的影子,只有小雨。
下车了,毛绒绒的细雨还真爽,穿着羽绒服实在是太热,准备好的雨伞也没有用上,徒步走在那条算是比较熟悉的街上,虽然很晚,但还不算冷清,还有饭店旅社在营业,用已经生硬的闽南语问了旅社,40块一晚,感觉挺不划算,最想找家网吧过夜,走过去没见着,想走回火车站过夜,给林林发信息一抬头就见着网吧了,也就有这段无聊的记录式文字。
天亮就可以出发了,也就是大年三十了。

Page 16 of 21« First...«1415161718»...Last »


Search
Feeds
Meta
Advertisement

Return to page top