Skip to content

Instantly share code, notes, and snippets.

View akmamun's full-sized avatar
🎯
Focusing

Al Mamun Khan akmamun

🎯
Focusing
View GitHub Profile
@akmamun
akmamun / sop_cors.csv
Created February 21, 2024 17:58
SOP Example with URL Results
URL Result Reason
http://example.com/* OK Only the path differs
https://example.com/* Not OK Not the same protocol
http://example.com:1234/* Not OK Not the same port
@akmamun
akmamun / django_event_listener.py
Last active September 16, 2023 09:54
Kafka Real-time Event Processing with Django
import json
import logging
from time import sleep
from confluent_kafka import Consumer
from django.core.management import BaseCommand
logger = logging.getLogger(__name__)
# pip install confluent_kafka
@akmamun
akmamun / encrytion_decrytion.py
Last active April 11, 2023 06:45
Public/Privet key encryption decryption with python
import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa, padding
KEY_SIZE = 2048
PASSWORD = b'1234546' # bytes of string
PRIVET_KEY_ENCODE = b'LS0tLS1CRUdJTiBFTkNSWVBURUQgUFJJVkFURSBLRVktLS0tLQpNSUlGSFRCWEJna3Foa2lHOXcw\nQkJRMHdTakFwQmdrcWhraUc5dzBCQlF3d0hBUUl4VEhpRWl6RUZ1VUNBZ2dBCk1Bd0dDQ3FHU0li\nM0RRSUpCUUF3SFFZSllJWklBV1VEQkFFcUJCREhWREs0NHp1enRDOVZGNlRoZ0pIMkJJSUUKd05E\nckR0MWpRaVBPWEFMaHhLVFJIRW9nVE9OS25tN1R0MVJ2b2hvc2FqWEdKYTByUUJxRXJFZlFBUjA4\naHJRdwp1anJFM3g1aUw3eGNRQmV2eWczMnYyWHBBYXBoczZKRjJoNklibUxabE0rU29mMmpMbVJv\ndzNOZ0x4ODg4c3ZRCm94V25WZXpGMCtZY0VIWHZKd3NvbkRmOFEvRHA3b08vdi9ndm1MMkpqcVl5\nZVh0LzlEanMyRVpRQzVQbTJIekcKR0dLSVBaRk9lWDdCWkcybFp0Q2RPWDZEcmJXdk9STjkwbmxF\nc1ZsOVVhOWlPVVk1OTNreFYwS3M0QUhUekJOQwpjcFhUaHp6R1dOckp4R08wMjV2TnZUcTNqQUZ0\ndXdyMXowV2NpNmZsdktHQUxIVkxya2JadEhYU2kzK1lLSWlkCkJqUXcyRkh2OURkY25hZ1NCSFYz\nZnhPNm14S1Jad0JXcGVpRDlzSEVjQnZvZnJJOU
@akmamun
akmamun / docker-compose.yml
Last active November 21, 2021 16:07
Docker Compose Host Mode Container
version: "3"
services:
server:
container_name: django_app
build: . # from Dockerfile or image name
command: gunicorn core.wsgi:application --bind 0.0.0.0:8001
# ports:
# - 8000:8000
network_mode: host
@akmamun
akmamun / django_mail.py
Last active December 6, 2021 15:15
Django send email for both html template and text
from django.conf import settings
from django.core.mail import EmailMessage
from django.template.loader import get_template
class EmailService:
def __init__(self):
self.from_email = settings.EMAIL_HOST
def send_email(self, subject: str, template: str, data=None):
@akmamun
akmamun / base_64_image_check.py
Created February 2, 2021 17:45
Base 64 Image Check
def is_base64(base_64):
try:
if len(base_64) == 0:
return False
if isinstance(base_64, str):
# If there's any unicode here, an exception will be thrown and the function will return false
sb_bytes = bytes(base_64, 'ascii')
elif isinstance(sb, bytes):
sb_bytes = base_64
@akmamun
akmamun / mailjet_send_mail.py
Created July 8, 2020 15:22
Python3 MailJet(https://www.mailjet.com/) Send Mail Service
#pip install mailjet_rest
from mailjet_rest import Client
from os import getenv
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
api_key = getenv("MAIL_API_KEY")
api_secret = getenv("MAIL_API_SECRET")
@akmamun
akmamun / .gitignore
Created March 11, 2020 06:42
Sample Node Git Ignore File
node_modules
build
npm-debug.log
.env
.DS_Store
@akmamun
akmamun / run.sh
Created January 26, 2020 18:56
Docker Serve React Build Pack with Nginx
docker run --mount type=bind,source="$(pwd)"/build,target=/usr/share/nginx/html -p 8080:80 nginx
@akmamun
akmamun / git.md
Created January 5, 2020 19:01
Git Essential

Git Essential

Git initialization

  • Only one time need to initialization
git init

Git add

  • Add single file or folder or all changes made