羁客

文章 评论 浏览 26

羁客 2025-02-17 05:22:33

对于触发 pull_request 而言,这是不正确的。这足以让此触发器与您的拉请请求相关联的分支 - 无需将其放入基本分支。

pull_request_target 需要在基本分支中才能命名一个示例。 -

That's not true for the trigger pull_request. It is enough for this trigger to be on the branch associated with your pull request -- no need to put it in the base branch.

pull_request_target, however, needs to be in the base branch to name an example. –

GitHub Action PR工作流程开发常规

羁客 2025-02-17 02:46:03

您可以使用 cjson 。使用此实用程序来解析您的JSON:
https://github.com/subhendushekhar/cjson

也有其他功能。

You can use cjson. Use this utility to parse your json:
https://github.com/SubhenduShekhar/cjson

There are other features too.

在JSON文件中添加评论

羁客 2025-02-16 05:26:51

我承认,将这些数据分别发送到函数的想法完全不同。

但是要直接返回值 aaaaaaaa

  1. 将第一个参数发送为JSON对象值
  2. 将第二个参数发送为JSON对象名称字符串
  3. 将第三个参数发送为键列表,

然后您可以使用 eval() 将字符串联合转换为代码:

def my_function(json_full, json_prefix, json_field):
    my_json = json_full
    my_json_str = json_prefix
    key_field = '["' + '"]["'.join(json_field) + '"]'
    try:
        value = eval(f'{json_prefix}{key_field}')
        return value
    except Exception as e:
        return e

def main():
    my_json = {
    "DataChangedEntry": {
            "CurrentValue": {
                "RefId": {
                    "Value": "aaaaaaa"
                },
            },
        },
    }

    get_value = my_function(my_json, 'my_json', ["DataChangedEntry","CurrentValue","RefId","Value"])
    print(get_value)

if __name__ == "__main__":
    main()

输出:

aaaaaaa

I confess that this idea of sending this data separately to a function is quite different.

But to directly return the value aaaaaaa:

  1. Send the first argument as the JSON object value
  2. Send the second argument as the JSON object name string
  3. Send third argument as key list

Then you can use eval() to convert the union of strings into code:

def my_function(json_full, json_prefix, json_field):
    my_json = json_full
    my_json_str = json_prefix
    key_field = '["' + '"]["'.join(json_field) + '"]'
    try:
        value = eval(f'{json_prefix}{key_field}')
        return value
    except Exception as e:
        return e

def main():
    my_json = {
    "DataChangedEntry": {
            "CurrentValue": {
                "RefId": {
                    "Value": "aaaaaaa"
                },
            },
        },
    }

    get_value = my_function(my_json, 'my_json', ["DataChangedEntry","CurrentValue","RefId","Value"])
    print(get_value)

if __name__ == "__main__":
    main()

Output:

aaaaaaa

Python如何将JSON对象传递到函数?

羁客 2025-02-16 02:05:26

上使用Regex

创建扩展名

extension RegexExt on String {
  bool validateEmail() => RegExp(
          r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
      .hasMatch(this);
}

您可以在字符串用法

String emailValidator(String email, BuildContext context) {
  if (email == null || email.length == 0) {
    return AppLocalizations.of(context).translate('validators.requiredField');
  }

  return email.validateEmail() ? null : AppLocalizations.of(context).translate('validators.invalidEmail'); 
}

You can use regex

Create an extension on String

extension RegexExt on String {
  bool validateEmail() => RegExp(
          r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
      .hasMatch(this);
}

Usage

String emailValidator(String email, BuildContext context) {
  if (email == null || email.length == 0) {
    return AppLocalizations.of(context).translate('validators.requiredField');
  }

  return email.validateEmail() ? null : AppLocalizations.of(context).translate('validators.invalidEmail'); 
}

@ flutter @ flutter之后如何验证电子邮件?

羁客 2025-02-16 01:31:10

根据“ nofollow noreferrer”> tramplast_control_control_protocol wikipedia on wikipedia:

序列号(32位)

具有双重角色:

如果设置了SYN标志(1),则这是初始序列号。实际的第一个数据字节的序列编号和相应的ACK中的已确认数字为此序列编号加1。

如果SYN标志是清晰的(0),则这是当前会话的第一个段字节的累积序列编号。

和根据史蒂文斯的 tcp ip所示,第1卷

每个TCP段(在连接建立期间交换的TCP段)
包括有效的序列号字段, ack号确认字段和a 窗口大小字段(包含窗口广告)。

现在,让我们构建一个方案并使用 tcpdump 跟踪TCP段:

  1. 初始化http(IE TCP)请求, curl
$ curl -iIL https://blog.codefarm.me/
HTTP/2 200 
server: GitHub.com
.....
  1. 同时,执行 tcpdump 并将转储日期写入文件如下:
tcpdump -n port 443 -r /tmp/https.pcap
  1. 使用以下命令读取转储数据:
$ tcpdump --number -ntS port 443 -r /tmp/https.pcap
reading from file /tmp/https.pcap, link-type EN10MB (Ethernet), snapshot length 262144
    1  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [S], seq 2427498844, win 64240, options [mss 1460,sackOK,TS val 2733586448 ecr 0,nop,wscale 7], length 0
    2  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [S.], seq 1574645920, ack 2427498845, win 64240, options [mss 1460], length 0
    3  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [.], ack 1574645921, win 64240, length 0
    4  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427498845:2427499362, ack 1574645921, win 64240, length 517
    5  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499362, win 64240, length 0
    6  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574645921:1574650508, ack 2427499362, win 64240, length 4587
    7  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [.], ack 1574650508, win 61320, length 0
    8  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499362:2427499442, ack 1574650508, win 62780, length 80
    9  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499442:2427499488, ack 1574650508, win 62780, length 46
   10  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499488:2427499537, ack 1574650508, win 62780, length 49
   11  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499442, win 64240, length 0
   12  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499488, win 64240, length 0
   13  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499537, win 64240, length 0
   14  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499537:2427499640, ack 1574650508, win 62780, length 103
   15  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499640, win 64240, length 0
   16  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574650508:1574651050, ack 2427499640, win 64240, length 542
   17  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574651050:1574651109, ack 2427499640, win 64240, length 59
   18  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [.], ack 1574651109, win 62780, length 0
   19  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499640:2427499671, ack 1574651109, win 62780, length 31
   20  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499671, win 64240, length 0
   21  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574651109:1574651502, ack 2427499671, win 64240, length 393
   22  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499671:2427499695, ack 1574651502, win 62780, length 24
   23  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499695, win 64240, length 0
   24  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [F.], seq 2427499695, ack 1574651502, win 62780, length 0
   25  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499696, win 64239, length 0
   26  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [FP.], seq 1574651502:1574651526, ack 2427499696, win 64239, length 24
   27  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [R], seq 2427499696, win 0, length 0

第11-13行中的数据包都是ACK段,而无需palyload。 tcpdump 还没有显示 seq 应该为 1574650508 作为带有有效负载的最后一个发送段(即来自服务器的有效负载)行号6)。

为什么?

现在,让我们运行 tcpdump 带有以下选项:

$ tcpdump --number -ntSxx port 443 -r /tmp/https.pcap
.....
    6  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574645921:1574650508, ack 2427499362, win 64240, length 4587
.....
   11  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499442, win 64240, length 0
    0x0000:  000c 298c df3f 0050 56e9 f627 0800 4500
    0x0010:  0028 5a0e 0000 8006 9e38 b9c7 6c99 c0a8
    0x0020:  5b80 01bb 8064 5ddb 428c 90b0 b3b2 5010
    0x0030:  faf0 0b70 0000 0000 0000 0000
   12  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499488, win 64240, length 0
    0x0000:  000c 298c df3f 0050 56e9 f627 0800 4500
    0x0010:  0028 5a0f 0000 8006 9e37 b9c7 6c99 c0a8
    0x0020:  5b80 01bb 8064 5ddb 428c 90b0 b3e0 5010
    0x0030:  faf0 0b42 0000 0000 0000 0000
   13  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499537, win 64240, length 0
    0x0000:  000c 298c df3f 0050 56e9 f627 0800 4500
    0x0010:  0028 5a10 0000 8006 9e36 b9c7 6c99 c0a8
    0x0020:  5b80 01bb 8064 5ddb 428c 90b0 b411 5010
    0x0030:  faf0 0b11 0000 0000 0000 0000
.....    

实际上,使用 xx 选项,我们可以分析32位序列号(IE 5DDDB 428C )上述TCP段(11-13),然后将其转换为小数号如下:

$ echo $((16#5ddb428c))
1574650508

在这里,我们可以看到ACK段中重复三次重复的序列编号为 1574650508 与Wireshark相同(使用绝对序列编号选项)。

According to the Transmission_Control_Protocol on Wikipedia:

Sequence number (32 bits)

Has a dual role:

If the SYN flag is set (1), then this is the initial sequence number. The sequence number of the actual first data byte and the acknowledged number in the corresponding ACK are then this sequence number plus 1.

If the SYN flag is clear (0), then this is the accumulated sequence number of the first data byte of this segment for the current session.

And according to the Stevens's TCP IP Illustrated, Volume 1:

Every TCP segment (except those exchanged during connection establishment)
includes a valid Sequence Number field, an ACK Number or Acknowledgment field, and a Window Size field (containing the window advertisement).

Now let's construct a scenario and use tcpdump to trace the tcp segments:

  1. Initialize a HTTP (i.e. TCP) request with curl:
$ curl -iIL https://blog.codefarm.me/
HTTP/2 200 
server: GitHub.com
.....
  1. Meanwhile, executing tcpdump and write the dump date to a file as below:
tcpdump -n port 443 -r /tmp/https.pcap
  1. Reading the dump data with the following command:
$ tcpdump --number -ntS port 443 -r /tmp/https.pcap
reading from file /tmp/https.pcap, link-type EN10MB (Ethernet), snapshot length 262144
    1  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [S], seq 2427498844, win 64240, options [mss 1460,sackOK,TS val 2733586448 ecr 0,nop,wscale 7], length 0
    2  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [S.], seq 1574645920, ack 2427498845, win 64240, options [mss 1460], length 0
    3  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [.], ack 1574645921, win 64240, length 0
    4  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427498845:2427499362, ack 1574645921, win 64240, length 517
    5  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499362, win 64240, length 0
    6  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574645921:1574650508, ack 2427499362, win 64240, length 4587
    7  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [.], ack 1574650508, win 61320, length 0
    8  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499362:2427499442, ack 1574650508, win 62780, length 80
    9  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499442:2427499488, ack 1574650508, win 62780, length 46
   10  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499488:2427499537, ack 1574650508, win 62780, length 49
   11  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499442, win 64240, length 0
   12  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499488, win 64240, length 0
   13  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499537, win 64240, length 0
   14  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499537:2427499640, ack 1574650508, win 62780, length 103
   15  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499640, win 64240, length 0
   16  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574650508:1574651050, ack 2427499640, win 64240, length 542
   17  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574651050:1574651109, ack 2427499640, win 64240, length 59
   18  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [.], ack 1574651109, win 62780, length 0
   19  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499640:2427499671, ack 1574651109, win 62780, length 31
   20  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499671, win 64240, length 0
   21  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574651109:1574651502, ack 2427499671, win 64240, length 393
   22  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [P.], seq 2427499671:2427499695, ack 1574651502, win 62780, length 24
   23  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499695, win 64240, length 0
   24  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [F.], seq 2427499695, ack 1574651502, win 62780, length 0
   25  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499696, win 64239, length 0
   26  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [FP.], seq 1574651502:1574651526, ack 2427499696, win 64239, length 24
   27  IP 192.168.91.128.32868 > 185.199.108.153.443: Flags [R], seq 2427499696, win 0, length 0

The packets at the line 11-13 are all ACK segments without palyload. And tcpdump also doesn't show the seq field which is should be 1574650508 as the last sending segment with payload from server (i.e. packet 6 at line number 6).

Why?

Now let's run tcpdump with the following options:

$ tcpdump --number -ntSxx port 443 -r /tmp/https.pcap
.....
    6  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [P.], seq 1574645921:1574650508, ack 2427499362, win 64240, length 4587
.....
   11  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499442, win 64240, length 0
    0x0000:  000c 298c df3f 0050 56e9 f627 0800 4500
    0x0010:  0028 5a0e 0000 8006 9e38 b9c7 6c99 c0a8
    0x0020:  5b80 01bb 8064 5ddb 428c 90b0 b3b2 5010
    0x0030:  faf0 0b70 0000 0000 0000 0000
   12  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499488, win 64240, length 0
    0x0000:  000c 298c df3f 0050 56e9 f627 0800 4500
    0x0010:  0028 5a0f 0000 8006 9e37 b9c7 6c99 c0a8
    0x0020:  5b80 01bb 8064 5ddb 428c 90b0 b3e0 5010
    0x0030:  faf0 0b42 0000 0000 0000 0000
   13  IP 185.199.108.153.443 > 192.168.91.128.32868: Flags [.], ack 2427499537, win 64240, length 0
    0x0000:  000c 298c df3f 0050 56e9 f627 0800 4500
    0x0010:  0028 5a10 0000 8006 9e36 b9c7 6c99 c0a8
    0x0020:  5b80 01bb 8064 5ddb 428c 90b0 b411 5010
    0x0030:  faf0 0b11 0000 0000 0000 0000
.....    

Actually, with the xx option, we can analyze the 32bit sequence number (i.e. 5ddb 428c) of the above TCP segments (11-13) and convert it to decimal number as below:

$ echo $((16#5ddb428c))
1574650508

Here, we can see the sequence number that repeated in ACK segment three times is 1574650508 which is same as the WireShark (with absolute sequence number option).

enter image description here

为什么某些TCP数据包在TCPDUMP中没有序列编号?

羁客 2025-02-15 15:05:35

在释放模式下,两种两项方法的IL主体都是相同的。

IL_0014: ldc.i4.2
IL_0015: newarr [System.Runtime]System.Int32
IL_001a: dup
IL_001b: ldc.i4.0
IL_001c: ldloc.0
IL_001d: stelem.i4
IL_001e: dup
IL_001f: ldc.i4.1
IL_0020: ldloc.1
IL_0021: stelem.i4
IL_0022: ret

在调试模式下,只有另外2个Opcodes。首先,该方法的主体;

IL_001c: ldc.i4.2
IL_001d: newarr [System.Runtime]System.Int32
IL_0022: dup
IL_0023: ldc.i4.0
IL_0024: ldloc.0
IL_0025: stelem.i4
IL_0026: dup
IL_0027: ldc.i4.1
IL_0028: ldloc.1
IL_0029: stelem.i4
IL_002a: stloc.3
IL_002b: br.s IL_0058

第二个示例;

IL_001c: ldc.i4.2
IL_001d: newarr [System.Runtime]System.Int32
IL_0022: dup
IL_0023: ldc.i4.0
IL_0024: ldloc.0
IL_0025: stelem.i4
IL_0026: dup
IL_0027: ldc.i4.1
IL_0028: ldloc.1
IL_0029: stelem.i4
IL_002a: stloc.3

IL_002b: ldloc.3   // Pushes local variable, returnArr to the 3rd index of the evaluation stack.
IL_002c: stloc.s 4 // Pops latest pushed value from evaluation stack

IL_002e: br.s IL_005c

在发布模式下,由于编译器的优化没有差异,因此没有任何差异。
在调试模式下,第二代码将变量推到堆栈,然后再次弹出,因此无论如何它都应该慢速运行。

要获得更准确的结果,您应该使用基准库,例如 benchmarkDotnet ,应该运行数百万或数十亿或数十亿或数十亿或数十亿的基准方法时间并获得平均/平均时间。

In Release mode, IL body of the both TwoSum methods are the same;

IL_0014: ldc.i4.2
IL_0015: newarr [System.Runtime]System.Int32
IL_001a: dup
IL_001b: ldc.i4.0
IL_001c: ldloc.0
IL_001d: stelem.i4
IL_001e: dup
IL_001f: ldc.i4.1
IL_0020: ldloc.1
IL_0021: stelem.i4
IL_0022: ret

In Debug mode, there are only 2 more opcodes. For first example, IL body of the method;

IL_001c: ldc.i4.2
IL_001d: newarr [System.Runtime]System.Int32
IL_0022: dup
IL_0023: ldc.i4.0
IL_0024: ldloc.0
IL_0025: stelem.i4
IL_0026: dup
IL_0027: ldc.i4.1
IL_0028: ldloc.1
IL_0029: stelem.i4
IL_002a: stloc.3
IL_002b: br.s IL_0058

Second example;

IL_001c: ldc.i4.2
IL_001d: newarr [System.Runtime]System.Int32
IL_0022: dup
IL_0023: ldc.i4.0
IL_0024: ldloc.0
IL_0025: stelem.i4
IL_0026: dup
IL_0027: ldc.i4.1
IL_0028: ldloc.1
IL_0029: stelem.i4
IL_002a: stloc.3

IL_002b: ldloc.3   // Pushes local variable, returnArr to the 3rd index of the evaluation stack.
IL_002c: stloc.s 4 // Pops latest pushed value from evaluation stack

IL_002e: br.s IL_005c

In Release mode, there are no difference because of compiler optimizations, so there shouldn't be any differences.
In Debug mode, second code pushes variable to the stack, and then pops it again, so it should run slower anyways.

For more accurate results, you should use benchmark libraries like BenchmarkDotNet and should run the benchmark methods for millions or billions times and get the average/mean time.

在返回之前初始化变量,在C#中更快

羁客 2025-02-15 13:34:40

我能够下载2.6.0如下

sudo curl -L https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

I was able to download 2.6.0 as follows

sudo curl -L https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

无法在Docker-Compose中运行Hyperledger问题的测试网络

羁客 2025-02-14 20:08:45

您可以做这样的事情。

from api4jenkins import Jenkins

j = Jenkins('http://localhost:8080', auth=('admin', 'admin'))
job = j['Sample'] # Getting the Job by name
for line in job.get_build(1).console_text():
    print(line)

还请记住,总是有可能直接下载日志。例如,请参考以下内容。

http:// localhost:8080/job/< jobname>/lastSuccessfulbuild/consoletext

You can do something like this.

from api4jenkins import Jenkins

j = Jenkins('http://localhost:8080', auth=('admin', 'admin'))
job = j['Sample'] # Getting the Job by name
for line in job.get_build(1).console_text():
    print(line)

Also remember it's always possible to directly download the log as well. For example refer the following.

http://localhost:8080/job/<JOBNAME>/lastSuccessfulBuild/consoleText

Jenkins API4Jenkins下载最后的构建工作控制台输出

羁客 2025-02-14 17:41:31

您可以这样做,使用香草JS

      <table class="button-box3">
      <thead>
         <tr >
            <th>vatId</th>
            <th>Desc</th>
            <th>MPK</th>
            <th>Quantity</th>
            <th>Vat </th>
            <th>Kwota Brutto</th>
            <th>Wartosc Netto</th>
            <th>Wartosc Brutto</th>
            <th>Action</th>
         </tr>
      </thead>
      <tbody>
         <tr id="vatek" class="active-row">
            <td>1</td>
            <td>xx</td>
            <td>Stychurski</td>
            <td>Manager</td>
            <td>21.04.2020</td>
            <td>20</td>
            <td >2022</td>
            <td>20</td>
            <td>
               <a href="#" type="button" class="submit-btn3">Change</a>
            </td>
         </tr>
         <tr class="row">
            <td>1</td>
            <td>xx</td>
            <td>Stychurski</td>
            <td>Manager</td>
            <td>21.04.2020</td>
            <td>20</td>
            <td >100</td>
            <td>20</td>
            <td>
               <a href="#" type="button" class="submit-btn3">Change</a>
            </td>
         </tr>
         <tr class="row">
            <td>1</td>
            <td>xx</td>
            <td>Stychurski</td>
            <td>Manager</td>
            <td>21.04.2020</td>
            <td>20</td>
            <td >3000</td>
            <td>20</td>
            <td>
               <a href="#" type="button" class="submit-btn3">Change</a>
            </td>
         </tr>
      </tbody>
      </table>
            <script>
               function setColor(e){
               const colors = ['#e47911', 'green'];
               
               const wartoscNetto = e.target.offsetParent.parentNode.children[6].innerText;
               const currentTr = e.target.offsetParent.parentNode;
               
               if(wartoscNetto > 1000) return currentTr.style.backgroundColor=colors[0];
               currentTr.style.backgroundColor=colors[1];
               };
               const btn = document.querySelectorAll('.submit-btn3');

               btn.forEach(el => el.addEventListener('click', setColor));

            </script>

You can do it like this, using vanilla js

      <table class="button-box3">
      <thead>
         <tr >
            <th>vatId</th>
            <th>Desc</th>
            <th>MPK</th>
            <th>Quantity</th>
            <th>Vat </th>
            <th>Kwota Brutto</th>
            <th>Wartosc Netto</th>
            <th>Wartosc Brutto</th>
            <th>Action</th>
         </tr>
      </thead>
      <tbody>
         <tr id="vatek" class="active-row">
            <td>1</td>
            <td>xx</td>
            <td>Stychurski</td>
            <td>Manager</td>
            <td>21.04.2020</td>
            <td>20</td>
            <td >2022</td>
            <td>20</td>
            <td>
               <a href="#" type="button" class="submit-btn3">Change</a>
            </td>
         </tr>
         <tr class="row">
            <td>1</td>
            <td>xx</td>
            <td>Stychurski</td>
            <td>Manager</td>
            <td>21.04.2020</td>
            <td>20</td>
            <td >100</td>
            <td>20</td>
            <td>
               <a href="#" type="button" class="submit-btn3">Change</a>
            </td>
         </tr>
         <tr class="row">
            <td>1</td>
            <td>xx</td>
            <td>Stychurski</td>
            <td>Manager</td>
            <td>21.04.2020</td>
            <td>20</td>
            <td >3000</td>
            <td>20</td>
            <td>
               <a href="#" type="button" class="submit-btn3">Change</a>
            </td>
         </tr>
      </tbody>
      </table>
            <script>
               function setColor(e){
               const colors = ['#e47911', 'green'];
               
               const wartoscNetto = e.target.offsetParent.parentNode.children[6].innerText;
               const currentTr = e.target.offsetParent.parentNode;
               
               if(wartoscNetto > 1000) return currentTr.style.backgroundColor=colors[0];
               currentTr.style.backgroundColor=colors[1];
               };
               const btn = document.querySelectorAll('.submit-btn3');

               btn.forEach(el => el.addEventListener('click', setColor));

            </script>

如何进行一个按钮,哪个按钮可以从TD上的价值上更改背部颜色基础?

羁客 2025-02-14 17:39:07

我修复了具有模态的主体的问题

I fixed the issue having the Body of the Modal, not in a variable but straight in the return body of the component

Reactjs材料模式不令人耳目一新

羁客 2025-02-14 10:00:30

我以为我有这个问题。

事实证明,当前版本的Copilot在很多情况下只有一个建议。

您可以通过将鼠标悬停在建议方面来查看Copilot是否有其他建议。对我来说,在键盘快捷键“不起作用”的情况下,根本没有其他建议。

I thought I had this problem.

It turned out that the current version of copilot simply only had one suggestion in a lot of cases.

You can see if copilot has alternate suggestions by hovering your mouse over the suggestion. For me, in the cases where the keyboard shortcuts 'didn't work', there simply were no other suggestions available.

如何使用&quot&quot next/上一Mac上GitHub Copilot的建议快捷方式?

羁客 2025-02-14 08:00:48

解决问题的另一种方法是通过 [value] = arrayformname.controls ,然后使用 datakey =“ value.id” 或任何其他属性。

P-table应该做的是将 [value] 的内容与 datakey

为了解决所有行扩展的问题,只需添加 rowexpandMode =“ single”

完整示例


<p-table dataKey="value.id"
         rowExpandMode="single"
         [value]="fatturaDettagli.controls">
  <ng-template pTemplate="header">
    <tr>
      <th style="width: 3rem"></th>
      <th>Name</th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-rowData let-expanded="expanded" let-i="rowIndex">
    <tr [formGroupName]="i">
      <td>
        <button type="button" 
                pButton 
                [pRowToggler]="rowData"
                class="p-button-text">
      </td>
      <td>{{rowData.get('name').value}}</td>
    </tr>
  </ng-template>
</p-table>

Another way to solve the problem is to pass [value]=arrayFormName.controls, and then use dataKey="value.id" or any other attribute.

What the p-table should do is concatenate the contents of [value] with dataKey.

While to solve the problem that all rows are expanded just add rowExpandMode="single"

Complete example


<p-table dataKey="value.id"
         rowExpandMode="single"
         [value]="fatturaDettagli.controls">
  <ng-template pTemplate="header">
    <tr>
      <th style="width: 3rem"></th>
      <th>Name</th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-rowData let-expanded="expanded" let-i="rowIndex">
    <tr [formGroupName]="i">
      <td>
        <button type="button" 
                pButton 
                [pRowToggler]="rowData"
                class="p-button-text">
      </td>
      <td>{{rowData.get('name').value}}</td>
    </tr>
  </ng-template>
</p-table>

可在P-table的可扩展行,Angular中的嵌套formarray

羁客 2025-02-14 00:50:54

在与@Sandeep Ranjan进行了对话之后:

这里的挑战是从存储为动态的JSON文档中提取字段,然后将它们包装到3个新的JSON文档中。

提取字段很简单,e,g。:

customDimensions.myfield

customDimensions["myfield"]

以后的字段名称具有空格和/或特殊字符的字段名称,例如:

customDimensions["my field"]
customDimensions["my-field!"]

包装字段可以使用3种不同的函数来完成彼此的同义词。
这些功能是 pack()&amp; bag_pack(

) :

let requests = datatable(customDimensions:dynamic) [dynamic({"x":1, "y":2, "z":3, "a":"hello", "b":"world", "k1":"v1", "k2":"v2", "k3":"v3", "k4":"v4"})];
requests
| project-rename cd = customDimensions // just to make things a little bit shorter
| extend json_1 = pack_dictionary("x",cd .x, "y", cd.y, "z", cd.z)
| extend json_2 = pack_dictionary("a", cd.a, "b", cd.b)
| extend json_3 = pack_dictionary("k1", cd.k1, "k2", cd.k2, "k3", cd.k3, "k4", cd.k4)
cd json_1 json_2 json_3
{“ x”:1,“ y”:2,“ z”:3,“ a”:“ hello”,“ b”:“ world”,“ k1”:“ v1”,“ k2 “:” v2“,“ k3”:“ v3”,“ k4”:“ v4”} {“ x”:1,“ y”:2,“ z”:3} {“ a”:“ hello”, “ b”:“ world”} {“ k1”:“ v1”,“ k2”:“ v2”,“ k3”:“ v3”,“ k4”:“ v4”}

小提琴

Following a conversation with @Sandeep Ranjan:

The challenge here was to extract fields from a JSON document stored as dynamic and then pack them together to 3 new separate JSON documents.

Extracting fields is straightforward, E,g.:

customDimensions.myfield

or

customDimensions["myfield"]

The later can be used for fields names with spaces and/or special characters, E.g.:

customDimensions["my field"]
customDimensions["my-field!"]

Packing the fields can be done with 3 different functions that are synonyms to each other.
Those functions are pack_dictionary(), pack() & bag_pack()

Here is a quick sample:

let requests = datatable(customDimensions:dynamic) [dynamic({"x":1, "y":2, "z":3, "a":"hello", "b":"world", "k1":"v1", "k2":"v2", "k3":"v3", "k4":"v4"})];
requests
| project-rename cd = customDimensions // just to make things a little bit shorter
| extend json_1 = pack_dictionary("x",cd .x, "y", cd.y, "z", cd.z)
| extend json_2 = pack_dictionary("a", cd.a, "b", cd.b)
| extend json_3 = pack_dictionary("k1", cd.k1, "k2", cd.k2, "k3", cd.k3, "k4", cd.k4)
cd json_1 json_2 json_3
{"x":1,"y":2,"z":3,"a":"hello","b":"world","k1":"v1","k2":"v2","k3":"v3","k4":"v4"} {"x":1,"y":2,"z":3} {"a":"hello","b":"world"} {"k1":"v1","k2":"v2","k3":"v3","k4":"v4"}

Fiddle

将定制量分为3个JSON,然后使用Kusto查询进行项目

羁客 2025-02-13 16:29:58

您可以在字典中生成从索引到键的映射。然后,您可以使用a transpose操作 argmin操作

从那里,您可以使用列表理解将生成的索引转换为字典中出现的键。

key_indices = {idx: key for idx, key in enumerate(dictionary)}

indices = [min(range(len(lst)), key=lambda x: lst[x]) for lst in zip(*dictionary.values())]

[key_indices[index] for index in indices]

这输出:

[1, 1, 1]

You can generate a mapping from an index to a key in the dictionary. Then, you can generate the indices where the minima occur using a transpose operation and an argmin operation.

From there, you can translate the generated indices into keys that appear in the dictionary using a list comprehension.

key_indices = {idx: key for idx, key in enumerate(dictionary)}

indices = [min(range(len(lst)), key=lambda x: lst[x]) for lst in zip(*dictionary.values())]

[key_indices[index] for index in indices]

This outputs:

[1, 1, 1]

所有键的每个元素的Python字典最小值

羁客 2025-02-13 12:26:53

如您的另一个问题所示(如何仅从中仅获取特定数据GraphQl查询), links 是一个数组,除非您循环循环或访问您无法做的特定位置:

post.data.links.blog.document.map((test)

我想您正在尝试做:

post.data.links[0].blog.document.map((test)

根据链接结构,它似乎是1个项目的数组。

在返回JSX之前,尝试通过添加断点或 console.logs 来调试循环,以便您可以查看要通过的内容:

{
  post.data.links.blog.document.map((test) => {
    console.log(test);
    return (
      <GridPosts>
        <GridPost>
          <img src={Post2} alt="Post1" />
          <FlexPost>
            <PostTitle>TEST</PostTitle>
            <PostParagraph>
              A lot of different components that will help you create the
              perfect look for your project
            </PostParagraph>
            <PostTag>Fiction</PostTag>
          </FlexPost>
        </GridPost>
      </GridPosts>
    );
  });
}

As shown in your other question (how to fetch only specific data from graphql query), links is an array so unless you loop through it or you access to a specific position you can't do:

post.data.links.blog.document.map((test)

I guess you are trying to do:

post.data.links[0].blog.document.map((test)

According to links structure, it seems to be an array of 1 item.

Try to debug your loops by adding a breakpoint or console.logs before returning the JSX, so you will be able to see what you are looping through:

{
  post.data.links.blog.document.map((test) => {
    console.log(test);
    return (
      <GridPosts>
        <GridPost>
          <img src={Post2} alt="Post1" />
          <FlexPost>
            <PostTitle>TEST</PostTitle>
            <PostParagraph>
              A lot of different components that will help you create the
              perfect look for your project
            </PostParagraph>
            <PostTag>Fiction</PostTag>
          </FlexPost>
        </GridPost>
      </GridPosts>
    );
  });
}

如何相应地从Plismic获取数据

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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