风流物

文章 评论 浏览 29

风流物 2025-02-19 18:21:11

检查这个,我为你写。

https://stackblitz.com/edit/angular-mat-select-select-example-9c3wcf?file=src%2fapp%2fapp%2fapp%2fapp; .module.ts

component.html

<h4>Basic mat-select</h4>
<mat-form-field appearance="fill">
  <mat-label>Favorite food</mat-label>
  <mat-select (selectionChange)="onChange($event.value)">
    <mat-option *ngFor="let month of months" [value]="month.name">
      {{ month.name }}
    </mat-option>
  </mat-select>
</mat-form-field>
<p>Api Filter Value is {{ selectedItem[0]?.name }}</p>

component.ts

import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';

import * as statesActions from './store/states.actions';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  selectedItem = [];

  apiData = [
    { name: 'apple', month: '1 month' },
    { name: 'orange', month: '2 month' },
    { name: 'coconut', month: '3 month' },
  ];

  months = [
    {
      id: 1,
      name: '1 month',
    },
    {
      id: 2,
      name: '2 month',
    },
    {
      id: 3,
      name: '3 month',
    },
  ];

  ngOnInit() {}

  onChange(deviceValue) {
    this.selectedItem = this.apiData.filter(
      (data) => data.month === deviceValue
    );
  }
}

Check this one , I write it for you.

https://stackblitz.com/edit/angular-mat-select-example-9c3wcf?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts

component.html

<h4>Basic mat-select</h4>
<mat-form-field appearance="fill">
  <mat-label>Favorite food</mat-label>
  <mat-select (selectionChange)="onChange($event.value)">
    <mat-option *ngFor="let month of months" [value]="month.name">
      {{ month.name }}
    </mat-option>
  </mat-select>
</mat-form-field>
<p>Api Filter Value is {{ selectedItem[0]?.name }}</p>

component.ts

import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';

import * as statesActions from './store/states.actions';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  selectedItem = [];

  apiData = [
    { name: 'apple', month: '1 month' },
    { name: 'orange', month: '2 month' },
    { name: 'coconut', month: '3 month' },
  ];

  months = [
    {
      id: 1,
      name: '1 month',
    },
    {
      id: 2,
      name: '2 month',
    },
    {
      id: 3,
      name: '3 month',
    },
  ];

  ngOnInit() {}

  onChange(deviceValue) {
    this.selectedItem = this.apiData.filter(
      (data) => data.month === deviceValue
    );
  }
}

如何使用Dropdow在Angular中按日期过滤数据

风流物 2025-02-19 18:01:40

您的问题不是 > 。您的问题是,您正在尝试将profileformatnumberdivider and(从base类)name的两个属性分配给同一元素名称&lt; e1&gt;通过设置 noroflow noreferrer“> ”)&gt; 两者都在。即,如果能够序列化您的profile formatnumber as-is,则XML看起来像:

<ProfileFormat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="ProfileFormatNumber">
  <e1>my name</e1>
  <e1>111</e1>
</ProfileFormat>

但是xmlSerialializer不支持这一点(也许是因为在挑战中会有歧义),因此(略微难以理解的)错误抱怨元素名称e1已经存在:

The XML element 'e1' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.]

相反,请使用其他混淆的元素名称profileformatnumber.divider例如&lt; f1&gt;

<XmlInclude(GetType(ProfileFormatNumber))>
Public Class ProfileFormat
    <XmlElement(ElementName:="e1")>
    Public Property Name As String = String.Empty      
End Class

Public Class ProfileFormatNumber
    Inherits ProfileFormat

    <XmlElement(ElementName:="f1")>
    Public Property Divider As Integer = 1
End Class

demo fiddle

Your problem is not with XmlInclude. Your problem is that you are trying to assign the two properties of ProfileFormatNumber, Divider and (from the base class) Name, to the same element name <e1> by setting <XmlElement(ElementName:="e1")> on both. I.e. if were able to serialize your ProfileFormatNumber as-is, the XML would look like:

<ProfileFormat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="ProfileFormatNumber">
  <e1>my name</e1>
  <e1>111</e1>
</ProfileFormat>

However XmlSerializer does not support this (perhaps because there would be ambiguity in deserialization), hence the (slightly inscrutable) error complaining that the element name e1 is already present:

The XML element 'e1' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.]

Instead, use a different obfuscated element name for ProfileFormatNumber.Divider such as <f1>:

<XmlInclude(GetType(ProfileFormatNumber))>
Public Class ProfileFormat
    <XmlElement(ElementName:="e1")>
    Public Property Name As String = String.Empty      
End Class

Public Class ProfileFormatNumber
    Inherits ProfileFormat

    <XmlElement(ElementName:="f1")>
    Public Property Divider As Integer = 1
End Class

Demo fiddle here.

XMLSerializer为什么不序列化此类,即使我为派生类添加了XMLinclude属性?

风流物 2025-02-19 15:58:22

我按照我的期望工作。我在复制的所有服务器来源上都这样做。

在此处安装

是文件monit_replication.sh

#!/bin/bash   
user="YOUR_USER"
password="YOUR_PASSWORD"

result=`echo "show slave status"|mysql -EsB --user="$user" --password="$password"`

contains_with_yes(){
        if echo "$1"|grep -i "$2"|grep -i "Yes" > /dev/null; then
                echo "$2 ok"
        else
                echo "$2 not ok"
                exit 1
        fi
}
 
contains_with_yes "$result" "Slave_IO_Running"
contains_with_yes "$result" "Slave_SQL_Running"
exit 0

使此可执行文件:

chmod 700 /YOUR_PATH_TO_THE_FILE/monit_replication.sh

添加到/etc/etc/monit/conf-enabled/mysql

 check program MySQL_replication with path "/YOUR_PATH_TO_THE_FILE/monit_replication.sh"
   every 120 cycles
   if status > 0 then alert
   group mysql 

testing

ran ran ran ran此sql:

STOP SLAVE;

重新启动monit:

/etc/init.d/monit restart

发现/var/log/monit.log

[2022-07-04T10:46:55+0000] error    : 'MySQL_replication' status failed (1) -- Slave_IO_Running not ok

接收到此电子邮件:

monit alert -- Status failed MySQL_replication

Status failed Service MySQL_replication

    Date:        Mon, 04 Jul 2022 10:46:55
    Action:      alert
    Host:        YOUR_HOST
    Description: status failed (1) -- Slave_IO_Running not ok

Your faithful employee,
Monit

这验证了测试。使用此SQL查询恢复复制:

START SLAVE;

其他解决方案

如果基于MONIT的任何简单解决方案可以提醒我Mariadb上的复制失败,我很乐意接受它作为问题的解决方案。

I got this to work as I expected. I did this on all servers sources of the replication.

Installing

Here is the file monit_replication.sh:

#!/bin/bash   
user="YOUR_USER"
password="YOUR_PASSWORD"

result=`echo "show slave status"|mysql -EsB --user="$user" --password="$password"`

contains_with_yes(){
        if echo "$1"|grep -i "$2"|grep -i "Yes" > /dev/null; then
                echo "$2 ok"
        else
                echo "$2 not ok"
                exit 1
        fi
}
 
contains_with_yes "$result" "Slave_IO_Running"
contains_with_yes "$result" "Slave_SQL_Running"
exit 0

Made this executable:

chmod 700 /YOUR_PATH_TO_THE_FILE/monit_replication.sh

Added to /etc/monit/conf-enabled/mysql:

 check program MySQL_replication with path "/YOUR_PATH_TO_THE_FILE/monit_replication.sh"
   every 120 cycles
   if status > 0 then alert
   group mysql 

Testing

Ran this SQL:

STOP SLAVE;

Restarted monit:

/etc/init.d/monit restart

Found in /var/log/monit.log:

[2022-07-04T10:46:55+0000] error    : 'MySQL_replication' status failed (1) -- Slave_IO_Running not ok

Received this email:

monit alert -- Status failed MySQL_replication

Status failed Service MySQL_replication

    Date:        Mon, 04 Jul 2022 10:46:55
    Action:      alert
    Host:        YOUR_HOST
    Description: status failed (1) -- Slave_IO_Running not ok

Your faithful employee,
Monit

This validates the test. Restoring replication with this SQL query:

START SLAVE;

Other solutions

If any simpler solution based on Monit can alert me of a replication failure on MariaDB, I would be happy to accept it as the solution to the question.

如何设置MONIT来监视MariadB复制?

风流物 2025-02-19 10:49:30

t2 = matrix [0] .size();是距离的。

你的意思

t2 = cols - 1;

t2 = matrix[0].size(); is out-of-bounds.

Did you mean

t2 = cols - 1;

即使我包括了避免流动流量的条件(问题74。搜索2D矩阵),从leetcode中获取缓冲区溢出

风流物 2025-02-19 10:36:54

未定义的引用winmain@16或类似'不寻常' main()输入点参考(尤其是 Visual-studio )。

您可能已经错过了使用实际IDE选择正确的项目类型。 IDE可能需要将例如Windows Application Projects绑定到此类输入点功能(如上所述所缺少的参考),而不是常用的int main(int argc,char ** argv);签名。

如果您的IDE支持普通控制台项目您可能需要选择此项目类型,而不是Windows应用程序项目。


这是 case2 从一个现实世界中的问题中更详细地处理。

undefined reference to WinMain@16 or similar 'unusual' main() entry point reference (especially for ).

You may have missed to choose the right project type with your actual IDE. The IDE may want to bind e.g. Windows Application projects to such entry point function (as specified in the missing reference above), instead of the commonly used int main(int argc, char** argv); signature.

If your IDE supports Plain Console Projects you might want to choose this project type, instead of a windows application project.


Here are case1 and case2 handled in more detail from a real world problem.

什么是未定义的参考/未解决的外部符号错误,我该如何修复?

风流物 2025-02-19 02:00:21

您可以使用类实现来迫使您的组件的消费者按某些道具的类型规则遵守。

例如,您可以拥有类似的东西:

abstract class Model {
   abstract prop1: string;
   abstract prop2: string;
   abstract prop3: number;
}

interface IMyGenericComponentProps {
   model: Model;
   // ... and some other props
}

然后,在要使用此通用组件时,在外部组件中,您可以定义任何自定义类,但需要实现抽象类。例如:

class CatModel implements Model {
// Here you will need to make sure that you implemented everything that is imposed by abstract Model
}

const cat = new CatModel(...);

return <MyGenericComponent model={cat} /> // and this will work because cat implements everything from abstract class

You can use class implementations in order to force consumer of your component to abide by type rules for certain props.

For example, you can have something like this:

abstract class Model {
   abstract prop1: string;
   abstract prop2: string;
   abstract prop3: number;
}

interface IMyGenericComponentProps {
   model: Model;
   // ... and some other props
}

Then, in your outer component when you want to consume this generic component, you can define any custom class but it is required to implement abstract class. For example:

class CatModel implements Model {
// Here you will need to make sure that you implemented everything that is imposed by abstract Model
}

const cat = new CatModel(...);

return <MyGenericComponent model={cat} /> // and this will work because cat implements everything from abstract class

是否可以使用特定类型定义功能组件?

风流物 2025-02-18 17:42:25

您也可以这样做:

import numpy as np
a = df.to_numpy()
b = np.divide.outer(a.sum(0),a.sum(1)) 
# divide is a ufunc(universal function) in numpy.
# All ufunc's support outer functionality
out = pd.DataFrame(b, index=df.index, columns=df.columns)

输出:

     0      1     2
0  2.0  2.500  3.00
1  0.8  1.000  1.20
2  0.5  0.625  0.75

You can also do it this way:

import numpy as np
a = df.to_numpy()
b = np.divide.outer(a.sum(0),a.sum(1)) 
# divide is a ufunc(universal function) in numpy.
# All ufunc's support outer functionality
out = pd.DataFrame(b, index=df.index, columns=df.columns)

output:

     0      1     2
0  2.0  2.500  3.00
1  0.8  1.000  1.20
2  0.5  0.625  0.75

如何按熊猫中的行总和划分列总和

风流物 2025-02-18 14:08:38

您的插入方法按值将item *进行,因此它不能在主函数中更改head变量。因此,您正在一遍又一遍地使用nullptr调用插入物,从不更改head。如果您通过参考而传递,则代码有效:

void insert(Item *&head, int value) {
    ...
}

但是它不是很C ++ - ISH。 C ++具有构造函数和破坏者,使用它们。您的代码会泄漏内存,因为您永远不会释放列表。值得在容器list中划出功能,而不是直接使用item*。而且,如果您跟踪列表的尾巴,那么末尾插入的速度要快得多,list容器允许您轻松地做:

#include <iostream>

class List {
    struct Node {
        Node(Node **&tail, int val_) : val(val_) {
            *tail = this;
            tail = &this->next;
        }
        int val;
        Node* next{nullptr};
    };

public:
    ~List() {
        clear();
    }

    void clear() {
        while (head) {
            Node *temp = head;
            head = head->next;
            delete temp;
        }
        tail = &head;
    }

    void insert(int value) {
        new Node(tail, value);
    }

    std::ostream & print(std::ostream &out) const {
        Node *temp = head;
        while (temp) {
            out << temp->val << " ";
            temp = temp->next;
        }
        return out;
    }
private:
    Node *head{nullptr};
    Node **tail{&head};
};

std::ostream & operator <<(std::ostream &out, const List &list) {
    return list.print(out);
}

int main()
{
    List list;

    for(int k = 0; k < 6; k++)
        list.insert(k);

    std::cout << list << std::endl;

    return 0;
}

Your insert method takes a Item * by value so it can not alter the head variable in the main function. So you are calling insert with nullptr over and over and never changing head. If you pass by reference instead the code works:

void insert(Item *&head, int value) {
    ...
}

But it's not very C++-ish. C++ has constructors and destructors, use them. Your code leaks memory because you never free the list. It's worth it to capsulate functionality in a container List instead of using the Item* directly. And if you keep track of the tail of the list then inserting at the end becomes much faster, which a List container allows you to do easily:

#include <iostream>

class List {
    struct Node {
        Node(Node **&tail, int val_) : val(val_) {
            *tail = this;
            tail = &this->next;
        }
        int val;
        Node* next{nullptr};
    };

public:
    ~List() {
        clear();
    }

    void clear() {
        while (head) {
            Node *temp = head;
            head = head->next;
            delete temp;
        }
        tail = &head;
    }

    void insert(int value) {
        new Node(tail, value);
    }

    std::ostream & print(std::ostream &out) const {
        Node *temp = head;
        while (temp) {
            out << temp->val << " ";
            temp = temp->next;
        }
        return out;
    }
private:
    Node *head{nullptr};
    Node **tail{&head};
};

std::ostream & operator <<(std::ostream &out, const List &list) {
    return list.print(out);
}

int main()
{
    List list;

    for(int k = 0; k < 6; k++)
        list.insert(k);

    std::cout << list << std::endl;

    return 0;
}

修复此LinkedList,不显示预期输出

风流物 2025-02-18 13:46:15

您可以在小组之后合并,并且agg类似:

df.merge(df.groupby('key',as_index=False).agg(
   unique_list = ('cfop_code', 'unique'),
   unique_count = ('cfop_code', 'nunique'),
   not_unique_count = ('cfop_code', 'size')
), on='key', how = 'left')

输出:

                    key    product  cfop_code   unique_list  unique_count  \
0  12345678901234567890  product a       2551  [2551, 3551]             2   
1  12345678901234567890  product b       2551  [2551, 3551]             2   
2  12345678901234567890  product c       3551  [2551, 3551]             2   
3  12345678901234567895  product a       2551        [2551]             1   
4  12345678901234567897  product b       2551  [2551, 2407]             2   
5  12345678901234567897  product c       2407  [2551, 2407]             2   

   not_unique_count  
0                 3  
1                 3  
2                 3  
3                 1  
4                 2  
5                 2  

You can do merge after group and agg like:

df.merge(df.groupby('key',as_index=False).agg(
   unique_list = ('cfop_code', 'unique'),
   unique_count = ('cfop_code', 'nunique'),
   not_unique_count = ('cfop_code', 'size')
), on='key', how = 'left')

output:

                    key    product  cfop_code   unique_list  unique_count  \
0  12345678901234567890  product a       2551  [2551, 3551]             2   
1  12345678901234567890  product b       2551  [2551, 3551]             2   
2  12345678901234567890  product c       3551  [2551, 3551]             2   
3  12345678901234567895  product a       2551        [2551]             1   
4  12345678901234567897  product b       2551  [2551, 2407]             2   
5  12345678901234567897  product c       2407  [2551, 2407]             2   

   not_unique_count  
0                 3  
1                 3  
2                 3  
3                 1  
4                 2  
5                 2  

groupby,同意字符串并返回独特的值

风流物 2025-02-18 11:45:19

您可能在项目之间(可能是由IDE构建和运行的)与Jenkins管理的自动构建之间的差距。

了解构建工具,例如 ant maven gradle 。如果他们可以构建您的项目,Jenkins可以触发它们并保留日志。

You may have a gap between your project (that probably gets built and run by some IDE) and automatic builds managed by Jenkins.

Learn about build tools like Ant, Maven and Gradle. If they can build your project, Jenkins can trigger them and keep the logs.

如何通过jenkins从源文件到jar文件构建项目

风流物 2025-02-18 10:19:30

vis-network 使用HTML5画布绘制图表。您可以使用beforeDrawing事件自己绘制网格。为了支持诸如Zooming和Panning之类的交互性,您还需要收听dragStartdragingdragend Zoom < /代码>。通过这些事件,应该可以实现完全交互的背景。

看看 a href =“ https://visjs.github.io/vis-network/examples/network/network/events/interactionevents.html” rel =“ nofollow noreferrer”> interactionEvents示例emame示例

vis-network uses a html5 canvas to draw the chart. You could draw the grid yourself using the beforeDrawing event. To support interactivity like zooming and panning you would also need to listen to the dragStart, dragging and dragEnd events as well as zoom. With these events it should be possible to implement a fully interactive background.

Have a look at the renderEvents example and the interactionEvents example.

我可以在VIS.JS网络上有一个网格作为背景吗

风流物 2025-02-17 20:18:02

在原始Word2Vec(作为-Sampame参数)中介绍的频繁词降采样选项('subsmpling')确实将降采样唯一应用于 - 频繁的单词。 (并且,鉴于自然语言中的“高头”/Zipfian单词的分布,这很大。)

典型的值留下大多数单词完全采样,如该公式所反映的,通过更大-than 1.0

所以:这里没有错误。这是原始Word2Vec实现和其他方式解释示例参数。大多数单词都免于任何变薄,但是一些最常见的单词被大量删除。 (但是,在培训集中,他们仍然有很多用法的示例 - 实际上,在这些单词上,花费减少培训更新,让其他其他单词获得更好的矢量,面对更少的争论/过度训练通用单词的稀释。)

The frequent-word downsampling option ('subsampling') introduced in the original word2vec (as a -sample argument) indeed applies downsampling only to a small subset of the very-most-frequent words. (And, given the 'tall head'/Zipfian distributions of words in natural-language texts, that's plenty.)

Typical values leave most words fully sampled, as reflected in this formula by a sampling-probability greater-than 1.0.

So: there's no error here. It's how the original word2vec implementation, and others, interpret the sample parameter. Most words are exempt from any thinning, but some of the most-common words are heavily dropped. (But, there's still plenty of their varied usage examples in the training set – and indeed spending fewer training updates redundantly on those words lets other words get better vectors, facing less contention/dilution from overtraining of common words.)

亚采样公式跳过NLP

风流物 2025-02-17 08:18:21

如果意图是要下载数据集B中列出的文件,则首先将数据集移至远程服务器。

然后,您可以使用该数据生成PROC下载代码。

rsubmit;
  proc upload data=b out=b; run;
  data _null_;
    set b;
    call execute(catx(' '
     ,'proc download infile=',quote(trim(link2))
     ,'outfile=',quote(cats('E:/test',_n_,'.txt'))
     ,';run;'
    ));
  run;
endrsubmit;

我看不出宏代码将如何帮助解决此问题。

If the intent was to download the file(s) listed in the dataset B then first move the dataset to the remote server.

Then you can use that data to generate PROC DOWNLOAD code.

rsubmit;
  proc upload data=b out=b; run;
  data _null_;
    set b;
    call execute(catx(' '
     ,'proc download infile=',quote(trim(link2))
     ,'outfile=',quote(cats('E:/test',_n_,'.txt'))
     ,';run;'
    ));
  run;
endrsubmit;

I don't see how macro code would help with this problem.

在Proc下载中的宏

风流物 2025-02-17 08:05:40

答:在将电子邮件地址发送到MailGun之前,我没有验证电子邮件地址。

Answer: I wasn't validating the email address before sending it to Mailgun.

有人知道如何解决此错误吗?我在Laravel中使用Mailgun

风流物 2025-02-16 21:32:10

我认为这应该与您的工作空间有关。 VSCODE运行文件将当前工作区作为根目录。

我认为当您显示问题时,您应该发布目录结构。我在这里有一个简单的复制:

工作区中的包装com.cn和软件包中的app.java。

​我认为目录结构不一致,或者运行文件时终端位置存在错误。

I think this should be related to your workspace. Vscode running file takes the current workspace as the root directory.

I think you should release the directory structure when you show the problem. I have a simple reproduction here:

There is a package com.cn in the workspace and a app.java in the package.

enter image description here

enter image description here

This is consistent with what you showed, but the results are different. I think the directory structure is inconsistent, or there is an error in the location of the terminal when you run the file.

在VSCODE中的软件包中无法在Java中运行程序

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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