Skip to content

Instantly share code, notes, and snippets.

@yusanshi
yusanshi / nginx.conf
Last active March 17, 2020 12:43
Nginx forward to 80
# Forward http://127.0.0.1:8080 to example.com/
# http://127.0.0.1:8081 to example.com/foo/
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@yusanshi
yusanshi / config.py
Last active March 2, 2020 04:21
Grade tools for students in USTC.
STUDENT_ID = ''
PASSWORD = ''
NAME_CN = ''
NAME_EN = ''
@yusanshi
yusanshi / script.js
Last active March 17, 2020 08:41
计蒜客助手 Jisuanke Helper
// ==UserScript==
// @name 计蒜客助手 Jisuanke Helper
// @namespace http://tampermonkey.net/
// @version 1.2.2
// @description 1. 取消复制限制; 2. 选择题显示序号(一般情况最小的几个是答案); 3. 跳过强制等待; 4. 双击单行或块代码区域复制代码; 5. 跳过点击直接复制提示内容
// @author yusanshi
// @source https://gist.github.com/yusanshi/981b5926851d4cde3d67536b279cbf34
// @match http://www.jisuanke.com/course/*
// @match https://www.jisuanke.com/course/*
// @grant none
@yusanshi
yusanshi / MonitoredVariable.js
Last active March 19, 2021 06:56
Create a monitored variable, do something when its value is being set or changed.
// Create a monitored variable, do something when its value is being set or changed
// Licensed under MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
// Copyright (c) 2021 yusanshi
// Define the class
// Since class declarations are not hoisted like function declarations,
// you first need to declare your class and then access it
class MonitoredVariable {
@yusanshi
yusanshi / wrapper.js
Last active March 26, 2020 15:05
A wrapper for CanvasRenderingContext2D.
/**
* A wrapper for fillText, with add additional options
* @param {string} text Text string to render into the context.
* @param {number} x The x-axis coordinate of the point at which to begin drawing, in pixels
* @param {number} y The y-axis coordinate of the point at which to begin drawing, in pixels
* @param {number} charSpace Proportion of canvas.width (%), can be negative or postive
* @param {number} _distortion Distortion factor. Not implemented yet
* @param {number} horizontalOffset Proportion of canvas.width (%)
* @param {number} verticalOffset Proportion of canvas.height (%)
*/
@yusanshi
yusanshi / youtube_migrate.py
Last active November 16, 2020 15:55 — forked from maxpoletaev/youtube_migrate.py
Transfer YouTube subscriptions to another account
"""
Automatic migration of subscriptions to another
YouTube account with Python and Selenium.
1. Install selenium from pypi:
$ pip install selenium
2. Go to the down of page https://www.youtube.com/subscription_manager
and download your current subscriptions feed.
Save file as subscription_manager.xml.
@yusanshi
yusanshi / group-photo-mosaic.py
Created June 25, 2021 03:40
Add mosaic to group photos.
import face_recognition
import argparse
from PIL import Image, ImageDraw, ImageFont
parser = argparse.ArgumentParser()
parser.add_argument('--input_path', type=str, required=True)
parser.add_argument('--mosaic_path', type=str, required=True)
parser.add_argument('--output_path', type=str, default='./output.jpg')
parser.add_argument('--zoom_coefficient', type=float, default=2.0)
parser.add_argument('--font_size', type=int, default=120)