-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1320 lines (877 loc) · 50 KB
/
Copy pathindex.html
File metadata and controls
1320 lines (877 loc) · 50 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/font-awesome@4/css/font-awesome.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"www.chaohang.top","root":"/","scheme":"Pisces","version":"7.7.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":3,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
</script>
<meta property="og:type" content="website">
<meta property="og:title" content="张小超的博客">
<meta property="og:url" content="https://www.chaohang.top/index.html">
<meta property="og:site_name" content="张小超的博客">
<meta property="article:author" content="张小超">
<meta property="article:tag" content="Java">
<meta property="article:tag" content=" JavaScript">
<meta property="article:tag" content=" Node.js">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://www.chaohang.top/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome: true,
isPost: false
};
</script>
<title>张小超的博客</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="Toggle navigation bar">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
<div class="site-meta">
<div>
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">张小超的博客</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<h1 class="site-subtitle" itemprop="description">超超不会飞</h1>
</div>
<div class="site-nav-right"></div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>Tags</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>About</a>
</li>
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>Search
</a>
</li>
</ul>
</nav>
<div class="site-search">
<div class="popup search-popup">
<div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocorrect="off" autocapitalize="off"
placeholder="Searching..." spellcheck="false"
type="search" class="search-input">
</div>
<span class="popup-btn-close">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div id="search-result"></div>
</div>
<div class="search-pop-overlay"></div>
</div>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content">
<div class="posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/11/18/%E4%B8%BA%E4%BB%80%E4%B9%88redo%20log%E5%85%B7%E6%9C%89crash-safe%E7%9A%84%E8%83%BD%E5%8A%9B/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/11/18/%E4%B8%BA%E4%BB%80%E4%B9%88redo%20log%E5%85%B7%E6%9C%89crash-safe%E7%9A%84%E8%83%BD%E5%8A%9B/" class="post-title-link" itemprop="url">为什么 redo log 具有 crash-safe 的能力,是 binlog 无法替代的?</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-11-18 09:49:20 / Modified: 09:46:04" itemprop="dateCreated datePublished" datetime="2020-11-18T09:49:20+08:00">2020-11-18</time>
</span>
<span id="/2020/11/18/%E4%B8%BA%E4%BB%80%E4%B9%88redo%20log%E5%85%B7%E6%9C%89crash-safe%E7%9A%84%E8%83%BD%E5%8A%9B/" class="post-meta-item leancloud_visitors" data-flag-title="为什么 redo log 具有 crash-safe 的能力,是 binlog 无法替代的?" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/11/18/%E4%B8%BA%E4%BB%80%E4%B9%88redo%20log%E5%85%B7%E6%9C%89crash-safe%E7%9A%84%E8%83%BD%E5%8A%9B/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/11/18/%E4%B8%BA%E4%BB%80%E4%B9%88redo%20log%E5%85%B7%E6%9C%89crash-safe%E7%9A%84%E8%83%BD%E5%8A%9B/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>昨天在复习 MySQL 日志相关的知识,学的东西过一段时间后就会遗忘,遗忘后再重新思考,往往会有新的收获。想到几个问题,把它记录下来。</p>
<h2 id="为什么-redo-log-具有-crash-safe-的能力,而-binlog-没有?"><a href="#为什么-redo-log-具有-crash-safe-的能力,而-binlog-没有?" class="headerlink" title="为什么 redo log 具有 crash-safe 的能力,而 binlog 没有?"></a>为什么 redo log 具有 crash-safe 的能力,而 binlog 没有?</h2><p>redo log 是什么?</p>
<p>一个固定大小,<strong>“循环写”</strong>的日志文件,记录的是物理日志——“在某个数据页上做了某个修改”。</p>
<p>binlog 是什么?</p>
<p>一个无限大小,<strong>“追加写”</strong>的日志文件,记录的是逻辑日志——“给 ID=2 这一行的 c 字段加1”。</p>
<p>redo log 和 binlog 有一个很大的区别就是,一个是循环写,一个是追加写。也就是说 redo log 只会记录未刷盘的日志,已经刷入磁盘的数据都会从 redo log 这个有限大小的日志文件里删除。binlog 是追加日志,保存的是全量的日志。</p>
<p>当数据库 crash 后,想要恢复<strong>未刷盘但已经写入 redo log 和 binlog 的数据</strong>到内存时,binlog 是无法恢复的。虽然 binlog 拥有全量的日志,但没有一个标志让 innoDB 判断哪些数据已经刷盘,哪些数据还没有。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/11/18/%E4%B8%BA%E4%BB%80%E4%B9%88redo%20log%E5%85%B7%E6%9C%89crash-safe%E7%9A%84%E8%83%BD%E5%8A%9B/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/11/03/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E5%8F%B0%E5%92%96%E5%95%A1%E6%9C%BA/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/11/03/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E5%8F%B0%E5%92%96%E5%95%A1%E6%9C%BA/" class="post-title-link" itemprop="url">我的第一台咖啡机</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-11-03 09:49:20 / Modified: 09:46:04" itemprop="dateCreated datePublished" datetime="2020-11-03T09:49:20+08:00">2020-11-03</time>
</span>
<span id="/2020/11/03/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E5%8F%B0%E5%92%96%E5%95%A1%E6%9C%BA/" class="post-meta-item leancloud_visitors" data-flag-title="我的第一台咖啡机" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/11/03/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E5%8F%B0%E5%92%96%E5%95%A1%E6%9C%BA/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/11/03/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E5%8F%B0%E5%92%96%E5%95%A1%E6%9C%BA/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><img data-src="http://cdn.chaohang.top/20201109164211.jpg" alt=""></p>
<p>自从开始早起,每天一杯咖啡就成了标配,在我的另一篇文章<a href="https://chaohang.top/archives/463" target="_blank" rel="noopener">《咖啡+奶》</a>中聊过,从一开始的3+1速溶进阶到黑咖啡+鲜牛奶,这次我的咖啡体验又升级啦。入了一台胶囊咖啡机 Nespresso Inissia C40,爱喝咖啡星人终于有了一台属于自己的咖啡机啦。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/11/03/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E5%8F%B0%E5%92%96%E5%95%A1%E6%9C%BA/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/10/19/%E9%AB%98%E6%95%88%E5%AD%A6%E4%B9%A0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/10/19/%E9%AB%98%E6%95%88%E5%AD%A6%E4%B9%A0/" class="post-title-link" itemprop="url">高效学习</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-10-19 08:28:52" itemprop="dateCreated datePublished" datetime="2020-10-19T08:28:52+08:00">2020-10-19</time>
</span>
<span id="/2020/10/19/%E9%AB%98%E6%95%88%E5%AD%A6%E4%B9%A0/" class="post-meta-item leancloud_visitors" data-flag-title="高效学习" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/10/19/%E9%AB%98%E6%95%88%E5%AD%A6%E4%B9%A0/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/10/19/%E9%AB%98%E6%95%88%E5%AD%A6%E4%B9%A0/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<blockquote>
<p>左耳听风《高效学习篇》笔记</p>
</blockquote>
<h2 id="端正学习态度"><a href="#端正学习态度" class="headerlink" title="端正学习态度"></a>端正学习态度</h2><p>学习所需要具备的能力:</p>
<ol>
<li>行动力:缺乏行动力的人只会嘴上说说,很少真实践行;</li>
<li>方向和目标:要在前进过程不断修正自己的方向,确立和实现自己的目标;</li>
<li>方法:学习的方法很重要,没有方法论的支持,可能耗费大量的时间却收获很少;</li>
<li>自律和坚持:严格的自律,坚持,有效学习不使蛮力,可持续发展。</li>
</ol>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/10/19/%E9%AB%98%E6%95%88%E5%AD%A6%E4%B9%A0/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/10/17/WordPress%E6%B7%BB%E5%8A%A0%E9%A1%B5%E9%9D%A2%E5%AF%BC%E8%88%AA/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/10/17/WordPress%E6%B7%BB%E5%8A%A0%E9%A1%B5%E9%9D%A2%E5%AF%BC%E8%88%AA/" class="post-title-link" itemprop="url">WordPress添加页面导航</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-10-17 14:46:40" itemprop="dateCreated datePublished" datetime="2020-10-17T14:46:40+08:00">2020-10-17</time>
</span>
<span id="/2020/10/17/WordPress%E6%B7%BB%E5%8A%A0%E9%A1%B5%E9%9D%A2%E5%AF%BC%E8%88%AA/" class="post-meta-item leancloud_visitors" data-flag-title="WordPress添加页面导航" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/10/17/WordPress%E6%B7%BB%E5%8A%A0%E9%A1%B5%E9%9D%A2%E5%AF%BC%E8%88%AA/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/10/17/WordPress%E6%B7%BB%E5%8A%A0%E9%A1%B5%E9%9D%A2%E5%AF%BC%E8%88%AA/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>WordPress 原生的页面导航不好用,我们可以利用插件改成分页导航。</p>
<p>我们使用 <code>WP-PageNavi</code> 插件来替代原生的页面导航。</p>
<p>安装结束后进入主题编辑器,找到首页 <code>index.php</code>,找到 <code>navigation</code> 或者 <code>nav</code> 相关的代码,注释掉相关代码,并在位置上添加如下代码:</p>
<p><code><?php wp_pagenavi(); ?></code></p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/10/17/WordPress%E6%B7%BB%E5%8A%A0%E9%A1%B5%E9%9D%A2%E5%AF%BC%E8%88%AA/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/10/17/WordPress%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/10/17/WordPress%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE/" class="post-title-link" itemprop="url">WordPress自动代码高亮</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-10-17 11:32:12" itemprop="dateCreated datePublished" datetime="2020-10-17T11:32:12+08:00">2020-10-17</time>
</span>
<span id="/2020/10/17/WordPress%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE/" class="post-meta-item leancloud_visitors" data-flag-title="WordPress自动代码高亮" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/10/17/WordPress%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/10/17/WordPress%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>WordPress 自带的代码块是没有代码高亮的,我们可以通过安装插件,设置代码高亮。</p>
<p>因为都是使用 Markdown 写博客,再用 MWeb 发布到博客上,<code>Enlighter</code> 这种需要依赖谷腾堡编辑器插入额外模块的插件,就不太适合我了,虽然这个插件很强大,有兴趣的朋友可以尝试下。</p>
<p><img data-src="http://cdn.chaohang.top/20201017140823.png" alt="Enlighter"></p>
<p>我只能选择自动美化谷腾堡代码块的插件,我找到了 <code>Code Prettify</code> 这个简单的插件,直接安装,不需要额外的配置,就能自动渲染代码块,目前我还是挺满意的,简单方便。大家要是有更好用的插件,也可以在评论区告诉我。</p>
<p>效果如下:</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/10/17/WordPress%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/10/17/%E5%A6%82%E4%BD%95%E7%BB%99WordPress%E6%B7%BB%E5%8A%A0%E9%98%85%E8%AF%BB%E8%AE%A1%E6%95%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/10/17/%E5%A6%82%E4%BD%95%E7%BB%99WordPress%E6%B7%BB%E5%8A%A0%E9%98%85%E8%AF%BB%E8%AE%A1%E6%95%B0/" class="post-title-link" itemprop="url">如何给WordPress添加阅读计数</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-10-17 10:49:20" itemprop="dateCreated datePublished" datetime="2020-10-17T10:49:20+08:00">2020-10-17</time>
</span>
<span id="/2020/10/17/%E5%A6%82%E4%BD%95%E7%BB%99WordPress%E6%B7%BB%E5%8A%A0%E9%98%85%E8%AF%BB%E8%AE%A1%E6%95%B0/" class="post-meta-item leancloud_visitors" data-flag-title="如何给WordPress添加阅读计数" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/10/17/%E5%A6%82%E4%BD%95%E7%BB%99WordPress%E6%B7%BB%E5%8A%A0%E9%98%85%E8%AF%BB%E8%AE%A1%E6%95%B0/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/10/17/%E5%A6%82%E4%BD%95%E7%BB%99WordPress%E6%B7%BB%E5%8A%A0%E9%98%85%E8%AF%BB%E8%AE%A1%E6%95%B0/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>显示文章的阅读次数对 SEO 是有很大好处的,因为每次点击都会对文章进行一次小小的更新,我们可以用 WP-PostViews 这个插件来实现这个功能。</p>
<h2 id="安装插件"><a href="#安装插件" class="headerlink" title="安装插件"></a>安装插件</h2><p>在博客后台安装 WP-PostViews 插件。</p>
<h2 id="修改主题代码"><a href="#修改主题代码" class="headerlink" title="修改主题代码"></a>修改主题代码</h2><h3 id="方法一:简单的修改。"><a href="#方法一:简单的修改。" class="headerlink" title="方法一:简单的修改。"></a>方法一:简单的修改。</h3><ol>
<li>在外观 -> 主题编辑器 中,找到 <code>index.php</code></li>
<li>找到 <code><?php while (have_posts()) : the_post(); ?></code> 这行代码</li>
<li>在循环内添加代码 <code><?php if(function_exists('the_views')) { the_views(); } ?></code></li>
</ol>
<p>这样就可以在首页添加一个默认样式,简易的阅读计数。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/10/17/%E5%A6%82%E4%BD%95%E7%BB%99WordPress%E6%B7%BB%E5%8A%A0%E9%98%85%E8%AF%BB%E8%AE%A1%E6%95%B0/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/10/04/LeetCode25-N%E6%AC%A1%E5%B9%82/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/10/04/LeetCode25-N%E6%AC%A1%E5%B9%82/" class="post-title-link" itemprop="url">LeetCode25-N次幂</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-10-04 07:49:20 / Modified: 07:46:04" itemprop="dateCreated datePublished" datetime="2020-10-04T07:49:20+08:00">2020-10-04</time>
</span>
<span id="/2020/10/04/LeetCode25-N%E6%AC%A1%E5%B9%82/" class="post-meta-item leancloud_visitors" data-flag-title="LeetCode25-N次幂" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/10/04/LeetCode25-N%E6%AC%A1%E5%B9%82/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/10/04/LeetCode25-N%E6%AC%A1%E5%B9%82/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h2><p>实现 pow(x, n) ,即计算 x 的 n 次幂函数。</p>
<p>示例 1:</p>
<p>输入: 2.00000, 10<br>输出: 1024.00000<br>示例 2:</p>
<p>输入: 2.10000, 3<br>输出: 9.26100<br>示例 3:</p>
<p>输入: 2.00000, -2<br>输出: 0.25000<br>解释: 2-2 = 1/22 = 1/4 = 0.25<br>说明:</p>
<p>-100.0 < x < 100.0<br>n 是 32 位有符号整数,其数值范围是 [−231, 231 − 1] 。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/10/04/LeetCode25-N%E6%AC%A1%E5%B9%82/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/10/03/LeetCode235-236%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/10/03/LeetCode235-236%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88/" class="post-title-link" itemprop="url">LeetCode235&236-二叉树的最近公共祖先</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-10-03 19:46:04" itemprop="dateCreated datePublished" datetime="2020-10-03T19:46:04+08:00">2020-10-03</time>
</span>
<span id="/2020/10/03/LeetCode235-236%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88/" class="post-meta-item leancloud_visitors" data-flag-title="LeetCode235&236-二叉树的最近公共祖先" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/10/03/LeetCode235-236%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/10/03/LeetCode235-236%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="235-二叉搜索树的最近公共祖先"><a href="#235-二叉搜索树的最近公共祖先" class="headerlink" title="235.二叉搜索树的最近公共祖先"></a>235.二叉搜索树的最近公共祖先</h2><h3 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h3><p>给定一个二叉搜索树, 找到该树中两个指定节点的最近公共祖先。</p>
<p>百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。”</p>
<p>例如,给定如下二叉搜索树: root = [6,2,8,0,4,7,9,null,null,3,5]</p>
<p><img data-src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2018/12/15/binarytree.png" alt=""></p>
<p>示例 1:</p>
<p>输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8<br>输出: 6<br>解释: 节点 2 和节点 8 的最近公共祖先是 6。<br>示例 2:</p>
<p>输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4<br>输出: 2<br>解释: 节点 2 和节点 4 的最近公共祖先是 2, 因为根据定义最近公共祖先节点可以为节点本身。</p>
<p>说明:</p>
<p>所有节点的值都是唯一的。<br>p、q 为不同节点且均存在于给定的二叉搜索树中。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/10/03/LeetCode235-236%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="https://www.chaohang.top/2020/09/30/LeetCode98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="http://cdn.chaohang.top/20201106105644.jpg">
<meta itemprop="name" content="张小超">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="张小超的博客">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2020/09/30/LeetCode98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/" class="post-title-link" itemprop="url">LeetCode98-验证二叉搜索树</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2020-09-30 18:00:23" itemprop="dateCreated datePublished" datetime="2020-09-30T18:00:23+08:00">2020-09-30</time>
</span>
<span id="/2020/09/30/LeetCode98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/" class="post-meta-item leancloud_visitors" data-flag-title="LeetCode98-验证二叉搜索树" title="Views">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span class="leancloud-visitors-count"></span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Valine: </span>
<a title="valine" href="/2020/09/30/LeetCode98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="/2020/09/30/LeetCode98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h2><p>给定一个二叉树,判断其是否是一个有效的二叉搜索树。</p>
<p>假设一个二叉搜索树具有如下特征:</p>
<p>节点的左子树只包含小于当前节点的数。<br>节点的右子树只包含大于当前节点的数。<br>所有左子树和右子树自身必须也是二叉搜索树。<br>示例 1:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">输入:</span><br><span class="line"> 2</span><br><span class="line"> / \</span><br><span class="line"> 1 3</span><br><span class="line">输出: true</span><br></pre></td></tr></table></figure><br>示例 2:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">输入:</span><br><span class="line"> 5</span><br><span class="line"> / \</span><br><span class="line"> 1 4</span><br><span class="line"> / \</span><br><span class="line"> 3 6</span><br><span class="line">输出: false</span><br><span class="line">解释: 输入为: [5,1,4,null,null,3,6]。</span><br><span class="line"> 根节点的值为 5 ,但是其右子节点值为 4 。</span><br></pre></td></tr></table></figure></p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/09/30/LeetCode98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>