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 dict_merge(): | |
| """ | |
| merge two dictionary | |
| :return: | |
| """ | |
| dict_a = {'a':1, 'b': 2} | |
| dict_b = {'b':10, 'c': 11} | |
| z = dict_a.copy() |
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
| __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) |
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
| __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 |
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
| __author__ = 'giasuddin' | |
| import requests | |
| import os | |
| f_url = "http://files.test.org.bd/crop/250/300/media/image/publication/wallpaper_poster_20180307.jpg" | |
| STORAGE_DESTINATION = "/home/giasuddin/Pictures/" | |
| def file_download(file_url): |
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
| __author__ = 'giasuddin' | |
| def pager(total_row=None, item_per_page=None): | |
| """ | |
| We are using this function for pagination database total row. | |
| Then using offset for query | |
| """ | |
| pages = {} | |
| total_page = total_row/item_per_page |
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
| __author__ = 'giasuddin' | |
| def is_ascii(s): | |
| return all(ord(c) < 128 for c in s) | |
| if __name__ == '__main__': | |
| test=is_ascii('রিকোয়ারমেন্') | |
| print(test) |
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
| __author__ = 'giasuddin' | |
| from pyramid.response import Response, FileResponse | |
| import os | |
| from pyramid.view import view_config | |
| @view_config(route_name='download', renderer='json') | |
| def download_view(request): | |
| if request.params.get('filename', ''): | |
| filename = request.params['filename'] |
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
| __author__ = 'giasuddin' | |
| from pyramid.view import view_config | |
| import os | |
| @view_config(request_method='POST', renderer='json') | |
| def post(self): | |
| file_type = self.request.matchdict['file_type'] | |
| node_type = self.request.matchdict['node_type'] | |
| sanitize_file = False |
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 re | |
| import glob, os | |
| def file_rename(dir, pattern, titlePattern): | |
| for pathAndFilename in glob.iglob(os.path.join(dir, pattern)): | |
| title, ext = os.path.splitext(os.path.basename(pathAndFilename)) | |
| replace_file = re.sub("[^a-zA-Z0-9_]+", "_", title) | |
| new_filename = (replace_file + ext ).lower() | |
| os.rename(pathAndFilename, |