Skip to content

Instantly share code, notes, and snippets.

@danielwertheim
danielwertheim / AutoMoqDataAttribute.cs
Created February 13, 2022 10:55
Autofixture with AutoMoq
namespace Tests.UnitTests
{
using AutoFixture;
using AutoFixture.AutoMoq;
using AutoFixture.Xunit2;
using System;
public class InlineAutoMoqDataAttribute : InlineAutoDataAttribute
{
public InlineAutoMoqDataAttribute(params object[] objects)
@danielwertheim
danielwertheim / .bashrc
Last active October 24, 2021 12:15
Dev Settings
alias cls=clear
alias gohome='cd $USERPROFILE && clear'
alias godev='cd c:/foo && clear'
alias exp='explorer .'
alias gs='git status'
alias gss='git status -s'
alias gco='git commit -a -m $1'
alias gl='git log --oneline --graph --all --decorate'
alias gm='git merge --no-ff'
alias az='az.cmd'
@danielwertheim
danielwertheim / Program.cs
Created October 29, 2019 13:52
ConcurrentQueue vs Queueu + lock
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ConsoleApp2
{
public class Program
@danielwertheim
danielwertheim / SuperSimpleSample.cs
Last active October 18, 2016 19:59
NATSConsumer
class Program {
static void Main(string[] args)
{
const string subject = "test";
var cnInfo = new ConnectionInfo(new Host("demo.nats.io")) {
AutoRespondToPing = true
};
Action<MsgOp> handler = msg => {
Console.WriteLine("R:" + Encoding.UTF8.GetString(msg.Payload));
@danielwertheim
danielwertheim / NatsConsumerSample.cs
Last active October 16, 2016 14:49
Future sample usage of NatsConsumer
public Task Alternative1() {
var consumer = new NatsConsumer(client);
var subscription = await consumer.SubscribeAsync("mySubject", msg => {
//do something with the message
});
//time goes by
subscription.Dispose(); //issues client.Unsub(subject) against NATS broker as well as removes handler
@danielwertheim
danielwertheim / MediatR_And_Autofac.cs
Last active March 19, 2016 11:48
How not to bootstrap MediatR and Autofac, as it will never release inner dependencies... Pretty much follows this: https://github.com/jbogard/MediatR/blob/master/samples/MediatR.Examples.Autofac/Program.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Autofac;
using Autofac.Features.Variance;
using MediatR;
namespace ConsoleApplication2
{
class Program
@danielwertheim
danielwertheim / RoutemeisterAndAutofac.cs
Last active April 5, 2017 03:34
How to bootstrap Autofac and Routemeister to get per request lifetime scopes. Blog: http://danielwertheim.se/routemeister-and-autofac/
using System;
using System.Threading.Tasks;
using Autofac;
using Routemeister;
using Routemeister.Routers;
namespace ConsoleApplication2
{
class Program
{
@danielwertheim
danielwertheim / MessagePipe.cs
Created March 16, 2016 20:46
Some Owin inspired message pipeline
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
public class MessageEnvelope
{
public object Message { get; }
@danielwertheim
danielwertheim / git-basics.md
Last active November 25, 2015 14:15
Git basic stuff WITH A DISCLAIMER... USE AT OWN RISK :-)

Demo

This is a simple guide of getting started. Commands can have a multitude of switches and be combined to make the most amazingly magical things. But this is more focused on "manual basic" stuff.

Setup

Download from https://git-scm.com/

Ensure to select option to:

  • Use bash console and integrate in command prompt
  • For line endings (if on Windows), "Commit Unix line endings, Checkout Windows" (core.autorcrlf=true)
@danielwertheim
danielwertheim / Program.cs
Last active September 26, 2015 06:12
Some MongoDB and Proxies
using System;
using System.Collections.Concurrent;
using Castle.DynamicProxy;
using MongoDB.Bson;
namespace FunnyBunny
{
class Program
{
static void Main(string[] args)