Skip to content

Instantly share code, notes, and snippets.

@makasim
makasim / main.go
Created September 2, 2025 06:38
Collect CPU,Memory,GC stats and print them to stdout
func main() {
go func() {
for {
m := stats.Measure()
time.Sleep(time.Minute)
m()
}
}()
}
@makasim
makasim / Cluster-VictoriaMetrics.txt
Last active August 26, 2025 16:02
Syncronize flags in docs from binaries
### List of command-line flags for vminsert
Below is the output for `/path/to/vminsert -help`:
{{% content "vminsert_flags.md" %}}
@makasim
makasim / README.md
Last active August 21, 2025 20:55
Weak pointer based labels compressor

Everytime we create a new key we increment usedBy on every label that is included in that key. Every time the weak key is garbage collected (checked in cleanup func) we decrement usedBy. When usedBy reaches zero it means nobody uses the label and we can safely remove it and remove the key.

The key can decompress itself using unsafe pointer dereference, see Key.Decompress func.

This is basically a workaround for missing slice comparable customization. Once go has one the code could be simplified a lot.

@makasim
makasim / 8704.md
Last active April 14, 2025 12:47
8704: Reproducing unexpected EOF on vmagent
@makasim
makasim / example.go
Last active April 29, 2024 17:56
Deterministic ULID generation from int64 in #golang
package main
import (
"fmt"
"time"
"intulid"
"github.com/oklog/ulid/v2"
)
func numIslands(grid [][]byte) int {
if len(grid) == 0 {
return 0
} else if len(grid[0]) == 0 {
return 0
}
cols := len(grid)
rows := len(grid[0])
var islands int
@makasim
makasim / TelegramHandler.php
Last active May 31, 2019 20:05
A monolog telegram handler that does not have negative impact on response time. Compose log records in a single message. Do not crush if telegram down
<?php
declare(strict_types=1);
namespace App\Infra\Monolog;
use GuzzleHttp\Client;
use Monolog\Handler\AbstractProcessingHandler;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\ConsoleEvents;
<?php declare(strict_types=1);
namespace App\Infra\Symfony;
use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
class FileOrContentEnvVarProcessor implements EnvVarProcessorInterface
{
@makasim
makasim / structures.go
Created March 30, 2019 13:11
gocv. connected structures size algo
package app
import (
"gocv.io/x/gocv"
"image"
"sort"
)
type RefMat struct {
cols int
@makasim
makasim / dump-db.sh
Last active February 1, 2019 14:28
Dump any mongo database and restore it with only Docker. restore-local-db could restore a dump to mongo running in a container
if (( "$#" != 1 ))
then
echo Host is required!
exit
fi
PROJECT_NAME=${PWD##*/}
mkdir -p dump