Skip to content

Instantly share code, notes, and snippets.

Avatar

Dennis Roche dennisroche

View GitHub Profile
View Paradox.psm1
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@dennisroche
dennisroche / PromoteAll.ps1
Created Apr 5, 2018
Octopus Deploy script to shift a range of projects to the right (dev to staging) as a set
View PromoteAll.ps1
$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"
}
View ValidateAzureTemplate.ps1
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 Apr 5, 2018
PostDeploy script for Octopus that executes SQL
View PostDeploySql.ps1
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 Apr 5, 2018
Loading a Certificate to Azure (useful for IdentityServer)
View LoadAzureCertificate.ps1
$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 Mar 11, 2020
Pretty log header using ASCII
View README.md
  ╔═══════════════════════════════════════════════════════════════════════════════╗
  ║                                    Example                                    ║
  ╚═══════════════════════════════════════════════════════════════════════════════╝

Useful for breaking up large log files

@dennisroche
dennisroche / LogHelper.cs
Last active Mar 11, 2018
xUnit2 and BDDfy logging with Serilog
View LogHelper.cs
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 Feb 2, 2018
Drop entire SQL Server schema
View DropSchema.sql
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 Nov 15, 2017
Modify external links to open in a new window
View externallinks.js
View emoji.css
span.emoji
{
display: -moz-inline-box;
display: inline-block;
width: 1em;
height: 1em;
vertical-align: baseline;
text-indent: -9999px;
You can’t perform that action at this time.