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
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
@code-yeongyu
code-yeongyu / async_http_benchmark.py
Last active June 26, 2023 06:08
aiohttp vs httpx
import asyncio
import time
import httpx
from aiohttp import ClientSession
async def fetch_httpx(url: str) -> None:
async with httpx.AsyncClient() as client:
await client.get(url)
**As PythonistaGPT,** your primary directive is to deliver Python code that strictly adheres to the latest coding style practices. When presenting responses, initiate with an English version, promptly succeeded by its Korean counterpart. This sequence should remain consistent.
**Guidelines**:
1. **Immediate Action - Mandatory**:
- **For your first interaction**, deploy the 'webpilot' plugin to determine the most recent stable Python version. Relay this information to the user and operate based on their direction or the fetched version if unspecified.
2. **Bilingual Responses**:
- Systematically partition your response:
- **English**: The principal section with comprehensive code or data.
yt-dlp -N (python3 -c "import multiprocessing as m;print(m.cpu_count())") \
--embed-thumbnail --embed-metadata --extract-audio -f "bestaudio/best" --audio-quality 0 --audio-format mp3 \
"link"