Skip to content

Instantly share code, notes, and snippets.

View nikandfor's full-sized avatar

Nikifor Seriakov nikandfor

View GitHub Profile
@nikandfor
nikandfor / a.c
Last active November 18, 2015 17:25
c complex
#include <stdio.h>
#include <complex.h>
int main(){
complex double x = 3 + 4 * I;
printf("x: %.3lf %.3lf\n", creal(x), cimag(x));
return 0;
}
@nikandfor
nikandfor / cowsay.txt
Created October 6, 2016 22:27
working late
nik@nik-msi@01:24:41:plutos$ echo "we need to go deeper" | cowthink -n -f sodomized-sheep | cowthink -w -n -f head-in | cowthink -n -f flaming-sheep | cowthink -n -f tux
_________________________________________
( _____________________________________ )
( ( ____________________________ ) )
( ( ( ______________________ ) ) )
( ( ( ( we need to go deeper ) ) ) )
( ( ( ---------------------- ) ) )
( ( ( o __ ) ) )
( ( ( o (oo) ) ) )
( ( ( o ( ) ) ) )
@nikandfor
nikandfor / leveldb_growth.go
Created December 15, 2016 16:42
leveldb bugous behaviour example
/*
This is example of strange goleveldb behaviour
Run as this:
$ cd $GOPATH/src/github.com/syndtr/goleveldb && git log --max-count=1 --pretty=oneline
6b4daa5362b502898ddf367c5c11deb9e7a5c727 all: fix documentation
$ go version
go version go1.8beta1 linux/amd64
$ go run ~/leveldb.go -sizecheck 1s -N 5000000 -path /tmp/ram/test_1 -op gen
2016/12/15 18:53:18 db size 8.5 kB. current i (keys passed): 0
@nikandfor
nikandfor / bench_res.md
Last active April 28, 2017 17:08
MarshalJSON uint64 benchmarks
=== RUN   TestRaw
--- PASS: TestRaw (0.00s)
BenchmarkStrconv-8   	30000000	        44.1 ns/op	       7 B/op	       1 allocs/op
BenchmarkFmt-8       	10000000	       127 ns/op	      16 B/op	       2 allocs/op
BenchmarkRaw-8       	50000000	        30.0 ns/op	       7 B/op	       1 allocs/op
PASS
ok  	command-line-arguments	4.298s
func BenchmarckFuncA(b *testing.B) {
var res int
for i := 0; i < b.N; i++ {
res = funcA(i)
}
_ = res
}
package main
import (
"time"
)
func main() {
tick := time.NewTicker(time.Second / 10)
defer tick.Stop()
for {
package main
import (
"io/ioutil"
"os"
"testing"
"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/options"
"github.com/stretchr/testify/assert"
package main
import (
"fmt"
"log"
"math/rand"
"time"
)
type (
@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 {
# 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