Skip to content

Instantly share code, notes, and snippets.

View nobbynobbs's full-sized avatar
👀
who's there?

Roman nobbynobbs

👀
who's there?
  • Nizhny Novgorod, Russia
View GitHub Profile
@nobbynobbs
nobbynobbs / stats.sql
Created June 23, 2022 17:41
postgres stats
SELECT
relname AS "relation",
C .reltuples::bigint AS approximate_rows,
pg_size_pretty (
pg_total_relation_size (C .oid)
) AS "data_size",
pg_size_pretty (
pg_indexes_size(C .oid)
) as "indexes_size",
pg_size_pretty (
@nobbynobbs
nobbynobbs / docker-compose.yaml
Created May 22, 2022 09:13
kafka and kafka-ui, without zookeeper
version: '2.4'
services:
kafka:
image: bitnami/kafka:3.1.0
container_name: kafka
command:
- 'sh'
- '-c'
- '/opt/bitnami/scripts/kafka/setup.sh && kafka-storage.sh format --config "$${KAFKA_CONF_FILE}" --cluster-id "lkorDA4qT6W1K_dk0LHvtg" --ignore-formatted && /opt/bitnami/scripts/kafka/run.sh' # Kraft specific initialise
environment:
@nobbynobbs
nobbynobbs / Jenkinsfile
Last active May 9, 2023 20:32
example of sidecar service in jenkins declarative pipeline
pipeline {
agent { label "docker" }
stages {
stage("test sidecar") {
steps{
script {
withDockerNetwork { n ->
// we could use Image.withRun() instead of Image.run(),
// and get rid of try/catch/finally blocks
// It's prefferable way, but it doesn't remove volumes after containers
@nobbynobbs
nobbynobbs / generic_descriptors.py
Created October 31, 2020 11:52
generic descriptor and inheritance
from typing import (
Generic, Optional, TYPE_CHECKING,
Type, TypeVar, Union, overload,
)
T = TypeVar("T", bound="A") # noqa
class Descr(Generic[T]):
@overload
import math
import signal
from concurrent.futures import ProcessPoolExecutor
from contextlib import suppress
from time import sleep
values = [40000000, 30000000, 20000000, 10000000]
PRIMES = [
112272535095293,
from typing import Dict, Any, List
import abc
class Repository(abc.ABC):
def __init__(self, model):
self.model = model # or connection pool
def create_one(self, data: Dict[str, Any]):
item = self.model.from_dict(data)
@nobbynobbs
nobbynobbs / test_ws_in_twisted.py
Last active April 6, 2020 06:46
py27, twisted, autobahn
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import
import base64
import pytest
import pytest_twisted
@nobbynobbs
nobbynobbs / install_geospatial_libs.sh
Last active November 10, 2019 13:51
how to install geospatial libraries for python on ubuntu 18.04 (GDAL, mapnik)
# GDAL
sudo apt install gdal-bin libgdal-dev
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="-I/usr/include/gdal"
# MAPNIK
sudo apt install mapnik-utils libmapnik-dev libboost-all-dev
mapnik-config -v # check mapnik version
@nobbynobbs
nobbynobbs / store_parser.py
Last active October 22, 2019 15:17
simple parser
import pprint
from collections import namedtuple
# fields names mapping
fields = {
"Название": "name",
"Сорт": "sort",
"Цена": "price",
"Картинка": "image",
}
@nobbynobbs
nobbynobbs / main.py
Created June 17, 2019 08:58
logging example
import logging
import requests
# init simpliest custom logger
logger = logging.getLogger("myAwesomeLogger")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())