-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ee7752
commit 43f2779
Showing
38 changed files
with
3,157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# C# Protobuf 接收数据并解析数据 | ||
|
||
在流里读出数据后,需要将数据包大小缩短成有效大小,即 `bytesRead` 长度。 | ||
|
||
下面是 C# 端接收并解析数据的示例代码: | ||
|
||
```C# | ||
private void ReceiveMessage() | ||
{ | ||
stream = client.GetStream(); | ||
int bytesRead; | ||
while (isKeepReading) | ||
{ | ||
if (stream.CanRead) | ||
{ | ||
buffer = new byte[client.ReceiveBufferSize]; | ||
bytesRead = stream.Read(buffer, 0, client.ReceiveBufferSize); | ||
if (bytesRead > 0) | ||
{ | ||
MemoryStream protoStream = new MemoryStream(buffer,0, bytesRead); | ||
Cas.Proto.DataMessage dataMessage = Cas.Proto.DataMessage.Parser.ParseFrom(protoStream); | ||
switch (dataMessage.Type) | ||
{ | ||
case DataMessage.Types.Type.Mesh: | ||
Debug.Log("Mesh类型"); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# C++ 中位运算的妙用:与运算和或运算的合并标志位 | ||
|
||
当我们处理程序中的多个标志位时,将它们合并成一个整数是一种常见的技巧。这种做法不仅有助于提高代码的可读性,还使得对多个标志位进行操作更为方便。 | ||
|
||
在C++中,可以使用按位或(`|`)运算符来实现这一功能。 | ||
|
||
## 合并标志位的基本思想 | ||
|
||
在C++中,合并标志位的基本思想是将多个标志位的二进制表示中的相应位进行按位或运算,形成一个包含所有标志位信息的整数。这样,就能够用一个整数表示多个不同的状态或选项。 | ||
|
||
## 代码示例 | ||
|
||
```cpp | ||
#include <iostream> | ||
|
||
int main() { | ||
// 定义三个标志位 | ||
const int FLAG_A = 0b0001; | ||
const int FLAG_B = 0b0010; | ||
const int FLAG_C = 0b0100; | ||
|
||
// 合并标志位 | ||
int flags = FLAG_A | FLAG_C; | ||
|
||
// 检查是否设置了某个标志位 | ||
if (flags & FLAG_A) { // True | ||
std::cout << "FLAG_A is set." << std::endl; | ||
} | ||
|
||
if (flags & FLAG_B) { // False | ||
std::cout << "FLAG_B is set." << std::endl; | ||
} | ||
|
||
if (flags & FLAG_C) { // True | ||
std::cout << "FLAG_C is set." << std::endl; | ||
} | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
在这个示例中,首先定义了三个标志位 `FLAG_A`、`FLAG_B` 和 `FLAG_C`,它们分别对应二进制的 `0001`、`0010` 和 `0100`。然后,使用 `|` 运算符将 `FLAG_A` 和 `FLAG_C` 合并成 `flags`。 | ||
|
||
接下来,使用按位与运算符 `&` 来检查 `flags` 中是否设置了每个标志位。如果某个标志位被设置,相应的条件语句将会执行。 | ||
|
||
## 优点与用途 | ||
|
||
- **可读性提高:** 将多个标志位合并成一个整数可以提高代码的可读性。通过使用有意义的常量名称,可以更清晰地了解整数表示的含义。 | ||
- **便于操作:** 合并后的整数可以方便地进行各种按位操作,如按位与、按位或等,而无需单独处理每个标志位。 | ||
- **节省内存:** 在某些情况下,将多个标志位合并成一个整数可能节省内存,特别是当标志位数量较多时。 | ||
|
||
在实际编码中,合并标志位是一种常见的编程技巧,适用于需要处理多个二进制状态的情况。这种技术不仅简化了代码,还使得代码更易维护和扩展。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Cassius0924 的 VSCode 插件 | ||
|
||
## \# | ||
- .NET Install Tool for Extenstion | ||
## A | ||
## B | ||
## C | ||
- C/C++ | ||
- C/C++ Extension Pack | ||
- C/C++ Themes | ||
- C# | ||
- C# Dev Kit | ||
- CMake | ||
- CMake Language Support | ||
- Cmake Tools | ||
- Codelf | ||
- Code Runner | ||
- Code Snap | ||
- Code Together | ||
- Color Highlight | ||
- Color Picker | ||
- CSS Peek | ||
## D | ||
- Dev Containers | ||
- Docker | ||
- Doxygen Documentation Genertor | ||
## E | ||
## F | ||
## G | ||
- Git Graph | ||
- git-commit-plugin | ||
- GitHub Copilot | ||
- GitHub Copilot Chat | ||
- GitHub Copilot Labs | ||
- GitHub Pull Resquest and Issues | ||
## H | ||
## I | ||
- IntelliCode API Usage Examples | ||
- IntelliCode for C# Dev Kit | ||
- IntelliJ IDEA New UI Theme | ||
## J | ||
- Jetbrains Fleet Theme | ||
- JetBrains Icon Theme | ||
- JetBrains IDE Keymap | ||
## K | ||
## L | ||
- Live Sever | ||
- Live Share | ||
## M | ||
- Markdown Preview Github Styling | ||
- Markdown Preview Mermaid Support | ||
- Marp for VS Code | ||
- MASM | ||
- masm-code | ||
- MASM/TASM | ||
- Material Icon Theme | ||
- mypy | ||
## N | ||
## O | ||
## P | ||
- Pylance | ||
- Python | ||
## Q | ||
## R | ||
- Remote - SSH: Editing Configuration Files | ||
- Remote - Development | ||
- Remote Explorer | ||
- REST API | ||
- Ruff | ||
## S | ||
- Slidev | ||
## T | ||
- TODO Highlight v2 | ||
## U | ||
## V | ||
- Vim | ||
- VSCode DOSBox | ||
- VSCode Git Commit Message | ||
## W | ||
- WSL | ||
## X | ||
## Y | ||
## Z | ||
|
||
- Marp for VS Code | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Google Coral Dev Board 修改散热器温度阈值指南 | ||
|
||
Google Coral Dev Board 是一款功能强大的开发板,可用于构建机器学习应用程序。该板配备了 Edge TPU,这是一款专门用于机器学习任务的加速器。Edge TPU 非常高效,但它也可能会产生热量。如果温度过高,Edge TPU 可能会降频或关闭。 | ||
|
||
## 查看目前 TPU 温度 | ||
|
||
使用命令查看目前开发板核心 TPU 的温度,输出温度为1000倍的摄氏度。 | ||
|
||
```shell | ||
cat /sys/class/thermal/thermal_zone0/temp | ||
``` | ||
|
||
如输出`54000`,则代表当前温度为54摄氏度。 | ||
|
||
## 修改散热器温度阈值 | ||
|
||
禁用热管理: | ||
|
||
```shell | ||
echo "disabled" > /sys/devices/virtual/thermal/thermal_zone0/mode | ||
``` | ||
|
||
修改散热器温度阈值为50摄氏度 | ||
|
||
```shell | ||
echo 50000 > /sys/devices/platform/gpio_fan/hwmon/hwmon0/fan1_target | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# HammerSpoon 入门指南 | ||
|
||
## 介绍 | ||
|
||
HammerSpoon 这是一款强大的OS X自动化工具。 | ||
|
||
HammerSpoon 本质上就是操作系统和Lua脚本引擎之间的桥梁。 | ||
|
||
HammerSpoon 之所以强大,在于它提供了一系列向用户公开特定系统功能模块的扩展。有了这些扩展,用户便可利用Lua脚本来控制 macOS 的各个方面。 | ||
|
||
## 安装 | ||
|
||
建议直接使用 Homebrew 安装。 | ||
|
||
```shell | ||
brew install hammerspoon --cask | ||
``` | ||
|
||
手动安装参考[官方 Github](https://github.com/Hammerspoon/hammerspoon)。 | ||
|
||
## 参考文档 | ||
|
||
- [HammerSpoon 入门指南](https://www.hammerspoon.org/go/) | ||
- [HammerSpoon API 文档](https://www.hammerspoon.org/docs/) | ||
- [HammerSpoon 常见问题](https://www.hammerspoon.org/faq/) | ||
- [HammerSpoon 配置示例](https://github.com/Hammerspoon/hammerspoon/wiki/Sample-Configurations) | ||
|
||
## 快速开始 | ||
|
||
### 启动应用 | ||
|
||
安装完毕后启动 HammerSpoon,设置中打开辅助功能。 | ||
|
||
![HS Preferences](https://s2.loli.net/2023/08/06/ZkNiYmXvIRPJ4bs.png) | ||
|
||
接着点击 Open Config 打开配置文件。下面开始教程。 | ||
|
||
### Hello World | ||
|
||
```lua | ||
-- Hello World | ||
hs.hotkey.bind({"cmd", "alt", "shift", "ctrl"}, "W", function() | ||
hs.alert.show("HammerSpoon is working!") | ||
end) | ||
``` | ||
|
||
> 每次修改配置文件后都需要点击 Reload Config。 | ||
以上代码实现了点击快捷键 `command` + `option` + `shift` + `control` + `w`,在屏幕中间显示弹窗提示的功能。 | ||
|
||
![Hello World](https://s2.loli.net/2023/08/06/PR3k6Ty4K5AVIqx.png) | ||
|
||
也可以使用 macOS 原生通知形式 | ||
|
||
```lua | ||
-- Hello World(macOS native notification) | ||
hs.hotkey.bind({"cmd", "alt", "shift", "ctrl"}, "Q", function() | ||
hs.notify.new({title="macOS Native Notification", informativeText="HammerSpoon is working"}):send() | ||
end) | ||
``` | ||
|
||
![macOS native notification](https://s2.loli.net/2023/08/06/HwxemCVBGf1KNnh.png) | ||
![[bg right opacity]](https://s2.loli.net/2023/08/06/HwxemCVBGf1KNnh.png) | ||
|
||
> [hs.hotkey API 介绍](https://www.hammerspoon.org/docs/hs.hotkey.html) | ||
> | ||
> [hs.notify API 介绍](https://www.hammerspoon.org/docs/hs.notify.html) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# HoloLens 应用程序渲染不出 Mesh 面片的解决方法 | ||
|
||
## 问题 | ||
|
||
当项目在 Unity 测试 Mesh 面片渲染正常,而打包部署到 HoloLens 后就无法正常显示 Mesh 面片了。 | ||
|
||
失败原因可能出在 Holo 不支持程序代码所用的 Shader 着色器,需要使用 MRTK3 官方提供的 Shader 着色器。 | ||
|
||
## 解决方法 | ||
|
||
默认前提你的项目已经安装了 MRTK3 开发包。 | ||
|
||
MRTK3 官方可用的彩色 Mesh 着色器为 `Mixed Reality Toolkit/Dashed Ray`。 | ||
|
||
```C# | ||
UnityEngine.Mesh mesh = new UnityEngine.Mesh(); | ||
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; #当面片数量超过65535时需要设置此项 | ||
GetComponent<MeshFilter>().mesh = mesh; | ||
Material material = new Material(Shader.Find("Mixed Reality Toolkit/Dashed Ray")); | ||
GetComponent<MeshRenderer>().material = material; | ||
``` |
Oops, something went wrong.