Skip to content

Instantly share code, notes, and snippets.

View GeorgeTsiokos's full-sized avatar

George Tsiokos GeorgeTsiokos

View GitHub Profile
@GeorgeTsiokos
GeorgeTsiokos / git.log
Last active December 26, 2017 16:09
Git Credential Manager login failure
11:01:47.181403 git.c:328 trace: built-in: git 'pull'
11:01:47.181403 run-command.c:626 trace: run_command: 'fetch' '--update-head-ok'
11:01:47.228279 git.c:328 trace: built-in: git 'fetch' '--update-head-ok'
11:01:47.228279 run-command.c:626 trace: run_command: 'remote-https' 'origin' 'https://redacted.visualstudio.com/DefaultCollection/project/_git/repo'
11:01:47.259524 git.c:560 trace: exec: 'git-remote-https' 'origin' 'https://redacted.visualstudio.com/DefaultCollection/project/_git/repo'
11:01:47.259524 run-command.c:626 trace: run_command: 'git-remote-https' 'origin' 'https://redacted.visualstudio.com/DefaultCollection/project/_git/repo'
11:01:47.712687 run-command.c:626 trace: run_command: 'git credential-manager get'
11:01:47.760474 git.c:560 trace: exec: 'git-credential-manager' 'get'
11:01:47.760474 run-command.c:626 trace: run_command: 'git-credential-manager' 'get'
11:01:47.838646 ...\Common.cs:527 trace: [
@GeorgeTsiokos
GeorgeTsiokos / ApplicationInsights.config
Created December 4, 2017 19:30
CD AI template to replace AuthenticationApiKey & InstrumentationKey
<?xml version="1.0" encoding="utf-8" ?>
<ApplicationInsights xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<InstrumentationKey xdt:Transform="Replace">#{InstrumentationKey}</InstrumentationKey>
<TelemetryModules>
<Add Locator="Condition(@Type=Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector)">
<AuthenticationApiKey xdt:Transform="Replace">#{AuthenticationApiKey}</AuthenticationApiKey>
</Add>
</TelemetryModules>
</ApplicationInsights>
@GeorgeTsiokos
GeorgeTsiokos / KeyValuePairExtensions.cs
Last active October 16, 2017 18:46
CopyTo - KeyValuePair / dictionary extensions
public static class KeyValuePairExtensions
{
public static void CopyTo<TKey>(this IEnumerable<KeyValuePair<TKey, string>> keyValuePairs, IDictionary<TKey, string> target) => CopyTo(keyValuePairs, target, (a, b) => $"{a},{b}");
public static void CopyTo<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> keyValuePairs, IDictionary<TKey, TValue> target, Func<TValue, TValue, TValue> aggregator)
{
foreach (var keyValuePair in keyValuePairs)
{
var key = keyValuePair.Key;
@GeorgeTsiokos
GeorgeTsiokos / SessionSettingsExtensions.cs
Created October 16, 2017 16:53
QuickFix SessionSettingsExtensions POC
public static class SessionSettingsExtensions
{
public static bool TryUseWeekdaySessionSettings(this SessionSettings sessionSettings)
{
var allSessionIds = sessionSettings.GetSessions();
var result = allSessionIds.Select(sessionId => TryUseWeekdaySessionSettings(sessionSettings, sessionId)).All(x => x);
Console.WriteLine(sessionSettings);
return result;
}
@GeorgeTsiokos
GeorgeTsiokos / DailyFileLog.cs
Last active April 10, 2023 11:33
QuickFix/n daily log files
internal sealed class DailyFileLog : ILog
{
readonly DailyFileLogWriter _eventLog;
readonly DailyFileLogWriter _messageLog;
public DailyFileLog(FileLogWriterOptions eventLog, FileLogWriterOptions messageLog)
{
_eventLog = new DailyFileLogWriter(eventLog);
_messageLog = new DailyFileLogWriter(messageLog);
}
public static class SingleProducer
{
public static IObservable<T> Merge<T>(params IObservable<T>[] sequences)
{
IDisposable SubscribeObserver(IObserver<T> observer)
{
IDisposable SubscribeSequence(IObservable<T> sequence) => sequence.Subscribe(observer);
foreach (var sequence in sequences)
@GeorgeTsiokos
GeorgeTsiokos / CancellationDelegatingHandler.cs
Last active August 15, 2017 14:26
Return Gone when IsCancellationRequested
/// <summary>
/// Returns the specified code when the CancellationToken is canceled
/// </summary>
public sealed class CancellationDelegatingHandler : DelegatingHandler
{
readonly HttpStatusCode _canceledCode;
public CancellationDelegatingHandler(HttpStatusCode canceledCode = HttpStatusCode.Gone)
{
@GeorgeTsiokos
GeorgeTsiokos / ServiceLocator.cs
Last active July 21, 2017 19:08
If you want a set-once static instance property, and for calling threads to block until it's set...
public static class ServiceLocator
{
static readonly TaskCompletionSource<IContainer> __container = new TaskCompletionSource<IContainer>();
public static IContainer Instance {
get => __container.Task.Result;
set => __container.SetResult(value);
}
@GeorgeTsiokos
GeorgeTsiokos / TestMetadataAdapter.cs
Created June 30, 2017 11:56
Lightstreamer .NET metadata adapter for authentication
internal class TestProvider : LiteralBasedProvider
{
public override void NotifyUser(string user, string password)
{
Console.WriteLine($"NotifyUser {user} {password}");
if (false)
throw new AccessException("Unauthorized user");
}
}
public sealed class ReactiveStubObserver : IStubObserver
{
readonly ISubject<Tuple<Type, Delegate>> _subject1;
readonly ISubject<Tuple<Type, Delegate, object>> _subject2;
readonly ISubject<Tuple<Type, Delegate, object, object>> _subject3;
readonly ISubject<Tuple<Type, Delegate, object, object, object>> _subject4;
readonly ISubject<Tuple<Type, Delegate, object[]>> _subject5;
public ReactiveStubObserver(IObserver<Tuple<Type, Delegate, object[]>> observer) : this(CreateSubject(observer))