Skip to content

Instantly share code, notes, and snippets.

View gravity00's full-sized avatar

João Simões gravity00

View GitHub Profile
@gravity00
gravity00 / NLog.config
Created May 29, 2016 22:06
Console Application using NLog as the logging framework
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="C:\Windows\Temp\ConsoleApplication\nlog-internal.log" >
<time type="FastUTC" />
<targets>
<target name="file" xsi:type="File"
public class GlobalExceptionFilter : IExceptionFilter
{
private readonly ILogger<ExampleExceptionFilter> _logger;
public ExampleExceptionFilter(ILogger<ExampleExceptionFilter> logger)
{
_logger = logger;
}
public void OnException(ExceptionContext context)
public class ExampleExceptionFilter : IExceptionFilter
{
private readonly ILogger<ExampleExceptionFilter> _logger;
public ExampleExceptionFilter(ILogger<ExampleExceptionFilter> logger)
{
_logger = logger;
}
public void OnException(ExceptionContext context)
@gravity00
gravity00 / SimpleSoft.Hosting.WithoutBuilder.Program.cs
Last active September 23, 2017 17:33
SimpleSoft.Hosting.WithoutBuilder
public static class Program
{
private static readonly CancellationTokenSource TokenSource;
static Program()
{
TokenSource = new CancellationTokenSource();
Console.CancelKeyPress += (sender, args) =>
{
TokenSource.Cancel();
@gravity00
gravity00 / SimpleSoft.Hosting.WithBuilder.Program.cs
Last active September 23, 2017 17:32
SimpleSoft.Hosting.WithBuilder
public static class Program
{
private static readonly CancellationTokenSource TokenSource;
static Program()
{
TokenSource = new CancellationTokenSource();
Console.CancelKeyPress += (sender, args) =>
{
TokenSource.Cancel();
@gravity00
gravity00 / SimpleSoft.Hosting.WithBuilderAndStartup.Program.cs
Created September 24, 2017 01:08
SimpleSoft.Hosting.WithBuilderAndStartup
public static class Program
{
private static readonly CancellationTokenSource TokenSource;
static Program()
{
TokenSource = new CancellationTokenSource();
Console.CancelKeyPress += (sender, args) =>
{
TokenSource.Cancel();
@gravity00
gravity00 / machine-setup-developer.ps1
Last active June 20, 2024 10:40
Clean developer machine setup using Chocolatey
$ErrorActionPreference = "Stop"
Set-ExecutionPolicy Bypass -Scope Process -Force;
## Install Chocolatey
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
## Install packages
# Web