Skip to content

Instantly share code, notes, and snippets.

View gshutler's full-sized avatar
📅
👨‍💻

Garry Shutler gshutler

📅
👨‍💻
View GitHub Profile
public static class ServiceBusExtensions
{
public static bool HasSubscribersFor<T>(this IServiceBus serviceBus, T message)
{
IEnumerable<Action<object>> enumerable = serviceBus.OutboundPipeline.Enumerate(message);
return enumerable.Any();
}
}
public static class ConventionHelper
{
public static string PluralUnderscore(string name)
{
return Underscore(Inflector.Net.Inflector.Pluralize(name));
}
public static string Underscore(string name)
{
return Regex.Replace(name, "([a-z])([A-Z])", "$1_$2").ToLowerInvariant().Trim();
public class PageTemplateManager : IPageTemplateManager
{
readonly IReadModelRepository readModelRepository;
readonly object mutex;
readonly IDictionary<Guid, IList<PageTemplate>> templates;
public PageTemplateManager(IReadModelRepository readModelRepository)
{
this.readModelRepository = readModelRepository;
this.templates = new Dictionary<Guid, IList<PageTemplate>>();
@gshutler
gshutler / about_scoring_project.rb
Created July 18, 2011 10:24 — forked from jakcharlton/about_scoring_project.rb
About Scoring from Ruby Koans
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
public static class DiffGenerator
{
public Diff<T> Generate<T>(IEnumerable<T> left, IEnumerable<T> right)
{
var added = right.Except(left).ToList();
var removed = left.Except(right).ToList();
var leftList = left.ToList();
var common = right.Where(item => leftList.Contains(item)).ToList();
@gshutler
gshutler / DiffGenerator.cs
Created March 2, 2012 17:27 — forked from DominicFinn/DiffGenerator.cs
Two ways of generating the difference in between two lists
using System.Collections.Generic;
using System.Linq;
namespace Other.Something.Core.Tasks
{
public static class DiffGenerator
{
public static Diff<T> Generate<T>(IEnumerable<T> left, IEnumerable<T> right)
{
var added = right.Except(left);
GET /users
Content-Type: application/json
Link: rel=page2;href=/users?page=2
{
page: 1,
total: 1111002324,
results: [
var optionSet = new OptionSet
{
{"p|password=", "The password for each certificate", x => password = x},
{"f|format=", "The string format for certificate names", x => format = x}
};
var outputPath = optionSet.Parse(args).FirstOrDefault();
// Vessl e:\Export
// Vessl --password=foobar e:\Export
@gshutler
gshutler / sketch.rb
Created June 29, 2012 16:04 — forked from mattwynne/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationCreator
@gshutler
gshutler / generator.rb
Created July 1, 2012 16:26 — forked from karlseguin/gist:3016329
File-based score data
require 'digest'
require 'json'
require 'fileutils'
$leaderboard_count = 5
$user_count = 200000
def username(i)
Digest::SHA1.hexdigest(i.to_s)
end