Monthly Archives: December 2008

Command line alternatives to Remote Desktop

Most days I’m connected to a client’s VPN working on a project and lately I’ve converted from using Remote Desktop (RD), Terminals actually and highly recommended btw, to psexec and $g(taskkill) to get things done. Using psexec I start/stop CCService, run CCNET from the console, use SVN and build from the command line to name a few. The machine I connect to most of the time has a limited simultaneous RD users and occasionally I’m unable to get a connection so having an alternative is crucial. One caveat I ran into was TortoiseProc.exe fails to terminate when run remotely with psexec and has to be killed manually and unfortunately the SVN command line tools are not installed, at least not yet. Occasionally, I use remote.exe from the NT Resource Toolkit though I haven’t used that in quite awhile not to mention the EXE I have is from 1997, not that that makes it any less effective.

Do you do something similar? What utilities do you use?

[Update: Feb 23, 2009] I also use psloggedon which is useful to see who is using the machine. Additionally, it’s nice to be able to launch a console window on the remote machine as well like this (though as Bary notes below ssh is also an option):

psexec.exe \\machine -w d:\ cmd.exe

ASP.NET Facebook Starter Kit for VS.NET 2008 updated to v0.8

I’ve updated my ASP.NET Facebook Starter Kit with the following improvements/changes:

  • Added support for dynamically resizable iframe which avoids a scrollbar though may have some side effects/caveats. Code is based on JavaScript sample from Facebook.
  • Added an example of XFBML which requires xd_receiver.htm (included) allowing for a Cross Domain Communication Channel
  • Added example of using FQL, refer to FQL.aspx
  • Updated Facebook Dev Toolkit assemblies
  • Added Facebook stylesheet from Bill Konrad

The download is here and full directions for installation and use are here. To see this application running on Facebook click here. As always, please direct questions on the Facebook API to the Developer’s Forum, or on the Facebook Developer’s Toolkit to the discussion list.

[Updated: Jan 15, 2010] This post is now outdated so please look for my updated versions. The latest is always available on my wiki.

Hosting MIT's Simile Exhibit OS project

I’ve been working on an application that makes use of MIT’s Simile Exhibit Open Source project and the other day the MIT server hosting the related JavaScript files went down. Exhibit is described thusly:

Exhibit enables web site authors to create dynamic exhibits of their collections without resorting to complex database and server-side technologies. The collections can be searched and browsed using faceted browsing. Assorted views are provided including tiles, maps, etc.

Here is an example. Based on what I can glean from the Exhibit newsgroup weather played a role but nonetheless it motivated me to investigate moving the sources to my ISP which happens to be discountASP.NET.While the main server appears to be back up and running at least one service needed for the map view extension is still offline making it more or less just a plain map absent the data points that make it interesting.
There was a request on the newsgroups to explain what I did to “self-host” the code so I figured I’d elaborate a bit. The main issue is that throughout the code there are hardcoded references to an MIT server, namely static.simile.mit.edu.
For starters, you’ll need to grab the Exhibit source code from SVN repository located here:
http://simile-widgets.googlecode.com/svn/exhibit/trunk
Fwiw, on Windows, I’m using $g(TortoiseSVN) as my SVN client. Next, correct the URL references in the code that refer to the above server. The source changes look like this:

        /*
         *  Extensions (for backward compatibility)
         */
        if (includeTimeline) {
            scriptURLs.push(useLocalResources ?
                "http://127.0.0.1:8888/exhibit/extensions/time/time-extension.js" :
//                "http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js");
                "http://www.stevetrefethen.com/simile/exhibit/webapp/extensions/time/time-extension.js");
        }
        if (includeMap) {
            scriptURLs.push(useLocalResources ?
                "http://127.0.0.1:8888/exhibit/extensions/map/map-extension.js" :
//                "http://static.simile.mit.edu/exhibit/extensions-2.0/map/map-extension.js");
                "http://www.stevetrefethen.com/simile/exhibit/webapp/extensions/map/map-extension.js");
        }

Basically, a simple search and replace for “static.simile.mit.edu will suffice to identify the locations that need to be changed. I also made one additional change I’m not sure is necessary which is the following query parameter on the script tag that loads the widget:

Bundling is not something I’ve examined closely though it’s in the interest of saving bandwidth for the amount of Javascript that has to be downloaded. Here is the set of files I modified with the type of changes described above:
Simile Exhibit modified files
Once you’ve made these changes you’ll need to upload the following source directories to your ISP:
simile/exhibit/ajax
simile/exhibit/webapp
simile/exhibit/graphics
Note, the above ajax and webapp directories each have a subdirectory called “site” that contains an example and should not be uploaded. You should now be set to host Exhibit from your own ISP. The map extension requires a Java servlet which you can also self host but since my ISP doesn’t provide that support I’m still relying on MIT’s server for that portion. I’m aware of one such alternative though I couldn’t get that working in the five to ten minutes I spent trying but I’ll likely revisit it as it’s clearly an important piece.
[Updated: March 28] On a somewhat related note I’ve created a simple Exhibit for my companies training engagements here.
[Updated: January 2010] Check out my Facebook application using Exhibit.

Bank of America's online My Portfolio feature lost all of my data

I’ve banked with BofA for well over a decade and earlier this year (2008) started using their My Portfolio feature that allows for categorizing transactions and linking accounts from other financial institutions providing an aggregated Net Worth view. That was at least until they lost all of my data. Earlier this month I was prompted to change my online user ID and I walked through the multi-step process that had me change my user ID, password and site key. After all that, I logged in an clicked on the My Portfolio view which has been particularly useful to get a quick overview in today’s sinking market but much to my surprise, ALL of my data was gone. The feature had been completely reset losing 7-8 months worth of accumulated data, hundreds of categorized transactions and all of my linked accounts.

Now, I understand to BofA this feature is provided as a courtesy but I’ve spent a significant enough number of hours categorizing transactions and I’m annoyed at having lost all of the data. Of course, at this point I’m in the classic situation of dealing with mega-company support. There is a support case created but that was now four days ago and I have little hope of actually having the data restored.

So, long story short if you’re using Bank of America’s My Portfolio feature understand there is no backup option and there is real potential for you to lose ALL of your data. Unless they can restore my data it’s unlikely I’ll start using My Portfolio again any time soon.

Anyone else have this experience?

[UPDATE: Dec 22, 2008] Called Customer Service again and the tech this time was aware of the problem and mentioned BofA uses a third party company to help provide the My Portfolio service and apparently the bank has a case filed with that company. I was told that other customers had experienced the same problem.

[Update Jan 9, 2009] A member of BofA’s online banking technical support called me back to let me know they’ve lost my data. They also confirmed that I’m not the only user affected by the problem but that they have no way to correct what’s happened. It sounds to me like the real issue is that this problem has impacted a limited number of users and they simply don’t want to invest the time to figure out what happened. She alluded to the fact that my data may still be there but there is no way to go back and undo what’s happened which may be a worse problem as it would mean that my data is now sitting in some no man’s zone including account information for my linked accounts. Finally, she mentioned that if at some point things changed she would get back to me.

Facebook Developer Toolkit now supports JSON results on FQL queries

Facebook’s query language (FQL) allows fetching results as $g(JSON) by supplying an additional “format=json” parameter as part of the request. I submitted a patch a few days ago that adds a UseJson property to the FQL object which was recently added to the Toolkit.

So, to fetch JSON results for FQL queries you can use the following:

facebook.fql q = new facebook.fql(Master.API);
q.UseJson = true;
string result = q.query("SELECT ...");

Be sure to grab the latest sources of the toolkit. Btw, the main reason for even mentioning it is that unless you’re reviewing the toolkit source code it’s unlikely you’d even know it’s there so this post will hopefully help people searching Google for the answer.

Take a look at this post to see how the JSON format can be useful for using Facebook data using an HttpHandler.

Using Google Maps for Geocoding in C# Part 2: Deserializing to a class

In my previous post, I illustrated how to $g(geocode) a city state combination using Google’s Map API and a comment was asked why not deserialize to a class. Well, I could have done that but in the app I’m playing around with that wasn’t really necessary although there is more useful data than just the coordinates so here’s part two.

Once you have the XML data you can construct a C# class that would allow for deserializing to an object. Generating the C# classes is straight forward and requires you to run XSD.EXE (installed with VS.NET) on the XML file to generate an .xsd file. Next, run XSD.EXE again on the .xsd with /classes to generate C# classes. Below is the output from the command line of XSD.EXE and you’ll notice I got an error the first time around (for the work around keep reading):

[c:\temp]"\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin"\xsd geo.xml
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\temp\geo.xsd'.
[c:\temp]"\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin"\xsd geo.xsd /cl
asses
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: The 'urn:oasis:names:tc:ciq:xsdschema:xAL:2.0:Address
Details' element is not declared. Line 23, position 22.
Warning: Schema could not be validated. Class generation may fail or may produce
 incorrect results.
Error: Error generating classes for schema 'geo'.
  - The element 'urn:oasis:names:tc:ciq:xsdschema:xAL:2.0:AddressDetails' is mis
sing.
If you would like more help, please type "xsd /?".

To work around the above error I deleted the value of the xmlns attribute on the <AddressDetails> node then reran the above commands resulting in this C# file.

Finally, to deserialize the XML I used the following code which is a modified version of the function from my previous post (with minimal error checking I might add). Btw, here is a page that discusses .NET XML serialization:

private string GeoCode(string city, string state, string country, string zip)
{
    string url = "http://maps.google.com/maps/geo?output=xml&key=<your_API_key>&q=" + System.Web.HttpUtility.UrlEncode(city + " " + state);
    WebRequest req = HttpWebRequest.Create(url);
    WebResponse res = req.GetResponse();
    StreamReader sr = new StreamReader(res.GetResponseStream());
    try
    {
        System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(kml));
        using (System.IO.StringReader reader = new System.IO.StringReader(sr.ReadToEnd()))
        {
            kml item = (kml)serializer.Deserialize(reader);
            if(item.Items.Count() > 0 && item.Items[0].Placemark.Count() > 0 && item.Items[0].Placemark[0].Point.Count() > 0)
                return item.Items[0].Placemark[0].Point[0].coordinates;
            else
              return "";
        }
    }
    finally
    {
        sr.Close();
    }
}

Using Google Maps for Geocoding in C#

Recently, I wanted to find out how to programmatically find the longitude and latitude given a city and state. From my previous work using Google Maps I knew this was possible. I did some digging and found Google Maps API supports a particular URL for geocoding a specific location. The URL looks like this:

http://maps.google.com/maps/geo?output=xml&key=<your_google_api_key>&q=<city_state>

Simply specify your $g(Google API Key) and your URL encoded city and state and you will get a result similar to the following (for “scotts valley ca”):

<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0"><Response>
  <name>scotts valley ca</name>
  <Status>
    <code>200</code>
    <request>geocode</request>
  </Status>
  <Placemark id="p1">
    <address>Scotts Valley, CA, USA</address>
    <AddressDetails Accuracy="4" xmlns="">
      <Country>
        <CountryNameCode>US</CountryNameCode>
        <CountryName>USA</CountryName>
        <AdministrativeArea>
          <AdministrativeAreaName>CA</AdministrativeAreaName>
          <Locality>
            <LocalityName>Scotts Valley</LocalityName>
          </Locality>
        </AdministrativeArea>
      </Country>
    </AddressDetails>
    <Point>
      <coordinates>-122.0120480,37.0555750,0</coordinates>
    </Point>
  </Placemark>
</Response>
</kml>

Hint: For illustration purposes this works without using an API Key although you should review Google’s Maps TOS.

Getting Geocode Information Programmatically

I wrote the following C# function (which lacks error checking) to fetch the above XML response from the Google Maps service. As you can see I’m using a simple regular expression to locate and return the actual coordinates.

private string GeoCode(string city, string state)
{
    string url = "http://maps.google.com/maps/geo?output=xml&key=<your_API_key>&q=" + System.Web.HttpUtility.UrlEncode(city + " " + state);
    WebRequest req = HttpWebRequest.Create(url);
    WebResponse res = req.GetResponse();
    StreamReader sr = new StreamReader(res.GetResponseStream());
    try
    {
        Match coord = Regex.Match(sr.ReadToEnd(), "<coordinates>.*</coordinates>");
        if(!coord.Success) return "";
        return coord.Value.Substring(13, coord.Length - 27);
    }
    finally
    {
        sr.Close();
    }
}

This turned out to be a lot less painful than I had originally thought it might be all thanks to Google’s Maps service. Have you done anything similar/easier/better?
[Update: Dec, 2 2008] Using Google Maps for Geocoding in C# Part 2: Deserializing to a class
[Update: Dec, 16 2008] Status codes returned by this service.