Skip to content

Instantly share code, notes, and snippets.

Bruno Hildenbrand hd9

View GitHub Profile
@hd9
hd9 / latency.txt
Created Jun 30, 2020 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
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 Feb 19, 2020
Suppressing Application Insights telemetry on an ASP.NET Core web applications
View aspnet-ai-telemetry-suppress-init-dotnetcore.cs
// **********************************************
// 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 Feb 19, 2020
Suppressing Application Insights telemetry on an ASP.NET web applications
View aspnet-ai-telemetry-suppress-init.cs
// **********************************************
// 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 Feb 19, 2020
Suppressing Application Insights telemetry on an ASP.NET Core web applications
View aspnet-ai-telemetry-suppress-request.cs
// **********************************************
// 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 Feb 18, 2020
Handling exceptions on ASP.NET Core web posting to Application Insights
View aspnet-ai-telemetry-trackException.cs
// **********************************************
// 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 Feb 18, 2020
Posting a custom event from an ASP.NET Core web application to Application Insights
View aspnet-ai-telemetry-trackEvent.cs
// **********************************************
// 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 Feb 18, 2020
Initializing Application Insights telemetry on an ASP.NET Core web application
View aspnet-ai-telemetry-init.cs
// **********************************************
// 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 Feb 10, 2020
MassTransit - Example os simple client service
View MassTransit-SimpleService-Client.cs
// **********************************************
// 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 Feb 10, 2020
MassTransit - Example os simple server
View MassTransit-SimpleService-Server.cs
// **********************************************
// 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 Feb 7, 2020
MassTransit - Console Hosted Service initialization
View MassTransit-SimpleService.cs
// **********************************************
// 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;
You can’t perform that action at this time.