Skip to content

Instantly share code, notes, and snippets.

@nblumhardt
nblumhardt / NoResourceTrackingInAutofac.cs
Created January 7, 2011 23:28
Disable disposable resource tracking for a service in Autofac
var builder = new ContainerBuilder();
// The thing we want to create haphazardly without ever
// disposing it or any of its dependencies:
builder.RegisterType<Foo>()
.Named<IFoo>("untracked");
// Owned<T> is itself untracked (i.e. disposal is up to the
// owner.) Since we just let the Owned<IFoo> slip away, it
var module = angular.module('octopusApp.projects');
module.controller('ProjectReleaseController', function ($scope, busy, $routeParams, pageTitle, octopusRepository, $q) {
var isLoading = $scope.isLoading = busy.create();
var projectId = $routeParams["id"];
var releaseVersion = $routeParams["version"];
var project, release, deploymentProcess;
isLoading.promise(octopusRepository.Projects.get(projectId).then(function (project2) {
project = project2;
@nblumhardt
nblumhardt / SampleReactor.cs
Created December 14, 2013 03:47
Just a simple example to show how plugins ("apps") consume data from the stream
using Seq.Apps;
using Seq.Apps.LogEvents;
namespace Seq.BuiltIn.SampleApp
{
public class SampleReactor : Reactor, ISubscribeTo<LogEventData>
{
public void On(Event<LogEventData> evt)
{
if (evt.Data.Level == LogEventLevel.Error)
using Seq.Apps;
using Seq.Apps.LogEvents;
using System;
using System.Linq;
namespace Seq.Sample.SlidingWindows
{
/// <summary>
/// Counts events in a sliding time window, writing a message back to the
/// stream when a set threshold is reached.
@nblumhardt
nblumhardt / gist:8914175
Created February 10, 2014 11:17
An alternative to stack walking to add caller names to Serilog events
public static class LoggerExtensions
{
public static ILogger ForHere(
this ILogger logger,
[CallerFilePath] string sourceFile = null,
[CallerLineNumber] int sourceLine = 0)
{
return logger
.ForContext("SourceFile", sourceFile)
.ForContext("SourceLine", sourceLine);
## --------------------------------------------------------------------------------------
## Configuration
## --------------------------------------------------------------------------------------
$ConfirmPreference = "None"
$isEnabled = $OctopusParameters["Octopus.Action.IISWebSite.CreateOrUpdateWebSite"]
if (!$isEnabled -or ![Bool]::Parse($isEnabled))
{
exit 0
@nblumhardt
nblumhardt / gist:07c8046ffdcbd3d6b1fa
Created May 18, 2014 11:08
Seq configuration via AppSettings

1. Install Serilog.Extras.AppSettings

PM> Install-Package Serilog.Extras.AppSettings

2. Add the 'read' method to logger config

... = new LoggerConfiguration()
@nblumhardt
nblumhardt / Program.cs
Created June 25, 2014 21:52
Exception data enricher for Serilog
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting.Json;
@nblumhardt
nblumhardt / Example.ps1
Last active November 8, 2019 11:03
Seq from Powershell POC
Import-Module Seq
# Specify the Seq server URL; an -apiKey can also be provided.
# Any properties set here will be attached to all events.
$seq = Open-Seq "http://my-seq" -properties @{ Machine = $env:ComputerName }
# Simple information method
Send-SeqEvent $seq "Hello from PowerShell"
@nblumhardt
nblumhardt / Body.tmpl
Created July 31, 2014 04:43
Showing step summary in a deployment email with Octopus Deploy
<h3>Task summary:</h3>
<ol>
#{each step in Octopus.Step}
<li>#{step.Name | HtmlEscape} &mdash; <strong>#{step.Status.Code}</strong> #{step.Status.Error | HtmlEscape}
#{if step.Status.ErrorDetail}
<pre>#{step.Status.ErrorDetail | HtmlEscape}</pre>
#{/if}
</li>
#{/each}
</ol>