Development

Looking forward - looking back

There are some fundamental differences in how Microsoft and Apple does things. If you haven’t been aware of them before switching from a Windows based computer to a Mac, you’ll probably notice some of them pretty fast.

One of the first things I discovered is that things are more “binary” in the Mac world. If you have an external device it either works with the Mac or it doesn’t. There isn’t that middle ground from the windows world where it almost works, but not quite - or worse it works in even week numbers but not when the sun shine.

ZendStudio for Eclipse

For professional PHP development, nothing beats ZendStudio in my book. Currently ZendStudio is in the process of moving from a standalone application to something build on top of Eclipse. I’m sure it might be a wise move on the long term, but there are a few things bugging me with th current version. The number one issue is shown in the screenshot to the right.

Would someone please tell either Eclipse or ZendStudio, that PHP files do not need to be build, compiled or what ever it is doing - besides wasting my time for a few minutes.

PHP4 RIP

In less than 3 months - on August 8th, 2008 - PHP4 reaches end of life. If you still haven’t updated, it’s damn well time to get migration started. PHP5 far better than the previous versions, and if it’s good enough for Yahoo, Facebook and many other huge sites, it’ll probably be a joyride for you too.

Google App Engine

I’ve been playing a bit with the Google App Engine the past few nights. It’s one of the newest toys out of Google, and it could very well be a very important piece of infrastructure to many web developers trying to create a dotcom adventure.

Google App Engine (once they let you in) allows you to run web applications of google’s server infrastructure. With the Google App Engine you can write applications (and run these of your local machine (Mac, Linux or Windows) and even use data storage in your applications. Currently applications can only be written in Python, but Google promises support for other languages later. Once approved by Google and your application is ready for prime time, you simple deploy it, and it runs of Googles Servers.

CVS - Getting started

CVS is a sourcecode version control system, which is just about the best thing which can ever happen to a software project. CVS gives you the power to manage the development of your sourcecode and keep track of changes in the code.

Below there’s a few pointers to the net, where you can find lots of information about CVS and the add-on tools which supplies it. The section called “local content” is our own attempt to add something to the endless pages describing and explaing how to use CVS. Enjoy.

Fetching Image details in Perl

Image::Size is fine, if size is the only thing, which matters. Sometimes, however, it isn’t enough, and when that is the case Image::Info (again fetched from CPAN) is your friend. Point it to a file (through various methods), and it will return a hash with all the information available about the image you pointed at. Most popular formats are supported.

#!/usr/bin/perl -w
use strict;
use Image::Info;

# Just fetch the size
my $imgInfo = Image::Info::image\_info("test.jpg");

# Print out all info fetched from the image
for (keys %$imgInfo) { print " $\_ -> $imgInfo->{$\_}n"; }

exit();

Rotating an Image with Perl

Turning images is quite simple. In the example below an image is turned 90 degrees clockwise, wirtten to a file, turned another 90 degress and written to a file again.

#!/usr/bin/perl -w
use strict;
use Image::Magick;

my $image = Image::Magick->new(magick=>'JPEG');
my $x = $image->Read('test.jpg');

$x = $image->Rotate(degrees=>90); # 90 degress clockwise
$x = $image->Write('test.90.jpg');

$x = $image->Rotate(degrees=>90); # Another 90 degress clockwise
$x = $image->Write('test.180.jpg');

exit();

Database optimization thoughts

If you’re working on heavy duty websites, knowing your database and how to use it best can make a world of difference in terms of performance, and thus you should always optimize the database. That’s pretty much obvious.

The tricky part is how you do the optimization? Often it requires a lot of reading up on how the database works - strengths, weaknesses and other details — and loads of experience. Having a DBA available to help you optimize would be ideal in some cases, but often you need to do it yourself.

Substring magic with mysql

Mysql is a wonderful database, and while many use it, most people only scratch the surface of what the database can do. One of the practical functions available is the substring_index function, and an imaginary mailing list example is a nice way to show how to use it.

Let imagine we have a mailinglist in a table named “mailinglist” and it has a (char) column with the email addresses subscribed to the list. We now want to figure out how many users, that are subscribed from the various domains in the list.

Quality of code

Not  all code are created equal. Some pieces of code are more important than others. The code that powers critical parts of a nuclear power plant is hopefully of a much higher standard than the code behind this site, but how do you recognize which quality of code you should aim for when developing websites?

A website may not have one set level for all content - usually the various pieces which make up the site (no matter if it be classes, files or functions - in PHP). On the level you’re looking, let me suggest, for each piece you judge the required (minimum) quality on two simple parameters: