骄兵必败

文章 评论 浏览 29

骄兵必败 2025-02-20 22:06:37

您可能在模型中定义了一些不可删除的内容,而JSON示例中实际上是无效的。例如,forbatch.result

可能使您的模型中的无效解决问题可以解决这个问题。

You might have some things defined in your model as non-nullable that are actually null in the JSON example. For instance, ForBatch.result.

Possibly making that nullable in your model could solve the issue.

Flutter Web-期望类型的值' lt; string,dynamic>',但获得了类型之一。

骄兵必败 2025-02-20 20:03:07

我已经尝试了此代码:

    public static void Usage(this ILogger logger, LogLevel logLevel, string area, string operation, Dictionary<string, string> parameters)
    {
        Func<Dictionary<string, string>> function = null;

        if (parameters == null)
        {
            var capturable = parameters;
            function = () => capturable;
        }

        logger.Usage(logLevel, area, operation, function);
    }

它导致了44B分配。

我想念什么?

方法平均错误stddevgen 0分配的
log_withinfra_extensionmethoddirect_noparameters11.83 NS4.657 NS0.255 NS0.008444 B

I've tried this code:

    public static void Usage(this ILogger logger, LogLevel logLevel, string area, string operation, Dictionary<string, string> parameters)
    {
        Func<Dictionary<string, string>> function = null;

        if (parameters == null)
        {
            var capturable = parameters;
            function = () => capturable;
        }

        logger.Usage(logLevel, area, operation, function);
    }

And it results in 44B of allocation.

What am i missing?

MethodMeanErrorStdDevGen 0Allocated
Log_WithInfra_ExtensionMethodDirect_NoParameters11.83 ns4.657 ns0.255 ns0.008444 B

即使此func&lt;&gt;变量是空的吗?

骄兵必败 2025-02-20 17:08:13

您可以在AwesomeIcons()函数中使用IFELSE()函数吗?

library(leaflet)
data(quakes)

quakes<-
  quakes %>% mutate(
    type = ifelse(stations > 60, "foo","bar")
  )

icon <- awesomeIcons(
  icon = 'ios-close',
  iconColor = 'black',
  library = 'ion',
  markerColor = ifelse(quakes$type == 'foo', 'green', 'red'))

leaflet(quakes[1:20, ]) %>% addTiles() %>%
  addAwesomeMarkers(~long, 
                    ~lat, 
                    icon= icon, 
                    label=~as.character(mag))

Could you use the ifelse() function in the awesomeIcons() function?

library(leaflet)
data(quakes)

quakes<-
  quakes %>% mutate(
    type = ifelse(stations > 60, "foo","bar")
  )

icon <- awesomeIcons(
  icon = 'ios-close',
  iconColor = 'black',
  library = 'ion',
  markerColor = ifelse(quakes$type == 'foo', 'green', 'red'))

leaflet(quakes[1:20, ]) %>% addTiles() %>%
  addAwesomeMarkers(~long, 
                    ~lat, 
                    icon= icon, 
                    label=~as.character(mag))

r叶叶aiddawesomemarkers。如何基于列值(字符)设置条件颜色

骄兵必败 2025-02-20 15:34:38

添加a /a> &lt; iframe&gt;中的属性

与此CSS代码max-width:100%;

这意味着移动设备中的视频iframe总是比设备的宽度要小。

以及高度保持不变,因此可以看到以下内容。

<iframe style="max-width: 100%;" width="560" height="315" id="youtube2" src="https://www.youtube.com/embed/JexOJOssGwk?rel=0&enablejsapi=1&origin=https%3A%2F%2Fwww.apetito.co.uk&widgetid=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

有用的文档:

- max-width https://developer.mozilla.org/en-us/docs/web/css/max-width

- 样式属性 https://developer.mozilla.org/en-us/docs/web/html/global_attributes/style

add a style="" attribute in the <iframe>

with this css code max-width: 100%;

enter image description here

this means that the video iframe in mobile always takes less than the width of the device.

and also the height remain the same, so the content below can be visible.

<iframe style="max-width: 100%;" width="560" height="315" id="youtube2" src="https://www.youtube.com/embed/JexOJOssGwk?rel=0&enablejsapi=1&origin=https%3A%2F%2Fwww.apetito.co.uk&widgetid=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

useful documentations:

- max-width: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width

- style attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style

如何使弹出视频各自响应移动设备

骄兵必败 2025-02-20 11:36:36

看起来您需要删除外部数组,并为字典值使用列表,

var required = new List<string>>();
var optional = new List<string>>();
foreach (DataTable table in dsgroupsinfo.Tables)
{
    foreach (DataRow dr in table.Rows)
    {
        required.Add(dr["requerido"].ToString());
        optional.Add(dr["opcional"].ToString());
    }
}
var rt = new Dictionary<string, List<string>>
{
    {"required", required},
    {"optional", optional},
};

return Ok(
    new {
        name = Dname,
        primaryLastName = DprimaryLastName,
        secondLastName = DsecondLastName,
        degrees = Ddegrees,
        roles = Droles,
        entityId = DentityId,
        enrollment = Denrollment,
        payrollNumber = DpayrollNumber,
        photo = Dphoto,
        groupsInfo = rt,
        birthDate = DbirthDate
    } 
);

理想情况下,您将使用适当的对象模型,如其他答案所示。

Looks like you need to remove the outer array, and use a list for the dictionary value

var required = new List<string>>();
var optional = new List<string>>();
foreach (DataTable table in dsgroupsinfo.Tables)
{
    foreach (DataRow dr in table.Rows)
    {
        required.Add(dr["requerido"].ToString());
        optional.Add(dr["opcional"].ToString());
    }
}
var rt = new Dictionary<string, List<string>>
{
    {"required", required},
    {"optional", optional},
};

return Ok(
    new {
        name = Dname,
        primaryLastName = DprimaryLastName,
        secondLastName = DsecondLastName,
        degrees = Ddegrees,
        roles = Droles,
        entityId = DentityId,
        enrollment = Denrollment,
        payrollNumber = DpayrollNumber,
        photo = Dphoto,
        groupsInfo = rt,
        birthDate = DbirthDate
    } 
);

Ideally you would use a proper object model, as the other answer has shown.

如何返回C#对象而不是数组JSON

骄兵必败 2025-02-20 10:33:45

我想您可以做类似:

<xsl:template match="body">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent="boolean(self::aside)">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:for-each-group select="current-group()" group-adjacent="@class">
                        <xsl:element name="tag{if (@class=(1,2)) then @class else 'X'}" >
                            <xsl:attribute name="class" select="@class"/>
                            <xsl:copy-of select="current-group()/node()"/>                  
                        </xsl:element>  
                    </xsl:for-each-group>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="current-group()"/>                 
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

ps的事情:如果一边,那么您可以将其缩短为:

<xsl:template match="body">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent="string(@class)">
            <xsl:choose>
                <xsl:when test="@class">
                    <xsl:element name="tag{if (@class=(1,2)) then @class else 'X'}" >
                        <xsl:attribute name="class" select="@class"/>
                        <xsl:copy-of select="current-group()/node()"/>                    
                    </xsl:element>  
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="current-group()"/>                    
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

I guess you could do something like:

<xsl:template match="body">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent="boolean(self::aside)">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:for-each-group select="current-group()" group-adjacent="@class">
                        <xsl:element name="tag{if (@class=(1,2)) then @class else 'X'}" >
                            <xsl:attribute name="class" select="@class"/>
                            <xsl:copy-of select="current-group()/node()"/>                  
                        </xsl:element>  
                    </xsl:for-each-group>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="current-group()"/>                 
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

P.S. If aside elements are the only child elements of body that have a (non-empty) class attribute, then you could shorten this to:

<xsl:template match="body">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent="string(@class)">
            <xsl:choose>
                <xsl:when test="@class">
                    <xsl:element name="tag{if (@class=(1,2)) then @class else 'X'}" >
                        <xsl:attribute name="class" select="@class"/>
                        <xsl:copy-of select="current-group()/node()"/>                    
                    </xsl:element>  
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="current-group()"/>                    
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

XSLT:将相邻元素与同类分组

骄兵必败 2025-02-20 04:33:39

对我来说,写作作品:

page.insert_image(rect, stream=img)

For me works writing:

page.insert_image(rect, stream=img)

将图像插入PDF文件

骄兵必败 2025-02-20 03:12:29

创建一个名为:keep_alive.py 的文件夹

,然后

from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def main():
  return "Your Bot Is Ready!" #Change this if you want

def run():
    app.run(host="0.0.0.0", port=8080) #don't touch this

def keep_alive():
    server = Thread(target=run)
    server.start()

导入import ewep_alive#不要忘记将文件导入到bot主文件夹中!

Create a Folder named : keep_alive.py

then

from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def main():
  return "Your Bot Is Ready!" #Change this if you want

def run():
    app.run(host="0.0.0.0", port=8080) #don't touch this

def keep_alive():
    server = Thread(target=run)
    server.start()

Now Import import keep_alive #don't forget to import the file! To your bot main folder

Discord Bot不会与Uptimerobot上网

骄兵必败 2025-02-20 01:52:56

使用poly例如,

c(1, poly(t(X), degree = 3, raw = TRUE))

请注意,订购将有所不同。

另请注意,Python代码不正确。如果x是列,则不要转置。在这种情况下,您将拥有每种语言的正确值:

poly.fit_transform(X.T) # Original X before transpose   
array([[1.00000000e+00, 2.98000000e+02, 8.88040000e+04, 2.64635920e+07],
       [1.00000000e+00, 5.69709349e+00, 3.24568742e+01, 1.84909847e+02],
       [1.00000000e+00, 3.50000000e+01, 1.22500000e+03, 4.28750000e+04],
       [1.00000000e+00, 5.00000000e-02, 2.50000000e-03, 1.25000000e-04],
       [1.00000000e+00, 1.00000000e-02, 1.00000000e-04, 1.00000000e-06]])

in R:

 X <- c(x1, log(x1), x2, x3, x4)
 cbind(intercept = 1, poly(X, 3, raw = TRUE))
     intercept          1           2            3
[1,]         1 298.000000 88804.00000 2.646359e+07
[2,]         1   5.697093    32.45687 1.849098e+02
[3,]         1  35.000000  1225.00000 4.287500e+04
[4,]         1   0.050000     0.00250 1.250000e-04
[5,]         1   0.010000     0.00010 1.000000e-06

Use poly eg

c(1, poly(t(X), degree = 3, raw = TRUE))

Note that the ordering will be different.

Also Note that the python code is incorrect. If X is a column, then do not transpose. in that case you will have the correct values from each language:

poly.fit_transform(X.T) # Original X before transpose   
array([[1.00000000e+00, 2.98000000e+02, 8.88040000e+04, 2.64635920e+07],
       [1.00000000e+00, 5.69709349e+00, 3.24568742e+01, 1.84909847e+02],
       [1.00000000e+00, 3.50000000e+01, 1.22500000e+03, 4.28750000e+04],
       [1.00000000e+00, 5.00000000e-02, 2.50000000e-03, 1.25000000e-04],
       [1.00000000e+00, 1.00000000e-02, 1.00000000e-04, 1.00000000e-06]])

in R:

 X <- c(x1, log(x1), x2, x3, x4)
 cbind(intercept = 1, poly(X, 3, raw = TRUE))
     intercept          1           2            3
[1,]         1 298.000000 88804.00000 2.646359e+07
[2,]         1   5.697093    32.45687 1.849098e+02
[3,]         1  35.000000  1225.00000 4.287500e+04
[4,]         1   0.050000     0.00250 1.250000e-04
[5,]         1   0.010000     0.00010 1.000000e-06

创建多项式特征矩阵

骄兵必败 2025-02-20 00:47:06

我们尝试的第一件事是简单地通过返回列表的单一子句进行选择:

(select'throws(where(和'房间“ somename”)))

答:[object {throw-schema},对象{throw-schema}]

,然后我们将列表操作员“ filter”应用于结果:

(filter(='with读取功能'1)(select'throws(whene(and'room“ somename”)))

请记住,我们还有一个读取回合的功能,然后吐回圆号我们过滤了圆形值的平等

The first thing we tried was to simply select via a single clause which returns a list:

(select 'throws (where (and ('room "somename")))

A: [object{throw-schema},object{throw-schema}]

And then we applied the list operator "filter" to the result:

(filter (= 'with-read-function' 1) (select 'throws (where (and ('room "somename"))))

Please keep in mind we had a further function that read the round and spit back the round number and we filtered for equality of the round value.

This ended up working but it felt very janky.

如何使用PACT智能合约语言中的多个子句选择一行

骄兵必败 2025-02-19 19:44:29

在您的情况下,使用模板的最简单方法是将所有内容包装在yamlencode中。因此,您的service_entry.yaml.tpl可以是:

${yamlencode(
{
    apiVersion = "networking.istio.io/v1beta1"
    kind = "ServiceEntry"
    metadata = {
      name = service_entry_name
      namespace = namespace    
    }  
    spec = {
      "hosts" = [hosts]
      ports = [ for idx in range(length(name)):
            {
               name: name[idx]
               number: number[idx]
               protocol: protocol[idx]            
            }
      ]
    }    
}
)}

这会生成有效的yaml文件,您不必与奇怪的模板语法作斗争。

The easiest way to work with templates, in your case yaml, is to wrap everything in yamlencode. So your service_entry.yaml.tpl can be:

${yamlencode(
{
    apiVersion = "networking.istio.io/v1beta1"
    kind = "ServiceEntry"
    metadata = {
      name = service_entry_name
      namespace = namespace    
    }  
    spec = {
      "hosts" = [hosts]
      ports = [ for idx in range(length(name)):
            {
               name: name[idx]
               number: number[idx]
               protocol: protocol[idx]            
            }
      ]
    }    
}
)}

This generates valid yaml file and you don't have to fight against the strange templating syntax.

多级地图,带有Terraform中模板的列表

骄兵必败 2025-02-19 18:55:37

python

8 % -3 = -1

因此,经过一些研究,默认模拟方法是语言取决于语言的,例如,javaScript的

8 % -3 = 2

是因为它使用js,它使用trunc方法

r = a - (n * trunc(a/n))
r is the remainder.
a is the dividend.
n is the divisor.

用于python,

r = a - (n * floor(a/n))

但是没有简单的方法可以像我们一样在python中切换python和使用 / vs //
但是,有一个数学库功能,我们可以使用

>>> 8.0 % -3
-1.0

>>> import math
>>> math.fmod(8.0, -3.0)
2.0

值得注意的是,并不是Python中的所有Modulo操作都是相同的。虽然与int和float类型一起使用的模量将带有除数的迹象,但其他类型不会。

参考 https://realpython.com/python-modulo-operator/#modulo-operator-with-a-a-negative-operand

So upon some research the default modulo method is language dependent, for python

8 % -3 = -1

for javascript for example

8 % -3 = 2

it is because for js it uses the trunc method

r = a - (n * trunc(a/n))
r is the remainder.
a is the dividend.
n is the divisor.

for python it is the floor method

r = a - (n * floor(a/n))

however there is no simple way to switch in python like we do with floor and trunc division to use / vs //
but there is a math library function we could use

>>> 8.0 % -3
-1.0

>>> import math
>>> math.fmod(8.0, -3.0)
2.0

worth noting not all modulo operations in Python are the same. While the modulo used with the int and float types will take the sign of the divisor, other types will not.

reference https://realpython.com/python-modulo-operator/#modulo-operator-with-a-negative-operand

python如何获得截短的模型与地板模型

骄兵必败 2025-02-18 23:53:11

在您的代码c&lt中; 1000a + b == c是不变的。总和(A + B + C)== 2 * C要求右三角形的最长侧(hypotenuse)与对方的总和一样长,并且没有这样的数字这可以满足它,因此主体永远不会执行。

for a in range(1, 1000):
    for b in range(1, 1000):
        c = 1000 - (a + b)
        if (a ** 2 + b ** 2 == c ** 2):
            print(a * b * c)
            exit()

In your code c < 1000 and a + b == c are invariants. The sum (a + b + c) == 2 * c requires that the longest side(hypotenuse) of the right triangle to be as long as the sum of the other sides, and there's no such numbers that satisfy it and so the if body never executes.

for a in range(1, 1000):
    for b in range(1, 1000):
        c = 1000 - (a + b)
        if (a ** 2 + b ** 2 == c ** 2):
            print(a * b * c)
            exit()

Projecteuler问题8-不确定我的代码有什么问题

骄兵必败 2025-02-18 02:11:12
> a <- c(1:5)
> b <- c(2:5,"?")
> c <- c("a","b","?","d","e")
> 
> df <- data.frame(a,b,c)
> df
  a b c
1 1 2 a
2 2 3 b
3 3 4 ?
4 4 5 d
5 5 ? e
> df[df == "?"] <- NA
> df
  a    b    c
1 1    2    a
2 2    3    b
3 3    4 <NA>
4 4    5    d
5 5 <NA>    e

然后,您可以使用na.omit()

> a <- c(1:5)
> b <- c(2:5,"?")
> c <- c("a","b","?","d","e")
> 
> df <- data.frame(a,b,c)
> df
  a b c
1 1 2 a
2 2 3 b
3 3 4 ?
4 4 5 d
5 5 ? e
> df[df == "?"] <- NA
> df
  a    b    c
1 1    2    a
2 2    3    b
3 3    4 <NA>
4 4    5    d
5 5 <NA>    e

then you can use na.omit()

如何去除行?标记而不是r中的n

骄兵必败 2025-02-18 00:54:26

Heroku在构建和部署代码之前,使用您的源代码创建一个GIT存储库。您曾尝试访问该私人GIT存储库,这是外界无法访问的(因此,不允许出现方法错误消息)。但是,部署Web应用程序的实际网站是不同的。该Web应用程序包含您的应用程序名称,如果您在Heroku应用程序创建过程中给出了一个应用程序名称,则为Web应用程序提供了一个随机名称。

heroku git存储库链接: https://git.heroku.com/ 。

​com/

Heroku creates a git repository with your source code before building and deploying your code. You had tried to access that private Git repository, which is not accessible to the outside world (therefore, the Method Not Allowed error message appeared). But the actual website where your web app is deployed is different. That web app includes your app name, if you had given one during Heroku app creation, else a random name is given to your web app.

Heroku Git Repository Link: https://git.heroku.com/serene-crag-92322.git

Deployed Heroku App Link: http://serene-crag-92322.herokuapp.com/

我如何解决“不允许的方法”在Heroku部署中

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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