Layered PNGs in GIMP

Posted 21:16, 6/5/2008, in Ubuntu

I quite often get website creative supplied in PNG format, particularly from our main designer who uses Macromedia Fireworks. Fireworks saves these by default with layers, which can be useful when convering layouts into HTML/CSS, but I never understood why these layers were gone when I opened the file in the GIMP.

It turns out, the reason is because... the PNG format doesn't support layers! The format does allow for files to contain some extra data, which is apparently where Macromedia stores the layer data. So much for the 'portable' network graphics format.

Comments (0)

Setting up PDT 1.x, Eclipse 3.3 on Ubuntu Hardy

Posted 13:03, 3/5/2008, in Ubuntu

Not quite convinced by PHP under Netbeans, I decided to go back to the PDT plugin for Eclipse for my PHP development. Unfortunately setting this all up is much more complicated than it should be, since the current release version of PDT requires Eclipse 3.3+, but the latest version in the Ubuntu repositories is 3.2.2.

There are alternative ways to install this of course, the PDT site offers an all-in-one package, or you can download Eclipse 3.3 from eclipse.org, and go from there. However I've never had too much luck with these.

So here's how to get it working:

  1. Install the latest version of Eclipse from the repositories (you can do this either via. Applications > Add/Remove, via. Synaptic or via. the command line).
  2. Update Eclipse to 3.3.x using its own build-in auto-update function. To do this:
    1. Run Eclipse via. the command line as root - sudo eclipse (this is important as otherwise your update will fail when it tries to overwrite some of the core files)
    2. Add some new update sites (which I got from this blog post), you can either add them manually or import from the from the supplied XML file.
    3. Select the most recent Eclipse 3.3.x version and then follow all of the installation instructions (will take a few mins).
    4. Exit the program
  3. Install PDT. Run Eclipse normally (not via. Sudo), you should get the 'Europa' splash screen, which will confirm that you're running version 3.3.x. Help > Find and install updates etc. Select PDT and its depdendencies, and install.

et. voila.

Hopefully the next Ubuntu release will include an Eclipse update, which will make this process a lot easier.

Comments (0) Tags: pdt, eclipse

Zend Framework in Ubuntu 8.04

Posted 14:42, 27/4/2008, in Web, Ubuntu

With the release of Hardy, the Ubuntu repositories now include a package for the Zend Framework, so you can have just one copy of the library on your server that is automatically updated. To install and use this:

sudo apt-get install zend-framework

then add it to the include_path for your app, in a .htaccess file:

php_value include_path '.:/usr/share/php/libzend-framework-php'

you can then require in Zend Framework classes as you need them, or use the Zend autoloader to pull them in automatically when instantiated.

Comments (0) Tags: zend framework, php

Ubuntu 8.04 released

Posted 14:09, 26/4/2008, in Ubuntu

Thursday saw the release of Ubuntu 8.04 (codenamed "hardy heron"). Since I had a load of new PC bits arrive yesterday, I had the opportunity to compare installation of both XP and Ubuntu from scratch on the same machine.

The XP installation took about 40 minutes (not including the initial disc format), during which there were a few interruptions where I had to select my country, language, keyboard layout etc. After it was completed, the machine booted into a very low resolution desktop with fairly sluggish graphics performance and no networking.

The Ubuntu installation on the other hand took 10 minutes (including the repartitioning), had fewer interruptions, and afterwards the machine booted into my screen's native resolution, and everything was working out of the box. The only thing I had to install was the non-free Nvidia drivers for my graphics card, which took a few clicks (no CDs or web searching required).

My only complaints about the Ubuntu installation process are the partioning screen, which still uses terminology that would scare off a lot of users. Since it can detect if any other operating systems are installed on the disc, really it should present some simple options like:

  1. Install Ubuntu on disc XXX, alongside your current Microsoft Windows XP installation
  2. Install Ubuntu on another disc (if there's more than one in the machine)
  3. Replace your existing Microsoft Windows XP installation (warning about deleting data)

if the user chooses option 1 they're presented with the slider to control how much space each OS should use (and it should default at giving each 50% of the disc space).

Manual creation of partitions, and terminology like 'contiguous space' and 'swap' should be hidden behind an advanced/manual configuration screen.

Netbeans vs. Eclipse

I'm also considering switching from Eclipse to Netbeans for PHP development. I'm already using Netbeans for Ruby (i.e. Rails) stuff at work, and I've never been especially happy with Eclipse. It's not particularly easy to setup (largely because the Ubuntu respository holds version 3.2 which isn't compatible with the latest version of PDT), and generally the more plugins you seem to add to it, the more flakey it becomes.

Netbeans is certainly much easier to setup - the version from the repository works straight out of the box, and adding plugins is a simple as ticking the ones you want to install from a menu. I believe both apps are Java-based, but Netbeans generally feels more responsive, and there are fewer hangs whilst the app reparses some code.

However, the PHP plugin for Netbeans still seems to be in its infancy. Once installed, I opened a sample PHP file and was presented with a horrible lime green background behind all the code. Apparently this isn't something that can be changed in the preferences yet (!). The code was all shown in a serif font, even though the options had it set to use a monospaced one.

Comments (0) Tags: ide, pdt, netbeans, eclipse

MySQL - weighting fields in LIKE searches

Posted 13:32, 22/4/2008, in Web

A client asked us today if we could do some work on their search feature to weight the ordering of results if the search term appeared in the title. The site is running a fairly old version of one of our products which uses a very basic LIKE search (the current version of the same system uses a Lucene-based system). The example search term they gave was a 3-letter word, which pretty much rules out MySQL fulltext (when you start reducing ft_min_word_len fulltext searching gets pretty slow), so we came up with a way of weighting standard LIKE searches:

SELECT title, description,
IF(title LIKE '%who%', 3, 0) +
IF(description LIKE '%who%', 2, 0) AS weight
FROM `products`
WHERE fullname LIKE '%who%' OR brief_description LIKE '%who%'
ORDER BY weight DESC

What this does is create an arbitary 'weight' value purely based on which field(s) the search term appears in. This value is used to order the products.

Yes, it's slow, as it's doing a two LIKE searches for every field, for every search term. But in this relatively small dataset (~200 products), it still runs in a fraction of a second so it's okay as a temporary solution.

Comments (0) Tags: search, mysql

Search this site
Login
(or login/signup the old fashioned way)
Elsewhere

External URLs/articles that may be of interest:

Drupal in the Enterprise

An interesting look at why the author doesn't feel Drupal is ready for the enterprise. Drupal certainly appears to be one of the better CMSes around, so some of these criticisms seem a little harsh when you compare it to some of its inferior competitors. However many can also be applied to PHP web apps in general.

BBC admits Linux usage figures were off

Recently the BBC said one of the reasons they didn't push for a Linux compatible version of their iPlayer was that their website only received about 600 visits a week from Linux users. They've now admitted this figure is closer to 100,000. Just a bit off then.

Online ad tracking 'opt out' list

Lobbyists in the US are trying to get an 'opt out' list created for online advertising, so users could choose not to have their browsing habits tracked. The irony is, for this to work technically, some system somewhere would have to create a huge list of IP addresses and personal information, which seems to defeat the point.

Amazon Patents Including a String at End of a URL

Amazon has patented searching by including a search term at the end of a URL, e.g. www.domain.com/Search Term. The US patent system is beyond a joke now, if you want prior art, PHP.net has been doing this for at least 6 years.