-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1122 lines (725 loc) · 77.4 KB
/
index.html
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 6.3.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="/lib/font-awesome/css/all.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"linyehui.me","root":"/","scheme":"Muse","version":"7.8.0","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":false,"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":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
</script>
<meta name="description" content="HABIT IS POWER">
<meta property="og:type" content="website">
<meta property="og:title" content="HABIT IS POWER">
<meta property="og:url" content="http://linyehui.me/index.html">
<meta property="og:site_name" content="HABIT IS POWER">
<meta property="og:description" content="HABIT IS POWER">
<meta property="og:locale">
<meta property="article:author" content="linyehui">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="http://linyehui.me/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome : true,
isPost : false,
lang : 'zh-Hans'
};
</script>
<title>HABIT IS POWER</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">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<h1 class="site-title">HABIT IS POWER</h1>
<span class="logo-line-after"><i></i></span>
</a>
<p class="site-subtitle" itemprop="description">习惯就是力量</p>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="main-menu menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>
</li>
</ul>
</nav>
</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 index posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2019/02/14/2019/2019-02-14-update-python-on-on-macos-x-mojave/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2019/02/14/2019/2019-02-14-update-python-on-on-macos-x-mojave/" class="post-title-link" itemprop="url">Mac OS X Mojave (10.14) 下更新python开发环境</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2019-02-14 00:00:00" itemprop="dateCreated datePublished" datetime="2019-02-14T00:00:00+08:00">2019-02-14</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="需求"><a href="#需求" class="headerlink" title="需求"></a>需求</h2><p>系统自带的python版本是2.7,之前用homebrew直接安装了一个python 3.6.5,不方便切换版本,想要清理下环境,使用pyenv来统一管理系统内的python版本</p>
<h2 id="清理老版本"><a href="#清理老版本" class="headerlink" title="清理老版本"></a>清理老版本</h2><h3 id="清理老的pip安装"><a href="#清理老的pip安装" class="headerlink" title="清理老的pip安装"></a>清理老的pip安装</h3><p>之前用sudu pip安装了不少package,太挫了,先把这部分清理一下</p>
<figure class="highlight bash"><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><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 确认下当前使用的文件</span></span><br><span class="line"><span class="built_in">which</span> pip</span><br><span class="line"><span class="built_in">which</span> python</span><br><span class="line"></span><br><span class="line"><span class="comment"># 删除pip</span></span><br><span class="line">sudu pip uninstall pip</span><br><span class="line"></span><br><span class="line"><span class="comment"># 卸载之前brew安装的python</span></span><br><span class="line">brew uninstall python –ignore-dependencies</span><br><span class="line"></span><br><span class="line">brew uninstall pyenv</span><br></pre></td></tr></table></figure>
<h3 id="检查是否清理干净"><a href="#检查是否清理干净" class="headerlink" title="检查是否清理干净"></a>检查是否清理干净</h3><p>下面这几个命令应该都找不到了</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">pyenv</span><br><span class="line">python</span><br><span class="line">pip</span><br></pre></td></tr></table></figure>
<h2 id="安装新版本"><a href="#安装新版本" class="headerlink" title="安装新版本"></a>安装新版本</h2><h3 id="最先需要安装的是pyenv"><a href="#最先需要安装的是pyenv" class="headerlink" title="最先需要安装的是pyenv"></a>最先需要安装的是pyenv</h3><figure class="highlight plaintext"><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><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">brew install pyenv</span><br><span class="line"></span><br><span class="line"># 打开.bash_profile</span><br><span class="line">vim ~/.bash_profile</span><br><span class="line"></span><br><span class="line"># 添加下面三行</span><br><span class="line"></span><br><span class="line"># pyenv</span><br><span class="line">export PYENV_ROOT=/usr/local/var/pyenv</span><br><span class="line">eval "$(pyenv init -)"</span><br><span class="line"></span><br><span class="line"># 重新加载下配置,查看当前的python版本,应该只有一个system版本</span><br><span class="line">source ~/.bash_profile</span><br><span class="line">pyenv versions</span><br></pre></td></tr></table></figure>
<h3 id="安装指定的python版本"><a href="#安装指定的python版本" class="headerlink" title="安装指定的python版本"></a>安装指定的python版本</h3><p>本来应该是一条命令搞定的事情,比如:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pyenv install 3.6.8</span><br></pre></td></tr></table></figure>
<p>结果遇到了问题:<a target="_blank" rel="noopener" href="https://github.com/pyenv/pyenv/issues/530">Install fails, “zlib not available” #530</a></p>
<p>简单来说,我确认了以下几个操作后最终可以了,我也不太确定是那个生效了:</p>
<figure class="highlight bash"><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><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 检查xcode编译工具</span></span><br><span class="line">xcode-select --install</span><br><span class="line"></span><br><span class="line"><span class="comment"># 检查几个安装,其实我之前都安装过了,提示是否需要reinstall,我没有重新安装</span></span><br><span class="line">brew install readline</span><br><span class="line"></span><br><span class="line"><span class="comment"># 修正zlib的inclue路径</span></span><br><span class="line"><span class="built_in">export</span> CFLAGS=<span class="string">"-I<span class="subst">$(xcrun --show-sdk-path)</span>/usr/include"</span></span><br><span class="line"><span class="built_in">export</span> CPPFLAGS=<span class="string">"-I/usr/local/opt/zlib/include"</span></span><br><span class="line">pyenv install 3.6.8</span><br></pre></td></tr></table></figure>
<p>安装成功后,把默认版本修改下</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">pyenv versions</span><br><span class="line">pyenv global 3.6.8</span><br></pre></td></tr></table></figure>
<p>检查下版本是否正常,正常的话就算完成了</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">python --version</span><br><span class="line">pip --version</span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2018/09/19/2018/2018-09-19-nvm-windows/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2018/09/19/2018/2018-09-19-nvm-windows/" class="post-title-link" itemprop="url">Windows下使用nvm管理node版本</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2018-09-19 00:00:00" itemprop="dateCreated datePublished" datetime="2018-09-19T00:00:00+08:00">2018-09-19</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="需求"><a href="#需求" class="headerlink" title="需求"></a>需求</h2><p>在Windows下像Mac和Linux那样使用NVM来管理node版本,使用npm</p>
<ul>
<li><p>原来的解决方案用的挺好的:<br><a target="_blank" rel="noopener" href="https://github.com/coreybutler/nvm-windows">https://github.com/coreybutler/nvm-windows</a></p>
</li>
<li><p>今天更新node版本遇到了问题:<br>之前安装的8.x的版本能正常使用,nvm install 10.10.0后发现node有但是npm文件没有下载下来</p>
</li>
</ul>
<p>nvm root看了下安装路径是在AppData下,虚拟链接是在%Program Files%目录下,nvm use的时候会弹出UAC提示,照理应该也不会出错,不过nvm的对应版本目录下并没有下载到npm文件。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>github上看了下,最近(2018-08-02)更新了一个版本1.1.7:<br><a target="_blank" rel="noopener" href="https://github.com/coreybutler/nvm-windows/releases">https://github.com/coreybutler/nvm-windows/releases</a></p>
<p>我把老的版本卸载干净,然后重新安装了下新版本,然后重新安装,重新安装的时候我把安装目录和软连接目录都放到的我的非系统盘D盘的根目录下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">D:\nodejs\</span><br><span class="line">D:\nvm\</span><br></pre></td></tr></table></figure>
<p>重新使用nvm安装下最新版本的node:</p>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line">nvm list available</span><br><span class="line">nvm install 10.10.0</span><br><span class="line">nvm use 10.10.0</span><br><span class="line"></span><br><span class="line">node --version</span><br><span class="line">npm --version</span><br></pre></td></tr></table></figure>
<p>验证了下版本,没问题:</p>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line">D:\>npm --version</span><br><span class="line">6.4.1</span><br><span class="line"></span><br><span class="line">D:\>node --version</span><br><span class="line">v10.10.0</span><br><span class="line"></span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2017/02/23/2017/2017-02-23-traffic-raiders-for-kansai-tourist/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2017/02/23/2017/2017-02-23-traffic-raiders-for-kansai-tourist/" 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="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2017-02-23 00:00:00" itemprop="dateCreated datePublished" datetime="2017-02-23T00:00:00+08:00">2017-02-23</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h2><p>2017年1月份,我和老婆带着未满3岁的儿子,从珠海出发,经由香港机场飞往日本大阪关西机场,并在大阪、京都、神户自由行了一个礼拜。</p>
<p>机票、酒店和游玩的行程安排都是老婆负责,而我负责的部分是游玩过程中的交通,结果只能算勉强及格,至少没走丢;这里我要分享的就是些关西旅行交通方面的经验教训。</p>
<h2 id="地图应用"><a href="#地图应用" class="headerlink" title="地图应用"></a>地图应用</h2><p>说交通怎么能不先说地图呢?我使用Google Map,需要提前买个日本3G上网卡;无论是地铁还是公交车,Google Map都能比较好的导航到搭车的地方,还有列车时刻表;你可以选择不同的地铁或公交线路;有个特别好的是,你在搭地铁的过程中,如果听不懂日语报站名,或者有些列车没有电子指示当前到哪一站了,这个时候你拿出手机看下Google Map,之前搜索的地铁路线包含了各个途径地铁站的名字和你当前的位置,非常实用。</p>
<h2 id="关西的铁路交通"><a href="#关西的铁路交通" class="headerlink" title="关西的铁路交通"></a>关西的铁路交通</h2><p>日本的铁路交通太发达了,所以铁路交通也是关西旅行交通的重头戏。</p>
<p>如果对日本的铁路交通完全没有概念的话,我建议先看下这个网站:<a target="_blank" rel="noopener" href="https://www.westjr.co.jp/global/sc/">西日本旅客铁道株式会社</a>,这是JR-West的官方网站,有中文版;我是回国之后整理攻略才知道的这个网站,后悔莫及,网上各种攻略很多,但都没这个全面实用,走了不少弯路。</p>
<p>JR只是日本众多铁路公司中的一个,不过乘车的规则什么的基本都是类似的,所以你看了JR的乘车指南,再搭乘其他公司的铁路交通,会比较轻车熟路。</p>
<h3 id="列车种类"><a href="#列车种类" class="headerlink" title="列车种类"></a>列车种类</h3><p>官方分类看这里:<a target="_blank" rel="noopener" href="https://www.westjr.co.jp/global/sc/howto/train_01.html#fqtop">列车种类</a></p>
<p>高铁(新幹線)、特快(特急列車)、快速(急行列車)、管内快速(新快速)、普快(快速)、普客(普通列車)</p>
<p>这么多分类,我自己搭乘后的经验是,其实就分三类就够了:<br>新干线、急行、普通。</p>
<p>不同类型的列车,除了车票价格的区别,买票方式上也有区别:<br>新干线需要单独买票,不能刷卡;<br>急行和普通的可以先刷IC卡进站,想要快的话,看到急行车上车后再补票,只是不一定能补到指定席。</p>
<h3 id="车票分类"><a href="#车票分类" class="headerlink" title="车票分类"></a>车票分类</h3><p>关键字:乘车券、自由席、指定席、急行券、新干线</p>
<p>在日本搭乘铁路交通,你至少需要“乘车券”;<br>在购票时你可以选择是自由席还是指定席;<br>而如果你想要搭乘急行或快速的列车,你还需要购买“急行券”;</p>
<p>上述几个选项是可以组合的,最便宜的是自由席乘车券,最贵的是指定席急行券;<br>需要注意的是并不是每个路线都有急行列车,需要提前查好车次;<br>还有就是日本的快车和慢车都是在同一个乘车站台,做错慢车的话很有可能早上车却更晚到达目的地。</p>
<p>还是没看明白的,可以看下JR-West的相关说明:<a target="_blank" rel="noopener" href="https://www.westjr.co.jp/global/sc/howto/ticket_02.html#fq07">搭乘JR-West的方法 购买车票</a></p>
<h3 id="交通IC卡"><a href="#交通IC卡" class="headerlink" title="交通IC卡"></a>交通IC卡</h3><p>各种日本旅行攻略里经常提到的交通IC卡主要是Suica和ICOCA,这两种卡目前都已经是日本全国通用了。</p>
<p>两个单词的读音可以提前学习下,因为这个卡的使用频率非常高:</p>
<blockquote>
<p>Suica(スイカ),读音类似:[su i ga]<br>ICOCA(イコカ),读音类似:[i ko ga]</p>
</blockquote>
<p>我用的是ICOCA,关西机场自动售卖机上能买到的也就是这个了,除了新干线需要单独购买乘车券,其他铁路只要不是指定席或者急行券,都可以直接刷卡上车,不用单独买票;另外市内公交车和便利店也能刷ICOCA。</p>
<h3 id="ICOCA-amp-HARUKA"><a href="#ICOCA-amp-HARUKA" class="headerlink" title="ICOCA & HARUKA"></a>ICOCA & HARUKA</h3><p>因为我们的到达机场是关西机场,第一站去的是京都,这里说下从关西机场到京都最快最划算的方式:ICOCA & HARUKA</p>
<p>官方介绍看这里:<a target="_blank" rel="noopener" href="https://www.westjr.co.jp/global/sc/ticket/icoca-haruka/">ICOCA & HARUKA</a></p>
<p>这个有多快捷呢?<br>从关西机场到京都站,这是最快的方式,没有之一。</p>
<p>这个有多划算呢?<br>从关西机场搭大巴车到京都应该是要1800日元,而这个ICOCA & HARUKA折扣券是1600日元。</p>
<p>又快又便宜,哪来这么好的事情;<br>原因在于他是和ICOCA卡捆绑销售的;<br>ICOCA本身第一次购买的话是需要2000日元,其中包含500日元押金;<br>虽然是捆绑销售,但是我上面提到了ICOCA和Suica已经全日本通用,而且便利店买东西也能用,其实2000日元很快就花完了的,万一万一花不完还可以退卡(虽然我不推荐退卡)。</p>
<p>特别要注意的是购买方法:只能在JR的绿色办公室里面购买!<br>关西机场的JR绿色办公室就在JR地铁入口的对面,在一排自动售卖机的右手边,进去找人买就对了,在自动售卖机上是买不到的(T_T)。</p>
<h3 id="儿童乘车"><a href="#儿童乘车" class="headerlink" title="儿童乘车"></a>儿童乘车</h3><p>12岁以上算大人、6岁至11岁算儿童、1岁至5岁算幼儿、未满1岁算婴儿;<br>每名大人最多可免费携带2名幼儿同行;<br>简单说就是5岁以下的小朋友,大人带着不要钱,不用买票。</p>
<p>这里再说下新干线买票的事情,因为我们当时带着小孩,没有买指定席,结果上车后带着小孩和行李换了好几次位置,乘务员说没办法补指定席的票,很麻烦,所以带小孩坐新干线的话最好直接买指定席。</p>
<h2 id="公交车"><a href="#公交车" class="headerlink" title="公交车"></a>公交车</h2><p>我们只在京都坐了公交车,京都的东西南北分布着各种寺庙,但并不是每个寺庙都有地铁直达,这时候就需要市内公交发挥作用了。</p>
<p>提前用Google Map查好公交转乘的路线,还是挺方便的。</p>
<p>Google Map的路线是没问题的,但公交车站台位置不是很准,如果你到了一个站台发现没有Google Map提示的那个公交线路站牌,比如说你要坐25路,结果站牌上怎么都找不到25路的站牌,那肯定是你走错公交站了,再找找看吧。</p>
<p>坐公交车还需要注意的是,如果你下一站下车,到站之前记得按下车上随处可见的红色按钮(不骗你,真的是随处可见)。</p>
<h2 id="的士"><a href="#的士" class="headerlink" title="的士"></a>的士</h2><p>都说日本打车贵,一开始都不太敢尝试,但是行李太多了,我们从酒店去京都站搭新干线的时候,还是打了个的士:</p>
<blockquote>
<p>3.2KM,1100日元,折合人民币60多块钱</p>
</blockquote>
<p>跟国内比肯定是贵很多,但是你要知道日本的地铁也不便宜;<br>我们还要拿着两件大行李,一个婴儿车,这么算的话价格还是可以接受的。</p>
<p>的士作为一种交通途径,在合适的时候还是可以选用的,并不是天价。</p>
<h2 id="长途大巴"><a href="#长途大巴" class="headerlink" title="长途大巴"></a>长途大巴</h2><p>我们从神户有马温泉去大阪的时候搭乘的是大巴车,车上10个人不到;<br>想不到的是大巴车上竟然没什么味道,更没有国内大巴车上那种无法描述的奇怪的大巴车味道……</p>
<p>大巴车快到大阪的时候,最左边的车道堵车堵了大概有10公里,但是右边的两个车道都还在正常快速行驶;中间好几次我都在想为什么右边这么快,没有人变道?后面才知道这10多公里的车都在排队下高速,高速出口有点堵车,但是只堵了最左边的一条道而已,佩服。</p>
<h2 id="交通IC卡充值"><a href="#交通IC卡充值" class="headerlink" title="交通IC卡充值"></a>交通IC卡充值</h2><p>地铁站买票的自动售卖机可以充值;<br>地铁站里面有精算机可以充值;<br>便利店可以充值。</p>
<h2 id="关于问路"><a href="#关于问路" class="headerlink" title="关于问路"></a>关于问路</h2><p>日本人英语听力都还不错,只是不太愿意说,你要是英文好的话直接英文问路完全没问题。</p>
<p>我的做法是,用有道翻译,把问路的关键字翻译成日语;注意是只是关键字而已,不要整个句子,因为我的实践结果告诉我,翻译句子比较坑;把关键字的日文给日本人看下,他们基本能猜猜八九不离十;实在不行再配合两句蹩脚的英语,嗯,应该可以了…… </p>
<p>还不行的话你就比划比划或者试下眼神交流吧</p>
<h2 id="对这次旅行交通的整体感受"><a href="#对这次旅行交通的整体感受" class="headerlink" title="对这次旅行交通的整体感受"></a>对这次旅行交通的整体感受</h2><p>准时,方便,不需要像国内那样预留太多的时间。</p>
<p>费用方面,这次旅行在关西交通上的花费,只是旅行费用中比较小的一部分;<br>我们也没有使用更划算的周游券,主要是因为我们带着小孩,行程本来就不固定,而且我们是三个城市走马观花式的自由行,不太适合;</p>
<p>只要行程确认,交通攻略上一个Google Map也就够了,还都是中文界面;<br>日本的交通很发达但也很规范,熟悉了规则之后会发现,日本的交通出行其实比你在国内一个陌生城市还要简单。</p>
<p>== The End ==</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2017/02/17/2017/2017-02-17-proxychain4-pod-update-failed/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2017/02/17/2017/2017-02-17-proxychain4-pod-update-failed/" class="post-title-link" itemprop="url">升级到Sierra后proxychains4 pod update失败</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2017-02-17 00:00:00" itemprop="dateCreated datePublished" datetime="2017-02-17T00:00:00+08:00">2017-02-17</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>我的问题是proxychains4 telnet 是没问题的,但是proxychains4 pod update就会报下面这样的警告,然后失败:</p>
<blockquote>
<p>[proxychains] preloading ./libproxychains4.dylib<br>dyld: warning: could not load inserted library ‘./libproxychains4.dylib’ into library validated process because no suitable image found. Did find:<br>./libproxychains4.dylib: code signing blocked mmap() of ‘./libproxychains4.dylib’</p>
</blockquote>
<h3 id="我的环境如下:"><a href="#我的环境如下:" class="headerlink" title="我的环境如下:"></a>我的环境如下:</h3><ul>
<li>macOS Sierra 10.12.3</li>
<li>proxychains-ng 4.12_1</li>
<li>SIP之前配置过用的是:csrutil enable –without debug,查询的状态如下:<figure class="highlight bash"><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><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">$ csrutil status</span><br><span class="line">System Integrity Protection status: enabled (Custom Configuration).</span><br><span class="line"></span><br><span class="line">Configuration:</span><br><span class="line"> Apple Internal: disabled</span><br><span class="line"> Kext Signing: enabled</span><br><span class="line"> Filesystem Protections: enabled</span><br><span class="line"> Debugging Restrictions: disabled</span><br><span class="line"> DTrace Restrictions: enabled</span><br><span class="line"> NVRAM Protections: enabled</span><br><span class="line"> BaseSystem Verification: enabled</span><br><span class="line"></span><br><span class="line">This is an unsupported configuration, likely to <span class="built_in">break</span> <span class="keyword">in</span> the future and leave your machine <span class="keyword">in</span> an unknown state.</span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="寻找原因"><a href="#寻找原因" class="headerlink" title="寻找原因"></a>寻找原因</h2><p>一开始是找到了这篇issues:<a target="_blank" rel="noopener" href="https://github.com/rofl0r/proxychains-ng/issues/109">Proxychains4 with brew for MacOs error #109</a>,以为是我的proxychains4版本问题或者是我的SIP问题,所以做了以下尝试:</p>
<figure class="highlight plaintext"><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><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"># 进入系统的recovery mode,禁用SIP</span><br><span class="line">csrutil disable</span><br><span class="line">reboot</span><br><span class="line"></span><br><span class="line"># 重启后卸载老的proxychains</span><br><span class="line">brew tap beeftornado/rmtree</span><br><span class="line">brew rmtree proxychains-ng</span><br><span class="line"></span><br><span class="line"># 重新安装</span><br><span class="line">proxychains-ng --universal</span><br><span class="line"></span><br><span class="line"># 确认下proxychains-ng的配置是否正确,如果不正确就再配置下proxychains.conf</span><br><span class="line"># 确认下telnet是否正常</span><br><span class="line">proxychains4 telnet google.com 80</span><br><span class="line"></span><br><span class="line"># 再尝试下pod update</span><br><span class="line">proxychains4 pod update</span><br><span class="line"></span><br><span class="line"># 问题依旧:code signing blocked mmap()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="问题所在"><a href="#问题所在" class="headerlink" title="问题所在"></a>问题所在</h2><p>在另外一个issue78:<a target="_blank" rel="noopener" href="https://github.com/rofl0r/proxychains-ng/issues/78">Not working on OS X 10.11 due to SIP #78</a>中看到了被点赞了4次的这个回答,让我最后解决了问题:</p>
<blockquote>
<p>It only happens if you execute a system binary using proxychains, e.g. proxychains4 ssh user@server. For now, a workaround is to copy the executable to another location (e.g. cp /usr/bin/ssh ~/XXX), and use it (e.g. proxychains4 ~/XXX/ssh user@server). You can modify the path variable so that ~/XXX/ssh is executed instead of /usr/bin/ssh, when you just type “ssh”.</p>
</blockquote>
<h3 id="一句话描述问题:"><a href="#一句话描述问题:" class="headerlink" title="一句话描述问题:"></a>一句话描述问题:</h3><blockquote>
<p>proxychain尝试注入系统bin目录下的二进制文件会出现这种情况,解决方案就是换个非系统目录的文件来执行和注入就可以了。</p>
</blockquote>
<h3 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h3><p>根据上面的问题描述,再考虑pod update的实际操作,其实就是调用git去更新,而我的git用的是系统自带的:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ which git</span><br><span class="line">/usr/bin/git</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>这样一来问题就变成了让pod update使用我自己安装的git就可以了:</p>
<figure class="highlight plaintext"><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">brew install git</span><br><span class="line"></span><br><span class="line"># 修改.bash_profile,增加下面的export配置,优先搜索/usr/local/bin目录</span><br><span class="line"># 这样修改后,terminal下使用git就会优先使用我们刚刚安装的git版本了</span><br><span class="line">export PATH=/usr/local/bin:/usr/local/sbin:${PATH}</span><br></pre></td></tr></table></figure>
<p>好了,配置好了,再试一下,成功了:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">proxychains4 pod update</span><br></pre></td></tr></table></figure>
<h3 id="关于SIP"><a href="#关于SIP" class="headerlink" title="关于SIP"></a>关于SIP</h3><p>最后我验证了下,SIP其实不需要disable,csrutil enable –without debug下proxychains也是能正常工作的</p>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>说下我这里能够正常运行的环境和因素:</p>
<ul>
<li>macOS Sierra 10.12.3</li>
<li>proxychains-ng 4.12_1</li>
<li>进入系统的recovery mode,打开terminal,csrutil enable –without debug<br>可以使用这个命令查询的状态,我的状态如下:<figure class="highlight bash"><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><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">$ csrutil status</span><br><span class="line">System Integrity Protection status: enabled (Custom Configuration).</span><br><span class="line"></span><br><span class="line">Configuration:</span><br><span class="line"> Apple Internal: disabled</span><br><span class="line"> Kext Signing: enabled</span><br><span class="line"> Filesystem Protections: enabled</span><br><span class="line"> Debugging Restrictions: disabled</span><br><span class="line"> DTrace Restrictions: enabled</span><br><span class="line"> NVRAM Protections: enabled</span><br><span class="line"> BaseSystem Verification: enabled</span><br><span class="line"></span><br><span class="line">This is an unsupported configuration, likely to <span class="built_in">break</span> <span class="keyword">in</span> the future and leave your machine <span class="keyword">in</span> an unknown state.</span><br></pre></td></tr></table></figure></li>
<li>我的git使用的是brew install git的版本:<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ which git</span><br><span class="line">/usr/local/bin/git</span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="参考材料"><a href="#参考材料" class="headerlink" title="参考材料"></a>参考材料</h2><p><a target="_blank" rel="noopener" href="https://github.com/rofl0r/proxychains-ng/issues/78">Not working on OS X 10.11 due to SIP #78</a><br><a target="_blank" rel="noopener" href="https://github.com/rofl0r/proxychains-ng/issues/109">Proxychains4 with brew for MacOs error #109</a><br><a target="_blank" rel="noopener" href="https://github.com/rofl0r/proxychains-ng/issues/159">code signing blocked mmap() #159</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2017/02/08/2017/2017-02-08-ignore-sigpipe-crash/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2017/02/08/2017/2017-02-08-ignore-sigpipe-crash/" class="post-title-link" itemprop="url">ignore SIGPIPE crash</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2017-02-08 00:00:00" itemprop="dateCreated datePublished" datetime="2017-02-08T00:00:00+08:00">2017-02-08</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>由于使用了Multipeer Connectivity和NSOutputStream,在某些网络环境切换的情况下,总是会遇到这样的crash:</p>
<blockquote>
<p>Signal 13 was raised. SIGPIPE</p>
</blockquote>
<p>查找资料后,发现最简单的解决方案就是忽略这个错误:</p>
<blockquote>
<p>signal(SIGPIPE, SIG_IGN);</p>
</blockquote>
<p>但实际的结果是我们设置了还是会继续出现闪退</p>
<h2 id="原因"><a href="#原因" class="headerlink" title="原因"></a>原因</h2><p>排查了很久后才发现,问题的原因是BugTags也会控制这个开头,默认是不忽略,而且这个默认显然代码是主动调用了,而不是我们期望的不调用就不设置:</p>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 是否忽略 PIPE Signal (SIGPIPE) 闪退,默认 NO</span><br><span class="line"> */</span><br><span class="line">@property(nonatomic, assign) BOOL ignorePIPESignalCrash;</span><br></pre></td></tr></table></figure>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>设置BugTags的对应开关即可:</p>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line">// Bugtags</span><br><span class="line">BugtagsOptions *options = [[BugtagsOptions alloc] init];</span><br><span class="line">options.ignorePIPESignalCrash = YES;</span><br><span class="line">[Bugtags startWithAppKey:BugTagsAPPKEY invocationEvent:BTGInvocationEventNone options:options];</span><br></pre></td></tr></table></figure>
<h2 id="思考"><a href="#思考" class="headerlink" title="思考"></a>思考</h2><p>这个问题我们排查了很久,一直在找我们自己的原因,但其实这种bug因为跟网络环境有关系不容易重现;<br>其实反思后发现,排查这个问题我们应该先做一个事情,就是手动出发SIGNAL 13,看闪退是否被正确忽略;<br>而我们恰恰没做这个事情,思路上的疏漏导致了之前的大量工作变成了无用功。</p>
<h2 id="参考材料"><a href="#参考材料" class="headerlink" title="参考材料"></a>参考材料</h2><p><a target="_blank" rel="noopener" href="http://www.jianshu.com/p/1957d2b18d2c">如何在 iOS 上避免 SIGPIPE 信号导致的 crash (Avoiding SIGPIPE signal crash in iOS)</a><br><a target="_blank" rel="noopener" href="https://developer.apple.com/reference/foundation/nsstream/1410399-close?language=objc">NSStream close</a><br><a target="_blank" rel="noopener" href="https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Streams/Articles/WritingOutputStreams.html">Writing OutputStreams</a><br><a target="_blank" rel="noopener" href="http://www.cnblogs.com/kesalin/archive/2013/04/29/ios_network_nsstream.html">[深入浅出Cocoa]iOS网络编程之NSStream</a><br><a target="_blank" rel="noopener" href="http://iphonedevsdk.com/forum/iphone-sdk-development/21065-how-to-make-a-nsstream-instance-reusable.html">How to make a NSStream instance reusable?</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2017/01/06/2017/2017-01-06-setstatusbarorientation-not-working/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2017/01/06/2017/2017-01-06-setstatusbarorientation-not-working/" class="post-title-link" itemprop="url">setStatusBarOrientation:animated: not working</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2017-01-06 00:00:00" itemprop="dateCreated datePublished" datetime="2017-01-06T00:00:00+08:00">2017-01-06</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>有个视频播放页面需要手动控制页面的横竖屏状态,使用setStatusBarOrientation可以达到这个效果;<br>但是很奇怪的事情发生了,我们发现代码在某台机器的某种情况下会出现setStatusBarOrientation调用无效。</p>
<h2 id="原因"><a href="#原因" class="headerlink" title="原因"></a>原因</h2><p>直接的原因是我们使用了BugTags,并且在白名单用户登录后打开了BugTags的悬浮小球,悬浮小球出现的时候setStatusBarOrientation调用就会无效;</p>
<p>分析后发现真正的原因是,页面已经不是the top-most full-screen view controller了:</p>
<blockquote>
<p>The setStatusBarOrientation:animated: method is not deprecated outright. It now works only if the supportedInterfaceOrientations method of the top-most full-screen view controller returns 0</p>
</blockquote>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>知道原因就简单了,需要全屏的时候隐藏BugTags的悬浮球即可</p>
<blockquote>
<p>BTGInvocationEventNone</p>
</blockquote>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><p><a target="_blank" rel="noopener" href="http://stackoverflow.com/questions/12563954/setstatusbarorientationanimated-not-working-in-ios-6">setStatusBarOrientation:animated: not working in iOS 6</a><br><a target="_blank" rel="noopener" href="http://blog.csdn.net/ginhoor/article/details/20454229">setStatusBarOrientation 未生效的解决办法</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2016/12/08/2016/2016-12-08-migrate-jekyll-to-hexo/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2016/12/08/2016/2016-12-08-migrate-jekyll-to-hexo/" class="post-title-link" itemprop="url">把GitHub Pages上的博客从Jekyll迁移到Hexo</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2016-12-08 17:21:02" itemprop="dateCreated datePublished" datetime="2016-12-08T17:21:02+08:00">2016-12-08</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>之前用的Jekyll,最大的痛点是对Markdown的代码格式支持的不是很好,尝试过一些方法,不过都不太理想;<br>最近偶然看到Hexo的介绍,决定尝试一下;<br>迁移过程中有些小Tips觉得有必要小结下,对于迁移的人来说还是很有用的。</p>
<ul>
<li>迁移结果:<br>最终效果:<a href="http://linyehui.me/">http://linyehui.me</a><br>Hexo生成的代码:<a target="_blank" rel="noopener" href="https://github.com/linyehui/linyehui.github.io">https://github.com/linyehui/linyehui.github.io</a><br>Blog源代码:<a target="_blank" rel="noopener" href="https://github.com/linyehui/linyehui-hexo-blog">https://github.com/linyehui/linyehui-hexo-blog</a></li>
</ul>
<h2 id="迁移步骤"><a href="#迁移步骤" class="headerlink" title="迁移步骤"></a>迁移步骤</h2><ul>
<li><p>我的系统是Mac OS 10.12.1</p>
</li>
<li><p>我原来的Jekylly代码在这个仓库下:<a target="_blank" rel="noopener" href="https://github.com/linyehui/linyehui.github.io">https://github.com/linyehui/linyehui.github.io</a></p>
</li>
<li><p>代码备份</p>
<ul>
<li>从master建立分支用于代码备份(多留个心眼,后面发现很有用),备份用的分支:<a target="_blank" rel="noopener" href="https://github.com/linyehui/linyehui.github.io/tree/release-jekyll">release-jekyll</a></li>
<li>保险起见,我把本地的github 仓库也备份了下</li>
</ul>
</li>
<li><p>创建一个新的github仓库用于存储我的hexo blog代码:<a target="_blank" rel="noopener" href="https://github.com/linyehui/linyehui-hexo-blog">linyehui-hexo-blog</a>,git clone到本地,得到hexo的本地根目录:linyehui-hexo-blog</p>
</li>
<li><p>初始化hexo本地环境</p>
<figure class="highlight shell"><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><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/linyehui/linyehui-hexo-blog</span><br><span class="line">cd linyehui-hexo-blog</span><br><span class="line">npm install -g hexo-cli</span><br><span class="line"></span><br><span class="line">hexo init</span><br><span class="line"></span><br><span class="line">npm install hexo --save</span><br><span class="line">npm install hexo-generator-index --save</span><br><span class="line">npm install hexo-generator-archive --save</span><br><span class="line">npm install hexo-generator-category --save</span><br><span class="line">npm install hexo-generator-tag --save</span><br><span class="line">npm install hexo-server --save</span><br><span class="line">npm install hexo-deployer-git --save</span><br><span class="line">npm install hexo-deployer-heroku --save</span><br><span class="line">npm install hexo-deployer-rsync --save</span><br><span class="line">npm install hexo-deployer-openshift --save</span><br><span class="line">npm install hexo-renderer-marked@0.2 --save</span><br><span class="line">npm install hexo-renderer-stylus@0.2 --save</span><br><span class="line">npm install hexo-generator-feed@1 --save</span><br><span class="line">npm install hexo-generator-sitemap@1 --save</span><br></pre></td></tr></table></figure>
<p> 这一步完成的时候,你就可以在根目录下执行hexo server,并且可以在浏览器上看到Hello World页面了</p>
</li>
<li><p>配置下_config.yml,这里就是各种名字的配置,配置完了之后,浏览器预览没问题就行了</p>
</li>
<li><p>配置theme,我用的是iissnan/hexo-theme-next</p>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line"># git clone到另外一个目录,然后复制到./linyehui-hexo-blog/themes/next目录下</span><br><span class="line">git clone https://github.com/iissnan/hexo-theme-next</span><br><span class="line"></span><br><span class="line"># 复制hexo-theme-next目录到./linyehui-hexo-blog/themes/next</span><br><span class="line"></span><br><span class="line"># 修改_config.yml中的这行文件,主题名字和目录名一致</span><br><span class="line">theme: next</span><br></pre></td></tr></table></figure>
<p> 根据自己的需要修改下主题的配置:./linyehui-hexo-blog/themes/next/_cofig.yml</p>
</li>
<li><p>迁移之前博客的文章</p>
<ul>
<li>把Jekyll版本的_posts目录下的文件复制到./linyehui-hexo-blog/source/_posts/</li>
<li>把之前根目录下的媒体文件目录:media(图片)复制到./linyehui-hexo-blog/source/media</li>
</ul>
<p> 浏览器中预览下,首页应该能看到你的文章了,数据迁移非常简单,就这一步</p>
</li>
<li><p>创建tags文件</p>
<figure class="highlight plaintext"><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">$ cd linyehui-hexo-blog</span><br><span class="line">$ hexo new page tags</span><br><span class="line"></span><br><span class="line"># 文件内容如下:</span><br><span class="line">title: 标签</span><br><span class="line">date: 2016-12-08 12:36:06</span><br><span class="line">type: "tags"</span><br><span class="line">comments: false</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
</li>
<li><p>上面都没问题,就可以发布了</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">## 发布前记得generate,保险起见带上--generate参数</span><br><span class="line">hexo deploy --generate</span><br></pre></td></tr></table></figure>
<p> 每次发布,你都会发现你的github仓库的master分支只有两次commit,也就是说hexo deploy把老的master分支给删除了……</p>
</li>
<li><p>发布没问题,我就把新的代码仓库下的文件给入库了,记得配置下.gitignore</p>
<figure class="highlight plaintext"><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">.DS_Store</span><br><span class="line">.deploy_git</span><br><span class="line">db.json</span><br><span class="line">node_modules</span><br><span class="line">public</span><br></pre></td></tr></table></figure>
</li>
<li><p>到这一步blog的主体功能已经迁移完成,剩下的就是些美化、图标、头像,这里就不细说了</p>
</li>
</ul>
<h2 id="迁移Tips"><a href="#迁移Tips" class="headerlink" title="迁移Tips"></a>迁移Tips</h2><ul>
<li>hexo deploy 每次会将master分支删除后重新创建,迁移之前的代码切记要建立分支进行备份</li>
<li>hexo deploy 所做的事情:删除现有的master分支,并建立新的master分支,把hexo目录下的.deploy_git目录push到master分支上</li>
<li>source/_posts目录支持按年份划分目录,_config.yml中这么配置就行了:<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">new_post_name:</span> <span class="string">:year/:year-:month-:day-:title.md</span> <span class="comment"># File name of new posts</span></span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h2><p><a target="_blank" rel="noopener" href="http://www.ezlippi.com/blog/2016/02/jekyll-to-hexo.html">Jekyll迁移到Hexo搭建个人博客</a><br><a target="_blank" rel="noopener" href="http://www.wukai.me/2016/01/13/blog-jekyll-to-hexo/">将博客从Jekyll迁移至Hexo</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2016/12/06/2016/2016-12-06-memory-leak-from-nsarray-sortedarrayusingfunction/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2016/12/06/2016/2016-12-06-memory-leak-from-nsarray-sortedarrayusingfunction/" class="post-title-link" itemprop="url">NSArray sortedArrayUsingFunction引发的内存泄漏</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2016-12-06 00:00:00" itemprop="dateCreated datePublished" datetime="2016-12-06T00:00:00+08:00">2016-12-06</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="问题描述"><a href="#问题描述" class="headerlink" title="问题描述"></a>问题描述</h2><p>对一个NSMutableArray进行排序,却造成了内存泄漏……</p>
<h3 id="代码说明:"><a href="#代码说明:" class="headerlink" title="代码说明:"></a>代码说明:</h3><p>在多线程的流程中,存在一个NSMutableArray *sortList;</p>
<p>对sortList进行排序,一开始用的方法是这样的,有内存泄漏:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">NSArray *sortedSendQuery = [self.sortList sortedArrayUsingFunction:frameDataCompare context:NULL];</span><br><span class="line">[self.sortList removeAllObjects];</span><br><span class="line">[self.sortList addObjectsFromArray:sortedSendQuery];</span><br></pre></td></tr></table></figure>
<p>修正后的代码只有一行,没有内存泄漏:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[self.sortList sortUsingFunction:frameDataCompare context:nil];</span><br></pre></td></tr></table></figure>
<h2 id="原因分析"><a href="#原因分析" class="headerlink" title="原因分析"></a>原因分析</h2><p>NSArray的排序方法是:sortedArrayUsingFunction<br>NSMutableArray的排序方法是:sortUsingFunction<br>self.sortList是一个NSMutableArray,直接使用NSMutableArray的排序方法sortUsingFunction不需要进行内存复制,可以提高性能;</p>
<p>除了性能问题,由于在多线程中使用,而且如果NSMutableArray中的object内存分配来自于其他线程的,那么不必要的内存复制会导致内存泄漏,出现的内存泄漏问题类似于:<br><a target="_blank" rel="noopener" href="http://stackoverflow.com/questions/5200857/memory-leaks-from-multidimensional-array-nsmutablearray-nsarray-addobject-and">Memory leaks from Multidimensional array: NSMutableArray, NSArray, addObject and insertObjectAtIndex</a></p>
<h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><p>对于NSMutable的使用,要留意调用正确的方法,能不做类型转换就不做</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2016/12/01/2016/2016-12-01-fix-memory-problem-with-allocation/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2016/12/01/2016/2016-12-01-fix-memory-problem-with-allocation/" class="post-title-link" itemprop="url">使用Instruments Allocations排查内存释放不及时的问题</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2016-12-01 00:00:00" itemprop="dateCreated datePublished" datetime="2016-12-01T00:00:00+08:00">2016-12-01</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="问题描述"><a href="#问题描述" class="headerlink" title="问题描述"></a>问题描述</h2><p>使用ARC的过程中,由于循环引用或者其他使用不当,会造成对象的内存没有及时释放,而这些内存在页面关闭的时候又会随着页面的生命周期一起释放,这就给我们排查“内存泄漏”带来了麻烦;</p>
<p>这种内存问题用Leaks是找不出问题的,因为这些内存其实只是释放不及时,而不是没有释放。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>使用Instruments Allocations的Mark Generation功能能帮助我们排查出这种问题。</p>
<h3 id="使用之前先说几个Instruments的调试技巧"><a href="#使用之前先说几个Instruments的调试技巧" class="headerlink" title="使用之前先说几个Instruments的调试技巧"></a>使用之前先说几个Instruments的调试技巧</h3><p>1、调试内存可以用Debug模式来调试,但是记得在工程设置中把Debug模式的Debug Information Format设置成:DWARF with dSYM File,否则无法在Instruments中看到出问题的符号对应的代码</p>
<p>2、性能调试真机调试的时候有时候连接不上,试试重启手机,实在还是不行,可以换成Debug模式,相对没那么容易连接不上手机(修改方法:Edit Scheme->Profile->Build Configuration 修改成Debug)</p>
<h3 id="一个典型案例,问题描述"><a href="#一个典型案例,问题描述" class="headerlink" title="一个典型案例,问题描述"></a>一个典型案例,问题描述</h3><p>假定我们有一个页面MainViewController,打开这个页面后会开始进行视频直播,在直播的过程中会出现内存没有及时释放,比如10分钟后应用的内存占用已经达到了200MB,但是页面一关闭内存有都正确释放了。</p>
<p>针对这样的一个问题我们应该怎么来排查呢?</p>
<h3 id="排查步骤"><a href="#排查步骤" class="headerlink" title="排查步骤"></a>排查步骤</h3><p>1、Xcode中启动Profile工具<br><img src="/media/files/2016/12/01/01.png" alt="image"></p>
<p>2、选择Allocations工具,点击红色按钮开始“录制”,这时Instruments会启动我们的应用<br><img src="/media/files/2016/12/01/02.png" alt="image"></p>
<p>3、打开有内存释放问题的页面,稍微等一下,等页面的常规初始化完成,比如等个10秒钟</p>
<p>4、从Instruments右下角的区域切换到“Display Settings” Tab页,并点击“Mark Generation”生成第一个Generation:Generation A;<br>这个相当于是我们判断内存没有及时释放的起始点<br><img src="/media/files/2016/12/01/04.png" alt="image"></p>
<p>5、为了让没有及时释放的内存泄漏问题,累积的更多一点,第二次Mark的时间可以稍微多等久一点(等多久这个取决于你的内存问题出现所需要的时间,比如2分钟),然后再次点击“Mark Generation”,这个时候你就会发现两次Generation之间的内存增长,而这里面的增长其实就是我们所寻找的没有及时释放的内存:</p>
<p><img src="/media/files/2016/12/01/05.png" alt="image"></p>
<p>6、点击小箭头查看更详细的信息,根据内存占用的比例,找到占用比例最高的,并且不断展开,直到找到我们自己的代码,这就是出问题的地方了。<br><img src="/media/files/2016/12/01/06.png" alt="image"></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
<link itemprop="mainEntityOfPage" href="http://linyehui.me/2016/11/15/2016/2016-11-15-installtaponbus-buffersize-not-taking-effect/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="linyehui">
<meta itemprop="description" content="HABIT IS POWER">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="HABIT IS POWER">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2016/11/15/2016/2016-11-15-installtaponbus-buffersize-not-taking-effect/" class="post-title-link" itemprop="url">使用AudioEngine时installTapOnBus的bufferSize设置无效</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2016-11-15 00:00:00" itemprop="dateCreated datePublished" datetime="2016-11-15T00:00:00+08:00">2016-11-15</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="需求"><a href="#需求" class="headerlink" title="需求"></a>需求</h2><p>1、使用AudioEngine进行音频采集,并加入部分EQ等效果器</p>
<p>2、将混音后的音频输出为PCM的Buffer</p>
<p>3、将PCM Buffer编码为AAC</p>
<h2 id="遇到的坑"><a href="#遇到的坑" class="headerlink" title="遇到的坑"></a>遇到的坑</h2><p>AudioEngine的这个方法有Bug: <a target="_blank" rel="noopener" href="https://developer.apple.com/reference/avfoundation/avaudionode/1387122-installtaponbus">installTapOnBus</a></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">- (void)installTapOnBus:(AVAudioNodeBus)bus bufferSize:(AVAudioFrameCount)bufferSize format:(AVAudioFormat * __nullable)format block:(AVAudioNodeTapBlock)tapBlock;</span><br></pre></td></tr></table></figure>
<p>iOS 10一下的版本,installTapOnBus的第二个参数bufferSize设置是无效的,<br>比如我设置bufferSize为1024,如果我的format中的bytePerFrame是4,那么最后出来的bufferSize应该是1024*4=4096才对,但是在iOS 10一下的版本,出来的bufferSize每次都是66148</p>
<p>如果我们要进行AAC编码,那么AAC编码的bufferSize必须是能够被1024整除的,而66148是无法被1024整除</p>
<p>如果AAC编码的时候没有对齐bufferSize和1024,就会出现音频数据丢失的情况</p>
<h3 id="解决这个问题的两个角度"><a href="#解决这个问题的两个角度" class="headerlink" title="解决这个问题的两个角度"></a>解决这个问题的两个角度</h3><p>1、让installTapOnBus出来的数据能够被1024整除</p>
<p>2、自己用做对齐的事情,那么部分音频数据的采集时间戳就需要自己构造</p>
<p>我个人比较偏向第一种,这样就不存在构造时间戳的问题。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><h3 id="第一步:installTapOnBus的Block中设置frameLength"><a href="#第一步:installTapOnBus的Block中设置frameLength" class="headerlink" title="第一步:installTapOnBus的Block中设置frameLength"></a>第一步:installTapOnBus的Block中设置frameLength</h3><figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line">const uint32_t frameLength = 1024;</span><br><span class="line">[_inputNode installTapOnBus:0 bufferSize:frameLength format:[_inputNode outputFormatForBus:0] block:</span><br><span class="line"> ^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {</span><br><span class="line"> // iOS 10以下需要这么设置才可以缩短Block回调的Buffer大小和同时也能缩短Block回调的时间间隔</span><br><span class="line"> // linyehui 2016-11-11</span><br><span class="line"> buffer.frameLength = frameLength;</span><br><span class="line">}];</span><br></pre></td></tr></table></figure>
<h4 id="参考:I-want-to-call-20-times-per-second-the-installTapOnBus-bufferSize-format-block"><a href="#参考:I-want-to-call-20-times-per-second-the-installTapOnBus-bufferSize-format-block" class="headerlink" title="参考:I want to call 20 times per second the installTapOnBus:bufferSize:format:block:"></a>参考:<a target="_blank" rel="noopener" href="http://stackoverflow.com/questions/26115626/i-want-to-call-20-times-per-second-the-installtaponbusbuffersizeformatblock">I want to call 20 times per second the installTapOnBus:bufferSize:format:block:</a></h4><h3 id="第二步:不要使用AVAudioPCMBuffer的mutableAudioBufferList"><a href="#第二步:不要使用AVAudioPCMBuffer的mutableAudioBufferList" class="headerlink" title="第二步:不要使用AVAudioPCMBuffer的mutableAudioBufferList"></a>第二步:不要使用AVAudioPCMBuffer的mutableAudioBufferList</h3><p>如果你使用了步骤一的代码,那么installTapOnBus回调出来的AVAudioPCMBuffer,不要使用mutableAudioBufferList,必须使用audioBufferList。</p>
<p>因为mutableAudioBufferList的mDataByteSize是frameCapacity,而audioBufferList的mDataByteSize是真实的frameLength</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<nav class="pagination">
<span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><span class="space">…</span><a class="page-number" href="/page/15/">15</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="Next page"></i></a>
</nav>
</div>
<script>
window.addEventListener('tabs:register', () => {
let { activeClass } = CONFIG.comments;
if (CONFIG.comments.storage) {
activeClass = localStorage.getItem('comments_active') || activeClass;
}
if (activeClass) {
let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
if (activeTab) {
activeTab.click();
}
}
});
if (CONFIG.comments.storage) {
window.addEventListener('tabs:click', event => {
if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
let commentClass = event.target.classList[1];
localStorage.setItem('comments_active', commentClass);
});
}
</script>
</div>
<div class="toggle sidebar-toggle">
<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>