问:
Flexbox wont expand
Working with a flexsite project and trying to make a flex element to expand when more "content" is added than the current height.

At the moment a scrollbar is added. But I want it to expand. Anyone know what I am doing wrong?

JSfiddle

html,
body,
.r_flex_container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: red;
  margin: 0;
}

.r_flex_container {
  display: flex;
  flex-flow: column nowrap;
  background-color: blue;
}

.r_flex_fixed_child {
  flex: none;
  background-color: black;
  color: white;
  height: 100px;
}

.r_flex_expand_child {
  flex: auto;
  overflow: auto;
  background-color: yellow;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="r_flex_container">
  <div class="r_flex_fixed_child">
    <p> This is the fixed child of the flex container </p>
  </div>
  <div class="slide">

  </div>
  <div class="r_flex_expand_child">
    <article>an article blah blah blah an article blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf
      asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article
      blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah
      blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf
      asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf
      an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an
      article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an
      article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf asdf 1 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
    </article>
  </div>
  <div class="r_flex_fixed_child">
    this is the fixed footer child of the flex container asdfadsf
    <p> another line</p>
  </div></code>```

答:
The only thing you actually need to do is to remove overflow: auto from the .r_flex_expand_child rule.

That will work in most browsers but IE (see below for IE), and the reason it does, is that a flex item by default can't be smaller than its content, hence it will overflow with an outer scroll as result, though I find the min-height version below more correct.

Stack snippet

html, body, .r_flex_container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: red;
  margin: 0;
}

.r_flex_container {
  background-color: blue;
  /*display: flex;                 already set in first rule  */
  /*flex-flow: column nowrap;      already set in first rule, nowrap is default  */
}

.r_flex_fixed_child {
  flex: none;
  background-color: black;
  color: white;
  height: 100px;
}

.r_flex_expand_child {
  flex: auto;
  /*overflow: auto;                remove as it should not scroll  */
  background-color: yellow;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="r_flex_container">
  <div class="r_flex_fixed_child">
    <p> This is the fixed child of the flex container </p>
  </div>
  <div class="slide">

  </div>
  <div class="r_flex_expand_child">
    <article>an article blah blah blah an article blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf
      asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article
      blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah
      blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf
      asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf
      an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an
      article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an
      article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf asdf 1 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
    </article>
  </div>
  <div class="r_flex_fixed_child">
    this is the fixed footer child of the flex container asdfadsf
    <p> another line</p>
  </div>
</div></code>```

To make it work in IE, do these 2 things:

Remove height: 100% from the html, body, .r_flex_container { ... } rule

Add min-height: 100vh to .r_flex_container { ... } rule

The min-height: 100vh is needed for the .r_flex_container to fill the viewport, even if the elements are empty, and to allow it to grow when the content is bigger.

Stack snippet 2

html, body, .r_flex_container {
  /*height: 100%;                  removed  */
  display: flex;
  flex-direction: column;
  background: red;
  margin: 0;
}

.r_flex_container {
  min-height: 100vh;           /*  added  */
  background-color: blue;

  /*display: flex;                 already set in first rule  */
  /*flex-flow: column nowrap;      already set in first rule, nowrap is default  */
}

.r_flex_fixed_child {
  flex: none;
  background-color: black;
  color: white;
  height: 100px;
}

.r_flex_expand_child {
  flex: auto;
  /*overflow: auto;                remove as it should not scroll  */
  background-color: yellow;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="r_flex_container">
  <div class="r_flex_fixed_child">
    <p> This is the fixed child of the flex container </p>
  </div>
  <div class="slide">

  </div>
  <div class="r_flex_expand_child">
    <article>an article blah blah blah an article blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf
      asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article
      blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah
      blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf
      asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf
      an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an
      article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an
      article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf asdf 1 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
    </article>
  </div>
  <div class="r_flex_fixed_child">
    this is the fixed footer child of the flex container asdfadsf
    <p> another line</p>
  </div>
</div></code>```

Title: Flexbox wont expand

Body:
Working with a flexsite project and trying to make a flex element to expand when more "content" is added than the current height.

At the moment a scrollbar is added. But I want it to expand. Anyone know what I am doing wrong?

JSfiddle

html,
body,
.r_flex_container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: red;
  margin: 0;
}

.r_flex_container {
  display: flex;
  flex-flow: column nowrap;
  background-color: blue;
}

.r_flex_fixed_child {
  flex: none;
  background-color: black;
  color: white;
  height: 100px;
}

.r_flex_expand_child {
  flex: auto;
  overflow: auto;
  background-color: yellow;
}

 This is the fixed child of the flex container

an article blah blah blah an article blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf
      asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article
      blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah
      blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf
      asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf
      an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an
      article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an
      article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf asdf 1 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf

    this is the fixed footer child of the flex container asdfadsf

 another line

Body:
The only thing you actually need to do is to remove overflow: auto from the .r_flex_expand_child rule.

That will work in most browsers but IE (see below for IE), and the reason it does, is that a flex item by default can't be smaller than its content, hence it will overflow with an outer scroll as result, though I find the min-height version below more correct.

Stack snippet

html, body, .r_flex_container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: red;
  margin: 0;
}

.r_flex_container {
  background-color: blue;
  /*display: flex;                 already set in first rule  */
  /*flex-flow: column nowrap;      already set in first rule, nowrap is default  */
}

.r_flex_fixed_child {
  flex: none;
  background-color: black;
  color: white;
  height: 100px;
}

.r_flex_expand_child {
  flex: auto;
  /*overflow: auto;                remove as it should not scroll  */
  background-color: yellow;
}

<div class="r_flex_container">
  <div class="r_flex_fixed_child">
    <p> This is the fixed child of the flex container </p>
  </div>
  <div class="slide">

  </div>
  <div class="r_flex_expand_child">
    <article>an article blah blah blah an article blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf
      asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article
      blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah
      blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf
      asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf
      an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an
      article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an
      article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf asdf 1 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
    </article>
  </div>
  <div class="r_flex_fixed_child">
    this is the fixed footer child of the flex container asdfadsf
    <p> another line</p>
  </div>
</div>

To make it work in IE, do these 2 things:

Remove height: 100% from the html, body, .r_flex_container { ... } rule

Add min-height: 100vh to .r_flex_container { ... } rule

The min-height: 100vh is needed for the .r_flex_container to fill the viewport, even if the elements are empty, and to allow it to grow when the content is bigger.

Stack snippet 2

html, body, .r_flex_container {
  /*height: 100%;                  removed  */
  display: flex;
  flex-direction: column;
  background: red;
  margin: 0;
}

.r_flex_container {
  min-height: 100vh;           /*  added  */
  background-color: blue;

  /*display: flex;                 already set in first rule  */
  /*flex-flow: column nowrap;      already set in first rule, nowrap is default  */
}

.r_flex_fixed_child {
  flex: none;
  background-color: black;
  color: white;
  height: 100px;
}

.r_flex_expand_child {
  flex: auto;
  /*overflow: auto;                remove as it should not scroll  */
  background-color: yellow;
}

<div class="r_flex_container">
  <div class="r_flex_fixed_child">
    <p> This is the fixed child of the flex container </p>
  </div>
  <div class="slide">

  </div>
  <div class="r_flex_expand_child">
    <article>an article blah blah blah an article blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf
      asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article
      blah blah blah asdfasdf asdf asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah
      blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf
      asdf 1 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf
      asdf an article blah blah blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf
      an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an
      article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an
      article blah blah blah asdfasdf asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf an article blah blah blah asdfasdf asdf asdf 1 an article blah blah
      blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 2 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah
      blah asdfasdf asdf asdf 3 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 4 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah
      asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 5 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 6 an article blah blah blah asdfasdf
      asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf 7 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
      asdf asdf 8 an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf asdf asdf asdf an article blah blah blah asdfasdf
    </article>
  </div>
  <div class="r_flex_fixed_child">
    this is the fixed footer child of the flex container asdfadsf
    <p> another line</p>
  </div>
</div>


来源: stackexchange

问:
How do I create a layout that can contain buttons in PyQt5?
I am trying to create a window that has a banner with two buttons underneath. I would like the layout to be like this:

Where I could put buttons in the green and blue boxes and an image in the red box. How would you go about doing something like this?

答:
I think the fastest and easiest way is to use Qt Designer.

Once there, basically, create your window (QWidgetfor example) and define your layout QVBoxLayout or QHBoxLayout before adding your buttonsQPushButton or images QImageor QIcon.

ContentLicense: CC BY-SA 3.0


问:
Filter stream using correlation between stream elements
Let’s say there’s a Person class that looks like this:

```<code>public class Person {
    private int id;
    private String discriminator;
    // some other fields plus getters/setters
}
</code>```

Now I have a Stream of Person elements and that stream may contain multiple Person instances that have same id, but different discriminator values, i.e. [Person{“id”: 1, “discriminator”: “A”}, Person{“id”: 1, “discriminator”: “B”}, Person{“id”: 2, “discriminator”: “A”}, ...]

What I’d like to do is to filter out all Person instances  with some id if there’s at least one Person instance with that id that has a particular discriminator value. So, continuing with the above example, filtering by discriminator value “A” would yield an empty collection (after the reduction operation, of course) and filtering by discriminator value “B” would yield a collection not containing any Person instance with id equal to 1.

I know I can reduce the stream using groupingBy collector and group elements by Person.id and then remove the mapping from the resulting Map if the mapped list contains a Person element with the specified discriminator value, but am still wondering if there’s a simpler way to achieve the same result?

答:
If I understood your problem correctly, you would first find all IDs that would match a discriminator:

```<code>Set<Integer> ids = persons.stream()
       .filter(p -> "A".equalsIgnoreCase(p.getDiscriminator()))
       .map(Person::getId)
       .collect(Collectors.toSet())
</code>```

And then remove the entries that would match those:

```<code>persons.removeIf(x -> ids.contains(x.getId()))
</code>```

Body:
Let’s say there’s a Person class that looks like this:

public class Person {
    private int id;
    private String discriminator;
    // some other fields plus getters/setters
}

Now I have a Stream of Person elements and that stream may contain multiple Person instances that have same id, but different discriminator values, i.e. [Person{“id”: 1, “discriminator”: “A”}, Person{“id”: 1, “discriminator”: “B”}, Person{“id”: 2, “discriminator”: “A”}, ...]

What I’d like to do is to filter out all Person instances  with some id if there’s at least one Person instance with that id that has a particular discriminator value. So, continuing with the above example, filtering by discriminator value “A” would yield an empty collection (after the reduction operation, of course) and filtering by discriminator value “B” would yield a collection not containing any Person instance with id equal to 1.

I know I can reduce the stream using groupingBy collector and group elements by Person.id and then remove the mapping from the resulting Map if the mapped list contains a Person element with the specified discriminator value, but am still wondering if there’s a simpler way to achieve the same result?

Body:
If I understood your problem correctly, you would first find all IDs that would match a discriminator:

Set<Integer> ids = persons.stream()
       .filter(p -> "A".equalsIgnoreCase(p.getDiscriminator()))
       .map(Person::getId)
       .collect(Collectors.toSet())

And then remove the entries that would match those:

persons.removeIf(x -> ids.contains(x.getId()))


问:
Scala main class error
My Program - HelloWorld.scala

```<code>object HelloWorld {
    def main(args: Array[String]): Unit = {
        println("Hello, world!")
    }
}
</code>```

jar cvfe HelloWorld.jar HelloWorld HelloWorld*.class

After jar file is created i tried to get the output from jar file

```<code>java -jar HelloWorld.jar
</code>```

but i got the error

```<code>    Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$
        at HelloWorld$.main(HelloWorld.scala:12)
        at HelloWorld.main(HelloWorld.scala)
Caused by: java.lang.ClassNotFoundException: scala.Predef$
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more
</code>```

答: You have to include the scala runtime and libraries into the java classpath, you can certainly do that from commandline, but I suggest you to use more comfortable tools, see for example the tutorial at www.scala-lang.org</p>

Title: Scala main class error

Body:
My Program - HelloWorld.scala

object HelloWorld {
    def main(args: Array[String]): Unit = {
        println("Hello, world!")
    }
}

jar cvfe HelloWorld.jar HelloWorld HelloWorld*.class

After jar file is created i tried to get the output from jar file

java -jar HelloWorld.jar

but i got the error

    Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$
        at HelloWorld$.main(HelloWorld.scala:12)
        at HelloWorld.main(HelloWorld.scala)
Caused by: java.lang.ClassNotFoundException: scala.Predef$
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more


问:
serialize inputs inside element (not form)
I have a HTML like:

```<code><table>
    <tr id="01">
        <td><input name="x"></td>
        <td><input name="y"></td>
    </tr>
    <tr id="02">
        <td><input name="x"></td>
        <td><input name="y"></td>
    </tr>
</table>
</code>```

And I'm trying to make a JSON string of the inputs only on a specific row. Would there be a good solution for this? Something like:

```<code>json = $('#01').serialize();
</code>```

but I need a json instead of the URLEncode'd string the serialize() provides.

答:
.serialize() can be used on a collection of inputs.

$("#submit").click(function() {
  var data = $("#01 input").serialize();
  console.log(data);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr id="01">
    <td><input name="x"></td>
    <td><input name="y"></td>
  </tr>
  <tr id="02">
    <td><input name="x"></td>
    <td><input name="y"></td>
  </tr>
</table>
<button id="submit">Click</button></code>```

BTW, the result of serialize() isn't JSON, it's application/x-www-form-urlencoded format.

Body:
I have a HTML like:

        <input name="x">
        <input name="y">

        <input name="x">
        <input name="y">

And I'm trying to make a JSON string of the inputs only on a specific row. Would there be a good solution for this? Something like:

json = $('#01').serialize();

but I need a json instead of the URLEncode'd string the serialize() provides.

Body:
.serialize() can be used on a collection of inputs.

$("#submit").click(function() {
  var data = $("#01 input").serialize();
  console.log(data);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr id="01">
    <td><input name="x"></td>
    <td><input name="y"></td>
  </tr>
  <tr id="02">
    <td><input name="x"></td>
    <td><input name="y"></td>
  </tr>
</table>
<button id="submit">Click</button>

BTW, the result of serialize() isn't JSON, it's application/x-www-form-urlencoded format.


问:
Order of exports in barrel file for provided services in Angular 2 changes DI behavior
This took me a while to figure out.  I'd greatly appreciate an explanation.

I keep all my core service files in a common folder which I then add to a barrel file called common.ts.

I import these services in app.module and provide them.

It appears the ordering of the services as exported from the barrel file makes a difference in the DI behavior.

When I run with the exports in this order

```<code>export { Core } from './core';
export { TestService } from './test-service';
</code>```

I receive

Can't resolve all parameters for OtherService: (?)

OtherService is a dummy service that is not included in the barren file as it is component specific for my testing.  OtherService is provided in app.module and is listed after TestService (not sure if that matters, but this has been a very weird day).

If I change the order of the exports in the common.ts barrel file to

```<code>export { TestService } from './test-service';
export { Core } from './core';
</code>```

OtherService will receive the TestService just fine.  The only other interaction I can think of is that CoreService is injected into app.component, but it has no dependency on TestService.

Why would changing the order of exports in a barrel file modify the behavior of the Angular DI engine?  That's crazy talk if you ask me.

If necessary I can try to reproduce online, but I'll wait for a request to do so.

Thanks for any input,
Mike

答:
TL;DR It seems there is no official answer.

Angular 2 - Dependency Injection and Barreling

This post has some insight but most importantly, it mentions that while it is indeed true that export order matters, it is not officially documented as such.

I would think of this in the same way I'd think of ordering my imports.

Body:
This took me a while to figure out.  I'd greatly appreciate an explanation.

I keep all my core service files in a common folder which I then add to a barrel file called common.ts.

I import these services in app.module and provide them.

It appears the ordering of the services as exported from the barrel file makes a difference in the DI behavior.

When I run with the exports in this order

export { Core } from './core';
export { TestService } from './test-service';

I receive

Can't resolve all parameters for OtherService: (?)

OtherService is a dummy service that is not included in the barren file as it is component specific for my testing.  OtherService is provided in app.module and is listed after TestService (not sure if that matters, but this has been a very weird day).

If I change the order of the exports in the common.ts barrel file to

export { TestService } from './test-service';
export { Core } from './core';

OtherService will receive the TestService just fine.  The only other interaction I can think of is that CoreService is injected into app.component, but it has no dependency on TestService.

Why would changing the order of exports in a barrel file modify the behavior of the Angular DI engine?  That's crazy talk if you ask me.

If necessary I can try to reproduce online, but I'll wait for a request to do so.

Thanks for any input,
Mike


问:
Recover Hibernate connection
Does anybody know a way to reestablish/retry again hibernate connection. I mean for example: the remote DB is down and I start my application. Hibernate is not able to establish a connection. it fails. But the application is not closed. Is there a way to say hibernate to try one more time to establish a connecton?

Thanks in advance

答:
C3P0 is the internal connection-pool implementation for hibernate.

Add "hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider"
in hibernate properties file. Create a file c3p0.properties setting the parameters accordingly. This file & c3p0-x.jar must be in classpath.

c3p0.properties

c3p0.idleConnectionTestPeriod : If this is a number greater than 0, c3p0 will test all idle, pooled but unchecked-out connections, every this number of seconds.

c3p0.testConnectionOnCheckout : Use only if necessary. Expensive. If true, an operation will be performed at every connection checkout to verify that the connection is valid. Better choice: verify connections periodically using idleConnectionTestPeriod.

There are several other properties that can be configured in hibernate.properties & c3p0.properties.

ContentLicense: CC BY-SA 2.5

Title: Recover Hibernate connection


问:
Converting from feed_dict to queues results in increasing loss
I have a working tensorflow model that I am trying to convert to using queues. It may not be the best function but it works.

The data comes in as a list(dict()) called 'rows' from a processing pipeline outside of TF in the form format [{'y1': 1,  'y2': 0, 'y3':1, 'y4':0, 'x1':...'x1182': 0}] (SPECIAL_FIELD_CHAR is 'y', meaning it's calculated from the 'xN' data). The features_outputs() just returns the xs and the ys as ['y1', 'y2', 'y3', 'y4'] and ['x1', ..., 'x1182']. The idea is that the xs determine the ys. There are 4 independent ys that are calculated per row of xs.

```<code>def train_rows(initial_weights, weights_filename, rows):
    (features, outputs ) = features_outputs(rows[0].keys())

    x_true = [ [float(row[feature]) for feature in features] for row in rows]
    try:
        y_true = [ [float(row[output]) for output in outputs] for row in rows ]
    except Exception as e:
        print [row[output] for output in outputs], e

    w_true = np.random.rand(len(features), 1) # init weights
    b_true = np.random.rand(1) # init bias

    x_in = tf.placeholder(tf.float32, [None, len(features)], "x_in")
    if initial_weights is None:
        w = tf.Variable(tf.random_normal((len(features), len(outputs))), name="w")
        b = tf.Variable(tf.constant(0.1, shape=[len(outputs)]), name="b")
    else:
        w = tf.Variable(weights['w'], name="w")
        b = tf.Variable(weights['b'], name="b")

    h = tf.add(tf.matmul(x_in, w), b, name="h")
    y_in = tf.placeholder(tf.float32, [None, len(outputs)], "y_in")
    loss_op = tf.reduce_mean(tf.square(tf.subtract(y_in, h)), name="loss")
    #train_op = tf.train.AdamOptimizer(0.01).minimize(loss_op)
    train_op = tf.train.GradientDescentOptimizer(0.3).minimize(loss_op)

    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        last_error = 1.7976931348623157e+308
        this_error = 1.7976931348623157e+307
        diff = 1
        iteration = initial_weights['iteration'] if initial_weights is not None and 'iteration' in initial_weights else 0
        while diff > 0:
            iteration += 1
            last_error = this_error
            for step in range(1000):
                sess.run(train_op, feed_dict={
                  x_in: x_true,
                  y_in: y_true
                })

            w_computed = sess.run(w)
            b_computed = sess.run(b)

            pred = tf.add(tf.matmul(x_in, w), b)

            results = sess.run(pred, feed_dict={x_in: x_true})
            error = tf.losses.mean_squared_error(y_true, results)
            this_error = float(error.eval())
            (diff, locs) = compare(y_true, results)
            if locs < 50:
                print "iteration:", iteration, "error:",this_error, "diff:", diff, "locs:", locs
</code>```

This produces a model that converges. However with the queue based version it does not, and error increases rapidly:

```<code>def multithreaded_train_rows(initial_weights, weights_filename, rows):
    (features, outputs ) = features_outputs(rows[0].keys())

    x_true = np.array([ [float(row[feature]) for feature in features] for row in rows])
    y_true = np.array([ [float(row[output]) for output in outputs] for row in rows ])

    #queue
    q = tf.FIFOQueue(capacity=len(rows), dtypes=tf.float32)
    #enq_op = q.enqueue_many(x_true)
    enq_op = q.enqueue_many(np.array( [ [float(row[f]) for f in sorted(row.keys())] for row in rows]  ))
    qr = tf.train.QueueRunner(q, [enq_op] * 1)
    tf.train.add_queue_runner(qr)

    keys = sorted(row.keys())
    x_indices = np.array([[i] for i in range(len(keys)) if not keys[i].startswith(SPECIAL_FIELD_CHAR)])
    y_indices = np.array([[i] for i in range(len(keys)) if     keys[i].startswith(SPECIAL_FIELD_CHAR)])

    input = q.dequeue()

    x_in = tf.transpose(tf.gather(input, x_indices))
    y_in = tf.gather(input, y_indices)

    if initial_weights is None:
        print 'Creating weights', len(x_indices), len(y_indices)
        w = tf.Variable(tf.random_normal((len(x_indices), len(y_indices))), name="w")
        b = tf.Variable(tf.constant(0.1, shape=[len(y_indices)]), name="b")
    else:
        print 'Using supplied weights', len(weights['w']), len(weights['w'][0])
        w = tf.Variable(weights['w'], name="w")
        b = tf.Variable(weights['b'], name="b")

    y = tf.add(tf.matmul(x_in, w), b, name="y")

    loss_op = tf.reduce_mean(tf.squared_difference(y_in, y), name="loss")
    train_op = tf.train.GradientDescentOptimizer(0.3).minimize(loss_op)

    print 'Starting session'
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)
        last_error = 1.7976931348623157e+308
        this_error = 1.7976931348623157e+307
        diff = 1
        iteration = initial_weights['iteration'] if initial_weights is not None and 'iteration' in initial_weights else 0
        while diff > 0:
            iteration += 1
            last_error = this_error
            for step in range(100):
                sess.run([train_op, loss_op])

            w_computed = sess.run(w)
            b_computed = sess.run(b)

            pred = tf.add(tf.matmul(x_in, w), b)

            results = sess.run(y, feed_dict={x_in: x_true})
            error = tf.losses.mean_squared_error(y_true, results)
            this_error = float(error.eval())

            (diff, locs) = compare(y_true, results)
            if locs < 50:
                print "iteration:", iteration, "error:",this_error, "diff:", diff, "locs:", locs

        coord.request_stop()
        coord.join(threads)
</code>```

They are meant to be the same, but I've had to change a few things:
1. Add a tf.transpose() to the x_in for the matmul()
2. Queue the entire row of xs and ys, then pull apart using tf.gather().

I've searched a lot for examples that match mine, and I can find no documentation on how to restart a queue and continue the training from the beginning. It'll seemly train forever(not sure why, who is replenishing the queue?) It'll also never stop.

But most of all I have no idea why given the exact same data, the first converges and the second does not?

答:
None of the gather marshalling is needed. Queue only the inputs (x_true), then

evaluate y against y_true, not y_in

```<code>loss_op = tf.reduce_mean(tf.square(y - y_true), name="loss")
</code>```

Body:
I have a working tensorflow model that I am trying to convert to using queues. It may not be the best function but it works.

The data comes in as a list(dict()) called 'rows' from a processing pipeline outside of TF in the form format [{'y1': 1,  'y2': 0, 'y3':1, 'y4':0, 'x1':...'x1182': 0}] (SPECIAL_FIELD_CHAR is 'y', meaning it's calculated from the 'xN' data). The features_outputs() just returns the xs and the ys as ['y1', 'y2', 'y3', 'y4'] and ['x1', ..., 'x1182']. The idea is that the xs determine the ys. There are 4 independent ys that are calculated per row of xs.

def train_rows(initial_weights, weights_filename, rows):
    (features, outputs ) = features_outputs(rows[0].keys())

    x_true = [ [float(row[feature]) for feature in features] for row in rows]
    try:
        y_true = [ [float(row[output]) for output in outputs] for row in rows ]
    except Exception as e:
        print [row[output] for output in outputs], e

    w_true = np.random.rand(len(features), 1) # init weights
    b_true = np.random.rand(1) # init bias

    x_in = tf.placeholder(tf.float32, [None, len(features)], "x_in")
    if initial_weights is None:
        w = tf.Variable(tf.random_normal((len(features), len(outputs))), name="w")
        b = tf.Variable(tf.constant(0.1, shape=[len(outputs)]), name="b")
    else:
        w = tf.Variable(weights['w'], name="w")
        b = tf.Variable(weights['b'], name="b")

    h = tf.add(tf.matmul(x_in, w), b, name="h")
    y_in = tf.placeholder(tf.float32, [None, len(outputs)], "y_in")
    loss_op = tf.reduce_mean(tf.square(tf.subtract(y_in, h)), name="loss")
    #train_op = tf.train.AdamOptimizer(0.01).minimize(loss_op)
    train_op = tf.train.GradientDescentOptimizer(0.3).minimize(loss_op)

    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        last_error = 1.7976931348623157e+308
        this_error = 1.7976931348623157e+307
        diff = 1
        iteration = initial_weights['iteration'] if initial_weights is not None and 'iteration' in initial_weights else 0
        while diff > 0:
            iteration += 1
            last_error = this_error
            for step in range(1000):
                sess.run(train_op, feed_dict={
                  x_in: x_true,
                  y_in: y_true
                })

            w_computed = sess.run(w)
            b_computed = sess.run(b)

            pred = tf.add(tf.matmul(x_in, w), b)

            results = sess.run(pred, feed_dict={x_in: x_true})
            error = tf.losses.mean_squared_error(y_true, results)
            this_error = float(error.eval())
            (diff, locs) = compare(y_true, results)
            if locs < 50:
                print "iteration:", iteration, "error:",this_error, "diff:", diff, "locs:", locs

This produces a model that converges. However with the queue based version it does not, and error increases rapidly:

def multithreaded_train_rows(initial_weights, weights_filename, rows):
    (features, outputs ) = features_outputs(rows[0].keys())

    x_true = np.array([ [float(row[feature]) for feature in features] for row in rows])
    y_true = np.array([ [float(row[output]) for output in outputs] for row in rows ])

    #queue
    q = tf.FIFOQueue(capacity=len(rows), dtypes=tf.float32)
    #enq_op = q.enqueue_many(x_true)
    enq_op = q.enqueue_many(np.array( [ [float(row[f]) for f in sorted(row.keys())] for row in rows]  ))
    qr = tf.train.QueueRunner(q, [enq_op] * 1)
    tf.train.add_queue_runner(qr)

    keys = sorted(row.keys())
    x_indices = np.array([[i] for i in range(len(keys)) if not keys[i].startswith(SPECIAL_FIELD_CHAR)])
    y_indices = np.array([[i] for i in range(len(keys)) if     keys[i].startswith(SPECIAL_FIELD_CHAR)])

    input = q.dequeue()

    x_in = tf.transpose(tf.gather(input, x_indices))
    y_in = tf.gather(input, y_indices)

    if initial_weights is None:
        print 'Creating weights', len(x_indices), len(y_indices)
        w = tf.Variable(tf.random_normal((len(x_indices), len(y_indices))), name="w")
        b = tf.Variable(tf.constant(0.1, shape=[len(y_indices)]), name="b")
    else:
        print 'Using supplied weights', len(weights['w']), len(weights['w'][0])
        w = tf.Variable(weights['w'], name="w")
        b = tf.Variable(weights['b'], name="b")

    y = tf.add(tf.matmul(x_in, w), b, name="y")

    loss_op = tf.reduce_mean(tf.squared_difference(y_in, y), name="loss")
    train_op = tf.train.GradientDescentOptimizer(0.3).minimize(loss_op)

    print 'Starting session'
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)
        last_error = 1.7976931348623157e+308
        this_error = 1.7976931348623157e+307
        diff = 1
        iteration = initial_weights['iteration'] if initial_weights is not None and 'iteration' in initial_weights else 0
        while diff > 0:
            iteration += 1
            last_error = this_error
            for step in range(100):
                sess.run([train_op, loss_op])

            w_computed = sess.run(w)
            b_computed = sess.run(b)

            pred = tf.add(tf.matmul(x_in, w), b)

            results = sess.run(y, feed_dict={x_in: x_true})
            error = tf.losses.mean_squared_error(y_true, results)
            this_error = float(error.eval())

            (diff, locs) = compare(y_true, results)
            if locs < 50:
                print "iteration:", iteration, "error:",this_error, "diff:", diff, "locs:", locs

        coord.request_stop()
        coord.join(threads)

They are meant to be the same, but I've had to change a few things:
1. Add a tf.transpose() to the x_in for the matmul()
2. Queue the entire row of xs and ys, then pull apart using tf.gather().

I've searched a lot for examples that match mine, and I can find no documentation on how to restart a queue and continue the training from the beginning. It'll seemly train forever(not sure why, who is replenishing the queue?) It'll also never stop.

But most of all I have no idea why given the exact same data, the first converges and the second does not?

Body:
None of the gather marshalling is needed. Queue only the inputs (x_true), then

evaluate y against y_true, not y_in

loss_op = tf.reduce_mean(tf.square(y - y_true), name="loss")


问:
How to remove DEBUG logging from the Amazon EC2 client
I have the following simple code

```<code>AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
DescribeInstancesRequest request = new DescribeInstancesRequest();
DescribeInstancesResult response = ec2.describeInstances(request);
</code>```

While running this code I see the multiline debug output. I show only the beginning below.  How to remove this output?

```<code>14:03:29.877 [main] DEBUG com.amazonaws.AmazonWebServiceClient - Internal logging successfully configured to commons logger: true
14:03:38.129 [main] DEBUG com.amazonaws.metrics.AwsSdkMetrics - Admin mbean registered under com.amazonaws.management:type=AwsSdkMetrics
14:03:38.480 [main] DEBUG com.amazonaws.auth.AWSCredentialsProviderChain - Unable to load credentials from EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY))
14:03:38.482 [main] DEBUG com.amazonaws.auth.AWSCredentialsProviderChain - Unable to load credentials from SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey)
14:03:38.580 [main] DEBUG com.amazonaws.auth.AWSCredentialsProviderChain - Loading credentials from com.amazonaws.auth.profile.ProfileCredentialsProvider@7fb9f71f
14:03:38.786 [main] DEBUG com.amazonaws.request - Sending Request: POST https://ec2.us-east-1.amazonaws.com / Parameters: ({"Action":["DescribeInstances"],"Version":["2016-11-15"]}Headers: (User-Agent: aws-sdk-java/1.11.135 Mac_OS_X/10.12.6 Java_HotSpot(TM)_64-Bit_Server_VM/25.144-b01/1.8.0_144, amz-sdk-invocation-id: 0a1303b3-16c0-b140-8d9b-b2e22dc685b1, )
14:03:40.160 [main] DEBUG com.amazonaws.auth.AWS4Signer - AWS4 Canonical Request: '"POST /

 amz-sdk-invocation-id:0a1303b3-16c0-b140-8d9b-b2e22dc685b1
 amz-sdk-retry:0/0/500
 host:ec2.us-east-1.amazonaws.com
 user-agent:aws-sdk-java/1.11.135 Mac_OS_X/10.12.6 Java_HotSpot(TM)_64-Bit_Server_VM/25.144-b01/1.8.0_144
 x-amz-date:20171113T190338Z
</code>```

答:
Log4j Assumption

Under the assumption your application's logging system is configured via a property file like log4j.properties present at the base of your Java classpath, you can reduce verbosity of the loggers by including the line

```<code>log4j.logger.com.amazonaws=WARN
</code>```

WARN or ERROR will guarantee you get the least amount of logs for the loggers inside the AWS SDK.

Should you wish to keep a more granular level of logging for a specific component of the AWS SDK, you can always override the level on a restricted scope (i.e. a subpackage of the com.amazonaws), e.g.

```<code>log4j.logger.com.amazonaws.request=INFO
</code>```

Logging frameworks supported by AWS Java SDK

The AWS SDK documentation states "Supported logging systems include the Java Logging Framework and Apache Log4j, among others".
I refer you to Logging AWS SDK for Java Calls for further reference.

Checking which logging framework is used by the test

The Apache Commons logging library referenced from Gradle is an abstraction layer on top of logging libraries which provide actual implementations of loggers. It is not, in itself, the logging implementation used by your test. In the statement you provided, you are using the Java logging framework ( java.util.Logger a.k.a JUL). But is it really the logging implementation your test uses?

A quick check you could do to verify if log4j is on your test's classpath is to add the VM argument -Dlog4j.debug=true and launch your test. If log4j is on your classpath you will see some output from the library printed on the console.

You could also check the runtime classpath of your test, because there may be transitive dependencies (as opposed to direct) to logging libraries, which may not be visible from the list of compile-time dependencies.

One last resort possibility could be to put a breakpoint there and debug to see which logger is used from the SDK itself (this code is called in your test because it is shown in the logs you provided).

Body:
I have the following simple code

AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
DescribeInstancesRequest request = new DescribeInstancesRequest();
DescribeInstancesResult response = ec2.describeInstances(request);

While running this code I see the multiline debug output. I show only the beginning below.  How to remove this output?

14:03:29.877 [main] DEBUG com.amazonaws.AmazonWebServiceClient - Internal logging successfully configured to commons logger: true
14:03:38.129 [main] DEBUG com.amazonaws.metrics.AwsSdkMetrics - Admin mbean registered under com.amazonaws.management:type=AwsSdkMetrics
14:03:38.480 [main] DEBUG com.amazonaws.auth.AWSCredentialsProviderChain - Unable to load credentials from EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY))
14:03:38.482 [main] DEBUG com.amazonaws.auth.AWSCredentialsProviderChain - Unable to load credentials from SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey)
14:03:38.580 [main] DEBUG com.amazonaws.auth.AWSCredentialsProviderChain - Loading credentials from com.amazonaws.auth.profile.ProfileCredentialsProvider@7fb9f71f
14:03:38.786 [main] DEBUG com.amazonaws.request - Sending Request: POST https://ec2.us-east-1.amazonaws.com / Parameters: ({"Action":["DescribeInstances"],"Version":["2016-11-15"]}Headers: (User-Agent: aws-sdk-java/1.11.135 Mac_OS_X/10.12.6 Java_HotSpot(TM)_64-Bit_Server_VM/25.144-b01/1.8.0_144, amz-sdk-invocation-id: 0a1303b3-16c0-b140-8d9b-b2e22dc685b1, )
14:03:40.160 [main] DEBUG com.amazonaws.auth.AWS4Signer - AWS4 Canonical Request: '"POST /

 amz-sdk-invocation-id:0a1303b3-16c0-b140-8d9b-b2e22dc685b1
 amz-sdk-retry:0/0/500
 host:ec2.us-east-1.amazonaws.com
 user-agent:aws-sdk-java/1.11.135 Mac_OS_X/10.12.6 Java_HotSpot(TM)_64-Bit_Server_VM/25.144-b01/1.8.0_144
 x-amz-date:20171113T190338Z

Body:
Log4j Assumption

Under the assumption your application's logging system is configured via a property file like log4j.properties present at the base of your Java classpath, you can reduce verbosity of the loggers by including the line

log4j.logger.com.amazonaws=WARN

WARN or ERROR will guarantee you get the least amount of logs for the loggers inside the AWS SDK.

Should you wish to keep a more granular level of logging for a specific component of the AWS SDK, you can always override the level on a restricted scope (i.e. a subpackage of the com.amazonaws), e.g.

log4j.logger.com.amazonaws.request=INFO

Logging frameworks supported by AWS Java SDK

The AWS SDK documentation states "Supported logging systems include the Java Logging Framework and Apache Log4j, among others".
I refer you to Logging AWS SDK for Java Calls for further reference.

Checking which logging framework is used by the test

The Apache Commons logging library referenced from Gradle is an abstraction layer on top of logging libraries which provide actual implementations of loggers. It is not, in itself, the logging implementation used by your test. In the statement you provided, you are using the Java logging framework ( java.util.Logger a.k.a JUL). But is it really the logging implementation your test uses?

A quick check you could do to verify if log4j is on your test's classpath is to add the VM argument -Dlog4j.debug=true and launch your test. If log4j is on your classpath you will see some output from the library printed on the console.

You could also check the runtime classpath of your test, because there may be transitive dependencies (as opposed to direct) to logging libraries, which may not be visible from the list of compile-time dependencies.

One last resort possibility could be to put a breakpoint there and debug to see which logger is used from the SDK itself (this code is called in your test because it is shown in the logs you provided).


问:
Notify email when Azure Storage table gets new entry
Is there an inbuilt way to notify an email when a new entry is added to the Table?

I am asking for anything programatically just within their own UI

答:
Not currently but you could put it on an Azure Storage Queue and process it to Table Storage and send an Email with Azure Functions.

Check out this page what is possible - https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings


问:
Django - get param from request.get and add it with another number
I have following code. I want to get values from from request and add it to another float number. I tried this code but gives me error :unsupported operand type(s) for +: 'float' and 'NoneType'

```<code>class RatingsUpdateView(UpdateAPIView):

    serializer_class = serializers.RatingsSerializer

    queryset = models.Ratings.objects.all()

    def update(self, request, *args, **kwargs):
        instance = self.get_object()
        #average =
        instance.total_number = instance.total_number + 1
        instance.sum_of_all_ratings =instance.sum_of_all_ratings + request.data.get("rating_give_by_user")

        instance.save()
</code>```

Look at the line where i am getting value 'request.data.get("rating_give_by_user")_give_by_user'. This value us NoneType but i want to add it to another float number. What is the solution and best practice. Thanks.

答: request.data.get("rating_give_by_user") is returning None and you are attempting to add this to a number. What do you expect this method call to return? An (int, str...)? Ensure that the GET parameter is properly being passed because right now django isn't seeing it.

Body:
I have following code. I want to get values from from request and add it to another float number. I tried this code but gives me error :unsupported operand type(s) for +: 'float' and 'NoneType'

class RatingsUpdateView(UpdateAPIView):

    serializer_class = serializers.RatingsSerializer

    queryset = models.Ratings.objects.all()

    def update(self, request, *args, **kwargs):
        instance = self.get_object()
        #average =
        instance.total_number = instance.total_number + 1
        instance.sum_of_all_ratings =instance.sum_of_all_ratings + request.data.get("rating_give_by_user")

        instance.save()

Look at the line where i am getting value 'request.data.get("rating_give_by_user")_give_by_user'. This value us NoneType but i want to add it to another float number. What is the solution and best practice. Thanks.


问:
headless browser with basic authentication
I want to use a headless browser to test a website in an internal network. The site makes use of basic authentication rather than a login page though so I've thus far been using something like https://username:password@testsite.com to access the site with my scripts.

I tried looking but is there any headless browser that supports using something like that as a URL?

I'm currently using HtmlUnitDriver with Selenium but it appears to not be working. When using the Firefox Driver, I'm able to log in just fine but I'm apparently getting  401 - Unauthorized: Access is denied due to invalid credentials when I try using HtmlUnitDriver.

For reference, I'm just using a simple driver.get(url) to open the page.

```<code>HtmlUnitDriver driver = new HtmlUnitDriver();
String url = "https://"+ uName + ":" + uPassword + "@" + testEnvironment;
driver.get(url);
System.out.println(driver.getTitle());
</code>```

答: I believe both puppeteer and nightmare allow you to use basic authentication and even proxies. I’d give either of those a shot</p>

Body:
I want to use a headless browser to test a website in an internal network. The site makes use of basic authentication rather than a login page though so I've thus far been using something like https://username:password@testsite.com to access the site with my scripts.

I tried looking but is there any headless browser that supports using something like that as a URL?

I'm currently using HtmlUnitDriver with Selenium but it appears to not be working. When using the Firefox Driver, I'm able to log in just fine but I'm apparently getting  401 - Unauthorized: Access is denied due to invalid credentials when I try using HtmlUnitDriver.

For reference, I'm just using a simple driver.get(url) to open the page.

HtmlUnitDriver driver = new HtmlUnitDriver();
String url = "https://"+ uName + ":" + uPassword + "@" + testEnvironment;
driver.get(url);
System.out.println(driver.getTitle());


问:
Action<T> Get parameter value
Goal: Pass an Action< T > to a method to be ran. The idea is if the method uses T then we can specify the type we will be passing into the method as a parameter rather than having to use dynamics.

Issue: I'm unable to get the parameter value, what is the best way to do this (most likely using reflection)?

Code:

```<code>public static void RunVoidMethod<T>(Action<T> methodToRun)
{
    try
    {
        // Below is a ParameterInfo, I want the parameter value for methodToRun
        var parameterValue = methodToRun.Method.GetParameters()[0];
        methodToRun(parameterValue);
    }
    catch (Exception e)
    {
        throw;
    }
}
</code>```

The worst case scenario is I can add an optional parameter which can also be of type T but I'm hoping to avoid this if possible.

答:
Perhaps you are looking for something like this (I am not 100% certain since your post didn't really include a question, just a statement).</p>

```<code>public static void RunVoidMethod<T>(Action<T> methodToRun, T param)
{
    try
    {
        methodToRun(param);
    }
    catch (Exception e)
    {
        throw;
    }
}
</code>```

Title: Action<T> Get parameter value

Body:
Goal: Pass an Action< T > to a method to be ran. The idea is if the method uses T then we can specify the type we will be passing into the method as a parameter rather than having to use dynamics.

Issue: I'm unable to get the parameter value, what is the best way to do this (most likely using reflection)?

Code:

public static void RunVoidMethod<T>(Action<T> methodToRun)
{
    try
    {
        // Below is a ParameterInfo, I want the parameter value for methodToRun
        var parameterValue = methodToRun.Method.GetParameters()[0];
        methodToRun(parameterValue);
    }
    catch (Exception e)
    {
        throw;
    }
}

The worst case scenario is I can add an optional parameter which can also be of type T but I'm hoping to avoid this if possible.

Body:
Perhaps you are looking for something like this (I am not 100% certain since your post didn't really include a question, just a statement).

public static void RunVoidMethod<T>(Action<T> methodToRun, T param)
{
    try
    {
        methodToRun(param);
    }
    catch (Exception e)
    {
        throw;
    }
}