Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mattjohnsonpint's full-sized avatar

Matt Johnson-Pint mattjohnsonpint

View GitHub Profile
@mattjohnsonpint
mattjohnsonpint / LICENSE
Last active April 2, 2024 02:54
Unified global Unhandled Exception event for .NET MAUI
MIT License
Copyright (c) 2022 Matt Johnson-Pint
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@mattjohnsonpint
mattjohnsonpint / HotRestartWorkaround.xml
Last active October 19, 2023 14:25
Workaround for Visual Studio Hot Restart issue
<!--
This target ensures that iOS Frameworks and XCFrameworks are collected from NuGet packages when using Hot Restart.
_UnpackHotRestartFrameworkAssemblies doesn't work for NuGet packages, because the frameworks aren't stored as embedded resources, but just files in the package.
-->
<Target Name="_CollectHotRestartFrameworksFromPackages" BeforeTargets="_CollectHotRestartFrameworks" Condition="'$(IsHotRestartBuild)' == 'true'">
<!--
Find all resources within NuGet packages.
For example, a package with assembly Foo.dll will have an adjacent Foo.resources folder or a Foo.resources.zip file.
-->
@mattjohnsonpint
mattjohnsonpint / Program.cs
Last active September 6, 2022 17:15
Airport Time Zones
using System.Text.RegularExpressions;
using GeoTimeZone; // Import from Nuget package "GeoTimeZone" (https://github.com/mattjohnsonpint/GeoTimeZone)
using TimeZoneConverter; // Import from Nuget package "TimeZoneConverter" (https://github.com/mattjohnsonpint/TimeZoneConverter)
namespace AirportTimeZones;
internal static class Program
{
private static void Main()
{
@mattjohnsonpint
mattjohnsonpint / dateonlybetween.cs
Created May 21, 2021 21:48
DateOnly Between methods
public static int DaysBetween(DateOnly startDate, DateOnly endDate)
{
return endDate.DayNumber - startDate.DayNumber;
}
public static (int Months, int Days) MonthsAndDaysBetween(DateOnly startDate, DateOnly endDate)
{
int months = (endDate.Year - startDate.Year) * 12 + endDate.Month - startDate.Month;
DateOnly testDate = startDate.AddMonths(months);
@mattjohnsonpint
mattjohnsonpint / Q14228793.cs
Created January 10, 2013 05:41
Example for SO Q14228793
using System.Collections.Generic;
using System.Linq;
using Raven.Client;
using Raven.Client.Indexes;
using Raven.Client.Linq;
using Raven.Tests.Helpers;
using Xunit;
namespace RavenTests.StackOverflow
{
@mattjohnsonpint
mattjohnsonpint / SPTZ.csv
Last active October 21, 2020 12:11
SharePoint time zone mappings
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 8.
"SharePoint ID","SharePoint Description","Windows Display Name","Windows ID","IANA Time Zone"
"2","(UTC) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London","(UTC) Dublin, Edinburgh, Lisbon, London","GMT Standard Time","Europe/London"
"3","(UTC+01:00) Brussels, Copenhagen, Madrid, Paris","(UTC+01:00) Brussels, Copenhagen, Madrid, Paris","Romance Standard Time","Europe/Paris"
"4","(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna","(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna","W. Europe Standard Time","Europe/Berlin"
"5","(UTC+02:00) Athens, Bucharest, Istanbul","(UTC+02:00) Athens, Bucharest","GTB Standard Time","Europe/Bucharest"
"6","(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague","(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague","Central Europe Standard Time","Europe/Budapest"
"7","(UTC+02:00) Minsk","(UTC+03:00) Kaliningrad, Minsk","Kaliningrad Standard Time","Europe/Kaliningrad"
"8","(UTC-03:00) Brasilia","(UTC-03:00) Brasilia","E. South Ameri
@mattjohnsonpint
mattjohnsonpint / Program.cs
Created January 30, 2017 23:02
Just playing with clocks
using System;
using System.Runtime.InteropServices;
namespace PreciseTimeTest
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("------------------------------------");
@mattjohnsonpint
mattjohnsonpint / wordpresstz.html
Created October 12, 2015 20:02
Wordpress Timezone List
<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">
<optgroup label="Africa">
<option value="Africa/Abidjan">Abidjan</option>
<option value="Africa/Accra">Accra</option>
<option value="Africa/Addis_Ababa">Addis Ababa</option>
<option value="Africa/Algiers">Algiers</option>
<option value="Africa/Asmara">Asmara</option>
<option value="Africa/Bamako">Bamako</option>
<option value="Africa/Bangui">Bangui</option>
<option value="Africa/Banjul">Banjul</option>
@mattjohnsonpint
mattjohnsonpint / PathModelBinderAttribute.cs
Created November 15, 2018 21:55
Path Model Binder for ASP.NET Core
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace MyNameSpace
{
public class PathModelBinderAttribute : ModelBinderAttribute
{
@mattjohnsonpint
mattjohnsonpint / moment-tz-guess.md
Created September 29, 2015 22:55
Testing moment-timezone guess feature
Windows Display Name Windows ID Preferred Response Moment Guess Result January Offset July Offset Notes
(UTC-12:00) International Date Line West Dateline Standard Time Etc/GMT+12 Etc/GMT+12 Match -12:00 -12:00
(UTC-11:00) Coordinated Universal Time-11 UTC-11 Etc/GMT+11 Pacific/Pago_Pago Acceptable -11:00 -11:00
(UTC-10:00) Hawaii Hawaiian Standard Time Pacific/Honolulu Pacific/Honolulu Match -10:00 -10:00
(UTC-09:00) Alaska Alaskan Standard Time America/Anchorage America/Anchorage Match -09:00 -08:00