Skip to content

Instantly share code, notes, and snippets.

View AntonC9018's full-sized avatar

Anton Curmanschii AntonC9018

View GitHub Profile
@AntonC9018
AntonC9018 / test.cs
Created September 20, 2022 09:46
Overloading generics in C# proof of concept
public static class A
{
public static void a<T>(this T[] l, in T t) where T : struct
{
}
}
public static class B
@AntonC9018
AntonC9018 / ScrollHelper.cs
Last active August 5, 2022 17:18
ScrollChildIntoView Unity helper function for ScrollRect
namespace Zayats.Unity.View
{
using UnityEngine;
using UnityEngine.UI;
public static class ScrollHelper
{
public static void ScrollChildIntoView(this ScrollRect scrollRect, int childIndex)
{
ScrollChildIntoView(scrollRect, (RectTransform) scrollRect.content.GetChild(childIndex));
@AntonC9018
AntonC9018 / ToPascalCase.cs
Created June 27, 2022 17:19
ToPascalCase
using System;
using System.Diagnostics;
using System.Text;
public class NotThreadSafeHelper
{
private static readonly StringBuilder _StringBuilderCached = new();
// Not thread safe! Reuses a static buffer.
public static string ToPascalCase(ReadOnlySpan<char> input)
module md4;
struct MD4Context
{
uint[4] hash;
uint[16] block;
ulong byteCount;
}
ubyte[MD4Context.hash.sizeof] md4Of(scope const(ubyte)[] input)
@AntonC9018
AntonC9018 / inverse_modulo.d
Created December 17, 2021 20:02
Inverse modulo via the euclidean algorithm
long inverse_modulo(long a, long n)
{
auto t0 = 0L;
auto t1 = 1L;
auto r0 = n;
auto r1 = a;
while (r1 != 0)
{
auto q = r0 / r1;
@AntonC9018
AntonC9018 / bitmap.d
Last active November 14, 2021 11:00
Bitmap
module bitmap;
struct Index
{
size_t numberIndex;
size_t bitIndex;
}
int getMask(TNumber)(Index index)
{