2020年7月9日星期四

操作系统的coredump

apt-get install systemd-coredump 安装coredump工具,这样应用程序有coredump的时候就会产生coredump文件了。

man coredump.conf,查看修改coredump相关配置,修改完后 systcl -p 生效配置。

coredump生成主要有两种方式。一种是external,文件生成在/var/lib/systemd/coredump下。另一种是journal,可以通过 man journald.conf 查看相关配置。

2020年4月28日星期二

python datetime计算时间差

from datetime import datetime
begin = datetime.strptime('00:01:00.000', '%H:%M:%S.%f')
end = datetime.strptime('00:01:00.002', '%H:%M:%S.%f')
duration = begin - end
duration.total_seconds()  // duration.seconds只计算秒的部分,duration.microseconds只计算毫秒的部分。计算时间差使用total_seconds

2020年2月19日星期三

Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

参考 https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry/46970344#46970344

apt-get remove python-pip python3-pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
python3 get-pip.py

如果运行get-pip.py很慢,修改文件中的args = ["install", "--upgrade", "--force-reinstall", "-i", "https://pypi.douban.com/simple"] + args,新增了pip源即可。

2020年1月13日星期一

bazel 2.0.0新版本问题

更新了最新的bazel,报错:
name 'maven_server' is not defined
name 'maven_jar' is not defined

新版本不支持这些了,需要切换到旧版本的bazel,参考:https://github.com/google/mediapipe/issues/337

mac系统如何降级bazel,参考https://github.com/bazelbuild/homebrew-tap/issues/39

2019年12月20日星期五

统计文件夹中所有wav的时长

ls | xargs -i sox {} -n stat 2>&1 | grep Length | awk '{print $3}' | awk '{sum+=$1} END {print sum}'

2019年12月13日星期五

大量http连接TIME_WAIT

netstat -alntp | grep 38080,发现大量的TIME_WAIT,不确定是否正常。

参考了https://cloud.tencent.com/developer/article/1038071,修改/etc/sysctl.conf,增加三行:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

/sbin/sysctl -p 使配置生效。

不确定是否能解决问题,待观察。