Forwarded from rxliuli
程序员,不要急于学习编程语言,先学会如何解决问题-InfoQ
https://www.infoq.cn/article/kRRB*FUJpRivjME95aCe
https://www.infoq.cn/article/kRRB*FUJpRivjME95aCe
www.infoq.cn
程序员,不要急于学习编程语言,先学会如何解决问题-InfoQ
这是一篇关于虚度青春的短篇回忆录。多年来,我一直在学习编程语言,然后用它们来构建更好的投资工具。在建立预测和风险管理模型之余,编程方面的工作堆积如山。但实际上,我并没有花太多时间在真正需要解决的问题上。我把大部分注意力放在了算法和编程语言上。多年来,我每周都要花几个小时学习计算机基础知识,却没有花太多时间应用这些知识来让现实世界变得更美好。而我的一个朋友却基于微软Office开发出了一个完整的产品
#js #vue
通过在写一个的vnode组件的方式简单地在 vue 实现渲染属性
https://stackoverflow.com/questions/49352525/can-you-render-vnodes-in-a-vue-template
通过在写一个的vnode组件的方式简单地在 vue 实现渲染属性
<div>
<vnode :vnode="value"/>
</div>
{
components: {
Vnode: {
functional: true,
render: (h, ctx) => ctx.props.vnode
}
},
props: ['value']
}
https://stackoverflow.com/questions/49352525/can-you-render-vnodes-in-a-vue-template
#ts
styled-components 的 type 包
解决方案(都不太好
1. 降级使用
围观地址(半年了还没修QAQ
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33311
styled-components 的 type 包
@types/styled-components 在 v.4.1.9 依赖了 @types/react-native ,导致全局类型冲突,结果就是使用了这个包的大部分项目 tsc 会打出 19 个类型冲突的错误解决方案(都不太好
1. 降级使用
@types/styled-components@v4.1.8
2. tsconfig设置 types 手动指定类型目录围观地址(半年了还没修QAQ
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33311
GitHub
node_modules/@types/react-native/globals.d.ts (36,15): Duplicate identifier 'FormData'. · Issue #33311 · DefinitelyTyped/DefinitelyTyped
If you know how to fix the issue, make a pull request instead. I tried using the @types/styled-components package and had problems because since of v.4.1.9 another conflicted dependency was added (...
#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