Skip to content

Instantly share code, notes, and snippets.

View daniefer's full-sized avatar
:octocat:
Working from home

Daniel Ferguson daniefer

:octocat:
Working from home
  • Austin, TX
View GitHub Profile
@daniefer
daniefer / GetSqlConnectionPoolCountByConnectionString.csx
Created August 25, 2020 14:49
Get SqlConnectionPool Count by Connection String
static Lazy<(IDictionary, Func<object, string>, Func<object, ICollection>)> ReflectionShit = new Lazy<(IDictionary, Func<object, string>, Func<object, ICollection>)>(() =>
{
var SqlConnectionFactoryType = typeof(System.Data.SqlClient.SqlConnection).Assembly.GetType("System.Data.SqlClient.SqlConnectionFactory");
var SqlConnectionFactoryInstanceField = SqlConnectionFactoryType.GetRuntimeField("SingletonInstance");
var instance = SqlConnectionFactoryInstanceField.GetValue(null);
var DbConnectionFactoryType = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType("System.Data.ProviderBase.DbConnectionFactory")).FirstOrDefault(x => x != null);
var DbConnectionPoolGroupType = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType("System.Data.ProviderBase.DbConnectionPoolGroup")).FirstOrDefault(x => x != null);
var DbConnectionPoolKeyType = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType("System.Data.Common.DbConnectionPoolKey")).FirstOrDefault(x => x != null);
var connecti
@daniefer
daniefer / TempateAsserts.csx
Created August 11, 2020 22:42
Generate Assert statements based on Type
private void Template<T>(T _ = default)
{
typeof(T).GetProperties().ToList().ForEach(p =>
{
switch (true)
{
case true when (typeof(decimal).IsAssignableFrom(p.PropertyType)):
_testOutputHelper.WriteLine($"Assert.Equal(0m, result.{p.Name});");
break;
case true when (typeof(int).IsAssignableFrom(p.PropertyType)):
@daniefer
daniefer / azure-pipelines.yml
Created December 21, 2018 02:08
Standard azure DevOps pipeline configuration file for .NET Core
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
pool:
vmImage: 'Ubuntu 16.04'
variables:
buildConfiguration: 'Release'
@daniefer
daniefer / service-watcher.path
Created December 21, 2018 01:48
Setup Amazon Lightsail with .NET Core 2.2, Sql Server, Nginx, Letsencrypt, and automatic restart on file change
[Path]
PathModified=/var/www/<your service publish directory here>
[Install]
WantedBy=multi-user.target

Keybase proof

I hereby claim:

  • I am daniefer on github.
  • I am daniefer (https://keybase.io/daniefer) on keybase.
  • I have a public key ASA1L3JYbSShLgj2LJNSHhhKZMRS_HVi0dtvXrNSZkwi2go

To claim this, I am signing this object:

msiexec /a PathToMSIFile /qb TARGETDIR=DirectoryToExtractTo
@daniefer
daniefer / find commits that contain filename
Created December 6, 2016 21:33
find commits that contain the passed in file name or file path
hg log -r 0:tip --template "{files % '{rev} - {file}\n'}" | find "$1"
@daniefer
daniefer / .hgrc
Created December 1, 2016 22:58
Explore Mercurial User Activity
[alias]
# Shows all users and the number of commits user has made since the creation of the branch you provide; ordered ascending.
# $1 = All ancestors of the first commit of the branch you specify
active-users = !hg log -r "min(branch('$1')):" --template "{author}\r\n" | sort | uniq -c | sort -n
# Shows all files that this use has touched since the creation of the branch you provide; ordered ascending.
# $1 = All ancestors of the first commit of the branch you specify
# $2 = User you want to filter on
# $3 = Extra filter options for hg log
active-files = !hg log -r "min(branch('$1')):" -u '$2' $3 --template "{files % '{file}\n'}" | sort | uniq -c | sort -n