Friday 21 October 2011

Load testing ajax application using Visual Studio 2010

In order to do this, you need to extend Visual Studio Web Performance Test  with your own Extraction and/or Validation Rule. Visual Studio 2010, which my current working copy, has all interfaces provided for the needed customizations.

Here is an official tutorial for Creating a Custom Extraction Rule, which can lead you to the place where you can find all useful information and a real code example.

For java users, you may want to explore HtmlUnit platform.

Wednesday 19 October 2011

Avoid InfoWindow from shifting Google Maps

It's kind of inconsistent in some cases that Google InfoWindow would shift the map while panning. That's a huge user experience if this map behaviour is not your intention. There a couple ways to resolve it, either close the InfoWindow when panning the map way far causing it invisible, or set the proper value to an attribute of InfoWindow, which I believe it is the easiest and most solid solution. Here is the code snippet for the 2nd solution.

 
var infoWin = new google.maps.InfoWindow({disableAutoPan: true});
 

Tuesday 18 October 2011

Get Ready for Android App Development

Being excited about mobile application and open source platform? Apple or Android? Personally I like both platforms but more lean to Android as I don't have any "expensive" Apple computer. Would be nice if I could get a sponsor. So Android App is my target for contributing to the community.

To get ready for your Android App development, you need the following stuff.
  1. JDK, any version since1.6.x or later and can be downloaded from here.
  2. Android SDK, and it can be downloaded from here.
  3. Eclipse IDE (recommended but not necessary), preferable to download Java EE Developer version
  4. Download and install Android Development Tools (ADT) plug-in for Eclipse.
  5. Add Android platforms to development environment.
    • From Eclipse, go to Window -> Android SDK and AVD Manager.
    • On Windows, double click the SDK Manager.exe file at the root fo the Android SDK directory.
    • On Mac or Linux, open a terminal and navigate to the tools/ directory in the Android SDK, then execute command: android
Now, you should be ready to get your hands wet on your first Android App development, Hello Word, for example. :)

For more information, you can always go to Android official home site for developers.





Sunday 16 October 2011

Convert Latitude and Longitude to android.maps.GeoPoint

Use the following code snippets


 
GeoPoint point = new GeoPoint((int)(latitude * 1e6), (int)(longitude * 1e6));
 

Obtain Android Google Maps SDK Debug Certificate

For developing your Google Maps application for android, I would like to obtain a debug Google Maps SDK debug certificate before production release. Android.com provides a very thorough instruction for helping newbies and beginners. Here I just list the steps that I went through in my own development environment: Windows 7 32bit + JDK1.7.0. Hope it would help simplify your learning curve.


1. Locate your debug.keystore.
    By default, build tools create the debug keystore in the active AVD directory which varies by platform:
  •     Windows Vista/7: c:\users\<user>\.android\debug.keystore
    For eclipse/ADT user, go to Windows -> Preferences -> Android -> Build for the full path of debug.keystore.

2. After the debug.keystore was located, use keytool utility to obtain the MD5 fingerprint of the debug certificate.
    Replace the below command with your JDK installation path and your actual user id
    "c:\program files\java\jdk1.7.0\bin\keytool" -v -list -alias androiddebugkey -keystore c:\users\<user>\.android\debug.keystore -storepass android -keypass android
    Note: only the MD5 fingerprint is recognized by Google. Other version, such as SHA1/256, is new since JDK 1.7, and cannot be used for registering Google Maps API.

3. Now, follow steps below to register your debug certificate with Google Maps Service
  1. Go to http://code.google.com/android/maps-api-signup.html
  2. If you don't have a Google account, use the link on the page to set one up. 
  3. Read the Android Maps API Terms of Service carefully. If you agree to the terms, indicate so using the checkbox on the screen. 
  4. Paste the MD5 certificate fingerprint of the certificate that you are registering into the appropriate form field. 
  5. Click "Generate API Key" 
The server will handle your request, associating the fingerprint with your developer identity and generating a unique Maps API Key, and then will return a results page that gives you your Key string.

Wednesday 5 October 2011

Find GPS location (latitude and longitude) is within given radius

In a project, I need to determine whether a given GPS location (latitude and longitude) is within a pre-set radius area, for example, within a 2 kilometres circle of a target place - Vancouver Convention Centre. It's not a rocket science to do it but it would be helpful for those who need to implement the similar logic.

Here is code snippet in javascript, and could be easily ported to other languages, like C#.

 
// center: the center goelocation of the radius
// radius: radius in meter
// loc: the geolocation that you want to check
function isInArea(center, radius, loc) {
        var R = 6371;
        var lat1 = loc.lat();
        var lon1 = loc.lng();
        var lat2 = center.lat();
        var lon2 = center.lng();
        var dLat = (lat2 - lat1) * Math.PI / 180;
        var dLon = (lon2 - lon1) * Math.PI / 180;
        var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
		Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
		Math.sin(dLon / 2) * Math.sin(dLon / 2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        var d = R * c;
        return (d * 1000 <= radius)
    };