小编Ale*_*gli的帖子

我可以将 Firebase 预览通道部署到我的自定义域吗?

我在 firebase 托管中有一个自定义域设置,工作正常。当我创建预览频道时,它总是在默认的“web.app”域中创建它。我尝试将预览频道 URL 中的“web.app”替换为我的自定义域,但出现“网站未找到”错误。有谁知道当前是否可以将预览通道部署到 firebase 托管中配置的自定义域?

示例:预览频道是:https://project-id--channel-name-8rdxche4.web.app,我希望它是https://project-id--channel-name-8rdxche4.my.domain

这是因为我的前端项目托管在 Firebase 中,但我的后端位于我自己的服务器上,该服务器也在我的自定义域下。因此,为了正确设置 cookie,我还需要从自定义域托管预览频道。

firebase-hosting

12
推荐指数
1
解决办法
1105
查看次数

我可以在 Firebase 身份验证模拟器中使用 auth:import 和 auth:export 工具吗?

我想在启动时使用我的测试用户帐户预加载 firebase auth 模拟器,就像我对 Firestore 模拟器及其导入/导出选项所做的一样。我尝试在模拟器运行时使用 auth:import 和 auth:export,但它连接到我们实际的开发 firebase 项目,而不是模拟器。无论如何要针对身份验证模拟器运行 auth:import 和 auth:export 吗?

作为参考,我指的是这些命令 ( https://firebase.google.com/docs/cli/auth ) 和这个模拟器 ( https://firebase.google.com/docs/emulator-suite/connect_auth )。

firebase firebase-tools firebase-authentication

11
推荐指数
2
解决办法
1398
查看次数

如何递归删除firestore中的集合?

我需要一种方法来快速清除整个 firestore 数据库,但找不到有关如何执行此操作的详细文档。最终我在堆栈溢出上找到了这个答案(清除所有数据的 Firestore 数据库?),但对清除数百万个文档的整个数据库需要多长时间感到有点紧张,所以我想要一种方法来递归删除集合一次。

背景:我一直在运行一些测试,将大量数据从旧数据库迁移到 firestore,每次运行后我都希望在 firestore 中使用干净的状态。不要在生产数据上使用它!

firebase google-cloud-firestore

11
推荐指数
1
解决办法
7899
查看次数

如何使用 google.oauth2 python 库?

我正在尝试对谷歌机器学习项目的安全预测端点进行简单的休息调用,但它找不到 google.oauth2 模块。这是我的代码:

import urllib2
from google.oauth2 import service_account

# Constants
ENDPOINT_URL = 'ml.googleapis.com/v1/projects/{project}/models/{model}:predict?access_token='
SCOPES = ['https://www.googleapis.com/auth/sqlservice.admin']
SERVICE_ACCOUNT_FILE = 'service.json'

credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
access_token=credentials.get_access_token()

opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(ENDPOINT_URL)
request.get_method = lambda: 'POST'
result = opener.open(request).read()
print(str(result))
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到此错误:

Traceback (most recent call last):
  File "wakeUpMLServer.py", line 30, in <module>
    from google.oauth2 import service_account
ImportError: No module named oauth2
Run Code Online (Sandbox Code Playgroud)

我使用 pip 安装了 google-api-python-client 库(来自此处的说明:https : //developers.google.com/api-client-library/python/apis/oauth2/v1)。安装说成功了。Python 版本:2.7.6 Pip 版本:1.5.4

如果它有某种冲突,你应该知道我也在同一台服务器上进行 protobuf 文件处理,所以我也安装了 protobufs 库。当我执行 pip list 时,它会显示两个库: …

python google-oauth google-api-python-client

9
推荐指数
2
解决办法
1万
查看次数

拖动元素时是否禁用 mousemove 事件?

我试图通过在拖动元素时观察文档上的 mousemove 事件来移动元素(使用 html5 拖放)。我在父元素上的文档上添加了一个 mousemove 侦听器,每当我移动鼠标时就会触发该侦听器,但是一旦我开始拖动另一个子元素,我就不再看到 mousemove 事件,一旦我停止拖动,我就会再次看到这些事件。我在 API ( https://developer.mozilla.org/en-US/docs/Web/Events/mousemove ) 的任何地方都没有看到它拖动禁用了这些事件,但我不知道如何停止他们来自我的代码。这只是 html5 拖放的一部分,它在拖动时禁用 mousemove 事件吗?

我正在使用 angular2 来检测鼠标移动。我尝试了两种不同的方法:

1)

@HostListener('document:mousemove', ['$event'])
    onMouseMove(event) {
        console.log('Global mousemove: ', event);
    }
Run Code Online (Sandbox Code Playgroud)

2)

constructor(
      public element: ElementRef,
      private renderer: Renderer2) {
        element.nativeElement.draggable = true;
      }
this.mouseMoveListener = this.renderer.listen('document', 'mousemove', this.onMouseMove.bind(this));
Run Code Online (Sandbox Code Playgroud)

drag-and-drop angular

7
推荐指数
1
解决办法
3878
查看次数

Was --killSignal flag removed from forever?

When I use the killSignal flag when stopping a nodejs script with forever it ignores it. My command is (where index.js is the nodejs script):

forever --killSignal=SIGTERM stop index.js
Run Code Online (Sandbox Code Playgroud)

Am I using the flag the wrong way? Can anyone get the killSignal flag to work? I'm using forever version 0.15.1, installed globally.

node.js forever

6
推荐指数
1
解决办法
598
查看次数

尝试使用mysql python连接器执行准备好的语句时出现NotImplementedError

我想使用准备好的语句使用python将数据插入MySQL DB(版本5.7),但是我一直收到NotImplementedError。我在这里关注文档:https : //dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursorprepared.html

使用python-2.7和mysql-connector-python库的8.0.11版本:

pip show mysql-connector-python
---
Metadata-Version: 2.1
Name: mysql-connector-python
Version: 8.0.11
Summary: MySQL driver written in Python
Home-page: http://dev.mysql.com/doc/connector-python/en/index.html
Run Code Online (Sandbox Code Playgroud)

这是我正在运行的python脚本的清理后的版本(没有特定的主机名,用户名,密码,列或表):

import mysql.connector
from mysql.connector.cursor import MySQLCursorPrepared

connection = mysql.connector.connect(user=username, password=password,
                                      host='sql_server_host',
                                      database='dbname')
print('Connected! getting cursor')
cursor = connection.cursor(cursor_class=MySQLCursorPrepared)
select = "SELECT * FROM table_name WHERE column1 = ?"
param = 'param1'
print('Executing statement')
cursor.execute(select, (param,))
rows = cursor.fetchall()
for row in rows:
    value = row.column1
print('value: '+ value)
Run Code Online (Sandbox Code Playgroud)

运行此命令时出现此错误:

Traceback (most recent call last):
  File …
Run Code Online (Sandbox Code Playgroud)

python mysql mysql-connector-python

6
推荐指数
1
解决办法
1899
查看次数

Firebase Cloud Functions 失败,没有日志,只是“错误:函数终止。建议采取的措施:检查日志以了解终止原因”

我很少在 Firebase Cloud Functions 日志中看到此错误:

“错误:函数终止。建议的操作:检查日志以了解终止原因。其他故障排除文档可在https://cloud.google.com/functions/docs/troubleshooting#logging请求被拒绝。”。

我查看了此错误发生前后的日志,没有看到任何其他信息,只是同一云函数的其他一些成功执行。同一函数每天成功执行数千次,但随后每天或几个小时就会显示一次。我的整个云函数体都包含在 try/catch 中,并且我已经看到从 catch 代码中的错误日志正确报告了逻辑错误,因此我不知道这个未捕获的错误是如何发生的,也不知道如何获取有关它的更多信息。有谁知道这个错误是如何发生的?这是该函数的清理版本,抛出了这个奇怪的错误:

exports.onUserDocUpdate = functions.firestore
  .document('user/{userId}/{collectionId}/{docId}')
  .onWrite(handleDocumentWrite);
  
async function handleDocumentWrite(change, context) {
  try {
    // Function logic here
  } catch (error) {
    functions.logger.error(`firestoreTriggers.handleDocumentWrite failed with error:`, error);
  }
}
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions

5
推荐指数
0
解决办法
611
查看次数

如何在jetpack compose测试中关闭软键盘?

我正在为jetpack 撰写屏幕编写测试,该屏幕上有一个文本字段。在我的测试中,我想在字段中输入一些文本,然后关闭软键盘,然后单击隐藏在软键盘下方的按钮。不过,我找不到在 jetpack 撰写测试中关闭软键盘的方法。我尝试了“performImeAction”,但这并没有关闭键盘,即使您在实际与此文本字段交互时按下软键盘上的 IME 键,它也会关闭键盘。

我希望能够做到这一点,但在组合测试中:

onView(withId(R.id.text_field)).perform(typeText("100"), closeSoftKeyboard())
Run Code Online (Sandbox Code Playgroud)

我当前的撰写代码在字段中输入“100”然后抛出错误:

composeTestRule
    .onNodeWithTag(TEXT_FIELD_TAG)
    .performTextInput("100")
composeTestRule
    .onNodeWithTag(TEXT_FIELD_TAG)
    .performImeAction() <------------- This fails
Run Code Online (Sandbox Code Playgroud)

报告错误:

java.lang.AssertionError: Failed to perform IME action as current node does not specify any.
Semantics of the node:
Node #48 at (l=0.0, t=748.0, r=788.0, b=1141.0)px, Tag: 'TEXT_FIELD_TAG'
ImeAction = 'Default'
EditableText = '100'
TextSelectionRange = 'TextRange(3, 3)'
Focused = 'true'
Actions = [GetTextLayoutResult, SetText, SetSelection, OnClick, OnLongClick, PasteText]
MergeDescendants = 'true'
Has 7 siblings
Run Code Online (Sandbox Code Playgroud)

android-jetpack-compose android-jetpack-compose-testing

5
推荐指数
1
解决办法
1988
查看次数

在 Google Apps 脚本中,如何获取没有指数的毫秒值?

我正在尝试在谷歌应用程序脚本中使用 UrlFetch 向网络服务发送毫秒时间戳。我的网络服务期望时间格式为 1433563200021,但 google 应用程序脚本不断将其转换为指数为 1.433563200021E12 的字符串,即使我调用 Number(startDate.getTime()) 也是如此。如何让谷歌应用程序脚本仅将数值存储在变量中?

google-apps-script

3
推荐指数
1
解决办法
4967
查看次数

如何为ng-repeat指定自定义过滤器功能?

我正在尝试使用ng-repeat的自定义过滤器函数,因为我的过滤器值是一个复杂的对象.我正在使用angularJS v1.5并遵循以下文档:https://code.angularjs.org/1.5.0/docs/api/ng/filter/filter

文档说你可以指定一个这样的表达式:{{filter_expression | filter:expression:comparator}}并且使用两个参数调用比较器函数,即数组中的实际对象和谓词值.我的比较器函数对于实际对象始终具有"未定义".我尝试使一切尽可能简单,它仍然发送未定义的实际对象.

$scope.athletes = [
    {
      "name":"first",
      "tags":[
      "Offense"]
    },
    {
      "name":"two",
      "tags":[
      "Defense"]
    },
    {
      "name":"three",
      "tags":[
      "Special Teams"]
    },
    {
      "name":"four",
      "tags":[
      "Offense"]
    }
    ];

    $scope.athletesInFunction = [];

    $scope.doesAthleteHaveTag = function(athlete,filterValue){
      if (athlete) {
      $scope.athletesInFunction.push(athlete);
      if (athlete.tags.indexOf(filterValue) > -1) {
        return true;
      }
      }
      return false;
    };
Run Code Online (Sandbox Code Playgroud)

HTML文件:

<div ng-repeat="athlete in athletes | filter:filterValue:doesAthleteHaveTag">
        <div>Name: {{athlete.name}}</div>
      </div>
Run Code Online (Sandbox Code Playgroud)

示例plunkr:https://plnkr.co/edit/lk26tFFgux2sLpuke56m p = preview

我究竟做错了什么?如何让它在实际的数组对象中发送以进行过滤?

编辑:我应该更清楚我的问题.我的问题是文档是否有效,以及使用自定义过滤器功能的推荐方法是什么.我目前只使用表达式函数,因为过滤谓词是范围广泛的变量,我可以在我的表达式函数中轻松访问它.我不知道这是否更好,更糟或与使用比较器功能相同,或者如果最好只编写一个自定义过滤器,如其中一个答案所述.

angularjs

3
推荐指数
1
解决办法
1万
查看次数