Skip to content

Instantly share code, notes, and snippets.

View dotMorten's full-sized avatar
:octocat:

Morten Nielsen dotMorten

:octocat:
View GitHub Profile
/**
* 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 / ObservableCollection2.cs
Created November 26, 2015 20:36
Observable Collection supporting range adds efficiently without causing a lot of UI updates
public class ObservableCollection2<T> : ObservableCollection<T>
{
public void AddRange(IEnumerable<T> items)
{
InsertRange(Count, items);
}
public void InsertRange(int index, IEnumerable<T> items)
{
int count = 0;
foreach(var item in items)
@dotMorten
dotMorten / MainPage-snippet.xaml
Last active June 23, 2016 21:35
StaggeredGrid
<ItemsControl x:Name="items" Grid.RowSpan="3" ItemsSource="{x:Bind Data}" Background="LightGray">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<local:StaggeredGridPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="{Binding Brush}" Height="{Binding Height}">
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" />
@dotMorten
dotMorten / XMLDocumentationStripper.cs
Last active September 14, 2016 17:54
Optimizes XML Doc for intellisense by stripping out internals and remarks from the XML doc
using Mono.Cecil;
using Mono.Cecil.Rocks;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
@dotMorten
dotMorten / Program.cs
Last active December 8, 2016 20:08
Simple Iotivity Server and Light Resource created using .NET calling into the Iotivity C-API
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
namespace SimpleServerNet
{
class Program
{
private static CancellationTokenSource ct;
@dotMorten
dotMorten / Program.cs
Created August 25, 2017 21:47
Slow webserver response test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TimeoutTestApp
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Core;
using Windows.UI.Xaml.Data;
namespace UniversalTestApp
@dotMorten
dotMorten / ARApp.Android.cs
Last active March 16, 2018 16:58
Abstract UrhoSharp AR class
#if __ANDROID__
using Urho;
using System.Linq;
using Com.Google.AR.Core;
using Urho.Droid;
namespace UrhoAR
{
public abstract partial class ARApp : SimpleApplication
{
@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
@dotMorten
dotMorten / MSBuildCheatSheet.xml
Last active May 2, 2025 22:37
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>