Skip to content

Instantly share code, notes, and snippets.

View AntonC9018's full-sized avatar

Anton Curmanschii AntonC9018

View GitHub Profile
@AntonC9018
AntonC9018 / .tmux.conf
Created May 18, 2024 22:41
Tmux config
set -ga update-environment EDITOR
# https://github.com/artemave/tmux_super_fingers
run-shell ~/.tmux/plugins/tmux_super_fingers/tmux_super_fingers.tmux
bind C-r source-file ~/.tmux.conf \; display "Reloaded!"
set -g mouse on
set-option -g history-limit 20000
bind \` switch-client -t'{marked}'
set -g base-index 1
@AntonC9018
AntonC9018 / alacritty.toml
Created March 3, 2024 20:44
Alacritty Windows 10 config
# C:\Users\Name\AppData\Roaming\alacritty\alacritty.toml
[window]
dynamic_padding = false
startup_mode = "Windowed"
opacity = 1
[window.dimensions]
columns = 100
lines = 85
@AntonC9018
AntonC9018 / .wezterm.lua
Last active March 3, 2024 12:30
Wezterm config
local wezterm = require 'wezterm'
local act = wezterm.action
local config = wezterm.config_builder()
config.use_dead_keys = false
-- https://github.com/wez/wezterm/discussions/5102
config.enable_kitty_keyboard = true
config.allow_win32_input_mode = false
@AntonC9018
AntonC9018 / Splitter.cs
Created August 30, 2023 19:11
Split that can be used on ReadOnlySpan<char> without allocations
public static class SpanExtensions
{
public static Splitter<T> Splitter<T>(
this ReadOnlySpan<T> span,
ReadOnlySpan<T> delimiter)
where T : IEquatable<T>
{
return new(span, delimiter);
}
@AntonC9018
AntonC9018 / Rename_Indices_ForeignKeyConstraints_ToEFCoreDefaults_CreateMissingDefaultIndices.sql
Last active August 9, 2023 19:12
Helper to reset some of the DB structure to EF Core defaults
create or alter procedure [dbo].[Rename_Indices_ForeignKeyConstraints_ToEFCoreDefaults_CreateMissingDefaultIndices]
as
begin
set nocount on;
declare namesCursor cursor for
select
names2.schemaName,
names2.tableName,
names2.otherTableName,
names2.columnName,
@AntonC9018
AntonC9018 / SetBitIndicesIterator.cs
Last active July 21, 2023 08:59
Iterator of set bit indices that reinterprets the indices as the specified enum
using System.Collections;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
// Enumerates the bits from highest to lowest
public struct SetBitIndicesIterator<T> : IEnumerator<T>
where T : struct, Enum
{
static SetBitIndicesIterator() =>
#nullable enable
using Microsoft.Extensions.DependencyInjection;
public static class ServiceRegistrationHelper
{
/// <summary>
/// Registers the given implementation type under all implementations of a generic service,
/// implemented by the given implementation type.
/// </summary>
/// <returns>True if at least one implementation has been registered</returns>
@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)