Skip to content

Instantly share code, notes, and snippets.

View peteraritchie's full-sized avatar
😖

Peter Ritchie peteraritchie

😖
View GitHub Profile

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
℅ care of ℞ prescription ⌖ target
⁃ hypen bullet ⦾ circled white bullet ⦿ ⦿ circled bullet
  very thin space ​ 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() {

CREATE

Clone an existing repository

$ git clone ssh://user@domain.com/repo.git

Create a new local repository

$ git init

LOCAL CHANGES

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}

Install a single PowerShell module file (psm1)

$AllUsersModules=($Env:PSModulePath -split ';')[1]
$moduleName="Do-TheThing"
md ($AllUsersModules+"\"+$modeuleName)
copy $modeuleName.psm1 ($AllUsersModules+"\$modeuleName"
dir ($AllUsersModules+"\send-settingchange")
get-module -ListAvailable
public async Task Start()
{
Console.WriteLine(Environment.CurrentManagedThreadId);
try
{
await DoSomething2(null);
}
catch (Exception ex)
{
Console.WriteLine("{0}: {1}", ex.Message, Environment.CurrentManagedThreadId);
public static IEnumerable<char> GetKeys()
{
while (true)
{
yield return Console.ReadKey().KeyChar;
}
}