挖鼻大婶

文章 评论 浏览 28

挖鼻大婶 2025-02-12 05:49:08

首先,由于MITM攻击,我不建议您在生产环境中使用此问题,只是回答您的问题; 您的证书具有域127.0.0.0.1,但不需要您的外部IP,您需要将该IP包括在内您的证书,这意味着您需要生成具有127.0.0.1和外部域的新证书。

最好的做法是将HTTPS协议用于外部网络通信,并使用HTTP协议进行内部网络通信,此方法为我们提供了反向逆转服务。这是一篇示例文章,如何用Docker https ://dotnetthoughts.net/how-to-to-nginx-reverse-proxy-with-docker-compose/

Firstly, I would not recommend to use this in production environment due to MITM attack, just answering to your question; your certificate has a domain 127.0.0.1 but not your external IP you need to include that IP into your certificate, which means that you need to generate a new certificate which has 127.0.0.1 and your external domain.

The best practice is using https protocol for external network communication and using http protocol for the internal network communication, this approach brings us reverse-proxy service to do that. this is an example article how to configure reverse proxy with docker https://dotnetthoughts.net/how-to-nginx-reverse-proxy-with-docker-compose/

启动该应用程序与HTTPS合作

挖鼻大婶 2025-02-12 04:25:55

框架挑战:您是否需要复制应用程序?

我经常看到试图以某种迭代方式修改列表副本的代码。要构建一个微不足道的示例,假设我们有不工作(因为 x 不应修改)代码,例如:

x = [8, 6, 7, 5, 3, 0, 9]
y = x
for index, element in enumerate(y):
    y[index] = element * 2
# Expected result:
# x = [8, 6, 7, 5, 3, 0, 9] <-- this is where the code is wrong.
# y = [16, 12, 14, 10, 6, 0, 18]

自然,人们会问如何制作 y 是<代码> x ,而不是同一列表的名称,因此循环的将做正确的事情。

但这是错误的方法。从功能上讲,我们真正想要做的是制作新列表,它是基于的原始>

我们不需要先制作副本就可以做到这一点,而且通常不应该这样做。

当我们需要将逻辑应用于每个元素时

,自然工具的自然工具就是列表的理解。这样,我们写下逻辑,告诉我们所需结果中的元素如何与原始元素相关。简单,优雅和富有表现力;而且,我们避免需要解决方法以修改 y 在 loop中复制复制(因为分配给迭代变量不会影响列表 - ,其原因是我们首先希望副本!)。

在上面的示例中,它看起来像:

x = [8, 6, 7, 5, 3, 0, 9]
y = [element * 2 for element in x]

列表综合功能非常强大;我们还可以使用它们来通过规则过滤元素,并使用子句子句,并且我们可以为 and and 链条(如果> renauses)(它的工作方式)相同的条款以相同的顺序 的相应代码;如果计划在修改副本“>避免问题)的情况下进行修改通过过滤列表的理解。

当我们需要按位置拒绝或插入特定元素时,

假设我们有类似的东西,而

x = [8, 6, 7, 5, 3, 0, 9]
y = x
del y[2:-2] # oops, x was changed inappropriately

不是首先制作 y 首先删除我们不想要的零件,我们可以构建一个列表通过将我们 do 的零件放在一起。因此:

x = [8, 6, 7, 5, 3, 0, 9]
y = x[:2] + x[-2:]

通过切片处理插入,替换等。恰恰理解您希望结果包含哪些子序列。这样的一种特殊情况是进行反向副本 - 假设我们完全需要一个新列表(而不是仅仅是<倒向),我们可以直接通过切割而不是克隆,然后使用 reververs 来直接创建它。


这些方法(例如列表理解)也具有将所需结果创建为表达式的优势,而不是通过程序将现有对象定为就地(和

Frame challenge: do you actually need to copy, for your application?

I often see code that tries to modify a copy of the list in some iterative fashion. To construct a trivial example, suppose we had non-working (because x should not be modified) code like:

x = [8, 6, 7, 5, 3, 0, 9]
y = x
for index, element in enumerate(y):
    y[index] = element * 2
# Expected result:
# x = [8, 6, 7, 5, 3, 0, 9] <-- this is where the code is wrong.
# y = [16, 12, 14, 10, 6, 0, 18]

Naturally people will ask how to make y be a copy of x, rather than a name for the same list, so that the for loop will do the right thing.

But this is the wrong approach. Functionally, what we really want to do is make a new list that is based on the original.

We don't need to make a copy first to do that, and we typically shouldn't.

When we need to apply logic to each element

The natural tool for this is a list comprehension. This way, we write the logic that tells us how the elements in the desired result, relate to the original elements. It's simple, elegant and expressive; and we avoid the need for workarounds to modify the y copy in a for loop (since assigning to the iteration variable doesn't affect the list - for the same reason that we wanted the copy in the first place!).

For the above example, it looks like:

x = [8, 6, 7, 5, 3, 0, 9]
y = [element * 2 for element in x]

List comprehensions are quite powerful; we can also use them to filter out elements by a rule with an if clause, and we can chain for and if clauses (it works like the corresponding imperative code, with the same clauses in the same order; only the value that will ultimately end up in the result list, is moved to the front instead of being in the "innermost" part). If the plan was to iterate over the original while modifying the copy to avoid problems, there is generally a much more pleasant way to do that with a filtering list comprehension.

When we need to reject or insert specific elements by position

Suppose instead that we had something like

x = [8, 6, 7, 5, 3, 0, 9]
y = x
del y[2:-2] # oops, x was changed inappropriately

Rather than making y a separate copy first in order to delete the part we don't want, we can build a list by putting together the parts that we do want. Thus:

x = [8, 6, 7, 5, 3, 0, 9]
y = x[:2] + x[-2:]

Handling insertion, replacement etc. by slicing is left as an exercise. Just reason out which subsequences you want the result to contain. A special case of this is making a reversed copy - assuming we need a new list at all (rather than just to iterate in reverse), we can directly create it by slicing, rather than cloning and then using .reverse.


These approaches - like the list comprehension - also have the advantage that they create the desired result as an expression, rather than by procedurally modifying an existing object in-place (and returning None). This is more convenient for writing code in a "fluent" style.

我如何克隆列表,以免在分配后意外变化?

挖鼻大婶 2025-02-12 03:36:32

如果您使用的是Kotlinx-coroutines-Test-JVM:1.7或更高版本,则可以作为参数传递超时。默认参数为10秒。

/**
 * The default timeout to use when running a test.
 */
internal val DEFAULT_TIMEOUT = 10.seconds

...
public fun runTest(
    context: CoroutineContext = EmptyCoroutineContext,
    timeout: Duration = DEFAULT_TIMEOUT,
    testBody: suspend TestScope.() -> Unit
): TestResult 

因此,您可以将参数添加到 runtest

fun `test load`() = runTest(timeout = 60.seconds) {
...
}

If you are using kotlinx-coroutines-test-jvm:1.7 or higher you can pass the timeout as an argument. The default argument is 10 seconds.

/**
 * The default timeout to use when running a test.
 */
internal val DEFAULT_TIMEOUT = 10.seconds

...
public fun runTest(
    context: CoroutineContext = EmptyCoroutineContext,
    timeout: Duration = DEFAULT_TIMEOUT,
    testBody: suspend TestScope.() -> Unit
): TestResult 

So you can add the argument to runTest

fun `test load`() = runTest(timeout = 60.seconds) {
...
}

获得Kotlin错误“等待60000毫秒后,Test Coroutine未完成”。

挖鼻大婶 2025-02-11 21:00:12

只需使用或操作员捕获任何缺失的值并将它们设置为零:

total_cost: parseInt(req.body.item1||'0') + parseInt(req.body.item2||'0') + parseInt(req.body.item3||'0'),

Just use the OR operator to catch any missing values and set them to zero:

total_cost: parseInt(req.body.item1||'0') + parseInt(req.body.item2||'0') + parseInt(req.body.item3||'0'),

在Express Data API中获取所选复选框的值?

挖鼻大婶 2025-02-11 09:56:13

jQuery load()函数是异步的,因此即使完成并继续进入代码中的下一行,这并不意味着该文件实际上已经加载了,因此您正在调用 Mathjax.typeset()在新内容在页面中之前。您可以将回调函数传递到 load()时,该函数已更新后调用。用它来调用 Mathjax.typeset()

    function loadHTML(filename){
        let file = `formulas/${filename}`
        $("#content").load(file, function () {
            MathJax.typeset();
        });
    };

The jQuery load() function is asynchronous, so even though it completes and goes on to the next line in your code, that doesn't mean the file has actually been loaded, so you are calling MathJax.typeset() before the new content is in the page. You can pass a callback function to load() that is called when the page has been updated. Use that to call MathJax.typeset():

    function loadHTML(filename){
        let file = `formulas/${filename}`
        $("#content").load(file, function () {
            MathJax.typeset();
        });
    };

从其他文件加载时,Mathjax将赢得负载公式

挖鼻大婶 2025-02-11 07:41:30

两种封闭的字符都是字符串。一种类型的报价可方便地用来包装另一种类型的报价。 “'” '“''。引号类型之间的最大区别是,封闭式标识符引用被用代替内部双引号,而不是在单个引号中。

Both kinds of enclosed characters are strings. One type of quote is conveniently used to enclose the other type of quote. "'" and '"'. The biggest difference between the types of quotes is that enclosed identifier references are substituted for inside double quotes, but not inside single quotes.

PHP中的单引号和双引号的字符串有什么区别?

挖鼻大婶 2025-02-11 03:50:29

这是获得相同结果而无需使用功能的另一种方法:

void main() {
  List<int> intList = [1, 2, 3];

  List<int> newList = [
    for (var x in intList) ...[x, x * 10, x * x],
  ];

  print(newList); // [1, 10, 1, 2, 20, 4, 3, 30, 9]
}

Here's another way to obtain the same result without using functions:

void main() {
  List<int> intList = [1, 2, 3];

  List<int> newList = [
    for (var x in intList) ...[x, x * 10, x * x],
  ];

  print(newList); // [1, 10, 1, 2, 20, 4, 3, 30, 9]
}

DART使用列表映射方法可以构建一个包含每个源列表项目的两个(或更多)项目的列表吗?

挖鼻大婶 2025-02-11 01:15:51

如果要滤除内部发件人,并且仅处理组织外部的发件人,请检查 senderemailtype 属性 - 它将是“ ex”使用Exchange Server)和“ SMTP” 用于外部发件人。

If you want to filter out internal senders and only process the senders outside your organization, check the SenderEmailType property - it will be "EX" for the internal senders (assuming you are using Exchange Server) and "SMTP" for the external senders.

PYWIN32-限制,通过潜在发件人列表进行过滤

挖鼻大婶 2025-02-10 19:52:24

我认为异步初始化存在问题。构建方法可以在初始化最后一个变量之前尝试构建(因为initstate方法不能异步)。您可以轻松地检查我的理论。删除initstate()内的“方法调用”(initinfo)。只需在屏幕上创建一个按钮,给它一个匿名的异步函数,在函数中调用您的初始化方法,然后尝试以这样的方式调用您的变量:

() async{
   await initInfo();
   print('partnerUID');
}

简单的方法来检查初始化过程。希望它有帮助。

I think there is a problem with the async initializing. The build method can try to build before you initialize the last variable(Because initState method can not async). You can easily check my theory.Delete the 'method call'(the initInfo) inside the initState(). Just create a button in the screen, give it a anonymous async function, inside the function call your init method and try to call your variables like this:

() async{
   await initInfo();
   print('partnerUID');
}

Easy way to checking out initialization process. Hope it helps.

Flutter X Firebase:如何在Firebase实时数据库中使用数据中使用数据正确初始化字段

挖鼻大婶 2025-02-10 01:58:34

JSON.PARSE 如果JSON并不无效,将工作。如注释中所述,该字符串必须格式为'[“ 1”,“ 2”]'

您无法控制格式,则可以手动解析它:如果字符串不包含报价,则可以使用 #replaceall(“''“”,'“”)

如果 您需要覆盖的边缘案例, json5 可能能够提供帮助: json5.parse5.parse5.parse5.parse5.parse (str)通过NPM或UNPKG加载脚本后

JSON.parse would work, if the JSON wasn't invalid. As mentioned in the comments, the string would have to be formatted as '["1", "2"]'.

If you do not have control over the formatting, you can parse it manually: if the strings don't contain quotes, you can use #replaceAll("'", '"').

If you have edge cases you need to cover, json5 may be able to help: JSON5.parse(str) once you have the script loaded via NPM or unpkg

JavaScript-将字符串阵列转换为一系列字符串

挖鼻大婶 2025-02-09 13:42:49

下面的功能将返回字符串的所有迭代,而无需考虑空间。

我们迭代所有可能的迭代,由

; 是字符的数量是字符串,然后每个迭代由编号 i 给出。

第一个索引(数学中的索引1,索引 0 在代码中)由:

”

最后一个索引(数学中的索引n,索引 n-1 中的代码中)由以下方式给出:

“

和中间索引(在2到n-1中,在 1 的代码中 n-2 )由以下方式给出:

这些方程式创建了一个索引列表,该函数可以从中从原始字符串中选择字符:

def dpro(string: str):
    """Similar to itertools.product for all characters in a string"""

    # get length of string
    N = len(string)

    # iterate over all iterations given by N ** N
    total_iterations = N ** N
    for i in range(total_iterations):

        # get the first character
        first_idx = i // N ** (N - 1)

        # get the last character
        last_idx = i % N

        # get the intermediate characters
        inter_idx = [i // N ** (N - 2 - j) % N for j in range(N - 2)]

        # create a list of
        indices = [first_idx] + inter_idx + [last_idx]

        yield ''.join(string[i] for i in indices)

string = 'abc'

for entry in dpro(string):
    print(entry)

这将以下打印到控制台:

aaa
aab
aac
aba
abb
abc
aca
acb
acc
baa
bab
bac
bba
bbb
bbc
bca
bcb
bcc
caa
cab
cac
cba
cbb
cbc
cca
ccb

我已经测试了字符串的代码,最高为5,但输出很长,所以我坚持使用3此示例的字符。

The function below will return all iterations of a string without considering spaces.

We iterate of all possible iterations, given by

total

where N is the number of characters is the string, and then each iteration is given by the number i.

The first index (index 1 in maths, index 0 in code) is given by:

first

The last index (index N in maths, index N-1 in code) is given by:

last

And the intermediate indices (in maths from 2 to N-1, in code from 1 to N-2) are given by:

inter

These equations creates a list of indices from which the function can select characters from the original string:

def dpro(string: str):
    """Similar to itertools.product for all characters in a string"""

    # get length of string
    N = len(string)

    # iterate over all iterations given by N ** N
    total_iterations = N ** N
    for i in range(total_iterations):

        # get the first character
        first_idx = i // N ** (N - 1)

        # get the last character
        last_idx = i % N

        # get the intermediate characters
        inter_idx = [i // N ** (N - 2 - j) % N for j in range(N - 2)]

        # create a list of
        indices = [first_idx] + inter_idx + [last_idx]

        yield ''.join(string[i] for i in indices)

string = 'abc'

for entry in dpro(string):
    print(entry)

This prints the following to the console:

aaa
aab
aac
aba
abb
abc
aca
acb
acc
baa
bab
bac
bba
bbb
bbc
bca
bcb
bcc
caa
cab
cac
cba
cbb
cbc
cca
ccb

I have tested the code for strings up to length 5 but the output is quite long so I stuck with 3 characters for this example.

通过没有模块的列表获取所有可能的变体

挖鼻大婶 2025-02-09 00:13:33

是的,ICestorm工具链支持ICE40-UP5K-SG48设备。

支持的设备列表中

https://clifford.at/icestorm 受 OPTS
ICE40-UP5K-SG48 48-PIN QFN(7 x 7 mm) 0.50 mm 39 -UP5K –PACKAGE SG48 -d 5k-d 5k -p sg48 -d UP5K

此外,此设备被焊接到 iCebreaker fpga board 。因此,”用于约束文件和工具脚本。

Yes, the icestorm toolchain supports the iCE40-UP5K-SG48 device.

From the supported devices list on the icestrom website:

Part Package Pin Spacing I/Os nextpnr opts arachne-pnr opts icetime opts
iCE40-UP5K-SG48 48-pin QFN (7 x 7 mm) 0.50 mm 39 -up5k –package sg48 -d 5k -P sg48 -d up5k

Furthermore, this device is soldered onto the iCEBreaker FPGA Board. Thus, the iCEBreaker examples might be a useful reference for constraint files and tool scripts.

支持ICE40UP5K-SG48I?

挖鼻大婶 2025-02-08 08:07:54

简短的答案是,如其他答案中所述,没有标准支持的计划。我在这里看不到的一种替代方法是 pydantic

basemodel 来自 pydantic 实质上是一个python数据类,在其构造函数中执行类型验证(并且还具有方便的方法来验证/unmarshal从JSON缓冲器中进行验证/Unmarshal)。对于您的特定问题,绝对值得注意的功能。...如果将可以解析为正确类型的字符串(即'1' - &gt; int |'1.5'1.5' - &gt; float ) ,Pydantic只有在无法将该值强制为正确的类型并为您执行转换时才会抛出错误(可以使用严格的类型或通过设置 strict = true 和使用 basemodel.model_validate )。

它不像 type_enforced 只需使用您的注释/提示(通过将您的函数包装在检查它们的另一个函数中),您仍然最终使用 baseModel constructor /验证者执行您的类型的验证者,即:

from pydantic import BaseModel,ValidationError
from typing import Union
from json import dumps as to_json

class Foo(BaseModel):
    a: int
    b: Union[int,str] = 2
    c: int = 3

def my_fn(foo: Foo) -> None:
    pass

good: Foo = Foo(a=1,b=2,c=3)

also_good: Foo = Foo(a='1',b=2,c='3')

good_dict: dict = {"a":1,"b":2,"c":3}
bad_dict_strict: dict = {"a":'1',"b":2,"c":'3'}

good_dict_json: str = to_json(good_dict)

from_good_dict: Foo = Foo(**good_dict)
from_good_dict_json: Foo = Foo.model_validate_json(good_dict_json)

try:
    bad: Foo = Foo(a='b',b='a',c=1)
except ValidationError as ve:
    print(ve)
try:
    bad_strict: Foo = Foo.model_validate(bad_dict_strict,strict=True)
except ValidationError as ve:
    print(ve)

my_fn(good)
my_fn(also_good)
my_fn(from_good_dict)
my_fn(from_good_dict_json)

Short answer is that there is no plan for standard support, as stated in the other answers. One alternative which I do not see mentioned here is pydantic.

The BaseModel from pydantic is essentially a python data class that performs type validation in its constructor (and also has handy methods to validate/unmarshal from json buffers). One definitely noteworthy feature for your specific question.... if you pass a string that can be parsed to the correct type (IE '1' -> int | '1.5' -> float), pydantic will only throw an error if the value cannot be coerced into the correct type, and otherwise perform the conversion for you (this can be subverted using strict types or by setting strict=True and using BaseModel.model_validate).

It's not like type_enforced where it will just use your annotations/hints (by wrapping your function in another function that checks them), you'll still end up using the BaseModel constructor/validators to enforce your types IE:

from pydantic import BaseModel,ValidationError
from typing import Union
from json import dumps as to_json

class Foo(BaseModel):
    a: int
    b: Union[int,str] = 2
    c: int = 3

def my_fn(foo: Foo) -> None:
    pass

good: Foo = Foo(a=1,b=2,c=3)

also_good: Foo = Foo(a='1',b=2,c='3')

good_dict: dict = {"a":1,"b":2,"c":3}
bad_dict_strict: dict = {"a":'1',"b":2,"c":'3'}

good_dict_json: str = to_json(good_dict)

from_good_dict: Foo = Foo(**good_dict)
from_good_dict_json: Foo = Foo.model_validate_json(good_dict_json)

try:
    bad: Foo = Foo(a='b',b='a',c=1)
except ValidationError as ve:
    print(ve)
try:
    bad_strict: Foo = Foo.model_validate(bad_dict_strict,strict=True)
except ValidationError as ve:
    print(ve)

my_fn(good)
my_fn(also_good)
my_fn(from_good_dict)
my_fn(from_good_dict_json)

可以执行类型的提示吗?

挖鼻大婶 2025-02-06 01:25:37

jinja2不允许模板内的位运算符,因此我们需要创建一个较小的全局函数来执行此类操作员并返回一个数字:

def leftshift(amount):
    return 1 << amount

# Get or create a Jinja2 environment
from jinja2 import Environment
env = Environment(...)

# Add leftshift function to the global context
env.globals['leftshift'] = leftshift

在模板中,现在我们可以使用loop Index:

typedef enum {
    {% for e in mylist %}
    {{ e }} = 0x{{ '{:04X}'.format(leftshift(loop.index0))}},
    {%- endfor %}
    ALL = 0x0FFF
} Sound_Region_t;

Jinja2 does not allow bitwise operators inside the templates, so we need to create a small global function that executes such operators and returns a number:

def leftshift(amount):
    return 1 << amount

# Get or create a Jinja2 environment
from jinja2 import Environment
env = Environment(...)

# Add leftshift function to the global context
env.globals['leftshift'] = leftshift

And in the templates now we can call leftshift function with the loop index:

typedef enum {
    {% for e in mylist %}
    {{ e }} = 0x{{ '{:04X}'.format(leftshift(loop.index0))}},
    {%- endfor %}
    ALL = 0x0FFF
} Sound_Region_t;

jinja2在模板表达式中使用数字表达式

挖鼻大婶 2025-02-05 14:55:41

我认为您只需更改您想要的内容,如果您想添加您只需使用 go mod供应商(用于添加新供应商)和 go mod tidy tidy

i think you just change what do you want, if you wanna add you just use go mod vendor (for adding new vendor) and go mod tidy (for update on your package)

安装时如何使用自定义GO MOD?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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