Skip to content

Instantly share code, notes, and snippets.

View makasim's full-sized avatar

Max Kotliar makasim

View GitHub Profile
@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
@makasim
makasim / docker-compose.yml
Last active March 20, 2020 11:23
Auto update telegram webhook url on docker compose up
version: '3.4'
services:
app:
image: 'formapro/nginx-php-fpm:latest-all-exts'
working_dir: '/app'
volumes:
- './:/app:cached'
env_file: '.env'
networks:
@makasim
makasim / traefik.toml
Created November 10, 2018 12:01
Secure Docker Registry with Traefik and LetsEncrypt 2
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[acme]
email = "admin@foobar.com"
@makasim
makasim / docker-compose.yml
Last active January 1, 2024 11:24
Secure Docker Registry with Traefik and LetsEncrypt
version: '3.1'
services:
registry:
restart: always
image: registry:2
volumes:
- registry:/var/lib/registry
environment:
- REGISTRY_HTTP_ADDR=0.0.0.0:5000
<?php
namespace Ecom\Price\Model;
use Makasim\Values\ValuesTrait;
class Price
{
use ValuesTrait;
/**