Where is my SQL Server 2005 Management Studio?

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!

Read More

New features on TravelStash

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

Read More

Migrating from Textpattern to WordPress

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

Read More

Code for GPS Tracking with Google Maps & AJAX

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);
?>
Read More

Textpattern plugins and Facebook apps

Since Chris and I have become addicted to Facebook, we decided it would be cool to have a plugin for our respective blogging engines (Chris uses WordPress, I use Textpattern) that would update our Facebook accounts’ mini-feeds when we posted something on our blogs. Thus we both set off on our epic missions to create Facebook applications and WordPress / Textpattern plugins that would support this behaviour.

Here I’ll relate my experience with my Textpattern plugin. I’ll leave Chris to talk about his experience with WordPress.

So yeah, basically, my experience was a nightmare.

This was my first attempt ever at writing a Textpattern plugin so I am by no means an expert at this. It took me a while to figure out how to compile my php code so that I could deploy it to my Textpattern instance on my web server. Then it took me another while to figure out how to hook into Textpattern ‘events’. I must say, the documentation for this is really poor and I found myself trawling through the Textpattern source to figure out what functions did what. Not pretty. The best (and only) sites I found that helped me somewhat were this article on threshold state and this Textpattern source repository.

When I finally figured out how to call the ‘register_callback’ functions and that I had to use ‘article’ as the event I wanted to register my own events against, I was able to get stuck into it.

My next challenge was how to add a checkbox to the ‘write’ tab of the admin screens. I wanted a checkbox that when checked, would essentially call my code to notify my facebook account of my post. If it wasn’t checked, it wouldn’t notify facebook. However, adding a checkbox and positioning it where ever I want in the flow of elements on the page was NOT an easy task. Below is a sample of the code I had to use to get this to work:

1
2
3
4
5
6
7
8
9
10
function mdt_event_insert_checkbox($buffer) {
   $fb_notify = graf('<small><label for="notify_facebook">'.
      checkbox("notify_facebook", '1', '1', '', 'notify_facebook').
      'Notify Facebook?</label>&nbsp;');
 
   $find = '<input type="submit"';
   $replace = $fb_notify.$find;
 
   return str_replace($find, $replace, $buffer);
}

NASTY! I had to find the ‘Save’ button, then replace the HTML with my new HTML that includes the checkbox. OMG.

Anyway, I finally got that working (see screenshot below).

Next I needed to grab the title of the new post, the friendly-url to the article on my site and the excerpt of the new article. This again was no easy task. The following code seems to do the trick:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function current_url() {
   return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
 
function get_latest_post() {
   include_once txpath.'/publish/taghandlers.php';
 
   // get the latest article posted
   $rs = safe_row("ID, Title, Excerpt", 'textpattern', "1=1 ORDER BY LastMod DESC LIMIT 0,1");
 
   $title = ' has blogged: ' . urlencode(stripslashes(urldecode('<a href="' . permlinkurl_id($rs['ID']) . '">'))) . substr($rs['Title'], 0, 45) . '</a>';
   $msg = substr($rs['Excerpt'], 0, 180);
   $url = current_url();
 
   if (strtolower($step) == "publish") {
   $url = $url . "?event=article";
 
   } elseif (strtolower($step) == "edit") {
      $url = $url . "?event=articlex%x%step=editx%x%ID=" . $rs['ID'];
   }
}

So now the tricky part – how to connect to Facebook, log in as myself and call the Facebook API function that updates my ‘mini-feed’ with some content. I first attempted this by embedding the Facebook API into the Textpattern plugin so that the integration would be completely seamless. This, however, was difficult on many levels. First of all, I couldn’t get the Facebook API to compile into my Textpattern plugin. The php compiler would tell me that certain server variables weren’t defined, etc etc. I did iron out all those error messages and warnings eventually though and finally got the code to compile. However, I later realized that this was never going to be a feasible solution because in order for this to work, my Facebook developers’ API key and secret key would need to be hard-coded into the Textpattern plugin and if I were ever to make this Textpattern plugin public (which I intend to do), I would be sharing my API and secret keys, something I don’t necessarily want to do. Doh! So I had to change my thinking somewhat.

The solution to this was to basically write the Facebook part of the plugin as a totally separate web application and have the Textpattern plugin call this web app, passing through to it the title, url and excerpt in the form of a query string. This method lets the Facebook web application handle all the Facebook functionality (logging in and authenticating, remembering you once you’re logged in, calling the appropriate API functions, etc etc) and the Textpattern plugin basically doesn’t need to know anything about Facebook.

What a mission.

However, it all seems to be working now and I’ve used it once already. Those of you who are on Facebook and have added me as a friend will be able to see little posts on my mini-feed (on my profile page) saying “Annie has blogged…” with a link through to this article. Very cool :) When I am comfortable that things are working as intended and I tidy things up enough to make my Textpattern plugin publicly available, I’ll put it up on my here somewhere for people to grab.

Phew

Read More

dotTrace – a cool profiler for .NET applications

Ever wondered why your application is chewing up so much of the processor? Or where all that memory is going?

Introducing dotTrace – a profiler for .NET applications, both desktop and web apps. It lets you run up a web app and take snapshots of it’s profile whenever you want. One view shows you a summary of the bits of code that the threads are busy executing complete with precise execution times, while another view shows you where the memory is being allocated, specifically which types of objects are using up the memory.

Something I particularly liked about dotTrace is its ability to show ‘hot spots’ – essentially a summary of functions that are using up the highest percentage of the thread’s time and effort. It shows how many calls to these functions are being made and where from. This quite nicely highlights some functions that are perhaps being overused in your applications (functions such as Concat and ToLower), allowing you to fine-tune your (already perfect, of course) code for performance.

Anyway, I’ve downloaded it and had a bit of a play – so far so good. Unfortunately, you either have to buy it (and it ain’t cheap) or deal with a 10 day trial license key. Still, I guess there’s no such thing as a free lunch!!

Read More