Skip to content

Instantly share code, notes, and snippets.

View cristaloleg's full-sized avatar
🇺🇦
still I can't believe it's me

Oleg Kovalov cristaloleg

🇺🇦
still I can't believe it's me
View GitHub Profile
@cristaloleg
cristaloleg / golangci.yaml
Created March 28, 2023 07:01
Go linters configuration, the right version.
# See: https://olegk.dev/go-linters-configuration-the-right-version
run:
# Depends on your hardware, my laptop can survive 8 threads.
concurrency: 8
# I really care about the result, so I'm fine to wait for it.
timeout: 30m
# Fail if the error was met.
@cristaloleg
cristaloleg / the_best_ba.sh
Created November 24, 2022 22:30
Bash best practices
#!/usr/bin/env bash
set -Eeuxo pipefail
set -o errexit
set -o nounset
set -o pipefail
trap "echo ERR trap fired!" ERR
olegkovalov@oleg-mbp membrane_videoroom % docker build -t membrane_videoroom_advanced .
olegkovalov@oleg-mbp membrane_videoroom % docker run -p 50000-50050:50000-50050/udp -p 4000:4000/tcp --env-file .env membrane_videoroom_advanced
ck_ip: {127, 0, 0, 1}, ports_range: {50000, 59999}, cert_file: nil], telemetry_label: [room_id: "1", peer_id: "4b8088d9-61c3-4d52-b679-4e02e079a4f3"]}, pid: #PID<0.2420.0>, playback_sync: :not_synced, spec_ref: #Reference<0.2131086919.1186463745.240205>, sync: :membrane_no_sync, terminating?: false}
07:31:16.060 [debug] [:endpoint_bin bin] Initializing playback state :stopped %Membrane.ChildEntry{clock: nil, component_type: :element, module: Membrane.Funnel, name: :ice_funnel, options: %Membrane.Funnel{end_of_stream: :on_last_pad}, pid: #PID<0.2426.0>, playback_sync: :not_synced, spec_ref: #Reference<0.2131086919.1186463745.240205>, sync: :membrane_no_sync, terminating?: false}
07:31:16.060 [debug] [:endpoint_bin bin] Ini
@cristaloleg
cristaloleg / lol.txt
Created November 3, 2021 22:40
init hugo
❯ GODEBUG=inittrace=1 ./hugo > lol.txt
init internal/bytealg @0.032 ms, 0 ms clock, 0 bytes, 0 allocs
init runtime @2.5 ms, 2.5 ms clock, 0 bytes, 0 allocs
init errors @6.6 ms, 0.45 ms clock, 0 bytes, 0 allocs
init internal/oserror @7.1 ms, 0.006 ms clock, 80 bytes, 5 allocs
init sync @7.1 ms, 0.003 ms clock, 16 bytes, 1 allocs
init syscall @7.1 ms, 0.57 ms clock, 752 bytes, 2 allocs
init time @7.7 ms, 2.5 ms clock, 400 bytes, 8 allocs
init path @10 ms, 0.005 ms clock, 16 bytes, 1 allocs
init io @10 ms, 0.003 ms clock, 144 bytes, 9 allocs
@cristaloleg
cristaloleg / golangci.yaml
Last active July 15, 2022 17:03
An opinionated golangci-lint config (right version™)
# $ golangci-lint run --config=~/.golangci.yml ./... > lint.txt
run:
# default concurrency is a available CPU number
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
# exit code when at least one issue was found, default is 1
@cristaloleg
cristaloleg / full-github-org-clone.sh
Last active March 28, 2023 09:06
Full Github organization clone
#!/bin/bash
# Usage: ./script NAME MAX-PAGE-NUMBER REGEX-PATTERN
#
# Also curl, jq and git are required.
#
# Author: https://gist.github.com/cristaloleg
#
# Based on https://gist.github.com/erdincay/4f1d2e092c50e78ae1ffa39d13fa404e
$ benchstat old.txt new.txt
name old time/op new time/op delta
EDSA/Sign-EdDSA-8 57.6µs ± 2% 57.2µs ± 4% ~ (p=0.218 n=10+10)
EDSA/Verify-EdDSA-8 140µs ± 2% 140µs ± 1% ~ (p=0.546 n=9+9)
ES/Sign-ES256-8 30.9µs ± 1% 34.9µs ±26% ~ (p=0.739 n=10+10)
ES/Verify-ES256-8 82.5µs ± 2% 83.0µs ± 3% ~ (p=0.971 n=10+10)
ES/Sign-ES384-8 4.80ms ± 1% 4.81ms ± 1% ~ (p=0.842 n=9+10)
ES/Verify-ES384-8 9.71ms ± 1% 9.54ms ± 2% -1.80% (p=0.001 n=7+10)
ES/Sign-ES512-8 8.43ms ± 1% 8.38ms ± 1% -0.56% (p=0.013 n=10+9)
ES/Verify-ES512-8 15.6ms ± 2% 15.5ms ± 4% ~ (p=0.400 n=9+10)
goos: darwin
goarch: amd64
pkg: github.com/cristalhq/jwt/v2
BenchmarkEDSA
BenchmarkEDSA/Sign-EdDSA
BenchmarkEDSA/Sign-EdDSA-8 18717 62351 ns/op 1056 B/op 13 allocs/op
BenchmarkEDSA/Verify-EdDSA
BenchmarkEDSA/Verify-EdDSA-8 8041 145674 ns/op 292 B/op 2 allocs/op
BenchmarkES
BenchmarkES/Sign-ES256
# build stage
FROM golang:alpine AS builder
WORKDIR /go/src/github.com/foo/bar
COPY go.mod .
COPY go.sum .
RUN apk add --no-cache git
RUN go mod download
Starting prometheus ... error
ERROR: for prometheus Cannot start service prometheus: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/olegkovalov/go/src/github.com/unytehq/unyte/prometheus.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/023fcb75c07e827bf056f8923477e70478a1634465d0cc5116cb2de5d431ce0c/merged\\\" at \\\"/var/lib/docker/overlay2/023fcb75c07e827bf056f8923477e70478a1634465d0cc5116cb2de5d431ce0c/merged/etc/prometheus/prometheus.yml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for prometheus Cannot start service prometheus: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/olegkovalov/go/src/github.com/unytehq/unyte/pr