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
@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"
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 \
--fragment-retries 40 --retry-sleep 5 --buffer-size 64K --continue --ignore-errors \
--cookies-from-browser brave \
-f "bestvideo+bestaudio" \
--merge-output-format "mp4" \
--all-subs \
--sub-lang en,ko \
Please create a test for the following Python file: <filepath>, using pytest class-based tests. Ensure that the test is fully typed and compatible with Python <python version>, without using any generic types. Additionally, incorporate mocks or patches as needed, and structure the test using the given-when-then format.