Monday, February 23, 2015

Disabling the Windows Phone frame rate numbers display while debugging

While debugging Windows Phone Apps, there will be some (weird looking) running numbers on the right side of the app's screen, as shown in the screen shot below.

These are actually frame rate counter numbers to aid in debugging. They can be easily switched off if you do not want them on the screen, especially if you want to capture the screen. To turn it off, just do the following:

  1. In Visual Studio, open up the project's App.xaml.cs file in the editor.


  2. Look for the following lines:

    if (System.Diagnostics.Debugger.IsAttached)
    {
    this.DebugSettings.EnableFrameRateCounter = true;
    }

  3. Change them to the following:

    if (System.Diagnostics.Debugger.IsAttached)
    {
    this.DebugSettings.EnableFrameRateCounter = false;
    }

  4. Run and debug the app again.

    The frame rate numbers are no longer displayed.


Monday, February 16, 2015

How to fix AdDuplex ad unit configuration error for Microsoft AdMediator

The following error message "Ad unit configuration error Please check the configuration" kept popping up in the Microsoft AdMediator control in an Windows Phone 8 app when it tried to display an ad from AdDuplex.

After troubleshooting the issue, I found that the AdDuplex configuration was indeed incorrect. To resolve the issue the following must be done.

  1. In the Visual Studio project, right click on the project with the AdMediator control. Choose Add | Connected Services.

    The Services Manager dialog box appears.

  2. Select AdDuplex. Click Configure.

    The Configure AdDuplex dialog box appears.
  3. Note that the dialog is asking for App ID.
  4. In a web browser, open up the AdDuplex app detail page that you want to show ads for https://manage.adduplex.com/#/apps.

  5. Important: Instead of using the App key as it says on the page, copy the Ad unit ID value at the bottom of the page, e.g. 123456.
  6. Now back to the desktop's Configure AdDuplex dialog box. In the App ID field, type in the value from the web page Ad unit ID, e.g. 123456. Click OK.
  7. In the Service Manager dialog box, click OK.
  8. Build and run the app.

    AdDuplex ads will start appearing correctly in the AdMediator control.

Monday, February 9, 2015

Calculating a rough estimate of the Earth's radius from the old definition of meter

I sometimes have a hard time remembering the radius of the Earth. This tip shows how to derive the rough value if you don't remember the actual number.

According to Wikipedia, the 'Metre' was previously defined as follows:
"The other approach suggested defining the metre as one ten-millionth of the length of the Earth's meridian along a quadrant; that is, the distance from the Equator to the North Pole."
If we approximate the Earth as a perfect Circle, then according to the definition above, the Circumference (C) of the Earth would be 4 times 10 Million meters i.e.
C =  40 Million meters.
Circumference C and Radius R of a circle
From the standard circle equation and the circumference of the Earth (C) above, we can quickly derive the approximate radius (R) of the Earth i.e.

Solving for R = 0.5 * C / Pi, we get the Earth's radius of roughly 6370 kilometers, which is not far from the more accurate 6371 Km value.