A WordPress Theme

August 29th, 2010

Here is a first attempt at a WordPress theme. I created it one weekend in June that surfaced from two things:

  • An evolving story behind a WordPress theme that I purchased.
  • A “thank you” comment that I received on the blog.

Although it is not complete and does not look gorgeous, it’s functional. I’ve tested it for consistent viewing and printing in IE 6, IE 8, Safari 4, Safari 5 and Firefox 3.6.

Requires: WordPress 3.0

Current release: v0.20 [ Download ]
Next release date: October 3rd, 2010.

Native PHP SOAP Tips

June 26th, 2010

PHP 5 introduces two new classes, SoapServer and SoapClient. Rather than explaining what they do, I will cover some of the issues and solutions that I’ve encountered while working with them.

  1. If SoapServer and the SoapClient classes are not found on a Unix-based machine, configure PHP with the --enable-soap option and rebuild it.
  2. Although Soap server and clients are available, there is no native support to generate WSDL documents. If you want to generate a WSDL document from source code, I found the following package useful which parses PHPDoc comments and generates its corresponding WSDL document. Keep in mind the following about the package:
    1. Some method calls are depreciated in PHP 5.3.0 and will create notice errors. You will need to change these.
    2. Add additional primitive types (i.e. float and date) to the $primitives property in WsdlType.php.
    3. Parameters containing an underscore aren’t recognized. You will need to modify the $docBlockTags property (sub-keys @param, regex) value in DocBlockParser.php to correct this.
  3. Warnings and notices generated from the server are transmitted to the client. I found it necessary to buffer the response and extract the text inside of the opening and closing envelope tags. If you receive a “looks like we got no XML document” message in your error logs, be sure and trim any whitespace around the response.
  4. During development set the cache_wsdl SoapServer option to WSDL_CACHE_NONE.
  5. If you want to transmit a Soap fault message from a process that is outside of a SoapServer::handle call , use SoapServer::fault. Note that program execution stops at this point.
  6. If you want to alter the return response of an array so it can be interpreted easier by the client, try returning a new SoapVar($an_array, SOAP_ENC_OBJECT);. The downside is that SOAP is no longer transparent.
  7. If responses are not transmitted to the client even though the method called does return information, the culprit could be a missing output tag in the WSDL document.

Shrinking (Encoding) Video

June 6th, 2010

This walkthrough goes through the process of shrinking (technical term, encoding) a video file into two popular video formats in the fewest number of steps. The original problem dealt with encoding a video taken with a Camera Powershot SD990 IS point-n-shoot digital camera and sending it over e-mail. These cameras lack the processing power to encode video as it’s recording, leaving you with a large file. Details concerning the video in question are:

  • Dimensions: 640×480
  • Time: 34 seconds
  • Size: 43.8 MB

I should mention that sending videos over e-mail are not guaranteed. Sending a 9 MB encoded video from one RoadRunner e-mail account to another will not work; whereas, sending the same file from a Hotmail to a RoadRunner e-mail account will.

Two video formats that this walkthrough will cover are contenders in the latest HTML5 video battle.

A. Theora – Supported by Mozilla / Google web browsers. (Container: Ogg)
B. H.264 – Supported by Apple / Microsoft (Internet Explorer 9) web browsers. (Container: MP4)

The video and audio portions of file encoded are placed into a container.

Read the rest of this entry »

PHP / Java Servlets

May 23rd, 2010

This illustrates the use two web programming languages, PHP and Java, to accomplish the same output in a simple example. In this example, they are used independently of each other. Any use of forms and associated problems with them are deliberately avoided. Any use of frameworks and additional libraries are also avoided. Note that my use of PHP is current, and my last dealings with Java are from 2005.

PHP

PHP is a programming language tailored for the web. It plugs into a web server as extension, a library that understands how to process files written in that language. Files can contain HTML markup intertwined with source code. Source code begins with <?php and terminates with ?>.

Java Servlets

The standard edition of Java runs from the command-line and has the capability to run desktop applications; however, it requires use of a servlet container to run on the web. This container supports two Java technologies:

  • Servlets – Classes that extend HttpServlet support inbound web requests. These classes override one or more of the following methods: doGet and doPost. There are two other methods, doPut and doDelete, but quite frankly, I have never used them.
  • JavaServer Pages (JSPs) – Allows intermixing HTML markup and Java source code. The Servlet container compiles JSPs into Servlets. Source code begins with <% and terminates with %>.

Note

In either language, heavy intermixing of HTML and source code will equate to a long-term world of hurt.

A Simple Example

The following example will calculate the calories burned while running a given mileage in terms of doughnuts. To keep things simple, we will assume that the caloric burn rate while running is 100 calories per mile and the number of calories in a doughnut is 250 calories.

This will be accepted using a HTTP GET request.

Read the rest of this entry »