Skip to content

Instantly share code, notes, and snippets.

View dadhi's full-sized avatar
🎯
Focusing

Maksim Volkau dadhi

🎯
Focusing
View GitHub Profile
@stolnikov
stolnikov / CSharpBench.cs
Created December 15, 2023 07:39
Odin vs C#
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace CSharpLib;
public class CSharpBench
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int[] CSharp_Bench2(int[] a, int[] b, int[] result, int size)
@dadhi
dadhi / code.cs
Created July 16, 2022 19:25 — forked from hypeartist/code.cs
Type instantiation (.ctor with parameters)
object obj;
var r = 0;
const int cnt = 1000000;
var constructorInfo = typeof(Class).GetConstructor(new[] { typeof(int) })!;
var hCtor = constructorInfo.MethodHandle;
RuntimeHelpers.PrepareMethod(RuntimeMethodHandle.FromIntPtr(hCtor.Value));
var pCtor = (delegate* managed<object, int, void>)hCtor.GetFunctionPointer();
@hypeartist
hypeartist / code.cs
Created July 16, 2022 19:21
Type instantiation (.ctor with parameters)
object obj;
var r = 0;
const int cnt = 1000000;
var constructorInfo = typeof(Class).GetConstructor(new[] { typeof(int) })!;
var hCtor = constructorInfo.MethodHandle;
RuntimeHelpers.PrepareMethod(RuntimeMethodHandle.FromIntPtr(hCtor.Value));
var pCtor = (delegate* managed<object, int, void>)hCtor.GetFunctionPointer();
using System.IO.Pipelines;
using System.Net;
using System.Net.Security;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
var builder = WebApplication.CreateBuilder(args);
# urls
https://badgen.net/badge/support/UKRAINE/?color=0057B8&labelColor=FFD700
https://badgen.net/badge/stand%20with/UKRAINE/?color=0057B8&labelColor=FFD700
# embedded badge in github markdown
![stand with Ukraine](https://badgen.net/badge/support/UKRAINE/?color=0057B8&labelColor=FFD700)
![stand with Ukraine](https://badgen.net/badge/stand%20with/UKRAINE/?color=0057B8&labelColor=FFD700)
@jreviews
jreviews / htmx-loading-states-extension.md
Last active April 1, 2024 22:22
htmx loading states extension

htmx loading states extension

The loading-states extension allows you to easily manage loading states while a request is in flight, including disabling elements, and adding and removing CSS classes.

Using the extension

Add the hx-ext="loading-states" attribute to the body tag or to any parent element containing your htmx attributes.

Add the following class to your stylesheet to make sure elements are hidden by default:

@davidfowl
davidfowl / MinimalAPIs.md
Last active April 10, 2024 04:24
Minimal APIs at a glance
@mmozeiko
mmozeiko / shader.hlsl
Last active February 4, 2024 17:53
compute shader for rendering monospaced glyphs in grid
//
struct TerminalCell
{
// cell index into GlyphTexture, should be two 16-bit (x,y) values packed: "x | (y << 16)"
uint GlyphIndex;
// 0xAABBGGRR encoded colors, nonzero alpha for Foreground indicates to render colored-glyph
// which means use RGB values from GlyphTexture directly as output, not as ClearType blending weights
uint Foreground;
@vsraptor
vsraptor / bin-tree.rs
Last active June 22, 2023 16:46
Rust : Binary tree
//based on the discussion here https://gist.github.com/aidanhs/5ac9088ca0f6bdd4a370
// Binary tree implementation (simplified)
#![allow(dead_code)]
use std::string::String;
use std::cmp::PartialEq;
use std::cmp::PartialOrd;
struct BinTree<T> {
@ekuzmichev
ekuzmichev / ZLayerPlayground.scala
Last active June 9, 2020 12:48
ZIO ZLayer DI playground
import zio._
object ZLayerPlayground {
case class User(id: String, name: String)
class MongoDb {
def insertUser(user: User): Task[Unit] = Task.succeed(()) <* UIO(println(s"[MongoDb]: Inserted user $user"))
}
object MongoDbLayer {