Skip to content

Instantly share code, notes, and snippets.

View adamralph's full-sized avatar
🤗
Living the dream

Adam Ralph adamralph

🤗
Living the dream
View GitHub Profile
@adamralph
adamralph / ConcurrencyThrottlingByMessageType.cs
Created December 10, 2018 13:47
Throttling concurrency by message type in NServiceBus
using NServiceBus.Pipeline;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
internal class ConcurrencyThrottlingByMessageType : IBehavior<IIncomingLogicalMessageContext, IIncomingLogicalMessageContext>
{
private static readonly Dictionary<Type, Throttle> throttles = new Dictionary<Type, Throttle>
{
@adamralph
adamralph / gist:5491576
Created April 30, 2013 20:13
new fork UI mail
Hi,
I really like the new fork UI with the large user/org icons.
There's just one problem - I previously used this as a shortcut to my own fork of a repo.
The old UI used to say something like 'fork already exists' against my user name with a link 'go to the fork'.
The new UI just says 'fork already exists' and doesn't let me click my user icon (the mouse turns into a red 'no entry' cursor).
@adamralph
adamralph / install.all.scriptpacks.cmd
Created March 28, 2015 11:37
A batch file to install all known scriptcs script packs
call scriptcs -install DotNetBuild.Runner.ScriptCs -pre
call scriptcs -install Fitter.ScriptCs -pre
call scriptcs -install Glimpse.ScriptCs -pre
call scriptcs -install MpnsTester -pre
call scriptcs -install ScriptCs.Adder -pre
call scriptcs -install ScriptCs.ArcGIS -pre
call scriptcs -install ScriptCs.Arduino -pre
call scriptcs -install ScriptCs.AzureManagement -pre
call scriptcs -install ScriptCs.AzureMediaServices -pre
call scriptcs -install ScriptCs.AzureMobileServices -pre
@adamralph
adamralph / cancellation.cs
Last active May 26, 2021 13:16
a fanciful idea about a better form of cancellation in C#
// a fanciful idea about a better form of cancellation in C#
try
{
Foo(cancellationToken);
}
catch (Cancellation cancellation) // System.Cancellation - does NOT inherit from System.Exception, but still has a stack trace, etc.
{
}
catch (Exception ex)
@adamralph
adamralph / .gitconfig
Last active February 6, 2021 10:38
My global .gitconfig
[user]
name = Adam Ralph
email = adam@adamralph.com
[core]
autocrlf = false
editor = \"C:/Users/adam/AppData/Local/Programs/Microsoft VS Code/Code.exe\" --wait
sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
[alias]
dtag = !git tag -l | xargs git tag -d
prune-all = !git remote | xargs -n 1 git remote prune
// ==UserScript==
// @name GitHub checklist highlighter 595491
// @version 5
// @grant none
// @include https://github.com/*
// ==/UserScript==
(function f() {
var taskListItems = document.getElementsByClassName("task-list-item enabled");
@adamralph
adamralph / bullseye-custom-args-mcmaster.cs
Last active October 17, 2019 09:51
Using Bullseye with custom args with McMaster.Extensions.CommandLineUtils
// dotnet add package McMaster.Extensions.CommandLineUtils
using System.Linq;
using McMaster.Extensions.CommandLineUtils;
using static Bullseye.Targets;
class Program
{
static void Main(string[] args)
{
@adamralph
adamralph / ci.md
Last active September 9, 2019 21:58
My current assessment of SaaS CI systems

This assessment is performed with respect to the requirements of the .NET community open source projects which I maintain. It is restricted to the free tier provided by each system.

Only the drawbacks are listed, which makes the assessment sound a bit negative, but it's relative to a baseline functional expectation:

  • Linux and Windows
  • Fast provisioning
  • Concurrent builds
  • Common build properties surfaced as env vars (e.g build number)
  • Readable, copyable, and line-linkable log output, supporting ANSI colour codes and code page 437
@adamralph
adamralph / DumpPalette.cs
Created August 26, 2019 00:28
For use in Bullseye Palette.cs when tuning for CI systems
Console.WriteLine($"{black}black{@default}");
Console.WriteLine($"{red}red{@default}");
Console.WriteLine($"{green}green{@default}");
Console.WriteLine($"{yellow}yellow{@default}");
Console.WriteLine($"{blue}blue{@default}");
Console.WriteLine($"{magenta}magenta{@default}");
Console.WriteLine($"{cyan}cyan{@default}");
Console.WriteLine($"{white}white{@default}");
Console.WriteLine($"{brightBlack}brightBlack{@default}");
@adamralph
adamralph / bullseye-custom-args-system.cs
Last active August 11, 2019 16:13
Using Bullseye with custom args with System.CommandLine.Experimental
// dotnet add package System.CommandLine.Experimental
using System.CommandLine;
using static Bullseye.Targets;
class Program
{
static void Main(string[] args)
{
var cmd = new RootCommand { TreatUnmatchedTokensAsErrors = false };