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
english_digits = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] | |
# check if string s1 starts with s2 | |
def startswith(s1, s2): | |
if len(s2) > len(s1): | |
return False | |
for i in range(len(s2)): | |
if s1[i] != s2[i]: | |
return False | |
return True |
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
from urllib.request import urlopen | |
from bs4 import BeautifulSoup | |
import json | |
import os | |
from youtube_search import YoutubeSearch | |
list_url = 'https://music.apple.com/us/playlist/a-list-pop/pl.5ee8333dbe944d9f9151e97d92d1ead9' | |
youtube_url = 'https://www.youtube.com' | |
use_cached = True | |
cached_filename = 'crawl_list.html' |
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
import time | |
from pynput.keyboard import Key, Controller | |
import pyperclip | |
import json | |
with open('crawl_list.json', 'r') as infile: | |
song_list = json.load(infile) | |
kb = Controller() |
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
chn_to_pinyin = { | |
["吖"]="ā",["阿"]="ā",["啊"]="ā",["锕"]="ā",["錒"]="ā",["嗄"]="á", | |
["厑"]="ae",["哎"]="āi",["哀"]="āi",["唉"]="āi",["埃"]="āi",["挨"]="āi", | |
["溾"]="āi",["锿"]="āi",["鎄"]="āi",["啀"]="ái",["捱"]="ái",["皑"]="ái", | |
["凒"]="ái",["嵦"]="ái",["溰"]="ái",["嘊"]="ái",["敱"]="ái",["敳"]="ái", | |
["皚"]="ái",["癌"]="ái",["娾"]="ái",["隑"]="ái",["剴"]="ái",["騃"]="ái", | |
["毐"]="ǎi",["昹"]="ǎi",["矮"]="ǎi",["蔼"]="ǎi",["躷"]="ǎi",["濭"]="ǎi", | |
["藹"]="ǎi",["譪"]="ǎi",["霭"]="ǎi",["靄"]="ǎi",["鯦"]="ǎi",["噯"]="ài", | |
["艾"]="ài",["伌"]="ài",["爱"]="ài",["砹"]="ài",["硋"]="ài",["隘"]="ài", | |
["嗌"]="ài",["塧"]="ài",["嫒"]="ài",["愛"]="ài",["碍"]="ài",["叆"]="ài", |
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
# used in conjunction with https://gist.github.com/xziyue/0e83c7c6938d125b05d5bcad5e12e43a | |
import pickle | |
from PIL import Image, ImageFont, ImageDraw, ImageOps | |
import os | |
from multiprocessing import Pool | |
def generate_render_param(text_dim, font, fontsize, spacing): | |
test_str = '\n'.join([' ' * text_dim[1] for _ in range(text_dim[0])]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/questions/632271/chat-like-text-bock-in-tikz-environment | |
\documentclass{article} | |
\usepackage[T1]{fontenc} | |
\usepackage{mathpazo} | |
\usepackage{tikz} | |
\usepackage{xcolor} | |
\usepackage{xparse} | |
\usepackage{calc} | |
\usepackage{varwidth} |
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
import itertools | |
import numpy as np | |
class Calculator: | |
def __init__(self, vars): | |
self.vars = vars | |
self.num_vars = len(vars) | |
self.var_index = np.arange(self.num_vars, dtype=np.uint64) |
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
\documentclass[answers]{exam} | |
\usepackage[T1]{fontenc} | |
\usepackage{expl3} | |
\usepackage{amsmath} | |
\usepackage{xparse} | |
\ExplSyntaxOn | |
\seq_new:N \l_curenv_seq | |
\seq_new:N \l_item_cmd_seq |