Skip to content

Instantly share code, notes, and snippets.

// Thanks to Michael Rush for the original version of this rule (
// IMPORTANT: Use a valid Incoming Webhook from Slack. To get one, go to
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var http = require('@jetbrains/youtrack-scripting-api/http');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
function formatIssueAsAttachment(i) {
/// <summary>
/// Serilog won't be able to pull structured props out of a C# interpolated string.
/// See
/// </summary>
public class NoInterpolationInSerilogAnalyzer : DiagnosticAnalyzer
const string Category = "Logging";
const string Title = "String interpolation breaks Serilog structuring";
const string MessageFormat = "String interpolation breaks Serilog structuring";
robfe / SettingsRegistrationSource.cs
Created April 6, 2018 11:49
Register a set of POCOs to be read from IConfiguration in Autofac
public class SettingsRegistrationSource : IRegistrationSource
public string Suffix { get; }
public SettingsRegistrationSource(string suffix)
Suffix = suffix;
public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor)
robfe /
Last active December 20, 2022 21:56
Running localstack in docker for windows with persistence enabled

Running localstack in docker for windows with persistence enabled

Running on Docker for Windows

Localstack comes with a docker-compose file that won't quite work when you're running the (linux) container in docker for Windows.

Two changes need to be made:

The docker.sock volume won't work on windows

We can just comment that line out:

let rows: string[] = [];
for (let count = 1; count <= 10; count++) {
let numbers = Array.from(new Array(count)).map((x, i) => i + 1);
let genericDef = => `T${x} extends string`).join(', ');
let parameterDef = => `a${x}: T${x}`).join(', ');
let recordDef = => `T${x}`).join('|');
rows.push(`<${genericDef}>(strings: TemplateStringsArray, ${parameterDef}): HasRouteTemplate & ((r: Record<${recordDef}, string>) => string);`);
console.log('\n\n' + rows.join('\n'));
type StateMap<TStates extends string, TActions extends string> = {
[S in TStates]: { //for every string option in TStates:
[A in TActions]?: TStates; //optionally map to the next state if it's a valid action there
}; //AKA: Record<TStates, Partial<Record<TActions, TStates>>>;
class StateMachine<TStates extends string, TActions extends string>{
constructor(private _currentState: TStates, private stateMap: StateMap<TStates, TActions>) { }
get currentState() {
var mm = components.mapModel;
var colours = '#FDB813 #A7BE38 #9EA4C1 #FF8384 #FFD87D'.split(' ');
function walk(node, depth){
if(!depth || !mm.getStyleForId(, 'background')){
console.log('setting '+node.title +' to ' +colours[depth], depth);
mm.updateStyle('script', 'background', colours[depth]);
color: black;
.mapjs-node[mapjs-level="1"] {
background-color: #FDB813;
.mapjs-node[mapjs-level="2"] {
background-color: #A7BE38;
robfe / ApprovalNameEnhancer.cs
Created November 28, 2014 03:09
Adds step names to Approvals.Net file names, so you can have multiple asserts in one unit test
public class ApprovalNameEnhancer : SpecFixtureBase
public override void StepSetup(Step step)
//tack the step description onto the approval file name:
NamerFactory.AdditionalInformation = step.Description;
//ok, but what if the step used twice in the same spec (with the same arguments)?
var dupes = step.Spec.Steps.Where(x => x.Description == step.Description);
var index = dupes.ToList().IndexOf(step);
robfe / SpecAttribute.cs
Last active August 29, 2015 14:10
Make XUnit tests dynamically skippable for SpecLight
/// <summary>
/// Speclight users like to see "Pending" steps (that throw NotImplementedException) as "skip" not "fail"
/// </summary>
public class SpecAttribute : FactAttribute
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
yield return new SkipIfNotImplemented(method);