Skip to content

Instantly share code, notes, and snippets.

View karenpayneoregon's full-sized avatar
🎯
Focusing

Karen Payne karenpayneoregon

🎯
Focusing
View GitHub Profile
var $debugHelper = $debugHelper || {};
$debugHelper = function () {
var href = "lib/debugger.css";
var addCss = function () {
if (styleStyleIsLoaded(href) === true) {
return;
}
const head = document.head;
const link = document.createElement("link");
link.type = "text/css";
@karenpayneoregon
karenpayneoregon / Helpers.cs
Last active September 13, 2024 20:39
Random
using System.Security.Cryptography;
public static class Helpers
{
public static string RandomNumberString(int length) =>
RandomNumberGenerator.GetString(
choices: new string('a'.To('z').Concat('0'.To('9')).ToArray()),
length: length
);
public static T[] RandomElements<T>(this T[] source, int count) =>
@karenpayneoregon
karenpayneoregon / keyboard.md
Last active September 12, 2024 14:39
Resharper Keys
public class BirthDay
{
private const string Template =
"""
Hey,
{name}'s birthday is on {dob}, which is in {month}.
Let's plan a party!
@karenpayneoregon
karenpayneoregon / IBaseEntity.cs
Created September 11, 2024 15:08
Read json asynchronous
public interface IBaseEntity
{
int Id { get; set; }
}
@karenpayneoregon
karenpayneoregon / RemoveExtraSpaces.cs
Created August 28, 2024 18:50
Remove extra spaces from a string
internal static partial class Extensions
{
public static string RemoveExtraSpaces(this string sender, bool trimEnd = true)
{
var result = MultipleSpacesRegex().Replace(sender, " ");
return trimEnd ? result.TrimEnd() : result;
}
[GeneratedRegex("[ ]{2,}", RegexOptions.None)]
private static partial Regex MultipleSpacesRegex();
@karenpayneoregon
karenpayneoregon / ProcedureProperty.cs
Last active August 23, 2024 16:11
Get user stored procedure extended properties
public class ProcedureProperty
{
public string Schema { get; set; }
public string Name { get; set; }
public string Information { get; set; }
public string PropertyValue { get; set; }
public override string ToString() => $"{Information} = {PropertyValue}";
}
@karenpayneoregon
karenpayneoregon / Deconstruction.cs
Created August 21, 2024 13:52
Deconstruction basics
public class Deconstruction
{
private static ItemContainer[] _responseKeys =
[
new ItemContainer(1, "A", "Yes"),
new ItemContainer(2, "B", "No"),
new ItemContainer(3, "C", "Yes"),
new ItemContainer(4, "A", "No")
];
@karenpayneoregon
karenpayneoregon / Person.cs
Created August 16, 2024 21:51
Generic iterate simple class/model
public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateOnly BirthDate { get; set; }
}
@karenpayneoregon
karenpayneoregon / Example.cs
Created August 15, 2024 13:18
Get month index for Abbreviated month
List<IndexContainer<string>> details = Helpers.AbbreviatedMonthNames();
var exist = Helpers.Contains("Jan");
var proper1 = "JAN".ProperCased();
var proper2 = "jAn".ProperCased();
var proper3 = "jan".ProperCased();
var index = Helpers.GetNumberFromShortMonth("jun");