Soap, lather, rinse, repeat
I have had to deal with Soap lately. Mostly it works, except when it doesn’t. In my case I found out that its not exactly straightforward to make a Nusoap client talk to a PHP5 Soap server. Of course, it also depends on the WSDL. Probably. Maybe. In any case I was in a world of pain, which I do really not want to describe in more detail.
But then I found this article, and it made my day
S stands for Simple. I have been suspecting this, but now its proven. Sigh.
Let me sum up. The definition of SOAP is in constant flux, SOAP is anything but simple, and it is no longer meant for accessing objects-even though that’s what all the tools still do.
Python API for TargetApi.com
Have you ever used DailyPerfect? Try it, its quite nice. Now the guys who built it have released their API for public use, it is called Target Api and is available at www.targetapi.com, there you can read about it and sign up for API key.
Once you have the API key, one the options to actually play with it is through Python, using a little library I wrote and made available at GitHub.
http://github.com/antiveeranna/py-targetapi
Go, read the source, checkout, fork, improve, play, contribute your improvements, whatever rocks your boat
Getting started with Unit testing your PHP Code
Giorgio Sironi compiled a really nice e-book explaining practical PHP testing with PHPUnit. You can download the book from his site.
PHP type juggling
Given the following piece of PHP code:
$a = '1112000000001779149'; $b = '1112000000001779148'; var_dump($a == $b);
Can you tell, without trying to run it, what the result is?
The answer – it depends on your platform. On a 64bit platform you will get boolean false, on a 32bit platform you will get boolean true.
Why? Because PHP does type juggling, if strings are compared and they look like numbers, then they will be convereted to numbers before doing the comparision. And the following piece of code demonstrates the behaviour:
print php_uname('m');
print "\n";
print PHP_INT_SIZE;
print "\n";
print (int)1112000000001779149;
print "\n";
If you run it on different platforms, then this is the result that you will get:
x86_64 8 1112000000001779149
i386 4 -1
From this its already obvious, why the above string comparision resulted in true on 32bit platform. Its because -1 indeed equals -1.
Solution?
Either use === for comparisions, or if you care about your numbers, use the bcmath extension
Eating habits of developers
This one started out as an internal joke, but it has become quite generic
* Java developers always go to eat together, in pairs, hand in hand, well organized (synchronized)
* PHP devs go at random times, some of them run, some walk, some take the elevator. (loose coding style)
* DB devs choose someone, who will then go to kitchen and fetch the food for everyone (also known as proxy)
* Delphi devs get the plate, put it in the center of kitchen, then get a fork and then walk between the food containers and plate, until plate is filled (drag ‘n drop)
* C devs kill their own animals and eat them raw (low-level)
* C++ devs prepare their food from prefabricated components in microwave oven (not that low-level)
* Frontend (HTML) devs decorate their food with cucumbers, tomatoes and generally everything else in the fridge and then play around with it until the food is cold
* Python devs always take the stairs (mandatory stepping) (from Jaagup Irve)
* Perl devs bring their own food to the work and eat it alone in the corner, while everybody else is giving them weird glances (You call THAT food? eewwwww) (syntax)