Skip to content

Instantly share code, notes, and snippets.

View hd9's full-sized avatar

Bruno Hildenbrand hd9

View GitHub Profile
@hd9
hd9 / latency.txt
Created June 30, 2020 20:05 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@hd9
hd9 / aspnet-ai-telemetry-suppress-init-dotnetcore.cs
Last active February 19, 2020 16:14
Suppressing Application Insights telemetry on an ASP.NET Core web applications
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/suppressing-application-insights.html
// **********************************************
// To register your custom telemetry processor, update the
// ConfigureServices on your Startup.cs class adding your custom
/// telemetry processor. Ex: SuppressFaviconFilter
public void ConfigureServices(IServiceCollection services)
{
@hd9
hd9 / aspnet-ai-telemetry-suppress-init.cs
Last active February 19, 2020 15:49
Suppressing Application Insights telemetry on an ASP.NET web applications
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/suppressing-application-insights.html
// **********************************************
// add this on your Global.asax
var builder = TelemetryConfiguration.Active.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
builder.Use((next) => new SuppressFaviconFilter(next));
builder.Build();
@hd9
hd9 / aspnet-ai-telemetry-suppress-request.cs
Last active February 19, 2020 17:26
Suppressing Application Insights telemetry on an ASP.NET Core web applications
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/suppressing-application-insights.html
// **********************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.ApplicationInsights.Channel;
@hd9
hd9 / aspnet-ai-telemetry-trackException.cs
Last active February 18, 2020 22:02
Handling exceptions on ASP.NET Core web posting to Application Insights
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/03/adding-application-insights-telemetry.html
// **********************************************
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
// IExceptionHandlerPathFeature requires Microsoft.AspNetCore.Diagnostics
// run: dotnet add package Microsoft.AspNetCore.Diagnostics --version 2.2.0
var error = HttpContext.Features.Get<IExceptionHandlerFeature>();
@hd9
hd9 / aspnet-ai-telemetry-trackEvent.cs
Last active February 18, 2020 22:02
Posting a custom event from an ASP.NET Core web application to Application Insights
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/03/adding-application-insights-telemetry.html
// **********************************************
public IActionResult Privacy()
{
_telemetry.TrackEvent($"Privacy requested @ {DateTime.UtcNow} UTC");
return View();
}
@hd9
hd9 / aspnet-ai-telemetry-init.cs
Last active February 18, 2020 22:02
Initializing Application Insights telemetry on an ASP.NET Core web application
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/03/adding-application-insights-telemetry.html
// **********************************************
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly TelemetryClient _telemetry;
@hd9
hd9 / MassTransit-SimpleService-Client.cs
Created February 10, 2020 21:58
MassTransit - Example os simple client service
// **********************************************
// Fore more information, visit:
// Blog: https://blog.hildenco.com/2018/08/masstransit-real-alternative-to.html
// Source: https://github.com/MassTransit/Sample-Direct
// **********************************************
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Contracts;
using MassTransit;
@hd9
hd9 / MassTransit-SimpleService-Server.cs
Last active February 10, 2020 22:08
MassTransit - Example os simple server
// **********************************************
// Fore more information, visit:
// Blog: https://blog.hildenco.com/2018/08/masstransit-real-alternative-to.html
// Source: https://github.com/MassTransit/Sample-Direct
// **********************************************
using System;
using System.Threading.Tasks;
using Contracts;
using MassTransit;
@hd9
hd9 / MassTransit-SimpleService.cs
Created February 7, 2020 20:27
MassTransit - Console Hosted Service initialization
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2018/08/masstransit-real-alternative-to.html
// **********************************************
using System.Threading;
using System.Threading.Tasks;
using MassTransit;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;