This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// org.apache.tuweni:tuweni-crypto:2.0.0 | |
import org.apache.tuweni.bytes.Bytes | |
import org.apache.tuweni.crypto.Hash | |
import org.apache.tuweni.crypto.SECP256K1 | |
import org.bouncycastle.jce.provider.BouncyCastleProvider | |
import org.slf4j.LoggerFactory | |
import java.security.Security | |
import java.time.Clock | |
import java.time.Duration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thriveglobal.reset | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.datetime.Clock | |
import kotlinx.datetime.Instant | |
import org.slf4j.LoggerFactory | |
import java.io.Closeable | |
import java.util.concurrent.LinkedBlockingDeque | |
import kotlin.time.Duration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type NoEarlyReturn() = | |
member _.Return x = [x] | |
member _.Combine (x, y) = x @ y | |
member _.Delay f = f() | |
let wtf = NoEarlyReturn() | |
wtf { | |
return 1 | |
return 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Collections.Generic | |
[<Struct>] | |
type DictBuilder<'a, 'b when 'a: equality> = | |
val d: Dictionary<'a,'b> | |
new(()) = { d = Dictionary<'a, 'b>() } | |
member this.Yield (key, value) = | |
this.d.Add(key, value) | |
member this.Zero() = this.d | |
member _.Combine(_, _) = () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Hopac" | |
open System | |
open System.Threading | |
open Hopac | |
// ------- IMPLEMENTATION ------- | |
type IQueue<'a> = | |
abstract member Dequeue: Alt<'a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object CustomDeserToTheRescue : | |
ApplicationFeature<ApplicationCallPipeline, Unit, CustomDeserToTheRescue> { | |
override val key: AttributeKey<CustomDeserToTheRescue> = AttributeKey("CustomDeserToTheRescue") | |
override fun install( | |
pipeline: ApplicationCallPipeline, | |
configure: Unit.() -> Unit | |
): CustomDeserToTheRescue { | |
pipeline.receivePipeline.intercept(ApplicationReceivePipeline.Transform) { receive -> | |
// skip if already transformed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
import java.util.UUID | |
// java.util.UUID.fromString doesn't enforce string representation of UUID https://www.ietf.org/rfc/rfc4122.txt | |
// It requires 4 '-' to present with any hex numbers in between. So it treats 1-1-1-1-1 as a valid UUID | |
// I don't think it's valid string representation of UUID. RFC4122 also doesn't think so | |
// Open JDK bug: https://bugs.openjdk.java.net/browse/JDK-8216407 | |
// That's why we have our own UUID parser here | |
// Taken from here https://github.com/openjdk/jdk/blob/f485171ce8c7e9c9d7d2c24e1807efaa6ff137e8/src/java.base/share/classes/java/util/UUID.java#L212-L259 | |
// But without "wrong" part |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Channels; | |
using System.Threading.Tasks; | |
public static class TaskExt | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Microsoft.AspNetCore | |
open Microsoft.AspNetCore.Hosting | |
open Giraffe | |
WebHost | |
.CreateDefaultBuilder() | |
.UseKestrel() | |
.Configure(fun a -> a.UseGiraffe(route "/" >=> POST >=> bindJson json)) | |
.ConfigureServices(fun s -> s.AddGiraffe() |> ignore) | |
.Build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Buffers; | |
using System.Globalization; | |
using System.Text; | |
using BenchmarkDotNet; | |
using BenchmarkDotNet.Attributes; | |
namespace BenchmarkSuite1 | |
{ | |