Skip to content

Instantly share code, notes, and snippets.

View pwelter34's full-sized avatar

Paul Welter pwelter34

View GitHub Profile
/// <summary>
/// Provides an abstraction for hashing passwords.
/// </summary>
public interface IPasswordHasher
{
/// <summary>
/// Returns a hashed representation of the supplied <paramref name="password"/> for the specified <paramref name="user"/>.
/// </summary>
/// <param name="password">The password to hash.</param>
/// <returns>A hashed representation of the supplied <paramref name="password"/> for the specified <paramref name="user"/>.</returns>
@pwelter34
pwelter34 / HashCode.cs
Created January 14, 2021 16:54
Generate hash code
public readonly struct HashCode
{
private readonly int _value;
private HashCode(int value) => _value = value;
public static HashCode Seed { get; } = new HashCode(17);
public HashCode Combine<T>(T obj)
{
/// <summary>
/// A paged collection.
/// </summary>
/// <typeparam name="T">The type of the items in the list.</typeparam>
/// <remarks>
/// When this collection is created, <see cref="IQueryable"/> Skip and Take is
/// calculated and called on the source list. Also, if total count
/// is not specified, <see cref="IQueryable"/> Count is called.
/// </remarks>
public class PagedList<T> : List<T>
public static class DictionaryExtensions
{
/// <summary>
/// Adds a key/value pair to the Dictionary if the key does not already exist.
/// </summary>
/// <typeparam name="TKey">The type of the keys in the dictionary.</typeparam>
/// <typeparam name="TValue">The type of the values in the dictionary.</typeparam>
/// <param name="dictionary"></param>
/// <param name="key">The key of the element to add.</param>
/// <param name="valueFactory">The function used to generate a value for the key.</param>
@pwelter34
pwelter34 / sqlserver.yaml
Created May 18, 2020 19:35
use sql server in azure devops
resources:
containers:
- container: sqlserver
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- 1433:1433
env:
ACCEPT_EULA: 'Y'
SA_PASSWORD: $(SqlPassword)
@pwelter34
pwelter34 / ConfigurationLoader.tsx
Created March 31, 2020 17:29
React Configuration Loader
import React, { useState, useEffect, createContext } from "react";
import Loader from './Loader';
interface Props {
children: JSX.Element;
file?: string;
}
interface IConfiguration{
@pwelter34
pwelter34 / Retry.cs
Created February 27, 2020 19:41
Retry code
/// <summary>
/// Retry helpers for common retry scenario
/// </summary>
public static class Retry
{
/// <summary>
/// The default retry count
/// </summary>
public const int RetryCount = 5;
@pwelter34
pwelter34 / index.html
Created January 28, 2020 14:43
fix blazor startup to not require sticky sessions
<script src="~/_framework/blazor.server.js" autostart="false" asp-append-version="true"></script>
<script>
Blazor.start({
configureSignalR: function (builder) {
builder.withUrl('_blazor', {
skipNegotiation: true,
transport: 1
});
builder.configureLogging(1);
}
@pwelter34
pwelter34 / DeltaCompare.cs
Created May 10, 2019 18:10
Compare two lists giving edits, creates and deletes
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Xunit;
namespace DeltaCompare.Tests
{
public class DeltaCompareTests
{
@pwelter34
pwelter34 / audiobook.ps1
Created October 5, 2018 23:45
Convert mp3 files into m4b audiobook
$outFile = ".\output.m4a"
$mergeText = ".\merge.txt"
$metadataText = ".\metadata.txt"
# cleanup working files
If (Test-Path $outFile){
Remove-Item $outFile
}
If (Test-Path $mergeText){
Remove-Item $mergeText