tonglin0325的个人主页

ubuntu下安装TexLive和Texmaker

1.首先下载TexLive2015的ISO文件,挂载并安装

参考:ubuntu14.04配置中文latex完美环境(texlive+texmaker+lyx)

中文字体设置参考:ubuntu 下安装 texlive 并设置 ctex 中文套装

首先新建一个目录,文件就挂载在这个目录下

1
2
sudo mkdir /media/cdimage

挂载,并使其有读写权限

1
2
sudo mount -o rw,loop /media/lintong/工作/Ubuntu_Software/64bit_Software/TeXLive/TeXLive2015/texlive2015.iso /media/cdimage

 使用下面的命令会出现问题:mount: /dev/loop3 is write-protected, mounting read-only

1
2
sudo mount -o loop /media/XXXX/TeXLive/TeXLive2015/texlive2015.iso /media/cdimage

进入挂载目录

1
2
cd /media/cdimage

 进行安装

1
2
sudo perl install-tl -gui

全文 >>

ubuntu16.04安装clickhouse

1.安装步骤参考官方文档

1
2
https://clickhouse.com/docs/zh/getting-started/install

如下

1
2
3
4
5
6
7
8
9
10
11
12
sudo apt-get install -y apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754

echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee \
/etc/apt/sources.list.d/clickhouse.list
sudo apt-get update

sudo apt-get install -y clickhouse-server clickhouse-client

sudo service clickhouse-server start
clickhouse-client # or "clickhouse-client --password" if you've set up a password.

填写default user的初始密码,回车可以看到如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Enter password for default user:
Password for default user is saved in file /etc/clickhouse-server/users.d/default-password.xml.
Setting capabilities for clickhouse binary. This is optional.
Cannot set 'net_admin' or 'ipc_lock' or 'sys_nice' or 'net_bind_service' capability for clickhouse binary. This is optional. Taskstats accounting will be disabled. To enable taskstats accounting you may add the required capability later manually.
chown -R clickhouse:clickhouse '/etc/clickhouse-server'

ClickHouse has been successfully installed.

Start clickhouse-server with:
sudo clickhouse start

Start clickhouse-client with:
clickhouse-client --password

修改clickhouse数据路径配置,需要将所有/var/lib/clickhouse的配置修改成

1
2
sudo sed -i 's/var\/lib\/clickhouse/data01\/clickhouse/g' /etc/clickhouse-server/config.xml

创建目录

1
2
3
lintong@master:/data01$ sudo mkdir clickhouse
lintong@master:/data01$ sudo chown -R clickhouse:clickhouse ./clickhouse

全文 >>

java使用gRPC框架

官方文档

1
2
https://grpc.io/docs/languages/java/quickstart/

官方example

1
2
https://github.com/grpc/grpc-java

1.定义proto文件

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
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}

proto定义,参考官方文档

1
2
https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/helloworld.proto

2.编译proto文件

1.使用protoc命令编译

在项目目录下运行编译命令,里面使用了protoc-gen-grpc-java执行文件,需要参考:编译grpc-java项目生成protoc-gen-grpc-java文件

1
2
protoc --plugin=protoc-gen-grpc-java=./protoc-gen-grpc-java -I=./ --java_out=./src/main/java/ --grpc-java_out=./src/main/java/ ./src/main/proto/helloworld.proto

得到proto文件中定义的model和service的java代码

全文 >>

编译grpc-java项目生成protoc-gen-grpc-java文件

使用protoc命令生成service代码的时候,需要使用如下命令

1
2
protoc --plugin=protoc-gen-grpc-java=./protoc-gen-grpc-java -I=./ --java_out=./src/main/java/ --grpc-java_out=./src/main/java/ ./src/main/proto/helloworld.proto

其中的protoc-gen-grpc-java执行文件需要自己编译生成

编译的步骤如下

git clone grpc-java项目,

1
2
git clone git@github.com:grpc/grpc-java.git

切换到使用的grpc版本,比如v1.59.0,编译这个版本需要jdk11的支持

1
2
git checkout v1.59.0

使用gradlew命令进行编译

全文 >>

go使用gRPC框架

官方文档

1
2
https://grpc.io/docs/languages/go/quickstart/

官方example

1
2
https://github.com/grpc/grpc-go

1.定义proto文件

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
syntax = "proto3";

option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";
option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";

package helloworld;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}

proto定义,参考官方文档

1
2
https://github.com/grpc/grpc-go/blob/master/examples/helloworld/helloworld/helloworld.proto

2.编译proto文件

使用protoc命令编译

需要先安装compile插件,参考:https://grpc.io/docs/languages/go/quickstart/

1
2
3
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

全文 >>

go学习笔记——text template

golang可以使用text/template来实现模板生成文本,官方文档:https://pkg.go.dev/text/template

1.变量

可以在模板中定义变量,然后将这些变量赋值到模板的变量中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import "text/template"

// 定义结构体
type Inventory struct {
Material string
Count uint
}
// 赋值
sweaters := Inventory{"wool", 17}
// 定义模板
tmpl, err := template.New("test").Parse(`
{{.Count}} items are made of {{.Material}}
`)
if err != nil {
panic(err)
}
// 填充模板
err = tmpl.Execute(os.Stdout, sweaters)
if err != nil {
panic(err)
}

输出

1
2
17 items are made of wool

2.if else

1.判断字符串是否相等

1
2
3
4
5
6
7
8
9
10
11
{{ if eq .Material "wool" }}
Material is "wool"
{{ else if eq .Material "not wool" }}
Material is not "wool"
{{ end }}
{{ if eq .Count 17 }}
Count is 17
{{ else if eq .Count 10 }}
Count is not 10
{{ end }}

输出

1
2
3
4
Material is "wool"

Count is 17

2.多条件,与或非

1
2
3
4
{{ if or (eq .Material "not wool") (eq .Count 17) }}
Count is 17
{{ end }}

输出

全文 >>