Skip to content

Instantly share code, notes, and snippets.

View makasim's full-sized avatar

Max Kotliar makasim

View GitHub Profile
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;
/**
@makasim
makasim / pvm_context.json
Last active July 17, 2018 07:10
pvm_context.json
{
"process": {
"schema": "http:\/\/pvm.forma-pro.com\/schemas\/Process.json",
"id": "749d7410-e1b0-4f27-aa35-97d09018754e",
"companyId": "12356692-eaac-4893-8e5d-9c2059fb4689",
"campaignId": "3569b06f-2210-48f4-853d-9a0d35c08182",
"nodes": {
"ad2fcc3c-ee83-40cc-9d76-cdb21d573098": {
"schema": "http:\/\/pvm.forma-pro.com\/schemas\/Node.json",
"id": "ad2fcc3c-ee83-40cc-9d76-cdb21d573098",