Skip to content

Instantly share code, notes, and snippets.

View Rustam-Z's full-sized avatar
🚀
Hello from Mars!

Rustam Zokirov Rustam-Z

🚀
Hello from Mars!
View GitHub Profile
@Rustam-Z
Rustam-Z / MyLogger.py
Created August 1, 2022 13:07 — forked from huklee/MyLogger.py
python Logger using example with Singleton Pattern
# -*- coding: utf-8 -*-
import logging
import os
import datetime
import time
class SingletonType(type):
_instances = {}
@Rustam-Z
Rustam-Z / .gitignore
Created May 15, 2022 07:12
Gitignore template
venv/*
.*
*.pyc
__pycache__*/
import pathlib
print(pathlib.Path(__file__).parent.absolute())
@Rustam-Z
Rustam-Z / import.py
Created February 25, 2022 16:56
Import Python modules using strings
import importlib
# Contrived example of generating a module named as a string
full_module_name = "tables." + "tasks"
# The file gets executed upon import, as expected.
mymodule = importlib.import_module(full_module_name)
# Then you can use the module like normal
var = mymodule.COLUMNS
@Rustam-Z
Rustam-Z / aws-index.html
Created February 21, 2022 06:24
Simple HTML file to run in the AWS EC2 instance to check the server
<html>
<body bgcolor=black>
<center>
<h2><font color=yellow>Hello from Mars!</font></h2>
<font color=red>Rustam-Z</font>
</center>
</body>
</html>
import os
import sys
print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@Rustam-Z
Rustam-Z / logger.py
Created February 10, 2022 07:41
Python logging module
import logging
logging.basicConfig(level=logging.INFO, filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logging.info('This will get logged')
"""
import logging.config
logging.basicConfig(
@Rustam-Z
Rustam-Z / minikube.md
Created November 30, 2021 06:23 — forked from rahulkumar-aws/minikube.md
Install/Uninstall Minikube from Mac
minikube stop; minikube delete
docker stop $(docker ps -aq)
rm -r ~/.kube ~/.minikube
sudo rm /usr/local/bin/localkube /usr/local/bin/minikube
systemctl stop '*kubelet*.mount'
sudo rm -rf /etc/kubernetes/
docker system prune -af --volumes
@Rustam-Z
Rustam-Z / html_generator.py
Last active August 9, 2021 12:01
Project: HTML generator with Python decorator
"""Project: HTML Generator
With the new html() decorator you can focus on
writing simple functions that return the
information you want to display on the webpage
and let the decorator take care of wrapping them
in the appropriate HTML tag.
"""
def html(open_tag, close_tag):
def decorator(func):
@wraps(func)
@Rustam-Z
Rustam-Z / memorize.py
Last active August 9, 2021 10:59
Store the results of the decorated function for fast lookup
from functools import wraps
def memorize(func):
"""Store the results of the decorated function for fast lookup """
# Store results in a dict that maps arguments to results
cache = {}
@wraps(func)
def wrapper(*args, **kwargs):