Skip to content

Instantly share code, notes, and snippets.

dadhi / latency.txt
Created Apr 14, 2021 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
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 /
Created Nov 23, 2020
Control PackageReference

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:

<Reference Include="$(PkgFoo_MyPackage)\lib\net45\CopyThis.dll">
dadhi /
Created Aug 20, 2020 — forked from pierrejoubert73/
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!


  1. A numbered
  2. list
    • With some
    • Sub bullets
dadhi / X.Y.Z.Sources.csproj
Created Jul 22, 2020 — forked from attilah/X.Y.Z.Sources.csproj
X.Y.Z.Sources nuget package
View X.Y.Z.Sources.csproj
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
dadhi / DryIoc_Issue293.csx
Last active Jul 19, 2020
DryIoc issue #293: ServiceKey and ServiceProvider
View DryIoc_Issue293.csx
Execute me as:
dotnet tool install dotnet-script
dotnet sctipt
```cs */
#r "nuget: Microsoft.Extensions.DependencyInjection, 2.2.0"
#r "nuget: Microsoft.Extensions.Options, 1.0.0"
dadhi /
Created Jul 1, 2020
Remove Cleanup Obj and Bin folders powershell script
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
View ZLayerPlayground.scala
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 / Demo.csproj
Last active May 8, 2020 — forked from danielcrenna/Demo.csproj
DI Source Generator
View Demo.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-preview.3.20215.2" />
dadhi / SpinWait.cs
Created Jan 8, 2020
Better SpinWait
View SpinWait.cs
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,