This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://askubuntu.com/a/1000020/657385 | |
ffmpeg -i file_orig.mp3 -acodec copy file_fixed.mp3 | |
# https://www.xmodulo.com/convert-mp3-id3-tag-encodings-linux.html | |
mid3iconv -e gbk/big5 -d input.mp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://unix.stackexchange.com/a/501546/215915 | |
env LC_ALL=zh_CN.GB2312 7z x file.zip | |
convmv -f zh_CN.GB2312 -t UTF8 -r . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convert passport.jpg -background transparent -fill black -size 1024x256 -pointsize 24 -gravity center -annotate +0+205 'For ... Purpose' passport-water.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://wiki.archlinux.org/title/Rsync#Full_system_backup | |
rsync -aAXHv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup | |
# More human readable | |
rsync -aAXHh --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% https://tex.stackexchange.com/a/84763/124998 | |
\usepackage{pgfpages} | |
\setbeameroption{show notes} | |
\setbeameroption{show notes on second screen=right} | |
% Command line: | |
% pdfpc --notes=right presentation.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://askubuntu.com/a/50180 | |
pdftoppm -png -r 300 input.pdf png/out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copied from https://stackoverflow.com/a/56175538/955952 | |
def indep_roll(arr, shifts, axis=1): | |
"""Apply an independent roll for each dimensions of a single axis. | |
Parameters | |
---------- | |
arr : np.ndarray | |
Array of any shape. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lens = [3, 5, 4] | |
# What we want: | |
# mask = [[1, 1, 1, 0, 0], | |
# [1, 1, 1, 1, 1], | |
# [1, 1, 1, 1, 0]] | |
# https://stackoverflow.com/questions/53403306/how-to-batch-convert-sentence-lengths-to-masks-in-pytorch | |
def len_to_mask(lens: np.ndarray, seq_len: Optional[int] = None) -> np.ndarray: | |
if seq_len is None: | |
seq_len = max(lens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logging.basicConfig( | |
level=logging.INFO, | |
stream=sys.stderr, | |
format="[%(asctime)s][%(levelname)s] - %(message)s", | |
) | |
log = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Number each line | |
cat FILE | sed -r 's/^[[:space:]]*//' | awk '{print NR, "\t", $0}' | |
# Remove empty lines and number | |
cat FILE | sed -r 's/^[[:space:]]*//' | grep -v '^$' | awk '{print NR, "\t", $0}' |
NewerOlder