Tuesday, September 20, 2011

Let's Play with Symfony 1.2 and Doctrine

It's been quite a long time I didn't give a go to Doctrine, so as it's gonna be bundled by default in with the upcoming 1.2 release of symfony, I thought it was a good occasion to play with it.

So let's checkout the 1.2 SVN branch of symfony and create a test project with a main application[1]:

 $ mkdir sf12test && cd sf12test $ mkdir -p lib/vendor $ svn co http://svn.symfony-project.com/branches/1.2 lib/vendor/symfony $ php lib/vendor/symfony/data/bin/symfony generate:project sf12test $ ln -s ../lib/vendor/symfony/data/web/sf web/sf $ ./symfony generate:app main

Create a webserver vhost pointing to the web folder of the project directory. I've already explained plenty of times how to achieve this step.

Now, let's enable the sfDoctrinePlugin and disable the Propel one by editing the setup() method of theconfig/ProjectConfiguration.class.php file:

  php   public function setup()   {     $this->disablePlugins('sfPropelPlugin');     $this->enablePlugins('sfDoctrinePlugin');   } 

You can list the available tasks running this simple command:

 $ ./symfony list doctrine

Managing the Database Schema

First, configure your config/databases.yml file to set the database connection parameters. If you want to quick test Doctrine, use a local SQLite db, like this:

  yaml all:   doctrine:     class:    sfDoctrineDatabase     param:       dsn:    sqlite://<?php echo dirname(__FILE__).'/../data/data.db' ?> 

We're going to make a very simple weblog application, so let's configure our database schema. We can do it in YAML[2], so fire up your favorite editor/IDE and edit a brand new config/doctrine/schema.yml:

  yaml BlogPost:   actAs:     Sluggable:       fields:       [title]     Timestampable:   columns:     title:          string(255)     body:           clob     author:         string(255)  BlogComment:   actAs:            [Timestampable]   columns:     blog_post_id:   integer     author:         string(255)     email:          string(255)     content:        clob   relations:     BlogPost:       class:        BlogPost       local:        blog_post_id       foreign:      id       foreignType:  many       type:         one 

Note that Doctrine offers several pretty cool features including native behaviors (timestampable and slugable are used here).

Now, create a data/fixtures folder and put a data.yml file in, containing some test data in YAML format:

  yaml BlogPost:   p1:     title: My first post     body: |       This is cool.     author: NiKo     created_at: "<?php echo date('Y-m-d H:i:s', time() - 86400) ?>"   p2:     title: My second post     body: |       This is still cool.     author: NiKo     created_at: "<?php echo date('Y-m-d H:i:s', time() - 7200) ?>"   p3:     title: Third post     body: |       Is this one cool?     author: Roger Hanin     created_at: "<?php echo date('Y-m-d H:i:s') ?>"  BlogComment:   c1:     BlogPost: p3     author: John     email: john@doe.com     content: Hey, you're right there.     created_at: "<?php echo date('Y-m-d H:i:s', time() - 86400) ?>"   c2:     BlogPost: p3     author: Paul     email: paul@doe.com     content: Nope, he's not.     created_at: "<?php echo date('Y-m-d H:i:s') ?>" 

Okay, now run the command below to generate the needed files, create the database and fill it with the data fixtures:

 $ ./symfony doctrine:build-all-load

We can run several DQL queries in command line to check if everything is fine. DQL is very powerful, and compatible with a lot of RDBMS. You'll find more information on DQL on the doctrine website.

For example, to find all blog posts:

 $ ./symfony doctrine:dql "From BlogPost p" found 3 results -   id: '21'   title: 'My first post'   body: "This is cool.\n"   author: NiKo   slug: my-first-post   created_at: '2008-10-29 15:14:25'   updated_at: '2008-10-30 15:14:25' -   id: '22'   title: 'My second post'   body: "This is still cool.\n"   author: NiKo   slug: my-second-post   created_at: '2008-10-30 13:14:25'   updated_at: '2008-10-30 15:14:25' -   id: '23'   title: 'Third post'   body: "Is this one cool?\n"   author: 'Roger Hanin'   slug: third-post   created_at: '2008-10-30 15:14:25'   updated_at: '2008-10-30 15:14:25' 

Another example, to find informations about the blog post with slug third-post and its associated comments:

 $ ./symfony doctrine:dql "Select p.title, p.author, c.author, c.content From BlogPost p, p.BlogComment c Where p.slug = 'third-post' Group by c.id" found 3 results -   id: '23'   title: 'Third post'   author: 'Roger Hanin'   BlogComment: [{ id: '15', author: John, content: 'Hey, you''re right there.' }, { id: '16', author: Paul, content: 'Nope, he''s not.' }] 

Put the Query Logic in the Model

The Model part of any MVC architecture must contains the business data and associated logic. In other words, these data and logic should never be handled anywhere else, to decouple your components at max. So we'll add some query methods in thelib/model/doctrine/BlogPostTable.class.php file, which represents our blog_post table and available operations on it:

  php <?php class BlogPostTable extends Doctrine_Table {   public function getAll()   {     return Doctrine_Query::create()->       select('p.title, p.slug, p.body, p.author, p.created_at, count(c.id) numcomments')->       from('BlogPost p, p.BlogComment c')->       orderBy('p.created_at DESC')->       groupBy('p.id')->       execute();   }    public function getOneBySlug($slug)   {     $posts = Doctrine_Query::create()->       from('BlogPost p')->       leftJoin('p.BlogComment c')->       where('p.slug = ?')->       orderBy('c.created_at ASC')->       limit(1)->       execute(array($slug));      return isset($posts[0]) ? $posts[0] : null;   } } 

A Weblog is About Web Interface, uh?

Okay, let's add pretty controllers and templates to give some life to our blog. First, generate a post module in the main app:

 $ ./symfony generate:module main post

Then, edit the apps/main/modules/post/actions/actions.class.php file:

  php <?php class postActions extends sfActions {   public function executeIndex($request)   {     $this->posts = Doctrine::getTable('BlogPost')->getAll();   }      public function executeShow($request)   {     $this->post = Doctrine::getTable('BlogPost')->getOneBySlug($slug = $request->getParameter('slug'));     $this->forward404Unless($this->post, 'No post with slug=' . $slug);     $this->comments = $this->post->getBlogComment();   } } 

We should have display templates too. The first one will show the posts list, inapps/main/modules/post/templates/indexSuccess.php:

  php <?php foreach ($posts as $post): ?>   <?php include_partial('post/post', array('post' => $post, 'numComments' => $post->getNumcomments())) ?>   <hr/> <?php endforeach; ?> 

Note that we must create the _post partial template, in apps/main/modules/post/templates/_post.php:

  php <h2><?php echo link_to($post->getTitle(), 'post/show?slug='.$post->getSlug()) ?></h2> <p>   <small>Posted by <?php echo $post->getAuthor() ?> on <?php echo $post->getCreatedAt() ?>   <?php if (isset($numComments)): ?>     - <?php echo $numComments ?> comments   <?php endif; ?>   </small> </p> <?php echo $post->getBody(ESC_RAW) ?> 

The other main template will display one post and its comments, in apps/main/modules/post/templates/showSuccess.php:

  php <?php include_partial('post/post', array('post' => $post)) ?>  <h2>Comments</h2> <?php if (!count($comments)): ?>   <p>No comment yet.</p> <?php else: ?> <?php foreach ($comments as $comment): ?>   <p><small>By <?php echo $comment->getAuthor() ?> on <?php echo $comment->getCreatedAt() ?></small></p>   <blockquote><?php echo $comment->getContent() ?></blockquote> <?php endforeach; ?> <?php endif; ?> 

That's it. A rough but functional weblog if you lauch your browser to yourhost/main_dev.php/post/index:

step2.png

And if you click a post title:

step1.png

Good News, the Forms Framework Works with Doctrine Too

Symfony 1.1 introduced the new forms framework, and good news, Doctrine can take part of it. So maybe you've already noticed it, we have form classes generated already, in the lib/form/doctrine folder of the project.

So let's add a neat commenting system to our blog, by first editing the lib/form/doctrine/BlogCommentForm.class.php file:

  php <?php class BlogCommentForm extends BaseBlogCommentForm {   public function configure()   {     unset($this['id'], $this['created_at'], $this['updated_at']);          $this->widgetSchema['blog_post_id'] = new sfWidgetFormInputHidden();          $this->validatorSchema['author']  = new sfValidatorString(array('min_length' => 3));     $this->validatorSchema['email']   = new sfValidatorEmail();     $this->validatorSchema['content'] = new sfValidatorString(array('min_length' => 5));   } } 

Now, use the form in the executeShow() method of our controller:

  php <?php // ...   public function executeShow($request)   {     $this->post = Doctrine::getTable('BlogPost')->getOneBySlug($slug = $request->getParameter('slug'));     $this->forward404Unless($this->post, 'No post with slug=' . $slug);     $this->comments = $this->post->getBlogComment();          $comment = new BlogComment();     $comment->setBlogPost($this->post);     $this->form = new BlogCommentForm($comment);          if ($request->isMethod('post') && $this->form->bindAndSave($request->getParameter('blog_comment')))     {       $this->redirect('post/show?slug='.$this->post->getSlug());     }   } 

And in the showSuccess.php template, we'll append the form display:

  php <h3>Add a comment</h3>  <?php echo $form->renderFormTag(url_for('post/show?slug='.$post->getSlug())) ?>   <table>     <?php echo $form ?>     <tr>       <td></td><td><input type="submit"/></td>     </tr>   </table> </form> 

We've now a pretty commeting system added to our blog, thanks to all the goodness provided by symfony and Doctrine:

step3.png

Conclusion

The time when everyone choosed Propel because it was more stable than Doctrine seems to be over. Doctrine is robust, and performs quite well on my box. Furthermore, it handles complex relationships and dynamic object hydratation natively and better than Propel. Doctrine is also very well integrated into symfony, certainly because Jonathan Wage - the Doctrine lead developer - now works for Sensio, creator and main sponsor of symfony.

Wednesday, August 10, 2011

symfony bridge wordpress, share cookie for domain and subdomain, Sharing cookies among all subdomains

There's a common problem of sharing cookies for domain and subdomain.
solution is set domain with www.example.com and set cookie domain to '.example.com'
reference: 


Sharing cookies among all subdomains


As explained earlier, cookies are not shared among subdomains or between the domain
and the subdomain. In order to set cookies accessible by all subdomains, use the 
following techniques:

  1. While writing the cookie, set the cookie domain to ".domain.ext" so that it applies 
    to all subdomains.

  2. If the cookie domain is set to ".domain.ext", it will not be accessible by a user
    who types in the address without the www before the domain (i.e. http://domain.ext).
    Therefore, redirect all requests without www to http://www.domain.ext.


There are some reported problems with the above approach. It is safe to set the default cookie 
with no domain specified and then set another one with domain as ".domain.ext". In this case 
there is no need for the redirects.
However, remember that session cookies are set by the web server software and you may not
have control over how the cookie domain is set.

real world case:

symfony site on example.com
blog is wordpress on blog.example.com
both sharing same top navigation, so, in blog, the login/logout link should be switched by user current status.
to achieve this, in blog.example.com , we need to know if user has logged in at example.com

steps:

1, set permanent redirect, redirect all example.com request to www.example.com

2, in sfGuardSecurityUser class, add

    // set a cookie for all subdomains
    sfContext::getInstance()->getResponse()->setCookie('wp_bridge', $this->generateRandomKey(), time() + $expiration_age, '/', '.example.com');

at bottom of signIn method

  add

sfContext::getInstance()->getResponse()->setCookie('wp_bridge', '', time() - $expiration_age, '/', '.example.com');

at bottom of signOut method


3, in wordpress

in my case, find the file : wp-content/themes/mytheme/custom/custome_functions.php

find cookie by

echo 'Hello '.($_COOKIE['wp_bridge']!='' ? $_COOKIE['wp_bridge'] : 'Guest');



DONE, enjoy the bridge.

Monday, August 08, 2011

Friday, May 13, 2011

网上问诊单

     首先声明,如有以下十一种人之一者请不要填写:

1、不信中�的人 .

2、���有疑�的人 .

3、自以�是的人 , 又要吃西�又要吃中�的人 .

4、懂一���中� , ����方指指��的人 .

5、拿到�方 , 不按�吃的人 .

6、拿到�方 , 到了�房抓� , ����此方太� , ��不行 , 要加那��等 , 立刻就�定不拿�了 , 或回������方�� , 此�笨蛋不要治 , �於��草型 , 完全不知道自己在作什� . ��不是�� , 他干���治� , �也信 , �在有�笨拙 .

7、不���建�的人 , 以�吃�就好了 , 比如: 肝硬化是由喝酒引起 , 吃中�後 , 仍然不戒酒 , 如何�好呢?

8、重��同一��的人 , 表示他不相信你了 . 不可治 . (我在看病�都ㄧ定��解�病情�病人�, 但是再次���病人居然�� , 吃��是�什�? 你��不�人 , 不相信就不要�看中� , 何必如此害自己呢?)

9、一有重病 , 只要人�什�好 , 就立刻去做 , �果�吃一大堆� , 此�有疾病�投�的人不要治 .

10、平�吃一大推不必要的�或�他命的人 , 生病��看�� , �身��一�囊 , ��求����何�可吃 , 何�不可吃 , ��人除了本身疾病外 , 又自己增添�多本�根本不存在的����生 , 千�不要看 .

11、吃药有效 , 不坚�吃的人

以上十一�人 , 奉�所有中�� , 千�不要去治 , 此�病人你就算是治好也不�感�你 , 他���你是蒙到的 , 治不好就都是你的� , �不�去���什�自己�得到此病 , �人�什��有此病 , 只�怪�生不好 . 但是如果他�是去看西�� , �度就一百八十度��了 , 完全�西�的� , 就像一�口袋中的�物一� , 主人�食什�就吃什� , 乖巧的要死 , 就算�果是死於西�之手 , 他�也不�去怪罪西� , 家����在抬病患��出院� , 列�向西�致�意的 ..

中医网上诊病,失去了四诊的望、闻、切三诊,为准确诊断,有效治疗,请问病患者详细填写下面内容(连同注意、说明全部复制,以便查阅),有则选择,无则删除。

1、请详细填写下列条目——

性别:

生辰:(公元)年月日时

籍贯: 

婚否:

职业:

身高:

体重: 

腰围:

肤色:

主要症状:

发病经过:

治疗经过(尽量详细一点):

西医病名:

是否长期用过激素:

是否大量用过消炎药:

是否做过内脏手术:

2、请选择下列部位身体状态(将所无状态删除)——

脉(左:快,慢,有力,无力,粗,细,浮,沉,松,紧,停顿,时快时慢)

(右:快,慢,有力,无力,粗,细,浮,沉,松,紧,停顿,时快时慢)

面(红,黄,白,黑,青):

眼(瞳仁色灰;白睛色青,色黄;有血丝,有瘀斑,有隆起,有黑点,眼下色青,眼皮肿):

舌(肥大,瘦,尖红,滑湿,有齿痕,干,苔腻,黄苔,白苔,中有裂纹,舌下筋脉曲张):

齿(整齐,龃龉,有缝,颜色,大,长,齿痛,活动,有斑,无力)

耳(鸣,聋,痒,痛,流水,左,右):

目(干涩,昏花,眩晕,流泪,痛,痒,左,右):

口(苦,干,酸,无味,溃疡,流涎):

鼻(不通,流涕,凉,热,左孔,右孔):

咽(干,痛,痒,吞咽困难):

胸(满,闷,胀,痛,骨痛,热,凉):

乳(胀,痛,增生,肿块,左,右):

胁(胀,痛,热,凉,左,右):

腹(胀,满,痛,肿,硬):

外阴(肿,胀,痛,热,凉,如烧,坠胀,挛缩):

心(烦,悸,慌,紧,痛,凉,热,跳快):

心下(满,闷,堵,胀,烧):

胃(胀,痛,满,酸,凉,热):

头(痛,晕,麻,木,昏,沉重):

项(僵,痛,酸重,不能转动):

肩(痛,凝,沉重,萎缩,凉,热,左,右):

臂(痛,麻,木,胀,酸,颤,凉,热,左,右):

手(凉,热,干,出汗,麻,颤,指痛,甲痛,萎缩,左,右):

背(痛,酸,重,胀,凉,热,左,右):

腰(酸,重,痛,胀,凉,热,左,右,中间):

腿(痛,酸,重,麻,木,肿,胀,僵,软,凉,热,左,右,内侧,外侧):

膝(痛,肿,凉,热,软,骨痛,无力,左,右):

足(痛,胀,麻,木,软,凉,热,左,右):

跟(痛,凉,热,麻,胀,左,右):

足趾(麻,痛,胀,凉,热,左,右,部位):

3、请选择与下列项目对应的身体状况(必选)——

饮(多,少,喜凉,喜热,喜温,喜酸,喜辣,喜苦,喜咸,喜甜):

食(多,少,喜米,喜面,喜粥,喜油腻,厌油腻):

睡眠(多,少,失眠,多睡,多梦,易醒):

大便(干,湿,粘,便秘,失禁,色黑,色黄,色白,溏泻,一日一次,一日数次,数日一次):

小便(多,少,不畅,不禁,色黄,色白,次数多,次数少):

房事(有,无,多,少,阳亢,阳痿,早泄,手淫,曾堕胎):

月经(先期,后期,多,少,暗,红,淡,浓稠,清稀,有血块,痛经,漏泻):

白带(有,无,多,少,白,黄,腥,臭):

4、请回答身体经常有如下哪些症状——

(发热,出汗,怕冷,怕风,怕热,哮,喘,咳,气短,有痰,打嗝,呕逆,恶心,腹泻,便血,尿血,吐血,鼻血,牙龈出血,烦躁,肢体震颤,肢体僵硬,乏力倦怠,头重脚轻,少气懒言,嗜卧,厌卧,半身不遂,时冷时热,长期低烧,淋巴节肿大,胸骨刺痛,站立觉累,静脉曲张,骨发空,骨发热,梦遗,早泄,阳痿,不孕)

5、七情何者为重——

(喜悦,愤怒,忧郁,思虑,悲伤,恐惧,惊悸)

如何知道你的身体是否健康,有以下五通标准。

饮食通:不偏食,有良好的嗅觉、味觉及食觉。口润不渴,亦可及时补充水分。

休息通:休息每日在七八个小时左右,午时有一小时的午睡时间,夜有梦但不多,睡眠深。醒后精力充沛。

大小便通:大小便正常,每日晨起有一次大便,不干不稀,通畅,五分钟可解决问题。小便清,无泡沫,无杂质。小便与饮水量成正比。

体力通:体力充沛,能够胜任一般劳动,不感到疲劳,过重体力劳动,半小时左右能休息过来

阳气通:身体温暧,手足温暧,身不畏寒,无上火现象,有正常的性能力。     

公布秘方,比一比,看谁的【生肌散】效果更好?(zhuanzai)

公布秘方,这是我用了十多年的生肌散,效果很好,公开给大家,欢迎各位拿秘方来比较效果高低!

人中白(炙)30g  象皮(砂炒泡)50g  乳香30g  滑石粉30g  血竭30g  白芨30g

共研细末,撒于创口处

主治:一切伤口、溃疡,久不愈合,效神速!


Thursday, May 05, 2011

肥胖的原因与减肥

    人体肥胖的原因,一是身体的垃圾不能及时清理,堆集在细胞和组织空隙,或与人体脂肪同处,垃圾和它所吸收的水分增加了人的体重,并使人的精神倦怠,气色黄浊。本质的原因则是年龄大或疾病造成的脏腑功能减弱,新成代谢不足及内分泌不调所引起;二是饮食不节,营养过剩,又因阳气不足,不能将多余的营养转化为动能,或转化为元精收藏(纳气归肾或曰潜阳)。反而使之化为脂肪存贮于人体组织间隙或体内空处。

减肥的方法一般有节食、运动和药物治疗等。节食对营养过剩引起的肥胖有一定作用,但对新成代谢不足或内分泌不调引起的肥胖效果不佳,且节食不能太过,否则影响人体的正常能量供给;运动有助于过剩营养的消耗并排除一些体内垃圾,但运动同时也促进代谢垃圾的产生,人如果阳气不足,运动消耗的阳气不能及时恢复和补充,运动增加的垃圾不能及时排除,反而使身体更差而益增肥胖。所以运动减肥只能针对内体较好而缺乏运动的人。但不管运动或节食,都很辛苦,大多数人都不能坚持,而且坚持了也不一定见效,所以人们更期望药物减肥。目前,国内外药物减肥的方法很多。一是厌食法,服用一些药物,让人不想吃东西,产生减肥的作用。肥是减了但对人身体的破坏很大,可谓本未倒置,得不偿失。且一旦不服药,肥胖又会回来。二是脱水法或曰排毒法。即服用具有泄泻作用的药物,使人增加排泄而减重。实际上只是排水,即减去了人体细胞和组织包括垃圾与脂肪的水分,毒(拉圾)和脂肪并没少,却会造成人正常生理需要的水分也不能满足,而影响了人的身体健康。停药后,垃圾与脂肪的水分得到补充,重量又回来了。且因人的身体变弱,会产生更多的垃圾和脂肪,人的体重迅速反弹,并将逐渐超过服药之前。

    正确的减肥方法只有一种,即保护和提升人体的阳气(即元气)。人体的阳气增加后,排毒(垃圾)功能和利用营养能力增强,产生和积聚的垃圾与脂肪少,并能排除积存的体内垃圾和燃烧利用体内脂肪,故能减肥。现代人普遍阳气不足。原因包括:夜生活过度,饮酒过度,纵情过度,焦虑过大,喜食冷饮,动辄服用清热药物和抗生素(寒性)等等。只有尽量克服以上毛病,才能保护好自身阳气。提升人体阳气的方法有:1、内体好而运动少的人可选择运动减肥(运动可增加人的阳气水平)。2、药物调节人体功能,扶助阳气,使清气能升,浊气能降。药方:

    党参15克、白术15克、干姜15克、甘草10克、肉桂8克、山楂肉15克。煎汤服用。(因病引起的肥胖,当先解决病根,再谈减肥。)

    服药后出现头晕,身酸无力,排便增加等等不舒服状,都是正常的。是在排垃圾,排完就好了。到时你发现你很容易的就这样减了肥,没有付作用不说,而且还美了容,健了身。感到身轻体健、饮食有味、睡眠加深、气色变好、工作精力增强、心情倍加愉悦。

    赞曰:莫道减肥难,岐路千万般;一旦方法对,玉环变飞燕。 

    补充说明:本减肥方可以长期吃,有双向调节的作用,可使胖者变瘦,瘦者变胖;有肥减肥,无肥强身。开始时排浅层毒素,减肥速度较快。但过后一段时间,可能反而会有增加体重或体积的现象,但不必惊奇,这是深层垃圾吸收水分造成的。继续吃药,垃圾就会排出,从而达到真正减肥而不反弹的目的。

Wednesday, April 27, 2011

办公室养生之――松肩(脾胃虚弱,面色晦暗者请进)


办公室养生之——松肩(脾胃虚弱,面色晦暗者请进)
  
   
  
  不经常运动的人,特别是办公室工作人员,因为用电脑的缘故,双肩容易紧张而不能松沉,乃至影响到颈椎和整个后背,好像背着重物。从外表看来,这类人双肩习惯性上耸,即所谓的“架肩”,长此下去脾胃之气容易积滞,进而面色苍白,四肢瘦弱,抑或是虚胖,体力不佳,从中医角度来看,这些均是脾胃虚弱,气机壅滞所导致的。因为双肩为中焦气血流通的要津,明代李�的《医学入门》中保养导引的方法中“开关法”和“起脾法”均是用松肩的方法以调理脾胃之气。一般人上肢用力往往力量锁在肩关节而透不到双手,但是传统锻炼方法则要求松肩,力量在肩关节不停留直接贯通到双手,如太极拳、形意拳、八卦掌等均有如此要求。下面为大家介绍一种锻炼双肩的方法,打通肩部的滞涩,恢复气血流通。
  
   
  
  1预备式:坐在椅子上或放松站立均可,两手交叉抱胸。
  
  2 摇肩:左右转圈摇摆,肘尖的轨迹呈“∞”字形,大约100次。
  
  3 转肩:两手自然下垂,手指自然伸直,肩膀用力由后向前转圈(后—上—前—下—后);之后由前向后转圈,各100次。要领:动作缓慢柔和,手臂放松,垂直下坠,好像挂在肩膀上的钟摆一样,丝毫不着力。
  
  4 开肩:本动作是在走路过程中完成的,走路时双手随步伐前后摆动,像解放军叔叔的“齐步走”。手的摆动的水平高度在肚脐和胸之间,大约在中脘、上脘的位置。要领:步伐不要太快,要像散步一样放松,手臂像钟摆一样摆动,手指自然伸直,全身放松。
  
  以上动作1、2、3可连续做,每次大约半小时,适合于办公室工作人员疲劳时缓解压力,放松身心。动作4可在上下班走路时做,每次最好持续半小时。
  
   
  
  动作效应:
  
  锻炼一般在10分钟后就会感觉肩关节周围发热,30分钟后会感到整个背部包括颈椎,都会有温热的感觉,说明通过运动阳经气血通畅,颈椎、肩周、失眠、头痛等疾病会得到缓解。在做动作半小时后,手指会有温暖而柔软的感觉,说明手三阴经逐渐通畅,心、肺、脑血管疾病都会有所减轻。
  
  本方法简单,但是功效卓著,长期锻炼可以增进食欲,健壮脾胃,增强体格。我们看看为什么参过军的人体质都比一般人要好?他们面色红润、声音洪亮、精神面貌和体力都是非常棒!包括大学生军训,我的一个同班同学军训后连晕车都治好了。其中一个重要的原因,那就是天天齐步走,暗合妙道,松开双肩,脾胃之气调畅,中焦脾胃是后天之本,它一旦强壮,自然有病祛病无病强身了。晕车本是脾胃病,用这种方法治疗自然会收到良好的效果。
  
   
  
  小建议:办公室工作人员,精神压力比较大,工作长时期不活动,难免心情郁闷,进而影响脾胃功能,食欲不振,消化不良,面色萎黄,睡眠不香。遇到这种情况,您可以在饭前饭后、睡觉之前花十分钟做一下松肩,使气血运行通畅,如果持之以恒,食欲逐渐就会旺盛,睡眠自然就会香甜。

Friday, February 18, 2011

Unknown record property / related component "profile" on "sfGuardUser"

If you got this error:

500 | Internal Server Error | Doctrine_Record_UnknownPropertyException Unknown record property / related component "user" on "sfGuardUserProfile"

You are lucky, this error bothered me for a long time, but now you know the answer!

user_id in Profile must be interger(4)

the important part is (4)

if you don't have it in the schema, you will get the error above.

example:

sfGuardUserProfile:   columns:     user_id: {type: integer(4)}     email: {type: string(100), email: true}     favorite_color: {type: string(100)}   indexes:     user_id_fk_idx:       fields: [user_id]   relations:     User:       class: sfGuardUser       local: user_id       foreign: id       type: one       foreignType: one       foreignAlias: Profile


keywords:

symfony 1.4 sfGuardUser Profile sfDoctrineGuardPlugin


--
Kindest Regards,

Zhen Sun

Tuesday, November 16, 2010

李子暘:“通胀”这把火玩不得

诱导大量错误投资,周期性地制造出经济危机,导致社会财富的巨额浪费,甚至酿成政治危机,这才是通胀最大的社会危害。
  李子暘
  经济学者,铅笔经济研究社理事
  最近通胀的话题很热闹,但舆论中关于通胀的常识性谬误很多,这里只拣两个最重要的来说说。
  谬误一:要用CPI(消费者物价指数)来衡量是否有通胀,通胀有多少。
  这个说法的错误有两层。第一层:CPI是可任意制定的指数。CPI,是一些消费品的价格加总计算。这些商品价格上涨了,就说CPI上涨了,还会煞有介事地计算出是百分之几点几。这些商品价格没有上涨,就说CPI没变,没有通胀。显然,选择哪些商品列入CPI的清单,功夫很深。想掩盖通胀,只要选择那些价格很少或没有变化的商品。至于涨价很凶的商品,只要将其排除到CPI以外即可。比如房价,虽然是许多居民支出中的大头,但从来就不列入CPI。
  政府的第二招是:就算列入CPI的商品价格上涨,也可以通过价格管制来应对。CPI当然不会按照黑市价格来计算。因此,如果某商品被列入CPI清单,企业家投资时一定要谨慎。该商品的价格很可能会受到政府管制。投资的企业家,分分钟可能被政府和公众指为乱涨价的奸商,成为通胀的替罪羊。
  即使CPI的计算是完备和公正的,能如实反映商品和服务的价格变化,它也不是衡量通胀的好指标。
  通货膨胀,从字面含义和经济原理上看,都是指货币数量增加,并没有物价上涨的含义。无论物价是否上涨,只要流通中的货币量增加了,就发生了通胀。用物价是否上涨来衡量是否有通胀,就好像用是否得了高血压、糖尿病来衡量一个人是否需要减肥。不是所有的肥胖者都必定得了高血压、糖尿病,但肥胖者必定体重超标。有体重一个指标就够了。
  同样,衡量通胀是否存在,只需看货币量是否增加,而不能等到物价上涨再来谈论通胀。等到物价上涨,再设法抑制通胀,为时已晚。
  谬误二:通胀的危害是造成物价上涨。
  从政府决策层,到经济学家和公众,都对此深信不疑。相应的政策后果就是:如果通胀造成的物价上涨没有超出社会容忍度,那为了刺激经济增长,不妨玩玩通胀。
  甚至还有经济学家主张提高通胀的社会容忍度,简直是一派胡言!
  如果通胀增发的货币在瞬间到达每个人,那就只是币值改变而已,但通胀的真实过程不是这样的。
  通胀增发出来的货币,是通过某个入口进入经济体的。现在,主要是通过银行贷款这个入口。于是,有机会从银行贷款的人,就先拿到了货币。而挣工资的广大民众,则较晚拿到增发的货币,甚至根本拿不到。那些先拿到货币的人自然好处多多。他们就像是可以合法使用伪钞的人。通胀就是把别人的财富偷偷地转移到这些人手中。
  可见,通胀是在全社会范围内公然进行的掠夺和财富再分配,而且是从大众向少数人转移财富,使贫者愈贫,富者愈富。这是通胀真正的社会危害,远比物价上涨恶劣得多。
  除此之外,通胀往往通过政府人为压低利率进行。压低了利率,银行就可以发放更多的贷款,就会有更多的货币进入流通。对普通人来说,银行升降几个百分点的利率,影响不大。但对产业投资来说,那几个百分点的利率变化是很关键的。
  投资10亿的项目,利率升降1%,就意味着每年成本增减1000万。利率的高低,直接决定了这个项目是合算还是不合算。人为压低利率,许多原本不合算的项目就会变得合算。这些项目所需要的各种原料能源供应,还会诱使一大批上下游项目投资上马。
  但低于市场利率的低利率是不可持续的。增发的货币,经过一段时间,会通过各种渠道,流到更多的社会成员手中,推动物价的普遍上涨,并形成政治压力。
  政治压力之下,政府只能选择提高银行利率,减少贷款量,减少流通中的货币量。这时,两难局面就出现了。
  要么,继续实行通胀政策,结果是物价飞涨,甚至民不聊生;要么,停止通胀政策,结果是大量错误的投资暴露出来,许多企业破产,员工失业,这就是经济危机和经济萧条。
  诱导大量错误投资,周期性地制造出经济危机,导致社会财富的巨额浪费,甚至酿成政治危机,这才是通胀最大的社会危害。
  那些以为通胀只意味着物价上涨的人,认识不到通胀真正的危害,就像小孩子不懂火的厉害一样。于是,他们也就像小孩玩火一样玩通胀。形容他们处境的最好比喻就是:盲人骑瞎马,夜半临深渊。
  可叹的是,他们的愚蠢,将由全体社会成员负责。大声疾呼让他们立即停止玩火,难道不是我们必须要做的事情吗?

Saturday, September 11, 2010

custom form formatter/decorators

symfony 1.4 form

custom form formatter/decorators

class xxxForm extends BaseXxxForm
{
  public function configure()
  {
    $myDecorator = new myListFormDecorator($this->getWidgetSchema());
    $this->widgetSchema->addFormFormatter('custom', $myDecorator);
    $this->widgetSchema->setFormFormatterName('custom');
  }
}

class myListFormDecorator extends sfWidgetFormSchemaFormatter {
  protected
    $rowFormat = "
      %hidden_fields% %field% %help%
    ",
    $helpFormat = '<div class="help">%help%</div>',
    $errorRowFormat = "%error%",
    $errorListFormatInARow = " ",
    $errorRowFormatInARow = " ",
    $namedErrorRowFormatInARow = " ",
    $decoratorFormat = "%content%";
}// decorator class

Friday, July 23, 2010

HTTPS and SSL Setup Step-by-Step Guide « Nurul Islam

HTTPS and SSL Setup Step-by-Step Guide « Nurul Islam

(attention: only restart apache when requested.)

I have tried to enable SSL on localhost . I found a solution on wampserver forum . You can try this :)

****************
****Step1****** -> Create SSL Certificate and Key
****************

1a) Open the DOS command window and change directory to bin directory of wamp apache directory by using the DOS command without quotes: “cd /d c:\” and then “cd wamp\bin\apache\apache2.2.8\bin”. apache2.2.8 should be changed to what apache folder your wamp server has.

After done, the DOS prompt should look like: C:\wamp\bin\apache\apache2.2.8\bin>

1b) Create a server key with 1024 bits encryption. You should enter this command without quotes:
“openssl genrsa -des3 -out server.key 1024″. It’ll ask you a pass phrase, just enter it. ‘
1c) Remove the pass phrase from the RSA private key (while keeping a backup copy of the original file). Enter this command without quotes: “copy server.key server.key.org” and then “openssl rsa -in server.key.org -out server.key”. It’ll ask you the pass phrase, just type it.

1d) Create a self-signed Certificate (X509 structure) with the RSA key you just created. Enter the command without quotes: “openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt -config C:\wamp\bin\apache\apache2.2.8\conf\openssl.cnf”.

You’ll fill in the information after entering this command. The correct location of config file, openssl.cnf may need to be changed. In windows, you won’t see “.cnf” extension of the file openssl, but in DOS you’ll see the full name openssl.cnf.

****************
***** Step2***** -> Copy the server.key and server.crt files.
****************

2a) In the conf folder of apache2.2.8 folder, create two folders named as ssl.key and ssl.crt

2b) copy the server.key file to ssl.key folder and server.crt file to ssl.crt

****************
****Step3****** -> Edit the httpd.conf file and php.ini
****************

3a) In httpd.conf file, remove the comment ‘#’ at the line which says: LoadModule ssl_module
modules/mod_ssl.so

3b) In httpd.conf, remove the comment ‘#’ at the line which says: Include
conf/extra/httpd_ssl.conf
Then move that line after this block ….

3c) open the php.ini file located in apache2.2….\bin folder, remove the comment ‘;’ at the line
which says: extension=php_openssl.dll

***************
****Step4***** -> Edit the httpd_ssl.conf file in the folder name, extra
***************

4a) Find the line which says “SSLMutex ….” and change it to “SSLMutex default” without quotes

4b) Find the line which says: . Right after it, change the line which says “DocumentRoot …” to DocumentRoot “C:/wamp/www/” with quotes. Change the line “ErrorLog….” to Errorlog logs/sslerror_log. Change the line “TransferLog ….” to TransferLog logs/sslaccess_log

4c) SSL crt file: Change the line “SSLCertificateFile ….” to SSLCertificateFile “conf/ssl.crt/server.crt”

4d) SSL key file: Change the line “SSLCertificateKeyFile ….” to SSLCertificateKeyFile “conf/ssl.key/server.key”

4e) Change the line which says or something similar to and add the following lines inside those … tags:

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

4f) Make sure the line CustomLog “logs/ssl_request_log” \
is uncommented (remove the #). This step is suggested by wmorse1.

**************
****Step5**** In the previous DOS Command windows, enter httpd -t . If it displays Sysntax is OK, then
************** go to Step 6. If not, then correct the wrong syntax and redo step 5.

**************
****Step6***** -> Restart the Apache server
***************

**************
****Step7**** -> if restart is successful, then open the browser and enter “https://localhost” without
************** quotes.

*************************
****Step8 (Optional)**** -> If you want to allow world wide web access to your HTTPS secure server, then
************** ********** in the httpd_ssl.conf file, change the line which says ‘ServerName localhost:443′ to ‘ServerName www.yourwebsitename.com:443′ without quotes. yourwebsitename is your registered internet domain name. If you don’t have it, then just use your WAN IP address. For example ‘ServerName 99.238.53.105:443′. Make sure these setups are correct to allow outside access to secured www server.

8.a The DocumentRoot you modified in step 4b points to the correct website folder on your
computer.

8.b If your computer’s connected to the router, setup the router to allow port 443 forwarding to your
computer.

8.c If your computer has a firewall enabled or behind a network firewall, set up the firewall to allow
incoming port 443 connection

And finally

Thursday, February 11, 2010

ullWiki - Show - Upgrade ullright to symfony 1.3/1.4

Currently: sfLoader::loadHelpers('I18N');
Should be: Use the same methods from the sfApplicationConfiguration object.
sfContext::getInstance()->getConfiguration()->loadHelpers('Debug','Other1','Other2')

ullWiki - Show - Upgrade ullright to symfony 1.3/1.4

Tuesday, February 09, 2010

Where is the ajax documentation ?

Ajax removed in Symfony 1.3, 1.4 due to they don't want to relied on a third-party platform. Fortunately there are plugins that return the functionality into symfony 1.3 and 1.4.

For you specific problem, have a look at
http://forum.symfony-project.org/index.php/t/23998/
http://forum.symfony-project.org/index.php/t/24736/
http://forum.symfony-project.org/index.php/t/24117/

symfony framework forum: General discussion => Where is the ajax documentation ?

escaping_strategy

Enables and defines the policy of the output escaping feature (see Chapter 7). Set it to off if you don't use the $sf_data container in your templates.

The Definitive Guide to symfony | Chapter 19 - Mastering Symfony's Configuration Files | symfony | Web PHP Framework

using link_to for non-symfony links is no longer possible

using link_to for non-symfony links is no longer possible in favour of the
new functionality. In fact, link_to was never intended for cases like this:

[php]
// does no longer work
"alert('js')"); ?>

// use this instead
Link

Changeset 27177 - symfony - Trac

Tuesday, January 26, 2010

增广贤文

古训《增广贤文》

                                       

昔时贤文,诲汝谆谆,集韵增文,多见多闻。
观今宜鉴古,无古不成今。
知己知彼,将心比心。
酒逢知己饮,诗向会人吟。
相识满天下,知心能几人。
相逢好似初相识,到老终无怨恨心。
近水知鱼性,近山识鸟音。
易涨易退山溪水,易反易覆小人心。
运去金成铁,时来铁似金,读书须用意,一字值千金。
逢人且说三分话,未可全抛一片心。
有意栽花花不发,无心插柳柳成阴。
画虎画皮难画骨,知人知面不知心。
钱财如粪土,仁义值千金。
流水下滩非有意,白云出岫本无心。
当时若不登高望,谁信东流海洋深。
路遥知马力,事久见人心。
两人一般心,无钱堪买金,一人一般心,有钱难买针。
相见易得好,久住难为人。
马行无力皆因瘦,人不风流只为贫。
饶人不是痴汉,痴汉不会饶人。
是亲不是亲,非亲却是亲。
美不美,乡中水,亲不亲,故乡人。
莺花犹怕春光老,岂可教人枉度春。
相逢不饮空归去,洞口桃花也笑人。
红粉佳人休使老,风流浪子莫教贫。
在家不会迎宾客,出外方知少主人。
黄金无假,阿魏无真。
客来主不顾,应恐是痴人。
贫居闹市无人问,富在深山有远亲。
谁人背后无人说,哪个人前不说人。
有钱道真语,无钱语不真。
不信但看筵中酒,杯杯先劝有钱人。
闹里有钱,静处安身。
来如风雨,去似微尘。
长江后浪推前浪,世上新人赶旧人。
近水楼台先得月,向阳花木早逢春。
莫道君行早,更有早行人。
莫信直中直,须防仁不仁。
山中有直树,世上无直人。
自恨枝无叶,莫怨太阳偏。
大家都是命,半点不由人。
一年之计在于春,一日之计在于寅,一家之计在于和,一生之计在于勤。
责人之心责己,恕己之心恕人。
守口如瓶,防意如城。
宁可人负我,切莫我负人。
再三须慎意,第一莫欺心。
虎生犹可近,人熟不堪亲。
来说是非者,便是是非人。
远水难救近火,远亲不如近邻。
有茶有酒多兄弟,急难何曾见一人。
人情似纸张张薄,世事如棋局局新。
山中也有千年树,世上难逢百岁人。
力微休负重,言轻莫劝人。
无钱休入众,遭难莫寻亲。
平生莫作皱眉事,世上应无切齿人。
士者国之宝,儒为席上珍。
若要断酒法,醒眼看醉人。
求人须求大丈夫,济人须济急时无。
渴时一滴如甘露,醉后添杯不如无。
久住令人贱,频来亲也疏。
酒中不语真君子,财上分明大丈夫。
出家如初,成佛有余。
积金千两,不如明解经书。
养子不教如养驴,养女不教如养猪。
有田不耕仓廪虚,有书不读子孙愚。
仓廪虚兮岁月乏,子孙愚兮礼义疏。
同君一席话,胜读十年书。
人不通今古,马牛如襟裾。
茫茫四海人无数,哪个男儿是丈夫。
白酒酿成缘好客,黄金散尽为收书。
救人一命,胜造七级浮屠。
城门失火,殃及池鱼。
庭前生瑞草,好事不如无。
欲求生富贵,须下死工夫。
百年成之不足,一旦败之有余。
人心似铁,官法如炉。
善化不足,恶化有余。
水太清则无鱼,人至察则无徒。
知者减半,省者全无。
在家由父,出家从夫。
痴人畏妇,贤女敬夫。
是非终日有,不听自然无。
宁可正而不足,不可邪而有余。
宁可信其有,不可信其无。
竹篱茅舍风光好,道院僧堂终不如。
命里有时终须有,命里无时莫强求。
道院迎仙客,书堂隐相儒。
庭栽栖凤竹,池养化龙鱼。
结交须胜己,似我不如无。
但看三五日,相见不如初。
人情似水分高下,世事如云任卷舒。
会说说都是,不会说无礼。
磨刀恨不利,刀利伤人指。
求财恨不得,财多害自己。
知足常足,终身不辱。
知止常止,终身不耻。
有福伤财,无福伤己。
差之毫厘,失之千里。
若登高必自卑,若涉远必自迩。
三思而行,再思可矣。
使口不如自走,求人不如求己。
小时是兄弟,长大各乡里。
妒财莫妒食,怨生莫怨死。
人见白头嗔,我见白头喜。
多少少年亡,不到白头死。
墙有逢,壁有耳。
好事不出门,恶事传千里。
贼是小人,知过君子。
君子固穷,小人穷斯滥也。
贫穷自在,富贵多忧。
不以我为德,反以我为仇。
宁向直中取,不可曲中求。
人无远虑,必有近忧。
知我者为我心忧,不知我者谓我何求。
晴天不肯去,只待雨淋头。
成事莫说,覆水难收。
是非只为多开口,烦恼皆因强出头。
忍得一时之气,免得百日之忧。
近来学得乌龟法,得缩头时且缩头。
惧法朝朝乐,欺公日日忧。
人生一世,草生一春。
黑发不知勤学早,看看又是白头翁。
月到十五光明少,人到中年万事休。
儿孙自有儿孙福,莫为儿孙作马牛。
人生不满百,常怀千岁忧。
今朝有酒今朝醉,明日愁来明日忧。
路逢险处难回避,事到头来不自由。
药能医假病,酒不解真愁。
人贫不语,水平不流。
一家有女百家求,一马不行百马忧。
有花方酌酒,无月不登楼。
三杯通大道,一醉解千愁。
深山毕竟藏猛虎,大海终须纳细流。
惜花须检点,爱月不梳头。
大抵选他肌骨好,不擦红粉也风流。
受恩深处宜先退,得意浓时便可休。
莫待是非来入耳,从前恩爱反为仇。
留得五湖明月在,不愁无处下金钩。
休别有鱼处,莫恋浅滩头。
去时终须去,再三留不住。
忍一句,息一怒,饶一着,退一步。
三十不豪,四十不富,五十将来寻死路。
生不论魂,死不认尸。
父母恩深终有别,夫妻义重也分离。
人生似鸟同林宿,大限来时各自飞。
人善被人欺,马善被人骑。
人无横财不富,马无野草不肥。
人恶人怕天不怕,人善人欺天不欺。
善恶到头终有报,只争来早与来迟。
黄河尚有澄清日,岂可人无得运时。
得宠思辱,安居虑危。
念念有如临敌日,心心常似过桥时。
英雄行险道,富贵似花枝。
人情莫道春光好,只怕秋来有冷时。
送君千里,终须一别。
但将冷眼看螃蟹,看你横行到几时。
见事莫说,问事不知。
闲事休管,无事早归。
假缎染就真红色,也被旁人说是非。
善事可作,恶事莫为。
许人一物,千金不移。
龙生龙子,虎生豹儿。
龙游浅水遭虾戏,虎落平阳被犬欺。
一举首登龙虎榜,十年身到风凰池。
十年窗下无人问,一举成名天下知。
酒债寻常行处有,人生七十古来稀。
养儿待老,积谷防饥。
鸡豚狗彘之畜,无失其时。
数家之口,可以无饥矣。
常将有日思无日,莫把无时当有时。
时来风送腾王阁,运去雷轰荐福碑。
入门休问荣枯事,观看容颜便得知。
官清书吏瘦,神灵庙祝肥。
息却雷霆之怒,罢却虎狼之威。
饶人算人之本,输人算人之机。
好言难得,恶语易施。
一言既出,驷马难追。
道吾好者是吾贼,道吾恶者是吾师。
路逢侠客须呈剑,不是才人莫献诗。
三人同行,必有我师,择其善者而从之,其不善者而改之。
少壮不努力,老大徒悲伤。
人有善愿,天必佑之。
莫饮卯时酒,昏昏醉到酉。
莫骂酉时妻,一夜受孤凄。
种麻得麻,种豆得豆。
天眼恢恢,疏而不漏。
见官莫向前,做客莫在后。
宁添一斗,莫添一口。
螳螂捕蝉,岂知黄雀在后。
不求金玉重重贵,但愿儿孙个个贤。
一日夫妻,百世姻缘。
百世修来同船渡,千世修来共枕眠。
杀人一万,自损三千。
伤人一语,利如刀割。
枯木逢春犹再发,人无两度再少年。
未晚先投宿,鸡鸣早看天。
将相胸前堪走马,公候肚里好撑船。
富人思来年,穷人思眼前。
世上若要人情好,赊去物件莫取钱。
死生有命,富贵在天。
击石原有火,不击乃无烟。
为学始知道,不学亦徒然。
莫笑他人老,终须还到老。
但能依本分,终须无烦恼。
君子爱财,取之有道。
贞妇爱色,纳之以礼。
善有善报,恶有恶报。
不是不报,日子不到。
人而无信,不知其可也。
一人道好,千人传实。
凡事要好,须问三老。
若争小可,便失大道。
年年防饥,夜夜防盗。
学者如禾如稻,不学者如蒿如草。
遇饮酒时须饮酒,得高歌处且高歌。
因风吹火,用力不多。
不因渔父引,怎得见波涛。
无求到处人情好,不饮从他酒价高。
知事少时烦恼少,识人多处是非多。
入山不怕伤人虎,只怕人情两面刀。
强中更有强中手,恶人须用恶人磨。
会使不在家豪富,风流不用着衣多。
光阴似箭,日月如梭。
天时不如地利,地利不如人和。
黄金未为贵,安乐值钱多。
世上万般皆下品,思量唯有读书高。
世间好语书说尽,天下名山僧占多。
为善最乐,为恶难逃。
羊有跪乳之恩,鸦有反哺之义。
你急他未急,人闲心不闲。
隐恶扬善,执其两端。
妻贤夫祸少,子孝父心宽。
既坠釜甑,反顾无益。
翻覆之水,收之实难。
人生知足何时足,人老偷闲且是闲。
但有绿杨堪系马,处处有路透长安。
见者易,学者难。
莫将容易得,便作等闲看。
用心计较般般错,退步思量事事难。
道路各别,养家一般。
从俭入奢易,从奢入俭难。
知音说与知音听,不是知音莫与弹。
点石化为金,人心犹未足。
信了肚,卖了屋。
他人观花,不涉你目。
他人碌碌,不涉你足。
谁人不爱子孙贤,谁人不爱千钟粟。
莫把真心空计较,五行不是这题目。
与人不和,劝人养鹅。
与人不睦,劝人架屋。
但行好事,莫问前程。
河狭水急,人急计生。
明知山有虎,莫向虎山行。
路不行不到,事不为不成。
人不劝不善,钟不打不鸣。
无钱方断酒,临老始看经。
点塔七层,不如暗处一灯。
万事劝人休瞒昧,举头三尺有神明。
但存方寸土,留与子孙耕。
灭却心头火,剔起佛前灯。
惺惺常不足,懵懵作公卿。
众星朗朗,不如孤月独明。
兄弟相害,不如自生。
合理可作,小利莫争。
牡丹花好空入目,枣花虽小结实成。
欺老莫欺小,欺人心不明。
随分耕锄收地利,他时饱满谢苍天。
得忍且忍,得耐且耐。
不忍不耐,小事成大。
相论逞英雄,家计渐渐退。
贤妇令夫贵,恶妇令夫败。
一人有庆,兆民咸赖。
人老心未老,人穷志莫穷。
人无千日好,花无百日红。
杀人可恕,情理难容。
乍富不知新受用,乍贫难改旧家风。
座上客常满,樽中酒不空。
屋漏更遭连年雨,行船又遇打头风。
笋因落箨方成竹,鱼为奔波始化龙。
记得少年骑竹马,看看又是白头翁。
礼义生于富足,盗贼出于贫穷。
天上众星皆拱北,世间无水不朝东。
君子安平,达人知命。
忠言逆耳利于行,良药苦口利于病。
顺天者存,逆天者亡。
人为财死,鸟为食亡。
夫妻相合好,琴瑟与笙簧。
有儿贫不久,无子富不长。
善必寿老,恶必早亡。
爽口食多偏作药,快心事过恐生殃。
富贵定要安本分,贫穷不必枉思量。
画水无风空作浪,绣花虽好不闻香。
贪他一斗米,失却半年粮。
争他一脚豚,反失一肘羊。
龙归晚洞云犹湿,麝过春山草木香。
平生只会量人短,何不回头把自量。
见善如不及,见恶如探汤。
人贫志短,马瘦毛长。
自家心里急,他人未知忙。
贫无达士将金赠,病有高人说药方。
触来莫与说,事过心清凉。
秋至满山多秀色,春来无处不花香。
凡人不可貌相,海水不可斗量。
清清之水,为土所防。
济济之士,为酒所伤。
蒿草之下,或有兰香。
茅茨之屋,或有侯王。
无限朱门生饿殍,几多白屋出卿。
醉后乾坤大,壶中日月长。
万事皆已定,浮生空白茫。
千里送毫毛,礼轻仁义重。
一人传虚,百人传实。
世事明如镜,前程暗似漆。
光阴黄金难买,一世如驹过隙。
良田万倾,日食一升。
大厦千间,夜眠八尺。
千经万典,孝义为先。
一字入公门,九牛拖不出。
衙门八字开,有理无钱莫进来。
富从升合起,贫因不算来。
家中无才子,官从何处来。
万事不由人计较,一生都是命安排。
急行慢行,前程只有多少路。
人间私语,天闻若雷。
暗室亏心,神目如电。
一毫之恶,劝人莫作。
一毫之善,与人方便。
欺人是祸,饶人是福。
天眼恢恢,报应甚速。
圣贤言语,神钦鬼伏。
人各有心,心各有见。
口说不如身逢,耳闻不如目见。
养军千日,用在一朝。
国清才子贵,家富小儿骄。
利刀割体痕易合,恶语伤人恨不消。
公道世间唯白发,贵人头上不曾饶。
有钱堪出众,无衣懒出门。
为官须作相,及第必争先。
苗从地发,树向枝分。
父子和而家不退,兄弟和而家不分。
官有正条,民有和约。
闲时不烧香,急时抱佛脚。
幸生太平无事日,恐逢年老不多时。
国乱思良将,家贫思贤妻。
池塘积水须防旱,田地勤耕足养家。
根深不怕风摇动,树正无愁月影斜。
奉劝君子,各宜守己。
只此程式,万无一失。
增广贤文