Skip to content

Instantly share code, notes, and snippets.

View dotMorten's full-sized avatar
:octocat:

Morten Nielsen dotMorten

:octocat:
View GitHub Profile
@dotMorten
dotMorten / NewClasses
Created October 1, 2014 19:10
New Windows 10 APIs
Windows.ApplicationModel.Activation.FileOpenPickerContinuationEventArgs
Windows.ApplicationModel.Activation.FileSavePickerContinuationEventArgs
Windows.ApplicationModel.Activation.FolderPickerContinuationEventArgs
Windows.ApplicationModel.Activation.IContinuationActivatedEventArgs
Windows.ApplicationModel.Activation.IFileOpenPickerContinuationEventArgs
Windows.ApplicationModel.Activation.IFileSavePickerContinuationEventArgs
Windows.ApplicationModel.Activation.IFolderPickerContinuationEventArgs
Windows.ApplicationModel.Activation.IWebAccountProviderActivatedEventArgs
Windows.ApplicationModel.Activation.IWebAccountProviderContinuationEventArgs
Windows.ApplicationModel.Activation.WebAccountProviderActivatedEventArgs
@dotMorten
dotMorten / Haversine.cs
Last active October 23, 2015 06:37
Calculate the distance between two points on the globe using Haversine and Vincenty formulas.
#region Haversine
/// <summary>
/// Gets the distance between two points in meters using the Haversine Formula.
/// </summary>
/// <param name="startLong">The start longitude.</param>
/// <param name="startLat">The start latitude.</param>
/// <param name="endLat">The end latitude.</param>
/// <param name="endLong">The end longitude.</param>
/// <returns>Distance between the two points in meters</returns>
public static double GetDistanceHaversine(double startLong, double startLat, double endLat, double endLong)
@dotMorten
dotMorten / GenericsIssue
Created June 6, 2014 20:37
The C# Generics problem
public abstract class ClassA<T> where T : ClassB { }
public abstract class ClassB { }
public class SubClassB : ClassB { }
public class SubClassA : ClassA<SubClassB> { }
ClassA<ClassB> obj = new SubClassA(); //Won't compile :(
@dotMorten
dotMorten / BaseValueConverter.cs
Last active August 29, 2015 14:02
Base class for IValue converter that abstracts away .NET and Windows Runtime IValueConverter differences. Inherit from this instead of IValueConverter
using System;
#if NETFX_CORE
using Windows.UI.Xaml.Data;
#else
using System.Windows.Data;
#endif
namespace SampleApp.Common
{
/// <summary>
@dotMorten
dotMorten / GetLocationFromHeading.cs
Last active August 29, 2015 14:02
Gets the location based on a start point, a heading and a distance.
using System;
namespace CodeFormulaOfTheDay
{
/// <summary>
/// Extension methods for geodesic calculations.
/// </summary>
public static class Geodesic
{
/// <summary>
@dotMorten
dotMorten / HeatIndex
Created May 27, 2014 16:08
Heat Index
/// <summary>
/// Calculates the heat index
/// </summary>
/// <param name="t">Temperature in Fahrenheit</param>
/// <param name="rh">Relative humidity (0..1)</param>
/// <returns>Heat Index in Fahrenheit</returns>
public double GetHeatIndex(double t, double rh)
{
if (rh < 0 || rh > 1)
@dotMorten
dotMorten / Readability_AddUrl
Last active August 29, 2015 14:01
How to add url to Readability using Hammock (assumes you've already done the oauth part to get the token and tokenSecret)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Peregrine.Utilities
{
public static class Readability
{
@dotMorten
dotMorten / Frameworks.xml
Last active August 29, 2015 14:00
Modified frameworks file for Sandcastle to add support for phone 8.1
<?xml version="1.0" encoding="utf-8"?>
<!-- This file defines the assemblies that make up the various versions of the .NET Framework. -->
<Frameworks>
<!-- This element defines a framework. The Platform attribute defines the platform and should be
".NETFramework" for standard frameworks, ".NETPortable" for portable library frameworks,
"Silverlight" for Silverlight frameworks, or ".NETCore" for Windows Store Apps frameworks. The Version
attribute should be set to the corresponding version of the framework. The Title element defines a
friendly name that can be used in development tools. The optional Redirect element allows you to specify
an alternate framework version to use if this version is not available on the system. Redirection will
continue until a version is found or a framework without a redirection is encountered. -->
@dotMorten
dotMorten / RandomLocationProvider.cs
Last active December 27, 2015 05:09
A custom location provider that randomly accelerates and changes heading for simple in-house testing of location
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Location;
using System;
using System.Linq;
using System.Threading.Tasks;
#if NETFX_CORE
using Windows.Foundation;
using Windows.UI.Xaml;
#else
using System.Windows.Threading;
@dotMorten
dotMorten / XamlMarkerSymbol.cs
Created November 1, 2013 21:16
A XAML based PictureMarkerSymbol for the ArcGIS Runtime .NET SDK
using Esri.ArcGISRuntime.Symbology;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
#if NETFX_CORE
using Windows.UI.Xaml.Markup;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.Foundation;