Skip to content

Instantly share code, notes, and snippets.

View EE APN IPv4.mobileconfig
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>APNs</key>
<array>
<dict>
@duncansmart
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 = "foo@example.com"
$mailFrom = "$env:COMPUTERNAME@example.com"
$smtpServer = "aspmx.l.google.com"
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
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="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Copy to %LOCALAPPDATA%\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\
-->
<PropertyGroup>
<!-- 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>
</PropertyGroup>
@duncansmart
duncansmart / Windows 10 CU ValueTuple hack.md
Last active Apr 24, 2017
Windows 10 CU ValueTuple hack
View Windows 10 CU ValueTuple hack.md

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=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Condition=" '$(Windows10CUFix)' != '' " Include="mscorlib">
    <HintPath>$(WINDIR)\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll</HintPath>
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
duncansmart / env.aspx
Created Apr 12, 2016
Dump server environment variables
View env.aspx
<%@ Page Language="C#" %>
<ul>
<% foreach (DictionaryEntry item in Environment.GetEnvironmentVariables()) { %>
<li><%:item.Key%>: <code><%:item.Value%></code></li>
<%}%>
<ul>
View track-all-branches.cmd
:: tracks all branches for a remote e.g. `git branch --track origin/foo foo`
:: based on info from http://stackoverflow.com/questions/67699/clone-all-remote-branches-with-git
git branch -r | for /f "delims=/ tokens=1,*" %%A IN ('find "origin/"') do (
@git branch --track %%A/%%B %%B
)
@duncansmart
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.