-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
470 lines (243 loc) · 150 KB
/
atom.xml
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
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>peijie's wiki</title>
<link href="https://liupj.top/atom.xml" rel="self"/>
<link href="https://liupj.top/"/>
<updated>2024-10-19T07:14:55.102Z</updated>
<id>https://liupj.top/</id>
<author>
<name>lpj</name>
</author>
<generator uri="https://hexo.io/">Hexo</generator>
<entry>
<title>童言即诗</title>
<link href="https://liupj.top/2024/10/19/childrensWordsIsPoem/"/>
<id>https://liupj.top/2024/10/19/childrensWordsIsPoem/</id>
<published>2024-10-19T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<blockquote><p>以下内容选摘自互联网络,仅仅因为觉得可爱故分享于此,如有雷同纯属巧合,侵权可删</p></blockquote><ul><li><p>一个小婴儿哭了,旁边的小朋友说:“阿姨你的宝宝响了!”</p></li><li><p>4 岁娃坐车上,外面阳光照他脸上,说:“我被太阳发现了!”</p></li><li><p>小孩不会读“逸”字,他说:”妈妈,这个小兔子有滑板车~“</p></li><li><p>坐地铁遇到一个小朋友,因为地铁摇晃站不稳,这个小朋友说了句:”地铁先生你不要乱动!“</p></li><li><p>女儿跟妈妈说怕黑,妈妈对女儿说要勇敢,她说:”我不怕红不怕绿不怕蓝不怕黄,还不够勇敢吗?“</p></li><li><p>小朋友蹲马桶腿麻了,他突然眼睛睁好大说:”我的腿里面好疯狂啊!“</p></li><li><p>给一个孩子上钢琴课,从大三度转到小三度音程时,他说这个音抑郁了…真的,这感觉太到位了</p></li><li><p>我儿子第一次见到黑人,头默默地埋在我怀里,很小声地问我:“叔叔是不是过期了”</p></li><li><p>我儿子小时候有一次问我要“驼背的花生”吃,原来他是要吃腰果</p></li><li><p>我儿子脚麻了,他说:“妈妈我的脚在放烟花”</p></li><li><p>我女儿洗完手,非常大声地说:“谢谢水龙头”,然后鞠躬,我当时简直是呆住了</p></li><li><p>我小女儿两三岁的时候每次拉完粑粑都要跟粑粑说再见,还要挥着手手说</p></li><li><p>风把门吹开了,小朋友说:“妈妈,风有我们家的钥匙“</p></li><li><p>我二宝坐在安全座椅里,被遮光帘碰到了,她说:”风在踢我“</p></li><li><p>我娃说90多岁拄着拐颤巍巍走路的老奶奶该换电池了</p></li></ul>]]></content>
<summary type="html"><blockquote>
<p>以下内容选摘自互联网络,仅仅因为觉得可爱故分享于此,如有雷同纯属巧合,侵权可删</p>
</blockquote>
<ul>
<li><p>一个小婴儿哭了,旁边的小朋友说:“阿姨你的宝宝响了!”</p>
</li>
<li><p>4 岁娃坐车上,外</summary>
</entry>
<entry>
<title>与通信相拥,共织中国结</title>
<link href="https://liupj.top/2024/08/26/chinese-knot/"/>
<id>https://liupj.top/2024/08/26/chinese-knot/</id>
<published>2024-08-26T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>烽火狼烟今不在,仍爱故人寄梅花。我的前二十六年,早已与通信结缘。</p><p>回想起来,对于通信这个现代名词的最初记忆,大概是孩童时期和伙伴们玩的一种游戏——将一根细绳的两头分别连接到两个一次性纸杯的底部,将细绳绷直,其中一个人对着杯口说话,另一个人就可以从另一个纸杯中清晰地听到声音。游戏虽然很简单,但那时的我却觉得乐趣无穷,冥冥中就像那个时代的通信,虽然原始,但却充满着无限可能。</p><p>时光荏苒,国内互联网的浪潮席卷而来,连接纸杯的细绳就变成了连接电脑的网线,拨号上网和一众新兴的互联网应用开始造访我的童年,我的小学同学一个接一个地拥有了他们的QQ号,交到了他们的第一批网友,快乐分享着各自的生活和喜怒哀乐。再后来出现了QQ空间,我也终于在发小的帮助下注册了自己的QQ号,依稀记得有几个好朋友给我留言,尽管我们只是用平白的文字和简单的网络符号进行交流,但这种新奇的、远程的、即时的信息交换方式,让当时的我兴奋无比。</p><p>通信技术的迅猛发展实打实地影响着我的生活,且以肉眼可见的速度不断改造着我生活的小镇。随着3G技术在中国市场商业化的展开,一个个背上印有红色中国结的通信工人开始奔走在我居住城市的大街小巷,秉持着心中红色的信仰,肩负着用网络连接千家万户的使命,一个个大大小小的信号塔被这些戴着脚扣、背着工具包的城市工蜂树立了起来。一批历经风雨垂垂老矣的电话亭开始识趣地让位,朝气蓬勃的电子商务和移动支付紧接着排队登场。通信时代的春风正向着我们扑面而来…</p><p>“你有一个思想,我有一个思想,我们交换思想,我们就都有了两个思想。”英国剧作家萧伯纳说的这句话曾一针见血地揭示了信息交换对于我们人类社会的重要意义。步入大学校园,我终于如愿以偿地拥有了自己的第一部智能手机,时值4G通信网络的普及,一众触手可得的网络应用使得我与数据通信世界交换信息变得前所未有地方便快捷。好大学的围墙开始被网络打破,bilibili、中国MOOC、好多信息共享网站正让资源变得唾手可得,曾经梦想在自己的网站上同网线彼端的读者们分享见解也顺理成章地成为现实。现在想来,我何尝不庆幸自己能有机会在宝贵的大学时光通过网络学到清北、伯克利、麻省理工等名校名师的优质课程,何尝不是通信技术的进步让我获得了更多平等受教育的机会呢?</p><p>2019年底,通过新闻媒体,家乡小镇的居民得知了新冠疫情爆发的消息,得益于5G的推广,社区第一时间组建了抗疫微信群来发布消息,健康码、行程码等疫情追踪应用应运而生,盒马鲜生、在线医疗咨询等服务迅速建立,通信技术的革新助力我们迅速建立起了抗击疫情的网络长城。接连三个除夕夜、三个新春佳节,大家都是足不出户,在家庭微信群里发红包,通过流畅的高清视频通话互相拜年,使用高清IPTV收看央视春节联欢晚会。疫情期间,我也通过远程视频面试的方式收到了联通的录取通知。那时爸爸就曾发出感慨:“幸亏现在有网络~”是啊,人民邮电为人民,通信的初心就是为了让我们普通百姓的生活变得更便捷、更美好。</p><p>在联通工作将满两年,跟着前辈奔走在生产一线,从ONU到交换机,从光交箱到服务器,联通千兆光网从抽象的拓扑图在我的认知里渐渐变得具象可感。跟在许多优秀的“大中国结”身边,我这个初出茅庐的“小中国结”,也见识到了诸如智能家居、5G云游、智慧城市、智慧农业、智慧生态治理等新应用、新产业的规划、实施和落地。所爱隔山海,山海皆可平。我感恩联通,感恩一代代通信人创造的数据互联互通的信息时代,同时我也热切期盼着下一代通信技术变革的到来,期待着和我的同事们一起,为这个世界带来更多惊喜。</p>]]></content>
<summary type="html"><p>烽火狼烟今不在,仍爱故人寄梅花。我的前二十六年,早已与通信结缘。</p>
<p>回想起来,对于通信这个现代名词的最初记忆,大概是孩童时期和伙伴们玩的一种游戏——将一根细绳的两头分别连接到两个一次性纸杯的底部,将细绳绷直,其中一个人对着杯口说话,另一个人就可以从另一个纸杯中清</summary>
</entry>
<entry>
<title>Java Grammar</title>
<link href="https://liupj.top/2023/12/10/JavarGrammar/"/>
<id>https://liupj.top/2023/12/10/JavarGrammar/</id>
<published>2023-12-10T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p><a href="https://www.bilibili.com/video/BV1c54y1U7pp">初学编程的常见误区</a></p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/image-20230330001856416.png" alt="image-20230330001856416"></p><h2 id="Module-1-Java-Fundamentals"><a href="#Module-1-Java-Fundamentals" class="headerlink" title="Module 1: Java Fundamentals"></a>Module 1: Java Fundamentals</h2><p>Variables: store data</p><p>Conditionals: control how your code runs</p><p>Arrays: store and work with many values</p><p>Loops: control how many times a piece of code needs to run</p><p>Functions: perform tasks</p><h2 id="Module-2-Object-Oriented-Programming"><a href="#Module-2-Object-Oriented-Programming" class="headerlink" title="Module 2: Object Oriented Programming"></a>Module 2: Object Oriented Programming</h2><p>objects、immutable objects、list collections、map collections、exception handling、</p><p>package and import、static and final、enums、unit test、inheritance and polymorphism、</p><p>higher order functions、big decimal、interface、concurrency and multithreading</p><h2 id="Reasons-to-learn-Java"><a href="#Reasons-to-learn-Java" class="headerlink" title="Reasons to learn Java"></a>Reasons to learn Java</h2><p>Java is general-purpose, which means that Java powers a wide range of applications.<br>As a Java developer,</p><ul><li>you can build web applications using Spring boot,</li><li>you can build applications on Android,</li><li>you can automate tasks using Selenium,</li><li>you can develop cloud native applications,</li><li>you can integrate microservices,</li><li>you can …</li></ul><p>Java can run on any machine, it’s well known for its “write once, run anywhere”</p><ul><li>This is because the Java Virtual Machine, the JVM, which is responsible for executing compiled Java code, can be installed on any platform</li></ul><p>Java is the No.1 language for developing enterprise applications</p><h2 id="To-run-Java-code-you-need"><a href="#To-run-Java-code-you-need" class="headerlink" title="To run Java code, you need"></a>To run Java code, you need</h2><ol><li><p>A Java Compiler - to compile your code.</p></li><li><p>A Java Runtime - to run the compiled code.</p><p> So, this is why JDK provides a Compiler、a Runtime、and a lot of other things.</p><p> <img style="width: 12rem;" src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20230307213835.png"></img></p></li></ol><h2 id="Roadmap"><a href="#Roadmap" class="headerlink" title="Roadmap"></a>Roadmap</h2><ol><li><p>Install a JDK(Java Development Kit) on your machine => from Amazon Corretto is recomended.</p><p> Amazon Corretto is just a distribution which once installed, does the work of setting up a JDK on your machine.<br> Basically all you need to do is install it and it’s going to do the heavy lifting.</p> <figure class="highlight shell"><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">javac -version # check compiler</span><br><span class="line">java -version # check runtime</span><br></pre></td></tr></table></figure><p> Finished ! you’ve just installed a JDK, now your computer can compile and run Java code.</p></li><li><p>Download a text editor to write code</p><p> I use vim & vscode(the extension pack for java is must).</p><p> Now you have everything you need to start building Java applications!</p></li><li><p>Write & Run your first Java code</p> <figure class="highlight shell"><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"><span class="meta prompt_"># </span><span class="language-bash">Every java file needs to follow the naming convention -> CamelCase</span></span><br><span class="line">touch HelloJava.java</span><br></pre></td></tr></table></figure> <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// In java, you must write all of your code in a class.</span></span><br><span class="line"><span class="comment">// And the ClassName needs to be the same as your FileName.</span></span><br><span class="line"><span class="comment">// So here we create a class.</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">HelloJava</span> {</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p> All right, so what’s next is the <code>main()</code> method, which is the entry point of a Java application.</p><p> And inside main, we’re going to print the message “Hello Java”</p> <figure class="highlight java"><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></pre></td><td class="code"><pre><span class="line"><span class="keyword">class</span> <span class="title class_">HelloJava</span> {</span><br><span class="line"> <span class="comment">// not understand this line is doesn't matter now.</span></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"> System.out.println(<span class="string">"Hello Java"</span>);</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/* Notice:</span></span><br><span class="line"><span class="comment"> the semicolon is really important, which means end of statement.</span></span><br><span class="line"><span class="comment"> every statement in Java, every line of code, needs a semicolon at the end.</span></span><br><span class="line"><span class="comment"> so if you forget your semicolon, your code is not gonna run.</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure><p> Now we’re ready to compile and run our Java code.</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></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">The javac <span class="built_in">command</span> compiles your javaCode into byteCode</span></span><br><span class="line">javac <FileName>.java</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">The java <span class="built_in">command</span> executes the compiled code</span></span><br><span class="line">java <FileName></span><br></pre></td></tr></table></figure><p> For example</p><p> <img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/image-20230331230902548.png" alt="image-20230331230902548"></p></li></ol><p>See you in workbook 1.1</p><h2 id="Variable"><a href="#Variable" class="headerlink" title="Variable"></a>Variable</h2><blockquote><p>Store data inside variable.</p></blockquote><h3 id="Java-is-strongly-typed"><a href="#Java-is-strongly-typed" class="headerlink" title="Java is strongly typed"></a>Java is strongly typed</h3><p>which means that variables can only store values of their type.</p><h3 id="Java-is-case-sensitive"><a href="#Java-is-case-sensitive" class="headerlink" title="Java is case sensitive"></a>Java is case sensitive</h3><p>eg: <code>people</code> is not the same as <code>People</code></p><h3 id="The-convention-to-naming-a-variable"><a href="#The-convention-to-naming-a-variable" class="headerlink" title="The convention to naming a variable"></a>The convention to naming a variable</h3><p><strong>lowerCamelCase</strong></p><p>eg: <code>int peopleOnBus = 20;</code></p><h3 id="Update-the-value-inside-a-variable"><a href="#Update-the-value-inside-a-variable" class="headerlink" title="Update the value inside a variable"></a>Update the value inside a variable</h3><p>Just set it equal to a new value, or use <code>+=</code>、<code>-=</code>、…</p><p>See you in workbook 2.1</p><h2 id="Use-variables-to-store-numeric-data"><a href="#Use-variables-to-store-numeric-data" class="headerlink" title="Use variables to store numeric data"></a>Use variables to store numeric data</h2><h3 id="Types-int-and-long"><a href="#Types-int-and-long" class="headerlink" title="Types: int and long"></a>Types: int and long</h3><p>We can use <code>int</code> and <code>long</code> variables to store whole numbers.</p><p>You should know the difference between <code>int</code> and <code>long</code> and when to use <code>int</code> vs <code>long</code>.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="variable">numberOfFans</span> <span class="operator">=</span> <span class="number">5000</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 如下两行等价,但显然第二行的可读性更好</span></span><br><span class="line"><span class="type">long</span> <span class="variable">population</span> <span class="operator">=</span> <span class="number">7000000000L</span>;</span><br><span class="line"><span class="type">long</span> <span class="variable">population</span> <span class="operator">=</span> <span class="number">7_000_000_000L</span>;</span><br></pre></td></tr></table></figure><p>为什么要在 7000000000 这个数后面加个 L ?</p><p>如果你不加 L,那么 Java 就只会看到这是一个很大的数,它并不知道你这个傻乎乎的开发者要将这个数存到什么地方,所以 Java 就慌了</p><p>因此,你只需在这个数后面加个 L 来告诉 Java:“放松啦~ 咱们要存的地方存得下这个数的。”,然后 Java 就平静了</p><h3 id="Type-double"><a href="#Type-double" class="headerlink" title="Type: double"></a>Type: double</h3><p>We can use <code>double</code> variables to store decimal numbers, which are given so much size in memory that a double value can reach 15 <a href="https://zh.wikipedia.org/wiki/%E6%9C%89%E6%95%88%E6%95%B0%E5%AD%97">significant digits</a>.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">double</span> <span class="variable">percentage</span> <span class="operator">=</span> <span class="number">55.7</span>;</span><br></pre></td></tr></table></figure><h3 id="Be-careful"><a href="#Be-careful" class="headerlink" title="Be careful !!!"></a>Be careful !!!</h3><p>Avoid just using integers for math calculations,</p><p>because if you multiply or divide two integers, the result will always be an integer,</p><p>because Java’s going to cut off all the decimals.</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">integer * integer => integer</span><br><span class="line">integer / integer => integer</span><br></pre></td></tr></table></figure><p>eg</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="variable">people</span> <span class="operator">=</span> <span class="number">3</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">wallet</span> <span class="operator">=</span> <span class="number">20</span>;</span><br><span class="line">System.out.println(wallet / people); <span class="comment">// 6, which is not the result we want.</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// So we need to make sure that at least one of these values is stored as a decimal,</span></span><br><span class="line"><span class="comment">// then Java's going to know to return a decimal result.</span></span><br><span class="line"><span class="type">int</span> <span class="variable">people</span> <span class="operator">=</span> <span class="number">3</span>;</span><br><span class="line"><span class="type">double</span> <span class="variable">wallet</span> <span class="operator">=</span> <span class="number">20</span>;</span><br><span class="line">System.out.println(wallet / people); <span class="comment">// 6.666666666666667, this is the result we want.</span></span><br></pre></td></tr></table></figure><h3 id="Golden-Rule"><a href="#Golden-Rule" class="headerlink" title="Golden Rule"></a>Golden Rule</h3><p>If precision is important, use <code>double</code> for math calculations.</p><h3 id="Type-String"><a href="#Type-String" class="headerlink" title="Type: String"></a>Type: String</h3><p>We can use the type <code>String</code> to store text.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">String</span> <span class="variable">sentence</span> <span class="operator">=</span> <span class="string">"Hello world !"</span>;</span><br></pre></td></tr></table></figure><p>String unlike <code>int</code> in memory, </p><p>no matter what you store in the integer variable, it’s always 4 bytes,</p><p>but with String, empty text alone takes up 24 bytes, and the more text that you add to a string, the more memory it takes up.</p><hr><p>You can use the <code>+</code> operator to join two String values.</p><figure class="highlight java"><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"><span class="type">String</span> <span class="variable">sentence</span> <span class="operator">=</span> <span class="string">"His name is: "</span>;</span><br><span class="line"><span class="type">String</span> <span class="variable">placeholder</span> <span class="operator">=</span> <span class="string">"Harry"</span>;</span><br><span class="line">System.out.println(sentence + placeholder);</span><br></pre></td></tr></table></figure><p>You can use the <code>+</code> operator to blend values into a string.</p><figure class="highlight java"><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"><span class="type">double</span> <span class="variable">points</span> <span class="operator">=</span> <span class="number">50</span>;</span><br><span class="line"><span class="type">String</span> <span class="variable">announcement</span> <span class="operator">=</span> <span class="string">" points for Gryffindor"</span>;</span><br><span class="line">System.out.println(points + announcement); <span class="comment">// 50.0 points for Gryffindor</span></span><br></pre></td></tr></table></figure><h3 id="Type-char"><a href="#Type-char" class="headerlink" title="Type: char"></a>Type: char</h3><p>We can use the <code>char</code> type to store single characters.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">char</span> <span class="variable">gender</span> <span class="operator">=</span> <span class="string">'F'</span>;</span><br></pre></td></tr></table></figure><p>We can join a String value with a char value using the <code>+</code> operator.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">System.out.println(<span class="string">"Gender: "</span> + <span class="string">'F'</span>);</span><br></pre></td></tr></table></figure><hr><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">String</span> <span class="variable">gender</span> <span class="operator">=</span> <span class="string">"F"</span>;</span><br></pre></td></tr></table></figure><p>It seems that String is more flexible than char,</p><p>so why not always use String ?</p><p>The answer is【memory】and【performance】!</p><p>char consumes less memory, and char is faster than String !</p><h3 id="Summarize"><a href="#Summarize" class="headerlink" title="Summarize"></a>Summarize</h3><p>There are 6 core data types (we didn’t cover <code>boolean</code> yet).</p><table><thead><tr><th>Data Type</th><th>Value</th><th>Amount of Memory (Bytes)</th><th>Valid Range of Values</th></tr></thead><tbody><tr><td>int</td><td>Whole numbers</td><td>4</td><td>From: -2147483648 To: 2147483647</td></tr><tr><td>long</td><td>Very large whole numbers</td><td>8</td><td>From: -9223372036854775808 To: 9223372036854775807</td></tr><tr><td>double</td><td>Decimals</td><td>8</td><td>Decimal can reach 15 significant digits</td></tr><tr><td>String</td><td>Text</td><td>Varies, 24 bytes for empty text.</td><td>-</td></tr><tr><td>char</td><td>A single character</td><td>2</td><td>-</td></tr></tbody></table><p>平时开发我基本不使用 <code>byte, short, float</code></p><p>See you in workbook 2.2</p><h3 id="补充知识"><a href="#补充知识" class="headerlink" title="补充知识"></a>补充知识</h3><p>在以二进制存储数据的计算机中,浮点数存在误差 !=> <a href="https://liupj.top/2021/08/31/01/">https://liupj.top/2021/08/31/01/</a></p><h2 id="Math-operators"><a href="#Math-operators" class="headerlink" title="Math operators"></a>Math operators</h2><p>So far you’ve learned about: <code>int</code>、<code>long</code>、<code>double</code>、<code>String</code> and <code>char</code>.</p><p>Now, you can use math operators shown as below to play with these values.</p><p><code>+, -, *, /, %, ++, --, +=, -=, ...</code></p><h3 id="Pattern"><a href="#Pattern" class="headerlink" title="Pattern"></a>Pattern</h3><p>An operation between whole numbers returns a whole number.</p><p>An operation between decimals will always perserve the decimal.</p><h3 id="Think-about-that-why-do-we-care-about-the-remainder"><a href="#Think-about-that-why-do-we-care-about-the-remainder" class="headerlink" title="Think about that why do we care about the remainder ?"></a>Think about that why do we care about the remainder ?</h3><p>It’s very useful if you want to identify odd or even numbers.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="variable">remainder</span> <span class="operator">=</span> <span class="number">10</span> % <span class="number">2</span>; <span class="comment">// 0</span></span><br></pre></td></tr></table></figure><p>See you in workbook 2.3</p><h2 id="Type-casting"><a href="#Type-casting" class="headerlink" title="Type casting"></a>Type casting</h2><p>In Java, we can cast variables from one type to another.</p><figure class="highlight java"><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 class="comment">// Cast double to int</span></span><br><span class="line"><span class="comment">// Just telling Java the type that we're casting to.</span></span><br><span class="line"><span class="type">double</span> <span class="variable">decimal</span> <span class="operator">=</span> <span class="number">4.3</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">integer</span> <span class="operator">=</span> (<span class="type">int</span>)decimal;</span><br></pre></td></tr></table></figure><p>See you in workbook 2.4</p><h2 id="Scanner"><a href="#Scanner" class="headerlink" title="Scanner"></a>Scanner</h2><p>Scanner contains many methods that we can use to scan for user input.</p><table><thead><tr><th>method</th><th>scan for</th><th>explaination</th></tr></thead><tbody><tr><td>nextInt()</td><td>integers</td><td>skips the whiteSpace and picks up the next Integer</td></tr><tr><td>nextLong()</td><td>integers</td><td>skips the whiteSpace and picks up the next Long</td></tr><tr><td>nextDouble()</td><td>decimals</td><td>skips the whiteSpace and picks up the next Double</td></tr><tr><td>next()</td><td>text</td><td>skips the whiteSpace and picks up the next String</td></tr><tr><td>nextLine()</td><td>text</td><td>picks up a line of data</td></tr><tr><td>…</td><td>…</td><td>…</td></tr></tbody></table><blockquote><p>The default delimiter is white space.</p></blockquote><h3 id="Usage"><a href="#Usage" class="headerlink" title="Usage"></a>Usage</h3><p>1、Create an instance of Scanner which can receive input from the <code>System.in</code>.</p><figure class="highlight java"><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"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="type">Scanner</span> <span class="variable">sc</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Scanner</span>(System.in);</span><br></pre></td></tr></table></figure><p>2、Use Scanner’s methods to pick up (integers、decimals、text、…) from user input.</p><figure class="highlight java"><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 class="type">int</span> <span class="variable">coffeeAmount</span> <span class="operator">=</span> sc.nextInt();</span><br><span class="line"><span class="type">double</span> <span class="variable">coffeePrice</span> <span class="operator">=</span> sc.nextDouble();</span><br><span class="line"><span class="type">String</span> <span class="variable">name</span> <span class="operator">=</span> sc.nextLine();</span><br><span class="line">...</span><br></pre></td></tr></table></figure><p>3、Once you are done with Scanner, always close it, otherwise you’re going to get a resource leak.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sc.close();</span><br></pre></td></tr></table></figure><h3 id="Debugging"><a href="#Debugging" class="headerlink" title="Debugging"></a>Debugging</h3><p>Fixing bugs in your code is called debugging, which is a must have skill for any programmer.</p><p>Debugging involves tracing the runTime step by step.</p><p>Please do not clutter your code with print statements to understand what’s going on,</p><p>use breakpoints instead !</p><h2 id="the-trap-of-nextLine"><a href="#the-trap-of-nextLine" class="headerlink" title="the trap of nextLine()"></a>the trap of nextLine()</h2><h3 id="recap"><a href="#recap" class="headerlink" title="recap"></a>recap</h3><table><thead><tr><th>method</th><th>scans for</th><th>explaination</th></tr></thead><tbody><tr><td>next()</td><td>text</td><td><strong>skips the whiteSpace</strong> and picks up the next String</td></tr><tr><td>nextLine()</td><td>text</td><td>picks up a line of data</td></tr></tbody></table><h3 id="表面现象"><a href="#表面现象" class="headerlink" title="表面现象"></a>表面现象</h3><p><code>nextLine()</code> gets skipped when placed after <code>nextInt()</code>、<code>nextLong()</code>、<code>nextDouble()</code> and <code>next()</code></p><h3 id="看清本质"><a href="#看清本质" class="headerlink" title="看清本质"></a>看清本质</h3><p>这不就是我在大一学 C 语言的时候,那个曾经让我头疼万分的所谓“没有吃回车”的问题嘛</p><p>当时我还浅浅了解了一下什么是 Shell,什么是 Shell 的缓冲区</p><h3 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h3><p>显而易见,用 <code>nextLine()</code> “吃一下残留在 Shell 的缓冲区中的回车”呗~</p><p>即:place a throwaway nextLine before the ‘real’ nextLine</p><h3 id="请阅读"><a href="#请阅读" class="headerlink" title="请阅读"></a>请阅读</h3><ul><li><p><a href="http://liupj.top/2022/05/09/single-char-io&shell-buffer/">什么是 Shell 的缓冲区</a></p></li><li><p><a href="https://stackoverflow.com/questions/22458575/whats-the-difference-between-next-and-nextline-methods-from-scanner-class">what’s-the-difference-between-next-and-nextline-methods-from-scanner-class</a></p></li></ul><p>See you in workbook 2.5</p><h1 id="Booleans-and-Conditionals"><a href="#Booleans-and-Conditionals" class="headerlink" title="Booleans and Conditionals"></a>Booleans and Conditionals</h1><p>In this section, you will gain full control over how your code runs.</p><h3 id="Roadmap-1"><a href="#Roadmap-1" class="headerlink" title="Roadmap"></a>Roadmap</h3><ol><li><p>Use conditions to control which parts of your code run.</p></li><li><p>Execute code by comaring a [value] against a list of [cases].</p></li></ol><h2 id="boolean"><a href="#boolean" class="headerlink" title="boolean"></a>boolean</h2><figure class="highlight java"><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"><span class="type">boolean</span> <span class="variable">bool1</span> <span class="operator">=</span> <span class="literal">true</span>;</span><br><span class="line"><span class="type">boolean</span> <span class="variable">bool2</span> <span class="operator">=</span> <span class="literal">false</span>;</span><br></pre></td></tr></table></figure><h3 id="Summarize-1"><a href="#Summarize-1" class="headerlink" title="Summarize"></a>Summarize</h3><table><thead><tr><th>Data Type</th><th>Value</th><th>Amount of Memory (Bytes)</th><th>Valid Range of Values</th></tr></thead><tbody><tr><td>int</td><td>Whole numbers</td><td>4</td><td>From: -2147483648 To: 2147483647</td></tr><tr><td>long</td><td>Very large whole numbers</td><td>8</td><td>From: -9223372036854775808 To: 9223372036854775807</td></tr><tr><td>double</td><td>Decimals</td><td>8</td><td>a decimal can reach 15 significant digits</td></tr><tr><td>String</td><td>Text</td><td>Varies, 24 bytes for empty text.</td><td>-</td></tr><tr><td>char</td><td>A single character</td><td>2</td><td>-</td></tr><tr><td>boolean</td><td></td><td>1</td><td>true or false</td></tr></tbody></table><h3 id="Comparison-Operators"><a href="#Comparison-Operators" class="headerlink" title="Comparison Operators"></a>Comparison Operators</h3><p><code>></code>, Greater than, returns <code>true</code> if the value on the left is greater than the value on the right.</p><p><code><</code>, Less than, returns <code>true</code> if the value on the left is less than the value on the right.</p><p><code>>=</code>, Greater than or equal to, returns <code>true</code> if the value on the left is greater than or equal to the value on the right.</p><p><code><=</code>, Less than or equal to, returns <code>true</code> if the value on the left is less than or equal to the value on the right.</p><p><code>==</code>, returns <code>true</code> if two values are equal.</p><p><code>!=</code>, returns <code>true</code> if two values are not equal.</p><h3 id="Comparing-Strings"><a href="#Comparing-Strings" class="headerlink" title="Comparing Strings"></a>Comparing Strings</h3><p>Do not use <code>==</code> or <code>!=</code> to compare strings.</p><p>Instead, you can compare one string to another by calling <code>equals()</code> from one of them.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">String</span> <span class="variable">str1</span> <span class="operator">=</span> <span class="string">"hello"</span>;</span><br><span class="line"><span class="type">String</span> <span class="variable">str2</span> <span class="operator">=</span> <span class="string">"hello"</span>;</span><br><span class="line"></span><br><span class="line">str1.equals(str2); <span class="comment">// true</span></span><br><span class="line">!str1.equals(str2); <span class="comment">// false</span></span><br></pre></td></tr></table></figure><p>You should know about how memory is being allocated. but 目前老师并没有讲</p><p>See you in workbook 3.1</p><h3 id="if-else"><a href="#if-else" class="headerlink" title="if - else"></a>if - else</h3><p>Goal: Use if - else to run specific code blocks based on various conditions.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (condition) {</span><br><span class="line"> <span class="comment">// Code runs if the condition is true</span></span><br><span class="line">} <span class="keyword">else</span> {</span><br><span class="line"> <span class="comment">// Code runs if the condition is false</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>The condition is usually the result of a comparison that returns true or false.</p><p>See you in workbook 3.2</p><hr><p>Not only can we test only one condition, but also many conditions by embedding a series of <code>else if (condition)</code> statements.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (condition) {</span><br><span class="line"> <span class="comment">// Code</span></span><br><span class="line">} <span class="keyword">else</span> <span class="keyword">if</span> (condition) {</span><br><span class="line"> <span class="comment">// Code</span></span><br><span class="line">} <span class="keyword">else</span> <span class="keyword">if</span> (condition) {</span><br><span class="line"> <span class="comment">// Code</span></span><br><span class="line">} <span class="keyword">else</span> {</span><br><span class="line"> <span class="comment">// Code</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>See you in workbook 3.3 and 3.4</p><h3 id="Logical-Operators"><a href="#Logical-Operators" class="headerlink" title="Logical Operators"></a>Logical Operators</h3><p>We can use logical operators to make our conditionals a little more complex.</p><p>There are 3 types of logical operators,</p><hr><p><code>&&</code> returns true only if both comparisons are true.</p><p>( comparison1 && comparison2 )</p><hr><p><code>||</code> returns true if either one of the comparison is true.</p><p>( comparison1 || comparison2 )</p><hr><p><code>!</code> reverses the value of a boolean expression.</p><hr><p>See you in workbook 3.5</p><h3 id="Switch-Statements"><a href="#Switch-Statements" class="headerlink" title="Switch Statements"></a>Switch Statements</h3><p>whenever you’re comparing one variable against a long list of values, such as</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (weather.equals(<span class="string">"sunny"</span>)) {</span><br><span class="line"> <span class="comment">// code</span></span><br><span class="line">} <span class="keyword">else</span> <span class="keyword">if</span> (weather.equals(<span class="string">"cloudy"</span>)) {</span><br><span class="line"> <span class="comment">// code</span></span><br><span class="line">} <span class="keyword">else</span> <span class="keyword">if</span> (weather.equals(<span class="string">"rainy"</span>)) {</span><br><span class="line"> <span class="comment">// code</span></span><br><span class="line">} <span class="keyword">else</span> {</span><br><span class="line"> <span class="comment">// code</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>you should avoid having a long list of <code>else if</code> statements, because this looks so disgusting !</p><p>Instead, you should favor using a <code>switch</code> statement which was designed to compare one variable against a list of cases.</p><figure class="highlight java"><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"><span class="keyword">switch</span> (weather) {</span><br><span class="line"> <span class="keyword">case</span> <span class="string">"sunny"</span>: <span class="comment">// code break;</span></span><br><span class="line"> <span class="keyword">case</span> <span class="string">"cloudy"</span>: <span class="comment">// code break;</span></span><br><span class="line"> <span class="keyword">case</span> <span class="string">"rainy"</span>: <span class="comment">// code break;</span></span><br><span class="line"> <span class="keyword">default</span>: <span class="comment">// code</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>Then you might be asking that when to use <code>if</code> vs <code>switch</code> ?</p><p>The only thing you can really do with <code>switch</code> is compare one variable against a list of values.</p><p><code>if</code> statement is more flexible so that suitable for complex conditions, such as when you need to compare multiple variables, they give you the flexibility to evaluate compound conditions using logical operators.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (temperature >= <span class="number">80</span> && humidity >= <span class="number">60</span>) {</span><br><span class="line"> System.out.println(<span class="string">"It's too hot and humid\n"</span>);</span><br><span class="line">} <span class="keyword">else</span> {</span><br><span class="line"> System.out.println(<span class="string">"It's comfortable\n"</span>);</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>See you in workbook 3.6 and 3.7</p><p>As you write more and more code inside <code>main()</code>, you’ll notice that it becomes increasingly cluttered and messy.</p><p>And the more code you write, the more unreadable that it becomes.</p><h3 id="Functions"><a href="#Functions" class="headerlink" title="Functions"></a>Functions</h3><p>A function is a grouping of code, it <strong>performs a task</strong>, and obviously it’s <strong>reusable</strong>.</p><p>Some functions rely on parameters to perform their task.</p><p>Some functions will return a final value.</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/image-20230423202020449.png" alt="image-20230423202020449"></p><p>Instead of writing all of your code inside of a single code block,</p><p>you can split it up into functions and call them as needed.</p><p>Let’s begin organizing your code using functions!</p><h3 id="Define-functions-and-call-them"><a href="#Define-functions-and-call-them" class="headerlink" title="Define functions and call them"></a>Define functions and call them</h3><p>See video on udemy.</p><h3 id="Notice"><a href="#Notice" class="headerlink" title="Notice"></a>Notice</h3><p>Functions’ name needs to represent the task it’s performing.</p><h3 id="Notice-1"><a href="#Notice-1" class="headerlink" title="Notice"></a>Notice</h3><p><code>public</code> means the function can be publicly accessed from any package or subfolder,</p><p>but because we’ve got only one package with a single class in it,</p><p>it doesn’t really matter what level of access you specify.</p><h3 id="Notice-2"><a href="#Notice-2" class="headerlink" title="Notice"></a>Notice</h3><p>You can notice that <code>main()</code> is also a function, it has a very similar signature to our functions.</p><p>Every function has a specific task that it performs, the <code>main()</code> function performs the task of running our application.</p><p>The <code>main()</code> function has a very specific signature that the JVM looks for when you run your app, when it finds <code>main()</code> function, it executes it.</p><h3 id="Parameters"><a href="#Parameters" class="headerlink" title="Parameters"></a>Parameters</h3><p>Functions with parameters expect to receive values.(these functions rely on parameters to perform their task)</p><p>Functions【without】parameters【do not expect】to receive values.</p><p>Parameters are essentially just variables.</p><h3 id="Arguments"><a href="#Arguments" class="headerlink" title="Arguments"></a>Arguments</h3><p>A value that you pass into a function is known as an argument.</p><p><strong>Parameters and Arguments makes functions completely reusable</strong>!</p><h3 id="Notice-3"><a href="#Notice-3" class="headerlink" title="Notice"></a>Notice</h3><p>When a function defines parameters, then in order to call it,</p><p>you need to pass in a matching number of arguments based on the position of these parameters.</p><h3 id="Return-Values"><a href="#Return-Values" class="headerlink" title="Return Values"></a>Return Values</h3><blockquote><p>You can return values from a function.</p></blockquote><h3 id="Notice-4"><a href="#Notice-4" class="headerlink" title="Notice"></a>Notice</h3><p>Bad practice: Your function handles the final result.</p><p>Good practice: Your function return the final result.</p><h3 id="Notice-5"><a href="#Notice-5" class="headerlink" title="Notice"></a>Notice</h3><p>Whenever you specify a return type,</p><p>you need to make sure that something gets returned no matter what gets passed in.</p><h3 id="Terminate-the-runTime"><a href="#Terminate-the-runTime" class="headerlink" title="Terminate the runTime"></a>Terminate the runTime</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">System.exit(<span class="number">0</span>);</span><br></pre></td></tr></table></figure><p>See you in workbook 4.3</p><h3 id="Doc-Comments"><a href="#Doc-Comments" class="headerlink" title="Doc Comments"></a>Doc Comments</h3><blockquote><p>Can be used to describe what a function does.</p></blockquote><p><strong>If you’re working in a team of developers, you should have a document for every function.</strong></p><h3 id="How-to-write-Doc-Comments"><a href="#How-to-write-Doc-Comments" class="headerlink" title="How to write Doc Comments ?"></a>How to write Doc Comments ?</h3><p>See udemy</p><p>See you in workbook 4.4</p><h3 id="Scope"><a href="#Scope" class="headerlink" title="Scope"></a>Scope</h3><blockquote><p>The scope of a variable determines its life span.</p></blockquote><p>The take home message is:<br> You can never access a variable outside the scope that it was defined in.</p><h3 id="Global-Scope"><a href="#Global-Scope" class="headerlink" title="Global Scope"></a>Global Scope</h3><p>Please against using global variables,</p><p>instead, you should keep everything local and use parameters,</p><p>because when you have too many global variables, you start losing track of what’s really going on(such as from your debugger in vscode).</p><blockquote><p>Please watch the video on udemy.</p></blockquote><h3 id="Built-in-Functions"><a href="#Built-in-Functions" class="headerlink" title="Built-in Functions"></a>Built-in Functions</h3><p>The JDK provides so many built-in functions that you can call out of the box.</p><p>But to be honest, a good developer never memorizes code!</p><p>Instead, a good developer uses the internet!<br> to read documentation.<br> to find resources.</p><p>See you in workbook 4.5</p><h3 id="Loops"><a href="#Loops" class="headerlink" title="Loops"></a>Loops</h3><p>For Loops: designed to run code a specific number of times.</p><p>While Loops: designed to run code an unknown number of times.</p><p>You will use the <code>break</code> and <code>continue</code> keywords to gain full control over your loops.</p><h3 id="For-Loops"><a href="#For-Loops" class="headerlink" title="For Loops"></a>For Loops</h3><figure class="highlight java"><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"><span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i < <span class="number">3</span>; i ++) {</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h3 id="While-Loops"><a href="#While-Loops" class="headerlink" title="While Loops"></a>While Loops</h3><p>What is a while loop ?</p><p>A while loop keeps running while a condition is true.</p><figure class="highlight java"><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"><span class="keyword">while</span> (condition) {</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>See you in workboook 5.8 ~ 5.10</p><h3 id="continue"><a href="#continue" class="headerlink" title="continue"></a>continue</h3><p>The <code>continue</code> keyword skips a run in the loop and continues with the next one.</p><h3 id="break"><a href="#break" class="headerlink" title="break"></a>break</h3><p>The <code>break</code> keyword when invoked, breaks the loop entirely.</p><h3 id="Nested-Loops"><a href="#Nested-Loops" class="headerlink" title="Nested Loops"></a>Nested Loops</h3><p>A nested loop is a loop inside of another loop.</p><p>eg: useful when working with 2D arrays.</p><figure class="highlight java"><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 class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i < <span class="number">3</span>; i++) {</span><br><span class="line"> <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">j</span> <span class="operator">=</span> <span class="number">0</span>; j < <span class="number">3</span>; j++) {</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>Arrays、2D_Arrays</p><p>Looping Arrays、Updating Arrays</p><h3 id="Arrays"><a href="#Arrays" class="headerlink" title="Arrays"></a>Arrays</h3><p>Sometimes values can be closely related and creating one variable after another can be very messy such as below.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">double</span> <span class="variable">price1</span> <span class="operator">=</span> <span class="number">5.99</span>;</span><br><span class="line"><span class="type">double</span> <span class="variable">price2</span> <span class="operator">=</span> <span class="number">6.99</span>;</span><br><span class="line"><span class="type">double</span> <span class="variable">price3</span> <span class="operator">=</span> <span class="number">7.99</span>;</span><br><span class="line"><span class="type">double</span> <span class="variable">price4</span> <span class="operator">=</span> <span class="number">8.99</span>;</span><br><span class="line"><span class="type">double</span> <span class="variable">price5</span> <span class="operator">=</span> <span class="number">9.99</span>;</span><br></pre></td></tr></table></figure><p>So what we can do is to store all of these values at the same time in an organized way which is called an array.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">double</span>[] prices = { <span class="number">5.99</span>, <span class="number">6.99</span>, <span class="number">7.99</span>, <span class="number">8.99</span>, <span class="number">9.99</span> };</span><br></pre></td></tr></table></figure><p>Although an array can hold many values, all of them have to share the same type. </p><p>For example as below, <code>integers</code> <strong>points to</strong> an array of integer values.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span>[] integers = { <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span> };</span><br></pre></td></tr></table></figure><h3 id="Talk-is-cheap"><a href="#Talk-is-cheap" class="headerlink" title="Talk is cheap"></a>Talk is cheap</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">String[] kindoms = { <span class="string">"qwe"</span>, <span class="string">"asd"</span>, <span class="string">"zxc"</span> };</span><br></pre></td></tr></table></figure><p>The truth is:</p><p>the variable <code>kingdoms</code> doesn’t store the array directly</p><p>instead</p><p>it stores a [reference] that points to it</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/202307291020173.png" alt="202307291020173"></p><figure class="highlight java"><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"><span class="comment">// You can try to compile and run this line of code,</span></span><br><span class="line"><span class="comment">// you will get a hashcode representation of the reference.</span></span><br><span class="line">System.out.println(kingdoms);</span><br></pre></td></tr></table></figure><p>and each element is stored at an index</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20230729103340.png" alt="20230729103340"></p><p>what will happen if I try to access an element outside the range of the array ?</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">System.out.println(kingdoms[<span class="number">3</span>]);</span><br></pre></td></tr></table></figure><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20230729105228.png" alt="20230729105228"></p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20230729110015.png" alt="20230729110015"></p><p>Java throws an ArrayIndexOutOfBoundsException, in essence, crashing our application, telling us that we have an error in our code —— “Index 3 is out of bounds”</p><h3 id="Preparing-to-loop-arrays"><a href="#Preparing-to-loop-arrays" class="headerlink" title="Preparing to loop arrays"></a>Preparing to loop arrays</h3><p>The <code>length</code> of an array indicates the number of items it contains.</p><figure class="highlight java"><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">String[] items = { <span class="string">"apple"</span>, <span class="string">"banana"</span>, <span class="string">"cherry"</span> };</span><br><span class="line">System.out.println(items.length); <span class="comment">// 3</span></span><br></pre></td></tr></table></figure><p>So we can use the <code>length</code> property to loop arrays.</p><h3 id="Looping-arrays"><a href="#Looping-arrays" class="headerlink" title="Looping arrays"></a>Looping arrays</h3><blockquote><p>Arrays and loops are like siblings.</p></blockquote><figure class="highlight java"><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></pre></td><td class="code"><pre><span class="line">String[] numbers = { <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span> };</span><br><span class="line"></span><br><span class="line"><span class="comment">// If you want to access each element in the array</span></span><br><span class="line"><span class="comment">// Would you perfer to index them all individually ?</span></span><br><span class="line">numbers[<span class="number">0</span>]</span><br><span class="line">numbers[<span class="number">1</span>]</span><br><span class="line">numbers[<span class="number">2</span>]</span><br><span class="line">numbers[<span class="number">3</span>]</span><br><span class="line">numbers[<span class="number">4</span>]</span><br><span class="line">numbers[<span class="number">5</span>]</span><br><span class="line"><span class="comment">// or use some kind of loop that iterates through every single element in the array ?</span></span><br><span class="line"><span class="comment">// I think the looping approach would be more efficient.</span></span><br></pre></td></tr></table></figure><figure class="highlight java"><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"><span class="comment">// Print the elements of an integer array using a loop</span></span><br><span class="line"><span class="type">int</span>[] numbers = {<span class="number">22</span>, <span class="number">24</span>, <span class="number">26</span>, <span class="number">29</span>, <span class="number">30</span>};</span><br></pre></td></tr></table></figure><h3 id="for-循环"><a href="#for-循环" class="headerlink" title="for 循环"></a>for 循环</h3><figure class="highlight java"><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 class="comment">// autoComplete a for loop in vscode: fori<ENTER></span></span><br><span class="line"><span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i < numbers.length; i++) {</span><br><span class="line"> System.out.println(numbers[i]);</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h4 id="foreach-循环"><a href="#foreach-循环" class="headerlink" title="foreach 循环"></a>foreach 循环</h4><p>foreach simplifies looping through an array without the need for a counter or a counter increment or anything.</p><figure class="highlight java"><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 class="comment">// autoComplete a foreach loop in vscode: fore<ENTER></span></span><br><span class="line"><span class="keyword">for</span> (<span class="type">int</span> number : numbers) {</span><br><span class="line"> System.out.println(number);</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>It just automatically iterates through every single number inside of the numbers array.</p><p>So as you can see, foreach is much cleaner and concise than the traditional for loop,</p><p>but the traditional for loop is more flexible because the counter <code>i</code> give us more control over the looping process.</p><p>I’m a bit tired of using loops to print an array,</p><p>Java has a function called <code>toString</code>, it takes your array as an argument, and it returns a string that we can print.</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/toString.png" alt="toString"></p><h3 id="Updating-Arrays"><a href="#Updating-Arrays" class="headerlink" title="Updating Arrays"></a>Updating Arrays</h3><blockquote><p>It’s time to learn how to update arrays.</p></blockquote><figure class="highlight java"><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">String[] flavours = { <span class="string">"Sweet"</span>, <span class="string">"Sour"</span>, <span class="string">"Bitter"</span> };</span><br><span class="line">flavours[<span class="number">2</span>] = <span class="string">"Salty"</span>;</span><br></pre></td></tr></table></figure><h3 id="Is-it-possible-to-change-the-array-length"><a href="#Is-it-possible-to-change-the-array-length" class="headerlink" title="Is it possible to change the array length ?"></a>Is it possible to change the array length ?</h3><p>NO.</p><p>Once you create an array, you cannot resize it.</p><figure class="highlight java"><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">String[] menu = { <span class="string">"Espresso"</span>, <span class="string">"Iced Coffee"</span>, <span class="string">"Latte"</span> };</span><br><span class="line">String[] newMenu = <span class="keyword">new</span> <span class="title class_">String</span>[<span class="number">5</span>];</span><br></pre></td></tr></table></figure><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/newMenu.png" alt="newMenu"></p><figure class="highlight java"><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"><span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i < menu.length; i++) {</span><br><span class="line"> newMenu[i] = menu[i];</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h3 id="The-reference-trap"><a href="#The-reference-trap" class="headerlink" title="The reference trap"></a>The reference trap</h3><blockquote><p>I told you earlier that a variable cannot store an array, it stores a reference that points to it.</p><p>Because of this, another variable can actually store a reference that points to the same array.</p></blockquote><figure class="highlight java"><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"><span class="type">int</span>[] numbers = { <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span> };</span><br><span class="line"><span class="type">int</span>[] numbers2 = numbers;</span><br></pre></td></tr></table></figure><p>Do not set array variables equal to each other!</p><p>Instead, create a new array, then, copy every value using a for loop.</p><h3 id="A-better-solution"><a href="#A-better-solution" class="headerlink" title="A better solution"></a>A better solution</h3><p>Arrays.copyOf(a, b);</p><p><code>a</code> means that the array you want to copy.</p><p><code>b</code> means that how much of it you want to copy.</p><h3 id="2D-Arrays"><a href="#2D-Arrays" class="headerlink" title="2D Arrays"></a>2D Arrays</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span>[][] grades = {</span><br><span class="line"> {<span class="number">72</span>, <span class="number">74</span>, <span class="number">78</span>, <span class="number">76</span>},</span><br><span class="line"> {<span class="number">65</span>, <span class="number">64</span>, <span class="number">61</span>, <span class="number">67</span>},</span><br><span class="line"> {<span class="number">95</span>, <span class="number">98</span>, <span class="number">99</span>, <span class="number">96</span>}</span><br><span class="line">};</span><br></pre></td></tr></table></figure><h3 id="When-to-work-with-2D-arrays"><a href="#When-to-work-with-2D-arrays" class="headerlink" title="When to work with 2D arrays ?"></a>When to work with 2D arrays ?</h3><blockquote><p>2D arrays is perfect for data in the form of a table.</p></blockquote><figure class="highlight java"><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"><span class="type">int</span>[][] integers = <span class="keyword">new</span> <span class="title class_">int</span>[<span class="number">3</span>][<span class="number">4</span>]; <span class="comment">// 3 行 4 列</span></span><br><span class="line">System.out.println(Arrays.toString(grades[<span class="number">0</span>])); <span class="comment">// [0, 0, 0, 0]</span></span><br></pre></td></tr></table></figure><h3 id="arrays-and-loops-are-like-siblings"><a href="#arrays-and-loops-are-like-siblings" class="headerlink" title="arrays and loops are like siblings"></a>arrays and loops are like siblings</h3><ul><li><p>nested loops</p><ul><li>outer loop runs through every row (i)</li><li>inner loop runs through every item in that row</li></ul> <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i < grades.length; i++) {</span><br><span class="line"> <span class="keyword">for</span> (j = <span class="number">0</span>; j < grades[i].length; j++) {</span><br><span class="line"> <span class="comment">// ...</span></span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure></li></ul>]]></content>
<summary type="html"><p><a href="https://www.bilibili.com/video/BV1c54y1U7pp">初学编程的常见误区</a></p>
<p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/i</summary>
</entry>
<entry>
<title>公司内部培训笔记</title>
<link href="https://liupj.top/2023/12/03/structuredExpression/"/>
<id>https://liupj.top/2023/12/03/structuredExpression/</id>
<published>2023-12-03T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>21世纪的 5 大生产要素:[数据]、土地、劳力、技术、资金</p><p>数据治理/运营是一种硬技能</p><h3 id="做解决方案的思路"><a href="#做解决方案的思路" class="headerlink" title="做解决方案的思路"></a>做解决方案的思路</h3><ol><li><p>让用户感受到我们了解他们行业,并且很专业(用户不愿意听一个外行的聒噪)</p></li><li><p>描述清楚客户的核心问题</p></li><li><p>针对性地提出方案</p></li><li><p>讲出用户和我们合作的理由(我们是很专业的)</p></li><li><p>口说无凭,给出我们做过的成功案例</p></li></ol><h3 id="用结构化的方式进行思考、表达"><a href="#用结构化的方式进行思考、表达" class="headerlink" title="用结构化的方式进行思考、表达"></a>用结构化的方式进行思考、表达</h3><p>Tips:思考的过程中应拿笔将思考出的结构用笔写下来,进而进一步分析</p><p>读观点传达类的文章可以对文章进行解构分析,然后建构,以清楚全面了解文章观点</p><p>学习别人的PPT可以先解构,再建构,为我所用</p><p><strong>解构4步法:PUTS</strong></p><ul><li>P:means pick,即提取要点</li><li>U:means unit,即分组整理</li><li>T:means track,即查找关联,画出结构树状图</li><li>S:means summary,即总结概括</li></ul><p><strong>建构4原则:PGOS 树状图</strong></p><ul><li>P:结论前置</li><li>G:共性分组</li><li>O:先后排序</li><li>S:上下对应</li></ul><h3 id="典型场景的结论撰写公式"><a href="#典型场景的结论撰写公式" class="headerlink" title="典型场景的结论撰写公式"></a>典型场景的结论撰写公式</h3><ul><li>计划型:准备做…. + 预期目标(结果)</li><li>解释型:因为…… + 准备做…</li><li>状态型:已进行到.. + 当前状态/阶段成果</li><li>总结型:….已完成 + 结果/影响是…</li><li>建议型:应该做…. + 以达到..目的/效果</li><li>表态型:我认为…. + 因为…的原因</li></ul><h3 id="营销的一种结构"><a href="#营销的一种结构" class="headerlink" title="营销的一种结构"></a>营销的一种结构</h3><ul><li>你的目的是:递观点<ul><li>讲故事</li><li>述情怀</li></ul></li></ul>]]></content>
<summary type="html"><p>21世纪的 5 大生产要素:[数据]、土地、劳力、技术、资金</p>
<p>数据治理&#x2F;运营是一种硬技能</p>
<h3 id="做解决方案的思路"><a href="#做解决方案的思路" class="headerlink" title="做解决方案的思路"></</summary>
</entry>
<entry>
<title>颓废文学</title>
<link href="https://liupj.top/2023/11/19/relax/"/>
<id>https://liupj.top/2023/11/19/relax/</id>
<published>2023-11-19T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<ul><li><p>正义都能迟到,为什么我上班不能迟到</p></li><li><p>比我优秀的人都在努力,那我努力还有什么用</p></li><li><p>干一行,恨一行,三百六十行,行行干破防</p></li><li><p>安慰别人一套一套,安慰自己绳子一套</p></li><li><p>天生我材必有用,至今不知有何用</p></li><li><p>轻舟已过万重山,乌蒙山连着山外山</p></li><li><p>明知山有虎,不去明知山</p></li><li><p>任何困难都可以直接克服我</p></li><li><p>希望大家都能走出舒适圈,然后让我进去</p></li><li><p>生活不是无路可走,还有死路一条</p></li><li><p>…</p></li></ul>]]></content>
<summary type="html"><ul>
<li><p>正义都能迟到,为什么我上班不能迟到</p>
</li>
<li><p>比我优秀的人都在努力,那我努力还有什么用</p>
</li>
<li><p>干一行,恨一行,三百六十行,行行干破防</p>
</li>
<li><p>安慰别人一套一套,安慰自己绳子一套<</summary>
</entry>
<entry>
<title>早起奔向面馆(转载)</title>
<link href="https://liupj.top/2023/09/10/eat-fish-noddle-at-morning/"/>
<id>https://liupj.top/2023/09/10/eat-fish-noddle-at-morning/</id>
<published>2023-09-10T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<blockquote><p>很喜欢这篇文章,所以转载到我的小站了,如有侵权请联系我<br>原文链接:<a href="https://www.yilinzazhi.com/2023/yl20231/2023111246.html">https://www.yilinzazhi.com/2023/yl20231/2023111246.html</a></p></blockquote><p>鱼面分离的长鱼汤面是小面馆的绝活儿,长鱼就是鳝鱼。一大碗汤面配上一小碟鳝鱼,足以作为一天的元气补给。汤面由青花瓷碗盛着,浸在奶白色泽的汤里。如果顾客无食忌,王师傅会加些葱花或韭菜提鲜。这碗汤,王师傅头天下午便开始熬。</p><p>这个熬可大有讲究,熬汤先熬骨。凌晨四点钟不到,已经开始忙活的王师傅加入鳝鱼片接着吊汤。直到清晨六点钟,汤熬毕,面备齐,小镇的八方食客也在来吃面的路上了。</p><p>“王师傅早!”“早上好!”王师傅利落地盛汤、盛面、迎客、送客。让我想起第一次看他“庖王片鳝”,原本呈二角面的鳝鱼骨头在王师傅手里瞬时变得不一样起来,似乎有了神圣的色彩。王师傅头一刀从鱼头扎下去,急速沿鱼肚破开,接着沿骨剖开,末了再来一刀,一条干净齐整的鱼骨就在这三刀间成功脱了鱼肉。后来熟悉了小面馆,熟悉了王师傅,知道他就是这样一个干净齐整的人,案板总是清清爽爽,菜码也是秩序分明。简单的汤面,鳝鱼摆盘,他也尽可能在最短的时间拾掇得适宜、美观。我夸他认真,他一边片他的鳝鱼,一边笑道:“日子不就是这样过的吗?”</p><p>日子一日三餐地过,举筷间我们一家人总要聊起小面馆,聊起认真过日子的王师傅。外公说:“做工作就要像老王,带劲!”他的确是带劲的,想来很大程度上缘于他有个好环境。在哪里工作,哪就是自己的领地。既然是领地,哪能潦草呢?除了“字典”里基本的整洁,王师傅还给自己的小面馆装了几盏灯。除了负责让店面更亮堂的暖黄灯管,还有星星一样的装饰灯,也是暖光的。他很得意地告诉我,这是他从儿子课本上看来的,书上说暖色调会刺激人的食欲。</p><p>用王师傅的话说“忙总要忙出名堂来的”。其实,他追求的也不过四个字——“健康美味”,只不过他从未搞错这两个词的顺序。王师傅不怕麻烦,我早就见识过,该先熬魚骨就先熬鱼骨,该下鱼肉了才下鱼肉,该几个小时就几个小时。直到准确的步骤和恰到好处的时间让鱼骨里的胶质毫无保留地煨在汤中,进入每个食客的胃中,暖身暖心,最终久久地写入他们的味蕾记忆。王师傅还不怕浪费,后来外公说起,我才知道他总是挑好的、贵的食材,从不吝啬。</p><p>一次,王师傅念小学的儿子给他打下手,小家伙一个没夹稳,食客要的荷包蛋“啪”的一声掉在了案板上,儿子拾起来就要往水池走,应该是想洗干净。王师傅停下手中的活儿,指着墙角的垃圾桶,说道:“扔掉。”得到大众认可总是有其道理的,而得到大家伙儿的肯定,除了能收获一众老客,还能收获满满的干劲。</p><p>在王师傅的小面馆里,的确蕴藏着极盛大的认真,大清早世界刚刚苏醒,他已带着足足的干劲盛汤、盛面、迎客、送客。热气扑向他,把他衬得像个早间厨神,好像人间千家万户的早餐,全都仰仗着他这双带劲的路膊。</p><p>我大喝一口乳白色的鲜鱼汤,由它把我体内的一个个器官朋友彻底激活。在早上急匆匆的城市大背景里选择稳当坐下来,认真吃一碗热腾腾、鲜入骨的长鱼汤面,也是我过日子所坚持的认真。</p>]]></content>
<summary type="html"><blockquote>
<p>很喜欢这篇文章,所以转载到我的小站了,如有侵权请联系我<br>原文链接:<a href="https://www.yilinzazhi.com/2023/yl20231/2023111246.html">https://www.yilinzazhi</summary>
</entry>
<entry>
<title>夜爬泰山有感</title>
<link href="https://liupj.top/2023/06/24/mountTai/"/>
<id>https://liupj.top/2023/06/24/mountTai/</id>
<published>2023-06-24T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>因为网上别人发表的攻略给了我不少帮助,所以我也决定写下这篇攻略,分享给大家</p><p>说实话,夜爬泰山之后,我是有些后怕的,为了大家的安全着想,我要先写一下此次夜爬我感受到的危险</p><p>我没有数我到底爬了多少级台阶,但据网友反映泰山大致需要爬六七千级台阶(但我觉得这每一级台阶都比普通住宅楼里的台阶更窄、更陡、更不平)</p><p>端午假期游人众多,十有八九都是二十啷当岁初生牛犊不怕虎的年轻人,达到了人挤人的状态,众多的爬山人和漆黑的夜色给山路增加了不少危险性</p><p>因为台阶上会有空的矿泉水瓶、西瓜皮、水果核,甚至还会有别人遗弃的登山杖,这些东西会向山下掉落,而你很难时刻注意你脚下的真实情况</p><p>一旦不小心踩住或绊住,就特别容易摔跤(下山路上不少台阶上已经干了的暗红色血迹真的让人不寒而栗)</p><p>而在人挤人的情况下,摔跤就变得更加危险,无论是自己摔跤还是别人摔跤,都极易造成连锁反应(幸好我没遇到)</p><p>另外,如果你爬到半山腰想放弃,你会进退两难,你只能向山路两边的护栏和岩石靠拢,而部分爬不动的人放倒在地面上的登山杖又容易绊倒上山的人</p><p>渴、饿、累、困、冷、拉肚子、低血糖,还有其他情况在高山上的夜晚都可能出现,商店很多,厕所不多,没有医院</p><p>另外,上山容易下山难,这是亘古不变的真理!!!</p><p>看到这里如果你觉得你可以,我要开始安利了</p><h3 id="上山之前"><a href="#上山之前" class="headerlink" title="上山之前"></a>上山之前</h3><p>你可以像我一样,下午去山东农大旁边的清真寺街吃当地的特色美食——姜片炒鸡</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/WechatIMG13.jpeg" alt="WechatIMG13"></p><p>清真寺街的许家姜片炒鸡很好吃也很适合作为上山前补充体力的食物</p><p>鸡肉外香里嫩干而不柴,姜片是油炸过的,薄脆像薯片,很适合我这种不喜欢姜味的人哈哈哈哈哈</p><p>老板娘年轻美丽,长得像我高中语文老师,掌柜的慈眉善目和蔼可亲,看起来人很正派,希望他们家红火</p><p>我吃了一只炒鸡一碗大米半份蒜泥黄瓜,昏昏欲睡。。</p><p>那就去红门游客中心旁边开个房吧,钟点房一小时 20 元,一觉醒来八点半了。。</p><p>九点多向山顶进发!</p><h3 id="爬山途中"><a href="#爬山途中" class="headerlink" title="爬山途中"></a>爬山途中</h3><p>一路上我竟然没有一丝困意,大概是太想登顶了吧,虽然我一直在出汗,一直在补水,到中天门没忍住,吃了两块西瓜</p><p>反正周围一片漆黑全是人啥风景也看不到,心中只有一个目标,冲向山顶!</p><p>早知道就不带风油精了,蚊子大概不知道该咬谁吧,全是人。。</p><p>脑海里竟然出现了角马大迁徙的场景,那个画面。。我们就是英勇无畏的角马!</p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/WechatIMG17.jpeg" alt="soMuchPeople" height="228"><p>登山杖立起来啊朋友们我都害怕踩到前面人的登山杖。。</p><h3 id="登顶了!"><a href="#登顶了!" class="headerlink" title="登顶了!"></a>登顶了!</h3><p>在一个看起来人不多的地方坐了下来,面前是齐鲁大地灯火辉煌的夜景,好令人震撼啊,打开手机指南针一看,正西。。</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/WechatIMG16.jpeg" alt="WechatIMG16"></p><p>溜了溜了</p><p>果不其然,正东已经坐下了两三排人,一点多啊,我还以为我来早了。。</p><p>看到一个空位,两边都是小姐姐。。我滴妈呀。。问了一句她们竟然是同伴。。友善的小姐姐给我挪了个位置,小姐姐真好啊,带了薄荷口香糖提神用的,问她吃不吃,好像把我当坏人了。。防人之心不可无啊。。</p><p>山风一阵阵的,这届大学生果然优秀,我们喊着口号“青春没有售价,泰山就在脚下!” 啊!心情舒畅!</p><video width="320" height="240" controls> <source src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/videos/mountTai.mp4" type="video/mp4"> 您的浏览器不支持Video标签。</video><p>扛旗的小伙子真酷啊!美丽的五星红旗在泰山之顶迎风飘荡,我们唱起了国歌!</p><p>租件大衣看来是正确的,山风一阵一阵的,没风的时候热,吹风的时候冷,嗨,还是穿着吧。。</p><p>好久没有看到过这么多的星星了啊,感觉真美好,可是星星不够亮,手机拍不出来。。</p><p>天蒙蒙亮了!岩石上一个小哥哥播放了下面这首歌,感谢他</p><audio controls> <source src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/musics/xiangYunDuan.mp3" type="audio/mpeg"> Your browser does not support the audio element.</audio><p>泰山之巅的启明星叫醒了不知名的鸟儿,歌声婉转,我的头顶还飞过了几只小蜜蜂,到底是谁喊了一句“md还有苍蝇”</p><p>远处的云竟然像一个齐平的大幕,太阳像一个烙红的热铁,又像一盏刚点亮的路灯,从云深处慢悠悠巍然而起</p><p>清晨的太阳变化很快,不一会儿就变得像一个顶着金色帽子的红色真知棒</p><p>前面的人开始下山,后面的人举着镜头向前,我开始饿了,找了个安全的地方开始补充体力,夜晚没看到的风景我要在凉爽的早晨补回来!</p><p>和一个刚毕业的小哥哥聊天了,我感觉他好有礼貌好帅气好紧张,我说我不年轻了,他说我心态年轻。。没毛病 95 后已经干不过 00 后了。。</p><p>我还是很感激他,告诉了我厕所在哪里,虽然我去了另一个厕所。。</p><p>在山顶休整了两个小时,山上开始变得冷清,我开始欣赏清晨的泰山景色,啊,山川大好,大好河山!</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/WechatIMG14.jpeg" alt="WechatIMG14"></p><p>我在泰山顶的岩石上晾晒我湿了的衣服,心想咱也是在泰山顶上晾过衣服的人了哈哈哈</p><p>有个零零后的小男生翻过了护栏让他朋友拍照,脚的旁边就是万丈悬崖,我看得好害怕,友善提醒了一句,他没听,幸好他安全翻回来了</p><p>别做傻事啊朋友们,青春价虽高,生命诚可贵,也可能是我太胆小了吧,但我觉得小心驶得万年船</p><p>我看到有一家人也在山顶玩耍,感觉素质很高,孩子丢下的垃圾都捡走了,给他们点赞,朋友们在保证安全的情况下尽量别乱丢垃圾啊,清洁工很辛苦,泰山奶奶不容易</p><p>我和他们一起聊着天下山了,他们竟然也从天津来,本来说要一起去坐索道,但是我不想排队了,就下山去中天门了</p><p>下山路上的风景真好啊,空气看起来就特别清新的样子,呼吸让人舒畅</p><p>坐索道的人应该会看到不一样的风景吧</p><p>坐着大巴下山了,这个盘山路真刺激啊,窄窄的双行道只有两个大巴的宽度,连续不断的大巴车擦身而过,司机师傅太牛了</p><p>车上超级安静,司机超级淡定,我超级亢奋,这比跑跑卡丁车都刺激</p><p>到了山下手机信号才变好了,去的时候带点一块的纸币爬山路上用得着啊朋友们</p><p>拜拜泰山,拜拜沿路遇到的每一个友善的人</p><blockquote><p>下次再来</p></blockquote><p>手机,充电线,充电宝,身份证,家里的钥匙,纸币零钱(山路上人多信号不好买补给用)</p><p>usb充电式强光手电,保暖衣物,小包卫生纸,面包(山顶的早餐)</p><p>备一点应急药物也是 ok 的</p>]]></content>
<summary type="html"><p>因为网上别人发表的攻略给了我不少帮助,所以我也决定写下这篇攻略,分享给大家</p>
<p>说实话,夜爬泰山之后,我是有些后怕的,为了大家的安全着想,我要先写一下此次夜爬我感受到的危险</p>
<p>我没有数我到底爬了多少级台阶,但据网友反映泰山大致需要爬六七千级台阶(但我觉</summary>
</entry>
<entry>
<title>简单学了一下 python 脚本编程</title>
<link href="https://liupj.top/2023/04/01/py_takeaway_message/"/>
<id>https://liupj.top/2023/04/01/py_takeaway_message/</id>
<published>2023-04-01T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>learn from: <a href="https://learn.udacity.com/courses/ud1110">https://learn.udacity.com/courses/ud1110</a></p><h2 id="A-scripter-to-solve-problem"><a href="#A-scripter-to-solve-problem" class="headerlink" title="A scripter to solve problem"></a>A scripter to solve problem</h2><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></pre></td><td class="code"><pre><span class="line">repeat:</span><br><span class="line"></span><br><span class="line"> try it the slow way to understand what you are trying to achieve</span><br><span class="line"> do some learning(remember to look up documentation)</span><br><span class="line"></span><br><span class="line"> break up the problem into steps</span><br><span class="line"> choose data_types、control_flows、...</span><br><span class="line"> write down your pseudo_code</span><br><span class="line"></span><br><span class="line"> write code & test code</span><br></pre></td></tr></table></figure><h2 id="why-you-should-choose-data-type"><a href="#why-you-should-choose-data-type" class="headerlink" title="why you should choose data_type"></a>why you should choose data_type</h2><p>An object’s type defines which operators and functions will work on that object and how they work,</p><p>different types have different properties,</p><p>so when you’re designing on computer program,</p><p>you need to choose types for your data based on how you’re going to use them.</p><p>For example, if you want to use a number as a part of a sentence in Python,</p><p>it’ll be easiest if that number is a string,</p><p>because there are specially designed operators and functions for working with these data.</p>]]></content>
<summary type="html"><p>learn from: <a href="https://learn.udacity.com/courses/ud1110">https://learn.udacity.com/courses/ud1110</a></p>
<h2 id="A-scripter-to-sol</summary>
</entry>
<entry>
<title>如何购买国外的课程(在中国)</title>
<link href="https://liupj.top/2023/03/28/how-to-buy-courses-on-udemy-in-china/"/>
<id>https://liupj.top/2023/03/28/how-to-buy-courses-on-udemy-in-china/</id>
<published>2023-03-28T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>先看看这篇文章:<a href="https://zhuanlan.zhihu.com/p/43166346">从支付、购买到售后:Google Play 购物指南</a></p><p>ok, 我选择使用【礼品卡】的付款方式</p><h2 id="使用的设备"><a href="#使用的设备" class="headerlink" title="使用的设备"></a>使用的设备</h2><p>macbook、iqoo-z5</p><h2 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h2><p>我的每台设备均可以正常访问 google</p><p>读者可以各显神通以获得速度良好的外网访问权限</p><h2 id="安卓手机如何下载-play-商店"><a href="#安卓手机如何下载-play-商店" class="headerlink" title="安卓手机如何下载 play 商店"></a>安卓手机如何下载 play 商店</h2><p>下载渠道:apkmirror.com</p><p>参考了这个视频:<a href="https://www.youtube.com/watch?v=isERiuP5xTY">https://www.youtube.com/watch?v=isERiuP5xTY</a></p><h2 id="安卓手机通过验证码验证谷歌账号时若不显示验证码的输入框怎么办"><a href="#安卓手机通过验证码验证谷歌账号时若不显示验证码的输入框怎么办" class="headerlink" title="安卓手机通过验证码验证谷歌账号时若不显示验证码的输入框怎么办"></a>安卓手机通过验证码验证谷歌账号时若不显示验证码的输入框怎么办</h2><p>将手机的【验证码安全保护】关闭即可,可在手机设置中搜索</p><p>感谢<a href="https://www.bilibili.com/video/av423953969/">这个视频</a>的评论区给予的帮助</p><h2 id="在哪购买礼品卡"><a href="#在哪购买礼品卡" class="headerlink" title="在哪购买礼品卡"></a>在哪购买礼品卡</h2><p>淘宝搜索【play 礼品卡】</p><p>根据自己需要哪个国家或地区的💰来选择购买礼品卡</p><p>笔者礼品卡购于咸鱼,使用方式可询问卖家</p><p>done</p>]]></content>
<summary type="html"><p>先看看这篇文章:<a href="https://zhuanlan.zhihu.com/p/43166346">从支付、购买到售后:Google Play 购物指南</a></p>
<p>ok, 我选择使用【礼品卡】的付款方式</p>
<h2 id="使用的设备"><a h</summary>
</entry>
<entry>
<title>记录我上手使用 Macbook Air M1 的过程</title>
<link href="https://liupj.top/2023/03/18/macos-m1-setup/"/>
<id>https://liupj.top/2023/03/18/macos-m1-setup/</id>
<published>2023-03-18T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>2023-03-18, 我收到了我人生中第一台 MacBook Air M1</p><p>由于这是我第一次使用 macos,所以我打算记录下我上手 macos 的过程</p><p>希望将它慢慢打造成适合我的一把利器,那就开始吧</p><p>进入桌面前的初始化设置操作就自己弄吧,原则:最小化设置</p><h3 id="设置触控板"><a href="#设置触控板" class="headerlink" title="设置触控板"></a>设置触控板</h3><p>点击屏幕左上角苹果 logo,然后选择系统设置,然后在打开的窗口的左侧边栏中下拉选择触控板</p><p>跟踪速度自行调整,勾选轻点来点按</p><h3 id="设置键盘"><a href="#设置键盘" class="headerlink" title="设置键盘"></a>设置键盘</h3><p>由于我是 Vim 重度用户,所以习惯性将 Caps Lock 键设置为 Escape 键</p><p>系统设置 =》键盘 =》闲置后关闭键盘背光灯(5分钟后)=》键盘快捷键 =》修饰键 =》大写锁定键更改为 Escape 键 =》完成</p><p>设置三指拖移:系统设置 =》辅助功能 =》指针控制 =》触控板选项 =》打开“使用触控板进行拖移”(或“启用拖移”)=》选取“三指拖移”拖移样式</p><p>=》好</p><h3 id="安装一些应用程序"><a href="#安装一些应用程序" class="headerlink" title="安装一些应用程序"></a>安装一些应用程序</h3><p>qq音乐、微信,腾讯会议,阿里云盘,…</p><h3 id="科学上网"><a href="#科学上网" class="headerlink" title="科学上网"></a>科学上网</h3><p>节点 + <a href="https://github.com/yichengchen/clashX/releases">clashX</a> 开启系统代理</p><p>单独给 Terminal.app 设置代理</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></pre></td><td class="code"><pre><span class="line">export http_proxy=http://127.0.0.1:7890</span><br><span class="line">export https_proxy=http://127.0.0.1:7890</span><br><span class="line">export all_proxy=socks5://127.0.0.1:7890</span><br></pre></td></tr></table></figure><h3 id="打造命令行"><a href="#打造命令行" class="headerlink" title="打造命令行"></a>打造命令行</h3><p>包管理器:<a href="https://brew.sh/">brew</a></p>]]></content>
<summary type="html"><h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>2023-03-18, 我收到了我人生中第一台 MacBook Air M1</p>
<p>由于这是我第一次使用 macos,所以我打算记录</summary>
</entry>
<entry>
<title>zerotier 简明教程</title>
<link href="https://liupj.top/2023/01/31/zerotier/"/>
<id>https://liupj.top/2023/01/31/zerotier/</id>
<published>2023-01-31T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>一台 ArchLinux 放家里,一台 Windows10 放单位</p><p>用 zerotier 将这俩机器放到一个虚拟局域网</p><p>用 ssh 就能相互访问</p><h3 id="用-zerotier-创建一个私有的-private-虚拟局域网,获取到网络ID"><a href="#用-zerotier-创建一个私有的-private-虚拟局域网,获取到网络ID" class="headerlink" title="用 zerotier 创建一个私有的(private)虚拟局域网,获取到网络ID"></a>用 zerotier 创建一个私有的(private)虚拟局域网,获取到网络ID</h3><p><a href="https://my.zerotier.com/">https://my.zerotier.com/</a></p><p>创建私有网络的好处是:任何机器想加入该网络都需要获得你的许可</p><h3 id="ArchLinux-设置步骤"><a href="#ArchLinux-设置步骤" class="headerlink" title="ArchLinux 设置步骤"></a>ArchLinux 设置步骤</h3><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></pre></td><td class="code"><pre><span class="line">sudo pacman -S zerotier-one</span><br><span class="line">sudo systemctl <span class="built_in">enable</span> --now zerotier-one.service</span><br><span class="line">sudo zerotier-cli <span class="built_in">join</span> 网络ID</span><br></pre></td></tr></table></figure><h3 id="Windows10-设置步骤"><a href="#Windows10-设置步骤" class="headerlink" title="Windows10 设置步骤"></a>Windows10 设置步骤</h3><p>下载地址:<a href="https://www.zerotier.com/download/">https://www.zerotier.com/download/</a></p><p>启动 zerotier,加入网络</p><h3 id="最后"><a href="#最后" class="headerlink" title="最后"></a>最后</h3><p>到 <a href="https://my.zerotier.com/">https://my.zerotier.com/</a> 对成员节点勾选授权</p><p>ok,至此,两台机器可以<a href="http://liupj.top/2022/05/20/ssh-ubuntu/">通过 ssh 相互访问</a>了</p><h3 id="参考了"><a href="#参考了" class="headerlink" title="参考了"></a>参考了</h3><p><a href="https://www.zerotier.com/manual/">https://www.zerotier.com/manual/</a></p><p><a href="https://jiajunhuang.com/articles/2019_09_11-zerotier.md.html">https://jiajunhuang.com/articles/2019_09_11-zerotier.md.html</a></p>]]></content>
<summary type="html"><h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>一台 ArchLinux 放家里,一台 Windows10 放单位</p>
<p>用 zerotier 将这俩机器放到一个虚拟局域网</p></summary>
</entry>
<entry>
<title>分享一道计算机网络的经典面试题(关于为什么网络层地址和 MAC 地址共存)</title>
<link href="https://liupj.top/2023/01/30/mac-ip/"/>
<id>https://liupj.top/2023/01/30/mac-ip/</id>
<published>2023-01-30T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<h3 id="有了-MAC-地址,为什么还需要-IP-地址-?"><a href="#有了-MAC-地址,为什么还需要-IP-地址-?" class="headerlink" title="有了 MAC 地址,为什么还需要 IP 地址 ?"></a>有了 MAC 地址,为什么还需要 IP 地址 ?</h3><p>计算机网络诞生之初,只是一个个小的局域网,还没有形成如今的互联网;</p><p>局域网内的计算机之间通信,需要对每个计算机进行唯一标识,所以就诞生了 MAC 地址。</p><p>随着计算机网络的发展,局域网之间开始互联互通,产生了计算机跨网络通信的需求;</p><p>试想,假设局域网 A 内的主机 A1 想要发送数据包给局域网 B 内的主机 B1</p><p>若 A1 只知道 B1 的 MAC 地址,显然 A1 无法知道应该将数据包发往哪个网络</p><p>即:MAC 地址并不具备标识网络的作用</p><p>所以,能够标识网络的 IP 地址诞生</p><hr><h3 id="既然-IP-地址的定位是标识网络,那么为什么要把-IP-地址设计成既能标识网络,又能标识主机-?"><a href="#既然-IP-地址的定位是标识网络,那么为什么要把-IP-地址设计成既能标识网络,又能标识主机-?" class="headerlink" title="既然 IP 地址的定位是标识网络,那么为什么要把 IP 地址设计成既能标识网络,又能标识主机 ?"></a>既然 IP 地址的定位是标识网络,那么为什么要把 IP 地址设计成既能标识网络,又能标识主机 ?</h3><p>举个例子,假设局域网 A 内的主机 A1 想要发送数据包给局域网 B 内的主机 B1</p><p>假设A1 只知道 B1 的 IP 地址</p><p>如果 IP 地址只能标识网络,那么 A1 就只能将数据包发往目的网络,然后数据包就不知该何去何从了</p><p>所以 IP 地址既要能标识网络,又要能标识主机</p><hr><h3 id="既然有了-IP-地址,为什么还要有-MAC-地址-?或者说只靠-IP-地址进行互联网通信行不行-?"><a href="#既然有了-IP-地址,为什么还要有-MAC-地址-?或者说只靠-IP-地址进行互联网通信行不行-?" class="headerlink" title="既然有了 IP 地址,为什么还要有 MAC 地址 ?或者说只靠 IP 地址进行互联网通信行不行 ?"></a>既然有了 IP 地址,为什么还要有 MAC 地址 ?或者说只靠 IP 地址进行互联网通信行不行 ?</h3><blockquote><p>参考了:<a href="http://liupj.top/2022/04/04/ether-net/">http://liupj.top/2022/04/04/ether-net/</a></p></blockquote><p>如果没有 MAC 地址,而是使用网络层协议进行通信,理论上来说是可以的,但是不好</p><p>因为在<a href="http://liupj.top/2022/04/04/ether-net/">以太网</a>诞生之初,IP 还没有垄断网络层协议(那时还有Novell网的IPX/SPX协议、DEC公司开发的CLNP网络协议,以及Apple公司开发的Apple Talk协议)</p><p>如果没有 MAC 地址,势必需要网卡解读网络层协议帧头的地址信息,而不同网络层协议帧头的地址都大相径庭,这就增加了以太网卡的实现复杂度。</p><p>如果网卡有了 MAC 地址,就可以不依赖于任何网络层协议,独立判断一个帧是否接收(依据 MAC 地址匹配),这就大大简化了网卡的实现。</p><p>即使以后出现更多的网络层协议,网卡也无需太多的改变,这就是网络分层的精髓</p><p>一层的内部实现无需知晓其上层、或下层</p><hr><p>其实,《计算机网络自顶向下方法》对该问题有明确的回答</p><p>英文原版<br><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20230130194206.png" alt="20230130194206"></p><p>中译版<br><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20230130194400.png" alt="20230130194400"></p><hr><p>综上所述,MAC 和 IP 缺一不可。</p><p>从 IP 到 MAC 的转换,使用 ARP 协议。</p><hr><p>补充知识:</p><p>主机的 IP 地址是可以动态变化的,而 MAC 地址是写死的,一般不能变(当然也有<a href="https://liupj.top/2022/03/26/mac-randomize/">随机 MAC 的手段</a>)</p>]]></content>
<summary type="html"><h3 id="有了-MAC-地址,为什么还需要-IP-地址-?"><a href="#有了-MAC-地址,为什么还需要-IP-地址-?" class="headerlink" title="有了 MAC 地址,为什么还需要 IP 地址 ?"></a>有了 MAC 地址,为什么还</summary>
</entry>
<entry>
<title>我为什么放弃了 firefox,重新回到 chrome</title>
<link href="https://liupj.top/2023/01/07/why-chrome/"/>
<id>https://liupj.top/2023/01/07/why-chrome/</id>
<published>2023-01-07T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>小孩子才做选择,chrome & firefox 我全都要 !</p><p>主 chrome</p><p>辅 firefox</p><hr><p>以下为原文</p><blockquote><p>course, v2raya is awesome.</p></blockquote><p>firefox 的痛点让我换回了 chrome</p><p>1、对沙拉查词的支持度不如 chrome</p><p>2、firefox 的快捷键默认无法修改,在组合键 ctrl-shift-p 上与 picgo 冲突,虽然可以修改 picgo 的快捷键,但更换组合键不便于记忆</p><p>3、I hate programs creating files or folders in my home directory casually without my permission, such as ~/.mozilla</p>]]></content>
<summary type="html"><p>小孩子才做选择,chrome &amp; firefox 我全都要 !</p>
<p>主 chrome</p>
<p>辅 firefox</p>
<hr>
<p>以下为原文</p>
<blockquote>
<p>course, v2raya is awesome.</p></summary>
</entry>
<entry>
<title>在 ArchLinux 主机上安装 win10 虚拟机</title>
<link href="https://liupj.top/2022/12/31/windows10-in-virtualbox/"/>
<id>https://liupj.top/2022/12/31/windows10-in-virtualbox/</id>
<published>2022-12-31T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>想啥呢 !在 Linux 主机上安装虚拟机是一件非常痛苦的事情 !</p><p>从此以后,不再在 Linux 主机上折腾一切有关虚拟机的东西 !</p>]]></content>
<summary type="html"><p>想啥呢 !在 Linux 主机上安装虚拟机是一件非常痛苦的事情 !</p>
<p>从此以后,不再在 Linux 主机上折腾一切有关虚拟机的东西 !</p>
</summary>
</entry>
<entry>
<title>小羊人的复盘与反思</title>
<link href="https://liupj.top/2022/12/12/ill/"/>
<id>https://liupj.top/2022/12/12/ill/</id>
<published>2022-12-12T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>稳住 !</p><h3 id="明确"><a href="#明确" class="headerlink" title="明确"></a>明确</h3><p>发热不是一件坏事,而是你的身体在与病毒做对抗</p><p>注意保暖,用煮鸡蛋和电解质水来为身体的免疫系统提供“弹药”支持</p><p>药品需要在药师的指导下使用,38.5 度以上才可考虑使用退烧药</p><h3 id="去附近大医院发热门诊"><a href="#去附近大医院发热门诊" class="headerlink" title="去附近大医院发热门诊"></a>去附近大医院发热门诊</h3><blockquote><p>医保码、挂号、缴费、出具检验报告、就诊ID,手机上都能整 !</p></blockquote><p>带</p><p>书包、充好电的手机、身份证</p><p>口罩、酒精湿巾、保温杯、面包</p><p>毛巾、卫生纸</p><p>手套、围巾、帽子</p>]]></content>
<summary type="html"><p>稳住 !</p>
<h3 id="明确"><a href="#明确" class="headerlink" title="明确"></a>明确</h3><p>发热不是一件坏事,而是你的身体在与病毒做对抗</p>
<p>注意保暖,用煮鸡蛋和电解质水来为身体的免疫系统提供“弹药</summary>
</entry>
<entry>
<title>我在 Linux 上听歌的方式</title>
<link href="https://liupj.top/2022/12/09/music-linux-method/"/>
<id>https://liupj.top/2022/12/09/music-linux-method/</id>
<published>2022-12-09T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>我喜欢听歌,但苦于国内各大音乐平台的割据状态(版权、音质、网速、…)</p><p>而我又喜欢双手不离开键盘(不用鼠标,尽可能地少用触控板)且我希望将尽可能多的工作在一个终端窗口中完成</p><p>于是我开始了如下探索,试图建立适合自己的听歌方式…</p><h3 id="最佳的音乐播放体验"><a href="#最佳的音乐播放体验" class="headerlink" title="最佳的音乐播放体验"></a>最佳的音乐播放体验</h3><p>当然是从互联网中搜索无损音乐(.flac),下载到本地进行播放咯</p><h3 id="从哪找没听过的歌呢"><a href="#从哪找没听过的歌呢" class="headerlink" title="从哪找没听过的歌呢"></a>从哪找没听过的歌呢</h3><p><a href="https://github.com/listen1">listen1</a></p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20221210150913.png" alt="20221210150913"></p><h3 id="本地音乐播放器推荐"><a href="#本地音乐播放器推荐" class="headerlink" title="本地音乐播放器推荐"></a>本地音乐播放器推荐</h3><p><a href="https://github.com/audacious-media-player">audacious</a></p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20221210150313.png" alt="20221210150313"></p><h3 id="怎么把想听的歌下载到本地呢"><a href="#怎么把想听的歌下载到本地呢" class="headerlink" title="怎么把想听的歌下载到本地呢"></a>怎么把想听的歌下载到本地呢</h3><p><a href="https://github.com/zonemeen/musicn">https://github.com/zonemeen/musicn</a> 404 了</p><p><a href="https://www.npmjs.com/package/musicn">musicn|npmjs</a></p><p>注意:该软件依赖 node.js 16+ 版本,我设置的版本为 <code>v16.18.1</code>,设置方式可参考<a href="https://liupj.top/2022/03/15/nvm-nodejs-npm-nrm/">这里</a></p><p>小技巧:<code>echo "alias msc="msc -p DIR_TO_STORE_MUSICS" >> ~/.bashrc</code> if you use bash.</p><p>哎嗨 !我们已经可以在终端中搜索并下载音乐了,测试使用效果如下</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20221209150558.png" alt="20221209150558"></p><hr><blockquote><p>以下播放音乐的方式仅适用于播放单个音频文件,仅供参考,选看。</p></blockquote><h3 id="sox"><a href="#sox" class="headerlink" title="sox"></a>sox</h3><p>如果只是想在终端中简单地播放一个音频文件/一首歌,那么推荐使用软件 <a href="https://archlinux.org/packages/community/x86_64/sox/">sox</a> 提供的 <code>play</code> 命令</p><p>Install by executing <code>sudo pacman -S sox</code> if you use ArchLinux like me.</p><p>测试使用效果如下</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20221209152728.png" alt="20221209152728"></p><p><em>参考了:<a href="https://askubuntu.com/questions/920539/how-do-you-play-a-sound-from-the-terminal">https://askubuntu.com/questions/920539/how-do-you-play-a-sound-from-the-terminal</a></em></p><h3 id="ranger-vlc"><a href="#ranger-vlc" class="headerlink" title="ranger + vlc"></a>ranger + vlc</h3><p>vlc 是一款在 Linux 上广受好评的多媒体播放器,能播放视频和音乐</p><p>而且我习惯使用 <a href="https://github.com/ranger/ranger">Ranger</a>, 一款为 vim/neovim 用户打造的文件浏览器,很好用 !</p><p>所以我希望 Ranger 能识别我的音乐文件并自动调用 vlc 播放</p><p>Luckily, Ranger ships with <code>rifle</code>, a file launcher that is good at automatically finding out which program to use for what file type. —— knowing from Ranger’s <a href="https://github.com/ranger/ranger">doc</a></p><p>所以我只需对 <code>rifle</code> 的<a href="https://github.com/Brannua/dotfiles/blob/8cf1bea49226938e1c41c245e84792f9c2b728cc/advanced/ranger/rifle.conf">配置文件</a>进行一下简单的修改即可</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20221210153018.png" alt="20221210153018"></p><p>测试使用效果如下,可以看到 Ranger 自动调用 vlc 开始播放音乐文件了</p><p><img src="https://aliyun-oss-lpj.oss-cn-qingdao.aliyuncs.com/images/by-clipboard/20221209160452.png" alt="20221209160452"></p><p><em>参考了:<a href="https://superuser.com/questions/724689/open-vlc-in-background">https://superuser.com/questions/724689/open-vlc-in-background</a></em></p><h3 id="期望"><a href="#期望" class="headerlink" title="期望"></a>期望</h3><p>受限于目前的工作和技术水平,我对目前的听歌方式还不够满意,希望在未来能打造一个适合我自己的音乐播放软件(GUI or CLI)running on linux which is both open-source、lightweight and reliable.</p>]]></content>
<summary type="html"><h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>我喜欢听歌,但苦于国内各大音乐平台的割据状态(版权、音质、网速、…)</p>
<p>而我又喜欢双手不离开键盘(不用鼠标,尽可能地少用触控板)</summary>
</entry>
<entry>
<title>矢志不渝,争做踔厉奋发通信人</title>
<link href="https://liupj.top/2022/10/22/1_big_20/"/>
<id>https://liupj.top/2022/10/22/1_big_20/</id>
<published>2022-10-22T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<blockquote><p>学习党的第二十次全国代表大会有感</p></blockquote><p>十月金秋,我们党的第二十次全国代表大会在和畅惠风中徐徐拉开大幕,我怀着一颗无比崇敬而向往的心,认真收看学习了习总书记在开幕会上的精彩报告,颇受激励,遂有如下感悟。</p><p><strong>漫漫征程看领航</strong></p><p>回首过往百年,是我们党始终牢牢把握了民族复兴征途的航向,不惧艰险,拨开迷雾,团结带领着亿万人民砥砺前行。身为一名新时代青年,我深知初出茅庐的我肩负着为国家大业添砖加瓦的一份使命和责任,就像鲁迅先生曾说的那样——摆脱冷气向上走,有一份光,发一份热;又如习总书记说的那样——当代青年生逢其时,施展才干的舞台无比广阔,实现梦想的前景无比光明。我深以为然。故而更加坚定了心中紧紧跟党走的信念,更加笃定了为家国事业脚踏实地、谦虚谨慎、艰苦奋斗的底气和决心。</p><p><strong>武装思想抓实践</strong></p><p>托尔斯泰有言——文明的建立不是机器而是思想,我们党历经百年风雨,俨然壮大为今日国际最大的马克思主义政党,恰得益于我们国家一代代共产党人对先进马克思主义的深刻学习和领会,以及先辈们充分发挥主观能动性,审时度势因地制宜地不断改造发展马克思主义,让其越发闪耀出本土化、时代化光芒的创新之举。我们青年一代是祖国未来几十年发展的主力军,更应奋力扛起习近平新时代中国特色社会主义的伟大旗帜,不断坚定道路自信、理论自信、制度自信和文化自信,不断学习和发扬一代代革命先辈们的锐意进取、守正创新和矢志不渝,从实践中来,到实践中去,在今后的工作岗位上多尝试新思路、多思考新办法,承前人之硕果,不断提质增效,续写华夏新篇章。</p><p><strong>回首成就固成因</strong></p><p>十八大以来的十年里,我们党团结带领全国各族人民完成了脱贫攻坚、全面建成小康社会的历史任务,中国特色社会主义进入了新时代,能取得如此举世瞩目的成就,定然在过往的各项工作中我们收获了不可胜数弥足珍贵的实践经验,那么我们就应该将这些零零碎碎的经验好好梳理,穿成串、织成网,充实丰富我们改革开放民族复兴大业前行路上的工具箱,为新征程不断助力。见著而观微,身为当代通信人,我不断观察学习着行业同事们高效的工作方式,不断听取借鉴着行业前辈们宝贵的工作经验,我感受到他们的热心和友善,更感受到他们的信任和期盼,经验是行业的传承,发展是行业的目标,前辈们宝贵的实践经验给我的信心以支撑,给我的信念以动能,青年强则国强,行业兴则国兴,我们通信行业青年一代必会抬头看路埋头前行,继往开来不辱使命。</p><p><strong>把握机遇迎挑战</strong></p><p>新冠疫情肆虐,国际形势复杂多变,近些年着实不寻常、不平凡,在如此社会大背景下,作为肩挑国家通信事业大梁的主力军,我们应当从挑战中敏锐发现机遇、把握机遇,始终将一颗建设、服务的心同党和人民紧密联系在一起,深入基层,奉献社会,做好当前形势下的通信保障工作;我深知打铁还需自身硬,我们年轻一代通信人还应当积极学习更先进科学文化知识,用科技的力量促进高质量发展,推动我国通信事业不断迈向更高的台阶,用更强大的网络基础设施催生更多先进上层应用的实施研发,保障更多高新产业的落地推广;我们还应从提升自身的网络安全意识做起,主动向身边人、全社会普及网络安全知识,努力提高全民的网络安全防范化解风险意识,以更加从容的姿态直面风险、应对挑战。</p><p>前途光明,任重道远,空谈误国,实干兴邦,我们联通青年必将不忘初心跟党走,牢记使命勇前行。</p><blockquote><p>天津联通河东分公司,刘培杰。</p></blockquote>]]></content>
<summary type="html"><blockquote>
<p>学习党的第二十次全国代表大会有感</p>
</blockquote>
<p>十月金秋,我们党的第二十次全国代表大会在和畅惠风中徐徐拉开大幕,我怀着一颗无比崇敬而向往的心,认真收看学习了习总书记在开幕会上的精彩报告,颇受激励,遂有如下感悟。</p>
</summary>
</entry>
<entry>
<title>珍藏的影片</title>
<link href="https://liupj.top/2022/10/02/movies/"/>
<id>https://liupj.top/2022/10/02/movies/</id>
<published>2022-10-02T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<h3 id="电影"><a href="#电影" class="headerlink" title="电影"></a>电影</h3><table><thead><tr><th>片名</th></tr></thead><tbody><tr><td>触不可及</td></tr><tr><td>切尔诺贝利</td></tr><tr><td>忠犬八公的故事</td></tr><tr><td>你好,李焕英</td></tr><tr><td>海上钢琴师</td></tr><tr><td>隐入尘烟</td></tr><tr><td>人生大事</td></tr><tr><td>肖申克的救赎</td></tr><tr><td>我不是药神</td></tr><tr><td>摔跤吧!爸爸</td></tr><tr><td>被解救的姜戈</td></tr><tr><td>1942</td></tr><tr><td>血战台儿庄</td></tr><tr><td>小鬼当家第一部</td></tr><tr><td>困在时间里的父亲</td></tr><tr><td>唐山大地震</td></tr><tr><td>天狗</td></tr><tr><td>小森林</td></tr><tr><td>八佰</td></tr><tr><td>逆行人生</td></tr><tr><td><++></td></tr></tbody></table><h3 id="电视剧"><a href="#电视剧" class="headerlink" title="电视剧"></a>电视剧</h3><table><thead><tr><th>片名</th></tr></thead><tbody><tr><td>亮剑</td></tr><tr><td>小兵张嘎</td></tr><tr><td>恋爱先生</td></tr><tr><td>情满四合院</td></tr><tr><td>人民的名义</td></tr><tr><td>好先生</td></tr><tr><td>父母爱情</td></tr><tr><td>新三国</td></tr><tr><td>小欢喜</td></tr><tr><td>我的阿勒泰</td></tr><tr><td><++></td></tr></tbody></table><h3 id="动画"><a href="#动画" class="headerlink" title="动画"></a>动画</h3><table><thead><tr><th>片名</th></tr></thead><tbody><tr><td>坏蛋联盟</td></tr><tr><td>终极细胞战</td></tr><tr><td>葫芦娃</td></tr><tr><td>狮子王</td></tr><tr><td>黑猫警长</td></tr><tr><td>猫咪小贝</td></tr><tr><td>哪吒闹海</td></tr><tr><td>虹猫蓝兔七侠传</td></tr><tr><td>机器猫(小叮当)</td></tr><tr><td>猫和老鼠</td></tr><tr><td>舒克贝塔</td></tr><tr><td>成龙历险记</td></tr><tr><td>鼹鼠的故事</td></tr><tr><td>大英雄狄青</td></tr><tr><td>疯狂元素城</td></tr><tr><td><++></td></tr></tbody></table><p>to be continue</p>]]></content>
<summary type="html"><h3 id="电影"><a href="#电影" class="headerlink" title="电影"></a>电影</h3><table>
<thead>
<tr>
<th>片名</th>
</tr>
</thead>
<tbody><tr>
<td>触不可及</td></summary>
</entry>
<entry>
<title>SIGINT And Other Termination Signals in Linux(转载)</title>
<link href="https://liupj.top/2022/08/05/sigint-and-other-termination-signals-in-linux/"/>
<id>https://liupj.top/2022/08/05/sigint-and-other-termination-signals-in-linux/</id>
<published>2022-08-05T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<blockquote><p>原文地址:<a href="https://www.baeldung.com/linux/sigint-and-other-termination-signals">https://www.baeldung.com/linux/sigint-and-other-termination-signals</a></p></blockquote><h2 id="Overview"><a href="#Overview" class="headerlink" title="Overview"></a>Overview</h2><p>In Linux systems, processes can receive a variety of <a href="https://man7.org/linux/man-pages/man7/signal.7.html">signals</a>, such as SIGINT or SIGKILL. Each signal is sent in different situations and each has different behavior.</p><p>In this article, we’ll talk about SIGINT, SIGTERM, SIGQUIT, and SIGKILL. We’ll also see the difference between them.</p><h2 id="Introduction-to-Signals"><a href="#Introduction-to-Signals" class="headerlink" title="Introduction to Signals"></a>Introduction to Signals</h2><p><strong>The <a href="https://man7.org/linux/man-pages/man7/signal.7.html">signals</a> are a method of communication between processes. When a process receives a signal, the process interrupts its execution and a signal handler is executed.</strong></p><p>How the program behaves usually depends on the type of signal received. <strong>After handling the signal, the process may or may not continue its normal execution.</strong></p><p>The Linux kernel can send signals, for instance, when a process attempts to divide by zero it receives the SIGFPE signal.</p><p>We can also send signals using the <a href="https://www.baeldung.com/linux/kill-commands">kill</a> program. Let’s run a simple script in the background and stop it:</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></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">(<span class="built_in">sleep</span> 30; <span class="built_in">echo</span> <span class="string">"Ready!"</span>) &</span></span><br><span class="line">[1] 26929</span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash"><span class="built_in">kill</span> -SIGSTOP 26929</span></span><br><span class="line">[1]+ Stopped ( sleep 30; echo "Ready!" )</span><br></pre></td></tr></table></figure><p>Now, we can resume it using SIGCONT:</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></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash"><span class="built_in">kill</span> -SIGCONT 26929</span></span><br><span class="line">Ready!</span><br><span class="line">[1]+ Done ( sleep 30; echo "Ready!" )</span><br></pre></td></tr></table></figure><p>Alternatively, we can send signals in a terminal using key combinations. For instance, Ctrl+C sends SIGINT, Ctrl+S sends SIGSTOP, and Ctrl+Q sends SIGCONT.</p><p><strong>Each signal has a default action, but a process can override the default action and handle it differently, or ignore it.</strong> However, some signals can’t be ignored nor handled differently and the default action is always executed.</p><p>We can handle signals in bash using the <code>trap</code> command. For instance, we can add <code>trap date SIGINT</code> in a script and it will print the date when SIGINT is received.</p><h2 id="SIGINT"><a href="#SIGINT" class="headerlink" title="SIGINT"></a>SIGINT</h2><p><strong>SIGINT is the signal sent when we press Ctrl+C. The default action is to terminate the process. However, some programs override this action and handle it differently.</strong></p><p>One common example is the bash interpreter. When we press Ctrl+C it doesn’t quit, instead, it prints a new and empty prompt line. Another example is when we use <a href="https://linux.die.net/man/1/gdb">gdb</a> to debug a program. We can send SIGINT with Ctrl+C to stop the execution and return it to the gdb’s interpreter.</p><p><strong>We can think of SIGINT as an interruption request sent by the user.</strong> How it is handled usually depends on the process and the situation.</p><p>Let’s write handle_sigint.sh using the trap command to handle SIGINT and print the current date:</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></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">trap</span> <span class="built_in">date</span> SIGINT</span><br><span class="line"></span><br><span class="line"><span class="built_in">read</span> input</span><br><span class="line"><span class="built_in">echo</span> User input: <span class="variable">$input</span></span><br><span class="line"><span class="built_in">echo</span> Exiting now</span><br></pre></td></tr></table></figure><p>We use read input to wait for the user interaction. Now, let’s run our script and let’s press Ctrl+C:</p><figure class="highlight shell"><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"><span class="meta prompt_">$ </span><span class="language-bash">./handle_sigint.sh</span> </span><br><span class="line">^CSat Apr 10 15:32:07 -03 2021</span><br></pre></td></tr></table></figure><p>We can see the script didn’t exit. We can now terminate the script by writing some input:</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></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">./handle_sigint.sh</span> </span><br><span class="line">^CSat Apr 10 15:32:07 -03 2021</span><br><span class="line">live long and prosper</span><br><span class="line">User input: live long and prosper</span><br><span class="line">Exiting now</span><br></pre></td></tr></table></figure><p>If we want to use a signal to terminate it, we can’t use SIGINT with this script. We should use SIGTERM, SIGQUIT, or SIGKILL instead.</p><h2 id="SIGTERM-and-SIGQUIT"><a href="#SIGTERM-and-SIGQUIT" class="headerlink" title="SIGTERM and SIGQUIT"></a>SIGTERM and SIGQUIT</h2><p><strong>The SIGTERM and SIGQUIT signals are meant to terminate the process.</strong> In this case, we are specifically requesting to finish it. <strong>SIGTERM is the default signal when we use the <a href="https://www.baeldung.com/linux/kill-commands">kill</a> command.</strong></p><p>The default action of both signals is to terminate the process. However, SIGQUIT also generates a <a href="https://www.baeldung.com/linux/managing-core-dumps">core dump</a> before exiting.</p><p><strong>When we send SIGTERM, the process sometimes executes a clean-up routine before exiting.</strong></p><p>We can also handle SIGTERM to ask for confirmation before exiting. Let’s write a script called handle_sigterm.sh to terminate only If the user sends the signal twice:</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><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><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line">SIGTERM_REQUESTED=0</span><br><span class="line"><span class="function"><span class="title">handle_sigterm</span></span>() {</span><br><span class="line"> <span class="keyword">if</span> [ <span class="variable">$SIGTERM_REQUESTED</span> -eq 0 ]; <span class="keyword">then</span></span><br><span class="line"> <span class="built_in">echo</span> <span class="string">"Send SIGTERM again to terminate"</span></span><br><span class="line"> SIGTERM_REQUESTED=1</span><br><span class="line"> <span class="keyword">else</span></span><br><span class="line"> <span class="built_in">echo</span> <span class="string">"SIGTERM received, exiting now"</span></span><br><span class="line"> <span class="built_in">exit</span> 0</span><br><span class="line"> <span class="keyword">fi</span></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="built_in">trap</span> handle_sigterm SIGTERM</span><br><span class="line"></span><br><span class="line">TIMEOUT=$(<span class="built_in">date</span> +%s)</span><br><span class="line">TIMEOUT=$((<span class="variable">$TIMEOUT</span> + <span class="number">60</span>))</span><br><span class="line"></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"This script will exit in 60 seconds"</span></span><br><span class="line"><span class="keyword">while</span> [ $(<span class="built_in">date</span> +%s) -lt <span class="variable">$TIMEOUT</span> ]; <span class="keyword">do</span></span><br><span class="line"> <span class="built_in">sleep</span> 1;</span><br><span class="line"><span class="keyword">done</span></span><br><span class="line"><span class="built_in">echo</span> Timeout reached, exiting now</span><br></pre></td></tr></table></figure><p>Now, let’s run it on background executing <code>$ ./handle_sigterm.sh &</code>. Then, we run <code>$ kill <PID></code> twice:</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></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">./handle_sigterm.sh &</span></span><br><span class="line">[1] 6092</span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash"><span class="built_in">kill</span> 6092</span></span><br><span class="line">Send SIGTERM again to terminate</span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash"><span class="built_in">kill</span> 6092</span></span><br><span class="line">SIGTERM received, exiting now</span><br><span class="line">[1]+ Done ./handle_sigterm.sh</span><br></pre></td></tr></table></figure><p>As we can see, the script exited after it received the second SIGTERM.</p><h2 id="SIGKILL"><a href="#SIGKILL" class="headerlink" title="SIGKILL"></a>SIGKILL</h2><p><strong>When a process receives SIGKILL it is terminated. This is a special signal as it can’t be ignored and we can’t change its behavior.</strong></p><p><strong>We use this signal to forcefully terminate the process. We should be careful as the process won’t be able to execute any clean-up routine.</strong></p><p>One common way of using SIGKILL is to first send SIGTERM. We give the process some time to terminate, we may also send SIGTERM a couple of times. If the process doesn’t finish on its own, then we send SIGKILL to terminate it.</p><p>Let’s rewrite the previous example to try to handle SIGKILL and ask for confirmation:</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><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></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line">SIGKILL_REQUESTED=0</span><br><span class="line"><span class="function"><span class="title">handle_sigkill</span></span>() {</span><br><span class="line"> <span class="keyword">if</span> [ <span class="variable">$SIGKILL_REQUESTED</span> -eq 0 ]; <span class="keyword">then</span></span><br><span class="line"> <span class="built_in">echo</span> <span class="string">"Send SIGKILL again to terminate"</span></span><br><span class="line"> SIGKILL_REQUESTED=1</span><br><span class="line"> <span class="keyword">else</span></span><br><span class="line"> <span class="built_in">echo</span> <span class="string">"Exiting now"</span></span><br><span class="line"> <span class="built_in">exit</span> 0</span><br><span class="line"> <span class="keyword">fi</span></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="built_in">trap</span> handle_sigkill SIGKILL</span><br><span class="line"></span><br><span class="line"><span class="built_in">read</span> input</span><br><span class="line"><span class="built_in">echo</span> User input: <span class="variable">$input</span></span><br></pre></td></tr></table></figure><p>Now, let’s run it on a terminal, and let’s send SIGKILL only once with <code>$ kill -SIGKILL <pid></code>:</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></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">./handle_sigkill.sh</span></span><br><span class="line">Killed</span><br><span class="line"><span class="meta prompt_">$</span></span><br></pre></td></tr></table></figure><p><strong>We can see it terminate right away without asking to re-send the signal.</strong></p><h2 id="How-SIGINT-Relates-to-SIGTERM-SIGQUIT-and-SIGKILL"><a href="#How-SIGINT-Relates-to-SIGTERM-SIGQUIT-and-SIGKILL" class="headerlink" title="How SIGINT Relates to SIGTERM, SIGQUIT and SIGKILL"></a>How SIGINT Relates to SIGTERM, SIGQUIT and SIGKILL</h2><p>Now that we understand more about signals, we can see how they relate to each other.</p><p>The default action for SIGINT, SIGTERM, SIGQUIT, and SIGKILL is to terminate the process. <strong>However, SIGTERM, SIGQUIT, and SIGKILL are defined as signals to terminate the process, but SIGINT is defined as an interruption requested by the user.</strong></p><p>In particular, if we send SIGINT (or press Ctrl+C) depending on the process and the situation it can behave differently. So, <strong>we shouldn’t depend solely on SIGINT to finish a process.</strong></p><p>As SIGINT is intended as a signal sent by the user, usually the processes communicate with each other using other signals. For instance, a parent process usually sends SIGTERM to its children to terminate them, even if SIGINT has the same effect.</p><p>In the case of SIGQUIT, it generates a core dump which is useful for debugging.</p><p>Now that we have this in mind, we can see we should choose SIGTERM on top of SIGKILL to terminate a process. <strong>SIGTERM is the preferred way as the process has the chance to terminate gracefully.</strong></p><p>As a process can override the default action for SIGINT, SIGTERM, and SIGQUIT, it can be the case that neither of them finishes the process. Also, if the process is hung it may not respond to any of those signals. In that case, we have SIGKILL as the last resort to terminate the process.</p><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>In this article, we learned about signals and the difference between SIGINT, SIGTERM, SIGQUIT, and SIGKILL. Also, we briefly learned how to handle signals in bash.</p><p>We saw how SIGINT sometimes doesn’t kill the process as it may a different meaning. On the other hand, the SIGKILL signal will always terminate the process.</p><p>We also learned that SIGQUIT generates a core dump by default and that SIGTERM is the preferred way to kill a process.</p>]]></content>
<summary type="html"><blockquote>
<p>原文地址:<a href="https://www.baeldung.com/linux/sigint-and-other-termination-signals">https://www.baeldung.com/linux/sigint-and</summary>
</entry>
<entry>
<title>公务员考试方法论(转载)</title>
<link href="https://liupj.top/2022/07/22/gongkao-method/"/>
<id>https://liupj.top/2022/07/22/gongkao-method/</id>
<published>2022-07-22T00:00:00.000Z</published>
<updated>2024-10-19T07:14:55.102Z</updated>
<content type="html"><![CDATA[<p>公务员考试,如何上岸?</p><p>先说结论:通关上岸,课程占30%,刷题占60%,剩下10%交给运气。</p><p>30%课程:</p><p>很多考生总有这样一种执念,觉得xx机构的课程一定很厉害,学完基本就稳了,但就是有点贵,动辄几千上万。。还有点纠结值不值,其实,这不就明摆着割韭菜吗?</p><p>公考制度已经运行这么多年了,相应的课程都已经非常成熟,不存在课程决定结果的现象,如果真有这种课程,学完就上岸,你觉得会在市面上广泛流通吗?</p><p>公考现在是非常公平公正公开的,是除了高考之外为数不多的实现阶级跃升的方式,所以很多机构利用这一点大肆夸张宣传,所以各位,要擦亮双眼哦~</p><p>60%刷题:</p><p>公考的本质就是一个熟练度问题,刷题就是不断提高熟练度的过程,可以说刷题,是最直接有效的方法,没有之一,充分调动自身的主观能动性去实践,每做一道题相当于进行一次知识梳理,只会越来越熟练,越来越得心应手。</p><p>就像“你只管努力,剩下的交给天意”,“不要假装很努力,结果不会陪你演戏”,这种地摊鸡汤文写的一样。</p><p>“你只管刷题,剩下的交给快递,把入职通知书寄回到你家里,打开写着恭喜录取大吉大利,peace~”</p><p>强调一点,刷题一定要用真题,真题是最有指导意义的,可以熟悉命题规律和趋势。</p><p>10%运气:</p><p>我们都知道,行测考试时间为 120 分钟,省考一般为 120 道题,国考为 135道题,再除去涂卡时间,平均不到 50 秒钟一道题,考试的时候没有人可以全部认真思考并作答完毕!</p><p>因此,到最后势必会有不会做的,或者来不及做的题目,这个时候肯定不能空着不选吧,就是蒙也要选上,这个对于99%的考生来说,基本就是靠运气了,蒙的都对,那就是运气爆表,蒙的都错,也无能为力。</p><p>如何人为控制正确率,提高这最后一部分题目的正确率,可以看下这篇文章</p><p>ok,关于课程+刷题+运气,就说到这里,从宏观上做了一个扼要说明,那接下来不废话,开始正文,上备考干货。</p><p>行测我们按模块来,申论整体进行。</p><p>一、常识模块</p><p>这个小模块,好像很多同学认为是举足轻重的,尤其是当做过真题或者模拟题被“毒打”以后,感觉自己的公考之路马上要断送了,急需抢救一下,因为经常有同学问我,大老师,常识怎么复习,正确率好低呀。。。</p><p>怎么复习?不用复习,别在这浪费时间。</p><p>常识判断,说白了它是考察你这二十多年的一个积累,从小到大你的学习、见闻、经验、以及涉猎的其他知识,短时间的备考无法发生质的改变。</p><p>备考这个模块,只需利用碎片时间进行积累,等人的时间、睡觉之前、刷题休息的间隙。。。总之,不要占用正规学习时间,投入产出比太低,把有限的备考时间,用到其他能提升分数的模块上。</p><p>二、言语理解</p><p>常见的题型有:阅读理解、逻辑填空、语句表达</p><p>主要考察考生运用语言文字进行思考和交流、迅速准确地理解和把握文字材料内涵的能力。</p><p>这个模块与公务员工作联系还是比较紧密的,上级单位发的会议精神,领导要求你写的稿子,都需要快速、准确领会意图,并用文字精准的表达出来。</p><p>备考时,以刷题为主进行倒推,看自己哪种题型正确率偏低就着重学习哪类题型的课程,再回头进行有针对性的加强,这样一个学习思路,可以又快又准的完成此模块的备考。</p><p>当然,逻辑填空里的词语、成语辨析,也需要积累,学习方式同常识模块一样,利用碎片时间进行即可。</p><p>三、判断推理</p><p>由逻辑判断、图形推理、定义判断、类比推理,四个小模块组成,两推理+两判断,主要考察逻辑思维能力。</p><p>这个模块很多题目都是有固定公式,解题的时候千万不要当成言语理解去做,严格按照逻辑进行推演。</p><p>刷题之前的基础课程,务必要学扎实了,这是解题的“密钥”,很多逻辑推理规则是固定不变的,学会以后才有能去做题,不要本末倒置。</p><p>四、数资模块</p><p>数量关系+资料分析,这两个模块是行测高分的分水岭,换句话说,行测要</p><p>得高分,和其他考生拉开分差,这两个模块的正确率必须保证!</p><p>这两个模块放到一起,有相同之处又有各自的特点。</p><p>共同点:非常明显,对数学计算能力都有一定要求。</p><p>不同点:数量关系,都是各自独立的题型,例如,工程问题、抽屉原理、排列组合、年龄问题等等,每种题型之间并无关联,只要掌握某种题型,就可以做到“会一道,对一片”的效果,备考时不要过早打退堂鼓,数量关系来来回回就这么十多种题型,每种学完,花不了多少时间精力,剩下交给刷题,提高熟练度即可。</p><p>资料分析,是一个整体,通过一段材料或者表格数据,进行整体分析计算,其中会涉及到如何快速阅读、快速估算、定性分析,技巧性比较强</p><p>五、申论</p><p>写的好不如抄的好,不要过度发挥,忠于原材料,紧扣主旨。</p><p>小学都做过阅读理解题吧,其中就有一道题叫做概括段落大意,其实申论要得高分,道理一样,把它当成一篇大型的概括段落大意题,紧紧围绕主旨,再适当的地方加上你储备的一些金句。</p><p>再说下阅卷规则与注意的事项</p><p>申论都是网上阅卷,阅卷老师分成几个组,每组只阅一道题,而且只能在屏幕上看到这一道题,如果你写到格子外头去了,阅卷老师就看不到了。</p><p>80%以上的老师根本都没有看过申论试题和给出的材料,只需要记住答案要点就可以上阵了。每组都有组长。大家首先进行试评。一人20份卷子,评过之后统计时间和分数分布区间,每道题根据分值的不同划定出一个误差区间。</p><p>正常情况下,一道题会有两个老师阅卷,他们给出的分数可能有高有低,如果分数差在误差区间内,那就取两者的平均值为该题的分数;如果分数差超过了误差区间,那就要组长进行三评,并以组长给出的分数为准。</p><p>电脑会自动统计出该组的三评率,如果三评率超出了规定范围,则证明这个阅卷组对于阅卷没有达成共识,对不起,前面所有的工作白费,重新停下来,大家统一规则,然后重新试评20份,误差率合格了,再重新阅卷。</p><p>想想吧,如果因为你个人的原因,分数误差大了导致全组停工试评从头再来,那是多大的罪过啊!所以,阅卷老师们都会心照不宣的在中间分和安全分上徘徊,以免出现招人白眼的状况。</p><p>枪打出头鸟,每个老师所有给出的分数都是在电脑终端有统计的,如果给出的分数太高,或者高分太多,或者中间分数太少,那巡视员就会把这个老师叫到电脑终端屏幕前,让他看分数曲线,然后温和的说一句,要不然,你们组再试评一下?为了集体荣誉,绝对不能重来啊!所以,大家都会努力的向中间分靠拢。</p><p>那什么是中间分和安全分,举个例子,一道20分的题目,可能你觉得自己应该怎么也能打个14分吧,哈哈,错啦!一道20分的题目,中间分是10分,标准误差是3分,也就是说,万一一个老师给该题打了10分,那你作为另一个阅卷老师,最高打到13分,最低打到7分。</p><p>但是,万一你觉得挺好的文章,另一个老师只给八九9分,你打13分就超了啊!所以,保险一点,打个11分总不会错,就算另一个老师觉得该题答得不好,也不至于给到7分以下或者14分以上了吧。</p><p>这就是一个阅卷博弈,经过这样一番博弈,大家的默契就是:一般的,给8-9分;还不错的,9-10分;不怎样的,7-8分;非常差的,6-7分;非常好的,10-11分。打到6分以下的低分或者13分以上的高分都是冒着生命危险的,很难很难。这就是为什么很多人觉得自己答得不错但是100分的申论才只得了四五十分的原因。</p><p>申论的第一二道题是得分的关键。</p><p>这是因为,客观的点好找,容易达成共识,老师们数着采分点给分,一般差距不大,分数得的也理直气壮;</p><p>最可怕的是主观性的阅卷分数,太没谱了,老师就是觉得文章写得好,也不敢给高分。所以,临考不到一个月,努力抓好前两道题,练习找准采分点,比使劲练大文章要有用得多。</p><p>那什么是采分点呢?说起来也挺荒唐的。阅卷组拿到申论答案以后,会根据题目分值将答案进行分配。</p><p>比如说15年国考申论第一道题吧,20分由结构分2分,采分点16分(八个点),主观分2分构成,大概是只要能答出“文段说了两件事情”,有个“两件、二层”之类的字样,就能得到结构分2分,用了分号但是没写“两”,就没这2分;</p><p>然后“粮食安全”“民生”各两分;再有什么就已经记不得了。反正,其实批卷子到后来,已经麻木到连自己都记不得答案和完整的采分点是什么了。就是给个中间分安全分,字好一点的看着顺眼一点,有几个点的,就给个9分,字差一点或者采分点少一点的,就7、8分,保证不会出错,误差率也在可控范围,全组的阅卷率很容易通过。</p><p>要是后面的大题就更虚了,不可能将好几十分都拆成一个个采分点,所以都是划档给分的,这就比前两道题靠采分点给分要模糊得多。</p><p>一般来讲,还是给个中间分,50分的题目,给个23分-27分之间就可以了。</p><p>阅卷时间的话,都是在电脑屏幕上阅卷,想象一下,每天从早上八点半开始盯着屏幕一字一字的看枯燥的重复内容,一直到晚上六点。除了上厕所和吃饭,基本没什么休息,脖子会酸屁股会麻胃里恶心眼睛会瞎掉,很辛苦的!</p><p>所以大家都想快点结束战斗,第一是不要取消成绩重新试评,第二是单位时间尽量多批一点。而且组员之间和各个组之间也都有无声的较量,每个人的业绩量都是清晰可见的,你批得少,那就是赤裸裸的偷懒了,会遭人鄙视的。</p><p>相对来说,新手阅卷时间都比较长,反复看反复找,还要斟酌给多少分,一道200字的题目可能要阅15-30秒,这样单位时间内阅卷量就会非常少,电脑终端那里显示你的工作量和单位效率都很可怜,经过一会儿的磨练,新手就会逐渐赶超老手,争取每道题五六秒的速度,甚至更快。</p><p>400字的题目,阅卷大概是8到10秒。最可怕的是800到1000字的大文章,阅卷时间老手差不多12秒,新手也会在16秒左右结束战斗。也就是说你辛辛苦苦花两个小时写的东西,阅卷老师统共用不上30秒,已经决定了你的生死,这才是名副其实的秒杀!</p><p>还有一点,为了便于规范统一,采分点大多数都是题目中已经给出的关键词或字眼,或者稍加改装整理。除了重要领导的重要讲话,一般的别的词汇是不太可能成为标准答案中的采分点的。</p><p>所以,如何从材料中找出关键词关键字眼,然后把他们拼到答案中,是练习的关键。某些参考答案脱离材料天马行空的提对策,即使可行,也不会是采分点的。</p><p>所以,申论备考,就一句话,忠于原材料,总结采分点。</p><p>关于公考备考,其实没有多复杂,充分发挥主观能动性,反复去练习总结,上岸只是时间问题。加油了各位!</p>]]></content>
<summary type="html"><p>公务员考试,如何上岸?</p>
<p>先说结论:通关上岸,课程占30%,刷题占60%,剩下10%交给运气。</p>
<p>30%课程:</p>
<p>很多考生总有这样一种执念,觉得xx机构的课程一定很厉害,学完基本就稳了,但就是有点贵,动辄几千上万。。还有点纠结值不值,其实</summary>
</entry>
</feed>