Skip to content

Instantly share code, notes, and snippets.

View mattdot's full-sized avatar

Matt Dotson mattdot

  • Microsoft
  • Los Angeles, CA, USA
  • 20:20 (UTC -08:00)
  • LinkedIn in/mattdot
View GitHub Profile
@mattdot
mattdot / Statistics.cs
Created May 11, 2018 23:46
Online/Streaming implementation of Std Deviation and Variance in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Statistics
{
public static class OnlineStatistics
{
@mattdot
mattdot / UserAgent.cs
Last active November 17, 2017 03:52
Set the UserAgent for a UWP WebView
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace UA
{
public static class UserAgent
@mattdot
mattdot / UniversalMouseBackButton.cs
Last active November 17, 2015 20:46
Sample showing how to enable back navigation by clicking the "back" in a Universal app.
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Windows.Devices.Enumeration;
using Windows.Media.Devices;
namespace HeadphoneJackDetection
{
public sealed class JackPrescenceEventArgs : EventArgs
@mattdot
mattdot / gist:1086078
Created July 16, 2011 06:39
WCF Web API: Extension methods for requesting a response in JSON, and for setting Basic auth headers
public static class HttpClientExtensionMethods
{
public static void SetBasicAuth(this HttpClient httpClient, string userName, string password)
{
var byteArray = Encoding.ASCII.GetBytes(userName + ":" + password);
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
public static void AcceptJson(this HttpClient httpClient)
{
@mattdot
mattdot / Timely Bookmarklet
Created March 15, 2011 14:30
Add this script as a bookmark to get Timely to work on your iPad/iPhone
javascript:(function(){var%20w=500,h=225,l=Math.round((screen.width-w)/2),t=Math.round((screen.height-h)/2),d=document,s=w.getSelection?w.getSelection():d.title;if(s=='')s=d.title;window.ft=window.open('http://timely.flowtown.com/bookmarklet?s='+encodeURIComponent(s+'%20'+d.location),'','left='+l+',top='+(t%3E0?t:0)+',width='+w+',height='+h+',personalbar=0,toolbar=0,scrollbars=0,resizable=1');})();