CentOS 使用 Remi 源安装 PHP8 时将配置放入 /etc/ 而不是 /opt/
关键点:不要直接 yum install php81-php-* 这样会安装到 /opt 目录,而应该启用 php81 后,依旧使用 yum install php-* 来安装(别加 php8 前缀)。
# CentOS 7
yum install epel-release yum-utils
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
#或 yum install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-rel...
yum install ImageMagick
批量压缩图片大小
# 将宽度大于 800 的图片处理成宽为 800 的图片
find ./ -type f -regextype 'posix-egrep' -iregex '.*\.(jpg|png|gif)' | while read line
do
echo $line
convert -resize '800>' $line $line
done
# 多行转成一行:
# bash:
find ./ -type f -regextype 'posix-egrep' -iregex '.*\.(jpg|png|gif)'...
启用防火墙
systemctl start firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent
firewall-cmd --remove-port=3306/tcp --permanent
firewall-cmd --reload
启用交换空间 swap 分区
dd if=/dev/zero of=/swapfile bs=1024k count=8192
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
软件源
...
安装Download URL Rewrite Module 2.1
/web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="http2https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input=&q...
不推荐使用本文的方法,建议使用 props 和 emit
方法来自:stackoverflow.com/questions/55316490,在用这个方法前可以先试试 this.$refs[‘子组件’].doSth(),比下文的方法简单。
子组件
export default {
methods: {
doSth() {
console.log('子组件的 doSth 方法');
},
},
mounted() {
let self = this;
self.$emit('callback', {
doSth: () =&...
# app/Providers/AppServiceProvider.php
public function boot()
{
DB::listen(function ($query) {
$location = collect(debug_backtrace())->filter(function ($trace) {
return !str_contains($trace['file'], 'vendor/');
})->first(); // grab the first element of non vendor/ calls
$bindings = implode(", ", $query->bindings); // format t...
生成版本号配置的文件
hooks.js
const packageInfo = require('./package.json');
const fs = require('fs');
const gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim();
const ref = gitHEAD.split(': ')[1];
let version = packageInfo.version;
let commitId = ref ? fs.readFileSync('.git/' + ref, 'utf-8').trim() : gitHEAD;
let date = (new Date()).toISOString();
let result = `
module.exports = {...
驱动来自 blackPantherOS/rtl8192fu(代码被清了,历史记录里还有,拉下来后 git reset –hard 即可)
下载
安装后需要重启
开机后如果没有出现 WiFi 设备而是多了一个 CD-ROM 的话,执行:
usb_modeswitch -v 0bda -p a192 -KW
# usb_modeswitch 不会开机自动运行可以参考这个:
# mv /lib/udev/rules.d/40-usb_modeswitch.rules /lib/udev/rules.d/61-usb_modeswitch.rules
# sudo udevadm control --reload-rule...
.env
APP_VERSION=v2.0.1 beta
app/Http/Kernel.php
protected $middleware = [
// ...
\App\Http\Middleware\Version::class, // 在 http header 中返回当前接口的 Git 版本
];
app/Http/Middleware/Version.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class Version
{
/**
* 在 header 中添加项目 Git 库的 commit id
*
* @param...
function dodash(callsign = '') {
var sign = callsign.match(/[a-z0-9]+/)[0].toUpperCase();
var hash = 0x73e2;
var i = 0;
while (i < sign.length) {
var f = sign[i].charCodeAt();
hash ^= f<<8;
if (sign[i + 1]) {
var s = sign[i+1].charCodeAt();
hash ^= s;
}
i += 2;
}
return Math.abs(hash);
}
var code = dodash('BZ0ZZZ');
co...
const packageInfo = require('./package.json');
const fs = require('fs');
const gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim();
const ref = gitHEAD.split(': ')[1];
let version = packageInfo.version;
let commitId = '';
if (ref) {
commitId = fs.readFileSync('.git/' + ref, 'utf-8').trim();
} else {
commitId = gitHEAD;
}
console.log(version, commitId);
fs.readFile('./...
介绍
laravel-nestedset(Nested Set Model)
安装
composer require kalnoy/nestedset
用法
// database/migrations/2020_08_10_155445_create_category_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCategoryTable extends Migration
{
public function up()
{
Schema::create('categor...
当服务器宕机时,同一个页面的所有接口都会报错,导致页面出现一堆消息,本文方法可以让相同内容的消息只显示最后一个。
不支持 .error() 式的用法。
操作步骤
编辑 main.js,添加以下代码:
import { Message } from 'element-ui';
var MessageStack = [];
Vue.prototype.msg = function(config = {}) {
MessageStack.forEach(function(item = {}) {
if (item.message == config.message && item.type == ...