This file contains hidden or 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 PIL import Image, ImageFont, ImageDraw | |
from collections import namedtuple | |
def position_tuple(*args): | |
Position = namedtuple('Position', ['top', 'right', 'bottom', 'left']) | |
if len(args) == 0: | |
return Position(0, 0, 0, 0) | |
elif len(args) == 1: | |
return Position(args[0], args[0], args[0], args[0]) |
This file contains hidden or 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
const assert = require('assert'); | |
const assign = require('object-assign'); | |
const htmlWebpackPlugin = require('html-webpack-plugin'); | |
const htmlTags = require('html-webpack-plugin/lib/html-tags'); | |
const createHtmlTag = htmlTags.createHtmlTagObject, htmlTagToString = htmlTags.htmlTagObjectToString; | |
const isStylesheetLink = (def) => def.tagName === 'link' && def.attributes.rel === 'stylesheet' && def.attributes.href; | |
const addMediaAttribute = (tag) => { | |
tag.attributes.media = 'print'; |
This file contains hidden or 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
// 2023.4.23 更新,修复 gtag.js 加了个回车导致失效的问题 | |
// 2023.3.2 更新,修复上报到 region*.google-analytics.com 未被代理的问题 | |
addEventListener('fetch', (event) => { | |
// 这里可以加 filter | |
return event.respondWith(handleRequest(event)); | |
}); | |
// worker 应用的路由地址,末尾不加 '/' | |
const DOMAIN = 'https://example.workers.dev/routerpath'; |
This file contains hidden or 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
# Modify from https://gist.github.com/668/2c8f936697ded94394ff4a6ffa4ae87e | |
import sys | |
from pypdf import PdfReader, PdfWriter | |
from pypdf.generic import ContentStream, TextStringObject, NameObject | |
# Load PDF into PyPDF2 | |
reader = PdfReader(open(sys.argv[1], "rb")) | |
writer = PdfWriter() |