问:
Linked Lists Append To Tail
I am trying to create an appendToTail function which will add a node to the end of a singly linked list.

I am having trouble in adding a node if the head is NULL(the linked list is empty)

```<code>class Node {
private:
    Node* next;
    int data;

public:
    Node(int d, Node* n = NULL)
        : data(d)
        , next(n)
    {
    }
    void appendToTail(int);
    //other trivial functions(getters and setters etc. ) defined and
    //declared
};

void Node::appendToTail(int d)
{
    Node* end = new Node(d);

    Node* n = this;

    if (n == NULL)
        n = end;

    else {
        while (n->next != NULL)
            n = n->next;
        n->next = end;
        n->next->next = NULL;
    }

    end = NULL;
    delete end;
}

int main()
{
    Node* n = NULL;
    n->appendToTail(5);
    std::cout << n->getData(); //getData() is a function which
    //retrieves the Data member variable
}
</code>```

I am expecting to get 5 but I am getting an error which appears to be caused because my node remains null.

答:
Now with modern C++ idioms we use smart pointers instead of raw pointers, it gives you the benefit of RAII (Resource acquisition is initialization) mechanism. In addition if you want an elegant solution to your problem you should introduce a List class with which you can express more clearly the concept of an empty list. It would give something like this:

```<code>#include <memory>
#include <iostream>

class List
{
public:
    class Node
    {
    private:
        std::shared_ptr<Node> next;
        int data;
    public:
        Node(int d):next(nullptr),data(d){}
        inline int getData() const {return data;}
        inline std::shared_ptr<Node> getNext() const {return next;}

        friend List;
    };
    List():head(nullptr),tail(nullptr){}

    void appendToTail(int );

    inline std::shared_ptr<Node> getHead() const {return head;}
    inline std::shared_ptr<Node> getTail() const {return tail;}
private:
    std::shared_ptr<Node>   head;
    std::shared_ptr<Node>   tail;
};

void List::appendToTail(int d)
{
    auto newTail = std::make_shared<Node>(d);

    if (head == nullptr)
    {
        head = tail = newTail;
    }
    else
    {
        tail->next = newTail;
        tail = newTail;
    }
}

int main()
{
    List    l;
    l.appendToTail(5);
    std::cout<<l.getHead()->getData();
}
</code>```

But you should definitely prefer std::list<T> or std::vector<T>.

Title: Linked Lists Append To Tail

Body:
I am trying to create an appendToTail function which will add a node to the end of a singly linked list.

I am having trouble in adding a node if the head is NULL(the linked list is empty)

class Node {
private:
    Node* next;
    int data;

public:
    Node(int d, Node* n = NULL)
        : data(d)
        , next(n)
    {
    }
    void appendToTail(int);
    //other trivial functions(getters and setters etc. ) defined and
    //declared
};

void Node::appendToTail(int d)
{
    Node* end = new Node(d);

    Node* n = this;

    if (n == NULL)
        n = end;

    else {
        while (n->next != NULL)
            n = n->next;
        n->next = end;
        n->next->next = NULL;
    }

    end = NULL;
    delete end;
}

int main()
{
    Node* n = NULL;
    n->appendToTail(5);
    std::cout << n->getData(); //getData() is a function which
    //retrieves the Data member variable
}

I am expecting to get 5 but I am getting an error which appears to be caused because my node remains null.

Body:
Now with modern C++ idioms we use smart pointers instead of raw pointers, it gives you the benefit of RAII (Resource acquisition is initialization) mechanism. In addition if you want an elegant solution to your problem you should introduce a List class with which you can express more clearly the concept of an empty list. It would give something like this:

#include <memory>
#include <iostream>

class List
{
public:
    class Node
    {
    private:
        std::shared_ptr<Node> next;
        int data;
    public:
        Node(int d):next(nullptr),data(d){}
        inline int getData() const {return data;}
        inline std::shared_ptr<Node> getNext() const {return next;}

        friend List;
    };
    List():head(nullptr),tail(nullptr){}

    void appendToTail(int );

    inline std::shared_ptr<Node> getHead() const {return head;}
    inline std::shared_ptr<Node> getTail() const {return tail;}
private:
    std::shared_ptr<Node>   head;
    std::shared_ptr<Node>   tail;
};

void List::appendToTail(int d)
{
    auto newTail = std::make_shared<Node>(d);

    if (head == nullptr)
    {
        head = tail = newTail;
    }
    else
    {
        tail->next = newTail;
        tail = newTail;
    }
}

int main()
{
    List    l;
    l.appendToTail(5);
    std::cout<<l.getHead()->getData();
}

But you should definitely prefer std::list<T> or std::vector<T>.


来源: stackexchange

问:
Responsive boxes in HTML Email
I use ActiveCampaign to send my emails, and recently I started building HTML emails to have better control of the situation.

ActiveCampaign automatically sets tables, so I don't need to worry about it, as it conforms a standard HTML to an email HTML.

I should have a responsive row with columns that wrap themselves once the user views the email on a mobile phone.

I'm trying to build some columns inside the email, I tried with flexbox but it constantly giving me errors in Gmail. I even tried with  but it does not wrap content.

Here you can find the full code.
I highlighted the part where I have issues.

.divmain {
  margin: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0 7px 0px #b5b5b5;
  -webkit-box-shadow: 0px 0 7px 0px #b5b5b5;
  box-shadow: 0px 0 7px 0px #b5b5b5;
}

.divp {
  background-image: url("http://i67.tinypic.com/jhzs0g.png"), linear-gradient(90deg, #FD8571, #EEBD7C);
  background-size: cover;
  background-position: bottom;
  background-repeat: no-repeat;
  width: auto;
  border-radius: 5px 5px 0px 0px;
  padding-left: 5%;
  padding-right: 5%;
  padding-top: 7%;
  padding-bottom: 7%;
  margin-bottom: 0;
  text-align: center;
}

.divs {
  background-image: url("http://i66.tinypic.com/350w10h.png"), linear-gradient(90deg, #7172fd, #bc7cee);
  background-size: cover;
  background-position: bottom;
  background-repeat: no-repeat;
  width: auto;
  border-radius: 0px 0px 5px 5px;
  padding-left: 5%;
  padding-right: 5%;
  padding-top: 7%;
  padding-bottom: 7%;
  margin-bottom: 0;
  text-align: center;
}

.divw {
  width: auto;
  padding-left: 7%;
  padding-top: 5%;
  padding-bottom: 1%;
  padding-right: 27%;
  text-align: left;
  border-style: solid;
  border-width: 0px 1px 0px 1px;
  border-color: #cecece;
  margin: 0;
}

.row {
  display: flex;
  justify-content: center;
  flex-flow: row wrap;
}

.column {
  flex: 33.33%;
  padding-left: 5%;
  padding-right: 5%;
  margin-bottom: 5%;
  margin-left: auto;
  margin-right: auto;
}

.columnbox {
  width: auto;
  border-radius: 8px;
  padding: 5%;
  text-align: center;
  border-style: solid;
  border-width: 1px;
  border-color: #cecece;
  -moz-box-shadow: 0px 0 7px 0px #b5b5b5;
  -webkit-box-shadow: 0px 0 7px 0px #b5b5b5;
  box-shadow: 0px 0 7px 0px #b5b5b5;
}

.row::after {
  content: "";
  clear: both;
  display: table;
}

.border-div {
  border-style: solid;
  border-width: 0px 1px 0px 1px;
  border-color: #cecece;
  border-radius: 0 0 3px 3px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>

<head>
</head>

<body>

  <div class="divmain">

    <div class="divp">

      <h1 style="color:white; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em">Sei della Famiglia adesso!</h1>

      <p style="font-size: 1.4em; color: white; line-height: 150%;  font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-top: 0; padding-top: 0">Moover non è un semplice servizio,<br> è una fantastica community!
      </p>

      <div class="btn" style="background-color: #4E69C2; text-decoration: none; display: inline-block; border: 3px solid #4E69C2; border-radius: 7px; font-size: 1.4em; padding: 0.3em 1em; -webkit-font-smoothing: antialiased; color: #fff;">Scopri di più ►</div>

    </div>

    <div class="divw">

      <p style="font-size: 1.1em; line-height: 150%; color: #3b3b3b; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif"><b>Oh! Eccoti!</b><br> Volevamo informarti che il servizio di Crescita Organica è stato attivato con successo sul profilo @%USERNAME%
      </p>

      <p style="font-size: 1.1em; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em;"><b>Il periodo di Prova Gratuita durerà 7 giorni!</b>
      </p>

      <p style="font-size: 1em; line-height: 150%; color: #3b3b3b; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-top: 0; padding-top: 0;">(Goditeli fino in fondo!)
      </p>

    </div>

    <!-- Here is where I have some problems -->

    <p class="border-div" style="margin: 0; text-align: center; font-size: 1.2em; line-height: 150%; color: #3b3b3b; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; font-weight: bold; padding-bottom: 1em; padding-top: 1em; ">Questi sono alcuni dati attuali del tuo account</p>

    <div class="row border-div desktop-view" style="padding-top: 1em; padding-right: 5%; padding-bottom: 3em; padding-left: 5%;">

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Follower Attuali</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Likes Attuali</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Commenti Attuali</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Engagement Rate</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

    </div>

    <!-- Here is where my problems finishes -->

    <div class="divs">

      <h1 style="color:white; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em">Entra nell'Area Personale!</h1>

      <p style="font-size: 1.4em; color: white; line-height: 150%;  font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-top: 0; padding-top: 0">Visita la tua Area personale cliccando qui.<br> Potrai tenere traccia dei tuoi risultati!
      </p>

      <div class="btn" style="background-color: #4E69C2; text-decoration: none; display: inline-block; border: 3px solid #4E69C2; border-radius: 7px; font-size: 1.4em; padding: 0.3em 1em; -webkit-font-smoothing: antialiased; color: #fff;">Visita la tua Area ►</div>

    </div>

  </div>

</body>

</html></code>```

The result should be a responsive row that, on the desktop has 4 columns aligned in a unique row. In mobile, it should be a vertical row like in the screenshot below:

Unfortunately, this is not the result that I have, and I absolutely need some help, because in Gmail App from Mobile Phone this is what I got:

答:
A few points:

Don't use flexbox in email unless you are confident with email coding in general. I've tweaked some of your code (expanding the flex:#%; to flex:0 0 #%; and adding a fallback width) and noticed I fixed some things so I don't think the implementation you've taken from front end is working in email clients as you would expect

There are quirks and fixes you need to include for different email
clients that you should be aware of. Google this for help, not sure
of any articles in particular as I haven't bothered trying to shoe
horn Flexbox into my emails. But some have so definitely do some
searching and you'll find some help.

The same goes with using divs in email. It can be done and many use
them but you need to know how to make them work in say Outlook
desktop clients etc. FYI, your email is completely broken in
Outlook, including the latest versions I can see in Litmus which is
Outlook 2019.

You may not need to support Outlook and that is fine, but it's good to know.

Invest in a testing platform. Litmus and Email On Acid being the top tools.

That way you can build and test and ensure your emails are working where they need to.

Overall, just be really cautious with pulling front end techniques into email. They won't all work but there are some in the community who have found ways to make Flexbox, CSS Grid and a few other popular front end techniques, work in email so do some research and you'll have a guide to follow.

Personally, I don't see the need to use up to date techniques like this. Using the good old table structure works for the most part.

Don't get me wrong, I have fun and test out the latest innovations and build stuff for fun but I always go back to the old phrase 'if it ain't broke, don't fix it'.

Email code isn't pretty and it isn't perfect but it works for 99% of designs out there and it's personal preference to implement fancy techniques like Flexbox etc.

And always remember that you want to use a technique that is easy to maintain. You don't want to hit issues like these every single time you try to update. It's time consuming and can be frustrating when you just want to get an email out.

I hope you can find a resolution for this though. Either through someone helping you with your Flexbox implementation, finding blog posts on doing this in email or by starting from scratch with code you're more comfortable with / is better supported and is easier for people to debug for you.

ContentLicense: CC BY-SA 4.0

Title: Responsive boxes in HTML Email

Body:
I use ActiveCampaign to send my emails, and recently I started building HTML emails to have better control of the situation.

ActiveCampaign automatically sets tables, so I don't need to worry about it, as it conforms a standard HTML to an email HTML.

I should have a responsive row with columns that wrap themselves once the user views the email on a mobile phone.

I'm trying to build some columns inside the email, I tried with flexbox but it constantly giving me errors in Gmail. I even tried with  but it does not wrap content.

Here you can find the full code.
I highlighted the part where I have issues.

.divmain {
  margin: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0 7px 0px #b5b5b5;
  -webkit-box-shadow: 0px 0 7px 0px #b5b5b5;
  box-shadow: 0px 0 7px 0px #b5b5b5;
}

.divp {
  background-image: url("http://i67.tinypic.com/jhzs0g.png"), linear-gradient(90deg, #FD8571, #EEBD7C);
  background-size: cover;
  background-position: bottom;
  background-repeat: no-repeat;
  width: auto;
  border-radius: 5px 5px 0px 0px;
  padding-left: 5%;
  padding-right: 5%;
  padding-top: 7%;
  padding-bottom: 7%;
  margin-bottom: 0;
  text-align: center;
}

.divs {
  background-image: url("http://i66.tinypic.com/350w10h.png"), linear-gradient(90deg, #7172fd, #bc7cee);
  background-size: cover;
  background-position: bottom;
  background-repeat: no-repeat;
  width: auto;
  border-radius: 0px 0px 5px 5px;
  padding-left: 5%;
  padding-right: 5%;
  padding-top: 7%;
  padding-bottom: 7%;
  margin-bottom: 0;
  text-align: center;
}

.divw {
  width: auto;
  padding-left: 7%;
  padding-top: 5%;
  padding-bottom: 1%;
  padding-right: 27%;
  text-align: left;
  border-style: solid;
  border-width: 0px 1px 0px 1px;
  border-color: #cecece;
  margin: 0;
}

.row {
  display: flex;
  justify-content: center;
  flex-flow: row wrap;
}

.column {
  flex: 33.33%;
  padding-left: 5%;
  padding-right: 5%;
  margin-bottom: 5%;
  margin-left: auto;
  margin-right: auto;
}

.columnbox {
  width: auto;
  border-radius: 8px;
  padding: 5%;
  text-align: center;
  border-style: solid;
  border-width: 1px;
  border-color: #cecece;
  -moz-box-shadow: 0px 0 7px 0px #b5b5b5;
  -webkit-box-shadow: 0px 0 7px 0px #b5b5b5;
  box-shadow: 0px 0 7px 0px #b5b5b5;
}

.row::after {
  content: "";
  clear: both;
  display: table;
}

.border-div {
  border-style: solid;
  border-width: 0px 1px 0px 1px;
  border-color: #cecece;
  border-radius: 0 0 3px 3px;
}

<!DOCTYPE html>

Sei della Famiglia adesso!

Moover non è un semplice servizio,
 è una fantastica community!

Scopri di più ►

Oh! Eccoti!
 Volevamo informarti che il servizio di Crescita Organica è stato attivato con successo sul profilo @%USERNAME%

Il periodo di Prova Gratuita durerà 7 giorni!

(Goditeli fino in fondo!)

Questi sono alcuni dati attuali del tuo account

Follower Attuali

99.000

Likes Attuali

99.000

Commenti Attuali

99.000

Engagement Rate

99.000

Entra nell'Area Personale!

Visita la tua Area personale cliccando qui.
 Potrai tenere traccia dei tuoi risultati!

Visita la tua Area ►

The result should be a responsive row that, on the desktop has 4 columns aligned in a unique row. In mobile, it should be a vertical row like in the screenshot below:

Unfortunately, this is not the result that I have, and I absolutely need some help, because in Gmail App from Mobile Phone this is what I got:


问:
Why datalist does not work when I make it dynamic (Angular 7)?
I created a function in my .ts file that allows to update a array (empty by default) that I use to create the options of my datalist.

When I inspect the HTML code I see the options in the datalist but they do not show in the GUI

<input list='id-RPG' type="text" pInputText class="inputTextStyle" [(ngModel)]="MyModal" (input)="searchList($event.target.value)"/>
<datalist id='id-RPG'>
 <option *ngFor="let element of array" [(value)]="element ">{{element }}</option>
</datalist>
```

```ngOnInit(){
this.array = [];
}

searchList(){
//Rest Here
this.array = ["aaa","aab","aac","aad"]
}
```

No error message is displayed

答:
I think it's not possible to update the DataList in real time, every time you have to click outside to get the new data ...
I used the old method, I think it's the right way to do this.</p>

```<code><div class="suggestedList" *ngIf="array.length > 0">
 <ul class="UlSugList" *ngFor="let element of array">
  <li class="LiSugList">
   <a (click)="select(element)">{{element}}</a>
  </li>
 </ul>
</div>
</code>```

```<code>select(RPG) {
    this.MyModal = RPG;
    this.array = [];
}
</code>```

Body:
I created a function in my .ts file that allows to update a array (empty by default) that I use to create the options of my datalist.

When I inspect the HTML code I see the options in the datalist but they do not show in the GUI

<input list='id-RPG' type="text" pInputText class="inputTextStyle" [(ngModel)]="MyModal" (input)="searchList($event.target.value)"/>
<datalist id='id-RPG'>
 <option *ngFor="let element of array" [(value)]="element ">{{element }}</option>
</datalist>

ngOnInit(){
this.array = [];
}

searchList(){
//Rest Here
this.array = ["aaa","aab","aac","aad"]
}

No error message is displayed

Body:
I think it's not possible to update the DataList in real time, every time you have to click outside to get the new data ...
I used the old method, I think it's the right way to do this.

<div class="suggestedList" *ngIf="array.length > 0">
 <ul class="UlSugList" *ngFor="let element of array">
  <li class="LiSugList">
   <a (click)="select(element)">{{element}}</a>
  </li>
 </ul>
</div>

select(RPG) {
    this.MyModal = RPG;
    this.array = [];
}


问:
SQL to find almost identical values
I am looking for a sql-query to identify product numbers in a table that is almost identical. The only difference between some of the product numbers is that "/" is replaced with "-", at the exact same position in product number.

Example 1:

```<code>Product number: ab345-2
Product number: ab345/2
</code>```

Example 2:

```<code>Product number: z0059966-98
Product number: z0059966/98
</code>```

Appreciate your help!

答:
You can self join the table to get each pair of duplicates in one row:

```<code>select
  t1.product_number,
  t2.product_number
from tablename t1 inner join tablename t2
on replace(t1.product_number, '-', '/') = t2.product_number
where t1.product_number like '%-%'
</code>```

See the demo.

Results:

```<code>| product_number | product_number |
| -------------- | -------------- |
| ab345-2        | ab345/2        |
| z0059966-98    | z0059966/98    |
</code>```

Title: SQL to find almost identical values

Body:
I am looking for a sql-query to identify product numbers in a table that is almost identical. The only difference between some of the product numbers is that "/" is replaced with "-", at the exact same position in product number.

Example 1:

Product number: ab345-2
Product number: ab345/2

Example 2:

Product number: z0059966-98
Product number: z0059966/98

Appreciate your help!

Body:
You can self join the table to get each pair of duplicates in one row:

select
  t1.product_number,
  t2.product_number
from tablename t1 inner join tablename t2
on replace(t1.product_number, '-', '/') = t2.product_number
where t1.product_number like '%-%'

See the demo.

Results:

| product_number | product_number |
| -------------- | -------------- |
| ab345-2        | ab345/2        |
| z0059966-98    | z0059966/98    |


问:
Getting error during update SQL query single-row subquery returns more than one row
I have 2 tables "HOF" and "WE_GROUP_HOF_K"

In "HOF" table total "2066666" records

In "WE_GROUP_HOF_K" table total "116" records

I have SQL query who find duplicate cnicno column with hofid column from 2 tables "HOF" and "WE_GROUP_HOF_K"

This query found total "120" duplicate cnicno records

QUERY:

```<code>SELECT hofid, cnicno
     FROM hof
    WHERE cnicno IN (SELECT cnic_no FROM we_group_hof_k);
</code>```

In "WE_GROUP_HOF_K" table there are 1 empty column "GROUP_HOF_ID". Now I want to update duplicate records of "HOFID" column into "GROUP_HOF_ID" column

I am getting this error while update records:

```<code>ORA-01427: single-row subquery returns more than one row
</code>```

Update SQL Query:

```<code>UPDATE we_group_hof_k wg
 SET wg.GROUP_HOF_ID =
      (SELECT h.hofid
         FROM hof h
        WHERE h.cnicno = wg.cnic_no);
</code>```

答:
If all CNICNOs share the same HOFID, then use DISTINCT:

```<code>UPDATE we_group_hof_k wg
 SET wg.GROUP_HOF_ID =
      (SELECT DISTINCT h.hofid           --> here
         FROM hof h
        WHERE h.cnicno = wg.cnic_no);
</code>```

If not, which HOFID do you want to take? MIN or MAX would also help, e.g.

```<code>UPDATE we_group_hof_k wg
 SET wg.GROUP_HOF_ID =
      (SELECT MIN(h.hofid)               --> here
         FROM hof h
        WHERE h.cnicno = wg.cnic_no);
</code>```

Body:
I have 2 tables "HOF" and "WE_GROUP_HOF_K"

In "HOF" table total "2066666" records

In "WE_GROUP_HOF_K" table total "116" records

I have SQL query who find duplicate cnicno column with hofid column from 2 tables "HOF" and "WE_GROUP_HOF_K"

This query found total "120" duplicate cnicno records

QUERY:

SELECT hofid, cnicno
     FROM hof
    WHERE cnicno IN (SELECT cnic_no FROM we_group_hof_k);

In "WE_GROUP_HOF_K" table there are 1 empty column "GROUP_HOF_ID". Now I want to update duplicate records of "HOFID" column into "GROUP_HOF_ID" column

I am getting this error while update records:

ORA-01427: single-row subquery returns more than one row

Update SQL Query:

UPDATE we_group_hof_k wg
 SET wg.GROUP_HOF_ID =
      (SELECT h.hofid
         FROM hof h
        WHERE h.cnicno = wg.cnic_no);

Body:
If all CNICNOs share the same HOFID, then use DISTINCT:

UPDATE we_group_hof_k wg
 SET wg.GROUP_HOF_ID =
      (SELECT DISTINCT h.hofid           --> here
         FROM hof h
        WHERE h.cnicno = wg.cnic_no);

If not, which HOFID do you want to take? MIN or MAX would also help, e.g.

UPDATE we_group_hof_k wg
 SET wg.GROUP_HOF_ID =
      (SELECT MIN(h.hofid)               --> here
         FROM hof h
        WHERE h.cnicno = wg.cnic_no);


问:
Controlling on tap text large size in flutter bottom navigation bar
I am using flutter's bottom navigation bar. On tapping the navbar icons, the text get larger. But it's way bit large for me as you can see in the image below.

Flutter Bottom Navigation Bar Image

I want to control the on tap text large size and make it a bit smaller. How can I do that in flutter?

Here's the code:

```<code>import 'package:flutter/material.dart';
import 'package:adminify/pages/PageOne.dart';
import 'package:adminify/pages/PageTwo.dart';
import 'package:adminify/pages/PageThree.dart';
import 'package:adminify/pages/PageFour.dart';
import 'package:adminify/pages/PageFive.dart';

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
  int _currentIndex = 0;

  @override
  void initState() {
    super.initState();
  }

  void navigationTapped(int page) {
    setState(() {
      _currentIndex = page;
    });
  }

  @override
  Widget build(BuildContext context) {
    // this is all pages here in list we can choose index when click bottom navigation bar
    List<Widget> _allPages = [
      PageOne(),
      PageTwo(),
      PageTree(),
      PageFour(),
      PageFive(),
    ];

    return Scaffold(
      body: _allPages[_currentIndex],
      bottomNavigationBar: buildBottomNavigationBar(),
    );
  }

  // Bottom navigation bar area you can choose icons what you want.
  BottomNavigationBar buildBottomNavigationBar() {
    return BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      fixedColor: Colors.red,
      currentIndex: _currentIndex,
      onTap: navigationTapped,
      // iconSize: 28,
      items: [
        BottomNavigationBarItem(
          icon: Icon(Icons.home),
          title: Text(
            "Home",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(
            Icons.explore,
          ),
          title: Text(
            "Admission",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.cloud),
          title: Text(
            "University",
            style: TextStyle(fontWeight: FontWeight.normal),
            overflow: TextOverflow.clip,
            textAlign: TextAlign.center,
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.person),
          title: Text(
            "Favorites",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.verified_user),
          title: Text(
            "Profile",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
      ],
    );
  }
}
</code>```

答:
There is a property selectedFontSize on the BottomNavigationBar.
You can use this one. Simply set the size (interger) to the desired value.

Additionaly; there is also a unselectedFontSize on the BottomNavigationBar, ther you can set all the title-fontsize attonce to the desired size.

```<code>      bottomNavigationBar: BottomNavigationBar(
        currentIndex: index,
        onTap: (int index) {
          setState(() {
            this.index = index;
          });
        },
        backgroundColor: Colors.white,
        type: BottomNavigationBarType.fixed,
        selectedFontSize: 12,
        unselectedFontSize: 12,
        items: [
          BottomNavigationBarItem(
            icon: ClipOval(
              child: Container(
                color:
        omitted ...
</code>```

Body:
I am using flutter's bottom navigation bar. On tapping the navbar icons, the text get larger. But it's way bit large for me as you can see in the image below.

Flutter Bottom Navigation Bar Image

I want to control the on tap text large size and make it a bit smaller. How can I do that in flutter?

Here's the code:

import 'package:flutter/material.dart';
import 'package:adminify/pages/PageOne.dart';
import 'package:adminify/pages/PageTwo.dart';
import 'package:adminify/pages/PageThree.dart';
import 'package:adminify/pages/PageFour.dart';
import 'package:adminify/pages/PageFive.dart';

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
  int _currentIndex = 0;

  @override
  void initState() {
    super.initState();
  }

  void navigationTapped(int page) {
    setState(() {
      _currentIndex = page;
    });
  }

  @override
  Widget build(BuildContext context) {
    // this is all pages here in list we can choose index when click bottom navigation bar
    List<Widget> _allPages = [
      PageOne(),
      PageTwo(),
      PageTree(),
      PageFour(),
      PageFive(),
    ];

    return Scaffold(
      body: _allPages[_currentIndex],
      bottomNavigationBar: buildBottomNavigationBar(),
    );
  }

  // Bottom navigation bar area you can choose icons what you want.
  BottomNavigationBar buildBottomNavigationBar() {
    return BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      fixedColor: Colors.red,
      currentIndex: _currentIndex,
      onTap: navigationTapped,
      // iconSize: 28,
      items: [
        BottomNavigationBarItem(
          icon: Icon(Icons.home),
          title: Text(
            "Home",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(
            Icons.explore,
          ),
          title: Text(
            "Admission",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.cloud),
          title: Text(
            "University",
            style: TextStyle(fontWeight: FontWeight.normal),
            overflow: TextOverflow.clip,
            textAlign: TextAlign.center,
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.person),
          title: Text(
            "Favorites",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.verified_user),
          title: Text(
            "Profile",
            style: TextStyle(fontWeight: FontWeight.normal),
          ),
        ),
      ],
    );
  }
}

Body:
There is a property selectedFontSize on the BottomNavigationBar.
You can use this one. Simply set the size (interger) to the desired value.

Additionaly; there is also a unselectedFontSize on the BottomNavigationBar, ther you can set all the title-fontsize attonce to the desired size.

      bottomNavigationBar: BottomNavigationBar(
        currentIndex: index,
        onTap: (int index) {
          setState(() {
            this.index = index;
          });
        },
        backgroundColor: Colors.white,
        type: BottomNavigationBarType.fixed,
        selectedFontSize: 12,
        unselectedFontSize: 12,
        items: [
          BottomNavigationBarItem(
            icon: ClipOval(
              child: Container(
                color:
        omitted ...


问:
How to avoid Collection Error Python Numpy
I am trying to train a Linear Regression Qualifier to continue a grap.
I have a couple of thousand lines of data in my csv file that I import into numpy arrays. Here is my code :

```<code>import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import csv
import math
from sklearn import preprocessing, svm
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

def predict():
    sample_data = pd.read_csv("includes\\csv.csv")
    x = np.array(sample_data["day"])
    y = np.array(sample_data["balance"])

    for x in x:
        x = x.reshape(1, -1)
        #lol

    for y in y:
        y.reshape(1, -1)
        #lol

    X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

    clf = LinearRegression()
    clf.fit(x_train, y_train)
    clf.score(x_test, y_test)
</code>```

When I run this, the error is:

```<code>TypeError: Singleton array 6014651 cannot be considered a valid collection.
</code>```

Any ideas why that's a thing?

答:
After discussion in comments:</p>

```<code>import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import csv
import math
from sklearn import preprocessing, svm
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

def predict():
    sample_data = pd.read_csv("includes\\csv.csv")
    x = np.array(sample_data["day"])
    y = np.array(sample_data["balance"])

    x = x.reshape(-1,1)

    y = y.reshape(-1,1)

    X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

    clf = LinearRegression()
    clf.fit(X_train, y_train)
    clf.score(X_test, y_test)
</code>```

Body:
I am trying to train a Linear Regression Qualifier to continue a grap.
I have a couple of thousand lines of data in my csv file that I import into numpy arrays. Here is my code :

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import csv
import math
from sklearn import preprocessing, svm
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

def predict():
    sample_data = pd.read_csv("includes\\csv.csv")
    x = np.array(sample_data["day"])
    y = np.array(sample_data["balance"])

    for x in x:
        x = x.reshape(1, -1)
        #lol

    for y in y:
        y.reshape(1, -1)
        #lol

    X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

    clf = LinearRegression()
    clf.fit(x_train, y_train)
    clf.score(x_test, y_test)

When I run this, the error is:

TypeError: Singleton array 6014651 cannot be considered a valid collection.

Any ideas why that's a thing?

Body:
After discussion in comments:

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import csv
import math
from sklearn import preprocessing, svm
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

def predict():
    sample_data = pd.read_csv("includes\\csv.csv")
    x = np.array(sample_data["day"])
    y = np.array(sample_data["balance"])

    x = x.reshape(-1,1)

    y = y.reshape(-1,1)

    X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

    clf = LinearRegression()
    clf.fit(X_train, y_train)
    clf.score(X_test, y_test)


问:
listening for a function execution
I have a function doSomething() that can be triggered by
many different DOM events.
Is it possible to listen not to an event, but to a moment, when that function is being called/ listen to a function execution?

I mean - I cannot edit the original function and looking for a solution on don't want to reapeat everything attatching another function to all those events.

答:
If it's possible to override the function, you can store the original, override it, then call the original. I've set this up to use rxjs as it's in the tags for the question, but the principle of this applies with or without it.

const DO_SOMETHING_EVENT_NAME = 'doSomething called';

function doSomething() {
  console.log('doing something');
}

var doSomethingOriginal = doSomething;
window.doSomething = function () {
  var event = new Event(DO_SOMETHING_EVENT_NAME);
  document.dispatchEvent(event);
  doSomethingOriginal();
};

var observable = rxjs.fromEvent(document, DO_SOMETHING_EVENT_NAME);

observable.subscribe(() => console.log('doing something else'));```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.5.2/rxjs.umd.js"></script>
<button onclick="doSomething()">First</button>
<button onclick="doSomething()">Second</button></code>```

Title: listening for a function execution

Body:
If it's possible to override the function, you can store the original, override it, then call the original. I've set this up to use rxjs as it's in the tags for the question, but the principle of this applies with or without it.

const DO_SOMETHING_EVENT_NAME = 'doSomething called';

function doSomething() {
  console.log('doing something');
}

var doSomethingOriginal = doSomething;
window.doSomething = function () {
  var event = new Event(DO_SOMETHING_EVENT_NAME);
  document.dispatchEvent(event);
  doSomethingOriginal();
};

var observable = rxjs.fromEvent(document, DO_SOMETHING_EVENT_NAME);

observable.subscribe(() => console.log('doing something else'));

<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.5.2/rxjs.umd.js"></script>
<button onclick="doSomething()">First</button>
<button onclick="doSomething()">Second</button>


问:
Difference in function evaluation between Scheme and Elisp
While studying elisp I tried something which I know works in Scheme and discovered to my surprise that I couldn't replicate it in Elisp.

```<code>;; works in Scheme. result: 5
((if 1 + -) 3 2)

;; doesn't work in Elisp. result: error
((if 1 '+ '-) 3 2)
</code>```

I would expect that the Elisp line evaluates to

```<code>(+ 3 2)
</code>```

and that the evaluation of this list result in 5. However I get:

```<code>(invalid-function (if t '+ '-))
</code>```

What am I missing here? Does Elisp not allow for such actions? Is this possibly related to the fact that Scheme is a lisp-1 language and Elisp a lisp-2?

答:
Yes, the error is due to the fact that Emacs Lisp is a Lisp-2. This should work:</p>

```<code>(funcall (if 1 '+ '-) 3 2)
</code>```

Body:
While studying elisp I tried something which I know works in Scheme and discovered to my surprise that I couldn't replicate it in Elisp.

;; works in Scheme. result: 5
((if 1 + -) 3 2)

;; doesn't work in Elisp. result: error
((if 1 '+ '-) 3 2)

I would expect that the Elisp line evaluates to

(+ 3 2)

and that the evaluation of this list result in 5. However I get:

(invalid-function (if t '+ '-))

What am I missing here? Does Elisp not allow for such actions? Is this possibly related to the fact that Scheme is a lisp-1 language and Elisp a lisp-2?

Body:
Yes, the error is due to the fact that Emacs Lisp is a Lisp-2. This should work:

(funcall (if 1 '+ '-) 3 2)


问:
Bash printing value of array reference
```<code>p=0
array="host_01"
HostProjects[$p]="project_01"
AvgCr=1569.22
eval "${array}_${HostProjects[$p]}=$AvgCr"
echo "Host Credit is ${host_01_project_01}"
</code>```

Gives me 1569.22

But how can I get the result 1569.22 from:

```<code>printf '%s\n' "${array}_${HostProjects[$p]}"
or even from:
echo "${array}_${HostProjects[$p]}"
</code>```

Which gives me host_01_project_01

I have tried several things but it ends up in syntax errors.
Thanks.

答:
If you're using Bash, indirect parameter expansion is your friend:</p>

```<code>varname="${array}_${HostProjects[$p]}"
echo "The value you want is ${!varname}"
</code>```

Title: Bash printing value of array reference

Body:
p=0
array="host_01"
HostProjects[$p]="project_01"
AvgCr=1569.22
eval "${array}_${HostProjects[$p]}=$AvgCr"
echo "Host Credit is ${host_01_project_01}"

Gives me 1569.22

But how can I get the result 1569.22 from:

printf '%s\n' "${array}_${HostProjects[$p]}"
or even from:
echo "${array}_${HostProjects[$p]}"

Which gives me host_01_project_01

I have tried several things but it ends up in syntax errors.
Thanks.

Body:
If you're using Bash, indirect parameter expansion is your friend:

varname="${array}_${HostProjects[$p]}"
echo "The value you want is ${!varname}"


问:
Using send_keys() on a search/filter input field does not filter results in table
There is a table with a list of users and their email on a webpage. At the top of the page, is a search/filter input field that allows the user to type an email or username and filter for the result as he/she is typing.

The problem: However, when I use the send_keys() method instead of doing this manually, nothing is filtered in the table view.

This is happening on the Safari browser on the iPhone 7 Plus (real device, not simulator). Some other information:

iOS version: 12.2

Appium version: 1.13.0-beta.3

Selenium version: 2.53.1

Programming language: Python 2.7.15

In addition to send_keys(), i've tried to use set_value(), i've also tried to execute JS and setting the attribute value, and also tried to send key for each character (in a for loop with a delay between each character).

I'm expecting for example, element.send_keys("test1000@test.com) to filter the table view on the web page so that the only user that is displayed has the associated test1000@test.com email as it does when I go through the site manually.

In actuality, send_keys() does not do that and nothing in the table view gets filtered.

Any help or guidance would be appreciated!

答:
Explicit wait for table to get populate in DOM

sendKeys search String and additional key Tab
textbox.sendKeys("test1000@test.com"+Keys.TAB)

Explicit Wait for filter to get applied and table to get refreshed.

find elements for the newly populated table with applied filters.


问:
Getting error when compiling debug mode: C++/CLI - error LNK2022
I've got a CLI code wrapping a C++ DLL.

When i try to compile it in debug mode, i get the following error:

Error 22 error LNK2022: metadata operation failed (8013118D) :

Inconsistent layout information induplicated types .... MSVCMRTD.lib (locale0_implib.obj)

The weird thing is that on Release mode it compiles OK and works OK.

The only difference i can see that causes the problem is when i change:

Configuration Properties -> C/C++ -> Code Generation -> Runtime Library

When it's set to: Multi-threaded Debug DLL (/MDd) it throws the error.

When it's set to: Multi-threaded DLL (/MD) it compiles fine.

The same settings work for all the other DLLs in the project (CLI and C++) and they inherit the same properties.

I'm using VS2010.

So, how can i solve this ?

And can I get some explanation to WHY this is happening ?

Update:

I've basically tried changing every option in the project's properties with no luck.

I've read somewhere that this might be caused from duplicate declarations of a type of the same name.

But in the CLI file i'm calling std::string etc. explicitly from std.

Renaming the objects didn't work

Any other ideas ?

Update:

A few error copy-pastes:

```<code>error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._String_val<char,std::allocator<char> >): (0x02000097).  E:\MyProject....\MSVCMRTD.lib(locale0_implib.obj)   DllName

error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._String_iterator<char,std::char_traits<char>,std::allocator<char> >): (0x02000091).  E:\MyProject....\MSVCMRTD.lib(locale0_implib.obj)   AnotherDllName
</code>```

Note that the MSVCMRTD.lib file is actually a MS file used for compilation and isn't actually in my project (nor should be)

Update

If you this helps, here's the linker command line:

/OUT:"E:\blah.CLI.dll" /INCREMENTAL
  /NOLOGO /LIBPATH:"e:\blah\Output\"
  /LIBPATH:"E:\blah\lib_64"
  /LIBPATH:"blah\Lib_64\" /DLL
  "e:\Otheblaf.lib" /MANIFEST
  /ManifestFile:"x64\Debug\blah.CLI.dll.intermediate.manifest"
  /ALLOWISOLATION
  /MANIFESTUAC:"level='asInvoker'
  uiAccess='false'" /DEBUG
  /PDB:"E:\blah.CLI.pdb"
  /SUBSYSTEM:WINDOWS /OPT:NOREF
  /OPT:NOICF /PGD:"E:\blah.CLI.pgd"
  /TLBID:1 /DYNAMICBASE:NO /FIXED:NO
  /MACHINE:X64 /ERRORREPORT:QUEUE

And the release that does work:

/OUT:"E:\blah.CLI.dll" /INCREMENTAL:NO
  /NOLOGO /LIBPATH:"E:\blah\"
  /LIBPATH:"E:\blah\Output\"
  /LIBPATH:"E:\blah\lib_64"  /DLL
  "Configuration.lib" "kernel32.lib"
  "user32.lib" "gdi32.lib"
  "winspool.lib" "comdlg32.lib"
  "advapi32.lib" "shell32.lib"
  "ole32.lib" "oleaut32.lib" "uuid.lib"
  "odbc32.lib" "odbccp32.lib"
  "E:\blah.lib" /MANIFEST
  /ManifestFile:"blah.CLI.dll.intermediate.manifest"
  /ALLOWISOLATION
  /MANIFESTUAC:"level='asInvoker'
  uiAccess='false'" /DEBUG
  /PDB:"E:\blah.CLI.pdb"
  /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF
  /PGD:"E:\blah.CLI.pgd" /LTCG /TLBID:1
  /DYNAMICBASE /FIXED:NO /MACHINE:X64
  /ERRORREPORT:QUEUE

答:
Finally got a solution:

In the end it was a problem in boost::lexical_cast<std:string>

There's a bug with .Net object using certain std:: objects. (in my case std::string as is shown in the error message).

This is because when they created this framework, they've re-invented some classes (std::string is one of them) but didn't do it properly in the debug version.

The class's signature is a bit different.

MSDN Related Article - Ambiguous References

So, the solution is to "hide" buggy classes from the .NET object.

Create a C++ level wrapper class that will wrap the original class's functions and cast the
buggy class types to other class types that compile correctly.

Make sure that in the wrapper class's header there's no references or includes to the buggy class type. (Can be done with careful Forward reference/decleration)

With VS2010 you can compile the unmanaged wrapper .cpp file explicitly without /clr.

Then you can use the wrapper class properly with the managed ref class.

Another option

replace lexical_cast<std::string> with:

```<code>ostringstream os;
os << i;
return os.str();
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I've got a CLI code wrapping a C++ DLL.

When i try to compile it in debug mode, i get the following error:

Error 22 error LNK2022: metadata operation failed (8013118D) :

Inconsistent layout information induplicated types .... MSVCMRTD.lib (locale0_implib.obj)

The weird thing is that on Release mode it compiles OK and works OK.

The only difference i can see that causes the problem is when i change:

Configuration Properties -> C/C++ -> Code Generation -> Runtime Library

When it's set to: Multi-threaded Debug DLL (/MDd) it throws the error.

When it's set to: Multi-threaded DLL (/MD) it compiles fine.

The same settings work for all the other DLLs in the project (CLI and C++) and they inherit the same properties.

I'm using VS2010.

So, how can i solve this ?

And can I get some explanation to WHY this is happening ?

Update:

I've basically tried changing every option in the project's properties with no luck.

I've read somewhere that this might be caused from duplicate declarations of a type of the same name.

But in the CLI file i'm calling std::string etc. explicitly from std.

Renaming the objects didn't work

Any other ideas ?

Update:

A few error copy-pastes:

error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._String_val<char,std::allocator<char> >): (0x02000097).  E:\MyProject....\MSVCMRTD.lib(locale0_implib.obj)   DllName

error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._String_iterator<char,std::char_traits<char>,std::allocator<char> >): (0x02000091).  E:\MyProject....\MSVCMRTD.lib(locale0_implib.obj)   AnotherDllName

Note that the MSVCMRTD.lib file is actually a MS file used for compilation and isn't actually in my project (nor should be)

Update

If you this helps, here's the linker command line:

/OUT:"E:\blah.CLI.dll" /INCREMENTAL
  /NOLOGO /LIBPATH:"e:\blah\Output\"
  /LIBPATH:"E:\blah\lib_64"
  /LIBPATH:"blah\Lib_64\" /DLL
  "e:\Otheblaf.lib" /MANIFEST
  /ManifestFile:"x64\Debug\blah.CLI.dll.intermediate.manifest"
  /ALLOWISOLATION
  /MANIFESTUAC:"level='asInvoker'
  uiAccess='false'" /DEBUG
  /PDB:"E:\blah.CLI.pdb"
  /SUBSYSTEM:WINDOWS /OPT:NOREF
  /OPT:NOICF /PGD:"E:\blah.CLI.pgd"
  /TLBID:1 /DYNAMICBASE:NO /FIXED:NO
  /MACHINE:X64 /ERRORREPORT:QUEUE

And the release that does work:

/OUT:"E:\blah.CLI.dll" /INCREMENTAL:NO
  /NOLOGO /LIBPATH:"E:\blah\"
  /LIBPATH:"E:\blah\Output\"
  /LIBPATH:"E:\blah\lib_64"  /DLL
  "Configuration.lib" "kernel32.lib"
  "user32.lib" "gdi32.lib"
  "winspool.lib" "comdlg32.lib"
  "advapi32.lib" "shell32.lib"
  "ole32.lib" "oleaut32.lib" "uuid.lib"
  "odbc32.lib" "odbccp32.lib"
  "E:\blah.lib" /MANIFEST
  /ManifestFile:"blah.CLI.dll.intermediate.manifest"
  /ALLOWISOLATION
  /MANIFESTUAC:"level='asInvoker'
  uiAccess='false'" /DEBUG
  /PDB:"E:\blah.CLI.pdb"
  /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF
  /PGD:"E:\blah.CLI.pgd" /LTCG /TLBID:1
  /DYNAMICBASE /FIXED:NO /MACHINE:X64
  /ERRORREPORT:QUEUE

Body:
Finally got a solution:

In the end it was a problem in boost::lexical_cast<std:string>

There's a bug with .Net object using certain std:: objects. (in my case std::string as is shown in the error message).

This is because when they created this framework, they've re-invented some classes (std::string is one of them) but didn't do it properly in the debug version.

The class's signature is a bit different.

MSDN Related Article - Ambiguous References

So, the solution is to "hide" buggy classes from the .NET object.

Create a C++ level wrapper class that will wrap the original class's functions and cast the
buggy class types to other class types that compile correctly.

Make sure that in the wrapper class's header there's no references or includes to the buggy class type. (Can be done with careful Forward reference/decleration)

With VS2010 you can compile the unmanaged wrapper .cpp file explicitly without /clr.

Then you can use the wrapper class properly with the managed ref class.

Another option

replace lexical_cast<std::string> with:

ostringstream os;
os << i;
return os.str();


问:
Node.js create folder or use existing
I already have read the documentation of Node.js and, unless if I missed something, it does not tell what the parameters contain in certain operations, in particular fs.mkdir(). As you can see in the documentation, it's not very much.

Currently, I have this code, which tries to create a folder or use an existing one instead:

```<code>fs.mkdir(path,function(e){
    if(!e || (e && e.code === 'EEXIST')){
        //do something with contents
    } else {
        //debug
        console.log(e);
    }
});
</code>```

But I wonder is this the right way to do it? Is checking for the code EEXIST the right way to know that the folder already exists? I know I can do fs.stat() before making the directory, but that would already be two hits to the filesystem.

Secondly, is there a complete or at least a more detailed documentation of Node.js that contains details as to what error objects contain, what parameters signify etc.

答:
Just as a newer alternative to Teemu Ikonen's answer, which is very simple and easily readable, is to use the ensureDir method of the fs-extra package.

It can not only be used as a blatant replacement for the built in fs module, but also has a lot of other functionalities in addition to the functionalities of the fs package.

The ensureDir method, as the name suggests, ensures that the directory exists. If the directory structure does not exist, it is created. Like mkdir -p. Not just the end folder, instead the entire path is created if not existing already.

the one provided above is the async version of it. It also has a synchronous method to perform this in the form of the ensureDirSync method.

Title: Node.js create folder or use existing

Body:
I already have read the documentation of Node.js and, unless if I missed something, it does not tell what the parameters contain in certain operations, in particular fs.mkdir(). As you can see in the documentation, it's not very much.

Currently, I have this code, which tries to create a folder or use an existing one instead:

fs.mkdir(path,function(e){
    if(!e || (e && e.code === 'EEXIST')){
        //do something with contents
    } else {
        //debug
        console.log(e);
    }
});

But I wonder is this the right way to do it? Is checking for the code EEXIST the right way to know that the folder already exists? I know I can do fs.stat() before making the directory, but that would already be two hits to the filesystem.

Secondly, is there a complete or at least a more detailed documentation of Node.js that contains details as to what error objects contain, what parameters signify etc.


问:
Flutter Search Delegate Architecture (code structure best practices)
I am relative new to flutter. I was wondering the proper approach in order to implement an AppBar search by using the Search Delegate in Flutter. I read various articles on how to do that. However, with dummy data (used in examples) and just no real world scenarios (code structure) there is no hustle.

My use case consists of

AppBar (home widget - where the search button exists)

One tab (other widget - having a service call to DB at init)

Another tab (other widget -having a service call to DB at init)

My issue is that I want the search to take place at the results lets say of the first tab. So somehow, I have to pass the values return from the service up to my Home widget and then to search Delegate .

I do not know which is the proper way to do that.

InheritedModel/ InheritedWidget ?

passing via the constructors from one widget to another (then I will have tight widget connections and I do not want that)

Some other way using services ?

if any other solution ?

I want the solution to be scalable (as much as possible), in order to make adjustments at near future or add new functionality.

Thanks in advance for your time.

Update

I tried the InheritedModel/ InheritedWidget. For some reason, when I tried to access the data from the build method in Delegate I was receiving null object for inherited object. Probably, I was doing something wrong...I will keep trying...

Adding an image in order to clarify the problem with my app structure...

答:
Do you already know this tutorial?

https://www.youtube.com/watch?v=Wm3OiFBZ2xI

I think, it is exactly what you need. My App uses Data from the Cloud Firestore and the search function is implemented like the search function in this tutorial. It works very well.


问:
how to restore soft delete with one more column?
I have a table named data and I am using soft delete to delete the record.i have one more field in my data table which is also updated when a record is deleted. but when I restore that soft deleted record, it updates my deleted_at field but doesn't update the other field.
I use this code

```<code>Data::withTrashed()->find($id)->restore();
</code>```

How can I do this?

答:
This will work</p>

```<code>Data::withTrashed()->whereId($id)->update([
    'deleted_at'=>null,
    'other_column'=>$value,
]);
</code>```

Body:
I have a table named data and I am using soft delete to delete the record.i have one more field in my data table which is also updated when a record is deleted. but when I restore that soft deleted record, it updates my deleted_at field but doesn't update the other field.
I use this code

Data::withTrashed()->find($id)->restore();

How can I do this?

Body:
This will work

Data::withTrashed()->whereId($id)->update([
    'deleted_at'=>null,
    'other_column'=>$value,
]);


问:
Elements outside vuejs transition component applied with transition effect
Vue Version
2.6.10

Please see the reproduction.

```<code><router-link to="/a"><a name="/a">[a]</a></router-link>
<router-link to="/b"><a name="/b">[b]</a></router-link>
<router-link to="/c"><a name="/c">[c]</a></router-link>
<transition :name="transitionName">
  <router-view></router-view>
</transition>
</code>```

There are three routes here. Switching from A to B, the router links are moving.

The router links should remain still since they are not in the transition tag. They are animated in my browser.

I have tried my best to minify the reproduction. Using other transition effects, removing the mounted hook or the focus operation, the effect doesn't show up. Switching between other route pairs also does not trigger this effect.

答: I have figured out what is happening. Because of overflow: hidden, I did not see the change of clientWidth. Without the scrollbar I did not see the change of scrollX when the input element is focused. That's why it looks like the links are animated.

Body:
Vue Version
2.6.10

Please see the reproduction.

<router-link to="/a">[a]</router-link>
<router-link to="/b">[b]</router-link>
<router-link to="/c">[c]</router-link>
<transition :name="transitionName">
  <router-view></router-view>
</transition>

There are three routes here. Switching from A to B, the router links are moving.

The router links should remain still since they are not in the transition tag. They are animated in my browser.

I have tried my best to minify the reproduction. Using other transition effects, removing the mounted hook or the focus operation, the effect doesn't show up. Switching between other route pairs also does not trigger this effect.


问:
How to append image in ng-circle-progress imageSrc option?
I am using ng-circle-progress to display progress-bar in angular 7.

I followed the steps given here: Progress-bar

Below is HTML code to display progress bar:

```<code><circle-progress
[percent]="85"
[radius]="23"
[outerStrokeWidth]="3"
[innerStrokeWidth]="3"
[outerStrokeColor]="'#78C000'"
[innerStrokeColor]="'#C7E596'"
[animation]="true"
[animationDuration]="1100"
[showTitle]="false"
[showUnits]="false"
[showSubtitle]="false"
[showImage]="true"
[imageSrc]="/assets/icons/music.svg"
[imageHeight]="23"
[imageWidth]="23"
></circle-progress>
</code>```

But it is throwing an error:

ERROR TypeError: Cannot read property 'svg' undefined

What could be the possible solution for that?

答:
[imageSrc]="/assets/icons/music.svg"

You're providing a variable when you use that syntax.

Switch to either of those ones, but not a mix of it

```<code>imageSrc="/assets/icons/music.svg"
[imageSrc]="'/assets/icons/music.svg'"
</code>```

Body:
I am using ng-circle-progress to display progress-bar in angular 7.

I followed the steps given here: Progress-bar

Below is HTML code to display progress bar:

<circle-progress
[percent]="85"
[radius]="23"
[outerStrokeWidth]="3"
[innerStrokeWidth]="3"
[outerStrokeColor]="'#78C000'"
[innerStrokeColor]="'#C7E596'"
[animation]="true"
[animationDuration]="1100"
[showTitle]="false"
[showUnits]="false"
[showSubtitle]="false"
[showImage]="true"
[imageSrc]="/assets/icons/music.svg"
[imageHeight]="23"
[imageWidth]="23"
></circle-progress>

But it is throwing an error:

ERROR TypeError: Cannot read property 'svg' undefined

What could be the possible solution for that?

Body:
[imageSrc]="/assets/icons/music.svg"

You're providing a variable when you use that syntax.

Switch to either of those ones, but not a mix of it

imageSrc="/assets/icons/music.svg"
[imageSrc]="'/assets/icons/music.svg'"


问:
Host does not start
For some reason, the host stopped running.

Previously, the console wrote that everything was OK and the application was running on a specific IP, but now nothing is written and API methods are not available:

There was an error connecting to
  http://localhost:20019/api/User/Authorize)

At the same time, no exceptions. The only thing that I recently changed is the password in the account. If something was not enough, it should have been a timeout. What could be the problem?

```<code> var host = new WebHostBuilder()
        .CaptureStartupErrors(false)
        .UseConfiguration(config)
        .UseHttpSys(options =>
        {
            options.Authentication.Schemes =
                AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate;
            options.UrlPrefixes.Add("http://*:20019");
            options.MaxRequestBodySize = config.GetValue<long?>("maxRequestBodySize");

        })
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseStartup<Startup>()
        .Build();
    var initializer = host.Services.GetService<IRepositoryInitializer>();
    initializer.Init();
    host.Run();
</code>```

答:
Can you try

```<code>  .CaptureStartupErrors(true) // the default
  .UseSetting("detailedErrors", "true")
</code>```

instead?

Other ideas: https://odetocode.com/blogs/scott/archive/2018/07/16/7-tips-for-troubleshooting-asp-net-core-startup-errors.aspx

Title: Host does not start

Body:
For some reason, the host stopped running.

Previously, the console wrote that everything was OK and the application was running on a specific IP, but now nothing is written and API methods are not available:

There was an error connecting to
  http://localhost:20019/api/User/Authorize)

At the same time, no exceptions. The only thing that I recently changed is the password in the account. If something was not enough, it should have been a timeout. What could be the problem?

 var host = new WebHostBuilder()
        .CaptureStartupErrors(false)
        .UseConfiguration(config)
        .UseHttpSys(options =>
        {
            options.Authentication.Schemes =
                AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate;
            options.UrlPrefixes.Add("http://*:20019");
            options.MaxRequestBodySize = config.GetValue<long?>("maxRequestBodySize");

        })
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseStartup<Startup>()
        .Build();
    var initializer = host.Services.GetService<IRepositoryInitializer>();
    initializer.Init();
    host.Run();

Body:
Can you try

  .CaptureStartupErrors(true) // the default
  .UseSetting("detailedErrors", "true")

instead?

Other ideas: https://odetocode.com/blogs/scott/archive/2018/07/16/7-tips-for-troubleshooting-asp-net-core-startup-errors.aspx


答:
You can use split to split the string and use them as Scott mentioned, however if you can present it as a string in this format</p>

```<code>str = '{'date1':'07/08/2018','date2':'07/08/2018','remark':'IMPS DR-1763308000000116-PYTM0123456-917 592674','credit':'5,000.00','balance' : '39,325.93' }'

#then you can just import json and do

json = json.loads(str)
</code>```

Title: python string convert into json for the bankstatement

Body:
This my input

string = '07/08/2018 07/08/2018 IMPS DR-1763308000000116-PYTM0123456-917 592674 5,000.00 39,325.93'

I need output like

{'date1':'07/08/2018','date2':'07/08/2018','remark':'IMPS DR-1763308000000116-PYTM0123456-917 592674','credit':'5,000.00','balance' : '39,325.93' }

I tried

result = { 'date1': list1[0], 'date2': list1[1], 'balance': list1[-1]}
print(result)

output

{'date1': '07/08/2018', 'date2': '07/08/2018', 'balance': '39,325.93'}

Body:
You can use split to split the string and use them as Scott mentioned, however if you can present it as a string in this format

str = '{'date1':'07/08/2018','date2':'07/08/2018','remark':'IMPS DR-1763308000000116-PYTM0123456-917 592674','credit':'5,000.00','balance' : '39,325.93' }'

#then you can just import json and do

json = json.loads(str)


问:
Use p() function mule to fetch secure property in dataweave 2.0
I have a encrypted value in my property file  using mule secure property
eg:

```<code>password = !#$#%%%f  (encrypted)
</code>```

I want to dynamically fetch this value unencrypted using the p function in dataweave based on the input parameter passed in the request

I get the encrypted value using this syntax

```<code>Mule::p(vars.password)
</code>```

How do i use the secure::   syntax on top of this to decrypt the value

```<code>{
    password: Mule::p('secure::vars.password')
}
</code>```

Can someone tell the correct way to do it in Mule 4

答:
To access a property defined in the secure property placeholder use the following syntax:

```<code>p('secure::myproperty.name')
</code>```

If the key is dynamic use string concatenation:

```<code>p('secure::' ++ vars.password)
</code>```

Body:
I have a encrypted value in my property file  using mule secure property
eg:

password = !#$#%%%f  (encrypted)

I want to dynamically fetch this value unencrypted using the p function in dataweave based on the input parameter passed in the request

I get the encrypted value using this syntax

Mule::p(vars.password)

How do i use the secure::   syntax on top of this to decrypt the value

{
    password: Mule::p('secure::vars.password')
}

Can someone tell the correct way to do it in Mule 4

Body:
To access a property defined in the secure property placeholder use the following syntax:

p('secure::myproperty.name')

If the key is dynamic use string concatenation:

p('secure::' ++ vars.password)


问:
Dynamically allocated arrays and HEAP corrupted
I am trying to write a program that takes inputs as a dynamic array and sorts them from lowest to highest and then displays from highest to lowest. However, I get a debugging error that states "HEAP CORRUPTION DETECTED: after Normal block (#182) at 0x010CE3E8.
CRT detected that the application wrote to memory after end of heap buffer."

Well, the program builds and runs successfully. However, when I try to exit the program it takes a really long time and I receive the error.

```<code>void insert_Array(int Array1[], int array_size)
{
    for (int counter = 0; counter < array_size; ++counter)
    {
         cout << " Please enter the " << counter << " number : ";
         cin >> Array1[counter];
    }
    return;
}

void swap(int* a, int* b)
{
    int holder = *a;
    *a = *b;
    *b = holder;
}

void sort_Array(int Array1[], int array_size)
{
    int lowestNum_index;
    for (int counter1 = 0; counter1 < array_size; ++counter1)
    {
        for (int counter2 = counter1; counter2 < array_size; ++counter2)
        {
            if (Array1[counter2] < Array1[counter2 + 1])
                lowestNum_index = counter2;
            else
                lowestNum_index = counter2 + 1;
        }
        swap(Array1[counter1], Array1[lowestNum_index]);
    }
    return;
}
</code>```

Main function

```<code>int* npointer = new int[nNumbers];
insert_Array(npointer, nNumbers);
sort_Array(npointer, nNumbers);
cout << " The number you desired is " << nNumbers << endl;

cout << " The numbers in the array from  high to low are ";
for (int i = 0; i < nNumbers; ++i)
{
    cout << *(npointer + nNumbers - i) << " ";
}

cout << endl;
delete [] npointer;
</code>```

When I run the program successfully sorts the numbers that I give from highest to lowest.

HEAP CORRUPTION DETECTED: after Normal block (#182) at 0x010CE3E8.
CRT detected that the application wrote to memory after end of heap buffer.

答:
Usually when doing a nested loop of this kind, the inner loop is set to start at outer loop + 1. So that you don't end up with values like this Array1[counter2 + 1] which leads to an illegal memory access outside the bounds of the array on the final iteration of the loop.

Even with that fixed, the sorting logic is incorrect. What you are trying to do is known as a selection sort where you compare each element of the array to the rest of elements in n^2 time complexity. You have to obtain the lowestNum_index for each iteration of the outer loop, not the entire array. Here's how I would do a selection sort.

```<code>void sort_Array(int Array[], int array_size)
{
  for (int i = 0; i < array_size; ++i)
  {
    int lowestIdx = i; // <-- always starts at i
    for (int j = i + 1; j < array_size; ++j)
      if (Array[j] < Array[i])
        lowestIdx = j;

    swap(&Array[lowestIdx], &Array[i]); // <--- note the & symbol to pass by reference
  }
}
</code>```

Since your swap function accepts two pointers, using Array[i] will lead to illegal memory access as  the [] operator dereferences the array to the value at i, you have to use the & operator to get the address for that location. i.e.

```<code>Array[i] = *(Array + i)
&Array[i] = Array + i // <--- essentially cancels the dereference operator
</code>```

Edit: Intialize lowestIdx = i on each outer loop

Body:
I am trying to write a program that takes inputs as a dynamic array and sorts them from lowest to highest and then displays from highest to lowest. However, I get a debugging error that states "HEAP CORRUPTION DETECTED: after Normal block (#182) at 0x010CE3E8.
CRT detected that the application wrote to memory after end of heap buffer."

Well, the program builds and runs successfully. However, when I try to exit the program it takes a really long time and I receive the error.

void insert_Array(int Array1[], int array_size)
{
    for (int counter = 0; counter < array_size; ++counter)
    {
         cout << " Please enter the " << counter << " number : ";
         cin >> Array1[counter];
    }
    return;
}

void swap(int* a, int* b)
{
    int holder = *a;
    *a = *b;
    *b = holder;
}

void sort_Array(int Array1[], int array_size)
{
    int lowestNum_index;
    for (int counter1 = 0; counter1 < array_size; ++counter1)
    {
        for (int counter2 = counter1; counter2 < array_size; ++counter2)
        {
            if (Array1[counter2] < Array1[counter2 + 1])
                lowestNum_index = counter2;
            else
                lowestNum_index = counter2 + 1;
        }
        swap(Array1[counter1], Array1[lowestNum_index]);
    }
    return;
}

Main function

int* npointer = new int[nNumbers];
insert_Array(npointer, nNumbers);
sort_Array(npointer, nNumbers);
cout << " The number you desired is " << nNumbers << endl;

cout << " The numbers in the array from  high to low are ";
for (int i = 0; i < nNumbers; ++i)
{
    cout << *(npointer + nNumbers - i) << " ";
}

cout << endl;
delete [] npointer;

When I run the program successfully sorts the numbers that I give from highest to lowest.

HEAP CORRUPTION DETECTED: after Normal block (#182) at 0x010CE3E8.
CRT detected that the application wrote to memory after end of heap buffer.

Body:
Usually when doing a nested loop of this kind, the inner loop is set to start at outer loop + 1. So that you don't end up with values like this Array1[counter2 + 1] which leads to an illegal memory access outside the bounds of the array on the final iteration of the loop.

Even with that fixed, the sorting logic is incorrect. What you are trying to do is known as a selection sort where you compare each element of the array to the rest of elements in n^2 time complexity. You have to obtain the lowestNum_index for each iteration of the outer loop, not the entire array. Here's how I would do a selection sort.

void sort_Array(int Array[], int array_size)
{
  for (int i = 0; i < array_size; ++i)
  {
    int lowestIdx = i; // <-- always starts at i
    for (int j = i + 1; j < array_size; ++j)
      if (Array[j] < Array[i])
        lowestIdx = j;

    swap(&Array[lowestIdx], &Array[i]); // <--- note the & symbol to pass by reference
  }
}

Since your swap function accepts two pointers, using Array[i] will lead to illegal memory access as  the [] operator dereferences the array to the value at i, you have to use the & operator to get the address for that location. i.e.

Array[i] = *(Array + i)
&Array[i] = Array + i // <--- essentially cancels the dereference operator

Edit: Intialize lowestIdx = i on each outer loop


问:
Add constructor logic here
I am trying to finish this piece of code so my smtp web.config code will send an email. I never made this code so I am unsure of what has to go at the top. I'm very new to coding and have never done web development before getting the job I have now. Right after public EmailHelper() in comments it says To Do: Add constructor logic here. I don't understand what the person who wrote it means.

Note: I took out the email and passwords so you could not see them they were not left out by accident.

```<code>    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web;
    using System.Net.Mail;
    using IBEW2330_2018.Domain;

    namespace IBEW2330_2018.Helpers
    {
        /// <summary>
        /// Summary description for EmailService
        /// </summary>
        public class EmailHelper
        {
            public EmailHelper()
            {
                //
                // TODO: Add constructor logic here
                //

            }
            public static string SendEmailWithCCList(string emailBody, string Subject, string emailTo, List<Member> member) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(emailTo);

                    if (member != null)
                    {
                        foreach (Member m in member)
                        {
                            if(Validator.EmailIsValid(m.EmailAddress))
                            {
                                mail.Bcc.Add(m.EmailAddress);
                            }
                        }
                    }
                    mail.From = new MailAddress("", Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message = "alert('Sending Failed...');";
                }
                return message;
            }

            public static string SendEmailWithFrom(string emailBody, string Subject, string emailTo, string ccEmailTo, string emailFrom) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(emailTo);
                    if (ccEmailTo != "")
                    {
                        mail.CC.Add(ccEmailTo);
                    }
                    mail.From = new MailAddress(emailFrom, Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();

                    //TODO: Comment out
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message = "alert('Sending Failed...');";
                }
                return message;
            }

            public static string SendEmail(string emailBody, string Subject, string emailTo, string ccEmailTo) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(emailTo);
                    if (ccEmailTo != "")
                    {
                        mail.CC.Add(ccEmailTo);
                    }
                    mail.From = new MailAddress("", Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    //mail.Attachments.Add(new Attachment(HttpContext.Current.Server.MapPath("~/App_Code/ChristmasParty.pdf")));
                    SmtpClient client = new SmtpClient();
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message="alert('Sending Failed...');";
                }
                return message;
            }

            public static string SendEmailWithAttachments(string emailBody, string Subject, string emailTo, string ccEmailTo, ArrayList strAttach) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    //mail.To.Add(emailTo);
                    mail.To.Add("");
                    if (ccEmailTo != "")
                    {
                        mail.CC.Add(ccEmailTo);
                    }
                    /*live on cartika*/
                    mail.From = new MailAddress("mailer@smtp.ibew.nf.ca", Subject, System.Text.Encoding.UTF8);
                    //mail.From = new MailAddress("diane@ibew.nf.ca", Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    int i=0;
                    for (i = 0; i <=  strAttach.Count - 1; i++)
                    {
                        mail.Attachments.Add(new Attachment(HttpContext.Current.Server.MapPath("~/usr/pdf/certs/" + strAttach[i].ToString())));
                    }
                    SmtpClient client = new SmtpClient();
                    client.Port = 587;
                    client.Host = "mail.smtp.ibew.nf.ca";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = false;
                    client.Send(mail);
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message = "alert('Sending Failed...');";
                }
                return message;
            }
        }
    }
</code>```

答: Just ignore it. It is apparently an auto-generated comment to guide you where to write your constructor. So you can just remove it and you will be fine, and also you will be saving a couple of bytes ;).</p>

Title: Add constructor logic here

Body:
I am trying to finish this piece of code so my smtp web.config code will send an email. I never made this code so I am unsure of what has to go at the top. I'm very new to coding and have never done web development before getting the job I have now. Right after public EmailHelper() in comments it says To Do: Add constructor logic here. I don't understand what the person who wrote it means.

Note: I took out the email and passwords so you could not see them they were not left out by accident.

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web;
    using System.Net.Mail;
    using IBEW2330_2018.Domain;

    namespace IBEW2330_2018.Helpers
    {
        ///
        /// Summary description for EmailService
        ///
        public class EmailHelper
        {
            public EmailHelper()
            {
                //
                // TODO: Add constructor logic here
                //

            }
            public static string SendEmailWithCCList(string emailBody, string Subject, string emailTo, List<Member> member) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(emailTo);

                    if (member != null)
                    {
                        foreach (Member m in member)
                        {
                            if(Validator.EmailIsValid(m.EmailAddress))
                            {
                                mail.Bcc.Add(m.EmailAddress);
                            }
                        }
                    }
                    mail.From = new MailAddress("", Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message = "alert('Sending Failed...');";
                }
                return message;
            }

            public static string SendEmailWithFrom(string emailBody, string Subject, string emailTo, string ccEmailTo, string emailFrom) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(emailTo);
                    if (ccEmailTo != "")
                    {
                        mail.CC.Add(ccEmailTo);
                    }
                    mail.From = new MailAddress(emailFrom, Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();

                    //TODO: Comment out
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message = "alert('Sending Failed...');";
                }
                return message;
            }

            public static string SendEmail(string emailBody, string Subject, string emailTo, string ccEmailTo) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(emailTo);
                    if (ccEmailTo != "")
                    {
                        mail.CC.Add(ccEmailTo);
                    }
                    mail.From = new MailAddress("", Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    //mail.Attachments.Add(new Attachment(HttpContext.Current.Server.MapPath("~/App_Code/ChristmasParty.pdf")));
                    SmtpClient client = new SmtpClient();
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message="alert('Sending Failed...');";
                }
                return message;
            }

            public static string SendEmailWithAttachments(string emailBody, string Subject, string emailTo, string ccEmailTo, ArrayList strAttach) //TODO: Edit/Test
            {
                string message = "";
                try
                {
                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    //mail.To.Add(emailTo);
                    mail.To.Add("");
                    if (ccEmailTo != "")
                    {
                        mail.CC.Add(ccEmailTo);
                    }
                    /*live on cartika*/
                    mail.From = new MailAddress("mailer@smtp.ibew.nf.ca", Subject, System.Text.Encoding.UTF8);
                    //mail.From = new MailAddress("diane@ibew.nf.ca", Subject, System.Text.Encoding.UTF8);
                    mail.Subject = Subject;
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body = emailBody;
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;
                    mail.Priority = MailPriority.High;
                    int i=0;
                    for (i = 0; i <=  strAttach.Count - 1; i++)
                    {
                        mail.Attachments.Add(new Attachment(HttpContext.Current.Server.MapPath("~/usr/pdf/certs/" + strAttach[i].ToString())));
                    }
                    SmtpClient client = new SmtpClient();
                    client.Port = 587;
                    client.Host = "mail.smtp.ibew.nf.ca";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = false;
                    client.Send(mail);
                    client.Port = 2525;
                    client.Host = "port80.smtpcorp.com";
                    client.Credentials = new System.Net.NetworkCredential("", "");
                    client.EnableSsl = true;
                    client.Send(mail);
                    message = "alert('Successfully Sent...');";
                }
                catch (Exception ex)
                {
                    Exception ex2 = ex;
                    string errorMessage = string.Empty;
                    while (ex2 != null)
                    {
                        errorMessage += ex2.ToString();
                        ex2 = ex2.InnerException;
                    }
                    message = "alert('Sending Failed...');";
                }
                return message;
            }
        }
    }