问:
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>```

答:
change flex:auto to flex:1

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

.r_flex_container {
  background-color: blue;
}

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

.r_flex_expand_child {
  flex: 1;
  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>```

OP's comment

Meh, this makes the flex element not to fill the content if it's blank

you can set height:100% only in html,body and min-height:100% in .r_flex_container along with flex: 1 (or flex: auto) in .r_flex_expand_child

html,
body {
  height: 100%;
}

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

.r_flex_container {
  min-height: 100%;
  background-color: blue;
}

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

.r_flex_expand_child {
  flex: 1;
  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></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>```

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:
change flex:auto to flex:1

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

.r_flex_container {
  background-color: blue;
}

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

.r_flex_expand_child {
  flex: 1;
  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>

OP's comment

Meh, this makes the flex element not to fill the content if it's blank

you can set height:100% only in html,body and min-height:100% in .r_flex_container along with flex: 1 (or flex: auto) in .r_flex_expand_child

html,
body {
  height: 100%;
}

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

.r_flex_container {
  min-height: 100%;
  background-color: blue;
}

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

.r_flex_expand_child {
  flex: 1;
  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></article>
  </div>
  <div class="r_flex_fixed_child">
    this is the fixed footer child of the flex container asdfadsf
    <p> another line</p>
  </div>


来源: stackexchange

问:
java.lang.ClassNotFoundException: scala.Int Error when loading typesafe configuration
I have akka project.

This is application-1.conf at src/resources folder.

```<code>akka {
  loglevel="INFO"
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    enabled-transports = ["akka.remote.netty.tcp"]
    netty.tcp {
     hostname = "127.0.0.1"
     port = 2552
   }
    log-sent-messages=on
    log-received-messages=on
 }
}
</code>```

Below is my action at package example7_2 at folder src/main/scala/example7_2.

```<code>package example7_2

import akka.actor.Actor
class SimpleActor extends Actor {
  override def receive: Receive = {
    case msg => println(s"I have been created at
    ${self.path.address.hostPort} and received message $msg")
 }
</code>```

}

I have the Main App HelloAkkaRemoting10 below.

```<code>package example7_2

import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory

object HelloAkkaRemoting10 extends App {
  val actorSystem = ActorSystem("HelloAkkaRemoting1", ConfigFactory.load("application-1"))
}
</code>```

When I run the application, I get the

```<code>[error] (run-main-0) java.lang.ClassNotFoundException: scala.Int
[error] java.lang.ClassNotFoundException: scala.Int
[error]         at sbt.internal.inc.classpath.ClasspathFilter.loadClass(ClassLoaders.scala:74)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[error]         at java.lang.Class.forName0(Native Method)
[error]         at java.lang.Class.forName(Class.java:348)
[error]         at akka.actor.ReflectiveDynamicAccess.$anonfun$getClassFor$1(ReflectiveDynamicAccess.scala:21)
[error]         at scala.util.Try$.apply(Try.scala:209)
[error]         at akka.actor.ReflectiveDynamicAccess.getClassFor(ReflectiveDynamicAccess.scala:20)
[error]         at akka.serialization.Serialization.$anonfun$bindings$3(Serialization.scala:313)
[error]         at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:739)
[error]         at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:231)
[error]         at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:462)
[error]         at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:738)
[error]         at akka.serialization.Serialization.<init>(Serialization.scala:311)
[error]         at akka.serialization.SerializationExtension$.createExtension(SerializationExtension.scala:15)
[error]         at akka.serialization.SerializationExtension$.createExtension(SerializationExtension.scala:12)
[error]         at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:880)
[error]         at akka.actor.ExtensionId.apply(Extension.scala:77)
[error]         at akka.actor.ExtensionId.apply$(Extension.scala:77)
[error]         at akka.serialization.SerializationExtension$.apply(SerializationExtension.scala:12)
[error]         at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:203)
[error]         at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:796)
[error]         at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:793)
[error]         at akka.actor.ActorSystemImpl._start(ActorSystem.scala:793)
[error]         at akka.actor.ActorSystemImpl.start(ActorSystem.scala:809)
[error]         at akka.actor.ActorSystem$.apply(ActorSystem.scala:244)
[error]         at akka.actor.ActorSystem$.apply(ActorSystem.scala:287)
[error]         at akka.actor.ActorSystem$.apply(ActorSystem.scala:262)
[error]         at example7_2.HelloAkkaRemoting10$.delayedEndpoint$example7_2$HelloAkkaRemoting10$1(HelloAkkaRemoting10.scala:7)
[error]         at example7_2.HelloAkkaRemoting10$delayedInit$body.apply(HelloAkkaRemoting10.scala:6)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:76)
[error]         at scala.collection.immutable.List.foreach(List.scala:389)
[error]         at scala.App.main(App.scala:76)
[error]         at scala.App.main$(App.scala:74)
[error]         at example7_2.HelloAkkaRemoting10$.main(HelloAkkaRemoting10.scala:6)
[error]         at example7_2.HelloAkkaRemoting10.main(HelloAkkaRemoting10.scala)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.lang.reflect.Method.invoke(Method.java:498)
[error]         at sbt.Run.invokeMain(Run.scala:89)
[error]         at sbt.Run.run0(Run.scala:83)
[error]         at sbt.Run.execute$1(Run.scala:61)
[error]         at sbt.Run.$anonfun$run$4(Run.scala:73)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error]         at sbt.TrapExit$App.run(TrapExit.scala:252)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error]         at sbt.Run$.executeTrapExit(Run.scala:120)
[error]         at sbt.Run.run(Run.scala:73)
[error]         at sbt.Defaults$.$anonfun$bgRunMainTask$6(Defaults.scala:1130)
[error]         at sbt.Defaults$.$anonfun$bgRunMainTask$6$adapted(Defaults.scala:1125)
[error]         at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:359)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at scala.util.Try$.apply(Try.scala:209)
[error]         at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:282)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (chapter7/compile:runMain) Nonzero exit code: 1
[error] Total time: 3 s, completed Oct 18, 2017 11:11:52 AM
</code>```

Other miscellaneous details -

sbt version - 1.0.2
scala version - 2.12.3
akka version - 2.5.4

Looks to me ConfigFactory load is throwing error but not sure the exact root cause. Please let me know if I am missing any configuration.

答: This appears to be a bug in sbt that has nothing to do with Typesafe Config and only slightly with Akka, I have filed it as https://github.com/sbt/sbt/issues/3736</p>

ContentLicense: CC BY-SA 3.0

Body:
I have akka project.

This is application-1.conf at src/resources folder.

akka {
  loglevel="INFO"
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    enabled-transports = ["akka.remote.netty.tcp"]
    netty.tcp {
     hostname = "127.0.0.1"
     port = 2552
   }
    log-sent-messages=on
    log-received-messages=on
 }
}

Below is my action at package example7_2 at folder src/main/scala/example7_2.

package example7_2

import akka.actor.Actor
class SimpleActor extends Actor {
  override def receive: Receive = {
    case msg => println(s"I have been created at
    ${self.path.address.hostPort} and received message $msg")
 }

}

I have the Main App HelloAkkaRemoting10 below.

package example7_2

import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory

object HelloAkkaRemoting10 extends App {
  val actorSystem = ActorSystem("HelloAkkaRemoting1", ConfigFactory.load("application-1"))
}

When I run the application, I get the

[error] (run-main-0) java.lang.ClassNotFoundException: scala.Int
[error] java.lang.ClassNotFoundException: scala.Int
[error]         at sbt.internal.inc.classpath.ClasspathFilter.loadClass(ClassLoaders.scala:74)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[error]         at java.lang.Class.forName0(Native Method)
[error]         at java.lang.Class.forName(Class.java:348)
[error]         at akka.actor.ReflectiveDynamicAccess.$anonfun$getClassFor$1(ReflectiveDynamicAccess.scala:21)
[error]         at scala.util.Try$.apply(Try.scala:209)
[error]         at akka.actor.ReflectiveDynamicAccess.getClassFor(ReflectiveDynamicAccess.scala:20)
[error]         at akka.serialization.Serialization.$anonfun$bindings$3(Serialization.scala:313)
[error]         at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:739)
[error]         at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:231)
[error]         at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:462)
[error]         at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:738)
[error]         at akka.serialization.Serialization.<init>(Serialization.scala:311)
[error]         at akka.serialization.SerializationExtension$.createExtension(SerializationExtension.scala:15)
[error]         at akka.serialization.SerializationExtension$.createExtension(SerializationExtension.scala:12)
[error]         at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:880)
[error]         at akka.actor.ExtensionId.apply(Extension.scala:77)
[error]         at akka.actor.ExtensionId.apply$(Extension.scala:77)
[error]         at akka.serialization.SerializationExtension$.apply(SerializationExtension.scala:12)
[error]         at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:203)
[error]         at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:796)
[error]         at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:793)
[error]         at akka.actor.ActorSystemImpl._start(ActorSystem.scala:793)
[error]         at akka.actor.ActorSystemImpl.start(ActorSystem.scala:809)
[error]         at akka.actor.ActorSystem$.apply(ActorSystem.scala:244)
[error]         at akka.actor.ActorSystem$.apply(ActorSystem.scala:287)
[error]         at akka.actor.ActorSystem$.apply(ActorSystem.scala:262)
[error]         at example7_2.HelloAkkaRemoting10$.delayedEndpoint$example7_2$HelloAkkaRemoting10$1(HelloAkkaRemoting10.scala:7)
[error]         at example7_2.HelloAkkaRemoting10$delayedInit$body.apply(HelloAkkaRemoting10.scala:6)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:76)
[error]         at scala.collection.immutable.List.foreach(List.scala:389)
[error]         at scala.App.main(App.scala:76)
[error]         at scala.App.main$(App.scala:74)
[error]         at example7_2.HelloAkkaRemoting10$.main(HelloAkkaRemoting10.scala:6)
[error]         at example7_2.HelloAkkaRemoting10.main(HelloAkkaRemoting10.scala)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.lang.reflect.Method.invoke(Method.java:498)
[error]         at sbt.Run.invokeMain(Run.scala:89)
[error]         at sbt.Run.run0(Run.scala:83)
[error]         at sbt.Run.execute$1(Run.scala:61)
[error]         at sbt.Run.$anonfun$run$4(Run.scala:73)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error]         at sbt.TrapExit$App.run(TrapExit.scala:252)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error]         at sbt.Run$.executeTrapExit(Run.scala:120)
[error]         at sbt.Run.run(Run.scala:73)
[error]         at sbt.Defaults$.$anonfun$bgRunMainTask$6(Defaults.scala:1130)
[error]         at sbt.Defaults$.$anonfun$bgRunMainTask$6$adapted(Defaults.scala:1125)
[error]         at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:359)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at scala.util.Try$.apply(Try.scala:209)
[error]         at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:282)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (chapter7/compile:runMain) Nonzero exit code: 1
[error] Total time: 3 s, completed Oct 18, 2017 11:11:52 AM

Other miscellaneous details -

sbt version - 1.0.2
scala version - 2.12.3
akka version - 2.5.4

Looks to me ConfigFactory load is throwing error but not sure the exact root cause. Please let me know if I am missing any configuration.


问:
Cannot login in flask - always asking username&password
I watched a tutorial (https://www.youtube.com/watch?v=VW8qJxy4XcQ) and I saw how easy to login to a webpage in flask. I tried it several times, but when I enter the correct username and password (the saving box comes up for a moment to remember my datas) the little box with the edit texts disappears and it asks them again. What am I doing wrong?

Thanks

```<code>from flask import Flask, render_template, request, make_response
import os
app = Flask(__name__)

@app.route('/pass')
def index():
    if request.authorization and request.authorization.username == 'a' and request.authorization.password == 'a':
        return 'logged in'
        #return render_template("index2.html")
    else:
        return make_response('Could not verify!', 401, {'WWW-Authenticate' : 'Basic realm=Login required'})

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

virtualhost:

```<code><VirtualHost *:80>
                ServerName 39.234.23.12
                ServerAdmin youemail@email.com
                WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
                <Directory /var/www/FlaskApp/FlaskApp/>
                        Order allow,deny
                        Allow from all
                </Directory>
                Alias /static /var/www/FlaskApp/FlaskApp/static
                <Directory /var/www/FlaskApp/FlaskApp/static/>
                        Order allow,deny
                        Allow from all
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</code>```

That didn't work, either despite of doing it locally, not on the google cloud virtual instance:

```<code>import os
from flask import Flask, render_template, request

app = Flask(__name__)

APP_ROOT = os.path.dirname(os.path.abspath(__file__))

@app.route("/")
def index():
    if request.authorization and request.authorization.username == 'a' and request.authorization.password == 'a':
        return "success"
    return "nope"
</code>```

答:
The code should work and looks more like a problem with a browser. Try resetting browser settings to default.

It the problem persists, first check debug log in console and make sure that after login attempt the response status code is 200.

```<code>127.0.0.1 - - [13/Nov/2017 17:33:10] "GET /pass HTTP/1.1" 200
</code>```

Print out request.authorization before and after checking authorization to see what is passed:

```<code>def index():
    print(request.authorization)
    if request.authorization and request.authorization.username == 'a' and request.authorization.password == 'a':
        print(request.authorization)
        return 'logged in'
    else:
        return make_response('Could not verify!', 401, {'WWW-Authenticate' : 'Basic realm=Login required'})
</code>```

First print should be None and after authorization second print should be a dictionary with a username and a password:

```<code>{'username': 'a', 'password': 'a'}
</code>```

After successful authorization, both should return a dictionary with username and password.

Body:
I watched a tutorial (https://www.youtube.com/watch?v=VW8qJxy4XcQ) and I saw how easy to login to a webpage in flask. I tried it several times, but when I enter the correct username and password (the saving box comes up for a moment to remember my datas) the little box with the edit texts disappears and it asks them again. What am I doing wrong?

Thanks

from flask import Flask, render_template, request, make_response
import os
app = Flask(__name__)

@app.route('/pass')
def index():
    if request.authorization and request.authorization.username == 'a' and request.authorization.password == 'a':
        return 'logged in'
        #return render_template("index2.html")
    else:
        return make_response('Could not verify!', 401, {'WWW-Authenticate' : 'Basic realm=Login required'})

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

virtualhost:

<VirtualHost *:80>
                ServerName 39.234.23.12
                ServerAdmin youemail@email.com
                WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
                <Directory /var/www/FlaskApp/FlaskApp/>
                        Order allow,deny
                        Allow from all
                </Directory>
                Alias /static /var/www/FlaskApp/FlaskApp/static
                <Directory /var/www/FlaskApp/FlaskApp/static/>
                        Order allow,deny
                        Allow from all
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

That didn't work, either despite of doing it locally, not on the google cloud virtual instance:

import os
from flask import Flask, render_template, request

app = Flask(__name__)

APP_ROOT = os.path.dirname(os.path.abspath(__file__))

@app.route("/")
def index():
    if request.authorization and request.authorization.username == 'a' and request.authorization.password == 'a':
        return "success"
    return "nope"

Body:
The code should work and looks more like a problem with a browser. Try resetting browser settings to default.

It the problem persists, first check debug log in console and make sure that after login attempt the response status code is 200.

127.0.0.1 - - [13/Nov/2017 17:33:10] "GET /pass HTTP/1.1" 200

Print out request.authorization before and after checking authorization to see what is passed:

def index():
    print(request.authorization)
    if request.authorization and request.authorization.username == 'a' and request.authorization.password == 'a':
        print(request.authorization)
        return 'logged in'
    else:
        return make_response('Could not verify!', 401, {'WWW-Authenticate' : 'Basic realm=Login required'})

First print should be None and after authorization second print should be a dictionary with a username and a password:

{'username': 'a', 'password': 'a'}

After successful authorization, both should return a dictionary with username and password.


问:
ASP.NET Identity 3.0 authentication cookie not getting created
I am attempting to add ASP.NET Identity 3.0 single user authentication to the
"ASP.NET Core Application Angular template" within Visual Studio 2017.  I have created a GitHub repository here:

https://github.com/DapperDanH/NutmegStackoverflow

There really is not much to this project yet.  From a high level, this is what i did:

Created a new "ASP.NET Core  Web Application" with .NET Core and ASP.NET  Core 2.0 and chose the Angular template within Visual Studio.

I added ASP.Identity, EF Core and scaffold code first files from an existing database.

I copied and pasted many of the Controllers and Views from the "ASP.NET Core  Web Application" with the Web Application template using "Individual User Account" sample project.

I modified the Startup.cs (added service.AddIdentity and app.UseAuthentication(), etc)

My goal is to use standard ASP.NET MVC for the authentication portions.

Everything appears to work.  The web application launches and shows the home page.  I created links to "Register" and "Login" pages.  I can successfully register a new user and the new user is added to the database.  The user can enter their information in the Login page, and the AccountController.Login method returns success to the PasswordSignInAsync method:

```<code>                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
</code>```

The issue is, no auth cookie is created.  Well, about 99% of the time a cookie is NOT created but every now and then one is created.

My gut says the issue may be in the Startup.cs.  Here is the code I am using:

```<code>// This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<NutmegContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

        services.AddIdentity<User, AppRole>()
            .AddEntityFrameworkStores<NutmegContext>()
            .AddDefaultTokenProviders();
        // Add application services.
        services.AddTransient<IEmailSender, EmailSender>();

        services.AddMvc();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
            {
                HotModuleReplacement = true
            });
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();
        app.UseAuthentication();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");

            routes.MapSpaFallbackRoute(
                name: "spa-fallback",
                defaults: new { controller = "Home", action = "Index" });
        });
    }
</code>```

I really hope someone can help me.  To see this in action:

Download the project here:  https://github.com/DapperDanH/NutmegStackoverflow

Run Update-Database in the Package Manager Console making sure the Default Project is Nutmeg.Data.

Run the application making sure the Nutmeg.Web is the startup project.

Click on Register button and register a new user.  Check the db and notice the user is added.

Click on Login.  Enter same information used in step 4.  Did a cookie get created?

Hoping someone can help me out.  Thanks for reading this long post!

Thanks,
Dan

答: I was able to get the application to consistently create the auth cookie but switching my web project to HTTPS. I have no clue why that would matter, but it seems to fix it. anyone able to explain?</p>

Body:
I am attempting to add ASP.NET Identity 3.0 single user authentication to the
"ASP.NET Core Application Angular template" within Visual Studio 2017.  I have created a GitHub repository here:

https://github.com/DapperDanH/NutmegStackoverflow

There really is not much to this project yet.  From a high level, this is what i did:

Created a new "ASP.NET Core  Web Application" with .NET Core and ASP.NET  Core 2.0 and chose the Angular template within Visual Studio.

I added ASP.Identity, EF Core and scaffold code first files from an existing database.

I copied and pasted many of the Controllers and Views from the "ASP.NET Core  Web Application" with the Web Application template using "Individual User Account" sample project.

I modified the Startup.cs (added service.AddIdentity and app.UseAuthentication(), etc)

My goal is to use standard ASP.NET MVC for the authentication portions.

Everything appears to work.  The web application launches and shows the home page.  I created links to "Register" and "Login" pages.  I can successfully register a new user and the new user is added to the database.  The user can enter their information in the Login page, and the AccountController.Login method returns success to the PasswordSignInAsync method:

                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);

The issue is, no auth cookie is created.  Well, about 99% of the time a cookie is NOT created but every now and then one is created.

My gut says the issue may be in the Startup.cs.  Here is the code I am using:

// This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<NutmegContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

        services.AddIdentity<User, AppRole>()
            .AddEntityFrameworkStores<NutmegContext>()
            .AddDefaultTokenProviders();
        // Add application services.
        services.AddTransient<IEmailSender, EmailSender>();

        services.AddMvc();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
            {
                HotModuleReplacement = true
            });
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();
        app.UseAuthentication();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");

            routes.MapSpaFallbackRoute(
                name: "spa-fallback",
                defaults: new { controller = "Home", action = "Index" });
        });
    }

I really hope someone can help me.  To see this in action:

Download the project here:  https://github.com/DapperDanH/NutmegStackoverflow

Run Update-Database in the Package Manager Console making sure the Default Project is Nutmeg.Data.

Run the application making sure the Nutmeg.Web is the startup project.

Click on Register button and register a new user.  Check the db and notice the user is added.

Click on Login.  Enter same information used in step 4.  Did a cookie get created?

Hoping someone can help me out.  Thanks for reading this long post!

Thanks,
Dan


问:
Javascript code for Drop Down List not working properly
I have written the following code for creating drop-down lists. The list for Research Area is working fine but corresponding to that research area, the second list viz Choose Professor which should show options like X, Y etc. is not appearing. What is the bug in my code?

```<code><!DOCTYPE html>
<html>

<head>
  <script type="text/javascript">
    function populate(s1, s2) {
      var s1 = document.getElementbyId(s1);
      var s2 = document.getElementbyId(s2);
      s2.innerHTML = "";
      if (s1.value == "Deep Learning") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Big Data") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Cryptography") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Algorithms") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Embedded Systems") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Graphic Design") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Computer Architecture") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      if (s1.value == "Robotics") {
        var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
      }
      for (var option in optionArray) {
        var pair = optionArray[option].split("|")
        var newOption = document.createElement("option");
        newOption.value = pair[0];
        newOption.innerHTML = pair[1];
        s2.options.add(newOption);
      }
    }
  </script>

</head>

<body>
  <h2>Choose Accordingly</h2>
  <hr/> Choose Research Area:
  <select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Deep Learning">Deep Learning</option>
    <option value="Big Data">Big Data</option>
    <option value="Cryptography">Cryptography</option>
    <option value="Algorithms">Algorithms</option>
    <option value="Embedded Systems">Embedded Systems</option>
    <option value="Graphic Design">Graphic Design</option>
    <option value="Computer Architecture">Computer Architecture</option>
    <option value="Robotics">Robotics</option>
    </select>
  <hr/> Choose Professor:
  <select id="slct2" name="slct2"></select>
  <hr />

</body>

</html>
</code>```

答:
You have a typo document.getElementbyId should be document.getElementById and you are populating the same values in the second dropdown no matter what you select in the first one. So there is no need of these if conditions

function populate(s1, s2) {
  var s1 = document.getElementById(s1);
  var s2 = document.getElementById(s2);
  s2.innerHTML = "";
   var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
  for (var option in optionArray) {
    var pair = optionArray[option].split("|")
    var newOption = document.createElement("option");
    newOption.value = pair[0];
    newOption.innerHTML = pair[1];
    s2.options.add(newOption);
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><h2>Choose Accordingly</h2>
<hr/> Choose Research Area:
<select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Deep Learning">Deep Learning</option>
    <option value="Big Data">Big Data</option>
    <option value="Cryptography">Cryptography</option>
    <option value="Algorithms">Algorithms</option>
    <option value="Embedded Systems">Embedded Systems</option>
    <option value="Graphic Design">Graphic Design</option>
    <option value="Computer Architecture">Computer Architecture</option>
    <option value="Robotics">Robotics</option>
    </select>
<hr/> Choose Professor:
<select id="slct2" name="slct2"></select>
<hr /></code>```

Body:
I have written the following code for creating drop-down lists. The list for Research Area is working fine but corresponding to that research area, the second list viz Choose Professor which should show options like X, Y etc. is not appearing. What is the bug in my code?

<!DOCTYPE html>

Choose Accordingly

 Choose Research Area:
  <select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Deep Learning">Deep Learning</option>
    <option value="Big Data">Big Data</option>
    <option value="Cryptography">Cryptography</option>
    <option value="Algorithms">Algorithms</option>
    <option value="Embedded Systems">Embedded Systems</option>
    <option value="Graphic Design">Graphic Design</option>
    <option value="Computer Architecture">Computer Architecture</option>
    <option value="Robotics">Robotics</option>
    </select>

 Choose Professor:
  <select id="slct2" name="slct2"></select>

Body:
You have a typo document.getElementbyId should be document.getElementById and you are populating the same values in the second dropdown no matter what you select in the first one. So there is no need of these if conditions

function populate(s1, s2) {
  var s1 = document.getElementById(s1);
  var s2 = document.getElementById(s2);
  s2.innerHTML = "";
   var optionArray = ["|", "X|X", "Y|Y", "Z|Z", "A|A"];
  for (var option in optionArray) {
    var pair = optionArray[option].split("|")
    var newOption = document.createElement("option");
    newOption.value = pair[0];
    newOption.innerHTML = pair[1];
    s2.options.add(newOption);
  }
}

<h2>Choose Accordingly</h2>
<hr/> Choose Research Area:
<select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Deep Learning">Deep Learning</option>
    <option value="Big Data">Big Data</option>
    <option value="Cryptography">Cryptography</option>
    <option value="Algorithms">Algorithms</option>
    <option value="Embedded Systems">Embedded Systems</option>
    <option value="Graphic Design">Graphic Design</option>
    <option value="Computer Architecture">Computer Architecture</option>
    <option value="Robotics">Robotics</option>
    </select>
<hr/> Choose Professor:
<select id="slct2" name="slct2"></select>
<hr />


问:
UITableView cells disappearing when moving using NSFetchedResultsController and Core Data
I'm building my first Core Data app and am trying to implement a feature where users can move cells by holding and dragging.

The problem I'm getting is that when the cells are released they disappear. However, if you scroll down enough and then pop back up, they reappear, albeit in their original order, not the rearranged order.

A screen-recording of the bug can be found here

Any idea where I'm going wrong?

My UITableViewController Sub-Class:

```<code>import UIKit
import CoreData
import CoreGraphics

class MainTableViewController: UITableViewController {

    let context = AppDelegate.viewContext

    lazy var fetchedResultsController: TodoFetchedResultsController = {
        return TodoFetchedResultsController(managedObjectContext: self.context, tableView: self.tableView)
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationItem.leftBarButtonItem = editButtonItem
        fetchedResultsController.tryFetch()

        let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressGestureRecognized(gestureRecognizer:)))
    tableView.addGestureRecognizer(longPressRecognizer)
}

    var snapshot: UIView? = nil
    var path: IndexPath? = nil

    @objc
    func longPressGestureRecognized(gestureRecognizer: UILongPressGestureRecognizer) {
        let state = gestureRecognizer.state
        let locationInView = gestureRecognizer.location(in: tableView)
        let indexPath = tableView.indexPathForRow(at: locationInView)

        switch state {
        case .began:
            if indexPath != nil {
                self.path = indexPath
                let cell = tableView.cellForRow(at: indexPath!) as! TodoTableViewCell
                snapshot = snapshotOfCell(cell)
                var center = cell.center
                snapshot!.center = center
                snapshot!.alpha = 0.0
                tableView.addSubview(snapshot!)

                UIView.animate(withDuration: 0.1, animations: { () -> Void in
                    center.y = locationInView.y
                    self.snapshot!.center = center
                    self.snapshot!.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
                    self.snapshot!.alpha = 0.98
                    cell.alpha = 0.0
                }, completion: { (finished) -> Void in
                    if finished {
                        cell.isHidden = true
                    }
                })
            }
        case .changed:
            if self.snapshot != nil {
                var center = snapshot!.center
                center.y = locationInView.y
                snapshot!.center = center
                if ((indexPath != nil) && (indexPath != self.path)) {
                    // Move cells
                    tableView.moveRow(at: self.path!, to: indexPath!)
                    self.path = indexPath
                }
            }
        default:
            if self.path != nil {
                let cell = tableView.cellForRow(at: self.path!) as! TodoTableViewCell
                cell.isHidden = false
                cell.alpha = 0.0
                UIView.animate(withDuration: 0.1, animations: { () -> Void in
                    self.snapshot!.center = cell.center
                    self.snapshot!.transform = CGAffineTransform.identity
                    self.snapshot!.alpha = 0.0
                    cell.alpha = 1.0
                }, completion: { (finished) -> Void in
                    if finished {
                        cell.isHidden = true // FIXME: - Something up here?
                    }
                })
            }
        }
    }

    func snapshotOfCell(_ inputView: UIView) -> UIView {
    UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, false, 0.0)

        guard let graphicsContext = UIGraphicsGetCurrentContext() else { fatalError() }
        inputView.layer.render(in: graphicsContext)

        et image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

        let cellSnapshot: UIView = UIImageView(image: image)
        cellSnapshot.layer.masksToBounds = false
        cellSnapshot.layer.cornerRadius = 0.0
        cellSnapshot.layer.shadowOffset = CGSize(width: -5.0, height: 0.0)
        cellSnapshot.layer.shadowRadius = 5.0
        cellSnapshot.layer.shadowOpacity = 0.4
        return cellSnapshot
    }

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return fetchedResultsController.sections?.count ?? 0
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        guard let section = fetchedResultsController.sections?[section] else { return 0 }
        return section.numberOfObjects
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Todo Cell", for: indexPath) as! TodoTableViewCell

        return configureCell(cell, at: indexPath)
    }

    private func configureCell(_ cell: TodoTableViewCell, at indexPath: IndexPath) -> TodoTableViewCell {
        let todo = fetchedResultsController.object(at: indexPath)

        do {
            try cell.update(with: todo)
        } catch {
            print("\(error)")
        }

        return cell
    }

    func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }

    // Support editing the table view.
    override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            let todoToDelete = fetchedResultsController.object(at: indexPath)
            context.delete(todoToDelete)
        } else if editingStyle == .insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }
        (UIApplication.shared.delegate as! AppDelegate).saveContext()
        tableView.reloadData()
    }

    // MARK: - Navigation
    ...
}
</code>```

My NSFetchedResultsControllerSubclass:

```<code>class TodoFetchedResultsController: NSFetchedResultsController<Todo>, NSFetchedResultsControllerDelegate {
    private let tableView: UITableView

    init(managedObjectContext: NSManagedObjectContext, tableView: UITableView) {
        self.tableView = tableView

        let request: NSFetchRequest<Todo> = Todo.fetchRequest()
        let sortDescriptor = NSSortDescriptor(key: "dueDate", ascending: true)
        request.sortDescriptors = [sortDescriptor]
        super.init(fetchRequest: request, managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)

        self.delegate = self

        tryFetch()
    }

    func tryFetch() {
        do {
            try performFetch()
        } catch {
            print("Unresolved error: \(error)")
        }
    }

    // MARK: - Fetched Results Controlle Delegate

    // Handle insertion, deletion, moving and updating of rows.
    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>,
                    didChange anObject: Any,
                    at indexPath: IndexPath?,
                    for type: NSFetchedResultsChangeType,
                    newIndexPath: IndexPath?) {
        switch type {
        case .insert:
            if let insertIndexPath = newIndexPath {
                self.tableView.insertRows(at: [insertIndexPath], with: .fade)
            }
        case .delete:
            if let deleteIndexPath = indexPath {
                self.tableView.deleteRows(at: [deleteIndexPath], with: .fade)
            }
        case .update:
            if let updateIndexPath = indexPath {
                if let cell = self.tableView.cellForRow(at: updateIndexPath) as! TodoTableViewCell? {
                    let todo = self.object(at: updateIndexPath)

                    do {
                        try cell.update(with: todo)
                    } catch {
                        print("error updating cell: \(error)")
                    }
                }
            }
        case .move:
            if let deleteIndexPath = indexPath {
                self.tableView.deleteRows(at: [deleteIndexPath], with: .fade)
            }
            if let insertIndexPath = newIndexPath {
                self.tableView.insertRows(at: [insertIndexPath], with: .fade)
            }
            break
        }
    }

    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableView.reloadData()
    }
}
</code>```

答:
Your code updates the table view's UI, but it does not update your data model to have the new order. The next time your table view needs to display a cell, your code gives it the same information as before the drag-- For example, tableView(_:, cellForRowAt:) still returns cells in the old order, because there's nothing that changes what happens there. This doesn't happen until you scroll away and then scroll back because that's when the table view needs to call that method. The old order will continue, simply because you never change it, you only make a temporary UI update.

If you want to make it possible to re-order items in the table, you need to update your data model to include that order. Probably that means adding a new field in Core Data, an integer called something like sortOrder. Then update the sortOrder so that it matches the new order from the drag and drop.

Body:
I'm building my first Core Data app and am trying to implement a feature where users can move cells by holding and dragging.

The problem I'm getting is that when the cells are released they disappear. However, if you scroll down enough and then pop back up, they reappear, albeit in their original order, not the rearranged order.

A screen-recording of the bug can be found here

Any idea where I'm going wrong?

My UITableViewController Sub-Class:

import UIKit
import CoreData
import CoreGraphics

class MainTableViewController: UITableViewController {

    let context = AppDelegate.viewContext

    lazy var fetchedResultsController: TodoFetchedResultsController = {
        return TodoFetchedResultsController(managedObjectContext: self.context, tableView: self.tableView)
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationItem.leftBarButtonItem = editButtonItem
        fetchedResultsController.tryFetch()

        let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressGestureRecognized(gestureRecognizer:)))
    tableView.addGestureRecognizer(longPressRecognizer)
}

    var snapshot: UIView? = nil
    var path: IndexPath? = nil

    @objc
    func longPressGestureRecognized(gestureRecognizer: UILongPressGestureRecognizer) {
        let state = gestureRecognizer.state
        let locationInView = gestureRecognizer.location(in: tableView)
        let indexPath = tableView.indexPathForRow(at: locationInView)

        switch state {
        case .began:
            if indexPath != nil {
                self.path = indexPath
                let cell = tableView.cellForRow(at: indexPath!) as! TodoTableViewCell
                snapshot = snapshotOfCell(cell)
                var center = cell.center
                snapshot!.center = center
                snapshot!.alpha = 0.0
                tableView.addSubview(snapshot!)

                UIView.animate(withDuration: 0.1, animations: { () -> Void in
                    center.y = locationInView.y
                    self.snapshot!.center = center
                    self.snapshot!.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
                    self.snapshot!.alpha = 0.98
                    cell.alpha = 0.0
                }, completion: { (finished) -> Void in
                    if finished {
                        cell.isHidden = true
                    }
                })
            }
        case .changed:
            if self.snapshot != nil {
                var center = snapshot!.center
                center.y = locationInView.y
                snapshot!.center = center
                if ((indexPath != nil) && (indexPath != self.path)) {
                    // Move cells
                    tableView.moveRow(at: self.path!, to: indexPath!)
                    self.path = indexPath
                }
            }
        default:
            if self.path != nil {
                let cell = tableView.cellForRow(at: self.path!) as! TodoTableViewCell
                cell.isHidden = false
                cell.alpha = 0.0
                UIView.animate(withDuration: 0.1, animations: { () -> Void in
                    self.snapshot!.center = cell.center
                    self.snapshot!.transform = CGAffineTransform.identity
                    self.snapshot!.alpha = 0.0
                    cell.alpha = 1.0
                }, completion: { (finished) -> Void in
                    if finished {
                        cell.isHidden = true // FIXME: - Something up here?
                    }
                })
            }
        }
    }

    func snapshotOfCell(_ inputView: UIView) -> UIView {
    UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, false, 0.0)

        guard let graphicsContext = UIGraphicsGetCurrentContext() else { fatalError() }
        inputView.layer.render(in: graphicsContext)

        et image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

        let cellSnapshot: UIView = UIImageView(image: image)
        cellSnapshot.layer.masksToBounds = false
        cellSnapshot.layer.cornerRadius = 0.0
        cellSnapshot.layer.shadowOffset = CGSize(width: -5.0, height: 0.0)
        cellSnapshot.layer.shadowRadius = 5.0
        cellSnapshot.layer.shadowOpacity = 0.4
        return cellSnapshot
    }

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return fetchedResultsController.sections?.count ?? 0
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        guard let section = fetchedResultsController.sections?[section] else { return 0 }
        return section.numberOfObjects
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Todo Cell", for: indexPath) as! TodoTableViewCell

        return configureCell(cell, at: indexPath)
    }

    private func configureCell(_ cell: TodoTableViewCell, at indexPath: IndexPath) -> TodoTableViewCell {
        let todo = fetchedResultsController.object(at: indexPath)

        do {
            try cell.update(with: todo)
        } catch {
            print("\(error)")
        }

        return cell
    }

    func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }

    // Support editing the table view.
    override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            let todoToDelete = fetchedResultsController.object(at: indexPath)
            context.delete(todoToDelete)
        } else if editingStyle == .insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }
        (UIApplication.shared.delegate as! AppDelegate).saveContext()
        tableView.reloadData()
    }

    // MARK: - Navigation
    ...
}

My NSFetchedResultsControllerSubclass:

class TodoFetchedResultsController: NSFetchedResultsController<Todo>, NSFetchedResultsControllerDelegate {
    private let tableView: UITableView

    init(managedObjectContext: NSManagedObjectContext, tableView: UITableView) {
        self.tableView = tableView

        let request: NSFetchRequest<Todo> = Todo.fetchRequest()
        let sortDescriptor = NSSortDescriptor(key: "dueDate", ascending: true)
        request.sortDescriptors = [sortDescriptor]
        super.init(fetchRequest: request, managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)

        self.delegate = self

        tryFetch()
    }

    func tryFetch() {
        do {
            try performFetch()
        } catch {
            print("Unresolved error: \(error)")
        }
    }

    // MARK: - Fetched Results Controlle Delegate

    // Handle insertion, deletion, moving and updating of rows.
    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>,
                    didChange anObject: Any,
                    at indexPath: IndexPath?,
                    for type: NSFetchedResultsChangeType,
                    newIndexPath: IndexPath?) {
        switch type {
        case .insert:
            if let insertIndexPath = newIndexPath {
                self.tableView.insertRows(at: [insertIndexPath], with: .fade)
            }
        case .delete:
            if let deleteIndexPath = indexPath {
                self.tableView.deleteRows(at: [deleteIndexPath], with: .fade)
            }
        case .update:
            if let updateIndexPath = indexPath {
                if let cell = self.tableView.cellForRow(at: updateIndexPath) as! TodoTableViewCell? {
                    let todo = self.object(at: updateIndexPath)

                    do {
                        try cell.update(with: todo)
                    } catch {
                        print("error updating cell: \(error)")
                    }
                }
            }
        case .move:
            if let deleteIndexPath = indexPath {
                self.tableView.deleteRows(at: [deleteIndexPath], with: .fade)
            }
            if let insertIndexPath = newIndexPath {
                self.tableView.insertRows(at: [insertIndexPath], with: .fade)
            }
            break
        }
    }

    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableView.reloadData()
    }
}


问:
how do I use a very large (>2M) word embedding in tensorflow?
I am running a model with a very big word embedding (>2M words).  When I use tf.embedding_lookup, it expects the matrix, which is big.  When I run, I subsequently get out of GPU memory error.  If I reduce the size of the embedding, everything works fine.

Is there a way to deal with larger embedding?

答:
The recommended way is to use a partitioner to shard this large tensor across several parts:

embedding = tf.get_variable("embedding", [1000000000, 20],
                            partitioner=tf.fixed_size_partitioner(3))
```

<p>This will split the tensor into 3 shards along 0 axis, but the rest of the program will see it as an ordinary tensor. The biggest benefit is to use a partitioner along with <em>parameter server replication</em>, like this:</p>

<pre class="lang-py prettyprint-override"><code>with tf.device(tf.train.replica_device_setter(ps_tasks=3)):
  embedding = tf.get_variable("embedding", [1000000000, 20],
                              partitioner=tf.fixed_size_partitioner(3))
</code>```

The key function here is tf.train.replica_device_setter.
It allows you to run 3 different processes, called parameter servers, that store all of model variables. The large embedding tensor will be split across these servers like on this picture.

Body:
The recommended way is to use a partitioner to shard this large tensor across several parts:

embedding = tf.get_variable("embedding", [1000000000, 20],
                            partitioner=tf.fixed_size_partitioner(3))

This will split the tensor into 3 shards along 0 axis, but the rest of the program will see it as an ordinary tensor. The biggest benefit is to use a partitioner along with parameter server replication, like this:

with tf.device(tf.train.replica_device_setter(ps_tasks=3)):
  embedding = tf.get_variable("embedding", [1000000000, 20],
                              partitioner=tf.fixed_size_partitioner(3))

The key function here is tf.train.replica_device_setter.
It allows you to run 3 different processes, called parameter servers, that store all of model variables. The large embedding tensor will be split across these servers like on this picture.


问:
Select only elements that don't have a parent with defined class
How do I select only children that don't have a parent with a certain class in their parent tree?

This didn't work:

```<code>div:not(.dontSelect) .child
</code>```

div {
  background-color: red;
  padding: 5px;
}

div:not(.dontSelect) .child {
  background-color: green;
  padding: 5px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  <div class="child">
    Select this
  </div>
  <div class="dontSelect">
    <div>
      <div class="child">
        Don't select this
      </div>
    </div>
  </div>
</div></code>```

答:
I don't think you can use combinator selectors with :not as stated in the documentation:

This selector only applies to one element; you cannot use it to
  exclude all ancestors. For instance, body :not(table) a will still
  apply to links inside of a table, since
 will match with the
  :not() part of the selector.

You could try something like this:

div {
  background-color: red;
  padding: 5px;
}

.child {
  background-color: green;
  padding: 5px;
}

.dontSelect .child {
  background-color: initial;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  <div class="child">
    Select this
  </div>
  <div class="dontSelect">
    <div>
      <div class="child">
        Don't select this
      </div>
    </div>
  </div>
</div></code>```

Body:
How do I select only children that don't have a parent with a certain class in their parent tree?

This didn't work:

div:not(.dontSelect) .child

div {
  background-color: red;
  padding: 5px;
}

div:not(.dontSelect) .child {
  background-color: green;
  padding: 5px;
}

    Select this

        Don't select this

Body:
I don't think you can use combinator selectors with :not as stated in the documentation:

This selector only applies to one element; you cannot use it to
  exclude all ancestors. For instance, body :not(table) a will still
  apply to links inside of a table, since <tr> will match with the
  :not() part of the selector.

You could try something like this:

div {
  background-color: red;
  padding: 5px;
}

.child {
  background-color: green;
  padding: 5px;
}

.dontSelect .child {
  background-color: initial;
}

<div>
  <div class="child">
    Select this
  </div>
  <div class="dontSelect">
    <div>
      <div class="child">
        Don't select this
      </div>
    </div>
  </div>
</div>


问:
sonarqube ignores sonar.junit.reportPaths
I have a gradle project which applies the sonarqube gradle plugin, version 2.6.

I run it against my team's sonarqube server, version 6.4 (build 25310).

According to documentation, new versions of sonarqube accept the property sonar.junit.reportPaths instead of sonar.junit.reportsPath.

My build runs 2 test tasks: test and integrationTest. Each test task outputs its xml into a different directory: build/test-results/test and build/test-results/integrationTest respectively.

I configured the sonarqube plugin to pick up both these directories:

```<code>project.sonarqube {
     properties {
         property 'sonar.junit.reportsPath', ['build/test-results/test',
                                              'build/test-results/integrationTest']

         // configure additional integration test properties that seem to be required
         Collection<File> integrationTestSourceDirs = project.sourceSets.integrationTest.allJava.srcDirs.findAll { File dir -> dir.exists() }
         properties['sonar.tests'] += integrationTestSourceDirs
         Collection<File> integrationTestsClasses = project.sourceSets.integrationTest.output.classesDirs.files.findAll { File file -> file.exists() }
         properties['sonar.java.test.binaries'] += integrationTestsClasses
     }
}
</code>```

This does not work. In sonarqube UI I only see unit tests (from the test directory) and don't see any integration tests.

I made sure that my integrationTest directory contains valid test reports, and it does.

It seems like sonarqube still uses the old parameter sonar.junit.reportsPath (which by default is assigned by the gradle plugin with the value build/test-results/test). I can tell this because if I remove this parameter I don't see any unit tests at all in the UI. This is how I removed the old parameter:

```<code>project.sonarqube {
   properties {
        properties.remove("sonar.junit.reportsPath")
   }
}
</code>```

As a workaround, I configured my integrationTest task to put its output into the same directory as unit tests: build/test-results/test. After doing this, all tests, including integration tests are picked up by sonarqube, and I can see them all in the UI.

However, I would prefer to keep outputs of different test tasks in different directories.

Is the described behavior intentional, or is it a bug?

答: Your SonarJava plugin is too old. The new property is only available from 4.11 on. In 4.10 only the old property is evaluated, so the new one is ignored. The Gradle plugin just sets the properties. The evaluation happens in the code that is downloaded from the SonarQube server and thus ignored.

Body:
I have a gradle project which applies the sonarqube gradle plugin, version 2.6.

I run it against my team's sonarqube server, version 6.4 (build 25310).

According to documentation, new versions of sonarqube accept the property sonar.junit.reportPaths instead of sonar.junit.reportsPath.

My build runs 2 test tasks: test and integrationTest. Each test task outputs its xml into a different directory: build/test-results/test and build/test-results/integrationTest respectively.

I configured the sonarqube plugin to pick up both these directories:

project.sonarqube {
     properties {
         property 'sonar.junit.reportsPath', ['build/test-results/test',
                                              'build/test-results/integrationTest']

         // configure additional integration test properties that seem to be required
         Collection<File> integrationTestSourceDirs = project.sourceSets.integrationTest.allJava.srcDirs.findAll { File dir -> dir.exists() }
         properties['sonar.tests'] += integrationTestSourceDirs
         Collection<File> integrationTestsClasses = project.sourceSets.integrationTest.output.classesDirs.files.findAll { File file -> file.exists() }
         properties['sonar.java.test.binaries'] += integrationTestsClasses
     }
}

This does not work. In sonarqube UI I only see unit tests (from the test directory) and don't see any integration tests.

I made sure that my integrationTest directory contains valid test reports, and it does.

It seems like sonarqube still uses the old parameter sonar.junit.reportsPath (which by default is assigned by the gradle plugin with the value build/test-results/test). I can tell this because if I remove this parameter I don't see any unit tests at all in the UI. This is how I removed the old parameter:

project.sonarqube {
   properties {
        properties.remove("sonar.junit.reportsPath")
   }
}

As a workaround, I configured my integrationTest task to put its output into the same directory as unit tests: build/test-results/test. After doing this, all tests, including integration tests are picked up by sonarqube, and I can see them all in the UI.

However, I would prefer to keep outputs of different test tasks in different directories.

Is the described behavior intentional, or is it a bug?


问:
Expand environment variable for My Documents
I know I can read environment variables like this:

```<code>Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
</code>```

However, it would be really helpful to me if I could do something like this:

```<code>Environment.ExpandEnvironmentVariables(@"%MyDocuments%\Foo");
</code>```

Is there an environement variable that equals SpecialFolder.MyDocuments?

I also tried to do something like this, but this doesn't lead to the expected result:

```<code>Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\My Documents\Foo");
</code>```

This way I ended up with something like @"C:\Users\<MyUser>\My Documents\Foo" but I what I need is @"\\someservername\users$\<MyUser>\My Documents\Foo".

EDIT: My Goal is NOT to hardcode either environment variable nor the part after that.

Any other suggestions?

答:
You can expand environment variables using then Environment.GetEnvironmentVariable method.  Given your comment, I would suggest breaking your path up into 2 separate config settings to make expanding it easier:

```<code>string variablePath = "%appdata%".Trim('%'); //read from some config setting
string appdataPath = Environment.GetEnvironmentVariable(variablePath);
string subdir = "foo";  //some other config setting
string myDir = Path.Combine(appdataPath, subdir);
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I know I can read environment variables like this:

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

However, it would be really helpful to me if I could do something like this:

Environment.ExpandEnvironmentVariables(@"%MyDocuments%\Foo");

Is there an environement variable that equals SpecialFolder.MyDocuments?

I also tried to do something like this, but this doesn't lead to the expected result:

Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\My Documents\Foo");

This way I ended up with something like @"C:\Users\<MyUser>\My Documents\Foo" but I what I need is @"\\someservername\users$\<MyUser>\My Documents\Foo".

EDIT: My Goal is NOT to hardcode either environment variable nor the part after that.

Any other suggestions?

Body:
You can expand environment variables using then Environment.GetEnvironmentVariable method.  Given your comment, I would suggest breaking your path up into 2 separate config settings to make expanding it easier:

string variablePath = "%appdata%".Trim('%'); //read from some config setting
string appdataPath = Environment.GetEnvironmentVariable(variablePath);
string subdir = "foo";  //some other config setting
string myDir = Path.Combine(appdataPath, subdir);


问:
C++ copy constructor double call on member initialization
Consider the below code, where a composing class with another class as its member is being instantiated:

```<code>class CopyAble {
private:
    int mem1;
public:
    CopyAble(int n1) : mem1(n1) {
        cout << "Inside the CopyAble constructor" << endl;
    }
    CopyAble(const CopyAble& obj) {
        cout << "Inside the CopyAble copy constructor" << endl;
        this->mem1 = obj.mem1;
        return *this;
    }

    CopyAble& operator=(const CopyAble& obj) {
        cout << "Inside the  CopyAble assignment constructor" << endl;
        this->mem1 = obj.mem1;
    }
    ~CopyAble() {};
};

class CopyAbleComposer {
    private:
        CopyAble memObj;
    public:
        CopyAbleComposer(CopyAble m1) : memObj(m1) {
            cout << "Composing the composer" << endl;
        }
        ~CopyAbleComposer() {}
};

int main()
{
    CopyAble ca(10);
    CopyAbleComposer cac(ca);
    return 0;
}
</code>```

When I run this, I get the output:

```<code>Inside the CopyAble constructor
Inside the CopyAble copy constructor
Inside the CopyAble copy constructor
Composing the composer
</code>```

Which means that the CopyAble copy constructor is being run twice - once when the CopyAble object is passed into the CopyAbleComposer constructor, and again when the initializer memObj(m1) runs.

Is this an idiomatic use of the copy constructor? It seems very inefficient that the copy constructor runs twice when we try to initialize a member object with a passed-in object of the same type, and it seems like a trap a lot of C++ programmers can easily fall into without realizing it.

EDIT: I don't think this is a duplicate of the question regarding passing a reference into the copy constructor. Here, we are being forced to pass a reference into a regular constructor to avoid duplicate object creation, my question was that is this generally known that class constructors in C++ should have objects passed in by reference to avoid this kind of duplicate copy?

答:
You should accept CopyAble by reference at CopyAbleComposer(CopyAble m1), otherwise a copy constructor will be called to construct an argument. You should also mark it as explicit to avoid accidental invocations:

```<code>explicit CopyAbleComposer(const CopyAble & m1)
</code>```

Body:
Consider the below code, where a composing class with another class as its member is being instantiated:

class CopyAble {
private:
    int mem1;
public:
    CopyAble(int n1) : mem1(n1) {
        cout << "Inside the CopyAble constructor" << endl;
    }
    CopyAble(const CopyAble& obj) {
        cout << "Inside the CopyAble copy constructor" << endl;
        this->mem1 = obj.mem1;
        return *this;
    }

    CopyAble& operator=(const CopyAble& obj) {
        cout << "Inside the  CopyAble assignment constructor" << endl;
        this->mem1 = obj.mem1;
    }
    ~CopyAble() {};
};

class CopyAbleComposer {
    private:
        CopyAble memObj;
    public:
        CopyAbleComposer(CopyAble m1) : memObj(m1) {
            cout << "Composing the composer" << endl;
        }
        ~CopyAbleComposer() {}
};

int main()
{
    CopyAble ca(10);
    CopyAbleComposer cac(ca);
    return 0;
}

When I run this, I get the output:

Inside the CopyAble constructor
Inside the CopyAble copy constructor
Inside the CopyAble copy constructor
Composing the composer

Which means that the CopyAble copy constructor is being run twice - once when the CopyAble object is passed into the CopyAbleComposer constructor, and again when the initializer memObj(m1) runs.

Is this an idiomatic use of the copy constructor? It seems very inefficient that the copy constructor runs twice when we try to initialize a member object with a passed-in object of the same type, and it seems like a trap a lot of C++ programmers can easily fall into without realizing it.

EDIT: I don't think this is a duplicate of the question regarding passing a reference into the copy constructor. Here, we are being forced to pass a reference into a regular constructor to avoid duplicate object creation, my question was that is this generally known that class constructors in C++ should have objects passed in by reference to avoid this kind of duplicate copy?

Body:
You should accept CopyAble by reference at CopyAbleComposer(CopyAble m1), otherwise a copy constructor will be called to construct an argument. You should also mark it as explicit to avoid accidental invocations:

explicit CopyAbleComposer(const CopyAble & m1)


问:
Scale content with size of menu
I was trying something out as a test but didn't quite know how to program it the right way. I was hoping someone could help me out with that.

I made a sketch so it would be a little more clear about what I want to achieve. The menu on the left needs to stay in that exact position.

Let's say the content next to the menu would be smaller than the menu itself. Then the green sections would go underneath the menu. This is not what I want to achieve. I was thinking about scaling the height of the content with Javascript if the content element is too small.

Do you feel like this is the right way to accomplish the desired result? Or could you suggest a better/cleaner way to accomplish this? (An example on jsfiddle would be great)

Thanks in advance!

Edit: I would also like to inform that the menu's height needs to be dynamic. For example what if I add an extra menu item.

答:
You mean something like this?

Just be wary this Only works on MODERN browsers as I am using the checkbox hack :)

Here is a code snipet

*{
 box-sizing:border-box;
 margin:0px;
 padding:0px;
}

#head{
 background-color:#000;
 border-bottom:#333 solid 1px;
 display:block;
 padding:10px 0px 0px 10px;
}
#head ul{
 background-color:#f00;
 display:block;
 width:150px;
 position:relative;
 list-style:none;
 margin:0px;
 text-align:center;
}
#head li{
 display:none;
}
#head input{
 display:none;
}
#head input:checked ~ li{
 display:block;
}
#head input:checked ~ label{
 background-color:#511;
 color:#fff;
}
#head label{
 font-family:Constantia;
 width:100%;
 padding:10px 0px;
 color:#333;
 border-bottom:#111 dotted 1px;
 display:block;
 font-weight:bold;
 text-transform:uppercase;
}
#head label:hover{
 background-color:#511;
 color:#fff;
 cursor:pointer;
}
#head a:link{
 background-color:#f00;
 width:150px;
 display:block;
 color:#111;
 text-decoration:none;
 border-bottom:#333 solid 1px;
 padding:10px;
 float:left;
 margin-right:10px;
}
#head a:visited{
 color:#111;
}
#head a:hover{
 background-color:#911;
 color:#fff;
 border-bottom:#211 solid 1px;
 font-weight:bold;
}
#body{
 padding:10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="head">
   <ul>
    <input type="checkbox" id="menu" />
    <label for="menu">Menu</label>

    <li>Link 1</li>
    <li>Link 2</li>
    <li>Link 3</li>
   </ul>
  </div>

  <div id="body">
   <h1>Content</h1>
   <p> All my content sits here what am I suppose to do?</p>
  </div></code>```

By making use of floats rather than position absolute lets the browser know there is suppose to be content under the header if I had to change it to apply position absolute it would still go out the header but won't take up any space therfore the content wont shift next to or under it but rather behind the navigation.

You should see that the content will go below it when the window gets smaller if you wish to make the content not be squashed up a bit before going underneath the navigation is to set a min-width to the #body{} tag.

Title: Scale content with size of menu

Body:
You mean something like this?

Just be wary this Only works on MODERN browsers as I am using the checkbox hack :)

Here is a code snipet

*{
 box-sizing:border-box;
 margin:0px;
 padding:0px;
}

#head{
 background-color:#000;
 border-bottom:#333 solid 1px;
 display:block;
 padding:10px 0px 0px 10px;
}
#head ul{
 background-color:#f00;
 display:block;
 width:150px;
 position:relative;
 list-style:none;
 margin:0px;
 text-align:center;
}
#head li{
 display:none;
}
#head input{
 display:none;
}
#head input:checked ~ li{
 display:block;
}
#head input:checked ~ label{
 background-color:#511;
 color:#fff;
}
#head label{
 font-family:Constantia;
 width:100%;
 padding:10px 0px;
 color:#333;
 border-bottom:#111 dotted 1px;
 display:block;
 font-weight:bold;
 text-transform:uppercase;
}
#head label:hover{
 background-color:#511;
 color:#fff;
 cursor:pointer;
}
#head a:link{
 background-color:#f00;
 width:150px;
 display:block;
 color:#111;
 text-decoration:none;
 border-bottom:#333 solid 1px;
 padding:10px;
 float:left;
 margin-right:10px;
}
#head a:visited{
 color:#111;
}
#head a:hover{
 background-color:#911;
 color:#fff;
 border-bottom:#211 solid 1px;
 font-weight:bold;
}
#body{
 padding:10px;
}

<div id="head">
   <ul>
    <input type="checkbox" id="menu" />
    <label for="menu">Menu</label>

    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
    <li><a href="#">Link 3</a></li>
   </ul>
  </div>

  <div id="body">
   <h1>Content</h1>
   <p> All my content sits here what am I suppose to do?</p>
  </div>

By making use of floats rather than position absolute lets the browser know there is suppose to be content under the header if I had to change it to apply position absolute it would still go out the header but won't take up any space therfore the content wont shift next to or under it but rather behind the navigation.

You should see that the content will go below it when the window gets smaller if you wish to make the content not be squashed up a bit before going underneath the navigation is to set a min-width to the #body{} tag.