Skip to content

Instantly share code, notes, and snippets.

@d1820
d1820 / PropertyMap.cs
Last active March 19, 2024 13:02
Parse object to create getter and setter expresssions
using System.Reflection;
namespace Entities
{
public class PropertyMap<T>
{
public Func<T, object> Getter { get; set; }
public PropertyInfo PropertyInfo { get; set; }
@d1820
d1820 / About.md
Created February 23, 2024 14:42
ChatGTP 3.5 Instructions that provides search links on BRAVE

This adopts the work done from ChatGPT-AutoExpert and updates it to get rid of some of the verboseness and adds links into the response (while not clickable, due to blocks by MS) are at least copy pastable to use.

Example output

image

@d1820
d1820 / Save EBooks You Own.md
Created February 20, 2024 18:52
Bookmarklets to auto advance pages from Ebooks online and save them as images

Saving ebooks as images

Saving Certain Ebook providers books

Some ebooks are image based and have certain DRM rights added to them, even though you PAID for them. These bookmarklets allows for capturing those EBooks YOU own.

Image based books

  • Install the advance-and-download-ebook bookmarklet as a favorite in your bookmarks bar.
@d1820
d1820 / Install POSH for Mac.sh
Last active February 8, 2024 14:19
Install Terminal Icons and POSH for Mac
#!/bin/bash
# Set default value for theme if not provided
theme=${1:-'quick-term.omp.json'}
font=${2:-'Meslo'}
echo 'Installing Posh...'
brew install jandedobbeleer/oh-my-posh/oh-my-posh
@d1820
d1820 / Install Terminal Icons and POSH for Powershell.ps1
Last active February 8, 2024 13:32
Install Terminal Icons and POSH for Powershell
param(
[string]$theme = "quick-term.omp.json",
[string]$font = "Meslo"
)
$moduleName = "Terminal-Icons"
$poshName = "JanDeDobbeleer.OhMyPosh"
Write-Host "Installing Terminal Icons..." -ForegroundColor Blue
Install-Module -Name $moduleName -Repository PSGallery
@d1820
d1820 / ExampleTest.cs
Last active January 13, 2024 19:14
Running XUNIT Tests that need a static implementation of a class
public class CommentHelperTests: IClassFixture<TestFixture>
{
private readonly TestFixture fixture;
public CommentHelperTests(TestFixture fixture, ITestOutputHelper output)
{
this.fixture = fixture;
this.fixture.Initialize(output);
}
@d1820
d1820 / SqlExpressionVisitor Example.txt
Last active December 29, 2023 17:57
Convert Linq Where expressions to user friendly string
foreach (var item in spec.WhereExpressions)
{
var sqlVisitor = new ExportsAPI.Domain.Visitors.SqlSearchExpressionVisitor();
string sqlString = sqlVisitor.VisitExpression(item.Filter, test);
sql.Add(sqlString);
}
SQL list:
[0]: "(Assigned.UserName = 'Awesome')"
[1]: "(Id = 'fb9244e7-72d5-4842-95a2-7b44af136a9c')"
[2]: "(ClientId = 'fb9244e7-72d5-4842-95a2-7b44af136a9c')"
@d1820
d1820 / BuilderResult.cs
Last active November 27, 2023 22:17
.Net Controller Unit Test Mock Builder
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Moq;
namespace Infrastructure.Testing.Builders
{
public class BuilderResult : HttpContextBuilderResult
{
@d1820
d1820 / CleanBinObj.ps1
Last active November 1, 2023 19:10 — forked from xtrmstep/cleanup-objbin.ps1
PowerShell command to delete all \bin and \obj folders. Use as a VS2022 External Tool
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { Write-Host "Removing $($_.fullname)"; remove-item $_.fullname -Force -Recurse }; Write-Host "Complete"
@d1820
d1820 / TaskExtensions.cs
Created October 24, 2023 15:02
.Net Task Extensions
// we use this to group them all as available based on already using this namespace
namespace Common.Extensions
{
/// <summary>
/// adapted from https://archive.ph/2022.10.14-213608/https://betterprogramming.pub/my-top-7-custom-extension-methods-for-net-7-and-c-494acb2e6634#selection-1935.0-2339.1
/// </summary>
public static class TaskExtensions
{
/// <summary>