Skip to content

Instantly share code, notes, and snippets.

View micdenny's full-sized avatar

Michael Denny micdenny

View GitHub Profile
@micdenny
micdenny / EasyNetQ-Template.cs
Last active April 3, 2018 14:48
EasyNetQ LINQPad Template
void Main()
{
var stopHandle = new ManualResetEventSlim();
var consumer = new Thread(() =>
{
var bus = RabbitHutch.CreateBus("host=localhost", x => x.Register<IEasyNetQLogger>(s => new EasyNetQ.Loggers.ConsoleLogger()));
bus.RespondAsync<MyRequest, MyResponse>(async request =>
{
@micdenny
micdenny / redis-ha-manual-failover.md
Last active May 28, 2018 13:31
Redis - High Availability - Manual Failover

Waiting until the support for slave-read-only on StackExchange.Redis, I would like to share my solution to fail-over a node with a minimum write interruption, maintaining data consistency, reducing (eliminating?) possible false write acknowledgment (on the node that is failing). You can lose some write because there's a window where both nodes are slaves. I feel that you can still have some false write ack because you can receive an ack while setting the master as slave and that write could be lost.

redis-slaveof-kvs01.txt

MULTI
SLAVEOF kvs01 6379
CONFIG REWRITE
PUBLISH "__Booksleeve_MasterChanged" "*"
EXEC
@micdenny
micdenny / Program.cs
Created May 9, 2016 10:57
EasyNetQ Avoid Static Factory
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using EasyNetQ;
using EasyNetQ.ConnectionString;
using EasyNetQ.Consumer;
using EasyNetQ.Interception;
using EasyNetQ.Loggers;
using EasyNetQ.Producer;
@micdenny
micdenny / App\Program.cs
Last active December 1, 2016 10:22
EFCore.PsToolsIssue7146
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EFCore.PsToolsIssue7146.App
{
public class Program
{
public static void Main()
@micdenny
micdenny / TrackEventOperation.cs
Created December 21, 2016 15:02
Application insights extension to track an event and record the duration of it as a metric associated to the Event
public static class TelemetryClientExtensions
{
public static IOperationHolder<TrackEventOperation> StartEventOperation(this TelemetryClient client, string eventName)
{
return new TrackEventOperationHolder(eventName, client);
}
}
public class TrackEventOperationHolder : IOperationHolder<TrackEventOperation>
{
@micdenny
micdenny / ChannelPoolingClientCommandDispatcher.cs
Last active February 14, 2017 13:12
ChannelPoolingClientCommandDispatcher
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using EasyNetQ;
using EasyNetQ.Producer;
using RabbitMQ.Client;
namespace EasyNetQSlowerThanRabbitMQ
{
@micdenny
micdenny / star-wars.ino
Last active May 5, 2017 21:00 — forked from eznj/star_wars.ino
Arduino Star Wars Song for Piezo
const int c = 261;
const int d = 294;
const int e = 329;
const int f = 349;
const int g = 391;
const int gS = 415;
const int a = 440;
const int aS = 455;
const int b = 466;
@micdenny
micdenny / super-mario.ino
Created May 5, 2017 20:57
Super Mario theme song w/ piezo buzzer and Arduino!
/*
Arduino Mario Bros Tunes
With Piezo Buzzer and PWM
Connect the positive side of the Buzzer to pin 3,
then the negative side to a 1k ohm resistor. Connect
the other side of the 1 k ohm resistor to
ground(GND) pin on the Arduino.
by: Dipto Pratyaksa
@micdenny
micdenny / Program.cs
Last active January 5, 2018 16:15
BinaryData: how to manage an optional property using ReadObject
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Syroot.BinaryData;
using Syroot.BinaryData.Extensions;
namespace ConsoleApp1
@micdenny
micdenny / iframe-tracker.component.html
Last active March 25, 2024 20:20
How to detect a click event on a cross domain iframe (iframe.tracker)
<div>
<iframe appIframeTracker (iframeClick)="onIframeClick()" src="http://www.google.com"></iframe>
</div>