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 / MSBuildCheatSheet.xml
Created January 14, 2019 23:19
MSBuild Cheat Sheet
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
How to define a variable.
Just stick a new node in a property group.
-->
<PropertyGroup>
<!-- This node in a property group will define a variable -->
<TestVariable>Test Variable Value</TestVariable>
@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 / ConvertXliffToResx.targets
Created June 20, 2020 01:13
Converting xliff to resx/resw as a build task
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="UpdateRuntimeResources">
<ItemGroup>
<XLiffResources Include="$(MSBuildThisFileDirectory)\xliff_resources\**\*.xliff" />
</ItemGroup>
<ImportResourceFiles XliffFiles="@(XLiffResources)" OutputDirectory="$(MSBuildThisFileDirectory)\LocalizedStrings" IsUWP="False" />
</Target>
<UsingTask TaskName="ImportResourceFiles" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
@dotMorten
dotMorten / CacheHttpHandler.cs
Created November 17, 2019 07:41
Quick and dirty implementation of etag and cache control: Note: threading issues! Don't use as is
using System;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HttpCacheClient
{
{
"acrylicOpacity": 0.5,
"background": "#012456",
"closeOnExit": true,
"colorScheme": "Campbell",
"commandline": "%comspec% /k \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\Tools\\VsDevCmd.bat\"",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "Consolas",
"fontSize": 10,
// Requires the following nuget packages:
// NuGet.Packaging
// OpenVsixSignTool.Core
// And built on .NET Framework 4.7.2+
using NuGet.Packaging;
using NuGet.Packaging.Signing;
using System;
using System.Collections.Generic;
using System.IO;
@dotMorten
dotMorten / Geolocation.cs
Last active August 2, 2019 21:05
Wraps the WinRT Geolocation APIs in reflection-based calls so no dependency on Win10 is needed
using System;
using System.Reflection;
using System.Threading.Tasks;
namespace Windows.Devices.Geolocation
{
internal sealed class Geolocator
{
private readonly object locatorInstance;
internal static Type WinRTType { get; } = Type.GetType("Windows.Devices.Geolocation.Geolocator, Windows, ContentType=WindowsRuntime");
@dotMorten
dotMorten / GraphicsTelemetry.cs
Created March 30, 2019 00:00
GraphicsTelemetry.cs
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
namespace TelemetryClientSample.Telemetry
{
class GraphicsTelemetry : ITelemetryInitializer
{
@dotMorten
dotMorten / XF3.4-3.5.md
Last active February 9, 2019 00:43
What's new in Xamarin.Forms between 3.4.0.1008975 and 3.5.0.129452
namespace Xamarin.Forms
{
    public class Xamarin.Xamarin.Forms.BackButtonBehavior : BindableObject
    {
        public BackButtonBehavior();
        public ICommand Command { get; set;  }
        public object CommandParameter { get; set;  }
        public ImageSource IconOverride { get; set;  }
 public bool IsEnabled { get; set; }
@dotMorten
dotMorten / RunUWPTests.cmd
Created September 29, 2018 03:44
Run UWP Unit Tests
REM Build project
msbuild /restore /t:Build /p:Platform=x64;Configuration=Debug MyUWPTestProject.csproj
REM Remove previous install
Powershell.exe -command "& {Remove-AppxPackage -Package 'd160b1a9-2c65-41ed-82af-4d4939e99742_1.0.0.0_x64__zy2ctb9gr90we'}"
REM Install cert. Note: Must be run with elevated (admin) access
certutil -addstore root "AppPackages\MyUWPTestProject_1.0.0.0_x64_Debug_Test\MyUWPTestProject_1.0.0.0_x64_Debug.cer"
REM Run Tests