Wake Me Up When September Ends.

A wanderer capable of grasping the beauty of the grass, with a heart full of ancient charm, and a fondness for playful wit. Those who understand my words are knowledgeable individuals; those who decipher my code truly comprehend the essence. I am a wandering code swordsman, carrying my skills and riding freely through the digital world.

比较新的linux服务器,常常用systemctl 管理服务,一些比较老的服务器会使用service来管理服务,比如一台安装centos 6.5 数据库服务器,那么servicesystemctl有哪区别?

service 命令

service 命令是传统的SysV init 系统的服务管理工具。它提供了一种简单的方法来启动、停止、重启和查询系统服务的状态。它通过读取位于 /etc/init.d/ 目录下的服务脚本来管理服务。使用 service 命令可以使用服务脚本的名称来操作服务,例如:

阅读全文 »

PHP 8.3已经如期发布,看一下新版特带来哪些特性!

常量类型化(Typed class constants)

定义常量目前可以标识类型了!

8.3 之前

interface I {
    // 过往历史长河中总是认为PHP常量总是一个字符串
    const PHP = 'PHP 8.2';
}

class Foo implements I {
    // 但是实现类可能会将其定义为数组。
    const PHP = [];
}

8.3 之后

interface I {
    const string PHP = 'PHP 8.3';
}

class Foo implements I {
    const string PHP = [];
}

//代码会发生致命错误:无法将数组用作类常量的值
阅读全文 »

很多时候我们在git库中,不小心把应该忽略的文件或目录提交远程库中,比如.idea.ivscode等。把远程删除,本地不发生变化,以下操作即可:

1.使用git rm 命令

git rm -r –cached 要删除的文件名或目录,如:

git rm -r --cached .idea #--cached 只删远程仓库的文件,不会删除本地的

2.提交操作记录描述

git commit -m '删除XX文件'

3.推送到远程仓库

git push -u origin <branch_name>

算法的本质

算法(algorithm)的本质是将问题划分为一系列可执行的步骤,并通过合理的计算和操作来达到预期的结果。同一个问题可以使用不同算法解决,但计算过程中消耗的时间和资源可能千差万别。

那如何比较不同算法之间的优劣呢?目前分析算法主要从时间和空间两个维度进行。

  1. 时间维度:时间复杂度(time complexity),算法需要消耗的时间。
  2. 空间维度:空间复杂度(space complexity),算法需要占用的内存空间。

因此,分析算法利弊主要从时间复杂度和空间复杂度进行。大多时候二者不可兼得,有时用时间换空间,有时用空间换时间,来满足所在场景需要!

阅读全文 »