命令install、v1-install、v2-install和new-install简单地描述为运行时“安装软件包” man cabal。它们彼此不同吗?哪个是首选?
我想使用 firebase admin SDK 让我的节点服务器免费访问我的数据库。index.js这是我文件夹中的代码functions:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
// Initialize app
admin.initializeApp({
credential: admin.credential.cert("logininfo.json"),
databaseURL: "https://thenameofmydatabase.firebaseio.com/",
databaseAuthVariableOverride: {
uid: "nameserver"
}
});
Run Code Online (Sandbox Code Playgroud)
在同一个文件夹中,我有我的 logininfo.json,它看起来像这样(出于明显的原因审查了密钥):
{
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "..."
}
Run Code Online (Sandbox Code Playgroud)
Failed to parse certificate key file: Error: ENOENT: no such file or directory但是,我在尝试部署到 firebase 托管时收到错误。
我该如何解决这个问题,是否有更安全/优雅的方法来处理这个问题?我可以在 firebase 托管中的某处更改GOOGLE_APPLICATION_CREDENTIALS变量吗?
node.js firebase firebase-hosting google-cloud-functions firebase-admin
我想使用Binance API的一些 websocket 流。我在这里发布这个是因为我认为这不是 API 的问题,而是我对 websockets 的一般理解。
我尝试订阅流,如官方 gorilla/websocket 示例所述:
conn, res, err := websocket.DefaultDialer.Dial("wss://stream.binance.com/ws/BTCUSD@markPrice", nil)
fmt.Println(conn)
fmt.Println(res)
fmt.Println(err)
for {
_, message, readErr := conn.ReadMessage()
if readErr != nil {
fmt.Println(readErr)
return
}
fmt.Println(message)
}
Run Code Online (Sandbox Code Playgroud)
连接创建时没有错误,但之后就不会读取任何消息。
我认为问题在于 API 要求我订阅流,如下所示:
{
"method": "SUBSCRIBE",
"params": [
"btcusdt@aggTrade",
"btcusdt@depth"
],
"id": 1
}
Run Code Online (Sandbox Code Playgroud)
我知道 websocket 连接从一个 HTTP 请求开始,据我所知,我发送此数据。但我应该在何时何地这样做呢?Dial不提供发送除 HTTP 标头之外的任何内容的选项。
更新:
我设法使用 Conn.WriteJSON发送正确的请求并获得正确的响应,如此处记录的:
{
"method": "SUBSCRIBE",
"params": [
"btcusdt@aggTrade",
"btcusdt@depth"
],
"id": …Run Code Online (Sandbox Code Playgroud) 我只是想在屏幕上画一条线。我正在使用 OpenGL 4.6。我发现的所有教程都使用了glVertexPointer,据我所知,它已被弃用。
我知道如何使用缓冲区绘制三角形,所以我用一条线尝试了这一点。它没有用,只是显示黑屏。(我正在使用 GLFW 和 GLEW,并且我正在使用我已经在三角形上测试过的顶点+片段着色器)
// Make line
float line[] = {
0.0, 0.0,
1.0, 1.0
};
unsigned int buffer; // The ID, kind of a pointer for VRAM
glGenBuffers(1, &buffer); // Allocate memory for the triangle
glBindBuffer(GL_ARRAY_BUFFER, buffer); // Set the buffer as the active array
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(float), line, GL_STATIC_DRAW); // Fill the buffer with data
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0); // Specify how the buffer is converted to vertices …Run Code Online (Sandbox Code Playgroud) 我在 C++ 程序中使用 GLFW 和 GLEW 来处理 OpenGL。我希望能够将 OpenGL 错误输出到控制台。为了测试这一点,我做了一个小程序:
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
// Test error function
void GLAPIENTRY MessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
std::cout << "ERROR";
}
// Main function
int main(void)
{
// Just some initialization
GLFWwindow* window;
if (!glfwInit()) {
return -1;
}
window = glfwCreateWindow(640, 480, "Debugtest", NULL, NULL);
if (!window) {
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewInit();
// Output the …Run Code Online (Sandbox Code Playgroud) 为了检索 OAuth / OpenID Connect 令牌,该函数在authlib 文档authorize_access_token中使用。像 Google 这样的 OAuth 提供商强烈建议手动验证这些令牌,例如通过检查到期日期。
文档在哪里authorize_access_token?我在网站上找不到任何东西。该函数会自动验证令牌还是我必须自己验证令牌?
AFAIK,在堆栈上声明的变量只在当前范围结束之前有效,所以基本上直到下一个}出现。但是,让我们以这个例子为例:
int main() {
int* ptrOne;
{
int intOne = 1;
ptrOne = &intOne;
}
int intTwo = 9;
std::cout << *ptrOne;
}
Run Code Online (Sandbox Code Playgroud)
当intTwo被宣布,intOne已经超出了范围。它不再可访问,因此应该被覆盖。但是,cout仍然有效并推出1. 在内存视图中,我可以看到 1 仍然存在,而 9 在其后面写入了几个字节。为什么?(我使用的是带有 MSVC 的 Visual Studio 2019)
我已阅读有关 Go fmt 包的文档。尽管如此,我还是不明白 Print、Fprint、Sprint、Printf、Fprintf 和 Sprintf 之间的区别。有人可以用外行的术语向我解释吗?