phương pháp nhanh hơn và không cần cài thêm package
code hoàn chỉnh:
import unicodedata
BANG_XOA_DAU = str.maketrans(| import re | |
| import unicodedata | |
| def remove_vietnamese_accents(input_str: str) -> str: | |
| # normalize input to unicode composed | |
| input_str = unicodedata.normalize('NFC', input_str) | |
| s1 = 'ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝàáâãèéêìíòóôõùúýĂăĐđĨĩŨũƠơƯưẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹ' | |
| s0 = 'AAAAEEEIIOOOOUUYaaaaeeeiioooouuyAaDdIiUuOoUuAaAaAaAaAaAaAaAaAaAaAaAaEeEeEeEeEeEeEeEeIiIiOoOoOoOoOoOoOoOoOoOoOoOoUuUuUuUuUuUuUuYyYyYyYy' | |
| s = '' | |
| for c in input_str: |
| ai | |
| am | |
| an | |
| anh | |
| ba | |
| ban | |
| bang | |
| bao | |
| bay | |
| be |
| # Python 3.6+ | |
| # Required library: requests | |
| import json | |
| import requests | |
| import os | |
| import sys | |
| from sys import exit | |
| if getattr(sys, 'frozen', False): | |
| # frozen |
| # +-----------------------------------------+ | |
| # | PFSENSE PORTAL TOGGLE | | |
| # +-----------------------------------------+ | |
| # This script is used to automatic toggle a captive portal on pfSense | |
| # Requirements: Python 3.x, additional packages: html_form_to_dict, requests, six | |
| # --- | |
| # Adapt these variables with your server config: | |
| # - pfsense_url: the base url of pfSense (include port, example: https://1.2.3.4:1234) | |
| # - portal_name: name of portal to toggle | |
| # - admin_username: the user account that is allowed to login to pfSense and change the configuration of the captive portal |
| version: '3.1' | |
| services: | |
| croc-relay: | |
| image: schollz/croc | |
| restart: always | |
| container_name: croc-relay | |
| ports: | |
| - 9009-9013:9009-9013 |
| # -*- coding: utf-8 -*- | |
| import os | |
| from psycopg2 import connect | |
| import sys | |
| import logging | |
| _logger = logging.getLogger(__name__) | |
| DB_NAME = "demo_db" | |
| DB_USER = 'odoo' |
| import sys | |
| import time | |
| from watchdog.observers import Observer | |
| from watchdog.events import FileSystemEventHandler | |
| class WatchDogEventHandler(FileSystemEventHandler): | |
| def on_modified(self, event): | |
| print(f'event type: {event.event_type} path : {event.src_path}') | |
| def on_created(self, event): |
| # python3 | |
| import sys | |
| import hashlib | |
| import os | |
| def file_hash_info(file_path: str): | |
| with open(file_path, "rb") as f: | |
| file_hash = hashlib.md5() | |
| while chunk := f.read(8192): | |
| file_hash.update(chunk) |
| #!/bin/bash | |
| REMOTE_HOST=$1 | |
| REMOTE_PORT=$2 | |
| TIMEOUT=1 | |
| shift 2 | |
| cmd="$@" | |
| if [ -n "$REMOTE_HOST" ] && [ -n "$REMOTE_PORT" ]; then | |
| while ! nc -w $TIMEOUT -z $REMOTE_HOST $REMOTE_PORT; do | |
| >&2 echo "Wait for remote host $REMOTE_HOST:$REMOTE_PORT" |