-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
1256 lines (525 loc) · 47.7 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 class="theme-next pisces use-motion" lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />
<meta name="keywords" content="Hexo, NexT" />
<link rel="alternate" href="/atom.xml" title="Vincent Lee" type="application/atom+xml" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />
<meta property="og:type" content="website">
<meta property="og:title" content="Vincent Lee">
<meta property="og:url" content="https://vincent10e.github.io/index.html">
<meta property="og:site_name" content="Vincent Lee">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Vincent Lee">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Pisces',
sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
fancybox: true,
motion: true,
duoshuo: {
userId: '0',
author: 'Author'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
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"}
}
};
</script>
<link rel="canonical" href="https://vincent10e.github.io/"/>
<title> Vincent Lee </title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="en">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-53388499-1', 'auto');
ga('send', 'pageview');
</script>
<div class="container sidebar-position-left
page-home
">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Vincent Lee</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle"></p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
Home
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
Tags
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
Archives
</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about" rel="section">
<i class="menu-item-icon fa fa-fw fa-user"></i> <br />
About
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://vincent10e.github.io/2017/05/21/miniKube/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Vincent Lee">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Vincent Lee">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/05/21/miniKube/" itemprop="url">
Kubernetes (ㄧ):Run Kubernetes Locally
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<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="Post created" itemprop="dateCreated datePublished" datetime="2017-05-21T16:48:15+08:00">
2017-05-21
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>前一陣子想了解 kubernetes,所以就註冊了 Google Cloud Platform,練習了一下,雖然現在註冊就送 300 美,但在熟悉這些名詞與相關的關係之前,總是會頻繁的新增 cluster 與砍 cluster,某天在逛 <a href="https://github.com/ramitsurana/awesome-kubernetes" target="_blank" rel="external">awesome-kubernetes</a> 發現了 <a href="https://github.com/kubernetes/minikube" target="_blank" rel="external">minikube</a> 這個能在 local 端執行 kubernetes 的工具,簡直開心。在這邊就簡單的介紹一下 minikube 的使用方式。</p>
<h2 id="前置作業"><a href="#前置作業" class="headerlink" title="前置作業"></a>前置作業</h2><ol>
<li><p>在 macOS 上,可以很方便的透過 brew 來安裝。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ brew cask install minikube</div></pre></td></tr></table></figure>
</li>
<li><p>安裝 Google Cloud SDK。</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ curl https://sdk.cloud.google.com | bash</div><div class="line">$ gcloud init</div></pre></td></tr></table></figure>
<ol>
<li>透過剛安裝好的 Google Cloud SDK 來安裝 kubernetes。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ gcloud components install kubectl</div></pre></td></tr></table></figure>
<p>以上前置作業就大概完成,可以檢查 minikube 是否能正確啟動。其實就是開個 VM 環境來當作測試的環境。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ minikube start</div><div class="line">Starting local Kubernetes cluster...</div><div class="line">Kubectl is now configured to use the cluster.</div></pre></td></tr></table></figure>
<p>minikube 實際上就是建立一台虛擬機器,預設是使用 VirtualBox。在 macOS 上另外還支援 xhyve driver 以及 VMware Fusion。</p>
<img src="http://i.imgur.com/KeLgTBg.png" class="[class names]" title="預設是使用 VirtualBox">
<h2 id="Project-練習"><a href="#Project-練習" class="headerlink" title="Project 練習"></a>Project 練習</h2><p>前置作業都完成後,就進入這次練習的目標,透過使用 node.js 寫個 application,並且使用 Docker build 出 images,然後透過 kubernets 來管理。</p>
<h3 id="建立-Cluster"><a href="#建立-Cluster" class="headerlink" title="建立 Cluster"></a>建立 Cluster</h3><p><code>minikube start</code> 指令會建立一個預設名稱為 <code>minikube</code> 的 kubectl context。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ minikube start</div></pre></td></tr></table></figure>
<p>由於我們是在 local 練習,就先將 kubectl 要操作的目標 context 切換為 <code>minikue</code>。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ kubectl config use-context minikube</div></pre></td></tr></table></figure>
<p>如果不做切換的話,也是可以在下指令的時候去指定對哪個 context 做操作</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ kubectl get pods --context=minikube</div></pre></td></tr></table></figure>
<h3 id="建立簡單的-Node-js-Application"><a href="#建立簡單的-Node-js-Application" class="headerlink" title="建立簡單的 Node.js Application"></a>建立簡單的 Node.js Application</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">var http = require('http');</div><div class="line"></div><div class="line">var handleRequest = function(request, response) {</div><div class="line"> response.writeHead(200);</div><div class="line"> response.end('Hello World!');</div><div class="line">};</div><div class="line">var www = http.createServer(handleRequest);</div><div class="line">www.listen(8080);</div></pre></td></tr></table></figure>
<h3 id="建立-Docker-Container-Image"><a href="#建立-Docker-Container-Image" class="headerlink" title="建立 Docker Container Image"></a>建立 Docker Container Image</h3><p>建立 <code>Dockerfile</code>。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">FROM node:6.9.2</div><div class="line">EXPOSE 8080</div><div class="line">COPY server.js .</div><div class="line">CMD node server.js</div></pre></td></tr></table></figure>
<p>在這邊產生出來的 images,因為只是單純在 local 環境跑,所以不需要將 image push 到例如 google cloud container registry 中。在這邊是讓 minikube 中的 docker daemon 就直接使用 local 端的 docker daemon。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ eval $(minikube docker-env)</div></pre></td></tr></table></figure>
<p>接著 build Docker image,並且加上 <code>hello-node:v1</code> 的 tag。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ docker build -t hello-node:v1 .</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ docker images</div><div class="line">REPOSITORY TAG IMAGE ID CREATED SIZE</div><div class="line">hello-node v1 26c151489537 1 minutes ago 655MB</div></pre></td></tr></table></figure>
<h3 id="建立-Deployment"><a href="#建立-Deployment" class="headerlink" title="建立 Deployment"></a>建立 Deployment</h3><p>Deployment 主要的功用是負責管理 Pod,監控著每個 Pod 的運作狀態並且確保指定數量的 Pod 正常運行,不過先不要碰到太複雜的設定,只先建立一個 Pod,而這個 Pod 是基於剛剛 build 出來的 Docker image。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ kubectl run hello-node --image=hello-node:v1 --port=8080</div></pre></td></tr></table></figure>
<p>檢查 deployment 是否正確建立。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">$ kubectl get deployments</div><div class="line"></div><div class="line">NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE</div><div class="line">hello-node 1 1 1 1 23s</div></pre></td></tr></table></figure>
<p>也可透過 <code>minikube dashboard</code> 來看是否有新增成功</p>
<img src="http://imgur.com/6F6vBN6.png" class="[class names]" title="Dashborad 畫面">
<h3 id="建立-Service"><a href="#建立-Service" class="headerlink" title="建立 Service"></a>建立 Service</h3><p>Service 負責定義如何去存取 Pods,簡單的來說就是能將外部流量導入 Pod 中。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ kubectl expose deployment hello-node --type=LoadBalancer</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ kubectl get services</div><div class="line"></div><div class="line">NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE</div><div class="line">hello-node 10.0.0.171 <pending> 8080:32229/TCP 1m</div><div class="line">kubernetes 10.0.0.1 <none> 443/TCP 7d</div></pre></td></tr></table></figure>
<p>到目前為止,所有設定已完成,只要再透過 minikube 跑下面指令,就能透過定義好的 service 來提供對外存取的入口點。</p>
<p>最後使用以下指令,瀏覽器就會自動開啟新的分頁,顯示 Node.js Application 的內容。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ minikube service hello-node</div></pre></td></tr></table></figure>
<hr>
<ol>
<li><a href="http://www.evanlin.com/Learn-about-kubernetes/" target="_blank" rel="external">DevOps 學習 Kubernetes 筆記之一: 透過單機版的 Kubernetes (miniKube) 來玩 K8S</a></li>
<li><a href="http://blog.kenyang.net/2016/04/07/getting-started-with-kubernetes" target="_blank" rel="external">Getting started with Kubernetes</a></li>
<li><a href="http://k8s.info/cs.html?utm_campaign=CodeTengu&utm_medium=web&utm_source=CodeTengu_54" target="_blank" rel="external">Kubernetes Community Resources</a></li>
</ol>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://vincent10e.github.io/2017/04/24/sucking-less/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Vincent Lee">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Vincent Lee">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/04/24/sucking-less/" itemprop="url">
Sucking Less
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<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="Post created" itemprop="dateCreated datePublished" datetime="2017-04-24T23:39:05+08:00">
2017-04-24
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>最近在某篇文章中發現CODING HORROR 這個部落格,作者就是 Stack Overflow 的創辦人 Jeff Atwood,發現這部落格之後每天晚上都會點幾篇來看,就這樣看了其中不少篇文章,很多針對性超強,自己也被其中的觀點戳中不少。今天則是看了這篇文章 <a href="https://blog.codinghorror.com/how-to-stop-sucking-and-be-awesome-instead/" target="_blank" rel="external">How to Stop Sucking and Be Awesome Instead</a> ,會點進來看也是被標題吸引,想知道偉大的 Jeff Atwood 會提出什麼樣的見解,潛意識覺得或許又是某種雞湯文吧。</p>
<p>文章有他演講的 youtube 影片,其中依序出現了兩張投影片 ,第一張上面寫著<code>Q : Why do we suck?</code> ,第二張上面寫著 <code>A : Because we're software too</code>,看到這時有種很難形容的感覺,可能也是隱約認同自己寫的軟體 suck 吧。</p>
<div class="video-container"><iframe src="//www.youtube.com/embed/L7EGIt3-WUQ" frameborder="0" allowfullscreen></iframe></div>
<blockquote>
<p>Software is a process, it’s never finished, it’s always evolving. That’s its nature. We know our software sucks. But it’s shipping! Next time we’ll do better, but even then it will be shitty…….. But it’s a process. We’ll make it less shitty. Just Watch!</p>
</blockquote>
<p>看到這張投影片的時候,想到最近看的一本書<<大話重構>>書中的幾段內容</p>
<blockquote>
<p>全方位的整理系統需求,再全方面的分析以及設計,接著再進入開發,測試。這樣的一個過程往往會持續數個月,耗費極大的工作量</p>
<p>簡單與快速回饋。不要想得太多,你永遠不可能預知今後會發生什麼。所以,做今天的設計,解決今天的問題,完成今天的重構。當我們的大腦開始思考各種複雜的問題時,就開始充血,接著就是夢遊,最後的結果就是顧此失彼</p>
</blockquote>
<p>現階段工作時,雖然會有現在不多思考一點,不久的未來就會出現某些處理不了的業務邏輯,在搞死現在的自己與搞死未來的自己中猶豫,但思考到預先設計與過度設計往往只是一線之隔,通常還是先做了再說,因為我知道我會有測試,之後再來更改或完善也不遲。</p>
<p>在工作上都已經有種體悟,那也應該把這套邏輯套用在自己的人生上啊,每個人想要達到的目標距離現在的你根本就是遙不可及,但還是要針對目標先採取點具體行為,就算很爛也沒關係,我知道我會回過頭來修正並且更加進步。</p>
<p>根據 Atwood 提出的三點,其實寫部落格就已經是符合前面兩項,也是個不錯的練習。</p>
<ul>
<li>Embrace the Suck</li>
<li>Do It in Public</li>
<li>Pick Stuff That Matters</li>
</ul>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://vincent10e.github.io/2017/04/17/tmux-in-your-day/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Vincent Lee">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Vincent Lee">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/04/17/tmux-in-your-day/" itemprop="url">
tmux 配合 tmuxifier
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<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="Post created" itemprop="dateCreated datePublished" datetime="2017-04-17T22:38:12+08:00">
2017-04-17
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>工作時一整天都會碰到 terminal ,在還沒有使用 tmux 之前,總是會在不同的 tab 中做切換,自從現在使用 tmux 之後,感覺到效率有稍稍的提升一點。</p>
<p>tmux 可以非常簡單地透過 Homebrew 來安裝</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ brew install tmux</div></pre></td></tr></table></figure>
<p>安裝好後,要開啟 tmux session,</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ tmux</div></pre></td></tr></table></figure>
<p>目前自己的 tmux <a href="https://gist.github.com/vincent10e/1802b342048467dc5c6b8d44926b07a8" target="_blank" rel="external">設定</a> 是 follow thoughtbot 的 screen 課程,其中覺得最值得調整的是以下幾個設定。</p>
<ul>
<li>如果在一個 window 中切了多了 pane,這個設定可以方便地在不同的 pane 之中切換</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"># act like vim</div><div class="line">bind-key -n C-h select-pane -L</div><div class="line">bind-key -n C-j select-pane -D</div><div class="line">bind-key -n C-k select-pane -U</div><div class="line">bind-key -n C-l select-pane -R</div></pre></td></tr></table></figure>
<ul>
<li>垂直以及水平切個出新的 pane</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"># split window</div><div class="line">bind-key - split-window -v -c '#{pane_current_path}'</div><div class="line">bind-key \ split-window -h -c '#{pane_current_path}'</div></pre></td></tr></table></figure>
<ul>
<li>調整 pane 之間的大小,配合 shift 或 control 就能做到小幅度或者是大幅度的調整。</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"># Fine adjustment (1 or 2 cursor cells per bump)</div><div class="line">bind -n S-Left resize-pane -L 2</div><div class="line">bind -n S-Right resize-pane -R 2</div><div class="line">bind -n S-Down resize-pane -D 1</div><div class="line">bind -n S-Up resize-pane -U 1</div><div class="line"></div><div class="line"># Coarse adjustment (5 or 10 cursor cells per bump)</div><div class="line">bind -n C-Left resize-pane -L 10</div><div class="line">bind -n C-Right resize-pane -R 10</div><div class="line">bind -n C-Down resize-pane -D 5</div><div class="line">bind -n C-Up resize-pane -U 5</div></pre></td></tr></table></figure>
<h2 id="再進階一點點"><a href="#再進階一點點" class="headerlink" title="再進階一點點"></a>再進階一點點</h2><p>上面的設定都是能夠讓我們方便的將 pane 調成自己想要的設定,但如果今天 session 重開就要重新再切個 pane,然後再調整 pane 大小為自己想要的樣子,實在是不符合懶惰的原則,為了能夠達成恢復 tmux session,可以配合 <a href="https://github.com/tmuxinator/tmuxinator" target="_blank" rel="external">tmuxinator</a> 一起使用。</p>
<p>安裝完之後,使用 tmuxinator 建立新的 project。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ tmuxinator new rails_demo_project</div></pre></td></tr></table></figure>
<p><code>~/.tmuxinator/sample.yml</code>,這邊做一個簡單的範例檔,當使用 tmuxinator 時會開啟一個 tmux window,在這個 window 中有兩個 panes,一個 pane 會執行 <code>rails server</code>,而另外一個則是執行 <code>rails console</code>。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"># ~/.tmuxinator/rails_demo_project.yml</div><div class="line"></div><div class="line">name: rails_demo_project</div><div class="line">root: ~/rails_demo_project</div><div class="line"></div><div class="line">windows:</div><div class="line"> - develop:</div><div class="line"> layout: main-vertical</div><div class="line"> panes:</div><div class="line"> - server:</div><div class="line"> - bundle exec rails server</div><div class="line"> - console:</div><div class="line"> - bundle exec rails console</div></pre></td></tr></table></figure>
<p>之後開發時,只要使用 tmuxinator,就能快速的開啟預先定義好的 session 畫面。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ tmuxinator start rails_demo_project</div></pre></td></tr></table></figure>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://vincent10e.github.io/2017/04/15/information/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Vincent Lee">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Vincent Lee">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/04/15/information/" itemprop="url">
你一天看了多少東西?
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<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="Post created" itemprop="dateCreated datePublished" datetime="2017-04-15T17:22:06+08:00">
2017-04-15
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="資訊爆炸"><a href="#資訊爆炸" class="headerlink" title="資訊爆炸"></a>資訊爆炸</h2><p>有意識的管理自己的資訊來源,你不做篩選,就只能被動接受別人餵食給你的資訊。最近公司的設計師分享了我們人一天會看到多少 LOGO,據他表明是 4000 ~ 10000,很可怕的數量,不過這些 Logo 大概也都不會暫留在我們心思太久,甚至沒有意識到自己有撇過這一眼。這就讓我不禁想問自己一天到底看了多少的資訊,好吧,我實在沒有動力去做記錄,但是我可以用檢視自己接觸資訊的方式,來替自己針對一整天到底接觸了多少資訊這個問題抓個大概。</p>
<p>今天認真的分類一下自己的資訊來源,大致上就分做這幾類,RSS、Facebook、Twitter、電子報、朋友圈以及實體書本。</p>
<h2 id="RSS"><a href="#RSS" class="headerlink" title="RSS"></a>RSS</h2><p>記得Google Reader 在 2013-07-01 關閉時也引起我不小的慌張,不過也順利找到替代品 <a href="https://feedly.com" target="_blank" rel="external">feedly</a> ,然後就一直用到了現在,目前 feedly 上訂閱的 RSS 大部分都是跟開發有關或者是一些新聞以及不錯的部落格。通常每天早上會先挑幾個 feedly 上的分類大致的看過,覺得自己可能會想要深入研究的文章就會先存到 <a href="https://www.instapaper.com/" target="_blank" rel="external">Instapaper</a> 中,覺得好像可看就會對那篇文章按 read later,會這樣區分是有目的的。另外平常看到不錯的網站也都是先丟到 Instapaper 中,然後在 Instapaper 每晚會將未閱讀的文章推送到我的 kinddle 中,每天睡前就會看一下 kindle 中的文章。</p>
<p>在 Kindle 上看這些比較碎片的文章,有幾個好處,第一是平常開發的時候已經盯了夠久的螢幕,有時下班後想要吸收點資訊,開電腦看又會加重眼睛的負擔,更別提還有可能分心去做其他事情的可能性。第二是在 kindle 中可以針對文章標記 highlight,,這些有被上 highlight 的內容,隔一段時間我會使用 <a href="https://itunes.apple.com/cn/app/klib-%E6%A0%87%E6%B3%A8%E7%AC%94%E8%AE%B0%E7%AE%A1%E7%90%86-for-kindle/id1196268448?mt=12" target="_blank" rel="external">Klib </a> 拉出來放到 <a href="http://www.bear-writer.com/" target="_blank" rel="external">Bear Note</a> 中,或者手寫在自己的筆記本中。</p>
<p>最後這些碎片化的資訊經過前面幾道手續,來到了最後一步,整理跟分類,之前是用 Evernote 來當作數位的筆記,現在是搬移到上面提到的 Bear Note 中,記下來的東西,除非你是天才能夠將這些資訊過目不忘,若是到達此境界,其實也不用搞得如此麻煩了,(在福爾摩斯的影集中,有一個人擁有過目不忘的能力,甚至稱自己的記憶空間為阿普羅之類的),但問題在於我們都不是,所以要如何分類,讓自己日後能夠再回頭看這些可能是某篇文章去蕪存菁後的精華,後續能夠再翻找,才是做這些事情的價值。</p>
<h2 id="實體書籍"><a href="#實體書籍" class="headerlink" title="實體書籍"></a>實體書籍</h2><p>通常一個月都會給自己不少的預算買書,有些書會細讀,有些書則是草率地看過去,不過對我來說認真讀一本書,並且了謄寫部分內容到筆記本,或者是隨意在書上寫個一小段心得,認真程度大概就僅止於此,不過不論是認真的讀或草率的讀,通常都能夠在腦中留下一點印象,有時候在生活中遭遇到某些事情卡關,自己想法停滯不前時就會想起去這時好像可以去翻翻哪本書,當然,不可能說看書就能解決問題,只不過是一種替低落的自己找尋別種出路的可能性。</p>
<h2 id="Other"><a href="#Other" class="headerlink" title="Other"></a>Other</h2><p>facebook 上主要加入的社團也是跟開發相關居多,裡面總是熱心分享第一手消息的人,另外則是 twitter 已經被我當作是一個 reader 在使用了。上面看到的東西覺得不錯也是使用 <a href="https://chrome.google.com/webstore/detail/instapaper/ldjkgaaoikpmhmkelcgkgacicjfbofhh" target="_blank" rel="external">Instapaper - Chrome Extension</a> 順手將文章存到 Instapaper 中。另外最重要的是朋友圈呀,有些人根本就是人型移動的 RSS Reader,你可以問他最近有什麼好看的電影可以推薦,有什麼不錯的餐廳可以試試,他們總是可以跟你分享一堆,有這些朋友真的要珍惜啊。</p>
<h2 id="最後"><a href="#最後" class="headerlink" title="最後"></a>最後</h2><p>另外要推薦一下這兩個網站 <a href="https://sspai.com/" target="_blank" rel="external">少數派</a>跟 <a href="http://liqi.io/" target="_blank" rel="external">利器 </a> ,雖然跟資訊資收沒有太大的關係,但裡面的文章有提到許多高生產力的人都是使用什麼樣的工具,何種工具可以幫助到他們,以及使用的心得,不過這邊要注意的是,雖然有時候看著看著就會自己好像也辦得到,自己好像也可以這麼有生產力的錯覺產生,沒錯,這是錯覺,最後還是要靠自己傻得願意去實踐跟嘗試改變,才能將工具還有資訊還有你的記憶做好整合。</p>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://vincent10e.github.io/2017/04/13/hello-world/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Vincent Lee">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Vincent Lee">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/04/13/hello-world/" itemprop="url">
Hello World
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<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="Post created" itemprop="dateCreated datePublished" datetime="2017-04-13T21:01:12+08:00">
2017-04-13
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="事出必有因"><a href="#事出必有因" class="headerlink" title="事出必有因"></a>事出必有因</h2><p> 最近涉略廣泛的老闆不知道哪來的時間,看到了我以前的部落格,還在下面留言戳了我一下,才讓我想起以前有使用 Octopress 配合github page 來架部落格,內容都是紀錄一點學習心得,對於當時 you don’t what you don’t know 的情況下,內容都是雜亂無章也不知道為什麼要這樣寫,只知道照做就可以 work,看到以前寫的內容竟然有強烈的羞恥感,不過另一方面又對這種強烈的羞恥感有另外一種解讀,是的,就是開心啊,這代表著我這段時間是有進步的。同時加上最近看到了一篇文章 <a href="https://dotblogs.com.tw/hatelove/2017/03/26/why-engineers-should-keep-blogging" target="_blank" rel="external">我為什麼鼓勵工程師寫 blog | In 91 - 點部落</a> ,裡面的一段話是完全打到我。</p>
<blockquote>
<p>「從腦袋裡面接收到資訊,思考,做出反應外顯出來,達到效果」這個過程是需要大量練習才能縮短反應時間並精準地達到效果。</p>
</blockquote>
<p> 這件事對我來說根本就超痛苦,一個存在腦中的內隱知識,要如何用文字清楚的表達?都是考驗著對那件事物本身的瞭解程度,以及自己描述事情的文字能力。似懂非懂的知識,就會像現在每個領域都碰一點卻無法建立有效的連結。</p>
<h2 id="出發總要有個方向"><a href="#出發總要有個方向" class="headerlink" title="出發總要有個方向"></a>出發總要有個方向</h2><p> 首先,最實在的第一步就是先買個 Filco Convertible 2 雙模藍芽鍵盤,自從某次吃飯,聽到了同事的室友介紹後,心中就一直念念不忘,但無奈各大網路平台都缺貨,或者是沒有進貨。那就往光華商場出發去,在所有網路平台都沒有進貨的情況下,進去問了金鍵盤的老闆,老闆表示:「當然有呀!」隨即側身連帶左手往上面的架子一指,哇靠,整整一疊的貨啊,不愧是台北賣鍵盤最專業的店,真是不浮誇。強迫自己執行這項行為,最後滿足的條件是花錢,花了大錢買了 ,真的是太貴又太痛了,真是讓我充滿了滿滿的動力,似乎不做點什麼都不行了。</p>
<h2 id="人生這檔事"><a href="#人生這檔事" class="headerlink" title="人生這檔事"></a>人生這檔事</h2><p> 回想當初為何會學 Ruby on Rails,只是因為延畢的那半年實在是沒有什麼事情做,整天在幫老師測試數據,或改改自己的論文的演算法,生活根本沒有什麼太大的挑戰,同時間又因為實在不知道畢業後不想要去大公司上班,總覺得去小公司上班是充滿挑戰的一件事情,就這樣花時間在琢磨 Rails。</p>
<p> 說起來也幸運,剛上台北時就遇到不少恩人,在一開始菜到不行的狀況下還能走上了開發這條路,之後輾轉也到了現在的公司。</p>
<p> 總是會有人關心的問,咦,你念電機系怎麼沒有去台積電或聯電啊之類的大公司,那個誰誰誰年薪百萬了耶,對於聽到這些不羨慕真的都是騙人的,但靜下來想還是現在過得比較快樂,工作中充滿了挑戰,同時這些挑戰是現階段你必須解決的,有人說老闆身上最重要的器官不是嘴巴而是肩膀,目前能有人這樣扛著,讓我能夠用各種學習到的想法套用在目前的工作問題中,真的是蠻爽的。並且培養出的能力是跟著自己的,不論到哪邊你都可以發揮同樣解決問題的能力。</p>
<p>這兩年過得很刺激,但也有種黑歷史的感覺,似乎在過程中碰了很多東西,也學了很多東西,但說不太上來的感覺。賈伯斯在史丹佛大學做的畢業演講中有一段話</p>
<blockquote>
<p>You can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future.</p>
</blockquote>
<p>這邊就當作是未來往回看時的一種依據吧。</p>
<h2 id="所以"><a href="#所以" class="headerlink" title="所以"></a>所以</h2><p> 最後的總結不能有太勵志的信心喊話,因為根據統計在部落格的第一天文章中期勉自己能夠不斷寫下去的人,有百分之九十是不會在繼續寫下去的,所以與其那樣字面上的喊話,那不如就用行動證明吧。</p>
<h2 id="延伸閱讀"><a href="#延伸閱讀" class="headerlink" title="延伸閱讀"></a>延伸閱讀</h2><p><a href="https://dotblogs.com.tw/hatelove/2017/03/26/why-engineers-should-keep-blogging" target="_blank" rel="external">我為什麼鼓勵工程師寫 blog | In 91 - 點部落</a><br><a href="https://blog.codinghorror.com/how-to-achieve-ultimate-blog-success-in-one-easy-step/" target="_blank" rel="external">How To Achieve Ultimate Blog Success In One Easy Step</a><br><a href="https://www.youtube.com/watch?v=UF8uR6Z6KLc" target="_blank" rel="external">Steve Jobs’ 2005 Stanford Commencement Address - YouTube</a></p>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</section>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>