Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Morten Nielsen dotMorten

:octocat:
View GitHub Profile
@dotMorten
dotMorten / Frameworks.xml
Last active Aug 29, 2015
Modified frameworks file for Sandcastle to add support for phone 8.1
View Frameworks.xml
<?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 / Readability_AddUrl
Last active Aug 29, 2015
How to add url to Readability using Hammock (assumes you've already done the oauth part to get the token and tokenSecret)
View Readability_AddUrl
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Peregrine.Utilities
{
public static class Readability
{
View HeatIndex
/// <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 / GetLocationFromHeading.cs
Last active Aug 29, 2015
Gets the location based on a start point, a heading and a distance.
View GetLocationFromHeading.cs
using System;
namespace CodeFormulaOfTheDay
{
/// <summary>
/// Extension methods for geodesic calculations.
/// </summary>
public static class Geodesic
{
/// <summary>
@dotMorten
dotMorten / BaseValueConverter.cs
Last active Aug 29, 2015
Base class for IValue converter that abstracts away .NET and Windows Runtime IValueConverter differences. Inherit from this instead of IValueConverter
View BaseValueConverter.cs
using System;
#if NETFX_CORE
using Windows.UI.Xaml.Data;
#else
using System.Windows.Data;
#endif
namespace SampleApp.Common
{
/// <summary>
@dotMorten
dotMorten / GenericsIssue
Created Jun 6, 2014
The C# Generics problem
View GenericsIssue
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 / MainPage.xaml
Created Sep 4, 2015
Logical DPI and scale changes all of a sudden
View MainPage.xaml
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
View smartenit-zbht2.groovy
/**
* Smartenit ZHBT-2
*
* Copyright 2015 Morten Nielsen
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@dotMorten
dotMorten / AsyncTaskExtensions.cs
Created Dec 12, 2012
Silverlight/WPF/WP7 Async tasks - for ESRI.ArcGIS.Client
View AsyncTaskExtensions.cs
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using ESRI.ArcGIS.Client.Tasks;
namespace ESRI.Samples.Async.Tasks
{
public static partial class Extensions
{
@dotMorten
dotMorten / RenderCode
Last active Oct 23, 2015
XamlRenderingBackgroundTask snippets
View RenderCode
internal class GraphTile
{
public static Task CreateTileGraphAsync(Data data, int width, int height, string filename)
{
return RenderAndSaveToFileAsync(GetVisual(data, width, height), (uint)width, (uint)height, filename);
}
public static Task CreateTileGraphAsync(Data data, int width, int height, IRandomAccessStream stream)
{
return RenderAndSaveToStreamAsync(GetVisual(data, width, height), (uint)width, (uint)height, stream);
}