Skip to content

Instantly share code, notes, and snippets.

View dzmitry-lahoda's full-sized avatar

dzmitry-lahoda dzmitry-lahoda

View GitHub Profile
@ufcpp
ufcpp / UnsafeAsBenchmark.cs
Last active March 10, 2019 14:53
Unsafe.As is faster than TypedReference
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.CsProj;
using BenchmarkDotNet.Toolchains.DotNetCli;
using System;
using System.Runtime.CompilerServices;
[Config(typeof(MyConfig))]
@ufcpp
ufcpp / GCHandleReuse.cs
Created November 17, 2017 11:07
GCHandle の値、どこかのスロットのアドレスがたぶん帰ってきてる。かつ、Free したスロットは即座に再利用されてる
using System;
using System.Runtime.InteropServices;
class X { }
class Y { }
public class Program
{
static void Main()
{
PostgreSQL Type PostgreSQL Size Description Range Diesel Type Rust Type
Nullable Types nullable Nullable``
@nlohmann
nlohmann / remove_empty_elements.py
Created March 12, 2018 14:19
Remove empty arrays, objects or null elements from a JSON value
def remove_empty_elements(d):
"""recursively remove empty lists, empty dicts, or None elements from a dictionary"""
def empty(x):
return x is None or x == {} or x == []
if not isinstance(d, (dict, list)):
return d
elif isinstance(d, list):
return [v for v in (remove_empty_elements(v) for v in d) if not empty(v)]
@mutin-sa
mutin-sa / Top_Public_Recursive_Name_Servers.md
Last active May 19, 2025 02:50
List of Top Public Recursive Name Servers

DNS:

IPv4 Addr IPv6 Addr ASn Political Region Loc Svc Org
8.8.8.8 2001:4860:4860::8888 AS15169 US Worldwide (Anycast) Google Public DNS Google
8.8.4.4 2001:4860:4860::8844 AS15169 US Worldwide (Anycast) Google Public DNS Google
1.1.1.1 2606:4700:4700::1111 AS13335 US Worldwide (Anycast) Cloudflare-DNS Cloudflare/APNIC
1.0.0.1 2606:4700:4700::1001 AS13335 US Worldwide (Anycast) Cloudflare-DNS Cloudflare/APNIC
95.85.95.85 2a03:90c0:999d::1 AS199524 EU *W
@justinclayton
justinclayton / hack.tf
Created May 1, 2018 19:02
Terraform: conditionally reference a data source that may or may not exist
variable "yes" { default = true }
data "template_file" "maybe" {
count = "${ var.yes == false ? 0 : 1 }"
template = "YES"
}
output "maybe" {
value = "${ var.yes == false ? "" : element(concat(data.template_file.maybe.*.rendered, list("")), 0) }" # <-- :_(
}
@ufcpp
ufcpp / FixedArray.cs
Created May 2, 2018 06:51
固定長配列モドキ
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Runtime.CompilerServices;
public interface IFixedArray<T> { }
public interface IFixedArrayAccessor<T, TArray>
where TArray : struct, IFixedArray<T>
{
@attilah
attilah / X.Y.Z.Sources.csproj
Last active April 8, 2025 20:22
X.Y.Z.Sources nuget package
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
@dadhi
dadhi / Lens.cs
Last active February 23, 2024 09:41
Functional optics, e.g. Lens, in C# - to simplify access and modification for deep part of immutable value
/*
Inspired by: https://medium.com/@gcanti/introduction-to-optics-lenses-and-prisms-3230e73bfcfe
*/
using System;
using static System.Console;
public static class Program
{
public static void Main()