Skip to content

Instantly share code, notes, and snippets.

View divan's full-sized avatar

Ivan Danyliuk divan

View GitHub Profile
@divan
divan / main.go
Created February 17, 2023 22:05
edgedb-delete-checker
package main
import (
"flag"
"fmt"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"sort"
@divan
divan / Makefile
Last active December 25, 2022 14:26
Make help
.PHONY: help
# This is a code for automatic help generator.
# It supports ANSI colors and categories.
# To add new item into help output, simply add comments
# starting with '##'. To add category, use @category.
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
@divan
divan / benchmark.txt
Created September 18, 2017 20:19
Branch prediction Go
$ go test -test.bench .
BenchmarkLoop-4 10000 146857 ns/op
BenchmarkLoopSorted-4 100000 19901 ns/op
PASS
ok test/branch 3.706s
@divan
divan / main.go
Created March 21, 2017 15:01
Golang database/sql+http example (postgres)
// Run PostgreSQL server:
// docker run -e POSTGRES_PASSWORD="" -p 5432:5432 postgres
// Monitor running processes:
// watch -n 1 'echo "select pid,query_start,state,query from pg_stat_activity;" | psql -h localhost -U postgres
//
// For all handlers, call to db takes 5 seconds,
//
// Three endpoints:
// - "/" - take 5 seconds
// - "/ctx" - take 1 seconds, due to 1 second cancellation policy
### Keybase proof
I hereby claim:
* I am divan on github.
* I am ivandaniluk (https://keybase.io/ivandaniluk) on keybase.
* I have a public key ASApyXdCqP1m8QKvieOB9yRosaGKzbIGhZQk86dFd_b8qgo
To claim this, I am signing this object:
package funcptr
import "testing"
type LargeStruct struct {
f1, f2, f3, f4, f5, f6, f7, f8, f9, f10 uint64
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uint64
b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 uint64
c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 uint64
d1, d2, d3, d4, d5, d6, d7, d8, d9, d10 uint64