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; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace ConsoleApplication | |
{ | |
public class Program | |
{ | |
private static readonly Char[] baseDigits = "abcdefghijklmnopqrstuvwxyz0123456789.?-+#".ToCharArray(); |
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
static unsafe TDest ReinterpretCast<TSource, TDest>(TSource source) | |
{ | |
var sourceRef = __makeref(source); | |
var dest = default(TDest); | |
var destRef = __makeref(dest); | |
*(IntPtr*)&destRef = *(IntPtr*)&sourceRef; | |
return __refvalue(destRef, TDest); | |
} |
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
private static Boolean BitwiseEquals(Byte[] a, Byte[] b) { | |
const Int32 _64BitIntPtrSize = 8; | |
const Int32 _32BitIntPtrSize = 4; | |
if (ReferenceEquals(a, b)) | |
return true; | |
if (a.Length != b.Length) | |
return false; | |
var i = 0; | |
var unionA = new Union { Bytes = a }; | |
var unionB = new Union { Bytes = b }; |
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; | |
using System.Collections.Generic; | |
namespace GeneralTesting.NETCore { | |
public struct FastString : IEquatable<FastString> | |
{ | |
public readonly String String; | |
public readonly Int32 Length; | |
public readonly Int32 HashCode; |
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
/// <summary> | |
/// Sync roots must be in the same order to prevent deadlocks | |
/// </summary> | |
public struct MultiLock : IDisposable | |
{ | |
private readonly object[] _syncRoots; | |
private readonly bool[] _locksTaken; | |
public MultiLock(object[] syncRoots) : this() | |
{ |
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; | |
using System.Runtime.InteropServices; | |
namespace NickStrupat { | |
public static class MarshalEx | |
{ | |
private static readonly Boolean IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | |
private static readonly Boolean IsMacOS = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); | |
private static readonly Boolean IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); |
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 Extensions | |
{ | |
public static IList<TResult> Select<TSource, TResult>(this IList<TSource> source, Func<TSource, TResult> selector) => new IListProjection<TSource, TResult>(source, selector); | |
private class IListProjection<TSource, TResult> : IList<TResult> | |
{ | |
private readonly IList<TSource> source; | |
private readonly Func<TSource, TResult> selector; | |
public IListProjection(IList<TSource> source, Func<TSource, TResult> selector) |
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
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"$id": "http://json-schema.org/draft-07/schema#", | |
"title": "Rosetta Configuration", | |
"type": "object", | |
"properties": { | |
"Options": { | |
"type": "object", | |
"additionalProperties": {} | |
}, |
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
Enum OSType { | |
Windows | |
Linux | |
} | |
function Ensure-Docker-Container-Engine-Mode([OSType] $osType) { | |
[OSType] $currentOSType = docker info --format "{{.OSType}}" | |
Write-Output "Current engine: $($currentOSType)" | |
Write-Output "Requested engine: $($osType)" | |
if ($currentOSType -eq $osType) { |
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
docker run -it -e DOCKER_HOST_USER_DOMAIN_NAME=$([System.Environment]::UserDomainName) -e DOCKER_HOST_USER_NAME=$([System.Environment]::UserName) mcr.microsoft.com/powershell |