Skip to content

Instantly share code, notes, and snippets.

View phatboyg's full-sized avatar

Chris Patterson phatboyg

View GitHub Profile
@phatboyg
phatboyg / FreeConsumer.cs
Created June 11, 2013 16:20
This is an example of a convention-based consumer with no dependencies on MassTransit.
public class FreeConsumer
{
public event EventHandler<MyPublishedEvent> MyPublish;
public void CommandHandler(MyCommand command)
{
// process the command
// the event handler will be bound by MT to publish the event handler message type
MyPublish(this, new MyPublishedEvent(...));
@phatboyg
phatboyg / Example.cs
Created February 12, 2013 13:09
Logical to physical address mapping for RabbitMQ
IServiceBus bus = ServiceBusFactory.New(c =>
{
c.ReceiveFrom("rabbitmq://logicalHost/my_queue");
c.UseRabbitMq(r =>
{
r.ConfigureHost("rabbitmq://logicalhost/", h =>
{
h.SetUsername("testUser");
h.SetPassword("test");
@phatboyg
phatboyg / private.xml
Created November 26, 2012 15:04
KeyRemap4MacBook Private Settings XML
<?xml version="1.0"?>
<root>
<item>
<name>Swap Fn-Keys and Functional Keys in Virtual Machine</name>
<appendix>For MacBook Pro</appendix>
<identifier>private.phatboyg_swap_fkeys_vm</identifier>
<not>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</not>
<autogen>--KeyToConsumer-- KeyCode::F1, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
<autogen>--KeyToConsumer-- KeyCode::F2, ConsumerKeyCode::BRIGHTNESS_UP</autogen>
<autogen>--KeyToKey-- KeyCode::F3, KeyCode::MISSION_CONTROL</autogen>
@phatboyg
phatboyg / .slate
Last active October 13, 2015 05:48
Slate Configuration
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config windowHintsShowIcons true
config windowHintsBackgroundColor 96;96;64;0.5
config windowHintsIgnoreHiddenWindows true
@phatboyg
phatboyg / ClassMappingExtension.cs
Created October 8, 2012 23:11
Automatonymous NHibernate Saga Mapping
using System;
using System.Linq.Expressions;
using Automatonymous;
using NHibernate.Mapping.ByCode;
public static class AutomatonymousNHibernateExtensions
{
public static void StateProperty<T, TMachine>(this IClassMapper<T> mapper, Expression<Func<T, State>> stateExpression)
where T : class
where TMachine : StateMachine, new()
@phatboyg
phatboyg / LeftJoinExtension.cs
Created September 20, 2012 14:37 — forked from bryanhunter/LeftJoinExtension.cs
Simplifies LINQ left joins
using System.Collections.Generic;
namespace System.Linq
{
public static class LeftJoinExtension
{
public static IEnumerable<TResult> LeftJoin<TLeft, TRight, TKey, TResult>(
this IEnumerable<TLeft> left,
IEnumerable<TRight> right,
Func<TLeft, TKey> leftKeySelector,
@phatboyg
phatboyg / Example.cs
Created September 9, 2012 17:30
Extensible Command Line Arguments for Topshelf
[Test]
public void Extensible_the_command_line_should_be_yes()
{
bool isSuperfly = false;
Host host = HostFactory.New(x =>
{
x.Service<MyService>();
x.AddCommandLineSwitch("superfly", v => isSuperfly = v);
@phatboyg
phatboyg / IProxyAsyncResult.cs
Created July 26, 2012 23:11
Method Async Proxy
using System;
public interface IProxyAsyncResult<T> :
IAsyncResult
{
T Result { get; }
}
@phatboyg
phatboyg / PhatBoyG-FontsAndColors.vssettings
Created July 25, 2012 18:52
Visual Studio 2010 Color Schema (w/R# settings)
<UserSettings>
<ApplicationIdentity version="10.0"/>
<ToolsOptions>
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/>
</ToolsOptions>
<Category name="Database Tools" RegisteredName="Database Tools"/>
<Category name="Environment_Group" RegisteredName="Environment_Group">
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package">
<PropertyValue name="Version">2</PropertyValue>
<FontsAndColors Version="2.0">
@phatboyg
phatboyg / AppendText.cs
Created July 18, 2012 15:54
Benchmarque Blog Post Code
public interface AppendText
{
string Append(params string[] args);
}