Showing posts from April, 2009

Zend_Pdf not as useful as it sounds

So I started using the Zend Framework in a new PHP project as it seemed to be my one-stop-shop for authentication, access control, pdf-generation, database abstraction, etc. Well it turns out many of these components are not as useful as they sound.

The Zend_Pdf component is described as:

The Zend_Pdf component is a PDF (Portable Document Format) manipulation engine. It can load, create, modify and save documents. Thus it can help any PHP application dynamically create PDF documents by modifying existing documents or generating new ones from scratch.

Sounds great! Let's use it to create a report containing some simple text, a few lists, a few long paragraphs, and perhaps a table or two. Umm, feeling lost? Maybe we should start with this tutorial describing all the basics. Here's a Hello World minimalistic example extracted from this guide:

//load Zend_Pdf if not using the auto Zend_Loader

//create PDF document instance
$pdf = new Zend_Pdf…

Google Chrome Firefox Theme

The one thing I miss most in Ubuntu is Google Chrome. While Google is working on a Linux version, this may not come out for years, if at all, meaning I have to go back to FireFox :(

Not that FireFox is bad or anything, but I like the Chrome minimalism approach. Luckily however it's possible to install various themes and add-ons to closely replicate the Chrome look.

This can be achieved as follows:
Install Chromifox theme.Install TinyMenu add-on.Install HideCaption add-on (experimental).Play around with toolbars until you get the right feel.The end-result will look something like this:

Note however that while this may look like Chrome, Chrome it ain't:
New-tab + button is missing.Tabs are below address bar instead of above.
Address bar doesn't double as a search bar the same way as it does in Chrome. Maybe this can be configured, I haven't looked into it much.FireFox is not as fast as Chrome. No, really. It isn't.All in all, I can live with it though. The theme gives me t…

Ubuntu 9.04 on Lenovo X300

I've recently installed Ubuntu 9.04 on a second partition of my Lenovo X300 laptop, dual-booting with Windows XP. The whole process was surprisingly smooth. I downloaded the ISO from a local mirror, burnt to a CD, restarted my PC, chose to boot from CD and then chose to install to hard-disk.

The installation wizard guides you through 7 simple steps, the most important being the partition selection, which automatically detected I had Windows XP running and gave me a few options to either dual-boot, use the whole disk, or manually configure the settings. I did encounter some errors here when formatting the new partition, something about not being able to mount a certain drive, etc. I chose to ignore these and continue with the installation, which was finished in about twenty minutes or so.

Once the installation is done, booting into Ubuntu takes about twenty to thirty seconds (feels about the same as my XP partition). The surprise however is that Ubuntu seems to have detected all of m…

LaTeX Lessons Learned

This post is a collection of lessons learned as a LaTeX newbee. Hopefully these will help others save some time when starting out. LaTeX can be pretty daunting on first sight.
List Line Spacing The following code-snippet shows how to reduce the line-spacing between enumerate/itemize list items: \begin{enumerate}
\item\setlength{\parskip}{-3pt} Item line one.
\item Item line two.
\item Item line three.
\item Item line four.
Page MarginsThere are many different ways to control page margins. The easiest solution I've come across is to use the following package declaration for 1 inch margins all around: \documentclass[10pt,a4paper]{article}
BibTeX Bibliography Title Casing
If you're using BibTeX in your LaTeX documents, you may have noticed that Titles in the Biblography/References section at the end of your documet get converted into sentence-case format. That is, the first letter of the Title is capitalized …

Eliminate require_once with Zend_Loader::registerAutoload();

This is a quick post on how to use the Zend Framework Zend_Loader component, and namely the bundled autoloader, to eliminate the need for require_once() statements in your PHP class files. Just place something like the following code somewhere in your bootstrap file (or main index, or any other file executed early in the cycle of every request):
'../../private/library' . PATH_SEPARATOR .
'../../private' . PATH_SEPARATOR .
'../../private/library/Util' . PATH_SEPARATOR .
'../../private/services' . PATH_SEPARATOR .
'../../private/services/helpers' . PATH_SEPARATOR .

require_once "Zend/Loader.php";
The Zend autoloader works on the convention that any referenced class will reside in one of the directories in your class-path and will be contained in a file of the same name plus a .php extension. That is, if your cod…

VCSM - An SOA/RIA Friendly MVC Upgrade

Anyone who's done any web-development in the last 5 to 10 years is probably familiar with (or has at least heard of) the MVC (Model-View-Controller) design-pattern. The pattern is adopted by more-or-less every notable web framework in every development language, from PHP to Java to ASP and to Flex.
In its simplest form MVC is merely a separation of layers, i.e. the Model is responsible for data access (be it from a DB, a CSV file or a Web Service), the Controller is responsible for encapsulating business logic surrounding processing of user actions, and the view simply represents information passed back from the controller to users in different forms. An MVC solution has the advantage that you can theoretically change any of the layers independently of the others.
This pattern has worked well for traditional web applications, but some frameworks and developers are beginning to struggle with how to fit in SOA hook points or RIA toolkits into the mix. I've rencetly started using …

Updated Blogger Template, Again

Just changed to a new Blogger template, yet again. I realized commenting wasn't working in the old template (the embedded comment form would not get displayed on post pages even through all the commenting settings were enabled and the archive Enable Post Pages setting was on as well).
Turns out this is a common bug of sorts with many templates, including some of the dull standard templates available by default. The easiest fix for this is to edit your template HTML code and search for this line:
<b:include data='post' name='comments'/>
Immediately below this, insert the following line to enable the embedded comment form: <b:include data='post' name='comment-form'/>
The template I'm using at the time of this writing is based on ITAdvance with a few small modifications (namely around the date header and the search box). You can download the exact template I'm using from here (remember to edit the search action URL and the Admin URL to r…

Zend Studio 6.1 for Eclipse Building Workspace...

I've recently started using Zend Studio 6.1 for Eclipse to try out the Zend Framework and play with some Dojo/YUI PHP integration. Creating a Zend Framework project and slapping together a few controllers and views worked well enough, but when I dumped in the Dojo library, things started going south...
Namely, the IDE will often go into a 'building workspace...' state that seems to last forever. The process is a background thread that seems to be performing PHP/JS code validation, which is all well and good, but you can't save your work or do much of anything else during this time. Any other IDE action you perform usually gets queued behing the building workspace task, meaning you either have to wait for 10 minutes or more for the task to complete (I kid you not), or copy-paste the code in a notepad window and do a forced-kill on Zend studio (cancelling the task doesn't work).
Now I know I may have been partially at fault for dumping both the Dojo and Zend framework …

YUI vs. Dojo and Zend Framework

I'm starting up a somewhat complex PHP project and have choosen to use Zend Framework as my backend swiss army knife. ZF is quiet flexible in allowing you to structure and architect your application the way you want whilst making use of many of it's time saver features. The standard MVC pattern implementation is great as well, but I need to spice up my application with some client-side goodness.
Having previsouly worked on a Flex project, I've been looking for a good component-based Ajax framework/library for integrating with my PHP backend. Seeing as how Zend now includes Dojo in it's framework and IDE, and the numerous other Dojo big-name supporters, I thought this would be the most obvious choice.
I spent a good part of today trying to get a simple example going and hit nothing but problems. Documentation on both the ZF and the Dojo sites is either sparse, incomplete or out-dated. I followed three or four different tutorials to the letter and none …

Google Chrome 2.0 Beta

I've been using Google Chrome as my primary browser for over three months now, and I'm loving it! The bare-metal minimalistic approach is very refreshing and frees up a lot of screen real-estate for actually seeing more of the web-pages you're trying to browse. Oh, and it's fast. Noticibly faster than both Firefox and Internet Explorer, not only at loading pages, but also in system resource consumption.
Having said that, Chrome currently doesn't support custom plugins (v1 or v2b) so if you can't bare to live without gestures or some fancy RSS reader add-on, etc, then Chrome may not be for you. Likewise if you do a lot of WebDev and rely on certain extensions for debugging, then again, Chrome may not be for you.
Nevertheless, the point of this post was to introduce people to Google Chrome 2.0 (Beta). If you've downloaded and installed Chrome from the Google web-site, then you would've been placed on the Stable automatic update channel, meaning you'll o…