Skip to content

Archive for July, 2009

31
Jul

iPhoneDevCampDC Presentation Overview

I’m going to the iPhoneDevCampDC tonight and tomorrow. I will try to present the following. Hope I can get the vote.

http://www.youtube.com/watch?v=_4m33PdMljw

24
Jul

Handling NULL type in the XMLRPC2 package

While working on a client project, I came across an interesting issue in the PEAR::XMLRPC2 package. By default, it uses the xmlrpc C extension in the system. Now that is great but the implementation of that library is so slightly different between different platforms. I found that on Ubuntu, that library can’t handle utf-8 encoding (if you know how to do that, let me know), and in some other system it’s missing all together.

I also found out that you can switch it to use the Php implementation of XML encode/decoding so it should be more cross platform. Great. However, that package doesn’t handle the NULL type, which the xmlrpc extension does!

As we already have multiple projects using this and many databases have NULL in it, I don’t want to do through every project to ensure we don’t send NULLs across, I went ahead and hacked the Php implementation to handle NULL.

Here is what I did (May not be completely correct, if you have better solution, let me know).

STEP 1: Update Value.php
Goto: XML/RPC2/Backend/Php/Value.php. Search for NULL. You will see it explicitly throws an exception. Change the case statment:

case ‘NULL’:
$explicitType = ‘null’;
break;
case ‘resource’:
case ‘unknown type’:

Then a few lines below, yet another switch-case statement, add the handling of Null:

case ‘Null’:
return ”;
default:

That’s it for Value.php. Now any independent Nulls will be handled correctly.

STEP 2: Update Struct.php
To avoid Struct calling encode() on a null pointer, goto /XML/RPC2/Backend/Php/Value/Struct.php. Goto encode(), add two lines:

$result .= ‘<value>’;
error_log(“element is $element”);
if ($element==null) $result .= ‘<string></string>’;
else
$result .= ($element instanceof XML_RPC2_Backend_Php_Value) ?

That’s it.

Now your xmlrpc will return empty string for NULL.

OK, so null is not empty string right? And one should not try to send null through XML? Correct. That’s why on new code, like on the iPhone, I’m coding to avoid sending NULL through XML. But on server code, many many of them, I’m just lazy.

Again, should you have better solution, let me know.

24
Jul

WordPress Expert!

Yesterday, my co-worker called and said where can he find a wordpress expert and said someone should be able to get it done in an hour. So, I asked, what do you need?

  • I have 3 themes that I like, I want to mix them up.
  • I want to do wrapper pages just like I could in Joomla.
  • and…

Wo, wo, I said, even if someone is very good with WordPress they can’t get that done in an hour. So, Sze being Sze, said, “I will look into it.”

By 3 pm, I finished:

- Mixing the overeasy theme with videographer theme so some posts uses videographer’s templates.
- Created custom sidebar for different pages
- Created a new wrapper template for wrapper external pages.

Am I a wordpress expert? No. I am just a friend.

10
Jul

UIButton setTitle issue in iPhone OS 3.0

I was working on a client project and come across a bizarre issue. I eventually solved it. Here is the issue, see if you can spot where the problem is.

The following few lines of code generates a button with label “Next” in SDK 2.2.1 but under 3.0, the label is gone.

UIButton *nextButton = [[UIButton buttonWithType: UIButtonTypeRoundedRect] initWithFrame:CGRectMake(183, 30, 65, 25)];
[nextButton addTarget:self action: @selector(nextSettings) forControlEvents: UIControlEventTouchUpInside];
[nextButton setTitle:@"Next" forState:UIControlStateNormal];
[nextButton setTitleColor:[UIColor blackColor] forState: UIControlStateNormal];
[self.view addSubview:nextButton];