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.

目前开发的笔记本使用的是ubuntu22.04.1 版本,时间长了系统里面或出现一些安装失败或配置错误的软件包,记录一下处理该问题的方法。

解决办法

命令如下:

# root  账号无需加上sudo
sudo apt purge $(dpkg -l|grep ^rc|awk '{ print $2 }')
sudo apt purge $(dpkg -l|grep iF|awk '{ print $2 }')
阅读全文 »

编写程序问题

Humen:如何对接MQTT服务?

Ai:

如果您想要连接到MQTT服务,首先需要安装MQTT客户端。安装完成后,您可以使用客户端连接到MQTT服务器。具体的步骤如下:

  1. 使用客户端连接到MQTT服务器。连接时需要提供服务器的地址和端口号。
  2. 使用客户端订阅感兴趣的主题。
  3. 使用客户端发布消息到指定主题。

如果您使用的是Python,可以使用paho-mqtt库来连接MQTT服务器。可以参考以下代码进行连接:

import paho.mqtt.client as mqtt

# 定义连接回调函数
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))

    # 连接成功后订阅主题
    client.subscribe("your_topic")

# 定义消息接收回调函数
def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))

# 创建MQTT客户端
client = mqtt.Client()

# 设置连接回调函数
client.on_connect = on_connect

# 设置消息接收回调函数
client.on_message = on_message

# 连接MQTT服务器
client.connect("your_mqtt_server", 1883, 60)

# 循环等待接收消息
client.loop_forever()

上面的代码展示了如何连接到MQTT服务器并订阅主题。您还可以使用client.publish()方法发布消息到指定主题!

阅读全文 »

一、Dockerfile 简介

Docker 镜像的定制实际上就是定制每一层所添加的配置、文件。如果我们可以把每一层修改、安装、构建、操作的命令都写入一个脚本,用这个脚本来构建、定制镜像,那么之前提及的无法重复的问题、镜像构建透明性的问题、体积的问题就都会解决。这个脚本就是 Dockerfile。

Dockerfile 是一个文本文件,其内包含了一条条的 **指令(Instruction)**,每一条指令构建一层,因此每一条指令的内容,就是描述该层应当如何构建。

阅读全文 »

Charles 官网 下载Charles,Debian系列发行版可以使用 apt-get install charles-proxy 安装,不过需要提前安装对应key才可以安装,我这边是直接下载安装包解压安装。

1.解压&安装

# 下载包具体以最新版本为准
tar -xvf charles-proxy-4.6.3_amd64.tar.gz

# 移动到程序安装目录
mv charles /opt/

# 检查一下 charles/bin/charles 是否具有执行权限没有需要`chmod u+x`
阅读全文 »