update
This commit is contained in:
parent
65e2409fae
commit
28daffb38a
57
babylonjs/start.md
Normal file
57
babylonjs/start.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# Babylon js
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## depends
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vue 3
|
||||||
|
babylonjs 5
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add @babylonjs/core @babylonjs/loaders
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 三核心
|
||||||
|
|
||||||
|
- 场景
|
||||||
|
- 摄像头
|
||||||
|
- 光
|
||||||
|
|
||||||
|
一般使用babylonjs 分为 3个步骤
|
||||||
|
|
||||||
|
```js
|
||||||
|
// 1 初始化 engine
|
||||||
|
var canvas = document.getElementById('renderCanvas')
|
||||||
|
let engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
|
||||||
|
|
||||||
|
// 2 添加 场景、灯光、摄像头
|
||||||
|
var createScene = function () {
|
||||||
|
const scene = new BABYLON.Scene(engine);
|
||||||
|
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 3, new BABYLON.Vector3(0, 0, 0));
|
||||||
|
camera.attachControl(canvas, true);
|
||||||
|
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 0, 1), scene);
|
||||||
|
const box = BABYLON.MeshBuilder.CreateBox("box", {});
|
||||||
|
|
||||||
|
return scene;
|
||||||
|
}
|
||||||
|
var scene = createScene();
|
||||||
|
|
||||||
|
// 3 循环渲染
|
||||||
|
engine.runRenderLoop(function () {
|
||||||
|
scene.render();
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 加载模型
|
||||||
|
|
||||||
3
book/eyi.md
Normal file
3
book/eyi.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# 恶意
|
||||||
|
|
||||||
|
真的是太绝了
|
||||||
14
linux/iscsi.md
Normal file
14
linux/iscsi.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# iscsi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get install open-iscsi
|
||||||
|
sudo iscsiadm -m discovery -t sendtargets -p 10.*.*.*
|
||||||
|
# 挂载
|
||||||
|
sudo iscsiadm -m node -T iqn.2000-01.com.synology:NAS01.Target-4.f41596f93f -p 10.*.*.* -l
|
||||||
|
# 卸载iscsi卷
|
||||||
|
sudo iscsiadm -m node -T iqn.2000-01.com.synology:NAS01.Target-4.f41596f93f -p 10.*.*.* -u
|
||||||
|
```
|
||||||
|
|
||||||
|
sudo dd if=/dev/sdb of=/dev/sdd count=322122547200 bs=1M iflag=count_bytes,direct oflag=direct
|
||||||
3
linux/lvm_recover.md
Normal file
3
linux/lvm_recover.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# lvm_recover
|
||||||
|
|
||||||
|
https://www.golinuxcloud.com/recover-lvm2-partition-restore-vg-pv-metadata/
|
||||||
@ -56,7 +56,7 @@ source ~/kolla_venv/bin/activate
|
|||||||
# centos7 缺 utf-8 字符集
|
# centos7 缺 utf-8 字符集
|
||||||
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
|
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
|
||||||
pip install -U pip
|
pip install -U pip
|
||||||
pip install ansible
|
pip install ansible==10.2
|
||||||
pip install ./kolla
|
pip install ./kolla
|
||||||
pip install ./kolla-ansible
|
pip install ./kolla-ansible
|
||||||
sudo mkdir -p /etc/kolla
|
sudo mkdir -p /etc/kolla
|
||||||
@ -88,6 +88,9 @@ vim /root/kolla_venv/share/kolla-ansible/ansible/roles/baremetal/defaults/main.y
|
|||||||
docker_yum_gpgcheck: false
|
docker_yum_gpgcheck: false
|
||||||
enable_docker_repo: false
|
enable_docker_repo: false
|
||||||
|
|
||||||
|
vim /home/parallels/kolla_venv/share/kolla-ansible/ansible/roles/prechecks/tasks/service_checks.yml
|
||||||
|
or result.stdout | regex_replace('.*\\b(\\d+\\.\\d+\\.\\d+)\\b.*', '\\1') is version(docker_version_min, '<')
|
||||||
|
|
||||||
kolla-ansible -i ./multinode bootstrap-servers
|
kolla-ansible -i ./multinode bootstrap-servers
|
||||||
kolla-ansible -i ./multinode prechecks
|
kolla-ansible -i ./multinode prechecks
|
||||||
kolla-ansible -i ./multinode deploy
|
kolla-ansible -i ./multinode deploy
|
||||||
|
|||||||
10
rust/date.md
Normal file
10
rust/date.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# rust 获取东八区时间
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use time;
|
||||||
|
|
||||||
|
let d = time::OffsetDateTime::now_utc().to_offset(time::UtcOffset::from_hms(8, 0, 0).unwrap());
|
||||||
|
|
||||||
|
```
|
||||||
107
rust/future.md
Normal file
107
rust/future.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# rust 异步基础
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### future
|
||||||
|
|
||||||
|
Future 生成三种方式
|
||||||
|
|
||||||
|
- async {}
|
||||||
|
- fn {} -> impl Future<>
|
||||||
|
- Impl Future for struct_future {}
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use std::future::Future;
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
|
use tokio::time::{sleep, Duration, Sleep};
|
||||||
|
|
||||||
|
struct ReadFileFuture {
|
||||||
|
count: u8,
|
||||||
|
sp: Pin<Box<Sleep>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Future for ReadFileFuture {
|
||||||
|
type Output = String;
|
||||||
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
|
match self.sp.as_mut().poll(cx) {
|
||||||
|
Poll::Pending => {
|
||||||
|
println!("wait ....");
|
||||||
|
return Poll::Pending;
|
||||||
|
}
|
||||||
|
Poll::Ready(()) => {
|
||||||
|
println!("finished wait");
|
||||||
|
// return Poll::Ready("asd".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if self.count < 5 {
|
||||||
|
println!(" continue read file");
|
||||||
|
self.count = self.count + 1;
|
||||||
|
cx.waker().clone().wake();
|
||||||
|
Poll::Pending
|
||||||
|
} else {
|
||||||
|
println!("finished to read file.");
|
||||||
|
return Poll::Ready("asd".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn task() -> impl Future<Output = String> {
|
||||||
|
async {
|
||||||
|
sleep(Duration::new(1, 0)).await;
|
||||||
|
println!("task finished. cost 1.");
|
||||||
|
String::from("asd")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn task2() {
|
||||||
|
sleep(Duration::new(2, 0)).await;
|
||||||
|
println!("task2 finished. cost 2s")
|
||||||
|
}
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let d = Duration::new(4, 0);
|
||||||
|
let mut s = sleep(d);
|
||||||
|
let mut f1 = ReadFileFuture {
|
||||||
|
count: 0,
|
||||||
|
sp: Box::pin(s),
|
||||||
|
};
|
||||||
|
let h1 = tokio::spawn(f1);
|
||||||
|
let h3 = tokio::spawn(task2());
|
||||||
|
let h2 = tokio::spawn(task());
|
||||||
|
_ = tokio::join!(h1, h2, h3);
|
||||||
|
println!("main finished")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- 运行结果
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wait ....
|
||||||
|
|
||||||
|
|
||||||
|
task finished. cost 1.
|
||||||
|
|
||||||
|
task2 finished. cost 2s
|
||||||
|
|
||||||
|
|
||||||
|
finished wait
|
||||||
|
continue read file
|
||||||
|
finished wait
|
||||||
|
continue read file
|
||||||
|
finished wait
|
||||||
|
continue read file
|
||||||
|
finished wait
|
||||||
|
continue read file
|
||||||
|
finished wait
|
||||||
|
continue read file
|
||||||
|
finished wait
|
||||||
|
finished to read file.
|
||||||
|
main finished
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
199
rust/marco.md
Normal file
199
rust/marco.md
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
# Rust 宏编程(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rust 宏主要分为 派生宏、类函数宏、属性宏,可以非常方便的生成重复性代码。
|
||||||
|
|
||||||
|
终于可以能写会写代码的代码了罒ω罒。
|
||||||
|
|
||||||
|
### 环境准备
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# dtolnay 大佬提供的 宏教学库
|
||||||
|
git clone https://github.com/dtolnay/proc-macro-workshop.git
|
||||||
|
|
||||||
|
## cargo expand 查看宏产生的全部代码
|
||||||
|
rustup toolchain install nightly-x86_64-apple-darwin
|
||||||
|
# 可先执行该指令 会提示你看着那个版本的nightly
|
||||||
|
cargo +nightly install cargo-expand
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## cargo test
|
||||||
|
|
||||||
|
- 目录结构
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
cd builder/
|
||||||
|
tree
|
||||||
|
|
||||||
|
.
|
||||||
|
├── Cargo.toml
|
||||||
|
├── src
|
||||||
|
│ └── lib.rs # 要编写宏的文件
|
||||||
|
└── tests
|
||||||
|
├── 01-parse.rs
|
||||||
|
├── 02-create-builder.rs
|
||||||
|
├── 03-call-setters.rs
|
||||||
|
├── 04-call-build.rs
|
||||||
|
├── 05-method-chaining.rs
|
||||||
|
├── 06-optional-field.rs
|
||||||
|
├── 07-repeated-field.rs
|
||||||
|
├── 08-unrecognized-attribute.rs
|
||||||
|
├── 08-unrecognized-attribute.stderr
|
||||||
|
├── 09-redefined-prelude-types.rs
|
||||||
|
└── progress.rs # 通过取消注释来确定运行那个test文件
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编写宏代码
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
#[proc_macro_derive(Builder)]
|
||||||
|
pub fn derive(input: TokenStream) -> TokenStream {
|
||||||
|
let _ = input;
|
||||||
|
// 打印看看input到底是什么
|
||||||
|
eprintln!("{:#?}", input);
|
||||||
|
// 注释下行 并返回空的结果, 下行表示未实现该发放并进行panic
|
||||||
|
// unimplemented!()
|
||||||
|
TokenStream::new()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 运行 test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# builder 目录下
|
||||||
|
cargo test
|
||||||
|
# 可以查看 test 运行成功无报错 并打印input 结构
|
||||||
|
TokenStream [
|
||||||
|
Ident {
|
||||||
|
ident: "pub",
|
||||||
|
span: #0 bytes(990..993),
|
||||||
|
},
|
||||||
|
Ident {
|
||||||
|
ident: "struct",
|
||||||
|
span: #0 bytes(994..1000),
|
||||||
|
},
|
||||||
|
Ident {
|
||||||
|
ident: "Command",
|
||||||
|
span: #0 bytes(1001..1008),
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
delimiter: Brace,
|
||||||
|
stream: TokenStream [
|
||||||
|
Ident {
|
||||||
|
ident: "executable",
|
||||||
|
span: #0 bytes(1015..1025),
|
||||||
|
},
|
||||||
|
....
|
||||||
|
....
|
||||||
|
...
|
||||||
|
Punct {
|
||||||
|
ch: ',',
|
||||||
|
spacing: Alone,
|
||||||
|
span: #0 bytes(1103..1104),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
span: #0 bytes(1009..1106),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## cargo expand
|
||||||
|
|
||||||
|
- builder/src/lib.rs
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
#[proc_macro_derive(Builder)]
|
||||||
|
pub fn derive(input: TokenStream) -> TokenStream {
|
||||||
|
eprintln!("{:#?}", input);
|
||||||
|
// 这里直接把传入的结构返回回去
|
||||||
|
input
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
- main.rs 根目录下
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
#[derive(Builder)]
|
||||||
|
pub struct Command {
|
||||||
|
executable: String,
|
||||||
|
args: Vec<String>,
|
||||||
|
env: Vec<String>,
|
||||||
|
current_dir: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 查看扩展代码
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 进入根目录, 运行
|
||||||
|
cargo expand --bin workshop
|
||||||
|
# 等同于
|
||||||
|
cargo expand
|
||||||
|
# 输出
|
||||||
|
```
|
||||||
|
|
||||||
|
```rust
|
||||||
|
#![feature(prelude_import)]
|
||||||
|
#[prelude_import]
|
||||||
|
use std::prelude::rust_2021::*;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate std;
|
||||||
|
use derive_builder::Builder;
|
||||||
|
pub struct Command {
|
||||||
|
executable: String,
|
||||||
|
args: Vec<String>,
|
||||||
|
env: Vec<String>,
|
||||||
|
current_dir: String,
|
||||||
|
}
|
||||||
|
pub struct Command {
|
||||||
|
executable: String,
|
||||||
|
args: Vec<String>,
|
||||||
|
env: Vec<String>,
|
||||||
|
current_dir: String,
|
||||||
|
}
|
||||||
|
fn main() {}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
可以看到生成了一个 多的Command结构体
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 运行cargo test 可以看到报错 重复定义的Command
|
||||||
|
|
||||||
|
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
|
||||||
|
error[E0428]: the name `Command` is defined multiple times
|
||||||
|
--> tests/01-parse.rs:27:1
|
||||||
|
|
|
||||||
|
27 | pub struct Command {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
| |
|
||||||
|
| `Command` redefined here
|
||||||
|
| previous definition of the type `Command` here
|
||||||
|
|
|
||||||
|
= note: `Command` must be defined only once in the type namespace of this module
|
||||||
|
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
剩下的就是根据tests/目录下每个测试文件编写符合要求的宏代码。
|
||||||
|
|
||||||
|
祝各位顺利~
|
||||||
|
|
||||||
|
rust真TM难学,其他语言能看着demo直接上手写项目, rus已经看了一周多了,还没开始写实际代码。
|
||||||
24
rust/rust.md
Normal file
24
rust/rust.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Rust
|
||||||
|
|
||||||
|
#### install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
|
rustup update
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## expand
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# just for mac
|
||||||
|
rustup toolchain install nightly-x86_64-apple-darwin
|
||||||
|
|
||||||
|
cargo +nightly install cargo-expand
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
18
vim/mac.md
Normal file
18
vim/mac.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# vim config for mac
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### fzf
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install fzf
|
||||||
|
# brew install --build-from-source fzf
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
24
vue/vue3.md
24
vue/vue3.md
@ -1,5 +1,17 @@
|
|||||||
# vue3 typescript vue-router vuex setup
|
# vue3 typescript vue-router vuex setup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 使用模板
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx degit veypi/vite-starter#master project_name
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 最近发现vue3相关库都更新的差不多了,尝试学习了新的版本, 使用setup 的确变了很多,像ref 、prop面目全非,刚开始用还找了很久
|
### 最近发现vue3相关库都更新的差不多了,尝试学习了新的版本, 使用setup 的确变了很多,像ref 、prop面目全非,刚开始用还找了很久
|
||||||
|
|
||||||
## 创建项目
|
## 创建项目
|
||||||
@ -43,6 +55,18 @@ export default router
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### tailwindcss
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
|
||||||
|
npx tailwindcss init -p
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### [vuex](https://next.vuex.vuejs.org/zh/guide/typescript-support.html)
|
### [vuex](https://next.vuex.vuejs.org/zh/guide/typescript-support.html)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user