Skip to content

Instantly share code, notes, and snippets.

View idusortus's full-sized avatar

Sam Johnson idusortus

  • FS-Consulting
  • Green Bay, WI
  • 20:06 (UTC -05:00)
View GitHub Profile
@idusortus
idusortus / Result.cs
Created January 30, 2024 13:33 — forked from m-jovanovic/Result.cs
Result type
public class Result
{
protected internal Result(bool isSuccess, Error error)
{
if (isSuccess && error != Error.None)
{
throw new InvalidOperationException();
}
if (!isSuccess && error == Error.None)
@idusortus
idusortus / MinimalAPIs.md
Created January 23, 2024 16:05 — forked from davidfowl/MinimalAPIs.md
Minimal APIs at a glance
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@idusortus
idusortus / csharp-expressions-statements.md
Last active April 9, 2021 14:25
C# - Expressions vs. Statements

Statements

From Microsoft:
The actions that a program takes are expressed in statements.

  • Do not return a value
  • Cannot be chained
  • May contain expressions
  • Generally cannot be used as expressions

Expressions

@idusortus
idusortus / csharp-reflection-compare-two-objects-replace-nulls.md
Last active April 9, 2021 12:52
C# .Net Core 3.1 - Compare Two Objects, Replace Nulls

Example:

var cem = new TemplateEmailModel
{
    To = "idusortus@gmail.com",
    Subject = "SES Test"                              
};

var testCem = new TemplateEmailModel
{
@idusortus
idusortus / net-csharp-sendgrid-inline-email-images.md
Last active April 7, 2021 02:14
Generate SendGrid Emails with Inline Images using C# .NET Core 3.1 ( Console )

Not optimized, or clean, but gets the point across. Getting inline images to show in the email was obnoxious. Key solution points are provided.

Backing Method

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
@idusortus
idusortus / repo-reset.md
Created January 21, 2020 23:23 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
// ternary operator
public static string Speak(string name="") => $"One for {(name=="" ? "you" : name)}, one for me.";}
// default value for optional argument
public static string Speak(string name="you") => string.Format("One for {0}, one for me.", name);
// null-coalescing assignment operator
public static string Speak(string name = null) => $"One for { name ?? "you"}, one for me.";
@idusortus
idusortus / meeting-guide-greenbayaa
Last active May 13, 2019 14:10
meeting-guide-greenbayaa
[{"name":"","slug":"0-NeverTooEarly","day":0,"time":"04:30","location":"218 Club","notes":"","locationNotes":"","updated":"2019-05-11 12:13:33","types":["c"],"address":"218 S. Oneida","city":"Green Bay","state":"WI"},{"name":"Very Early Birds","slug":"0-Very Early Birds","day":0,"time":"06:00","location":"218 Club","notes":"","locationNotes":"","updated":"2019-05-11 12:13:33","types":["c"],"address":"218 S. Oneida","city":"Green Bay","state":"WI"},{"name":"Early Birds","slug":"0-Early Birds","day":0,"time":"07:30","location":"218 Club","notes":"Back Room","locationNotes":"","updated":"2019-05-11 12:13:33","types":["c"],"address":"218 S. Oneida","city":"Green Bay","state":"WI"},{"name":"Never on Sunday","slug":"0-Never on Sunday","day":0,"time":"09:30","location":"The Bridge","notes":"","locationNotes":"","updated":"2019-05-11 12:13:33","types":["c"],"address":"2514 Jenny Lane","city":"Green Bay","state":"WI"},{"name":"","slug":"0-EspanolaWillebrord","day":0,"time":"10:00","location":"St. Willebrord Church","n