Skip to content

Instantly share code, notes, and snippets.

View yuhr123's full-sized avatar
🏠
Working from home

Herald Yu yuhr123

🏠
Working from home
View GitHub Profile
@yuhr123
yuhr123 / proc
Created October 26, 2023 05:42
A Bash script is used to obtain command line parameters of the running programs.
#!/bin/bash
# Check whether the command line parameters are provided.
# If not, display the usage and exit
if [ $# -ne 1 ]; then
echo "Usage: $0 <process_name>"
exit 1
fi
# Get the process name to find from the command line parameters
@yuhr123
yuhr123 / create_files.py
Created October 11, 2023 05:44
Script for testing the write performance of MinIO, S3FS-FUSE, and JuiceFS.
import os
import time
import argparse
# Create a file
def create_local_file(file_number, local_directory, file_size_mb):
local_file_name = f'sample_file_{file_number}.txt'
local_file_path = os.path.join(local_directory, local_file_name)
with open(local_file_path, 'wb') as file:
file.write(os.urandom(file_size_mb * 1024 * 1024))
@yuhr123
yuhr123 / scroll.html
Created January 31, 2019 09:20
ul 列表项自动循环滚动,每次显示一条。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>滚动条</title>
<style>
#s1 {
overflow: hidden;
@yuhr123
yuhr123 / backup-docker-volume-to-s3.sh
Last active February 7, 2024 10:21
导出并打包 Docker volume 上传到 s3 对象存储
#!/bin/bash
# Docker Volume: ghost_data
# MariaDB Container: mariadb
# 定义文件名变量
data_filename="ghost_data-`date +%Y-%m-%d_%H%M%S`.tar.gz"
db_filename="ghost_db-`date +%Y-%m-%d_%H%M%S`.sql"
# 通过临时创建的中间容器挂载 volume 并压缩打包成带时间的 tar.gz 文件
docker run --rm \
"gettext": {
"scope": "html",
"prefix": "_",
"body": "{{ _('$1') }}",
"description": "create a gettext code"
},
"variable": {
"scope": "html",
"prefix": "jv",
"body": "{{ $1 }}",
@yuhr123
yuhr123 / frpc-runit-sample.sh
Created March 22, 2018 00:35
FRP 客户端 runit 脚本示例
#!/bin/sh
FRPC=/usr/bin/frpc
CONFIG=/etc/frp/frpc.ini
LOG=/var/log/frp.log
USER=pi # change this with the actual user
exec chpst -u $USER $FRPC -c $CONFIG -L $LOG
@yuhr123
yuhr123 / datatime_by_timezone.py
Created February 2, 2018 03:06
Python datatime 模块按时区打印时间
from datetime import datetime, timedelta, timezone
# 东8区时间
time_utc_8 = datetime.now().astimezone(timezone(timedelta(hours=8)))
print(time_utc_8)
# 2018-02-02 10:56:10.496695+08:00
# 格式化
format = time_utc_8.strftime('%Y-%m-%d %H:%M:%S')
Verifying my Blockstack ID is secured with the address 1NWuk5A3KPrSRYSs8ApqEEmjAA97uEfevJ https://explorer.blockstack.org/address/1NWuk5A3KPrSRYSs8ApqEEmjAA97uEfevJ
@yuhr123
yuhr123 / install-docker-on-debian.sh
Created October 19, 2017 07:18
Install Docker CE on Debian Strach x86_64
#!/bin/bash
# install dependency packages
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
# add gpg key
@yuhr123
yuhr123 / Settings.json
Last active September 17, 2017 15:24
EspoCRM 添加自定义货币
# custom/Espo/Custom/Resources/metadata/entityDefs/Settings.json
{
"fields": {
"currencyList": {
"options": ["__APPEND__","RMB"]
}
}
}