This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DateTimeOffsetUnixTimestampMillisJsonConverter : JsonConverter<DateTimeOffset> | |
{ | |
public override DateTimeOffset Read( | |
ref Utf8JsonReader reader | |
, Type typeToConvert | |
, JsonSerializerOptions options) | |
{ | |
return DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using System.Runtime.CompilerServices; | |
namespace Ruzzie.Common.Collections; | |
/// <summary> | |
/// A Buffer (queue) that supports | |
/// multiple concurrent (lock-free, not wait free (spinning)) writers (MPSC) | |
/// ,single reader, that reads in batches | |
/// the reader should only read every N messages, otherwise another |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Elm = | |
type Expression = | |
| TopLevelVariable of string * Expression | |
| InlineList of Expression list | |
| Tuple of (Expression * Expression) | |
| String of string | |
| Int of int | |
| SimpleInvoke of (string * Expression) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConcurrentGreedyDoubleLinkedList<T> where T: ILinkable<T> | |
{ | |
private readonly int _initialSize; | |
private ILinkable<T> _head; | |
private readonly ILinkable<T> _tail; | |
public ConcurrentGreedyDoubleLinkedList(in int initialSize = 1024) | |
{ | |
if (initialSize <= 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ($env:DEPLOYMENT_SOURCE -eq "") -or ($env:DEPLOYMENT_SOURCE -eq $null)) | |
{ | |
$env:DEPLOYMENT_SOURCE = "..\" | |
} | |
if ( ($env:DEPLOYMENT_TARGET -eq "") -or ($env:DEPLOYMENT_TARGET -eq $null)) | |
{ | |
$env:DEPLOYMENT_TARGET = "..\source\MtgDataImports\RuzzieMtgFunctionsWebProject" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ($env:DEPLOYMENT_SOURCE -eq "") -or ($env:DEPLOYMENT_SOURCE -eq $null)) | |
{ | |
$env:DEPLOYMENT_SOURCE = "..\" | |
} | |
if ( ($env:DEPLOYMENT_TARGET -eq "") -or ($env:DEPLOYMENT_TARGET -eq $null)) | |
{ | |
$env:DEPLOYMENT_TARGET = "YOUR LOCAL TARGET" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<Target Name="CopyDllToAllPrecompiledFunctionDirectories"> | |
<ItemGroup> | |
<AllFunctionsItems Include="@(Content)" | |
Condition="'%(Filename)' == 'function' And '%(Extension)' == '.json'" /> | |
<AllFunctionDirectories Include="@(AllFunctionsItems->'%(RootDir)%(Directory)'->Distinct())" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleRandom : Random | |
{ | |
private readonly RandomSampler _randomSampler; | |
private const int IntMaxValueMinusOne = int.MaxValue - 1; | |
public SimpleRandom(int seed, int hValue, int eValue) | |
{ | |
//For bytes: 0,00106736330262713 127,5 H1741966517 E1631200041 | |
//0,000000001594884 0,499999998405116 H1612099793 E1610967361, with _pTwo PrimeToolHash.GetPrime(hashOrValue.FindNearestPowerOfTwoLessThan()) | |
_randomSampler = new RandomSampler(seed, hValue, eValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleCrypto : ICryptoTransform | |
{ | |
private byte[] _key; | |
private byte[] _iv; | |
private static readonly int KeySizeInBytes = 32; | |
private static readonly int IVSizeInBytes = 4; | |
private static readonly int NumberOfPasses = 2; | |
private readonly SimpleRandom _generator; | |
public SimpleCrypto(byte[] key, byte[] iv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Statistics | |
{ | |
public static double StreamAverage(double previousAverage, double currentNumber, double currentCount) | |
{ | |
return ((previousAverage*currentCount) + currentNumber)/(currentCount + 1); | |
} | |
public static double Entropy<T>(this IDictionary<T, int> histogram, int dataSize) | |
{ | |
double entropy = 0; |
NewerOlder