Skip to content

Instantly share code, notes, and snippets.

View tarampampam's full-sized avatar
🍻
go test && go build && go drink-beer

Pаramtamtām tarampampam

🍻
go test && go build && go drink-beer
View GitHub Profile
@tarampampam
tarampampam / middleware.go
Last active October 12, 2025 20:26
Golang HTTP middleware for dealing with Server-Timing header
// Package serverTiming implements a small Server-Timing middleware and helpers to measure named timings during HTTP
// request handling and emit them as the `Server-Timing` response header as specified by the Performance API.
package serverTiming
import (
"bufio"
"context"
"errors"
"fmt"
"maps"
@tarampampam
tarampampam / README.md
Last active September 22, 2025 16:08
Resolve public IP in Golang

Small, dependency-free Go helper to discover your machine’s public IPv4 quickly and reliably. It races three strategies under a short overall timeout and returns the first winner:

  • OpenDNS (myip.opendns.com A lookup via OpenDNS resolvers)
  • Google DNS (TXT on o-o.myaddr.l.google.com via Google authoritative NS)
  • HTTP (plain-text IP from several well-known endpoints)

Each strategy is isolated with short dial/read timeouts and early cancellation. You can supply your own resolvers and tweak the overall budget via functional options.

Usage example

@tarampampam
tarampampam / .gitlab-ci.yml
Created May 6, 2024 09:04
FFmpeg static binary build using docker
# GitLab CI help: <https://docs.gitlab.com/ee/ci/yaml/>
# GitLab environments: <https://docs.gitlab.com/ee/ci/variables/>
variables:
GITLAB_IMAGE: $CI_REGISTRY_IMAGE
GITHUB_IMAGE: ...
stages:
- build
@tarampampam
tarampampam / run.bash
Created December 15, 2023 08:31
Enable dark mode on linux, including Google Chrome
$ gsettings get org.gnome.desktop.interface color-scheme
# default
$ gsettings set org.gnome.desktop.interface color-scheme prefer-dark
@tarampampam
tarampampam / handlers.go
Last active January 6, 2023 10:25
Golang simple RPC client/server
package rpc
type (
API struct{}
LivenessArgs struct{}
LivenessReply struct{ Ok bool }
)
// NewAPI returns a new API instance.
@tarampampam
tarampampam / syncmap.go
Last active December 2, 2024 08:00
Golang SyncMap (sync.Map with generics, type-safe)
package syncmap
import "sync"
// SyncMap is like a Go sync.Map but type-safe using generics.
//
// The zero SyncMap is empty and ready for use. A SyncMap must not be copied after first use.
type SyncMap[K comparable, V any] struct {
mu sync.Mutex
m map[K]V
@tarampampam
tarampampam / disable-grub-timeout-mint20.md
Last active January 9, 2024 11:58
Disabling grub timeout (Linux Mint 20.x and older)

Edit file:

$ sudo nano /etc/default/grub

Set (update) next values:

GRUB_DEFAULT=0
@tarampampam
tarampampam / fix-no-sound-after-suspending-mint.md
Last active January 9, 2024 11:59
Fixing "no sound after suspending" error for Linux Mint on Xiaomi Notebook 15 pro

Fast checking

After suspending (when your system cannot play any sounds) try to execute in your terminal (after sudo su):

$ lspci -D | grep -i Audio | awk '{print $1}'

And then:

@tarampampam
tarampampam / change-dirs-locale-mint.md
Last active January 9, 2024 11:59
Change locale of the /home/user/ directories

Actual for linux mint 18.3 and others

Source: https://askubuntu.com/a/465679

$ echo 'en_US' > ~/.config/user-dirs.locale
$ LANG=C xdg-user-dirs-update --force