Skip to content

Instantly share code, notes, and snippets.

View binarycat0's full-sized avatar

Artur Rakhmatulin binarycat0

View GitHub Profile
@binarycat0
binarycat0 / set_cls_attrs wrapper
Created September 7, 2021 09:32
python set_cls_attrs wrapper
def set_cls_attrs(**injected_attrs):
def wrap_cls(cls):
# inject new class attr
for _attr_name, _attr_val in injected_attrs.items():
setattr(cls, _attr_name, _attr_val)
# wrapper class based on original cls
class wrapper_cls(cls):
def __init__(self, *args, **kw):
import argparse
import json
import subprocess
from collections import defaultdict
def _execute(*args) -> str:
p = subprocess.Popen(args, stdout=subprocess.PIPE)
res, _ = p.communicate()
return res.decode('utf8')
# create data dirs
mkdir -p /mysql/data/db
mkdir -p /mysql/conf
# customizing mysql instance
echo [mysqld] > /mysql/conf/custom_options.cnf
echo innodb_buffer_pool_size=100M >> /mysql/conf/custom_options.cnf
# run mysql image
docker run -d --name mysql-db \
# create ftp dir
mkdir -p /ftp/ftp-user
# change creds
chmod 0777 -R /ftp
# run vsftp
docker run --rm -it \
--name ftpd_server \
-p 21:21 \
-p 20:20 \