Skip to content

Instantly share code, notes, and snippets.

View ahydrax's full-sized avatar
🦾
Serve. Flex. I do work.

Viktor Svyatokha ahydrax

🦾
Serve. Flex. I do work.
View GitHub Profile
@ahydrax
ahydrax / program.cs
Created November 20, 2021 12:01
Debugger minimal repro
using System;
namespace debugger_minimal_repro
{
enum TestEnum
{
Default,
NonDefault
}
db.getCollection('CollectionItem').find({"cid" : 118, "itemId" : {
"$in" : [
ObjectId("5c8a54661437270efcd030e7"),
ObjectId("5c8a54da1437260f941af45b"),
ObjectId("5c8a56641437250d98768a5d"),
ObjectId("5c8a56da1437260f941b453a")
]
},
"isCurrent" : true}).sort({_id:-1}).explain("allPlansExecution")
indexes:
[
{
"v" : 2,
"key" : {
"cid" : 1.0,
"funcId" : 1.0
},
"name" : "FunctionalId",
"ns" : "db_prd.CollectionItem"
internal sealed class ExpressionBasedControllerActivator : IHttpControllerActivator
{
private readonly Dictionary<Type, Func<ILifetimeScope, IHttpController>> _activatorCache;
public ExpressionBasedControllerActivator()
{
_activatorCache = new Dictionary<Type, Func<ILifetimeScope, IHttpController>>();
Warmup();
}
[MemoryDiagnoser]
[SimpleJob(RunStrategy.Monitoring, launchCount: 1, warmupCount: 1, targetCount: 2, invocationCount: 10001)]
public class CompileBenchmark
{
private static LambdaExpression ResolutionExpression;
[GlobalSetup]
public void GlobalSetup()
{
var owinBuilder = new AppBuilder();
@ahydrax
ahydrax / DryIoc exception
Created November 6, 2018 11:22
DryIoc exception
- $exception {The runtime refused to evaluate the expression at this time.} System.StackOverflowException
[Lightweight Function]
DryIoc.dll!DryIoc.Scope.TryGetOrAdd(ImTools.ImMap<object> items, int id = 564, DryIoc.CreateScopedValue createValue, int disposalOrder = 0) Line 8213 C#
DryIoc.dll!DryIoc.Scope.GetOrAdd(int id, DryIoc.CreateScopedValue createValue, int disposalOrder) Line 8198 C#
[Lightweight Function]
DryIoc.dll!DryIoc.Container.DryIoc.IResolver.Resolve(System.Type serviceType, object serviceKey, DryIoc.IfUnresolved ifUnresolved, System.Type requiredServiceType, DryIoc.Request preResolveParent, object[] args) Line 325 C#
DryIoc.dll!DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(System.Type serviceType, DryIoc.IfUnresolved ifUnresolved) Line 238 C#
DryIoc.dll!DryIoc.Container.DryIoc.IResolver.Resolve(System.Type serviceType, DryIoc.IfUnresolved ifUnresolved) Line 209 C#
> MyApp.Web.Api.dll!MyApp.Web.Api.Caching.DryIoCControllerActivato
public IFetchedJob Dequeue(string[] queues, CancellationToken cancellationToken)
{
var fetchJobSqlTemplate = @"
UPDATE jobqueue AS jobqueue
SET fetchedat = NOW() AT TIME ZONE 'UTC'
WHERE jobqueue.id = (
SELECT id
FROM jobqueue
WHERE queue IN @queues
AND (fetchedat IS NULL OR fetchedat < NOW() AT TIME ZONE 'UTC' - @timeout)
public void RunThrottling()
{
// ACQUIRING
acquiring:
var lockEntity = _lockStorage.UpdateLastAcquiringAndGetPrevious(Key);
// ACQUIRED
if (lockEntity == null)
{
// WAITING
public class ItemMapper
{
public CollectionItem Map(ItemBase item) => MapDynamic(item);
private CollectionItem MapDynamic(dynamic item) => MapInternal(item);
private CollectionItem MapInternal(ItemBase item) =>
throw new NotSupportedException($"Item type {item.GetType().Name} is not supported");
private CollectionItem MapInternal(ConcreteItem item)
@ahydrax
ahydrax / Program.cs
Last active April 29, 2017 12:46
Performance comparison between existing and proposed implementation of method ToHexString
using System;
using System.Linq;
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ToHexStringPerf
{
public class Tests
{