在树莓派3b上部署minio服务

安装 我的树莓派安装的是manjaro,直接执行如下命令即可 yay -S minio 官方的安装文档开源参考 https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-single-drive.html 启用服务 systemctl enable minio 修改配置 主要修改mino的设置文件,文件位置为/etc/minio/minio.conf # Local export path. MINIO_VOLUMES="/srv/minio/data/" # Server user. MINIO_ROOT_USER=gopher # Server password. MINIO_ROOT_PASSWORD=gopher # Use if you want to run Minio on a custom port. MINIO_OPTS="--console-address :8888" MINIO_SERVER_URL="https://minio.xxx.org" MINIO_BROWSER_REDIRECT_URL="https://minio-console.xxx.org" 修改 MINIO_OPTS 主要是为了自定义Console的端口,而这个参数主要是在service定义中使用,安装软件后自动使用的service(路径为/usr/lib/systemd/system/minio.service)定义如下 [Unit] Description=Minio Documentation=https://docs.minio.io Wants=network-online.target After=network-online.target AssertFileIsExecutable=/usr/bin/minio [Service] # Specifies the maximum file descriptor number that can be opened by this process LimitNOFILE=65536 Type=simple User=minio Group=minio EnvironmentFile=/etc/minio/minio....

April 12, 2023 · 1 min · czyt

一些Rust的学习资料

在线教程 concurrency programming via rust https://blog.fudenglong.site/Programming-Rust/ jetbrains出品的rust教程 Rust Book experiment 微软出品:写给.net开发人员的Rust教程 Google Android团队写的Rust教程 通过例子学rust https://cheats.rs/ Rust语言圣经 learn how to write macros in Rust Operating System development tutorials in Rust on the Raspberry Pi Rust语言实战 inside rust std library A Plugin System in Rust https://learning-rust.github.io https://github.com/CleanCut/ultimate_rust_crash_course Writing a JVM in Rust Rust 宏小册 Writing an OS in Rust 清华大学程序设计训练(Rust) Rust 异步编程指南 rust ffi guide Rust基础教程 rCore-Tutorial-Book 第三版 OffensiveRust RustPrimer Rust Atomics and Locks中文版 Rust 程序设计语言 2021版 中文 The Rust on ESP Book中文版 rust 教程资料收集 - fkysly case studies Y分钟速成X=Rust Rust 101 Rust Design Patterns 中文版 / pdf gRPC相关 https://blog....

March 28, 2023 · 1 min · czyt

我和AI讨论的一些C#话题

很久没有用C#,最近需要使用。下面是跟AI问的一些C#的问题,未作整理。 基础 Span类型 c# Span的应用场景及具体例子 Span是一种新的引用类型,它允许存储和操作连续的内存块。它特别适用于那些需要高效处理内存块的应用场景,例如字符串处理、IO操作和序列化/反序列化。 下面是一些具体的例子: 字符串处理:Span可以用于快速地操作字符串,例如从字符串中截取子串、替换子串、查找子串等。下面是一个例子: string str = "hello world"; Span<char> span = str.AsSpan(6, 5); // 从第6个字符开始,截取长度为5的子串 IO操作:Span可以用于将IO操作映射到内存中,以提高性能。下面是一个例子: using (FileStream stream = File.OpenRead("file.txt")) { byte[] buffer = new byte[1024 * 1024]; while (stream.Read(buffer) > 0) { Span<byte> span = buffer.AsSpan(); // 将字节数组映射为Span // 处理Span } } 序列化/反序列化:Span可以用于快速地序列化和反序列化数据,尤其是在网络传输等场景中。下面是一个例子: public static void Serialize<T>(T value, Span<byte> buffer) where T : struct { unsafe { fixed (byte* ptr = buffer) { *(T*)ptr = value; // 将值拷贝到Span中 } } } public static T Deserialize<T>(Span<byte> buffer) where T : struct { unsafe { fixed (byte* ptr = buffer) { return *(T*)ptr; // 从Span中读取值 } } } 异步 c# SynchronizationContext的使用场景及例子...

March 24, 2023 · 3 min · czyt

【译】如何使用 http.ResponseController 类型

本文原文地址 https://www.alexedwards.net/blog/how-to-use-the-http-responsecontroller-type,使用chatGPT翻译 One of my favorite things about the recent Go 1.20 release is the new http.ResponseController type, which brings with it three nice benefits: 关于最近的 Go 1.20 版本,我最喜欢的事情之一是新的 http.ResponseController 类型,它带来了三个好处: You can now override your server-wide read and write deadlines on a per request basis. 您现在可以根据每个请求覆盖服务器范围内的读取和写入截止日期。 The pattern for using the http.Flusher and http.Hijacker interfaces is clearer and feels less hacky. No more type assertions necessary! 使用 http.Flusher 和 http....

March 9, 2023 · 6 min · czyt

golang CGO参考

开源项目 https://github.com/dolthub/go-library-sample https://github.com/draffensperger/go-interlang https://github.com/kbehouse/go_call_cxx_so https://github.com/tailscale/libtailscale https://github.com/iikira/golang-msvc https://github.com/vladimirvivien/go-cshared-examples https://github.com/tailscale/libtailscale/tree/main 文档 Embedding Go in C Calling C code from go C? Go? Cgo! CGO编程(Go语言高级编程) https://stackoverflow.com/questions/14581063/golang-cgo-converting-union-field-to-go-type https://sunzenshen.github.io/tutorials/2015/05/09/cgotchas-intro.html https://totallygamerjet.hashnode.dev/the-smallest-go-binary-5kb 代码片段 Convert ‘C’ array to golang slice func carray2slice(array *C.int, len int) []C.int { var list []C.int sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&list))) sliceHeader.Cap = len sliceHeader.Len = len sliceHeader.Data = uintptr(unsafe.Pointer(array)) return list }

February 3, 2023 · 1 min · czyt

命令行的艺术

*** 本文摘自项目** https://github.com/jlevy/the-art-of-command-line 命令行的艺术 前言 基础 日常使用 文件及数据处理 系统调试 单行脚本 冷门但有用 仅限 OS X 系统 仅限 Windows 系统 更多资源 免责声明 熟练使用命令行是一种常常被忽视,或被认为难以掌握的技能,但实际上,它会提高你作为工程师的灵活性以及生产力。本文是一份我在 Linux 上工作时,发现的一些命令行使用技巧的摘要。有些技巧非常基础,而另一些则相当复杂,甚至晦涩难懂。这篇文章并不长,但当你能够熟练掌握这里列出的所有技巧时,你就学会了很多关于命令行的东西了。 这篇文章是许多作者和译者共同的成果。 这里的部分内容 首次 出现 于 Quora, 但已经迁移到了 Github,并由众多高手做出了许多改进。 如果你在本文中发现了错误或者存在可以改善的地方,请贡献你的一份力量。 前言 涵盖范围: 这篇文章不仅能帮助刚接触命令行的新手,而且对具有经验的人也大有裨益。本文致力于做到覆盖面广(涉及所有重要的内容),具体(给出具体的最常用的例子),以及简洁(避免冗余的内容,或是可以在其他地方轻松查到的细枝末节)。在特定应用场景下,本文的内容属于基本功或者能帮助您节约大量的时间。 本文主要为 Linux 所写,但在仅限 OS X 系统章节和仅限 Windows 系统章节中也包含有对应操作系统的内容。除去这两个章节外,其它的内容大部分均可在其他类 Unix 系统或 OS X,甚至 Cygwin 中得到应用。 本文主要关注于交互式 Bash,但也有很多技巧可以应用于其他 shell 和 Bash 脚本当中。 除去“标准的”Unix 命令,本文还包括了一些依赖于特定软件包的命令(前提是它们具有足够的价值)。 注意事项: 为了能在一页内展示尽量多的东西,一些具体的信息可以在引用的页面中找到。我们相信机智的你知道如何使用 Google 或者其他搜索引擎来查阅到更多的详细信息。文中部分命令需要您使用 apt-get,yum,dnf,pacman, pip 或 brew(以及其它合适的包管理器)来安装依赖的程序。 遇到问题的话,请尝试使用 Explainshell 去获取相关命令、参数、管道等内容的解释。 基础 学习 Bash 的基础知识。具体地,在命令行中输入 man bash 并至少全文浏览一遍; 它理解起来很简单并且不冗长。其他的 shell 可能很好用,但 Bash 的功能已经足够强大并且到几乎总是可用的( 如果你只学习 zsh,fish 或其他的 shell 的话,在你自己的设备上会显得很方便,但过度依赖这些功能会给您带来不便,例如当你需要在服务器上工作时)。...

February 2, 2023 · 9 min · czyt

Golang Web框架Buffalo 简单使用

官方文档 https://gobuffalo.io 安装 安装要求 Before installing make sure you have the required dependencies installed: A working Go environment Go version v1.16.0. Frontend Requirements# The following requirements are optional. You don’t need them if you want to build an API or if you prefer to build your app in an old-fashioned way. node version 8 or greater either yarn or npm for the asset pipeline built upon webpack. Database Specific Requirements# Again, if you don’t need a database, you won’t need these....

January 29, 2023 · 1 min · czyt

从Golang的开源项目中学习不同的功能实现

缘起 最近看到有些go开源项目中的代码,看到其中的功能,故整理备用。 数据结构 优先级队列 项目 https://github.com/tigrisdata/tigris // Copyright 2022-2023 Tigris Data, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied....

November 25, 2022 · 54 min · czyt

C#扫码枪输入Hook

摘自网络,测试可用 public class ScanerHook { public delegate void ScanerDelegate(ScanerCodes codes); public event ScanerDelegate ScanerEvent; //private const int WM_KEYDOWN = 0x100;//KEYDOWN //private const int WM_KEYUP = 0x101;//KEYUP //private const int WM_SYSKEYDOWN = 0x104;//SYSKEYDOWN //private const int WM_SYSKEYUP = 0x105;//SYSKEYUP //private static int HookProc(int nCode, Int32 wParam, IntPtr lParam); private int hKeyboardHook = 0;//声明键盘钩子处理的初始值 private ScanerCodes codes = new ScanerCodes();//13为键盘钩子 //定义成静态,这样不会抛出回收异常 private static HookProc hookproc; delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam); [DllImport("user32....

November 1, 2022 · 4 min · czyt

使用protoc-gen-star编写protoc插件

预备知识 需要安装的软件 protoc golang go 软件包 github.com/lyft/protoc-gen-star 插件调用步骤 protoc,PB编译器,使用一组标志(记录在protoc -h下)进行配置,并将一组文件作为参数交给它。在这种情况下,I标志可以被多次指定,是它在proto文件中用于导入依赖关系的查找路径。默认情况下,官方描述符protos已经被包含在内。 myplugin_out 告诉 protoc 使用 protoc-gen-myplugin protoc-plugin。这些插件会从系统的 PATH 环境变量中自动解析,或者可以用另一个标志明确指定。官方的protoc-plugins (例如,protoc-gen-python) 已经在protoc注册了。该标志的值是特定于特定插件的,但 :…/generated 后缀除外。这个后缀表示protoc将把该包生成的文件放在哪个根目录下(相对于当前工作目录)。然而,这个生成的输出目录不会传播给 protoc-gen-myplugin,所以它需要在标志的左边重复。PG* 通过一个 output_path 参数支持这一点。 protoc 解析传入的 proto 文件,确保它们在语法上是正确的,并加载任何导入的依赖项。它将这些文件和依赖关系转换成描述符 (它们本身就是 PB 消息),并创建一个 CodeGeneratorRequest (又是一个 PB)。protoc 将这个请求序列化,然后执行每个配置的 protoc-plugin,通过 stdin 发送有效载荷。 protoc-gen-myplugin 启动,接收请求的有效载荷,并将其解密。一个基于 PG* 的 protoc-plugin 有两个阶段。首先,PG* 对从 protoc 收到的 CodeGeneratorRequest 进行解密,并为每个文件和其包含的所有实体创建一个完全连接的抽象语法树 (AST)。为这个插件指定的任何参数也会被解析,以便以后使用。 当这一步完成后,PG*就会执行任何注册的模块,把构建的AST交给它。模块可以被写成生成人工制品(例如,文件),或者只是对所提供的图进行某种形式的验证而没有任何其他副作用。模块在针对PB的操作方面提供了极大的灵活性。 一旦所有的模块都被运行,PG*会将任何自定义的工件写入文件系统,或者将生成器特定的工件序列化为CodeGeneratorResponse并将数据发送到其stdout。这整个流程看起来像这样。 foo.proto → protoc → CodeGeneratorRequest → protoc-gen-myplugin → CodeGeneratorResponse → protoc → foo.pb.go 假设插件名称为diy,则需要编译程序为protoc-gen-diy,并将程序加入系统Path变量,通过下面的命令调用插件。 protoc -I ....

October 29, 2022 · 3 min · czyt