AWS Amplify 部署 Hugo 项目失败报错
Amplify 自动部署 Hugo 项目在构建前端环节失败,报错某个模板时解析失败。类似:
JS 字符串数组的连接 array.join
使用 Array.prototype.join()
以下内容参考 MDN web docs
join() 方法将数组中所有元素成一个新的字符串并返回。默认使用逗号作为分隔符或使用指定的分隔字符。
语法:Array.join( )Array.join(separator)
举例:
cURL post JSON 数据
使用 curl 通过 post 方法提交 json 格式的数据:
Python 执行命令行程序并返回结果
使用 pexpect 库比较省心,使用方便。也不像使用 subprocess 会出现很多问题。
代码:
Git 替换分支(覆盖分支)
假设要将 main 分支完全替换成 dev 分支的内容(即用 dev 分支内容覆盖 main 分支内容):
CSS flexbox 内部元素居中
CSS:
.container{
display: flex;
justify-content: center; //水平居中
align-items: center; //垂直居中
}HTML:
shell 文本文件的倒数行(尾部几行)
tail -n 3 file 显示文件内容的最后3行
-n <行数>显示文件的尾部 n 行内容
tail 命令更多选项
- -f 循环读取
- -q 不显示处理信息
- -v 显示详细的处理信息
- -c<数目> 显示的字节数
- –pid=PID 与-f合用,表示在进程ID,PID死掉之后结束
- -q, –quiet, –silent 从不输出给出文件名的首部
- -s, –sleep-interval=S 与-f合用,表示在每次反复的间隔休眠S秒
macOS 如何关闭自启动的后台服务进程
删除如下三个目录中的 .plist 文件,或转移到一个备份文件夹里。
~/Library/LaunchAgents/~/Library/LaunchAgents/~/Library/LaunchDaemons/
Quote from ravbug.com:
OS to automatically run and re-launch headless background processes.
There are at minimum three such folders on macOS. They are:/Library/LaunchAgents,~/Library/LaunchAgents/, and/Library/LaunchDaemons
Python 删除文件夹
pathlib.Path.unlink()removes a file or symbolic link.
删除单个文件或文件符号链接os.rmdir()或pathlib.Path.rmdir()removes an empty directory.
删除一个空文件夹os.removedirs()remove recursive empty directories
删除多层的空文件夹shutil.rmtree()deletes a directory and all its contents.
删除文件夹,包括其中所有子文件夹和文件