Skip to content

Instantly share code, notes, and snippets.

@naile
naile / ApplicationInsightsFilter.cs
Created August 24, 2017 12:32
Application Insights Telemetry ignore statuscodes for specific operations
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using System.Linq;
namespace AppInsightsFilter
{
public class ApplicationInsightsFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
@naile
naile / ConfigureIoThreads.cs
Last active March 19, 2018 12:39
set dotnet IOCP/worker threads for Redis
public static class ConfigureIoThreads
{
private static int IOCPThreadsMin = Environment.ProcessorCount * 4;
private static int WorkerThreadsMin = Environment.ProcessorCount * 2;
//https://gist.github.com/JonCole/e65411214030f0d823cb#file-threadpool-md
public static void ForRedis(ILogger logger)
{
// get the current settings.
ThreadPool.GetMinThreads(out int currentMinWorker, out int currentMinIOC);
@naile
naile / search.js
Created February 3, 2019 20:55
search.js
//vanilla js version of https://gist.github.com/sebz/efddfc8fdcb6b480f567
var lunrIndex,
$results,
pagesIndex;
// Initialize lunrjs using our generated index file
function initLunr() {
var request = new XMLHttpRequest();
request.open('GET', 'js/lunr/index.json', true);

Keybase proof

I hereby claim:

  • I am naile on github.
  • I am naile (https://keybase.io/naile) on keybase.
  • I have a public key whose fingerprint is E7E5 540F B32C 9FA2 5C3E 1FCF 61C2 A08D 3F50 3619

To claim this, I am signing this object:

@naile
naile / RedisBloomExtensions.cs
Last active January 21, 2022 05:05
Extension methods for using RedisBloom module with StackExchange.Redis
public static class RedisBloomExtensions
{
public static async Task BloomReserveAsync(this IDatabaseAsync db, RedisKey key, double errorRate, int initialCapacity)
=> await db.ExecuteAsync("BF.RESERVE", key, errorRate, initialCapacity);
public static async Task<bool> BloomAddAsync(this IDatabaseAsync db, RedisKey key, RedisValue value)
=> (bool)await db.ExecuteAsync("BF.ADD", key, value);
public static async Task<bool[]> BloomAddAsync(this IDatabaseAsync db, RedisKey key, IEnumerable<RedisValue> values)
=> (bool[])await db.ExecuteAsync("BF.MADD", values.Cast<object>().Prepend(key).ToArray());