Skip to content

Instantly share code, notes, and snippets.

View giasuddin90's full-sized avatar
🎯
Focusing

Gias Uddin giasuddin90

🎯
Focusing
View GitHub Profile
@giasuddin90
giasuddin90 / python_file_sanitize.py
Created October 30, 2019 10:57
python sanitize string. is there any script, SQL tag in string
__author__ = 'giasuddin'
import html
data = {"description":"><img src=x onerror=prompt(1)>",
}
def sanitizeHtmlText(**kwargs):
"""
python sanitize string. is there any script, sql tag in string
@giasuddin90
giasuddin90 / python_image_resize.py
Created October 30, 2019 11:00
Python image file resize using pill library
__author__ = 'giasuddin'
from PIL import Image
import os, sys
size = (250, 500)
path = "/home/giasuddin/script/imgresize/all"
dirs = os.listdir(path)
directory = '/home/giasuddin/script/imgresize/dr'
# os.makedirs(directory)
@giasuddin90
giasuddin90 / py_dict_merge.py
Created October 30, 2019 11:03
python script for merging dictionary
def dict_merge():
"""
merge two dictionary
:return:
"""
dict_a = {'a':1, 'b': 2}
dict_b = {'b':10, 'c': 11}
z = dict_a.copy()
@giasuddin90
giasuddin90 / python_password_encryption.py
Created October 30, 2019 11:06
python password encryption by salt. some time we need encryption for password or other thin for your software then we can use hashlb and shah512 for encryption. Encryption is needed for security, you have lot of option to encryption your password, i am just giving simple way to encryption password.
__author__ = 'giasuddin'
import hashlib
'''
some time we need encryption for password or other thin for your software then we can use hashlb and shah512 for encryption.
Encryption is needed for security, you have lot of option to encryption your password, i am just giving simple way to encryption password.
'''
def password_encyption(password):
@giasuddin90
giasuddin90 / html_mail_script.py
Created October 30, 2019 11:11
Python html script mail by using third party mail server
__author__ = 'giasuddin'
test_html=""" <!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
@giasuddin90
giasuddin90 / py_file_read_by_extension.py
Created October 30, 2019 11:13
Python read file from a directory by using file extension
__author__ = 'giasuddin'
import os
import fnmatch
images = ['*.css', '*.jpeg', '*.ico', '*.gif', '*.png']
file_path= '/home/giasuddin/pyramid_sites/test//css'
for (dirpath, dirnames, filenames) in os.walk(file_path):
for extensions in images:
for filename in filenames:
if fnmatch.fnmatch(filename, extensions):
print(filename)
@giasuddin90
giasuddin90 / read_pdf_write_xlsx.py
Created October 30, 2019 11:16
By using python PyPDF2 and openpyxl library read data from pdf file and write data in xlsx file
#-*- coding: utf-8 -*-
import PyPDF2
from openpyxl import Workbook
def pypd():
pdfFileObj = open('principle of marketing.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
# allpage= pdfReader.numPages
pages = range(939, 959)
# pages = range(939, 940)
@giasuddin90
giasuddin90 / python_linux_command.py
Created October 30, 2019 11:19
using python sub process run linux command
__author__ = 'giasuddin'
from subprocess import call
call(["ls"])
call(["sudo apt-get update"])
call(["sudo apt-get upgrade"])
call(["dir"])
@giasuddin90
giasuddin90 / short_code_generation.py
Last active October 30, 2019 11:29
Generate python short code by using random library, We need short code for sms verification, user verification , mail verification, token service
__author__ = 'giasuddin'
import string
import random
def code_generator(size=6, chars=string.ascii_uppercase + string.digits):
"""
Generate python short code, We need short code for sms verification, user verification , mail verification, token service
:param size:
:param chars:
# pre rehnquist:
# >psycopg2
# >python version 3.*
#> SQLAlchemy
#
# Outcome:
# >using Sqlalchemy create table and call data from database
# >Table sync in postgresql