首页
Uphie's Blog
取消

Go 实现 set

Go 开发过程中有时我们需要集合(set)这种容器,但 Go 本身未内置这种数据容器,故常常我们需要自己实现,其实实现也很简单。 附,推荐阅读:https://github.com/Visforest/goset map[xxx]struct{} 最常用和最容易想到的实现是使用 map,如: type StrSet struct{ data map[string]struct{...

其和大于指定值的长度最小的连续子数组

原题:https://leetcode.cn/problems/minimum-size-subarray-sum 问题 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl+1, …, numsr-1, numsr] ,并返回其长度。如果不存在符合条件的子数组,返回 0 。 示例...

error while loading shared libraries libcrypto.so.1.1

在 Ubuntu 22.04.2 LTS 上,mongodb 5.0.17 启动时报错, root@node1:/home/uphie# systemctl start mongo Job for mongo.service failed because the control process exited with error code. See "systemctl status mon...

Linux设置静态IP

由于最近 DIY 了一台主机,在新主机上创建Linux虚拟机做服务器集群需要服务器IP为静态IP,之前在Cent OS上设置过,这次使用Ubuntu 22.04.2 会有些区别,一并记录下设置方法。 设置静态IP重点是以下信息: 网段 网关 IP地址 dns服务器地址 禁用 dhcp 协议 虚拟机与宿主机之间使用了 NAT,宿主机网段和虚拟机网段不同。 ubun...

MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk.

程序有一天突然出错,和 redis 有关: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instan...

TencentOS安装gitlab

由于之前承担 git 的腾讯云服务器配置低性能较差,这次需要更换一个服务器,再安装一次 gitlab,记录一下过程。 gitlab 自带 nginx 、Postgresql、redis,读者要注意下避免重复安装。 本机系统版本: $ cat /etc/redhat-release TencentOS Server release 3.1 (Final) 安装依赖 $ yum ins...

nginx的http2模块安全漏洞处理

今天收到收到腾讯云的服务器报警: Nginx HTTP/2 模块安全漏洞 (CVE-2019-9511等) 漏洞标签 远程利用 漏洞类型 应用漏洞 威胁等级 高危 CVE编号 CVE-2019-9511/CVE-2019-9513/CVE-2019-9516 披露时间 2020-09-14 漏洞描述 漏洞存在于ngx_http_v2_modul...

客户端配置ssh密钥登录服务器

编辑 ~/.ssh/config 文件,如果没有的话先创建,添加以下内容: Host myserver HostName 192.168.0.9 User root Port 22 IdentityFile ~/.ssh/myserver.pem 其中: Host 是你给你的服务器取的别名; HostName 是你的服务器的真实地址,可以是IP、域名、Host; User 是你的服务器登...

No `meta.properties` found in /tmp/kraft-combined-logs (have you run `kafka-storage.sh` to format the directory?)

Ubuntu 版本为 22.04.1,Kafka 版本为 3.4.0,以 Kraft 模式启动。 打开电脑上的 Linux 虚拟机后,发现 Kafka 挂了,restart 也失败: root@node2:/home/uphie# systemctl restart kafka root@node2:/home/uphie# systemctl status kafka × kaf...

统计文件中列数据的和

还花呗的时候怀疑还款金额不对,想手动算一下,但又懒得用 Excel 等工具。想着在文件中每行记录下每笔的消费,然后使用命令行工具统计下: $ cat huabei.txt|sum 但结果明显错误,因为我猜想会有求和的命令程序,于是想当然地尝试使用了 sum 命令,命令可以运行,但 sum 程序用错了,sum 是计算并显示指定文件的校验和与文件所占用的磁盘块数。 后面找到了一个方法,用强...