Skip to content

Instantly share code, notes, and snippets.

@robfe
robfe / about.md
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:

@robfe
robfe / Hubs.tt
Last active March 18, 2020 16:17
T4 template that creates Typescript type definitions for all your Signalr hubs. If you have C# interface named "I<hubName>Client", a TS interface will be generated for the hub's client too.If you turn on XML documentation in your build, XMLDoc comments will be picked up.Licensed with http://www.apache.org/licenses/LICENSE-2.0
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output extension=".d.ts" #>
<# /* Update this line to match your version of SignalR */ #>
<#@ assembly name="$(SolutionDir)\packages\Microsoft.AspNet.SignalR.Core.2.2.0\lib\net45\Microsoft.AspNet.SignalR.Core.dll" #>
<# /* Load the current project's DLL to make sure the DefaultHubManager can find things */ #>
<#@ assembly name="$(TargetPath)" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Web" #>
<#@ assembly name="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
<#@ assembly name="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
// Thanks to Michael Rush for the original version of this rule (https://software-development.dfstudio.com/youtracks-new-javascript-workflows-make-slack-integration-a-breeze-d3275605d565)
// IMPORTANT: Use a valid Incoming Webhook from Slack. To get one, go to https://my.slack.com/services/new/incoming-webhook/
var SLACK_WEBHOOK_URL = 'https://hooks.slack.com/services';
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 https://nblumhardt.com/2015/01/c-6-string-interpolation-and-serilog/
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
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
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)
let rows: string[] = [];
for (let count = 1; count <= 10; count++) {
let numbers = Array.from(new Array(count)).map((x, i) => i + 1);
let genericDef = numbers.map(x => `T${x} extends string`).join(', ');
let parameterDef = numbers.map(x => `a${x}: T${x}`).join(', ');
let recordDef = numbers.map(x => `T${x}`).join('|');
rows.push(`<${genericDef}>(strings: TemplateStringsArray, ${parameterDef}): HasRouteTemplate & ((r: Record<${recordDef}, string>) => string);`);
}
console.log('\n\n' + rows.join('\n'));
.mapjs-node{
color: black;
}
.mapjs-node[mapjs-level="1"] {
background-color: #FDB813;
color:white;
}
.mapjs-node[mapjs-level="2"] {
background-color: #A7BE38;
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() {
@robfe
robfe / QrCodeElement.cs
Created November 9, 2011 22:20
WPF templated control for QrCode.codeplex.com
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Gma.QrCodeNet.Encoding;
namespace Gma.QrCodeNet.Wpf
{
public class QrCodeElement : Control
var mm = components.mapModel;
var colours = '#FDB813 #A7BE38 #9EA4C1 #FF8384 #FFD87D'.split(' ');
function walk(node, depth){
if(!depth || !mm.getStyleForId(node.id, 'background')){
console.log('setting '+node.title +' to ' +colours[depth], depth);
mm.selectNode(node.id);
mm.updateStyle('script', 'background', colours[depth]);
}