Skip to content

Instantly share code, notes, and snippets.

@huypl53
huypl53 / rename_invalid.sh
Last active October 30, 2025 02:17
bash tool
#!/usr/bin/bash
# Recursively rename all files in current directory and subdirectories
# to standardized names (only a-z, A-Z, 0-9, _, and .)
# Start in current directory (or pass a path as first argument)
BASE_DIR="${1:-.}"
# Find all files (not directories)
find "$BASE_DIR" -type f | while read -r file; do
dir=$(dirname "$file")
@huypl53
huypl53 / AppSwitchKey.ahk
Last active February 26, 2025 01:36
AutoHotKey 2.0.19
; AutoHotkey v2 script to switch between windows of the same application using Alt + `
!`:: {
; Get the process name of the active window
activeProcess := WinGetProcessName("A")
; Get a list of all windows matching the process name
windowList := []
for window in WinGetList("ahk_exe " . activeProcess) {
if WinGetTitle(window) {
windowList.Push(window)
@huypl53
huypl53 / tex-bib-filter.py
Created January 11, 2025 09:36
latex helpful tools
import sys
import re
if __name__ == '__main__':
# tex-bib-filter.py <source_tex_file.tex> <bib_item_file.bib>
tex_file, bib_file = sys.argv[1: 3]
print(tex_file, bib_file)
re_cite_key = re.compile(r'\\cite{(.*?)}')
# \bibitem{dosovitskiy2021an}
@huypl53
huypl53 / rolabel2pascal.py
Last active October 21, 2024 07:06
convert rolabel to pascal voc
import os
import xml.etree.ElementTree as ET
def convert_bbox(cx, cy, w, h):
# Convert (cx, cy, w, h) to (xmin, ymin, xmax, ymax)
xmin = cx - (w / 2)
ymin = cy - (h / 2)
xmax = cx + (w / 2)
ymax = cy + (h / 2)
@huypl53
huypl53 / excel2json.py
Last active May 3, 2023 10:17
Python generate sql
import pandas as pd
from pypika import Query, Table
from tqdm import tqdm
import re
re_utf_string = re.compile(r"\'(?=\w)")
xls_file_path = "./demo.xlsx"
xls = pd.ExcelFile(xls_file_path)
@huypl53
huypl53 / coco_to_yolo.py
Last active December 3, 2022 08:44
YOLO dataset
import cv2
import json
from os import path as osp
import sys
import json
CATES = {
"Beer": 0,
"Alcohol": 1,
"Sextoy": 2
@huypl53
huypl53 / Microsoft.PowerShell_profile.ps1
Last active January 12, 2025 03:31
windows-terminal-config
oh-my-posh init pwsh --config "~\AppData\Local\Programs\oh-my-posh\themes\emodipt-extend.omp.json" | Invoke-Expression
@huypl53
huypl53 / LexicalEnvironment.js
Last active August 30, 2021 02:59
Javascript Q&A
let user = {
firstName: "John",
sayHi() {
alert(`Hello, ${this.firstName}!`);
}
};
setTimeout(user.sayHi, 1000); // Hello, undefined!
/*
In line 8, user.sayHi is passed into `setTimeout`, then its lexical environment is setTimeout's closure. So it has no idea where is this reference -> unidentified with this.name in line 4