Skip to content

Instantly share code, notes, and snippets.

View code-yeongyu's full-sized avatar
๐Ÿง˜
Conquering the world

YeonGyu-Kim code-yeongyu

๐Ÿง˜
Conquering the world
View GitHub Profile
[tool.ruff]
line-length = 119
target-version = "py312"
lint.select = ["PLE", "PLW", "E", "W", "F", "I", "Q", "UP", "C4", "PT"]
[tool.mypy]
python_version = "3.12"
strict = false
check_untyped_defs = true
cat list.txt | xargs -n 1 -P (python3 -c "import multiprocessing as m;print(m.cpu_count()*2)") -I {} yt-dlp -N (python3 -c "import multiprocessing as m;print(m.cpu_count()*2)") \
--embed-thumbnail --embed-metadata --embed-subs --embed-chapters --embed-info-json -f "bestvideo+bestaudio" --merge-output-format "mp4" --write-subs --convert-subs srt --cookies-from-browser brave {}
# License: MIT
from collections.abc import Callable
from functools import wraps
from typing import Any, TypeVar
from django.db import models
from django.db.models.fields import reverse_related
T = TypeVar("T", bound=models.Model)
import ast
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
import typer
from rich import print
from typer import Typer
def is_method_parameter_type_hinted(node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool:
@code-yeongyu
code-yeongyu / clean-srt.py
Last active October 27, 2023 01:22
Merges consecutive subtitles and reindex.
#!/usr/bin/env python
import re
from pathlib import Path
from typing import Optional, cast
import pysrt
import typer
from rich import print
@code-yeongyu
code-yeongyu / modern-rm.go
Created September 13, 2023 12:07
modern-rm.go
package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"
"github.com/spf13/pflag"
@code-yeongyu
code-yeongyu / modern-rm.py
Created September 13, 2023 08:54
Safely delete with recovery in a sleek CLI interface. Fully compatible with `rm`. Based on `rip`.
#!/usr/bin/env python3
import os
import shutil
import subprocess
try:
from rich.console import Console
from rich.style import Style
except ImportError:
๋‹น์‹ ์€ SrtTranslationGPT์ž…๋‹ˆ๋‹ค.
- ์‚ฌ์šฉ์ž๋Š” ๋‹น์‹ ์—๊ฒŒ SRT ํŒŒ์ผ์˜ ์ „์ฒด๋‚˜ ์ผ๋ถ€๋ฅผ ์ œ๊ณต ํ•ฉ๋‹ˆ๋‹ค.
- ๋‹น์‹ ์˜ ๊ณผ์ œ๋Š” SRT ์ž๋ง‰ ํŒŒ์ผ์„ ๋ฒˆ์—ญ ๋˜๋Š” ์˜์—ญํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
- ๋ฒˆ์—ญ๊ณผ ์˜์—ญ์€ ์ž์—ฐ์Šค๋Ÿฌ์šด ๊ตฌ์–ด์ฒด ํ•œ๊ตญ์–ด๋กœ ์ด๋ฃจ์–ด์ ธ์•ผํ•ฉ๋‹ˆ๋‹ค.
- ์˜์—ญ์˜ ๋ชฉ์ ์€ ์ˆœํ™”๊ฐ€ ์•„๋‹Œ ๋งฅ๋ฝ์— ๋งž์ง€ ์•Š๋Š” ์ด์ƒํ•œ ๋ง์„ ๋งฅ๋ฝ์ƒ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋„ฃ๋Š”๊ฒƒ์— ๋ชฉ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
๋‹น์‹ ์˜ ๋ชฉํ‘œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
- ์ œ๊ณต๋˜๋Š” ์ž๋ง‰์€ ์Œ์„ฑ์ธ์‹ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ์ž‘์„ฑ๋˜์—ˆ์„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋งฅ๋ฝ์ƒ ์ด์ƒํ•œ ๋ฌธ์žฅ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ๋งฅ๋ฝ์ƒ, ๊ทธ๋ฆฌ๊ณ  ์ œ๊ณต๋˜๋Š” ์ถ”๊ฐ€์ ์ธ ์š”์ฒญ ์‚ฌํ•ญ์„ ์ฐธ๊ณ ํ•ด ์ ์ ˆํ•œ ๋‚ด์šฉ์œผ๋กœ ๋Œ€์ฒดํ•ด์„œ ์˜์—ญํ•ด์ฃผ์„ธ์š”.
- ์ดํ•ดํ•  ์ˆ˜ ์—†๋Š” ๋‹จ์–ด๋ฅผ ์ ๊ฑฐ๋‚˜ ๋‹จ์ˆœ ์Œ์ฐจ๋Š” ๊ธˆ์ง€๋ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ๋ฌธ์žฅ์€ ํ•œ๊ตญ์ธ์ด ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” ์ž์—ฐ์Šค๋Ÿฌ์šด ๋ฌธ์žฅ์ด์–ด์•ผํ•ฉ๋‹ˆ๋‹ค..
- ์ผ๊ด€์„ฑ ์žˆ๊ณ  ์ฝ๊ธฐ ํŽธํ•œ ์ž์—ฐ์Šค๋Ÿฌ์šด ๋ฒˆ์—ญ์„ ์œ„ํ•ด ์ตœ์„ ์„ ๋‹คํ•˜์„ธ์š”.
from typing import TYPE_CHECKING, Optional
def import_or_install(package: str, submodule: Optional[str] = None):
try:
if submodule:
module = __import__(f"{package}.{submodule}", fromlist=[submodule])
else:
module = __import__(package)
return module