Skip to content

Instantly share code, notes, and snippets.

View abduakhatov's full-sized avatar
🏠
Working from home

Shohruh abduakhatov

🏠
Working from home
View GitHub Profile
@abduakhatov
abduakhatov / output.sh
Created April 8, 2023 07:10
Transport protocol with SSL in asyncio
openssl genrsa -out root-ca.key 2048
openssl req -x509 -new -nodes -key root-ca.key -days 365 -out root-ca.crt
python3 ssl_web_server.py
echo "then open browser: https://localhost:4433"
@abduakhatov
abduakhatov / install-docker.sh
Last active February 19, 2023 09:47
docker swarm for aws ec2
#!/bin/sh
set -x
sudo apt-get update -q
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
... global user data
user.signingkey=8F8EC40B4421AC93
commit.gpgsign=true
gpg.program=/opt/homebrew/bin/gpg
@abduakhatov
abduakhatov / client.py
Created January 7, 2023 17:57
TCP handshake
# client.py
import socket
def main():
# creating the socket
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# just connecting
sck.connect(("localhost", 7456))
print("Sending data...")
@abduakhatov
abduakhatov / README.MD
Last active December 24, 2022 07:52
The ticker.py is a python asyncio implementation within a multiprocessing context.

Ticker

The ticker.py is a python asyncio implementation within a multiprocessing context.

Usage

ticker.py [-h] [-m {sync,async}] [-c COUNT] [-p PARALLEL] -t TICKERCONF [-o OUTDIR]

Example

@abduakhatov
abduakhatov / redis_cli.py
Created December 8, 2022 15:10
Metaclass for creating classes that allow only a single instance to be created.
class MetaSingleton(type):
"""Metaclass for creating classes that allow only a single instance to be created."""
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super().__call__(*args, **kwargs)
return cls._instances[cls]
@abduakhatov
abduakhatov / Dockerfile
Last active June 30, 2022 19:54
Docker image to limit size of python package. Source `black`
FROM python:3-slim AS builder
RUN mkdir /src
COPY . /src/
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
# Install build tools to compile dependencies that don't have prebuilt wheels
&& apt update && apt install -y git build-essential \
&& cd /src \
&& pip install --user --no-cache-dir .[colorama,d]
@abduakhatov
abduakhatov / Logger.py
Created February 5, 2022 09:00
Logger as a decorator
import logging
from functools import wraps
def logged(cls=None, *, name=''):
def logged_for_init(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
logger_name = name or self.__class__.__name__
self.log = logging.getLogger(logger_name)
return func(self, *args, **kwargs)
lsof -ti:5901 | xargs kill -9
name: catalyst
channels:
- conda-forge
- defaults
dependencies:
- ca-certificates=2017.08.26
- certifi=2018.1.18
- intel-openmp=2018.0.0
- ipython=6.4.0
- jupyter=1.0.0