Skip to content

Instantly share code, notes, and snippets.

View erinnmclaughlin's full-sized avatar

Erin McLaughlin erinnmclaughlin

View GitHub Profile
@erinnmclaughlin
erinnmclaughlin / Program.cs
Created July 15, 2025 12:57
Expressions & EF Core
using System.Linq.Expressions;
using System.Text;
using Dumpify;
string[] abc = ["a", "b", "c"];
var q1 = abc.AsQueryable();
Console.WriteLine(q1.Expression);
q1.Expression.Dump();
@erinnmclaughlin
erinnmclaughlin / Program.cs
Created June 7, 2025 13:29
C# Expression Trees
using System.Linq.Expressions;
// An expression simply turns a delegate into a data about itself. So a => a + 1 becomes something like "On the left side there's an int a. On the right side you add 1 to it."
// Func doesn't carry with it a way to get into itself.
// Source: https://stackoverflow.com/a/34606818
// This is a function that will add 1 to the input a.
// Inside your code, this does exactly that.
// However, let's say you want to translate this function into SQL. Your code will need to know what this fuction DOES.
// This is not possibly with just a Func. So...
@erinnmclaughlin
erinnmclaughlin / 00 - Cursor AI Prompting Rules.md
Created March 25, 2025 03:40 — forked from aashari/00 - Cursor AI Prompting Rules.md
Cursor AI Prompting Rules - This gist provides structured prompting rules for optimizing Cursor AI interactions. It includes three key files to streamline AI behavior for different tasks.

Cursor AI Prompting Framework

This repository provides a structured set of prompting rules to optimize interactions with Cursor AI. It includes three key files to guide the AI’s behavior across various coding tasks.

Files and Their Roles

core.md

  • Purpose: Establishes foundational rules for consistent AI behavior across all tasks.
  • Usage: Place this file in your project’s .cursor/rules/ folder to apply it persistently:
  • Save core.md under .cursor/rules/ in the workspace root.
@erinnmclaughlin
erinnmclaughlin / .editorconfig
Created March 24, 2025 11:47
Default .editorconfig settings
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
tab_width = 4
indent_style = space
max_line_length = 150
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using AssessmentService.Common.Pagination;
using AssessmentService.Common.Serialization;
using MediatR;
namespace IntegrationTests;
public static class XunitJsonExtensions
{
@erinnmclaughlin
erinnmclaughlin / Program.cs
Last active October 31, 2024 18:26
Entity Framework Core Projections
using Microsoft.EntityFrameworkCore;
var dbContext = new TodoListDbContext();
await dbContext.InitializeWithSeedData();
// Example 1: Extending the entity:
var query1 = dbContext.TodoLists.Select(x => x.ToDto()); // this will NOT work as expected
var query1Sql = query1.ToQueryString();
var query1Result = await query1.FirstAsync();
@erinnmclaughlin
erinnmclaughlin / Program.cs
Last active August 7, 2024 18:31
Adjusting Dates for Daylight Savings Time in C#
var easternTime = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
for (var month = 1; month <= 12; month++)
{
var date = new DateTime(2024, month, 1);
var utcOffset = easternTime.GetUtcOffset(date);
var timeZoneName = easternTime.IsDaylightSavingTime(date) ? easternTime.DaylightName : easternTime.StandardName;
Console.WriteLine($"On {date}, the UTC offset will be {utcOffset} ({timeZoneName}).");
}
@erinnmclaughlin
erinnmclaughlin / MyApiFactory.cs
Last active August 6, 2024 14:20
Integration testing with Docker & Web Application Factory
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Testcontainers.MsSql;
namespace MyIntegrationTests;
@erinnmclaughlin
erinnmclaughlin / tailwind-variables.css
Last active December 29, 2023 12:40
css variables from Tailwind
/**************************************/
/*************** Colors ***************/
/**************************************/
:root {
/* Slate */
--colors-slate-50: 248 250 252;
--colors-slate-100: 241 245 249;
--colors-slate-200: 226 232 240;
--colors-slate-300: 203 213 225;
@erinnmclaughlin
erinnmclaughlin / connection-strings.json
Last active May 24, 2025 19:24
Connection String Formats
{
"MsSqlLocalDb": "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog={YOUR_DB_NAME};Integrated Security=True;",
"SqlExpress": "Data Source=localhost,1433;Initial Catalog={YOUR_DB_NAME};User Id={YOUR_USER_ID};Password={YOUR_PASSWORD};TrustServerCertificate=True",
"Postgres": "Host=localhost:5432;Database={YOUR_DB_NAME};Username=postgres;Password=postgres"
}