Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新上游 #6

Merged
merged 209 commits into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
731e494
核对与更新 8 月 19 日前的积分
lsvih Oct 22, 2019
4b3d7a0
写给大家的代数效应入门 (#6280)
TiaossuP Oct 23, 2019
29a952c
在 Flutter 中使用 Provider 构建底部导航栏 (#6361)
XatMassacrE Oct 23, 2019
55212a3
现代脚本加载 (#6385)
Oct 23, 2019
41cfc47
使用 `import()` 执行 JavaScript 代码 (#6427)
EmilyQiRabbit Oct 23, 2019
8fe7b5e
设置 git 别名 (#6435)
EmilyQiRabbit Oct 23, 2019
242e9c3
趣味学习 CSS 布局 —— 第一部分:弹性布局 (#6437)
MarchYuanx Oct 23, 2019
9a49c5e
趣味学习 CSS 布局 —— 第二部分:网格布局 (#6452)
EmilyQiRabbit Oct 23, 2019
40c5e1a
如何计划你的一天 —— 这里有一份攻略请查收 (#6436)
evanzme Oct 23, 2019
2286c2b
核对与更新 8 月 27 日前的积分
lsvih Oct 24, 2019
e05654c
核对与更新 10 月 18 日前的积分
lsvih Oct 24, 2019
3468e71
TypeScript 3.7 Beta 版发布 (#6449)
Xuyuey Oct 25, 2019
080af87
Create react-svg-icon-components.md (#6466)
sunui Oct 30, 2019
d581614
关于现代应用样式的探讨 (#6366)
EmilyQiRabbit Oct 30, 2019
abdfd5f
Flutter 的状态管理方案:setState、BLoC、ValueNotifier、Provider (#6304)
talisk Nov 1, 2019
3df9970
Node.js 新特性将颠覆 AI、物联网等更多惊人领域 (#6454)
JaxNext Nov 1, 2019
36041e3
JavaScript 的发布者/订阅者(Publisher/Subscriber)模式 (#6459)
EmilyQiRabbit Nov 4, 2019
e24060c
Create the-fallacy-of-easy.md
sunui Nov 5, 2019
c9200b9
使用因果分析优化 Go HTTP/2 服务器 (#6348)
JackEggie Nov 5, 2019
de9f80e
Create offline-first.md (#6478)
sunui Nov 8, 2019
e7c1be1
Update offline-first.md
sunui Nov 8, 2019
444cf39
如何用 Keras 从头搭建一维生成对抗网络 (#6396)
TokenJan Nov 11, 2019
3f5c02c
Create the-trick-to-animating-the-dot-on-the-letter-i.md (#6486)
sunui Nov 11, 2019
92a332c
Update the-trick-to-animating-the-dot-on-the-letter-i.md
sunui Nov 11, 2019
3448b91
Create real-world-dynamic-programming-seam-carving.md (#6490)
sunui Nov 13, 2019
72ec6fd
Create how-to-prioritize-your-teams-work.md (#6492)
sunui Nov 13, 2019
c0816e0
Create nodejs-jwt-authentication-oauth.md (#6499)
sunui Nov 15, 2019
f1c9a7a
Flutter: 使用 Redux 实现无限 ListView (#6388)
XatMassacrE Nov 15, 2019
62cd9e1
Create the-evolution-of-the-design-from-ux-towards-personal-experienc…
sunui Nov 18, 2019
422fd82
设计离线优先的网络应用 (#6501)
EmilyQiRabbit Nov 21, 2019
656e507
让字母“i”的点动起来的秘密 (#6502)
v2-lab Nov 22, 2019
90c3ff9
Fix URL
sunui Nov 22, 2019
b8c1ad4
Create the-concepts-of-graphql.md (#6516)
sunui Nov 22, 2019
42ccc61
Create how-we-ditched-redux-for-mobx.md (#6525)
sunui Nov 28, 2019
367cb76
Create whats-new-in-php-7-4-top-10-features-that-you-need-to-know.md …
sunui Dec 2, 2019
938de8e
Create offline-graphql-queries-with-redux-offline-and-apollo.md (#6533)
sunui Dec 2, 2019
58a88cc
Create expressive-code-for-state-machines-in-cpp.md (#6535)
sunui Dec 2, 2019
1e4be30
如何确定团队工作的优先级 (#6519)
evanzme Dec 2, 2019
eebb57a
将 GraphQL 概念可视化 (#6520)
eizyc Dec 2, 2019
bd0f353
如何将 SVG 图标用做 React 组件? (#6474)
TiaossuP Dec 4, 2019
21c5ad8
这么多编程语言,我该怎么选? (#6485)
JaxNext Dec 4, 2019
05f5dad
Update enough-to-decide.md
lsvih Dec 4, 2019
abba8b1
动态规划算法的实际应用:接缝裁剪 (#6497)
nettee Dec 5, 2019
f53b839
设计的变革 —— 从用户体验到个人体验 (#6530)
Charlo-O Dec 5, 2019
5088b85
你不需要 passport.js — node.js认证指南 (#6512)
HytonightYX Dec 5, 2019
37742fb
简单的谬误 (#6496)
Charlo-O Dec 6, 2019
227c48f
为什么自己动手写代码能让你成为更好的开发者 (#6488)
ericpen12 Dec 6, 2019
d7051ee
类型及其在参数中的应用:能优化代码的的 Dart 特性 (#6462)
EmilyQiRabbit Dec 6, 2019
ae100a0
Create my-personal-git-tricks-cheatsheet.md (#6546)
sunui Dec 10, 2019
c09b7d2
Fixed format issues
lsvih Dec 14, 2019
07f6958
Format integral file.
lsvih Dec 17, 2019
d437f63
Reformat integral file.
lsvih Dec 17, 2019
c2905dc
PHP 7.4 有什么新功能?你必须掌握的 10 大特性 (#6549)
evanzme Dec 18, 2019
53e3eca
Create understanding-recursion.md (#6553)
sunui Dec 18, 2019
aff8e1b
Create the-ripple-effect-expanding-our-icon-design-system.md (#6555)
sunui Dec 18, 2019
9b617ce
我个人的 Git 技巧备忘录 (#6548)
Dec 23, 2019
bb9265c
理解递归、尾调用优化和蹦床函数优化 (#6557)
eizyc Dec 23, 2019
a8c7fca
我们为何抛弃 Redux 拥抱 MobX (#6538)
lihaobhsfer Dec 23, 2019
46a2ef0
Translation/my personal git tricks cheatsheet.md (#6560)
Dec 23, 2019
f10909e
Syslog:系统管理员完整指南 (#6391)
githubmnume Dec 23, 2019
3c3f1c1
深入解析 Flutter Provider 包 (#6480)
EmilyQiRabbit Dec 23, 2019
2677720
Create json-parser-with-javascript.md (#6564)
sunui Dec 24, 2019
19a80cf
使用 Redux Offline 和 Apollo 进行离线 GraphQL 查询 (#6541)
v2-lab Dec 24, 2019
ebf3b1e
Create how-to-build-a-blog-with-nest-js-mongodb-and-vue-js.md (#6567)
sunui Dec 25, 2019
b3b281d
Create an-introduction-to-raspberry-pi-4-gpio-and-controlling-it-with…
sunui Dec 25, 2019
5f72e9c
Create why-svelte-wont-kill-react.md (#6570)
sunui Dec 25, 2019
447e6b9
完成 11 月 1 日前的积分统计
lsvih Dec 27, 2019
855475c
完成 2019 年 12 月 27 日前的全部文章积分统计
lsvih Dec 27, 2019
edd7bc5
补录积分
lsvih Dec 29, 2019
0688d3f
Create how_to_prep_your_github_for_job_seeking.md (#6583)
lsvih Dec 29, 2019
240adc8
Create how-to-write-video-chat-app-using-webrtc-and-nodejs.md (#6585)
lsvih Dec 29, 2019
f98782c
登记 2019 年优秀英文文章推荐奖励积分
lsvih Dec 29, 2019
9790d2b
使用 JavaScript 编写 JSON 解析器 (#6582)
Gavin-Gong Dec 30, 2019
a172bc9
数学编程  ——  一个为推进数据科学发展而培养的关键习惯 (#6389)
Weirdochr Dec 30, 2019
8540dc4
C++ 中清晰明了的状态机代码 (#6552)
zh1an Dec 30, 2019
7237f4b
登记#9582 积分
lsvih Dec 30, 2019
5f5e8b5
Create creating-website-sitemap.md (#6589)
sunui Dec 30, 2019
1b3fe5c
Create use-web-workers-for-your-event-listeners.md (#6591)
sunui Dec 30, 2019
0197116
图标万花筒 (#6561)
JaxNext Dec 31, 2019
d0f1b08
WebRTC 联手 Node.js:打造实时视频聊天应用 (#6587)
JaxNext Dec 31, 2019
8996863
Create top-7-modern-programming-language-to-learn-now.md (#6595)
sunui Jan 2, 2020
4cfc1a2
Create levels-of-seniority.md (#6600)
sunui Jan 3, 2020
5e88df0
Create history-of-javascript.md (#6602)
sunui Jan 3, 2020
5678c96
Create when-workers.md (#6608)
sunui Jan 6, 2020
1f0892e
Create i-dont-hate-arrow-functions.md (#6609)
sunui Jan 6, 2020
48848a1
为何 Svelte 杀不死 React (#6575)
JaxNext Jan 6, 2020
6ea5848
如何为求职准备你的 GitHub (#6604)
nettee Jan 6, 2020
dca8f71
论资历的级别 (#6613)
JaxNext Jan 8, 2020
55c9a86
JavaScript 简史 (#6606)
Jan 8, 2020
f2f49b0
JavaScript 简史 补充修改 (#6616)
Jan 9, 2020
5082951
如何用 Nest.js、MongoDB 和 Vue.js 搭建一个博客 (#6617)
eizyc Jan 10, 2020
c7b15c4
Create nestjs-basic-auth-and-sessions.md (#6625)
sunui Jan 14, 2020
811ccef
Create build-a-blog-using-nuxt-strapi-and-apollo.md (#6626)
sunui Jan 14, 2020
037d248
现在就该学习的 7 门现代编程语言 (#6618)
lihaobhsfer Jan 14, 2020
b5a6d1b
Create goodbye-clean-code.md (#6631)
sunui Jan 15, 2020
1895cb7
Create how-to-choose-the-right-database.md (#6637)
sunui Jan 16, 2020
5541c22
Create is-no-sql-killing-sql.md (#6638)
sunui Jan 16, 2020
c3df525
5 个简单步骤为您的网站创建 Sitemap (#6621)
eizyc Jan 18, 2020
01ad8c4
再见,整洁的代码 (#6641)
zh1an Jan 19, 2020
745022e
使用 Web Workers 优化事件监听器 (#6614)
v2-lab Jan 19, 2020
74dee44
在什么时候你需要使用 Web Workers? (#6643)
weibinzhu Jan 23, 2020
7aa08a2
Create edge-detection-in-python.md
lsvih Jan 23, 2020
4133a96
Update edge-detection-in-python.md
lsvih Jan 23, 2020
2c8fd2e
Create the-algorithm-is-not-the-product.md (#6648)
lsvih Jan 23, 2020
1e3c7a4
使用 Nuxt (Vue.js)、Strapi 和 Apollo 构建博客 (#6646)
v2-lab Jan 24, 2020
6711310
Create 8-ui-ux-design-trends-for-2020.md (#6656)
lsvih Feb 1, 2020
1448eea
Create webassembly-why-and-how-to-use-it.md (#6665)
lsvih Feb 4, 2020
c18a90f
Create understanding-service-workers-and-caching-strategies.md (#6667)
lsvih Feb 4, 2020
755eef0
Create how-to-write-beautiful-and-meaningful-readme-md-for-your-next-…
lsvih Feb 4, 2020
afba20c
算法不是产品 (#6652)
fireairforce Feb 4, 2020
0b37767
Create learn-to-cache-your-nodejs-application-with-redis-in-6-minutes…
lsvih Feb 5, 2020
2990deb
Create fast-pipelines-with-generators-in-typescript.md (#6674)
lsvih Feb 5, 2020
101e6a3
如何写出优雅且有意义的 README.md (#6671)
eizyc Feb 5, 2020
60004bf
Update the-algorithm-is-not-the-product.md
lsvih Feb 5, 2020
0463159
如何选择合适的数据库 (#6660)
eizyc Feb 6, 2020
edeae3e
使用 Python 进行边缘检测 (#6650)
lsvih Feb 7, 2020
effc273
Create image-inpainting-humans-vs-ai.md (#6681)
lsvih Feb 8, 2020
f265ada
Create making-svg-icon-component-in-vue.md (#6686)
lsvih Feb 9, 2020
aa26709
Create stop-using-everywhere.md (#6689)
lsvih Feb 9, 2020
7f25516
Create javascript-native-methods-you-may-not-know.md (#6690)
lsvih Feb 9, 2020
452eb23
图像修复:人类和 AI 的对决 (#6684)
Starry316 Feb 12, 2020
2bcb119
Create 7-principles-of-icon-design.md (#6699)
lsvih Feb 14, 2020
f2dc0eb
Create a-simple-guide-to-a-b-testing-for-data-science.md (#6705)
lsvih Feb 15, 2020
6897eb8
WebAssembly:带有代码示例的简单介绍 (#6680)
fireairforce Feb 16, 2020
77938c8
您可能不知道的原生 JavaScript 方法 (#6704)
eizyc Feb 18, 2020
0f0101b
笔误 (#6713)
hgfkeep Feb 19, 2020
8dbd684
Create password-hashing-pbkdf2-scrypt-bcrypt-and-argon2.md (#6714)
sunui Feb 19, 2020
105211a
Create rel-noopener.md (#6716)
sunui Feb 19, 2020
2c55e6a
Create btc-history-git.md (#6718)
sunui Feb 19, 2020
8c5f2e9
用 6 分钟学习如何用 Redis 缓存您的 NodeJS 应用! (#6677)
eizyc Feb 20, 2020
c6db1e1
移除 2019 年年度积分
lsvih Feb 21, 2020
69956ec
更新 1~2 月推荐文章积分
lsvih Feb 21, 2020
fc56287
在 Vue 中编写 SVG 图标组件 (#6703)
fireairforce Feb 21, 2020
21f57e3
Create a-beginners-guide-to-simulating-dynamical-systems-with-python.…
lsvih Feb 22, 2020
9303158
Create the-7-programming-languages-frameworks-to-learn-in-2020.md (#6…
lsvih Feb 23, 2020
bdabcb8
SQL 将死于 No-SQL 之手? (#6662)
JalanJiang Feb 25, 2020
1dbe8fd
Create fixing-memory-leaks-in-web-applications.md (#6735)
sunui Feb 26, 2020
5b70b6d
关于 icon 设计的 7 大准则 (#6739)
eizyc Mar 3, 2020
5b19544
Create a-new-go-api-for-protocol-buffers.md (#6752)
lsvih Mar 4, 2020
b3489f2
停止在任何地方使用 === (#6750)
zaviertang Mar 4, 2020
6f6620c
Create eye-tracking-and-the-best-ux-practices-in-the-mobile-world.md …
lsvih Mar 4, 2020
b1c265a
Create making-logs-colorful-in-nodejs.md (#6755)
lsvih Mar 4, 2020
88306da
理解 Service Worker 和缓存策略 (#6693)
lsvih Mar 5, 2020
7533ff4
Create whats-going-on-in-that-front-end-head.md (#6760)
lsvih Mar 5, 2020
2e2e43d
一份数据科学 A/B 测试的简单指南 (#6732)
Amberlin1970 Mar 6, 2020
dfe5c3d
登记 1 月翻译校对积分
lsvih Mar 6, 2020
c5ef3ee
登记 2 月翻译校对积分
lsvih Mar 6, 2020
f581cf2
Create separation-of-data-and-ui-in-your-web-app.md (#6764)
lsvih Mar 7, 2020
19f273f
Create 5-secret-features-of-json-stringify.md (#6766)
lsvih Mar 7, 2020
11b0439
Create javascript-top-level-await-in-a-nutshell.md (#6769)
lsvih Mar 8, 2020
c6540d9
Create create-a-line-chart-in-swiftui-using-paths.md (#6771)
lsvih Mar 8, 2020
9360515
Create decouple-your-code-with-dependency-injection.md (#6773)
lsvih Mar 8, 2020
52a938b
Create 5-ways-to-create-a-settings-icon.md (#6779)
lsvih Mar 9, 2020
f000616
2020 年要学习的 7 种编程语言和框架 (#6763)
Mar 9, 2020
8e19ed7
Git 的历史: 软件版本控制的统治之路 (#6768)
fireairforce Mar 12, 2020
9a6763f
更新 3 月 12 日前翻译校对及推荐奖励积分
lsvih Mar 12, 2020
31606a0
Create 11-chrome-apis-that-give-your-web-app-a-native-feel.md (#6784)
lsvih Mar 12, 2020
7bb011c
Create 8-useful-tree-data-structures-worth-knowing.md (#6786)
lsvih Mar 12, 2020
b4bbb17
Create a-realworld-comparison-of-front-end-frameworks-2020.md (#6796)
sunui Mar 15, 2020
66f606c
密码哈希的方法:PBKDF2,Scrypt,Bcrypt 和 ARGON2 (#6792)
Mar 16, 2020
f6e97b7
给 NodeJS 的 Logs 点颜色看看! (#6788)
eizyc Mar 16, 2020
1ca11c8
Create everything-you-need-to-know-about-javascript-symbols.md (#6800)
lsvih Mar 16, 2020
e65a228
Create how-to-write-a-front-end-developer-resume-that-will-land-you-a…
lsvih Mar 16, 2020
eb0c285
前端代码顶部的 Header 标签里都有些什么? (#6781)
eizyc Mar 17, 2020
2c45902
Create composing-software-the-book.md (#6807)
sunui Mar 19, 2020
a5e2a7f
Create the-dao-of-immutability.md (#6808)
sunui Mar 19, 2020
9fc3622
Create master-the-javascript-interview-what-is-a-pure-function.md (#6…
sunui Mar 19, 2020
6845f7b
Create master-the-javascript-interview-what-is-functional-programming…
sunui Mar 19, 2020
2fdfc3b
Create elements-of-javascript-style.md (#6811)
sunui Mar 19, 2020
1b7f28a
Fix invalid url. Resolved #6817
lsvih Mar 22, 2020
1ee089a
8 个值得了解的树形数据结构 (#6804)
Amberlin1970 Mar 27, 2020
2fc1f6f
眼动跟踪和移动世界的最佳用户体验实践 (#6806)
Charlo-O Mar 27, 2020
b1dc91b
我并不讨厌箭头函数(#6610) (#6659)
TiaossuP Mar 27, 2020
85b370b
掌握 JavaScript 面试:什么是纯函数? (#6828)
nia3y Mar 28, 2020
50fe5ba
fix:文章翻译问题 (#6833)
fireairforce Mar 28, 2020
03a5ad1
用依赖注入来解耦你的代码 (#6823)
JalanJiang Mar 29, 2020
ec81f83
Create generator-functions-in-javascript.md (#6841)
lsvih Mar 31, 2020
09bdfca
Create how-to-keep-your-dependencies-secure-and-up-to-date.md (#6843)
lsvih Mar 31, 2020
b31262e
Create deep-dive-into-react-fiber-internals.md (#6845)
lsvih Mar 31, 2020
e558412
Update deep-dive-into-react-fiber-internals.md
lsvih Mar 31, 2020
b092388
Create how-can-cloud-services-help-improve-your-businessess-efficienc…
lsvih Mar 31, 2020
1890989
Create should-you-learn-vim-as-a-developer-in-2020.md (#6849)
lsvih Mar 31, 2020
86c98a0
Go 发布新版 Protobuf API (#6827)
Mar 31, 2020
3a97b80
JSON.stringify() 的 5 个秘密特性 (#6793)
fireairforce Mar 31, 2020
7e5c087
Create high-speed-inserts-with-mysql.md (#6853)
lsvih Apr 1, 2020
1b8f128
组合软件:书 (#6832)
fireairforce Apr 2, 2020
e9ffc55
Create 6-best-javascript-frameworks-in-2020.md (#6861)
lsvih Apr 3, 2020
10ee3f1
2020 年用各大前端框架构建的 RealWorld 应用对比 (#6851)
jasperxihuan Apr 4, 2020
9e581b5
Create the-importance-of-why-docs.md (#6868)
lsvih Apr 6, 2020
8435cc5
不变性之道 (#6857)
nia3y Apr 6, 2020
078db71
Create polymorphic-react-components.md (#6870)
lsvih Apr 6, 2020
6617fdd
Create active-learning-in-machine-learning.md (#6872)
lsvih Apr 6, 2020
fee835c
Create kafka-vs-rabbitmq-why-use-kafka.md (#6874)
lsvih Apr 6, 2020
f871ee3
Create i-built-an-app-that-uses-all-7-new-features-in-javascript-es20…
lsvih Apr 6, 2020
15bd0f2
云服务如何帮助你提高业务效率? (#6859)
QinRoc Apr 7, 2020
b8212d7
NestJS 实现基本用户认证和会话 (#6731)
eizyc Apr 7, 2020
e174933
作为 2020 年的开发者,你应该学习 VIM 吗? (#6856)
chaingangway Apr 7, 2020
090cf24
MySQL 最佳实践—— 高效插入数据 (#6863)
Apr 8, 2020
fa1d408
Create combine-getting-started.md (#6883)
lsvih Apr 9, 2020
dc6bac3
Create how-to-be-a-good-remote-developer.md (#6885)
lsvih Apr 9, 2020
297f881
Create why-is-object-immutability-important.md (#6887)
lsvih Apr 9, 2020
cf32cda
Create what-on-earth-is-the-shadow-dom-and-why-it-matters.md
lsvih Apr 9, 2020
39e1036
2020 年排名前 6 位的 JavaScript 框架 (#6867)
QinRoc Apr 9, 2020
64e4165
JavaScript 风格元素 (#6878)
febrainqu Apr 9, 2020
61ec18b
怎样让依赖库保持安全和最新 (#6864)
chaingangway Apr 9, 2020
c7588af
Create 5-best-practices-to-prevent-git-leaks.md (#6894)
lsvih Apr 10, 2020
9698791
Create swiftui-3d-scroll-effect.md (#6896)
lsvih Apr 10, 2020
5ec9371
Web 应用程序中的数据和 UI 分离 (#6794)
fireairforce Apr 10, 2020
84f7988
fix:typo (#6903)
fireairforce Apr 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO/the-hidden-treasures-of-object-composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
>
> “优先考虑对象组合而不是类继承。” ~ Gang of Four,[《设计模式:可复用面向对象软件的基础》](https://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612//ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=eejs-20&linkId=06ccc4a53e0a9e5ebd65ffeed9755744)

软件开发中最常见的错误之一就是对于类继承的过度使用。类继承是一个代码复用机制,实例对象和基类构成了 **是一个(is-a)**关系。如果你想要使用 is-a 关系来构建应用程序,你将陷入麻烦,因为在面向对象设计中,类继承是最紧的耦合形式,这种耦合会引起下面这些常见问题:
软件开发中最常见的错误之一就是对于类继承的过度使用。类继承是一个代码复用机制,实例对象和基类构成了 **is-a** 关系。如果你想要使用 is-a 关系来构建应用程序,你将陷入麻烦,因为在面向对象设计中,类继承是最紧的耦合形式,这种耦合会引起下面这些常见问题:

* 脆弱的基类问题
* 猩猩/香蕉问题
Expand Down
417 changes: 417 additions & 0 deletions TODO1/11-chrome-apis-that-give-your-web-app-a-native-feel.md

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions TODO1/5-best-practices-to-prevent-git-leaks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
> * 原文地址:[5 Best Practices To Prevent Git Leaks](https://levelup.gitconnected.com/5-best-practices-to-prevent-git-leaks-4997b96c1cbe)
> * 原文作者:[Coder’s Cat](https://medium.com/@coderscat)
> * 译文出自:[掘金翻译计划](https://github.com/xitu/gold-miner)
> * 本文永久链接:[https://github.com/xitu/gold-miner/blob/master/TODO1/5-best-practices-to-prevent-git-leaks.md](https://github.com/xitu/gold-miner/blob/master/TODO1/5-best-practices-to-prevent-git-leaks.md)
> * 译者:
> * 校对者:

# 5 Best Practices To Prevent Git Leaks

![Photo by Clint Patterson on Unsplash](https://cdn-images-1.medium.com/max/4000/0*bskmb4Tr98q5if_y.jpg)

Countless developers are using Git for version control, but many don’t have enough knowledge about how Git works. Some people even use Git and Github as tools for backup files. This leads to information disclosure in Git repositories. [Thousands of new API or cryptographic keys leak via GitHub projects every day.](https://www.zdnet.com/article/over-100000-github-repos-have-leaked-api-or-cryptographic-keys/)

I have been working in the field of information security for three years. About two years ago, our company had a severe security issue triggered by the information leak in a Git repository.

An employee accidentally leaked an AWS key to Github. The attacker used this key to download more sensitive data from our servers. We put a lot of time into fixing this issue, we tried to find out how much data leaked, analyzed the affected systems and related users, and replaced all the leaked keys in systems.

It is a sad story that any company and developer would not want to experience.

I won’t write more details about it. Instead, I hope more people know how to avoid it. Here are my suggestions for you to keep safe from Git leaks.

## Build security awareness

Most junior developers don’t have enough security awareness. Some companies will train new employees, but some companies don’t have systematic training.

As a developer, we need to know which kind of data may introduce security issues. Remember these categories of data can not be checked into Git repository:

1. Any configuration data, including password, API keys, AWS keys, private keys, etc.
2. [Personally Identifiable Information](https://en.wikipedia.org/wiki/Personal_data) (PII). According to GDPR, if a company leaked the users’ PII, the company needs to notify users, relevant departments and there will be more legal troubles.

If you are working for a company, don’t share any source code or data related to the company without permission.

Attackers can easily find some code with a company copyright on GitHub, which was accidentally leaked to Github by employees.

My advice is, try to distinguish between company affairs and personal stuff strictly.

## Use Git ignore

When we create a new project with Git, we must set a **.gitignore** properly. **gitignore** is a Git configuration file that lists the files or directories that will not be checked into the Git repository.

This project’s [gitignore](https://github.com/github/gitignore) is a collection of useful .gitignore templates, with all kinds of programming language, framework, tool or environment.

We need to know the pattern matching rules of **gitignore** and add our own rules based on the templates.

![](https://cdn-images-1.medium.com/max/2000/0*VmEolB6qYNCYr9Wf.png)

## Check commits with Git hooks and CI

No tools could find out all the sensitive data from a Git repository, but a couple of tools and practices can help.

[git-secrets](https://github.com/awslabs/git-secrets) and [talisman](https://github.com/thoughtworks/talisman) are similar tools, they are meant to be installed in local repositories as [pre-commit hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). Every change will be checked before committed, pre-commit hooks will reject the commit if they detect a prospective commit may contain sensitive information.

[gitleaks](https://github.com/zricethezav/gitleaks) provides another way to find unencrypted secrets and other unwanted data types in git repositories. We could integrate it into automation workflows such as CICD.

## Code review

Code review is a best practice for team working. All the teammates will learn from each other’s source code. Junior developer’s code should be reviewed by developers with more experience.

Most unintended changes can be found out during the code review stage.

[Enabling branch restrictions](https://help.github.com/en/github/administering-a-repository/enabling-branch-restrictions) can enforce branch restrictions so that only certain users can push to a protected branch in repositories. Gitlab has a similar option.

Setting master to a restricted branch helps us to enforce the code review workflow.

![](https://cdn-images-1.medium.com/max/2208/0*RUqDCQlDgym-Jo8x.png)

## Fix it quickly and correctly

With all the above tools and mechanisms, errors still could happen. If we fix it quickly and correctly, the leak may introduce no actual security issue.

If we find some sensitive data leaked in the Git repository, we can not just make another commit to clean up.

![This fix is self-deception](https://cdn-images-1.medium.com/max/2000/0*FsGBhHSlXdeSpTk4.png)

What we need to do is remove all the sensitive data from the entire Git history.

**Remember to backup before any cleanup, and then remove the backup clone after we confirmed everything is OK**.

Use the `--mirror` to clone a bare repository; this is a full copy of the Git database.

```bash
git clone --mirror git://example.com/need-clean-repo.git
```

We need **git filter-branch** to remove data from all branches and commit histories. Suppose we want to remove `./config/passwd` from Git:

```bash
$ git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch ./config/password' \
--prune-empty --tag-name-filter cat -- --all
```

Remember to add the sensitive file to .gitignore:

```bash
$ echo "./config/password" >> .gitignore
$ git add .gitignore
$ git commit -m "Add password to .gitignore"
```

Then we push all branches to remote:

```bash
$ git push --force --all
$ git push --force --tags
```

Tell our collaborators to rebase:

```bash
$ git rebase
```

[BFG](https://rtyley.github.io/bfg-repo-cleaner/) is a faster and simpler alternative to **git filter-branch** for removing sensitive data. It’s usually 10–720x faster than **git filter-branch**. Except for deleting files, BFG could also be used to replace secrets in files.

BFG will leave the latest commit untouched. It’s designed to protect us from making mistakes. We should explicitly delete the file, commit the deletion, then clean up the history to remove it.

If the leaked Git repository is forked by others, we need to follow the [DMCA Takedown Policy](https://help.github.com/en/github/site-policy/dmca-takedown-policy#c-what-if-i-inadvertently-missed-the-window-to-make-changes) to ask Github to remove the forked repositories.

The whole procedure requires some time to finish, but it’s the only way to remove all the copies.

## Conclusion

Don’t make the same mistake that countless people have made. Try to put some effort to avoid safety accidents.

Use these tools and strategies will help much in avoiding Git leaks.

> 如果发现译文存在错误或其他需要改进的地方,欢迎到 [掘金翻译计划](https://github.com/xitu/gold-miner) 对译文进行修改并 PR,也可获得相应奖励积分。文章开头的 **本文永久链接** 即为本文在 GitHub 上的 MarkDown 链接。

---

> [掘金翻译计划](https://github.com/xitu/gold-miner) 是一个翻译优质互联网技术文章的社区,文章来源为 [掘金](https://juejin.im) 上的英文分享文章。内容覆盖 [Android](https://github.com/xitu/gold-miner#android)、[iOS](https://github.com/xitu/gold-miner#ios)、[前端](https://github.com/xitu/gold-miner#前端)、[后端](https://github.com/xitu/gold-miner#后端)、[区块链](https://github.com/xitu/gold-miner#区块链)、[产品](https://github.com/xitu/gold-miner#产品)、[设计](https://github.com/xitu/gold-miner#设计)、[人工智能](https://github.com/xitu/gold-miner#人工智能)等领域,想要查看更多优质译文请持续关注 [掘金翻译计划](https://github.com/xitu/gold-miner)、[官方微博](http://weibo.com/juejinfanyi)、[知乎专栏](https://zhuanlan.zhihu.com/juejinfanyi)。
150 changes: 150 additions & 0 deletions TODO1/5-secret-features-of-json-stringify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
> * 原文地址:[5 Secret features of JSON.stringify()](https://medium.com/javascript-in-plain-english/5-secret-features-of-json-stringify-c699340f9f27)
> * 原文作者:[Prateek Singh](https://medium.com/@prateeksingh_31398)
> * 译文出自:[掘金翻译计划](https://github.com/xitu/gold-miner)
> * 本文永久链接:[https://github.com/xitu/gold-miner/blob/master/TODO1/5-secret-features-of-json-stringify.md](https://github.com/xitu/gold-miner/blob/master/TODO1/5-secret-features-of-json-stringify.md)
> * 译者:[zoomdong](https://github.com/fireairforce)
> * 校对者:[Long Xiong](https://github.com/xionglong58), [niayyy](https://github.com/niayyy-S)

# JSON.stringify() 的 5 个秘密特性

![Credits: [Kirmeli.com](https://www.google.com/url?sa=i&url=https%3A%2F%2Fahmedalkiremli.com%2Fwhy-to-learn-what-to-learn-and-how-to-learn%2F&psig=AOvVaw3IGik44VGBXe661UZsW5Mh&ust=1581750442478000&source=images&cd=vfe&ved=0CAMQjB1qFwoTCMj-5Oi90OcCFQAAAAAdAAAAABAR)](https://cdn-images-1.medium.com/max/2000/1*aQy1TrGzC_n_UC0j9hXBbw.jpeg)

> JSON.stringify() 方法能将一个 JavaScript 对象或值转换成一个 JSON 字符串。

作为一名 JavaScript 开发人员,`JSON.stringify()` 是用于调试的最常见函数。但是它的作用是什么呢,难道我们不能使用 `console.log()` 来做同样的事情吗?让我们试一试。

```js
//初始化一个 user 对象
const user = {
"name" : "Prateek Singh",
"age" : 26
}

console.log(user);

// 结果
// [object Object]
```

哦!`console.log()` 没有帮助我们打印出期望的结果。它输出 `**[object Object]**`,**因为从对象到字符串的默认转换是 `[object Object]`**。因此,我们使用 `JSON.stringify()` 首先将对象转换成字符串,然后在控制台中打印,如下所示。

```js
const user = {
"name" : "Prateek Singh",
"age" : 26
}

console.log(JSON.stringify(user));

// 结果
// "{ "name" : "Prateek Singh", "age" : 26 }"
```

---

一般来说,开发人员使用 `stringify` 函数的场景较为普遍,就像我们在上面做的那样。但我要告诉你一些隐藏的秘密,这些小秘密会让你开发起来更加轻松。

## 1: 第二个参数(数组)

是的,`stringify` 函数也可以有第二个参数。它是要在控制台中打印的对象的键数组。看起来很简单?让我们更深入一点。我们有一个对象 **product** 并且我们想知道 product 的 name 属性值。当我们将其打印出来:
console.log(JSON.stringify(product));
它会输出下面的结果。

```js
{"id":"0001","type":"donut","name":"Cake","ppu":0.55,"batters":{"batter":[{"id":"1001","type":"Regular"},{"id":"1002","type":"Chocolate"},{"id":"1003","type":"Blueberry"},{"id":"1004","type":"Devil’s Food"}]},"topping":[{"id":"5001","type":"None"},{"id":"5002","type":"Glazed"},{"id":"5005","type":"Sugar"},{"id":"5007","type":"Powdered Sugar"},{"id":"5006","type":"Chocolate with Sprinkles"},{"id":"5003","type":"Chocolate"},{"id":"5004","type":"Maple"}]}
```

在日志中很难找到 **name** 键,因为控制台上显示了很多没用的信息。当对象变大时,查找属性的难度增加。
stringify 函数的第二个参数这时就有用了。让我们重写代码并查看结果。

```js
console.log(JSON.stringify(product,['name' ]);

// 结果
{"name" : "Cake"}
```

问题解决了,与打印整个 JSON 对象不同,我们可以在第二个参数中将所需的键作为数组传递,从而只打印所需的属性。

## 2: 第二个参数(函数)

我们还可以传入函数作为第二个参数。它根据函数中写入的逻辑来计算每个键值对。如果返回 `undefined`,则不会打印键值对。请参考示例以获得更好的理解。

```js
const user = {
"name" : "Prateek Singh",
"age" : 26
}
```

![Passing function as 2nd argument](https://cdn-images-1.medium.com/max/2000/1*V3EQcCdgRLDish8PkY0s5A.png)

```js
// 结果
{ "age" : 26 }
```

只有 `age` 被打印出来,因为函数判断 `typeOf` 为 String 的值返回 `undefined`。

## 3: 第三个参数为数字

第三个参数控制最后一个字符串的间距。如果参数是一个**数字**,则字符串化中的每个级别都将缩进这个数量的空格字符。

```js
// 注意:为了达到理解的目的,使用 '--' 替代了空格

JSON.stringify(user, null, 2);
//{
//--"name": "Prateek Singh",
//--"age": 26,
//--"country": "India"
//}
```

## 4: 第三个参数为字符串

如果第三个参数是 **string**,那么将使用它来代替上面显示的空格字符。

```js
JSON.stringify(user, null,'**');
//{
//**"name": "Prateek Singh",
//**"age": 26,
//**"country": "India"
//}
// 这里 * 取代了空格字符
```

## 5: toJSON 方法

我们有一个叫 `toJSON` 的方法,它可以作为任意对象的属性。`JSON.stringify` 返回这个函数的结果并对其进行序列化,而不是将整个对象转换为字符串。参考下面的例子。

```js
const user = {
firstName : "Prateek",
lastName : "Singh",
age : 26,
toJSON() {
return {
fullName: `${this.firstName} + ${this.lastName}`
};
}
}

console.log(JSON.stringify(user));

// 结果
// "{ "fullName" : "Prateek Singh"}"
```

这里我们可以看到,它只打印 `toJSON` 函数的结果,而不是打印整个对象。

我希望你能学到 `stringify()` 的一些基本特征。

如果你觉得这篇文章有用,请点赞,然后跟我读更多类似的精彩文章。

> 如果发现译文存在错误或其他需要改进的地方,欢迎到 [掘金翻译计划](https://github.com/xitu/gold-miner) 对译文进行修改并 PR,也可获得相应奖励积分。文章开头的 **本文永久链接** 即为本文在 GitHub 上的 MarkDown 链接。

---

> [掘金翻译计划](https://github.com/xitu/gold-miner) 是一个翻译优质互联网技术文章的社区,文章来源为 [掘金](https://juejin.im) 上的英文分享文章。内容覆盖 [Android](https://github.com/xitu/gold-miner#android)、[iOS](https://github.com/xitu/gold-miner#ios)、[前端](https://github.com/xitu/gold-miner#前端)、[后端](https://github.com/xitu/gold-miner#后端)、[区块链](https://github.com/xitu/gold-miner#区块链)、[产品](https://github.com/xitu/gold-miner#产品)、[设计](https://github.com/xitu/gold-miner#设计)、[人工智能](https://github.com/xitu/gold-miner#人工智能)等领域,想要查看更多优质译文请持续关注 [掘金翻译计划](https://github.com/xitu/gold-miner)、[官方微博](http://weibo.com/juejinfanyi)、[知乎专栏](https://zhuanlan.zhihu.com/juejinfanyi)。
Loading