window下查找监听端口进程并关闭

测试mock服务程序在windows下运行,强制关闭后终端cmd后再次启动时发现, 端口已经被占用。

2022-11-29 · 3 min · 541 words · Garlic Space

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,) 官方文档中描述: Note that it is actually the comma which makes a tuple, not the parentheses. The parentheses are optional, except in the empty tuple case, or when they are needed to avoid syntactic ambiguity. For example, f(a, b, c) is a function call with three arguments, while f((a, b, c)) is a function call with a 3-tuple as the sole argument. ...

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

mysql error 1364 Field doesn't have a default values

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

2022-04-30 · 2 min · 411 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 · 89 words · Garlic Space

vim putty gruvbox

putty 使用的是putty进行访问,可以使用gruvbox 提供的配色访问进行调整。 可以使用下面链接进去: 1 https://github.com/morhetz/gruvbox-contrib/tree/master/putty 其他工具 如果使用是其他工具也可以找到对应的工具 1 https://github.com/morhetz/gruvbox-contrib 操作系统自带Vim 如果使用的操作系统自带Vim工具,可以下载下面工具编辑~/.vimrc 1 2 $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 1 2 3 4 5 6 7 $ cat ~/.vimrc 。。。 call plug#begin() Plug 'morhetz/gruvbox' call plug#end() 。。。 $ vi打开后 1 :PlugInstall grubbox提供的一些安装方法 1 https://github.com/morhetz/gruvbox/wiki/Installation 参考及引用 https://opensource.com/article/20/2/how-install-vim-plugins 图片from 江金倫 彰化縣-竹塘鄉-竹塘木棉道

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

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

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

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

centos8 过滤 syslog信息

服务器(centos8)在用户登录的时候会出现一些登录日志。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 example.com systemd[1]: Started /run/user/0 mount wrapper. example.com systemd[1]: Created slice User Slice of UID 0. example.com systemd[1]: Starting User Manager for UID 0... example.com systemd[1]: Started Session 51 of user root. example.com systemd[20871]: Starting D-Bus User Message Bus Socket. example.com systemd[20871]: Reached target Timers. example.com systemd[20871]: Reached target Paths. example.com systemd[20871]: Listening on D-Bus User Message Bus Socket. example.com systemd[20871]: Reached target Sockets. example.com systemd[20871]: Reached target Basic System. example.com systemd[20871]: Reached target Default. example.com systemd[20871]: Startup finished in 51ms. example.com systemd[1]: Started User Manager for UID 0. example.com systemd[1]: session-51.scope: Succeeded. example.com systemd[1]: Stopping User Manager for UID 0... example.com systemd[20871]: Stopped target Default. example.com systemd[20871]: Stopped target Basic System. example.com systemd[20871]: Stopped target Sockets. example.com systemd[20871]: Stopped target Paths. example.com systemd[20871]: dbus.socket: Succeeded. example.com systemd[20871]: Closed D-Bus User Message Bus Socket. example.com systemd[20871]: Reached target Shutdown. example.com systemd[20871]: Starting Exit the Session... example.com systemd[20871]: Stopped target Timers. example.com systemd[1]: user@0.service: Killing process 20967 (systemctl) with signal SIGKILL. example.com systemd[1]: user@0.service: Succeeded. example.com systemd[1]: Stopped User Manager for UID 0. example.com systemd[1]: Stopping /run/user/0 mount wrapper... example.com systemd[1]: Removed slice User Slice of UID 0. example.com systemd[1]: run-user-0.mount: Succeeded. example.com systemd[1]: user-runtime-dir@0.service: Succeeded. example.com systemd[1]: Stopped /run/user/0 mount wrapper. 通过下面命令生成rsyslog的过滤规则; 1 2 3 4 5 6 7 8 9 10 echo 'if $programname == "systemd" and ($msg contains "Started /run/$msg" or $msg contains "Starting Session" or $msg contains "Started Session" or $msg contains "Created slice User" or $msg contains "Starting User Manager" or $msg contains "Starting User" or $msg contains "Starting D-Bus" or $msg contains "Reached target" or $msg contains "Listening on D-Bus" or $msg contains "Startup finished" or $msg contains "session-" or $msg contains "Stopping User Manager" or $msg contains "Stopped target" or $msg contain "dbus.socket" or $msg contains "Stopped target " or $msg contains "Removed session" or $msg contains "Removed slice User Slice of" or $msg contains "Stopped /run/user" or $msg contains "Stopped User Manager" or $msg contains "Stopping User Slice of" ) then stop' >/etc/rsyslog.d/ignore-systemd-session-slice.conf 根据实际情况, 新增相关过滤规则即可 ...

2022-01-02 · 2 min · 385 words · Garlic Space

C++ pointers 和reference

Pointer 和 references 主要区别 reference:总代表一个对象, 没有null reference;pointer则没有限制,可以为null poiner可以被重新赋值; reference不可以被重新赋值。 应用场景 如果在不同时间指向不同对象则使用pointer, 如果一旦代表该对象就不能改变选择reference. 相关代码: 使用reference更富效率, 如下面的例子,不需要测试rd的值,他代表某一个double 1 2 3 4 void printDouble(const double &rd) { cout << rd; } 而如果用pointers,那么就得测试下他是否为null。 1 2 3 4 5 6 void printDouble(const double *pd) { if (pd) { cout << *pd; } } 其他: 当然也有例外, 比如leveldb中就可以看到一下issue,DB::Get API should use reference instead of pointer #140 可以看到在下面一段描述,这里主要讨论关于函数参数使用引用还是指针。 1 2 3 4 5 6 7 8 9 10 11 Original issue 134 created by jvb127 on 2013-01-03T06:36:56.000Z: The current DB::Get API is defined as: virtual Status Get(const ReadOptions& options, const Slice& key, std::string* value) = 0; However, 'value' is not an optional parameter - it should point to a valid std::string. This is not checked by the implementation It could be considered to use a reference rather than a pointer: virtual Status Get(const ReadOptions& options, const Slice& key, std::string& value) = 0; 可以看到在google早些年的开发指南中,使用指针定义参数列表的参数和引用,通过const区分输入,输出参数。 ...

2021-10-25 · 2 min · 308 words · Garlic Space

docker 安装 Wordpress 及更新

今天登录到博客提示需要升级php,更新了下镜像顺便把之前搭建的步骤整理了一下。

2021-08-24 · 1 min · 123 words · Garlic Space

Vagrant 创建Centos8 环境

使用Vagrant重新搭建一个测试环境,只需要简单几步就可以启动一个测试环境。

2021-05-07 · 1 min · 43 words · Garlic Space