Skip to content

Instantly share code, notes, and snippets.

@LeeCampbell
LeeCampbell / IRunnable.cs
Last active July 29, 2016 01:24
SerialDisposable Perf Tests
namespace RxPerformanceTest.SerialDisposable.Console
{
interface IRunnable
{
ThroughputTestResult[] Run();
}
}
@LeeCampbell
LeeCampbell / LeftFold.cs
Created May 11, 2016 08:35
An example of a LeftFold helper for Cedar EventStore lib.
using System;
using System.Collections.Generic;
using System.Globalization;
using Cedar.EventStore.Streams;
namespace DunkyMoleFanClub
{
public static class LeftFold
{
public static readonly string DefaultKey = string.Empty;
@LeeCampbell
LeeCampbell / MyLib.Messaging.cs
Created December 12, 2012 16:29
Thoughts on a simple Messaging API
using System;
namespace MyLib.Messaging
{
public interface IConsumer<out T>
{
///<summary>Allows non-destructive read access to the next message on the queue</summary>
T Peek();
///<summary>Transactional consumer. Requires a transaction scope to be accessed.</summary>
@LeeCampbell
LeeCampbell / ScrollViewerCorrector.cs
Created October 26, 2012 15:03
Corrects the ScrollViewer behavior that does not allow parent to scroll once child has exhausted scrolling.
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MyLib
{
//http://serialseb.blogspot.co.uk/2007/09/wpf-tips-6-preventing-scrollviewer-from.html
@LeeCampbell
LeeCampbell / csharp.xslt
Created October 9, 2012 13:39
Protobuf-Net xslt file to produce Nullable Properties
<!--
In conjunction with the patch for issue 72
https://code.google.com/p/protobuf-net/issues/detail?id=72
This file can make the current implementation of the Protobuf-net tools useful. Without these however protobuf-net is full of surprises like:
* Requiring you to specify if it should detect missing values (why is this not always on?)
* Not being able to identify between not specified (null in every other computer system) and the default value
* Not being able to compile if an Enum is optional but does not specify a default value?!
* Happily serializing invalid messages i.e. where required values are missing
@LeeCampbell
LeeCampbell / MyPermissionRepo.cs
Created October 5, 2012 14:42
Asynchronous cache of values
void Main()
{
var repo = new MyPermissionRepo();
//These will all get batched up and sent together
repo.IsPermissioned("Marcus").Dump("Marcus");
repo.IsPermissioned("Lee").Dump("Lee");
repo.IsPermissioned("Merc").Dump("Merc");
repo.IsPermissioned("Si").Dump("Si");
@LeeCampbell
LeeCampbell / ObservableAPMExtensions.cs
Created February 13, 2012 16:33
Extension methods to help with converting APM pattern to Observable.
public static class ObservableAPMExtensions
{
public static IObservable<byte> ToObservable(this FileStream source)
{
return source.ToObservable(4096, Scheduler.CurrentThread);
}
public static IObservable<byte> ToObservable(this FileStream source, int buffersize, IScheduler scheduler)
{
@LeeCampbell
LeeCampbell / StubRegionManager
Created September 7, 2011 10:39
Prebuilt Stub RegionManager to enable friction-free testing of the IRegionManager Prism interface
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using Moq;
using System.Collections.ObjectModel;
namespace ArtemisWest.Prism.Testing
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
leecampbell@lxc-vm:~$ sed -i 's/\r//' kafka.sh
leecampbell@lxc-vm:~$ bash kafka.sh
in the file
lxc-net stop/waiting
lxc-net start/running
Setting up the GPG keyring
ERROR: Unable to fetch GPG key from keyserver.
lxc_container: lxccontainer.c: create_run_template: 1125 container creation template for zookeeper failed
lxc_container: lxc_create.c: main: 271 Error creating container zookeeper