It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Text.Json; | |
using Serilog.Core; | |
using Serilog.Events; | |
class JsonDocumentDestructuringPolicy : IDestructuringPolicy | |
{ | |
public bool TryDestructure(object value, ILogEventPropertyValueFactory _, out LogEventPropertyValue result) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.Remoting.Messaging; | |
using System.Threading.Tasks; | |
using MassTransit; | |
using MassTransit.Configurators; | |
using MassTransit.PipeBuilders; | |
using MassTransit.PipeConfigurators; | |
using MassTransit.Pipeline; |
Many people use Redis for a simple message broker. RedisMQ is a trivial layer on Redis and StackExchange.Redis that probably does not work. It provides two simple messaging patterns:
A publisher publishes messages. 0, 1 or more consumers subscribe to the messages.
This is a small tool that allows transforms logs written with pino
in newline-delimited JSON on the standard output to the Compact Log Event Format (CLEF
) supported by the Seq logging server.
Typical use case for this is :
- write your logs with pino how you would normally do it
logger.info({some: 'extra', context:'info'}, 'this is the message');
- optionally use the
Message Template
syntax (https://messagetemplates.org/) for more user-friendly logs
logger.info({user: 'John', amount:'2345', extra: 'other info'}, '{user} just spent {amount} euros on the website');
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void RequestStartup(ILifetimeScope requestContainer, IPipelines pipelines, NancyContext context) | |
{ | |
pipelines.OnError.AddItemToEndOfPipeline((z, a) => | |
{ | |
log.Error("Unhandled error on request: " + context.Request.Url + " : " + a.Message, a); | |
return ErrorResponse.FromException(a); | |
}); | |
base.RequestStartup(requestContainer, pipelines, context); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$edition, | |
[switch]$noWeb = $false | |
) | |
# Try and find a version of Visual Studio in the expected location, since the VS150COMNTOOLS environment variable isn't there any more | |
$basePath = join-path (join-path ${env:ProgramFiles(x86)} "Microsoft Visual Studio") "2017" | |
if ((test-path $basePath) -eq $false) { | |
write-warning "Visual Studio 2017 is not installed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[string]$SeqVersion, | |
[string]$SeqInstanceName, | |
[string]$SeqPort | |
) | |
$installBasePath = "C:\Install\" | |
$seqDataPath = "C:\ProgramData\Seq" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.config ($httpProvider) -> | |
$httpProvider.interceptors.push ($q, $rootScope, apiUrl, authToken) -> | |
request: (config) -> | |
# Intercept API requests and inject the auth token. | |
config.headers["X-Auth-Token"] = authToken if config.url.indexOf(apiUrl) is 0 and authToken? | |
config or $q.when config | |
responseError: (response) -> | |
# Intercept unauthorised API responses and fire an event. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static IObservable<string> CheckForFraud(IObservable<string> logins) | |
{ | |
return from g in logins.GroupByUntil(l => l, CheckForFraud) | |
from c in g.Count() | |
where c >= 3 | |
select g.Key; | |
} | |
static IObservable<Unit> CheckForFraud(IGroupedObservable<string, string> g) | |
{ |
NewerOlder