<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>fg411 | A blog for fg411</title>
    <description>做一条咸鱼，偶尔撸撸代码，吹吹牛逼</description>
    <link>/</link>
    <atom:link href="/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Fri, 04 Dec 2020 08:42:42 +0000</pubDate>
    <lastBuildDate>Fri, 04 Dec 2020 08:42:42 +0000</lastBuildDate>
    <generator>Jekyll v3.9.0</generator>
    
      <item>
        <title>赛马题-从25匹马中选出最快的三/五匹马</title>
        <description>&lt;h2 id=&quot;从25匹马中选出最快的三五匹马&quot;&gt;从25匹马中选出最快的三/五匹马&lt;/h2&gt; &lt;p&gt;前些天看别人的面试题，看到这个题目。一开始没仔细想，后来看了一篇博客，发现之前的答案都不是最少的&lt;/p&gt; &lt;h3 id=&quot;从25匹马中选出最快的三匹马&quot;&gt;从25匹马中选出最快的三匹马&lt;/h3&gt; &lt;p&gt;问：25匹马，5个赛道，没有表和计数器之类的东西，至少跑几次可以找出最快的三匹马？&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;25匹马分五组，每组按成绩排序，如下：&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[ q, w, e, r, t ] [ y, u, i, o, p ] [ a, s, d, f, g ] [ h, j, k, l, z ] [ x, c, v, b, n ] &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;第六次：取每组第一名：[ q, y, a, h, x ]，比赛一次, 假设按成绩排序是 [ a, q, x, h, y ]，则第一名是 &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;因为只需要取前三名，第六次比赛时第四名和第五名不在筛选范围内，又因为这两匹马都是小组第一，所以，这两个小组都不在筛选范围内。&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[ q, w, e, r, t ] [ s, d, f, g ] [ x, c, v, b, n ] &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;此时，除去 a 之后，目前的筛选范围中，第一组的前两名[q, w]和第二组的前两名[s, d]都有可能是前三，而 x 最好的结果是第三名&lt;/p&gt;...</description>
        <pubDate>Fri, 04 Dec 2020 16:19:00 +0000</pubDate>
        <link>/horse-race-question/</link>
        <guid isPermaLink="true">/horse-race-question/</guid>
        
        <category>fg411</category>
        
        <category>算法</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>scp命令</title>
        <description>&lt;h1 id=&quot;语法&quot;&gt;语法&lt;/h1&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;scp &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;可选参数] file_source file_target &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;参数说明&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-1： 强制scp命令使用协议ssh1 -2： 强制scp命令使用协议ssh2 -4： 强制scp命令只使用IPv4寻址 -6： 强制scp命令只使用IPv6寻址 -B： 使用批处理模式（传输过程中不询问传输口令或短语） -C： 允许压缩。（将-C标志传递给ssh，从而打开压缩功能） -p： 保留原文件的修改时间，访问时间和访问权限。 -q： 不显示传输进度条。 -r： 递归复制整个目录。 -v： 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接，验证和配置问题。 -c： cipher： 以cipher将数据传输进行加密，这个选项将直接传递给ssh。 -F： ssh_config： 指定一个替代的ssh配置文件，此参数直接传递给ssh。 -i： identity_file： 从指定文件中读取传输时使用的密钥文件，此参数直接传递给ssh。 -l： limit： 限定用户所能使用的带宽，以Kbit/s为单位。 -o： ssh_option： 如果习惯于使用ssh_config(5)中的参数传递方式， -P： port：注意是大写的P, port是指定数据传输用到的端口号 -S： program： 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;从本地复制到远程&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 复制文件命令格式&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;scp local_file remote_username@remote_ip:remote_folder &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;scp local_file remote_username@remote_ip:remote_file &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;scp local_file remote_ip:remote_folder &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;scp local_file remote_ip:remote_file &lt;span class=&quot;c&quot;&gt;# 复制目录命令格式&lt;/span&gt; scp &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; local_folder remote_username@remote_ip:remote_folder scp &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; local_folder remote_ip:remote_folder &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;...</description>
        <pubDate>Fri, 20 Nov 2020 09:22:00 +0000</pubDate>
        <link>/scp-command/</link>
        <guid isPermaLink="true">/scp-command/</guid>
        
        <category>Linux</category>
        
        <category>Scp</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>Less命令</title>
        <description>&lt;p&gt;　　我们常用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tail -n&lt;/code&gt;  或者 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tail -f&lt;/code&gt; 或者 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt; 或者 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vi&lt;/code&gt; 、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat&lt;/code&gt; 等各种命令去查看异常信息，记下&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;less&lt;/code&gt; 的使用方法&lt;/p&gt; &lt;hr /&gt; &lt;h4 id=&quot;基操&quot;&gt;基操&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;第一步：打开日志文件 &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;less sigma.log &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;第二步：定位到日志文件的最后一行（ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shift+g&lt;/code&gt; 可移动到最后一行）&lt;/li&gt; &lt;li&gt;第三步：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ctrl+b&lt;/code&gt; 往前一页一页翻页查看&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;h4 id=&quot;常见使用方法&quot;&gt;常见使用方法&lt;/h4&gt; &lt;p&gt;&lt;strong&gt;搜索&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;当使用命令 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;less file-name&lt;/code&gt; 打开一个文件后,可以使用下面的方式在文件中搜索。搜索时整个文本中匹配的部分会被高亮显示&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;1.1 向前搜索 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; : 使用一个模式进行搜索，并定位到下一个匹配的文本（按 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt; : 向前查找下一个匹配的文本；按 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N&lt;/code&gt; : 向后查找前一个匹配的文本）&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;1.2 向后搜索 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt; : 使用模式进行搜索,并定位到前一个匹配的文本（&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt; : 向后查找下一个匹配的文本；&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N&lt;/code&gt; : 向前查找前一个匹配的文本）&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;strong&gt;全屏导航&lt;/strong&gt;&lt;/p&gt;...</description>
        <pubDate>Thu, 19 Nov 2020 17:26:00 +0000</pubDate>
        <link>/less-command/</link>
        <guid isPermaLink="true">/less-command/</guid>
        
        <category>Linux</category>
        
        <category>Less</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>使用vue指令实现复制代码</title>
        <description>&lt;p&gt;　　看掘金刷到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue.directive&lt;/code&gt;，想想到现在自己也没写过指令，于是就想写一个指令试试。正考虑写什么好呢，瞅到了&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;复制代码&lt;/code&gt;，不禁感叹：哥真是机智啊。废话不多说，撸起来！&lt;/p&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt;的目录下有关文件的路径：&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;├─ main.js ├─ libs │ ├─ copy.js │ └─ directives.js └─ pages └─ Index.vue &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy.js&lt;/code&gt;：指令的具体内容&lt;/p&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vCopy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;clickHandler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;el&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;code&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;previousElementSibling&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;textContent&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// let code...</description>
        <pubDate>Fri, 29 May 2020 16:50:00 +0000</pubDate>
        <link>/vue-directive-copy/</link>
        <guid isPermaLink="true">/vue-directive-copy/</guid>
        
        <category>vue</category>
        
        <category>Vue.directive</category>
        
        <category>复制代码</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>tree常用命令</title>
        <description>&lt;h2 id=&quot;mac安装&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mac&lt;/code&gt;安装&lt;/h2&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;tree
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;实用命令&quot;&gt;实用命令&lt;/h2&gt;

&lt;p&gt;　　我们可以在目录遍历时使用 -L 参数指定遍历层级。例：显示项目三层结构，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tree -l 3&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;tree &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;　　如果你想把一个目录的结构树导出到文件 Readme.md ,可以这样操作&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;tree &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; 2 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;README.md //然后我们看下当前目录下的 README.md 文件
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;　　只显示文件夹&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;tree &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tree -I pattern&lt;/code&gt; 用于过滤不想要显示的文件或者文件夹。比如要过滤项目中的node_modules文件夹&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;tree &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;node_modules&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;资料&quot;&gt;资料&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.jianshu.com/p/9411d60950bf&quot;&gt;Mac下的 tree 命令 输出目录树层结构&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 19 May 2020 11:50:00 +0000</pubDate>
        <link>/tree-command/</link>
        <guid isPermaLink="true">/tree-command/</guid>
        
        <category>tree</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>如何使用mock模拟数据</title>
        <description>&lt;h2 id=&quot;mockjs的使用&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mockjs&lt;/code&gt;的使用&lt;/h2&gt; &lt;p&gt;　　如今的项目开发模式大多都是前后端分离，既然前后端分离，那开发时就可能会遇到前后端不同步，当前端多次催促服务端后还得不到接口时，分歧就有可能产生。此时&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mock.js&lt;/code&gt;的存在，对前端而言应该算是一种福利了，在开发过程中，前端可以自己模拟数据，开发进度不再受服务端影响&lt;/p&gt; &lt;p&gt;　　有文章说&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mock.js&lt;/code&gt;数据模拟通过改写jquery和zepto的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$.ajax&lt;/code&gt;方法实现拦截Ajax请求，使用原生js封装的ajax方法可能不能拦截&lt;/p&gt; &lt;p&gt;　　本篇是在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue&lt;/code&gt;项目中使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mock.js&lt;/code&gt;,各位看官可根据个人的项目使用灵活应变&lt;/p&gt; &lt;h3 id=&quot;安装-mockjs-模块&quot;&gt;安装 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mock.js&lt;/code&gt; 模块&lt;/h3&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; npm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;mockjs &lt;span class=&quot;nt&quot;&gt;--save-dev&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;使用-mockjs-进行数据模拟&quot;&gt;使用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mock.js&lt;/code&gt; 进行数据模拟&lt;/h3&gt; &lt;p&gt;　　新建一个模拟数据的js文件，如在src目录下新建&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mock.js&lt;/code&gt;,并在 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.js&lt;/code&gt;引入该文件 以下是个简单的例子：&lt;/p&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/mock.js&lt;/code&gt; 内容&lt;/p&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Mock&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;mockjs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Random&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Mock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Random&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;customList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span...</description>
        <pubDate>Fri, 24 Apr 2020 10:22:00 +0000</pubDate>
        <link>/use-mock/</link>
        <guid isPermaLink="true">/use-mock/</guid>
        
        <category>mock</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>git常用语句</title>
        <description>&lt;h3 id=&quot;配置用户信息&quot;&gt;配置用户信息&lt;/h3&gt; &lt;p&gt;　　安装完 Git 之后，要做的第一件事就是设置你的用户名和邮件地址。 这一点很重要，因为每一个 Git 提交都会使用这些信息，它们会写入到你的每一次提交中，不可更改&lt;/p&gt; &lt;p&gt;　　下面是配置全局的用戶信息&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config &lt;span class=&quot;nt&quot;&gt;--global&lt;/span&gt; user.name &lt;span class=&quot;s2&quot;&gt;&quot;xxx&quot;&lt;/span&gt; // 修改用户名，xxx 处填写你的用户名 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config &lt;span class=&quot;nt&quot;&gt;--global&lt;/span&gt; user.email &lt;span class=&quot;s2&quot;&gt;&quot;xxx&quot;&lt;/span&gt; // 修改邮箱地址，xxx 处填写你的邮箱地址 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;检查配置信息&quot;&gt;检查配置信息&lt;/h3&gt; &lt;p&gt;　　如果想要检查你的配置，可以列出所有 Git 当时能找到的配置，也可以只查看用戶名、郵箱&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config &lt;span class=&quot;nt&quot;&gt;--list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config user.name &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config user.email &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;修改指定项目的用户名和邮箱地址&quot;&gt;修改指定项目的用户名和邮箱地址&lt;/h3&gt; &lt;p&gt;　　如果希望在一个特定的项目中使用不同的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;用户名&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;邮箱&lt;/code&gt; 来提交，可以使用下面的方法单独设置 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;用户名&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;邮箱&lt;/code&gt; ，如果不设置就会默认使用上面全局设置的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;用户名&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;邮箱&lt;/code&gt;&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config user.name &lt;span class=&quot;s2&quot;&gt;&quot;xxx&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git config user.email &lt;span...</description>
        <pubDate>Wed, 22 Apr 2020 15:30:00 +0000</pubDate>
        <link>/git-command/</link>
        <guid isPermaLink="true">/git-command/</guid>
        
        <category>fg411</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>npm-ci命令行</title>
        <description>&lt;p&gt;　　刷微博，刷到阮一峰的微博提到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm ci&lt;/code&gt;，出于好奇，查了一下，在这记录下来&lt;/p&gt; &lt;h2 id=&quot;用途&quot;&gt;用途&lt;/h2&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm ci&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm i&lt;/code&gt; 类似，都可以用来安装依赖。他比常规的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm i&lt;/code&gt; 安装快，也比常规安装更严格，他可以npm依赖安装的一致和稳定 (锁版本)&lt;/p&gt; &lt;p&gt;　　在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt;中，每次install后，对应的版本前都有个 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^&lt;/code&gt; 符号。在这种情况下，你再次install时安装的包的版本可能与前次不一样。具体的，你可以到 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package-lock.json&lt;/code&gt; 中查看实际的包版本&lt;/p&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^&lt;/code&gt;的匹配规则是：&amp;gt;= 当前版本，且保持从左至右的第一个非零版本。举例说明：&lt;/p&gt; &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;^1.2.3&quot;: 大于等于 1.2.3 且小于 2.0.0版本 &quot;^0.3.4&quot;: 大于等于 0.3.4 且小于 0.4.0版本 &quot;^0.0.6&quot;: 大于等于 0.0.6 且小于 0.0.7版本 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　若我们一直使用install命令时，便会遇到开发和测试、发布时包版本不同的问题，这种细微的差别往往会导致严重的结局&lt;/p&gt; &lt;h2 id=&quot;用法&quot;&gt;用法&lt;/h2&gt; &lt;p&gt;　　在 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm i(install)&lt;/code&gt; 的地方改用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm ci&lt;/code&gt;，当然项目中必须有一个 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package-lock.json&lt;/code&gt; 或 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm-shrinkwrap.json&lt;/code&gt;&lt;/p&gt; &lt;p&gt;　　注：npm版本要 &amp;gt;= 5.7&lt;/p&gt; &lt;h2 id=&quot;与npm-i的区别&quot;&gt;与&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm i&lt;/code&gt;的区别&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm i&lt;/code&gt;依赖&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt;，而&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm ci&lt;/code&gt;依赖&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package-lock.json&lt;/code&gt;, 项目里面必须存在 &lt;code class=&quot;language-plaintext...</description>
        <pubDate>Thu, 16 Apr 2020 09:55:00 +0000</pubDate>
        <link>/npm-ci-command/</link>
        <guid isPermaLink="true">/npm-ci-command/</guid>
        
        <category>npm</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>JS实现粘贴图片</title>
        <description>&lt;p&gt;　　之前同事写过把剪切板内容粘贴到富文本框编辑器，当时只想当咸鱼就没有研究，最近研究&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileReader&lt;/code&gt;时发现一个例子也是粘贴图片内容，闲来无事就写个demo试一试，顺便还发现了很多不常见的知识点&lt;/p&gt; &lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;preview&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;contenteditable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; 江湖笑，&lt;span class=&quot;nt&quot;&gt;&amp;lt;br&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt; 恩怨了，&lt;span class=&quot;nt&quot;&gt;&amp;lt;br&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt; 人过招，&lt;span class=&quot;nt&quot;&gt;&amp;lt;br&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt; 笑藏刀。 &lt;span class=&quot;nt&quot;&gt;&amp;lt;br&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;paste&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;items&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;clipboardData&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;clipboardData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;blob&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;items&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;items&lt;/span&gt;&lt;span...</description>
        <pubDate>Fri, 10 Apr 2020 17:03:00 +0000</pubDate>
        <link>/js-paste-img/</link>
        <guid isPermaLink="true">/js-paste-img/</guid>
        
        <category>粘贴图片</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>var、let和const的区别</title>
        <description>&lt;h2 id=&quot;letvar和const的区别&quot;&gt;let、var和const的区别&lt;/h2&gt; &lt;p&gt;　　现在讨论一下&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES5&lt;/code&gt;的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES6&lt;/code&gt;的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;let&lt;/code&gt;、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;const&lt;/code&gt;&lt;/p&gt; &lt;h3 id=&quot;为什么会有let-和-const&quot;&gt;为什么会有&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;let&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;const&lt;/code&gt;&lt;/h3&gt; &lt;p&gt;　　ES5只有 全局作用域 和 函数作用域，有时遇到一些不合理的场景，比如遇到下面的代码，大部分人会选择使用闭包来解决这个问题。而&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES6&lt;/code&gt;引入的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;let&lt;/code&gt;可以完美的解决这个问题。至于如何使用闭包实现&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;let&lt;/code&gt;功能，可以看&lt;a href=&quot;https://fg411.github.io/learn-es6-let/&quot;&gt;这里&lt;/a&gt;，有错误的话，还望指正。&lt;/p&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s2&quot;&gt;`use strict`&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;k&lt;/span&gt;&lt;span...</description>
        <pubDate>Wed, 25 Mar 2020 11:20:00 +0000</pubDate>
        <link>/let-var-const/</link>
        <guid isPermaLink="true">/let-var-const/</guid>
        
        <category>js</category>
        
        <category>let</category>
        
        <category>var</category>
        
        <category>const</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>CSS画几何图形</title>
        <description>&lt;p&gt;　　一直对css不在行，最近发现CSS可以很简单的画出几何图形，这里选了几个贴上来，想看更多请 &lt;a href=&quot;http://www.jb51.net/css/41448.html&quot;&gt;点击这里&lt;/a&gt;&lt;/p&gt; &lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;/*正方形*/&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;#square&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;blue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;/*圆形*/&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;#circle&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;-moz-border-radius&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;-webkit-border-radius&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;border-radius&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;/*椭圆*/&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;#oval&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;red&lt;/span&gt;&lt;span...</description>
        <pubDate>Wed, 25 Mar 2020 11:20:00 +0000</pubDate>
        <link>/css-geometry/</link>
        <guid isPermaLink="true">/css-geometry/</guid>
        
        <category>css</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>Git忽略规则及.gitignore规则正确姿势</title>
        <description>&lt;h2 id=&quot;实现需求&quot;&gt;实现需求&lt;/h2&gt;

&lt;p&gt;　　在git中如果想忽略掉某个文件或者文件夹，不想这个文件或者文件夹提交到版本库中，可以使用修改根目录中 .gitignore 文件的方法（如无，则需自己手工建立此文件）。这个文件每一行保存了一个匹配的规则例如：&lt;/p&gt;

&lt;h2 id=&quot;创建gitignore文件&quot;&gt;创建gitignore文件&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;touch&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;注释git忽略规则&quot;&gt;注释Git忽略规则&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 此为注释 – 将被 Git 忽略
 
*.a       # 忽略所有 .a 结尾的文件
!lib.a    # 但 lib.a 除外
/-liberxuesite     # 仅仅忽略项目根目录下的 liberxuesite 文件，不包括 subdir/liberxuesite
liberxue/    # 忽略 liberxue文件夹/ 目录下的所有文件以及文件夹本身
doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;gitignore忽略规则不生效原因&quot;&gt;gitignore忽略规则不生效原因&lt;/h3&gt;

&lt;p&gt;　　规则很简单，不做过多解释，但是有时候在项目开发过程中，突然心血来潮想把某些目录或文件加入忽略规则，按照上述方法定义后发现并未生效，原因是.gitignore只能忽略那些原来没有被track的文件，如果某些文件已经被纳入了版本管理中，则修改.gitignore是无效的。那么解决方法就是先把本地缓存删除（改变成未track状态），然后再提交：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; git &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--cached&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; git add &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'update .gitignore'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Tue, 24 Mar 2020 15:44:00 +0000</pubDate>
        <link>/use-gitignore/</link>
        <guid isPermaLink="true">/use-gitignore/</guid>
        
        <category>Git</category>
        
        <category>gitignore</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>关于html中的position属性</title>
        <description>&lt;p&gt;　　 　　今天按demo写例子，发现&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;relative&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;absolute&lt;/code&gt;可以配合使用，所以又来复习一下&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;position&lt;/code&gt;的常用属性:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;sticky&lt;/strong&gt;：基于用户的滚动位置来定位。也就是以sticky标签定义的标签会随着页面上下移动，但是其内容却不会超过屏幕比如在网站侧边那些移动导航栏&lt;/li&gt; &lt;li&gt;&lt;strong&gt;static&lt;/strong&gt;：HTML元素的默认值，即没有定位，元素出现在正常的流中。静态定位的元素不会受到 top, bottom, left, right影响。也就是和没写position一样的效果&lt;/li&gt; &lt;li&gt;&lt;strong&gt;fixed&lt;/strong&gt;：元素的位置相对于浏览器窗口是固定位置。即使窗口是滚动的它也不会移动，相当一个壁纸标签一样一动不动像镶嵌在屏幕里一样，在很多网站尤其是购物网站里面经常能看到，你看到页面侧边那静静躺在那的导航栏就是用fixed实现的&lt;/li&gt; &lt;li&gt;&lt;strong&gt;relative&lt;/strong&gt;：生成相对定位的元素，相对于其正常位置进行定位；因此，”left:20” 会向元素的 LEFT 位置添加 20 像素&lt;/li&gt; &lt;li&gt;&lt;strong&gt;absolute&lt;/strong&gt;：生成绝对定位的元素，相对于 static 定位以外的第一个父元素进行定位；元素的位置通过 “left”, “top”, “right” 以及 “bottom” 属性进行规定&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;看完各个属性，上代码&lt;/p&gt; &lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;back&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;modal&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;span&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;desc&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; 描述文字 &lt;span class=&quot;nt&quot;&gt;&amp;lt;/span&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;style &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/css&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.box&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;300px&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.back&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span...</description>
        <pubDate>Wed, 11 Mar 2020 16:50:00 +0000</pubDate>
        <link>/position-in-html/</link>
        <guid isPermaLink="true">/position-in-html/</guid>
        
        <category>position</category>
        
        <category>relative</category>
        
        <category>absolute</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>罗列一些常见的页面布局</title>
        <description>&lt;ul&gt; &lt;li&gt;圣杯布局&lt;/li&gt; &lt;li&gt;双飞翼布局&lt;/li&gt; &lt;li&gt;flex 布局&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;　　昨天看博客时无意间发现&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;圣杯布局&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;双飞翼布局&lt;/code&gt;，知(gu)识(lou)渊(gua)博(wen)的我赶紧学习一下&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;　　圣杯布局和双飞翼布局是前端工程师需要日常掌握的重要布局方式。两者的功能相同，都是为了实现一个&lt;em&gt;两侧宽度固定，中间宽度自适应的三栏布局&lt;/em&gt;。&lt;/p&gt; &lt;p&gt;　　圣杯布局是为了讨论「三栏液态布局」的实现，最早的完美实现是由 Matthew Levine 在 2006 年写的一篇文章 《In Search of the Holy Grail》 ，而双飞翼布局来源于淘宝UED。虽然两者的实现方法略有差异，不过都遵循了以下要点：&lt;/p&gt; &lt;ul&gt; &lt;li&gt;两侧宽度固定，中间宽度自适应&lt;/li&gt; &lt;li&gt;中间部分在DOM结构上优先，以便先行渲染&lt;/li&gt; &lt;li&gt;允许三列中的任意一列成为最高列&lt;/li&gt; &lt;li&gt;只需要使用一个额外的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;&lt;/code&gt;标签&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;p&gt;&lt;strong&gt;圣杯布局&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hd&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;header&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;bd&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;middle&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;middle&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;left&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;left&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;right&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;right&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;footer&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;footer&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;style&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;#hd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span...</description>
        <pubDate>Mon, 09 Mar 2020 15:40:00 +0000</pubDate>
        <link>/page-layout/</link>
        <guid isPermaLink="true">/page-layout/</guid>
        
        <category>圣杯布局</category>
        
        <category>双飞翼布局</category>
        
        <category>flex布局</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>用canvas画个闹钟吧</title>
        <description>&lt;p&gt;　　之前想学canvas，今天看到个课程是用canvas画的闹钟，一开始以为会很难，按照课程写了一遍后发现如此简单，下面把 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;js&lt;/code&gt; 部分贴上来&lt;/p&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;dom&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;clock&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ctx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;dom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getContext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;2d&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 计算闹钟半径&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;rem&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 计算比例，防止放大缩小时变型&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span...</description>
        <pubDate>Wed, 15 Jan 2020 16:00:00 +0000</pubDate>
        <link>/canvas-of-clock/</link>
        <guid isPermaLink="true">/canvas-of-clock/</guid>
        
        <category>canvas</category>
        
        <category>clock</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>Mac上实用的命令行语句</title>
        <description>&lt;h3 id=&quot;查看当前目录下的所有文件包含文件夹大小&quot;&gt;查看当前目录下的所有文件（包含文件夹）大小&lt;/h3&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-hs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-shc&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;两个命令都可以，第二个能在最后显示一个 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;total&lt;/code&gt; 大小，即当前目录的总大小&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sh&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;显示当前目录下所有文件（包含文件夹）大小，并排序&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;打开文件夹&quot;&gt;打开文件夹&lt;/h3&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;open &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;查看硬盘容量&quot;&gt;查看硬盘容量&lt;/h3&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;查看文件&quot;&gt;查看文件&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tail&lt;/code&gt;命令查看文件的最后十行内容&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;tail&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-10&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;参考&quot;&gt;参考&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.jianshu.com/p/85f048998e92&quot;&gt;Mac 终端命令大全&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 06 Jan 2020 18:00:00 +0000</pubDate>
        <link>/command-line/</link>
        <guid isPermaLink="true">/command-line/</guid>
        
        <category>terminal</category>
        
        <category>javascript</category>
      </item>
    
      <item>
        <title>JS的this面试题</title>
        <description>&lt;h2 id=&quot;1--this&quot;&gt;1 . &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt;&lt;/h2&gt; &lt;hr /&gt; &lt;p&gt;　　什么是 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; ？在讨论 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; 绑定前，我们得先搞清楚 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; 代表什么&lt;/p&gt; &lt;ul&gt; &lt;li&gt;1 . &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt;是&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JavaScript&lt;/code&gt;的关键字之一。它是 对象自动生成的一个内部对象，只能在 对象 内部使用。随着函数使用场合的不同，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; 的值会发生变化&lt;/li&gt; &lt;li&gt;2 . &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt;指向什么，完全取决于 什么地方以什么方式调用，而不是 创建时&lt;/strong&gt;。（比较多人误解的地方）（它非常语义化，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt;在英文中的含义就是 &lt;strong&gt;这，这个&lt;/strong&gt; ，但这其实起到了一定的误导作用，因为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt;并不是一成不变的，并不一定一直指向当前 &lt;strong&gt;这个&lt;/strong&gt;）&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;2--this-绑定规则&quot;&gt;2 . &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; 绑定规则&lt;/h2&gt; &lt;hr /&gt; &lt;p&gt;　　掌握了下面介绍的4种绑定的规则，那么&lt;strong&gt;你只要看到函数调用就可以判断 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; 的指向了&lt;/strong&gt;&lt;/p&gt; &lt;h3 id=&quot;21-默认绑定&quot;&gt;2.1 默认绑定&lt;/h3&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;foo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 10&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;...</description>
        <pubDate>Mon, 06 Jan 2020 18:00:00 +0000</pubDate>
        <link>/javascript-of-this/</link>
        <guid isPermaLink="true">/javascript-of-this/</guid>
        
        <category>this</category>
        
        <category>JavaScript</category>
        
        <category>javascript</category>
      </item>
    
      <item>
        <title>curl 和 wget 的区别和使用</title>
        <description>&lt;p&gt;　　非要说区别的话，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt; 由于可自定义各种请求参数所以在模拟web请求方面更擅长；&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget&lt;/code&gt; 由于支持 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ftp&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Recursive&lt;/code&gt; 所以在下载文件方面更擅长。类比的话 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt; 是浏览器，而 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget&lt;/code&gt; 是迅雷&lt;/p&gt; &lt;h4 id=&quot;1-下载文件&quot;&gt;1. 下载文件&lt;/h4&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; http://man.linuxde.net/text.iso &lt;span class=&quot;c&quot;&gt;#O大写，不用O只是打印内容不会下载&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;wget http://www.linuxde.net/text.iso &lt;span class=&quot;c&quot;&gt;#不用参数，直接下载文件&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;2-下载文件并重命名&quot;&gt;2. 下载文件并重命名&lt;/h4&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; rename.iso http://www.linuxde.net/text.iso &lt;span class=&quot;c&quot;&gt;#o小写&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;wget &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; rename.zip http://www.linuxde.net/text.iso &lt;span class=&quot;c&quot;&gt;#O大写&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;3-断点续传&quot;&gt;3. 断点续传&lt;/h4&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; - http://man.linuxde.net/text.iso &lt;span class=&quot;c&quot;&gt;#O大写，C大写&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;wget &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; http://www.linuxde.net/text.iso &lt;span class=&quot;c&quot;&gt;#c小写&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4 id=&quot;4-限速下载&quot;&gt;4. 限速下载&lt;/h4&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span...</description>
        <pubDate>Fri, 03 Jan 2020 16:00:00 +0000</pubDate>
        <link>/use-curl-and-wget/</link>
        <guid isPermaLink="true">/use-curl-and-wget/</guid>
        
        <category>curl</category>
        
        <category>wget</category>
        
        <category>blog</category>
      </item>
    
      <item>
        <title>jQuery实现瀑布流</title>
        <description>&lt;p&gt;　　瀑布流，又称瀑布流式布局。是比较流行的一种网站页面布局，视觉表现为参差不齐的多栏布局，随着页面滚动条向下滚动，这种布局还会不断加载数据块并附加至当前尾部&lt;/p&gt; &lt;h2 id=&quot;瀑布流的排序规律&quot;&gt;瀑布流的排序规律&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;每张图片的宽度是一致的&lt;/li&gt; &lt;li&gt;从左往右进行排序，第一排放不下则从第二排从新开始排列&lt;/li&gt; &lt;li&gt;第二排或者往后的每排图片放置的位置为上一排高度最小图片的下面依次排放&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;瀑布流实现的原理&quot;&gt;瀑布流实现的原理&lt;/h2&gt; &lt;p&gt;1、图片的位置摆放&lt;/p&gt; &lt;ul&gt; &lt;li&gt;图片位置的摆放大致可以不添加样式一次放置&lt;/li&gt; &lt;li&gt;通过设置成块级元素，进行摆放&lt;/li&gt; &lt;li&gt;通过绝对定位来进行摆放&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;2、 瀑布流图片/div容器的实现是通过对其进行绝对定位来实现的&lt;/p&gt; &lt;ul&gt; &lt;li&gt;假设X轴列有4张图片，宽度为100px; 那第一张left 值为0，第二张left值为100px，第三张为200px,第四张为300px&lt;/li&gt; &lt;li&gt;图片的高度，我们需要通过对其图片的高度进行判断，让第二横对的图片首先放到 X 列高度最小的图片下面(如图所示，一横列为4张图片，第五张图片放在第二横列中，寻找到第二列的图片高度最低，就将图片当道第二列中。第6张图片寻找到第四列的高度低就将图片放到第四列中，下面每次都是这样)&lt;/li&gt; &lt;li&gt;因为图片的高度很重要，我们需要保存并进行比较，所以我们要用一个数组来接受图片的高度&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;瀑布流&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;style &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/css&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.waterfall&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;860px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.waterfall&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;absolute&lt;/span&gt;&lt;span...</description>
        <pubDate>Tue, 24 Dec 2019 18:00:00 +0000</pubDate>
        <link>/learn-water-fall/</link>
        <guid isPermaLink="true">/learn-water-fall/</guid>
        
        <category>瀑布流</category>
        
        <category>jQuery</category>
        
        <category>javascript</category>
      </item>
    
      <item>
        <title>ES6中let的实现</title>
        <description>&lt;p&gt;　　之前看到过一篇博客写&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES6&lt;/code&gt;中&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;let&lt;/code&gt;的实现，没太在意，最近闲来搜了一下也看了几篇博客，在这贴一些代码&lt;/p&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES6&lt;/code&gt;出来之前，作为菜鸟的我遇到下面这种，就会抱怨&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JS&lt;/code&gt;真是满满的坑&lt;/p&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s2&quot;&gt;`use strict`&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 我们想在 console.log 中打印 0 ~ 4，而事实打印出来的却是 5 个 5&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　现在使用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES6&lt;/code&gt; 的 &lt;code class=&quot;language-plaintext...</description>
        <pubDate>Fri, 20 Dec 2019 16:00:00 +0000</pubDate>
        <link>/learn-es6-let/</link>
        <guid isPermaLink="true">/learn-es6-let/</guid>
        
        <category>var</category>
        
        <category>let</category>
        
        <category>变量提升</category>
        
        <category>javascript</category>
      </item>
    
      <item>
        <title>CSS小技巧</title>
        <description>&lt;h2 id=&quot;用-font-size-0-来清除间距&quot;&gt;用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;font-size: 0&lt;/code&gt; 来清除间距&lt;/h2&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;inline-block&lt;/code&gt; 的元素之间会受空白区域的影响，也就是元素之间差不多会有一个字符的间隙。如果在同一行内有4个25%相同宽度的元素，会导致最后一个元素掉下来。你可以利用元素浮动 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;float&lt;/code&gt;，或者压缩html，清除元素间的空格来解决。但最简单有效的方法还是设置父元素的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;font-size&lt;/code&gt; 属性为 0&lt;/p&gt; &lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;box-sizing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;border-box&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.items&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.items&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.item&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inline-block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;25%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1px&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;solid&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;#ccc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;text-align&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;line-height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;#eee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;...</description>
        <pubDate>Fri, 06 Dec 2019 15:00:40 +0000</pubDate>
        <link>/tips-of-css/</link>
        <guid isPermaLink="true">/tips-of-css/</guid>
        
        <category>css</category>
        
        <category>clip-path</category>
        
        <category>shape-outside</category>
        
        <category>http</category>
      </item>
    
      <item>
        <title>node实现反向代理</title>
        <description>&lt;p&gt;　　公司在做银行项目，开发都在云桌面。不能直接访问服务器上的接口服务，但是可以连接到云桌面，所以搭建个代理之后就可以愉快的在本地开发啦&lt;/p&gt; &lt;p&gt;　　安装&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http-proxy&lt;/code&gt;模块&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;npm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;http-proxy &lt;span class=&quot;nt&quot;&gt;--save-dev&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　新建js文件&lt;/p&gt; &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// server.js&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;httpProxy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;http-proxy&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;proxy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;httpProxy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createProxyServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({});&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;proxy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;writeHead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;text/plain&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt; &lt;span...</description>
        <pubDate>Mon, 18 Nov 2019 18:00:40 +0000</pubDate>
        <link>/take-proxy-for-node/</link>
        <guid isPermaLink="true">/take-proxy-for-node/</guid>
        
        <category>node</category>
        
        <category>http-proxy</category>
        
        <category>反向代理</category>
        
        <category>http</category>
      </item>
    
      <item>
        <title>nvm介绍与使用</title>
        <description>&lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Node&lt;/code&gt; 版本快速迭代，项目多了就会需要切换 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Node&lt;/code&gt; 版本，这时可以尝试使用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NVM&lt;/code&gt; 或 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt;，在这里我们介绍一下 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NVM&lt;/code&gt;&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;node &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　在官网下载的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node&lt;/code&gt; 安装包，运行后会自动安装在全局目录，使用过程中经常会遇到一些权限问题，所以卸载全局安装的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node/npm&lt;/code&gt;&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nvm &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　列出已安装&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;nvm &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　显示当前的版本&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;nvm current &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　安装最新稳定版 node&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;nvm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;stable &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　安装指定版本（如：8.11.4）&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;nvm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;8.11.4 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　删除已安装指定版本（如：8.11.4）&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;nvm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;8.11.4 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　切换版本（如：8.11.4 /...</description>
        <pubDate>Mon, 11 Nov 2019 14:00:00 +0000</pubDate>
        <link>/use-nvm/</link>
        <guid isPermaLink="true">/use-nvm/</guid>
        
        <category>NVM</category>
        
        <category>Node</category>
        
        <category>tutorial</category>
      </item>
    
      <item>
        <title>更换brew镜像源并安装oh-my-zsh</title>
        <description>&lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Homebrew&lt;/code&gt; 通过 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git&lt;/code&gt; 来工作的, 默认的源是 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Github&lt;/code&gt;. 所以&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;update&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;install&lt;/code&gt;超级慢!&lt;/p&gt; &lt;h3 id=&quot;更换-brew-镜像源&quot;&gt;更换 brew 镜像源&lt;/h3&gt; &lt;p&gt;　　&lt;strong&gt;1.替换 brew.git&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;brew &lt;span class=&quot;nt&quot;&gt;--repo&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 切换到 Homebrew 目录&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git &lt;span class=&quot;c&quot;&gt;# 切换成阿里源, 其实就是改了远程仓库的地址&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　&lt;strong&gt;替换 homebrew-core.git&lt;/strong&gt;&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;brew &lt;span class=&quot;nt&quot;&gt;--repo&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/Library/Taps/homebrew/homebrew-core&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;　　&lt;strong&gt;替换 homebrew-bottles&lt;/strong&gt; : 二进制文件&lt;/p&gt; &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HOMEBREW_BOTTLE_DOMAIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://mirrors.ustc.edu.cn/homebrew-bottles’ &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bash_profile &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; ~/.bash_profile &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;...</description>
        <pubDate>Mon, 11 Nov 2019 14:00:00 +0000</pubDate>
        <link>/use-brew-and-ohmyzsh/</link>
        <guid isPermaLink="true">/use-brew-and-ohmyzsh/</guid>
        
        <category>brew</category>
        
        <category>oh-my-zsh</category>
        
        <category>javascript</category>
      </item>
    
      <item>
        <title>2019年的书单</title>
        <description>&lt;h4 id=&quot;书单&quot;&gt;书单&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;del&gt;你坏&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;树莓派开始，玩转Linux&lt;/del&gt; （入门可以尝试购买）&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;浪潮之巅（上册）&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;我们仨&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;湖畔&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;以眨眼干杯&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;岛上书店&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;浪潮之巅（下册）&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;明朝那些事儿&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;围城&lt;/li&gt;
  &lt;li&gt;罗生门&lt;/li&gt;
  &lt;li&gt;三体&lt;/li&gt;
  &lt;li&gt;杀死一只知更鸟&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;只是丢了手机而已&lt;/del&gt;&lt;/li&gt;
  &lt;li&gt;我是貓&lt;/li&gt;
  &lt;li&gt;追风筝的人&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 11 Nov 2019 11:11:11 +0000</pubDate>
        <link>/book-list/</link>
        <guid isPermaLink="true">/book-list/</guid>
        
        <category>2019书单</category>
        
        <category>life</category>
      </item>
    
      <item>
        <title>浏览器的同源策略与跨域</title>
        <description>&lt;p&gt;　　1995年，同源政策由 Netscape 公司引入浏览器。目前，所有支持JavaScript的浏览器都都会使用这个策略。”同源政策”（same-origin policy）是浏览器安全的基石&lt;/p&gt; &lt;hr /&gt; &lt;h3 id=&quot;1-概述&quot;&gt;1 概述&lt;/h3&gt; &lt;h4 id=&quot;11-含义&quot;&gt;1.1 含义&lt;/h4&gt; &lt;p&gt;　　所谓同源是指，域名，协议，端口相同&lt;/p&gt; &lt;h4 id=&quot;12-目的&quot;&gt;1.2 目的&lt;/h4&gt; &lt;p&gt;　　同源政策的目的，是为了保证用户信息的安全，防止恶意的网站窃取数据&lt;/p&gt; &lt;h4 id=&quot;13-缺点和权衡&quot;&gt;1.3 缺点和权衡&lt;/h4&gt; &lt;p&gt;　　如果严格的遵循同源策略，会面临很多的问题。比如，图片，css，js等都得从同域名网站下去获取，个人网站，小网站这样是没问题的。但是对于用户量很大的网站，显然对服务器的压力将会很大，图片等大文件都会占用服务器的带宽&lt;/p&gt; &lt;p&gt;　　不要安全不行，不要性能也不行。在安全和性能上的考虑，使得现代浏览器在安全性和可用性之间选择了一个平衡。所以，现在的浏览器，对于一些资源标签，都开了后门权限。比如，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;img&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;style&lt;/code&gt;等标签，都允许垮域引用资源&lt;/p&gt; &lt;p&gt;　　正因为跨域访问的存在，web世界才能更加的精彩&lt;/p&gt; &lt;h4 id=&quot;14-限制范围&quot;&gt;1.4 限制范围&lt;/h4&gt; &lt;p&gt;　　随着互联网的发展，”同源政策”越来越严格。目前，如果非同源，共有三种行为受到限制&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Cookie、LocalStorage 和 IndexDB 无法读取&lt;/li&gt; &lt;li&gt;DOM 无法获得&lt;/li&gt; &lt;li&gt;AJAX 请求不能发送&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;　　同源策略下的web世界, 域的壁垒高筑, 从而保证各个网页相互独立, 互相之间不能直接访问, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iframe&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ajax&lt;/code&gt; 均受其限制, 而&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script&lt;/code&gt;标签不受此限制&lt;/p&gt; &lt;p&gt;&lt;strong&gt;iframe限制&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;可以访问同域资源, 可读写&lt;/li&gt; &lt;li&gt;访问跨域页面时, 只读&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Ajax限制&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;同域资源可读写&lt;/li&gt; &lt;li&gt;跨域请求会直接被浏览器拦截(chrome下跨域请求不会发起, 其他浏览器一般是可发送跨域请求, 但响应被浏览器拦截)&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Script限制&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;　　script并无跨域限制, 这是因为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script&lt;/code&gt;标签引入的文件不能够被客户端的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;js&lt;/code&gt; 获取到, 不会影响到原页面的安全, 因此&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script&lt;/code&gt;标签引入的文件没必要遵循浏览器的同源策略. 相反, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ajax&lt;/code&gt; 加载的文件内容可被客户端 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;js&lt;/code&gt; 获取到, 引入的文件内容可能会泄漏或者影响原页面安全, 故 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ajax&lt;/code&gt;...</description>
        <pubDate>Fri, 08 Nov 2019 14:30:00 +0000</pubDate>
        <link>/same-origin-policy/</link>
        <guid isPermaLink="true">/same-origin-policy/</guid>
        
        <category>http</category>
        
        <category>同源策略</category>
        
        <category>跨域</category>
        
        <category>JSONP</category>
        
        <category>CORS</category>
        
        <category>http</category>
      </item>
    
      <item>
        <title>eslint规则整理</title>
        <description>&lt;p&gt;　　使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vue-cli&lt;/code&gt;脚手架生成的Vue项目，会有关于代码规范的选择，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eslint&lt;/code&gt;是其中之一。作为一个开发者，主流的开发规范虽然不是必须要使用，但是还是需要了解一下的&lt;/p&gt; &lt;h3 id=&quot;eslint-主要有以下特点&quot;&gt;ESLint 主要有以下特点&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;1、默认规则包含所有 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JSLint&lt;/code&gt;、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JSHint&lt;/code&gt; 中存在的规则，易迁移&lt;/li&gt; &lt;li&gt;2、规则可配置性高：可设置「警告」、「错误」两个 error 等级，或者直接禁用&lt;/li&gt; &lt;li&gt;3、包含代码风格检测的规则（可以丢掉 JSCS 了）&lt;/li&gt; &lt;li&gt;4、支持插件扩展、自定义规则&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue&lt;/code&gt;项目&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ESLint&lt;/code&gt;的配置规则在 根目录下 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.eslintrc.js&lt;/code&gt;文件的 rules 下&lt;/p&gt; &lt;p&gt;　　以下是规则和注释，留下以备以后开发时用到&lt;/p&gt; &lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nl&quot;&gt;&quot;rules&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;定义对象的set存取器属性时，强制定义get&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;accessor-pairs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;指定数组的元素之间要以空格隔开(&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;后面)，&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;never参数：&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;之前和&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;之后不能带空格，always参数：&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;之前和&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;之后必须带空格&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;array-bracket-spacing&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span...</description>
        <pubDate>Fri, 01 Nov 2019 14:00:00 +0000</pubDate>
        <link>/eslint-rules/</link>
        <guid isPermaLink="true">/eslint-rules/</guid>
        
        <category>eslint</category>
        
        <category>rules</category>
        
        <category>tutorial</category>
      </item>
    
      <item>
        <title>Raspberry安装shadowsocks-qt5</title>
        <description>&lt;p&gt;更新软件源&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装PIP环境&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;python-pip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装shadowsocks&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pip &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;shadowsocks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;后台运行&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ssserver &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 23564 &lt;span class=&quot;nt&quot;&gt;-k&lt;/span&gt; password &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; rc4-md5 &lt;span class=&quot;nt&quot;&gt;--user&lt;/span&gt; nobody &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;端口号：23564
密码：password
加密方法：rc4-md5&lt;/p&gt;
</description>
        <pubDate>Fri, 01 Nov 2019 10:30:00 +0000</pubDate>
        <link>/install-shadowsocks-qt5/</link>
        <guid isPermaLink="true">/install-shadowsocks-qt5/</guid>
        
        <category>ubuntu</category>
        
        <category>shadowsocks</category>
        
        <category>tutorial</category>
      </item>
    
      <item>
        <title>搭建shadowsocks服务</title>
        <description>&lt;p&gt;更新软件源&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装PIP环境&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;python-pip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装shadowsocks&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pip &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;shadowsocks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;后台运行&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ssserver &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 23564 &lt;span class=&quot;nt&quot;&gt;-k&lt;/span&gt; password &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; rc4-md5 &lt;span class=&quot;nt&quot;&gt;--user&lt;/span&gt; nobody &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;端口号：23564
密码：password
加密方法：rc4-md5&lt;/p&gt;
</description>
        <pubDate>Fri, 01 Nov 2019 10:30:00 +0000</pubDate>
        <link>/build-shadowsocks/</link>
        <guid isPermaLink="true">/build-shadowsocks/</guid>
        
        <category>ubuntu</category>
        
        <category>shadowsocks</category>
        
        <category>tutorial</category>
      </item>
    
      <item>
        <title>使用 sendemail 发送邮件</title>
        <description>&lt;p&gt;　　看树莓派的书，发现可以使用 &lt;strong&gt;sendemail&lt;/strong&gt; 发送天气信息，闲来无事，折腾一波&lt;/p&gt; &lt;h2 id=&quot;获取天气数据&quot;&gt;获取天气数据&lt;/h2&gt; &lt;p&gt;　　在这里可以使用&lt;a href=&quot;https://dev.heweather.com/&quot;&gt;和风天气开发者&lt;/a&gt; ，注册并获取 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;key&lt;/code&gt;&lt;/p&gt; &lt;p&gt;　　进入开发文档，可以使用获取常规天气数据的接口（免费版）&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;https://free-api.heweather.net/s6/weather/{weather-type}?{parameters}&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{weather-type}&lt;/code&gt; 代表不同的天气数据类型，必选。使用以下值：&lt;/p&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;weather-type 值&lt;/th&gt; &lt;th&gt;描述&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;now&lt;/td&gt; &lt;td&gt;实况天气&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;forecast&lt;/td&gt; &lt;td&gt;3-10天预报&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;hourly&lt;/td&gt; &lt;td&gt;逐小时预报&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;lifestyle&lt;/td&gt; &lt;td&gt;生活指数&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;　　&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{parameters}&lt;/code&gt; 代表请求参数，包括必选和可选参数。所有请求参数使用 &amp;amp; 进行分隔，参数值存在中文或特殊字符的情况，需要对参数进行 url encode&lt;/p&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;parameters 值&lt;/th&gt; &lt;th&gt;描述&lt;/th&gt; &lt;th&gt;描述&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;location&lt;/td&gt; &lt;td&gt;需要查询的城市或地区（经纬度 / 城市名 [拼音、汉字] /IP 等）&lt;/td&gt; &lt;td&gt;必选&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;lang&lt;/td&gt; &lt;td&gt;多语言，可以不使用该参数，默认为简体中文&lt;/td&gt; &lt;td&gt;选填&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;unit&lt;/td&gt; &lt;td&gt;单位选择，公制（m）或英制（i），默认为公制单位&lt;/td&gt; &lt;td&gt;选填&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;key&lt;/td&gt; &lt;td&gt;用户认证key&lt;/td&gt; &lt;td&gt;必填&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;　　具体请自行查看和风天气API&lt;/p&gt; &lt;p&gt;　　API 返回的数据是 json 字符串，需要对数据进行解析，这里可以安装&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt;工具&lt;/p&gt; &lt;div class=&quot;language-shell...</description>
        <pubDate>Thu, 31 Oct 2019 18:00:00 +0000</pubDate>
        <link>/send-email/</link>
        <guid isPermaLink="true">/send-email/</guid>
        
        <category>树莓派</category>
        
        <category>sendemail</category>
        
        <category>和风天气</category>
        
        <category>linux</category>
      </item>
    
  </channel>
</rss>
