跳至主要内容

博文

目前显示的是 2013的博文

相信什么

信任总的有一个人先开始。预测一场已经结束的比赛的比分,那不预测,那叫总结。相信一件已经成为事实的过去的事情,那不叫相信,那只能叫尊重事实。 其实只要是没有发生的事情,只要是未来,选择才变得有意义。在很多重要的时候,其实也就两个选择,信于不信,做与不做。相信很多时候就是有盲目的成分在里面,爱其实便是最大的盲目,很多时候都不是愿意去相信,而是刻意去相信,否则那就没有爱情了,那只有交易。 我愿意去相信,我选择去相信,至于是什么结果,懒得去想了,因为想要的到的东西,只能选择相信才有可能。但愿你也能如此想。

送给小女人

总想为这段时间留下点什么,生怕回过头,它们就悄悄淡去,再也找不到它们存在过得痕迹。人生的很多日子都会这样渐渐远去以至于你都记不起它们存在过,以至于你都开始怀疑它们是否曾经如此的真实。

sql join difference

jquery file upload with symfony2

for use this plugin, install jquery-file-upload in web install punk_ave bundle and this is my example: /** * @Route("/import",name="prospection_admin_import") * @Template() */ public function importAction(){ $fileUploader = $this->get('punk_ave.file_uploader'); $request = $this->getRequest(); $existingFiles=null; $editId = $request->query->get('editId'); if (!$editId){ $editId=$request->getSession()->get('editId'); } if ($editId){ $existingFiles = $fileUploader->getFiles(array('folder' => '/tmp/attachments/'. $editId)); if ($request->getMethod() == 'POST') { $type=$request->request->get("importType"); $importHandler=$this->get('addepi.prospection.import.handler'); $path=$this->get('kernel')->getRootDir()."/../web/uploads/tmp/attachments/".$editId."/originals/"; f

dynamically change the form presentation

In this article, we discussed how to do it: http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html I also give my example : public function buildForm(FormBuilderInterface $builder, array $options) { $factory=$builder->getFormFactory(); $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($factory){ // ... add a choice list of friends of the current application user $address = $event->getData(); $form = $event->getForm(); if ($address instanceof Address && $address->getWebSite()!=""){ $url=$address->getWebSite(); }else{ $url= 'http://www.'; } $form->add($factory->createNamed('webSite','url',$url,array( 'required'=> false, 'attr' => array('class' => 'defaultInvalid'), 'label' => 'form.address.label.webSite&#

regex hint

how to test a char is repeat more than 3 times?  The regex is  /(.)\1{9,}/ . Test: #!perl use warnings ; use strict ; my $regex = qr /(.) \1 { 9 ,}/; print "NO" if "abcdefghijklmno" =~ $regex ; print "YES" if "------------------------" =~ $regex ; print "YES" if "========================" =~ $regex ; Here the  \1  is called a backreference. It references what is captured by the dot  .  between the brackets (.)  and then the  {9,0}  asks for nine or more of the same character. Thus this matches ten or more of any single character. Although the above test script is in Perl, this is very standard regex syntax and should work in any language. In some variants you might need to use more backslashes, e.g. Emacs would make you write  \(.\)\1\{9,\}  here.

jquery how to hide the select arrow when the ajax return only one option

well, just note it for memo. html: less: /* Select arrow styling */ .address_city_chooser{ >div{ position:relative; display:inline-block; &.disabled{ label:after{ content: ''; width: 23px; height: 23px; position: absolute; display: inline-block; top: 4px; right: 4px; background: #fff; pointer-events: none; } } } } and js: $.get( Routing.generate('prospection_public_city',{'postCode':code,'_locale':currentLang}), function(response){ if(typeof response.error!="undefined"){ $('#errorDialog').html(response.error); $('#errorDialog').dialog('open'); }else{ $(container).html(response); if ($(container).find('option').length<2){ $(container)

jquery validation, how to check a select box is not the default value

1. You can write your own rule! // add the rule here $ . validator . addMethod ( "valueNotEquals" , function ( value , element , arg ){ return arg != value ; }, "Value must not equal arg." ); // configure your validation $ ( "form" ). validate ({ rules : { SelectName : { valueNotEquals : "default" } }, messages : { SelectName : { valueNotEquals : "Please select an item!" } } }); 2. An easier solution has been outlined here:  [jQuery] Validate select box Make the value be empty and add the required attribute id = "select" class = "required" > value = "" > Choose an option value = "option1" > Option1 value = "option2" > Option2 value = "option3" > Option3

css zoom a block

zoom : 145 %; - moz - transform : scale ( 1.45 ); - webkit - transform : scale ( 1.45 ); Zoom and transform scale are not the same thing. They are applied at different times. Zoom is applied before the rendering happens, transform - after. The result of this is if you take a div with width/height = 100% nested inside of another div, with fixed size, if you apply zoom, everything inside your inner zoom will shrink, or grow, but if you apply transform your entire inner div will shrink (even though width/height is set to 100%, they are not going to be 100% after transformation). In my opinion, i think we should use zomm not transform, transform is just resize the element.

rsync exclude some folder or file

example: rsync -avt /home/workspace/symfony2.1_bannieres /home/local_workspace/admin --delete --exclude-from '/home/local_workspace/exclude_admin.txt' suppose we have a exclude file in /home/local_workspace/exclude_admin.txt, and his content is : app/logs app/cache .svn .git this is the article: http://articles.slicehost.com/2007/10/10/rsync-exclude-files-and-folders

css rewrite , concerned with less and yui

I have a problem really odd about css rewrite. suppose we have a css in AcmeTestBundle/Resources/public/css folder, named a.less. In this a.css we have a rule like: background: url(../images/buttons.png) no-repeat top left; which is the AcmeTestBundle/Resources/public/images/button.png, for some ugly reasons, if we use symfony2 assetic, the cssrewrite can not translate it correctly, so we use this commmand first ; php app/console assets:install and then in our layout.twig, we can use this: {% stylesheets 'bundles/acmetest/css/*.less' filter='lessphp,cssrewrite,?yui_css' output='css/test.css' %} {% endstylesheets %} well, the odd thing come, we get a web/css/test.css, and in this file, we have a image link like this: background: url((../../bundles/acmetest/images/buttons.png) no-repeat top left; if your site url is the root of the domain, no problem, like you have a domain name : www.abcefg.com. But,

symfony2 PHP Warning: SessionHandler::close(): Parent session handler is not open when logout

this is an error introduced by php version under 4.11, https://groups.google.com/forum/#!topic/symfony-devs/Q-f0lKT7OZ8 and https://github.com/symfony/symfony/issues/5868 are the bug report, the solution for no way to upgrade  php is : logout: path: fos_user_security_logout target: / invalidate_session: false

awstats

normally installed awstats in ubuntu has a folder in /usr/share/doc/awstats This folder contains the awstats_updateall.pl, which can trigger all the update for all config file in the specific path. So we should not remove these folder from doc. you can bind the awstats by cron.d or logroate , see this example in /etc/logrotate.d/apache2 : prerotate /usr/share/doc/awstats/examples/awstats_updateall.pl -configdir=/etc/awstats -awstatsprog=/usr/lib/cgi-bin/awstats.pl now endscript Sure, here is an good explaination for this topic: http://www.dalouche.com/wordpress/2006/11/22/howto-apache2-awstats-setup-on-debianubuntu-edgy-eft/ normally, we should do both of them, use cron.d and attach it with logrotate, cause logrotate will disable our awstats

jquery change the select box value

we can do this at first: $("#simple_search_bar .cat option[value=0]").prop('selected',true); and there is an article talke about this: The right way to do this depends upon your circumstances. Case 1: No  value  attributes on the  option  elements If your  option  elements don't have  value  attributes  (and you're not worried about the possibility of somebody adding them later and inadvertently breaking your existing code),  then  just use the  .val() method  of the jQuery object wrapping your  select  element. For instance, in the OP's case... $select = $ ( '#cbCategory' ); $select . val ( cat ); // Selects the option with text `cat`, as long as the options don't have // 'value' attributes. Case 2:  Option  elements have  value  attributes If your  option  elements have value attributes (or  value  attributes might be added in the future and you don't want your code to break), then there'