Skip to content

Instantly share code, notes, and snippets.

View nikandfor's full-sized avatar

Nikifor Seriakov nikandfor

View GitHub Profile
// I would changed this
for b.Loop() {
w := words[i]
tree.Insert(w, w)
if i == size-1 {
tree = art.NewAlphaSortedTree[[]byte, []byte]()
}
i = (i + 1) % size
}
SELECT
f_login,
min(day) AS d,
max(day) AS last,
groupUniqArray(repo) AS repos
FROM stars
WHERE login = 'filapro'
GROUP BY ALL
ORDER BY d ASC
package benchmark
import (
"bytes"
"testing"
)
const (
bsN = 1000
p1N = 4

I agree with the previous comment, switching the language won't help you with the situation in general. It's absolutely natural situation when your codebase becomes bad as the project evolves, especially when you just start it. The solution to that is to grab all the knowledge and understanding of the system and just rewrite it from scratch redesigning things according to a fresh model. I'm doing RnD professionally for more than 10 years and anyway I need 4-5 iterations of nearly full rewrite to achieve fine result, and 2-3 times more to get something near the optimal solution. This is just natural process.

For sure C adds some complexity by memory management, but it also disciplines you and even suggests how to organize your code. The pattern to free the resource in the same place you acquired it is a very good and useful. It not only applies to memory, but also to opening files, network connections, mutexes, and many other things. If Go save you (with a cost) from freeing memory, it won't save you from eve

# old style data, before Timeline moved to devices
$ cat Timeline.json | jq -c '.semanticSegments[].timelinePath[]?' | head
{"point":"55.7060442°, 37.5081516°","time":"2011-12-11T16:37:00.000+01:00"}
{"point":"55.7060303°, 37.5081599°","time":"2011-12-12T07:09:00.000+01:00"}
{"point":"55.7054305°, 37.5150152°","time":"2011-12-12T07:18:00.000+01:00"}
{"point":"55.700644°, 37.525313°","time":"2011-12-12T07:22:00.000+01:00"}
{"point":"55.700627°, 37.533557°","time":"2011-12-12T09:05:00.000+01:00"}
{"point":"55.7010704°, 37.5690199°","time":"2011-12-12T10:00:00.000+01:00"}
{"point":"55.6979375°, 37.5410527°","time":"2011-12-12T10:12:00.000+01:00"}
{"point":"55.7010704°, 37.5690199°","time":"2011-12-12T10:24:00.000+01:00"}
package main
import (
"bytes"
"fmt"
)
func main() {
r1 := f1("key", 1)
fmt.Println("first ", r1)
#include <coroutine>
#include <seastar/core/coroutine.hh>
#include <seastar/core/app-template.hh>
#include <seastar/core/reactor.hh>
#include <seastar/net/api.hh>
#include <seastar/net/inet_address.hh>
#include <seastar/net/dns.hh>
namespace ss = seastar;
# results of https://github.com/nikandfor/fifo/blob/79666f84bc24cfcf939a3eb7179219b6114851b8/slice_vs_sll_test.go
% gotip test -bench .
goos: darwin
goarch: arm64
pkg: github.com/nikandfor/fifo
BenchmarkFIFOPush-8 340634864 3.141 ns/op 12 B/op 0 allocs/op
BenchmarkFIFOPop-8 142949896 10.79 ns/op 0 B/op 0 allocs/op
BenchmarkFIFO10Cycles-8 10714357 116.7 ns/op 75 B/op 0 allocs/op
BenchmarkQueueSlicePush-8 261353589 5.114 ns/op 42 B/op 0 allocs/op
@nikandfor
nikandfor / listen.go
Last active May 21, 2021 17:34
Stop blocked goroutine
type Node struct {
p net.PacketConn
stopc chan struct{}
}
func (n *Node) listener() (err error) {
var buf [0x10000]byte
for {
package main
import (
"fmt"
"log"
"math/rand"
"time"
)
type (