跳至主要内容

博文

目前显示的是 七月, 2012的博文

jquery ui

hide tabs when loading: Tab 1 Tab 2 Tab 3 Content 1 Content 2 Content 3 然后可以如此: $( "#tabs" ).tabs({ create: function(event, ui) { //executed after tab is created. $('.tabs_content').show(); }, show: function (event, ui) { //on every tabs clicked } });

wao wao wao. lenon is right!!

The following is some words from a blog:  Lennon is right. The key to life is happiness, but what makes you happy can be completely different from what makes me or anyone else on this planet happy. I found my passion in life: photography. I love it! I’ve had a great ride in my 22 plus years (so far) and I have never regretted my choice. Specifically, most of my life I have been a photojournalist. For the last two years I’ve been a freelance photographer. Hampton Brooks, what do you love? Is it sports? Science? Movies? I can’t help but marvel at Quinten Tarantino who worked as a video store clerk because he loved movies. He was able to watch thousands of movies and later became a director because it was his passion. Follow your passion and it will lead to happiness. If your passion is sitting in front of a TV playing video games, how about a job in that world? Would it be cool to get paid to be a game tester? Whatever your passion is, find a way to make it a career. If no career exis

小说

我总觉的小说不外乎是表达感情的一种形式,所谓的感情,也就是所谓的什么道德,爱情,经历,愿望,和一些具体的感觉,比如触觉,听觉,视觉之类的。当然,一般一本小说有主要的表达对象,通过对这个对象的展开和填充,间接的表达了作者的感情。 小说就是虚拟现实的起源,其实另外一方面也说明了,生活在别处。作者通过它生活在别处,读者通过它生活在别处,我们都愿意生活在别处,这么说来,真的只有不看书的才生活在现在么?也不尽然,农民自然可以抬头望天,政客也能低头迎接民众的欢呼,或者是谩骂,妓女可以一边做爱,一边想着家里的吃的还够不够,上课的孩子们也早已学会睁着眼睛睡觉。原来,我们真的都生活在别处。 那是我们搭建的房子,那是我们充满的阳光,我们是主,我们是那羊羔。也许这就是小说的魅力吧。

swift mail

swiftmailer 在symfony2.0下面似乎有点问题,如果你有 Warning: call_user_func() expects parameter 1 to be a valid callback 这个问题,或者: Class 'Swift_Mailer' not found  的问题,参见: https://github.com/swiftmailer/swiftmailer/issues/219 需要将 app/autoload.php 的最后两行删掉,加上: require __DIR__.'/../vendor/swiftmailer/lib/swift_required.php'; 不然是不行的。好像symfony2.1就不需要这个了。

get or set parameter in controller

$email_address = $this->container->getParameter('email_address'); If we don’t want to use the config.yml file and want to set your own parameter through a bundle controller or service you can set a parameter using: $this->container->setParameter('email_address', 'someone.else@anybody.com');

快乐

看到这段话真的是不知道该说什么,翻译一下: 当我去上学的时候,老师问我,你长大了做什么?我回答老师:'快乐'.他们说我没有明白老师的问题,我告诉老师,你们不懂生活。 ====这里有个trick,有什么和成为什么都是一个词'etre'. 所以,老师问想做什么,回答是‘快乐’。其实这是所有人都追求的,没有蜗牛喜欢被晒干,没有鱼儿喜欢上岸,除非它长着两片肺。我们追求温暖舒适,我们大都喜欢甜味,喜欢赞扬,因为什么,因为它能给你带来快乐。

de Patricia

Si tu as grandi à mon époque ; tu faisais du vélo sans casque ; tu te prenais une baffe si tu répondais mal ; tu avais une télévision avec cinq chaines et tu savais te lever pour les changer ; tu rembobinais les cassettes avec un stylo ; tu  sortais avec 5 francs en poche ou moins et tu ramenais encore de la monnaie ; tu jouais dans la rue ; tu mettais les fringues de tes frères ou sœurs ; tu respectais tes professeurs et tu avais même de l'affection pour certains et finalement tu t'en es bien sorti!. Colle ça sur ton mur pour freiner un peu la connerie des jeunes de maintenant qui ont tout et ne sont jamais contents ----- Je suis tout à fait d'accord avec cela.

eclipse 总报错

1. Requesting JavaScript AST from selection". !STACK 0 java.lang.NullPointerException If I go to Window-->Preferences->Javascript-->Editor-->Mark Occurrences then untick 'Mark occurrences of the selected element in the current file', I don't seem to get the error anymore (so far...). 2. 如果你的content assistent总是不好使: window->preference->JavaScript->Editor->content assit->advanced->Other javaScript proposal 选中

bind a select with entity and it could be null

Catchable Fatal Error: Argument 1 passed to MyProject\EntityBundle\Entity\Requirements::setReplacedEmployee() must be an instance of MyProject\EntityBundle\Entity\Employee, null given, called in /var/www/MyProject/vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 347 and defined in /var/www/MyProject/src/MyProject/EntityBundle/Entity/Requirements.php line 384 Should do this: I can't fully understand your question but, if you want to allow  null  values for the relation with  Employee  you should first edit the mapping (this maybe not necessary as  JoinColumn  should allow  null  values by default):   /**  * @var replacedEmployee  *  * @ORM\ManyToOne(cascade={"persist"},targetEntity="Employee")  * @ORM\JoinColumns({  *   @ORM\JoinColumn(  *     name="replaced_employee_id",referencedColumnName="id",onDelete="CASCADE",  *     nullable=true  *   )  * })  */ private $replacedEmployee ; After generating

when will they come?

First they came for the communists, and I didn't speak out because I wasn't a communist. Then they came for the trade unionists, and I didn't speak out because I wasn't a trade unionist. Then they came for the Jews, and I didn't speak out because I wasn't a Jew. Then they came for me and there was no one left to speak out for me. Most of us do not think it's urgent, cause : I'm not Chinese, I'm not in China, I still have my house, my father & mother & sister etc.... They do not happen to me, I've never seen them. I have no time, no power, no money!! For god's sick!! Just think about it. Do anyone can afford the collapse of China? Is there a country can escape to another planet? Just open your eyes and take a look, a collapsed stat as huge as China or India will destruct the planet and no one can get out of here. Unfortunately, Chinese people will suffer the most difficult part. Please, trying to break the GWF Chi

李承鹏:一次路西法效应实验——什邡小调查

一路北上什邡,雨时下时不下,像从那里传来的消息忽真忽假。等站到市委所在的永生巷,天全然无雨,眼前一切为真。 上千人对着灯火通明处一直喊“放人、放人”,灯火通明处抓了二十七个人,人包括一些学生。在民警、便衣、特警三层控制下,千人不散,他们喊:既然宣布停止钼铜项目,为什么迟迟不放人。而 “活力什邡”则说:被抓的人采取过激行为,严重影响社会稳定。这,恰是七月三日再次冲突的直接原因。“活力什邡”作为政府一张以正视听的脸,更像一张美白面膜,有时与真相无关,有时直接与脸脱节。 我走近街头,人们说:那天,学生们只是拉起横幅反对钼铜,特警就来抢横幅,学生不干,特警就从拉扯到直接开打,用棍子打,然后抓进大院……从而引起更多的大人参加进来。这样的镜头好像在一部电影里看过……好吧,虽然人民也会撒谎,可太多的人民告诉我同一个版本的谎言,细节无差。这样的谎言包括:人们扔的那些花盆常见的那种黑软胶做的,矿泉瓶和石头是和特警对峙时扔的,特警追打人群时不分男女老幼,为不让人们摄到,抓住人就拖进附近小区黑巷子里开打,为进入小区还把门踢烂…… 我走进医院。27岁的网吧员工王小江站在我面前,像一个被卡坏了零件的木偶,面无表情、行走艰难。他说那天晚上他只是与同事骑电瓶车去几十米远的小店买米粉,离警戒线还远,突然冲来一群人围住他就用棍子打,他瞬间被打晕,怎被送进医院,竟也想不起来。他发誓那天只是去买米粉。而他那位同事至今不知下落。他伤心地说,两岁的儿子见到头缠纱布的他已经认不出来。他心疼丢掉的手机,而医生说,更糟糕的是被打坏的左眼可能无法复原…… 与王小江住在同一家医院的石江华是一名的士司机,腿部裂开,眼睛受伤。他跟朋友正在老电影院聊天,也在警戒线之外,不知为何就冲来一群特警拎棍子开打,同样是六七个人围住一个人打。他不断念叨他是本份人,拥护解放军,5.12大地震时他还免费搭载了南京军医的军人进山的…… 昨天深夜将近十二时,碰到一个六七十岁的老人,脸已被打得有点变形,流很多血,手臂受伤,话不成句。只是说,冤枉,我这么大把年纪怎么会过激行动,我是回家路过。 这些人均是随机抽样,并非刻意筛选。其中上述三人,一个是去单位附近几十米的地方买米粉,一个是在警戒线外围观打酱油,一个是回家路过……人们问,为什么一件本可以和平协商的事情最后演变成一场暴力冲突?美白面膜的“活力什邡”表示这是事前沟通不到位,造成

简化字

汉字简化后,親不见,愛无心,產不生,厰空空,麵无麦,運无车,導无道,兒无首,飛单翼,湧无力,雲无雨,開関无门,鄉里无郎,聖不能听也不能说,買成刀下有人头,輪成人下有匕首,進不是越来越佳而是往井里走,可魔仍是魔,匪还是匪

symfony2 database connection

symfony2 的config里有一个parameter被我忽略了: doctrine: dbal: default_connection: default connections: default: host: %database_host% port: %database_port% dbname: %user_database% user: %user_database_user% password: %user_database_passord% driver: %database_driver% unix_socket: /var/run/mysqld/mysqld.sock unix_socket 东西指定了 mysql.default_socket /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock 如果你的php用的是fpm 而且有好几个版本的话,很可能不用default的/tmp/mysql.sock 所以他无法连接数据库也是正常的。

symfony2 update vendor package 的问题

今天很奇怪的遇到这个错误。 Parse error: parse error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/addepi/admin/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php on line 35 PHP Parse error: parse error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/addepi/admin/app/console on line 13 Content-type: text/html X-Powered-By: PHP/4.3.9 我用 php bin/vendors install 来更新服务器端的vendros, 服务器端装有4个php 的版本,4.3, 5.2, 5.3.2, 5.3.9。 我提前用alias php=‘/opt/php5.3.9/bin/php’ 来避开默认的php版本,执行都ok,就是最后在升级这个sensio 的时候它自己要执行一个个脚本,结果又用会php4.3, 解决办法是先把默认的php 改成php 5.3.9,具体做法是: cp /opt/php5.3.9/bin/php /usr/local/bin/php 最后再还原回去。

windows & linux

I really need to mark it down!! Windows is not case sensitive. Linux is. @EWZ\  Bundle  \RecaptchaBundle\Validator\Constraints\True instead of @EWZ\  bundle  \RecaptchaBundle\Validator\Constraints\Tru3 take me 8 hours to remember it, need to write it down here.

apache 笔记

$ which ls 显示命令的路径  WARNING: php_bin /Applications/MAMP/bin/php5/bin/php appears to have a suffix 5/bin/php, but config variable php_suffix does not match  就是你的默认php不是你现在正在使用的php,可以用:  alias php='/Applications/MAMP/bin/php5/bin/php' 来暂时解决这个问题,如果你想永久改变路径,先查一下是否有其他的程序使用php,否则会造成大麻烦 (主要由于可能有的project用旧版php,而现有程序用新版) 安装两个不同版本的php: http://www.bsntech.com/bsntech-blog-mainmenu-321/computers-mainmenu-281/1681-install-two-versions-of-php-on-ubuntu-lucid-1004-php-53-and-php-52.html 如果在非默认安装的php中安装package: pear channel-update pear.php.net pear upgrade PEAR pecl channel-update pecl.php.net pear install intl 比如这个intl

return to referer url

in controller: $request=$this->getRequest(); return $this->redirect($request->getRequestUri()); 实际上,这个不对, $request->headers->get('referer') 这个才是正确的,但是我并不清楚他们的实际区别。 in twig: {{ app.request.requesturi}}

save array in a record mysql

save them: #using serialize() method $data = serialize($_SESSION); $sql = "Insert into sessioninfo `data` values('$data')"; and then to retrive: # I assume you can retrieve the data from database and assign to the following variable $data = unserialize($row['data']);

twig hint

symfony has introduced translation at here: http://symfony.com/doc/current/book/translation.html a point is if the transchoice is null, you will get an exception like: Unable to choose a translation So we need to check if the choice is valid or not before we use this twig tag. {{ ( chart . name ~ '.short' )| trans ({}, "charts" ) }} 如果你想合并string 的话,不要忘了在trans前面加个括号。 如果修改了trans 文件的名字,或者增加了一个tans 文件,需要clear cache, 即便是在dev中

vardump in twig

in a former post i give a solution to make var_dump in twig, the main idea is set twig into debug mode and debug a variable, but Symfony2 or such kind of framework make it impossible, the circle of reference make the dump infinitive. So we need to don in another way: First , we need to create a service which can be called by a twig file, the tutorial can see here : symfony2 offical service creatation for twig extension in your service.xml and then : /** * TVarDumper class. * * TVarDumper is intended to replace the buggy PHP function var_dump and print_r. * It can correctly identify the recursively referenced objects in a complex * object structure. It also has a recursive depth control to avoid indefinite * recursive display of some peculiar variables. * * TVarDumper can be used as follows, * * echo TVarDumper::dump($var); * * * @author Qiang Xue qiang.xue@gmail.com * @version $Id$ * @package System.Util * @since 3.0 * @modifi

symfony2 one to one or many to one relationship form builder

if you have a one to one relationship or many-to-one relationship to render, and you do not want to use the 'collection' type to render the child entity, in fact, you can not. cause you are doing the inverse way, so ,just do this way: public function buildForm(FormBuilder $builder, array $options) { $builder ->add('object',new ModerationObjectForm()) ->add('annonce',new AnnonceForm()); }

symfony2 的问题

[Tue Jul 03 16:35:40 2012] [crit] (OS 5)拒绝访问   : Parent: Unable to duplicate the start mutex to the child 如果出现类似的错误,请删除symfony的cache, 如果有一个app.php 你更改了prod,debug等的参数之后又一直没有反应,注意检查apc的cache,那个玩意很讨厌。

symfony2 reverse engineering when use multi database connection

如果symfony2使用multi database的话,那么从database 生成entity就需要选择我们使用的connection,这个命令可以使我们选择我们需要的connection: php app/console doctrine:mapping:convert yml ./src/MyCo/Base/ MyBundle/Resources/config/doctrine/metadata/orm --from-database --force  --em=commun 这里的commun是自定义的connection

avoid using switch

今天读了一个关于怎样避免使用switch的blog,觉得他的想法甚好,虽然本身是基于javascript的,但其实可以用在任何语言上,只要能支持通过变量的值来call function就可以了。 例子如下: switch (something) { case 1: doX(); break; case 2: doY(); break; case 3: doN(); break; // And so on... } var cases = { 1: doX, 2: doY, 3: doN }; if (cases[something]) { cases[something](); } 就像他所说的,不仅仅是因为后面的更简单或者更清晰,而且因为他更容易扩展,它把实现和定义分开了,你可以在服务器端加你所有想增加的function,而实现则是统一的。就像我以前做的php的controller 一样, $functionName=$_GET['action'].'Action'; $controller->$functionName(); 外面可以加一个catch exception,如果这个action 不存在的话。