Skip to content

Instantly share code, notes, and snippets.

@tombatron
tombatron / Enumerate.cs
Last active April 18, 2017 10:42
Python's `enumerate` in C# 7.
void Main()
{
var items = new []{ "first", "second", "third" };
foreach(var (item, index) in Enumerate(items))
{
Console.WriteLine($"{item} is index {index}.");
}
}
using Autofac;
using Autofac.Features.Variance;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Xunit;
using System;
namespace MediatR.Decorator.Example
@tombatron
tombatron / AutofacExtensions.cs
Last active May 19, 2017 18:22
Setup MediatR, with "decorator" support.
using Autofac;
using Autofac.Features.Variance;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Mediatr.Extras.Autofac
{
@tombatron
tombatron / GroupedDictionary.cs
Created July 15, 2017 13:36
GroupedDictionary
public class GroupedDictionary<TKey, TValue> : Dictionary<TKey, ICollection<TValue>>
{
private readonly Func<TValue, TKey> _groupingKeyExtractor;
public GroupedDictionary(IEnumerable<TValue> values, Expression<Func<TValue, TKey>> groupingKey)
{
_groupingKeyExtractor = groupingKey.Compile();
PopulateDictionary(values);
}
docker run -p 6379:6379 -v /Users/tombatron/docker/redis:/data -v /Users/tombatron/docker/redis/redis.conf:/usr/local/etc/redis/redis.conf --name redis redislabs/redismod /usr/local/etc/redis/redis.conf --dir /data
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
@tombatron
tombatron / MulticastExperiment.cs
Last active February 5, 2019 03:34
Just messing around with multicast sockets.
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Collections.ObjectModel;
using System.Threading;
namespace Prototype
{
public static class Program
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Linq;
using System.Text;
namespace HtmlRemover
{
# File generated at : 14:25:02, Fri 22 Nov
# Converted Project : V8.Net-Proxy-x64.vcxproj
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
add_definitions(-D_MSC_PLATFORM_TOOLSET=200)
# TODO: Make a variable for holding the path to the V8 source.
# installed clang and set it as the default compiler
# installed sudo apt-get install libc++-dev
@tombatron
tombatron / testing.cxx
Last active December 20, 2019 13:03
V8 Context Dispose Question
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include "include/libplatform/libplatform.h"
#include "include/v8.h"
#include "v8eval.h"