Skip to content

Instantly share code, notes, and snippets.

View peteraritchie's full-sized avatar
😖

Peter Ritchie peteraritchie

😖
View GitHub Profile
/// <summary>
/// Some extensions for <seealso cref="ImmutableList{T}"/>
/// </summary>
public static class ImmutableListExtensions
{
/// <summary>
/// Replace <paramref name="value"/> in <paramref name="source"/> based on object equality
/// </summary>
/// <remarks>
/// This method depends on the <typeparamref name="T"/> implementing Object.Equals, if it does not,

The structure of IPv4 addresses lies at the core of the internet's architecture

  • does calling out IPv4 mean many of the details in this chapter apply to IPv6?

The very structure of IPv4 addresses presents an interesting duality: they serve as both identifiers and locators.

  • "Locator" in what sense?

[Just as a street address indicates a specific location, an IP address designates a particular device on a network. The subnet mask, analogous to the zip code, guides data packets to their intended destination.](https://cwoodruff.github.io/book-network-programming-csharp/chapter02/#:~:text=just%20as%20

HTML Entities

general

HTML Description HTML Description HTML Description
&incare; care of &rx; prescription &target; target
&hybull; hypen bullet &olcir; circled white bullet &ofcir; ⦿ circled bullet
&hairsp; very thin space &ZeroWidthSpace; zero-width space

Arrows

@peteraritchie
peteraritchie / Directory.build.props
Last active February 27, 2024 20:11
A Directory.build.props file that cleans the `obj` and `bin` directories when executing `dotnet clean` or the clean operation in Visual Studio. Find latest version here: https://gist.githubusercontent.com/peteraritchie/c32008d0c20323126c908a61ef9991d6/raw/Directory.build.props
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>
</PropertyGroup>
<Target Name="PostClean" AfterTargets="Clean">
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
</Project>
@peteraritchie
peteraritchie / visual-studio-classes.ps1
Created February 27, 2024 16:02
A work in progress for a couple (maybe more) classes to wrap some `dotnet new` commands.
<# e.g.:
. .\visual-studio-classes.ps1
$csproj = [Project]::CreateClassLib(".\Solution\ClassLib\ClassLib.csproj");
$csproj.AddClass('MyClass');
#>
class Project {
[string]$Folder;
Project() {

Visual Studio HTTP Files

env

{
  "dev": {
    "ClientSecret": {
      "provider": "AzureKeyVault",
      "secretName": "clientSecret",
@peteraritchie
peteraritchie / search-replace-try-catch.md
Created December 12, 2023 22:34
Search and replace try/catch in C#

Search for

^(?'tab'\s*)try\s*\r?\n+\k<tab>\{\r?\n(?'tried'(.*\r?\n)+)\k<tab>\}\r?\n\k<tab>catch\s+.*\r?\n\k<tab>\{\s*\r?\n(?'caught'(.*\r?\n)+)\k<tab>\}(\r?\n)+

Replace with:

${tried}

dotnet new sln -n MySolution
gci -r '*.csproj' | ForEach-Object { dotnet sln MySolution.sln add $_.FullName;}

Akin's Laws Spacecraft Design

From Akin's Laws of Spacecraft Design

  1. Engineering is done with numbers. Analysis without numbers is only an opinion.

  2. To design a spacecraft right takes an infinite amount of effort. This is why it's a good idea to design them to operate when some things are wrong .

  3. Design is an iterative process. The necessary number of iterations is one more than the number you have currently done. This is true at any point in time.