Skip to content

Instantly share code, notes, and snippets.

Duncan Smart duncansmart

Block or report user

Report or block duncansmart

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View EE APN IPv4.mobileconfig
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
duncansmart / MailEventLogs.ps1
Created Jul 13, 2017
Emails filtered eventlogs from previous 24 hours
View MailEventLogs.ps1
# powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -Command "& { .\MailEventLogs.ps1 }"
$mailTo = ""
$mailFrom = "$"
$smtpServer = ""
Set-StrictMode -Version Latest
$startDate = (Get-Date).AddDays(-1).AddMinutes(-5)
View csc_net46.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
duncansmart / NET47ValueTupleFix.props
Created May 30, 2017
Fix for `CS8179: Predefined type 'System.ValueTuple`2' is not defined or imported` in Razor files
View NET47ValueTupleFix.props
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="">
Copy to %LOCALAPPDATA%\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\
<!-- If we have .NET 4.7 use ValueTuple defined in mscorlib -->
<DotNet47Installed Condition=" '$([MSBuild]::GetRegistryValueFromView(`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.7`, null, `NOT_FOUND`, RegistryView.Registry64))' == '' ">True</DotNet47Installed>
<TargetFrameworkVersion Condition="$(TargetFrameworkVersion) == '4.6' And '$(DotNet47Installed)' == 'True'">v4.7</TargetFrameworkVersion>
duncansmart / Windows 10 CU ValueTuple
Last active Apr 24, 2017
Windows 10 CU ValueTuple hack
View Windows 10 CU ValueTuple

Define an environment variable called Windows10CUFix with value = 1

In proj file locate <Reference Include="System.ValueTuple... and replace with following:

<Reference Condition=" '$(Windows10CUFix)' == '' " Include="System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<Reference Condition=" '$(Windows10CUFix)' != '' " Include="mscorlib">
View StreamingXmlParser.cs
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Diagnostics;
class StreamingXmlParser
public class ElementInfo
View ParsingFileUploadsWithMimeKit.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using FakeItEasy;
using MimeKit;
using System.Collections.Specialized;
using System.Collections.Generic;
duncansmart / env.aspx
Created Apr 12, 2016
Dump server environment variables
View env.aspx
<%@ Page Language="C#" %>
<% foreach (DictionaryEntry item in Environment.GetEnvironmentVariables()) { %>
<li><%:item.Key%>: <code><%:item.Value%></code></li>
View track-all-branches.cmd
:: tracks all branches for a remote e.g. `git branch --track origin/foo foo`
:: based on info from
git branch -r | for /f "delims=/ tokens=1,*" %%A IN ('find "origin/"') do (
@git branch --track %%A/%%B %%B
duncansmart / PrecompileWebApp.cs
Created Jan 21, 2016
How to ensure a an ASP.NET web app is fully compiled at startup
View PrecompileWebApp.cs
using System;
using System.Web;
// ...
namespace Foo
public class MyWebApp : System.Web.HttpApplication
protected void Application_Start()
var cbm = new System.Web.Compilation.ClientBuildManager(HttpRuntime.AppDomainAppId, null);
You can’t perform that action at this time.