骄傲

文章 评论 浏览 32

骄傲 2025-02-05 05:20:09

我遇到了同样的问题。
我通过将下一个JS更新为最新版本来解决它:v12.1.7-canary.41

不要使用使用效果,因为它会增加第一个字节(TTFB)的时间,从而使您的页面从Google不合格。

I faced the same problem.
I solved it by updating Next JS to the latest version : v12.1.7-canary.41

Don't use Use UseEffect, because It will increase Time to First Byte (TTFB) and thus causing your pages to be unranked from google.

在服务器端渲染nextJ和材料-UI期间的组件闪烁?

骄傲 2025-02-04 23:35:56

您可以使用

\{(#[a-zA-Z0-9]{6})\}(.*?)(?=\{#[a-zA-Z0-9]{6}\}|$)

regex demo 详细信息

  • \ { - a { char
  • (#[A-ZA-Z0-9] {6}) - 组1:a char和六个alphanumerics
  • \} - a } char char
  • (。*?) - 第2组:除换期折扣以外的任何零或更多的字符
  • (?= \ {#[a-za-z0-9] {6} \} \} | $) -位置立即遵循 {,六个字母数字和} char或字符串的结尾。

You can use

\{(#[a-zA-Z0-9]{6})\}(.*?)(?=\{#[a-zA-Z0-9]{6}\}|$)

See the regex demo. Details:

  • \{ - a { char
  • (#[a-zA-Z0-9]{6}) - Group 1: a # char and six alphanumerics
  • \} - a } char
  • (.*?) - Group 2: any zero or more chars other than line break chars as few as possible
  • (?=\{#[a-zA-Z0-9]{6}\}|$) - a position immediately followed with a {, #, six alphanumerics and a } char, or end of string.

正则表达式以匹配模式和文本,直到再次发生该模式,然后重复

骄傲 2025-02-04 21:04:56

删除括号,当前您正在立即调用该功能。当前正在传递给Settimeout的是从testfunction()调用中返回的值,但是您应该传递到Settimeout,因为第一个参数是函数参考

setTimeout(testfunction, 2000);

Remove the parenthesis, currently you are invoking the function immediately. What is currently being passed to setTimeout is the returned value from the testfunction() call, but what you should pass to setTimeout as the first argument is a function reference

setTimeout(testfunction, 2000);

为什么我使用SettiMeout时立即执行该函数?

骄傲 2025-02-04 08:31:41

移动

declare global {
  interface Window {
    initMap: () => void;
  }
}

主函数有效,然后

  const initMap = () => {
    const geocoder = new google.maps.Geocoder();
    setGeocoder(geocoder);
  };
  window.initMap = initMap;

在文件中调用您将使用钩子,然后添加脚本标签以初始化Google API

 <script
      src={`https://maps.googleapis.com/maps/api/js?key=${your API key}&callback=initMap&v=weekly&libraries=geocoder`}
      defer
    ></script>

Moving

declare global {
  interface Window {
    initMap: () => void;
  }
}

Outside of the main function works, then calling

  const initMap = () => {
    const geocoder = new google.maps.Geocoder();
    setGeocoder(geocoder);
  };
  window.initMap = initMap;

Within the file you will use the hook, and add a script tag to initialize the Google API

 <script
      src={`https://maps.googleapis.com/maps/api/js?key=${your API key}&callback=initMap&v=weekly&libraries=geocoder`}
      defer
    ></script>

打字稿错误:环境模块声明仅在文件中的顶级允许

骄傲 2025-02-04 02:48:56

toomanyrequestSexception 您遇到的例外是API节流的结果,试图进行轮询作业状态'[1]。
使用当前的方法,您需要捕捉到ToomanyRequestSexception,并以退位阈值[2]尝试民意调查。

最可扩展的解决方案是使用CloudWatch事件并基于STATUS_UPDATE,完整和错误状态[3]。

事件模式示例的

{
  "source": [
    "aws.mediaconvert"
  ],
  "detail-type": [
    "MediaConvert Job State Change"
  ],
  "detail": {
    "status": [
      "STATUS_UPDATE"
    ]
  }
}

状态更新事件有效载荷的外观:

{
    "version": "0",
    "id": "ABC",
    "detail-type": "MediaConvert Job State Change",
    "source": "aws.mediaconvert",
    "account": "111122223333 ",
    "time": "2021-02-18T17:52:32Z",
    "region": "us-west-2",
    "resources": [
        "arn:aws:mediaconvert:us-west-2:111122223333 :jobs/1613670689802-emcngz"
    ],
    "detail": {
        "timestamp": 1613670752653,
        "accountId": "111122223333 ",
        "queue": "arn:aws:mediaconvert:us-west-2:111122223333 :queues/Default",
        "jobId": "1613670689802-emcngz",
        "status": "STATUS_UPDATE",
        "userMetadata": {},
        "framesDecoded": 2024,
        "jobProgress": {
            "phaseProgress": {
                "PROBING": {
                    "status": "COMPLETE",
                    "percentComplete": 100
                },
                "TRANSCODING": {
                    "status": "PROGRESSING",
                    "percentComplete": 2
                },
                "UPLOADING": {
                    "status": "PENDING",
                    "percentComplete": 0
                }
            },
            "jobPercentComplete": 7,
            "currentPhase": "TRANSCODING",
            "retryCount": 0
        }
    }
}

MediaConvert每个阶段提供粒度百分比(探测输入,转码和上传输出)以及总体百分比。 MediaConvert Console UI上显示的是JobPercentComplete,可能是您要捕获的一个。

可能会设置CloudWatch事件规则以使用SQS队列作为其目的地。在这种情况下,EKS托管的应用程序然后可以对队列进行轮询。
另外,可以设置该规则以调用lambda函数。在这种情况下,您可以拥有处理事件的nodejs代码。

  1. AWS元素Mediavert端点和配额: htttps:// docs。 aws.amazon.com/general/latest/gr/mediaconvert.html

  2. ​api retries.html“ rel =” nofollow noreferrer“> https://docs.aws.amazon.com/general/general/latest/gr/api-retries.html

  3. 监视AWS Element Mediavert:


The TooManyRequestsException exception you are encountering is as a result of API throttling while trying to poll job status' [1].
With the current approach you would need to catch for the TooManyRequestsException and try the poll with a back off threshold [2].

The most scalable solution is to use CloudWatch Events and track jobs based the STATUS_UPDATE, COMPLETE and ERROR status [3].

Example of the Event Pattern

{
  "source": [
    "aws.mediaconvert"
  ],
  "detail-type": [
    "MediaConvert Job State Change"
  ],
  "detail": {
    "status": [
      "STATUS_UPDATE"
    ]
  }
}

Example of what the Status Update event payload looks like:

{
    "version": "0",
    "id": "ABC",
    "detail-type": "MediaConvert Job State Change",
    "source": "aws.mediaconvert",
    "account": "111122223333 ",
    "time": "2021-02-18T17:52:32Z",
    "region": "us-west-2",
    "resources": [
        "arn:aws:mediaconvert:us-west-2:111122223333 :jobs/1613670689802-emcngz"
    ],
    "detail": {
        "timestamp": 1613670752653,
        "accountId": "111122223333 ",
        "queue": "arn:aws:mediaconvert:us-west-2:111122223333 :queues/Default",
        "jobId": "1613670689802-emcngz",
        "status": "STATUS_UPDATE",
        "userMetadata": {},
        "framesDecoded": 2024,
        "jobProgress": {
            "phaseProgress": {
                "PROBING": {
                    "status": "COMPLETE",
                    "percentComplete": 100
                },
                "TRANSCODING": {
                    "status": "PROGRESSING",
                    "percentComplete": 2
                },
                "UPLOADING": {
                    "status": "PENDING",
                    "percentComplete": 0
                }
            },
            "jobPercentComplete": 7,
            "currentPhase": "TRANSCODING",
            "retryCount": 0
        }
    }
}

MediaConvert provides granular percentages per phases the job is in (probing input, transcoding, and uploading outputs) as well as an overall percentage. The one that is displayed on the MediaConvert Console UI is the jobPercentComplete, and would probably be the one you want to capture.

The CloudWatch Event rule can potentially be setup to use an SQS Queue as its destination. In this case the EKS hosted application can then poll the queue.
Alternatively, the rule can be setup to invoke a lambda function. In this case, you can have NodeJS code that processes the event.

  1. AWS Elemental MediaConvert endpoints and quotas: https://docs.aws.amazon.com/general/latest/gr/mediaconvert.html

  2. Error retries and exponential backoff in AWS : https://docs.aws.amazon.com/general/latest/gr/api-retries.html

  3. Monitoring AWS Elemental MediaConvert :
    https://docs.aws.amazon.com/mediaconvert/latest/ug/monitoring-overview.html

致电MediaConvert以使用JavaScript SDK更新UI中的作业状态时,toomanyrequestsexception

骄傲 2025-02-03 20:09:16

根据这篇文章: https://www.w3schools.com/nodejs/nodejs_mongodb_create_db.asp.:~: text =:text = Text =; /a>。

const url='mongodb://localhost:27017/shopping'

通过在'/'之后添加dbname,我们创建数据库

According to this post: https://www.w3schools.com/nodejs/nodejs_mongodb_create_db.asp#:~:text=To%20create%20a%20database%20in,make%20a%20connection%20to%20it.

const url='mongodb://localhost:27017/shopping'

By adding dbname after '/' we create database

数据不在收藏中创建mongo db

骄傲 2025-02-03 19:50:08

即使所有枢轴表共享了单个连接,也似乎是Excel的默认行为。一种可能的解决方案是编写宏来请求用户凭据,并以此信息即时编辑连接。

希望有帮助。

Even with a single connection shared by all the pivot table this seems to be the default behavior of Excel. One possible solution would be to write a macro to request the user credentials and somehow edit the connection on the fly with this information.

Hope that helps.

ICCube Excel XMLA每次透视开设一个会话(连接)

骄傲 2025-02-03 17:48:41

您可以使用 jscodeshift

transform_rxjs_6_6_to_to_7.js

module.exports = function transformer(file, api) {
  const j = api.jscodeshift;
  const root = j(file.source);

  // Find all method calls to `subscribe`
  root.find(j.CallExpression, {
    callee: {
      property: {name: 'subscribe'}
    },
    arguments: args =>
      args.length == 0
      || (args.length > 0 && !j.ObjectExpression.check(args[0]))
  }).replaceWith(path => {
    const {node} = path;

    // Wrap the argument in an object with `next` property
    const properties = [];
    if (node.arguments.length > 0) {
      properties.push(
        j.property('init', j.identifier('next'), node.arguments[0]));
    }
    if (node.arguments.length > 1) {
      properties.push(
        j.property('init', j.identifier('error'), node.arguments[1]));
    }
    if (node.arguments.length > 2) {
      properties.push(
        j.property('init', j.identifier('complete'), node.arguments[2]));
    }
    node.arguments = [j.objectExpression(properties)];

    return node;
  });

  return root.toSource();
};

并运行它,并且使用它运行,则可以使用此变压器。

npx jscodeshift --parser ts --transform=transform_rxjs_6_to_7.js --extensions=js,ts src

You can use this transformer with jscodeshift

transform_rxjs_6_to_7.js

module.exports = function transformer(file, api) {
  const j = api.jscodeshift;
  const root = j(file.source);

  // Find all method calls to `subscribe`
  root.find(j.CallExpression, {
    callee: {
      property: {name: 'subscribe'}
    },
    arguments: args =>
      args.length == 0
      || (args.length > 0 && !j.ObjectExpression.check(args[0]))
  }).replaceWith(path => {
    const {node} = path;

    // Wrap the argument in an object with `next` property
    const properties = [];
    if (node.arguments.length > 0) {
      properties.push(
        j.property('init', j.identifier('next'), node.arguments[0]));
    }
    if (node.arguments.length > 1) {
      properties.push(
        j.property('init', j.identifier('error'), node.arguments[1]));
    }
    if (node.arguments.length > 2) {
      properties.push(
        j.property('init', j.identifier('complete'), node.arguments[2]));
    }
    node.arguments = [j.objectExpression(properties)];

    return node;
  });

  return root.toSource();
};

and run it with

npx jscodeshift --parser ts --transform=transform_rxjs_6_to_7.js --extensions=js,ts src

代码mod/转移到重构RXJS订阅方法

骄傲 2025-02-03 12:18:36

烧瓶应用需要以编程方式绑定到Heroku $ port

port_nr = int(os.environ.get("PORT", 5001))
app.run(port=port_nr, host='0.0.0.0')

The Flask app needs to bind programmatically to the Heroku $PORT

port_nr = int(os.environ.get("PORT", 5001))
app.run(port=port_nr, host='0.0.0.0')

烧瓶应用在Heroku上带有R10错误崩溃

骄傲 2025-02-03 12:13:28

尝试使用 focus 包装 textfield 的小部件。内部 onfocuschange 回调使用 setState 更改保留图标颜色的状态变量。

声明状态类变量:

Color _cancelColor = Colors.black;

内部构建方法:

Focus(
  onFocusChange: (focused) {
    setState(() {
      _cancelColor = focused ?
        Colors.green : Colors.black;
    });
  },
  child: TextField(
    ...
    suffix: Icon(Icons.xxx, color: _cancelColor),
  ),
)

Try to use Focus widget which wraps the TextField. Inside onFocusChange callback use setState to change the state variable which keeps icon color.

Declare state class variable:

Color _cancelColor = Colors.black;

Inside build method:

Focus(
  onFocusChange: (focused) {
    setState(() {
      _cancelColor = focused ?
        Colors.green : Colors.black;
    });
  },
  child: TextField(
    ...
    suffix: Icon(Icons.xxx, color: _cancelColor),
  ),
)

当扑朔迷离时,我们可以动态更改图像图标吗?

骄傲 2025-02-03 11:46:45

您可以将 seriply.Apply 的结果转换为列表,然后分配到多个列,

df[['DOUBLE', 'TRIPLE']] = df['x'].apply(do_math).tolist()
print(df)

   x  DOUBLE  TRIPLE
0  1       2       3
1  2       4       6
2  3       6       9
3  4       8      12

也可以尝试使用 dataflame.apply 在行上使用 result_type ='evation'代码>

df[['DOUBLE', 'TRIPLE']] = df.apply(lambda row: do_math(row['x']), axis=1, result_type='expand')
print(df)

   x  DOUBLE  TRIPLE
0  1       2       3
1  2       4       6
2  3       6       9
3  4       8      12

由于您的操作很简单,因此您也可以尝试

df = df.eval('''
double = 2 * x
triple = 3 * x
'''
)
print(df)

   x  double  triple
0  1       2       3
1  2       4       6
2  3       6       9
3  4       8      12

You can convert the result of Series.apply to list then assign to multiple columns

df[['DOUBLE', 'TRIPLE']] = df['x'].apply(do_math).tolist()
print(df)

   x  DOUBLE  TRIPLE
0  1       2       3
1  2       4       6
2  3       6       9
3  4       8      12

You can also try DataFrame.apply on rows with result_type='expand'

df[['DOUBLE', 'TRIPLE']] = df.apply(lambda row: do_math(row['x']), axis=1, result_type='expand')
print(df)

   x  DOUBLE  TRIPLE
0  1       2       3
1  2       4       6
2  3       6       9
3  4       8      12

Since your operation is simple, you can also try df.eval

df = df.eval('''
double = 2 * x
triple = 3 * x
'''
)
print(df)

   x  double  triple
0  1       2       3
1  2       4       6
2  3       6       9
3  4       8      12

用pandas.series返回多个变量

骄傲 2025-02-03 09:03:18

如果我是您,我将围绕我的文本(例如:101)和一个较低的(例如:100)(或默认一个)围绕 z index 属性。需要在下面显示。

1 Bootstrap 5 colum带有CSS类 col-12 以及图像以及其中的文本,并带有以下内容:

  • w-50 the Image
  • W-75 上文本上的bg-transparent 或将相同的背景应用于该文本的Div容器。
  • 您的背景CSS课程包含所有内容。

您可以使用 ratios> ratios 位置用于您的文本。
至少在采用其他策略之后,我将首先尝试一下。

If I were you, I will seek around the z-index property for my text (in example: 101) and a lower one (in example: 100) (or default one) for my image which I need to display below it.

1 bootstrap 5 colum with the css class col-12 and the image and the text inside it with the following stuff :

  • w-50 on the image
  • w-75 bg-transparent on the text or apply the same background to that div container for your text.
  • your background css classes for the stylized row containing them all.

You can use ratios and positions for your text.
At least I will try it first, after adopting any other strategy.

Bootstrap 5中的另一列

骄傲 2025-02-03 03:35:54

从mozilla web文档中提取以下注释

注意: foreach 期望同步函数。

foreach 不等待承诺。确保您知道
使用承诺(或异步功能)作为 foreach 的含义
回调。

因此,您这个问题与 replaySubject 无关,您只是无法为此用例使用 foreach

Cheers

编辑:解决

import { ReplaySubject } from "rxjs";

export const rs$ = new ReplaySubject();

rs$.subscribe({
  next: (data) => console.log(data),
  error: (error) => console.warn(error),
  complete: () => console.log("ReplaySubject completed"),
});

const fakeAPIValuesOne = [7, 11, 13];

// That won't work:
// fakeAPIValuesOne.forEach(async (entry: number) => {
//   await wait(2000);
//   rs$.next(entry);
// });


// That will work
for (const element of fakeAPIValuesOne) {
  await wait(2000);
  rs$.next(element);
}

function wait(milliseconds: number) {
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
}

Following note is extracted from mozilla web docs here

Note: forEach expects a synchronous function.

forEach does not wait for promises. Make sure you are aware of the
implications while using promises (or async functions) as forEach
callback.

So you this issue isn't related to the ReplaySubject, you just cannot use forEach for this use-case.

Cheers

EDIT: Solved

import { ReplaySubject } from "rxjs";

export const rs$ = new ReplaySubject();

rs$.subscribe({
  next: (data) => console.log(data),
  error: (error) => console.warn(error),
  complete: () => console.log("ReplaySubject completed"),
});

const fakeAPIValuesOne = [7, 11, 13];

// That won't work:
// fakeAPIValuesOne.forEach(async (entry: number) => {
//   await wait(2000);
//   rs$.next(entry);
// });


// That will work
for (const element of fakeAPIValuesOne) {
  await wait(2000);
  rs$.next(element);
}

function wait(milliseconds: number) {
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
}

深入研究RX。重新启动主体:如何延迟`n next()`?

骄傲 2025-02-02 21:05:51

由于我使用MSELOSS的功能爆炸了梯度问题,因此出现了问题,并且我的数据集使用了大量数字。平均平方误差最初很高,因此我对随机梯度下降的迭代将损失迭代为预期的损失,但是这些值太大了,因此当平方立即将它们分类到NP.Inf时,这样做太晚了修复梯度以进行将来的迭代。

解决方案:
将数据集降低,同时大大降低学习率,我尝试了E^-8的迭代。

使用其他损失功能。这是我使用的解决方案,我使用了平均绝对错误。由于其属性的事实,我从此资源中学到了 https://neptune.ai/blog /pytorch-loss功能

什么时候可以使用?

回归问题,尤其是当目标变量的分布具有离群值时,例如与平均值相距很大的小值或大值。对于离群值而言,它被认为更强大。

上面的属性适合我的用例,因此我适当地实现了它。这阻止了我爆炸的梯度问题。

The issue arose due to the lost function exploding gradient issue since I was using MSEloss and my dataset was using large numbers. the Mean Squared error was initially high, So my iterations on stochastic gradient descent Iterated the loss to a higher value as expected, but these values were too large so when squared they immediately got classified to np.inf, in doing so it was too late to fix the gradient for future iterations.

The solution:
Scale the dataset down, whilst drastically decreasing the learning rate, I tried iterations of e^-8.

Or

Use a different loss function. This is the solution I went with, I used the Mean Absolute error. Due to the fact of its properties which I learned from this resource https://neptune.ai/blog/pytorch-loss-functions

When could it be used?

Regression problems, especially when the distribution of the target variable has outliers, such as small or big values that are a great distance from the mean value. It is considered to be more robust to outliers.

The property above fits my use case, thus I implemented it appropriately. Which stopped my exploding gradient issue.

为什么我的损失功能趋向于无效,但是当x和y坐标交换时,它适当地工作

骄傲 2025-02-02 11:54:22

在事件过滤器中返回 true 并不总是足以防止事件传播。对于关闭的事件,您还必须明确地忽略了事件

class MyApp(QMainWindow, Ui_MainWindow):
    ...
    def eventFilter(self, source, event):
        if event.type() == QtCore.QEvent.Close and source is self.models:
            self.set_parent_main(source)
            event.ignore()
            return True
        return super().eventFilter(source, event)
    

Returning True in the event-filter isn't always sufficient to prevent propagation of the event. For close-events, you must also explicitly ignore the event:

class MyApp(QMainWindow, Ui_MainWindow):
    ...
    def eventFilter(self, source, event):
        if event.type() == QtCore.QEvent.Close and source is self.models:
            self.set_parent_main(source)
            event.ignore()
            return True
        return super().eventFilter(source, event)
    

pyqt5:如何在事件过滤器中重新实现关闭事件

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文