Skip to content

Instantly share code, notes, and snippets.

View ritasker's full-sized avatar

Richard Tasker ritasker

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Services.Common;
namespace Pier8Software.TestingHelpers
public class NodaTimeModelBinder : ModelBinderBase
{
private readonly JsonSerializerOptions serializerOptions;
public NodaTimeModelBinder(ILoggerFactory loggerFactory) : base(loggerFactory)
{
serializerOptions = new JsonSerializerOptions {PropertyNameCaseInsensitive = true};
serializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
}
public Task<KrakenFuturesTransfersResponse> FetchTransfers(DateTime? lastTransferTime = null)
{
var queryParams = new Dictionary<string, string>();
if(lastTransferTime != null)
{
queryParams.Add("lastTransferTime", lastTransferTime?.ToString("O"));
}
var webRequest = CreateAuthenticatedRequest(endpoint, queryParams)
var response = await this.client.SendAsync(webRequest)
namespace Carter.Benchmarks
{
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.Extensions.DependencyInjection;
public class UseCarterBenchmarks
{
private ApplicationBuilder app;
Write-Host "Installing Chocolatey..." -ForegroundColor Yellow
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
$Env:Path += ";$Env:ALLUSERSPROFILE\chocolatey\bin"
choco --version
Write-Host "Installing K8S tools..." -ForegroundColor Yellow
choco install -y minikube kubernetes-cli
Write-Host "Setup Hyper-V Virtual Network Switch..." -ForegroundColor Yellow
@ritasker
ritasker / ExponentialBackoff.cs
Created September 24, 2018 20:50
Demonstrates How An Exponential Back-Off Works
using System;
using System.Collections.Generic;
public class Program
{
private static int _highInterval;
private static int _lowInterval;
private static int _maxInterval;
private static int _minInterval;
private static int _retryLimit;
@ritasker
ritasker / gist:339060762892ff36d86e350ca719c414
Created January 28, 2018 22:07 — forked from SzymonPobiega/gist:5220595
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@ritasker
ritasker / Elasticsearch.txt
Created January 15, 2018 11:59
Elastcsearch Exception
[2018-01-15T05:57:03,292][WARN ][o.e.m.j.JvmGcMonitorService] [_3m0Rmo] [gc][169] overhead, spent [2.4s] collecting in the last [2.4s]
[2018-01-15T05:57:32,682][WARN ][o.e.m.j.JvmGcMonitorService] [_3m0Rmo] [gc][170] overhead, spent [29.3s] collecting in the last [1.5s]
Dumping heap to java_pid1.hprof ...
java.lang.OutOfMemoryError: Java heap space
Heap dump file created [2392178503 bytes in 8.593 secs]
[2018-01-15T06:00:03,297][WARN ][o.e.m.j.JvmGcMonitorService] [_3m0Rmo] [gc][171] overhead, spent [2.3m] collecting in the last [2.6m]
[2018-01-15T06:00:09,991][WARN ][o.e.m.j.JvmGcMonitorService] [_3m0Rmo] [gc][173] overhead, spent [5s] collecting in the last [5s]
[2018-01-15T06:01:18,987][WARN ][o.e.m.j.JvmGcMonitorService] [_3m0Rmo] [gc][174] overhead, spent [1.1m] collecting in the last [28.8s]
[2018-01-15T06:02:43,695][WARN ][o.e.m.j.JvmGcMonitorService] [_3m0Rmo] [gc][175] overhead, spent [1.4m] collecting in the last [2m]
[2018-01-15T06:05:29,271][WARN ][o.e.t.TransportService ] [_3m0Rmo] Received res
@ritasker
ritasker / fluentd.configmap.yaml
Last active January 9, 2019 12:44
K8s Fluentd Setup
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-config
labels:
app: fluentd
data:
fluent.conf: |
@include kubernetes.conf