修改hosts文件解决github慢的问题
GFW原因导致github访问异常慢,git clone速度仅10K/s,需要在hosts文件中添加一些域名映射来改善github的访问。
hosts文件添加:192.30.253.113 github.com
GFW原因导致github访问异常慢,git clone速度仅10K/s,需要在hosts文件中添加一些域名映射来改善github的访问。
hosts文件添加:192.30.253.113 github.com
$phpWord = \PhpOffice\PhpWord\IOFactory::load("/test/test1.docx");
//创建注释
$comment= new \PhpOffice\PhpWord\Element\Comment('森森', new \DateTime(), 'my_initials');
$comment->addText('这是批注的信息内容', array('bold' => false, 'color'=>'ff0000'));
//添加到注释
$phpWord->addComment($comment);
$section = $phpWord->getSection(0);
//创建文本并添加注释
$textrun = $section->addTextRun();
$textrun->addText('这里需要进行');
$text = $textrun->addText('注释');
//将注释链接到刚创建的文本上
$text->setCommentRangeStart($comment);
//也可以为注释设置起始位置
//$comment->setStartElement($text);
//原始文本添加注释
//导出注释版
$phpWord->save("/test/test2.docx");
//设置localStorage
function setLocalStorage(key, value) {
var curtime = new Date().getTime(); // 获取当前时间 ,转换成JSON字符串序列
var valueDate = JSON.stringify({
val: value,
timer: curtime
});
try {
localStorage.setItem(key, valueDate);
} catch(e) {
// 兼容性写法
if(isQuotaExceeded(e)) {
console.log("Error: 本地存储超过限制");
localStorage.clear();
} else {
console.log("Error: 保存到本地存储失败");
}
}
}
function isQuotaExceeded(e) {
var quotaExceeded = false;
if(e) {
if(e.code) {
switch(e.code) {
case 22:
quotaExceeded = true;
break;
case 1014: // Firefox
if(e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
quotaExceeded = true;
}
break;
}
} else if(e.number === -2147024882) { // IE8
quotaExceeded = true;
}
}
return quotaExceeded;
}
//获取localStorage
function getLocalStorage(key, day=1) {
var exp = 60 * 60 * day; // 一天的秒数
exp = exp*1000;
if(localStorage.getItem(key)) {
var vals = localStorage.getItem(key); // 获取本地存储的值
var dataObj = JSON.parse(vals); // 将字符串转换成JSON对象
// 如果(当前时间 - 存储的元素在创建时候设置的时间) > 过期时间
var isTimed = (new Date().getTime() - dataObj.timer) > exp;
if(isTimed) {
console.log("存储已过期");
localStorage.removeItem(key);
return null;
} else {
var newValue = dataObj.val;
}
return newValue;
} else {
return null;
}
}
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开启了xss过滤
修改ueditor.config.js
中whitList的section标签即可
同样,如img标签默认也无style
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标签中的style和class属性丢失,严重影响美观。
原因:ueditor中有xss过滤器,默认启用,按照配置文件中的白名单列表,不在其中的将去除。
解决:
修改ueditor文件中whiteList中找到section那项,把class和style加入白名单。