Skip to content

Instantly share code, notes, and snippets.

View Ishtiaq11's full-sized avatar

Ishtiaq Ahmed Ishtiaq11

View GitHub Profile
@Ishtiaq11
Ishtiaq11 / html_mail.py
Created March 16, 2024 06:54 — forked from ehrenfeu/html_mail.py
Use Python to send HTML emails with expand/collapse boxes working in TB and Android
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_html_mail(subject, body, to_addr, from_addr):
"""Send an HTML email using the given subject, body, etc."""
# Create message container - the correct MIME type is multipart/alternative here!
message = MIMEMultipart('alternative')
message['subject'] = subject
class MicroserviceClient:
def __init__(self, base_url):
self.base_url = base_url
def make_request(self, endpoint, method, **kwargs):
"""
Make a request to the microservice.
"""
try:
url = f"{self.base_url}/{self.endpoint}"
@Ishtiaq11
Ishtiaq11 / postgres-backup.sh
Created May 30, 2022 05:37 — forked from 4410287/postgres-backup.sh
Shell script for daily postgres database backup with basic archiving.
#!/bin/bash
# Written 2018-11-15 by 4410287
# This script will create a backup file of a postgres database and compress it. It is capable of access a local or remote server to pull the backup. After creating a new backup, it will delete backups that are older than 15 days, with the exception of backups created the first of every month. It is recommended to create a seperate database user specifically for backup purposes, and to set the permissions of this script to prevent access to the login details. Backup scripts for different databases should be run in seperate folders or they will overwrite each other.
HOSTNAME=
USERNAME=
PASSWORD=
DATABASE=
@Ishtiaq11
Ishtiaq11 / log.py
Created May 19, 2022 17:46 — forked from nguyenkims/log.py
Basic example on how setup a Python logger
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FILE = "my_app.log"
def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)
@Ishtiaq11
Ishtiaq11 / myscript.sh
Created April 28, 2021 08:33 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@Ishtiaq11
Ishtiaq11 / digitalstream.py
Created April 18, 2021 14:21
Digital Stream by Ishtiaq Pias
import shutil,time,sys,random
MIN_STREAM_LENGTH = 5
MAX_STREAM_LENGTH = 15
DENSITY = 0.02
WIDTH = shutil.get_terminal_size()[0]
COLUMN = [0] * WIDTH
STREAM_CHARS = ['0', '1', '2', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
PAUSE = 0.1
@Ishtiaq11
Ishtiaq11 / find_divisible_by_5.py
Last active February 12, 2021 06:25
print those number which r divided by 5 and if not found then print 'Not found'
nums = [9, 10, 11, 20, 25]
found = False
for num in nums:
if num % 5 == 0:
found = True
print(num)
if not found:
print("Not Found")