Skip to content

Instantly share code, notes, and snippets.

View dadhi's full-sized avatar
🎯
Focusing

Maksim Volkau dadhi

🎯
Focusing
View GitHub Profile
@dadhi
dadhi / latency.txt
Created April 14, 2021 11:18 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dadhi
dadhi / PackRef.md
Created November 23, 2020 20:47
Control PackageReference

NuGet/Home#5986 (comment)

I've found that you can manually control which .dlls to reference and which .dlls to copy to output from a NuGet package if you turn off all assets on the PackageReference:

<PackageReference Include="Foo.MyPackage" Version="1.0.0" ExcludeAssets="all" GeneratePathProperty="true" />

and then manually reference the .dlls you need:

@dadhi
dadhi / markdown-details-collapsible.md
Created August 20, 2020 16:56 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@dadhi
dadhi / X.Y.Z.Sources.csproj
Created July 22, 2020 06:41 — forked from attilah/X.Y.Z.Sources.csproj
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 / DryIoc_Issue293.csx
Last active July 19, 2020 12:29
DryIoc issue #293: ServiceKey and ServiceProvider
/*
Execute me as:
```
dotnet tool install dotnet-script
dotnet sctipt https://tinyurl.com/yylj3vcp
```
```cs */
#r "nuget: Microsoft.Extensions.DependencyInjection, 2.2.0"
#r "nuget: Microsoft.Extensions.Options, 1.0.0"
@dadhi
dadhi / RemoveBinObj.ps
Created July 1, 2020 09:56
Remove Cleanup Obj and Bin folders powershell script
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
@dadhi
dadhi / ZLayerPlayground.scala
Created June 9, 2020 12:48 — forked from ekuzmichev/ZLayerPlayground.scala
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 {
@dadhi
dadhi / Demo.csproj
Last active May 8, 2020 05:39 — forked from danielcrenna/Demo.csproj
DI Source Generator
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-preview.3.20215.2" />
</ItemGroup>
<ItemGroup>
@dadhi
dadhi / SpinWait.cs
Created January 8, 2020 11:07
Better SpinWait
/*
sources:
- http://www.adammil.net/blog/v111_Creating_High-Performance_Locks_and_Lock-free_Code_for_NET_.html
- http://badamczewski.blogspot.com/2012/08/lock-free-and-spinwait-msdn-example.html
A better spin lock:
The result is a spin lock that's quite fast — about twice as fast as locking with a Monitor (or the C# lock statement).
(It can be further sped up slightly by breaking the Enter method into two methods: Enter,