猫言猫语

严以律己·宽以待人·自强不息·知行合一

类 Unix 系统安装 Rust

| 类 Unix 系统安装 Rust已关闭评论

在终端中运行以下命令,然后按提示信息选择:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

CentOS 8 使用 iptables firewalld 后端实现

| CentOS 8 使用 iptables firewalld 后端实现已关闭评论

CentOS8 中 firewalld 默认使用的是 nftables,如果不想使用 nftables,还想使用老的 iptables 作为防火墙的后端实现,可以通过修改 /etc/firewalld/firewalld.conf 配置文件,将 FirewallBackend 配置项修改为 iptables 即可

# FirewallBackend
# Selects the firewall backend implementation.
# Choices are:
#	- nftables (default)
#	- iptables (iptables, ip6tables, ebtables and ipset)
FirewallBackend=iptables

macOS 管理 tftp 服务

| macOS 管理 tftp 服务已关闭评论

启动 tftp 服务的步骤

sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
sudo launchctl start com.apple.tftpd

tftp 服务的根目录在 /private/tftpboot 下

停止 tftp 服务的步骤

sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plist
sudo launchctl stop com.apple.tftpd

macOS 安装 DOSBox

| macOS 安装 DOSBox已关闭评论

brew install dosbox --cask
==> Installing Cask dosbox
==> Moving App 'dosbox.app' to '/Applications/dosbox.app'
🍺  dosbox was successfully installed!

SpringBoot 中引用 bootstrap 前端库

| SpringBoot 中引用 bootstrap 前端库已关闭评论

一种比较直接的方法是直接把 bootstrap 的 css/js 等资源文件手动拷贝到项目的 resources 目录下,这种方法的缺点是脱离了项目依赖包的版本管理,算不上好办法。

比较好的办法是通过 WebJars 的方式,将 bootstrap 以 pom 包的形式引用:

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>bootstrap</artifactId
    <version>5.3.2</version>
</dependency>

之后就可以通过 /webjars/bootstrap/5.3.2/css/bootstrap.min.css 这种路径访问到资源文件,但我们注意到这个路径下还存在 5.3.2 这样的版本号,如果升级 bootstrap 的版本,势必也要一同更新引用了这个资源的模板文件,此时我们还可以引入 webjars-locator 包:

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>webjars-locator</artifactId>
    <version>0.50</version>
</dependency>

然后我们就可以直接通过:/webjars/bootstrap/css/bootstrap.min.css 这样的路径访问了。

SpringBoot 集成 WebSocket

| SpringBoot 集成 WebSocket已关闭评论

首先添加一下 pom 依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-websocket</artifactId>
</dependency>

然后添加一个 WebSocketConfig 配置类

/**
 * @author wuwx
 */
@EnableWebSocket
@Configuration
public class WebSocketConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new TextWebSocketHandler(), "/websocket");
    }
}

启动这个 SpringBoot 项目就可以在 /websocket 进行 WebSocket 连接了

macOS 更新全部 cask 应用

| macOS 更新全部 cask 应用已关闭评论

默认 upgrade 是更新非 cask 的应用,如果想全部更新,需要增加 2 个参数

brew update
brew upgrade --cask --greedy

pecl 安装特定版本的 PHP 扩展

| pecl 安装特定版本的 PHP 扩展已关闭评论

默认使用 pecl 安装的 PHP 扩展是最新版本的,例如以下将安装 oci8-3.3.0

pecl install oci8

假如我们想安装 oci8-2.2.0 则需要需要使用以下的命令进行安装

pecl install oci8-2.2.0