Python Kafka

kafka是一个分布式消息队列。具有高性能、持久化、多副本备份、横向扩展能力。生产者往队列里写消息,消费者从队列里取消息进行业务逻辑。一般在架构设计中起到解耦、削峰、异步处理的作用。

Confluent kafka client

Reference

https://anaconda.org/conda-forge/python-confluent-kafka

https://docs.confluent.io/current/clients/confluent-kafka-python/

https://github.com/confluentinc/confluent-kafka-python

https://kafka.apache.org/quickstart

阅读更多

linux下创建热点

linux创建热点


create_ap

先甩个链接:

https://github.com/oblique/create_ap

安装就不说了.

  • 首先先查看你的网卡
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
~ » ifconfig                                                         
enp2s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 20:89:84:97:0d:ac txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 972 bytes 53280 (52.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 972 bytes 53280 (52.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.202.36.11 netmask 255.255.252.0 broadcast 10.202.39.255
inet6 fe80::26fd:52ff:fe74:c002 prefixlen 64 scopeid 0x20<link>
ether 24:fd:52:74:c0:02 txqueuelen 1000 (Ethernet)
RX packets 35414 bytes 17903776 (17.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14346 bytes 1851081 (1.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

可以看到网卡是enp2s0和wlp3s0,wlp3s0是无线网卡.


Examples

  • No passphrase (open network):

create_ap wlan0 eth0 MyAccessPoint

我对应的命令就是

1
sudo create_ap wlp3s0 enp2s0 MyAccessPoint

那么带密码:

  • WPA + WPA2 passphrase:
1
sudo create_ap wlp3s0 enp2s0 MyAccessPoint MyPassPhrase
  • Internet sharing from the same WiFi interface:
1
sudo create_ap wlp3s0 wlp3s0 MyAccessPoint MyPassPhrase

感觉常用的就这三个.

一个禁用笔记本键盘的命令

发现一个linux下禁用键盘的命令


1
sudo rmmod atkbd 

临时禁用然后把键盘放在笔记本上,再也不用担心外接键盘压到笔记本按键了。

linux编码转换

编码转换命令如下

1
iconv -f GBK -t UTF-8 file1 -o file2

博客建好了,测试下markdown语法


This is an H1

This is an H2

这是 H1

这是 H2

这是 H6

这是 H1

这是 H2

这是 H3

First level header

Third level header

Second level header

This is a paragraph.

A nested blockquote.

Headers work

  • lists too

and all other block-level elements

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
/**
* @author John Smith <[email protected]>
* @version 1.0
*/
package l2f.gameserver.model;

import java.util.ArrayList;

public abstract class L2Character extends L2Object {
public static final Short ABNORMAL_EFFECT_BLEEDING = 0x0_0_0_1; // not sure

public void moveTo(int x, int y, int z) {
_ai = null;
_log.warning("Should not be called");
if (1 > 5) {
return;
}
}

/** Task of AI notification */
@SuppressWarnings( { "nls", "unqualified-field-access", "boxing" })
public class NotifyAITask implements Runnable {
private final CtrlEvent _evt;

List<String> mList = new ArrayList<String>()

public void run() {
try {
getAI().notifyEvent(_evt, _evt.class, null);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
1
2
3
4
5
6
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
1
2
~~~~~~~
code with tildes
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

$$
\begin{align*}
& \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right)
= \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\
& (x_1, \ldots, x_n) \left( \begin{array}{ccc}
\phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\
\vdots & \ddots & \vdots \\
\phi(e_n, e_1) & \cdots & \phi(e_n, e_n)
\end{array} \right)
\left( \begin{array}{c}
y_1 \\
\vdots \\
y_n
\end{array} \right)
\end{align*}
$$

This \`is not a code\` span!


This⋅para⋅line⋅starts⋅at⋅the⋅first⋅column.⋅However,
⋅⋅⋅⋅⋅⋅the⋅following⋅lines⋅can⋅be⋅indented⋅any⋅number⋅of⋅spaces/tabs.
⋅⋅⋅The⋅para⋅continues⋅here.

⋅⋅This⋅is⋅another⋅paragraph,⋅not⋅connected⋅to⋅the⋅above⋅one.⋅But⋅⋅
with⋅a⋅hard⋅line⋅break.⋅\\
And⋅another⋅one.

First level header
==================

Second level header
------

Other first level header
=

This is a normal
paragraph.

And A Header
------------
And a paragraph

> This is a blockquote.

And A Header
------------


header
---
para



test gcp

~~~ html
<script type="text/javascript">
// Say hello world until the user starts questioning
// the meaningfulness of their existence.
function helloWorld(world) {
for (var i = 42; --i >= 0;) {
alert('Hello ' + String(world));
}
}
</script>
<style>
p { color: pink }
b { color: blue }
u { color: "umber" }
</style>
1
2
$('#h2outline').height() //获取元素高度
$('header').outerHeight() //获取元素外部高度(包括margin)