问:
Trying to get jQuery to change a different img src when clicked
I've got 2 seperate divs that change background img src when clicked which works fine, but I would like it to change the other image its present with. E.g. div 1 is pressed and becomes "open", if div2 is "open" it then becomes closed. My jQuery is rather limited and have it functioning where it can change the image, but need to figure out how to apply the "closed" class to images that haven't just been clicked. Ideally it would use the attr() so I can add more later.

jQuery

$(".box").on("click", function() {

      // need to make this function select the other div.
      if ($(this).hasClass("closed")) {
        $(this).addClass("open").removeClass("closed");
      } else {
        $(this).addClass("closed").removeClass("open");
      }

      var id = $(this).attr("data-id");
      $(this).toggleClass("open");
      $(".hideDivs").hide();
      $("#" + id).show();
    });```
<pre class="snippet-code-css lang-css prettyprint-override"><code> .container {
      width: 640px;
      height: 450px;
      background-color: #eee;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }

    .text-primary {
      font-size: 14px;
      text-align: center;
      margin-bottom: 5px;
    }

    .box {
      cursor: pointer;
      width: 90px;
      height: 180px;
      display:block;
      margin:auto;
      background-image: url("http://res.cloudinary.com/dez1tdup3/image/upload/v1499052120/closed_vo1pn2.png");
    }

    .open {
      background-image: url("http://res.cloudinary.com/dez1tdup3/image/upload/v1499052120/open_ihcmuz.png");
    }

    .closed {
      background-image: url("http://res.cloudinary.com/dez1tdup3/image/upload/v1499052120/closed_vo1pn2.png");
    }

    .hideDivs {
      display: none;
    }

    .panel-body {
      padding: 10px;
      margin-top: 5px;
    }

    .title {
      font-weight: bold;
      font-size: 14px;
    }</code>```

              Practices for safe packaging of cooked foods

Label and date all food.

Package high-risk food in small batches for refrigeration and return to refrigerated storage as soon as possible (within 20 minutes).

Store packaging products in a clean environment and protect from contamination.

              Practices for safe freezing of cooked foods

When packaging food for freezing, cover or wrap, label and date (production and freezing date) all foods.

Freeze food in small quantities to ensure food is frozen quickly.

Do not overload freezer units and ensure air can circulate.

Do not freeze foods that have been cooked then refrigerated and reheated.

```

答:
Please check the jsfiddle and let me know if you are looking something like this.
https://jsfiddle.net/314sybno/2/</p>

```<code>$(".box").on("click", function() {
    var id = $(this).attr("data-id");
    if( id === 'divId1') {
        $('div[data-id="divId2"]').addClass('closed').removeClass('open');
    } else {
        $('div[data-id="divId1"]').addClass('closed').removeClass('open');
    }

    // need to make this function select the other div.
    if ($(this).hasClass("closed")) {
        $(this).addClass("open").removeClass("closed");
    } else {
        $(this).addClass("closed").removeClass("open");
    }
    $(".hideDivs").hide();
    $("#" + id).show();
});
</code>```

Body:
I've got 2 seperate divs that change background img src when clicked which works fine, but I would like it to change the other image its present with. E.g. div 1 is pressed and becomes "open", if div2 is "open" it then becomes closed. My jQuery is rather limited and have it functioning where it can change the image, but need to figure out how to apply the "closed" class to images that haven't just been clicked. Ideally it would use the attr() so I can add more later.

jQuery

$(".box").on("click", function() {

      // need to make this function select the other div.
      if ($(this).hasClass("closed")) {
        $(this).addClass("open").removeClass("closed");
      } else {
        $(this).addClass("closed").removeClass("open");
      }

      var id = $(this).attr("data-id");
      $(this).toggleClass("open");
      $(".hideDivs").hide();
      $("#" + id).show();
    });

 .container {
      width: 640px;
      height: 450px;
      background-color: #eee;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }

    .text-primary {
      font-size: 14px;
      text-align: center;
      margin-bottom: 5px;
    }

    .box {
      cursor: pointer;
      width: 90px;
      height: 180px;
      display:block;
      margin:auto;
      background-image: url("http://res.cloudinary.com/dez1tdup3/image/upload/v1499052120/closed_vo1pn2.png");
    }

    .open {
      background-image: url("http://res.cloudinary.com/dez1tdup3/image/upload/v1499052120/open_ihcmuz.png");
    }

    .closed {
      background-image: url("http://res.cloudinary.com/dez1tdup3/image/upload/v1499052120/closed_vo1pn2.png");
    }

    .hideDivs {
      display: none;
    }

    .panel-body {
      padding: 10px;
      margin-top: 5px;
    }

    .title {
      font-weight: bold;
      font-size: 14px;
    }

              Practices for safe packaging of cooked foods

Label and date all food.

Package high-risk food in small batches for refrigeration and return to refrigerated storage as soon as possible (within 20 minutes).

Store packaging products in a clean environment and protect from contamination.

              Practices for safe freezing of cooked foods

When packaging food for freezing, cover or wrap, label and date (production and freezing date) all foods.

Freeze food in small quantities to ensure food is frozen quickly.

Do not overload freezer units and ensure air can circulate.

Do not freeze foods that have been cooked then refrigerated and reheated.

Body:
Please check the jsfiddle and let me know if you are looking something like this.
https://jsfiddle.net/314sybno/2/

$(".box").on("click", function() {
    var id = $(this).attr("data-id");
    if( id === 'divId1') {
        $('div[data-id="divId2"]').addClass('closed').removeClass('open');
    } else {
        $('div[data-id="divId1"]').addClass('closed').removeClass('open');
    }

    // need to make this function select the other div.
    if ($(this).hasClass("closed")) {
        $(this).addClass("open").removeClass("closed");
    } else {
        $(this).addClass("closed").removeClass("open");
    }
    $(".hideDivs").hide();
    $("#" + id).show();
});


来源: stackexchange

问:
How to handle iOS 11 Navigation BarButtonItems bug?
I found a UINavigationBar bug in iOS 11.Fisrtly setup navigation item button in viewDidLoad with self.navigationItem.rightBarButtonItems = @[fixSpaceItem, item]. And use gesture pop back, but I don't really pop back, when pop back starts, I release my finger and let the viewcontroller cancel pop back, then right navigation button items disappear. The left item buttons have the same problem. To reproduce this bug, you must add fixSpaceItem like [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]. And real device but not simulator can reproduce the bug.
Here is my main code:

```<code>- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;

    self.navigationItem.rightBarButtonItems = @[[self negativeSpacerWithWidth:5],[self rightButton]];
    self.navigationItem.leftBarButtonItems = @[[self negativeSpacerWithWidth:5], [self leftButton]];

}

- (UIBarButtonItem *)leftButton {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    [button setImage:[UIImage imageNamed:@"icon_app_back_normal"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)rightButton {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    [button setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)negativeSpacerWithWidth:(CGFloat)width {
    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    [spacer setWidth:width];
    return spacer;
}
</code>```

答:
It seems a bug when you add the FixedSpace BarButtonItem to BarButtonItem array. If you want to set offsets to navigation item, may have to use another way, such as changing imageEdgeInsets of button.

```<code>- (void)viewDidLoad {
    [super viewDidLoad];

    // Do not set Fixed Space type button item.
    self.navigationItem.leftBarButtonItem = [self leftButton];
    self.navigationItem.rightBarButtonItem = [self rightButton];

    // It work too
    //self.navigationItem.leftBarButtonItems = @[[self leftButton], [self leftButton]];
    //self.navigationItem.rightBarButtonItems = @[[self rightButton], [self rightButton]];

    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
}

- (UIBarButtonItem *)leftButton
{
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    //...

    // to add offset you want
    button.imageEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 15);

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)rightButton
{
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    //...

    // to add offset you want
    button.imageEdgeInsets = UIEdgeInsetsMake(0, 15, 0, -15);

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I found a UINavigationBar bug in iOS 11.Fisrtly setup navigation item button in viewDidLoad with self.navigationItem.rightBarButtonItems = @[fixSpaceItem, item]. And use gesture pop back, but I don't really pop back, when pop back starts, I release my finger and let the viewcontroller cancel pop back, then right navigation button items disappear. The left item buttons have the same problem. To reproduce this bug, you must add fixSpaceItem like [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]. And real device but not simulator can reproduce the bug.
Here is my main code:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;

    self.navigationItem.rightBarButtonItems = @[[self negativeSpacerWithWidth:5],[self rightButton]];
    self.navigationItem.leftBarButtonItems = @[[self negativeSpacerWithWidth:5], [self leftButton]];

}

- (UIBarButtonItem *)leftButton {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    [button setImage:[UIImage imageNamed:@"icon_app_back_normal"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)rightButton {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    [button setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)negativeSpacerWithWidth:(CGFloat)width {
    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    [spacer setWidth:width];
    return spacer;
}

Body:
It seems a bug when you add the FixedSpace BarButtonItem to BarButtonItem array. If you want to set offsets to navigation item, may have to use another way, such as changing imageEdgeInsets of button.

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do not set Fixed Space type button item.
    self.navigationItem.leftBarButtonItem = [self leftButton];
    self.navigationItem.rightBarButtonItem = [self rightButton];

    // It work too
    //self.navigationItem.leftBarButtonItems = @[[self leftButton], [self leftButton]];
    //self.navigationItem.rightBarButtonItems = @[[self rightButton], [self rightButton]];

    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
}

- (UIBarButtonItem *)leftButton
{
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    //...

    // to add offset you want
    button.imageEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 15);

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)rightButton
{
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    //...

    // to add offset you want
    button.imageEdgeInsets = UIEdgeInsetsMake(0, 15, 0, -15);

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}


问:
How to open a website hosted in MAMP on the Mac?
I've installed MAMP on my Mac. Then, I put my website into the htdocs folder of MAMP. I started the Server. But how can I launch the website in Safari now? What's the URL to the website, when it's named "testsite" for example?</p>

答:
click on the "open webstart page" then click on mywebsite on
mywebsite on the page.

ContentLicense: CC BY-SA 2.5


问:
How do you create a blog post in rails without a topic?
I am doing a Ruby on Rails course and I am on a part where I am trying to create a blog post but it is giving me an error. It says:

1 error prohibited this blog from being saved:

Topic must exist

my code

What do I change to fix it?

答:
In your Blog model you can add:

```<code>belongs_to :topic, optional: true
</code>```

This will remove the validation check for your Topic association.

Here are the docs on optional. Keep in mind this is if you want to have a Blog save without a Topic.

Body:
In your Blog model you can add:

belongs_to :topic, optional: true

This will remove the validation check for your Topic association.

Here are the docs on optional. Keep in mind this is if you want to have a Blog save without a Topic.


问:
Matlab: change vector values based on if-else condition on the same vector
I have a threshold requirement and would like to round values of a vector to 0 or 1. I don't need to save the old values of the vector

I saw, in the link below, that I could use the following to change the all values of 0 in the s vector to -1 with s( s==0 )=-1; or in general vector(if condition) = desiredValue.

This is better than using a for loop and having an enclosed if condition. What if I would like to include another condition: to change all values greater than 0.8 to 1? Would I have to add another line of code:s( s>=0.8 )=1; or is there a way of checking the two conditions by traversing the vector just once? I only know of using a for loop with an enclosed if-else condition but would like a shorter version if one exists.

https://www.mathworks.com/matlabcentral/newsreader/view_thread/158413

The only related link I found was for R but I am not working with it: Change vector value based on value in same vector

答:
Matlab allows so-called logical indexing, which is really efficient. To understand what

```<code>s(s>0.8) = 1;
</code>```

does, you can check it with two steps:

```<code>ind = s>0.8;
</code>```

Here ind is a logical array with the same size as s, and has true (1) at locations where s is greater than 0.8, and false (0) otherwise.

```<code>s(ind) = 1;
</code>```

will assign s to 1 at locations where ind is true, while not touching those where ind is false.

To make this easy to understand, you can do this:

```<code>ind = find(ind);
</code>```

This will return those indices for s>0.8. Then you do

```<code>s(ind) = 1;
</code>```

The logical indexing allows you to skip find, which makes the code simpler and much faster.

To change to different values (-1 and 1 in your example), you need two command for the assignment.

Body:
Matlab allows so-called logical indexing, which is really efficient. To understand what

s(s>0.8) = 1;

does, you can check it with two steps:

ind = s>0.8;

Here ind is a logical array with the same size as s, and has true (1) at locations where s is greater than 0.8, and false (0) otherwise.

s(ind) = 1;

will assign s to 1 at locations where ind is true, while not touching those where ind is false.

To make this easy to understand, you can do this:

ind = find(ind);

This will return those indices for s>0.8. Then you do

s(ind) = 1;

The logical indexing allows you to skip find, which makes the code simpler and much faster.

To change to different values (-1 and 1 in your example), you need two command for the assignment.


问:
Login functionality in cassandra database
I have a user table(column family) with userId as primary key, it also has other details like emailId, password, username etc.

My doubt is when user login using emailId, how to look for password in the table as my primary key is userId not emailId?

or is it better to create emailId is primary key?

or additional table for mapping userId with emailId?

答: Creating additional mapping table (emailId to userId) would require you to query two tables. This goes against design principles of Cassandra. Try to reduce the queries that you need to fire. In your case, a table with emailId as PRIMARY KEY would be necessary.</p>


问:
Error in Qt 5.9.1 SQLite Vacuum?
hello I have a small app in Qt C++ / SQLite was working nicely on Qt 5.6.2 and I did upgrade to Qt 5.9.1 and the problem is i get runtime errors when i try to VACUUM my db
note that all queries works except vacuum :( and it works without error on Qt 5.6.2

relevant code

```<code>QString msql::sqlExec(QString sqlCmd)
{
    query->clear();
    QString value;

    if (!query->exec(sqlCmd))
    {
        mDebug() << sqlCmd << query->lastError().text();
    }
    else if (!query->first())
    {
        //mDebug() << "not valid query: " << sqlCmd << query->isSelect();
        mDebug() << query->lastError().text();
        return "";
    }
    else
    {
        value = query->value(0).toString();
    }
    query->finish();
    return value;
}
</code>```

and

```<code>bool msql::vacuum()
{
    QStringList tables = db.tables(QSql::AllTables);
    int x = 1;
    int y = tables.count();
    foreach (QString table, tables)
    {
        sqlExec(QString("VACUUM `%1`").arg(table));
        emit progress(QString("Optimizing table %1/%2:%3").arg(x).arg(y).arg(table));
        if (killLoopFlag_)
            return false;
        x++;
    }
    return true;
}
</code>```

I get this errors

```<code>Debug:[2017-07-17 02:51 AM] "VACUUM `visits`" "unknown database `visits` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `investigations`" "unknown database `investigations` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `credentials`" "unknown database `credentials` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `siblings`" "unknown database `siblings` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `surgicalNotes`" "unknown database `surgicalNotes` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `metadata`" "unknown database `metadata` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `drugs`" "unknown database `drugs` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `deceased`" "unknown database `deceased` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `visitPrices`" "unknown database `visitPrices` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `conditions`" "unknown database `conditions` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `conditions_patients`" "unknown database `conditions_patients` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `perinatal`" "unknown database `perinatal` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `development`" "unknown database `development` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `obgyn`" "unknown database `obgyn` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `patients`" "unknown database `patients` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `agendaView`" "unknown database `agendaView` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `registerView`" "unknown database `registerView` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `sqlite_master`" "unknown database `sqlite_master` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `SERVICES`" "unknown database `SERVICES` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `defaultDoses`" "unknown database `defaultDoses` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `allergies`" "unknown database `allergies` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `complaints`" "unknown database `complaints` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `diagnoses`" "unknown database `diagnoses` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `dictionary`" "unknown database `dictionary` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `doses`" "unknown database `doses` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `surgeries`" "unknown database `surgeries` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `investigations`" "unknown database `investigations` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `jobs`" "unknown database `jobs` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `places`" "unknown database `places` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `placeOfBirth`" "unknown database `placeOfBirth` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `expander`" "unknown database `expander` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `drugs`" "unknown database `drugs` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `diet`" "unknown database `diet` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `sqlite_master`" "unknown database `sqlite_master` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `drugsIndex`" "unknown database `drugsIndex` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `metadata`" "unknown database `metadata` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `sqlite_master`" "unknown database `sqlite_master` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
</code>```

答:
VACUUM is applied not to specific tables, but to a whole database. You used to append table names that were ignored by the VACUUM command. Since you upgraded Qt, you've upgraded also SQLite drivers. From the SQLite site:

Compatibility Warning: The ability to vacuum attached databases was added in version 3.15.0 (2016-10-14). Prior to that, a schema-name added to the VACUUM statement would be silently ignored and the "main" schema would be vacuumed.

"Schema-name" here is a name of database. So you can just keep a string

```<code>sqlExec("VACUUM");
</code>```

Title: Error in Qt 5.9.1 SQLite Vacuum?

Body:
hello I have a small app in Qt C++ / SQLite was working nicely on Qt 5.6.2 and I did upgrade to Qt 5.9.1 and the problem is i get runtime errors when i try to VACUUM my db
note that all queries works except vacuum :( and it works without error on Qt 5.6.2

relevant code

QString msql::sqlExec(QString sqlCmd)
{
    query->clear();
    QString value;

    if (!query->exec(sqlCmd))
    {
        mDebug() << sqlCmd << query->lastError().text();
    }
    else if (!query->first())
    {
        //mDebug() << "not valid query: " << sqlCmd << query->isSelect();
        mDebug() << query->lastError().text();
        return "";
    }
    else
    {
        value = query->value(0).toString();
    }
    query->finish();
    return value;
}

and

bool msql::vacuum()
{
    QStringList tables = db.tables(QSql::AllTables);
    int x = 1;
    int y = tables.count();
    foreach (QString table, tables)
    {
        sqlExec(QString("VACUUM `%1`").arg(table));
        emit progress(QString("Optimizing table %1/%2:%3").arg(x).arg(y).arg(table));
        if (killLoopFlag_)
            return false;
        x++;
    }
    return true;
}

I get this errors

Debug:[2017-07-17 02:51 AM] "VACUUM `visits`" "unknown database `visits` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `investigations`" "unknown database `investigations` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `credentials`" "unknown database `credentials` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `siblings`" "unknown database `siblings` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `surgicalNotes`" "unknown database `surgicalNotes` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `metadata`" "unknown database `metadata` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `drugs`" "unknown database `drugs` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `deceased`" "unknown database `deceased` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `visitPrices`" "unknown database `visitPrices` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `conditions`" "unknown database `conditions` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `conditions_patients`" "unknown database `conditions_patients` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `perinatal`" "unknown database `perinatal` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `development`" "unknown database `development` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `obgyn`" "unknown database `obgyn` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `patients`" "unknown database `patients` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `agendaView`" "unknown database `agendaView` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `registerView`" "unknown database `registerView` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `sqlite_master`" "unknown database `sqlite_master` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `SERVICES`" "unknown database `SERVICES` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `defaultDoses`" "unknown database `defaultDoses` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `allergies`" "unknown database `allergies` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `complaints`" "unknown database `complaints` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `diagnoses`" "unknown database `diagnoses` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `dictionary`" "unknown database `dictionary` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `doses`" "unknown database `doses` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `surgeries`" "unknown database `surgeries` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `investigations`" "unknown database `investigations` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `jobs`" "unknown database `jobs` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `places`" "unknown database `places` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `placeOfBirth`" "unknown database `placeOfBirth` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `expander`" "unknown database `expander` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `drugs`" "unknown database `drugs` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `diet`" "unknown database `diet` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `sqlite_master`" "unknown database `sqlite_master` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `drugsIndex`" "unknown database `drugsIndex` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `metadata`" "unknown database `metadata` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)
Debug:[2017-07-17 02:51 AM] "VACUUM `sqlite_master`" "unknown database `sqlite_master` Unable to execute statement" (..\qtemr\msql.cpp:16) class QString __thiscall msql::sqlExec(class QString)

Body:
VACUUM is applied not to specific tables, but to a whole database. You used to append table names that were ignored by the VACUUM command. Since you upgraded Qt, you've upgraded also SQLite drivers. From the SQLite site:

Compatibility Warning: The ability to vacuum attached databases was added in version 3.15.0 (2016-10-14). Prior to that, a schema-name added to the VACUUM statement would be silently ignored and the "main" schema would be vacuumed.

"Schema-name" here is a name of database. So you can just keep a string

sqlExec("VACUUM");


问:
How i can use the id in the textbox from a moda form to do query using php and mysql to fill out the value of other textbox
I had a form table and For the edit button, when i click the button the modal will come out.

The problem is how i can use the id in the textbox to do query using php and mysql to fill out the value of other textbox.

```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script type="text/javascript">
//jquery funtion to sent id to Edit modal
$(document).ready(function() {
  $('#modalEditGroup').on('show.bs.modal', function(e) {
    var id = $(e.relatedTarget).data('id');
     $('#id').val(id);
  });
});
</script></code>```

<input type="button" id="edit-group" name="edit-group" class="btn btn-primary btn-xs" data-id="<?php echo $row['group_id'];?>" data-toggle="modal" data-target="#modalEditGroup" value="Edit">

              <button type="button" class="close"
                 data-dismiss="modal">
                     ×
                     Close
              </button>

                  Edit Group

              <form class="form-horizontal" role="form" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">

                  Id

                          <input type="text" class="form-control" id="id" name="id" class="id" />

                  Group Name

                       <input type="text" id="group_name_edit" required="required" class="form-control col-md-7 col-xs-12" value=""  name="group_name_edit">

                  Access Level

                   <input type="text" id="access_level_edit" required="required" class="form-control col-md-7 col-xs-12" value=""  name="access_level_edit">

                  Approve By

                   <input type="text" id="approve_by_edit" required="required" class="form-control col-md-7 col-xs-12" value=""  name="approve_by_edit">

                      <button class="btn btn-primary" type="reset">Reset</button>
                      <button type="submit" class="btn btn-success" id="submit" name="submit">Submit</button>

              </form>

```

答:
On click of edit button before showing the modal, make an ajax call the ID and get the details of associated with that ID and fill it to the modal elements and than show the modal.

Ex:

```<code>$('#modalEditGroup').on('show.bs.modal', function(e) {
     var id = $(e.relatedTarget).data('id');
     // make ajax() call here with the id
     // fill the response in the the modal
     // show the modal
});
</code>```

Body:
I had a form table and For the edit button, when i click the button the modal will come out.

The problem is how i can use the id in the textbox to do query using php and mysql to fill out the value of other textbox.

<input type="button" id="edit-group" name="edit-group" class="btn btn-primary btn-xs" data-id="<?php echo $row['group_id'];?>" data-toggle="modal" data-target="#modalEditGroup" value="Edit">

              <button type="button" class="close"
                 data-dismiss="modal">
                     ×
                     Close
              </button>

                  Edit Group

              <form class="form-horizontal" role="form" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">

                  Id

                          <input type="text" class="form-control" id="id" name="id" class="id" />

                  Group Name

                       <input type="text" id="group_name_edit" required="required" class="form-control col-md-7 col-xs-12" value=""  name="group_name_edit">

                  Access Level

                   <input type="text" id="access_level_edit" required="required" class="form-control col-md-7 col-xs-12" value=""  name="access_level_edit">

                  Approve By

                   <input type="text" id="approve_by_edit" required="required" class="form-control col-md-7 col-xs-12" value=""  name="approve_by_edit">

                      <button class="btn btn-primary" type="reset">Reset</button>
                      <button type="submit" class="btn btn-success" id="submit" name="submit">Submit</button>

              </form>

Body:
On click of edit button before showing the modal, make an ajax call the ID and get the details of associated with that ID and fill it to the modal elements and than show the modal.

Ex:

$('#modalEditGroup').on('show.bs.modal', function(e) {
     var id = $(e.relatedTarget).data('id');
     // make ajax() call here with the id
     // fill the response in the the modal
     // show the modal
});


问:
Error when inserting data to MySql
I have 1 tables and I need to insert two client details at once. However, there is error for me to insert the second client's data to MySql. Also, when both of the results are not able to key in when I insert in the second time.
MySql table:

This is Html table:

```<code>   <form name="creditAssessPage2" id="basicform" method="post" action="post.php" enctype="multipart/form-data">
         <tr>
             <td>Occupation</td>
             <td><input type="text"   id="occupationMain" name="occupationMain" class="form-control" autocomplete="off" ></td>
             <td><input type="text"   id="occupationJoint1" name="occupationJoint1" class="form-control" autocomplete="off" ></td>
        </tr>
        <tr>
            <td>Employment</td>
            <td contenteditable="true">
            <input list="employTypeList" name="employTypeMain" id="employTypeMain" class="form-control">
                 <datalist id="employTypeList">
                      <option value="">
                      <option value="Self-employed">
                      <option value="Employed">
                      <option value="Unemployed">
                      <option value="Retired">
                 </datalist>
            </td>
            <td contenteditable="true">
                <input list="employTypeList" name="employTypeJoint1" id="employTypeJoint1" class="form-control">
                <datalist id="employTypeList">
                     <option value="">
                     <option value="Self-employed">
                     <option value="Employed">
                     <option value="Unemployed">
                     <option value="Retired">
                </datalist>
            </td>
        </tr>
        <tr>
            <td>Company</td>
            <td><input type="text"   id="companyMain" name="companyMain" class="form-control" autocomplete="off" ></td>
            <td><input type="text"   id="companyJoint1" name="companyJoint1" class="form-control" autocomplete="off" ></td>
        </tr>
        <div class="form-group">
<button type="submit" name="submit" class="btn btn-default">Create</button><br/>
</div>
    </form>
</code>```

This is is my post.php code:

```<code><?php

require_once 'db/dbfunction.php';
require_once 'db/dbCreditAssessment.php';

session_start();
$con = open_connection();

$occupationMain = $_POST['occupationMain'];
$employTypeMain = $_POST['employTypeMain'];
$companyMain = $_POST['companyMain'];

$occupationJoint1 = $_POST['occupationJoint1'];
$employTypeJoint1 = $_POST['employTypeJoint1'];
$companyJoint1 = $_POST['companyJoint1'];

addemployementdetails($con,$occupationMain,$employTypeMain,$companyMain);
addemployementdetails2($con,$occupationJoint1,$employTypeJoint1,$companyJoint1);

close_connection($con);
?>
</code>```

This is the code for dbCreditAssessment.php:

```<code><?php

function addemployementdetails($con,$occupationMain,$employTypeMain,$companyMain){

    $query = "insert into employementdetails(Occupation,EmploymentStatus,NameOfBusiness)
            values('$occupationMain','$employTypeMain','$companyMain')";
                 //echo "{$sqlString}";

                 $insertResult = mysqli_query($con, $query);

                 if($insertResult){
                     echo " Applicant Detail Added !<br />";
                     echo "<a href='index.php'>Back to Home</a>";
                 }
                 else {
                     echo " Error !";
                     echo "{$query}";
                     //header('Location: post.php');
                 }

}

function addemployementdetails2($con,$occupationJoint1,$employTypeJoint1,$companyJoint1){
    $query2 = "insert into employementdetails(Occupation,EmploymentStatus,NameOfBusiness)
            values('$occupationJoint1','$employTypeJoint1','$companyJoint1')";

                 $insertResult2 = mysqli_query($con, $query2);

                 if($insertResult2){
                     echo " Applicant Detail Added !<br />";
                     echo "<a href='index.php'>Back to Home</a>";
                 }
                 else {
                     echo " Error !";
                     echo "{$query2}";
                     //header('Location: post.php');
                 }
}
</code>```

答: The problem is the design of MySql table, employementdetails table need to have AI ID. In this case, employementdetailsID have to be auto generated. </p>

Title: Error when inserting data to MySql

Body:
I have 1 tables and I need to insert two client details at once. However, there is error for me to insert the second client's data to MySql. Also, when both of the results are not able to key in when I insert in the second time.
MySql table:

This is Html table:

   <form name="creditAssessPage2" id="basicform" method="post" action="post.php" enctype="multipart/form-data">

             Occupation
             <input type="text"   id="occupationMain" name="occupationMain" class="form-control" autocomplete="off" >
             <input type="text"   id="occupationJoint1" name="occupationJoint1" class="form-control" autocomplete="off" >

            Employment

            <input list="employTypeList" name="employTypeMain" id="employTypeMain" class="form-control">
                 <datalist id="employTypeList">
                      <option value="">
                      <option value="Self-employed">
                      <option value="Employed">
                      <option value="Unemployed">
                      <option value="Retired">
                 </datalist>

                <input list="employTypeList" name="employTypeJoint1" id="employTypeJoint1" class="form-control">
                <datalist id="employTypeList">
                     <option value="">
                     <option value="Self-employed">
                     <option value="Employed">
                     <option value="Unemployed">
                     <option value="Retired">
                </datalist>

            Company
            <input type="text"   id="companyMain" name="companyMain" class="form-control" autocomplete="off" >
            <input type="text"   id="companyJoint1" name="companyJoint1" class="form-control" autocomplete="off" >

<button type="submit" name="submit" class="btn btn-default">Create</button>

    </form>

This is is my post.php code:

<?php

require_once 'db/dbfunction.php';
require_once 'db/dbCreditAssessment.php';

session_start();
$con = open_connection();

$occupationMain = $_POST['occupationMain'];
$employTypeMain = $_POST['employTypeMain'];
$companyMain = $_POST['companyMain'];

$occupationJoint1 = $_POST['occupationJoint1'];
$employTypeJoint1 = $_POST['employTypeJoint1'];
$companyJoint1 = $_POST['companyJoint1'];

addemployementdetails($con,$occupationMain,$employTypeMain,$companyMain);
addemployementdetails2($con,$occupationJoint1,$employTypeJoint1,$companyJoint1);

close_connection($con);
?>

This is the code for dbCreditAssessment.php:

<?php

function addemployementdetails($con,$occupationMain,$employTypeMain,$companyMain){

    $query = "insert into employementdetails(Occupation,EmploymentStatus,NameOfBusiness)
            values('$occupationMain','$employTypeMain','$companyMain')";
                 //echo "{$sqlString}";

                 $insertResult = mysqli_query($con, $query);

                 if($insertResult){
                     echo " Applicant Detail Added !
";
                     echo "Back to Home";
                 }
                 else {
                     echo " Error !";
                     echo "{$query}";
                     //header('Location: post.php');
                 }

}

function addemployementdetails2($con,$occupationJoint1,$employTypeJoint1,$companyJoint1){
    $query2 = "insert into employementdetails(Occupation,EmploymentStatus,NameOfBusiness)
            values('$occupationJoint1','$employTypeJoint1','$companyJoint1')";

                 $insertResult2 = mysqli_query($con, $query2);

                 if($insertResult2){
                     echo " Applicant Detail Added !
";
                     echo "Back to Home";
                 }
                 else {
                     echo " Error !";
                     echo "{$query2}";
                     //header('Location: post.php');
                 }
}


问:
STM32 uploading application/software over ethernet
Is there a way to upload applications to an STM32 board over the ethernet?

I need to be able to upload code to ~200 Nucleo F429ZI boards that are only connected together with a PC via a LAN.

答:
I have not used LwIP_IAP - as noted by Gürtaç Kadem - but it seems like the easiest solution.

Another way (also applicable to non-ST boards, in case someone else wanders to this question) would be to add the mbed bootloader to your project. Then run a TCP server on your board, let the PC connect to the board and write the new application to the board. Store the new binary in flash, and the bootloader can then load the new binary on reboot.

Requires a bit of coding though. Also you'd need to add a trust relationship between computer and board, perhaps by signing the new binary with a private key and holding the public key on the board. mbed TLS is capable of this (f.e. via X509).

ContentLicense: CC BY-SA 4.0


问:
What's the magic of arrays in C#
```<code>int[] a = new int[5];
string[] b = new string[1];
</code>```

The types of both a and b inherit from the abstract System.Array, but there is no real classes in the built-in library(it seems that there are some runtime types, you can't find the type defination class of an int[]). Can you tell me what happens while compiling? And why did they(the c# team) make this design(I mean why it's not something like Array<T>,instead they are using an abstract class with compiler magics)?

答:
Look at the Array class.

When declaring an array using the [] syntax, the compiler, behind the scenes will use this class for you.

For C#, [] becomes a type that inherits from System.Array.

From the C# 4.0 spec:

§12.1.1 The System.Array type

The type System.Array is the abstract base type of all array types. An implicit reference conversion (§6.1.6) exists from any array type to System.Array, and an explicit reference conversion (§6.2.4) exists from System.Array to any array type. Note that System.Array is not itself an array-type. Rather, it is a class-type from which all array-types are derived.

Title: What's the magic of arrays in C#

Body:
int[] a = new int[5];
string[] b = new string[1];

The types of both a and b inherit from the abstract System.Array, but there is no real classes in the built-in library(it seems that there are some runtime types, you can't find the type defination class of an int[]). Can you tell me what happens while compiling? And why did they(the c# team) make this design(I mean why it's not something like Array<T>,instead they are using an abstract class with compiler magics)?


问:
Webpack, remove comments from ejected Angular CLI app not working
I have an ejected Angular CLI app which produces comments "no matter what" I do to the UglifyJs settings.

I have followed the advice from here, here, and various places, but none of it seems to work.

I'm not sure where in the plugins order I should place UglifyJsPlugin. I've tried at the first position, last position, second position, and simultaneously at every other position.

Are there maybe some settings in the other plugins which interfere?

I run this on Windows with "build:prod": "set NODE_ENV=production&&webpack --define process.env.NODE_ENV=\"'production'\""

```<code>/* eslint-disable node/no-unpublished-require */
/* eslint-disable node/no-extraneous-require */
const path = require('path');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const postcssUrl = require('postcss-url');
const cssnano = require('cssnano');

const { NoEmitOnErrorsPlugin } = require('webpack');
const { GlobCopyWebpackPlugin, BaseHrefWebpackPlugin } = require(
  '@angular/cli/plugins/webpack');
const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
const { AotPlugin } = require('@ngtools/webpack');

const nodeModules = path.join(process.cwd(), 'node_modules');
const genDirNodeModules = path.join(
  process.cwd(),
  './src',
  '$$_gendir',
  'node_modules');
const entryPoints = [
  'inline', 'polyfills', 'sw-register', 'scripts', 'styles', 'vendor', 'main'];
const minimizeCss = false;
const baseHref = '';
const deployUrl = '';
// safe settings based on: https://github.com/ben-eb/cssnano/issues/358#issuecomment-283696193:
const postcssPlugins = function() {
  // const importantCommentRe =
  //   /@preserve|@license|[@#]\s*source(?:Mapping)?URL|^!/i;
  const minimizeOptions = {
    autoprefixer: false,
    safe: true,
    mergeLonghand: false,
    discardComments: {
      remove: (comment) => true,
      // !importantCommentRe.test(comment)
    },
  };
  return [
    postcssUrl({
      url: (URL) => {
        // Only convert root relative URLs, which CSS-Loader won't process
        // into require().
        if (!URL.startsWith('/') || URL.startsWith('//')) {
          return URL;
        }
        if (deployUrl.match(/:\/\//)) {
          // If deployUrl contains a scheme, ignore baseHref use deployUrl
          // as is.
          return `${deployUrl.replace(/\/$/, '')}${URL}`;
        } else if (baseHref.match(/:\/\//)) {
          // If baseHref contains a scheme, include it as is.
          return baseHref.replace(/\/$/, '') +
            `/${deployUrl}/${URL}`.replace(/\/\/+/g, '/');
        } else {
          // Join together base-href, deploy-url and the original URL.
          // Also dedupe multiple slashes into single ones.
          return `/${baseHref}/${deployUrl}/${URL}`.replace(/\/\/+/g, '/');
        }
      },
    }),
    autoprefixer(),
  ].concat(minimizeCss ? [cssnano(minimizeOptions)] : []);
};

const isProduction = process.env.NODE_ENV === 'production';

module.exports = {
  'devtool': 'none', // 'source-map',
  'resolve': {
    'extensions': [
      '.ts',
      '.js',
    ],
    'modules': [
      './node_modules',
      './node_modules',
    ],
  },
  'resolveLoader': {
    'modules': [
      './node_modules',
    ],
  },
  'entry': {
    'main': [
      './src\\main.ts',
    ],
    'polyfills': [
      './src\\polyfills.ts',
    ],
    'scripts': [
      'script-loader!./node_modules\\moment\\min\\moment.min.js',
      'script-loader!./node_modules\\pptxgenjs\\dist\\pptxgen.js',
      'script-loader!./node_modules\\pptxgenjs\\dist\\pptxgen.shapes.js',
      'script-loader!./node_modules\\pptxgenjs\\libs\\jszip.min.js',
      'script-loader!./node_modules\\pptxgenjs\\libs\\jquery.min.js',
    ],
    'styles': [
      './src\\styles.scss',
    ],
  },
  'output': {
    'path': path.join(process.cwd(), 'dist'),
    'filename': '[name].bundle.js',
    'chunkFilename': '[id].chunk.js',
  },
  'module': {
    'rules': [
      // {
      //   'enforce': 'pre',
      //   'test': /\.js$/,
      //   'loader': 'source-map-loader',
      //   'exclude': [
      //     /\/node_modules\//,
      //   ],
      // },
      {
        'test': /\.json$/,
        'loader': 'json-loader',
      },
      {
        'test': /\.html$/,
        'loader': 'raw-loader',
      },
      {
        'test': /\.(eot|svg)$/,
        'loader': 'file-loader?name=[name].[hash:20].[ext]',
      },
      {
        'test': /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
        'loader': 'url-loader?name=[name].[hash:20].[ext]&limit=10000',
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.css$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
        ],
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.scss$|\.sass$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'sass-loader',
            'options': {
              'sourceMap': false,
              'precision': 8,
              'includePaths': [],
            },
          },
        ],
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.less$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'less-loader',
            'options': {
              'sourceMap': false,
            },
          },
        ],
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.styl$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'stylus-loader',
            'options': {
              'sourceMap': false,
              'paths': [],
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.css$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.scss$|\.sass$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'sass-loader',
            'options': {
              'sourceMap': false,
              'precision': 8,
              'includePaths': [],
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.less$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'less-loader',
            'options': {
              'sourceMap': false,
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.styl$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'stylus-loader',
            'options': {
              'sourceMap': false,
              'paths': [],
            },
          },
        ],
      },
      {
        'test': /\.ts$/,
        'loader': '@ngtools/webpack',
      },
    ],
  },
  'plugins': [
    new NoEmitOnErrorsPlugin(),
    new UglifyJsPlugin({
      comments: false,
      sourceMap: false,
      compress: {
        sequences: true,
        dead_code: true,
        conditionals: true,
        booleans: true,
        unused: true,
        if_return: true,
        join_vars: true,
        drop_console: true,
      },
      // mangle: {
      //   except: ['$super', '$', 'exports', 'require'],
      // },
      output: {
        comments: false,
      },
    }),
    new GlobCopyWebpackPlugin({
      'patterns': [
        'assets',
        'favicon.ico',
      ],
      'globOptions': {
        'cwd': 'c:\\dev\\engage\\js-engage\\src',
        'dot': true,
        'ignore': '**/.gitkeep',
      },
    }),
    new ProgressPlugin(),
    new HtmlWebpackPlugin({
      'template': './src\\index.html',
      'filename': './index.html',
      'hash': false,
      'inject': true,
      'compile': true,
      'favicon': false,
      'minify': false,
      'cache': true,
      'showErrors': true,
      'chunks': 'all',
      'excludeChunks': [],
      'title': 'Webpack App',
      'xhtml': true,
      'chunksSortMode': function sort(left, right) {
        let leftIndex = entryPoints.indexOf(left.names[0]);
        let rightindex = entryPoints.indexOf(right.names[0]);
        if (leftIndex > rightindex) {
          return 1;
        } else if (leftIndex < rightindex) {
          return -1;
        } else {
          return 0;
        }
      },
    }),
    new BaseHrefWebpackPlugin({}),
    new CommonsChunkPlugin({
      'name': 'inline',
      'minChunks': null,
    }),
    new CommonsChunkPlugin({
      'name': 'vendor',
      'minChunks': (module) => module.resource &&
      (module.resource.startsWith(nodeModules) || module.resource.startsWith(
        genDirNodeModules)),
      'chunks': [
        'main',
      ],
    }),
    new AotPlugin({
      'mainPath': 'main.ts',
      'hostReplacementPaths': {
        'environments\\environment.ts': isProduction
          ? 'environments\\environment.prod.ts'
          : 'environments\\environment.ts',
      },
      'exclude': [],
      'tsConfigPath': 'src\\tsconfig.app.json',
      'skipCodeGeneration': true,
    }),
  ],
  'node': {
    'fs': 'empty',
    'global': true,
    'crypto': 'empty',
    'tls': 'empty',
    'net': 'empty',
    'process': true,
    'module': false,
    'clearImmediate': false,
    'setImmediate': false,
  },
  'devServer': {
    'historyApiFallback': true,
  },
};
</code>```

Update:

Instead of 'none', which is wrong, I set devtools: false, but it didn't help.

In addition, I tried remove-comments-loader and webpack-comment-remover-loader, but neither helped.

Actually I just realized the comments are appearing in main.bundle.js.map — and even if I turned off source maps that file was being kept around. When I manually deleted the preexisting maps and did a new build with source maps deleted, they weren't remade, and no comments were included in the javascript files.

Tl;dr: User error. Turn off source maps, delete any preexisting sourcemaps, rebuild.

答:
Here is webpack.config.js file.Make relevant changes.

```<code>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');

const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin } = require('webpack');
const { BaseHrefWebpackPlugin, GlobCopyWebpackPlugin } = require('@angular/cli/plugins/webpack');
const { CommonsChunkPlugin } = require('webpack').optimize;
const { AotPlugin } = require('@ngtools/webpack');

const nodeModules = path.join(process.cwd(), 'node_modules');
const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];

module.exports = {
  "devtool": "source-map",
  "resolve": {
    "extensions": [
      ".ts",
      ".js"
    ],
    "modules": [
      "./node_modules"
    ]
  },
  "resolveLoader": {
    "modules": [
      "./node_modules"
    ]
  },
  "entry": {
    "main": [
      "./src\\main.ts"
    ],
    "polyfills": [
      "./src\\polyfills.ts"
    ],
    "styles": [
      "./src\\styles.css"
    ]
  },
  "output": {
    "path": path.join(process.cwd(), "dist"),
    "filename": "[name].bundle.js",
    "chunkFilename": "[id].chunk.js"
  },
  "module": {
    "rules": [
      {
        "enforce": "pre",
        "test": /\.js$/,
        "loader": "source-map-loader",
        "exclude": [
          /\/node_modules\//
        ]
      },
      {
        "test": /\.json$/,
        "loader": "json-loader"
      },
      {
        "test": /\.html$/,
        "loader": "raw-loader"
      },
      {
        "test": /\.(eot|svg)$/,
        "loader": "file-loader?name=[name].[ext]"
      },
      {
        "test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
        "loader": "url-loader?name=[name].[ext]&limit=10000"
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.css$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader"
        ]
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.scss$|\.sass$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader",
          "sass-loader"
        ]
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.less$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader",
          "less-loader"
        ]
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.styl$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader",
          "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
        ]
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.css$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.scss$|\.sass$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader",
    "sass-loader"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.less$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader",
    "less-loader"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.styl$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader",
    "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "test": /\.ts$/,
        "loader": "@ngtools/webpack",
        "exclude": [
          /\.(spec|e2e)\.ts$/
        ]
      }
    ]
  },
  "plugins": [
    new NoEmitOnErrorsPlugin(),
    new HtmlWebpackPlugin({
      "template": "./src\\index.html",
      "filename": "./index.html",
      "hash": false,
      "inject": true,
      "compile": true,
      "favicon": false,
      "minify": false,
      "cache": true,
      "showErrors": true,
      "chunks": "all",
      "excludeChunks": [],
      "title": "Webpack App",
      "xhtml": true,
      "chunksSortMode": function sort(left, right) {
        let leftIndex = entryPoints.indexOf(left.names[0]);
        let rightindex = entryPoints.indexOf(right.names[0]);
        if (leftIndex > rightindex) {
            return 1;
        }
        else if (leftIndex < rightindex) {
            return -1;
        }
        else {
            return 0;
        }
    }
    }),
    new BaseHrefWebpackPlugin({}),
    new CommonsChunkPlugin({
      "name": "inline",
      "minChunks": null
    }),
    new CommonsChunkPlugin({
      "name": "vendor",
      "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
      "chunks": [
        "main"
      ]
    }),
    new GlobCopyWebpackPlugin({
      "patterns": [
        "assets",
        "favicon.ico"
      ],
      "globOptions": {
        "cwd": "D:\\Webpack\\demo\\src",
        "dot": true,
        "ignore": "**/.gitkeep"
      }
    }),
    new ProgressPlugin(),
    new ExtractTextPlugin({
      "filename": "[name].bundle.css",
      "disable": true
    }),
    new LoaderOptionsPlugin({
      "sourceMap": false,
      "options": {
        "postcss": [
          autoprefixer()
        ],
        "sassLoader": {
          "sourceMap": false,
          "includePaths": []
        },
        "lessLoader": {
          "sourceMap": false
        },
        "context": ""
      }
    }),
    new AotPlugin({
      "tsConfigPath": "src\\tsconfig.json",
      "mainPath": "main.ts",
      "hostReplacementPaths": {
        "environments\\environment.ts": "environments\\environment.ts"
      },
      "exclude": [
        "**/*.spec.ts",
        "D:\\Webpack\\demo\\src\\test.ts"
      ],
      "skipCodeGeneration": true
    })
  ],
  "node": {
    "fs": "empty",
    "global": true,
    "crypto": "empty",
    "tls": "empty",
    "net": "empty",
    "process": true,
    "module": false,
    "clearImmediate": false,
    "setImmediate": false
  }
};
</code>```

Hope,it will help!

Body:
I have an ejected Angular CLI app which produces comments "no matter what" I do to the UglifyJs settings.

I have followed the advice from here, here, and various places, but none of it seems to work.

I'm not sure where in the plugins order I should place UglifyJsPlugin. I've tried at the first position, last position, second position, and simultaneously at every other position.

Are there maybe some settings in the other plugins which interfere?

I run this on Windows with "build:prod": "set NODE_ENV=production&&webpack --define process.env.NODE_ENV=\"'production'\""

/* eslint-disable node/no-unpublished-require */
/* eslint-disable node/no-extraneous-require */
const path = require('path');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const postcssUrl = require('postcss-url');
const cssnano = require('cssnano');

const { NoEmitOnErrorsPlugin } = require('webpack');
const { GlobCopyWebpackPlugin, BaseHrefWebpackPlugin } = require(
  '@angular/cli/plugins/webpack');
const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
const { AotPlugin } = require('@ngtools/webpack');

const nodeModules = path.join(process.cwd(), 'node_modules');
const genDirNodeModules = path.join(
  process.cwd(),
  './src',
  '$$_gendir',
  'node_modules');
const entryPoints = [
  'inline', 'polyfills', 'sw-register', 'scripts', 'styles', 'vendor', 'main'];
const minimizeCss = false;
const baseHref = '';
const deployUrl = '';
// safe settings based on: https://github.com/ben-eb/cssnano/issues/358#issuecomment-283696193:
const postcssPlugins = function() {
  // const importantCommentRe =
  //   /@preserve|@license|[@#]\s*source(?:Mapping)?URL|^!/i;
  const minimizeOptions = {
    autoprefixer: false,
    safe: true,
    mergeLonghand: false,
    discardComments: {
      remove: (comment) => true,
      // !importantCommentRe.test(comment)
    },
  };
  return [
    postcssUrl({
      url: (URL) => {
        // Only convert root relative URLs, which CSS-Loader won't process
        // into require().
        if (!URL.startsWith('/') || URL.startsWith('//')) {
          return URL;
        }
        if (deployUrl.match(/:\/\//)) {
          // If deployUrl contains a scheme, ignore baseHref use deployUrl
          // as is.
          return `${deployUrl.replace(/\/$/, '')}${URL}`;
        } else if (baseHref.match(/:\/\//)) {
          // If baseHref contains a scheme, include it as is.
          return baseHref.replace(/\/$/, '') +
            `/${deployUrl}/${URL}`.replace(/\/\/+/g, '/');
        } else {
          // Join together base-href, deploy-url and the original URL.
          // Also dedupe multiple slashes into single ones.
          return `/${baseHref}/${deployUrl}/${URL}`.replace(/\/\/+/g, '/');
        }
      },
    }),
    autoprefixer(),
  ].concat(minimizeCss ? [cssnano(minimizeOptions)] : []);
};

const isProduction = process.env.NODE_ENV === 'production';

module.exports = {
  'devtool': 'none', // 'source-map',
  'resolve': {
    'extensions': [
      '.ts',
      '.js',
    ],
    'modules': [
      './node_modules',
      './node_modules',
    ],
  },
  'resolveLoader': {
    'modules': [
      './node_modules',
    ],
  },
  'entry': {
    'main': [
      './src\\main.ts',
    ],
    'polyfills': [
      './src\\polyfills.ts',
    ],
    'scripts': [
      'script-loader!./node_modules\\moment\\min\\moment.min.js',
      'script-loader!./node_modules\\pptxgenjs\\dist\\pptxgen.js',
      'script-loader!./node_modules\\pptxgenjs\\dist\\pptxgen.shapes.js',
      'script-loader!./node_modules\\pptxgenjs\\libs\\jszip.min.js',
      'script-loader!./node_modules\\pptxgenjs\\libs\\jquery.min.js',
    ],
    'styles': [
      './src\\styles.scss',
    ],
  },
  'output': {
    'path': path.join(process.cwd(), 'dist'),
    'filename': '[name].bundle.js',
    'chunkFilename': '[id].chunk.js',
  },
  'module': {
    'rules': [
      // {
      //   'enforce': 'pre',
      //   'test': /\.js$/,
      //   'loader': 'source-map-loader',
      //   'exclude': [
      //     /\/node_modules\//,
      //   ],
      // },
      {
        'test': /\.json$/,
        'loader': 'json-loader',
      },
      {
        'test': /\.html$/,
        'loader': 'raw-loader',
      },
      {
        'test': /\.(eot|svg)$/,
        'loader': 'file-loader?name=[name].[hash:20].[ext]',
      },
      {
        'test': /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
        'loader': 'url-loader?name=[name].[hash:20].[ext]&limit=10000',
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.css$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
        ],
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.scss$|\.sass$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'sass-loader',
            'options': {
              'sourceMap': false,
              'precision': 8,
              'includePaths': [],
            },
          },
        ],
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.less$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'less-loader',
            'options': {
              'sourceMap': false,
            },
          },
        ],
      },
      {
        'exclude': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.styl$/,
        'use': [
          'exports-loader?module.exports.toString()',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'stylus-loader',
            'options': {
              'sourceMap': false,
              'paths': [],
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.css$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.scss$|\.sass$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'sass-loader',
            'options': {
              'sourceMap': false,
              'precision': 8,
              'includePaths': [],
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.less$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'less-loader',
            'options': {
              'sourceMap': false,
            },
          },
        ],
      },
      {
        'include': [
          path.join(process.cwd(), 'src\\styles.scss'),
        ],
        'test': /\.styl$/,
        'use': [
          'style-loader',
          {
            'loader': 'css-loader',
            'options': {
              'sourceMap': false,
              'importLoaders': 1,
            },
          },
          {
            'loader': 'postcss-loader',
            'options': {
              'ident': 'postcss',
              'plugins': postcssPlugins,
            },
          },
          {
            'loader': 'stylus-loader',
            'options': {
              'sourceMap': false,
              'paths': [],
            },
          },
        ],
      },
      {
        'test': /\.ts$/,
        'loader': '@ngtools/webpack',
      },
    ],
  },
  'plugins': [
    new NoEmitOnErrorsPlugin(),
    new UglifyJsPlugin({
      comments: false,
      sourceMap: false,
      compress: {
        sequences: true,
        dead_code: true,
        conditionals: true,
        booleans: true,
        unused: true,
        if_return: true,
        join_vars: true,
        drop_console: true,
      },
      // mangle: {
      //   except: ['$super', '$', 'exports', 'require'],
      // },
      output: {
        comments: false,
      },
    }),
    new GlobCopyWebpackPlugin({
      'patterns': [
        'assets',
        'favicon.ico',
      ],
      'globOptions': {
        'cwd': 'c:\\dev\\engage\\js-engage\\src',
        'dot': true,
        'ignore': '**/.gitkeep',
      },
    }),
    new ProgressPlugin(),
    new HtmlWebpackPlugin({
      'template': './src\\index.html',
      'filename': './index.html',
      'hash': false,
      'inject': true,
      'compile': true,
      'favicon': false,
      'minify': false,
      'cache': true,
      'showErrors': true,
      'chunks': 'all',
      'excludeChunks': [],
      'title': 'Webpack App',
      'xhtml': true,
      'chunksSortMode': function sort(left, right) {
        let leftIndex = entryPoints.indexOf(left.names[0]);
        let rightindex = entryPoints.indexOf(right.names[0]);
        if (leftIndex > rightindex) {
          return 1;
        } else if (leftIndex < rightindex) {
          return -1;
        } else {
          return 0;
        }
      },
    }),
    new BaseHrefWebpackPlugin({}),
    new CommonsChunkPlugin({
      'name': 'inline',
      'minChunks': null,
    }),
    new CommonsChunkPlugin({
      'name': 'vendor',
      'minChunks': (module) => module.resource &&
      (module.resource.startsWith(nodeModules) || module.resource.startsWith(
        genDirNodeModules)),
      'chunks': [
        'main',
      ],
    }),
    new AotPlugin({
      'mainPath': 'main.ts',
      'hostReplacementPaths': {
        'environments\\environment.ts': isProduction
          ? 'environments\\environment.prod.ts'
          : 'environments\\environment.ts',
      },
      'exclude': [],
      'tsConfigPath': 'src\\tsconfig.app.json',
      'skipCodeGeneration': true,
    }),
  ],
  'node': {
    'fs': 'empty',
    'global': true,
    'crypto': 'empty',
    'tls': 'empty',
    'net': 'empty',
    'process': true,
    'module': false,
    'clearImmediate': false,
    'setImmediate': false,
  },
  'devServer': {
    'historyApiFallback': true,
  },
};

Update:

Instead of 'none', which is wrong, I set devtools: false, but it didn't help.

In addition, I tried remove-comments-loader and webpack-comment-remover-loader, but neither helped.

Actually I just realized the comments are appearing in main.bundle.js.map — and even if I turned off source maps that file was being kept around. When I manually deleted the preexisting maps and did a new build with source maps deleted, they weren't remade, and no comments were included in the javascript files.

Tl;dr: User error. Turn off source maps, delete any preexisting sourcemaps, rebuild.

Body:
Here is webpack.config.js file.Make relevant changes.

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');

const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin } = require('webpack');
const { BaseHrefWebpackPlugin, GlobCopyWebpackPlugin } = require('@angular/cli/plugins/webpack');
const { CommonsChunkPlugin } = require('webpack').optimize;
const { AotPlugin } = require('@ngtools/webpack');

const nodeModules = path.join(process.cwd(), 'node_modules');
const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];

module.exports = {
  "devtool": "source-map",
  "resolve": {
    "extensions": [
      ".ts",
      ".js"
    ],
    "modules": [
      "./node_modules"
    ]
  },
  "resolveLoader": {
    "modules": [
      "./node_modules"
    ]
  },
  "entry": {
    "main": [
      "./src\\main.ts"
    ],
    "polyfills": [
      "./src\\polyfills.ts"
    ],
    "styles": [
      "./src\\styles.css"
    ]
  },
  "output": {
    "path": path.join(process.cwd(), "dist"),
    "filename": "[name].bundle.js",
    "chunkFilename": "[id].chunk.js"
  },
  "module": {
    "rules": [
      {
        "enforce": "pre",
        "test": /\.js$/,
        "loader": "source-map-loader",
        "exclude": [
          /\/node_modules\//
        ]
      },
      {
        "test": /\.json$/,
        "loader": "json-loader"
      },
      {
        "test": /\.html$/,
        "loader": "raw-loader"
      },
      {
        "test": /\.(eot|svg)$/,
        "loader": "file-loader?name=[name].[ext]"
      },
      {
        "test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
        "loader": "url-loader?name=[name].[ext]&limit=10000"
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.css$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader"
        ]
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.scss$|\.sass$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader",
          "sass-loader"
        ]
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.less$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader",
          "less-loader"
        ]
      },
      {
        "exclude": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.styl$/,
        "loaders": [
          "exports-loader?module.exports.toString()",
          "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
          "postcss-loader",
          "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
        ]
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.css$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.scss$|\.sass$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader",
    "sass-loader"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.less$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader",
    "less-loader"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "include": [
          path.join(process.cwd(), "src\\styles.css")
        ],
        "test": /\.styl$/,
        "loaders": ExtractTextPlugin.extract({
  "use": [
    "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
    "postcss-loader",
    "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
  ],
  "fallback": "style-loader",
  "publicPath": ""
})
      },
      {
        "test": /\.ts$/,
        "loader": "@ngtools/webpack",
        "exclude": [
          /\.(spec|e2e)\.ts$/
        ]
      }
    ]
  },
  "plugins": [
    new NoEmitOnErrorsPlugin(),
    new HtmlWebpackPlugin({
      "template": "./src\\index.html",
      "filename": "./index.html",
      "hash": false,
      "inject": true,
      "compile": true,
      "favicon": false,
      "minify": false,
      "cache": true,
      "showErrors": true,
      "chunks": "all",
      "excludeChunks": [],
      "title": "Webpack App",
      "xhtml": true,
      "chunksSortMode": function sort(left, right) {
        let leftIndex = entryPoints.indexOf(left.names[0]);
        let rightindex = entryPoints.indexOf(right.names[0]);
        if (leftIndex > rightindex) {
            return 1;
        }
        else if (leftIndex < rightindex) {
            return -1;
        }
        else {
            return 0;
        }
    }
    }),
    new BaseHrefWebpackPlugin({}),
    new CommonsChunkPlugin({
      "name": "inline",
      "minChunks": null
    }),
    new CommonsChunkPlugin({
      "name": "vendor",
      "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
      "chunks": [
        "main"
      ]
    }),
    new GlobCopyWebpackPlugin({
      "patterns": [
        "assets",
        "favicon.ico"
      ],
      "globOptions": {
        "cwd": "D:\\Webpack\\demo\\src",
        "dot": true,
        "ignore": "**/.gitkeep"
      }
    }),
    new ProgressPlugin(),
    new ExtractTextPlugin({
      "filename": "[name].bundle.css",
      "disable": true
    }),
    new LoaderOptionsPlugin({
      "sourceMap": false,
      "options": {
        "postcss": [
          autoprefixer()
        ],
        "sassLoader": {
          "sourceMap": false,
          "includePaths": []
        },
        "lessLoader": {
          "sourceMap": false
        },
        "context": ""
      }
    }),
    new AotPlugin({
      "tsConfigPath": "src\\tsconfig.json",
      "mainPath": "main.ts",
      "hostReplacementPaths": {
        "environments\\environment.ts": "environments\\environment.ts"
      },
      "exclude": [
        "**/*.spec.ts",
        "D:\\Webpack\\demo\\src\\test.ts"
      ],
      "skipCodeGeneration": true
    })
  ],
  "node": {
    "fs": "empty",
    "global": true,
    "crypto": "empty",
    "tls": "empty",
    "net": "empty",
    "process": true,
    "module": false,
    "clearImmediate": false,
    "setImmediate": false
  }
};

Hope,it will help!


问:
ImportError: cannot import name TwilioRestClient
I ran the Example code of send text using Twilio,the code from:https://www.twilio.com/docs/libraries/python
my code is:

```<code>from twilio.rest import TwilioRestClient,

account_sid = "{{ Account 510 from www.twilio.com/console }}"
auth_token = "{{ Auth Token from www.twilio.com/console  }}"
client = TwilioRestClient(account_sid, auth_token)
message = clientmessages.create(body="You are the best!",
                                to="your phone number",
                                from_="your Twilio number")
print(message.sid)
</code>```

I already install the twilio,using pip, why this problem happened,please help~
there is a copy of my code:

```<code>from twilio.rest import TwilioRestClient;

account_sid = "{{ ACCOUNT_SID }}" # Your Account SID from www.twilio.com/console
auth_token  = "{{ AUTH_TOKEN }}"  # Your Auth Token from www.twilio.com/console

client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(body="You are the best!",
    to="+phonenumber",    # Replace with your phone number
    from_="+(201) ") # Replace with your Twilio number

print(message.sid)
</code>```

答:
I am using twilio version 6+

When I tried with twiliorestclient even got the same error as mention upper, now I am trying this , this solve my problem even

```<code> from twilio.rest import Client

 #Your Account SID from twilio.com/console
 account_sid = "" #your account SID from twilio console

 #Your Auth Token from twilio.com/console
 auth_token  = "" #your auth token from twilio console

 client = Client(account_sid, auth_token)
 message = client.messages.create(
 to="your number",
 from_="your twilio number",
 body="message body")

 print(message.sid) #To print sid
</code>```

Thanks

Body:
I ran the Example code of send text using Twilio,the code from:https://www.twilio.com/docs/libraries/python
my code is:

from twilio.rest import TwilioRestClient,

account_sid = "{{ Account 510 from www.twilio.com/console }}"
auth_token = "{{ Auth Token from www.twilio.com/console  }}"
client = TwilioRestClient(account_sid, auth_token)
message = clientmessages.create(body="You are the best!",
                                to="your phone number",
                                from_="your Twilio number")
print(message.sid)

I already install the twilio,using pip, why this problem happened,please help~
there is a copy of my code:

from twilio.rest import TwilioRestClient;

account_sid = "{{ ACCOUNT_SID }}" # Your Account SID from www.twilio.com/console
auth_token  = "{{ AUTH_TOKEN }}"  # Your Auth Token from www.twilio.com/console

client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(body="You are the best!",
    to="+phonenumber",    # Replace with your phone number
    from_="+(201) ") # Replace with your Twilio number

print(message.sid)

Body:
I am using twilio version 6+

When I tried with twiliorestclient even got the same error as mention upper, now I am trying this , this solve my problem even

 from twilio.rest import Client

 #Your Account SID from twilio.com/console
 account_sid = "" #your account SID from twilio console

 #Your Auth Token from twilio.com/console
 auth_token  = "" #your auth token from twilio console

 client = Client(account_sid, auth_token)
 message = client.messages.create(
 to="your number",
 from_="your twilio number",
 body="message body")

 print(message.sid) #To print sid

Thanks