Rasp3b 安装MongoDB

安装 机器安装的是Manjaro,所以本文介绍的是Manjaro的树莓派3安装方式 ➜ ~ screenfetch czyt@** OS: Manjaro-ARM 22.01 Kernel: aarch64 Linux 5.15.24-1-MANJARO-ARM-RPI ##### Uptime: 21d 21h 58m ####### Packages: Unknown ##O#O## Shell: zsh 5.8.1 ####### Disk: 11G / 118G (9%) ########### CPU: BCM2835 @ 4x 1.2GHz ############# GPU: ############### RAM: 248MiB / 919MiB ################ ################# ##################### ##################### ################# 使用命令 yay -S mongodb44-bin进行安装,安装完毕后 启用服务 systemctl enable mongodb 检查服务状态 systemctl status mongodb ● mongodb.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2022-03-23 13:11:08 CST; 11s ago Docs: https://docs.mongodb.org/manual Main PID: 624895 (mongod) CPU: 2.610s CGroup: /system.slice/mongodb.service └─624895 /usr/bin/mongod --config /etc/mongodb.conf 常见问题 非法指令 (核心已转储) 启动服务报错 非法指令 (核心已转储)英文系统可能是(Illegal instruction(core dumped)) 开始使用的是 yay -S mongodb-bin进行安装,后搜索官方论坛发现是官方打包的时候默认使用了最新架构,但是树莓派是老设备,可能不支持部分指令,换成上文的指令安装4.x版本后解决。 ...

2022-03-23 · 2 分钟 · czyt

WPF Prism 8如何注册Logging

Nuget包 基础包 Microsoft Logging Abstractions Microsoft Extensions DependencyInjection 可选日志包 可以按实际需求进行选择,如NLog等,我们这里采用的是 Serilog 这个Nuget包Serilog Extensions Logging 根据日志输出的目标不同,可以选择不同的扩展方法包 目标 包名 说明 文件 Serilog.Sinks.File WiteTo可以使用File方法详细说明 命令行 Serilog.Sinks.Console 调试输出 Serilog.Sinks.Debug WiteTo可以使用Debug方法 其他扩展,请搜索 点击 日志容器注册 我们使用的是 DryIoc 进行注册,需要安装Nuget包 DryIoc.Microsoft.DependencyInjection 具体代码如下: protected override IContainerExtension CreateContainerExtension() { var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); return new DryIocContainerExtension(new Container(CreateContainerRules()) .WithDependencyInjectionAdapter(serviceCollection)); } 如果是Unity 则需要安装包 Unity.Microsoft.DependencyInjection 具体代码如下: protected override IContainerExtension CreateContainerExtension() { var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); var container = new UnityContainer(); container.BuildServiceProvider(serviceCollection); return new UnityContainerExtension(container); } 我们对于不同的日志插件框架都是在 AddLogging这个地方进行添加的,需要注意的是我们不仅需要在ServiceCollection 中注册,还需要在容器对象中注册。注意区分 DryIoc中的WithDependencyInjectionAdapter 与Unity中的BuildServiceProvider使用差异。 ...

2022-03-08 · 1 分钟 · czyt

grpc-golang windows环境搭建说明

下载protoc,打开链接 下载后将对应的文件解压到gopath的bin目录。 下载protoc的golang插件。下载地址 链接 下载后放在protoc的同级目录(需要改扩展名为exe) 测试,定义一个Proto syntax = "proto3"; option go_package = ".;hello"; package main; message String { string value = 1; } 然后执行命令 protoc hello.proto --go_out=. ,大功告成,生成的文件内容如下: // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.24.0-devel // protoc v3.12.3 // source: hello.proto package hello import ( proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // This is a compile-time assertion that a sufficiently up-to-date version // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 type String struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` } func (x *String) Reset() { *x = String{} if protoimpl.UnsafeEnabled { mi := &file_hello_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *String) String() string { return protoimpl.X.MessageStringOf(x) } func (*String) ProtoMessage() {} func (x *String) ProtoReflect() protoreflect.Message { mi := &file_hello_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use String.ProtoReflect.Descriptor instead. func (*String) Descriptor() ([]byte, []int) { return file_hello_proto_rawDescGZIP(), []int{0} } func (x *String) GetValue() string { if x != nil { return x.Value } return "" } var File_hello_proto protoreflect.FileDescriptor var file_hello_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_hello_proto_rawDescOnce sync.Once file_hello_proto_rawDescData = file_hello_proto_rawDesc ) func file_hello_proto_rawDescGZIP() []byte { file_hello_proto_rawDescOnce.Do(func() { file_hello_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_proto_rawDescData) }) return file_hello_proto_rawDescData } var file_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_hello_proto_goTypes = []interface{}{ (*String)(nil), // 0: main.String } var file_hello_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_hello_proto_init() } func file_hello_proto_init() { if File_hello_proto != nil { return } if !protoimpl.UnsafeEnabled { file_hello_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*String); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hello_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_hello_proto_goTypes, DependencyIndexes: file_hello_proto_depIdxs, MessageInfos: file_hello_proto_msgTypes, }.Build() File_hello_proto = out.File file_hello_proto_rawDesc = nil file_hello_proto_goTypes = nil file_hello_proto_depIdxs = nil } 注意: ...

2022-02-28 · 3 分钟 · czyt

Rust安装及配置

下载rustup 从此处 下载,如果你需要安装vs的cpp生成工具,可以在这个页面 进行下载。 设置rustup镜像 字节提供的镜像 https://rsproxy.cn export RUSTUP_DIST_SERVER="https://rsproxy.cn" export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" 设置两个环境变量即可。windows可以使用下面的命令进行设置: setx RUSTUP_DIST_SERVER "https://rsproxy.cn" setx RUSTUP_UPDATE_ROOT "https://rsproxy.cn/rustup" 中科大 设置环境变量 RUSTUP_DIST_SERVER (用于更新 toolchain) export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static 以及 RUSTUP_UPDATE_ROOT (用于更新 rustup) export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup 华中科技大学 **方法一:**在“系统-高级系统设置-环境变量” 中增加环境变量。 变量名为 RUSTUP_DIST_SERVER,值为https://mirrors.hust.edu.cn/rustup。 变量名为 RUSTUP_UPDATE_ROOT,值为https://mirrors.hust.edu.cn/rustup/rustup。 **方法二(推荐):**直接执行下面的Powershell脚本: [System.Environment]::SetEnvironmentVariable("RUSTUP_DIST_SERVER", "https://mirrors.hust.edu.cn/rustup", "User") [System.Environment]::SetEnvironmentVariable("RUSTUP_UPDATE_ROOT", "https://mirrors.hust.edu.cn/rustup/rustup", "User") 设置RUSTUP_HOME和CARGO_HOME可以实现自定义安装路径 对于使用buf的开发者,需要添加下面的内容: [registries.buf] index = "sparse+https://buf.build/gen/cargo/" credential-provider = "cargo:token" 然后登陆,token可以从这里 获取 cargo login --registry buf "Bearer {token}" 更多内容,请参考https://buf.build/docs/bsr/generated-sdks/cargo crates.io 镜像 编辑 ~/.cargo/config ,这里使用的是中科大的镜像。 cargo版本 1.39 中添加了对 .toml 扩展的支持,并且是首选形式。如果两个文件都存在,Cargo 将使用不带扩展名的文件。 [source.crates-io] replace-with = 'ustc' [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index" 或者使用字节的,参考官网文档 ...

2022-02-28 · 9 分钟 · czyt

一个免费的TTS接口

示例: https://dds.dui.ai/runtime/v1/synthesize?voiceId=ppangf_csn&text=您好世界&speed=1&volume=50&audioType=wav 使用步骤 graph LR; 选择声音 --> 输入要转语音文本 --> 拼接URL --> 使用语音 参数说明: text 要转音频的文本内容 (200字以内) speed 语速 volume 声音大小 voiceId 发音类型可以取下面的值: VoiceId 名称 说明 qiumum_0gushi 精品秋木 活泼开朗适合有声读物等场景 kaolam_diantai 精品考拉 电台男声温柔的电台男声 juan1f 小美 客服女声声音甜美热情,客服、营销场景均适用 xmguof 婷婷 营销女声音色亲切大方,适用于电话销售、调研回访等场景 xmamif 小咪 营销女声活力甜美,适用于电话营销、邀约等场景 lunaif_ctn 晓健 标准粤语女声偏正式的标准粤语,适用于新闻播报等场景 hchunf_ctn 何春 自然粤语女声音色偏甜美自然,适用于家居播报等场景 dayaof_csd 大瑶 山东话女声音色偏甜美自然,适用于家居播报等场景 wqingf_csn 文卿 四川话女声音色偏甜美自然,适用于车载导航等场景 ppangf_csn 胖胖 四川话女声音色偏甜美自然,适用于家居播报等场景 yezi1f_csh 叶子 上海话女声音色偏甜美自然,适用于家居播报等场景 madoufp_yubo 麻豆 娱播女声甜美欢快的女声,适合做娱乐新闻的播报 madoufp_wenrou 麻豆 甜美温柔客服、营销、阅读听书的场景均可使用 xjingfp 小静 甜美女声音色甜美知性,可用于娱乐新闻等播报 xjingf_gushi 小静 自然音色甜美知性,可用于娱乐新闻等播报 xjingf 小静 商务知性音色甜美知性,可用于娱乐新闻等播报 zhilingfp 小玲 甜美女神音色亲切、欢快、自然,适合用于各种场景 zhilingfp_huankuai 小玲 欢快自然音色亲切、欢快、自然,适合用于各种场景 zhilingfa 小玲 标准小玲的音色亲切,甜美,自然,适合用于各种场景 zhilingf 传统小玲 甜美性感音色甜美、自然、性感,适合用于各种场景 anonyf 小佚 平和沉稳音色沉稳严肃,适合用于新闻播报等 xbekef 贝壳 可爱女童童真可爱,适合讲幼儿故事 xijunma 精品小军 新闻播报适合新闻播报等场景 xijunm 传统小军 标准正式标准发音,适合新闻播报等场景 geyou 葛爷 淡定风趣模仿葛优音色 gdgm 纲叔 沉稳幽默模仿郭德纲音色 zxcm 星哥 风趣幽默模仿周星驰音色 qianranf 传统然然 天真俏皮成人女声模仿女童音色 hyanif 小妮 温柔亲切适合情感电台播报等场景 gqlanf 标准小兰 邻家女声温柔的邻家女声,适合做客服音色 gqlanfp 精品小兰 温柔甜美温柔的邻家女声,适合做客服音色 qianranfa 标准然然 天真俏皮语速1.2–1.4更佳 kaolaf 考拉 端庄优雅适合做新闻资讯等场景 smjief 小洁 亲切缓和推荐百科等有声读物的播报 wjianm_xsheng 小江 亲切友善推荐电话客服的场景,推荐语速1.3 feyinf 风吟 女老师威严正式的女老师 jlshim 季老师 成熟稳重适用于新闻播报的场景 lili1f_shangwu 璃璃 商务大气适用于新闻、政务的内容播报 lili1f_yubo 璃璃 活力娱播适合娱乐新闻的播报 xizhef 行者 端庄正式端庄严肃的女声,适合社会新闻的播报 cyangfp 精品初阳 乖巧可爱乖巧可爱的女学生音色,可用于导航场景 cyangf 标准初阳 乖巧可爱乖巧可爱的女学生音色,可用于导航场景 lzliafp 精品连连 活泼可爱推荐讲童话故事等有声读物 lzliafa 标准连连 活泼可爱推荐讲童话故事等有声读物 lzliaf 传统连连 活泼可爱推荐有声读物的场景 gdfanf_natong 方方 元气男孩推荐有声读物的场景 hyanifa 标准小妮 温柔亲切适合情感电台播报等场景 lucyfa 小浩 干练适合英文场景 gdfanfp 芳芳 甜美客服推荐客服场景使用 aningfp 精品安宁 温婉温婉可人,适合讲哲理故事 aningf 标准安宁 温婉温婉可人,适合讲哲理故事 boy 堂堂 少先队推荐使用电话手表等智能设备场景 jjingf 标准晶晶 知性大方知性大方,适合多种文本与场景 jjingfp 精品晶晶 知性大方知性大方,适合多种文本与场景 kaolam 考拉 标准男声发音标准正式,适合新闻资讯等场景 lanyuf 蓝雨 温柔甜美温柔甜美的女声,擅长讲童话故事 lili1f_diantai 璃璃 电台安静适用情感电台的场景 qiumum 秋木 活泼开朗推荐讲寓言故事 tzruim 小睿 活力朝气适合读课文 xiyaof 小妖 慵懒烟嗓特殊的慵懒嗓音,适合讲悬疑小说 xiyaof_qingxin 小妖 清新甜美适合讲言情小说 yaayif 杨阿姨 和蔼可亲亲切的阿姨,适合讲百科知识等场景 zzherf 朱株儿 温柔舒适推荐讲童话故事等有声读物 juyinf_guigushi 绝音 鬼故事推荐讲鬼故事等恐怖场景 zzhuaf 砖砖 自然推荐讲寓言故事等有声读物 yukaim_all 俞老师 磁性发音自然有磁性,可用户哲理故事场景 linbaf_gaoleng 零八 高冷推荐有声读物的场景 linbaf_qingxin 零八 清新推荐有声读物的场景 xiyaof_laoshi 小妖 女老师推荐武侠小说等场景 anonyg 佚佚 成人女声模仿女童音色 luyaof 瑶瑶 自然亲切可用与情感电台等场景 官方网站 https://www.talkinggenie.com/tts

2022-02-28 · 2 分钟 · czyt

golang webserver with genergic base64 /favicon.ico

package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/favicon.ico", favicon) http.HandleFunc("/", hello) fmt.Printf("listening on http://localhost:8000/\n") http.ListenAndServe("localhost:8000", nil) } func favicon(w http.ResponseWriter, r *http.Request) { fmt.Printf("%s\n", r.RequestURI) w.Header().Set("Content-Type", "image/x-icon") w.Header().Set("Cache-Control", "public, max-age=7776000") fmt.Fprintln(w, "data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=\n") } func hello(w http.ResponseWriter, r *http.Request) { fmt.Printf("%s\n", r.RequestURI) fmt.Fprintln(w, "Hello, World!") }

2022-02-23 · 1 分钟 · czyt

Golang嵌入可执行程序

reddit链接 On Linux it might be possible to use the memfd_create system call, but that’s not portable to other operating systems. need go 1.16 + package main import ( _ "embed" "log" "os" "os/exec" "strconv" "golang.org/x/sys/unix" ) //go:embed binary var embeddedBinary []byte func main() { fd, err := unix.MemfdCreate("embedded_binary", 0) if err != nil { log.Fatal(err) } path := "/proc/" + strconv.Itoa(os.Getpid()) + "/fd/" + strconv.Itoa(int(fd)) err = os.WriteFile(path, embeddedBinary, 0755) if err != nil { log.Fatal(err) } cmd := exec.Command(path) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err = cmd.Run() if err != nil { log.Fatal(err) } } You should be able to replace that os.WriteFile with f := os.NewFile(fd, “memfd”); _, err := f.Write(embeddedBinary) for a simpler end result. ...

2022-02-23 · 1 分钟 · czyt

Golang通过ssh连接数据库

Mysql View this Gist on GitHub Postgresql View this Gist on GitHub

2022-02-23 · 1 分钟 · czyt

golang正则表达式小札

准备工作 golang正则需要引入包中的regexp包。 import ( "regexp" ) 如果需要复用正则表达式对象来提高性能,可以通过Compile() 或者 MustCompile()创建一个编译好的正则表达式对象。 支持的表达式 单个匹配: . any character, possibly including newline (flag s=true) [xyz] character class [^xyz] negated character class \d Perl character class \D negated Perl character class [[:alpha:]] ASCII character class [[:^alpha:]] negated ASCII character class \pN Unicode character class (one-letter name) \p{Greek} Unicode character class \PN negated Unicode character class (one-letter name) \P{Greek} negated Unicode character class 组合匹配: xy x followed by y x|y x or y (prefer x) 多次匹配: ...

2021-07-27 · 3 分钟 · czyt

golang不创建临时文件上传网络文件

func UploadFromUrl(uploadUrl string, resUrl string,postFileName string, submitField string) error { method := "POST" payload := &bytes.Buffer{} writer := multipart.NewWriter(payload) if res, err := http.Get(resUrl); err != nil { return err } else { defer func() { if res != nil { _ = res.Body.Close() } }() part, _ := writer.CreateFormFile(submitField, postFileName) if _, copyErr := io.Copy(part, res.Body); copyErr != nil { return copyErr } if err := writer.Close(); err != nil { return err } } client := &http.Client{} req, err := http.NewRequest(method, uploadUrl, payload) if err != nil { return err } req.Header.Set("Content-Type", writer.FormDataContentType()) resp, err := client.Do(req) if err != nil { return err } defer func() { _ = resp.Body.Close() client = nil writer = nil }() return nil }

2021-05-21 · 1 分钟 · czyt