Skip to content

Instantly share code, notes, and snippets.

View dperish's full-sized avatar

David Lee Perish dperish

View GitHub Profile
/* XmlToMD.csx
*
* Converts .Net generated XML comments into a markdown file.
* Forked from: https://gist.github.com/lontivero/593fc51f1208555112e0
*
* Usage: scriptcs xmltomd.csx -- [XML_INPUT_FILE] <[MD_OUTPUT_FILE]>
*
* The second argument is optional, and will default to the same path
* & file name prefix as the input file.
*/
@dperish
dperish / HaskellListExtensions.cs
Created February 8, 2015 15:39
Haskell List Extensions for C#
/// <summary>
/// Extends IEnumerable Types to provide the basic
/// Haskell-like list manipulations
/// </summary>
public static class HaskellListExtensions {
/// <summary>
/// Returns the first item of a list
/// </summary>
public static T Head<T>(this IEnumerable<T> xs) {
@dperish
dperish / Enable_vt100_csharp.cs
Created November 26, 2019 13:47 — forked from tomzorz/Enable_vt100_csharp.cs
Enable VT100 for the current console window from .NET Core
using System;
using System.Runtime.InteropServices;
namespace Vt100Test
{
public class Program
{
// ReSharper disable InconsistentNaming
#include <iostream>
/** Olive's first c++ program.
Written on 2019-12-24 with love and patience.
I'm proud beyond words, and will be so forever and always.
Love,
-Daddy
*/
int main(int x)
@dperish
dperish / Guard.cs
Created June 24, 2020 13:32
Basic guard class in C#, which throws or provides method chaining on valid results
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
namespace PiotApi.Domain.Common
{
public class Guard
class GuidFlavoring<FlavorT> {
// tslint:disable-next-line: variable-name
_type?: FlavorT;
}
/** A **guid** type, based on **string** */
type GuidFlavor<T, FlavorT> = T & GuidFlavoring<FlavorT>;
/** A **guid**-flavored string primitive, supported by factory methods in the **Guid** class
*/
<#
.SYNOPSIS
- _ ___ _ ___ _ _
- /_\ ___ / __| ___ __ _ _ _ __| |_ | _ \___(_)_ _ __| |_____ _____ _ _
- / _ \ |_ / \__ \/ -_) _` | '_/ _| ' \ | / -_) | ' \/ _` / -_) \ / -_) '_|
- /_/ \_\/__| |___/\___\__,_|_| \__|_||_| |_|_\___|_|_||_\__,_\___/_\_\___|_|
.DESCRIPTION
Given an Azure search resource, this script will discover and reindex all
search indexes. This is necessary as non-soft-deletes do not remove data
from the indexes.
@dperish
dperish / MauiProviders.cs
Created February 27, 2023 14:15
Maui Test Providers
public interface IMauiProviders
{
IDialogProvider Dialogs { get; }
IPreferencesProvider Preferences { get; }
IShellProvider Shell { get; }
}
public class MauiProviders : IMauiProviders
{
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
namespace BS.Pool.App.Common;
public interface IMauiProviders
{
IDialogProvider Dialogs { get; }
IPreferencesProvider Preferences { get; }
IShellProvider Shell { get; }
@dperish
dperish / Customizations.cs
Created December 29, 2023 16:47
AutoFixture customizations for .net Maui
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using AutoFixture.AutoMoq;
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using AutoFixture.Kernel;
using AutoFixture.Xunit2;
using Objectivity.AutoFixture.XUnit2.Core.Customizations;
namespace BS.Pool.App.Tests.Customizations;