Skip to content

Instantly share code, notes, and snippets.

func BenchmarkJSON(b *testing.B) {
for i := 0; i < b.N; i++ {
obj := Object{}
if err := json.Unmarshal(testCase, &obj); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkFastJSON(b *testing.B) {
@powerman
powerman / create-local-CA.md
Last active May 7, 2024 01:23
Create local CA to issue localhost HTTPS certificates

Create local CA to issue localhost HTTPS certificates

You can check How to securely test local/staging HTTPS project for more details about required setup or just follow instructions below.

WARNING: You'll need to run these commands just once, don't run them again if you already did this before for some other project.

MacOS users should first prepare OpenSSL package:

--- /tmp/westmore.flags 2020-05-30 12:25:20.909340358 +0300
+++ /tmp/haswell.flags 2020-05-30 12:25:34.182340758 +0300
+abm
-aes
+cpuid_fault
-dca
+ept_ad
+erms
+fsgsbase
-ida
@powerman
powerman / chan_queue.go
Created June 20, 2021 16:35
Helper for buffering data from non-blocking channel for sending into blocking channel
// Usage example:
func process(in <-chan Msg, outBlocking chan<- Msg) {
out := newQueueMsg(QueueSize, outBlocking)
for {
select {
case msg := <-in:
out.append(msg)
case out.C <- out.Elem:
out.del()
}
@powerman
powerman / OAuth 2.0.adoc
Created June 25, 2022 18:34
Recommendations on secure implementation of OAuth 2.0 (server and client)

OAuth 2.0

Table of Contents

Abstract