Skip to content

Instantly share code, notes, and snippets.

View jaredyam's full-sized avatar
👫
Falling in love with Wu.

jaredyam

👫
Falling in love with Wu.
  • Beijing, China
View GitHub Profile
@jaredyam
jaredyam / pip2requirements.sh
Last active September 19, 2020 06:14
Auto-update requirements.txt with custom pip install and uninstall command.
# Auto-update requirements.txt with custom pip command.
#
# Usage
# -----
# 1. save functions to your ~/.*shrc or save this file to the root of your project;
# 2. source file;
# 3. test in your terminal: $ pip-install [modules]; $ pip-uninstall [modules];
# 4. check out the requirements.txt in the predefined directory.
PROJECT_ROOT=path/to/project # or you can directly use $PYTHONPATH if it exists and with a proper setting
@jaredyam
jaredyam / condaf.sh
Created August 9, 2020 02:44
Auto-suggestion conda environment activation workflow using fzf.
# Implement Auto-suggestion/auto-complete conda environment activation workflow combining conda env manager and fzf fuzzy find method.
#
# Note
# ----
# The command *conda init base* can help you initialize your terminal with the base env,
# in which setting your default Python interpreter is always the base one.
#
# Usage
# -----
# 1. include this function in your ~/.bashrc or ~/.zshrc;
@jaredyam
jaredyam / translate-srt-subtitles.py
Last active June 2, 2022 09:07
Translate a .srt file using Google Translate Ajax API
"""Translate .srt files using Google Translate Ajax API.
Usage
-----
$ python translate_srt.py *.srt [src=]en [dest=]zh-cn [-n *.srt] [-p 5] [-v]
Note:
- the available values to assign position arguments [src, dest] can be abtained from the below *AVAILABLE LANGUAGES* section.
- try to assign a high value to *patience* argument if you meet a high failure ratio. [-p 5] is recommended. [-p -1] expects no failures would be happen which instead requires a long period to bruce-force complete.
@jaredyam
jaredyam / remove-srt-duplications.py
Last active February 23, 2023 18:25
Remove duplicate subtitles in a .srt file
"""Remove duplicate subtitles in a .srt file.
- What does the standard srt file look like?
- See https://www.3playmedia.com/2017/03/08/create-srt-file/
- What does the duplicate subtitle look like?
- The duplicate subtitle is something like the addition of its previous and next subtitle.
- Which match pattern has been used in this script?
- Line 85, 87
- What does the output srt file look like?
- [original_file_name]_changed.srt