分类 工作心德 下的文章

mysql全文索引实现模糊查询

配置mysql的ngram,打开mysql.ini的配置文件,编辑在[mysqld]下面加入这样的配置

# vim /etc/my.cnf
[mysqld]
ngram_token_size=2
ft_min_word_len=1 //最小分词长度(默认是4,小于4则忽略搜索)

保存退出,并重启mysql

# service mysql restart

再登入mysql,并通过命令查看:

mysql> show variables like 'ngram_token_size%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| ngram_token_size | 1     |
+------------------+-------+

创建测试表

CREATE TABLE `test` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(128) DEFAULT NULL,
  `data` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  FULLTEXT KEY `name` (`name`) WITH PARSER ngram 
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO test VALUES(null,'welcome to you!',unix_timestamp());
INSERT INTO test VALUES(null,'this is the fan site of you xp 你好',unix_timestamp());
INSERT INTO test VALUES(null,'hello phpjs,you are welcome',unix_timestamp());
INSERT INTO test VALUES(null,'fuck you tomorrow!!',unix_timestamp());

阅读

配置websocket+ssl

location /wss {
        proxy_pass http://localhost:2346;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_connect_timeout 5s; #配置点1
        proxy_read_timeout 60000s; #配置点2,如果没效,可以考虑这个时间配置长一点
        proxy_send_timeout 60000s; #配置点3
    }

证书是https的证书,只需要往nginx下新增便可

composer忽略版本号

composer install --ignore-platform-reqs//安装
or
composer update --ignore-platform-reqs//更新

开启Chrome自带的多线程下载功能

  1. 打开 Chrome 浏览器,国产 Chrome 内核的浏览器通通适用,包括前段时间推送的新版 Edge 也可以
  2. 在地址栏输入 chrome://flags/#enable-parallel-downloading
  3. 打开后如下图模式
    201911201574231257754319.jpg
  4. 选择“Enable”,出现"Relaunch"(重启浏览器),点击它
  5. 重启后就开启了多线程下载功能,接下来咱们再来看看之前文件的下载速度。
  6. 201911201574231315160445.gif

laravel获取路由的两种方式

$routes = app()->router->getRoutes();
//第一种
foreach ($routes as $k => $value) {
    if($value->action['namespace'] == 'App\Http\Controllers\Api') {
        $path[$k]['uri'] = $value->uri;
        $path[$k]['path'] = $value->methods[0];
    }
}
dump($path);

//第二种
$data = [];
$routes = collect($routes)->map(function ($route) use ($data) {
    if($route->action['namespace'] == 'App\Http\Controllers\Api') {
        $data['uri'] = $route->uri;
        $data['path'] = $route->methods[0];
    }
    return $data;
})->filter()->all();
dump($routes);
备案号:粤ICP备18155514号-2