Thursday, November 29, 2007

Wisdom|兵法三十六计 13计 【攻战】打草惊蛇

13计 【攻战】打草惊蛇
送交者: 东京老虎 [进士☆] 于 October 27, 2007 23:58:38 已读 336

回答: ┊◆┊┊◆┊┊◆┊兵法三十六计┊◆┊┊◆┊┊◆┊ 由 东京老虎 于 October 27, 2007 23:46:36:

疑以叩实①,察而后动;复者②,阴之媒也③。 www.6park.com

①疑以叩实:叩,问,查究。意为发现了疑点就应 当考实查究清楚。 www.6park.com

②复者:反复去做,即反复去叩实而后动。 www.6park.com

③阴之媒也:阴,此指某些隐藏着的、暂时尚不明显或未暴露的事物、情况。媒,媒介。 www.6park.com

"复者,阴之媒也",意即反复叩实查究,而后采取相应的行动,实际是发现隐藏之敌的重要手段。 www.6park.com

古人按语说:敌力不露,阴谋深沉,未可轻进,应遍挥其锋。兵书云:"军旁有险阻、潢井、葭苇、山林、翳荟者,必谨复索之,此伏奸所藏也"(《孙子・行军篇》)。 www.6park.com

兵法早已告诫指挥者,进军的路旁,如果遇到险要地势,坑地水洼,芦苇密林,野草遍地,―定不能麻痹大意,稍有不慎,就会"打草惊蛇"而被埋伏之敌所歼。可是,战场情况复杂变化多端,有时已方巧设伏兵,故意"打草惊蛇",让敌军中计的战例也层出不穷。 www.6park.com

打草惊蛇之计,一则指对于隐蔽的敌人,己方不得轻举妄动,以免敌方发现我军意图而采取主动;二则指用佯攻助攻等方法"打草",引蛇出动,中我埋伏,聚而歼之。 www.6park.com

打 草惊蛇,语出段成式《酉阳杂俎》:唐代王鲁为当涂县令,搜刮民财,贪污受贿。有一次,县民控告他的部下主薄贪脏。他见到状子,十分惊骇,情不自禁地在状子 上批了八个字:"汝虽打草,吾已惊蛇."打草惊蛇,作为谋略,是指敌方兵力没有暴露,行踪诡秘,意向不明时,切切不可轻敌冒进,应当查清敌方主力配置、 运动状况再说。 www.6park.com

公元前627年, 秦穆公发兵攻打郑国,他打算和安插在郑国的奸细里应外合,夺取郑国都城。大夫蹇叔以为秦国离郑国路途遥远,兴师动众长途跋涉,郑国肯定会作好迎战准备。秦 穆公不听,派孟明视等三帅率部出征。蹇叔在部队出发时.痛哭流涕地警告说,恐怕你们这次袭郑不成,反会遭到晋国的埋伏,只有到崤山去给士兵收尸了。果然不 出蹇叔所料,郑国得到了秦国袭郑的情报,逼走了秦国安插的奸细,作好了迎敌准备。秦军见袭郑不成,只得回师,但部队长途跋涉,十分疲惫。部队经过崤山时, 仍然不作防备。他们以为秦国曾对晋国刚死不久的晋文公有恩,晋国不会攻打秦军。哪里知道,晋国早在崤山险蜂峡谷中埋伏了重兵。一个炎热的中午,秦军发现晋 军小股部队,孟明十分恼怒,下令追击。追到山隘险要处.晋军突然不见踪影。孟明一见此地山高路窄,草深林密,情知不妙。这时鼓声震天,杀声四起,晋军伏兵 蜂涌而上,大败秦军,生擒孟明视等三帅。秦军不察敌情,轻举妄动,"打草惊蛇"终于遭到惨败。当然,军事上有时也可故意"打草惊蛇"而诱敌暴露,从而取得 战斗的胜利。 www.6park.com

李自成起义部队逐步壮大,所向 披靡,公元1642年,围困明朝都城开封。崇祯连忙调集各路兵马,援救开封。李自成部已完成了对开封的包围部署。敌人二十五万兵马和一万辆炮车增援开封, 集中在离开封西南四十五里的朱仙镇。李自成为了不让援军与开封守敌合为一股,在开封和朱仙镇分别布置了两个包围圈,把敌军分割开来。又在南方交通线上挖一 条长达百里、宽为一丈六尺的大壕沟,一断敌军粮道,二断敌军退路。敌军各路兵马,貌合神离,心怀鬼胎,互不买帐。李自成兵分两路,一路突袭朱仙镇南部的虎 大威的部队,造成"打草惊蛇"的作用,一路牵制力量最强的左良玉部队。击溃虎大威部后,左良玉果然因被围困得难以脱身,人马损失过半,拼命往西南突围。李 自成故意放开一条路,让败军溃逃。哪知,左良玉退了几十里地又遇截击,面临李自成挖好的大壕沟,马过不去,士兵只得弃马渡沟,仓皇逃命。这时等在此地的伏 兵迅速出击,敌军人仰马翻,尸填沟堑,全军覆没。 www.6park

Wisdom|兵法三十六计 12计 【敌战】顺手牵羊

12计 【敌战】顺手牵羊
送交者: 东京老虎 [进士☆] 于 October 27, 2007 23:57:52 已读 335

回答: ┊◆┊┊◆┊┊◆┊兵法三十六计┊◆┊┊◆┊┊◆┊ 由 东京老虎 于 October 27, 2007 23:46:36:

微隙在所必乘①;微利在所必得。少阴,少阳②。 www.6park.com

①微隙在所必乘:微隙,微小的空隙,指敌方的某些漏洞、疏忽。 www.6park.com

②少阴,少阳:少阴,此指敌方小的疏漏,少阳,指我方小的得利。此句意为我方要善于捕捉时机,伺隙捣虚,变敌方小的疏漏而为我方小的得利。 www.6park.com

古人按语说:大军动处,其隙甚多,乘间取利,不必以胜。胜固可用,败亦可用。 www.6park.com

大 部队在运动的过程中,漏洞肯定很多,比如,大兵急于前进,各部运动速度不同,给养可能造成困难,协调可能不灵,战线拉得越长,可乘之机一定更多。看准敌人 的空隙,抓住时机一击,只要有利,不一定完全取胜也行。这个方法,胜利者可以运用,失败者也可以运茫�看蟮囊环娇梢栽擞茫�跣〉囊环揭部梢栽擞谩? 战争史上一方经常用小股游击队,钻进敌人的心脏,神出鬼没打击敌人,攻敌薄弱处,应手得利。这样用顺手牵羊取胜的例子,不胜枚举。 www.6park.com

顺手牵羊是看准敌方在移动中出现的漏洞,抓住薄弱点,乘虚而入获取胜利的谋略。古人云:"善战者,见利不失,遇时不疑。"意思是要捕捉战机,乘隙争利,当然,小利是否应该必得,这要考虑全局,只要不会"因小失大",小胜的机会也不应该放过。 www.6park.com

公 元383年, 前秦统一了黄河流域地区,势力强大。前秦王苻坚坐镇项城,调集九十万大军,打算一举歼灭东晋。他派其弟苻融为先锋攻下寿阳,初战告捷,苻融判断东晋兵力不 多并且严重缺粮,建议苻坚迅速进攻东晋。苻坚闻讯,不等大军齐集,立即率几千骑兵赶到寿阳。东晋将领谢石得知前秦百万大军尚未齐集,抓住时机,击败敌方前 锋,挫敌锐气。谢石先派勇将刘牢之率精兵五万,强渡洛涧,杀了前秦守将梁成。刘牢之乘胜追击,重创前秦军。谢石率师渡过洛涧,顺淮河而上,抵达淝水一线, 驻扎在八公山边,与驻扎在寿阳的前秦军隔岸对峙。苻坚见东晋阵势严整,立即命今坚守河岸,等待后续部队。谢石看到敌众我寡,只能速战速决。于是,他决定用 激将法激怒骄狂的苻坚。他派人送去一封信,说道,我要与你决一雌雄,如果你不敢决战,还是趁早投降为好。如果你有胆量与我决战,你就暂退一箭之地,放我渡 河与你比个输赢。苻坚大怒,决定暂退一箭之地,等东晋部队渡到河中间,再回兵出击,将晋兵全歼水中。他哪里料到此时秦军士气低落,撤军令下,顿时大乱。秦 兵争先恐后,人马冲撞,乱成一团,怨声四起。这时指挥已经失灵,几次下令停止退却,但如潮水般撤退的人马已成溃败之势。这时谢石指挥东晋兵马,迅速渡河, 乘敌人大乱,奋力追杀。前秦先锋苻融被东晋军在乱军中杀死,苻坚也中箭受伤,慌忙逃回洛阳。前秦大败。淝水之战,东晋军抓住战机,乘虚而入,是古代战争史 上以弱胜强的著名战例。 www.6park.com

唐朝中期,各镇节度史都拥有军事、经济大权,根本不把朝廷放在眼里。蔡州节度使的儿子吴元济在父死之后,起兵叛乱。唐宪宗派大将李诉担任唐州节度使,剿灭吴元济。 www.6park.com

李诉到任,放风麻痹吴元济。散布说,我是个懦弱无能的人。朝廷派我来,只是为了安顿地方秩序。至于攻打吴元济,与我无干。吴元济观察了李诉的动静,见他毫无进攻之意,也就不把李诉放在心上了。 www.6park.com

其 实李诉一直在思考攻打吴元济老巢蔡州的策略。他趁机擒获了吴元济手下的大将李佑,对他优礼有加,感动了李佑。李佑告诉李诉,吴元济的主力部队都部署在洄曲 一带,防止官军进攻,而防守蔡州城的不过是些老弱残兵。蔡州是吴元济最大的空隙,如果出奇制胜,应该迅速直捣蔡州,活捉吴元济。 www.6park.com

李 诉在一个雪天的傍晚,率领精兵抄小路,神奇地直抵蔡州城边,趁守城士兵呼呼大睡时,爬上城墙,杀了守兵,打开城门,部队静悄悄涌进了城。筹吴元济从睡梦中 惊醒,发现宅第已被围困,负隅顽抗,终于被捉。李诉将吴元济装进囚车,押往长安。驻扎在洄曲的董重质见大势已去,也向李诉投降。 www.6park.com

Tuesday, November 27, 2007

Wisdom|兵法三十六计 11计 【敌战】李代桃僵

11计 【敌战】李代桃僵
送交者: 东京老虎 [进士☆] 于 October 27, 2007 23:57:07 已读 484
天天养生堂
数百种美国名厂保健品,超低价直销全球!
蜜糖交友中心
海外孤身?强大搜索功能,轻松找到意中人!
一杯茶一台电脑
在家炒汇很有趣! 免费体验, 试试!

回答: ┊◆┊┊◆┊┊◆┊兵法三十六计┊◆┊┊◆┊┊◆┊ 由 东京老虎 于 October 27, 2007 23:46:36:

必有损,损阴以益阳①。 www.6park.com

① 损阴以益阳:阴:此指某些细微的、局部的事物。阳,此指事物带整体意义的、全局性的事物。这是说在军事谋略上,如果暂时要以某种损失、失利为代价才能最终 取胜,指挥者应当机立断,作出某些局部、或暂时的牺牲,去保全或者争取全局的、整体性的胜利。这是运用我国古代阴阳学说的阴阳相生相克、相互转化的道理而 制定的军事谋略。 www.6park.com

古人按语说:我敌之情,各有长短。战争之事,难得全胜,而胜负之诀,即在长短之相较,乃有以短胜长之秘诀。如以下驷敌上驷,以上驷敌中驷,以中驷敌下驷之类:则诚兵家独具之诡谋,非常理之可测也。 www.6park.com

两 军对峙,敌优我劣或势均力敌的情况是很多的。如果指挥者主观指导正确,常可变劣势为优势。孙膑赛马的故事为大家的熟知,他在田忌的马总体上不如对方的情况 下,使他仍以二比一获胜。但是,运用此法也不可生搬硬套。春秋时齐魏桂陵之战,魏军左军最强,中军次之,右军最弱。齐将田忌准备按孙膑赛马之计如法泡制, 孙膑却认为不可。他说,这次作战不是争个二胜一负,而应大量消灭敌人。于是用下军对敌人最强的左军,以中军对势均力敌的中军,以力量最强的部队迅速消灭敌 人最弱的右军。齐军虽有局部失利,但敌方左军、中军已被钳制住,右军很快败退。田忌迅即指挥已方上军乘胜与中军合力,力克敌方中军,得手后,三军合击,一 起攻破敌方最强的左军。这样,齐军在全局上形成了优势,终于取胜。李代桃僵,就是趋利避害,指挥的高明之处,是要会"算帐"。古人云:"两利相权从其重, 两害相衡趋其轻。"以少量的损失换取很大的胜利,是划得来的。 www.6park.com

李 代桃僵,语出《乐府诗集・鸡鸣篇》:"桃生露井上,李树生桃旁,虫来啮桃根,李树代桃僵,树木身相代,兄弟还相忘?"本意是指兄弟要象桃李共患难一样相互 帮助,相互友爱。此计用在军事上,指在敌我双方势均力敌,或者敌优我劣的情况下,用小的代价,换取大的胜利的谋略。很象大家在象棋比赛中的"舍车保帅"的 战术。 www.6park.com

战国后期,越国北部经常受到匈奴蟾褴国及 东胡、林胡等部骚扰,边境不宁。赵王派大将李牧镇守北部门户雁门。李牧上任后,日日杀牛宰羊,犒赏将士,只许坚壁自守,不许与敌交锋。匈奴摸不消底细,也 不敢贸然进犯。李牧加紧训练部队,养精蓄锐, 几年后,兵强马壮,士气高昂。公元前250年,李牧准备出击匈奴。他派少数士兵保护边寨百姓出去放牧。匈奴人见状,派出小股骑兵前去劫掠,李牧的士兵与敌 骑交手,假装败退,丢下一些人和牲畜。匈奴人占得便宜,得胜而归。匈奴单于心想,李牧从来不敢出城征战,果然是一个不堪一击的胆小之徒。于是亲率大军直逼 雁门。李牧已料到骄兵之计已经奏效,于是严阵以待,兵分三路,给匈奴单于准备了一个大口袋。匈奴军轻敌冒进,被李牧分割几处,逐个围歼。单于兵败,落荒而 逃,蟾褴国灭亡。李牧用小小的损失,换得了全局的胜利。 www.6park.com

春 秋时期,晋国大奸臣屠岸贾鼓动晋景公灭掉于晋国有功的赵氏家族。屠岸贾率三千人把赵府团团围住,把赵家全家老小,杀得一个不留。幸好赵朔之妻庄姬公主已被 秘密送进宫中。屠岸贾闻讯必欲赶尽杀绝,要晋景公杀掉公主。景公念在姑侄情分,不肯杀公主。公主已身怀有孕,屠岸贾见景公不杀她,就定下斩草除根之计,准 备杀掉婴儿。公主生下一男婴,屠岸贾亲自带人入宫搜查,公主将婴儿藏在裤内,躲过了搜查。屠岸贾估计婴儿已偷送出官,立即悬赏缉拿。赵家忠实门客公孙许臼 与程婴商量救孤之计:如能将一婴儿与赵氏孤儿对换, www.6park.com

我 带这一婴儿逃到首阳山,你便去告密,让屠贼搜到那个假赵氏遗孤,方才会停止搜捕,赵氏嫡脉才能保全。程婴的妻子此时正生一男婴,他决定用亲子替代赵氏孤 儿。他以大义说服妻了忍着悲痛把儿子让公孙许臼带走。程婴依计,向屠岸贾告密。屠贼迅速带兵追到首阳山,在公孙井臼居住的茅屋,搜出―个用锦被包裹的男 婴。于是屠贼摔死了婴儿。他认为已经斩草除很,放松了警戒。在忠臣韩厥的帮助下,一个心腹假扮医生,入宫给公主看病,用药箱偷偷把婴儿带出宫外,程婴已经 听说自己的儿子被屠贼摔死,强忍悲痛,带着孤儿逃往外地,过了十五年后,孤儿长大成人,知道自己的身世后,在韩厥的帮助下,兵戈讨贼,杀了奸臣屠岸贾,报 了大仇。 www.6park.com

程婴见赵氏大仇已报,陈冤已雪,不肯独享富贵,拔剑自刎,他与公孙许臼合葬一墓,后人称"二义冢"。他们的美名千古流传。

Wisdom|10计 兵法三十六计【敌战】笑里藏刀

10计 【敌战】笑里藏刀
送交者: 东京老虎 [进士☆] 于 October 27, 2007 23:56:28 已读 433

回答: ┊◆┊┊◆┊┊◆┊兵法三十六计┊◆┊┊◆┊┊◆┊ 由 东京老虎 于 October 27, 2007 23:46:36:

信而安之①, 阴以图之②,备而后动,勿使有变。刚中柔外也 ③。 www.6park.com

①信而安之:信,使信。安,使安,安然,此指不生 疑心。 www.6park.com

②阴以图之:阴,暗地里。 www.6park.com

③刚中柔外:表面柔顺,实质强硬尖利。 www.6park.com

古 人按语说:兵书云:"辞卑而益备者,进也;……无约而请和者,谋也。" 故凡敌人之巧言令色,皆杀机之外露也。宋曹玮知渭州,号令明肃,西夏人惮之。一日玮方对客奕棋,会有叛夸数千,亡奔夏境。堠骑(骑马的侦宿员)报至,诸将 相顾失色,公言笑如平时。徐谓骑日."吾命也,汝勿显言。"西夏人闻之,以为袭己,尽杀之。此临机应变之用也。若勾践之事夫差.则意使其久而安之矣。 www.6park.com

宋 将曹玮,闻�腥伺驯洌��堑�痪�郑�炊�婊�Ρ悖�感ψ匀纾�挥枳? 捕,让敌人把叛逃者误认为是曹玮派来进攻的,把他们全部杀光。曹琼把笑里藏刀和借刀杀人之计运用得何其自如!古代兵法早就提醒为战者:切不可轻信对方的甜 言蜜语、空头支票,要谨防他们暗中隐藏的杀机。总之,此计还多用于军事政治与外交的伪装上。 www.6park.com

笑里藏刀,原意是指那种口蜜腹剑,两面三刀,"口里喊哥哥,手里摸家伙" 的作法。此计用在军事上,是运用政治外交上的伪装手段,欺骗麻痹对方,来掩盖己方的军事行动。这是一种表面友善而暗藏杀机的谋略。 www.6park.com

战 国时期,秦国为了对外扩张,必须夺取地势险要的黄河崤山一带,派公孙鞅为大将,率兵攻打魏国。公孙鞅大军直抵魏国吴城城下。这吴城原是魏国名将吴起苦心经 营之地,地势险要,工事坚固,正面进攻恐难奏效。公孙鞍苦苦思索攻城之计。他探到魏国守将是与自己曾经有过交往的公子行,心中大喜。他马上修书一封,主动 与公子行套近乎,说道,虽然我们俩现在各为其主,但考虑到我们过去的交情,还是两国罢兵,订立和约为好。念旧之情,溢干言表。他还建议约定时间会谈议和大 事。信送出后,公孙鞅还摆出主动撤兵的姿态,命令秦军前锋立即撤回。公子行看罢来信,又见秦军退兵,非常高兴,马上回信约定会谈日期。公孙鞅见公子行已钻 入了圈套,暗地在会谈之地设下埋伏。会谈那天,公子行带了三百名随从到达约定地点,见公孙鞅带的随从更少,而且全部没带兵器,更加相信对方的诚意。会谈气 氛十分融洽,两人重叙昔日友情,表达双方交好的诚意。公孙鞍还摆宴款待公子行。公子行兴冲冲人席,还未坐定,忽听一声号令,伏兵从四面包围过来,公子行和 三百随从反应不及,全部被擒。公孙鞅利用被俘的随从,骗开吴城城门,占领吴城。魏国只得割让西河一带,向秦求和。秦国用公孙鞅笑里藏刀计轻取崤山一带。 www.6park.com

三国时期, 由于荆州地理位置十分重要,成为兵家必争之地。公元217年,鲁肃病死。孙、刘联合抗曹的蜜月已经结束。当时关羽镇守荆州,孙权久存夺取荆州之心,只是时 机尚未成熟。不久以后,关羽发兵进攻曹操控制的樊城,怕有后患,留下重兵驻守公安、南郡,保卫荆州。孙权手下大将吕蒙认为夺取荆州的时机已到,但因有病在 身,就建议孙权派当时毫无名气青年将领陆逊接替他的位置,驻守陆口。陆逊上任,并不显山露水,定下了与关羽假和好、真备战的策略。他给关羽写去一信,信中 极力夸耀关羽,称关羽功高威重,可与晋文公、韩信齐名。自称―介书生,年纪太轻,难担大任,要关羽多加指教。关羽为人,骄做自负,目中无人,读罢陆逊的 信,仰天大笑,说道:"无虑江东矣。"马上从防守荆州的守军中调出大部人马,一心一意攻打樊城。陆逊又暗地派人向曹操通风报信,约定双方一起行动,夹击关 羽。孙权认定夺取荆州的时机已经成熟,派吕蒙为先锋,向荆州进发。吕蒙将精锐部队埋伏在改装成商船的战舰内,日夜兼程,突然袭击,攻下南部。关羽得讯,急 忙回师,但为时已晚,孙权大军已占领荆州。关羽只得败走麦城。

Monday, November 26, 2007

Python|如何提高网站访问速度 从30秒到3秒的改变

如何提高网站访问速度 从30秒到3秒的改变


作者:未知 来源:未知 网络营销手册www.tomx.com 加入时间:2007-3-27 

 

2006 年10月份,我开始对web开发产生了兴趣,并决定自己也尝试开发一个网站。在此之前,我做过3年的java application的开发,对web开发应该算一无所知。在比较了java,php,ror,和python后,我选择了基于python的web框 架 - django 。到目前为止,我还认为这是一个明智的决定。Django高效的开发效率让我仅仅用一个月的业余时间,就基本完成了网站的开发。这是一个网络书签的网站, 我加上了一些有意思的特性,让网站显得有些与众不同。

我购买了域名和Dreamhost 的主机空间。Dreamhost支持django,并且第一年的费用只有180元人民币。2006年11月份,http: //www.hpbookmarks.com 上线了。网友们发来了善意的评论,"很有创意","点意思","一些feature很不错"。同时,还有一个非常一致的意见就是,"访问速度太慢了"。其 实,当时的情况不只是访问速度慢,而且是相当不稳定。很多时候是几个小时网站无法访问。当时,我并没有在意,因为我有两个自以为"合理"的解释。第一,我 用的是国外最便宜的虚拟主机,国内访问慢是很正常的。第二,django的还处于0.95的状态,效率和稳定性方面有问题也正常。

但是,我慢慢发现上面的解释不过是自己骗自己的借口。很多用dreamhost的网站,访问起来也很快。而且django也已经被成功应用在许多大型的网 站。我开始认真考虑提高网站速度的问题了。毕竟,速度慢的网站很可能在第一次就失去的用户,他们可以永远不会再来了。终于,我进行了下面一步一步的优化工 作,并且取得了一个看起来还不错的结果。

第一步,用Ajax提高用户体验

由于我的网站上链接字体的大小是根据点击次数决定,所以每次点击都要提交到服务器端并记录次数,再在客户端打开网站链接。这在localhost测试的时 候没有发现问题,但是部署到服务器上,会感到明显的等待。解决办法就是用Ajax。用户点击网站链接后就直接打开,再通过Ajax将点击的事件提交到服务 器端记录。这样用户感觉不到任何延时。

第二步,将逻辑移到客户端的javascript中

在开始的时候,"网站标签高亮"和"手气不错"的功能都是提交到服务器端操作,然后返回结果的。后来,我发现其实很多逻辑是可以移到客户端,由 javascript来实现的。Javascript非常强大,可以完成很多复杂的逻辑。将逻辑移到客户端的javascript中,可以很有效的减少和 服务器通讯的次数,获得更好的访问速度。

第三步,解决进程的

由于采用的是fastCGI的方式,我配置了django.fcgi。可是,我发现系统进程中,有大量的django.fcgi进程被标记为 < defunct>(失去功能)。这些进程会导致服务器有时无法正常访问。我开始尝试用命令来kill掉这些进程,但是很快发现这无法从根本上解决问 题。后来,我看到一个老外在blog上提到一个解决方案,将django.fcgi改名为dispatch.fcgi。原来,dispatch.fcgi 是一个dreamhost的系统进程,它的健壮性是可以得到保障的。果然,我将django.fcgi改名为 dispatch.fcgi后,的现象再没有出现。

第四步,优化SQL语句

SQL语句的执行通常也是一个很花费时间的操作。经过检查,我发现我的一条SQL语句,是一个嵌套三层的子表查询。而这条SQL还必须是一个Raw SQL,即不能采用django的OR Maping。这意味着不能被cache缓存,每次都是真刀真枪的执行。更失败的是,经过我的分析,这条SQL完全可以不执行。这是一次设计上的失误,标
准的over design(过渡设计)。当时,我是想通过数据库得到一个最精确的统计值。后来发现,这个值完全可以用一个近似的常量代替。优化SQL,尤其是避免不必要的SQL执行,带来的效果是非常明显的。

第五步,尽量减少页面大小

随着添加网站越来越多,有一天我发现django生成的首页已经达到了80k。我很清楚这是一个非常不能被接受的数字。我开始检查页面,很快发现 了线索。 第一,因为偷懒,页面中很多layout是用空格( )实现的。第二,因为为了增加代码可读行,调试方便,每行生成的页面都增加换行符 (\n)。第三,最糟糕的是,大量的用了
inline css。就是将css style直接嵌入标记块中。于是,我立即动手,用css的align解决layout,去掉\n,将inline css抽象到独立的css文件中。这样下来,在不更改任何内容的情况下,80k变成了57k。(补充:由于网站链接大部分是打开新窗口,所以用了大量的 target=_blank。在ylsdd的提示下,在html的head里增加了,又节约了4k。)

第六步,用gzip进行页面压缩

当我兴高采烈的把页面优化结果贴到了smth bbs上,却被直接泼了盆凉水。原来百分之二十几的优化结果,实在太一般了。ylsdd给我了一个很重要的线索,deflate。原来apache的 deflate模块可以把文件进行gzip压缩,压缩后的文件传到浏览器后再被解压。主流的浏览器都支持这种gzip的解压操作。于是,我在apache 的配置文
件中加入了Add OutputFilter DEFAULT html css js的语句。经过测试,css,js这些文本文件的压缩后都只有原来尺寸的25%。这里,和大家分享一个网站http: //www.port80software.com/products/httpzip/compresscheck 它的作用是检测你的网站是否被压缩,以及压缩比率等。

第七步,回归静态页面

新的问题又来了。原来deflate只支持静态文件的压缩。而我的首页是django动态生成的,deflate模块没有进行压缩。我突然想到,网站的首 页为什么不能是静态页面呢?于是,我增加了一个runtime的api,这个api提供的是和原来一样由django动态生成的页面。我又写了一个 python的程序,通过urllib2模块下载这个动态生成的页面,并保存为index.html。我将网站的root映射到index.html这个 静态页面。最后,通过linux crontab定义一个行为,每五分钟执行一下这个python程序,生成新的index.html。值得一提的是,由于网络原因,python程序不一 定每次都能准确完整的下载动态生成的页面。所以我们必须再进行一个校验算法。当页面大小要超过一定数字,页面中出现某个校验字符串的情况下,才保存 index.html。这样,每次用户提交的访问,不是由服务器端动态生成页面,极大的节省了服务器端的开销。而静态页面又可以有效的被deflate压 缩。最后结果,首页被压缩为13k,为原来的22%。唯一的区别就是,新提交和推荐的网站不能立即出现在首页。但是我认为,这应该是可以被接受的。

至此,网站的优化工作基本完成。网站的访问速度从原来30秒以上,缩短到3秒左右,应该说算是一个飞跃。虽然,3秒的速度也不是非常快,但是,考虑到虚拟主机等客观原因,这个结果我还是满意的。原来感觉我的网站很慢的朋友们,也可以再试试。

以上的优化方案出自我的个人经验,并不一定适合所有网站。但是,它告诉我们一个事实。影响网站访问速度的不仅仅是服务器配置,网络带宽。也许,你糟糕的设 计,低效率的方案也是致命的因素。应当注意的是,优化工作也不能匆匆上手。一定要仔细研究,具体情况具体分析,得到统计数据,找到真正的问题所在,再开始 优化。相信自己,提高网站的访问速度并不是不可能。毕竟,Nothing is Impossible。祝大家成功。

Python|Framework Performance

Framework Performance

We recently decided to switch our projects (what were they to start with? Perl / CGI?) to a MVC framework and our choice of the framework came down to three final contenders:

To better understand the pros and cons of each, we wrote a very simple demo application in all three. The app we chose was the one built in the Ruby on Rails tutorial Rolling with Ruby on Rails http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html.

We really wanted to test the framework, not static file serving or database performance. So we didn't come up with complex queries or serve any static CSS or image files. All requests/hits/transactions are rendered pages. Also, all of the tests are GET operations (database SELEC Ts) for concurrent testing fairness and simplicity.

Each of the tested pages was configured to have a unique number displayed on it based on microtime (to verify the pages weren't being cached). Also, the same pages across all three apps were edited to have nearly the same number of bytes served.

DISCLAIMER: There are infinitely more test scenarios we could have performed. But we wanted something done in a finite time. We feel these results, though not the whole picture, offer hints about relative performance between the three frameworks/platforms.

Test Hardware:

  • Dell 1U server (unknown model)
  • Dual Xeon 3.2Ghz (6400 bogomips)
  • 2 Gigs of RAM
  • 2 240Gig (?) SATA drives

Test OS/Software:

  • OS: SuSE 10.1
  • kernel: 2.6.16.13-4-smp
  • database: Mysql 5.0.18
  • stress-test software: Siege 2.64 http://www.joedog.org/JoeDog/Siege
  • Used stock RPM's for all software unless noted below

Symfony setup:

  • Apache 2.2.0 (mod_php)
  • PHP 5.1.2
  • APC 3.0.10 (PHP accelerator, compiled from source)
  • Symfony 0.7.1587 (not an RPM )

Django setup:

  • Apache 2.2.0 (mod_python)
  • Python 2.4.2
  • Django 0.95-3336 (not an RPM)

Rails setup:

  • Apache 2.2.0 (mod_proxy_balancer)
  • Ruby 1.8.4
  • Rails 1.1.4 (not an RPM)
  • Mongrel and lighttpd web server (not an RPM)

Apache Prefork tuning:

StartServers         5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 150
MaxClients 150
MaxRequestsPerChild 10000

Results

For each of the platforms, we experimented a bit with some options to try to get the best performance by running 3-minute tests. Then we ran an extended 30-minute test on each platform. (Before the actual tests, we pre-ran siege for a minute or two to prime whatever cache's, etc.) Here are some of the results:

Symfony – 50 concurrent users

With PHP+APC: (30 min)

Transactions:                  85862 hits
Availability: 100.00 %
Elapsed time: 1801.15 secs
Data transferred: 114.41 MB
Response time: 1.04 secs
Transaction rate: 47.67 trans/sec
Throughput: 0.06 MB/sec
Concurrency: 49.63
Successful transactions: 85862
Failed transactions: 0
Longest transaction: 4.15
Shortest transaction: 0.02

Mysql: 7% of CPU
Siege:
5% of CPU

With APC disabled: (3 min)

Transactions:                   2256 hits
Availability: 99.34 %
Elapsed time: 181.76 secs
Data transferred: 3.15 MB
Response time: 3.64 secs
Transaction rate: 12.41 trans/sec
Throughput: 0.02 MB/sec
Concurrency: 45.19
Successful transactions: 2256
Failed transactions: 15
Longest transaction: 30.57
Shortest transaction: 0.14

NOTE: NOT having a PHP accelerator yields about 12 trans/sec! Horrible! Rumor has it that APC will be included by default in PHP6. In the above tests, we also had syck (for YAML parsing). However it didn't significantly change the results on a 3 minute test (less than 0.5 trans/sec).

Rails – 50 concurrent users

With 10 mongrels: (30 min)

Transactions:                 158747 hits
Availability: 100.00 %
Elapsed time: 1800.82 secs
Data transferred: 211.38 MB
Response time: 0.57 secs
Transaction rate: 88.15 trans/sec
Throughput: 0.12 MB/sec
Concurrency: 49.89
Successful transactions: 158747
Failed transactions: 0
Longest transaction: 11.11
Shortest transaction: 0.00

Mysql: 10% of CPU
Siege:
10% of CPU

NOTE: In the test above Rails was configured with 10 stand-alone mongrel processes (production mode) and web requests were redirected through Apache using mod_proxy_balancer. In subsequent 3 minute tests, having 20 or 30 mongrels didn't affect the transaction rate more than 0.5 trans/sec.

With lighttpd+fastcgi: (3 min)

Transactions:                  15415 hits
Availability: 100.00 %
Elapsed time: 180.66 secs
Data transferred: 20.53 MB
Response time: 0.58 secs
Transaction rate: 85.33 trans/sec
Throughput: 0.11 MB/sec
Concurrency: 49.89
Successful transactions: 15415
Failed transactions: 0
Longest transaction: 1.25
Shortest transaction: 0.04

NOTE: The above test was run with the default lighttpd.conf, but on port 80 and in production mode. The number of trans/sec was about the same, but the longest transaction time was much smaller!

Django, 50 concurrent users

With mod_python: (30 min)

Transactions:                 224588 hits
Availability: 100.00 %
Elapsed time: 1800.52 secs
Data transferred: 298.94 MB
Response time: 0.40 secs
Transaction rate: 124.74 trans/sec
Throughput: 0.17 MB/sec
Concurrency: 49.92
Successful transactions: 224576
Failed transactions: 0
Longest transaction: 9.31
Shortest transaction: 0.00

Mysql: 17% of CPU
Siege:
11% of CPU

NOTE: The above test was run with PythonAutoReload? Off and PythonDebug? Off (production mode). These are by far the best performance numbers of the three frameworks!

High-load Results

I re-ran 3-minute tests on all three platforms with 150 concurrent users to check high-load results.

Symfony – PHP+APC, 150 concurrent users

results

Transactions:              14363 hits
Availability: 98.68 %
Elapsed time: 183.12 secs
Data transferred: 3.72 MB
Response time: 1.34 secs
Transaction rate: 78.43 trans/sec
Throughput: 0.02 MB/sec
Concurrency: 105.06
Successful transactions: 122
Failed transactions: 192
Longest transaction: 30.67
Shortest transaction: 0.02

NOTE: You can see there were very few successful transactions. Most were "500 – Internal Server Errors" and 192 failed to connect altogether. It looks like the 500 errors were caused by something with Mysql, because the dev interface returned: "connect failed Native Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock"

Rails – 10 mongrels, 150 concurrent users

results

Transactions:                  14718 hits
Availability: 100.00 %
Elapsed time: 180.61 secs
Data transferred: 20.22 MB
Response time: 1.79 secs
Transaction rate: 81.49 trans/sec
Throughput: 0.11 MB/sec
Concurrency: 146.12
Successful transactions: 14718
Failed transactions: 0
Longest transaction: 18.39
Shortest transaction: 0.00

NOTE: "Transaction rate" down, and "Longest trans" time is up (from 50 concurrent users), but no failed transactions.

NOTE: Attempting this test with lighttpd+fastcgi failed. The web server returned "500 – Internal Server Error"'s and absurd siege result numbers.

Django, 150 concurrent users

results

Transactions:                  19903 hits
Availability: 100.00 %
Elapsed time: 180.78 secs
Data transferred: 26.73 MB
Response time: 1.35 secs
Transaction rate: 110.10 trans/sec
Throughput: 0.15 MB/sec
Concurrency: 148.32
Successful transactions: 19903
Failed transactions: 0
Longest transaction: 20.03
Shortest transaction: 0.01

NOTE: "Transaction rate" down, and "Longest trans" time is up (from 50 concurrent users), but no failed transactions. Still the top performer.

Summary

Rails performed much better than Symfony. And Django performed much better than Rails.

Comment
When connecting rails to Oracle the performance dropped to the extent it made any production use of the product useless.

Question
"when connecting rails to Oracle the performance dropped to the extent it made any production use of the product useless". Any idea what went wrong there?

Comment
I am very new to Rails and am still learning, but I am experienced in Oracle. I would bet performance degrades dramatically when Rails connects to Oracle as Rails does not use Bind Variables or cache prepared statements. Not using bind variables in Oracle is the single most common mistake. When running the load test connected to Oracle, does Oracle consume a lot of the CPU?
Its unfortunate, as until Rails handles Oracle correctly, its not really fit to be used on it, and I was really hoping to use it there!

Comment
re: Oracle – I speculate that the time necessary to build a connection to Oracle for every request is what kills the performance.

Statistics Question
Is it possible to repeat the tests with httperf instead of siege?

Request: Zed, I think you are quite possibly the best person to do this test. I have read your blog and your concerns re: the common mistakes people make when doing perf testing.

Can you PLEASE PLEASE PLEASE do a proper comparison ???

Zed: Look, go read about "power" in statistics. Specifically just read power.t.test from R's help pages. There's a dead simple calculation you can do to find out how many samples and sample runs you have to do to make this accurate. Running it for 30 minutes don't mean jack, you need runs of samples.

Source Question
Is it possible to get the source for each example?

Helma
Have you consider http://helma.org ?
features inclues
MVC
use JavaScript instead of Ruby,
compiled code to Java bycode for fast runtime performance
codeless mapping of application objects to database tables (Just like active record)
- caches query in memory

Well, this comparison proves that RoR is not the most performant framework. But I bet most RoR users already knew that because they have different priorities (e.g. agility). For me, it is enough to know that (performance-wise) RoR is not complete crap. I bet a C solution could pretty much outperform all three solutions. But only masochists would prefer such a solution. There is much more than pure performance to consider.
Much more interesting would be a comparison how long it took to write the app and how much effort is needed should new requirements arise. but I admit that it is almost impossible to have meaningful measurements for this.

Comment
Just because C will always be faster than Rails, it does not mean Rails' performance cannot be improved. It can, and perhaps this data will help. How long it took to write the demo is irrelevant in this context.

Question
I am afraid to say but i don't think the benchmark was done properly, i can't tell about Ruby on rails since i never tested it, but i can about Django and Symfony, and, i do not believe the testers did the deployment procedures in Symfony as described here: http://www.symfony-project.com/book/trunk/deployment
This will increase performance alot, i can't believe symfony got such a bad performance (after working with both symfony and django), it really looks like the tests were done using '_dev.php' wich is the development 'view' with extended logging and debugging wich decreases alot the framework performance. So question is, what was the complete Symfony setup used to do this benchmarks including the URL's in symfony used to do so.

Comment
Well, after reading better some lines of the above article regarding the benchmark, i've just reached 1 conclusion: The testers have no knowledge whatsoever to benchmark anything PHP related, i've just read this small note to reach this conclusion,
"NOTE: You can see there were very few successful transactions. Most were "500 – Internal Server Errors" and 192 failed to connect altogether. It looks like the 500 errors were caused by something with Mysql, because the dev interface returned: "connect failed Native Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock" "
FIY, that is caused by using persistent connections to MySQL databases, meaning, mysql will open inumerous childs, when it reaches it's childs limit doesn't allow any more connections untill the previous childs are closed. Clearly states the lack of knowledge of both PHP AND MySQL. I am still astonished with this sentence 'It looks like the 500 errors were caused by something with MySQL' and you guys quickly throw the fault to Symfony/PHP who can take this tests seriously when this kind of comments blatantly show the complete lacking of knowledge of what they're testing.
Ridiculous.

Comment

Aside from earlier comments, what exceptionally whacked about this comparison is how running Rails / mongrel behind a reverse proxy still gets it's butt kicked by mod_python – that shouldn't happen (at least in theory). This comparison at least needed to be done with mod_ruby or stick the others behind a reverse proxy.

Would expect mod_python (1st) / mod_ruby to win any flat race over mod_php – mod_php's interface to Apache sacrifices some performance here in return for "refresh" of state on every new request – so long as you don't do anything like attempt persistant db connections, without knowing what you're doing…

Oh – and for more fun, trying adding this to python http://psyco.sourceforge.net ;)

Comment

The benchmark is completely bullshit. For example django performs much better with python-fastcgi and Apache2. Or running django over the cherrypy WSGI Server is faster than mod_python too. Also enabling psyco gives you a huge performance improvement. And with Python2.5 another Performance Improvement.

Also the symfony benchmark seem strange. In my test installation symfony outperforms Rails easily. No idea what's wrong on the setup here but something seriously is.

I don't want to say that rails is bad, if you choose rails you know that the performance isn't the best but development is fun.

Comment by Cald

The person who mentioned Helma asked for this, and I thought somebody else might also be interested.

From the article RailsvVsDjango:

"In this paper, we compare the two frameworks from the point of view of a developer attempting to choose one of the two frameworks for a new project."

http://docs.google.com/View?docid=dcn8282p_1hg4sr9

Comment
There are a lot of complaints / rants about the efficacy of this test. For those people… if you can do better, then "just do it." It does not take genius, initiative, or knowledge to find fault. It does take at least one of the above to design and run a benchmark test.

It may well be that the test is flawed. But… we would be better served by better tests than flaming someone else's initiative and labor.

I say kudos to the people who designed and ran this test. You gave us something to think about. To the flamers and detractors… put up or shut up.

Comment by KurtStephens

Not sure if this belongs here…

This RubyInline hack took 15% off our app execution time.

Date uses Rational heavily, which calls Integer#gcd for every new Rational.

http://kurtstephens.com/node/34

Comment by Elmer Thomas

You should be able to improve Symfony performance with this:
http://blog.thembid.com/index.php/2007/04/05/build-scalable-web-20-sites-with-ubuntu-symfony-and-lighttpd/

Comment by Massimo

my tests show that a loop in Ruby is about 15 times slower than the same loop in Python. That was enough for me to drop Rails. I'd love you to benchmark Gluon (http://mdp.cti.depaul.edu) which should be even faster than Django because it allows you to byte-code the web app, including the templates, so there is no parsing or text manipulation in production mode. No other framework allows it.

Monday, November 19, 2007

Invest|2008年最有投资价值的20只牛股

2007年11月8日,《全球商业经典》杂志再次本着专业、负责的态度,通过金融专家的点评,精心选出2008年最有投资价值的20只牛股:(个股具体分 析详情见《20只股票分析》)  工商银行(601398) 股价预期:150元。入选理由:中国最大商业银行,溢价优势明显,估值偏低。  招商银行 (600036) 股价预期:650元。入选理由:股份制商业银行龙头,公司质地优秀,不良贷款率低,成长快速。  万科A(000002) 股价预期: 500元。入选理由:房地产行业龙头,土地储备丰富,公司治理水平第一,中国城市化进程的受益者。  中国平安(601318) 股价预期:1700元。 入选理由:中国龙头保险公司,寿险品种质地优秀,公司策略正确。  中国银行(601988) 股价预期:100元。入选理由:四大商业银行之一,拥有海 内外平台统一服务优势,价值低估。  五粮液(000858) 股价预期:600元。入选理由:白酒龙头,四季度销售旺季,股权激励方案即将实施。  深 发展A(000001) 股价预期:700元。入选理由:资本约束即将解除,主营业务盈利能力强,估值偏低。  中信证券(600030) 股价预期: 1500元。入选理由:在行业中具有一览众山小的地位,明年业务增长50%以上。  中国远洋(601919) 股价预期:10000元。入选理由:四季 度航运高峰,全球第一的干散货船队,BDI指标最大受益者。  振华港机(600320) 股价预期:405元。入选理由:全球集装箱订单排名第一,中国 少有的世界级龙头企业,盈利稳定。  建设银行(601939) 股价预期:105元。入选理由:四大商业银行之一,行业龙头,价值低估。  民生银行 (600016) 股价预期:300元。入选理由:资产质量好,激励制度完善,价值低估。  兖州煤业(600188) 股价预期:400元。入选理由: 公司质地优秀,下半年煤炭提价在即,煤变油技术产能预期好。  黄山旅游(600054) 股价预期:400元。入选理由:旅游消费资源垄断优势强大,经 营策略正确,激励机制即将出台。  中国人寿(601628) 股价预期:850元。入选理由:唯一央企寿险公司,投资收益巨大,渠道品牌强势。  兴业 银行(601166) 股价预期:1000元。入选理由:盈利增长能力强,派发预期良好,核心资本充足率高,公司质地优秀。  丽江旅游(002033)  股价预期:450元。入选理由:中国唯一拥有文化遗产、自然遗产、记忆遗产三项世界桂冠的国际旅游地,收益预期好。  中信银行(601998) 股价 预期:150元。入选理由:大股东集团优势明显,受益于大股东金融平台。投行业务前景好。  交通银行(601328) 股价预期:220元。入选理由: 人民币升值直接受益者,不良贷款率低,2008年是业绩转折点。  白云机场(600004) 股价预期:220元。入选理由:奥运会和世博会直接受益 者,价值低

Saturday, November 10, 2007

Stock|操盘感觉训练法

操盘感觉训练法

操盘必读:操盘感觉训练法

良好的盘感是投资股票的必备条件,盘感需要训练,通过训练,大多数人会进步。如何训练盘感,可从以下几个方面进行:

  一、坚持每天复盘,并按自己的选股方法选出目标个股。复盘的重点在浏览所有个股走势,副业才是找目标股。在复盘过程中选出的个股,既符合自己的 选股方法,又与目前的市场热点具有共性,有板块、行业的联动,后市走强的概率才高。复盘后你会从个股的趋同性发现大盘的趋势,从个股的趋同性发现板块。据 接触过吕梁的朋友称,吕梁绝对是位分析高手,盘面感觉堪称一流,盘面上除了一条3日均线就是光溜溜的k线――股道至简。

  二、对当天涨幅、跌幅在前的个股再一次认真浏览,找出个股走强(走弱)的原因,发现你认为的买入(卖出)信号。对符合买入条件的个股,可进入你的备选股票池并予以跟踪。

  三、实盘中主要做到跟踪你的目标股的实时走势,明确了解其当日开、收、最高、最低的具体含义,以及盘中的主力的上拉、抛售、护盘等实际情况,了解量价关系是否的正常等。

  四、条件反射训练。找出一些经典底部启动个股的走势,不断的刺激自己的大脑。

  五、训练自己每日快速浏览动态大盘情况。

  六、最核心的是有一套适合自己的操作方法,特别是适合自己。方法又来自上面的这些训练。

  复盘就是利用静态再看一边市场全貌,这针对你白天动态盯盘来不及观察、来不及总结等等情况,在收盘后或者定时你又进行一次翻阅各个环节,进一步 明确一下,明确那些股资金流进活跃,那些股资金流出主力在逃,大盘的抛压主要来自哪里,大盘做多动能又来自哪里,它们是不有行业、板块的联系,产生这些情 况原因是什么?那些个股正处于上涨的黄金时期,那些即将形成完美突破,大盘今日涨跌主要原因是什么等等情况,需要你重新对市场进行复合一遍,更了解市场的 变化。

  复盘的一般步骤是:

  1、看两市涨跌幅榜:

  (1)对照大盘走势,与大盘比较强弱,了解主力参与程度,包括其攻击、护盘、打压、不参与等情况可能,了解个股量价关系是否正常,主力拉抬或打压时动作、真实性以及目的用意。了解一般投资者的参与程度和热情。

  (2)了解当日k线在日k线图中的位置,含义。再看周k线和月k线,在时间上、空间上了解主力参与程度、用意和状态。

  (3)对涨幅前2版和跌幅后2版的个股要看的特别仔细。了解那些个股在悄悄走强,那些个股已是强弓之弩,那些个股在不计成本的出逃,那些个股正在突破启动,那些个股正在强劲的中盘,也就说,有点象人口普查,了解各部分的状态,这样才能对整个大盘的情况基本上了解大概。

  (4)在了解个股的过程中,把那些处于低部攻击状态的个股挑出来,仔细观察日K线、周K线、月K线所经历的时间和空间、位置等情况良好的,剔除 控盘严重的庄股和主力介入不深和游资阻击的个股,剩余的再看一下基本面,有最新的调研报告最好调出来看一下,符合的进入自己的自选股。

  看涨幅在前两版的个股,看他们之间有那些个股存在板块、行业等联系,了解资金在流进那些行业和板块,看跌幅在后的两板,看那些个股资金在流出, 是否具有板块和行业的联系,了解主力做空的板块。需要说明的看几板合适主要看当日行情的大小,好多看几板,差看前后两板就可以了。

  2、看自己的自选股(包括当日选入的):

  观察是不是按照自己预想的在走,检验自己的选股方法,有那些错误,为什么出错,找出原因,改进。看那些个股已经出现买点(买点自己定的,按照什么标准也是你自己定的)的个股,你要做一个投资计划,包括怎么样情况怎么买,买多少、多少价格、止损位设置等。

  3、看大盘走势:

  主要分析收阴阳的情况、成交量情况,与昨日相比是否怎么样的情况,整个量价关系是否正常,在日K线的位置、含义,看整个日K线整体趋势,判断是 否可以参与个股,能否出现中线波段,目前大盘处于哪一级趋势的那个阶段。看当日大盘波动情况,什么时候在拉抬、什么时候在打压,拉抬是那些股,打压又是那 些股,他们对大盘的影响力又是如何。看涨跌平个股家数,了解大盘涨跌是否正常。了解流通市值前10名个股的运况,以及对大盘的影响,如果不是大盘股影响大 盘,找出影响大盘的板块。了解大盘当日的高低点含义,了解大盘的阻力和支持位,了解大盘在什么位置有吸盘和抛压,了解那些个股在大盘打压之前先打压,那些 个股在大盘打压末期先止住启动。

  综合排名榜,市场各要素都展现在这里,那些个股在活跃,那些个股在出逃最强烈,那些个股在拉尾市勾当,那些在尾市打压制造恐慌假象,那些个股盘轻如燕,那些步履蹒跚,这是主力的照妖镜。

  别忘了还要关注其他市场和品种的情况,回购情况如何,国债情况如何,B股情况如何等等,他们反映的什么样的资金面以及对大盘的情况

  掌握基本要素和复盘熟练的要求后,你的盘面感觉肯定是不同的。反复训练后,可加快速度,翻阅个股也不必要看全部,看涨跌前后几版、权重股、自选股等就可以了。复盘是辛苦的,但只有苦尽才能甘来!

归档在: 股票交易

Finance|什么是PE,它有什么重要

PE就是PRICE EARNING RATIO,中文译为本益比。

PE的算法简单,我们只需要把一只股票的股价除以它的每股净利就可得到它的本益比PE。
(PE = PRICE / EARNING PER SHARE)

举个例子:

MIECO的股本是210million。1999年它的净盈利是21million。净盈利就是after tax profit。所以它的每股净利EARNING PER SHARE(EPS)就是0.10。

EPS = EARNING / NO. OF SHARES
EPS = 21 / 210
EPS = 0.10

23/2/2001它的股价是0.86令吉。

PRICE = 0.86

PE的算法就是:

PE = PRICE / EPS
PE = 0.86 / 0.10
PE = 8.6

所以它的本益比PE就是8.6。

PE是随着股价而变动的,股价上升PE就会随着上升,股价下跌PE就会随着下跌。

假设MIECO的股价上升到2.00令吉,它的PE就是:2.00/0.10=20。

假设MIECO的股价下跌到0.50令吉,它的PE就是:0.50/0.10=5。

如果我们想买股,PE是越低越好。PE低就代表股价便宜。

如果我们想卖股,PE是越高越好。PE高就代表股价昂贵。

有的时候股价纹风不动,PE也会变动的。例如:

MIECO的股价停留在0.86令吉,而它的2000年最新业绩却公布了。

假设它的EPS下降了一半,只剩0.05令吉。那么它的PE就会变成17.2。

PE = PRICE / EPS
PE = 0.86 / 0.05
PE = 17.2

假设它的EPS上升了一倍,达到0.20令吉。那么它的PE就会变成4.3。

PE = PRICE / EPS
PE = 0.86 / 0.20
PE = 4.3

所以我们要常常注意公司的业绩,尤其是公司公布业绩的时刻。有时我们需要自己算算PE,不能依赖报章的数据为根据,因为报章通常迟了几个月才更新它的数据。有时我们也要自己预测公司的PE。

例如MAYBANK刚刚公布它的半年业绩,它的最新EPS是半年0.30令吉。所以我们就可预测它的全年EPS将是0.60令吉。(0.30×2=0.60)

现在MAYBANK的股价大约为14.40令吉,所以它的PE应该是24。

PE = PRICE / EPS
PE = 14.40 / 0.60
PE = 24

那么多少的PE才是合理的呢?

依我个人的看法,只要它比定期存款的PE低就是合理的了。

定期存款也有它的PE吗?当然有。

那么现在定期存款的PE是多少?

今天定期存款的利息是4.50巴仙。1.00令吉的存款一年只能赚0.045令吉。

所以PRICE=1.00,EPS=0.045。

PE = PRICE / EPS
PE = 1.00 / 0.045
PE = 22.2

所以今天定期存款的PE就是22.2。

那么知道了合理的PE对我们就有所帮助吗?

当然。例如在1998年初,综合指数大约是700点,当时的定期存款利息却高达12.5巴仙。每1.00令吉的存款一年就能赚0.125令吉。它的PE就是8。(1.00/0.125=8)

当时KLCI的平均PE却是14.08。所以两者比较起来,股票就比定期存款昂贵了。我们只要知道股票是昂贵的,我们就知道该怎样做了。

那么今天KLCI的平均PE是多少呢?我们怎样获得这数据?

根据KLSE出版的月刊INVESTORS DIGEST,截至2000年12月KLCI的平均PE是16.46。所以跟定期存款的PE比较起来,现在的股票是便宜的了。

根据以上所述,1998年2月KLCI的PE是14,2000年12月KLCI的PE是16,那一个时候的股价才算便宜?

乍看起来14的PE是比16的PE来得便宜。其实不然,因为和当时的定期存款的PE比较起来,2000年12月的股价比较便宜。所以PE的用法一定要灵活,不能死板。

BJGROUP的股价是0.33令吉,EON的股价是8.00令吉。请问那一个的股价比较便宜?

如果单单看价钱当然是BJGROUP比较便宜。

但是如果用PE来衡量,EON的股价却远比BJGROUP来得便宜。

BJGROUP是亏钱的公司,根本就没有PE。(没有EPS就不能计算PE)

EON的EPS是2.10令吉,股价8.00令吉,所以它的PE就是3.8。

跟KLCI的平均PE(16)比较起来EON的PE(4)是太便宜的了。

结论:

本益比PE是用来衡量股票的价值。但是我们却要灵活应用,不能死板。我个人的看法是PE的妙用是预测未来的股价,所以未来的PE比过去的PE来得重要。如何预测未来的PE才是决定投资的成败关键。这又是一章长篇大论,留待下回我们再来研究。

Tuesday, November 6, 2007

Java|AN INTRODUCTION TO JSTL 1

AN   INTRODUCTION   TO   JSTL  
 (JSP  STANDARD TAG  LIBRARY)  
---------------------------------  

by  R.S.RAMASWAMY.  

(  published in DeveloperIQ  magazine—Oct-2004)
( comments on this article may be sent to:  ramrsr@rediffmail.com )

In this four-part tutorial on JSTL, the author  introduces the concept of tag-based programming and  discusses its merits and demerits,  with some simple illustrations.  

JSP Tutorials HomeTutorial Home | Part 1 | Part 2Part 3 | Part 4

Part-1  - JSTL   Basics.  
In the first part of this tutorial on JSTL, the author gives a brief introduction to JSTL and shows why and how it evolved .        

As J2EE programmers, we are familiar with Servlets , JSP   and JavaBeans.  Any JSP page should encapsulate the business logic in a bean and invoke it by using <jsp:useBean>  tag.  Till recently, a combination of Servlets, JSP and beans was the standard practice. But, the JCP realeased an API for enabling programmers to create custom tags and use them in their JSP pages. The difference between javabean and java custom tags was that, though both made use of java classes,  tags can be used by non-programmers also without  knowledge of Java programming, just as they would use html tags.( From a programmer's perspective,however, a much more important distinction is that tags are specific to the page in which they are created while javabeans are general. )

{{{  Back in  1998, a Web-Server Technology , known as ColdFusion , created by Allaire of Allaire Corporation, was very much in demand!. It was a purely tag-based language, using which page-authors can turn into programmers overnight. The tags were so powerful and simple to use! There is a separate lesson on using ColdFusion for typical web-based database opeartions, elsewhere in this edition, just to indicate the source of inspiration of the tag library idea, of the JSTL. To this day, ColdFusion is unbeatable, in its power,speed, ease of use and productivity. However, among the various web-server technologies ( namely

ASP, Servlets, JSP,Perl,PHP , ColdFusion &

ASP.net), CF is the only technology that is not free!And perhaps for this reason, it is no longer popular in Indian environment, though it is said to be very much in vogue still, in US!

MacroMedia of 'Flash fame' purchased ColdFusion .There was even a tutorial on MacroMedia ColdFusion Exprsess in DeveloperIQ., a few months back.It is interesting to make a comparison of the CF tags approach and the JSTL approach., especially , in DataBase operations.Readers are requested to read the lesson on ColdFusion,in this edition, after covering sql tags in JSTL , in the fourth part of this tutorial..}}}

       To resume,the release of the TagLibrary API, triggered   a lot of   activity and hundreds of tags were introduced by the java community, some of them 'open' and a few 'proprietary'.  This led to a lot of confusion in code maintenance, because knowledge of Java was no longer sufficient to understand and interpret a given jsp page using non-standard tags .The JCP had unwittingly   introduced elements of confusion by the JSP-Custom-Tag specification.

       To correct this problem, Sun and JCP, initiated   the JSP-Standard Tag Library (JSTL) project.  Though there are a number of popular and powerful tag-libraries, it is always better for j2ee coders to  adopt the JCP standard because, it is likely to be merged into the core specification of Java langauage itself , in future. (That yardstick may be valid for all creations, in Java world. Splintering of the Java platform due to' hyper-active creativity'  without the corresponding discipline to get it through a standards body ,is the greatest threat, looming large in the Java-horizon.

Too frequent revisions and additions, that too without caring for backward compatibility,are not conducive to programmer productivity  and the net result is that programmers spend ,in learning new twists in grammar,  their  precious time  which should have been spent more usefully in applying that grammar in solving business-logic problems and acquiring proficiency in the chosen application-domain. While, tag library is sometimes very elegant and simple to use, it defeats the very purpose if the tags  are not standard tags and if there is proliferation of non-standard tags.It is for this reason that JSTL merits our serious study and adoption.

JSTL is a quite recent  development. It was only in 2003, that the official version 1.1 was released and now incorporated into  JSP-2.

   According to the latest position, the JCP is suggesting that a JSP page should be completely free from any trace of Java code!  So, programmers who were writing their JSP using Javabeans and scriptlets , may not be able to carry on in their old style as,  to prevent programmers from introducing scripting sections in their pages, there is a  provision  for turning off scriptlets altogether from a jsp page. If that happens ,all our knowledge of Java coding will be of little use in creating a jsp page, though such knowledge may be useful in creating beans and other types of java programs.

    It is thus very important for  J2EE students, to understand the trend and get to know the techniques, advantages and limitations of  tag libraries...In a way, a study of JSTL is almost synonymous  with a study of the latest version of JSP (ie) JSP2.0 .

---------------------------------------

  Without an introductory demo for each of these types, it may be difficult to appreciate the significance of the above lines. So we will now give simplest illustration.

==============================================

[It is presumed that readers are conversant with basic Servlets & JSP techniques and executing them in Tomcat environment. In case of any difficulty, they can refer to back issues of this magazine ( from Oct-2003  onwards) and gain access to a number of lessons for illustrations.]

Servlets are full-fledged java-classes and so are very powerful. But, when we want to create a dynamicalay-generated web-page using servlets, it becomes difficult and clumsy.Let us consider a very simple example.

The user fills up text in html form with his name and submits the form,to the servlet. The servlet reads the data , appends a greeting and sends it back to the user.

-----------------------------------------------

  We begin with a simple html form;

  //   greeting.htm

=============

  <html>  <body>

  <form   method=post 
 
action= 'http://localhost:8080/servlet/greeting'>
 
<input   type=text   name='text1'> 
 
<input   type=submit> 
  
</form> 
  
</body> 
  
</html>

-----------------------------------------------------------------------------
  (relevant section of greeting.java servlet)
//  greeting.java ( code-snippet only)
 public void doPost(HttpServletRequest  req,
                                    HttpServletResponse  resp) 
       
throws  ServletException,IOException {

        resp.setContentType("text/html");
        PrintWriter  out = resp.getWriter();  
        //-------------------------------  
        String  s = req.getParameter("text1");
        out.println("<html><body  bgcolor=yellow>");  
        out.println("we  welcome"+",<br>");  
        out.println (s);  
        out.println("</body> </html>");  
}

-----------------------------------------------

It will be noticed that  we have to write so many 'out.println' statements. This makes the page unreadable.( If String-buffer is used , we can do it with just a single out.println , but  forming the correct string may pose difficulties).

  It is to solve this problem   that JSP was developed five years back(1999).While a servlet   interposes HTML   in java code, JSP interposes java-code in HTML, as some authors correctly observe..( in this case, we have to modify the action field in html form, so that it refers to the following  greeting1.jsp).Student readers will know about 'delimiters' ( <%).in ASP.

This is the same as in  JSP. Only the syntax is slightly different.In JSP parlance, the code within delimiters is known as 'scriptlet'.( see greeting1.jsp)

-----------------------------------------------

//  greeting1.jsp

  <html>

  <body     bgcolor=yellow> 
          
 <%  
            
String   s = request.getParameter("text1"); 
           
out.println("we welcome"+<br>); 
            
out.println(s); 
           
 %> 

  
</body> 
 
</html>
  -----------------------------------------------

 Some coders prefer to use expressions.

What is an 'expression'? It is a method of sustituting request-time values in html page. ( see greeting2.jsp). Carefully note that there is no semi-colon after ("text1").

-----------------------------------------------  //  greeting2.jsp

     <html> 
     <body    bgcolor=yellow>    
 
    we  welcome <br> 
  
  <%=  request.getParameter("text1") %>       
   
</body> 
   
</html>

-----------------------------------------------

The third variant is to use a javabean to encapsulate the business-logic. We  develop a jsp-bean as follows:

------------------------------------------

//   greeter.java  
//==============

package    ourbeans;

public class  greeter {

    public greeter()  { 
   
public  String   greetme(String  s)    
        
return  "we welcome..."+s; 
   
}  
}
-------------------------------------------

This source file is compiled and the class-file is copied to :

'e:\tomcat5\webapps\root\WEB-INF\classes\ourbeans'

 

(Carefully note that WEB-INF folder name should be in capital letters).

( Anytime, a new class is placed in Tomcat, we should remember to restart the server).
We can now   write our JSP code as follows:
------------------------------------------------

// greeting3.jsp

<html>  
<body>  

<jsp:useBean    id='bean1'  class='ourbeans.greeter'> 

  
<%  

     String  s = request.getParameter ("text1");  
     String      r =     bean1.greeteme(s);  
     out.println(r); 

  
%>
</body>  
</html>
----------------------------------------------
We are now entering    JSTL    zone.  

   How exactly we should proceed to  instal   JSTL, we will take up shortly. For the moment, we are just getting familiar with the required syntax.   We begin with taglib directive.

<%@  taglib        prefix="c"   uri="http://java.sun.com/jstl/core"  %>        

The directive says that we are using 'core' tags and the prefix will be 'c'.  If we want to assign the value 'sam' to a variable 'a' and then print it, the JSTL code will be

 <c:set    var="a"     value="sam" />

 <c:out   value="${a}"   />

-----------------------------------

The Dollar sign  & brace will be familiar ground for Perl programmers.   In JSTL & JSP-2, it is  known as EL ( Expression Language).

==============================================

To consider another example,  In servlet & jsp, we write:

 String s = request.getParameter("text1");

to collect the input from the user.

The same job is done in    JSTL   by:
<c:set  var="s" value ="${param.text1}" >

==================================

 With these brief hints, it should not be difficult to understand the

following   JSP  page written  by   using JSTL core-tags.

-----------------------------------------------

//   greeting4.jsp   (  uses  JSTL)

===========

<%@  taglib     prefix="c" uri="http://java.sun.com/jstl/core"  %> 
<html>  
<body>  
<c:set var=s  value="${param.text1}" />  
We welcome<br>  
<c:out      value="${s}" />  
</body>  
</html>

-----------------------------------------------

In the previous  examples, there was java code in a few lines atleast. But, in the  JSTL  example, we find that there are only tags and no java    scriptlets. This is the avowed objective of the JSTL  initiative,

under the auspices of Java Community Project! Why?   This enables , clean separation of  Page author's role and Logic programmers' role. Thus maintenance becomes easy.

===============================================

  There are five groups under which the JSTL tags have been organized.

     They are as follows:

          1)   core

          2)   xml

          3)   sql

          4)   formatting

          5)   functions.

-----------------------------------------------     The most difficult part is  to set up Tomcat  so that it executes JSTL.   There are some basic requirements, before we can experiment and study the use of JSTL.All that we have studied in using Tomcat for servlets and JSP may not be sufficient to learn JSTL, because, jstl library is not built into Tomcat5  even, as yet.

    Without hands-on experimention, JSTL could be confusing and strange,because of the   fact that it is very  recent  . But in coming months, support will be built into Tomcat and we won't have to worry about installing the JSTL  libraries inside Tomcat. But, as it is, we have to learn how to set up the necessary development environment..

   So , how do we go about , placing the JSTL libraries in tomcat?

------------------------------------------------    The best solution is to get JWSDP1.3.

   This is Java Web Service Development' Pack.

( Carefully note the version , however!).

   It is good to start with this because, it contains a lot of valuable software , including the latest and greatest from  JCP, (ie) JSF

(Java Server Faces).... which may soon replace Struts
We unzip         the jwsdp1.3  and install     it in C: drive. There   are  a number of folders like JAXP, JAXR, JAXB,JAX-RPC, JSF, JSTL etc. in the JWSDP pack.

 For the present, we are interested in JSTL folder only. If we expand the JSTL folder, we find  four   sub folders :

     a)  docs

     b)  lib

     c)  samples

     d)  tld  (  tag library descriptors)

   When we look into the 'lib' folder, we find      two jar files:

    a)  standard.jar

    b)   jstl.jar

We should copy  these two jar files into  :

 'e:\tomcat5\webapps\root\WEB-INF\lib'

-----------------------------------------------

( Remember to restart the Tomcat server). That is all that is required to use   JSTL. !  

The included taglibrary descriptors do not have to be placed in the WEB-INF folder.These files are already  included in the /META-INF folder of the jstl.jar and so will be automatically loaded by Tomcat, when it is restarted.

***********************************************

 ( we are using tomcat5 & jdk1.4.2)

 ( the results are not  ensured         for other environments.).( however, we adopted the same method in Tomcat4.1 with jdk1.41 and got correct functioning.)

===============================================

    The JSTL    folder contains a sub-folder named 'tld'.  There will be a number of tld files there such as

c.tld,    ( core)

x.tld,    (xml)

fmt.tld,  (format)

sql.tld &  (sql)

fn.tld.    (functions)

------------------------------

Some authors say that we should copy these tld files  to ..

..:\tomcat5\webapps\root\WEB-INF   folder.

 A few others , say that there is automatic detection and so it is  not necessary. We  chose not to copy the tld files into

e:\tomcat5\webapps\root\WEB-INF    folder !

We found that the programs works well. No problem!  

When we study the web.xml file in e:\tomcat\webapps\root\WEB-INF   folder, we find that it follows  DTD and not Schema.

( DTD  stands for Document -Type- Definition).

( Schema  serves the same purpose but is in XML format and is more powerful). ( The default is DTD ).

   This point is very important. The default allows us to use EL,(Expression Language) but by using <c:out   value="${s}" syntax.

If we modify the DTD into the prescribed J2EE schema , we can directly print as   ${s}. This requires very careful handling and we take it up later.

   For the present , let us not tamper with the DTD. or the web.xml file.

In the next part of this tutorial, we study the tags available in the JSTL-core library.

JSP Tutorials HomeTutorial Home | Part 1 | Part 2Part 3 | Part 4

Monday, November 5, 2007

Game|Pattern Analysis of MegaMillions Lottery Numbers

Pattern Analysis of MegaMillions Lottery Numbers - Article - OmniNerd

Everyone wants to get rich, especially if it only costs them $1. Fortunately, many local state governments host lotteries, allowing their constituents to donate cash into the budget in hopes of winning a multi-million dollar prize. In practice, most lottery drawings consist of a series of balls drawn randomly from a chamber which should guarantee a fair opportunity for everyone to win. Theories of rigged lotteries and fraud, however, run rampant across the Internet.

Sunday, November 4, 2007

Wisdom|兵法三十六计 09计 【敌战】隔岸观火

09计 【敌战】隔岸观火

09计 【敌战】隔岸观火
送交者: 东京老虎 [进士☆] 于 October 27, 2007 23:55:51 已读 339
天天养生堂
数百种美国名厂保健品,超低价直销全球!
蜜糖交友中心
海外孤身?强大搜索功能,轻松找到意中人!
免费网上炒汇:
送您$10,000虚拟资金,免费体验真实汇市

回答: ┊◆┊┊◆┊┊◆┊兵法三十六计┊◆┊┊◆┊┊◆┊ 由 东京老虎 于 October 27, 2007 23:46:36:

阳乖序乱①,明以待逆②。暴戾恣睢③,其势自毙。顺以动豫,豫顺以动④。 www.6park.com

①阳乖序乱:阳,指公开的。乖,违背,不协调。此指敌方内部矛盾激化,以致公开地表现出多方面秩序混乱、倾轧。 www.6park.com

②阴以待逆:阴,暗下的。逆,叛逆。此指我暗中静观敌变,坐待敌方更进一步的局面恶化。 www.6park.com

③暴戾恣睢:戾,凶暴,猛烈。睢,任意胡为。 www.6park.com

④顺以动豫, 豫顺以动: 语出《易经.豫》卦。豫,卦名。本卦为异卦相叠(坤下震上)。本卦的下卦为坤为地,上卦为震为雷。是雷生于地,雷从地底而出,突破地面,在空中自在飞腾。《豫卦》的《彖》辞说"豫,刚应而志行,顺以动。" 意即豫卦的意思是顺时而动,正因�ヘ灾�馐撬呈倍����蕴斓鼐湍芩婧推湟猓? 做事就顺当自然。 www.6park.com

此计正是运用本卦顺时以动的哲理,说坐观敌人的内部恶变,我不急于采取攻逼手段,顺其变,"坐山观虎斗",最后让敌人自残自杀,时机―到而我即坐收其利,一举成功。古人按语说:乖气浮张,逼则受击,退则远之,则乱自起。昔袁尚、袁熙奔辽东,众尚有数千骑。初,辽东太守公孙康,恃远不服。及曹操破乌丸,或说曹遂征之,尚兄弟可擒也。操曰:"吾方使斩送尚、熙首来,不烦兵矣。"九月,操引兵自柳城还,康即斩尚、熙,传其首。诸将问其故,澡日:"彼素畏尚等,吾急之, 则并力; 缓之,则相图,其势然也。"或曰:此兵书火攻之道也,按兵书《火攻篇》前段言火攻之法,后段言慎动之理,与隔岸观火之意,亦相吻合。 www.6park.com

按语提到《孙子・ 火攻篇》,认为孙子言慎动之理,与隔岸观火之意,亦相吻合。这是很正确的。在《火攻篇》后段,孙子强调,战争是利益的争夺,如果打了胜仗而无实际利益,这是没有作用的。所以,"非利不动,非得(指取胜)不用,非危不战,主不可以怒而兴师,将不可以愠(指怨愤、恼怒)而致战。合于利而动,不合于利而止。"所以说一定要慎用兵,戒轻战。战必以利为目的。当然,隔岸观火之计,不等于站在旁边看热闹,一旦时机成熟,就要改"坐观"为"出击",以取胜得利为目的。 www.6park.com

隔岸观火,就是"坐山观虎斗","黄鹤楼上看翻船"。敌方内部分裂,矛盾激化,相互倾轧,势不两立,这时切切不可操之过急,免得反而促成他们暂时联手对付你。正确的方法是静止不动,让他们互相残杀,力量削弱,甚至自行瓦解。 www.6park.com

东汉末年,袁绍兵败身亡,几个儿子为争夺权力互相争斗,曹操决定击败袁氏兄弟。袁尚、袁熙兄弟投奔乌桓,曹操向乌桓进兵,击败乌既,袁氏兄弟又去投奔辽东太守公孙康。曹营诸将向曹操进君,要一鼓作气,平服辽东,捉拿二袁。曹操哈哈大笑说,你等勿动,公孙康自会将二袁的头送上门来的。于是下令班师,转回许昌,静观辽东局势。公孙康听说二袁归降,心有疑虑。袁家父子一向都有夺取辽东的野心,现在二袁兵败,如丧家之犬,无处存身,投奔辽东实为迫不得已。公孙康如收留二袁,必有后患,再者,收容二袁,肯定得罪势力强大的曹操。但他又考虑,如果曹操进攻辽东,只得收留二袁,共同抵御曹操。当他探听到曹操已经转回许昌,并无进攻辽东之意时,认为收容二袁有害无益。于是预设伏兵,召见二袁,一举擒拿,割下首级,派人送到曹操营中。曹操笑着对众将说,公孙康向来俱怕袁氏吞并他,二袁上门,必定猜疑,如果我们急于用兵,反会促成他们合力抗拒。我们退兵,他们肯定会自相火并。看看结果,果然不出我料。 www.6park.com

战国后期,秦将武安君白起在长平一战,全歼赵军四十万,赵国国内一片恐慌。白起乘胜连下韩国十七城,直逼赵国国都邯郸,赵国指日可破。赵国情势危急,平原君的门客苏代向赵王献计,愿意冒险赴秦,以救燃眉。赵王与群臣商议,决定依计而行。 www.6park.com

苏代带着厚礼到咸阳拜见应侯范睢,对范睢说:"武安君这次长平一战,威风凛凛,现在又直逼邯郸,他可是秦国统一天下的头号功臣。我可为您担心呀!您现在的地位在他之上,恐怕将来您不得不位居其下了。这个人不好相处啊。"苏代巧舌如簧,说得应侯沉默不语。过了好一会儿,才问苏代有何对策。苏代说:"赵国已很衰弱,不在话下,何不劝秦王暂时同意议和。这样可以剥夺武安君的兵权,您的地位就稳如泰山了。" www.6park.com

范睢立即面奏秦王。"秦兵劳苦日久,需要修整,不如暂时宣谕息兵,允许赵国割地求和。"秦王果然同意。结果,赵国献出六城,两国罢兵。 www.6park.com

白起突然被召班师,心中不快,后来知道是应侯范睢的建议,也无可奈何。两年后,秦王又发兵攻赵,白起正在生病,改派王陵率十万大军前往。这时赵国已起用老将廉颇,设防甚严,秦军久攻不下。秦王大怒,决定让白起挂帅出征。白起说: "赵国统帅廉颇,精通战略,不是当年的赵括可比;再说,两国已经议和,现在进攻,会失信于诸侯.所以,这次出兵,恐难取胜。"秦王又派范睢去动员白起,两人矛盾很深,白起便装病不答应。秦王说:"除了白起,难道秦国无将了吗?"于是又派王陵攻邯郸,五月不下。秦王又令白起挂帅,白起伪称病重,拒不受命。秦王怒不可遏,削去白起官职,赶出咸阳。这时范睢对秦王说:"白起心怀怨恨,如果让他跑到别的国家去,肯定是秦国的祸害。"秦王一听,急派人赐剑白起,令其自刎。可怜,为秦国立下汗马功劳的白起,落到这个下场。 www.6park.com

当白起围邯郸时,秦国国内本无"火",可是苏代点燃范睢的妒忌之火,制造秦国内乱,文武失和。赵国隔岸观火,使自己免遭灭亡。

Wisdom|兵法三十六计 08计 【敌战】暗渡陈仓

08计 【敌战】暗渡陈仓

08计 【敌战】暗渡陈仓
送交者: 东京老虎 [进士☆] 于 October 27, 2007 23:55:10 已读 326
天天养生堂
数百种美国名厂保健品,超低价直销全球!
蜜糖交友中心
海外孤身?强大搜索功能,轻松找到意中人!
免费网上炒汇:
送您$10,000虚拟资金,免费体验真实汇市

回答: ┊◆┊┊◆┊┊◆┊兵法三十六计┊◆┊┊◆┊┊◆┊ 由 东京老虎 于 October 27, 2007 23:46:36:

示之以动①,利其静而有主,益动而巽②。 www.6park.com

①示之以动:示,给人看。动,此指军事上的正面佯攻、佯动等迷惑敌方的军事行动。 www.6park.com

②益动而巽:语出《易经・益》卦。益,卦名。此卦为异卦相叠(震下巽上)。上卦为巽,巽为风;下卦为震,震为雷。意即风雷激荡,其势愈增,故卦名为益。与损卦之义,互相对立,构成一个统一的组纷。《益卦》的《彖》辞说:"益动而巽,日进无疆。"这是说益卦下震为雷为动,上巽为风为顺,那么,动而合理,是天生地长,好处无穷。 www.6park.com

此计是利用敌人被我"示之以动"的迷惑手段所蒙蔽,而我即乘虚而入,以达军事上的出奇制胜。 www.6park.com

古人按语说:奇出于正,无正不能出奇。不明修栈道,则不能暗渡陈仓。昔邓艾屯白水之北;姜维遥廖化屯白水之南,而结营焉。艾谓诸将日:"维令卒还,吾军少,法当来渡,而不作桥,此维使化持我,令不得还。必自东袭取洮城矣。"艾即夜潜军,径到洮城。维果来渡。而艾先至,据城,得以不破。此则是姜维不善用暗渡陈仓之计;而邓艾察知其声东击西之谋也。 www.6park.com

这则按语讲出了"奇"、"正"的辩证关系。奇正相互对立,又相互联系。孙子田:"凡战者,以正合,以奇胜。"所谓"正",指的是兵法中的常规原则;所谓"奇",指的是与常规原则相对而言的灵活用兵之法。其实,奇正也可以互相转化。比如说,"明修找通,暗渡陈仓",写入兵书,此法可以说由奇变为正,而适时的正面强攻又可能转化为奇了。邓艾识破姜维"暗渡陈仓" www.6park.com

之计,认定姜维派廖化屯白水之南,不过是想迷惑自己,目的是袭取洪城,等姜淮偷袭洪城时,邓艾已严阵已待了。邓艾懂得兵法中奇正互变的道理,识破姜维之计。由此可见,对于熟悉兵法的人来说,战场上千变万化,使用各种计谋,必须审时度势,机械搬用某种计谋,是难以成功的。 www.6park.com

暗渡陈仓,意思是采取正面佯攻,当敌军被我牵刺而集结固守时,我军悄悄派出一支部队迂回到敌后,乘虚而入,进行决定性的突袭。 www.6park.com

此计与声东击西计有相似之处,都有迷惑敌人、隐蔽进攻的作用。二者的不同处是:声东击西,隐蔽的是攻击点;暗渡陈仓,隐蔽的是攻击路线。 www.6park.com

此计是汉大将军韩信创造。"明修栈道,暗渡陈仓"是古代战争史上的著名成功战例。 www.6park.com

秦朝末年,政治腐败,群雄并起,纷纷反秦。刘邦的部队首先进入关中,攻进咸阳。势力强大的项羽进入关中后,逼迫刘邦退出关中。鸿门宴上,刘邦险些丧命。刘邦此次脱险后,只得率部退驻汉中。为了麻痹项羽,刘邦退走时,将汉中通往关中的栈道全部烧毁,表示不再返回关中。其实刘邦一天也没有忘记一定要击败项羽,争夺天下。 www.6park.com

公元前206年, 已逐步强大起来的刘邦,派大将军韩信出兵东征。出征之前,韩信派了许多士兵去修复已被烧毁的栈道,摆出要从原路杀回的架势。关中守军闻讯,密切注视修复栈道的进展情况,并派主力部队在这条路线各个关日要塞加紧防范,阻拦汉军进攻。韩信"明修栈道"的行动,果然奏效,由于吸引了敌军注意力,把敌军的主力引诱到了栈道一线,韩信立即派大军绕道到陈仓(今陕西宝鸡县东)发动突然袭击,一举打败章邯,平定三秦,为刘邦统一中原迈出了决定性的一步。一般来说,一个将领实施某一计谋取成功之后,敌方会吸取教训,防止再次上当。因此,故伎重演,难度很大。古代军事奇才韩信,二施"暗渡陈仓"的计谋,玩弄敌人于股掌之上,堪称一绝。楚汉相争,各路诸侯,自知力量不敌刘邦、项羽,他们密切注意战争动向,寻找靠山。西魏王豹,本已投靠刘邦,后见汉兵受挫,就转而投靠项羽,联楚反汉。大将军韩信举兵攻打西魏,大军进至黄河渡口临晋关(今陕西大荔东)。西魏王豹派重兵把守临晋关对岸的蒲坂(今山西永济西),凭借黄河天险,紧守度日,封锁临晋关河面,森严壁垒。 www.6park.com

韩信深知,如果从临晋关渡河,损失太大,难以成功。他决定再施"暗渡陈仓" 的计谋。他佯装准备从临晋关渡河决战,调集人马,赶造船只,派人沿黄河上游察看地形。经过认真调查韩信决定从黄河上游夏阳(今陕西韩城南)渡河,那里地势险要,魏兵守备空虚。韩信一面命大军向夏口调集,一面佯装从临晋关渡河,派兵丁擂鼓呐喊,推船入水,作出强攻的样子。魏军无论如何也没想到,就在汉军佯装大举强渡的时候,汉军已在韩信率领下从夏阳渡河后,直取魏都平阳(今山西临汾),等到西魏王豹得到消息,派兵堵截汉军,已经来不及了。汉军生擒西魏王豹,占领了西魏。 www