Skip to content

Instantly share code, notes, and snippets.

View dennisroche's full-sized avatar
🐱

Dennis Roche dennisroche

🐱
View GitHub Profile
@dennisroche
dennisroche / cfn-http2-target-group.py
Last active February 12, 2021 01:53
CloudFormation custom resource to create HTTP2 Target Group
'''
Uses crhelper https://github.com/aws-cloudformation/custom-resource-helper
Requires
- 'elasticloadbalancing:*'
- 'ec2:DescribeInternetGateways'
- 'ec2:DescribeVpcs'
'''
from crhelper import CfnResource
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@dennisroche
dennisroche / PromoteAll.ps1
Created April 5, 2018 05:01
Octopus Deploy script to shift a range of projects to the right (dev to staging) as a set
$octo = Get-OctopusTools
Write-Heading 'Projects'
function GetProjectsInGroup([string]$projectGroupName, [string]$ignoreProjectNames) {
$projectGroup = Invoke-OctopusApi '/api/projectgroups/all' | Where-Object { $_.Name -eq $projectGroupName }
if ($null -eq $projectGroup) {
Write-Fatal "Project $projectGroupName not found"
}
@dennisroche
dennisroche / ValidateAzureTemplate.ps1
Created April 5, 2018 04:59
Validate Azure ARM template
function Format-ValidationOutput {
Param (
[Parameter(ValueFromPipeline=$true)] $ValidationOutput,
[int] $Depth = 0
)
return @($ValidationOutput | Where-Object { $_ -ne $null } | ForEach-Object { @(' ' * $Depth + ': ' + $_.Message) + @(Format-ValidationOutput @($_.Details) ($Depth + 1)) })
}
# Template
@dennisroche
dennisroche / PostDeploySql.ps1
Created April 5, 2018 04:58
PostDeploy script for Octopus that executes SQL
trap {
Write-Error "$_"
Exit 1
}
# Injected by Octopus Deploy Step Template
$connectionString = $DeploySqlConnectionString
$filter = $Filter
Write-Host "Executing scripts in folder '$($PSScriptRoot)'"
@dennisroche
dennisroche / LoadAzureCertificate.ps1
Created April 5, 2018 04:56
Loading a Certificate to Azure (useful for IdentityServer)
$pfx = $OctopusParameters["PrimarySigningCertificate.Pfx"]
$thumbprint = $OctopusParameters["PrimarySigningCertificate.Thumbprint"]
$appName = "auth-api-$AzureEnvironment"
function Set-AzureRmCertificate($ResourceGroupName, $Location, $Pfx, $Thumbprint) {
$ResourceLocation = $Location
$ResourceName = $Thumbprint
$PropertiesObject = @{
pfxBlob = $Pfx;
password = ""
@dennisroche
dennisroche / README.md
Last active October 21, 2022 04:17
Pretty log header using ASCII
  ╔═══════════════════════════════════════════════════════════════════════════════╗
  ║                                    Example                                    ║
  ╚═══════════════════════════════════════════════════════════════════════════════╝

Useful for breaking up large log files

@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 / externallinks.js
Last active November 15, 2017 14:18
Modify external links to open in a new window