叶测试 发布的文章
利用canvas给网页添加文字水印
addWaterMarker('我 是 水 印');
function addWaterMarker(str, w=300, h=300, c='#999999') {
// 创建一个 Canvas 元素
var canvas = document.createElement('canvas');
canvas.width = w; // 设置 Canvas 的宽度
canvas.height = h; // 设置 Canvas 的高度
// 获取 Canvas 的 2D 上下文
var ctx = canvas.getContext('2d');
// 设置文本样式
ctx.font = '18px Arial';
ctx.fillStyle = c;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
// 设置字体水平度
ctx.rotate(30 * Math.PI / 180);
// 绘制文本
ctx.fillText(str, canvas.width / 2, canvas.height / 2);
// 将 Canvas 转换为 PNG 图片
var dataURL = canvas.toDataURL('image/png');
// 创建body下的div元素,使用固定定位,将canvas所谓背景图并铺满全屏
let node = document.createElement("div");
node.style.pointerEvents = "none";
// 设置元素固定定位,并将宽高设置为100%,铺满全屏
node.style.position = "fixed";
node.style.width = "100%";
node.style.height = "100%";
node.style.top = "0";
node.style.left = "0";
node.style.opacity = "0.2";
node.style.zIndex = "998";
// 将canvas作为背景图,并设置左上开始,重复铺满全屏
node.style.background = "url(" + dataURL + ") left top repeat";
// 将创建的元素插入body中,作为body的子元素
document.body.appendChild(node);
}
ueditor section标签丢失class和style样式问题
这是由于ueditor开启了xss过滤
修改ueditor.config.js
中whitList的section标签即可
同样,如img标签默认也无style
Let’s Encrypt 证书自动更新
Let’s Encrypt 每次申请仅3个月有效期
更新命令:certbot renew
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
0 0 1 */2 * certbot renew --quiet --force-renewal
certbot安装yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
执行certbot certonly
测试安装是否正确
PS:我也是随便复制的,只是想到了Let’s Encrypt的自动更新便百度了一下 :)
解决ueditor复制section丢失class及style样式问题
在复制微信的文章格式到ueditor时发现section标签中的style和class属性丢失,严重影响美观。
原因:ueditor中有xss过滤器,默认启用,按照配置文件中的白名单列表,不在其中的将去除。
解决:
修改ueditor文件中whiteList中找到section那项,把class和style加入白名单。
composer install和update
所有依赖都存在composer.json中,由于composer.json中相应库版本号未必为精确版本,所以同一份composer.json在不同时刻我们可能拉取到不同的依赖文件(默认拉取最新),从而可能导致问题。
当你执行composer update的时候,composer会去读取composer.json中指定的依赖,去分析他们,并且去拉取符合条件最新版本的依赖。然后他会把所拉取到的依赖放入vendor目录下,并且把所有拉取的依赖的精确版本号写入composer.lock文件中。
composer install所执行的事情非常类似,只在第一步的时候有差别。当你本地如果已经存在一份composer.lock时,它将会去读取你的composer.lock而非composer.json,并且以此为标准去下载依赖。当你本地没有composer.lock的时候,它所做的事情和composer update其实并没有区别。
可指定依赖更新,如 composer update monolog/monolog
When calling Ramsey\Uuid\Converter\Time\DegradedTimeConverter::calculateTime on a 32-bit system, Moontoast\Math\BigNumber must be present.
解决:https://github.com/ramsey/uuid/issues/153
This is correct. Some of the math involved when dealing with UUIDs is impossible on 32-bit systems. This is because a UUID is an unsigned 128-bit integer, and the time portion of a version 1 UUID is an unsigned 64-bit number. PHP on a 32-bit system only supports signed integers up to 2147483647
.
Installing the moontoast/math library should fix your issue:
composer require moontoast/math
MYSQL5.7版本sql_mode=only_full_group_by问题
错误信息
`SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3
of SELECT list is not in GROUP BY clause and contains nonaggregated column
'iicityYii.opportunity_conditions.money' which is not functionally dependent
on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by`
- 查看 sql_mode
select @@global.sql_mode
- 去掉 ONLY_FULL_GROUP_BY
set @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
或者:SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
或者,修改mysql配置文件,新增
[mysqld]
sql-mode=""