World’s Most Traveled People

July 11, 2008 - 3:24 pm No Comments

This morning I came across an article on Gadling about Charles Veley, a man who is supposedly the world’s most traveled person. He’s been to… wait for it… 630 of 673 distinct places. Those places don’t have to be countries, just places that are ethnically or politically different enough from elsewhere to constitute being a separate place.

In reading about Charles Veley, I discovered that there is an elite club called the “Travelers’ Century Club” that you can only become a member of if you have visited 100 or more of the 317 countries defined by the Travelers’ Century Club. Like Veley, they also define some places as countries even though officially they are not countries, simply because these areas are “removed by parent, either geographically, politically or ethnologically”. Fair enough!

So, I wonder what it takes to have traveled to 100 or more of these countries. I’ve made a list of all the places I’ve visited to that are on their list…

1. Australia
2. Cook Islands
3. Hawaiian Islands
4. New Zealand
5. Mexico
6. United States
7. Argentina
8. Brazil
9. Chile
10. Peru
11. Uruguay
12. Austria
13. Czech Republic
14. Denmark
15. England
16. France
17. Germany
18. Italy
19. Netherlands
20. Norway
21. Poland
22. Slovakia
23. Spain
24. Sweden
25. Switzerland
26. Vatican City
27. Egypt
28. South Africa
29. Swaziland
30. Bangladesh
31. Cambodia
32. Hong Kong
33. Japan
34. Malaysia
35. Singapore
36. Thailand

The grand total is… 36. Ok, a wee way off yet from sending in my application. Damn.

Anyway, I think I’ve found my new life goal… to become a member of the Travelers’ Century Club. I’m sure my parents will be very proud… :P

Brisbane .NET User Group - aka QMSDNUG

June 24, 2008 - 4:40 pm No Comments

On Tuesday, Chris and I went along to our first .NET User Group (or Queensland MSDN User Group) meeting here in Brisbane. Having attended a few back in Wellington, I thought it would be nice to check out the Brisbane version.

The meetings are held in the Brisbane Microsoft offices, in a very very flash building down town. Like usual, the meeting started off with pizza and soft drinks which is always much appreciated by those attending. The crowd started off small but within a few minutes, there were a lot of people there – I’d say at least 40 or so showed up, not bad (of which only about 3 were girls but that’s to be expected!). The couple of .NET User Group meetings I went to in Wellington were probably about half this size but then again I guess Wellington is a much smaller city than Brisbane.

The topic for the evening’s talk was “Silverlight 2.0 and WPF – what’s the same, what’s different?”. The speaker, Joseph Cooney, was very well informed and well spoken. As the title would suggest, he compared Silverlight 2.0 and WPF but not to try and say that one was better than the other. Instead he wanted to try and inform the audience as to why you would want to choose one over the other, what situations suit which more.

What I took away from Joseph Cooney’s talk is that Silverlight is basically a lightweight version of WPF. It’s meant to be a 4~5mb download and you really can’t package up too many libraries in that. In order to keep that size down, Microsoft have removed mundane values such as all but the main HTML colors in the Color namespace. Really, who even knows what CornflowerBlue looks like??

There are some controls which are only available to WPF and like-wise, others which are only available to Silverlight. I guess this means you can’t really call Silverlight a subset of WPF.

I can’t wait to get to use WPF and/or Silverlight in a commercial manner and hope to start on a project at work or at home that’ll let me spend a bit of time investigating these new libraries and what they’re capable of!

And as for the Brisbane .NET User Group, it looks like a great place for networking and meeting other like minded .NET-geeks so I’m sure I’ll be turning up to future meetings.

Enabling & Disabling ASP.NET radio buttons using code-behind and JavaScript

June 19, 2008 - 12:35 am 2 Comments

I have just come across a strange problem when trying to disable some radio buttons on a web page using .NET and JavaScript. It seems to work well in Firefox but not IE, what a surprise!

The situation:

I have two sets of radio buttons – two RadioButtonList controls. The first set needs to control the second set – that is, when one of the radio buttons in the first set is selected, the other RadioButtonList control should be enabled, and when the other of the radio buttons in the first RadioButtonList control is selected, the second RadioButtonList control should be disabled.

In my code-behind, I had an event handler for the first RadioButtonList control to check if the selected index had changed. If so, check the value of the first RadioButtonList control and if it’s say equal to 1, then set the Enabled property of the second RadioButtonList control to false. Otherwise, set the Enabled property to true.

Obviously this alone doesn’t fix the problem unless the first RadioButtonList control is set to AutoPostBack = True. I needed some code on the client side to do this when while the user wasn’t posting the page back.

The code to disable some radio buttons is simple:

[?][-]View Code JAVASCRIPT
1
2
3
4
var secondRadioButtons = document.form1.secondRadioButtonList;
for(var i=0; i<secondRadioButtons.length;i++ ){
    document.form1.secondRadioButtons[i].disabled = false;
}

The problem:

When you wire all this up, it works fine in Firefox… But does it work in IE? No, of course not. So why not? I found that when I first loaded the page, the radio buttons were enabled / disabled as they should have been. Clicking on the first set of radio buttons was disabling / enabling the second RadioButtonList control as it should have. But as soon as I posted the page back (the page had a button that submitted a form and displayed some results), the second RadioButtonList control was completely disabled and no matter which of the first radio buttons I selected, I couldn’t re-enable it. I stuck some debug code in my JavaScript only to find that it was running correctly and firing when it should. As far as I could tell, the JavaScript was setting disabled = false (as above) on all of the radio buttons in the second RadioButtonList control, but they were still disabled. Why!?

I took a look at the source code for the page and noticed something that I thought might have been causing the problem I was experiencing. Basically, browsers renders an asp:RadioButtonList control like this:

1
2
3
4
5
6
<span id="secondRadioButtonList">
<input id="secondRadioButtonList_0" name="secondRadioButtonList" value="1" type="radio" />
    <label for="secondRadioButtonList_0">First radio button</label>
<input id="secondRadioButtonList_1" name="secondRadioButtonList" value="2" type="radio" />
    <label for="secondRadioButtonList_1">Second radio button</label>
</span>

If you disable a RadioButtonList in your code-behind, the same asp:RadioButtonList control will be rendered like this:

1
2
3
4
5
6
7
8
<span id="secondRadioButtonList" disabled="disabled">
    <span disabled="disabled">
<input id="secondRadioButtonList_0" name="secondRadioButtonList" value="1" disabled="disabled" type="radio" />
        <label for="secondRadioButtonList_0">First radio button</label>
<input id="secondRadioButtonList_1" name="secondRadioButtonList" value="2" disabled="disabled" type="radio" />
        <label for="secondRadioButtonList_1">Second radio button</label>
    </span>
</span>

This is precisely why I don’t like asp controls – they look nice in the html that you write yet when they render out to the browser, they’re filled with extra stuff like these two spans.

Anyway, the problem were these spans – obviously even though I was setting ‘disabled = true’ on all the radio buttons inside my asp:RadioButtonList control, there were a couple of spans around the radio buttons that were also disabled causing my radio buttons to appear disabled regardless of their individual status.

The solution:

My solution to this was to simply remove the code-behind that I had written to enable or disable the RadioButtonList control on the server side. My JavaScript is all I really need.

However, if you desperately want or need to have some server-side code also disabling your radio buttons, you should do so like this:

1
secondRadioButtonList.InputAttributes.Add(”disabled”, “disabled”);

rather than

1
secondRadioButtonList.Enabled = false;

Where is my SQL Server 2005 Management Studio?

June 10, 2008 - 11:54 pm No Comments

I’ve just had the toughest time getting SQL Server 2005 WITH Management Studio installed, so I thought I would blog about my thoughts on the matter and my rather round about way of getting it going.

1 – Install SQL Server 2005 Developer Edition. Stick Disk 1 in. Everywhere says ‘click on the link to start the SQL Server Installation Wizard.’ Well guess what, there isn’t a link that says that! There are two links, one to install components and another to install SQL Native Client. Grr.

2 – I click on the components one and it seems to install everything I need to run SQL Server 2005, EXCEPT for Management Studio. Why? I don’t know. I do however wonder why it never asks me for Disk 2… hmm.

3 – Open up Control Panel, Add or Remove Programs. Look for “Microsoft SQL Server 2005”. Click on the “Change” button.

4 – Select the ‘SQL Server 2005 common components > Workstation Components’ option and hit Next. When you are finally given the option to ‘remove’ this component, do it. Just do it.

5 – Once this is all finished (takes forever!), repeat step 3. When you are shown the the same dialog box as in step 4, there won’t be a ‘SQL Server 2005 common components > Workstation Components’ option. Instead there will be some text telling you you should use the ‘To install a new component, click here’ link at the top of the dialog box. Click this link. This will open up a series of dialog boxes very similar to those encountered in step 2 – your basic installation. Select the last option (I think it was ‘Tools’?).

6 – It should tell you it’s going to install a bunch of stuff and then start installing it all… pretty quickly however, it will ask you to insert Disk 2. This is a good sign.

7 – Insert Disk 2.

8 – Wait for the installation of all the different components to complete.

9 – And like magic, you should now have a whole bunch more shortcuts in your start menu under Microsoft SQL Server 2005. Although this seems like all you did was install, uninstall and re-install, believe me, it’s the only way I managed to get it to work.

As I said above, I’m not sure if I’m the only person this has ever happened to but I have seen plenty of other blog articles on how to get Management Studio installed if it doesn’t appear to be there already so I believe I’m not alone. None of the other solutions I saw helped me either so hopefully this will help someone else in the same position as me!

A few changes for… Me.

April 20, 2008 - 6:35 pm No Comments

Last time I posted about “Me”, I mentioned that Chris and I were moving across to London. I was due to start my new job at Next Jump in a few weeks time, and Chris was looking for work by sending out dozens of emails every day. Well, that was over a month ago now and during that time, we started realizing that things really weren’t looking good for Chris to find someone to sponsor him for a work permit in the UK (you can read all about his feelings re this here). We waited about as long as we could before making an inevitable decision – forget the UK for now – let’s go to Brisbane (Australia) instead. Because Chris and I are both NZ citizens, we are entitled to live and work in Australia. This means we should, in theory, have no big problem finding work there. The stress and tension created by not knowing whether Chris was even going to be able to stay in the UK for more than 6 months (tourist visa) was awful and so we had to make a call. It wasn’t an easy decision to make because I was really looking forward to my new job at Next Jump and we’d already shipped 4 boxes of personal effects across to London as well, not to mention the $2000 price tag attached to my UK HSMP visa (which is now all sorted out and stamped in my passport, doh!). But it felt like the right decision to make.

Since then, a few things have happened. Chris flew back to NZ (yay!), we spent a week in Wellington applying for roles in Brisbane on SEEK, we both did a few phone interviews for potential jobs, and right now we’re in Brisbane for about a week, doing a few face-to-face interviews with companies that are interested in us. We’re staying with Rheanna and Sanjay, friends from Wellington, which has been so great. (Thanks guys!!)

I’ll tell you what – I have done so many interviews over the past couple of years it’s really quite ridiculous. Including the 10 or so interviews I did with Google, I guess I’ve done about.. 20 or so interviews… mostly technical. I’m kinda tired of doing them, but hopefully I won’t have to for much longer. The stupid thing is that most of those 20 or so interviews have actually ended in job offers, but for one reason or another I haven’t accepted them. Dumb eh? Anyway, right now I’m focusing on the mining industry because it seems like a really really interesting industry to be involved in and there is lots of work for software developers in mining here in Australia. Sweet. I had 1 interview + 1 meeting with a recruiter on Thursday and 2 interviews + 3 meetings with recruiters on Friday. Wowee. Another couple of interviews scheduled for Monday and Tuesday. Busy busy busy!!

The plan is to secure a job for at least one of us while we’re here, fly back to Wellington mid-next week then come back about a week after that, after shipping all our stuff over and saying goodbye to everyone all over again. Hopefully then we’ll find us a nice place to live and settle down a bit! We haven’t had our own place for more than 6 months now and it’s getting a bit tiring living out of backpacks, suitcases and other people’s kindness.

So yeah, it’s been a bit of a stressful and confusing time but I think we’ve made the right decision. The last few days in Brisbane have been really cool – it’s a really nice city, the weather is wonderful (I LOVE the sunshine!), there are beaches near by and it looks like we’ll be able to afford to live in a neat apartment with a pool and gym in the complex. I’m not complaining :P. Oh, and it’s also a bit closer to NZ too, so hopefully friends and family will be able to come and visit us more often than they would’ve if we had ended up in the UK!

Anyway, I’ll post again when I have some more definite news on where I’ll be working and stuff like that :)

New features on TravelStash

April 7, 2008 - 12:42 am No Comments

TravelStash

As some of you may by now know, Chris and I have written a website called ‘TravelStash’. It’s essentially a blogging site intended for travelers. It integrates things normally associated with blogging (i.e. writing blog posts, uploading photos, comments) with a map. The structure behind TravelStash is a bit complex but it does make sense. Basically when you join up, you get your own membership. Once you’re a member, you can create a group for yourself and invite others to join your group. Each member can belong to many groups. Someone in the group creates a trip and then all the members of that group are able to log in and post an article about that trip.

We used TravelStash for our ‘Camp Europe’ holiday and more recently for our ‘Exploring the East’ holiday (even though we haven’t quite finished blogging about that one yet… lazy!). Although we’ve almost finished writing all the code necessary to allow others to join, create their own groups, blog about their trips and upload photos from their holidays, we haven’t quite opened it up to the general public. We’re hoping to do that real soon though so keep posted on that one :)

In the mean time however, I thought I might add a couple of new features to TravelStash. First is the ability to view an entire group’s photos. Until now, photos were only shown on the article with which they were associated. I figured it might be nice to view all of a group’s photos on one page rather than having to individually click on all the articles to see all their photos. You can see an example of that here. Neat eh?

The other feature I added only last night were ‘Travel Tips’. I had lunch with a good friend the other day who told me that it would be neat if we had travel tips posted on TravelStash. He’s right, Chris and I had thought of doing that anyway so I figured I might as well get onto it and just do it. So a few code changes later and we’ve got ‘Travel Tips’ on TravelStash! As you can see, not many travel tips just yet but I’ll make sure to add some more and hopefully when we open TravelStash up to the general public and people flock to it, they’ll add their amazing travel tips too. I was thinking it might be cool to allow comments on travel tips too in case others have something to say about it. Ahh, so many ideas.

Anyway, that’s about it for new features on TravelStash. Chris and I have heaps of ideas for new features, however, so with a bit of luck there may be some cool new stuff on there soon. And obviously we’re really excited about ‘launching’ it to the general public. I’m sure we’ll both learn lots from that experience. :)

Migrating from Textpattern to WordPress

March 25, 2008 - 12:26 am 1 Comment

Part of setting up my new blog was to migrate all my old articles from Textpattern to WordPress. As with all migrations and updates, I was somewhat cautious, thinking it would probably take a lot of time and effort. Ahh well, I’ll never know if I don’t try!

Turns out I was right. WordPress actually provides a script to do the migration for you. This script should take care of importing categories, users, posts, comments, and links (blogroll). All you have to do is fill in a small form with your Textpattern database details – database user, password, name, host and any prefix you might have used on your Textpattern tables – and hit Import! However, when I ran it, it did nothing. Yup, that horribly annoying problem that all developers absolutely loathe. The script ran… and did nothing. It kept telling me it had not imported anything but it didn’t give me any reason as to why that might be the case nor did it give me any errors or warnings. Urgh!

So I searched Google. I found out that a few people have had issues with this script. A couple of other people (such as Alex Brie) have written their own instructions and even scripts (or at least modified the one that comes with WordPress). Most of the advice I read on the matter said you should have both your Textpattern and WordPress tables in the same database for the script to work. Apparently that’s actually not necessary but I tried it anyway. Still nothing imported. I tried using the modified import scripts that I found… still no luck. Argh!

At this point I was starting to get mildly frustrated that something that should be quite straight forward just wasn’t doing anything for me. A lot of the comments on the blog posts I was reading had people quoting errors or saying that they’d finally got it all working. I didn’t get either. It was at this point that I surrendered to my geek-soul and opened up the PHP import script in Dreamweaver. I read through some of the code and eventually found some places where I could stick some debug code in. First thing I tried was to output the values that I’d entered into the import form (my Textpattern database details). BINGO. There was my problem. My database host includes slashes and colons and there was a nice wee line in the script that was scrubbing all those characters out. Grrr…. I changed that line from:

1
add_option('txphost',  sanitize_user($_POST['dbhost'], true));

to:

1
add_option('txphost',  sanitize_user($_POST['dbhost'], false));

I guess whoever wrote the script didn’t realize that some of us have complex database hosts!

Anyway, that seems to have fixed the problem at least in my case. The rest of the script worked great. So now, as you can see for yourself, all my old articles written on mindtrip using Textpattern are now sitting here in Wordpress! Awesome. :)

A new look, a fresh start…

March 16, 2008 - 6:48 pm 2 Comments

After close to 3 years on www.mindtrip.co.nz, I decided to try something new, perhaps something more relevant to my field (technology). Boy it’s hard thinking of new domain names that haven’t already been taken!

Since I was choosing a new domain name anyway, I figured I might as well try a different blogging engine too. To date, I’ve been a true Textpattern fan. However, everyone else I know that keeps a blog seems to be using WordPress these days. I couldn’t help but wonder what I was missing out on. So I’ve taken the plunge and I’ve switched to WordPress. We’ll see how it all goes!

Things will probably be a bit broken and won’t look finished for a while, but hopefully that won’t last for long. Please bear with me in the meantime!

The latest on… Me.

March 15, 2008 - 6:38 pm No Comments

Plenty has changed since I last blogged about me. In fact, plenty has changed since I last blogged at all. I must admit, I’ve been a bit slack and haven’t been maintaining my blog much recently. I must do better. I really must.

So a quick update – as mentioned in a previous blog post, Chris and I finally decided to pack up and move overseas. We quit our jobs at Trade Me back in November ‘07 and the plan was to travel throughout South-East Asia for 3 months and ultimately end up in London where we would both find IT work and earn the big bucks.

Our 3 months in South-East Asia were amazing. I can’t stress that enough – if you haven’t been… GO! Asia has so much to offer and even the NZ dollar gets you so far! Thailand and Cambodia are cheeeeeap and cheerful, Japan was cold and expensive. Bangladesh was fascinating, Singapore was hot and sweaty, Malaysia was wet and Hong Kong was busy. Anyway, we haven’t done Vietnam yet so we’ll be going back… one day :). If you want to read all about our adventures in Asia, go to TravelStash – Chris And Annie, our very own travel blog.

During our holiday, I was offered two jobs – one at Google in Zurich as a Software Engineer in Test (omg, after so many years and so many interviews!) and another at Next Jump as a Software Engineer in London. Took me a while because it was a really tough decision to make, but eventually I picked Next Jump because the role was much more in line with where I want my career to head. Google then tried to convince me to join them in London instead. Let me tell you – it feels great to be so wanted! Anyway, I stuck with my decision and began the process of applying for the UK HSMP so that I could start at Next Jump as soon as I arrived in London. This application form ended up being a real mission, requiring me to provide all sorts of documentation, most of which I didn’t have access to, especially from some beach resort in Thailand! So my parents and brother did a great job helping me out, and together we got all the documents and forms done and sent off. The most memorable part of this process was jumping onto the back of a dodgy little motorbike with Chris AND a driver (yes, 3 of us!), wearing nothing more than shorts, singlets and jandals (psshhh, who needs a helmet!!), and weaving in and out of traffic on our way down to the main post office in Phnom Pehn to post my drivers’ license off to London. That would be enough to give any traffic cop in NZ a heart-attack!

We ended up in London on the 21st of February ‘08, a little ahead of schedule. Only a couple of days later I received my letter of acceptance from the Home Office in the UK – my HSMP application had been approved. However, it was only then that I found out that I had to go back to NZ to finish off the process and get my ‘entry clearance’. That took me a bit by surprise but what the hell, going back to NZ means I get to see my family and friends a lot sooner than I’d expected which is all good! Chris started looking for work (he needs someone to sponsor his work permit) by sending out a million emails a day to recruiters and large IT companies alike. Hopefully he’ll find the right role for him and we’ll be able to stay in the UK!! :)

Anyway, I’m writing this article from NZ so right now I’m waiting to have my biometrics meeting and get my entry clearance so I can finally start my new job at Next Jump. I’m really excited and can’t wait to sink my teeth into a new job! Looks like I might even get to go to New York for 3~4 weeks training on my way back to the UK so that should be awesome! Now I just need to get my brain back into geek mode and I should be fine… lol ;)

Code for GPS Tracking with Google Maps & AJAX

March 15, 2008 - 4:42 pm No Comments

Over the past few months, my article on GPS Tracking with Google Maps & AJAX has received many hits and attracted a multitude of comments requesting that the code for it be made available. I apologize for the delay but I’ve been away on holiday and far away from my trusted laptop. Now that things are somewhat back to normal and I can spend hour upon hour on my laptop again, here is the code that so many of you have asked for. I hope it makes sense and that it helps you all with what you’re trying to achieve. Obviously I haven’t posted the entire HTML and PHP coz it’s not all relevant to the GPS plotting but I hope what I have posted gives ya’ll a general idea on how to solve this particular problem. I’m sure there are many different ways to do this but this was just one way that I tried.Please feel free to ask questions and I’ll try to answer as best as I can! :)

...

Within the head section of the page that contains the gps tracking map:

[?][-]View Code JAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<script language="JavaScript">
 
function setTimer() {
   window.setTimeout("show_data();",5000);
}
 
function show_data(){
   //Append the id (just a simple count) to the requestURL
   var requestURL = "http://www.sitename.com/getGpsPoints.php";
   var count = document.getElementById("counter").value;
   count = parseInt(count, 10);
   var queries = "?id=" + count;
   var url = requestURL + queries;
 
   //Increment the hidden counter variable
   document.getElementById("counter").value = count+1; 
 
   var request = GXmlHttp.create();
   request.open("GET", url, true);
 
   request.onreadystatechange = function() {
      if (request.readyState == 4) {
         var xmlDoc = request.responseXML;
         var markers = xmlDoc.documentElement.getElementsByTagName("marker");
 
         for (var i = 0; i < markers.length; i++) {
            var point = new GPoint(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
 
            // Draw the MapMarker
            var mapMarker = new GMarker(point);
            map.addOverlay(mapMarker);
         }
 
         // Recenter the map
         map.centerAtLatLng(point); 
      }
   }
 
   request.send(null);
 
   //Reset the timer so that the page keeps refreshing itself
   setTimer();
}
 
</script>

Within the body section of the page that contains the gps tracking map, right at the bottom just before the /body tag:

[?][-]View Code JAVASCRIPT
1
2
3
4
5
6
7
8
<script language="JavaScript">
   var query = window.location.pathname;
   if (query == "/mapping/gps-tracking-with-google-maps--ajax") {
      var map = new GMap(document.getElementById("map"));
      mapSetup();
      setTimer();
   }
</script>

Separate PHP script that queries your database to retrieve the GPS points to plot:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
    header ("content-type: text/xml");
 
    $link = mysql_connect ("localhost", "username", "password");
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
 
    mysql_select_db ("dbname");
 
    //If no search string is passed, then we can't search
    if(empty($_GET["id"])) {
        echo " ";
    } else {
        //Remove whitespace from beginning x%x% end of passed search.
        $search = trim($_GET["id"]);
 
        //Query the DB and store the result in a variable
        $query = mysql_query("SELECT * FROM gps WHERE id=".$search);
 
        //If no rows are found...
        if(mysql_num_rows($query) == 0) {
            echo " ";
        } else {
            //Stick the returned rows into a handy array for easy use
            $row = mysql_fetch_array($query) or die(mysql_error()); 
 
            //Write out XML using values returned by the query
            echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><markers><marker lat=\"".$row["lat"]."\" lng=\"".$row["lng"]."\" /></markers>";
        }
    }
 
    mysql_close($link);
?>