#npm
为 shell 开启 npm 的 tab 命令补全
https://docs.npmjs.com/cli/completion
为 shell 开启 npm 的 tab 命令补全
// npm completion >> ~/.bashrc
npm completion >> ~/.zshrc
https://docs.npmjs.com/cli/completion
#mac
mac 升级到 catalina 之后 git 报错
解决方法很简单,运行以下命令更新即可
https://stackoverflow.com/questions/52522565/git-is-not-working-after-macos-update-xcrun-error-invalid-active-developer-pa
mac 升级到 catalina 之后 git 报错
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
解决方法很简单,运行以下命令更新即可
xcode-select --install
https://stackoverflow.com/questions/52522565/git-is-not-working-after-macos-update-xcrun-error-invalid-active-developer-pa
#python
python 中对 bytes 取反的正确姿势
不进行 & 操作的话位数会太长
https://stackoverflow.com/questions/28361323/python3-byte-level-bit-operations
python 中对 bytes 取反的正确姿势
b = bytes([~ b & 0xFF])
不进行 & 操作的话位数会太长
https://stackoverflow.com/questions/28361323/python3-byte-level-bit-operations
#js 浮点数陷阱
js 的浮点误差很容易触发
需要使用
注意这两个函数的参数略有不同结果也不太一样,我们一般关心小数点后的位数,因此比较推荐使用
参考
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
https://stackoverflow.com/questions/3337849/difference-between-tofixed-and-toprecision
https://github.com/camsong/blog/issues/9
js 的浮点误差很容易触发
0.14 * 10 // 1.4000000000000001
0.18 * 10 // 1.7999999999999998
需要使用
numObj.toPrecision(precision) (precision 用来指定有效数个数) 或 numObj.toFixed(digits) (digits为小数点后数字的个数)处理精度注意这两个函数的参数略有不同结果也不太一样,我们一般关心小数点后的位数,因此比较推荐使用
numObj.toFixed(digits)
10.001.toPrecision(1) // "1e+1" <- 这家伙贴心地帮你把数字转成了科学记数法 🌚
10.001.toPrecision(3) // "10.0"
10.001.toFixed(1) // "10.0"
参考
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
https://stackoverflow.com/questions/3337849/difference-between-tofixed-and-toprecision
https://github.com/camsong/blog/issues/9
#github
项目推荐
vue-interactive-paycard
A fantastic credit card form with smooth and sweet micro-interactions. Includes number formatting, validation and automatic card type detection. Built with vuejs and also fully responsive.
https://github.com/muhammederdem/vue-interactive-paycard
项目推荐
vue-interactive-paycard
A fantastic credit card form with smooth and sweet micro-interactions. Includes number formatting, validation and automatic card type detection. Built with vuejs and also fully responsive.
https://github.com/muhammederdem/vue-interactive-paycard
GitHub
GitHub - muhammed/interactive-card: Credit card form with smooth and sweet micro-interactions
Credit card form with smooth and sweet micro-interactions - muhammed/interactive-card
Arki 的每日 BUG 观察
#js str.replace('abc', '') 不是全部替换!!默认只替换第一个 repalceAll 请使用正则表达式 str.replace(/abc/g, '')
#tc39 #js
现在在 stage 3
https://github.com/tc39/proposal-string-replaceall
String.prototype.replaceAll proposal现在在 stage 3
https://github.com/tc39/proposal-string-replaceall
GitHub
GitHub - tc39/proposal-string-replaceall: ECMAScript proposal: String.prototype.replaceAll
ECMAScript proposal: String.prototype.replaceAll. Contribute to tc39/proposal-string-replaceall development by creating an account on GitHub.
#webpack
webpack-cli 里塞了魔法,只要配置名以
也就是说我们可以极低成本地使用 ES6 写 webpack 配置文件
细节
https://github.com/webpack/webpack-cli/blob/c193b96047f847f92ab8a19683f180855f740fc7/lib/groups/config.js#L56
(使用其他后缀也有其他效果,详见
https://github.com/gulpjs/interpret
webpack-cli 里塞了魔法,只要配置名以
.babel.js 结尾,并装有 @babel/register ,运行 webpack 就会自动走项目的 babel 配置也就是说我们可以极低成本地使用 ES6 写 webpack 配置文件
细节
https://github.com/webpack/webpack-cli/blob/c193b96047f847f92ab8a19683f180855f740fc7/lib/groups/config.js#L56
(使用其他后缀也有其他效果,详见
https://github.com/gulpjs/interpret
Arki 的每日 BUG 观察
#git 如何将某个 dist 文件夹单独部署 gh-pages 分支? 大部分人可能重新建个git仓库push cd dist git init git add . git commit -m 'Deploy' git remote add upstream [Upstream git URL] git push origin gh-pages 实际上,使用 subtree 这个稀有命令更方便更优雅 git subtree split --prefix dist -b gh-pages # create…
#git
试用了一下,有几个要注意的地方
git subtree split 的原理是 从原本 master 的完整提交中挑选出相关的 commit 作为子项目 commit
因此使用之前需要把 dist 提交到 master ,执行完命令记得
所以这个方案也不是特别完美,另外想要维持 gh-pages 的历史时还不知道该怎么办
试用了一下,有几个要注意的地方
git subtree split 的原理是 从原本 master 的完整提交中挑选出相关的 commit 作为子项目 commit
git subtree split --prefix dist -b gh-pages 这里的操作就是将 dist 相关的提交 cherry-pick 到 gh-pages因此使用之前需要把 dist 提交到 master ,执行完命令记得
git reset HEAD~ 回来所以这个方案也不是特别完美,另外想要维持 gh-pages 的历史时还不知道该怎么办
Arki 的每日 BUG 观察
#git 试用了一下,有几个要注意的地方 git subtree split 的原理是 从原本 master 的完整提交中挑选出相关的 commit 作为子项目 commit git subtree split --prefix dist -b gh-pages 这里的操作就是将 dist 相关的提交 cherry-pick 到 gh-pages 因此使用之前需要把 dist 提交到 master ,执行完命令记得 git reset HEAD~ 回来 所以这个方案也不是特别完美,另外想要维持 gh…
#git
看了一下 travis 的 gh-pages keep history 实现
总体思路也是老办法,cd 到 dist 目录后新建仓库,然后提交推送。
keep history 的核心代码在下面这句
https://github.com/travis-ci/dpl/pull/719/files#diff-cc5438ae072229825b07abf38951a912R132-R171
看了一下 travis 的 gh-pages keep history 实现
总体思路也是老办法,cd 到 dist 目录后新建仓库,然后提交推送。
keep history 的核心代码在下面这句
git checkout --orphan gh-pagesorphan branch 大致就是分支上的提交互不相关,因此提交时无需关心旧的 commithttps://github.com/travis-ci/dpl/pull/719/files#diff-cc5438ae072229825b07abf38951a912R132-R171
GitHub
Enable gh-pages to retain deploy branch history by webknjaz · Pull Request #719 · travis-ci/dpl
Closes travis-ci/travis-ci#7562
Resolves #704
This duplicates efforts of #715, but a bit differently. I wrote it a long time ago, but was unsure whether it's ready. Now I think it's...
Resolves #704
This duplicates efforts of #715, but a bit differently. I wrote it a long time ago, but was unsure whether it's ready. Now I think it's...
#java
今日 bug
YYYY 表示的是以周为基础的年度,会计人员依靠这一点来避免在两个不同的年份之间拆分周数
然后在跨年的这一周就会显示为 2020
解决方案是使用
扩展阅读
[Serious Security: The decade-ending “Y2K bug” that wasn’t](https://nakedsecurity.sophos.com/2019/12/23/serious-security-the-decade-ending-y2k-bug-that-wasnt/)
今日 bug
YYYY-MM-ddYYYY 表示的是以周为基础的年度,会计人员依靠这一点来避免在两个不同的年份之间拆分周数
然后在跨年的这一周就会显示为 2020
解决方案是使用
yyyy-MM-dd 😷扩展阅读
[Serious Security: The decade-ending “Y2K bug” that wasn’t](https://nakedsecurity.sophos.com/2019/12/23/serious-security-the-decade-ending-y2k-bug-that-wasnt/)
Forwarded from YSC 的频道
草,刚刚在分析 KeePass 如何实现复制时不添加到 Win10 剪贴板历史记录,发现用的是 WinRT 的剪贴板 API,里面有个选项可以控制是否添加到历史记录。
然后尝试逆向 WinRT API 的实现,发现最终是调用 OleSetClipboard 来设置剪贴板的,但是仍然找不到哪个参数控制的,于是往回找。发现 DataPackagePropertySet 有几个文档中找不到的 Property,其中一个是 CanIncludeInClipboardHistory,突发奇想去网上搜一下,结果……………………
微软的文档直接就有写……
To stop content from being included in Clipboard History, set the registered format as CanIncludeInClipboardHistory with a DWORD value of zero. (A DWORD value of one will include the content).
https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats
然后尝试逆向 WinRT API 的实现,发现最终是调用 OleSetClipboard 来设置剪贴板的,但是仍然找不到哪个参数控制的,于是往回找。发现 DataPackagePropertySet 有几个文档中找不到的 Property,其中一个是 CanIncludeInClipboardHistory,突发奇想去网上搜一下,结果……………………
微软的文档直接就有写……
To stop content from being included in Clipboard History, set the registered format as CanIncludeInClipboardHistory with a DWORD value of zero. (A DWORD value of one will include the content).
https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats
Docs
Clipboard Formats - Win32 apps
A window can place more than one object on the clipboard, each representing the same information in a different clipboard format. Users need not be aware of the clipboard formats used for an object on the clipboard.