Skip to content

Instantly share code, notes, and snippets.

@sverrehundeide
sverrehundeide / evenlog-entry.xml
Last active August 23, 2018 07:03
Blog - Hosting ASP .Net Core websites in IIS using AspNetCoreModule
<Event
xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>3</Level>
<Opcode>16</Opcode>
<Keywords>0x100</Keywords>
<TimeCreated SystemTime="2018-01-11T11:34:06.803Z"/>
@sverrehundeide
sverrehundeide / Octopus-Update-Certificates.ps1
Created December 30, 2017 17:41
Updating multiple site bindings in IIS with new SSL-certificate
# Example of usage:
# Update-Certificates -domainNameMatchPattern "mycompany.com" -variableNameForCertificateToUse "CurrentMyCompanyDotComCertificate"
function Write-Info ($message) {
Write-Host "Info:" $message
}
function AssignCertificate([string] $friendlyName, [string] $hostName, [int] $port) {
$matchingCertificates = (Get-ChildItem cert:\localmachine\my) | Where-Object {$_.FriendlyName -eq $friendlyName}
$matchCount = ($matchingCertificates | Measure-Object).Count
@sverrehundeide
sverrehundeide / with-aaa.cs
Created April 18, 2017 17:18
Blog - Arrange, Act and Assert syntax for testing
[TestMethod]
public void GetCustomerById()
{
// Arrange
const int CustomerId = 5;
var repository = new CustomerRepository();
// Act
Customer customer = repository.GetCustomerById(CustomerId);
@sverrehundeide
sverrehundeide / method-template.cs
Last active October 17, 2017 20:08
Blog - A simple and compact style for BDD specifications
public void $Method$_Given$Context$_Should$ExpectedBehaviour$()
@sverrehundeide
sverrehundeide / ccnet-config.xml
Created April 16, 2017 16:58
Blog - Intellisense for CruiseControl.Net configuration files
<cruisecontrol xmlns="http://thoughtworks.org/ccnet/1/5">
<project name="foo">
<webURL>http://localhost/ccnet</webURL>
<modificationDelaySeconds>10</modificationDelaySeconds>
@sverrehundeide
sverrehundeide / ccnet-config.xml
Last active October 17, 2017 20:05
Blog - Using Gendarme with CruiseControl.Net for code analysis
</msbuild>
2: <exec>
3: <executable>powershell</executable>
4: <buildArgs>-Command "Get-ChildItem -Path 'D:\SomeDir\Work' -Recurse -Include MyCompany*.dll -Exclude *.Test*.dll,*Generated.dll | sort -Property Name -Unique | sort -Property FullName | foreach {$_.FullName} | Out-File -FilePath 'D:\SomeDir\Artifact\AssembliesForCodeAnalysis.txt' -Width 255"</buildArgs>
5: </exec>
6: <gendarme>
7: <executable>C:\Program Files (x86)\Gendarme\gendarme.exe</executable>
8: <assemblyListFile>D:\SomeDir\Artifact\AssembliesForCodeAnalysis.txt</assemblyListFile>
9: <baseDirectory>D:\SomeDir\Work</baseDirectory>
10: <limit>2000</limit>
@sverrehundeide
sverrehundeide / winrm-set-memorypershell.ps1
Created April 16, 2017 16:35
Blog - First experiences with using WinRM/WinRS for remote deployment
WinRM set winrm/config/Winrs @{MaxMemoryPerShellMB = “1000”}
@sverrehundeide
sverrehundeide / nservicebusconfigurator.cs
Last active October 17, 2017 20:04
Blog - NServiceBus fails to connect to RavenDB during high load
public class NServiceBusConfigurator : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
public void Init()
{
Configure.Instance.CustomiseRavenPersistence(ConfigureRavenStore);
}
private static void ConfigureRavenStore(Raven.Client.IDocumentStore store)
{
store.JsonRequestFactory.ConfigureRequest += (sender, args) =>
@sverrehundeide
sverrehundeide / globalerrorhandler.cs
Created April 11, 2017 19:46
Blog - Logging errors in NServiceBus
public class GlobalErrorHandler : IWantToRunWhenBusStartsAndStops
{
private readonly ILogger _logger;
private readonly BusNotifications _busNotifications;
readonly List<IDisposable> _notificationSubscriptions = new List<IDisposable>();
public GlobalErrorHandler(ILogger logger, BusNotifications busNotifications)
{
_logger = logger;
_busNotifications = busNotifications;
@sverrehundeide
sverrehundeide / modelconfig-isconcurrencytoken.cs
Last active October 17, 2017 20:03
Blog - Optimistic concurrency with MySQL and Entity Framework
Property(x => x.Version).IsRequired()
.IsConcurrencyToken()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);