Skip to content

Instantly share code, notes, and snippets.

View xziyue's full-sized avatar

Z. "Alan" Xiang xziyue

View GitHub Profile
@xziyue
xziyue / enter_list_to_groovy.py
Created December 26, 2020 05:36
enter groovy music list into Discord
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()
@xziyue
xziyue / groovy_music_from_apply.py
Created December 26, 2020 05:13
Pull song lists from Apple Music for Groovy BOT
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'
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
@xziyue
xziyue / latex3-maze-game.tex
Created October 18, 2020 14:01
LaTeX3 maze PDF game
\documentclass{article}
\usepackage[paperwidth=8cm, paperheight=8cm, margin=2mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage{expl3}
\usepackage{enumitem}
\usepackage{hyperref}
\pagestyle{empty}
@xziyue
xziyue / emoji_write.py
Last active September 28, 2020 00:46
"typing" with emojis in discord
import os
import sys
import numpy as np
from PIL import Image, ImageFont, ImageDraw, ImageEnhance
import matplotlib.pyplot as plt
# parameters
font_size = 12
threshold = 0.9
emoji = ':a_:'
@xziyue
xziyue / lua_latex_parser.lua
Created August 11, 2020 00:02
Simple LaTeX parser in Lua
inspect = require "inspect.lua"
function raise_error(...)
local arg = {...}
local description = "a luaprogtable package exception occured:\n" .. table.concat(arg, ", ")
tex.error(description)
error(description)
end
local _spacer = lpeg.S(" \t\f\v\n\r")
\section{Math}
\makeatletter
\begin{longtable}{|l|l|l|l|l|l|l|}
\hline
Deadline & No. & Lorem Ipsum & Dolor Sit & Amet Consectetuer & Adipiscing Elit & Aenean Commodo \\ \hline
\def\@linkcolor{blue}\hyperref[subsec-2020-07-15]{2020-07-15} & \def\@linkcolor{green}\hyperref[subsubsec-2020-07-15-basic]{1} & \def\@linkcolor{red}\hyperref[figure-2020-07-15-basic-lorem-ipsum]{4.43} & \def\@linkcolor{red}\hyperref[figure-2020-07-15-basic-dolor-sit
@xziyue
xziyue / jekyll-index-term-new.rb
Last active July 5, 2020 15:08
A Simple Ruby Program For Jekyll Indexing
require 'digest/sha1'
module Jekyll
module JekyllIndexTermFilter
@@show_warning = true
@@tag_re = /(%+)({)(.*?)(}%)/
@@tag_alias_re = /(?<!\\)@/
@@TagInfo = Struct.new(:type, :raw, :segments)
@xziyue
xziyue / latex2html_gui.py
Created December 11, 2019 17:28
Converting colored LaTeX listing to HTML
from TexSoup.data import TexNode, TexEnv, TexCmd, RArg
from TexSoup import TexSoup
import re
import copy
import html as htmlib
class Tex2HTML:
def __init__(self):
@xziyue
xziyue / jekyll-index-term.rb
Last active December 11, 2019 00:16
A simple Ruby program to support indexing in Jekyll
require 'digest/sha1'
module Jekyll
module JekyllIndexTermFilter
# html display name, index name
def getnames(matchedString)
stripped = matchedString.strip()
matchResult = stripped.match(/(?<!\\)@/)