Blog entries from March, 2009

Riding out west, including going the wrong way

Sunday, March 22nd, 2009 at 5:32 pm

Yesterday Damien and I went for a ride:

Bicycle Path - Federation, Werribee River and Skeleton Creek Trails at Bikely.com

We covered:

The Skeleton Creek Trail was not part of our initial plan, our plan was to head back up the Federation Trail and around the Western Ring Road Trail to Albion Railway Station. Because of this change we were not aware that there was only one bridge on the Skeleton Creek Trail that allows you to cross from the west side of the creek to the eastern side.

We did not use the bridge and continued along the west side of the creek, which meant that once we reached the end of the path there was no way to cross over. However Google Maps did show a ford across the creek which we did use to cross over, but only after jumping a fence into the Cheetham Wetlands. We then crossed over a small channel to get back to the path on the east side of the creek.

In hindsight we should have crossed the creek at the bridge, but the way we ended up going was definitely more interesting.

Tagged with:

StixCampNewstead was awesome

Thursday, March 19th, 2009 at 8:16 pm

Last weekend was StixCampNewstead, a Melbourne BarCamp out in the sticks. The general consensus is that the event can be summarised in a single word:

Awesome

This one word covers:

  • the talks/discussions – schedule of talks
  • the venue – Welshmans Reef Vineyard
  • the food – BBQ lunch; wood fired pizzas; bacon, egg and sausage rolls; homemade dumplings
  • the people – too many to list
  • the adhoc discussions – to varied to list

If you didn’t come along, you must come along to the next BarCampMelbourne in September and next year’s StixCamp, wherever that will be.

Over the weekend I took almost 600 photos, earlier in the week I sorted through them an uploaded 129 into a set on Flickr. There are photos from others on Flickr, or you can check out what people said before, during and after the event on Twitter or Identi.ca.

Tagged with: , , , , ,

Tether Nokia 6120 classic to OS X for data

Thursday, March 19th, 2009 at 7:41 pm

When I am on-call for work I am required to remain within 30 minutes of a suitable internet connection. I am on-call this weekend, but I was planning to go for a ride along the Federation Trail.

That would be a problem, until a mobile broadband card was suggested and I remembered that we had data enabled on the on-call phone. So I could just take my PowerBook along with me.

The steps to get online through a Nokia 6120 classic on my 12″ Apple PowerBook (running OS X 10.5.6):

  1. Connect phone via an A to mini-B USB cable
  2. Phone should be in ‘PC Suite’ mode
  3. Open System Preferences > Network
  4. Two Nokia 6120 classic interfaces were detected. (each time I connected it is detected two more…)
  5. Select the first of the new interfaces
  6. Click Advanced
  7. Set vendor to Nokia, then the only model available was GPRS (GSM/3G)
  8. I entered Telstra.wap as the APN after looking at the existing phone settings, and left CID as 1.
  9. OK, Apply, and Connect
  10. Browse the intertubes

One caveat for these instructions is that data was already setup correctly on the phone, I did not have to do that.

It should also be possible to set this up over Bluetooth instead of USB, but I know this works and it’s not as if I will need it very often. I just need to remember three things: the phone, my powerbook and the USB cable.

The connection was surprisingly responsive and I have to say that the Telstra Next G network does appear to be quite nice (they sponsored StixCampNewstead last weekend with a connection), although I would never pay for it myself.

Tagged with: , , ,

Contributing back to wp-lifestream

Sunday, March 8th, 2009 at 5:09 pm

I have just finished sorting through the changes I have made to my install of the wp-lifestream plugin and have posted some patches to the support forum:

Hopefully they are incorporated back into the plugin.

Tagged with: , ,

Sorting in PHP is extra effort … and there is no spaceship

Monday, March 2nd, 2009 at 10:47 pm

Tonight I have been hacking in PHP on wp-lifestream in order to get grouped events ordered by time. I say hacking because there is a lot of PHP I don’t know and I don’t fully know how wp-lifestream is arranged.

When I first looked into sorting the grouped events my initial thought was to do it when the group was rendered. However that involved sorting data structures, so I decided that it would be easier to perform the sort when they were retrieved from the database. This is the change I made, and I thought it had worked.

Earlier today I found that while it worked when a feed was refreshed, it didn’t work when the group was updated after an event was deleted through the interface (I uploaded one too many photos to Flickr, which I later remved). So I had to turn back to the rendering code.

A var_dump() (Perl people should think Data::Dumper) later I knew what I was dealing with: an array of associative arrays that represented each item in the group. The relevant keys being date (in seconds since epoch) and title.

If this were perl it would be an array of hashrefs and I would have sorted it like this:

@events =
    sort { $a->{'date'} <=> $b->{'date'} || lc $a->{'title'} cmp lc $b->{'title'} } 
        @events;

Not so in PHP:

  • PHP sort functions sort the array in place instead of returning a new list
  • The more advanced PHP sort functions take a callback to use instead of a block
  • I’m not using PHP 5.3 so there are no closures yet, but at least anonymous functions can be created with create_function()
  • PHP does not have a spaceship operator (<=> for numerical comparison), even though there are equivalents of cmp (strcmp, strcasecmp).

This is what I ended up with:

usort(
    $data,
    create_function('$a,$b', '
        if ( $a["date"] == $b["date"] )
        {
            return strcasecmp( $b["title"], $a["title"] );
        }
        return ( $b["date"] < $a["date"] ) ? -1 : 1;
    ')
);

To me the logic is all messed up. Because there is no <=>, it needs a == comparison first. In the usort examples this returned 0, but gave me a convenient place to call strcasecmp() for the secondary sort. But that is breaking one sort into two statements and mixing in the other sort. It works and appears to be the PHP way of doing things, but it looks wrong to me.

(And yes, create_function() takes a string. Shudder…)

Tagged with: , , , ,