Monday, July 14, 2008

Is Vaseline Good For Tattoo

advice from the lady (PHP), 2nd vol Song

holiday in full and write somehow I do not want:) But, in the form of brief advice automobilizacji present. As we all know, functions and classes PHP must be zainkludowane before their first use. Definition of the classes have even tighter consisting in the fact that if the object of the class put in $ _SESSION is that it can be re zdeserializowany script the next time the class definition must be included using include or require before calling session_start (). But we must remember one very important detail: the included file can not send any data to the browser, so that they do not modified the headers sent by the PHP which is sent, inter alia, cookie with the session id. Often, however, even being aware of this requirement, we prepared a script spits out some "junk", causing warning messages and the failure of the session initialization. It is in this case, see the beginning and end of PHP script file. Very often, by mistake, before and after the tags \u0026lt;? Php?> Be placed whitespace. Sometimes, it instantly inserts your editor, especially if you use the AutoFormat option in Eclipse. Hardly anyone knows that if the file does not discard any content you do not need to use the closing bracket '?>' And we can Place any number of whitespace at the end of the file. Our
file may therefore be of the form
 
\u0026lt;? Php function func1
($ parm, $ parm2, $ parm3) {//...

}
function func2 ($ parm) {//...

}
func3 function ($ parm, $ parm2) {//...

}
func4 function ($ parm, $ parm2) {//...

return;}



/ / use the closing tag '?>' Is optional



Yes to save the file is syntactically correct and does not cause any poblemów during its turn in our application.

So much for tonight

Tuesday, July 1, 2008

Were Can I Read Good Lilicon Manga



For all who still doubt the benefits to be gained from automated testing your own code:)

A wise, what programs he knew he had to say that ...,
with each code even if you do not want to compile is not enough to knock
, patterns, know
Klepac
remnant forces still need to have good tests to this effect has been,
result was

Du-du - a lot of bugs you have and more will soon
du-du is a debugger and strace release'a somehow niet!

increasing pressure from the top
Wild deadline again
Just the fact that shipping was the lack of quality still

Although it appears once Poraz
Such as already
However, the tester does the trick again, I

Blocker blocker has gone!

Monday, June 30, 2008

Convert A Quad Into A Buggy

QA Testing methods and static functions in PHP

recently on a blog devoted to testing on Google in one of the posts Fri Defeat "Static Cling" read an interesting suggestion about testing static methods in Java. As in Java and PHP can not create a static method Mock authors suggest creating a special post type calling static methods which would be encapsulated. I admit that, while in Java a compiled language such a solution is most acceptable in an interpreted PHP always try to avoid a proliferation of new classes and types. Using PHPUnit can easily create objects whose implementation is replaced by the test code only required by us and, besides, the whole class behaves just like the original.
Suppose that we have a sample Person class in which we find static method declarations:
 
class Person {public static function
find ($ id) {
/ / Code that gets such a database
return $ person;}



the code in other parts of the code can be used, for example, like this:
 
NotFoundException class extends Exception {} class

PersonsController {public
show_person ( $ id) {
$ p = Person:: find ($ id);
if ($ p) {throw new NotFoundException
();}


/ / some operations on the variable $ p

return $ p;

}}

now wanting to test the controller code will certainly want to be able to this static method pay at the request of different values \u200b\u200bor throw exceptions as such (for example, if we can not find the object with the given ID.) Unfortunately, not easy to get a Person object Mock.
simple solution is to close the static calls Person:: find () from the controller code:

 
class
PersonsController {public function find ($ id) {return
Person:: find ($ id);}
public
show_person ( $ id) {
$ p = $ this-> find ($ id);
if ($ p) {throw new NotFoundException
();}

//...
return $ p;

}}


Now the test code using PHPUnit3 might look like this
 
testShouldThrowAnExceptionIfPersonNotFound public function () {$ controller
= $ this-> getMock ('PersonsController', array ('find'));
$ controller-> expects ($ this-> any ())
-> method ('find')
-> will ($ this-> returnValue (false)) / / simulate situations in which the find is not the object
try
{$ controller-> find (1) / / search for a nonexistent object, to which the controller should react to a specific exception
$ this-> assertFail ('Exception not thrown ');

} catch (NotFoundException $ e) {return
;
} catch (Exception $ e) {
$ this-> assertFail (' Invalid Exception thrown ');}


}



Since functions in PHP have the static bind (this user functions as well as those of the modules and the core of the language for example, all functions working on arrays) and such calls should be enclosed in a non-static object methods and thereby gain the opportunity to exchange implementations for testing a variety of situations.

Tuesday, June 10, 2008

Woodbury Common Hollister

advice from the lady (PHP), vol.1

Recently watched RubyOnRails web framework a lot and I liked it very approach to the HTML template that is used there. I decided that in PHP projects also apply similar structures. As it turns out PHP has a wealth of opportunities in the deposition of code because the language was designed primarily for embedding in HTML. Occasional hash fails
used can be embedded code is to use the html tag with the attribute language = "php":
 
\u0026lt;script language="php">
echo "execute PHP code ';
\u0026lt;/ script>

not I unless specifically highlight how beneficial it is to use this option if a template needs to get a person working on the layout and uses the HTML editor with built-in preview. One drawback is the length of this record - it is suitable mainly for blocks of code whose performance is closely related to the display view - these elements should be as little as possible, of course, but you can block this elegantly put any specific helpers closely linked to the rendered view.

Like Ruby templates is possible to use short tags opening and closing in PHP. As described below, we can transform the array into a html table:
 
\u0026lt;? foreach ($ array as $ row) {?>
\u0026lt;tr>
\u0026lt;? foreach ($ row as $ cell) {?>
\u0026lt;td> \u0026lt;? = $ cell?> \u0026lt;/ td>
\u0026lt;? }?>
\u0026lt;/ tr>
\u0026lt;? }?>

I personally believe that a person who is not too much to do with programming, the presence of braces is less legible than a clear statement that tells where the conditional instruction begins and where it ends: PHP offers an alternative to writing klamrowego which is a record like pseudocode:
 
\u0026lt;? if (isset ($ _REQUEST ['param'])):?>
\u0026lt;div> bestowed on the parameter \u0026lt;/ div>
\u0026lt;? endif;?>

A similar syntax can also be used for the loop (while, for, foreach), and a switch statement.

That's all for today - I greet and wish you have fun with the syntax of PHP!

Monday, May 26, 2008

Driver Toshiba Satellite L455d - S5976

Raid for "Dummies"

For some time there are motherboards with built-in disk controllers coupled together to enable a different configuration or personal use most often observed that people use these controllers in two ways: either join the drive to enlarge the available disk space, or tempted by the demon speed drives unite in this way to allow a parallel reading of two (or more) units. Raid
But I do not fell so much to the taste - a little afraid of your files, and the more complicated setup, including in the event of failure something harder to recover. Recently, however, because of that it has two units I got the idea to separate system files from user files and put the system and the swap of one unit, and user files on the other. The result - great - I did not know that my old box, can again take a bit of air.
So simple advice: if you have two drives and you have no idea - in addition to getting rid of your allegro proposes a single mount partitions / home and the second to leave the whole system and swap partitions.

Marion 40something Peachyforum

Welcome to the blog!

Welcome to my first blog post! Sometimes the fall
I think of different ideas and I thought that perhaps we might do something about it and to share them - hence the idea of \u200b\u200bblogging. Topics will probably be fluctuating around the issues that preoccupy my head, mainly: dynamic programming languages \u200b\u200b(Ruby, PHP, Python, Javascript), configuration and use Linux, but maybe something else (beer?, Windows?:)). Maybe someone interested
recorded ideas and experiences here, and maybe he'll be able to look at the issues described here from a longer perspective.
invite you to visit and comment.