Archive for March, 2008

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. :)

  • Share/Bookmark

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!

  • Share/Bookmark

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 ;)

  • Share/Bookmark

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);
?>
  • Share/Bookmark

Fatal error: Call to a member function decode() on a non-object in /home/geekchick/www/www/wp-content/plugins/twitter-tools/twitter-tools.php on line 744