-
Notifications
You must be signed in to change notification settings - Fork 1
/
rss.xml
837 lines (819 loc) · 49.8 KB
/
rss.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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<language>zh-cn</language>
<copyright>cxy</copyright>
<generator>caixiangyue.github.io</generator>
<title>cxy</title>
<link>https://caixiangyue.github.io</link>
<description> cxy's blog </description>
<item>
<title>msync总结</title>
<link>https://caixiangyue.github.io/msync总结.html</link>
<description> <![CDATA[<ol>
<li>集群调用函数</li>
</ol>
<div class="highlight highlight-source-erlang"><pre class="notranslate">执行命令
<span class="pl-en">rp</span>(<span class="pl-en">tool</span>:<span class="pl-en">rpc</span>({<span class="pl-c1">application</span>, <span class="pl-c1">get_env</span>, [<span class="pl-c1">message_store</span>, <span class="pl-c1">is_use_channel_sync</span>]}, <span class="pl-c1">'msync@ebs'</span>)).
查日志
<span class="pl-en">tool</span>:<span class="pl-en">log_search_rpc</span>(<span class="pl-s"><span class="pl-pds">"</span>2022-07-05 15:18:27<span class="pl-pds">"</span></span>, <span class="pl-c1">7200</span>, <span class="pl-s"><span class="pl-pds">"</span>1028405512963623676<span class="pl-pds">"</span></span>, <span class="pl-c1">20</span>, <span class="pl-s"><span class="pl-pds">"</span>ejabberd@ebs<span class="pl-pds">"</span></span>).
查聊天室
[<span class="pl-smi">MucPid</span>] <span class="pl-k">=</span> <span class="pl-en">easemob_muc_router</span>:<span class="pl-en">get_router</span>(<<<span class="pl-s"><span class="pl-pds">"</span>easemob-demo#easeim_185068033212417<span class="pl-pds">"</span></span>>>).
<span class="pl-en">rp</span>(<span class="pl-en">tool</span>:<span class="pl-en">get_state</span>(<span class="pl-s"><span class="pl-pds">"</span><55333.5711.7675><span class="pl-pds">"</span></span>)).</pre></div>
<pre class="notranslate"><code class="notranslate">config:load_env("/data/apps/opt/msync/releases/23.3.1.0/sys.config").
easemob_traffic_control_sup:stop(),easemob_traffic_control_sup:start().
</code></pre>
<ol start="2">
<li>trace</li>
</ol>
<div class="highlight highlight-source-erlang"><pre class="notranslate">{<span class="pl-c1">ok</span>, <span class="pl-smi">Dev</span>} <span class="pl-k">=</span> <span class="pl-en">file</span>:<span class="pl-en">open</span>(<span class="pl-s"><span class="pl-pds">"</span>/tmp/trace<span class="pl-pds">"</span></span>,[<span class="pl-c1">write</span>]).
<span class="pl-en">recon_trace</span>:<span class="pl-en">calls</span>({<span class="pl-c1">queue</span>, <span class="pl-c1">in</span>, <span class="pl-k">fun</span>(<span class="pl-c1">_</span>) -> <span class="pl-en">return_trace</span>() <span class="pl-k">end</span>}, <span class="pl-c1">3</span>, [{<span class="pl-c1">io_server</span>, <span class="pl-smi">Dev</span>}]).
<span class="pl-en">recon_trace</span>:<span class="pl-en">calls</span>({<span class="pl-c1">easemob_user_channel</span>, <span class="pl-c1">read</span>, <span class="pl-k">fun</span>(<span class="pl-c1">_</span>) -> <span class="pl-en">return_trace</span>() <span class="pl-k">end</span>}, <span class="pl-c1">100</span>, [{<span class="pl-c1">return_to</span>, <span class="pl-c1">true</span>}, {<span class="pl-c1">scope</span>, <span class="pl-c1">local</span>}]).</pre></div>
<ol start="3">
<li>kafka</li>
</ol>
<div class="highlight highlight-source-shell"><pre class="notranslate">./kafka-consumer-groups.sh --bootstrap-server hsb-didi-guangzhou-mesos-master2:9092 --list
./kafka-consumer-groups.sh --bootstrap-server hsb-didi-guangzhou-mesos-master2:9092 --describe --group msync-channel-outgoing</pre></div>
<pre class="notranslate"><code class="notranslate">rm /Users/one/easemob/msync/apps/msync/src/msync.appup.src
</code></pre>
<ol start="4">
<li>msync kafka</li>
</ol>
<p>msync_log, easemob_log, easemob_log_worker: kafka的生产者</p>
<ul>
<li>用户发送的消息,支持的消息类型有上行,下行,离线,ack</li>
<li>用户的状态</li>
<li>好友操作</li>
<li>用户禁言操作</li>
<li>敏感词</li>
<li>...</li>
</ul>
<p>easemob_rest_event: 消费redis/kafka,发送多人聊天事件消息 (发现聊天室/群组kafka消费处于空转状态)<br>
msync_easemob_sendmsg: 消费redis/kafka发消息</p>
<p>easemob_kafka: 读写kafka的核心模块</p>
<p>相关配置</p>
<ul>
<li>kafka_client_module brod | ekaf</li>
<li>queue_log_module kafka | redis</li>
<li>kafka_log_async true | false</li>
</ul>
<h2>测试</h2>
<ol>
<li>登陆</li>
<li>禁言 (单聊,群聊,聊天室)</li>
<li>发消息(单聊,群聊,聊天室,消息撤回,消息透传和扩展)</li>
<li>好友(添加,删除,拒绝,接受)</li>
<li>presence</li>
<li>黑名单</li>
<li>通知</li>
</ol>
<p>问题:</p>
<ol>
<li>无法设置app_config</li>
<li>无法访问存储</li>
</ol><hr><p>Fri Dec 1 14:21:07 2023</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>kafka学习</title>
<link>https://caixiangyue.github.io/kafka学习.html</link>
<description> <![CDATA[<h4>环境搭建</h4>
<p>启动<code class="notranslate">zookeeper</code></p>
<pre class="notranslate"><code class="notranslate">$ bin/zookeeper-server-start.sh config/zookeeper.properties
</code></pre>
<p>启动<code class="notranslate">kafka</code></p>
<pre class="notranslate"><code class="notranslate">$ bin/kafka-server-start.sh config/server.properties
</code></pre>
<p>创建topic</p>
<pre class="notranslate"><code class="notranslate">$ bin/kafka-topics.sh --create --topic t1 --bootstrap-server localhost:12346 --partitions 1 --replication-factor 1
Created topic t1
</code></pre>
<p>生产消息</p>
<pre class="notranslate"><code class="notranslate">$ bin/kafka-console-producer.sh --topic t1 --bootstrap-server localhost:12346
</code></pre>
<p>消费消息</p>
<pre class="notranslate"><code class="notranslate">$ bin/kafka-console-consumer.sh --topic t1 --from-beginning --bootstrap-server localhost:12346
</code></pre><hr><p>Tue Dec 7 16:32:28 2021</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>似水年华</title>
<link>https://caixiangyue.github.io/似水年华.html</link>
<description> <![CDATA[<p>最近有个想法:把每一天发生的事记录下,一定会很有意思吧。:laughing:</p>
<blockquote>
<p>愿你生命中有够多的云翳,来造成一个美丽的黄昏。 —— 冰心</p>
</blockquote>
<ul>
<li><a href="#user-content-20240115">2024-01-15</a></li>
<li><a href="#user-content-20231123">2023-11-23</a></li>
<li><a href="#user-content-20231107">2023-11-07</a></li>
<li><a href="#user-content-20231016">2023-10-16</a></li>
<li><a href="#user-content-20230719">2023-07-19</a></li>
<li><a href="#user-content-20230608">2023-06-08</a></li>
<li><a href="#user-content-20230530">2023-05-30</a></li>
<li><a href="#user-content-20230526">2023-05-26</a></li>
<li><a href="#user-content-20230522">2023-05-22</a></li>
<li><a href="#user-content-20230128">2023-01-28</a></li>
<li><a href="#user-content-20220808">2022-08-08</a></li>
<li><a href="#user-content-20220207">2022-02-07</a></li>
<li><a href="#user-content-20220111">2022-01-11</a></li>
<li><a href="#user-content-20220110">2022-01-10</a></li>
<li><a href="#user-content-20220104">2022-01-04</a></li>
<li><a href="#user-content-20211222">2021-12-22</a></li>
<li><a href="#user-content-20210925">2021-09-25</a></li>
<li><a href="#user-content-20210830">2021-08-30</a></li>
<li><a href="#user-content-20210720">2021-07-20</a></li>
<li><a href="#user-content-20210208">2021-02-08</a></li>
<li><a href="#user-content-20210129">2021-01-29</a></li>
<li><a href="#user-content-20210119">2021-01-19</a></li>
<li><a href="#user-content-20201103">2020-11-03</a></li>
<li><a href="#user-content-20200916">2020-09-16</a></li>
<li><a href="#user-content-20200714">2020-07-14</a></li>
<li><a href="#user-content-20200701">2020-07-01</a></li>
<li><a href="#user-content-20200421">2020-04-21</a></li>
<li><a href="#user-content-20200414">2020-04-14</a></li>
<li><a href="#user-content-20200327">2020-03-27</a></li>
</ul>
<h4>2024-01-15</h4>
<span id="user-content-20240115">
</span>
<p>做了<a href="../img/20240115/1.jpeg">焗饭</a></p>
<h4>2023-11-23</h4>
<span id="user-content-20231123">
</span>
<p>北京。</p>
<p>风。</p>
<p>起风了,</p>
<p>让我们迎风而生。</p>
<h4>2023-11-07</h4>
<span id="user-content-20231107">
</span>
<p>清晨。</p>
<p>骑行。</p>
<p>阳光透过树叶枝桠,忽明忽暗。</p>
<p>涌现一丝困意。</p>
<h4>2023-10-16</h4>
<span id="user-content-20231016">
</span>
<p>秋,</p>
<p>凉风习习。</p>
<h4>2023-07-19</h4>
<span id="user-content-20230719">
</span>
<p>一些天空</p>
<p><a href="../img/20230522/5.jpeg">天空1</a></p>
<p><a href="../img/20230522/6.jpeg">天空2</a></p>
<h4>2023-06-08</h4>
<span id="user-content-20230608">
</span>
<p>最近又看了一遍古龙先生的《多情剑客无情剑》</p>
<h4>2023-05-30</h4>
<span id="user-content-20230530">
</span>
<p>一旦上了赌桌,你就不可避免的成为了赌徒</p>
<h4>2023-05-26</h4>
<span id="user-content-20230526">
</span>
<p>坐地铁看小说,这个习惯真是坏,总是害得我坐过站,若是看的还是一本有趣的小说,那真是坏透了。</p>
<h4>2023-05-22</h4>
<span id="user-content-20230522">
</span>
<p>大同行</p>
<p><a href="../img/20230522/1.jpeg">云冈石窟</a></p>
<p><a href="../img/20230522/2.jpeg">华严寺</a></p>
<p><a href="../img/20230522/3.jpeg">悬空寺</a></p>
<p><a href="../img/20230522/4.jpeg">北岳恒山</a></p>
<p>乘坐G2531次列车,历时1时40分来到了黄土高坡大同。</p>
<p>大同平均海拔1千米,气温下降了10度,吹着风,除了有点儿冷,并没有明显不适。</p>
<p>主要游览了云冈石窟,华严寺,大同古城,悬空寺,北岳恒山。</p>
<p>吃了极具特色的大同黄糕</p>
<h4>2023-01-28</h4>
<span id="user-content-20230128">
</span>
一年一度的春节假期结束了
<p>只能感叹时光太匆匆,还有很多想做却没做的事情,就踏上了归程</p>
<p>见了多年未见的几个同学</p>
<p>和父母,弟弟一起吃了许多顿饭,一起出去散步</p>
<p>和我弟玩了几局农药</p>
<h4>2022-09-06</h4>
<span id="user-content-20220906">
</span>
<p><a href="../img/20220906/1.jpg">偶遇一只螳螂!</a></p>
<h4>2022-08-08</h4>
<span id="user-content-20220808">
</span>
<p><a href="../img/20220808/1.mp4">大雨滂沱</a></p>
<h4>2022-02-07</h4>
<span id="user-content-20220207">
</span>
<p>一年一度的春节结束了,我们一起做了10道菜,还算不错吧。</p>
<p>继续努力,争取不负韶华。</p>
<h4>2022-01-11</h4>
<span id="user-content-20220111">
</span>
<p>最近租的房子发霉了,是不是要有好运降临了呢?</p>
<p>希望过年能回家 🚋</p>
<h4>2022-01-10</h4>
<span id="user-content-20220110">
</span>
<p>周末为zn做了蒜苔炒肉。</p>
<p>zn戴上了王冠。</p>
<p>唱了祝你生日快乐,生日快乐,快乐,乐……</p>
<p>没有点蜡烛,但还是又长大了一岁。</p>
<blockquote>
<p>「 岁岁年年,万喜万般宜 」</p>
</blockquote>
<h4>2022-01-04</h4>
<span id="user-content-20220104">
</span>
昨天和朋友们聚餐,下午一起做了三个菜,香菇油菜,青椒炒肉,排骨土豆。
<p>吃得很快,一会儿就没了。</p>
<h4>2021-12-22</h4>
<span id="user-content-20211222">
</span>
<p>昨天是冬至,晚上和zn一起吃了两斤思念的<code class="notranslate">虾仁三鲜水饺</code>,真的是每个饺子都至少有一个大虾仁(吃了好几个都有三个虾仁)!</p>
<p>今天北京天气晴朗:sun_with_face:,万里无云。</p>
<p>在这个美丽的上午,想一想今天要做的事情:</p>
<ol class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 看一下Redis深度历险</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 分析下erlang集群的任务</li>
</ol>
<h4>2021-12-16</h4>
<span id="user-content-20211216">
</span>
<p>公司团建去了环球影视城。<br>
<a href="../img/20211216/1.jpeg">哈利波特</a><br>
<a href="../img/20211216/2.jpeg">变形金刚</a><br>
体验都非常不错,玩得很开心!</p>
<h4>2021-09-25</h4>
<span id="user-content-20210925">
</span>
<p>今天和zn尝试做了<code class="notranslate">炒蛏子</code>和<code class="notranslate">粉丝娃娃菜</code>,第一次做,味道还不错。</p>
<p>一起看了部电影叫<code class="notranslate">完美世界</code>。感觉说教是没用的,你的一言一行就是最重要的教育。</p>
<h4>2021-08-30</h4>
<span id="user-content-20210830">
</span>
<blockquote>
<p>业精于勤,荒于嬉;行成于思,毁于随。</p>
</blockquote>
<h4>2021-07-20</h4>
<span id="user-content-20210720">
</span>
<p>今日完成:</p>
<ol class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 实现了2个RPC函数,写了英文文档(用的Google翻译)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 学习MySQL</li>
</ol>
<p>InnoDB的数据是存储在磁盘上的,会把经常访问的数据(索引页,数据页,undo页,插入缓冲,自适应hash索引,锁信息,数据字典信息)放到一块内存区域(缓冲池)访问,缓冲池使用LRU算法管理。</p>
<p>缓冲池默认页大小16KB</p>
<p>show engine innodb status;</p>
<h4>2021-02-08</h4>
<span id="user-content-20210208">
</span>
<p>最近看了本书叫作《窗边的小豆豆》,对我发人深省。<br>
记录下些许感悟:</p>
<ul>
<li>要蹲下来,多多倾听孩子的想法,感受他们的喜乐,为他们的高兴而高兴,为他们的悲伤而悲伤。</li>
<li>要做好孩子的榜样。</li>
<li>要让孩子幸福健康地成长。</li>
<li>不要把自己的喜好强加给孩子,孩子有自己的想法,应该让他们自己选择自己喜欢什么。</li>
<li>不要总是讲道理,要让他们从生活中感悟。</li>
<li>经常夸奖孩子,比如小林校长经常说的:你真是一个好孩子呀!</li>
</ul>
<h4>2021-01-29</h4>
<span id="user-content-20210129">
</span>
<p>昨天刮了大风,今天又放晴了。</p>
<p>人生各个阶段都有各自的幸福啊。</p>
<h4>2021-01-19</h4>
<span id="user-content-20210119">
</span>
北京下雪了,在黄色路灯的衬托下,显得格外好看。
<p>今天成功实现了早上6:30起床的梦想。改变不易,奖励下自己。</p>
<blockquote>
<p>「 为了做一名真正的绅士,即使明知必输无疑,也要有勇气接受挑战!」</p>
</blockquote>
<h4>2020-11-03</h4>
<span id="user-content-20201103">
</span>
<p>今天简单玩了玩 <code class="notranslate">github profile</code> 和 <code class="notranslate">github action</code>。感觉还是挺有意思的。<br>
尤其是 <code class="notranslate">github action</code> 有一个 <code class="notranslate">workflow</code> 的概念,并且基于他做了一个 <code class="notranslate">workflow</code> 市场的感觉,上传自己的 <code class="notranslate">workflow</code>,其他人可以使用自己需要的<code class="notranslate">workflow</code>,极大地提升了生产力,很棒!</p>
<h4>2020-09-16</h4>
<span id="user-content-20200916">
工作第三年了,三年时光稍纵即逝。
<p>感慨时光飞逝啊,感觉什么都不做,一会儿是春天,一会儿又是酷暑难耐,这几天迅速入秋,天气转凉,今年又到了尾巴。</p>
<p>想想曾经的自己也是意气风发,也有抱负,不甘堕落。这几年除了工作,每天就是玩玩玩,懒惰至极,总是找各种借口,新买的书一页都没看。</p>
<p>我心中有预感不能再这么下去了,人生短短数十载,荒废的光阴再也回不来了。而我回首过去,并没有因为偷懒而得到什么,得到的只是虚无。懒惰得到一时的满足,努力得到的是内心深处的满足,这种满足绵延而又长久。</p>
<p>再接下来的岁月,我也要成为一个自律,生活充满规律,不浪费生命,积极努力的人!立帖为证。<br>
</p>
<h4>2020-07-14</h4>
<span id="user-content-20200714">
为了成为更厉害的人而努力!:muscle:
</span>
<h4>2020-07-01</h4>
<span id="user-content-20200701">
我发现只要每天定下很多任务,就什么都做不了。还不如每天只做一个任务,还轻松,闲适。
<p>一辈子做好一件事儿可真难啊!<br>
</p>
<h4>2020-04-21</h4>
<span id="user-content-20200421">
重新理解了什么是:“好读书,不求甚解”。
</span>
<h4>2020-04-14</h4>
<span id="user-content-20200414">
有的时候觉得自己很酷,可以做一些以前只有大人才能做成的事情。
</span>
<h4>2020-03-27</h4>
<span id="user-content-20200327">
不想记录一些流水账。
</span></span></span><hr><p>Mon Jan 15 12:06:10 2024</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>常用地址</title>
<link>https://caixiangyue.github.io/常用地址.html</link>
<description> <![CDATA[<h2>常用源</h2>
<ol>
<li><a href="https://pypi.tuna.tsinghua.edu.cn/simple" rel="nofollow">pip</a></li>
<li><a href="https://goproxy.cn" rel="nofollow">GOPROXY</a></li>
</ol>
<h2>翻墙</h2>
<ol>
<li><a href="https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt" rel="nofollow">SwichyOmega</a></li>
</ol>
<h2>软件</h2>
<ol>
<li><a href="https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh" rel="nofollow">ohmyzsh</a></li>
</ol>
<h2>博客</h2>
<ol>
<li><a href="https://draveness.me/" rel="nofollow">面向信仰编程</a></li>
<li><a href="https://coolshell.cn/" rel="nofollow">酷壳</a></li>
<li><a href="https://www.yinwang.org/" rel="nofollow">当然我在扯淡</a></li>
<li><a href="https://www.ixiqin.com/" rel="nofollow">西秦公子</a></li>
<li><a href="https://blog.codingnow.com/" rel="nofollow">云风</a></li>
<li><a href="http://blog.devtang.com/" rel="nofollow">唐巧的博客</a></li>
</ol><hr><p>Tue Nov 23 15:44:51 2021</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>配置文件</title>
<link>https://caixiangyue.github.io/配置文件.html</link>
<description> <![CDATA[<h1>配置文件</h1>
<h2>validators</h2>
<p>在<code class="notranslate">schema</code>文件中可以为<code class="notranslate">mapping</code>编写<code class="notranslate">validator</code>函数,去执行一些更高级的校验。</p>
<p>例子1:</p>
<p>限制某个配置的取值范围</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate">{<span class="pl-c1">mapping</span>, <span class="pl-s"><span class="pl-pds">"</span>platform_len_limit<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>msync.platform_len_limit<span class="pl-pds">"</span></span>, [
{<span class="pl-c1">default</span>, <span class="pl-c1">10</span>},
{<span class="pl-c1">datatype</span>, <span class="pl-c1">integer</span>},
{<span class="pl-c1">validators</span>, [<span class="pl-s"><span class="pl-pds">"</span>>=0<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span><=50<span class="pl-pds">"</span></span>]}
]}.
{<span class="pl-c1">validator</span>, <span class="pl-s"><span class="pl-pds">"</span>>=0<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>must be at least 0<span class="pl-pds">"</span></span>,
<span class="pl-k">fun</span>(<span class="pl-smi">V</span>) ->
<span class="pl-smi">V</span> <span class="pl-k">>=</span> <span class="pl-c1">0</span>
<span class="pl-k">end</span>}.
{<span class="pl-c1">validator</span>, <span class="pl-s"><span class="pl-pds">"</span><=50<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>50 and larger are not supported<span class="pl-pds">"</span></span>,
<span class="pl-k">fun</span>(<span class="pl-smi">V</span>) ->
<span class="pl-smi">V</span> <span class="pl-k">=<</span> <span class="pl-c1">50</span>
<span class="pl-k">end</span>}.</pre></div>
<p>如果把<code class="notranslate">platform_len_limit</code>的值设置为<code class="notranslate">-1</code>,生成配置文件会打印如下报错:<br>
<a target="_blank" rel="noopener noreferrer" href="../img/20230919/1.png"><img src="../img/20230919/1.png" alt="" style="max-width: 100%;"></a></p>
<p>例子2:</p>
<p>检查某个配置必须在<code class="notranslate">conf</code>文件配置</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate">{<span class="pl-c1">mapping</span>, <span class="pl-s"><span class="pl-pds">"</span>node_type<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>msync.node_type<span class="pl-pds">"</span></span>, [
{<span class="pl-c1">default</span>, <span class="pl-c1">none</span>},
{<span class="pl-c1">datatype</span>, <span class="pl-c1">atom</span>},
{<span class="pl-c1">validators</span>, [<span class="pl-s"><span class="pl-pds">"</span>must_config<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>node_type<span class="pl-pds">"</span></span>]}
]}.
{<span class="pl-c1">validator</span>, <span class="pl-s"><span class="pl-pds">"</span>must_config<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>must be set in the config file<span class="pl-pds">"</span></span>,
<span class="pl-k">fun</span>(<span class="pl-smi">V</span>) ->
<span class="pl-smi">V</span> <span class="pl-k">=/=</span> <span class="pl-c1">none</span>
<span class="pl-k">end</span>}.</pre></div>
<p>如果在<code class="notranslate">conf</code>文件中没有配置,会打印如下报错:<br>
<a target="_blank" rel="noopener noreferrer" href="../img/20230919/2.png"><img src="../img/20230919/2.png" alt="" style="max-width: 100%;"></a></p>
<p>例子3:</p>
<p>检查一组配置是否都有配置</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-c"><span class="pl-c">%</span>% easemob queues</span>
{<span class="pl-c1">mapping</span>, <span class="pl-s"><span class="pl-pds">"</span>easemob_queues<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>msync.easemob_queues<span class="pl-pds">"</span></span>, [
{<span class="pl-c1">default</span>, <span class="pl-s"><span class="pl-pds">"</span>queue_channel,queue_group_channel,queue_offline,queue_presence_session,queue_reaction,queue_ets<span class="pl-pds">"</span></span>},
{<span class="pl-c1">datatype</span>, <span class="pl-c1">string</span>}
]}.
{ <span class="pl-c1">translation</span>,
<span class="pl-s"><span class="pl-pds">"</span>msync.easemob_queues<span class="pl-pds">"</span></span>,
<span class="pl-k">fun</span>(<span class="pl-smi">Conf</span>) ->
<span class="pl-smi">AllQueues</span> <span class="pl-k">=</span> <span class="pl-en">cuttlefish</span>:<span class="pl-en">conf_get</span>(<span class="pl-s"><span class="pl-pds">"</span>easemob_queues<span class="pl-pds">"</span></span>, <span class="pl-smi">Conf</span>),
<span class="pl-smi">Queues</span> <span class="pl-k">=</span> <span class="pl-en">string</span>:<span class="pl-en">tokens</span>(<span class="pl-smi">AllQueues</span>, <span class="pl-s"><span class="pl-pds">"</span>,<span class="pl-pds">"</span></span>),
<span class="pl-en">lists</span>:<span class="pl-en">foreach</span>(<span class="pl-k">fun</span>(<span class="pl-smi">Queue</span>) ->
<span class="pl-en">cuttlefish</span>:<span class="pl-en">conf_get</span>(<span class="pl-smi">Queue</span> <span class="pl-k">++</span> <span class="pl-s"><span class="pl-pds">"</span>.pool_size<span class="pl-pds">"</span></span>, <span class="pl-smi">Conf</span>)
<span class="pl-k">end</span>, <span class="pl-smi">Queues</span>),
[<span class="pl-en">erlang</span>:<span class="pl-en">list_to_atom</span>(<span class="pl-smi">Queue</span>) || <span class="pl-smi">Queue</span> <span class="pl-k"><-</span> <span class="pl-en">string</span>:<span class="pl-en">tokens</span>(<span class="pl-smi">AllQueues</span>, <span class="pl-s"><span class="pl-pds">"</span>,<span class="pl-pds">"</span></span>)]
<span class="pl-k">end</span>
}.</pre></div>
<p>如果<code class="notranslate">easemob_queues</code> 依赖的 <code class="notranslate">pool_size</code> 没有配置,会打印如下报错:<br>
<a target="_blank" rel="noopener noreferrer" href="../img/20230919/3.png"><img src="../img/20230919/3.png" alt="" style="max-width: 100%;"></a></p>
<h3>一些注意事项</h3>
<ul>
<li><code class="notranslate">validator</code>函数仅有一个参数</li>
<li><code class="notranslate">validator</code>函数在一个schema文件定义后,在所有schema文件都可以使用</li>
<li>不要在多个<code class="notranslate">schema</code>文件中重复定义配置</li>
</ul>
<h2>单元测试</h2>
<div class="highlight highlight-source-erlang"><pre class="notranslate"> <span class="pl-c"><span class="pl-c">%</span>% 仅通过schema文件生成配置</span>
<span class="pl-smi">Config</span> <span class="pl-k">=</span> <span class="pl-en">cuttlefish_unit</span>:<span class="pl-en">generate_templated_config</span>(
<span class="pl-s"><span class="pl-pds">"</span>../../lib/msync/priv/msync.schema<span class="pl-pds">"</span></span>, [], []),
<span class="pl-c"><span class="pl-c">%</span>% assert validator 设置的错误信息</span>
<span class="pl-c1">ok</span> <span class="pl-k">=</span> <span class="pl-en">cuttlefish_unit</span>:<span class="pl-en">assert_error_message</span>(<span class="pl-smi">Config</span>, <span class="pl-s"><span class="pl-pds">"</span>platform_len_limit invalid, must be at least 0<span class="pl-pds">"</span></span>).
</pre></div>
<div class="highlight highlight-source-erlang"><pre class="notranslate"> <span class="pl-c"><span class="pl-c">%</span>% 通过 config 和 schema 共同生成配置</span>
<span class="pl-smi">LocalConfig</span> <span class="pl-k">=</span> [{[<span class="pl-s"><span class="pl-pds">"</span>platform_len_limit<span class="pl-pds">"</span></span>], <span class="pl-c1">10</span>}],
<span class="pl-smi">Config</span> <span class="pl-k">=</span> <span class="pl-en">cuttlefish_unit</span>:<span class="pl-en">generate_templated_config</span>(
<span class="pl-s"><span class="pl-pds">"</span>../../lib/msync/priv/msync.schema<span class="pl-pds">"</span></span>, <span class="pl-smi">LocalConfig</span>, []),
<span class="pl-c"><span class="pl-c">%</span>% assert 生成的配置是否符合预期</span>
<span class="pl-c1">ok</span> <span class="pl-k">=</span> <span class="pl-en">cuttlefish_unit</span>:<span class="pl-en">assert_config</span>(<span class="pl-smi">Config</span>, <span class="pl-s"><span class="pl-pds">"</span>msync.platform_len_limit<span class="pl-pds">"</span></span>, <span class="pl-c1">10</span>),
<span class="pl-c"><span class="pl-c">%</span>% assert 是否没有生成此配置</span>
<span class="pl-c1">ok</span> <span class="pl-k">=</span> <span class="pl-en">cuttlefish_unit</span>:<span class="pl-en">assert_not_configured</span>(<span class="pl-smi">Config</span>, <span class="pl-s"><span class="pl-pds">"</span>msync.roam_server<span class="pl-pds">"</span></span>).
</pre></div><hr><p>Wed Sep 20 17:21:29 2023</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>erlang学习</title>
<link>https://caixiangyue.github.io/erlang学习.html</link>
<description> <![CDATA[<h4>hello world.</h4>
<p>创建一个源文件<code class="notranslate">hello.erl</code></p>
<div class="highlight highlight-source-erlang"><pre class="notranslate">-<span class="pl-k">module</span>(<span class="pl-en">hello</span>).
-<span class="pl-k">export</span>([<span class="pl-en">hello</span>/<span class="pl-c1">0</span>]).
<span class="pl-en">hello</span>()<span class="pl-k">-></span>
<span class="pl-en">io</span>:<span class="pl-en">format</span>(<span class="pl-s"><span class="pl-pds">"</span>hello world.<span class="pl-c1">~n</span><span class="pl-pds">"</span></span>).</pre></div>
<p>编译运行</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-ii">$ </span><span class="pl-c1">erl</span>
<span class="pl-smi">Erlang</span><span class="pl-k">/</span><span class="pl-smi">OTP</span> <span class="pl-c1">24</span> [<span class="pl-c1">erts</span><span class="pl-k">-</span><span class="pl-c1">12.1</span>.<span class="pl-c1">5</span>] [<span class="pl-c1">source</span>] [<span class="pl-c1">64</span><span class="pl-k">-</span><span class="pl-c1">bit</span>] [<span class="pl-c1">smp</span>:<span class="pl-c1">8</span>:<span class="pl-c1">8</span>] [<span class="pl-c1">ds</span>:<span class="pl-c1">8</span>:<span class="pl-c1">8</span>:<span class="pl-c1">10</span>] [<span class="pl-c1">async</span><span class="pl-k">-</span><span class="pl-c1">threads</span>:<span class="pl-c1">1</span>] [<span class="pl-c1">jit</span>] [<span class="pl-c1">dtrace</span>]
<span class="pl-smi">Eshell</span> <span class="pl-smi">V12</span>.<span class="pl-c1">1.5</span> (<span class="pl-c1">abort</span> <span class="pl-c1">with</span> ^<span class="pl-smi">G</span>)
<span class="pl-c1">1</span><span class="pl-k">></span> <span class="pl-en">c</span>(<span class="pl-c1">hello</span>).
{<span class="pl-c1">ok</span>,<span class="pl-c1">hello</span>}
<span class="pl-c1">2</span><span class="pl-k">></span> <span class="pl-en">hello</span>:<span class="pl-en">hello</span>().
<span class="pl-c1">hello</span> <span class="pl-c1">world</span>.
<span class="pl-c1">ok</span></pre></div>
<h4>元组</h4>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-c1">1</span><span class="pl-k">></span> <span class="pl-smi">Point</span> <span class="pl-k">=</span> {<span class="pl-c1">4</span>, <span class="pl-c1">5</span>}.
{<span class="pl-c1">4</span>,<span class="pl-c1">5</span>}
<span class="pl-c1">2</span><span class="pl-k">></span> {<span class="pl-smi">X</span>, <span class="pl-smi">Y</span>} <span class="pl-k">=</span> <span class="pl-smi">Point</span>.
{<span class="pl-c1">4</span>,<span class="pl-c1">5</span>}
<span class="pl-c1">3</span><span class="pl-k">></span> <span class="pl-smi">X</span>.
<span class="pl-c1">4</span>
<span class="pl-c1">4</span><span class="pl-k">></span> <span class="pl-smi">Y</span>.
<span class="pl-c1">5</span>
<span class="pl-c1">5</span><span class="pl-k">></span> {<span class="pl-c1">point</span>, <span class="pl-smi">Point</span>}.
{<span class="pl-c1">point</span>,{<span class="pl-c1">4</span>,<span class="pl-c1">5</span>}}</pre></div>
<h4>列表</h4>
<p>基本操作</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-k">></span> <span class="pl-smi">L</span> <span class="pl-k">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>].
[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">2</span><span class="pl-k">></span> [<span class="pl-smi">H</span>|<span class="pl-smi">T</span>] <span class="pl-k">=</span> <span class="pl-smi">L</span>.
[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">3</span><span class="pl-k">></span> <span class="pl-smi">H</span>.
<span class="pl-c1">1</span>
<span class="pl-c1">4</span><span class="pl-k">></span> <span class="pl-smi">T</span>.
[<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">5</span><span class="pl-k">></span> <span class="pl-smi">N</span> <span class="pl-k">=</span> [<span class="pl-c1">1</span>]<span class="pl-k">++</span><span class="pl-smi">T</span>.
[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">6</span><span class="pl-k">></span> <span class="pl-smi">N</span><span class="pl-k">--</span>[<span class="pl-c1">1</span>].
[<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]</pre></div>
<p>列表推导</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-c1">10</span><span class="pl-k">></span> <span class="pl-smi">N</span>.
[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">11</span><span class="pl-k">></span> [ <span class="pl-c1">2</span><span class="pl-k">*</span><span class="pl-smi">X</span> || <span class="pl-smi">X</span> <span class="pl-k"><-</span> <span class="pl-smi">N</span> ].
[<span class="pl-c1">2</span>,<span class="pl-c1">4</span>,<span class="pl-c1">6</span>]
<span class="pl-c1">15</span><span class="pl-k">></span> <span class="pl-smi">W</span> <span class="pl-k">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">a</span>, <span class="pl-c1">b</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>].
[<span class="pl-c1">1</span>,<span class="pl-c1">a</span>,<span class="pl-c1">b</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">16</span><span class="pl-k">></span> [ <span class="pl-c1">2</span><span class="pl-k">*</span><span class="pl-smi">X</span> || <span class="pl-smi">X</span> <span class="pl-k"><-</span> <span class="pl-smi">W</span>, <span class="pl-en">integer</span>(<span class="pl-smi">X</span>) ].
[<span class="pl-c1">2</span>,<span class="pl-c1">4</span>,<span class="pl-c1">6</span>]</pre></div>
<h4>位语法</h4>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-c1">11</span><span class="pl-k">></span> <span class="pl-smi">Color</span> <span class="pl-k">=</span> <span class="pl-c1">16#FF00AA</span>.
<span class="pl-c1">16711850</span>
<span class="pl-c1">12</span><span class="pl-k">></span> <span class="pl-smi">Pixel</span> <span class="pl-k">=</span> <<<span class="pl-smi">Color</span>:<span class="pl-c1">24</span>>>.
<<<span class="pl-c1">255</span>,<span class="pl-c1">0</span>,<span class="pl-c1">170</span>>>
<span class="pl-c1">13</span><span class="pl-k">></span> <<<span class="pl-smi">R</span>:<span class="pl-c1">8</span>, <span class="pl-smi">Rest</span>/<span class="pl-k">binary</span>>> <span class="pl-k">=</span> <span class="pl-smi">Pixel</span>.
<<<span class="pl-c1">255</span>,<span class="pl-c1">0</span>,<span class="pl-c1">170</span>>>
<span class="pl-c1">14</span><span class="pl-k">></span> <span class="pl-smi">R</span>.
<span class="pl-c1">255</span></pre></div>
<h4>函数</h4>
<p>创建<code class="notranslate">same.erl</code></p>
<div class="highlight highlight-source-erlang"><pre class="notranslate">-<span class="pl-k">module</span>(<span class="pl-en">same</span>).
-<span class="pl-k">compile</span>(<span class="pl-c1">export_all</span>).
<span class="pl-en">same</span>(<span class="pl-smi">X</span>, <span class="pl-smi">X</span>)<span class="pl-k">-></span>
<span class="pl-c1">true</span>;
<span class="pl-en">same</span>(<span class="pl-c1">_</span>,<span class="pl-c1">_</span>)<span class="pl-k">-></span>
<span class="pl-c1">false</span>.</pre></div>
<p>运行</p>
<div class="highlight highlight-source-erlang"><pre class="notranslate"><span class="pl-c1">1</span><span class="pl-k">></span> <span class="pl-en">c</span>(<span class="pl-c1">same</span>).
<span class="pl-c1">same</span>.<span class="pl-c1">erl</span>:<span class="pl-c1">2</span>:<span class="pl-c1">2</span>: <span class="pl-smi">Warning</span>: <span class="pl-c1">export_all</span> <span class="pl-c1">flag</span> <span class="pl-c1">enabled</span> <span class="pl-k">-</span> <span class="pl-c1">all</span> <span class="pl-c1">functions</span> <span class="pl-c1">will</span> <span class="pl-c1">be</span> <span class="pl-c1">exported</span>
<span class="pl-c"><span class="pl-c">%</span> 2| -compile(export_all).</span>
<span class="pl-c"><span class="pl-c">%</span> | ^</span>
{<span class="pl-c1">ok</span>,<span class="pl-c1">same</span>}
<span class="pl-c1">2</span><span class="pl-k">></span> <span class="pl-en">same</span>:<span class="pl-en">same</span>(<span class="pl-c1">1</span>,<span class="pl-c1">1</span>).
<span class="pl-c1">true</span>
<span class="pl-c1">3</span><span class="pl-k">></span> <span class="pl-en">same</span>:<span class="pl-en">same</span>(<span class="pl-c1">1</span>,<span class="pl-c1">2</span>).
<span class="pl-c1">false</span></pre></div><hr><p>Tue Aug 23 14:48:22 2022</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>tcp相关配置</title>
<link>https://caixiangyue.github.io/tcp相关配置.html</link>
<description> <![CDATA[<h4>linux 内核参数</h4>
<ul>
<li>tcp_max_syn_backlog: 用于设置半连接队列(syn queue,内核中实现为一个哈希表)大小</li>
<li>somaxconn: 用于设置全连接队列(accept queue)大小</li>
<li>syncookies: 开启此参数可以再不使用半连接队列的情况下成功建立连接</li>
</ul>
<h4>用户参数</h4>
<ul>
<li>backlog: 用于设置全连接队列大小</li>
</ul>
<p>tcp_max_syn_backlog, somaxconn, backlog这三个参数的最小值就是半连接队列的最大长度</p>
<p>somaxconn和backlog的最小值就是全连接队列的最大长度</p>
<h4>临时修改内核参数命令</h4>
<div class="highlight highlight-source-shell"><pre class="notranslate">sudo sysctl -w net.core.somaxconn=4096</pre></div><hr><p>Mon Dec 6 10:39:41 2021</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>用C扩展Python</title>
<link>https://caixiangyue.github.io/用C扩展Python.html</link>
<description> <![CDATA[<blockquote>
<p>用C语言写一个最简单的python扩展。</p>
</blockquote>
<h2>一. 上代码</h2>
<ol>
<li>hello.c</li>
</ol>
<div class="highlight highlight-source-c"><pre class="notranslate"><span class="pl-k">#include</span><span class="pl-s"><Python.h></span>
<span class="pl-k">static</span> <span class="pl-smi">PyObject</span> <span class="pl-c1">*</span><span class="pl-en">say_hello</span>(<span class="pl-smi">PyObject</span> <span class="pl-c1">*</span><span class="pl-s1">self</span>, <span class="pl-smi">PyObject</span> <span class="pl-c1">*</span><span class="pl-s1">args</span>) {
<span class="pl-k">return</span> <span class="pl-en">Py_BuildValue</span>(<span class="pl-s">"s"</span>, <span class="pl-s">"hello from c."</span>);
}
<span class="pl-k">static</span> <span class="pl-smi">PyMethodDef</span> <span class="pl-s1">methods</span>[] <span class="pl-c1">=</span> {
{<span class="pl-s">"say_hello"</span>, <span class="pl-s1">say_hello</span>, <span class="pl-c1">METH_VARARGS</span>, <span class="pl-s">"say hello."</span>},
{<span class="pl-c1">NULL</span>, <span class="pl-c1">NULL</span>, <span class="pl-c1">0</span>, <span class="pl-c1">NULL</span>}
};
<span class="pl-k">static</span> <span class="pl-k">struct</span> <span class="pl-smi">PyModuleDef</span> <span class="pl-s1">module_def</span> <span class="pl-c1">=</span>
{
<span class="pl-s1">PyModuleDef_HEAD_INIT</span>,
<span class="pl-s">"hello"</span>,
<span class="pl-s">"say hello"</span>,
<span class="pl-c1">-1</span>,
<span class="pl-s1">methods</span>
};
<span class="pl-smi">PyMODINIT_FUNC</span> <span class="pl-en">PyInit_hello</span>(<span class="pl-smi">void</span>) {
<span class="pl-k">return</span> <span class="pl-en">PyModule_Create</span>(<span class="pl-c1">&</span><span class="pl-s1">module_def</span>);
}</pre></div>
<ol start="2">
<li>setup.py</li>
</ol>
<div class="highlight highlight-source-python"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">distutils</span>.<span class="pl-s1">core</span> <span class="pl-k">import</span> <span class="pl-s1">setup</span>, <span class="pl-v">Extension</span>
<span class="pl-s1">module</span> <span class="pl-c1">=</span> <span class="pl-v">Extension</span>(<span class="pl-s">'hello'</span>, <span class="pl-s1">sources</span> <span class="pl-c1">=</span> [<span class="pl-s">'hello.c'</span>])
<span class="pl-en">setup</span>(<span class="pl-s1">name</span> <span class="pl-c1">=</span> <span class="pl-s">'say hello'</span>, <span class="pl-s1">version</span> <span class="pl-c1">=</span> <span class="pl-s">'0.0.1'</span>, <span class="pl-s1">ext_modules</span> <span class="pl-c1">=</span> [<span class="pl-s1">module</span>])</pre></div>
<h2>二. 编译</h2>
<div class="highlight highlight-source-shell"><pre class="notranslate">$ python setup.py build</pre></div>
<h2>三. 调用</h2>
<p><strong>注</strong> 此时想要调用需要把<code class="notranslate">hello.so</code>共享库加到PYTHONPATH环境变量中。</p>
<div class="highlight highlight-source-python"><pre class="notranslate"><span class="pl-c">#!/usr/bin/env python3</span>
<span class="pl-k">import</span> <span class="pl-s1">hello</span>
<span class="pl-en">print</span>(<span class="pl-s1">hello</span>.<span class="pl-en">say_hello</span>()) </pre></div>
<h2>四. 参考</h2>
<ul>
<li><a href="https://docs.python.org/3/extending/extending.html" rel="nofollow">https://docs.python.org/3/extending/extending.html</a></li>
</ul><hr><p>Tue Nov 23 15:44:51 2021</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>景色</title>
<link>https://caixiangyue.github.io/景色.html</link>
<description> <![CDATA[<h2>欢一中</h2>
<p><a target="_blank" rel="noopener noreferrer" href="../img/20241016/1.jpg"><img src="../img/20241016/1.jpg" alt="0" style="max-width: 100%;"></a></p>
<h2>兰各庄村</h2>
<p><a target="_blank" rel="noopener noreferrer" href="../img/20231106/lgz.jpeg"><img src="../img/20231106/lgz.jpeg" alt="lgz" style="max-width: 100%;"></a></p>
<h2>北京奥林匹克公园</h2>
<p><a target="_blank" rel="noopener noreferrer" href="../img/20231106/5.jpeg"><img src="../img/20231106/5.jpeg" alt="0" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer" href="../img/20231106/1.jpeg"><img src="../img/20231106/1.jpeg" alt="1" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer" href="../img/20231106/2.jpeg"><img src="../img/20231106/2.jpeg" alt="2" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer" href="../img/20231106/3.jpeg"><img src="../img/20231106/3.jpeg" alt="3" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer" href="../img/20231106/4.jpeg"><img src="../img/20231106/4.jpeg" alt="4" style="max-width: 100%;"></a></p><hr><p>Wed Oct 16 19:10:56 2024</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>朝花夕拾</title>
<link>https://caixiangyue.github.io/朝花夕拾.html</link>
<description> <![CDATA[<h2>一. c宏</h2>
<ol>
<li>
<p><code class="notranslate">do{}while(0)</code> 宏的用处?</p>
<p>避免调用者出现使用错误,保证程序执行的一致性。<br>
例如:</p>
<div class="highlight highlight-source-c"><pre class="notranslate"><span class="pl-k">#define</span> <span class="pl-en">FOO</span>() foo1();foo2();</pre></div>
<p>调用代码:</p>
<div class="highlight highlight-source-c"><pre class="notranslate"><span class="pl-k">if</span> (<span class="pl-s1">a</span> <span class="pl-c1">></span> <span class="pl-c1">0</span>)
<span class="pl-en">FOO</span>();</pre></div>
<p>会被扩展成:</p>
<div class="highlight highlight-source-c"><pre class="notranslate"><span class="pl-k">if</span> (<span class="pl-s1">a</span> <span class="pl-c1">></span> <span class="pl-c1">0</span>)
<span class="pl-en">foo1</span>();<span class="pl-en">foo2</span>();</pre></div>
<p>这时就产生了一个问题,若是<code class="notranslate">a <= 0</code>,<code class="notranslate">foo2()</code>仍然会被调用。<br>
正确的写法:</p>
<div class="highlight highlight-source-c"><pre class="notranslate"><span class="pl-k">#define</span> <span class="pl-en">FOO</span>() \
do{ \
foo1(); \
foo2(); \
}while(0)</pre></div>
</li>
</ol>
<h2>二. 计算机二三事</h2>
<ol>
<li>
<p>栈和堆的区别</p>
<ul>
<li>栈的结构是先进后出,永远操作的是栈顶</li>
<li>栈中的数据必须已知且大小固定(如c语言的数组)</li>
<li>堆是缺乏组织的,当向堆中放入数据,操作系统会去寻找到一块足够大的空间,标记为已使用,并返回一个指向这块空间的指针</li>
</ul>
<p>操作栈空间是比堆速度快的,因为使用堆你需要先寻找到一块足够大的空间(<code class="notranslate">malloc</code>),而且使用的内存并不是连续的(如动态链表),需要在内存中跳来跳去,这些操作都会降低性能。<br>
还有很多原因,如cpu对栈有直接支持(<code class="notranslate">push</code>, <code class="notranslate">pop</code>);栈内存由操作系统管理,而堆内存由用户程序管理。</p>
</li>
<li>
<p>指针</p>
<blockquote>
<p>In computer science, a pointer is a programming language object that stores a memory address. --wikipedia</p>
</blockquote>
<p>在计算机科学中,指针就是存储了一个内存地址的编程语言对象。</p>
</li>
<li>
<p>引用</p>
<p>以 java 为例:</p>
<blockquote>
<p>A reference is an address that indicates where an object's variables and methods are stored.</p>
</blockquote>
<p>引用是一个指向了对象的方法和变量存储位置的地址。</p>
</li>
</ol>
<h2>三. linux命令</h2>
<ol>
<li>
<p>删除当前目录除某文件外的所有文件</p>
<div class="highlight highlight-source-shell"><pre class="notranslate">ls <span class="pl-k">|</span> grep -v except_filename <span class="pl-k">|</span> xargs rm -rf</pre></div>
</li>
<li>
<p>更新所有的module</p>
<pre class="notranslate"><code class="notranslate">git submodule update --init --recursive --remote
</code></pre>
</li>
</ol>
<h2>四. Redis需要注意的问题</h2>
<ol>
<li>集群环境下使用lua脚本只支持一个key,多个key需要用{}括起来</li>
</ol><hr><p>Thu Feb 17 10:27:30 2022</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>hello world</title>
<link>https://caixiangyue.github.io/hello-world.html</link>
<description> <![CDATA[<h1>Hello World</h1>
<h2>1.test</h2>
<blockquote>
<p>test</p>
</blockquote><hr><p>Tue Nov 23 15:44:51 2021</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
<item>
<title>学习笔记</title>
<link>https://caixiangyue.github.io/学习笔记.html</link>
<description> <![CDATA[<h2>计算机网络</h2>
<p><a href="https://www.cxyxiaowu.com/13489.html" rel="nofollow">网络</a></p>
<ol>
<li>三次握手</li>
</ol>
<p><a href="https://www.cxyxiaowu.com/15668.html" rel="nofollow">三次握手</a></p>
<p>三次握手中第三次握手可以携带数据。</p>
<h2>数据库</h2>
<ol>
<li>MySQL</li>
</ol>
<p><a href="https://www.cxyxiaowu.com/16302.html" rel="nofollow">MySQL</a></p>
<h2>C++</h2>
<ol>
<li>
<p>C++ 内存布局<br>
堆区(低地址向高地址),栈区(高地址向低地址),代码段,文本段(字面量池),全局数据段(已初始化的数据,全局和静态变量),未初始化数据段(未初始化的数据)</p>
</li>
<li>
<p>new和malloc区别<br>
<a href="https://www.cnblogs.com/qg-whz/p/5140930.html" rel="nofollow">new和malloc区别</a></p>
</li>
<li>
<p>c++ 强制类型转换</p>
</li>
</ol>
<ul>
<li>static_cast 编译时类型检查
<ol>
<li>基本数据类型间的转换,如char->int</li>
<li>向上转型是安全的,向下转型是不安全的(没有运行时类型检查)</li>
<li>把指针转换成空指针</li>
</ol>
</li>
<li>dynamic_cast
<ol>
<li>主要用于多态,类层次间的转换</li>
<li>引用类型可能会抛出std::bad_cast异常</li>
</ol>
</li>
<li>const_cast</li>
</ul>
<ol start="4">
<li>c++ 智能指针<br>
unique_ptr</li>
</ol>
<h2>操作系统</h2>
<h2>排序</h2>
<p><a href="https://zhuanlan.zhihu.com/p/74820690" rel="nofollow">归并排序</a></p>
<h2>设计模式</h2>
<ol>
<li>
<p>单例模式</p>
</li>
<li>
<p>工厂模式</p>
</li>
</ol><hr><p>Mon Nov 6 11:39:18 2023</p><script src="https://utteranc.es/client.js"
repo="caixiangyue/caixiangyue.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
]]></description>
</item>
</channel>
</rss>