Skip to content

Instantly share code, notes, and snippets.

View phatboyg's full-sized avatar

Chris Patterson phatboyg

View GitHub Profile
@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 / 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 / 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 / .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 / 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 / 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 / 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(...));

Hypermedia API design session

Proposed/ran by Andreas Schmidt, Nokia

Based off his design around the Nokia Places API

Notes

  • Picked JSON, no support for XML
  • Added ?accept=application/json to the URL in the browser for a raw response
@phatboyg
phatboyg / Code.cs
Created October 29, 2013 02:37
You can't attempt to close a generic type twice, particularly if you close it first with a generic type.
namespace ConsoleApplication1
{
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
[alias]
## Compound command alias
# View all alias
alias = !"git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\t=> \\2/' | sort"
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master"
# Stage all missing files for delete
r = !"git ls-files -z --deleted | xargs -0 git rm"
# Show all files modified using `git assume` alias
assumed = !"git ls-files -v | grep ^h | cut -c 3-"