├── 2016 └── 2016.6.2.md ├── 2017 ├── 2017.1.20-22.md ├── 2017.10.11.md ├── 2017.10.28.md ├── 2017.11.23.md ├── 2017.11.25.md ├── 2017.2.15.md ├── 2017.2.19.md ├── 2017.2.21.md ├── 2017.2.22.md ├── 2017.3.16.md ├── 2017.3.17.md ├── 2017.3.8.md ├── 2017.4.11.md ├── 2017.4.25.md ├── 2017.4.5.md ├── 2017.5.15.md ├── 2017.5.22.md ├── 2017.5.23.md ├── 2017.5.24.md ├── 2017.5.7.md ├── 2017.7.16.md ├── 2017.7.18.md ├── 2017.8.2.md └── 2017.9.10.md ├── 2018 ├── CSS_Pre-Processors.md ├── 2018.4.1.md ├── 2018.4.24.md ├── 2018.4.8.md ├── 2018.7.17.md ├── AST.md ├── CSS_Normalize&Reset.md ├── CSS_selector_specificity.md ├── CSS伪类和伪元素.md ├── CSS:Box Model&BFC&IFC&Float.md ├── ES6 箭头函数.md ├── Eventloop.md ├── HTTP2HTTPS.md ├── JS-Proxy │ ├── ES6-Proxy&Reflect.md │ ├── script-1.js │ ├── script-2.js │ ├── script-3.js │ └── script-4.js ├── JS_Closure.md ├── JS_shallow&deep_cpoy.md ├── JS执行上下文与作用域链.md ├── JavaScript_Ninja │ └── chapter3.md ├── Promise.md ├── Vue.js 的 template 编译.md ├── Vue2.x的diff算法.md ├── css_world │ └── chapter_1.md ├── display:contents.md ├── draw_line_algorithm.md ├── generator.js ├── koajs.md ├── postcss.md ├── 从编写 JS 游戏到了解浏览器渲染机制.md ├── 前后端如何在项目中连接.md └── 面向设计的前端分享.md ├── 2019 ├── Google_performance_note.md ├── HTTP&HTTPS_NOTE.md ├── HTTP.md ├── JS_Modules.md ├── OS_IPC.md ├── ajax_race.md ├── async_await.md ├── code_exercise │ ├── EventEmitter.js │ ├── Generator.js │ ├── Intermediate.js │ ├── bigNumerAdder.js │ ├── curry_adder.js │ ├── drag.html │ ├── easy.js │ ├── flatten.js │ ├── input.html │ ├── promise_detailed.js │ ├── promise_simple.js │ └── quickSort.js ├── interview_preparation │ └── 2.27.md ├── react-router.md ├── requestAnimationFrame.md └── web_cache.md ├── 2020 └── Go学习笔记 │ ├── ch1.go │ ├── ch1_fetch.go │ ├── ch1_server1_main.go │ ├── ch1_server2_main.go │ ├── ch1_server3_main.go │ ├── ch4.go │ ├── ch4_github.go │ ├── ch4_github_issue.go │ └── ch5_findlink_main.go ├── README.md └── img └── router.png /2016/2016.6.2.md: -------------------------------------------------------------------------------- 1 | - [CSS Stacking Context里那些鲜为人知的坑](http://blog.angular.in/css-stacking-contextli-na-xie-xian-wei-ren-zhi-de-keng/?nsukey=ref%2F%2BVaMdy%2Fd0NEg7Ry7%2FSDGUdG1AlJnLazfcqv0yX8wIB2jnLLm4wb37SF7cj55gO83O0IcW%2B9%2B4rjNhJFpj%2F9ZoTF1zCY0Sk%2Fh%2BqxA6pezYxMfCQU1NIHvjyjjf2qpHmdO%2FD49xXroK08HJd8%2Bonh6yIUS7RcY14y%2Bufzoua1EehCd7W%2BxsCXFlSkciDnx) 2 | -------------------------------------------------------------------------------- /2017/2017.1.20-22.md: -------------------------------------------------------------------------------- 1 | ### CSS Reset 2 | 因为早期的浏览器支持和理解的CSS规范不同,导致渲染页面时效果不一致,会出现很多兼容性问题。2004年Tantek根据自身需要对于一些标签进行了简单的重置.即清除所有浏览器默认样式。 3 | ``` 4 | /* undohtml.css */ 5 | /* (CC) 2004 Tantek Celik. Some Rights Reserved. */ 6 | :link,:visited { text-decoration:none } 7 | ul,ol { list-style:none } 8 | h1,h2,h3,h4,h5,h6,pre,code { font-size:1em; } 9 | ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote, 10 | fieldset,input{ margin:0; padding:0 } 11 | a img,:link img,:visited img { border:none } 12 | address { font-style:normal } 13 | ``` 14 | Normalize.css 15 | * Preserves useful defaults, unlike many CSS resets. 16 | 保护有用的浏览器默认样式而不是完全去掉它们 17 | * Normalizes styles for a wide range of elements 18 | 一般化的样式:为大部分HTML元素提供 19 | * Corrects bugs and common browser inconsistencies 20 | 修复浏览器自身的bug并保证各浏览器的一致性 21 | * Improves usability with subtle improvements 22 | 优化CSS可用性:用一些小技巧 23 | * Explains what code does using detailed comments 24 | 解释代码:用注释和详细的文档来 25 | 26 | ###垂直居中的方法 27 | * 单行文本垂直居中:line-height设置成和height值一样 28 | * 给容器设置绝对定位 `position:absolute`,并且定位高度`top:50%`和margin-top为高度的一半`margin-top: -height/2 ` 29 | * 30 | ``` 31 | position: absolute; 32 | top: 0; 33 | bottom: 0; 34 | left: 0; 35 | right: 0; 36 | margin: auto; 37 | height: 240px; 38 | width: 70%; 39 | ``` 40 | 缺点是IE不适用 41 | * 在元素外插入一个 div。设置此 div `height:50%;` ` margin-bottom:-contentheight;` 该元素清除浮动,并显示在中间。 42 | * 使用绝对定位的 `div`,把它的 `top` 设置为 50%,`top margin` 设置为负的 content 高度。这意味着对象必须在 CSS 中指定固定的高度。因为有固定高度,content 指定 `overflow:auto`,这样如果 content 太多的话,就会出现滚动条,以免content 溢出。缺点:没有足够空间时,content 会消失(类似div 在 body 内,当用户缩小浏览器窗口,滚动条不出现的情况) 43 | * `calc()` 计算 44 | * 模拟表格,将容器设置为`display: table`,然后将子元素也就是要垂直居中显示的元素设置为`display: table-cell`,然后加上`vertical-align: middle`来实现。 45 | 46 | 47 | ###div并列 48 | * `display: inline-block` 49 | * `vertical-algn: middle` 50 | * 设置浮动,将div都设置为 'float: left;'或'float: right;'宽度设置合适; div分别设置为float: left; float: right; 51 | 52 | ###消除inline-block的元素间距 53 | * 改变HTML代码,把所有回车换行都删掉(代码写成一行)。不推荐 54 | * font-size + 负margin 。子元素向左margin了-1px,需将父元素#demo向左padding 1px,用于抵消位置偏移。 55 | * 父元素word-spacing:-1px;font-size:0; 56 | * 使用margin负值,margin负值的大小与上下文的字体和文字大小相关,[本文第六点](http://www.zhangxinxu.com/wordpress/2010/11/%E6%8B%9C%E6%8B%9C%E4%BA%86%E6%B5%AE%E5%8A%A8%E5%B8%83%E5%B1%80-%E5%9F%BA%E4%BA%8Edisplayinline-block%E7%9A%84%E5%88%97%E8%A1%A8%E5%B8%83%E5%B1%80/) 57 | -------------------------------------------------------------------------------- /2017/2017.10.11.md: -------------------------------------------------------------------------------- 1 | # How Recursion Works 2 | 3 | **什么是递归** 4 | 5 | > 递归就是一个函数调用自身,直到达到某个特定状态。 6 | 7 | Recursion: 8 | 9 | - Base Case: when the function doesn't call itself again 10 | - Recursion Case: when the function call itself 11 | 12 | **调用栈看递归过程** 13 | 14 | 1. 阶乘 15 | 16 | ``` 17 | function fact(x) { 18 | if (x == 1) { 19 | return 1; 20 | } else { 21 | return x * fact(x-1); 22 | } 23 | } 24 | console.log(fact(3)); 25 | ``` 26 | 在调用栈中,先加入函数fact(x),接着判断x的值是否等于1,不等于则执行`return x * fact(x-1);`语句,copy一个x的值,直到x==1。 27 | 最终将每一次return的值依次**从栈顶弹出**。 28 | 29 | 2. Factorial Function 30 | 31 | ![调用栈](https://personalzone-hulgokm2zfcmm9u.netdna-ssl.com/wp-content/uploads/2017/04/recursion-factorial-call-stack.jpg) 32 | 33 | 我的理解是保存每一次Recursion Case,最终到Base Case时将每一次的return从栈顶弹出,并更新参数。 -------------------------------------------------------------------------------- /2017/2017.10.28.md: -------------------------------------------------------------------------------- 1 | # Vue 作用域插槽Scoped Slots 2 | 3 | 4 | ## 如何使用作用域插槽来构建可重用的列表组件 5 | 6 | 7 | - 注册基本组件`my-list` 8 | 9 | ``` 10 |
11 |
{{ title }}
12 |
13 |
14 |
{{ shape.name }} ({{ shape.sides }} sides)
15 |
16 |
17 |
18 | ``` 19 | 为了可以复用,抽象出data,给`my-list`添加插槽,这样父组件可以定义如何显示特定的列表。 20 | 父组件中: 21 | 22 | ``` 23 | 24 |
25 |
{{ shape.name }} ({{ shape.sides }} sides) 26 |
27 |
28 |
29 | ``` 30 | 31 | 但是这样组件中仍然有重复的代码,比如`
`。 32 | 33 | - 利用作用域插槽,可以将上述重复的代码委托给父组件。 34 | 35 | 作用域插槽允许你讲模板传递给插槽,并且可以访问某些子数据 36 | 37 | 例如子组件: 38 | 39 | ``` 40 |
41 | 42 |
43 | ``` 44 | 45 | 父组件: 46 | 47 | ``` 48 | 49 | 52 | 53 | ``` 54 | 55 | - 在`my-list`使用scoped slots 56 | 57 | 将列表数组作为`props`传递给`my-list`。用一个scoped slot,这样`my-list`只负责迭代列表项,但是父组件仍然可以定义每个列表如何显示。 58 | 59 | ``` 60 | // app.js file 61 | Vue.component('my-list', 62 | { template: '#my-list', 63 | props: ['title', 'items'] 64 | }) 65 | 66 | // index.html 67 | 77 | ``` 78 | 现在`title`和`items`都作为`props`绑定到插槽中了。 79 | 80 | 父组件: 81 | 82 | ``` 83 | 84 | 88 | 89 | 90 | 95 | 96 | ``` -------------------------------------------------------------------------------- /2017/2017.11.23.md: -------------------------------------------------------------------------------- 1 | [Everything You Never Knew About CSS Floats](https://designshack.net/articles/css/everything-you-never-knew-about-css-floats/) 2 | 3 | 比较基础全面的文章,复习一遍更深入的了解到 4 | **使用浮动的九条规则** 5 | 6 | 1. 浮动元素会被推到他的容器的边缘。 7 | 2. 任何浮动元素都会出现在他之前的浮动元素的旁边或是下方。如果元素都是左浮动,那么第二个元素将会出现在第一个元素的右边,如果都是右浮动,第二个元素会出现在第一个元素的左边。 8 | 3. 左浮动的盒子不能出现在右浮动盒子的右边。 9 | 4. 浮动元素不能高过他的容器的上边缘(当涉及到塌陷的边距这将会更复杂,请参考最初的规则)。 10 | 5. 浮动元素不能比前一个块级元素或浮动元素高。 11 | 6. 浮动元素不能高过前一行内联元素。 12 | 靠着另一个浮动元素的浮动元素不能超出自己的父容器边缘。 13 | 7. 一个浮动的盒子必须尽可能的高的放置。 14 | 8. 一个左浮动的盒子必须尽可能左的放置,一个右浮动的盒子要尽可能的右的放置。尽可能高的位置的优先级比左右高。 -------------------------------------------------------------------------------- /2017/2017.11.25.md: -------------------------------------------------------------------------------- 1 | [(译文)All About Recursion, PTC, TCO and STC in JavaScript](http://www.zcfy.cc/article/all-about-recursion-ptc-tco-and-stc-in-javascript-2813.html) 2 | 3 | [尾调用优化](http://www.ruanyifeng.com/blog/2015/04/tail-call.html) 4 | 5 | 本文将通过图示的方法讨论递归,讨论什么是PTC、TCO(Tail Call Optimization,尾调用优化)、STC(Syntactic Tail Call,语法级尾调用),以及它们的区别、原理,还会讨论主流JavaScript引擎对它们的实现。 6 | 7 | 假如递归调用过多,调用栈会越来越大,最终可能导致Stack Buffer Overflow。只要栈达到容量上限,多一个调用就会造成溢出。 8 | 9 | 10 | **尾调用** 11 | 12 | 适当的尾调用可以避免递归调用时的栈膨胀。 13 | 14 | 尾调用就是指某个函数的最后一步是调用另一个函数,执行时不会造成栈膨胀的函数。尾调用是执行return之前要做的最后一个操作,而这个被调用函数的返回值由调用它的函数返回。调用函数不能是生成器函数。 15 | 16 | ``` 17 | function f(x){ 18 | return g(x); 19 | } 20 | ``` 21 | 22 | 23 | **尾调用优化 Tail Call Optimization** 24 | 25 | 尾调用优化是编译器使用的一种技术,它使用jumps把递归调用转换成一个循环。 26 | 27 | 28 | 我们知道, 函数调用会在内存里面形成一个“调用记录”,又称“调用栈”(call stack),保存调用位置和内部变量等信息。 29 | 30 | 31 | 32 | ![](http://image.beekka.com/blog/2015/bg2015041002.png) 33 | 34 | 35 | ``` 36 | function f() { 37 | let m = 0; 38 | let n = 1; 39 | return g(m + n); 40 | } 41 | ``` 42 | 尾调用由于是函数的最后一步操作,所以不需要保留外层函数的调用记录,因为调用位置、内部变量等信息都不会再用到了,只要直接用内层函数的调用记录,取代外层函数的调用记录就可以了。 43 | 44 | **尾递归** 45 | 46 | 修改factorial函数,变成尾部递归 47 | 48 | ``` 49 | function factorial(n, total = 1) { 50 | if (n === 0) { 51 | return total 52 | } 53 | 54 | return factorial(n - 1, n * total) 55 | ``` 56 | 57 | 以下是调用factorial(4)的过程: 58 | 59 | 1. 在栈顶部压入一个对factorial的调用。 60 | 2. 因为4不是0(既定情况),那么我们知道下一次要计算的值(3)和当前累积值(4 * total)。 61 | 3. 再次调用factorial,它会得到完成计算所需的所有数据:要计算的下一个阶乘和累积的总数。至此,不再需要之前的栈帧了,可以把它弹出,只添加新的调用factorial(3, 4)。 62 | 4. 这次调用同样大于0,于是需要计算下一个数的阶乘,同时将累积值(4)与当前值(3)相乘。 63 | 5. 至此(又)不再需要上一次调用了,可以把它弹出,再次调用factorial并传入2和12。再次更新累积值为24,同时计算1的阶乘。 64 | 6. 前一帧又从栈中被删除,我们又用1乘以24(总数),并计算0的阶乘。 65 | 7. 最后,0的阶乘返回了累积的总数,也就是24(就是4的阶乘)。 66 | 67 | 计算n的阶乘,最多需要保存n个调用记录,复杂度 O(n) 。 68 | 如果改写成尾递归,只保留一个调用记录,复杂度 O(1) 。 69 | 70 | **严格模式** 71 | 72 | ES6的尾调用优化只在严格模式下开启,正常模式是无效的。 73 | 74 | 这是因为在正常模式下,函数内部有两个变量,可以跟踪函数的调用栈。 75 | 76 | - arguments:返回调用时函数的参数。 77 | - func.caller:返回调用当前函数的那个函数。 78 | - 79 | 尾调用优化发生时,函数的调用栈会改写,因此上面两个变量就会失真。严格模式禁用这两个变量,所以尾调用模式仅在严格模式下生效。 80 | 81 | 为了在Node中使用适当的尾调用,必须在JS文件顶部添加'use strict'以启用strict mode,然后以--harmony_tailcalls标记来运行。 -------------------------------------------------------------------------------- /2017/2017.2.15.md: -------------------------------------------------------------------------------- 1 | - [JavaScript let](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/let) 2 | - [What's the difference between using “let” and “var” to declare a variable?](https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var-to-declare-a-variable) 3 | - [JavaScript 数组方法对比](http://web.jobbole.com/90333/) 4 | -------------------------------------------------------------------------------- /2017/2017.2.19.md: -------------------------------------------------------------------------------- 1 | html 2 | ``` 3 |
4 | 5 | 6 | 7 | 8 | 9 |
10 | ``` 11 | 12 | JS 13 | ``` 14 | new Vue({ 15 | el: 'body', 16 | data: { 17 | showPass: false, 18 | // init 19 | password: '' 20 | } 21 | }) 22 | ``` -------------------------------------------------------------------------------- /2017/2017.2.21.md: -------------------------------------------------------------------------------- 1 | 正则表达式 有效密码格式 2 | ``` 3 | function validateEmail(email) { 4 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 5 | return re.test(email); 6 | } 7 | ``` 8 | 9 | [A Complete Guide to Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) -------------------------------------------------------------------------------- /2017/2017.2.22.md: -------------------------------------------------------------------------------- 1 | - [div居中](http://www.jianshu.com/p/a7552ce07c88) 2 | 3 | 方法之一: 4 | ``` 5 | .parent{ 6 | padding: ; 7 | } 8 | .child{ 9 | margin: 0 auto; 10 | display: block; 11 | width: ; 12 | height: ; 13 | } 14 | ``` 15 | 16 | - [footer置底](https://stackoverflow.com/questions/42294/how-do-you-get-the-footer-to-stay-at-the-bottom-of-a-web-page?rq=1) 17 | 1.Have a `
` with class="wrapper" for your content 18 | 2。Right before the closing
of the wrapper place the `
` 19 | 3.Right after the closing
of the wrapper place the `` 20 | 21 | ``` 22 | * { 23 | margin: 0; 24 | } 25 | html, body { 26 | height: 100%; 27 | } 28 | .wrapper { 29 | min-height: 100%; 30 | height: auto !important; 31 | height: 100%; 32 | margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */ 33 | } 34 | .footer, .push { 35 | height: 142px; /* .push must be the same height as .footer */ 36 | } 37 | ``` 38 | 39 | - [在移动浏览器中使用viewport元标签控制布局](https://developer.mozilla.org/zh-CN/docs/Mobile/Viewport_meta_tag) 40 | 41 | - [纯CSS来画图形](http://www.cnblogs.com/jscode/archive/2012/10/19/2730905.html) 42 | -------------------------------------------------------------------------------- /2017/2017.3.16.md: -------------------------------------------------------------------------------- 1 | - [Http Basic Authorization的使用](https://zxc0328.github.io/2015/11/04/http-basic-auth/) 2 | - [Using an authorization header with Fetch in React Native](http://stackoverflow.com/questions/30203044/using-an-authorization-header-with-fetch-in-react-native) -------------------------------------------------------------------------------- /2017/2017.3.17.md: -------------------------------------------------------------------------------- 1 | [聊聊CSSModules](http://zxc0328.github.io/2016/11/12/css-modules/) -------------------------------------------------------------------------------- /2017/2017.3.8.md: -------------------------------------------------------------------------------- 1 | [Vuelidate](https://monterail.github.io/vuelidate/#getting-started) 2 | -------------------------------------------------------------------------------- /2017/2017.4.11.md: -------------------------------------------------------------------------------- 1 | - [移动端真机调试指南](https://aotu.io/notes/2017/02/24/Mobile-debug/) 2 | 3 | - [Vue2.0 短信倒计时组件](https://juejin.im/post/58de6807da2f60005fc1a9bb) 4 | -------------------------------------------------------------------------------- /2017/2017.4.25.md: -------------------------------------------------------------------------------- 1 | - [JavaScript事件](http://yujiangshui.com/javascript-event/) 2 | js中关于事件较全面的概括。 3 | - [什么是URI、URL、URN、URC和Data URI](https://www.luyuqiang.com/uri-url-urn-urc-and-data-uri) 4 | -------------------------------------------------------------------------------- /2017/2017.4.5.md: -------------------------------------------------------------------------------- 1 | - [meta 标签使用总结](https://www.notion.so/meta-8cd558ba52d843058292b5beb485ee1f) 2 | 3 | - [Element](http://element.eleme.io/#/zh-CN) 4 | 5 | - 一些碎片CSS知识点 6 | 7 | **行内元素和块级元素的具体区别是什么?行内元素的padding和margin可设置吗** 8 | 9 | 块级元素(block)特性: 10 | 11 | * 总是独占一行,表现为另起一行开始,而且其后的元素也必须另起一行显示; 12 | * 宽度(width)、高度(height)、内边距(padding)和外边距(margin)都可控制; 13 |   内联元素(inline)特性: 14 | * 和相邻的内联元素在同一行; 15 | * 宽度(width)、高度(height)、内边距的top/bottom(padding-top/padding-bottom)和外边距的top/bottom(margin-top/margin-bottom)都不可改变(也就是padding和margin的left和right是可以设置的),就是里面文字或图片的大小。 16 |   浏览器还有默认的天生inline-block元素(拥有内在尺寸,可设置高宽,但不会自动换行):