跳至主要内容

博文

目前显示的是 三月, 2013的博文

symfony2 unit test

how tu simulate a request without call a controller? This article give a solution even his basic idea is to fast the controller unit test. For example, if we need to test a service which is called by a controller. In the service we have some parmeters from the request, or have a request as parameter, so we need to generate the container before test this service. But the normal way of symfony2 unit test you need to generate a client and then send them to controller, so we need to find a way directly inject our container to the service. http://leftnode.com/entry/faster-symfony2-tests.html   see this. namespace Acme\DemoBundle\Tests\Unit\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; class ControllerTest extends WebTestCase { public function testControllerAction() { $client = static::createClient(); $container = $client->getKernel() ->getContainer(); $request = new

转贴

有那么一群人:他们从来不进市场购物,却在研究着你的物价。 有那么一群人,他们从来不要买房,却在研究着你的房价。 他们从来不用交养老钱,却在研究着你的社保。 有那么一群人,他们从来都不会失业,却在研究着你的下岗。 他们儿孙都在美国,却在研究着你该如何爱国。

eclipse run makegood as phpunit test for symfony2.2

well, as the title says, these articles give me the hint to install it. install phpunit for symfony2.2 is so simple: add "require-dev": { "phpunit/phpunit": "3.7.*" }, in your composer.json in symfony2.2 project. http://blog.loftdigital.com/running-phpunit-tests-in-eclipse-pdt install eclipse make good http://dev4theweb.blogspot.fr/2012/07/makegood-and-symfony2.html this one make makegood works with symfony2 if you get something like this: The  MakeGood View  notify now:  PHPUnit_Framework_TestCase class is not available. Fix… you need to add the phpunit folder in the include path(this is for windows), if in ubuntu, maybe see this: http://www.stuermer-benjamin.de/v12_1/eclipse-4-2-with-php-android-and-unit-testing/ and the makegood official user guild is here: http://piece-framework.com/projects/25/wiki/MakeGood_User_Guide_1_2_0

git problem

if you get this: remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable to remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. well , if found the p

install git server

all the precedure is written in this article.  http://git-scm.com/book/zh/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E5%9C%A8%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E9%83%A8%E7%BD%B2-Git  但是我却碰到了一个很奇怪的问题,就是无论如何也clone不了新建的项目:  fatal: protocol error: bad line length character: fatal: The remote end hung up unexpectedly  有人说可以看一下这个命令的输出: ssh mathieu@192.168.1.52 git-receive-pack /var/www/gitproject.git 然后我就看了: This is BASH 4.2 - DISPLAY on :0.0 Thu Mar 21 15:44:29 CET 2013 00760000000000000000000000000000000000000000 capabilities^{} report-status delete-refs side-band-64k quiet ofs-delta 看起来最后一行好像是git的输出,而且没有错。那前面三行是什么东西?这段话好像每次ssh都会给我,于是去看了一眼.barshrc # Looks best on a black background..... #echo -e "${CYAN}This is BASH ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n" #date #if [ -x /usr/games/fortune ]; then # /usr/games/fortune -s # makes our day a bit more fun.... :-) #fi #function _exit() # function to run upon exit of shell #{

how to add a customized jquery ui button

. ui-button . ui-icon . you-own-cusom-class { background-image : url ( your-path-to-normal-image-file.png ); width : your-icon-width ; height : your-icon-height ; } . ui-button . ui-state-hover . ui-icon . you-own-cusom-class { background-image : url ( your-path-to-highlighted-image-file.png ); width : your-icon-width ; height : your-icon-height ; } then just type in the JS code: jQuery ( 'selector-to-your-button' ). button ({ text : false , icons : { primary : "you-own-cusom-class" // Custom icon }});

写点什么?

这么无聊,还不如自己编故事玩?也许也会很不错呢 生是无奈的,死是绝望的,站在无奈和绝望中间的我们,是什么样的? 以此纪念那些无奈,绝望的人们。 唉,算了,找不到历史的灵魂,苍白的经历也无法想象那些不曾经历的黑暗,生活本身的无奈又不知如何才能够生动的表达,这文章是总也写不下去的。 人都说,思考是灵魂,可是要把思考整理一遍的时候才发现,那也不是那么容易的意见事情。 我希望,我希望中华民族有希望,我希望找到一个方法,哪怕是想象中的,只要它有那么一丁点可能,但前提是,它必须是合理的,它必须是能够实现的。早已经过了那种随便想想的年龄,这笔提起来的时候就分外艰难。不过我相信思想是能够被整理,也是能够通过不断的练习来表达的,所以我们需要的只是一个开始,也许你的东西注定了一辈子都不会有人看,但是那是你的东西,就是你的。 小说有几个选择,其实我对于什么穿越之类的一点兴趣也没有,因为那并不符合现实,也不可能从你的生活中获得多少东西,如果说真的要写,还不如直接写历史小说,不用什么大事件,就像围城那样,专心于刻画历史某一时刻的某一个角落,让人们了解到历史中的人性,或者通过历史来了解人性。或者是干脆写现在,现在的官文那么多,却没有几个是真正的在写生活,莫不是意淫罢了,跟当年的阿Q没有任何区别,看这别人娶了几房太太,就幻想这个名以后都能够换到自己手里来,如果只是从这只手换到那只手,我们还革命作甚?死那么多人,破坏那么多环境,浪费那么多年光阴,你的几房姨太太和他的几房姨太太有什么区别? 中国人到底怎么了?问题在哪里?100多年前的时候,那么多仁人志士努力想,努力解决,结果却是一个法西斯共产党当了皇帝,你不能回到过去,你不能改变历史,只需要的是知道为什么,而这个为什么在如今的天空下都已经变得如此之难。我无法想象当时的情形,我甚至也无从知道这种选择背后的种种因由,唯有那一段又一段的结果摆在我们的面前。 如果我要意淫,那我一定意淫一个在当今的环境下依然能够实现的梦,小说其实就是白日梦嘛,不如我们一起来做个白日梦吧。不管怎样,这也是我们寻找道路的方法。我想通常意义上的小说家都应该有超凡的记忆力和一颗敏感的心,这两样对于我,都有,就在记忆中寻找一点灵感吧。 人的命运都是紧紧的和时代联系在一起的,你自以为超脱的时候殊不知那超脱也带着时代的印记。

javascript 循环执行某个function

方法1 var timesRun = 0 ; var interval = setInterval ( function (){ timesRun += 1 ; if ( timesRun === 60 ){ clearInterval ( interval ); } //do whatever here.. }, 2000 ); If you want to stop it after a set time has passed (e.g. 1 minute) you can do: var startTime = new Date (). getTime (); var interval = setInterval ( function (){ if ( new Date (). getTime () - startTime > 60000 ){ clearInterval ( interval ); return ; } //do whatever here.. }, 2000 ); 方法2: $ ( function () { var timer = null ; var input = document . getElementById ( 'input' ); function tick () { ++ input . value ; start (); // restart the timer }; function start () { // use a one-off timer timer = setTimeout ( tick , 1000 ); }; function stop () { clearTimeout ( timer ); }; $ ( '#start' ). bind ( "cl