问:
Can i set the cursor/caret when clicking on pseudo element?
I am setting a Pilcrow character (does not matter) as after element to a paragraph using this css

```<code>body.p:after {
    content:'\00b6'; // the used char or image does not matter
}
</code>```

When i click after the after element inside the body the cursor/caret gets placed at the end of the paragraph as wished. But when i click on the after element no cursor is shown and typing in some letters does not work.

Is there a workaround for this?

答:
Here is my solution to the problem.
OnClick i check if the offset of the click event equals the maximum textnodelength in order to decide if the caret needs to get set or not.
Goal here was to set the cursor to the end of the actual paragraph when clicked on the after element.</p>

```<code>ed.onClick.add(function(ed, evt){

  var node = ed.selection.getNode();

  // need to set Cursor onClick on after element?
  if (ed.controlManager.get('irhiddenchars') && ed.controlManager.get('irhiddenchars').isActive() &&
  evt.target.nodeName.toLowerCase() == 'p'){
    if (node != evt.target) {
        ed.selection.setCursorLocation(evt.target, 0);
    }
    else {
        if (evt.rangeParent.nodeType == 3 && evt.rangeParent.textContent.length == evt.rangeOffset)
        {
            ed.selection.setCursorLocation(evt.rangeParent, evt.rangeOffset);
        }
    }
    // show Caret
    ed.focus();
  }
});
</code>```

Body:
I am setting a Pilcrow character (does not matter) as after element to a paragraph using this css

body.p:after {
    content:'\00b6'; // the used char or image does not matter
}

When i click after the after element inside the body the cursor/caret gets placed at the end of the paragraph as wished. But when i click on the after element no cursor is shown and typing in some letters does not work.

Is there a workaround for this?

Body:
Here is my solution to the problem.
OnClick i check if the offset of the click event equals the maximum textnodelength in order to decide if the caret needs to get set or not.
Goal here was to set the cursor to the end of the actual paragraph when clicked on the after element.

ed.onClick.add(function(ed, evt){

  var node = ed.selection.getNode();

  // need to set Cursor onClick on after element?
  if (ed.controlManager.get('irhiddenchars') && ed.controlManager.get('irhiddenchars').isActive() &&
  evt.target.nodeName.toLowerCase() == 'p'){
    if (node != evt.target) {
        ed.selection.setCursorLocation(evt.target, 0);
    }
    else {
        if (evt.rangeParent.nodeType == 3 && evt.rangeParent.textContent.length == evt.rangeOffset)
        {
            ed.selection.setCursorLocation(evt.rangeParent, evt.rangeOffset);
        }
    }
    // show Caret
    ed.focus();
  }
});


来源: stackexchange

问:
How to show Flutter firebase realtime database on widgets with data updates using Stream builder?
I am using Firebase for first time. My app is connected to firebase successfully and i am able access data on screen by following code. My problem is that while Values changes in database it should be changed on the screen without any button press or something.

```<code>stream:  FirebaseDatabase.instance.ref("app3-e0228-default-rtdb").onvalue,
</code>```

while i use above line the data on the screen will not accessible. what should I do?

```<code>      StreamBuilder(
                stream:  FirebaseDatabase.instance.ref("app3-e0228-default-rtdb").once().asStream(),

                builder: (context,AsyncSnapshot<dynamic>  snapshot) {
                  if (snapshot.connectionState == ConnectionState.done) {
                     DatabaseEvent databaseEvent = snapshot.data!; //  Get the DatabaseEvent from the AsyncSnapshot
                     var databaseSnapshot = databaseEvent.snapshot; //  Get the DataSnapshot from the DatabaseEvent
                     print('Snapshot: ${databaseSnapshot.value}');
                    return Text("${databaseSnapshot.value}");
                  } else {
                    return CircularProgressIndicator();
                  }
                }),
</code>```

DataBase

答:
The first problem I spot is here:

```<code>stream: FirebaseDatabase.instance
    .ref("app3-e0228-default-rtdb")
    .once()
    .asStream(),
</code>```

You're calling once(), which means you read the value from the database once (hence its name), and then turn that into a stream. So your stream will just have one element.

If you want to listen to the database and receive updates too, use onValue:

```<code>stream: FirebaseDatabase.instance
    .ref("app3-e0228-default-rtdb")
    .onValue
</code>```

Inside your builder you'll then have a DataSnapshot that contains the data from your database, and you can simply do:

```<code>builder: (context, snapshot) {
  if (snapshot.connectionState == ConnectionState.done) {
    var databaseEvent = snapshot.data!; //  Get the DatabaseEvent from the AsyncSnapshot
    var databaseSnapshot = databaseEvent.snapshot; //  Get the DataSnapshot from the DatabaseEvent
    print('Snapshot: ${databaseSnapshot.value}');
    return LiveMatch();
  } else {
    return CircularProgressIndicator();
  }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am using Firebase for first time. My app is connected to firebase successfully and i am able access data on screen by following code. My problem is that while Values changes in database it should be changed on the screen without any button press or something.

stream:  FirebaseDatabase.instance.ref("app3-e0228-default-rtdb").onvalue,

while i use above line the data on the screen will not accessible. what should I do?

      StreamBuilder(
                stream:  FirebaseDatabase.instance.ref("app3-e0228-default-rtdb").once().asStream(),

                builder: (context,AsyncSnapshot<dynamic>  snapshot) {
                  if (snapshot.connectionState == ConnectionState.done) {
                     DatabaseEvent databaseEvent = snapshot.data!; //  Get the DatabaseEvent from the AsyncSnapshot
                     var databaseSnapshot = databaseEvent.snapshot; //  Get the DataSnapshot from the DatabaseEvent
                     print('Snapshot: ${databaseSnapshot.value}');
                    return Text("${databaseSnapshot.value}");
                  } else {
                    return CircularProgressIndicator();
                  }
                }),

DataBase

Body:
The first problem I spot is here:

stream: FirebaseDatabase.instance
    .ref("app3-e0228-default-rtdb")
    .once()
    .asStream(),

You're calling once(), which means you read the value from the database once (hence its name), and then turn that into a stream. So your stream will just have one element.

If you want to listen to the database and receive updates too, use onValue:

stream: FirebaseDatabase.instance
    .ref("app3-e0228-default-rtdb")
    .onValue

Inside your builder you'll then have a DataSnapshot that contains the data from your database, and you can simply do:

builder: (context, snapshot) {
  if (snapshot.connectionState == ConnectionState.done) {
    var databaseEvent = snapshot.data!; //  Get the DatabaseEvent from the AsyncSnapshot
    var databaseSnapshot = databaseEvent.snapshot; //  Get the DataSnapshot from the DatabaseEvent
    print('Snapshot: ${databaseSnapshot.value}');
    return LiveMatch();
  } else {
    return CircularProgressIndicator();
  }


问:
R adding a new column in a data frame by recursivly filling 1:3 value based on another column
I have a dataframe, e.g.:

```<code>df <- data.frame(Group = rep(c("A", "B", "C"),  times = c(4, 4, 6))
> df
   Group
1      A
2      A
3      B
4      B
5      B
6      B
7      C
8      C
9      C
10     C
11     C
12     C
</code>```

I want to add a new column Type by recursively filling value 1:3 based on the Group column.

The resulting DF is like

```<code>> df2
   Group Type
1      A    1
2      A    2
3      B    1
4      B    2
5      B    3
6      B    1
7      C    1
8      C    2
9      C    3
10     C    1
11     C    2
12     C    3
</code>```

I don't know how to achieve this. Thanks a lot for your help

答:
You could also use %% remainder:

```<code>library(dplyr)

df %>%
  group_by(Group) %>%
  mutate(Type = (row_number() - 1) %% 3 + 1)
</code>```

Output

```<code>   Group  Type
   <chr> <dbl>
 1 A         1
 2 A         2
 3 A         3
 4 A         1
 5 B         1
 6 B         2
 7 B         3
 8 B         1
 9 C         1
10 C         2
11 C         3
12 C         1
13 C         2
14 C         3
</code>```

Body:
I have a dataframe, e.g.:

df <- data.frame(Group = rep(c("A", "B", "C"),  times = c(4, 4, 6))
> df
   Group
1      A
2      A
3      B
4      B
5      B
6      B
7      C
8      C
9      C
10     C
11     C
12     C

I want to add a new column Type by recursively filling value 1:3 based on the Group column.

The resulting DF is like

> df2
   Group Type
1      A    1
2      A    2
3      B    1
4      B    2
5      B    3
6      B    1
7      C    1
8      C    2
9      C    3
10     C    1
11     C    2
12     C    3

I don't know how to achieve this. Thanks a lot for your help

Body:
You could also use %% remainder:

library(dplyr)

df %>%
  group_by(Group) %>%
  mutate(Type = (row_number() - 1) %% 3 + 1)

Output

   Group  Type
   <chr> <dbl>
 1 A         1
 2 A         2
 3 A         3
 4 A         1
 5 B         1
 6 B         2
 7 B         3
 8 B         1
 9 C         1
10 C         2
11 C         3
12 C         1
13 C         2
14 C         3


问:
How to encrypt java Strings in C considering their size difference?
Good evening,
I am building a java project in which it communicates with an Intel SGX Enclave via JNI, and sees information it sends sealed by the enclave.

However, decrypting information returns information I cannot understand, and at this point, I believe it to be due to size differences,but I dont exactly understand it.

So, I know that Sizeof(char*) is equivalent to 1 byte, just like sizeof(jbyte). However, sizeof(jchar) is equivalent to 2 bytes.

After acquiring this knowledge, I decided to implement the Sealing (Or encryption) function by having it take a JByteArray in order to circumvent this problem. Should this byte[] be given in UTF-8 or UTF-16? Does it affect the function overall?

Here is an example of what I do:

```<code>JNIEXPORT jbyteArray JNICALL Java_sgxUtils_SgxFunctions_jni_1sgx_1seal_1info
  (JNIEnv * env, jobject, jbyteArray jArray){

   //Create a char* from the given byte array.
   jbyte *b = env->GetByteArrayElements(jArray,NULL);
   int StringSize = env->GetArrayLength(jArray);
   char* c = (char*)malloc(sizeof(char) * StringSize);
   memcpy(c,b,StringSize);

   //Calculate the size of the encryption.
   size_t sealed_size = sizeof(sgx_sealed_data_t) + StringSize;

   //Create a uint8_t pointer to store the sealed information
   uint8_t* sealed_data = (uint8_t*)malloc(sealed_size);

   sgx_status_t ecall_status; //Store the status of the ecall.
   seal(global_eid, &ecall_status,(uint8_t*)&c,StringSize, sgx_sealed_data_t*)sealed_data,sealed_size);

   //Produce the jbyteArray to return:
    jbyte* jresult = (jbyte*)calloc(sizeof(jbyte),sealed_size);
    for(int i = 0 ; i < sealed_size ;i++){
        jresult[i] = (jbyte)sealed_data[i];
    }

    jbyteArray jArray2 = env->NewByteArray(sealed_size+1);
    env->SetByteArrayRegion(jArray2,0,sealed_size,jresult);

    return jArray2;
</code>```

Does using uint8_t affect the sealing? I am at a loss of what it might be.
The way I receive this byte[] in java is as follows:

```<code>byte[] c = sgx.jni_sgx_seal_info("toEncrypt".getBytes(Charset.forName("UTF-8")));
String sealed = new String(c,StandardCharsets.UTF_8);
</code>```

Does anyone know what could be affecting this? The output after unsealing (decryption) currently stands as �|(�

答:
You can't convert random bytes (such as produced by encryption) into UTF-8 (or many multi-byte encodings, 8-bit single byte encodings are fine). The String will most likely become corrupted, as there are byte sequences describing illegal characters, they will be replaced with 0xFFFE or � i.e. he unicode replacement character.

So you will need to keep the byte[] around and not convert that to a String until you've decrypted the byte array, not a String.

Body:
Good evening,
I am building a java project in which it communicates with an Intel SGX Enclave via JNI, and sees information it sends sealed by the enclave.

However, decrypting information returns information I cannot understand, and at this point, I believe it to be due to size differences,but I dont exactly understand it.

So, I know that Sizeof(char*) is equivalent to 1 byte, just like sizeof(jbyte). However, sizeof(jchar) is equivalent to 2 bytes.

After acquiring this knowledge, I decided to implement the Sealing (Or encryption) function by having it take a JByteArray in order to circumvent this problem. Should this byte[] be given in UTF-8 or UTF-16? Does it affect the function overall?

Here is an example of what I do:

JNIEXPORT jbyteArray JNICALL Java_sgxUtils_SgxFunctions_jni_1sgx_1seal_1info
  (JNIEnv * env, jobject, jbyteArray jArray){

   //Create a char* from the given byte array.
   jbyte *b = env->GetByteArrayElements(jArray,NULL);
   int StringSize = env->GetArrayLength(jArray);
   char* c = (char*)malloc(sizeof(char) * StringSize);
   memcpy(c,b,StringSize);

   //Calculate the size of the encryption.
   size_t sealed_size = sizeof(sgx_sealed_data_t) + StringSize;

   //Create a uint8_t pointer to store the sealed information
   uint8_t* sealed_data = (uint8_t*)malloc(sealed_size);

   sgx_status_t ecall_status; //Store the status of the ecall.
   seal(global_eid, &ecall_status,(uint8_t*)&c,StringSize, sgx_sealed_data_t*)sealed_data,sealed_size);

   //Produce the jbyteArray to return:
    jbyte* jresult = (jbyte*)calloc(sizeof(jbyte),sealed_size);
    for(int i = 0 ; i < sealed_size ;i++){
        jresult[i] = (jbyte)sealed_data[i];
    }

    jbyteArray jArray2 = env->NewByteArray(sealed_size+1);
    env->SetByteArrayRegion(jArray2,0,sealed_size,jresult);

    return jArray2;

Does using uint8_t affect the sealing? I am at a loss of what it might be.
The way I receive this byte[] in java is as follows:

byte[] c = sgx.jni_sgx_seal_info("toEncrypt".getBytes(Charset.forName("UTF-8")));
String sealed = new String(c,StandardCharsets.UTF_8);

Does anyone know what could be affecting this? The output after unsealing (decryption) currently stands as �|(�


问:
c++ : Why does my boolean store a value greater than 1?
I'm learning C++ and am right now starting with the concept of classes. And I learned that a new created object (without constructor) will have randomized attributes. So I wanted to test that and wrote a short code:

#include <iostream>
#include <vector>

class Person;
class Person {
public:
  bool const isHungry() {
    return hungry;
  }
  bool const isOld() {
    return age;
  }
private:
  bool hungry;
  bool age;
};

int main() {
  Person person1,person2,person3;
  std::vector<Person> persons {person1,person2,person3};
  for (auto i : persons) {
    std::cout << "Hungrig: " << i.isHungry() << ";\t Alt: " << i.isOld();
    std::cout << std::endl;
  }
}
```
<p>And the result were:</p>
<p>Hungrig: 96;     Alt: 147</p>
<p>Hungrig: 222;    Alt: 46</p>
<p>Hungrig: 252;    Alt: 127</p>
<p>So yes, it is randomized, but a now I got a new question:
How can that be?? It's a boolean, it should be 0 or 1!</p>
<p>Edit: I think the trouble I have with it is that I thought the boolean converts integers greater than 1 to 1. Like this:</p>
```  bool test;
  test= 32;
  std::cout << test << std::endl;
```

Result is always 1. So it puzzles me why it doesn't do it with the boolean in my class.

答:
And I learned that a new created object (without constructor) will have randomized attributes.

This is wrong. The uninitialized members will have indeterminate values until they are assigned to. Trying to read an indeterminate value causes the program to have undefined behavior, which means that there will be no guarantee on how the program will behave. This is different from simply producing an unspecified value. It allows the program to behave in any way, whether or not it fits e.g. the constraints of types that you expect from a valid program.

Practically speaking, it often happens that the undefined behavior of reading uninitialized variables manifests simply in producing unspecified values, but these values are not randomized either. They are deterministic and a result of the specific way in which the compiler compiled the invalid program.

You are correct that a bool variable can have only values 0 or 1, but the memory that the variable occupies may have more states than that and so it is possible that multiple object representations represent the same value. For example a bool variable may occupy a whole byte of memory and one possible interpretation would be that all states of this memory are valid object representations with one specific bit identifying the value of the bool. But it may also be that each value has only one valid object representation, in which case it is likely that the code reading and printing the bool will not bother extracting such a bit and print non-sense if the memory is in an invalid state for the type, such as is likely to happen when you don't initialize the memory.

Body:
I'm learning C++ and am right now starting with the concept of classes. And I learned that a new created object (without constructor) will have randomized attributes. So I wanted to test that and wrote a short code:

#include <iostream>
#include <vector>

class Person;
class Person {
public:
  bool const isHungry() {
    return hungry;
  }
  bool const isOld() {
    return age;
  }
private:
  bool hungry;
  bool age;
};

int main() {
  Person person1,person2,person3;
  std::vector<Person> persons {person1,person2,person3};
  for (auto i : persons) {
    std::cout << "Hungrig: " << i.isHungry() << ";\t Alt: " << i.isOld();
    std::cout << std::endl;
  }
}

And the result were:

Hungrig: 96;     Alt: 147

Hungrig: 222;    Alt: 46

Hungrig: 252;    Alt: 127

So yes, it is randomized, but a now I got a new question:
How can that be?? It's a boolean, it should be 0 or 1!

Edit: I think the trouble I have with it is that I thought the boolean converts integers greater than 1 to 1. Like this:

  bool test;
  test= 32;
  std::cout << test << std::endl;

Result is always 1. So it puzzles me why it doesn't do it with the boolean in my class.


问:
BlackBerry Database Slow Performance
I'm making use of a 5 mb SQLite db in my app, on app's 1st use the db is being copied to the device memory card.

The problem is that the db querying is very slow.

Any suggestions to performance improvments?

Thanks!

答:
I'd take a look at these tips in order to optimize your SQLite database performance:

Best practice: Optimizing SQLite database performance

ContentLicense: CC BY-SA 3.0

Title: BlackBerry Database Slow Performance


问:
Is there any way to view the currently mapped keys in Vim?
Basically, I'd like to view all of the keys maps made in the current buffer by all of plugins, vimrc, etc, in the current buffer. Is there anyway to do this?</p>

答:
Install this plug like this:
Plug 'https://github.com/tpope/vim-scriptease'

What to know what <M-C-F10>(my own mapping) does?
try this

```<code>:Verbose nmap <M-C-F10> |  omap <M-C-F10> | vmap <M-C-F10> | imap <M-C-F10> | cmap <M-C-F10> | tmap <M-C-F10>
</code>```

put it in a function:

```<code>            func! Leo_keymap(keys)
                exe "verbose map " . a:keys
                exe "verbose map! " . a:keys
                exe "verbose tmap " . a:keys

                " 不好 / not good:
                    " exe "verbose nmap " . a:keys
                    " exe "verbose omap " . a:keys
                    " exe "verbose vmap " . a:keys
                    " exe "verbose imap " . a:keys
                    " exe "verbose cmap " . a:keys
                    " exe "verbose tmap " . a:keys
                " 不行 / not work
                    " exe "Verbose map " . a:keys  . <Bar> . "verbose map! " . a:keys . <Bar> .  "verbose tmap " . a:keys
            endfunc

        cnoreabbrev <expr> map   getcmdtype() == ":" && getcmdline() == 'map'          ? 'Verbose call Leo_keymap("")<left><left>'                       :   'map'
                " 不行 / not work
                    " command! -nargs=* Map :new<CR>:put = Vim_out('call Leo_keymap(input())')
                " 不行 / not work
                    " :put = Vim_out("call Leo_keymap('ls')")

        " may be take placed by the above line
            cnoreabbrev <expr> nmap  getcmdtype() == ":" && getcmdline() == 'nmap'          ? 'Verbose map'                       :   'map'
            cnoreabbrev <expr> imap  getcmdtype() == ":" && getcmdline() == 'imap'         ? 'Verbose imap'                      :   'imap'
            cnoreabbrev <expr> cmap  getcmdtype() == ":" && getcmdline() == 'cmap'         ? 'Verbose cmap'                      :   'cmap'
            cnoreabbrev <expr> tmap  getcmdtype() == ":" && getcmdline() == 'tmap'         ? 'Verbose tmap'                      :   'tmap'

</code>```

old content, may be useless:

```<code>func! Leo_keymap(keys)
    exe "verbose map " . a:keys
    exe "verbose map! " . a:keys
    exe "verbose tmap " . a:keys
    " exe "Verbose map " . a:keys  . <Bar> . "verbose map! " . a:keys . <Bar> .  "verbose tmap " . a:keys
    " exe "verbose nmap " . a:keys
    " exe "verbose omap " . a:keys
    " exe "verbose vmap " . a:keys
    " exe "verbose imap " . a:keys
    " exe "verbose cmap " . a:keys
    " exe "verbose tmap " . a:keys
endfunc

command! -nargs=* Map :call Leo_keymap(<q-args>)
</code>```

now :Map d gets:

```<code>n  dL          * v$hhd
        Last set from ~/dotF/cfg/nvim/plug_wf.vim line 712
n  df          * ggdG
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 250
n  dB          * %dab
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 230
n  d"          * da"
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 212
n  dw          * diw
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 211
n  d'          * :call DoubleAsSingle()<CR>da'
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 195
No mapping found
No mapping found
Press ENTER or type command to continue
</code>```

So far, I don't know how to combine this with :Verbose .....

Body:
Install this plug like this:
Plug 'https://github.com/tpope/vim-scriptease'

What to know what <M-C-F10>(my own mapping) does?
try this

:Verbose nmap <M-C-F10> |  omap <M-C-F10> | vmap <M-C-F10> | imap <M-C-F10> | cmap <M-C-F10> | tmap <M-C-F10>

put it in a function:

            func! Leo_keymap(keys)
                exe "verbose map " . a:keys
                exe "verbose map! " . a:keys
                exe "verbose tmap " . a:keys

                " 不好 / not good:
                    " exe "verbose nmap " . a:keys
                    " exe "verbose omap " . a:keys
                    " exe "verbose vmap " . a:keys
                    " exe "verbose imap " . a:keys
                    " exe "verbose cmap " . a:keys
                    " exe "verbose tmap " . a:keys
                " 不行 / not work
                    " exe "Verbose map " . a:keys  . <Bar> . "verbose map! " . a:keys . <Bar> .  "verbose tmap " . a:keys
            endfunc

        cnoreabbrev <expr> map   getcmdtype() == ":" && getcmdline() == 'map'          ? 'Verbose call Leo_keymap("")<left><left>'                       :   'map'
                " 不行 / not work
                    " command! -nargs=* Map :new<CR>:put = Vim_out('call Leo_keymap(input())')
                " 不行 / not work
                    " :put = Vim_out("call Leo_keymap('ls')")

        " may be take placed by the above line
            cnoreabbrev <expr> nmap  getcmdtype() == ":" && getcmdline() == 'nmap'          ? 'Verbose map'                       :   'map'
            cnoreabbrev <expr> imap  getcmdtype() == ":" && getcmdline() == 'imap'         ? 'Verbose imap'                      :   'imap'
            cnoreabbrev <expr> cmap  getcmdtype() == ":" && getcmdline() == 'cmap'         ? 'Verbose cmap'                      :   'cmap'
            cnoreabbrev <expr> tmap  getcmdtype() == ":" && getcmdline() == 'tmap'         ? 'Verbose tmap'                      :   'tmap'

old content, may be useless:

func! Leo_keymap(keys)
    exe "verbose map " . a:keys
    exe "verbose map! " . a:keys
    exe "verbose tmap " . a:keys
    " exe "Verbose map " . a:keys  . <Bar> . "verbose map! " . a:keys . <Bar> .  "verbose tmap " . a:keys
    " exe "verbose nmap " . a:keys
    " exe "verbose omap " . a:keys
    " exe "verbose vmap " . a:keys
    " exe "verbose imap " . a:keys
    " exe "verbose cmap " . a:keys
    " exe "verbose tmap " . a:keys
endfunc

command! -nargs=* Map :call Leo_keymap(<q-args>)

now :Map d gets:

n  dL          * v$hhd
        Last set from ~/dotF/cfg/nvim/plug_wf.vim line 712
n  df          * ggdG
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 250
n  dB          * %dab
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 230
n  d"          * da"
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 212
n  dw          * diw
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 211
n  d'          * :call DoubleAsSingle()<CR>da'
        Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 195
No mapping found
No mapping found
Press ENTER or type command to continue

So far, I don't know how to combine this with :Verbose .....


问:
Max score to reach end of array with step length
Assume an array and we start from element at index 0. We want to go from 0 index to last index of the array by taking steps of at max length K.

For example, suppose an array is [10,2,-10,5,20] and K is 2, which means maximum step length is 2 (We can assume K is always possible and less than length of array).
Now as we start from index 0, our score currently is 10 and then we can either go to 2 or can go to -10. Suppose we go to 2 from here so total score becomes 10+2=12. Now from 2 we can go to -10 or 5 so you go to 5 making score 12+5=17. From here you directly go to last index as you have no way other than that, hence total score is 17+20=37.

For given array of length N and an integer K we need to find maximum score we can get.
I thought of a solution, to divide it into sub problems by deciding weather to go at index i or not and recursively call the remaining array. But I sense some dynamic programming out of this problem.

How can this be solved for given array of size N and integer K.

Constraint : 1<=N<=100000 and 1<=K<=N

答:
A greedy solution. You might find it is easier to understand.</p>
```<code>class Solution {
 public static void main(String[] args) {
  //Init
  int[]path= {10,2,-10,5,20};
  int maxStep=2;
  int max=path[0];
  if(path.length==0)System.out.println(0);
  for(int i=0;i<path.length-1;) {
   int index=0,temp=Integer.MIN_VALUE;
   //for each step, choose the step that has max value
   for(int j=1;(j<=maxStep)&&(i+j<=path.length-1);j++) {
      if(i+j>path.length-1)break;
      if(path[i+j]>temp) {
      temp=path[i+j];
      index=j;
    }
   }
   //change the index and the max value
   i+=index;max+=temp;
  }
  System.out.println(max);
 }
}
</code>```

Body:
A greedy solution. You might find it is easier to understand.

class Solution {
 public static void main(String[] args) {
  //Init
  int[]path= {10,2,-10,5,20};
  int maxStep=2;
  int max=path[0];
  if(path.length==0)System.out.println(0);
  for(int i=0;i<path.length-1;) {
   int index=0,temp=Integer.MIN_VALUE;
   //for each step, choose the step that has max value
   for(int j=1;(j<=maxStep)&&(i+j<=path.length-1);j++) {
      if(i+j>path.length-1)break;
      if(path[i+j]>temp) {
      temp=path[i+j];
      index=j;
    }
   }
   //change the index and the max value
   i+=index;max+=temp;
  }
  System.out.println(max);
 }
}


问:
Use values from a function and pass it to another function
I have the below two functions and I want the SOURCE and TARGET of the ROBOCOPY function used within the Comparision function. Can anyone tell me how to do this please. Thanks.</p>

```<code>Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
Write-Host "Pre-Staging Script for DFSR Server" -ForegroundColor Magenta -BackgroundColor White
Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
Write-Host ""
Function GetHot-Fix
{
                Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Checking Service Installation" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""
                write-host "This will check if Hotfix KB979808 is installed." -ForegroundColor Black -BackgroundColor Cyan
                write-host "This is required for Windows Server 2008 R2 Robocopying"  -ForegroundColor Black -BackgroundColor Cyan
                Write-Host ""

                Get-HotFix -id KB979808 -ErrorAction SilentlyContinue

}

Function Start-MyRobocopy($source,$Target)
{
                Write-Host "=============" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Robocopy Data" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "=============" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""

                $Source = Read-Host "Please enter path of SOURCE"

                If ($Source -and (Test-Path -Path $Source -PathType Container))
                {
                                $Target = Read-Host "Please enter path of TARGET"
                }
                Else
                {
                Write-Host "Please enter a directory"
                }
                                If ($Target -and (Test-Path -Path $Target -PathType Container))
                                {
                                $Output = Read-Host "Please enter where to place output file eg c:\temp\COPY.log"
                                }
                                Else
                                {
                                Write-Host "Please enter a directory"
                                }

robocopy.exe $Source $Target /b /e /copyall /r:1 /xd dfsrprivate /log:$Output /tee
}
Function Comparision
{
                Write-Host ""
                Write-Host ""
                Write-Host "===============================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Checking Directory Count and Folder comparision" -ErrorAction SilentlyContinue -ForegroundColor Magenta -BackgroundColor White
                Write-Host "===============================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""

             #$Source = Read-Host "Please enter Source directory to check"
             #$Target = Read-Host "Please enter Target directory to check"
                Write-Host ""
                If($source -and (Test-Path -Path $source -PathType Container))
                {
                "There are $(@(Get-ChildItem $Source).Count) items in the '$Source' directory"
                }
                Else
                {
                Write-Host "Please enter a directory"
                                }
                                If($source -and (Test-Path -Path $Target -PathType Container))
                                {
                                "There are $(@(Get-ChildItem $Target).Count) items in the '$Target' directory"
                }
                Else
                {
                Write-Host "Please enter a directory"
                }

                Write-Host ""
                $child1 = Get-ChildItem -Path $Source -Recurse -Force
                $child2 = Get-ChildItem -Path $Target -Recurse -Force

                Compare-Object $child1 -DifferenceObject $child2 -Property Name

                Write-Host ""
                Write-Host "NOTE:" -BackgroundColor Cyan -ForegroundColor Black
                Write-Host "Any symbols with '=>' mean that the file Does NOT exist in SOURCE but is in the Target" -BackgroundColor Cyan -ForegroundColor Black
                Write-Host "Any symbols with '<=' mean that the file Does NOT exist in TARGET but is in the Source" -BackgroundColor Cyan -ForegroundColor Black
}

$hotfix = GetHot-Fix
If ($hotfix) {
                Write-Host "Hotfix installed" -BackgroundColor Green -ForegroundColor Black
                Write-Host ""
                Write-Host "Proceeding with Robocopy...."
                Write-Host "............................"
                Write-Host ""
                Start-MyRobocopy
                }
else {
                                Write-Host "Hotfix is NOT installed - Please ensure you install this hotfix BEFORE" -ForegroundColor "red"
        Write-host "Copying any data" -foregroundcolor "red"
                                Write-Host ""
                                return
                }

Comparision
</code>```

答: You have a few choices. Two of those are global state (have $source and $target declared at the file scope and both functions use them) and have Comparison take those as parameters. Given that your robocopy function queries the user for the source and target if they are null, then global state is the simplest solution. Personally, I would probably write a third function called something like Get-SourceAndTarget that handles that part and outputs the source and target so you can pass those into both Start-MyRobocopy and Comparison. I don't hack powershell all that well, so I'm a little unclear on the syntax, but that should probably get you started.</p>

Body:
I have the below two functions and I want the SOURCE and TARGET of the ROBOCOPY function used within the Comparision function. Can anyone tell me how to do this please. Thanks.

Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
Write-Host "Pre-Staging Script for DFSR Server" -ForegroundColor Magenta -BackgroundColor White
Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
Write-Host ""
Function GetHot-Fix
{
                Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Checking Service Installation" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""
                write-host "This will check if Hotfix KB979808 is installed." -ForegroundColor Black -BackgroundColor Cyan
                write-host "This is required for Windows Server 2008 R2 Robocopying"  -ForegroundColor Black -BackgroundColor Cyan
                Write-Host ""

                Get-HotFix -id KB979808 -ErrorAction SilentlyContinue

}

Function Start-MyRobocopy($source,$Target)
{
                Write-Host "=============" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Robocopy Data" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "=============" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""

                $Source = Read-Host "Please enter path of SOURCE"

                If ($Source -and (Test-Path -Path $Source -PathType Container))
                {
                                $Target = Read-Host "Please enter path of TARGET"
                }
                Else
                {
                Write-Host "Please enter a directory"
                }
                                If ($Target -and (Test-Path -Path $Target -PathType Container))
                                {
                                $Output = Read-Host "Please enter where to place output file eg c:\temp\COPY.log"
                                }
                                Else
                                {
                                Write-Host "Please enter a directory"
                                }

robocopy.exe $Source $Target /b /e /copyall /r:1 /xd dfsrprivate /log:$Output /tee
}
Function Comparision
{
                Write-Host ""
                Write-Host ""
                Write-Host "===============================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Checking Directory Count and Folder comparision" -ErrorAction SilentlyContinue -ForegroundColor Magenta -BackgroundColor White
                Write-Host "===============================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""

             #$Source = Read-Host "Please enter Source directory to check"
             #$Target = Read-Host "Please enter Target directory to check"
                Write-Host ""
                If($source -and (Test-Path -Path $source -PathType Container))
                {
                "There are $(@(Get-ChildItem $Source).Count) items in the '$Source' directory"
                }
                Else
                {
                Write-Host "Please enter a directory"
                                }
                                If($source -and (Test-Path -Path $Target -PathType Container))
                                {
                                "There are $(@(Get-ChildItem $Target).Count) items in the '$Target' directory"
                }
                Else
                {
                Write-Host "Please enter a directory"
                }

                Write-Host ""
                $child1 = Get-ChildItem -Path $Source -Recurse -Force
                $child2 = Get-ChildItem -Path $Target -Recurse -Force

                Compare-Object $child1 -DifferenceObject $child2 -Property Name

                Write-Host ""
                Write-Host "NOTE:" -BackgroundColor Cyan -ForegroundColor Black
                Write-Host "Any symbols with '=>' mean that the file Does NOT exist in SOURCE but is in the Target" -BackgroundColor Cyan -ForegroundColor Black
                Write-Host "Any symbols with '<=' mean that the file Does NOT exist in TARGET but is in the Source" -BackgroundColor Cyan -ForegroundColor Black
}

$hotfix = GetHot-Fix
If ($hotfix) {
                Write-Host "Hotfix installed" -BackgroundColor Green -ForegroundColor Black
                Write-Host ""
                Write-Host "Proceeding with Robocopy...."
                Write-Host "............................"
                Write-Host ""
                Start-MyRobocopy
                }
else {
                                Write-Host "Hotfix is NOT installed - Please ensure you install this hotfix BEFORE" -ForegroundColor "red"
        Write-host "Copying any data" -foregroundcolor "red"
                                Write-Host ""
                                return
                }

Comparision


问:
Updating image source on scroll using pure javascript
I'm trying to make a component that updates its source image on scroll when it gets referenced in its div tag ' infoBG 'in my main component. The function seems to work but I guess the return statement is overriding the function and just returns the original image without updating. What's the right way to do this so the function updates the first returned image?</p>
```<code>
function Infoimg () {

  window.addEventListener("scroll", event => {
    var scrollValue = window.scrollY;
    var image = document.getElementById('infoBG');
    if (scrollValue>100){
      image.setAttribute = ('src','images/ccpLogo.svg');
    }else{
      image.setAttribute = ('src','images/Passport Stock Photo.svg');
    }
    console.log(image)
    console.log(scrollValue);
  });

 return(

 <img src={'images/Passport Stock Photo.svg'} alt='Info-Background'/>

 )

}

</code>```

答:
It is generally a bad idea to manipulate the DOM directly in React. Instead, rely on hooks and states to update variables that will be interpolated into your template instead.

In this case, it makes sense to create a new state using the useState hook to allow reading and writing of your image URL, and then use the setter returned by useState to update the value.

Moreover, some handful tips:

You should use useEffect() and add the event listener on render

You should also return a function in useEffect() to ensure that your scroll event listener is properly removed to avoid potential memory leaks and allow for garbage collection

You can simplify your if/else statement into a simple ternary statement

You might want to manually invoke onScroll() for the first time, especially if the user may arrive at the page with a cached scroll position (i.e. user does not start from top of page)

With all these points in mind, here is an improved version of your code:

```<code>const [image, setImage] = useState('images/Passport Stock Photo.svg');

useEffect(() => {
  const onScroll = () => {
    setImage(window.scrollY > 100 ? 'images/ccpLogo.svg' : 'images/Passport Stock Photo.svg');
  };

  // Note: Listen to scroll event
  window.addEventListener('scroll', onScroll);

  // Optional: Handle scenario where user arrives at a pre-scrolled position (non-zero scrollY on load)
  onScroll();

  // Note: Clean up to avoid memory leaks
  return () => {
    window.removeEventListener('scroll', onScroll);
  };
}, []);

return (
  <img src={image} alt="Info-Background" />
);
</code>```

Body:
I'm trying to make a component that updates its source image on scroll when it gets referenced in its div tag ' infoBG 'in my main component. The function seems to work but I guess the return statement is overriding the function and just returns the original image without updating. What's the right way to do this so the function updates the first returned image?

function Infoimg () {

  window.addEventListener("scroll", event => {
    var scrollValue = window.scrollY;
    var image = document.getElementById('infoBG');
    if (scrollValue>100){
      image.setAttribute = ('src','images/ccpLogo.svg');
    }else{
      image.setAttribute = ('src','images/Passport Stock Photo.svg');
    }
    console.log(image)
    console.log(scrollValue);
  });

 return(

 )

}

Body:
It is generally a bad idea to manipulate the DOM directly in React. Instead, rely on hooks and states to update variables that will be interpolated into your template instead.

In this case, it makes sense to create a new state using the useState hook to allow reading and writing of your image URL, and then use the setter returned by useState to update the value.

Moreover, some handful tips:

You should use useEffect() and add the event listener on render

You should also return a function in useEffect() to ensure that your scroll event listener is properly removed to avoid potential memory leaks and allow for garbage collection

You can simplify your if/else statement into a simple ternary statement

You might want to manually invoke onScroll() for the first time, especially if the user may arrive at the page with a cached scroll position (i.e. user does not start from top of page)

With all these points in mind, here is an improved version of your code:

const [image, setImage] = useState('images/Passport Stock Photo.svg');

useEffect(() => {
  const onScroll = () => {
    setImage(window.scrollY > 100 ? 'images/ccpLogo.svg' : 'images/Passport Stock Photo.svg');
  };

  // Note: Listen to scroll event
  window.addEventListener('scroll', onScroll);

  // Optional: Handle scenario where user arrives at a pre-scrolled position (non-zero scrollY on load)
  onScroll();

  // Note: Clean up to avoid memory leaks
  return () => {
    window.removeEventListener('scroll', onScroll);
  };
}, []);

return (
  <img src={image} alt="Info-Background" />
);


问:
How to convert multiple rows with same ID to single rows
I have a dataset1 which is as follows (table 1) :

```<code>structure(list(TCODE = c("T1", "T1", "T1", "T2", "T2", "T2",
"T2", "T2", "T3", "T4", "T4", "T4", "T4"), MATERIAL = c("M105",
"M100", "M102", "M345", "M400", "M100", "M220", "M260", "M400",
"M390", "M400", "M100", "M700")), class = "data.frame", row.names = c(NA,
-13L))

   TCODE MATERIAL
1     T1     M105
2     T1     M100
3     T1     M102
4     T2     M345
5     T2     M400
6     T2     M100
7     T2     M220
8     T2     M260
9     T3     M400
10    T4     M390
11    T4     M400
12    T4     M100
13    T4     M700
</code>```

How to convert multiple rows into a single row based on first column?
The desired output is : table 2

1     2       3       4       5

1   M105,   M100,   M102

2   M345,   M400,   M100,   M220,   M260

3   M400

4   M390,   M400,   M100,   M700

Thanks.

答:
Using data.table

```<code>library(data.table)
dcast(setDT(df), TCODE ~ paste0("id_", rowid(TCODE)), value.var = 'MATERIAL')
</code>```

-output

```<code>   TCODE   id_1   id_2   id_3   id_4   id_5
   <char> <char> <char> <char> <char> <char>
1:     T1   M105   M100   M102   <NA>   <NA>
2:     T2   M345   M400   M100   M220   M260
3:     T3   M400   <NA>   <NA>   <NA>   <NA>
4:     T4   M390   M400   M100   M700   <NA>
</code>```

Body:
I have a dataset1 which is as follows (table 1) :

structure(list(TCODE = c("T1", "T1", "T1", "T2", "T2", "T2",
"T2", "T2", "T3", "T4", "T4", "T4", "T4"), MATERIAL = c("M105",
"M100", "M102", "M345", "M400", "M100", "M220", "M260", "M400",
"M390", "M400", "M100", "M700")), class = "data.frame", row.names = c(NA,
-13L))

   TCODE MATERIAL
1     T1     M105
2     T1     M100
3     T1     M102
4     T2     M345
5     T2     M400
6     T2     M100
7     T2     M220
8     T2     M260
9     T3     M400
10    T4     M390
11    T4     M400
12    T4     M100
13    T4     M700

How to convert multiple rows into a single row based on first column?
The desired output is : table 2

1     2       3       4       5

1   M105,   M100,   M102

2   M345,   M400,   M100,   M220,   M260

3   M400

4   M390,   M400,   M100,   M700

Thanks.

Body:
Using data.table

library(data.table)
dcast(setDT(df), TCODE ~ paste0("id_", rowid(TCODE)), value.var = 'MATERIAL')

-output

   TCODE   id_1   id_2   id_3   id_4   id_5
   <char> <char> <char> <char> <char> <char>
1:     T1   M105   M100   M102   <NA>   <NA>
2:     T2   M345   M400   M100   M220   M260
3:     T3   M400   <NA>   <NA>   <NA>   <NA>
4:     T4   M390   M400   M100   M700   <NA>


问:
Write to lowercase 'default' section ConfigParser
I am working with an ini file where the default section is named 'default' and not 'DEFAULT'. Pythons ConfigParser seams to handle these sections ok with no problem. However, for whatever reason, they dont allow you to add a 'default' section or write to it.
In the code, they have hardcoded that you can not create a section of any case-insensitive version of 'DEFAULT'.

So if I can not add the section 'default' how do I write to it? The spec says you write to 'DEFAULT' since the section always exists. However, how to I write to 'default'?

I want to stay consistent with the way the file is already written, so I want the default section to be written in lowercase and not all uppercase.

If the file doesnt exist yet, I want to add the [default] section. Writing to section 'default' gives me a ValueError: Invalid section name: default

(note: writing to default works fine when I use an already correctly formatted file)

Also, I am willing to listen to suggestions for other configuration libraries I can use. But they must not be 3rd party (I shouldn't need to pip install them)

答:
I think that the simplest approach is this...

from configparser import ConfigParser

config_parser = ConfigParser()
config_parser.default_section = "default"
```


问:
ExpressJS Await not working - SQL SELECT too fast (before INSERT)
I want to make a SQL Insert and after that a Select with the complete List to show in Vue inclusive the new entry. But the Select is faster than the Insert and does only return the old values which are already in the Table. I tried with setTimeout and Async-Await. (SQL Statements are working)

Can someone help me i am new into JS.

```<code>async function select_time(datum, mitarbeiter_id){
    let returnQuery = 'SELECT ...'
    let retquery = mysql.format(returnQuery,[datum, mitarbeiter_id]);
    pool.query(retquery,(err, data) => {
        if(err) {
            console.error(err);
            return err
        }

        return data
    });
}

async function insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit){

    let selectQuery = 'INSERT INTO ...';
    let query = mysql.format(selectQuery,[taetigkeit, projekt_id, mitarbeiter_id, zeit_von, zeit_bis, stunden, datum]);
    pool.query(query,(err) => {
        if(err) {
            console.error(err);
        }
    });
    if(taetigkeit == 15){
        let updateQuery = "UPDATE ..."
        let query2 = mysql.format(updateQuery, [mitarbeiter_id])
        pool.query(query2,(err, data) => {
        if(err) {
            console.error(err);
        }
        });
    }
}

async function run_insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit){
    await insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit)
    const jsret = await select_time(datum, mitarbeiter_id)
    return jsret
}

app.get('/insertTime', (req, res) => {
    const datum = req.query.datum;
    const mitarbeiter_id = req.query.mitarbeiter_id;
    let projekt_id = req.query.projekt_id;
    let zeit_von = req.query.zeit_von;
    let zeit_bis = req.query.zeit_bis;
    const stunden = req.query.stunden;
    const taetigkeit = req.query.taetigkeit;

    const js = run_insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit)

    res.json(js)
 })
</code>```

答:
If pool.query does not have a similar function with Promise support then you need to wrap all such calls into promises to be able to wait for results and return them outside if you want.

async function select_time(datum, mitarbeiter_id){
    let returnQuery = 'SELECT ...'
    let retquery = mysql.format(returnQuery,[datum, mitarbeiter_id]);
    return new Promise((resolve, reject) => {
      pool.query(retquery,(err, data) => {
          if(err) {
              console.error(err);
              reject(err);
          }

          resolve(data);
      });
    });
}
```

Look at this answer to find out more about how to convert functions with callbacks into promise-like functions.

Body:
I want to make a SQL Insert and after that a Select with the complete List to show in Vue inclusive the new entry. But the Select is faster than the Insert and does only return the old values which are already in the Table. I tried with setTimeout and Async-Await. (SQL Statements are working)

Can someone help me i am new into JS.

async function select_time(datum, mitarbeiter_id){
    let returnQuery = 'SELECT ...'
    let retquery = mysql.format(returnQuery,[datum, mitarbeiter_id]);
    pool.query(retquery,(err, data) => {
        if(err) {
            console.error(err);
            return err
        }

        return data
    });
}

async function insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit){

    let selectQuery = 'INSERT INTO ...';
    let query = mysql.format(selectQuery,[taetigkeit, projekt_id, mitarbeiter_id, zeit_von, zeit_bis, stunden, datum]);
    pool.query(query,(err) => {
        if(err) {
            console.error(err);
        }
    });
    if(taetigkeit == 15){
        let updateQuery = "UPDATE ..."
        let query2 = mysql.format(updateQuery, [mitarbeiter_id])
        pool.query(query2,(err, data) => {
        if(err) {
            console.error(err);
        }
        });
    }
}

async function run_insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit){
    await insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit)
    const jsret = await select_time(datum, mitarbeiter_id)
    return jsret
}

app.get('/insertTime', (req, res) => {
    const datum = req.query.datum;
    const mitarbeiter_id = req.query.mitarbeiter_id;
    let projekt_id = req.query.projekt_id;
    let zeit_von = req.query.zeit_von;
    let zeit_bis = req.query.zeit_bis;
    const stunden = req.query.stunden;
    const taetigkeit = req.query.taetigkeit;

    const js = run_insert_time(datum, mitarbeiter_id, projekt_id, zeit_von, zeit_bis, stunden, taetigkeit)

    res.json(js)
 })

Body:
If pool.query does not have a similar function with Promise support then you need to wrap all such calls into promises to be able to wait for results and return them outside if you want.

async function select_time(datum, mitarbeiter_id){
    let returnQuery = 'SELECT ...'
    let retquery = mysql.format(returnQuery,[datum, mitarbeiter_id]);
    return new Promise((resolve, reject) => {
      pool.query(retquery,(err, data) => {
          if(err) {
              console.error(err);
              reject(err);
          }

          resolve(data);
      });
    });
}

Look at this answer to find out more about how to convert functions with callbacks into promise-like functions.


问:
How to show, edit or delete widget/property of widget in ListView.builder when a specific item widget is pressed on flutter?
I have made a custom widget that fetches the data from the API and displays it using ListView.builder method in flutter. ListView.builder returns a widget, so I have made custom widget 'menuLoadedList' that is returned by ListView.builder to display the data from the API. Inside this custom 'menuLoadedList' widget there are many widget, to display number, to display item name and GestureDetector widget to detect user tap, onTap(). Activity looks like this:
ListView.builder displaying data from the API

I have only designed this one list ListView design, which is used by listview.builder method to display all the data in the database.

```<code>child: FutureBuilder(
            future: _thisMenu(),
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              if (snapshot.hasData) {
                // load the data here to display it in the list view
                print("Data is here");
                return ListView.builder(
                  padding: const EdgeInsets.only(bottom: 50),
                  itemCount: snapshot.data.menus.length,
                  itemBuilder: (context, index) {
                    Menu menuu = snapshot.data;
                    MenuElement menuItem = menuu.menus[index];
                    return menuLoadedList(menuItem, index);
                  },
                );
              }

              ///when the API cannot fetch the data properly
              /// should design some error handling mechanism, custom widget to displau "Oops! Something went wrong" with a image
              else if (snapshot.hasError) {
                return Text("${snapshot.error}");
              }

              /// when the data is still loading, for loading screen
              else {
                print("we are still loading");
                return ListView.builder(
                  itemCount: 6,
                  itemBuilder: (context, index) {
                    return menuListShimmer();
                  },
                );
              }
            },
          ),
</code>```

And the custom widget to display the data is implemented with: -

```<code> Widget menuLoadedList(MenuElement menuItem, int index) {
return DefaultTextStyle(
  style: const TextStyle(color: Colors.white, fontSize: 16.0),
  child: Column(
    children: <Widget>[
      Container(
        padding: const EdgeInsets.all(4.0),
        //column for the list view to display menu name, price and displying button to add, remove and show the quantity of the order
        child: Column(
          children: <Widget>[
            //first row shows the menu name and price
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                // shows the menu name
                Expanded(
                  child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(menuItem.name),
                  ),
                ),
                //show the menu price
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text("Rs. " + menuItem.price.toString()),
                ),
              ],
            ),
            //second row shows the add, remove and show the quantity of the order
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                //first button shows the add button
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: GestureDetector(
                    // when the users taps the minus button
                    onTap: () {
                      print(index);
                      _addItemToOder(false, index, "Spicy", 5);
                    },
                    child: const Icon(
                      Icons.remove_circle,
                      color: Colors.white,
                    ),
                  ),
                ),
                Text("$counter"), // this needs to be updated
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: GestureDetector(
                    onTap: () {
                      print(index);
                      _addItemToOder(true, index, "Spicy", 5);
                      setState(() {

                      });
                    },
                    child: const Icon(
                      Icons.add_circle,
                      color: Colors.white,
                    ),
                  ),
                ),
              ],
            ),
            Visibility(
              child: Container(
                // height: 30,
                margin: const EdgeInsets.all(2.0),
                child: const TextField(
                  autofocus: false,
                  style: TextStyle(color: Colors.white, fontSize: 12.0),
                  //defines the charcter of test field for the remarks textfield
                  decoration: InputDecoration(
                    isDense: true,
                    contentPadding: EdgeInsets.all(8),
                    enabledBorder: OutlineInputBorder(
                      borderSide:
                          BorderSide(color: Colors.blue, width: 2.0),
                    ),
                    focusedBorder: OutlineInputBorder(
                      borderSide:
                          BorderSide(color: Colors.green, width: 2.0),
                    ),
                    hintText: "Add your remarks",
                    hintStyle: TextStyle(
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
              visible: showRemarksField,
            ),
          ],
        ),
      ),
    ],
  ),
);
</code>```

}

On the custom widget implementation there is Text widget with comment this need to be updated. When the app is called upon with onTap method, how to update the Text widget of that particular Listview.builder item only out of many other.

My question is:- When I press the plus or minus button in any of the widget item within the custom widget, how can I update only the Text widget its property/value within that custom widget in the listview.builder ? How can I keep the track of the button of the list item in the listview.builder that I have pressed and update the text widget within that list item only?

Note:- When I press any one plus or minus button in the list every text value is updated. I cannot change any specific text widget within custom widget.

答: Add 'counter' property into MenuElement when call setState it still values edit</p>

Body:
I have made a custom widget that fetches the data from the API and displays it using ListView.builder method in flutter. ListView.builder returns a widget, so I have made custom widget 'menuLoadedList' that is returned by ListView.builder to display the data from the API. Inside this custom 'menuLoadedList' widget there are many widget, to display number, to display item name and GestureDetector widget to detect user tap, onTap(). Activity looks like this:
ListView.builder displaying data from the API

I have only designed this one list ListView design, which is used by listview.builder method to display all the data in the database.

child: FutureBuilder(
            future: _thisMenu(),
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              if (snapshot.hasData) {
                // load the data here to display it in the list view
                print("Data is here");
                return ListView.builder(
                  padding: const EdgeInsets.only(bottom: 50),
                  itemCount: snapshot.data.menus.length,
                  itemBuilder: (context, index) {
                    Menu menuu = snapshot.data;
                    MenuElement menuItem = menuu.menus[index];
                    return menuLoadedList(menuItem, index);
                  },
                );
              }

              ///when the API cannot fetch the data properly
              /// should design some error handling mechanism, custom widget to displau "Oops! Something went wrong" with a image
              else if (snapshot.hasError) {
                return Text("${snapshot.error}");
              }

              /// when the data is still loading, for loading screen
              else {
                print("we are still loading");
                return ListView.builder(
                  itemCount: 6,
                  itemBuilder: (context, index) {
                    return menuListShimmer();
                  },
                );
              }
            },
          ),

And the custom widget to display the data is implemented with: -

 Widget menuLoadedList(MenuElement menuItem, int index) {
return DefaultTextStyle(
  style: const TextStyle(color: Colors.white, fontSize: 16.0),
  child: Column(
    children: <Widget>[
      Container(
        padding: const EdgeInsets.all(4.0),
        //column for the list view to display menu name, price and displying button to add, remove and show the quantity of the order
        child: Column(
          children: <Widget>[
            //first row shows the menu name and price
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                // shows the menu name
                Expanded(
                  child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(menuItem.name),
                  ),
                ),
                //show the menu price
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text("Rs. " + menuItem.price.toString()),
                ),
              ],
            ),
            //second row shows the add, remove and show the quantity of the order
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                //first button shows the add button
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: GestureDetector(
                    // when the users taps the minus button
                    onTap: () {
                      print(index);
                      _addItemToOder(false, index, "Spicy", 5);
                    },
                    child: const Icon(
                      Icons.remove_circle,
                      color: Colors.white,
                    ),
                  ),
                ),
                Text("$counter"), // this needs to be updated
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: GestureDetector(
                    onTap: () {
                      print(index);
                      _addItemToOder(true, index, "Spicy", 5);
                      setState(() {

                      });
                    },
                    child: const Icon(
                      Icons.add_circle,
                      color: Colors.white,
                    ),
                  ),
                ),
              ],
            ),
            Visibility(
              child: Container(
                // height: 30,
                margin: const EdgeInsets.all(2.0),
                child: const TextField(
                  autofocus: false,
                  style: TextStyle(color: Colors.white, fontSize: 12.0),
                  //defines the charcter of test field for the remarks textfield
                  decoration: InputDecoration(
                    isDense: true,
                    contentPadding: EdgeInsets.all(8),
                    enabledBorder: OutlineInputBorder(
                      borderSide:
                          BorderSide(color: Colors.blue, width: 2.0),
                    ),
                    focusedBorder: OutlineInputBorder(
                      borderSide:
                          BorderSide(color: Colors.green, width: 2.0),
                    ),
                    hintText: "Add your remarks",
                    hintStyle: TextStyle(
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
              visible: showRemarksField,
            ),
          ],
        ),
      ),
    ],
  ),
);

}

On the custom widget implementation there is Text widget with comment this need to be updated. When the app is called upon with onTap method, how to update the Text widget of that particular Listview.builder item only out of many other.

My question is:- When I press the plus or minus button in any of the widget item within the custom widget, how can I update only the Text widget its property/value within that custom widget in the listview.builder ? How can I keep the track of the button of the list item in the listview.builder that I have pressed and update the text widget within that list item only?

Note:- When I press any one plus or minus button in the list every text value is updated. I cannot change any specific text widget within custom widget.


问:
take data from edit text in kotlin
I have some edittext boxes (input type = phone) in a fragment. I need to get the value from them and store them in a variable called totalincome and pass this value to another fragment which has a textview. how to do this in the kotlin way. I'm a beginner.

is this the right way
etincome.toString().toInt()

答:
in java and kotlin

```<code>editText.getText().toString()
</code>```

kotlin

```<code>editText.text.toString()

</code>```

Title: take data from edit text in kotlin

Body:
in java and kotlin

editText.getText().toString()

kotlin

editText.text.toString()


问:
Menu item not showing titles in android
I am currently adding the sorting functionality to my food app. But my app didn't show the menu items instead it shows a blank white menu.Any ways to resolve this problem?

```<code><?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">

        <item
            android:id="@+id/sortName"
            android:title="Name" />

        <item
            android:id="@+id/sortRating"
            android:title="Rating" />

        <item
            android:id="@+id/sortCostAsc"
            android:title="Cost (low to high)" />

        <item
            android:id="@+id/sortCostDesc"
            android:title="Cost (high to low)" />

    </group>
</menu>
</code>```

This is my menu layout.

```<code><resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.FoodSpot" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/primary_violet</item>
        <item name="colorPrimaryVariant">@color/secondary_violet</item>
        <item name="colorOnPrimary">@color/black</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
        <item name="android:actionMenuTextColor">@color/black</item>
    </style>

    <style name="ThemeOverlay.AppCompat.navTheme">
        <!-- Color of text and icon when SELECTED -->
        <item name="colorPrimary">@color/secondary_violet</item>
        <!-- Background color when SELECTED -->
        <item name="colorControlHighlight">@color/secondary_violet</item>
    </style>
</resources>
</code>```

This is my themes.xml . Based on some suggestion I've changed my colorOnPrimary and actionMenuTextColor. But Still same problem.

```<code>override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
        inflater.inflate(R.menu.sort_menu,menu)
    }
</code>```

Here, I inflate the menu layout.

```<code>setHasOptionsMenu(true)
</code>```

And, also I added this inside my Oncreateview method of the fragment to enable the menu in the toolbar.

I've added the screenshot of my app here..

答:
<item name="colorOnPrimary">@color/white</item>

change this this causes the white color in your menu

Title: Menu item not showing titles in android

Body:
I am currently adding the sorting functionality to my food app. But my app didn't show the menu items instead it shows a blank white menu.Any ways to resolve this problem?

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">

        <item
            android:id="@+id/sortName"
            android:title="Name" />

        <item
            android:id="@+id/sortRating"
            android:title="Rating" />

        <item
            android:id="@+id/sortCostAsc"
            android:title="Cost (low to high)" />

        <item
            android:id="@+id/sortCostDesc"
            android:title="Cost (high to low)" />

    </group>
</menu>

This is my menu layout.

<resources xmlns:tools="http://schemas.android.com/tools">

</resources>

This is my themes.xml . Based on some suggestion I've changed my colorOnPrimary and actionMenuTextColor. But Still same problem.

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
        inflater.inflate(R.menu.sort_menu,menu)
    }

Here, I inflate the menu layout.

setHasOptionsMenu(true)

And, also I added this inside my Oncreateview method of the fragment to enable the menu in the toolbar.

I've added the screenshot of my app here..


问:
Send many mail problem
I'm creating newsletter in asp.net. I'm sending to 2000 email recipients. This operation iterate every mail and send using SMTP mail. Please see my previous question .My server use hmailserver.

My problem is

Sometimes this error shown:  Mailbox unavailable. The server response was: 5.1.1  Recipient address rejected: User unknown in relay recipient table

or

Mailbox unavailable. The server response was: Unknown user Mailbox unavailable. The server response was: Unknown user

答: You should send mail to each recipient separately. But instead of using Send method use SendAsync method. You can hook SendCompleted so you know which recepient passed a which failed.</p>

ContentLicense: CC BY-SA 2.5

Title: Send many mail problem


问:
How to find the first incident of any signature in a list/array within an email?
I want to give credit to an agent, if they're the one that sent the message, but only if their signature is at the top of the email.

Here is what I have. The search order is off. The code searches for one name at a time, and clear through the document. I need it to search for All names, the first one that hits in the body of the email.

```<code>Sub CountOccurences_SpecificText_In_Folder()
    Dim MailItem As Outlook.MailItem
    Dim strSpecificText As String
    Dim tmpStr As String
    Dim x As Integer
    Dim Count As Integer

    Dim HunterCnt As Integer
    Dim SunmolaCnt As Integer
    Dim RodriguezCnt As Integer
    Dim MammedatyCnt As Integer
    Dim MitchellCnt As Integer
    Dim TannerCnt As Integer
    Dim TAYLORCnt As Integer
    Dim WilsonCnt As Integer
    Dim WilliamsCnt As Integer
    Dim GrooverCnt As Integer
    Dim TyreeCnt As Integer
    Dim ChapmanCnt As Integer
    Dim LukerCnt As Integer
    Dim KlinedinstCnt As Integer
    Dim HicksCnt As Integer
    Dim NATHANIALCnt As Integer
    Dim SkinnerCnt As Integer
    Dim SimonsCnt As Integer

    Dim AgentNames(14) As Variant
    AgentNames(0) = "Simons"
    AgentNames(1) = "Skinner"
    AgentNames(2) = "Mammedaty"
    AgentNames(3) = "Hunter"
    AgentNames(4) = "Sunmola"
    AgentNames(5) = "Rodriguez"
    AgentNames(6) = "Mitchell"
    AgentNames(7) = "Tanner"
    AgentNames(8) = "Taylor"
    AgentNames(9) = "Wilson"
    AgentNames(10) = "Williams"
    AgentNames(11) = "Groover"
    AgentNames(12) = "Tyree"
    AgentNames(13) = "Chapman"
    AgentNames(14) = "Luker"

x = 0
While x < ActiveExplorer.Selection.Count

    x = x + 1
    Set MailItem = ActiveExplorer.Selection.item(x)
        tmpStr = MailItem.Body

    For Each Agent In AgentNames
        If InStr(tmpStr, Agent) <> 0 Then
           If Agent = "Assunta" Then
              HunterCnt = HunterCnt + 1
              GoTo skip
           End If
           If Agent = "Sunmola" Then
              SunmolaCnt = SunmolaCnt + 1
              GoTo skip
           End If
           If Agent = "Rodriguez" Then
              RodriguezCnt = RodriguezCnt + 1
              GoTo skip
           End If

           If Agent = "Mammedaty" Then
              MammedatyCnt = MammedatyCnt + 1
              GoTo skip
           End If

           If Agent = "Mitchell" Then
              MitchellCnt = MitchellCnt + 1
              GoTo skip
           End If

           If Agent = "Tanner" Then
              TannerCnt = TannerCnt + 1
              GoTo skip
           End If

           If Agent = "Taylor" Then
              TAYLORCnt = TAYLORCnt + 1
              GoTo skip
           End If

           If Agent = "Wilson" Then
              WilsonCnt = WilsonCnt + 1
              GoTo skip
           End If

           If Agent = "Williams" Then
              WilliamsCnt = WilliamsCnt + 1
              GoTo skip
           End If

           If Agent = "Groover" Then
              GrooverCnt = GrooverCnt + 1
              GoTo skip
           End If

           If Agent = "Tyree" Then
              TyreeCnt = TyreeCnt + 1
              GoTo skip
           End If

           If Agent = "Chapman" Then
              ChapmanCnt = ChapmanCnt + 1
              GoTo skip
           End If

           If Agent = "Luker" Then
              LukerCnt = LukerCnt + 1
              GoTo skip
           End If

           If Agent = "Hicks" Then
              HicksCnt = HicksCnt + 1
              GoTo skip
           End If

        End If
    Next
 skip:
    Count = Count + 1
    Wend
    MsgBox "Found " & vbCrLf & "Hunter Count: " & HunterCnt & vbCrLf & "Sunmola Count: " & SunmolaCnt & vbCrLf & "Rodriguez Count: " & RodriguezCnt & vbCrLf & "Mammedaty Count: " & MammedatyCnt & vbCrLf & "Mitchell Count: " & MitchellCnt & vbCrLf & "Tanner Count: " & TannerCnt & vbCrLf & "Taylor Count: " & TAYLORCnt & vbCrLf & "Wilson Count: " & WilsonCnt & vbCrLf & "Williams Count: " & WilliamsCnt & vbCrLf & "Groover Count: " & GrooverCnt & vbCrLf & "Tyree Count: " & TyreeCnt & vbCrLf & "Chapman Count: " & ChapmanCnt & vbCrLf & "Luker Count: " & LukerCnt & vbCrLf & " in: " & Count & " emails"

End Sub
</code>```

答:
The idea in the previous answer may be better implemented like this:

Option Explicit

Sub CountOccurences_SpecificText_SelectedItems()

    Dim objItem As Object
    Dim objMail As MailItem

    Dim i As Long
    Dim j As Long

    Dim x As Long
    Dim position As Long
    Dim First As Long

    Dim AgentNames() As String
    AgentNames = Split("Simons,Skinner,Mammedaty,Hunter,Sunmola,Rodriguez,Mitchell,Tanner,Taylor,Wilson,Williams,Groover,Tyree,Chapman,Luker", ",")

    ReDim AgentCount(LBound(AgentNames) To UBound(AgentNames)) As Long

    For j = 1 To ActiveExplorer.Selection.Count

        Set objItem = ActiveExplorer.Selection(j)

        ' Verify before attempting to return mailitem poroperties
        If TypeOf objItem Is MailItem Then

            Set objMail = objItem
            Debug.Print
            Debug.Print "objMail.Subject: " & objMail.Subject

            x = Len(objMail.Body)

            For i = LBound(AgentNames) To UBound(AgentNames)

                Debug.Print
                Debug.Print "AgentNames(i): " & AgentNames(i)
                position = InStr(objMail.Body, AgentNames(i))
                Debug.Print "       position: " & position

                If position > 0 Then
                    If position < x Then
                        x = position
                        First = i
                    End If
                End If

                Debug.Print "Lowest position: " & x
                Debug.Print "  Current first: " & AgentNames(First)

            Next i

            If x < Len(objMail.Body) Then

                AgentCount(First) = AgentCount(First) + 1
                Debug.Print
                Debug.Print AgentNames(First) & " was found first"

            Else
                Debug.Print "No agent found."

            End If

        End If
    Next

    For i = LBound(AgentNames) To UBound(AgentNames)
        Debug.Print AgentNames(i) & " Count: " & AgentCount(i)
    Next i

End Sub
```

Body:
I want to give credit to an agent, if they're the one that sent the message, but only if their signature is at the top of the email.

Here is what I have. The search order is off. The code searches for one name at a time, and clear through the document. I need it to search for All names, the first one that hits in the body of the email.

Sub CountOccurences_SpecificText_In_Folder()
    Dim MailItem As Outlook.MailItem
    Dim strSpecificText As String
    Dim tmpStr As String
    Dim x As Integer
    Dim Count As Integer

    Dim HunterCnt As Integer
    Dim SunmolaCnt As Integer
    Dim RodriguezCnt As Integer
    Dim MammedatyCnt As Integer
    Dim MitchellCnt As Integer
    Dim TannerCnt As Integer
    Dim TAYLORCnt As Integer
    Dim WilsonCnt As Integer
    Dim WilliamsCnt As Integer
    Dim GrooverCnt As Integer
    Dim TyreeCnt As Integer
    Dim ChapmanCnt As Integer
    Dim LukerCnt As Integer
    Dim KlinedinstCnt As Integer
    Dim HicksCnt As Integer
    Dim NATHANIALCnt As Integer
    Dim SkinnerCnt As Integer
    Dim SimonsCnt As Integer

    Dim AgentNames(14) As Variant
    AgentNames(0) = "Simons"
    AgentNames(1) = "Skinner"
    AgentNames(2) = "Mammedaty"
    AgentNames(3) = "Hunter"
    AgentNames(4) = "Sunmola"
    AgentNames(5) = "Rodriguez"
    AgentNames(6) = "Mitchell"
    AgentNames(7) = "Tanner"
    AgentNames(8) = "Taylor"
    AgentNames(9) = "Wilson"
    AgentNames(10) = "Williams"
    AgentNames(11) = "Groover"
    AgentNames(12) = "Tyree"
    AgentNames(13) = "Chapman"
    AgentNames(14) = "Luker"

x = 0
While x < ActiveExplorer.Selection.Count

    x = x + 1
    Set MailItem = ActiveExplorer.Selection.item(x)
        tmpStr = MailItem.Body

    For Each Agent In AgentNames
        If InStr(tmpStr, Agent) <> 0 Then
           If Agent = "Assunta" Then
              HunterCnt = HunterCnt + 1
              GoTo skip
           End If
           If Agent = "Sunmola" Then
              SunmolaCnt = SunmolaCnt + 1
              GoTo skip
           End If
           If Agent = "Rodriguez" Then
              RodriguezCnt = RodriguezCnt + 1
              GoTo skip
           End If

           If Agent = "Mammedaty" Then
              MammedatyCnt = MammedatyCnt + 1
              GoTo skip
           End If

           If Agent = "Mitchell" Then
              MitchellCnt = MitchellCnt + 1
              GoTo skip
           End If

           If Agent = "Tanner" Then
              TannerCnt = TannerCnt + 1
              GoTo skip
           End If

           If Agent = "Taylor" Then
              TAYLORCnt = TAYLORCnt + 1
              GoTo skip
           End If

           If Agent = "Wilson" Then
              WilsonCnt = WilsonCnt + 1
              GoTo skip
           End If

           If Agent = "Williams" Then
              WilliamsCnt = WilliamsCnt + 1
              GoTo skip
           End If

           If Agent = "Groover" Then
              GrooverCnt = GrooverCnt + 1
              GoTo skip
           End If

           If Agent = "Tyree" Then
              TyreeCnt = TyreeCnt + 1
              GoTo skip
           End If

           If Agent = "Chapman" Then
              ChapmanCnt = ChapmanCnt + 1
              GoTo skip
           End If

           If Agent = "Luker" Then
              LukerCnt = LukerCnt + 1
              GoTo skip
           End If

           If Agent = "Hicks" Then
              HicksCnt = HicksCnt + 1
              GoTo skip
           End If

        End If
    Next
 skip:
    Count = Count + 1
    Wend
    MsgBox "Found " & vbCrLf & "Hunter Count: " & HunterCnt & vbCrLf & "Sunmola Count: " & SunmolaCnt & vbCrLf & "Rodriguez Count: " & RodriguezCnt & vbCrLf & "Mammedaty Count: " & MammedatyCnt & vbCrLf & "Mitchell Count: " & MitchellCnt & vbCrLf & "Tanner Count: " & TannerCnt & vbCrLf & "Taylor Count: " & TAYLORCnt & vbCrLf & "Wilson Count: " & WilsonCnt & vbCrLf & "Williams Count: " & WilliamsCnt & vbCrLf & "Groover Count: " & GrooverCnt & vbCrLf & "Tyree Count: " & TyreeCnt & vbCrLf & "Chapman Count: " & ChapmanCnt & vbCrLf & "Luker Count: " & LukerCnt & vbCrLf & " in: " & Count & " emails"

End Sub