Skip to content

Instantly share code, notes, and snippets.

View jayzhan211's full-sized avatar
🇹🇼
Focus

Jay Zhan jayzhan211

🇹🇼
Focus
  • Backend Engineer @ Tiktok
  • Singapore
  • 18:27 (UTC +08:00)
  • LinkedIn in/jayzhan
View GitHub Profile
@jayzhan211
jayzhan211 / yt_vlc.py
Created August 9, 2022 12:58
python-vlc with pafy
import pafy
import vlc
url = 'https://www.youtube.com/watch?v=x1UsJ2Znjk0'
video = pafy.new(url)
video_best = video.getbest()
play_url = video_best.url
# print(play_url)
@jayzhan211
jayzhan211 / favorite.txt
Created April 28, 2021 01:58
Interesting Leetcode-like problem
Codeforces 865D. Buy Low Sell High
CSAcademy Firestarter
// Compiled with: g++ -Wall -std=c++14 -pthread
#include <bits/stdc++.h>
using namespace std;
void quick_sort(vector<int> &a, int l, int r) {
int i = l;
int j = r;
int p = (l + r) / 2; // pivot
@jayzhan211
jayzhan211 / Makefile
Created February 10, 2021 02:56
Makefile for one cpp file
TARGET = main
CXXFLAGS = -g -std=c++17 -O2
OBJS = ${TARGET}.o
main: ${OBJS}
${CXX} ${CXXFLAGS} $< -o $@
%.o : %.cpp
${CXX} -c ${CXXFLAGS} $< -o $@
find . -type f -print0 | xargs -0 dos2unix // dos2unix to entire directory
@jayzhan211
jayzhan211 / google_images_download.py
Created November 17, 2019 12:21
google_images_download
from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()
url = 'https://www.google.com.tw/search?q=crayon+illustration&hl=zh-TW&tbm=isch&tbs=rimg:CXGAdYHYQIovImAgIOC67N3khY71ydA4U4Z-tvzOVnhUynH8VJsno2NEhiL3RPSYEIMW2cV8Jdi7bg-epOoA8KS2RGi2dxrMhnkf6pDj1qseJAjyeqp6n3InQctHPfWsoQOGVLBMcDUKQZoqEgkgIOC67N3khREJWXFRcKR-YSoSCY71ydA4U4Z-EdcidLqKngNbKhIJtvzOVnhUynERDZv56iW5puIqEgn8VJsno2NEhhFsO_1TA8pqV0CoSCSL3RPSYEIMWERd2hA0Pps38KhIJ2cV8Jdi7bg8R6_10GgsZGLV4qEgmepOoA8KS2RBHEQKl0KumA8yoSCWi2dxrMhnkfERn-Lh_1wP2_1cKhIJ6pDj1qseJAgRoGxvUnBvLTEqEgnyeqp6n3InQRGtaA9t2ocSACoSCctHPfWsoQOGEfCm7bbEkQCuKhIJVLBMcDUKQZoRQbHclHJgl-0&tbo=u&sa=X&ved=2ahUKEwiH7fX03vDlAhW1LqYKHfr9DyIQrnZ6BAgBEBY&biw=1918&bih=928&dpr=1'
absolute_image_paths = response.download(
{
"url": url,
"limit": 1000,
@jayzhan211
jayzhan211 / file_reformat.py
Last active February 5, 2020 11:46
file_reformat
"""
file format
* abc
* abcd
* abcde
* pef
* zxc
* zxcv
"""
with open('song.txt', 'r', encoding='utf-8-sig') as f:
@jayzhan211
jayzhan211 / love.js
Last active March 3, 2019 02:20
hexo/js/mouseclick/words
var a_idx = 0;
jQuery(document).ready(function($) {
$("body").click(function(e) {
var a = new Array("傲慢", "貪婪 ", "色慾", "嫉妒", "暴食", "憤怒", "怠惰");
var $i = $("<span/>").text(a[a_idx]);
a_idx = (a_idx + 1) % a.length;
var x = e.pageX,
y = e.pageY;
$i.css({
"z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
@jayzhan211
jayzhan211 / Receptive Field Computation.md
Last active December 22, 2018 03:32
ReceptiveField for CPM