Skip to content

Instantly share code, notes, and snippets.

View ctolkien's full-sized avatar
👋

Chad Tolkien ctolkien

👋
View GitHub Profile
@ctolkien
ctolkien / OptionExposer.cs
Created March 22, 2017 06:43
Toying with middleware for showing what options we have
public static class ExposingConfigurationMiddlewareExtensions
{
public static IApplicationBuilder UseExposeConfiguration(
this IApplicationBuilder builder,
IConfigurationRoot configRoot,
string pathMatch = "/options")
{
return builder.MapWhen(x =>
{
@ctolkien
ctolkien / dotnetversions.md
Last active March 9, 2017 03:46
.Net version landscape
Thing LTS Current
Tooling / SDK 1.0.0 1.0.1
Runtime 1.0.4 1.1.1
NetStandard.Library 1.6.0 1.6.1
MVC 1.0.3 1.1.2
EF Core 1.0.3 1.1.1
@ctolkien
ctolkien / cldr
Created October 12, 2016 04:13
The correct incantation required for AU date validation
<script>
$(function(){
$.when(
$.get("@Url.Content("~/Content/components/cldr-data/main/en-AU/ca-gregorian.json")"),
$.get("@Url.Content("~/Content/components/cldr-data/main/en-AU/numbers.json")"),
$.get("@Url.Content("~/Content/components/cldr-data/supplemental/numberingSystems.json")"),
$.get("@Url.Content("~/Content/components/cldr-data/main/en-AU/timeZoneNames.json")"),
$.get("@Url.Content("~/Content/components/cldr-data/supplemental/likelySubtags.json")"),
$.get("@Url.Content("~/Content/components/cldr-data/supplemental/timeData.json")"),
$.get("@Url.Content("~/Content/components/cldr-data/supplemental/weekData.json")")
public string RenderRazorViewToString(string viewName, object model)
{
ViewData.Model = model;
using (var sw = new StringWriter())
{
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext,
viewName);
var viewContext = new ViewContext(ControllerContext, viewResult.View,
ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
@ctolkien
ctolkien / AppInsights404TelemetryFilter
Created June 27, 2016 01:20
AppInsights404TelemetryFilter
public class AppInsights404TelemetryFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
public AppInsights404TelemetryFilter(ITelemetryProcessor next)
{
Next = next;
}
public void Process(ITelemetry item)
{
@ctolkien
ctolkien / gist:4fcbecdcbbedde85fd7997a32278149f
Created June 21, 2016 04:09
Pushing from AppVeyor to AppInsights
powershell Invoke-Command ([scriptblock]::Create((Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/ApplicationInsights-Home/master/API/CreateReleaseAnnotation.ps1).Content)) -ArgumentList "appId", "apiKey", $(APPVEYOR_REPO_COMMIT)
@ctolkien
ctolkien / gist:f7bf9ea30c71210d386229882ff49e06
Created April 19, 2016 23:55
Routing to specific azure deployment slots.
@ChadT FYI: If you ever happen to be in similar situation that I described earlier, there's a solution: you can set querystring parameter ?x-ms-routing-name=<slotName> that routes traffic into given slot
@ctolkien
ctolkien / gist:944536be1955149725b7
Created March 3, 2016 00:37
App Insights Error Monitoring
public class AppInsightsExceptionHandlerAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
if (filterContext != null && filterContext.HttpContext != null && filterContext.Exception != null)
{
//If customError is Off, then AI HTTPModule will report the exception
if (filterContext.HttpContext.IsCustomErrorEnabled)
{
// Note: A single instance of telemetry client is sufficient to track multiple telemetry items.
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
param([string]$title) "Called with parameter: $title"