iView select 表单验证踩坑

September 23, 2019 · 0 min · K8sCat

js 对象拷贝

今天写 Vue 前端项目的时候遇到这样一个问题(但这个问题和 Vue 似乎没有半毛钱关系), 就是存在一个对象, 怎样才能不改变这个原有的对象进行操作? 很明显, 简单的 let newObj = oldObj 是肯定不行的, 可以通过 浅拷贝 进行解决: let oldObj = { a: 1, b: '2' } let newObj = Object.assign({}, oldObj) 参考: https://juejin.im/entry/5a28ec86f265da43163cf720 https://www.cnblogs.com/linhp/p/6085826.html

September 22, 2019 · 1 min · K8sCat

Sublime 的使用

厌倦 vsc 了, 换 sublime 用用! 添加命令行启动(mac) # 我用的是zsh vi ~/.zshrc # 添加以下内容 alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" # 生效 source ~/.zshrc

September 18, 2019 · 1 min · K8sCat

Git 必备技能 - 版本回退

线上版本有bug, 想回退到之前的版本怎么办? $ git log --pretty=oneline 1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master) append GPL e475afc93c209a690c39c13a46716e8fa000c366 add distributed eaadf4e385e865d25c48e7ca9c8395c3f7dfaef0 wrote a readme file # 回退到上一个版本 $ git reset --hard HEAD^ # 回退到指定版本 $ git reset --hard eaadf4e385e86 参考: https://www.liaoxuefeng.com/wiki/896043488029600/897013573512192

September 16, 2019 · 1 min · K8sCat

crontab 无法执行 docker-compose 命令

0 0 * * * cd /somewhere && docker-compose up -d some-service 像这样的定时任务没法正常启动? This is unlikely to be an issue with docker-compose. It's good practice to use absolute paths in crontabs because your $PATH may not be the same as an interactive shell. Maybe add set -x to see why it's failing? # whereis docker-compose 0 0 * * * cd /somewhere && /usr/local/bin/docker-compose up -d some-service ...

September 11, 2019 · 1 min · K8sCat

如何使用 SQL 替换字段中的内容

最近写了一个爬虫, 并需要去除一些内容, 用的是 python 的 replace 方法, 但这个方法不会改变原有字符串, 所以数据库中存了很多 不干净 的数据, 但数据太多了, 删掉重新爬取需要很多时间, 那如何使用 sql 将这些数据更新一下呢? update your_table set your_column = replace(your_column, 'old_str', 'new_str') 参考: https://www.w3cschool.cn/sql/sql-replace.html

September 11, 2019 · 1 min · K8sCat

Docker 批量删除镜像或容器

# 删除所有<none>镜像 docker rmi `docker images | grep '<none>' | awk '{print $3}'` # 删除所有已退出的容器 docker rm `docker ps -a | grep Exited | awk '{print $1}'`

September 7, 2019 · 1 min · K8sCat

今天又被字符编码虐了, 我太难了

'\\u4eca\\u5929\\u53c8\\u88ab\\u5b57' \ '\\u7b26\\u7f16\\u7801\\u8650\\u4e86' \ '\\u002c\\u0020\\u6211\\u592a\\u96be\\u4e86'\ .encode('utf-8').decode('unicode_escape') Talk is cheap, show you the code. ...

September 4, 2019 · 1 min · K8sCat