Skip to content

Instantly share code, notes, and snippets.

View JerryNixon's full-sized avatar
🤔
Trying to make a living.

Jerry Nixon JerryNixon

🤔
Trying to make a living.
View GitHub Profile
@JerryNixon
JerryNixon / app.xaml
Last active May 1, 2017 21:45
The Visual Studio 2017 default UWP Application
<Application
x:Class="Sample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sample"
RequestedTheme="Light" />
@JerryNixon
JerryNixon / AppxManifest.xml
Last active June 1, 2020 02:02
Microsoft Windows 10 Photos App
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Package IgnorableNamespaces="uap mp uap3 build" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:wincap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/windowscapabilities" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
<Identity Name="Microsoft.Windows.Photos" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="17.313.10010.0" ProcessorArchitecture="x64" />
<mp:PhoneIdentity PhoneProductId="fca55e1b-b9a4-4289-882f-084ef4145005" PhonePublisherId="95d94207-0c7c-47ed-82db-d75c81153c35" />
<Properties>
<DisplayName>ms-resource:
@JerryNixon
JerryNixon / Extensions.cs
Last active June 19, 2017 18:57
Some nifty extensions for UWP apps using web services
using System;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Web.Http;
public static class Extensions
{
@JerryNixon
JerryNixon / AuthenticationHelper.cs
Created July 25, 2017 21:48
Microsoft's Graph API SDK Helper
//Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
//See LICENSE in the project root for license information.
using System;
using System.Diagnostics;
using System.Net.Http.Headers;
using System.Net.Http;
using System.Linq;
using System.Threading.Tasks;
using Windows.Security.Authentication.Web;
@JerryNixon
JerryNixon / ObservableDictionary.cs
Created August 13, 2018 18:51
Generic observable dictionary.
public class ObservableDictionary<K, V> : INotifyCollectionChanged, IEnumerable<KeyValuePair<K, V>>
{
private Dictionary<K, V> _dictionary = new Dictionary<K, V>();
private void RaiseChanged(NotifyCollectionChangedAction action, params K[] keys)
{
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(action, keys));
DictionaryChanged?.Invoke(this, new NotifyDictionaryChangedEventArgs(action, keys));
}
@JerryNixon
JerryNixon / TimeZoneHelper.cs
Last active August 16, 2018 20:43
US-centric, 99% accurate time zone helper.
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new DateTimeOffset(DateTime.Now));
foreach (var item in Enumerable.Range(1, 10))
{
var date = new DateTime(2018, 8, 16);
var offset = TimeSpan.FromHours(-item);
var now = new DateTimeOffset(date, offset);
@JerryNixon
JerryNixon / HolidayHelper.cs
Last active August 18, 2018 13:42
Public holidays in North America
public static class HolidayHelper
{
public static DateTime NewYears => new DateTime(DateTime.Now.Year, 1, 1).Date;
public static DateTime Christmas => new DateTime(DateTime.Now.Year, 12, 25).Date;
public static DateTime GoodFriday => GetEaster(DateTime.Now.Year).AddDays(-2);
public static DateTime Easter => GetEaster(DateTime.Now.Year);
public static class Canada
{
public static DateTime LabourDay => new DateTime(DateTime.Now.Year, 5, 1).Date;
public static DateTime Independence => new DateTime(DateTime.Now.Year, 7, 1).Date;
[ContentProperty(Name = nameof(LiteralContent))]
public sealed class AppBarLiteral : AppBarSeparator
{
public AppBarLiteral()
{
DefaultStyleKey = typeof(AppBarLiteral);
}
public object LiteralContent
{
static async Task<string> ScaleImageAsync(string path, uint height = 32, uint width = 32, StorageFile output_file = null)
{
// open file from path
var input_file = default(StorageFile);
try
{
input_file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(path));
}
catch (FileNotFoundException)
@JerryNixon
JerryNixon / app.xaml.cs
Created October 22, 2018 16:57
Preventing UWP Suspension
sealed partial class App : Application
{
public App()
{
InitializeComponent();
Suspending += (s, e) => Helpers.ShowToast("Suspending");
Resuming += (s, e) => Helpers.ShowToast("Resuming");
Helpers.SetupExSession(
allowed: () => Helpers.ShowToast("Allowed"),
denied: () => Helpers.ShowToast("Denied"),