问:
How to change Icon color while hover over an  tag
While I hover over an  tag area I want to switch the icon's color but for some reason it remains the same. I was able to get the wanted result only if I pinpointed the icon directly
.sidebar .menu li a .icon:hover{background: #ecedf2;color: #3d5654;} but I have to hover exactly over the icon. What I wanted to achieve is to change the icon's color while a hover over the  tag area. Let me know if I am doing something wrong.

HTML

```<code><div class="sidebar">
  <ul class="menu">
    <li>
      <a href="#"
        ><span class="icon"><i class="fas fa-desktop"></i></span
        ><span class="text">Dashboard</span></a
      >
    </li>
  </ul>
</div>
</code>```

CSS

```<code>* {
  list-style: none;
  text-decoration: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Jost', sans-serif;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100wh;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  display: grid;
  grid-template-columns: auto 8fr;
  grid-template-rows: 80px auto 50px;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
}

.sidebar {
  grid-area: sidebar;
  width: 260px;
  background: #2c343b;
  height: 100%;
}

.sidebar .menu {
  padding-right: 30px;
  padding-left: 20px;
  margin: 0;
  overflow: auto;
  transition: all 0.5s;
}

.sidebar .menu li a {
  color: #ecedf2;
  display: block;
  width: 100%;
  line-height: 60px;
  text-decoration: none;
  padding: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1px;
  transition: 0.5s;
}

.sidebar .menu li a .icon {
  color: #ecedf2;
  width: 25px;
  display: inline-block;
}

.sidebar .menu li a:hover,
.sidebar .menu li a.active {
  background: #ecedf2;
  color: #3d5654;
}
</code>```

答:
Try this..

* {
  list-style: none;
  text-decoration: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Jost', sans-serif;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100wh;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  display: grid;
  grid-template-columns: auto 8fr;
  grid-template-rows: 80px auto 50px;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
}

.sidebar {
  grid-area: sidebar;
  width: 260px;
  background: #2c343b;
  height: 100%;
}

.sidebar .menu {
  padding-right: 30px;
  padding-left: 20px;
  margin: 0;
  overflow: auto;
  transition: all 0.5s;
}

.sidebar .menu li a {
  color: #ecedf2;
  display: block;
  width: 100%;
  line-height: 60px;
  text-decoration: none;
  padding: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1px;
  transition: 0.5s;
}

.sidebar .menu li a .icon {
  color: #ecedf2;
  width: 25px;
  display: inline-block;
}

.sidebar .menu li a:hover,
.sidebar .menu li a.active {
  background: #ecedf2;
  color: #3d5654;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="sidebar">
  <ul class="menu">
    <li>
      href="#"
        ><span class="icon"><i class="fas fa-desktop"></i></span
        ><span class="text">Dashboard</span></a
      >
    </li>
  </ul>
</div></code>```

Title: How to change Icon color while hover over an <a> tag

Body:
While I hover over an  tag area I want to switch the icon's color but for some reason it remains the same. I was able to get the wanted result only if I pinpointed the icon directly
.sidebar .menu li a .icon:hover{background: #ecedf2;color: #3d5654;} but I have to hover exactly over the icon. What I wanted to achieve is to change the icon's color while a hover over the  tag area. Let me know if I am doing something wrong.

HTML

      Dashboard

CSS

* {
  list-style: none;
  text-decoration: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Jost', sans-serif;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100wh;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  display: grid;
  grid-template-columns: auto 8fr;
  grid-template-rows: 80px auto 50px;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
}

.sidebar {
  grid-area: sidebar;
  width: 260px;
  background: #2c343b;
  height: 100%;
}

.sidebar .menu {
  padding-right: 30px;
  padding-left: 20px;
  margin: 0;
  overflow: auto;
  transition: all 0.5s;
}

.sidebar .menu li a {
  color: #ecedf2;
  display: block;
  width: 100%;
  line-height: 60px;
  text-decoration: none;
  padding: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1px;
  transition: 0.5s;
}

.sidebar .menu li a .icon {
  color: #ecedf2;
  width: 25px;
  display: inline-block;
}

.sidebar .menu li a:hover,
.sidebar .menu li a.active {
  background: #ecedf2;
  color: #3d5654;
}

Body:
Try this..

* {
  list-style: none;
  text-decoration: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Jost', sans-serif;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100wh;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  display: grid;
  grid-template-columns: auto 8fr;
  grid-template-rows: 80px auto 50px;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
}

.sidebar {
  grid-area: sidebar;
  width: 260px;
  background: #2c343b;
  height: 100%;
}

.sidebar .menu {
  padding-right: 30px;
  padding-left: 20px;
  margin: 0;
  overflow: auto;
  transition: all 0.5s;
}

.sidebar .menu li a {
  color: #ecedf2;
  display: block;
  width: 100%;
  line-height: 60px;
  text-decoration: none;
  padding: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1px;
  transition: 0.5s;
}

.sidebar .menu li a .icon {
  color: #ecedf2;
  width: 25px;
  display: inline-block;
}

.sidebar .menu li a:hover,
.sidebar .menu li a.active {
  background: #ecedf2;
  color: #3d5654;
}

<div class="sidebar">
  <ul class="menu">
    <li>
      <a href="#"
        ><span class="icon"><i class="fas fa-desktop"></i></span
        ><span class="text">Dashboard</span></a
      >
    </li>
  </ul>
</div>


来源: stackexchange

问:
Faster methods of unzipping Assets
I'm writting an app that deals with Zip files of content. I have a few different unzipping methods, depending on where the content is stored.
When unzipping on the SD card, I'm using ZipFile, and that's working great, as I'm always trying to get a specific file out of the zip.
When I'm dealling with a zip that is stored in Assets, I'm resorting to getting an InputStream from the asset, and then iterating through the stream to find the specific file that I'm looking for. e.g:

```<code>ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream); // Editted following comment from Jave
ZipEntry entry;
ZipEntry targetEntry = null;
try {
    while (targetEntry == null
        && (entry = zipInputStream.getNextEntry()) != null)
    {
        if (entry.getName().endsWith(fileName))
        {
            targetEntry = entry;
        }
    }
</code>```

I'm finding that this iteration is taking way too much time. Does anyone know of a faster method to unzip an asset? (for example is there an alternate way to grab an asset, rather than getting it as a Stream?)
I can't really think of anything (other than perhaps copying the zip to the SD before I begin).

答:
```<code>ZipInputStream inZip = new ZipInputStream(MainActivity.this.getAssets().open(_zipFile));
</code>```

Like this,your can get a zipFile by name from assets.

ContentLicense: CC BY-SA 3.0

Title: Faster methods of unzipping Assets

Body:
I'm writting an app that deals with Zip files of content. I have a few different unzipping methods, depending on where the content is stored.
When unzipping on the SD card, I'm using ZipFile, and that's working great, as I'm always trying to get a specific file out of the zip.
When I'm dealling with a zip that is stored in Assets, I'm resorting to getting an InputStream from the asset, and then iterating through the stream to find the specific file that I'm looking for. e.g:

ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream); // Editted following comment from Jave
ZipEntry entry;
ZipEntry targetEntry = null;
try {
    while (targetEntry == null
        && (entry = zipInputStream.getNextEntry()) != null)
    {
        if (entry.getName().endsWith(fileName))
        {
            targetEntry = entry;
        }
    }

I'm finding that this iteration is taking way too much time. Does anyone know of a faster method to unzip an asset? (for example is there an alternate way to grab an asset, rather than getting it as a Stream?)
I can't really think of anything (other than perhaps copying the zip to the SD before I begin).

Body:
ZipInputStream inZip = new ZipInputStream(MainActivity.this.getAssets().open(_zipFile));

Like this,your can get a zipFile by name from assets.

ContentLicense: CC BY-SA 4.0


问:
werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?

"werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"

How to solve this error? I have tried many things but can't solve it by myself.

http_methods.py:

```<code>from flask import Flask, redirect, url_for, request
app = Flask(__name__)

@app.route('/success/<name>')
def success(name):
    return 'welcome %s' % name

@app.route('/login', methods=['POST', 'GET'])
def login():
    if request.method == 'POST':
        user = request.form['nm']
        return redirect(url_for('success', name = user))
    else:
        user = request.args.get('nm')
        return redirect(url_for('success', name = user))

if __name__ == "__main__":
    app.run(debug=True)
</code>```

I get an error in the login method, that value of ['name'] is not specified; how to solve this error?

login.html:

```<code><!DOCTYPE html>
<html lang="en">
    <body>
        <form action="http://127.0.0.1:5000/login" method="POST">
            <p>Enter name:</p>
            <p><input type="text" name="nm" value="nm"/></p>
            <p><input type="submit" value="submit"/></p>
        </form>
    </body>
</html>
</code>```

output:

```<code>  File "/Users/chirag.kanzariya/pythonprojects/v_python/lib/python3.7/site-packages/flask/helpers.py", line 345, in url_for
    force_external=external)
  File "/Users/chirag.kanzariya/pythonprojects/v_python/lib/python3.7/site-packages/werkzeug/routing.py", line 1776, in build
    raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
</code>```

I am using python 3.7 and flask 1.0.2 version right now.

答: There's nothing wrong with your code, all you need to do is navigate to the folder containing your .py code and the html file containing the form (ensuring they are in the same folder) and run the html file, complete the form and submit. the server takes care of the connection between the python code and html code using the link passed in action. I hope it helps.I battled with this very same issue, all suggested responses work only if you run your html code first not just the .py script.</p>

Body:
"werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?"

How to solve this error? I have tried many things but can't solve it by myself.

http_methods.py:

from flask import Flask, redirect, url_for, request
app = Flask(__name__)

@app.route('/success/<name>')
def success(name):
    return 'welcome %s' % name

@app.route('/login', methods=['POST', 'GET'])
def login():
    if request.method == 'POST':
        user = request.form['nm']
        return redirect(url_for('success', name = user))
    else:
        user = request.args.get('nm')
        return redirect(url_for('success', name = user))

if __name__ == "__main__":
    app.run(debug=True)

I get an error in the login method, that value of ['name'] is not specified; how to solve this error?

login.html:

<!DOCTYPE html>

        <form action="http://127.0.0.1:5000/login" method="POST">

Enter name:

<input type="text" name="nm" value="nm"/>

<input type="submit" value="submit"/>

        </form>

output:

  File "/Users/chirag.kanzariya/pythonprojects/v_python/lib/python3.7/site-packages/flask/helpers.py", line 345, in url_for
    force_external=external)
  File "/Users/chirag.kanzariya/pythonprojects/v_python/lib/python3.7/site-packages/werkzeug/routing.py", line 1776, in build
    raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'success'. Did you forget to specify values ['name']?
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2019 14:48:00] "GET /login?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -

I am using python 3.7 and flask 1.0.2 version right now.


问:
Google Chrome showing black border on focus state for button user agent styles
Recently i was working on a web design project, and noticed something odd, after the last Google Chrome update. The default border style(user agent style) for button is changed, and which is looking visually annoying to me.

Is there any method to modify/restore the default browser styles, i.e., user agent styles permanently?

here are some images of the problem:

i have also checked other websites and even google

also checked the dev tool, found this border styles applied on the focus state of the button

答:
You could try disabling this flag: chrome://flags/#form-controls-refresh

Apparently the 83+ version of chrome changed how forms are rendered / handled:
https://blog.chromium.org/2020/03/updates-to-form-controls-and-focus.html

Here is a relevent Google Support page which links to the blog post above:
https://support.google.com/chrome/thread/48974735?hl=en


问:
Why "gradle dependencies" doesn't show all dependencies?
I have implementation 'mysql:mysql-connector-java' currently in my gradle.build.

And I look up in maven repository,it says mysql:mysql-connector-java have a complie dependency of com.google.protobuf:protobuf-java.

But if i execute gradle dependencies,this was shown:

So why there is no com.google.protobuf:protobuf-java after it??

答:
The com.google.protobuf:protobuf-java package is required for building the source of mysql:mysql-connector-java package mainly and gradle fetches build jar files from the maven repository. That's why that package is missing in the library list.

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-installing-maven.html

Check the below link :

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-installing-source.html


问:
How to remove black border from option when hover in chrome 83
I update my chrome browser to 83 and saw the option tag and it looks ugly, It shows the black border when hovering in option.

I tried

```<code>option {
    box-shadow: none;
    border: none;
    -webkit-appearance: none;
}

option:hover {
    box-shadow: none;
    border: none;
    -webkit-appearance: none;
}
</code>```

option {
  box-shadow: none;
  border: none;
  -webkit-appearance: none;
}

option:hover {
  box-shadow: none;
  border: none;
  -webkit-appearance: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3">Option 3</option>
  <option value="4">Option 4</option>
</select></code>```

but still no luck!! why? I don't know.

I want to remove that black border because In my project it looks ugly.

MY NEED

I need same result as previous select and option tag have.

答:
This is an experimental feature.
You could try disabling this flag: chrome://flags/#form-controls-refresh
Apparantly the 83+ version of chrome changed how forms are rendered / handled.</p>

Body:
I update my chrome browser to 83 and saw the option tag and it looks ugly, It shows the black border when hovering in option.

I tried

option {
    box-shadow: none;
    border: none;
    -webkit-appearance: none;
}

option:hover {
    box-shadow: none;
    border: none;
    -webkit-appearance: none;
}

option {
  box-shadow: none;
  border: none;
  -webkit-appearance: none;
}

option:hover {
  box-shadow: none;
  border: none;
  -webkit-appearance: none;
}

<select>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3">Option 3</option>
  <option value="4">Option 4</option>
</select>

but still no luck!! why? I don't know.

I want to remove that black border because In my project it looks ugly.

MY NEED

I need same result as previous select and option tag have.


问:
How to Animate Binding of Child View
A bit confused as to why this code does not work as expected.

Some generic animatable view:

```<code>struct SomeAnimatableView: View, Animatable {
    var percent: Double

    var body: some View {
        GeometryReader { geo in
            ZStack {
                Rectangle()
                    .fill(Color.blue)
                    .frame(height: 120)
                Rectangle()
                    .fill(Color.red)
                    .frame(width: geo.size.width * CGFloat(self.percent), height: 116)
            }
            .frame(width: geo.size.width, height: geo.size.height)
        }
    }

    var animatableData: Double {
        set { percent = newValue }
        get { percent }
    }
}
</code>```

A view which wraps said animatable view:

```<code>struct ProgressRectangle: View {
    @Binding var percent: Double

    var body: some View {
        SomeAnimatableView(percent: percent)
    }
}
</code>```

Finally another view, consider it parent:

```<code>struct ContentView: View {
    @State var percent: Double

    var body: some View {
        VStack {
            ProgressRectangle(percent: $percent.animation())
            Text("Percent: \(percent * 100)")
        }
        .onTapGesture {
            self.percent = 1
        }
    }
}
</code>```

Issue ⚠ why doesn't the progress animate? $percent.animation() isn't that supposed cause animations? Lots of questions...

A fix :

```<code>    .onTapGesture {
        withAnimation {
            self.percent = 1
        }
    }
</code>```

However, this doesn't actually fix the issue or answer the question to why that binding doesn't animate. Because this also seems to animate the entire view, notice the button animating its width in this example:

Thoughts, ideas?

答:
Update: additional clarification

Animation to Binding is a mechanism to transfer animation inside child so when bound variable is changed internally it would be changed with animation.

Thus for considered scenario ProgressRectangle would look like

```<code>struct ProgressRectangle: View {
    @Binding var percent: Double

    var body: some View {
        SomeAnimatableView(percent: percent)
            .onTapGesture {
                withAnimation(_percent.transaction.animation) { // << here !!
                    self.percent = 0 == self.percent ? 0.8 : 0
                }
            }
    }
}
</code>```

without onTapGesture in ContentView (similarly as would you have Toggle which changes value internally).

Test module on GitHub

Original (still valid and works)

Here is working solution. Tested with Xcode 11.4 / iOS 13.4

```<code>@State var percent: Double = .zero
var body: some View {
    VStack {
        ProgressRectangle(percent: $percent)
            .animation(.default)            // << place here !!
            .onTapGesture {
                    self.percent = self.percent == .zero ? 1 : .zero
            }
        Text("Percent: \(percent * 100)")
    }
}
</code>```

Title: How to Animate Binding of Child View

Body:
A bit confused as to why this code does not work as expected.

Some generic animatable view:

struct SomeAnimatableView: View, Animatable {
    var percent: Double

    var body: some View {
        GeometryReader { geo in
            ZStack {
                Rectangle()
                    .fill(Color.blue)
                    .frame(height: 120)
                Rectangle()
                    .fill(Color.red)
                    .frame(width: geo.size.width * CGFloat(self.percent), height: 116)
            }
            .frame(width: geo.size.width, height: geo.size.height)
        }
    }

    var animatableData: Double {
        set { percent = newValue }
        get { percent }
    }
}

A view which wraps said animatable view:

struct ProgressRectangle: View {
    @Binding var percent: Double

    var body: some View {
        SomeAnimatableView(percent: percent)
    }
}

Finally another view, consider it parent:

struct ContentView: View {
    @State var percent: Double

    var body: some View {
        VStack {
            ProgressRectangle(percent: $percent.animation())
            Text("Percent: \(percent * 100)")
        }
        .onTapGesture {
            self.percent = 1
        }
    }
}

Issue ⚠ why doesn't the progress animate? $percent.animation() isn't that supposed cause animations? Lots of questions...

A fix :

    .onTapGesture {
        withAnimation {
            self.percent = 1
        }
    }

However, this doesn't actually fix the issue or answer the question to why that binding doesn't animate. Because this also seems to animate the entire view, notice the button animating its width in this example:

Thoughts, ideas?

Body:
Update: additional clarification

Animation to Binding is a mechanism to transfer animation inside child so when bound variable is changed internally it would be changed with animation.

Thus for considered scenario ProgressRectangle would look like

struct ProgressRectangle: View {
    @Binding var percent: Double

    var body: some View {
        SomeAnimatableView(percent: percent)
            .onTapGesture {
                withAnimation(_percent.transaction.animation) { // << here !!
                    self.percent = 0 == self.percent ? 0.8 : 0
                }
            }
    }
}

without onTapGesture in ContentView (similarly as would you have Toggle which changes value internally).

Test module on GitHub

Original (still valid and works)

Here is working solution. Tested with Xcode 11.4 / iOS 13.4

@State var percent: Double = .zero
var body: some View {
    VStack {
        ProgressRectangle(percent: $percent)
            .animation(.default)            // << place here !!
            .onTapGesture {
                    self.percent = self.percent == .zero ? 1 : .zero
            }
        Text("Percent: \(percent * 100)")
    }
}


问:
Insert distinct records from duplicate valued records in DATASTAGE
Hi I am using DATASTAGE to import hive data into Oracle, I don't have any primary key constraints in hive but on Oracle I am having a combination primary key.
For example I have a data which doesn't have duplicates on basis of whole record but the pk constraints has duplicate
Table has columns
Table name: item_details ;--(hive)
no primary key constraints

Id mfg_date   item  exp_date

1  12-01-2018 abc   31-03-2018

2  12-01-2018 cde   28-02-2018

3  15-01-2018 efg   10-04-2018

4  12-01-2018 abc   10-04-2018

Where the mfg_date and item together are primary key for the target table(Oracle) which is same structure.

And I need to push the data into target table.

But it says a primary key violation  and gets aborted.

Can anybody give me a solution.

Ps. We cannot change the schema for the tables

答:
This is what I use [[twt]] for.  it's faster than doing Lookup and join stages.

start by changing the output sql from Insert to Custom SQL.

then you can create a custom SQL Statement like the one below:

```<code>insert into <<target table>>
select Id, mfg_date, item, exp_date from [[twt]]
where not exist (select 1 from <<target table>> where <<target table>>.id = [[twt]].id)
</code>```

it'll fire off records that don't exist.
because custom sql allows for multiple statements, you can do your whole update this way.

By using [[twt]], you can change this to an ELT form of loading, and control the inserts.

thanks.

Body:
This is what I use [[twt]] for.  it's faster than doing Lookup and join stages.

start by changing the output sql from Insert to Custom SQL.

then you can create a custom SQL Statement like the one below:

insert into <<target table>>
select Id, mfg_date, item, exp_date from [[twt]]
where not exist (select 1 from <<target table>> where <<target table>>.id = [[twt]].id)

it'll fire off records that don't exist.
because custom sql allows for multiple statements, you can do your whole update this way.

By using [[twt]], you can change this to an ELT form of loading, and control the inserts.

thanks.


问:
Getting the Stacktrace
When Exception happens you can print out the StackTrace and review it.

What if you want to get the StackTrace without an exception happening?

Is there a way to do this?

答:
When you catch an exception you can construct StackTrace object and extract useful information from it. See the following example:

```<code>        StackTrace st = new StackTrace(true);
        for(int i =0; i< st.FrameCount; i++ )
        {
            // Note that high up the call stack, there is only
            // one stack frame.
            StackFrame sf = st.GetFrame(i);
            Console.WriteLine();
            Console.WriteLine("High up the call stack, Method: {0}",
                sf.GetMethod());

            Console.WriteLine("High up the call stack, Line Number: {0}",
                sf.GetFileLineNumber());
        }
</code>```

PS: This works even without an exception -- see How to print the current stack trace in .NET without any exception.

OwnerDisplayName: Debbi

LastEditorDisplayName: BtBh

Title: Getting the Stacktrace

Body:
When you catch an exception you can construct StackTrace object and extract useful information from it. See the following example:

        StackTrace st = new StackTrace(true);
        for(int i =0; i< st.FrameCount; i++ )
        {
            // Note that high up the call stack, there is only
            // one stack frame.
            StackFrame sf = st.GetFrame(i);
            Console.WriteLine();
            Console.WriteLine("High up the call stack, Method: {0}",
                sf.GetMethod());

            Console.WriteLine("High up the call stack, Line Number: {0}",
                sf.GetFileLineNumber());
        }

PS: This works even without an exception -- see How to print the current stack trace in .NET without any exception.

OwnerDisplayName: David Pokluda

ContentLicense: CC BY-SA 2.5


问:
Protect any cell after inserting value
i want to make a excel sheet where anyone can insert data. but once user insert data after that user can't change. only one person say admin can change data.</p>

答:
Finally solved by myself. Solution</p>

```<code>Private Sub Worksheet_Change(ByVal Target As Range)
Dim c1 As Range
ActiveSheet.Unprotect Password:="123"
For Each c1 In Target
If c1.Value <> "" Then
c1.Locked = True
End If
Next c1
ActiveSheet.Protect Password:="123"
End Sub
</code>```

Title: Protect any cell after inserting value

Body:
Finally solved by myself. Solution

Private Sub Worksheet_Change(ByVal Target As Range)
Dim c1 As Range
ActiveSheet.Unprotect Password:="123"
For Each c1 In Target
If c1.Value <> "" Then
c1.Locked = True
End If
Next c1
ActiveSheet.Protect Password:="123"
End Sub


问:
Ionic 4 ion-action-controller prevent auto close on button click
I am trying to show the list of language available as an Action sheet. But as soon as the language button is pressed the action sheet closes automatically. Is there any possible way to prevent the auto close of ion-action-sheet controller on clicking the ActionsheetButton.

```<code>async showChangeLangAlert() {
    const actionSheet = await this.actionSheet.create(
      {
        header: this.translateText('Select language'),
        buttons: this.getLanguageInputTypes(),
        cssClass: 'confirmation-popup select-lang',
        backdropDismiss: true,
        mode: 'md'
      }
    );

    actionSheet.present();

    actionSheet.onWillDismiss().then(res => {
      console.log(res);
      event.preventDefault();
    });

    actionSheet.onDidDismiss().then(res => {
      this.langChoosen.next(this.selectedLanguage);
    });
  }

private getLanguageInputTypes(): ActionSheetButton[] {
    if (this.selectedLanguage === undefined) {
      this.selectedLanguage = 'en';
    }
    return [
      {
        text: this.translateText('English'),
        icon: (this.selectedLanguage.toLowerCase() === 'en') ? 'radio-button-on' : 'radio-button-off',
        cssClass: (this.selectedLanguage.toLowerCase() === 'en') ? 'active-option' : '',
        handler: () => {
          this.selectedLanguage = 'en';
        }
      },
      {
        text: this.translateText('German'),
        icon: (this.selectedLanguage.toLowerCase() === 'de') ? 'radio-button-on' : 'radio-button-off',
        cssClass: (this.selectedLanguage.toLowerCase() === 'de') ? 'active-option' : '',
        handler: () => {
          this.selectedLanguage = 'de';
        }
      },
      {
        text: this.translateText('Select'),
        icon: 'checkmark-circle',
        cssClass: (this.selectedLanguage.toLowerCase() === 'de') ? 'active-option' : '',
        handler: () => {
          this.setSelectedLanguage();
        }
      }
        ];
      }

private setSelectedLanguage() {
 // close the action-sheet here
}
</code>```

I want to achieve the manual close of the action-sheet controller, but it closes automatically on clicking any action button. What I am missing or is there any workaround to show the alert window as an action sheet?

答:
backdropDismiss
Description
If true, the action sheet will be dismissed when the backdrop is clicked.

Attribute   backdrop-dismiss
Type    boolean
Default true

```<code>backdropDismiss:false
</code>```

Body:
I am trying to show the list of language available as an Action sheet. But as soon as the language button is pressed the action sheet closes automatically. Is there any possible way to prevent the auto close of ion-action-sheet controller on clicking the ActionsheetButton.

async showChangeLangAlert() {
    const actionSheet = await this.actionSheet.create(
      {
        header: this.translateText('Select language'),
        buttons: this.getLanguageInputTypes(),
        cssClass: 'confirmation-popup select-lang',
        backdropDismiss: true,
        mode: 'md'
      }
    );

    actionSheet.present();

    actionSheet.onWillDismiss().then(res => {
      console.log(res);
      event.preventDefault();
    });

    actionSheet.onDidDismiss().then(res => {
      this.langChoosen.next(this.selectedLanguage);
    });
  }

private getLanguageInputTypes(): ActionSheetButton[] {
    if (this.selectedLanguage === undefined) {
      this.selectedLanguage = 'en';
    }
    return [
      {
        text: this.translateText('English'),
        icon: (this.selectedLanguage.toLowerCase() === 'en') ? 'radio-button-on' : 'radio-button-off',
        cssClass: (this.selectedLanguage.toLowerCase() === 'en') ? 'active-option' : '',
        handler: () => {
          this.selectedLanguage = 'en';
        }
      },
      {
        text: this.translateText('German'),
        icon: (this.selectedLanguage.toLowerCase() === 'de') ? 'radio-button-on' : 'radio-button-off',
        cssClass: (this.selectedLanguage.toLowerCase() === 'de') ? 'active-option' : '',
        handler: () => {
          this.selectedLanguage = 'de';
        }
      },
      {
        text: this.translateText('Select'),
        icon: 'checkmark-circle',
        cssClass: (this.selectedLanguage.toLowerCase() === 'de') ? 'active-option' : '',
        handler: () => {
          this.setSelectedLanguage();
        }
      }
        ];
      }

private setSelectedLanguage() {
 // close the action-sheet here
}

I want to achieve the manual close of the action-sheet controller, but it closes automatically on clicking any action button. What I am missing or is there any workaround to show the alert window as an action sheet?

Body:
backdropDismiss
Description
If true, the action sheet will be dismissed when the backdrop is clicked.

Attribute   backdrop-dismiss
Type    boolean
Default true

backdropDismiss:false


问:
How to store results of a for loop in a vector or a list in R
I want to run a simple for loop and store values in a list or a vector. For example:

```<code>ex = c(10,11,17)

for (i in (0:length(ex))){
  if ex[i] < 12 {
    # store the value in a vector
  }
}
</code>```

How can I do this, when I do not know the length of the vector and therefore cannot define it first?

答:
You can allocate a max possible size vector and only partially fill it, then reduce it down.</p>

```<code>ex = c(10,11,17,9,14,1,20,1)
store <- list(length(ex))
for (i in (1:length(ex))){
  if(ex[i] < 12){
    store[[i]] <- ex[i]
  }
}
unlist(store)

[1] 10 11  9  1  1
</code>```

Body:
I want to run a simple for loop and store values in a list or a vector. For example:

ex = c(10,11,17)

for (i in (0:length(ex))){
  if ex[i] < 12 {
    # store the value in a vector
  }
}

How can I do this, when I do not know the length of the vector and therefore cannot define it first?

Body:
You can allocate a max possible size vector and only partially fill it, then reduce it down.

ex = c(10,11,17,9,14,1,20,1)
store <- list(length(ex))
for (i in (1:length(ex))){
  if(ex[i] < 12){
    store[[i]] <- ex[i]
  }
}
unlist(store)

[1] 10 11  9  1  1


答:
For Multiindexes, it is much safer to use the loc method to get your results.

In the code below, loc focuses on the columns (axis=0 would imply working on the rows), and selects "Close" and "High". You can safely place the replacement values on the other side of the equation, and should not get any errors.

I'd also suggest reading pandas docs on MultiIndexes for more information - I believe it will help you when working with multiIndexes:

```<code>a.loc(axis=1)[["Close","High"]] = a[["Close","High"]].pct_change().fillna(0)
</code>```

Title: How can I reassign multiple MultiIndex columns at once in pandas?

Body:
Given two versions of the same dataset, one stacked and the other not.

>>> a = pandas_datareader.DataReader(["MSFT", "AAPL"], "yahoo")
>>> a
Attributes   Adj Close                   Close                    High                     Low                    Open                  Volume
Symbols           MSFT        AAPL        MSFT        AAPL        MSFT        AAPL        MSFT        AAPL        MSFT        AAPL        MSFT        AAPL
Date
2015-06-01   42.744289  120.306801   47.230000  130.539993   47.770000  131.389999   46.619999  130.050003   47.060001  130.279999  28837300.0  32112800.0
2015-06-02   42.463726  119.772255   46.919998  129.960007   47.349998  130.660004   46.619999  129.320007   46.930000  129.860001  21498300.0  33667600.0
2015-06-03   42.400375  119.919716   46.849998  130.119995   47.740002  130.940002   46.820000  129.899994   47.369999  130.660004  28002200.0  30983500.0
2015-06-04   41.956924  119.219307   46.360001  129.360001   47.160000  130.580002   46.200001  128.910004   46.790001  129.580002  27745500.0  38450100.0
2015-06-05   41.757805  118.564957   46.139999  128.649994   46.520000  129.690002   45.840000  128.360001   46.310001  129.500000  25438100.0  35626800.0
...                ...         ...         ...         ...         ...         ...         ...         ...         ...         ...         ...         ...
2020-05-22  183.509995  318.890015  183.509995  318.890015  184.460007  319.230011  182.539993  315.350006  183.190002  315.769989  20826900.0  20450800.0
2020-05-26  181.570007  316.730011  181.570007  316.730011  186.500000  324.239990  181.100006  316.500000  186.339996  323.500000  36073600.0  31380500.0
2020-05-27  181.809998  318.109985  181.809998  318.109985  181.990005  318.709991  176.600006  313.089996  180.199997  316.140015  39517100.0  28236300.0
2020-05-28  181.399994  318.250000  181.399994  318.250000  184.149994  323.440002  180.380005  315.630005  180.740005  316.769989  33810200.0  33390200.0
2020-05-29  183.250000  317.940002  183.250000  317.940002  184.270004  321.149994  180.410004  316.470001  182.729996  319.250000  42130400.0  38383100.0

>>> b = a.stack()
>>> b
Attributes           Adj Close       Close        High         Low        Open      Volume
Date       Symbols
2015-06-01 MSFT      42.744289   47.230000   47.770000   46.619999   47.060001  28837300.0
           AAPL     120.306801  130.539993  131.389999  130.050003  130.279999  32112800.0
2015-06-02 MSFT      42.463726   46.919998   47.349998   46.619999   46.930000  21498300.0
           AAPL     119.772255  129.960007  130.660004  129.320007  129.860001  33667600.0
2015-06-03 MSFT      42.400375   46.849998   47.740002   46.820000   47.369999  28002200.0
...                        ...         ...         ...         ...         ...         ...
2020-05-26 AAPL     316.730011  316.730011  324.239990  316.500000  323.500000  31380500.0
2020-05-27 MSFT     181.809998  181.809998  181.990005  176.600006  180.199997  39492600.0
           AAPL     318.109985  318.109985  318.709991  313.089996  316.140015  28211100.0
2020-05-28 MSFT     181.580002  181.580002  182.470001  180.389999  180.740005   9760951.0
           AAPL     319.850006  319.850006  321.070007  315.630005  316.769989  10119124.0

I'm trying to get a couple of columns from a, transform them and reassign them to the dataset. This works perfectly with b.

>>> b[["Close", "High"]] = b[["Close", "High"]].pct_change().fillna(0)
>>> b
Attributes           Adj Close     Close      High         Low        Open      Volume
Date       Symbols
2015-06-01 MSFT      42.744289  0.000000  0.000000   46.619999   47.060001  28837300.0
           AAPL     120.306801  1.763921  1.750471  130.050003  130.279999  32112800.0
2015-06-02 MSFT      42.463726 -0.640570 -0.639623   46.619999   46.930000  21498300.0
           AAPL     119.772255  1.769821  1.759451  129.320007  129.860001  33667600.0
2015-06-03 MSFT      42.400375 -0.639504 -0.634624   46.820000   47.369999  28002200.0
...                        ...       ...       ...         ...         ...         ...
2020-05-26 AAPL     316.730011  0.744396  0.738552  316.500000  323.500000  31380500.0
2020-05-27 MSFT     181.809998 -0.425978 -0.438718  176.600006  180.199997  39492600.0
           AAPL     318.109985  0.749684  0.751250  313.089996  316.140015  28211100.0
2020-05-28 MSFT     181.580002 -0.429191 -0.427473  180.389999  180.740005   9760951.0
           AAPL     319.850006  0.761483  0.759577  315.630005  316.769989  10119124.0

[2516 rows x 6 columns]

But the same doesn't work for a.

>>> a[["Close", "High"]] = a[["Close", "High"]].pct_change().fillna(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/renatomz/.local/lib/python3.8/site-packages/pandas/core/frame.py", line 2935, in __setitem__
    self._setitem_array(key, value)
  File "/home/renatomz/.local/lib/python3.8/site-packages/pandas/core/frame.py", line 2961, in _setitem_array
    raise ValueError("Columns must be same length as key")
ValueError: Columns must be same length as key

This is perfectly possible if I where to do it column by column. I'm using a for loop as a temporary solution, but it seems inefficient and unclean to me.

>>> a["Close"] = a["Close"].pct_change().fillna(0)
>>> a
Attributes   Adj Close                 Close                  High                     Low                    Open                  Volume
Symbols           MSFT        AAPL      MSFT      AAPL        MSFT        AAPL        MSFT        AAPL        MSFT        AAPL        MSFT        AAPL
Date
2015-06-01   42.744289  120.306801  0.000000  0.000000   47.770000  131.389999   46.619999  130.050003   47.060001  130.279999  28837300.0  32112800.0
2015-06-02   42.463726  119.772255 -0.006564 -0.004443   47.349998  130.660004   46.619999  129.320007   46.930000  129.860001  21498300.0  33667600.0
2015-06-03   42.400375  119.919716 -0.001492  0.001231   47.740002  130.940002   46.820000  129.899994   47.369999  130.660004  28002200.0  30983500.0
2015-06-04   41.956924  119.219307 -0.010459 -0.005841   47.160000  130.580002   46.200001  128.910004   46.790001  129.580002  27745500.0  38450100.0
2015-06-05   41.757805  118.564957 -0.004745 -0.005489   46.520000  129.690002   45.840000  128.360001   46.310001  129.500000  25438100.0  35626800.0
...                ...         ...       ...       ...         ...         ...         ...         ...         ...         ...         ...         ...
2020-05-21  183.429993  316.850006 -0.012011 -0.007455  186.669998  320.890015  183.289993  315.869995  185.399994  318.660004  29119500.0  25672200.0
2020-05-22  183.509995  318.890015  0.000436  0.006438  184.460007  319.230011  182.539993  315.350006  183.190002  315.769989  20826900.0  20450800.0
2020-05-26  181.570007  316.730011 -0.010572 -0.006774  186.500000  324.239990  181.100006  316.500000  186.339996  323.500000  36073600.0  31380500.0
2020-05-27  181.809998  318.109985  0.001322  0.004357  181.990005  318.709991  176.600006  313.089996  180.199997  316.140015  39492600.0  28211100.0
2020-05-28  183.561005  322.510010  0.009631  0.013832  183.820007  323.000000  180.389999  315.630005  180.740005  316.769989  15009134.0  16107365.0

I'm writing this as part of a program that should be agnostic to whether columns are a MultiIndex or not, is there any cleaner/faster way I could do that without looping over the columns?

Body:
For Multiindexes, it is much safer to use the loc method to get your results.

In the code below, loc focuses on the columns (axis=0 would imply working on the rows), and selects "Close" and "High". You can safely place the replacement values on the other side of the equation, and should not get any errors.

I'd also suggest reading pandas docs on MultiIndexes for more information - I believe it will help you when working with multiIndexes:

a.loc(axis=1)[["Close","High"]] = a[["Close","High"]].pct_change().fillna(0)


答:
Maybe it will help you. I just add a CSS selector for the icon.</p>

```<code>.sidebar .menu li a:hover i{
   color:red;
}
</code>```

Body:
While I hover over an  tag area I want to switch the icon's color but for some reason it remains the same. I was able to get the wanted result only if I pinpointed the icon directly
.sidebar .menu li a .icon:hover{background: #ecedf2;color: #3d5654;} but I have to hover exactly over the icon. What I wanted to achieve is to change the icon's color while a hover over the  tag area. Let me know if I am doing something wrong.

HTML

      Dashboard

CSS

* {
  list-style: none;
  text-decoration: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Jost', sans-serif;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100wh;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  display: grid;
  grid-template-columns: auto 8fr;
  grid-template-rows: 80px auto 50px;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
}

.sidebar {
  grid-area: sidebar;
  width: 260px;
  background: #2c343b;
  height: 100%;
}

.sidebar .menu {
  padding-right: 30px;
  padding-left: 20px;
  margin: 0;
  overflow: auto;
  transition: all 0.5s;
}

.sidebar .menu li a {
  color: #ecedf2;
  display: block;
  width: 100%;
  line-height: 60px;
  text-decoration: none;
  padding: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1px;
  transition: 0.5s;
}

.sidebar .menu li a .icon {
  color: #ecedf2;
  width: 25px;
  display: inline-block;
}

.sidebar .menu li a:hover,
.sidebar .menu li a.active {
  background: #ecedf2;
  color: #3d5654;
}

Body:
Maybe it will help you. I just add a CSS selector for the icon.

.sidebar .menu li a:hover i{
   color:red;
}


问:
Deploy WAR to Tomcat (Spring Boot + Angular)
I am trying to deploy the Spring Boot Application with WAR packaging to Tomcat 10. The application gets deployed successfully, however, when I try to access the endpoints it results in 404 Not Found.

WAR File: application.war

```<code>http://localhost:8080/application/api/abc -> 404 Not Found (Spring Boot Endpoint)
http://localhost:8080/application/abc -> 404 Not Found (Angular URL which calls /api/abc)
</code>```

Tomcat webapps/application folder consists of following and index.html (Angular) have <base href="/">

As discussed here, I have added a class AppServletInitializer which extends SpringBootServletInitializer as follow

```<code>@Configuration
public class AppServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringApp.class);
    }
}
</code>```

In pom.xml, I have added the dependency for spring-boot-starter-tomcat, tomcat-embed-jasper and set packaging option as war. I have shared the simplified (removed dependency, plugins. will add the same if required)

pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.name</groupId>
    <artifactId>application</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>My Application</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8.RELEASE</version>
        <relativePath />
    </parent>

    <properties>
        <!-- Build properties -->
        <maven.version>3.3.9</maven.version>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
        <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
        <m2e.apt.activation>jdt_apt</m2e.apt.activation>
        <run.addResources>false</run.addResources>

        <jhipster-dependencies.version>3.0.5</jhipster-dependencies.version>
        <spring-boot.version>2.1.8.RELEASE</spring-boot.version>
        <spring.version>5.1.9.RELEASE</spring.version>
        <hibernate.version>5.3.11.Final</hibernate.version>
        <javassist.version>3.23.2-GA</javassist.version>
        <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
        <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
        <maven-war-plugin.version>3.2.3</maven-war-plugin.version>
        <properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>spring-boot:run</defaultGoal>
        <finalName>application</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>${start-class}</mainClass>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <optional>true</optional>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>prod</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>target/classes/static/</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <mainClass>${start-class}</mainClass>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-info</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!--                    <plugin>-->
                    <!--                        <groupId>org.apache.maven.plugins</groupId>-->
                    <!--                        <artifactId>maven-war-plugin</artifactId>-->
                    <!--                        <version>${maven-war-plugin.version}</version>-->
                    <!--                        <executions>-->
                    <!--                            <execution>-->
                    <!--                                <goals>-->
                    <!--                                    <goal>war</goal>-->
                    <!--                                </goals>-->
                    <!--                                <phase>package</phase>-->
                    <!--                            </execution>-->
                    <!--                        </executions>-->
                    <!--                        <configuration>-->
                    <!--                            <!–<warSourceIncludes>WEB-INF/**,META-INF/**</warSourceIncludes>–>-->
                    <!--                            <failOnMissingWebXml>false</failOnMissingWebXml>-->
                    <!--                        </configuration>-->
                    <!--                    </plugin>-->
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
</code>```

Application.java

```<code>import io.github.jhipster.config.JHipsterConstants;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.core.env.Environment;

@SpringBootApplication
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class, AppServletInitializer.class})
public class Application extends SpringBootServletInitializer implements InitializingBean {

    private static final Logger log = LoggerFactory.getLogger(Application.class);

    private final Environment env;

    public Application(Environment env) {
        this.env = env;
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
        if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
            log.error("You have misconfigured your application! It should not run " +
                "with both the 'dev' and 'prod' profiles at the same time.");
        }
        if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
            log.error("You have misconfigured your application! It should not " +
                "run with both the 'dev' and 'cloud' profiles at the same time.");
        }
    }

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        DefaultProfileUtil.addDefaultProfile(app);
        Environment env = app.run(args).getEnvironment();
        logApplicationStartup(env);
    }

    private static void logApplicationStartup(Environment env) {
        String protocol = "http";
        if (env.getProperty("server.ssl.key-store") != null) {
            protocol = "https";
        }
        String serverPort = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path");
        if (StringUtils.isBlank(contextPath)) {
            contextPath = "/";
        }
        String hostAddress = "localhost";
        try {
            hostAddress = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            log.warn("The host name could not be determined, using `localhost` as fallback");
        }
        log.info("\n----------------------------------------------------------\n\t" +
                "Application '{}' is running! Access URLs:\n\t" +
                "Local: \t\t{}://localhost:{}{}\n\t" +
                "External: \t{}://{}:{}{}\n\t" +
                "Profile(s): \t{}\n----------------------------------------------------------",
            env.getProperty("spring.application.name"),
            protocol,
            serverPort,
            contextPath,
            protocol,
            hostAddress,
            serverPort,
            contextPath,
            env.getActiveProfiles());
    }
}
</code>```

application.yml

```<code>server:
  servlet:
    context-path: /application
</code>```

We are using Angular on the client-side and resources are located in the static folder.

Environment:
Spring Boot 2.1.8,
Angular 8,
Java 11,

I have already referred, unfortunately, none of them is working for me. Any help would be Appreciated

Create a Deployable War File

Spring Boot War Deploy

Can not access deployed WAR file on Tomcat

答:
The configuration was correct in the Project. As mentioned in the comment, there might be some issue with Tomcat 10 as it was in the alpha version. I have used Tomcat 9 it was working fine.

The configuration are as below.

Step 1: Change the packing option to war in pom.xml

<packaging>war</packaging>

Step 2: extends SpringBootServletInitializer

```<code>import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
 * This is a helper Java class that provides an alternative to creating a {@code web.xml}.
 * This will be invoked only when the application is deployed to a Servlet container like Tomcat, JBoss etc.
 */
public class ApplicationWebXml extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ApplicationApp.class);
    }
}
</code>```

Step 3: Create WAR file

```<code>mvn clean install
</code>```

And there we go! We can access the endpoints at

```<code>http://localhost:8080/context-path/endpoint OR
http://localhost:8080/war-filename/endpoint
</code>```

We can also create the profile for war as below

<properties>
    <maven-war-plugin.version>3.2.3</maven-war-plugin.version>
</properties>

     <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven-war-plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>war</goal>
                            </goals>
                            <phase>package</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <warSourceIncludes>WEB-INF/**,META-INF/**</warSourceIncludes>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <warSourceDirectory>target/classes/static/</warSourceDirectory>
                        <webResources>
                            <resource>
                                <directory>src/main/webapp</directory>
                                <includes>
                                    <include>WEB-INF/**</include>
                                </includes>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>war</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

```

Body:
I am trying to deploy the Spring Boot Application with WAR packaging to Tomcat 10. The application gets deployed successfully, however, when I try to access the endpoints it results in 404 Not Found.

WAR File: application.war

http://localhost:8080/application/api/abc -> 404 Not Found (Spring Boot Endpoint)
http://localhost:8080/application/abc -> 404 Not Found (Angular URL which calls /api/abc)

Tomcat webapps/application folder consists of following and index.html (Angular) have <base href="/">

As discussed here, I have added a class AppServletInitializer which extends SpringBootServletInitializer as follow

@Configuration
public class AppServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringApp.class);
    }
}

In pom.xml, I have added the dependency for spring-boot-starter-tomcat, tomcat-embed-jasper and set packaging option as war. I have shared the simplified (removed dependency, plugins. will add the same if required)

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.name</groupId>
    <artifactId>application</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>My Application</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8.RELEASE</version>
        <relativePath />
    </parent>

    <properties>

        <maven.version>3.3.9</maven.version>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
        <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
        <m2e.apt.activation>jdt_apt</m2e.apt.activation>
        <run.addResources>false</run.addResources>

        <jhipster-dependencies.version>3.0.5</jhipster-dependencies.version>
        <spring-boot.version>2.1.8.RELEASE</spring-boot.version>
        <spring.version>5.1.9.RELEASE</spring.version>
        <hibernate.version>5.3.11.Final</hibernate.version>
        <javassist.version>3.23.2-GA</javassist.version>
        <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
        <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
        <maven-war-plugin.version>3.2.3</maven-war-plugin.version>
        <properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>spring-boot:run</defaultGoal>
        <finalName>application</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>${start-class}</mainClass>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <optional>true</optional>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>prod</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>target/classes/static/</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <mainClass>${start-class}</mainClass>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-info</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>
</project>

Application.java

import io.github.jhipster.config.JHipsterConstants;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.core.env.Environment;

@SpringBootApplication
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class, AppServletInitializer.class})
public class Application extends SpringBootServletInitializer implements InitializingBean {

    private static final Logger log = LoggerFactory.getLogger(Application.class);

    private final Environment env;

    public Application(Environment env) {
        this.env = env;
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
        if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
            log.error("You have misconfigured your application! It should not run " +
                "with both the 'dev' and 'prod' profiles at the same time.");
        }
        if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
            log.error("You have misconfigured your application! It should not " +
                "run with both the 'dev' and 'cloud' profiles at the same time.");
        }
    }

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        DefaultProfileUtil.addDefaultProfile(app);
        Environment env = app.run(args).getEnvironment();
        logApplicationStartup(env);
    }

    private static void logApplicationStartup(Environment env) {
        String protocol = "http";
        if (env.getProperty("server.ssl.key-store") != null) {
            protocol = "https";
        }
        String serverPort = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path");
        if (StringUtils.isBlank(contextPath)) {
            contextPath = "/";
        }
        String hostAddress = "localhost";
        try {
            hostAddress = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            log.warn("The host name could not be determined, using `localhost` as fallback");
        }
        log.info("\n----------------------------------------------------------\n\t" +
                "Application '{}' is running! Access URLs:\n\t" +
                "Local: \t\t{}://localhost:{}{}\n\t" +
                "External: \t{}://{}:{}{}\n\t" +
                "Profile(s): \t{}\n----------------------------------------------------------",
            env.getProperty("spring.application.name"),
            protocol,
            serverPort,
            contextPath,
            protocol,
            hostAddress,
            serverPort,
            contextPath,
            env.getActiveProfiles());
    }
}

application.yml

server:
  servlet:
    context-path: /application

We are using Angular on the client-side and resources are located in the static folder.

Environment:
Spring Boot 2.1.8,
Angular 8,
Java 11,

I have already referred, unfortunately, none of them is working for me. Any help would be Appreciated

Create a Deployable War File

Spring Boot War Deploy

Can not access deployed WAR file on Tomcat

Body:
The configuration was correct in the Project. As mentioned in the comment, there might be some issue with Tomcat 10 as it was in the alpha version. I have used Tomcat 9 it was working fine.

The configuration are as below.

Step 1: Change the packing option to war in pom.xml

<packaging>war</packaging>

Step 2: extends SpringBootServletInitializer

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
 * This is a helper Java class that provides an alternative to creating a {@code web.xml}.
 * This will be invoked only when the application is deployed to a Servlet container like Tomcat, JBoss etc.
 */
public class ApplicationWebXml extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ApplicationApp.class);
    }
}

Step 3: Create WAR file

mvn clean install

And there we go! We can access the endpoints at

http://localhost:8080/context-path/endpoint OR
http://localhost:8080/war-filename/endpoint

We can also create the profile for war as below

<properties>
    <maven-war-plugin.version>3.2.3</maven-war-plugin.version>
</properties>

     <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven-war-plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>war</goal>
                            </goals>
                            <phase>package</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <warSourceIncludes>WEB-INF/**,META-INF/**</warSourceIncludes>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <warSourceDirectory>target/classes/static/</warSourceDirectory>
                        <webResources>
                            <resource>
                                <directory>src/main/webapp</directory>
                                <includes>
                                    <include>WEB-INF/**</include>
                                </includes>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>war</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>


问:
How to insert into sql table while VSTS load test is also inserting
I need to track custom information  associated with each request URI during 'load test' run.

I know that VSTS stores 'requestURI' in table called 'WebLoadTestRequestMap'.

Could some one tell me how to achieve this?

答:
You would have to add your own new table to the database (with LoadTestRunId as a foreign key) and insert your custom information into that table in the PostRequest event.

There is no way to alter the automatic behaviour of the load test engine when it adds data to the load test database.


问:
How to change the order of DataFrame columns?
I have the following DataFrame (df):

```<code>import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.rand(10, 5))
</code>```

I add more column(s) by assignment:

```<code>df['mean'] = df.mean(1)
</code>```

How can I move the column mean to the front, i.e. set it as first column leaving the order of the other columns untouched?

答:
Suppose you have df with columns A B C.

The most simple way is:

```<code>df = df.reindex(['B','C','A'], axis=1)
</code>```

Body:
I have the following DataFrame (df):

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.rand(10, 5))

I add more column(s) by assignment:

df['mean'] = df.mean(1)

How can I move the column mean to the front, i.e. set it as first column leaving the order of the other columns untouched?

Body:
Suppose you have df with columns A B C.

The most simple way is:

df = df.reindex(['B','C','A'], axis=1)


问:
Is there any way I can output the variable name instead of the value? [JAVA]
for example, I have a list of integer variables

```<code>int CLUTCH_CASE = 8;
int CS20 = 6;
int DANGER_ZONE_CASE = 6;
int TOTAL_CASE = 0;
</code>```

I have an array:

```<code>int CaseValue[] = {CS20, CLUTCH_CASE, DANGER_ZONE_CASE};
</code>```

and I output the value of total cases, which is going to be:

```<code>for (int counter=0;counter<CaseValue.length;counter++) {
    TOTAL_CASE += CaseValue[counter];
}
System.out.println("You have "+CaseValue.length+" CSGO Cases");
System.out.println("You have a total of "+TOTAL_CASE+" CSGO Cases:");
</code>```

Output:

```<code>You have 3 CSGO Cases
You have a total of 20 CSGO Cases:
</code>```

yet I also want to output the name.

Example:
(CASENAME are just placeholders for this example. I wanted to use CaseValue[].NAME even that does not exist since it's an example)

```<code>for (int counter2=0;counter2<CaseValue.length;counter2++) {
    System.out.println(CASENAME+": "+CaseValue[counter2]);
}
</code>```

My expected and wanted output to be:

```<code>CLUTCH_CASE: 8
CS20: 6
DANGER_ZONE_CASE: 6
</code>```

Is there any way to output the name of the integer variable?

答:
Use a Map.

```<code>Map<String, Integer> ma = new Hashmap()
for (int counter=0;counter<CaseValue.length;counter++) {
    TOTAL_CASE += CaseValue[counter];
    ma.put(<your_key>, <your_value>)
}
</code>```

I still dont understand your code completely. So cannot give you a full working snippet. I have however added a snippet on how you could possibly use a map. Store the key as the name that you want and its corresponding value in that key of the map.

Body:
for example, I have a list of integer variables

int CLUTCH_CASE = 8;
int CS20 = 6;
int DANGER_ZONE_CASE = 6;
int TOTAL_CASE = 0;

I have an array:

int CaseValue[] = {CS20, CLUTCH_CASE, DANGER_ZONE_CASE};

and I output the value of total cases, which is going to be:

for (int counter=0;counter<CaseValue.length;counter++) {
    TOTAL_CASE += CaseValue[counter];
}
System.out.println("You have "+CaseValue.length+" CSGO Cases");
System.out.println("You have a total of "+TOTAL_CASE+" CSGO Cases:");

Output:

You have 3 CSGO Cases
You have a total of 20 CSGO Cases:

yet I also want to output the name.

Example:
(CASENAME are just placeholders for this example. I wanted to use CaseValue[].NAME even that does not exist since it's an example)

for (int counter2=0;counter2<CaseValue.length;counter2++) {
    System.out.println(CASENAME+": "+CaseValue[counter2]);
}

My expected and wanted output to be:

CLUTCH_CASE: 8
CS20: 6
DANGER_ZONE_CASE: 6

Is there any way to output the name of the integer variable?

Body:
Use a Map.

Map<String, Integer> ma = new Hashmap()
for (int counter=0;counter<CaseValue.length;counter++) {
    TOTAL_CASE += CaseValue[counter];
    ma.put(<your_key>, <your_value>)
}

I still dont understand your code completely. So cannot give you a full working snippet. I have however added a snippet on how you could possibly use a map. Store the key as the name that you want and its corresponding value in that key of the map.


问:
forEach works without passing arguments?
```<code>var arr = [2, 3];

const addNum = (num) => console.log(num + 2);

arr.forEach(addNum);

Result in the console:
// 4
// 5
</code>```

<p>In the above code, I used the forEach method and as a callback function, I used the addNum function. But, in the addNum function I didn't pass any arguments and it still works, how come? </p>

答: Because foreach receives a callback(currentValue [, index [, array]]) so in this case the currentValue is num

Body:
var arr = [2, 3];

const addNum = (num) => console.log(num + 2);

arr.forEach(addNum);

Result in the console:
// 4
// 5

In the above code, I used the forEach method and as a callback function, I used the addNum function. But, in the addNum function I didn't pass any arguments and it still works, how come?


答:
The forEach function has an argument that takes a function.

The documentation specifies the signature as:

```<code>arr.forEach(callback(currentValue [, index [, array]])[, thisArg])
</code>```

You can give that function however you like. It could be pre-defined, or it could be inline, as in forEach(function(x) { ... }) or forEach(x => ...).

You have a lot of flexibility in how you call functions like forEach as they generally follow the same rules. This is a pattern you'll see a lot of in JavaScript.

Title: forEach works without passing arguments?

Body:
The forEach function has an argument that takes a function.

The documentation specifies the signature as:

arr.forEach(callback(currentValue [, index [, array]])[, thisArg])

You can give that function however you like. It could be pre-defined, or it could be inline, as in forEach(function(x) { ... }) or forEach(x => ...).

You have a lot of flexibility in how you call functions like forEach as they generally follow the same rules. This is a pattern you'll see a lot of in JavaScript.


问:
How to change Icon color while hover over an  tag
While I hover over an  tag area I want to switch the icon's color but for some reason it remains the same. I was able to get the wanted result only if I pinpointed the icon directly
.sidebar .menu li a .icon:hover{background: #ecedf2;color: #3d5654;} but I have to hover exactly over the icon. What I wanted to achieve is to change the icon's color while a hover over the  tag area. Let me know if I am doing something wrong.

HTML

```<code><div class="sidebar">
  <ul class="menu">
    <li>
      <a href="#"
        ><span class="icon"><i class="fas fa-desktop"></i></span
        ><span class="text">Dashboard</span></a
      >
    </li>
  </ul>
</div>
</code>```

CSS

```<code>* {
  list-style: none;
  text-decoration: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Jost', sans-serif;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100wh;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  display: grid;
  grid-template-columns: auto 8fr;
  grid-template-rows: 80px auto 50px;
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
}

.sidebar {
  grid-area: sidebar;
  width: 260px;
  background: #2c343b;
  height: 100%;
}

.sidebar .menu {
  padding-right: 30px;
  padding-left: 20px;
  margin: 0;
  overflow: auto;
  transition: all 0.5s;
}

.sidebar .menu li a {
  color: #ecedf2;
  display: block;
  width: 100%;
  line-height: 60px;
  text-decoration: none;
  padding: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1px;
  transition: 0.5s;
}

.sidebar .menu li a .icon {
  color: #ecedf2;
  width: 25px;
  display: inline-block;
}

.sidebar .menu li a:hover,
.sidebar .menu li a.active {
  background: #ecedf2;
  color: #3d5654;
}
</code>```

答:
You can achieve this with the :hover (it's a pseudo class)
syntax

```<code>a:hover { color : value }
</code>```

//a is the element you want the hover to apply to//
//check mdn documentation,pseudo class//

Body:
You can achieve this with the :hover (it's a pseudo class)
syntax

a:hover { color : value }

//a is the element you want the hover to apply to//
//check mdn documentation,pseudo class//


问:
How to skip a before_filter for Devise's SessionsController?
I have a before_filter in my ApplicationController; that is, for every controller in my project.

How can I skip_before_filter for Devise's SessionsController create action ?

答:
We did something like this:

First up, create your own session controller, make sure to inherit correctly:

```<code>class SessionsController < Devise::SessionsController
  skip_before_filter :foobar
</code>```

Then fix the routes

```<code>devise_for :users,
  :controllers => {
    :sessions => "sessions"
  }
</code>```

Alternatively you could monkey-patch Devise's session controller.

Body:
We did something like this:

First up, create your own session controller, make sure to inherit correctly:

class SessionsController < Devise::SessionsController
  skip_before_filter :foobar

Then fix the routes

devise_for :users,
  :controllers => {
    :sessions => "sessions"
  }

Alternatively you could monkey-patch Devise's session controller.


问:
Question mark characters display within text. Why is this?
I have a backup server that automatically backs up my live site, both files and database.

On the live site, the text looks fine, but when you view the mirrored version of it, it displays '?' within some of the text. This text is stored within the news database table.

Here is a screenshot of it being on the live server and of it on the mirrored server.

What could happen within the process of backing it up to the mirrored server?

The live server is Solaris, and the mirrored server is Linux Red Hat Linux 5.

答:
I had this issue so I just took all my content, copy/pasted it into Notepad, made a new PHP file, pasted back in, re-saved and overwrote, and.. that worked!

It really was some relic of Microsoft Word editing...

OwnerDisplayName: Brad

LastEditorDisplayName: BradC


答:
There is no command in Java to access the variable name.

You could use a map (like stated in other answers), but I'd also like to present a simple possibility that is possible without advanced features of Java.

What you could do is the following:

```<code>String[] caseName = {"CS20", "CLUTCH_CASE", "DANGER_ZONE_CASE"};
</code>```

After that you can do:

```<code>for (int i=0; i<CaseValue.length; i++) {
    System.out.println(caseName[i] + ": " + CaseValue[i]);
}
</code>```

Title: Is there any way I can output the variable name instead of the value? [JAVA]

Body:
There is no command in Java to access the variable name.

You could use a map (like stated in other answers), but I'd also like to present a simple possibility that is possible without advanced features of Java.

What you could do is the following:

String[] caseName = {"CS20", "CLUTCH_CASE", "DANGER_ZONE_CASE"};

After that you can do:

for (int i=0; i<CaseValue.length; i++) {
    System.out.println(caseName[i] + ": " + CaseValue[i]);
}


问:
Angular routing not working when deployed statically with Node
I am building my angular project and inserting the build output into a public folder in the root of my node project.

In my app.js file, I have the following code:

```<code>...
app.use(express.static(path.join(__dirname, 'public')));
...
app.get('*', (req, res) => {
     res.send(path.join(__dirname, 'public/index.html'));
});
</code>```

When deploying the project, this works perfectly; when I load the page, the index.html is rendered and navigating through the page works.

However, when I enter a url like for example '/admin', which is defined in my angular routing, I get a not found error.

How can this be solved?

答:
I don't know your code but

you can try setting up the base-href in your index.html

```<code><base href="/">
</code>```

properly....

Serving with nginx could have a configuration like this. It directs the index.html to the correct routes of your SPA:

```<code>root /home/app/dist/;

server {
    listen 8080;
    server_name  localhost;

    location /admin/ {
      alias /home/app/dist/my-app/admin/;
      expires -1;
      add_header Cache-Control "no-cache, must-revalicate, post-check=0 pre-check=0";
      index index.html;
      try_files $uri $uri/ index.html =404;
    }

    location / {
      alias /home/app/dist/my-app/;
      expires -1;
      add_header Cache-Control "no-cache, must-revalicate, post-check=0 pre-check=0";
      index index.html;
      try_files $uri $uri/ index.html =404;
    }
}
</code>```

see nginx how-to here: https://medium.com/better-programming/how-to-properly-get-angular-and-nginx-working-together-for-development-3e5d158734bf

Body:
I am building my angular project and inserting the build output into a public folder in the root of my node project.

In my app.js file, I have the following code:

...
app.use(express.static(path.join(__dirname, 'public')));
...
app.get('*', (req, res) => {
     res.send(path.join(__dirname, 'public/index.html'));
});

When deploying the project, this works perfectly; when I load the page, the index.html is rendered and navigating through the page works.

However, when I enter a url like for example '/admin', which is defined in my angular routing, I get a not found error.

How can this be solved?

Body:
I don't know your code but

you can try setting up the base-href in your index.html

<base href="/">

properly....

Serving with nginx could have a configuration like this. It directs the index.html to the correct routes of your SPA:

root /home/app/dist/;

server {
    listen 8080;
    server_name  localhost;

    location /admin/ {
      alias /home/app/dist/my-app/admin/;
      expires -1;
      add_header Cache-Control "no-cache, must-revalicate, post-check=0 pre-check=0";
      index index.html;
      try_files $uri $uri/ index.html =404;
    }

    location / {
      alias /home/app/dist/my-app/;
      expires -1;
      add_header Cache-Control "no-cache, must-revalicate, post-check=0 pre-check=0";
      index index.html;
      try_files $uri $uri/ index.html =404;
    }
}

see nginx how-to here: https://medium.com/better-programming/how-to-properly-get-angular-and-nginx-working-together-for-development-3e5d158734bf


问:
CSS overflow Property/Update
Is there a new update for CSS? For some reason, I noticed that my website and several others that usually has overflow : auto now has a visible scroll? I though it was my browser( Chrome ) turns out, its with firefox and safari as well.

答: So i found the actual cause of this. When the computer registers a mouse, it automatically adds scroll bars as default. This can be configured in the settings > general > show scroll bars option

Title: CSS overflow Property/Update


答:
```<code>arr.forEach(callback(currentValue [, index [, array]])[, thisArg])
</code>```

Because forEach() method executes a provided function once for each array element.

Body:
arr.forEach(callback(currentValue [, index [, array]])[, thisArg])

Because forEach() method executes a provided function once for each array element.


答:
You can achieve using this code</p>

```<code>.sidebar .menu a:hover i{
        background: #ecedf2;
        color: #3d5654;
}
</code>```

Body:
You can achieve using this code

.sidebar .menu a:hover i{
        background: #ecedf2;
        color: #3d5654;
}


问:
How to upload contacts CSV file to my Gmail account?
Just wondering whether it' s possible to upload a CSV file with contacts information in it to my Gmail account?

I already looked at the Google Data API. it only allows you to add one at a time. Is there a bulk import ?

答: If it's not in the API then the answer's probably "no".  But it';s wouldn't be hard to write a script to parse the CSV file and call the API to import each contact in turn.</p>


问:
Bulk rename txt files with different parts using Python
I have a list of files that I wish to rename to.

Receipt ABC-001 623572349-1.txt --> Receipt ABC-001A.txt

Receipt ABC-001 623572349-2.txt --> Receipt ABC-001B.txt

However, even at the first step, everytime  I get the following error "Cannot create a file when that file already exists:". What would be the best option to achieve the above outcome where files ending with 1 will become A; ending with 5.txt will become E.txt, and soforth?

Below is the code I have used:

```<code>import os, fnmatch

#Set directory of locataion; include double slash for each subfolder.
file_path = "C:\\Users\\Mr.Slowbro\\Desktop\\TBU\\"

#Set file extension accordingly
files_to_rename = fnmatch.filter(os.listdir(file_path), '*.txt')

for file_name in files_to_rename:
    file_name_new = file_name[-5:5]
    os.rename(file_path + file_name, file_path + file_name_new)
</code>```

答:
This should help you out. Using the ord() function returns the Unicode point of a character. So 'a' would be 97, 'b' would be 98, etc. Likewise, chr() returns the character of that Unicode point. So, I think the code below will help you with your issue.</p>

```<code>
#Set directory of locataion; include double slash for each subfolder.
file_path = "C:\\Users\\Mr.Slowbro\\Desktop\\TBU\\"

#Set file extension accordingly
files_to_rename = fnmatch.filter(os.listdir(file_path), '*.txt')

for file_name in files_to_rename:
    number = chr(int(file_name[-5]) - 1 + ord('A'))
    file_name_new = 'Receipt ABC-001' + number + '.txt'
    os.rename(file_name, file_name_new)```
</code>```

Body:
I have a list of files that I wish to rename to.

Receipt ABC-001 623572349-1.txt --> Receipt ABC-001A.txt

Receipt ABC-001 623572349-2.txt --> Receipt ABC-001B.txt

However, even at the first step, everytime  I get the following error "Cannot create a file when that file already exists:". What would be the best option to achieve the above outcome where files ending with 1 will become A; ending with 5.txt will become E.txt, and soforth?

Below is the code I have used:

import os, fnmatch

#Set directory of locataion; include double slash for each subfolder.
file_path = "C:\\Users\\Mr.Slowbro\\Desktop\\TBU\\"

#Set file extension accordingly
files_to_rename = fnmatch.filter(os.listdir(file_path), '*.txt')

for file_name in files_to_rename:
    file_name_new = file_name[-5:5]
    os.rename(file_path + file_name, file_path + file_name_new)

Body:
This should help you out. Using the ord() function returns the Unicode point of a character. So 'a' would be 97, 'b' would be 98, etc. Likewise, chr() returns the character of that Unicode point. So, I think the code below will help you with your issue.

#Set directory of locataion; include double slash for each subfolder.
file_path = "C:\\Users\\Mr.Slowbro\\Desktop\\TBU\\"

#Set file extension accordingly
files_to_rename = fnmatch.filter(os.listdir(file_path), '*.txt')

for file_name in files_to_rename:
    number = chr(int(file_name[-5]) - 1 + ord('A'))
    file_name_new = 'Receipt ABC-001' + number + '.txt'
    os.rename(file_name, file_name_new)```


问:
ESRI : Failed to parse source map
I am getting this error in the Google chrome developer console.

Failed to parse SourceMap:
  http://localhost:15132/Scripts/_External/igniteui/css/themes/infragistics/infragistics.theme.css.map

How do I fix it?

答:
I noticed that problem because of AdBlock Extension,
I turned off AdBlock extension the issue got resolve.</p>

Title: ESRI : Failed to parse source map