春有百花秋有月
夏有凉风冬有雪控制typecho首页不显示全文,只显示摘要的方法
虽然在Typecho的文章撰写里面可以使用
<!--more-->
来控制首页显示文章的内容,但有时候码完字后忘记添加了又需要进去编辑添加。为了能达到一劳永逸的效果,以下将采用修改Typecho模版来实现全局控制文章显示的内容:
阅读剩余部分 →为typecho文中代码增加一键复制功能
Update header.php,add codecopy,eg:
vi /var/www/typecho/usr/themes/single/header.php
在header之前增加如下js脚本:
<script>
// 在代码块右上角添加复制按钮
document.addEventListener('DOMContentLoaded', initCodeCopyButton);
function initCodeCopyButton() {
function initCSS(callback) {
const css = `
.btn-code-copy {
position: absolute;
line-height: .6em;
top: .2em;
right: .2em;
color: rgb(87, 87, 87);
}
.btn-code-copy:hover {
color: rgb(145, 145, 145);
cursor: pointer;
}
`;
const styleId = btoa('btn-code-copy').replace(/[=+\/]/g, '');
const head = document.getElementsByTagName('head')[0];
if (!head.querySelector('#' + styleId)) {
const style = document.createElement('style');
style.id = styleId;
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
callback();
};
function copyTextContent(source) {
let result = false;
const target = document.createElement('pre');
target.style.opacity = '0';
target.textContent = source.textContent;
document.body.appendChild(target);
try {
const range = document.createRange();
range.selectNode(target);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
result = true;
} catch (e) { console.log('copy failed.'); }
document.body.removeChild(target);
return result;
};
function initButton(pre) {
const code = pre.querySelector('code');
if (code) {
const preParent = pre.parentElement;
const newPreParent = document.createElement('div');
newPreParent.style = 'position: relative';
preParent.insertBefore(newPreParent, pre);
const copyBtn = document.createElement('div');
copyBtn.innerHTML = 'copy';
copyBtn.className = 'btn-code-copy';
copyBtn.addEventListener('click', () => {
copyBtn.innerHTML = copyTextContent(code) ? 'success' : 'failure';
setTimeout(() => copyBtn.innerHTML = 'copy', 250);
});
newPreParent.appendChild(copyBtn);
newPreParent.appendChild(pre);
}
};
const pres = document.querySelectorAll('pre');
if (pres.length !== 0) {
initCSS(() => pres.forEach(pre => initButton(pre)));
}
};
</script> 阅读剩余部分 →
acme网站证书更新
/root/.acme.sh/acme.sh --upgrade
/root/.acme.sh/acme.sh --renew-all
如果你的服务器有多个网站的SSL证书,而你只想更新其中一个网站的SSL证书,可以使用“-d 域名”参数,例如
/root/.acme.sh/acme.sh --renew -d domain
二、自动更新
-
1.编写自动更新脚本,将更新后的证书替换nginx中使用的证书
#!/bin/bash # 定义变量 ACME_HOME="/root/.acme.sh" CERT_TARGET_DIR="/etc/nginx/ssl" NGINX_SERVICE="nginx" # 停 Nginx echo "Stoping Nginx service..." systemctl stop "${NGINX_SERVICE}" # 更新所有证书 echo "Updating all certificates..." "${ACME_HOME}/acme.sh" --cron --home "${ACME_HOME}" if [ $? -eq 0 ]; then echo "Certificates updated successfully. Processing each domain..." # 遍历所有域名目录 for domain_dir in "${ACME_HOME}"/*_ecc; do if [ -d "${domain_dir}" ]; then # 获取域名 domain_name=$(basename "${domain_dir}" | sed 's/_ecc$//') # 检查证书和密钥是否存在 cert_file="${domain_dir}/fullchain.cer" key_file="${domain_dir}/${domain_name}.key" if [ -f "${cert_file}" ] && [ -f "${key_file}" ]; then # 确保目标目录存在 target_dir="${CERT_TARGET_DIR}/${domain_name}" mkdir -p "${target_dir}" # 拷贝证书和密钥 cp "${cert_file}" "${target_dir}/fullchain.cer" cp "${key_file}" "${target_dir}/${domain_name}.key" echo "Certificates for ${domain_name} copied to ${target_dir}." else echo "Certificate or key file missing for ${domain_name}. Skipping." fi fi done # 重启 Nginx echo "Restarting Nginx service..." systemctl restart "${NGINX_SERVICE}" if [ $? -eq 0 ]; then echo "Nginx restarted successfully. Certificates are now active." else echo "Failed to restart Nginx. Please check the configuration." fi else echo "Failed to update certificates. Check acme.sh logs for details." fi -
2.手动执行测试
阅读剩余部分 →
修改系统配置和v2ray配置支持fast-open和udp-relay
查看系统是否支持fast-open
sysctl net.ipv4.tcp_fastopen
备份配置文件
cp /etc/sysctl.conf /etc/sysctl.conf.bak
vi /etc/sysctl.conf
新增支持fastopen conf
net.ipv4.tcp_fastopen = 3
应用设置
sysctl -p
2.修改v2ray支持fastopen
vi /etc/v2ray/config.json
修改进站支持udp
{
"port": ****,
"protocol": "dokodemo-door",
"settings": {
"address": "0.0.0.0", // 捕获所有地址的 UDP 流量
"port": 0, // 捕获所有端口的 UDP 流量
"network": "udp", // 指定网络类型为 UDP
"timeout": 0, // 超时时间,0 表示不超时
"followRedirect": true // 允许重定向
}
}
修改出站支持fastopen
阅读剩余部分 →debian&ubuntu info
1.修改nginx欢迎页,一般默认路径为/usr/share/nginx/html/index.html
by:onedrive/myser/index.html
2.通过nginx代理静态文件,使用python上传文件:
by:onedrive/myser/upload_service.py
3.v2ray info
by:onedrive/myser/v2ray/*
阅读剩余部分 →mac下mysql8.0重置root密码
1.进入安全模式
cd /usr/local/mysql/bin
sudo su
./mysqld_safe --skip-grant-tables &
**2.
再次启动一个新的终端(之前那个放着不动)**
mysql
use mysql
UPDATE user SET authentication_string='' where user='root';
flush privileges;
3.设置新密码
mysql -uroot -p
use mysql
alter user 'root'@'localhost' identified by '你期望的新密码';
flush privileges;
4.新密码测试
mysql -uroot -p
5.重启 MySQL 服务
阅读剩余部分 →Oracle cloud申请与R探长抢实例---后续
脚本一直抢不到,在tg群中得知,需要等待放水,昨天账号升级成功,收到oracle官方邮件后,脚本自动抢机成功
上周升级账号失败,这周重试,唯一区别就是本周使用chrome的无痕模式升的级,其它一切不变,卡使用的是申请时候的实体卡,这周升级一次成功提交申请,上午申请下午4点左右收到官方升级成功的邮件通知。
mark一下。
阅读剩余部分 →Oracle cloud申请与R探长抢实例
近期成功申请到了Oracle cloud的账号,简单总结一下相关信息。
号与永久免费使用的说明**
Out of capacity for shape VM.Standard.E2.1.Micro in availability domain AD-1. Create the instance in a different availability domain or try again later. If you specified a fault domain, try creating the instance without specifying a fault domain. If that doesn’t work, please try again later. Learn more about host capacity.
听说最近(2024年11月14日)只有孟买可以手工创建成功,其它区域都比较难,上网找解决方案,试试R探长脚本。
详情可参考:https://telegra.ph/oracleR-Bot-03-04
核心步骤
wget -N "https://raw.githubusercontent.com/jin-gubang/public/main/oracle_role_apiuser_policy.sh" --no-check-certificate && chmod +x oracle_role_apiuser_policy.sh && bash oracle_role_apiuser_policy.sh
关于运行语句的内容及安全性,有能力的可以查看GitHub
https://github.com/jin-gubang/public/blob/main/oracle_role_apiuser_policy.sh
运行后的效果如下:
在服务器上安装 v2ray-plugin 插件
在服务器上安装 v2ray-plugin 插件,具体步骤如下:
在安装 v2ray-plugin 之前,需要确保服务器上已经安装了 Shadowsocks 以及相关的依赖,如 wget 和 unzip。
运行以下命令来更新系统并安装依赖:
sudo apt update
sudo apt install wget unzip -y
- 下载 v2ray-plugin
https://github.com/shadowsocks/v2ray-plugin/releases
wget https://github.com/shadowsocks/v2ray-plugin/releases/download/v1.3.2/v2ray-plugin-linux-amd64-v1.3.2.tar.gz
- 解压 v2ray-plugin
下载完成后,使用以下命令解压:
tar -zxvf v2ray-plugin-linux-amd64-v1.3.2.tar.gz
解压后会生成一个可执行文件 v2ray-plugin。
阅读剩余部分 →网页正常,app登录自托管bitwarden报错:An error has occurred.
更新ios到18系统之后,网页正常,app登录自托管bitwarden报错:An error has occurred.
尝试如下解决方案:
阅读剩余部分 →