This file contains hidden or 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 HashUtils | |
| { | |
| public static uint Lcg(uint value) | |
| { | |
| unchecked { | |
| value = 1664525 * value + 1013904223; | |
| return value; | |
| } | |
| } |
This file contains hidden or 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; | |
| using System.Collections.Generic; | |
| using System.Reflection; | |
| using System.Runtime.CompilerServices; | |
| using System.Runtime.InteropServices; | |
| using System.Threading; | |
| namespace System.Reflection | |
| { |
This file contains hidden or 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 Microsoft.AspNetCore.Http; | |
| using Microsoft.AspNetCore.Http.Features; | |
| using System; | |
| using System.Collections.Concurrent; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace Ogxd | |
| { | |
| public class ThrottlingMiddleware |
This file contains hidden or 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
| //! Prints objects, cool for debugging | |
| println!("{:#?}", my_object); | |
| //! Empty struct shorthand | |
| struct MyStruct; |
This file contains hidden or 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 ManualOptionMonitor<T> : IOptionsMonitor<T> | |
| { | |
| private readonly Dictionary<int, Action<T, string>> _listeners = new Dictionary<int, Action<T, string>>(); | |
| private volatile int _nextId; | |
| private T _currentValue; | |
| public T CurrentValue | |
| { | |
| get | |
| { |
This file contains hidden or 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 System; | |
| public static class StringConcatenationExtensions | |
| { | |
| /// <summary> | |
| /// Concatenates strings with manamal allocations and good performance. | |
| /// (only the end result string is allocated) |
This file contains hidden or 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; | |
| using System.Linq; | |
| namespace Ogxd; | |
| /// <summary> | |
| /// Returns a string for a given enum value, without allocations | |
| /// </summary> | |
| /// <typeparam name="T"></typeparam> |
This file contains hidden or 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
| sudo -i | |
| dnctl pipe 1 config delay 300 | |
| echo "dummynet in proto {tcp,icmp} from any to any pipe 1" | pfctl -f - | |
| pfctl -e | |
| pfctl -f /etc/pf.conf | |
| dnctl -q flush |
This file contains hidden or 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 ComUtils | |
| { | |
| private delegate int DllGetClassObject(ref Guid clsid, ref Guid iid, out nint classFactoryPtr); | |
| private delegate void CreateInstance(nint self, nint pUnkOuter, ref Guid riid, out nint ppvObjectPtr); | |
| public static nint Load(string library) | |
| { | |
| Guid exceptionProfilerGuid = new Guid("805A308B-061C-47F3-9B30-F785C3186E82"); | |
| Guid iclassFactoryGuid = new Guid("00000001-0000-0000-c000-000000000046"); | |
| Guid iCorProfilerCallback8Guid = new Guid("5BED9B15-C079-4D47-BFE2-215A140C07E0"); |
This file contains hidden or 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 BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Order; | |
| // | Method | str | Mean | Error | StdDev | Allocated | | |
| // |-------------------- |-------------------- |-----------:|----------:|----------:|----------:| | |
| // | Split | this(...)oose [131] | 162.522 ns | 1.7171 ns | 1.6062 ns | 760 B | | |
| // | SplitAllocationFree | this(...)oose [131] | 1.748 ns | 0.0187 ns | 0.0175 ns | - | 🚀 | |
| [Orderer(SummaryOrderPolicy.Declared)] | |
| [MemoryDiagnoser(false)] |