跳至主要内容

博文

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

apache .htaccess form some file or one file:

见: Satisfy any Order allow,deny Deny from all Allow from 127.0.0.1 AuthType Basic AuthName "private" AuthUserFile /var/www/phpexperts.pro/.htpasswd AuthGroupFile /dev/null Require valid-user IP Alone: Order allow,deny Deny from all Allow from 127.0.0.1 但是我这样做不行,改了一下后:         order deny,allow         deny from all         allow from 90.14.212.42 这样就可以,好像deny, allow 的顺序要和后面deny,allow的顺序相同 甚至你可以这样写: order deny,allow deny from all allow from 12.345.67.890 allow from 890.67.345.12 如此可以添加多个ip

Javascript error: $.browser is undefined

I’ve had to fix a couple of our sites today due to the javascript error “$.browser is undefined”, If you’re using Google’s CDN to deliver your minified jQuery, you may well be seeing the same thing. It looks like Google has updated their main 1.0 branch of jQuery to serve version 1.9 of the popular javascript library.  Unfortunately some plugins haven’t been updated (or site owners haven’t updated the plugin) to stop using $.browser which is now  deprecated . Fortunately, fixing this is just a case of hardcoding the CDN call to use version 1.8, so in this case change - http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js to http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js And that should fix it. So far I’ve seen problems with jQuery.autocomplete and jCrop plugins, feel free to add more in the comments. from :  http://osblues.com/2013/01/16/javascript-error-browser-is-undefined/

eclipse 如何阻止其显示某些文件夹的错误

如题,很多错误都是外部library,我根本不需要知道,如何把它们排除呢? n the Validation section of Window > Preferences you can add different rules in settings (...) column, you can add a "Folder or file name rule" in the Exclude Group for XML types. 这个哥们提供了一个比较方便的方法。转载于: http://stackoverflow.com/questions/2272237/how-to-exclude-specific-folders-or-files-from-validation-in-eclipse

symfony2 transchoice:

in tranlate file, you must add a "'" for your transchoice string, but it is not needed for trans string. For example: list: create: company: Ajouter une société appointment: Ajouter une rendez-vous export: company: Exporter des entreprises text: vers un fichier texte website: vers un site web index: visit: '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples' call: '{0}There is no apples |{1} There is one apple |]1,Inf] There are %count% apples' If you remove the ', then symfony will tell you he can not find the proper trans string.

sync two folders in ubuntu

a programm autosync two folders, this says could be local=>local, local=>remote, i'm testing remote=>local #!/bin/bash # # Watch current directory (recursively) for file changes, and execute # a command when a file or directory is created, modified or deleted. # # Written by: Senko Rasic # # Requires Linux, bash and inotifywait (from inotify-tools package). # # To avoid executing the command multiple times when a sequence of # events happen, the script waits one second after the change - if # more changes happen, the timeout is extended by a second again. # # Installation: # chmod a+rx onchange.sh # sudo cp onchange.sh /usr/local/bin # # Example use - rsync local changes to the remote server: # # onchange.sh rsync -avt . host:/remote/dir # # Released to Public Domain. Use it as you like. # EVENTS="CREATE,CLOSE_WRITE,DELETE,MODIFY,MOVED_FROM,MOVED_TO" if [ -z "$1" ]; then echo "Usage: $0 cmd ..." exit -1; fi in

create a download link in symfony2

download_route : pattern : /download/ { filename } defaults : { _controller : YourBundle : Controller : download } And then in your controller, public function downloadAction ( $filename ) { $request = $this -> get ( 'request' ); $path = $this -> get ( 'kernel' )-> getRootDir (). "/../web/downloads/" ; $content = file_get_contents ( $path . $filename ); $response = new Response (); //set headers $response -> headers -> set ( 'Content-Type' , 'mime/type' ); $response -> headers -> set ( 'Content-Disposition' , 'attachment;filename="' . $filename ); $response -> setContent ( $content ); return $response ; } For generating download link check  Generating urls  section of the doc. for a nomal php , if the content is a file: if ( file_exists ( $file )) { header ( 'Content-Description: File Transfer' );

如何在twig中 call 一个保存在字符串变量中的function

attribute ¶ New in version 1.2:  The  attribute  function was added in Twig 1.2. attribute  can be used to access a "dynamic" attribute of a variable: 1 2 3 {{ attribute ( object , method ) }} {{ attribute ( object , method , arguments ) }} {{ attribute ( array , item ) }} 比如: {% for column in columns %} {% if column=='activity' %} {% for activity in company.activity %} {% endfor %} {% else if column='contacts' %} {% for contact in company.contacts %} {% endfor %} {% else %} {{ attribute(company, column) }} {% endif %} {% endfor %}

get entity obj from form view in twig template

form . get ( 'value' ) is deprecated since symfony 2.1. Copy from Symfony\Component\Form\FormView : /* * @deprecated Deprecated since version 2.1, to be removed in 2.3. Access * the public property {@link vars} instead. */ public function get ( $name , $default = null ) .... so, I guess form . vars . value . youMethod () And if you get {{ form . vars . value }} is NULL. If you have form.element (not the form object itself) object, for example if you are overriding a form_row template that has passed the form.row object, you can get the Entity like this: {{ form . getParent (). vars . value . MyEntityMethod }}