python tuple 一个元素时需要增加逗号

项目中使用python tuple时如果是一个元素一定要增加一个逗号,使用python3看下输出。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 >>> t(0) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 't' is not defined >>> t=(0) >>> print(type(t)) <class 'int'> >>> print(t) 0 >>> t=(0,) >>> print(type(t)) <class 'tuple'> >>> print(t) (0,) ...

2022-05-08 · 1 min · 304 words · Garlic Space

单元测试

单元测试的目的并不是查找bug,而是帮助我们更好的设计我们的代码,如何合理的来拆分我们的代码。

2022-05-08 · 3 min · 1321 words · Garlic Space

Non-Constructible Change

问题: 给定一系列正整数,代表硬币的面值,找到无法从这些整数组连续组合成的最小值。比如 coins=[1,2,5], 最小不能组合成的值为4. 解答: 如果下一个整数大于前面所有值的累积和 + 1,那么就知道最小值,如果能被组合范围[0, sum], 下一个数据为y, 如果能构造出联系数据 sum+1 要在 [y,sum+y]范围内。也就是y<=sum+1<=sum+y。 由于排序数组 y>=1, 也就是满足y>sum+1。就可以找到最小组合值。 ...

2022-05-04 · 1 min · 442 words · Garlic Space

Debugging NGINX

这篇文章来自nginx document

2022-05-01 · 2 min · 1002 words · Garlic Space

mysql error 1364 Field doesn't have a default values

前一阵在做一个系统迁移工作, mysql数据库版本进行了升级,

2022-04-30 · 2 min · 801 words · Garlic Space

git 常用命令

查看分支 1 git branch -av 导出分支 1 2 git remote add origin ssh://git@ip:port/branch.git git checkout -b localbranch origin/remotebranch 稀疏导出 1 2 3 4 5 6 git init <project> cd <project> git config core.sparsecheckout true echo "path1/" >> .git/info/sparse-checkout echo "path2/" >> .git/info/sparse-checkout git pull origin remotebranch 恢复误删除文件 1 2 3 git status git reset HEAD git checkout . non-fast-forward 1 2 git fetch origin master git merge origin FETCH_HEAD 本地rebase导致non-fast-forward 1 2 git reflog 查看HEAD的移动历史 git reset --hard xxxx 提交 1 git push origin localbranchname ...

2022-04-05 · 1 min · 146 words · Garlic Space

Message-Based Load Balancing

最近工作中涉及到一些负载均衡一些知识这里今天这篇文章是F5的 Message-Based Load Balancing。 这是2009年发布的一篇文章,后续F5已经建议从MBLB迁移到MRP功能模块。 ...

2022-04-01 · 2 min · 990 words · Garlic Space

Tournament winner

问题 循环赛每个队对战所有其他对手, 胜利者记3分, 失败者记1分. 两个数组做为输入, competitions,存放主场队和客场队, results存放结果, 1表示主队获胜, 0表示客队获胜。返回分数最高的队伍。 ...

2022-03-30 · 1 min · 267 words · Garlic Space

vim putty gruvbox

putty 使用的是putty进行访问,可以使用gruvbox 提供的配色访问进行调整。 可以使用下面链接进去: 1 https://github.com/morhetz/gruvbox-contrib/tree/master/putty 其他工具 如果使用是其他工具也可以找到对应的工具 ...

2022-03-21 · 1 min · 205 words · Garlic Space

centos8 yum 相关国内镜像仓库弃用(deprecated)

今天centos8使用yum安装软件时报错。

2022-02-03 · 1 min · 287 words · Garlic Space