Skip to content

Instantly share code, notes, and snippets.

View astrohart's full-sized avatar

Brian astrohart

View GitHub Profile
@astrohart
astrohart / Data.TextTemplate.tt
Created February 19, 2021 15:13
Template for a database-enabled text-templating (T4) file.
<#@ template language="C#" debug="false" hostspecific="true" #>
<#@ output extension=".cs" #>
<#@ assembly name="System" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data.Entity" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
@astrohart
astrohart / EnvDTE Boilerplate.linq
Last active January 11, 2021 14:48
LINQPad Query Boilerplate to Access VS 2019 via EnvDTE from LINQpad
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
<NuGetReference>EnvDTE</NuGetReference>
<NuGetReference>Microsoft.VisualStudio.Setup.Configuration.Interop</NuGetReference>
<Namespace>EnvDTE</Namespace>
<Namespace>Microsoft.VisualStudio.Setup.Configuration</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Collections.Generic</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.IO</Namespace>
@astrohart
astrohart / Database.DataBinding.tt
Last active January 30, 2021 14:38
T4 Template that creates an ObservableListSource in the <project-name>.DataBinding Namespace. This is what Navigation Properties should use for EF6+WinForms compatibility.
<#@ template language="C#" debug="false" hostspecific="true" #>
<#@ output extension=".cs" #>
<#@ assembly name="System" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data.Entity" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
@astrohart
astrohart / BusinessLayer.WinForms.tt
Last active January 30, 2021 14:38
T4 Text Templates (2 of them) to scaffold an Entity Framework Business Layer for a C# Windows Forms application that uses data-bound controls - both the BusinessLayer.WinForms.tt and ObservableListSource.DataBinding.tt files must be downloaded and added to your project/solution for it to work!
<#@ template language="C#" debug="false" hostspecific="true" #>
<#@ output extension=".cs" #>
<#@ assembly name="System" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data.Entity" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
@astrohart
astrohart / Open SQL Server DB Perms to a Windows Network Service.sql
Last active December 20, 2020 17:07
Open NETWORK SERVICE full perms on Microsoft SQL Serve 2019 database.
/*
Script to Open Full Permissions on a Database for a Windows Service
Purpose: Open full access privileges to the NT AUTHORITY\NETWORK SERVICE
user on the local computer to the SQL Server database named MyDatabase.
Objective is to allow Windows Service processes that run under that user
to access the target dataase hosted by an instance of Microsoft SQL Server
2019.
SQL Server version: Microsoft SQL Server 2019
@astrohart
astrohart / BusinessLayer.tt
Last active January 30, 2021 14:39
T4 template File to Generate Full Database Business Layer Stack with Logging, Robust Execution, and Exception Handling for free, plus full XML documentation
<#@ template language="C#" debug="false" hostspecific="true" #>
<#@ output extension=".cs" #>
<#@ assembly name="System" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data.Entity" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
@astrohart
astrohart / make_windows10_great_again.bat
Created January 26, 2019 19:18 — forked from IntergalacticApps/make_windows10_great_again.bat
Make Windows 10 Great Again - stop Windows 10 spying!
@echo off
setlocal EnableDelayedExpansion
ver | find "10." > nul
if errorlevel 1 (
echo Your Windows version is not Windows 10... yet. Brace yourself, Windows 10 is coming^^!
pause
exit
)
@astrohart
astrohart / server.c
Last active December 21, 2020 17:23
Echo server example for Linux in C
///////////////////////////////////////////////////////////////////////////////
// Echo server in C
// The server receives text a line at a time and echoes the text back to its
// client only AFTER an entire line has been received.
//
// AUTHOR: Brian Hart
// DATE: 20 Sep 2018
//
// Shout-out to <https://gist.githubusercontent.com/suyash/2488ff6996c98a8ee3a8
// 4fe3198a6f85/raw/ba06e891060b277867a6f9c7c2afa20da431ec91/server.c> and