Skip to content

Instantly share code, notes, and snippets.

View sean-gilliam's full-sized avatar

Sean Gilliam sean-gilliam

View GitHub Profile
@sean-gilliam
sean-gilliam / POCOGenerator.sql
Last active March 21, 2025 21:34
Entity Framework POCO generator
-- from https://gist.github.com/joey-qc/6710702
-- USER SETTABLE
declare @tableNameForPOCO varchar(200)--limits POCO class generation to only mentioned table(s)
--SET @tableNameForPOCO = 'Table1,Table2,Table3'--@tableNameForPOCO can be null to mean all tables
--or it can be set to a comma-delimited list of table names
--there should be no space(s) before and after each comma in this list
set @tableNameForPOCO = 'TABLE_NAME'
--
@sean-gilliam
sean-gilliam / filter-by-type-tuple.cpp
Created August 28, 2024 17:59
C++ - Filtering tuple by type
#include <iostream>
#include <vector>
#include <tuple>
#include <typeinfo>
template<class... Tp>
std::vector<int*> GetData(std::tuple<Tp...>&& t)
{
std::vector<int*> accumulator;

Unit testing with NavigationManager

When writing unit tests for classes / services that contain methods that include NavigationManager, then create a simple derived class to "mock" that functionality.

namespace Your.Namespace.Here;

using Microsoft.AspNetCore.Components;

Entity Framework Core - Mocking DBContexts with async methods.

When mocking DbContexts for unit testing that contain async methods, an exception is thrown with the following verbiage:

System.InvalidOperationException: 'The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'. Only providers that implement 'IAsyncQueryProvider' can be used for Entity Framework asynchronous operations.'

In order to avoid this exception create the following classes:

@sean-gilliam
sean-gilliam / thunderbird-supernova-customize.md
Created October 3, 2023 22:38
Revert some of the customization that Thunderbird Supernova imposes

The new release of Thunderbird, codename Supernova, changes some key elements of the UI to be more "modern". For those who wish to keep the new release but modify some elements to semi-reflect the old UI, then here are some steps to accomplish this.

Restore Title bar

  • Click the hamburger menu in the top right corner and select Settings.
  • Click the General tab.
  • Scroll to the bottom and click the Config Editor button.
@sean-gilliam
sean-gilliam / decorator.cs
Created April 17, 2023 20:04
data-member-decorator
void Main()
{
string contract = @"
public int keyId { get; set; }
public bool error { get; set; }
public string changeProposal { get; set; }
public string dataCode { get; set; }
public string master { get; set; }
";
@sean-gilliam
sean-gilliam / qemu-gpupassthrough-lookingglass-scream-setup.md
Last active May 29, 2025 18:09
Setup Qemu for GPU Passthough with Looking Glass and Scream support.

Setup Qemu for GPU Passthough with Looking Glass and Scream support.

Before we begin, make sure that you have a monitor hooked up to the second GPU. In some situations, the video card will fail to properly initialize if one isnt attached. Also it helps with debugging issues that will most assuredly arise.

GPU Passthrough setup

Ensure that IOMMU is enabled in the BIOS. For me using an Intel system from Dell, it was under Virtualization -> Direct I/O. It should be something along those lines for AMD as well. That was the easy part :).

Before we proceed we're going to need to gather some information. Run the command, lspci -nn|grep NVIDIA (or AMD if your using that). The output for me was:

using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
void Main()
{
var input = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var test = Adapter<Test>(input);
Console.WriteLine(test);
}
This file has been truncated, but you can view the full file.
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "code/act_comm.c"
No compilation database found in /home/sgilliam/src/riftshadow/code or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
962 warnings and 1 error generated.
Error while processing /home/sgilliam/src/riftshadow/code/act_comm.c.
1725 warnings and 21 errors generated.
@sean-gilliam
sean-gilliam / exclude.ps1
Created March 9, 2020 22:06
Powershell exclusion list
$folderExclusionList = @("bin", "obj" ,"packages")
...
Where-Object {
$dir = $_.DirectoryName
# return all directories that don't have part of the exclusion list in the name
$null -eq ($folderExclusionList | Where-Object { $dir -match $_ })
}
...