Mar 2

Chris Heilmann posted a simple commenting trick at ajaxian, these tricks are so simple but usefull i myself never think about ‘em before. As a programmer nor a designer we often comment nor uncomment many lines of our code while testing it, rather than inserting and deleting the same lines (commeting tags) everytime we test it, we simply do these tricks:

Javascript

view plaincopy to clipboardprint?

  1. foo(); 

  2. //* 

  3. bar();

  4. baz.foo = 200;

  5. return 

  6. {

  7. dolly:clone()

  8. }

  9. // */ 

and to comment all lines except foo() we only need to remove a slash at the beginning of the comment tags, and to re-comment it just add the slash at the same place.

view plaincopy to clipboardprint?

  1. foo(); 

  2. /*

  3. bar();

  4. baz.foo = 200;

  5. return

  6. {

  7. dolly:clone()

  8. }

  9. // */ 

CSS

Here are the trick for commenting in CSS

view plaincopy to clipboardprint?

  1. .test 

  2. {

  3. font:bold 1.2em/1em arial

  4. /**/ 

  5. padding:0 5px

  6. margin:0

  7. color:red

  8. /**/ 

  9. border:solid 1px red

  10. }

and to activate the comment we simply remove an asterix(*) character on the beginning of the comment tags

view plaincopy to clipboardprint?

  1. .test 

  2. {

  3. font:bold 1.2em/1em arial

  4. /*/

  5. padding:0 5px;

  6. margin:0;

  7. color:red;

  8. /**/ 

  9. border:solid 1px red

  10. }

PHP

These trick is for php programing by collaborate sharp(#), slash(/), and asterix(*)

view plaincopy to clipboardprint?

  1. private function foo() 

  2. {

  3. $return =   false; 

  4. /*

  5. $this->foobar();

  6. if($this->bar)

  7. {

  8. $return = true;

  9. }

  10. else

  11. {

  12. $this->foo();

  13. }

  14. #*/ 

  15. return $return

  16. }

and to activate the commented lines simply we put sharp(#) character before the slash(/) at the beginning of the comment tags.

view plaincopy to clipboardprint?

  1. private function foo() 

  2. {

  3. $return =   false; 

  4. #/*

  5. $this->foobar();

  6. if($this->bar)

  7. {

  8. $return = true;

  9. }

  10. else

  11. {

  12. $this->foo();

  13. }

  14. #*/ 

  15. return $return

  16. }

So simple huh but i belive these will save your time alot :).

Next Entries »