This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------- | |
# Programmer : github.com/PyMmdrza | |
# pip install tqdm ftplib boto3 pysftp | |
# -------------------------------------- | |
import ftplib | |
import pysftp | |
import boto3 | |
import tarfile | |
import zipfile | |
import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql.connector | |
# Source database connection configuration | |
SOURCE_DB_CONFIG = { | |
'host': 'source_db_host', | |
'user': 'source_db_user', | |
'password': 'source_db_password', | |
'database': 'source_db_name' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def create_project_structure_from_file(file_path, base_directory="PyMermid"): | |
""" | |
Create a file and folder structure based on the tree-like format in the input text file. | |
Args: | |
- file_path (str): The path to the text file containing the directory structure. | |
- base_directory (str): The base directory where the project structure will be created. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import concurrent.futures | |
from urllib.parse import urlparse | |
import boto3 | |
from botocore.exceptions import ClientError | |
from colorama import Fore, Style | |
from datetime import datetime | |
class S3Scanner: | |
def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import sys | |
import os | |
def generate_id_from_text(text): | |
""" | |
Generates a valid id from text by converting it to lower case, | |
removing special characters, and replacing spaces with hyphens. | |
""" | |
return text.lower().replace(" ", "-").replace(",", "").replace(".", "").replace("'", "").replace("\"", "").replace("&", "and") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
import hashlib | |
def read_block(file_path): | |
with open(file_path, 'rb') as f: | |
while True: | |
magic = f.read(4) | |
if len(magic) < 4: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def naturalsize(num_bytes: int) -> str: | |
for unit in ['B', 'KB', 'MB', 'GB', 'TB']: | |
if num_bytes < 1024.0: | |
return f"{num_bytes:.2f} {unit}" | |
num_bytes /= 1024.0 | |
return f"{num_bytes:.2f} PB" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# // ------------------------- [ Config Setup ] ------------------------ // | |
# set permission swapfile | |
chmod 600 /swapfile | |
# create new swapfile | |
mkswap /swapfile | |
# write and added swap file to etc section | |
echo ‘/swapfile none swap sw 0 0’ | tee -a /etc/fstab | |
# system resourse optimize | |
sysctl vm.swappiness=10 | |
echo “vm.swappiness = 10” >> /etc/sysctl.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def format_time_ago(download_date): | |
download_datetime = datetime.strptime(download_date, '%Y-%m-%d %H:%M:%S') | |
current_datetime = datetime.now() | |
time_difference = current_datetime - download_datetime | |
if time_difference.days > 365: | |
years = time_difference.days // 365 |
NewerOlder