Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Morten Nielsen dotMorten

:octocat:
View GitHub Profile
@dotMorten
dotMorten / ConvertXliffToResx.targets
Created Jun 20, 2020
Converting xliff to resx/resw as a build task
View ConvertXliffToResx.targets
<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 Nov 17, 2019
Quick and dirty implementation of etag and cache control: Note: threading issues! Don't use as is
View CacheHttpHandler.cs
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
{
View WindowsTerminal.VSDev.json
{
"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,
View Program.cs
// 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 Aug 2, 2019
Wraps the WinRT Geolocation APIs in reflection-based calls so no dependency on Win10 is needed
View Geolocation.cs
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");
View 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 Feb 9, 2019
What's new in Xamarin.Forms between 3.4.0.1008975 and 3.5.0.129452
View XF3.4-3.5.md
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;  }
View MSBuildCheatSheet.xml
<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>
View RunUWPTests.cmd
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
@dotMorten
dotMorten / ARApp.Android.cs
Last active Mar 16, 2018
Abstract UrhoSharp AR class
View ARApp.Android.cs
#if __ANDROID__
using Urho;
using System.Linq;
using Com.Google.AR.Core;
using Urho.Droid;
namespace UrhoAR
{
public abstract partial class ARApp : SimpleApplication
{