Skip to content

Instantly share code, notes, and snippets.

@musukvl
musukvl / IgnoreNullMembersInExpectation.cs
Last active July 24, 2020 09:23
Fluent assertions: skip checking for default fields in Expectation. (for cases if we want to check only defined non-default fields)
class IgnoreNullMembersInExpectation : IEquivalencyStep
{
public bool CanHandle(IEquivalencyValidationContext context, IEquivalencyAssertionOptions config) =>
context.Expectation is null ||
context.Expectation is ValueType == default;
public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator parent, IEquivalencyAssertionOptions config) => true;
}
@musukvl
musukvl / Dockerfile
Created July 21, 2020 12:01
Debug Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic
RUN apt-get update
RUN apt-get install mc -y
@musukvl
musukvl / ActionPool.cs
Created June 17, 2020 09:18
Limited action pool async
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Common
{
public class LimitedLengthActionPool : IAsyncDisposable
{
@musukvl
musukvl / find-all-references.ps1
Created April 22, 2020 06:53
Generates nuget install for all references
# place this file to your prepository root, or set the your repository full path to $repositoriesRoot
$repositoriesRoot = Convert-Path .
$files = Get-ChildItem -Path $repositoriesRoot -Filter *.csproj -Recurse -File -Name
$commands = @()
foreach ($fileName in $files) {
$xml = [Xml](Get-Content "$repositoriesRoot\$fileName")
foreach ($item in $xml.SelectNodes("//PackageReference")) {
@musukvl
musukvl / web.config
Created February 10, 2020 10:21
IIS request forwarding for Grafana. xxx.domain.com -> http://localhost:3008
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="HttpToHttpsRule" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
@musukvl
musukvl / GenerationController.cs
Created July 18, 2019 21:21
Example rendering IEnumerable to Asp.net core API action result
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace ApiModelingApp.Controllers
{
[Route("api/generation")]
[ApiController]
@musukvl
musukvl / WebApp.cs
Created March 16, 2019 06:42
.htaccess file for asp.net core application
// # .htaccess content sample
// RewriteRule ^/apache-mod-rules-redirect/(.*) /redirected?id=$1 [L,R=302]
using (StreamReader apacheModRewriteStreamReader =
File.OpenText(".htaccess"))
{
var options = new RewriteOptions()
.AddApacheModRewrite(apacheModRewriteStreamReader);
app.UseRewriter(options);
@musukvl
musukvl / MassTransitTest.cs
Created February 15, 2019 18:42
Mass transit concurrent sample
using System;
using System.Threading;
using GreenPipes;
using MassTransit;
namespace TestMassTransit
{
public class VideoFileMessage
{
public int Num { get; set; }
@musukvl
musukvl / async-context.js
Created January 14, 2019 18:28
Async context for your cli tools
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let result = (async function() {
await timeout(3000);
console.log("done");
})();
@musukvl
musukvl / web.config
Created January 10, 2019 20:29
Web,config for IIS url rewrite poxy from public domain to local port. Used for Teamcity
<?xml version="1.0" encoding="UTF-8"?>
<!---
config based on
https://blogs.msdn.microsoft.com/friis/2016/08/25/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world-apps/
https://blogs.msdn.microsoft.com/friis/2016/08/25/iis-with-url-rewrite-as-a-reverse-proxy-part-2-dealing-with-500-52-status-codes/
To you this configs you need to add
HTTP_ACCEPT_ENCODING
HTTP_X_ORIGINAL_ACCEPT_ENCODING