跳至主要内容

博文

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

Unrecognized field: usernameCanonical for symfony2 FosUserbundle

I got this error when try to login to my system. I searched in internet and find this could be caused by several problems, of cause if your configuration is the following: orm: auto_generate_proxy_classes: %kernel.debug% default_entity_manager: italy entity_managers: italy: connection: italy mappings: MobMindsCoreBundle: ~ FOSUserBundle: ~ metadata_cache_driver: apc query_cache_driver: apc result_cache_driver: type: memcache host: %memcache_host% port: %memcache_port% instance_class: Memcache class: Doctrine\Common\Cache\MemcacheCache world: connection: world mappings: MobMindsCoreBundle: ~ FOSUserBundle: ~ metadata_cache_driver: apc query_cache_driver: apc result_cache_driver: type: memcache host: %memcache_host%

关于html形式的mail

今天看到一篇文章讲如何写richtext的mail。链接: http://css-tricks.com/using-css-in-html-emails-the-real-story/ 有几个要注意的地方: 不能用< head> 不能用外部style sheet 不能用background-image或者background-position 不能用float 不能用margin 不能用font 这里有一个url让我们把一个正常的html变成一个mail能用的html。 http://premailer.dialect.ca/ 对写恶心的htmlmail很有帮助

奇怪的syntax error

在firefox 中是: syntax error 在chrome中是: syntax error Unexpected token < 这个问题很诡异,有个哥们写了这篇文章解释了这个问题: http://blog.ryanrampersad.com/2008/09/06/syntax-error-break-on-this-error-doctype-html-public-w3cdtd-xhtml3orgtr-xhtml1-dtd-xhtml1-strictdtd/ 基本上个原因是有个js没有成功load, 我的symfony project 也同样有这个问题,找了半天最后原因是在/app/config/security.yml中,我加了一句: - { path: ^/, roles: ROLE_USER } 结果有些js就不能够成功load了,然后就冒出这么个错误,这你妈坑爹的。

symfony annotation

一个刚刚发现的annotation的问题:比如说你有两个function, public function contactAction(){ return array(); } /** * @Route("/zipcode/{zipCode}",name="_user_public_get_city", options={"expose"=true}) * @Template() */ public function getCityAction($zipCode) { ... } annotation注释那块和上一个function 之间的空行不能删除,否则就不起作用。 /** * @Route("/changeStatus/{id}/{status}",requirements={"id" = "\d+","status"="confirm|delete|doubt"},name="_moderation_annonce_change_status", options={"expose"=true}) * */ @route内必须用双引号,单引号是不行地。

她来听我的演唱会

下午放了这首歌,老板跑来说很好听虽然他不知道唱的是什么,张大神还是有功力的啊。 今天一天都挺热,幸运的是中间下了一会阵雨,虽然并没有让天气彻底凉下来,但风中传来的雨的味道不禁让人精神一震。回忆总会远去,但也还是会像老歌一样,唱起来总带着那么多特别的滋味,就像今天的雨,就像小时门前的雨,就像阳沟里的小鱼,就像水田里的泥鳅,就像池塘里的白云,就像戈壁滩上的石头,是啊,我问爸爸,我们去的地方好玩么?爸爸说“很好玩的,有好多石头“,于是吃剩的罐头盒子里就装满了各式各样的石头,半透明的,带金属色的,白色的,绿色的,灰色的。 跑题了,咱还是说演唱会吧,虽然我好像没办过演唱会,也就是表演过几次而已。后来玉问我你最近学了什么新歌?我一想,都已经好久没有学了,难怪吸引力下降了呢...人生就是那么写个远的近的影子,你觉得他们好清楚的时候,一晃眼又都不见了,你觉得他们都在眼前想去捞可能抓起来的只是一把把石头。我们都会老的,人说一个普通人留下的影响一般在3代以内就结束了。可云不会老,水不会老,石头也不会老,也许我们就是那田里的韭菜,割了一茬又一茬,地还是那块地。两个韭菜偶尔打个结,韭菜们就不必那么纠结了吧。 这首歌安静的时候很好听,不过别听太多了。

如何用javascript 实现 regex match 忽略accents

function prepareHighLightWord(word){ word=word.replace(/a/ig,'[aáàäâÄ]'); word=word.replace(/e/ig,'[eéèëêÈÉÊË]'); word=word.replace(/o/ig,'[oôöÖÕÔ]'); word=word.replace(/i/ig,'[iiïîÌÌ]'); word=word.replace(/u/ig,'[uüûÜÛ]'); word=word.replace(/c/ig,'[cç]'); word=word.replace(/y/ig,'[yÿý]'); return word; } var searchString="..." var matchString="..."; var word=prepareHighLightWord(string); var pattern = new RegExp('('+word+')', ['gi']); var rs = ' $1 '; var newString=searchString.replace(pattern, rs); 这是一个简单的例子。

use setTimeout

var timeout ; function animate () {     // do stuff here     clearTimeout ( timeout );     timeout = setTimeout ( animate , 2500 ); } This is an example which settimeout works fine, in fact, it just clear a time before we call it. and another solution is to do like this: function test (){ ...     if (....){       setTimeout ( function (){ test ();}, 1000 );       } } or ,we can not this more easily: function test (){ ...     if (....){       setTimeout ( test , 1000 );       } } further more, window.setTimeout('window.parent.generateOutput(true)', 1000); // deprecated is deprecated. So it explain why it works sometimes for the older version of spoop. you can see the reference : https://developer.mozilla.org/en/DOM/window.setTimeout

CSS print

翻来翻去翻到这么一句话:  It's up to the user and their browser settings to print or not print background images. To keep yourself from relying on that, put the images in the foreground in HTML. 也就是说我们不能把img放到background。但是不放到background又不能居中 找到一个不用background来居中imag的方法: 转载  http://www.brunildo.org/test/img_center.html .wraptocenter { display: table-cell; text-align: center; vertical-align: middle; width: ...; height: ...; } .wraptocenter * { vertical-align: middle; } /*\*//*/ .wraptocenter { display: block; } .wraptocenter span { display: inline-block; height: 100%; width: 1px; } /**/ 当然你要为你的img建一个container, 假设为 wraptocenter 可以这样写: 这里有另外两篇文章介绍了如何正确处理print的问题: http://davidwalsh.name/optimizing-content-print-css http://davidwalsh.name/css-page-breaks

jquery 相关小问题 持续更新

$("#mySelect option[value='3']").attr('selected', 'selected'); 这个可以设置摸个选项为select,但是在firefox中可以直接使用:IE9中,这会导致选择一个空选项,IE8中不会有任何作用。< 总结,IE真的是脑残啊!! 这个jquery的plugin挺有意思的: 可以让你在input中输入不同格式的数字外带一个数学符号之类的, http://www.decorplanit.com/plugin/ 跟masked input有一定的相似之处, 但是有一个很重的的问题是他几乎不能和以前那种通过更改input 的value的hint类插件同时使用,会使得hint失效,因为它总是trigger一个change,然后就匹配input的value,结果是字符串,所以就被重新归空。 var io = holder.io, value = iv.val(), origValue = value; if (value !== ''){ value = autoStrip(value, io); if ( checkEmpty(value, io) === null && autoCheck(value, io) ) { value = fixNumber(value, io.aDec, io.aNeg); value = autoRound(value, io.mDec, io.mRound, io.aPad); value = presentNumber(value, io.aDec, io.aNeg); } else { value = ''; } } 所以显然的,这玩意很讨厌。

如何在blog上显示code style

嗯嗯,我还是怕忘记了,先记在这里吧: Paste the followig code 在你所有code前面,现在的html标准已经不需要把script和css放在header里了 然后你需要在之前加上: 最后,你的blog上你可以使用 pre 这个东东来显示code, source请见: http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

fadein 和 fadeout 问题

如果你想一个图片小时以后再显示另一个图片, $("#imagDetail").fadeOut(500,function(){ $("#imagDetail").css("background", "url(/data/photos/Big/" +src + " ) no-repeat center center"); $("#imagDetail").fadeIn(500); }); 这个fadeOut(500,function())表示fadeout完成了以后再执行的程序,而如果并排写的话,就会不管fadeout执行完毕没有都会执行下一句,也就是说fadeout另开了一个线程执行延时动作。

uploadify出问题以后的解决办法

其实这也应当是所有flash的问题,当出现错误的时候就什么提示信息都没有,有几个解决办法。 1.在服务器端的响应文件里写入log。 2.通过使用http://www.charlesproxy.com/download/latest-release/download.do这种网络监测软件来监测网络通信状况。当然需要在php.ini中打开display_errors”,通常这种信息不能在firebug中显示,因为不是由firefox发出的请求。

dump a variable

Twig: How to var_dump variables inside a template Do you sometimes wish you could just do a var_dump inside a Twig template while trying to debug some code? Well Twig comes with its own Debug extension to allow you to do just that. Firstly, add the following to your /app/config/config_dev.yml (you don’t want to do this on Prod): twig: debug: 1 services: debug.twig.extension: class: Twig_Extensions_Extension_Debug tags: [{ name: 'twig.extension' }] Now inside your Twig templates you can “var_dump” variables using the  built-in Twig Debug : {% debug nameOfVariable %}