02 July, 2009

Hacking away at PHP

I got involved with a geocaching TB race being held here in South Africa. The race rules were all set up by a geocacher called cincol who is a South African living in Qatar. At first I offered to keep score with him, and then looked for a way to "publish" the scores on the web.
I contacted another geocacher, who publishes cache find scores on a web site for all the South African cachers, and he was quite happy the he would host my few pages on his site.

The previous year the race contained 16 entrants, and I thought this year it would be more or less the same. To update a few static HTML pages would not be a huge task. On the day the race started we had 47 entrants, and at one point I was hoping to break the previous years 16.

This became a huge task to maintain, so I opted to PHP-efy the pages a little. And so began my first look at PHP. I have done a few financial web sites in ASP, so thought it could not be to hard.

There were times I found it very frustrating to work with PHP, as I had no intellisense, but was quite intregued in how I could address an array in PHP (key/value pair).

Another cacher (Far-Jar-Hug) pointed me to a PHP script which could extract GPS points from a KML file, and create a small signiture item for ones Travelbugs. Link:caughtatwork

This set me on enhancing the static info of the travel bugs to include the last location of each bug. I wanted to add the GPS position as well, but this has very little meaning unloss you are seeking a cache. After a little bit of a search on the net I found GeoNames, which will give you the country, province / state, and near which town it is.

As the page loaded very slowly, I set out to optomise it a little and cache the info localy on the web server, but this does require me to log in once every morning to get the new KML and location files. But hay it works for now.

As I mainly program in C# now, I found it quite interesting how another language works. Sometimes I found PHP very primative, and not very well structured, but this could be due to my inexperence in PHP, and other times quite amazing. All in all, I am enjoying the little bit of hacking I am doin in PHP.

I was also amazed that I was able to download install and run an Apache server (MicroApache), using PHP on my windows maching and the complete download was less than 2 Meg. That is impressive! So I can code, debug, fix the pages localy on my machine, and upload to the Linux server where it is hosted. One thing I battled with though is getting the configuration just right to work. I event ran it of my USB stick for a short period.

I was put in touch with someone else who is hosting a TB race in the states. I zipped up the files and sent the web site off to him. With the questions and issues he is having, I can see it should maybe rewrite it with less hardcodeing and more configuration options. But the site did not start out to be hosted multiple instances. Maybe refactor it and then put it on source forge, if there is a small demand.

03 May, 2009

Geocaching CITO event / 350 finds.

Yesterday the 2nd May 2009, we reached 350 finds, at a geocaching CITO event. CITO stands for Cache In Trash Out, and it is the geocaching way to give a little back to nauture, for giving us such great adventures and hiding spots for this great game. The 2nd may was also international CITO day world wide, and we were one of many events that cleaned a park somewhere in the world. At my last check there were more then 1000 photos uploaded to CITO Event.

In total we were about 26 people, where of 6 were school going kids, at this the only South African event.

We arrived at the given co-ordinates, and were give some yellow plastic bags, much stronger then the black bags we use at home, tehn some instructions, and then sent into a small velt /nature reserve.

We slowly moved down the park on the southern side of the river, pickup up trash. We even found an odd tennisball, soccer ball, hocky ball, and golf ball, hit over the school fence. One guy even found a small scooter. By the time we got to the bottom of the park, the bakkie, was layden down with trash, and straps had to be used, to keep the bags from falling off.

The return path back to the top on the northern side was much quicker, and I saw a huge bee hive in one of the drains.

Once at the top we took another photo, of bakkie with trash, and and then went to a nearby lapa where we had a social get together, and a braai.

In total, I recon, we picked up more then 500 kg of trash. Not bad, if you consider that Joel, the park's person in charge of this area, sent in his guys 3 weeks, and they all returned with half a bag full each, saying the park is now clean.

I am glad that I have now completed my first ever CITO event, but would not like to do it to often. Once a year I would be happy with. I have now removed much, much more trash in weight, then I have hidden to date.