Skip to content

Instantly share code, notes, and snippets.

View DIYer22's full-sized avatar

Lei Yang DIYer22

View GitHub Profile
@DIYer22
DIYer22 / get_max_inscribed_circle.py
Last active August 1, 2023 08:28
Get the maximum/largest inscribed circle inside mask/polygon/contours based on cv2. Support non-convex/hollow shape.
import cv2
import numpy as np
def get_test_mask():
# Create an image
r = 100
mask = np.zeros((4 * r, 4 * r), dtype=np.uint8)
# Create a sequence of points to make a contour
vert = [None] * 6
vert[0] = (3 * r // 2, int(1.34 * r))
@DIYer22
DIYer22 / htmlTableAutoSortTempermonkey.js
Created July 27, 2020 03:54
Tempermonkey version of [html-table-sort](https://github.com/jchamet/html-table-sort), and support sorting table in asynchronous content(like gitlab)
// ==UserScript==
// @name html_table_auto_sort
// @namespace Diyer22
// @description Tempermonkey version of [html-table-sort](https://github.com/jchamet/html-table-sort), and support sorting table in asynchronous content(like gitlab)
// @include *
// @version 1.7
// @grant none
// ==/UserScript==
/*

自动将 arxiv.org 的链接重定向到

@DIYer22
DIYer22 / accelerateL2.py
Created March 14, 2019 07:42
赵振宇的 numpy 加速求每一对向量间的 L2
from boxx import *
import numpy as np
def zzy(M):
# M = np.array([[1,1],[2,2],[3,3]])
a2 = np.sum(M*M, axis = 1).reshape(1,-1)
b2 = a2.T
ab = M.dot(M.T)
@DIYer22
DIYer22 / self_attention.py
Created August 22, 2018 14:23
code for self-attention
# -*- coding: utf-8 -*-
"""
code for self-attention
see self-attention GAN
none-local
@author: yl
"""
@DIYer22
DIYer22 / download_ weekly_review.py
Created June 25, 2018 18:09
Download all DIYer22's weekly review and save to one markdown file
# -*- coding: utf-8 -*-
"""
Download all DIYer22's weekly review and save to one markdown file
Created on Mon Jun 25 20:41:22 2018
@author: Lei Yang
"""
from boxx import *
@DIYer22
DIYer22 / merge_multi_GIF.py
Last active June 2, 2021 02:42
Merge multi GIF pictures into one GIF with Python.
# -*- coding: utf-8 -*-
"""
Merge multi GIF pictures into one GIF.
requirement:
pip install boxx>=0.9.1
@author: DIYer22@github
"""
@DIYer22
DIYer22 / removeZhihuHot.js
Last active June 12, 2018 09:35
屏蔽知乎的"热门内容" for Tampermonkey Javascript 脚本 Chrome 扩展脚本。
// ==UserScript==
// @name removeZhihuHot
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over your time line!
// @author leiYang
// @match https://www.zhihu.com
// @grant none
// ==/UserScript==
@DIYer22
DIYer22 / Detection Python Environment, Especially distinguish Spyder, Jupyter notebook, Qtconsole.py
Created May 8, 2018 12:46
Detection Python Environment, Especially distinguish Spyder, Jupyter notebook, Qtconsole
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 8 20:40:30 2018
@author: yanglei
"""
'''
# Detection Python Environment, Especially distinguish Spyder, Jupyter notebook, Qtconsole
@DIYer22
DIYer22 / addPageNumberToPDF.py
Last active July 24, 2023 19:41
Add Page Number to PDF file with Python(Python 给 PDF 添加 页码)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
helpDoc = '''
Add Page Number to PDF file with Python
Python 给 PDF 添加 页码
usage:
python addPageNumberToPDF.py [PDF path]
require: