白衬杉格子梦

文章 评论 浏览 30

白衬杉格子梦 2025-02-20 08:51:18

您必须在您的字段中添加自定义类,然后必须添加CSS样式,它可以来自文件或直接在HTML中。

在这种情况下,该类是“形式控制”,因此以下样式就足够了

<style>
   .form-control {
     height: 50px;
   }
</style>

You must add a custom class to your field, then you must add a css style, it can be from a file or directly in your html.

In this case, the class is 'form-control', so the following style would suffice

<style>
   .form-control {
     height: 50px;
   }
</style>

如何将表单标签的自定义CS添加到Django表单上?

白衬杉格子梦 2025-02-20 05:58:17

没有现有的实用程序来执行此转换,但是编写一个函数并不是那么复杂。例如,我在 @grpc/grpc-js-xds 图书馆

function validateValue(obj: any): Value {
  if (Array.isArray(obj)) {
    return {
      kind: 'listValue',
      listValue: {
        values: obj.map((value) => validateValue(value)),
      },
    };
  } else {
    switch (typeof obj) {
      case 'boolean':
        return {
          kind: 'boolValue',
          boolValue: obj,
        };
      case 'number':
        return {
          kind: 'numberValue',
          numberValue: obj,
        };
      case 'string':
        return {
          kind: 'stringValue',
          stringValue: obj,
        };
      case 'object':
        if (obj === null) {
          return {
            kind: 'nullValue',
            nullValue: 'NULL_VALUE',
          };
        } else {
          return {
            kind: 'structValue',
            structValue: getStructFromJson(obj),
          };
        }
      default:
        throw new Error(`Could not handle struct value of type ${typeof obj}`);
    }
  }
}

function getStructFromJson(obj: any): Struct {
  if (typeof obj !== 'object' || obj === null) {
    throw new Error('Invalid JSON object for Struct field');
  }
  const fields: { [key: string]: Value } = {};
  for (const [fieldName, value] of Object.entries(obj)) {
    fields[fieldName] = validateValue(value);
  }
  return {
    fields,
  };
}

There is not an existing utility for performing this transformation, but it is not that complicated to write a function to do it. For example, I use the following code in the @grpc/grpc-js-xds library:

function validateValue(obj: any): Value {
  if (Array.isArray(obj)) {
    return {
      kind: 'listValue',
      listValue: {
        values: obj.map((value) => validateValue(value)),
      },
    };
  } else {
    switch (typeof obj) {
      case 'boolean':
        return {
          kind: 'boolValue',
          boolValue: obj,
        };
      case 'number':
        return {
          kind: 'numberValue',
          numberValue: obj,
        };
      case 'string':
        return {
          kind: 'stringValue',
          stringValue: obj,
        };
      case 'object':
        if (obj === null) {
          return {
            kind: 'nullValue',
            nullValue: 'NULL_VALUE',
          };
        } else {
          return {
            kind: 'structValue',
            structValue: getStructFromJson(obj),
          };
        }
      default:
        throw new Error(`Could not handle struct value of type ${typeof obj}`);
    }
  }
}

function getStructFromJson(obj: any): Struct {
  if (typeof obj !== 'object' || obj === null) {
    throw new Error('Invalid JSON object for Struct field');
  }
  const fields: { [key: string]: Value } = {};
  for (const [fieldName, value] of Object.entries(obj)) {
    fields[fieldName] = validateValue(value);
  }
  return {
    fields,
  };
}

GRPC:未知的JSON作为输入和输出

白衬杉格子梦 2025-02-20 00:24:00

由于提取是异步的,因此最常见的方法是显示一些负载指示器(例如旋转器)&amp;数据进来后,请改用组件。

如果您不需要指标,则可能只需返回 null

一般的想法是根据承诺状态操纵某些中间状态(例如 data iSerror )。

查看或更轻的抽象(例如 usefetch hook 查看它们如何管理。

这是 usefetch 的示例实现>::

const useFetch = (url, options) => {
  const [response, setResponse] = React.useState(null);
  const [error, setError] = React.useState(null);
  const [abort, setAbort] = React.useState(() => {});

  React.useEffect(() => {
    const fetchData = async () => {
      try {
        const abortController = new AbortController();
        const signal = abortController.signal;
        setAbort(abortController.abort);
        const res = await fetch(url, {...options, signal});
        const json = await res.json();
        setResponse(json);
      } catch (error) {
        setError(error);
      }
    };
    fetchData();
    return () => {
      abort();
    }
  }, []);

  return { response, error, abort };
};

Since fetching is asyncronous, the most common way is to show some loading indicator (like a spinner) & once the data come in, show the component instead.

If you don't need an indicator, you might just return null.

The general idea is to manipulate some intermediary states (e.g. data, isError) based on the promise state.

Check out react-query library example or a lighter abstraction like useFetch hook to see how they manage it.

Here's a sample implementation of useFetch taken from this article:

const useFetch = (url, options) => {
  const [response, setResponse] = React.useState(null);
  const [error, setError] = React.useState(null);
  const [abort, setAbort] = React.useState(() => {});

  React.useEffect(() => {
    const fetchData = async () => {
      try {
        const abortController = new AbortController();
        const signal = abortController.signal;
        setAbort(abortController.abort);
        const res = await fetch(url, {...options, signal});
        const json = await res.json();
        setResponse(json);
      } catch (error) {
        setError(error);
      }
    };
    fetchData();
    return () => {
      abort();
    }
  }, []);

  return { response, error, abort };
};

React Prop返回零,因为它依赖于状态

白衬杉格子梦 2025-02-19 20:38:41

连接器连接器的数组,因此您需要确定哪个
您要显示的数组元素。例如,所有元素,例如:

 VStack(alignment: .leading) {
     ForEach(item.chargingPark.connectors, id: \.self) { conector in
        Text("connectorType: \(conector.connectorType)")
        Text("PowerKw: \(conector.ratedPowerKw)")
        Text("voltageV: \(conector.voltageV)")
        Text("currentA: \(conector.currentA)")
        Text("currentType: \(conector.currentType.rawValue)")
     }
 }

或第一个元素,例如:在此示例中:

 VStack(alignment: .leading) {
     Text("\(item.chargingPark.connectors.first?.ratedPowerKw ?? 0)")
     Text("\(item.chargingPark.connectors.first?.voltageV ?? 0)")
     Text("\(item.chargingPark.connectors.first?.currentA ?? 0)")
     Text("\(item.chargingPark.connectors.first?.currentType.rawValue ?? "")")
 }

调整代码并按照您的特定需求进行显示。请注意,您可能需要使用 struct Connector:Codable,Hashable {...} 或Make Connector 识别。

connectors is an array of Connector, and so you need to decide which
array element you want to display. For example all elements, such as:

 VStack(alignment: .leading) {
     ForEach(item.chargingPark.connectors, id: \.self) { conector in
        Text("connectorType: \(conector.connectorType)")
        Text("PowerKw: \(conector.ratedPowerKw)")
        Text("voltageV: \(conector.voltageV)")
        Text("currentA: \(conector.currentA)")
        Text("currentType: \(conector.currentType.rawValue)")
     }
 }

or the first one as in this example:

 VStack(alignment: .leading) {
     Text("\(item.chargingPark.connectors.first?.ratedPowerKw ?? 0)")
     Text("\(item.chargingPark.connectors.first?.voltageV ?? 0)")
     Text("\(item.chargingPark.connectors.first?.currentA ?? 0)")
     Text("\(item.chargingPark.connectors.first?.currentType.rawValue ?? "")")
 }

Adjust the code and display to your specific needs. Note you may need to use struct Connector: Codable, Hashable {...} or make Connector Identifiable.

无法在嵌套的复杂JSON中与Swift中的阵列显示正确的数据

白衬杉格子梦 2025-02-19 18:05:27

我将使用 strip() 将这些修剪成像:

p=['  /gene="1"','  /gene="2"']
Gene=[]
for i in p:
  Gene.append(int(i.replace("  /gene=","").strip("\" ")))

或偶数:

p=['  /gene="1"','  /gene="2"']
Gene=[]
for i in p:
  Gene.append(int(i.strip("/gen=\" ")))

或者,如果您不想处理平等标志的左侧,请使用分区

p=['  /gene="1"','  /gene="2"']
Gene=[]
for s in p:
    _, _, value = s.partition('=')
    Gene.append(value.strip("\" "))

I’d use strip() to trim those down like:

p=['  /gene="1"','  /gene="2"']
Gene=[]
for i in p:
  Gene.append(int(i.replace("  /gene=","").strip("\" ")))

or even:

p=['  /gene="1"','  /gene="2"']
Gene=[]
for i in p:
  Gene.append(int(i.strip("/gen=\" ")))

or if you don't want to deal with the left side of the equals sign use partition:

p=['  /gene="1"','  /gene="2"']
Gene=[]
for s in p:
    _, _, value = s.partition('=')
    Gene.append(value.strip("\" "))

我如何制作1&quot” 1&quot;进入整数?

白衬杉格子梦 2025-02-19 13:14:28

我认为您想要以下代码,其中p值是按照p = 10^-s进行计算的,其中s是您的

library(EnhancedVolcano)
EnhancedVolcano(all_genes, x = "logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
                pCutoff =  10^-1.3, FCcutoff = 1)

1.3 rel =“ nofollow noreferrer”> “在此处输入图像描述”

I think you want the following code where the p-value is calculated like p=10^-s where s is your 1.3 like this:

library(EnhancedVolcano)
EnhancedVolcano(all_genes, x = "logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
                pCutoff =  10^-1.3, FCcutoff = 1)

Output:

enter image description here

在R中格式化p值截止线

白衬杉格子梦 2025-02-19 09:47:26

我成功地解决了,通过将控件更改为文本,然后在其上应用Bootstrap DatePicker库,就像在此演示中一样:

https://jqueryui.com/resources/demos/datepicker/localization.html

$("#endDate").datepicker({ dateFormat: 'm-d-yy' }).datepicker($.datepicker.regional["ar"]);
$("#startDate").datepicker({ dateFormat: 'm-d-yy' }).datepicker($.datepicker.regional["ar"]);
<input class="form-control" lang="en-us" asp-for="@Model.EndDate" type="text" placeholder="شهر-يوم-سنة" autocomplete="off" id="endDate" max="2200-12-31">
                                   
<input class="form-control" lang="en-us" asp-for="@Model.StartDate" type="text" placeholder="mm-dd-yyyy" autocomplete="off" max="2200-12-31" id="startDate" value="">

I succeeded to solve, by changing the control to be text and then applying bootstrap datepicker library on it , Just like in this demo:

https://jqueryui.com/resources/demos/datepicker/localization.html

$("#endDate").datepicker({ dateFormat: 'm-d-yy' }).datepicker($.datepicker.regional["ar"]);
$("#startDate").datepicker({ dateFormat: 'm-d-yy' }).datepicker($.datepicker.regional["ar"]);
<input class="form-control" lang="en-us" asp-for="@Model.EndDate" type="text" placeholder="شهر-يوم-سنة" autocomplete="off" id="endDate" max="2200-12-31">
                                   
<input class="form-control" lang="en-us" asp-for="@Model.StartDate" type="text" placeholder="mm-dd-yyyy" autocomplete="off" max="2200-12-31" id="startDate" value="">

阿拉伯浏览器中的HTML5输入日期占位符

白衬杉格子梦 2025-02-18 16:42:30

此时,Apple M1不是正式支持的,但这可能有效:

  1. 确保您已安装了最新的核心工具V4(4.0.4590+)。
  2. local.settings.json 文件中,设置 functions_worker_runtime_version to “ 7.2” 。 Powershell 7.0没有(也可能不会)在Apple M1上得到支持。

Apple M1 is not officially supported at this point, but this may work:

  1. Make sure you have the latest Core Tools v4 installed (4.0.4590+).
  2. In the local.settings.json file, set FUNCTIONS_WORKER_RUNTIME_VERSION to "7.2". PowerShell 7.0 is not (and probably will not be) supported on Apple M1.

如何在Apple M1上获得Azure功能PowerShell?

白衬杉格子梦 2025-02-18 16:33:46

因为您仅在发现DUPE的情况下清除列表。对于非DUPE情况,在下一个迭代中,列表不断提高DUPE的可能性。

Because you clear up the list only in cases when dupes are found. For non-dupe cases the list keeps growing increasing probability of the dupes in the next iterations.

关于生日悖论结果的一些问题

白衬杉格子梦 2025-02-18 12:29:53

您无法使用变换旋转获得所需的效果 - 正如您注意到的那样,动画会立即将其更改为旋转(0)

但是,您可以做的是利用 animation-delay css属性。

而不是计算随机旋转,而是在0到5秒之间计算一个随机时间,然后使用否定的时间来设置 and> and> Animation-delay 。该动画将在其周期,随机点和因此以随机角度。

这是一个纯CSS/HTML/JS片段,旋转放慢速度,因此更容易看到旋转每次都以不同的角度启动:

const spinner = document.querySelector('.spin');
spinner.style.setProperty('--delay', Math.floor(Math.random() * 50));
.spin {
  width: 100px;
  height: 100px;
  background: red;
  animation: spin 50s linear infinite;
  animation-delay: calc(var(--delay) * -1s);
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
<div class="spin"></div>

You can't get the required effect using transform rotate - as you have noted the animation will immediately alter this to rotate(0).

But what you can do is leverage the animation-delay CSS property.

Instead of calculating a random rotation, calculate a random time between 0 and 5 seconds and use that, negative, to set animation-delay.The animation will start part way through its cycle, at a random point and so at a random angle.

Here's a pure CSS/HTML/JS snippet with the rotation slowed down so it's easier to see that the rotation does start at a different angle each time:

const spinner = document.querySelector('.spin');
spinner.style.setProperty('--delay', Math.floor(Math.random() * 50));
.spin {
  width: 100px;
  height: 100px;
  background: red;
  animation: spin 50s linear infinite;
  animation-delay: calc(var(--delay) * -1s);
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
<div class="spin"></div>

使用KeyFrames中的React中的随机启动位置旋转图像

白衬杉格子梦 2025-02-18 06:15:54

考虑到Kafka的语义,复制目标恰好是Kafka时,此问题尤其重要。从好的方面来说,只要您不压实主题,就可以说明您的消费申请收到的每条消息。问题是在Kafka消息中有一些东西,可以使您单调密集的序列编号。如果消费者仅读取数据的一个子集,就会出现问题,因为并非所有的序列编号都会被读取,因此很难知道数据是否不存在,因为它在主题/分区中, t阅读或是否实际缺少。

在完美的情况下,您的来源在用户数据中具有序列编号。从我的许多客户互动中,这不太可能。在我的产品中(我为IBM工作并拥有CDC Kafka目标引擎),我们允许用户在处理用户数据的处理中引入一个序列号。您可以考虑在订阅和主题/分区级别上这样做。但是在那时,您相信CDC捕获了原始数据,并且首先没有“错误”。假设您信任CDC至少要从源日志中读取源信息。...如果您想自己去做路线,则可以在我们的产品中插入一个序列编号。

有问题,因为序列编号是给定的复制会话。...因此,如果存在异常终止,并且您启动了子,则可能会看到新条目以零开始的复制。您可以通过在复制到的来源上记录有效的日志位置的位置中的位置来解决此问题。

为了解决所有这些问题,我设计了一种称为交易一致的消费者的东西。。。它可以消除重复和重新安置操作。它具有一个检查点的字节集,可在先前看到的任何点(允许流数据丢失或不完整处理)中重新启动源流。它确实要求您信任CDC最初捕获了所有更改(这是企业等级复制产品的重点)。如果您碰巧具有源生成的序列编号,则可以与此结合使用。

https://www.ibm。 com/doc/en/idr/11.4.0?主题= kafka-transactionally-Consistent-Consumer

如果您有兴趣。

我在卡夫卡峰会上介绍了技术背后的想法。...

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

嗯 -Leveraging-kafka-to-to-to-end-to-end-acid-transactions/“ rel =“ nofollow noreferrer”> https://www.confluent.io/kafka-summit-summit-summit-summit-sf18/a-sunder-summit-summit-summit-sulth-solution-solution-for-letraging-for- letraging -Kafka-to-to-to-end-to-end-acid-transactions/

希望这对企业等级产品的处理方式有所帮助。

干杯。

This problem is particularly significant when the replication target happens to be Kafka, given the semantics of Kafka. On the bright side, as long as you are not compacting topics it is possible to account for each message received by your consuming application. The issue is having something in the Kafka message that gives you a monotonically dense increasing sequence number. And there becomes issues if a consumer is only reading a subset of the data, as then not all of the sequence numbers would be read so it becomes hard to know if the data isn't there because its in a topic/partition you aren't reading or whether it is actually missing.

In the perfect situation your source has a sequence number in the user data. From my many customer interactions, this is highly unlikely. In my product (I work for IBM and own the CDC Kafka target engine), we allow a user to introduce a sequence number in the processing of the user data. You can consider doing this at both the subscription and topic/partition level. But at that point you are trusting that CDC captured the original data and did not have a "bug" in reading it in the first place. Assuming you trust CDC to have at least read the source information from the source log.... you can then insert a sequence number with our product if you want to go the do it yourself route.

There are problems with this, in that the sequence number is for a given replication session.... so if there's an abnormal termination and you start the sub up, you might see replication with the new entries starting at zero. You can solve this by storing the number you left off in the location you note the effective log position on the source that you've replicated to.

To solve all of this I designed something called the Transactionally Consistent Consumer.... It removes duplication and exactly resequences operations. It has a checkpoint set of bytes that can be used to restart the source stream at any point previously seen (allowing for down stream data loss or incomplete processing). It does require that you trust CDC originally captured all the changes (which is the point of an enterprise grade replication product). If you happened to have source generated sequence numbers than that could work in conjunction with this.

https://www.ibm.com/docs/en/idr/11.4.0?topic=kafka-transactionally-consistent-consumer

If your interested.

I did a presentation at the Kafka summit on the idea behind the technology ....

uh here....

https://www.confluent.io/kafka-summit-sf18/a-solution-for-leveraging-kafka-to-provide-end-to-end-acid-transactions/

Hopefully that helps a bit with how enterprise grade products approach this.

Cheers.

如何验证CDC数据管道?

白衬杉格子梦 2025-02-18 02:21:31

samplemethod()不是一种抽象方法,它是默认的methode,这意味着您可以在任何实现中称呼此methode,因为这是将被调用的默认methode。
此外,您可以在实现中覆盖此方法,但是如果您不这样做,它将仅从接口中调用默认的Methode。因此,您不必在实施类中覆盖/实施它。

但是请记住,即使在界面中使用默认的methode,如果您不这样做,也无法管理任何变量

public abstract class SomeAbstractClass{
    String thing;

    protected SomeAbstractClass(String thing) {
        this.thing = thing;
    }

    void sampleMethod() {
        System.out.println(thing);
        //or do other stuff
    }

    abstract void otherMethode();
}

The sampleMethod() isn't an abstract method it is a default methode, which means that you can call this Methode at any implementation, because this is the default methode which will be called.
Furthermore you can override this methode in your implementation but if you do not it wil simply call your default methode from the interface. So you don't have to override/implement it in your implementation class.

But keep in mind that even with a default methode in your interface you can't manage any variables if you wont to do this use an abstract class like this

public abstract class SomeAbstractClass{
    String thing;

    protected SomeAbstractClass(String thing) {
        this.thing = thing;
    }

    void sampleMethod() {
        System.out.println(thing);
        //or do other stuff
    }

    abstract void otherMethode();
}

抽象方法可以做system.out.println吗?

白衬杉格子梦 2025-02-17 08:59:41

从您的问题来看,它看起来像标签是一个字符串 - 但是您的评论说这是 list 。您可以从列表中提取第一个项目(在这种情况下,只有项目)

tags = ['aaatYnqSi']
clean_tag, *_ = tags
clean_tag = clean_tag.strip()
print(clean_tag, end='')
# 'aaatYnqSi'

From your question, it looks like tags is a string - but your comment says it is a list. You can extract the first item (in this case, only item) from the list with unpacking

tags = ['aaatYnqSi']
clean_tag, *_ = tags
clean_tag = clean_tag.strip()
print(clean_tag, end='')
# 'aaatYnqSi'

如何删除&#x27; [&#x27;&#x27;]&#x27;从字符串中写成txt,仅在文本中写

白衬杉格子梦 2025-02-17 04:58:22

当使用多个git忽略的多个分支时,我会看到一些怪异的行为。因此,现在我要使用批处理文件来推动多个git忽略的多个git回购。
谢谢。

I see some weird behaviors when using multiple branches with multiple git ignore. Hence, now I am going to use a batch file to push multiple git repo with multiple git ignore.
Thanks.

Git Hook首次签名

白衬杉格子梦 2025-02-17 00:00:19

通常,对算法进行了编码,因此您只需要知道一次等价。因此,需要两个电话而不是一个电话并不是一个不合理的负担。

仅需<代码> bool 结果就需要少的结果使事情变得更简单。

Generally the algorithms are coded so you only need to know equivalence once, at the end. So requiring two calls instead of one is not an unreasonable burden.

Requiring only less-than with a bool result makes things simpler.

为什么不c&#x2b;&#x2B;比较需要整数作为返回值?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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