Archive for the 'Programming' Category

SimpleXMLElement attributes

Ya unless you work on PHP SimpleXML that title won’t make much sense. But if you do and you need to mess with SimpleXML as I have been lately to parse some Media RSS feeds you will need to use this function.

I was using it to store some urls in a drupal job queue and it was dropping in serialized SimpleXMLElement objects rather than urls.

If you go to the relevant PHP manual page you will find a comment that explains that you need to cast these attributes as string to get the value I was looking to store.

What was more interesting was Googling php SimpleXMLElement shows the solution on the second result as a summery.

Damn they are good.

Popularity: 2% [?]

Selling out

The state of Java and MySql are changing. In case you missed it. Sun bought MySql and Oracle bought Sun. I’ve been working on Java for over 10 years and MySql for over 5 now. I’m not happy with what is happening.

The Java and MySql websites have changed. On the mysql.com site there is no prominent link to get to the community edition. If you go to mysql.org to redirects to dev.mysql.com where you can find it.

This is not good for me or a country like Sri Lanka. Most of the solutions I’ve been involved over the years have used open source foundations. So we were able to deliver solutions to clients at a very reasonable cost. If things get too commercial I’m a afraid the licensing costs will far overtake the implementation costs.

I’m sure there will always be open source or free to use versions of Java and MySql, but with a large commercial entity backing them profit comes first then community. I don’t know I think its time to look at some alternatives.

Update: They got to VirtualBox too.

Popularity: 1% [?]

Open Path IT Rebooted

Open Path IT

I’ve finally got around to putting up a page (ya just one for now) showing my freelance work. I’ve been freelancing here and there since around 1996. Most of the things I built have been too small to mention.

I give you Open Path IT.

Just a basic start for now. Open Path IT (Information or Inspiration Technologies) was supposed to be a software company that never got formed. One day maybe.

So if you got some work or looking for work within the skill-set I’ve mentioned get in touch.

Popularity: 1% [?]

Jar Clean Up Story

I’m pretty happy with moving some common Java libraries out of the project source folders.

I have about 4 branches of the same project checked out. Each of them were about 57mb a piece. I noticed this while I was trying to sync my projects to a remote server. (I hate slow running scripts)

I managed to move the jar files out to a common folder which was about 27mb. I wrote another recursive ant clean script (which I will share below) that helped me clean up before the sync.

Moving the libraries was relatively simple with a few changes in the ant build scripts.

Anyway I managed to bring down each project to about 10mb. Here is the recursive ant clean script.


#!/bin/bash

projects=~/projects

for project in $(ls $projects/);
do
if [ -f $projects/$project/build.xml ]; then
echo ""
echo "Cleaning $project"
cd $projects/$project
ant clean
fi
done

I tried a similar script in Windows batch, didn’t work as easily. Don’t need bat files, Cygwin is better. And the same bash shell scripts on Linux most of the time with little or no modification.

For a programmer tweaking never stops. I try not to work on Sunday. But its a good day to take a step back and do backups, cleanups etc.

I knew about this jar duplication but really saw it while trying to run a backup and then looking at the projects folder with jDiskReport. Need more tools like this.

Popularity: unranked [?]

Fixing PHP Redirect On Nokia N80 Web Browser

I had a problem on a PHP page that was supposed to redirect to another page after some process was done. This is the code I used.


header("Location: http://example.com");

This kept giving me a


Web: no gateway reply

So after looking at the PHP manual for the header function and HTTP status codes I managed to get it working with this redirect.


header("Location: http://example.com", 307);

Popularity: unranked [?]