Skip to content

Instantly share code, notes, and snippets.

@tdakkota
tdakkota / call_test.go
Last active August 9, 2021 13:22
E2E call DH initialization test
package e2etest
import (
"context"
"crypto/sha1"
"crypto/sha256"
"encoding/binary"
"math/big"
"strconv"
"testing"
@tdakkota
tdakkota / e2e_test.go
Created August 6, 2021 09:14
E2E encryprtion test
package e2etest
import (
"context"
"crypto/rand"
"crypto/sha1"
"encoding/binary"
"io"
"math/big"
"strconv"
@tdakkota
tdakkota / povezlo_povezlo.txt
Created June 30, 2021 14:31
повезло повезло
cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
BenchmarkEncode
BenchmarkEncode/Original
BenchmarkEncode/Original-12 198959738 6.091 ns/op 0 B/op 0 allocs/op
BenchmarkEncode/Inline
BenchmarkEncode/Inline-12 252104388 4.651 ns/op 0 B/op 0 allocs/op
BenchmarkEncode/Expand
BenchmarkEncode/Expand-12 137883550 8.575 ns/op 0 B/op 0 allocs/op
BenchmarkEncode/Optimized
BenchmarkEncode/Optimized-12 320572156 3.725 ns/op 0 B/op 0 allocs/op
package main
import (
"fmt"
"net/http"
)
type HList interface {
hlist()
}
@tdakkota
tdakkota / same_type.go
Last active October 11, 2021 06:03
Compare two generic types in go2go. https://go2goplay.golang.org/p/WWTcvX9lDWH
package main
import (
"bytes"
"fmt"
"io"
)
type wrap[T any] struct{}
package main
import (
"fmt"
"go/ast"
"go/token"
"os"
"strings"
builders "github.com/tdakkota/astbuilders"
@tdakkota
tdakkota / lfu.go
Last active November 2, 2020 15:11
LFU Cache written in Go2. Playground: https://go2goplay.golang.org/p/qFlA5TGqxHb
package main
type CacheNode[K, V any] struct {
key K
value V
prev *CacheNode[K, V]
next *CacheNode[K, V]
parent *FreqNode[K, V]
}
var id = 1;
var users = [];
var i = 0;
while(i < 25) {
var req = API.groups.getMembers({"group_id":id,"count":1000,
"offset":i*1000,"fields":"sex, bdate, city, country, photo_50, photo_100, photo_200_orig, photo_200, photo_400_orig, photo_max, photo_max_orig, online, online_mobile, lists, domain, has_mobile, contacts, connections, site, education, universities, schools, can_post, can_see_all_posts, can_see_audio, can_write_private_message, status, last_seen, common_count, relation, relatives"});
users.push(req.items);
i = i + 1;
}
@tdakkota
tdakkota / greka.hs
Last active July 9, 2020 10:36
приключения греки, описанные на лучшем в мире языке
через :: a -> a
через a = a
греку :: a -> a
греку a = a
в :: a -> a
в a = a
реке :: a -> a
package main
import (
"fmt"
)
type Context struct {
Max int
Max7 int
}