Skip to content

Instantly share code, notes, and snippets.

View yuezhao238's full-sized avatar
🎯
Focusing

Yue Zhao yuezhao238

🎯
Focusing
View GitHub Profile
@yuezhao238
yuezhao238 / mp_wrapper.py
Created February 19, 2024 08:32
Plug and play multi processing with a decorator
import concurrent.futures
from functools import wraps
from progress.bar import Bar
import time
import random
random.seed(42)
def concurrent_processing(executor_type):
@yuezhao238
yuezhao238 / xlsx2csv.py
Created February 19, 2024 05:07
read xlsx file and write to csv file
import openpyxl
import csv
def xlsx_to_csv(xlsx_file, csv_file):
wb = openpyxl.load_workbook(xlsx_file)
sheet = wb.active
with open(csv_file, 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
for row in sheet.iter_rows():
writer.writerow([str(cell.value).strip() for cell in row if cell.value is not None])
@yuezhao238
yuezhao238 / hierachical_JS.js
Last active February 16, 2024 10:31
Marvellous JS code for building hierachical representations of any web
function hasVisibleText(text) {
return /[\x21-\x7E]/.test(text);
}
function getElementInfo(node, path) {
if (node.nodeType !== 1 && node.nodeType !== 3 || node.tagName && (node.tagName.toLowerCase() === 'script' || node.tagName.toLowerCase() === 'noscript')) {
return null;
}
let info = {};
if (node.nodeType === 3) {