Archive for March, 2007

The quicker way to test odd or even

Tuesday, March 27th, 2007

The mathmatically way
Explaination: We all know an even number is multiple of twos, and odd numbers are not. is_float is a PHP function test if $number divided by 2 is a whole number or not.

Show Code

  1.  
  2. echo is_float($number/2);
  3.  

Using bitwise operator
Explaination: In PHP & or AND is a bitwise operator. When used it performs bitwise operation between two numbers. In the following example, the operator will test if the last bit of $number is 1. Thus successfully tests if $number is even or odd.

Show Code

  1.  
  2. echo $number & 1;
  3.  

Conclusion:: Use bitwise operator to test an number is odd or even is much faster than using the division method. More detailed instruction can be found here.

REST web service with Delphi

Monday, March 26th, 2007

When I was looking for examples of how to make REST calls in Delphi 7, I found
XML-RPC for Delphi. XML-RPC for Delphi is an object library that utilises Open Source Indy Components and helps your application connects REST web service. XML-RPC comes full source code and some examples, but does not come any documentation.

Here is a round up of what XML-RPC supports:

  • Basic data types, string, interger, datetime etc.
  • Array data type
  • Struct data type
  • Automatic data type conversion between Delphi data type and REST data type
  • Base64 string conversion

I am current using XML-RPC to develop a Wordpress client in Delphi. I will post more result and findings in the future.

Winhelp for Windows Vista finally available for download

Sunday, March 25th, 2007

Winhelp support were not included in any of the Windows Vista editions when it was released. Though winhelp is still depreciated in Windows Vista, Microsoft had finally released vista compatible Winhelp program.

Here is the direct download page.