Skip to content

Instantly share code, notes, and snippets.

View mrlacey's full-sized avatar
😇

Matt Lacey mrlacey

😇
View GitHub Profile
@mrlacey
mrlacey / addAppointment
Created March 9, 2015 13:45
Things you can do with Windows 10 Web Apps
addAppointment = function(e, t, n) {
if ("undefined" != typeof Windows) {
var o = new Windows.ApplicationModel.Appointments.Appointment;
o.allDay = !0, o.startTime = new Date(i(t, "dddd, Do MMM YYYY").format()), o.subject = "Trip to " + n, Windows.ApplicationModel.Appointments.AppointmentManager.showAddAppointmentAsync(o, {
x: 300,
y: 0,
width: 600,
height: 100
}).done(function(t) {
t ? (console.log("created!"), e()) : console.log("issue")
@mrlacey
mrlacey / MultiColorImageCreator
Created June 12, 2015 13:50
Snippet from a WPF app that produces an image where every pixel is a different color.
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows;
namespace GenerateMultiColorImages
{
public partial class MainWindow : Window
{
public MainWindow()
{
@mrlacey
mrlacey / AdMediatorSizeByDevice.xaml
Last active October 12, 2015 16:32
Example of how to change the size of the AdMediatorControl depending on the device width.
<Grid>
<Universal:AdMediatorControl x:Name="AdControl"
Id="ecba2d7a-f2d9-43bb-ab12-f8c5df300987"
Height="90"
Width="728" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="Mobile">
<VisualState.StateTriggers>
@mrlacey
mrlacey / DebugBuildOnly.cs
Created November 8, 2016 03:35
For creating XAML based solution for limiting which build controls are included in
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace OnlyIn
{
public class DebugBuild : ContentControl
{
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
using Windows.UI.Xaml.Controls;
namespace OnlyIn
{
public class DebugBuild : ContentControl
{
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
<Page
x:Class="MediaDial.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Padding="50">
@mrlacey
mrlacey / IsOneOfBenchmarks.cs
Last active October 10, 2017 06:14
Benchmark tests comparing ways of matching a variable against multiple possible options. As created for http://www.mrlacey.com/2017/10/optimizing-comparison-of-variable-with.html
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Linq;
namespace IsOneOfBenchmarks
{
class Program
{
static void Main(string[] args)
{
@mrlacey
mrlacey / AutomatedWizardTestingBase.cs
Last active April 24, 2018 19:23
Base class for WinAppDriver based UI tests
public class AutomatedWizardTestingBase : IDisposable
{
protected WindowsDriver<WindowsElement> AppSession { get; private set; }
protected AutomatedWizardTestingBase()
{
CheckWinAppDriverInstalled();
StartWinAppDriverIfNotRunning();
}
@mrlacey
mrlacey / StrRevVizBenchamarks.cs
Created November 12, 2018 21:05
Code used in benchmark tests for StringResourceVisualizer when reviewing cahnging string manipulation to use Span<T>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
@mrlacey
mrlacey / GridLines.cs
Created December 8, 2018 16:19
UWP Grid ShowGridLines
public class GridLines : DependencyObject
{
public static readonly DependencyProperty AreVisibleProperty =
DependencyProperty.RegisterAttached(
"AreVisible",
typeof(Boolean),
typeof(GridLines),
new PropertyMetadata(false, OnPropertyChanged)
);