This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public record Person(string FirstName, string LastName, DateOnly BirthDate, string[] PhoneNumbers) | |
{ | |
protected virtual bool PrintMembers(StringBuilder sb) | |
{ | |
sb.Append($"FirstName = {FirstName}, LastName = {LastName}, Birth = {BirthDate:MM/dd/yyyy}"); | |
if (!(PhoneNumbers?.Length > 0)) return true; | |
sb.Append(", PhoneNumbers: "); | |
sb.Append(string.Join(", ", PhoneNumbers)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DateTimeHelpers | |
{ | |
/// <summary> | |
/// Generates a list of dates representing the next week's dates starting from the upcoming Sunday. | |
/// </summary> | |
/// <returns>A list of <see cref="DateOnly"/> objects representing the dates of the next week.</returns> | |
public static List<DateOnly> NextWeeksDates() | |
{ | |
var start = DateTime.Now; | |
var nextSunday = DateOnly.FromDateTime(start).Next(DayOfWeek.Sunday); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Provides a custom JSON converter for <see cref="decimal"/> values, ensuring consistent formatting and parsing. | |
/// </summary> | |
/// <remarks> | |
/// This converter reads <see cref="decimal"/> values from JSON as strings and parses them using | |
/// <see cref="CultureInfo.InvariantCulture"/>. When writing, it formats <see cref="decimal"/> values | |
/// as strings with two decimal places using the same culture. | |
/// </remarks> | |
public class FixedDecimalJsonConverter : JsonConverter<decimal> | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string text = "Splits a \"PascalCase\" or \"camelCase\" string into " + | |
"separate \"words\" by inserting \"spaces\" before \"uppercase letters\"."; | |
var parts = text.StringsBetweenQuotes1(); | |
foreach (var item in parts) | |
{ | |
Console.WriteLine(item); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.Json; | |
namespace TODO; | |
class Samples | |
{ | |
public static void IntegerListMatch() | |
{ | |
List<List<int>> list = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function expandToolSectionAccordionItem() { | |
let collapseElement = document.getElementById('collapseTools'); | |
if (collapseElement) { | |
let bsCollapse = new bootstrap.Collapse(collapseElement, { | |
toggle: true | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function expandAll() { | |
document.querySelectorAll('.accordion-collapse').forEach(item => { | |
let bsCollapse = new bootstrap.Collapse(item, { toggle: false }); | |
bsCollapse.show(); | |
}); | |
} | |
function collapseAll() { | |
document.querySelectorAll('.accordion-collapse').forEach(item => { | |
let bsCollapse = new bootstrap.Collapse(item, { toggle: false }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string DefaultInterpolatedStringHandler() | |
{ | |
var title = "Mr."; | |
var firstName = "John"; | |
var middleName = "Q."; | |
var lastName = "Doe"; | |
DefaultInterpolatedStringHandler stringHandler = new(50, 4); | |
stringHandler.AppendLiteral("Hello "); | |
stringHandler.AppendFormatted(title); | |
stringHandler.AppendLiteral(" "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Bootstrap scrollable modal</title> | |
<link href="Lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" /> | |
<!-- REQUIRED --> | |
<script src="Lib/bootstrap/js/bootstrap.bundle.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Spectre.Console; | |
namespace SpectreExceptionsLibrary; | |
/// <summary> | |
/// Custom setting for presenting runtime exceptions using AnsiConsole.WriteException. | |
/// | |
/// The idea here is to present different types of exceptions with different colors while | |
/// one would be for all exceptions and the other(s) for specific exception types. | |
/// </summary> |