ant design

Upload 集成在菜单/下拉框选项

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
let items = [            
{
label: <Upload
multiple={false}
showUploadList={false}
accept=".json"
customRequest={onSelect}>导入</Upload>,
icon: <ImportOutlined/>,
key: 1
}
]

<Menu
selectedKeys={1}
items={menuItems}
/>

// 自定义上传逻辑
const onSelect = (info: any) => {
let {file} = info
let reader = new FileReader();
reader.onload = (e: ProgressEvent<FileReader>) => {
if (e && e.target && e.target.result) {
let space: string = e.target.result.toString();
importSpace(JSON.parse(space)) // importSpace: 发送请求, 返回 Promise 对象
.then(() => {
message.success("导入成功");
})
.catch(e => message.error("导入失败"));
}
};
reader.readAsText(file);
};

pyenv

安装

1
2
3
4
5
# 安装 brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 安装 pyenv
brew install pyenv

生效

1
eval "$(pyenv init -)"

安装 Python 版本

1
pyenv install 3.9.10

使用版本

1
pyenv global 3.9.10

错误

openssl 错误

1
2
3
...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
...

解决

1
2
3
4
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install 2.7.16

# 或者尝试
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv

flink

Protobuf

设置自定义序列化

引入依赖

1
2
3
4
5
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill-protobuf</artifactId>
<version>0.10.0</version>
</dependency>

设置自定义序列化类

1
2
3
import com.twitter.chill.protobuf.ProtobufSerializer

env.getConfig.registerTypeWithKryoSerializer(classOf[PbMessage], classOf[ProtobufSerializer])

参数

1
2
3
4
5
6
7
8
9
10
-m    address of job manager which to connect
-d detached mode
-yd yarn detached mode
-ynm yarn application name
-yn number of yarn container to allocate = Number of Task Managers
-ys Number of slots per TaskManager
-yjm Memory for JobManager Container with optional unit (default: MB)
-ytm Memory per TaskManager Container with optional unit (default: MB)
-p The parallelism with which to run the program.
-c class to run

cassandra - cql

语法

CQL

Datacenter

1
2
use system;
select data_center from local;

Role / User

创建

1
2
3
4
5
CREATE ROLE [IF NOT EXISTS] role_name 
[WITH SUPERUSER = true | false
| LOGIN = true | false
| PASSWORD = 'password'
| OPTIONS = option_map]

示例

1
2
CREATE ROLE IF NOT EXISTS 'root' WITH SUPERUSER = true AND LOGIN = false;
CREATE ROLE IF NOT EXISTS 'root' WITH SUPERUSER = true AND PASSWORD = 'root';

修改权限

1
2
3
4
5
ALTER ROLE role_name 
[WITH [PASSWORD = 'password']
[LOGIN = true | false]
[SUPERUSER = true | false]
[OPTIONS = map_literal]]

示例

1
ALTER ROLE root WITH PASSWORD = 'NewPassword';

Key Space

查询

1
2
# 列出所有 keysapces
desc keyspaces;

创建

1
2
3
4
5
6
7
CREATE  KEYSPACE [IF NOT EXISTS] keyspace_name 
WITH REPLICATION = {
'class' : 'SimpleStrategy', 'replication_factor' : N }
| 'class' : 'NetworkTopologyStrategy',
'dc1_name' : N [, ...]
}
[AND DURABLE_WRITES = true|false] ;

示例

1
2
3
4
CREATE  KEYSPACE IF NOT EXISTS "trace" WITH REPLICATION = {
'class' : 'NetworkTopologyStrategy',
'vg' : 2
}

Table

查询

1
desc <keyspace-name>;
1
2
use <keyspace-name>;
desc tables;

创建

1
2
3
4
5
6
7
CREATE TABLE [IF NOT EXISTS] [keyspace_name.]table_name ( 
column_definition [, ...]
PRIMARY KEY (column_name [, column_name ...])
[WITH table_options
| CLUSTERING ORDER BY (clustering_column_name order])
| ID = 'table_hash_tag'
| COMPACT STORAGE]

数据类型参考这里

删除

1
DROP TABLE [IF EXISTS] keyspace_name.table_name

修改

添加列

1
2
3
4
5
6
ALTER TABLE [keyspace_name.] table_name 
[ALTER column_name TYPE cql_type]
[ADD (column_definition_list)]
[DROP column_list | COMPACT STORAGE ]
[RENAME column_name TO column_name]
[WITH table_properties];

示例

1
ALTER TABLE trace.ranker ADD rid TEXT;

Query

1
2
3
// 查询一条
select * from ks.table limit 1;
select * from ks.table where id='value' limit 1;