我们知道 Windows 电脑没有监控 CPU 温度的功能,如果想知道 CPU 温度需要安装软件,比如鲁大师。
那么是否可以不安装软件,就实现 CPU 的温度监控呢?
以管理员权限执行如下 PowerShell 脚本:
方法一:
方法二:
我们知道 Windows 电脑没有监控 CPU 温度的功能,如果想知道 CPU 温度需要安装软件,比如鲁大师。
那么是否可以不安装软件,就实现 CPU 的温度监控呢?
以管理员权限执行如下 PowerShell 脚本:
方法一:
方法二:
蓝牙鼠标正常配对使用,刚刚开始使用正常的。但是过一阵子不使用蓝牙鼠标,或者鼠标电源调整成关闭状态,或者拔掉电池,大概率连接不上。需要在电脑上手工删除蓝牙连接,然后重新配对。
刚开始猜测是鼠标使用的 南孚 TENAVOLTS 锂电池 DC-DC 降压电路释放的信号干扰到了蓝牙通信协议或者电压纹波导致芯片工作异常,在更换为普通的 1.5V 非充电电池之后,问题依旧复现。
无意中点击蓝牙设备列表,发现重新配对之后 Lenovo ThinkLife 的 MAC 地址变化了。这说明两者进行配对的时候使用了动态协商出来的临时 MAC 地址,没有使用设备的真实 MAC 地址。这样诱发一个问题,那就是鼠标需要记住这个动态协商出来的 MAC 地址,然后用这个地址进行通信。这样就能解释为什么拔掉电池多等一会儿,让设备完全放电,再插上电池很容易复现这个问题。因为长时间断电之后,设备上记录的协商 MAC 地址丢失了。
网站配置了 robots.txt 来控制爬虫的行为,由于文件里面有中文注释,导致直接浏览器打开之后中文显示乱码。
对于 Apache 服务器,可以通过在 .htaccess 中配置文件的字符集格式解决显示乱码问题。
Set universal UTF-8 encoding:
Set UTF-8 encoding on select file types only:
Note: An .htaccess file located in a sub-directory overrides any duplicate rules from previous .htaccess files. For example, if you have a .htaccess file located in the root defining a 404 and 403 error page, and another .htaccess located in the “test” folder defining only a 404 error page, any files and folders in the “test” folder will use the 404 page defined in the "test" .htaccess file, and the 403 page defined in the root .htaccess file.
在参照使用 Ubuntu 22.04使用Podman部署OpenGrok的详细教程 进行 OpenGrok 部署的时候,其中的 Dockerfile 配置了两个独立的镜像来源。恰好这两个镜像来源都需要配置 PIP 国内镜像。于是思考如何在同一个 Dockerfile 存在两个镜像的场景下,如果共用一个变量。
研究了一阵,发现还是通过 ARG 变量实现上述想法。
具体说明参考下面的完整文章。
The Docker ecosystem is rich with tools and best practices that streamline containerization. One of these practices is using multistage builds to create lean, efficient containers. However, as your Dockerfiles grow more complex, managing variables and maintaining readability can become a challenge. Enter the ARG instruction—your key to sharing variables across stages in a multistage Dockerfile. In this blog post, we’ll explore how ARG can simplify your Dockerfiles, enhance reusability, and maintain cleaner code.
Multistage builds in Docker allow you to use multiple FROM statements in a single Dockerfile, creating separate stages that can be used to build a final image. This method is particularly useful for creating lightweight production images, as you can copy only the necessary artifacts from earlier stages. Here’s a quick example to illustrate:
In this simple example, the build stage compiles a Go application, and the production stage creates a minimal image containing only the compiled binary.
While multistage builds are powerful, they can introduce a common challenge: variable reuse. Suppose you need to use a specific version of an application or a common path across multiple stages. Without a way to share variables, you might end up duplicating code, leading to maintenance headaches and potential errors.
Here’s where ARG (argument) comes into play. The ARG instruction allows you to define variables that can be used throughout your Dockerfile, even across different stages.
The ARG instruction defines a variable that users can pass at build time to customize the build process. Unlike environment variables (ENV), which are persisted in the image, ARG variables are only available during the build process and do not become part of the final image.
Let’s start with a basic example:
In this example, BASE_IMAGE is an argument that can be overridden when building the Dockerfile. The default value is alpine:3.12, but you could specify a different base image at build time:
The real power of ARG comes into play with multistage builds. To share ARG variables between stages, you need to redefine the ARG in each stage. Let’s look at a more advanced example:
In this Dockerfile, we define GO_VERSION as an argument at the top. By repeating ARG GO_VERSION in each stage, we make the argument available for use. Notice how the build stage uses GO_VERSION to specify the Go image, and the production stage echoes the Go version used.
You might find it useful to combine ARG with ENV to set environment variables conditionally based on build arguments. This can further enhance your Dockerfile’s flexibility.
Following example demonstrates the use of ARG and ENV to have a generic Dockerfile for a Turborepo application:
Environment Variables (ENV):
Build Arguments (ARG):
When working with ARG variables, you might run into issues where arguments aren’t passed correctly or variables aren’t set as expected. Here are some tips to help you debug:
Check Build Logs: Use docker build with the --progress=plain flag to get more detailed logs that can help identify where arguments are being used or missed.
Echo Variables: Add RUN echo statements to print the values of your ARG variables during the build process.
Use Default Values: Define sensible default values for your ARG variables to ensure that your build doesn’t fail if arguments are not provided.
Using ARG to share variables across stages in a multistage Dockerfile can significantly improve your Docker builds’ maintainability and flexibility. Whether you’re building lightweight production images or dynamically configuring your builds, ARG provides a powerful tool to streamline and enhance your Dockerfile.
AGP 4.2 后,默认关闭了 so 文件的压缩。
AGP 7.1 且 minSdkVersion>=23 后默认关闭了 dex 文件压缩,app bundle 打包不受影响
升级到 AGP7 之后发现打包出来的 APK 变大不少,差不多增加了三分之一的大小。将 APK 拖入 Android Studio 中分析对比下之前的 APK 发现主要 so 文件增大、dex 文件未压缩。
AGP 3.6 之后默认关闭了 so 压缩,声明为 true 就行了。
minSdkVersion < 23 或 Android Gradle Plugin < 3.6.0 情况下,打包时 android:extractNativeLibs=true;
minSdkVersion >= 23 并且 Android Gradle Plugin >= 3.6.0 情况下,打包时 android:extractNativeLibs=false;
或者
There are several Gnome Shell extensions to display system resource usage in Ubuntu, but in this tutorial I’m going to introduce an indicator that works in not only GNOME, but also Unity, MATE, and Budgie desktop environments.
It’s Indicator-SysMonitor, a free and open-source applet developed by the leader of Ubuntu Budgie team.
With it, user can display the usage and/or temperature of the following system resource in top-panel:
Most important is that user can customize the output, by setting which one or ones to display, in which order with which text. User just need to click the indicator on panel to open ‘Preferences’ dialog from pop-down menu, and format the output code in ‘Advanced’ tab.
The developer has an Ubuntu PPA contains the packages for Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.10, and even the next Ubuntu 23.04.
1. First, press Ctrl+Alt+T on keyboard to open a terminal window. When it opens, run command to add the PPA:
Type user password when it asks and hit Enter to continue.
2. For the old Ubuntu 18.04, you need to manually refresh package index after adding PPA:
3. And, install the indicator applet via command:
Finally, search for and open the applet like a normal application (it has same icon to System Monitor).
And click on the applet to open Preferences, and turn on start at login, configure output layout, refresh interval, etc.
You can close the applet by clicking on it in panel and select “Quit”. And remove the package at any time by running a single command in terminal window:
Also remove the PPA repository, either by running the command below or open “Software & Updates”and remove source line under “Other Software” tab.
This Indicator Shows CPU, GPU, Memory Usage on Ubuntu 22.04 Panel
Android 客户端使用 OKHTTP 的时候,需要通过修改底层的 Socket 来解决问题,比如设置 TCP 的心跳、修改TCP 的滑动窗口算法等。
相关的代码参考如下:
TCP includes a feature called Nagle’s Algorithm that will postpone sending small messages, in hopes of combining them with future messages. This can save bandwidth, because TCP has to include additional information along with each segment. Combining multiple small messages into a single segment reduces the overall bandwidth used. However, this increases the time it will take for some small messages to be received.
If you want all of your messages to be sent with the lowest latency possible, and you are willing to use additional bandwidth, you should disable Nagle’s Algorithm. WebSocket connections made with OkHttp have Nagle’s Algorithm enabled by default. There was an issue about this back in 2013, and the fix was to add the socketFactory and sslSocketFactory options.
To disable Nagle’s Algorithm using these options, you have to create classes that extend SocketFactory and SSLSocketFactory and call setTcpNoDelay(true) on their underlying sockets. You can use the following classes I created, which use composition:
You can create an OkHttpClient that uses these classes as follows:
WebSocket connections that your OkHttpClient makes will have Nagle’s Algorithm disabled.
Scarlet is a library from Tinder that uses OkHttp for WebSocket connections. If you pass the OkHttpClient that you created above to OkHttpClientUtils#newWebSocketFactory, all WebSocket connections made with Scarlet will have Nagle’s Algorithm disabled.
Note that all Scarlet WebSocket connections use OkHttp. As of writing this post, Scarlet is still using OkHttp version 3.11. OkHttp 4 has been out for over a year. If you are starting a new project, consider using OkHttp directly, rather than using Scarlet.
矩阵分解是一种常见的矩阵分析方法,主要用于处理高维数据的降维和特征提取。在现代数据挖掘和机器学习领域,矩阵分解技术被广泛应用于推荐系统、图像处理、文本摘要等方面。本文将介绍如何使用 C++ 的 Armadillo 库和 Eigen 库实现矩阵分解算法,并详细解释其核心原理、数学模型以及具体操作步骤。
矩阵分解是指将一个矩阵分解为多个较小的矩阵的过程。这些较小的矩阵通常具有一定的结构或特点,可以帮助我们更好地理解和处理原始矩阵。矩阵分解的主要目的是将复杂的高维数据降维,以便更容易地进行分析和处理。
常见的矩阵分解方法有非负矩阵分解(NMF)、奇异值分解(SVD)、高斯混合模型(GMM)等。这些方法各自具有不同的优势和局限性,适用于不同类型的数据和问题。
Armadillo 是一个 C++ 的数值计算库,提供了丰富的数据结构和算法实现,可以方便地处理向量、矩阵和高维数据。Armadillo 库支持各种线性代数计算、优化问题解决、随机数生成等功能,是一个强大的 C++ 数值计算工具。
Eigen 库是一个 C++ 的线性代数库,专注于高效的矩阵计算和求解线性方程组。Eigen 库提供了丰富的矩阵类和操作函数,支持各种基本线性代数操作、高级线性代数结构和求解线性方程组等功能。
在本文中,我们将使用 Armadillo 库和 Eigen 库实现矩阵分解算法,并详细解释其核心原理、数学模型以及具体操作步骤。
矩阵分解的核心概念包括:
矩阵:矩阵是由行向量组成的有序列。矩阵可以用来表示高维数据、系数、权重等信息。
矩阵分解:将一个矩阵分解为多个较小矩阵的过程。这些较小矩阵通常具有一定的结构或特点,可以帮助我们更好地理解和处理原始矩阵。
降维:矩阵分解的一个重要应用是降维,即将高维数据降至低维数据,以便更容易地进行分析和处理。
特征提取:矩阵分解还可以用于特征提取,即从原始矩阵中提取出具有代表性的特征,以便进行更精确的分类、聚类等分析。
Armadillo 库和 Eigen 库都是 C++ 的数值计算库,提供了丰富的数据结构和算法实现,可以方便地处理向量、矩阵和高维数据。这两个库在矩阵分解算法实现中发挥着重要作用,主要体现在以下几个方面:
数据结构:Armadillo 库和 Eigen 库提供了丰富的矩阵类和操作函数,可以方便地创建、操作和处理矩阵数据。
线性代数计算:这两个库提供了各种线性代数计算函数,如矩阵乘法、逆矩阵、求解线性方程组等,可以方便地实现矩阵分解算法中的核心计算。
高级线性代数结构:Armadillo 库和 Eigen 库支持各种高级线性代数结构,如对称矩阵、正交矩阵、特征分解等,可以帮助我们更好地理解和处理矩阵分解算法。
非负矩阵分解(NMF)是一种常见的矩阵分解方法,目标是将一个非负矩阵分解为两个非负矩阵的乘积。NMF 的核心思想是将一个矩阵分解为低维空间中的线性组合,从而实现数据的降维和特征提取。
NMF 的主要优势在于它可以处理非负数据,并且可以找到非负的基元素,这有助于解释和解释数据的特征。NMF还具有稀疏表示的优势,可以用于处理稀疏数据。
奇异值分解(SVD)是一种常见的矩阵分解方法,目标是将一个矩阵分解为三个矩阵的乘积。SVD 的核心思想是将一个矩阵分解为低维空间中的线性组合,从而实现数据的降维和特征提取。
SVD 的主要优势在于它可以处理正定矩阵,并且可以找到正定的基元素,这有助于解释和解释数据的特征。SVD 还具有稀疏表示的优势,可以用于处理稀疏数据。
假设给定一个非负矩阵
其中
NMF的目标是最小化以下目标函数:
假设给定一个矩阵
其中
SVD的目标是最小化以下目标函数:
其中
初始化
使用梯度下降法或其他优化算法最小化目标函数。
更新
返回
对矩阵
将
返回
矩阵分解技术在现代数据挖掘和机器学习领域具有广泛的应用前景,未来的发展趋势和挑战主要包括:
高效算法:随着数据规模的增加,矩阵分解算法的计算复杂度和运行时间将成为主要挑战。未来的研究需要关注如何提高矩阵分解算法的效率和并行性,以应对大规模数据处理的需求。
多模态数据处理:未来的矩阵分解技术需要能够处理多模态数据,如文本、图像、音频等。这将需要结合多种数据处理技术,并开发新的矩阵分解算法来处理不同类型的数据。
深度学习与矩阵分解的融合:深度学习技术在近年来取得了显著的进展,但与矩阵分解技术的结合仍然存在挑战。未来的研究需要关注如何将矩阵分解技术与深度学习技术相结合,以提高深度学习模型的性能和解释性。
解释性和可视化:矩阵分解技术的一个主要优势是它可以提供数据的解释性和可视化。未来的研究需要关注如何提高矩阵分解技术的解释性,以帮助用户更好地理解和利用分解结果。
Q: 矩阵分解与主成分分析(PCA)有什么区别?
A: 矩阵分解是将一个矩阵分解为多个较小矩阵的过程,目标是实现数据的降维和特征提取。主成分分析(PCA)是一种线性变换技术,目标是将原始数据变换为新的特征空间,使得新的特征具有最大的方差。矩阵分解和 PCA 都是用于数据降维和特征提取的方法,但它们的具体算法和实现方法有所不同。
Q: 矩阵分解与奇异值分解(SVD)有什么区别?
A: 矩阵分解是一种更一般的方法,可以将一个矩阵分解为多个较小矩阵的乘积,如非负矩阵分解(NMF)。奇异值分解(SVD)是矩阵分解的一种特殊实现,将一个矩阵分解为三个矩阵的乘积,即左特征向量矩阵、奇异值矩阵和右特征向量矩阵。奇异值分解是矩阵分解的一个具体实现,但矩阵分解可以包括其他实现。
Q: 如何选择矩阵分解算法?
A: 选择矩阵分解算法时,需要考虑数据类型、数据规模、计算资源等因素。如果数据是非负的,可以选择非负矩阵分解(NMF)算法。如果数据是正定矩阵,可以选择奇异值分解(SVD)算法。此外,还可以根据算法的计算复杂度、并行性和实现难度等因素进行选择。在实际应用中,可以尝试不同算法,并通过验证结果和性能来选择最佳算法。
论Devops及其应用。Devops是一组过程、方法与系统的统称,用于促进开发、技术运营和质量保障部门之间的沟通,协作与整合。它是一种重视软体开发人员和工厂运维技术人员之间沟通合作的模式。透过自动化“软件交付”和“架构变更”的流程,使得构建、测试,发布软件能够更加快捷、频繁和可靠。请围绕“Devops及其应用"论题,依次从以下三个方面进行论述。
概要叙述你参与管理和开发的软件项目,以及你在其中担任的主要工作.
结合你具体参与管理和开发的的实际项目,详细给述是哪些因素促使你决定引入Devops
结合你具体参与管理和开发的实际项目中如何引入DevOps
注:实际的论文题目内容与上述描述有较大出入,但本质上都是要求在项目中引入DevOps开发及自动化运维的过程,侧重于开发、管理。
在项目启动时,将安全目标融入需求分析与规划中。团队通过威胁建模评估系统可能存在的风险,并制定应对策略。此阶段工作包括:
开发阶段将安全审查融入编码实践中,通过自动化工具进行代码扫描和漏洞检测,确保每一行代码的安全性。具体任务包括:
在持续集成/持续交付(CI/CD)流水线中增加安全测试环节,确保构建的代码包满足安全要求。主要工作有:
通过基础设施即代码(IaC)技术构建安全的部署环境,确保基础设施配置符合安全标准。任务包括:
在运维阶段,实时监控系统运行状态,并通过日志分析与安全警报工具快速响应安全事件。工作内容包括:
以下仅提供论文写作思路,参考。
结合具体项目的特点和挑战,引入DevOps的决定因素如下:
客户因业务调整频繁提出新需求,传统开发模式中需求变更需等待当前阶段结束后处理,响应时间长,且易导致累积风险。DevOps中的持续交付(Continuous Delivery)可以实现频繁部署,快速响应业务变化。
每次上线需耗费大量时间进行手动操作,包括代码打包、环境配置和部署测试,效率低且错误率高。自动化部署工具(如 Jenkins 和 Ansible)可以将这些环节流程化,大幅提升效率。
开发团队关注功能实现,而运维团队关注系统稳定性,两者缺乏有效协作。在项目中曾因日志配置问题导致系统上线后频繁宕机,问题排查耗时数日,影响了客户的使用体验。DevOps强调开发与运维的一体化协作,可以从根本上解决此类问题。
传统开发模式中,测试通常集中在上线前进行,测试时间短且覆盖面不足,导致上线后问题频发。DevOps中的持续集成(Continuous Integration)将测试融入开发过程,确保每次代码变更都经过充分测试,从而提高代码质量。
随着项目扩展,系统组件数量增加,传统模式下环境配置复杂且易出错。基础设施即代码(Infrastructure as Code, IaC)技术通过代码化管理环境配置,解决了环境不一致的问题。
在项目的开发中期,笔者组织各团队成员分析当前开发与运维的痛点,结合项目需求明确了引入DevOps的目标:
结合项目需求,选择并配置了以下工具:
持续集成的主要工作包括:
流水线的持续交付部分负责将构建后的制品部署到测试环境或生产环境:
DevOps的成功实施离不开团队文化的转变。推动以下举措以优化团队协作:
引入DevOps后,项目的开发与交付流程得到了显著优化:
自动化部署减少了人为操作,部署时间从1天缩短至1小时,每周可实现多次上线。
通过自动化测试,代码缺陷发现率提高了40%,上线后问题数量减少了60%。
开发与运维之间的沟通更加顺畅,问题解决时间减少了50%。
借助监控与日志工具,系统异常能够被实时发现并快速处理,平均故障恢复时间从4小时减少到30分钟。
目前测试可用的是雷克沙(Lexar) PLAY 1TB SSD 固态硬盘 2230 M.2接口
New NVMe SSDs are not partitioned and will need to be both partitioned and formatted when first connected to the Raspberry Pi before they will be accessed in the Explorer.
Enable the external PCIe port on the Raspberry Pi 5. Edit /boot/firmware/config.txt and add the following at the bottom:
修改后的完整内容:
查看磁盘分区:
增加挂载项: