Skip to content

Instantly share code, notes, and snippets.

View dennisroche's full-sized avatar
🐱

Dennis Roche dennisroche

🐱
View GitHub Profile
@dennisroche
dennisroche / LogHelper.cs
Last active March 11, 2018 06:20
xUnit2 and BDDfy logging with Serilog
internal static class LogHelper
{
private static readonly AsyncLocal<Guid> TestCorrelationId = new AsyncLocal<Guid>();
private static readonly ConcurrentDictionary<Guid, XUnitBddfyTextReporter> BddfyTextReporterLookup = new ConcurrentDictionary<Guid, XUnitBddfyTextReporter>();
private static readonly ConcurrentDictionary<Guid, ITestOutputHelper> LoggerLookup = new ConcurrentDictionary<Guid, ITestOutputHelper>();
private static readonly ConcurrentDictionary<Guid, ILogger> SerilogLookup = new ConcurrentDictionary<Guid, ILogger>();
public static IDisposable Capture(ITestOutputHelper outputHelper)
{
if (outputHelper == null)
@dennisroche
dennisroche / DropSchema.sql
Created February 2, 2018 16:43
Drop entire SQL Server schema
DECLARE @schema VARCHAR(128)
SET @schema = 'dbo' --< change this
/* Drop all Foreign Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA=@schema AND CONSTRAINT_CATALOG=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)
@dennisroche
dennisroche / NodaClock.cs
Last active December 9, 2017 14:11
NodaTime Static Clock
public static class NodaClock
{
private static readonly AsyncLocal<IClock> ClockThreadSafe;
public static void ChangeClock(IClock clock)
{
ClockThreadSafe.Value = clock;
}
static ApiClock()
@dennisroche
dennisroche / externallinks.js
Last active November 15, 2017 14:18
Modify external links to open in a new window
@dennisroche
dennisroche / emoji.css
Last active November 15, 2017 03:38
Emoji
span.emoji
{
display: -moz-inline-box;
display: inline-block;
width: 1em;
height: 1em;
vertical-align: baseline;
text-indent: -9999px;
@dennisroche
dennisroche / kbd.css
Last active October 28, 2017 07:40
Style <kbd> tags
kbd
{
font-size: 15px;
line-height: 1.4;
display: inline-block;
margin: 0 .1em;
padding: .1em .6em;
@dennisroche
dennisroche / README.md
Last active October 25, 2017 13:31
Expand posh-git alias

Add PowerShell alias to your profile.

function Get-Git { & git $args }
New-Alias g Get-Git -Force -Option AllScope

This will alias g to git, however you forgo the tab expansion.

posh-git shell is replacing default TabExpansion function with own implementation.

@dennisroche
dennisroche / Install-Seq.ps1
Last active February 23, 2017 19:30
Download and install Seq (https://getseq.net/). Can be used by Azure Resource Manager template. Use RawGit to access the file with proper Content-Type headers - https://rawgit.com/
[CmdletBinding()]
param (
[string]$SeqVersion,
[string]$SeqInstanceName,
[string]$SeqPort
)
$installBasePath = "C:\Install\"
$seqDataPath = "C:\ProgramData\Seq"
<#
.SYNOPSIS
This Azure Automation runbook automates the scheduled shutdown and startup of virtual machines in an Azure subscription.
.DESCRIPTION
The runbook implements a solution for scheduled power management of Azure virtual machines in combination with tags
on virtual machines or resource groups which define a shutdown schedule. Each time it runs, the runbook looks for all
virtual machines or resource groups with a tag named "AutoShutdownSchedule" having a value defining the schedule,
e.g. "10PM -> 6AM". It then checks the current time against each schedule entry, ensuring that VMs with tags or in tagged groups
are shut down or started to conform to the defined schedule.
@dennisroche
dennisroche / Remove-GitMergedBranches.ps1
Created September 23, 2016 06:04
A posh-git script that identifies local branches that have been merged to `master`.
function Remove-GitMergedBranches {
Write-Output "Fetching latest"
git fetch origin --prune
$currentBranch = & git rev-parse --abbrev-ref HEAD
if ($currentBranch -ne "master") {
Write-Output "Changing branch to master"
git checkout master
}