Issue with Loading Fonts in WeChat Mini Program on Android Devices
Using the wx.loadFontFace method to load fonts, fonts can be successfully loaded in development tools and on Apple devices. However, on Android devices, it always triggers the fail callback, and there’s no specific reason provided, only returning {"status": "error"}.
The solution was eventually found as follows:
The request domain for WeChat Mini Program is servicewechat.com, which requires CORS support to be added.Alternatively, CORS support for font files can be a ...
PHP Directly Output Binary Image Display Image ThinkPHP Directly Output Binary Image Display
The key is the code starting from ob_end_clean();.
// Read background image and target image$backgroundPath = 'background_image_path';$overlayPath = 'overlay_image_path';// Get resources of background image and target image$background = imagecreatefrompng($backgroundPath);$overlay = imagecreatefrompng($overlayPath);// Get the width and height of the target image$overlayWidth = imagesx($overlay);$overlayHeight = imagesy($overlay);// Overlay the target image onto the backgroun ...
Python Sequential Grouping Followed by Shuffling Group Order
Python Sequential Grouping Followed by Shuffling Group Order
# Merge ts videosimport os, time, random, shutil# Define loop timesloop_times = 10# Array for sorting and groupingmySortArr = []path = r"D:\XXX\Video_TS_Folder"for file in os.listdir(path): if file.endswith('.ts'): mySortArr.append(file)# Minimum number of files in each groupmaxFileNum = 4def find_all_index(arr, item): return [i for i, a in enumerate(arr) if a == item]randomListMax = len(mySortArr) * 10 ...
Introducing layui into fastadmin and invoking layui interfaces
First Method: Global IntroductionFirst, go to the layui official website, download the entire repository, which includes the dist and src directories.https://gitee.com/layui/layui
Place the downloaded layui in the following directory:
public/libs/layui
In the following file, add layui to paths and shim respectively:
public/assets/js/require-backend.js
require.config({ paths: { // Add layui layui: "../libs/layui/src/layui", }, // Shim d ...
Python Batch Shuffle, Reorder, and Rename Files in a Folder
I have tens of thousands of images that need to be shuffled, reordered, and renamed. Let’s implement this using Python.
First, batch shuffle the files in the folder.
Second, reorder the files.
Third, batch rename them.
import os, random, timedef rename(): # Configuration # File extension filetype = '.png' # File name prefix filename = '' # Number of digits in the filename, padding zeros in the beginning if less zfillNum = 5 # Configure the folder pat ...
Save VCARD Directly to Contacts by Scanning with Mobile Camera or WeChat
Save VCARD Directly to Contacts by Scanning with Mobile Camera or WeChatGenerate the following content into a QR code. When scanned with a mobile phone, it will automatically prompt to save to contacts, compatible with Android/iOS.
BEGIN:VCARDVERSION:3.0N:NameORG:Company NameTITLE:Position: New Employee Research and DevelopmentTEL;TYPE=WORK:18888886686TEL;TYPE=HOME:18888888888ADR;TYPE=HOME:;;Address1;;;;LABEL;TYPE=HOME:Address2,EMAIL:email@gmail.comURL:www.abc.comBDAY:2023-04-23REV:2023-04- ...
Electron: Resolve Socket Port Occupied Issue, Start Socket Service with Automatic Attempt to Find Available Port
The principle is to locally create a config.json, initially placing the port number inside it. Every time the Electron socket service starts, if it finds the port occupied, it updates the port number in config.json by adding 1 and saves it to config.json. Then, it exits and restarts Electron until it finds an available port.
{"port":1081}
const { app, BrowserWindow, protocol, dialog } = require("electron");const path = require("path");const ...