川水往事

文章 评论 浏览 30

川水往事 2025-02-20 22:45:22

不,这是不可能的。

规则的作者(DRL或其他)可以通过类路径导入他们可用的任何类。

No this is not possible.

The author of the rules (DRL or otherwise) can import any class that's available to them via the classpath.

限制从规则[drools]中访问类

川水往事 2025-02-20 12:44:38

可以使用 MATD \ z (字符串的结尾)?

string = "my_name"

suffix1 = "name"
suffix2 = "name2"

在Ruby> = 3.1

result1 = %r{#{suffix1}\z}.match(string)&.match(0)
# => "name"

result2 = %r{#{suffix2}\z}.match(string)&.match(0)
# => nil

中in Ruby< 3.1

result1 = %r{#{suffix1}\z}.match(string)&.[](0)
# => "name"

result2 = %r{#{suffix2}\z}.match(string)&.[](0)
# => nil

仅用于 的娱乐技巧:

string.tap { |s| break s.end_with?(suffix1) ? suffix1 : nil }
# => "name"

string.tap { |s| break s.end_with?(suffix2) ? suffix2 : nil }
# => nil

May be using match and \z (end of string)?

string = "my_name"

suffix1 = "name"
suffix2 = "name2"

In Ruby >= 3.1

result1 = %r{#{suffix1}\z}.match(string)&.match(0)
# => "name"

result2 = %r{#{suffix2}\z}.match(string)&.match(0)
# => nil

In Ruby < 3.1

result1 = %r{#{suffix1}\z}.match(string)&.[](0)
# => "name"

result2 = %r{#{suffix2}\z}.match(string)&.[](0)
# => nil

Just for fun trick with tap:

string.tap { |s| break s.end_with?(suffix1) ? suffix1 : nil }
# => "name"

string.tap { |s| break s.end_with?(suffix2) ? suffix2 : nil }
# => nil

RUBY:如果end_with获得值?是真的

川水往事 2025-02-20 05:07:46

重新启动您的计算机。重新开放项目后,转到 file&gt;与gradle文件同步项目。这对我有用。

它也可能有助于从磁盘中重新加载

Restart your computer. Once you reopen your project, go to File > Sync Project with Gradle Files. This worked for me.

It might help to Reload All from Disk too.

compilesdkversion未在Expo Run Android上指定

川水往事 2025-02-20 03:14:56

步骤:

  1. 备份现有D365组织的数据库
  2. 创建一个新的D365组织,
  3. 使用步骤1的备份来还原新组织。

向导将指导您完成整个过程。

Steps:

  1. Backup the database of the existing D365 organization
  2. Create a new D365 organization
  3. Restore the new organization using the backup of step 1

The wizard will guide you through the process.

克隆动力学v9本地环境的正确方法是什么?

川水往事 2025-02-19 18:41:37

正如评论中指出的那样,您面临的第一个问题是,您不能将系列迫使一个布尔值进行评估以评估if语句。这就是错误消息所指出的:

valueerror:系列的真实价值是模棱两可的。使用A.Empty,A.Bool(),A.Item(),A.Any()或A.all()

如果您要运行操作,如果某些汇总统计量是正确的,则可以使用其中之一减少,例如

def quanta(data):
    if (data['C'] > 0).any():
        return ((data['A']+data['B']),(data['A']-data['B']))

,一旦解决此问题,您仍然会有一个情况, a,b = Quanta()可能会导致问题,因为 Quanta 将返回 none 如果不满足条件。

您可以通过处理功能返回的可能情况来处理此问题。如果 Quanta 评估false中的条件,将返回。因此,只需在您的代码中处理它:

quanta_result = quanta()
if quanta_result is not None:
    a, b = quanta_result

另一方面,如果您实际上是在尝试执行元素操作,则可能正在寻找 series.where ?您可以执行各种蒙版操作,例如:

def quanta(data):
    # in rows where C > 0, return A + B, and return A - B elsewhere
    return (data["A"] + data["B"]).where(
        data["C"] > 0, 
        (data["A"] - data["B"]),
    )

这只是一个例子 - 我不确定您要做什么。

As is pointed out in comments, the first issue you're facing is that you can't coerce a Series to a single boolean needed to evaluate for an if statement. That is what the error message is indicating:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

If you're trying to run the operation if some aggregate statistic is true, you can use one of these reductions, e.g.

def quanta(data):
    if (data['C'] > 0).any():
        return ((data['A']+data['B']),(data['A']-data['B']))

once you resolve this, you will still have a case where a, b = quanta() can cause problems, as quanta will return None if the condition is not satisfied.

you can handle this by handling the possible cases returned by your function. if the condition in quanta evaluates False, None will be returned. so just handle that in your code:

quanta_result = quanta()
if quanta_result is not None:
    a, b = quanta_result

If, on the other hand, you're actually trying to perform an elementwise operation, you may be looking for something like Series.where? you could do all kinds of masked operations, e.g.:

def quanta(data):
    # in rows where C > 0, return A + B, and return A - B elsewhere
    return (data["A"] + data["B"]).where(
        data["C"] > 0, 
        (data["A"] - data["B"]),
    )

This is just an example - I'm not totally sure what you're going for.

我可以从条件函数中返回多个值并单独打印它们吗?

川水往事 2025-02-19 16:18:17

尝试 group_by() summarize()从dplyr:

library(dplyr)

cars %>%
   group_by(car) %>%
   summarise(Count = n() %>%
   arrange(desc(Count)

应提供每种汽车类型的列表,以降序的顺序排序。

希望这有帮助!

Try a group_by() and summarise() approach from dplyr:

library(dplyr)

cars %>%
   group_by(car) %>%
   summarise(Count = n() %>%
   arrange(desc(Count)

That should provide a list of each car type sorted in descending order of their count.

Hope this helps!

总结两列的类型数量?

川水往事 2025-02-19 13:15:55

请尝试更改它:

<li><a href="politics">Politics</a></li>

与:

<li><a href="{% url 'politics' %}">Politics</a></li>

Please try changing it:

<li><a href="politics">Politics</a></li>

With:

<li><a href="{% url 'politics' %}">Politics</a></li>

valueRror在 /邮政 /政治领域&#x27; id&#x27;期待一个数字,但得到了政治&#x27;

川水往事 2025-02-19 01:10:39

简单的caches无法启用索引。请参阅:

是否可以索引简单的Infinispan缓存?

川水往事 2025-02-18 18:53:10

如果有帮助,我的印象是,列的循环应该起作用。一个人可以修改循环或添加更多条件,以填充列的其他值。

#written in R version 4.2.1
data(mtcars)
mtcars$want = 0
for(i in 1:dim(mtcars)[1]){
if(mtcars$carb[i] == 1){
mtcars$want[i] = mtcars$qsec[i]
}}

结果:

head(mtcars)
#                   mpg cyl disp  hp drat    wt  qsec vs am gear carb  want
#Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4  0.00
#Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4  0.00
#Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1 18.61
#Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1 19.44
#Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2  0.00
#Valiant 

If it is helpful, I am of the impression that a loop over the columns should work. One can modify the loop or add further conditionals as appropriate to fill in the other values of the column.

#written in R version 4.2.1
data(mtcars)
mtcars$want = 0
for(i in 1:dim(mtcars)[1]){
if(mtcars$carb[i] == 1){
mtcars$want[i] = mtcars$qsec[i]
}}

Result:

head(mtcars)
#                   mpg cyl disp  hp drat    wt  qsec vs am gear carb  want
#Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4  0.00
#Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4  0.00
#Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1 18.61
#Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1 19.44
#Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2  0.00
#Valiant 

如果A列等于C列中B列的标准返回值

川水往事 2025-02-18 17:26:34

多亏了@geobreze的评论,我将其深入到@mockbean。
这是我数千次尝试尝试的一种方法,但是我复制了一些代码,而我却没有真正理解我

使用@spybean的应对方法,因为@mockbean嘲笑所有方法类。要进行SEMPLIFY实现我嘲笑了客户端对象,请交换RESTTEMPLATE,这有点复杂,我不想遇到其他愚蠢的错误。

这不是有用的声明所有类链,所以我卸下了立面,并且我使用@Autowired注释,而不是@InjectMock

在这里我的测试

@ActiveProfile("test")
@RunWith(SpringRunner.class)
@SpringbootTest
@EmbeddedKafka
public class MySuccessfullTest{

    @SpyBean MyClient client;
    @Autowired KafkaConsumer consumer;
    @Autowired KafkaProducer producer;

    @Test
    public void test(){
        MyClientResponse responseObject = MyClientResponse();

        Mokito.doReturn(responseObject).when(client).callApi();
        producer.send("My Kafka Message");
    }
}

thanks to @geobreze comment I drilled down into @MockBean.
It was a way tried on my thousands tries but I copied some code without really understand what it was coping

At the end I've used @SpyBean because @MockBean mocks all methods class. To semplify implementation I've mocked Client object, exchenge of RestTemplate it is a little bit complex, I didn't want fall in other stupid error.

It is not useful declare all classes chain, so I've removed facade and I've used @autowired annotation rather than @InjectMock

here my test

@ActiveProfile("test")
@RunWith(SpringRunner.class)
@SpringbootTest
@EmbeddedKafka
public class MySuccessfullTest{

    @SpyBean MyClient client;
    @Autowired KafkaConsumer consumer;
    @Autowired KafkaProducer producer;

    @Test
    public void test(){
        MyClientResponse responseObject = MyClientResponse();

        Mokito.doReturn(responseObject).when(client).callApi();
        producer.send("My Kafka Message");
    }
}

sububClass中的模拟rettemplate

川水往事 2025-02-17 20:07:18

我同意关于使用过载的273K和TemplateTypEdef。

但是,如果您对拥有案例处理逻辑的模板设定为一个地方,则可以这样做:

#include <iostream>
#include <type_traits>

using std::cout;

enum class CURSOR { ON, OFF };
enum class ANSI { ON, OFF };

template <typename T>
void OPTION(T opt) {
    if constexpr (std::is_same_v<T, CURSOR>) {
        if (opt == CURSOR::ON) cout << "cursor is on\n";
        else if (opt == CURSOR::OFF) cout << "cursor is off\n";
    } else if constexpr (std::is_same_v<T, ANSI>) {
        if (opt == ANSI::ON) cout << "ANSI is on\n";
        else if (opt == ANSI::OFF) cout << "ANSI is off\n";
    }
}

int main() {
    OPTION( CURSOR::ON );
    OPTION( ANSI::ON );
}

I agree with 273K and templatetypedef about using overloads instead.

However, if you have your heart set on having a template with the case handling logic all in one place, you can do it this way:

#include <iostream>
#include <type_traits>

using std::cout;

enum class CURSOR { ON, OFF };
enum class ANSI { ON, OFF };

template <typename T>
void OPTION(T opt) {
    if constexpr (std::is_same_v<T, CURSOR>) {
        if (opt == CURSOR::ON) cout << "cursor is on\n";
        else if (opt == CURSOR::OFF) cout << "cursor is off\n";
    } else if constexpr (std::is_same_v<T, ANSI>) {
        if (opt == ANSI::ON) cout << "ANSI is on\n";
        else if (opt == ANSI::OFF) cout << "ANSI is off\n";
    }
}

int main() {
    OPTION( CURSOR::ON );
    OPTION( ANSI::ON );
}

以不同的枚举类型为输入的功能如何?

川水往事 2025-02-17 12:12:05

您的 consolehandler()非静态类方法。必须在 runner 的对象实例上调用它。

这意味着您不能将其用作Win32 API回调。它具有隐藏的参数,API不知道,因此无法将 Runner 对象地址传递给。

您对强制 consolehandler()的打字是调用不确定的行为,这就是为什么 cevent 参数未接收正确的值的原因。它正在从错误的内存位置接收其值。

如果您删除类型,则有正当理由的原因是,此代码将无法编译。只有独立的功能和静态类方法,才能用作Win32 API回调。请勿使用类型播种来沉默编译器错误。改用错误。

而是尝试一下:

class Runner {
public:
    static void reevoke(){
        char p[] = "path to exe";
        STARTUPINFO si;
        PROCESS_INFORMATION pi;

        ZeroMemory( &si, sizeof(si) );
        si.cb = sizeof(si);
        ZeroMemory( &pi, sizeof(pi) );

        if (CreateProcess(p,              // the path
                          NULL,           // Command line
                          NULL,           // Process handle not inheritable
                          NULL,           // Thread handle not inheritable
                          FALSE,          // Set handle inheritance to FALSE
                          0,              // No creation flags
                          NULL,           // Use parent's environment block
                          NULL,           // Use parent's starting directory
                          &si,            // Pointer to STARTUPINFO structure
                          &pi             // Pointer to PROCESS_INFORMATION structure (removed extra parentheses)
            ))
        {
            CloseHandle(pi.hThread);
            CloseHandle(pi.hProcess);
        }
    }

    static BOOL WINAPI ConsoleHandler(DWORD CEvent)
    {
        cout << CEvent << " | " <<  CTRL_CLOSE_EVENT << endl;

        switch (CEvent)
        {
            case CTRL_CLOSE_EVENT:
                Beep(600, 200);
                MessageBox(NULL,
                           "CTRL+BREAK received!",
                           "CEvent",
                           MB_OK);
                cout << "closed bbbb" << endl;
                reevoke();
                break;

            case CTRL_C_EVENT:
                reevoke();
                return TRUE;

            default:
                 cout << "Event was: " << CEvent << endl;
        }

        return TRUE;
    }

    ~Runner()
    {
        cout << "destructor called" << endl;
        if (GetKeyState('Q') & 0x8000){
            cout << "q pressed" << endl;
        }
        else if (SetConsoleCtrlHandler(&ConsoleHandler, TRUE) == FALSE){
            cout << "could not set Handler" << endl;
        }
        else{
            cout << "Handler Set" << endl;
            Sleep(1000);

            while (1) {}
        }
    }
};

int main()
{
    cout << "Hello world! I am unstoppable" << endl;
    Runner r;
    return 0;
}

Your ConsoleHandler() is a non-static class method. It must be called on an object instance of Runner.

Which means, you can't use it as an Win32 API callback. It has a hidden this parameter, which the API doesn't know about, and so can't pass the Runner object address to.

Your typecast to force ConsoleHandler() as a callback is invoking undefined behavior, which is why the CEvent parameter is not receiving the correct values. It is receiving its value from the wrong memory location.

There is a valid reason why this code will fail to compile if you drop the typecast. Only free-standing functions, and static class methods, can be used as Win32 API callbacks. Do not use typecasts to silence compiler errors. Fix the errors instead.

Try this instead:

class Runner {
public:
    static void reevoke(){
        char p[] = "path to exe";
        STARTUPINFO si;
        PROCESS_INFORMATION pi;

        ZeroMemory( &si, sizeof(si) );
        si.cb = sizeof(si);
        ZeroMemory( &pi, sizeof(pi) );

        if (CreateProcess(p,              // the path
                          NULL,           // Command line
                          NULL,           // Process handle not inheritable
                          NULL,           // Thread handle not inheritable
                          FALSE,          // Set handle inheritance to FALSE
                          0,              // No creation flags
                          NULL,           // Use parent's environment block
                          NULL,           // Use parent's starting directory
                          &si,            // Pointer to STARTUPINFO structure
                          &pi             // Pointer to PROCESS_INFORMATION structure (removed extra parentheses)
            ))
        {
            CloseHandle(pi.hThread);
            CloseHandle(pi.hProcess);
        }
    }

    static BOOL WINAPI ConsoleHandler(DWORD CEvent)
    {
        cout << CEvent << " | " <<  CTRL_CLOSE_EVENT << endl;

        switch (CEvent)
        {
            case CTRL_CLOSE_EVENT:
                Beep(600, 200);
                MessageBox(NULL,
                           "CTRL+BREAK received!",
                           "CEvent",
                           MB_OK);
                cout << "closed bbbb" << endl;
                reevoke();
                break;

            case CTRL_C_EVENT:
                reevoke();
                return TRUE;

            default:
                 cout << "Event was: " << CEvent << endl;
        }

        return TRUE;
    }

    ~Runner()
    {
        cout << "destructor called" << endl;
        if (GetKeyState('Q') & 0x8000){
            cout << "q pressed" << endl;
        }
        else if (SetConsoleCtrlHandler(&ConsoleHandler, TRUE) == FALSE){
            cout << "could not set Handler" << endl;
        }
        else{
            cout << "Handler Set" << endl;
            Sleep(1000);

            while (1) {}
        }
    }
};

int main()
{
    cout << "Hello world! I am unstoppable" << endl;
    Runner r;
    return 0;
}

控制台eventhandling的工作不像假定的c&#x2b;&#x2B;

川水往事 2025-02-17 10:58:45

由于您的 FormParametro 在您的 {{#每个parametro}}} block中呈现部分,因此每次呈现部分的上下文是当前迭代的项目,来自 parametro 。因此,部分无法访问 tipoparametros

我们要做的是为我们的部分提供一个上下文,即 do 包含 tipoparametros 。这很简单。车把文档涵盖部分上下文,它可以提供上下文来提供上下文部分作为胡须括号内的第二个参数,如:

{{&gt; mypartial myothercontext}}}

作为您的 tipoparametros 对象属于您的根上下文,我建议使用 @root data varible 将root上下文传递给部分。因此,模板中的行调用您的部分会变为:

{{&gt; formParametro @root}}

我已经创建了 fiddle 供您参考。

As your formparametro partial is rendered within your {{#each parametro}} block, the context for each time the partial is rendered is the currently iterated item from parametro. Therefore, the partial has no access to tipoParametros.

What we want to do is provide a context to our partial that does contain tipoParametros. This is very simple. The Handlebars documentation covers Partial Contexts and it states that a context can be supplied to the partial as the second parameter within the mustache brackets, as in:

{{> myPartial myOtherContext }}

As your tipoParametros object belongs to your root context, I would recommend using the @root data variable to pass the root context to your partial. The line in your template invoking your partial thus becomes:

{{> formparametro @root}}

I have created a fiddle for your reference.

如何使用{{#each}}在车把nodej中迭代两个单独的数组?

川水往事 2025-02-17 03:08:32

解决方案:

我似乎已经弄清楚了,我的方法是错误的。 TF通过提供数据源来照顾ECR Auth Token:

data "aws_ecr_authorization_token" "token" {}

resource "null_resource" "local-image" {
  triggers = {
    js_file     = filemd5(local.file_loc)
    docker_file = filemd5(local.dockerfile_loc)
  }

  provisioner "local-exec" {
    interpreter = ["PowerShell", "-Command"]
    command     = <<EOF
docker login ${data.aws_ecr_authorization_token.token.proxy_endpoint} -u AWS -p ${data.aws_ecr_authorization_token.token.password}
cd docker
docker build -t ${aws_ecr_repository.my-repo.repository_url}:${local.image_tag} .
docker push ${aws_ecr_repository.my-repo.repository_url}:${local.image_tag}
EOF
  }
  depends_on = [
    data.aws_ecr_authorization_token.token
  ]
}

它可完美地工作, data.aws_ecr_authorization_token.token.token.token.paspoken.password 被设置为敏感,并已正确从console redact中删除输出。

Solution:

I seem to have figured it out, my approach was wrong. TF takes care of the ecr auth token by providing a data source:

data "aws_ecr_authorization_token" "token" {}

resource "null_resource" "local-image" {
  triggers = {
    js_file     = filemd5(local.file_loc)
    docker_file = filemd5(local.dockerfile_loc)
  }

  provisioner "local-exec" {
    interpreter = ["PowerShell", "-Command"]
    command     = <<EOF
docker login ${data.aws_ecr_authorization_token.token.proxy_endpoint} -u AWS -p ${data.aws_ecr_authorization_token.token.password}
cd docker
docker build -t ${aws_ecr_repository.my-repo.repository_url}:${local.image_tag} .
docker push ${aws_ecr_repository.my-repo.repository_url}:${local.image_tag}
EOF
  }
  depends_on = [
    data.aws_ecr_authorization_token.token
  ]
}

This works flawlessly, and data.aws_ecr_authorization_token.token.password is set as sensitive and is properly redacted from console outputs.

Docker Login-Password-STDIN似乎在PS中被打破,我可以在CLI中使用密码登录,但不能与STDIN一起登录

川水往事 2025-02-16 20:25:51
mtcars[do.call(order, mtcars[cols]), ]
mtcars[do.call(order, mtcars[cols]), ]

使用$和字符值动态选择数据框列

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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