之前的文章集合:
一些可以参考文章集合1_xuejianxinokok的博客-CSDN博客
一些可以参考文章集合2_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合3_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合4_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合5_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合6_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合7_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合8_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合9_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合10_xuejianxinokok的博客-CSDN博客
一些可以参考的文档集合11_xuejianxinokok的博客-CSDN博客
20230627
支持 WebGPU API 的环境,可不止浏览器一个。
虽说 NodeJS 没什么消息说要支持,但是 Deno 这个 js/ts 运行时老早就支持了,能脱离浏览器直接在控制台访问 GPU,感觉十分有趣。
确保 Deno 版本
至少要高于 1.8,最好装最新
API网关是作为服务器或服务的角色,充当外部客户端与应用程序内部微服务或基于API的后端服务之间的中介。在现代架构中,特别是在基于微服务的系统中,它是一个重要的组成部分,它简化了通信过程,并为客户端提供了一个访问各种服务的单一入口。
API网关的主要功能包括:
- 请求路由:根据预定义的规则和配置,API网关将来自客户端的API请求指向适当的后端服务或微服务。
- 身份验证和授权:API网关管理用户身份验证和授权,确保只有经过授权的客户端能够访问服务。它在将请求路由到后端服务之前,会验证API密钥、令牌或其他凭证。
- 限速和节流:为了保护后端服务免受过度负载或滥用,API网关会根据预定义的策略对客户端的请求进行限速或节流。
- 缓存:为了最小化延迟和后端负载,API网关会缓存经常使用的响应,并直接服务于客户端,无需查询后端服务。
- 请求和响应转换:API网关可以修改请求和响应,如转换数据格式、添加或删除头部,或改变查询参数,以确保客户端和服务之间的兼容性。
-
正向代理与反向代理
正向代理,也被称为"代理服务器"或简单的"代理",是放置在一个或多个客户端机器前的服务器,充当客户端和互联网之间的中介。当客户端机器请求互联网上的资源时,请求首先发送到正向代理。然后,正向代理代表客户端机器将请求转发到互联网,并将响应返回给客户端机器。
另一方面,反向代理是放置在一个或多个Web服务器前的服务器,作为Web服务器和互联网之间的中介。当客户端请求互联网上的资源时,请求首先发送到反向代理。然后,反向代理将请求转发到其中一台Web服务器,该服务器将响应返回给反向代理。最后,反向代理将响应返回给客户端。
填充方式
纹理是要贴到画布的某个区域上的,并不一定刚好设置一下填充方式。
纹理比绘制区域大,就要做缩放;纹理比绘制区域小,就要做放大;纹理没能完全填充绘制区域,就要在水平和垂直方向进行填充。
这些场景都需要对应设置不同的策略。
// 缩小和放大都都使用 “最近点采样”
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
容器探测用于检测容器中的应用实例是否正常工作,是保障业务可用性的一种传统机制。如果经过探测,实例的状态不符合预期,那么kubernetes就会把该问题实例" 摘除 ",不承担业务流量。kubernetes提供了两种探针来实现容器探测,分别是:
- liveness probes:存活性探针,用于检测应用实例当前是否处于正常运行状态,如果不是,k8s会重启容器
- readiness probes:就绪性探针,用于检测应用实例当前是否可以接收请求,如果不能,k8s不会转发流量
livenessProbe 决定是否重启容器,readinessProbe 决定是否将请求转发给容器。
20230625
"C:\Program Files\Google\Chrome\Application\chrome_proxy.exe" --profile-directory=Default --app=https://www.baidu.com
20230621
performance.mark()
该方法是做一个标记mark,结合measures方法,可以计算两个标记之间间隔的时间差;因此可以直接依据业务上的不同,计算两个业务逻辑之间的距离。
20230620
2.2 下载安装过程
从源码编译安装十分麻烦,推荐安装核心的Emscripten SDK。
# 1、Windows环境
# 先使用如下命令下载emsdk。
# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git
# Enter that directory
cd emsdk
# 再使用如下命令安装配置Emscripten。
# Fetch the latest registry of available tools.
.\emsdk.bat update
# Download and install the latest SDK tools. Need install Python first.
.\emsdk.bat install latest
# Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file)
.\emsdk.bat activate latest
# Activate PATH and other environment variables in the current terminal
.\emsdk_env.bat
# 使用如下命令验证Emscripten是否安装配置正确。
# Enter that directory
cd emsdk
# Activate PATH and other environment variables in the current terminal
.\emsdk_env.bat
# Verifying Emscripten
emcc.bat -v
# 创建名为 helloworld.cpp 的文件,其内容如下
#include <stdio.h>
int main() {
printf("hello, world!\n");
return 0;
}
# 生成 a.out.js
emcc.bat helloworld.cpp
# 生成 helloworld.js
emcc.bat helloworld.cpp -o helloworld.js
# 生成 helloworld.html 和 helloworld.js
emcc.bat helloworld.cpp -o helloworld.html
使用如下命令测试编译后生成的代码,将输出“hello,world!”。
node a.out.js
D:\soft>git clone https://github.com/emscripten-core/emsdk.git
Cloning into 'emsdk'...
remote: Enumerating objects: 3720, done.
remote: Counting objects: 100% (610/610), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 3720 (delta 541), reused 579 (delta 528), pack-reused 3110
Receiving objects: 100% (3720/3720), 2.13 MiB | 1.80 MiB/s, done.
Resolving deltas: 100% (2456/2456), done.
D:\soft>cd emsdk
D:\soft\emsdk>.\emsdk.bat update
You seem to have bootstrapped Emscripten SDK by cloning from GitHub. In this case, use "git pull" instead of "emsdk update" to update emsdk. (Not doing that automatically in case you have local changes)
D:\soft\emsdk>.\emsdk.bat install latest
Resolving SDK alias 'latest' to '3.1.41'
Resolving SDK version '3.1.41' to 'sdk-releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit'
Installing SDK 'sdk-releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit'..
Installing tool 'node-15.14.0-64bit'..
Downloading: D:/soft/emsdk/zips/node-v15.14.0-win-x64.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/node-v15.14.0-win-x64.zip, 28255378 Bytes
Unpacking 'D:/soft/emsdk/zips/node-v15.14.0-win-x64.zip' to 'D:/soft/emsdk/node/15.14.0_64bit'
Done installing tool 'node-15.14.0-64bit'.
Installing tool 'python-3.9.2-nuget-64bit'..
Downloading: D:/soft/emsdk/zips/python-3.9.2-4-amd64+pywin32.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/python-3.9.2-4-amd64+pywin32.zip, 14413267 Bytes
Unpacking 'D:/soft/emsdk/zips/python-3.9.2-4-amd64+pywin32.zip' to 'D:/soft/emsdk/python/3.9.2-nuget_64bit'
Done installing tool 'python-3.9.2-nuget-64bit'.
Installing tool 'java-8.152-64bit'..
Downloading: D:/soft/emsdk/zips/portable_jre_8_update_152_64bit.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/portable_jre_8_update_152_64bit.zip, 69241499 Bytes
Unpacking 'D:/soft/emsdk/zips/portable_jre_8_update_152_64bit.zip' to 'D:/soft/emsdk/java/8.152_64bit'
Done installing tool 'java-8.152-64bit'.
Installing tool 'releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit'..
Downloading: D:/soft/emsdk/zips/eb71265ef0ab905620015adbfedacf88c5dbf021-wasm-binaries.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/eb71265ef0ab905620015adbfedacf88c5dbf021/wasm-binaries.zip, 426741498 Bytes
Unpacking 'D:/soft/emsdk/zips/eb71265ef0ab905620015adbfedacf88c5dbf021-wasm-binaries.zip' to 'D:/soft/emsdk/upstream'
Done installing tool 'releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit'.
Done installing SDK 'sdk-releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit'.
D:\soft\emsdk>.\emsdk.bat activate latest
Resolving SDK alias 'latest' to '3.1.41'
Resolving SDK version '3.1.41' to 'sdk-releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit'
Setting the following tools as active:
node-15.14.0-64bit
python-3.9.2-nuget-64bit
java-8.152-64bit
releases-eb71265ef0ab905620015adbfedacf88c5dbf021-64bit
Adding directories to PATH:
PATH += D:\soft\emsdk
PATH += D:\soft\emsdk\upstream\emscripten
Setting environment variables:
PATH = D:\soft\emsdk;D:\soft\emsdk\upstream\emscripten;C:\Program Files\ImageMagick-7.1.0-Q8;D:\soft\cuda\development\bin;D:\soft\cuda\development\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\soft\Git\cmd;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;D:\soft\python3;D:\soft\python3\Scripts;D:\soft\python27\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.1.1\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\dotnet\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NetSarang\Xftp 7\;C:\Program Files (x86)\NetSarang\Xshell 7\;C:\Program Files\OpenSSL-Win64\bin;;C:\Program Files\Docker\Docker\resources\bin;C:\Users\xueji\AppData\Local\Microsoft\WindowsApps;D:/soft/jdk-19\bin;D:\soft\apache-maven-3.8.6\bin;D:\soft\nodejs;D:\soft\nodejs\node_global;D:\soft\go\bin;D:\soft\cmake-3.24.1\bin;C:\Users\xueji\.dotnet\tools;D:\soft\go\GOPATH\bin;D:\soft\MinGW\bin;D:\soft\Fiddler;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
EMSDK = D:/soft/emsdk
EMSDK_NODE = D:\soft\emsdk\node\15.14.0_64bit\bin\node.exe
EMSDK_PYTHON = D:\soft\emsdk\python\3.9.2-nuget_64bit\python.exe
JAVA_HOME = D:\soft\emsdk\java\8.152_64bit
Clearing existing environment variable: EMSDK_PY
The changes made to environment variables only apply to the currently running shell instance. Use the 'emsdk_env.bat' to re-enter this environment later, or if you'd like to register this environment permanently, rerun this command with the option --permanent.
D:\soft\emsdk>emcc.bat -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.41 (71634e036d20209a5d81c2b2171e145b44de1e12)
clang version 17.0.0 (https://github.com/llvm/llvm-project 88421ea973916e60c34beb26597a5fc33f83dd8f)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: D:\soft\emsdk\upstream\bin
如何传递参数给webassembly
// js side
const uints = [1, 2, 3, 4];
// 在 wasm heap 中分配 bytes 长度的内存, 返回一个指针
const ptr = this.module._malloc(uints.length)
// 从 wasm heap 中截取这段堆内存
const heapBytes = new Uint8Array(this.module.HEAPU8.buffer, ptr, uints.length)
// 在这段堆内存上填充这段 8-bit 无符号整数
heapBytes.set(uints)
// emscripten 中的内部方法
ccall(ptr, heapBytes.length);
// c side
void c_fn(uint8_t *buf, size_t buf_len) {}
20230619
从Spring6.x开始支持Problem Detail。
Spring中要使用ProblemDetail首先需要通过如下配置开启:
复制
spring:
mvc:
problemdetails:
enabled: true
20230614
首先需要从Google在2020年发布的mediapipe开发包说起,这个开发包集成了人脸、眼睛、虹膜、手势、姿态等各种landmark检测与跟踪算法。
https://google.github.io/mediapipe/
MediaPipe + OpenCV五分钟搞定手势识别https://mp.weixin.qq.com/s/nD7hV4SUiyDWqqvb-TeBwQ