问:
3 boxes inline, content alignment
I have 3 boxes with dynamic content, in each box there is a form with submit button, and some other things. How to get the effect from the picture.

Height of the each box is max from all boxes. Submit buttons in one line, on the bottom.

body {
  width: 720px;
}
form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}
form label {
  text-align: left;
  width: 100%;
  display: block;
}
.box-container {
  display: flex;
}
.box {
  border: 1px solid #000;
  flex: 1 1 auto;
  max-width: calc(33% - 2px);
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}
.box p {
  text-align: justify;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="box-container">
  <div class="box">
    <h1>bla bla bla</h1>
    <p> some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>
  </div>
  <div class="box">
    <h1>bla bla bladada das dasd asd</h1>
    <p>Longer information<br> some information dasd asd asd asd an</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
      <label>value 3</label>
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>
  </div>
  <div class="box">
    <h1>bla bla b</h1>
    <p>Longer information</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>
  </div>
<div></code>```

答:
I have added some left margin to the 2nd and 3rd columns for the spacing. I have absolute bottom positioned a new button wrapper with padding to centrally position it. I have added some padding bottom on the box to help prevent the button overlapping the content. This would run in to issue if the button got bigger or the button text wrapped on to another line, however it is the best solution I could think of.

form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}
form label {
  text-align: left;
  width: 100%;
  display: block;
}
.box-container {
  display: flex;
  padding: 5px;
}
.box {
  flex: 1 1 auto;
  border: 1px solid #000;
  width: 33.333%;
  text-align: center;
  box-sizing: border-box;
  padding: 10px 10px 40px;
  margin-left: 10px;
  position: relative;
}
.box:first-child {
  margin-left: 0;
}
.box p {
  text-align: justify;
}
.button-wrap  {
  position: absolute;
  bottom:0;
  left: 0;
  right:0;
  padding:10px;
}
.button-wrap input {
  margin:0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="box-container">
  <div class="box">
    <h1>bla bla bla</h1>
    <p> some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
   <div class="button-wrap">
    <input type="submit" value="submit"/>
   </div>
    </form>
  </div>
  <div class="box">
    <h1>bla bla bladada das dasd asd</h1>
    <p>Longer information<br> some information dasd asd asd asd an</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
      <label>value 3</label>
      <input type="text"/>
   <div class="button-wrap">
    <input type="submit" value="submit"/>
   </div>
    </form>
  </div>
  <div class="box">
    <h1>bla bla b</h1>
    <p>Longer information</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
   <div class="button-wrap">
    <input type="submit" value="submit"/>
   </div>
    </form>
  </div>
<div></code>```

Title: 3 boxes inline, content alignment

Body:
I have 3 boxes with dynamic content, in each box there is a form with submit button, and some other things. How to get the effect from the picture.

Height of the each box is max from all boxes. Submit buttons in one line, on the bottom.

body {
  width: 720px;
}
form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}
form label {
  text-align: left;
  width: 100%;
  display: block;
}
.box-container {
  display: flex;
}
.box {
  border: 1px solid #000;
  flex: 1 1 auto;
  max-width: calc(33% - 2px);
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}
.box p {
  text-align: justify;
}

bla bla bla

 some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s

    <form>
      value 1
      <input type="text"/>
      value 2
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>

bla bla bladada das dasd asd

Longer information
 some information dasd asd asd asd an

    <form>
      value 1
      <input type="text"/>
      value 2
      <input type="text"/>
      value 3
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>

bla bla b

Longer information

    <form>
      value 1
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>

Body:
I have added some left margin to the 2nd and 3rd columns for the spacing. I have absolute bottom positioned a new button wrapper with padding to centrally position it. I have added some padding bottom on the box to help prevent the button overlapping the content. This would run in to issue if the button got bigger or the button text wrapped on to another line, however it is the best solution I could think of.

form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}
form label {
  text-align: left;
  width: 100%;
  display: block;
}
.box-container {
  display: flex;
  padding: 5px;
}
.box {
  flex: 1 1 auto;
  border: 1px solid #000;
  width: 33.333%;
  text-align: center;
  box-sizing: border-box;
  padding: 10px 10px 40px;
  margin-left: 10px;
  position: relative;
}
.box:first-child {
  margin-left: 0;
}
.box p {
  text-align: justify;
}
.button-wrap  {
  position: absolute;
  bottom:0;
  left: 0;
  right:0;
  padding:10px;
}
.button-wrap input {
  margin:0;
}

<div class="box-container">
  <div class="box">
    <h1>bla bla bla</h1>
    <p> some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
   <div class="button-wrap">
    <input type="submit" value="submit"/>
   </div>
    </form>
  </div>
  <div class="box">
    <h1>bla bla bladada das dasd asd</h1>
    <p>Longer information<br> some information dasd asd asd asd an</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
      <label>value 3</label>
      <input type="text"/>
   <div class="button-wrap">
    <input type="submit" value="submit"/>
   </div>
    </form>
  </div>
  <div class="box">
    <h1>bla bla b</h1>
    <p>Longer information</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
   <div class="button-wrap">
    <input type="submit" value="submit"/>
   </div>
    </form>
  </div>
<div>


来源: stackexchange

问:
How to set radio buttons fixed on background?
When I am making the page smaller the radio buttons will show up on te next textline like this:
But the radio buttons has to stand on their place when I am making te page smaller. (not scrolling with the background, just like the other form elements)
Can you please help me?

label[class=number]::before {
    counter-increment: section;
    content: counter(section) " " ;
    display: inline-block;
    color: white;
    width: 20px;
    background-color: black;
    text-align: center;
    padding-top: 1%;
    margin-left: 10px;
    padding-bottom: 1%;
}

label[id=Bert_natter] {
    display: block;
    margin-top: 10px;
}

label[class=number], select {
 display: inline-block;
    margin-top: 20px;
    width: 345px;
}

#bestellen input[type=number], #bestellen input[type=text], select {
 width: 40px;
    margin-left: 102%;
    display: block;
    margin-top: -7%;
    border-color: skyblue;
    border-style: double;
}

input[type=range] {
    width: 40px;
    position: relative;
    margin-left: 102%;
    background-color: transparent;
    margin-top: -5%;
    display: block;
}

small {
 display: block;
    margin-left: 420px;
    margin-top: -1.5%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form id="bestellen" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi">
        <label class="number" id="David_Vann">David Vann - Aquarium: <input size="3" name="David_Vann" type="number" min="1"></label><small> Max. 10 exemplaren</small>
        <label class="number" id="Robert_Seethaler">Robert Seethaler - Een heel leven: <input size="3" name="Robert_Seethaler" type="text" pattern="[0-9]{2}"></label><small> Max. 99 exemplaren</small>
        <label id="Paula" class="number">Paula Hawkins - Het meisje in de trein: <input name="Paula_Hawkins" type="range" min="0" max="15" step="5" list="Paula_Hawkins"></label><small>Bestel 0, 5, 10 of 15 exemplaren</small>
          <datalist id="Paula_Hawkins">
            <option value="0">
            <option value="5">
            <option value="10">
            <option value="15">
         </datalist>
        <label class="number" id="Ernest_van_der_kwast">Ernest van der Kwast - De ijsmakers: </label>
        <label> <input type="radio" name="Ernest van der kwast" value="1">1</label>
        <label> <input type="radio" name="Ernest van der kwast" value="10">10</label>
        <label> <input type="radio" name="Ernest van der kwast" value="20">20</label><br>
        <label class="number" id="Bert_natter">Bert Natter - Remington:
            <select name="Bert Natter">
              <option value="geen">geen</option>
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
             </select>
         </label>
   </form> </code>```

答:
label[class=number]::before {
    counter-increment: section;
    content: counter(section) " " ;
    display: inline-block;
    color: white;
    width: 20px;
    background-color: black;
    text-align: center;
    padding-top: 1%;
    margin-left: 10px;
    padding-bottom: 1%;
}

label[id=Bert_natter] {
    display: block;
    margin-top: 10px;
}

label[class=number], select {
 display: inline-block;
    margin-top: 20px;
    width: 345px;
}

#bestellen input[type=number], #bestellen input[type=text], select {
 width: 40px;
    margin-left: 102%;
    display: block;
    margin-top: -7%;
    border-color: skyblue;
    border-style: double;
}

input[type=range] {
    width: 40px;
    position: relative;
    margin-left: 102%;
    background-color: transparent;
    margin-top: -5%;
    display: block;
}

small {
 display: block;
    margin-left: 420px;
    margin-top: -1.5%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div style="white-space: nowrap;">
<form id="bestellen" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi">
        <label class="number" id="David_Vann">David Vann - Aquarium: <input size="3" name="David_Vann" type="number" min="1"></label><small> Max. 10 exemplaren</small>
        <label class="number" id="Robert_Seethaler">Robert Seethaler - Een heel leven: <input size="3" name="Robert_Seethaler" type="text" pattern="[0-9]{2}"></label><small> Max. 99 exemplaren</small>
        <label id="Paula" class="number">Paula Hawkins - Het meisje in de trein: <input name="Paula_Hawkins" type="range" min="0" max="15" step="5" list="Paula_Hawkins"></label><small>Bestel 0, 5, 10 of 15 exemplaren</small>
          <datalist id="Paula_Hawkins">
            <option value="0">
            <option value="5">
            <option value="10">
            <option value="15">
         </datalist>
        <label class="number" id="Ernest_van_der_kwast">Ernest van der Kwast - De ijsmakers: </label>
        <label> <input type="radio" name="Ernest van der kwast" value="1">1</label>
        <label> <input type="radio" name="Ernest van der kwast" value="10">10</label>
        <label> <input type="radio" name="Ernest van der kwast" value="20">20</label><br>
        <label class="number" id="Bert_natter">Bert Natter - Remington:
            <select name="Bert Natter">
              <option value="geen">geen</option>
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
             </select>
         </label>
   </form>
</div></code>```

ContentLicense: CC BY-SA 3.0

Body:
When I am making the page smaller the radio buttons will show up on te next textline like this:
But the radio buttons has to stand on their place when I am making te page smaller. (not scrolling with the background, just like the other form elements)
Can you please help me?

label[class=number]::before {
    counter-increment: section;
    content: counter(section) " " ;
    display: inline-block;
    color: white;
    width: 20px;
    background-color: black;
    text-align: center;
    padding-top: 1%;
    margin-left: 10px;
    padding-bottom: 1%;
}

label[id=Bert_natter] {
    display: block;
    margin-top: 10px;
}

label[class=number], select {
 display: inline-block;
    margin-top: 20px;
    width: 345px;
}

#bestellen input[type=number], #bestellen input[type=text], select {
 width: 40px;
    margin-left: 102%;
    display: block;
    margin-top: -7%;
    border-color: skyblue;
    border-style: double;
}

input[type=range] {
    width: 40px;
    position: relative;
    margin-left: 102%;
    background-color: transparent;
    margin-top: -5%;
    display: block;
}

small {
 display: block;
    margin-left: 420px;
    margin-top: -1.5%;
}

<form id="bestellen" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi">
        David Vann - Aquarium: <input size="3" name="David_Vann" type="number" min="1"> Max. 10 exemplaren
        Robert Seethaler - Een heel leven: <input size="3" name="Robert_Seethaler" type="text" pattern="[0-9]{2}"> Max. 99 exemplaren
        Paula Hawkins - Het meisje in de trein: <input name="Paula_Hawkins" type="range" min="0" max="15" step="5" list="Paula_Hawkins">Bestel 0, 5, 10 of 15 exemplaren
          <datalist id="Paula_Hawkins">
            <option value="0">
            <option value="5">
            <option value="10">
            <option value="15">
         </datalist>
        Ernest van der Kwast - De ijsmakers:
         <input type="radio" name="Ernest van der kwast" value="1">1
         <input type="radio" name="Ernest van der kwast" value="10">10
         <input type="radio" name="Ernest van der kwast" value="20">20

        Bert Natter - Remington:
            <select name="Bert Natter">
              <option value="geen">geen</option>
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
             </select>

   </form>

Body:
label[class=number]::before {
    counter-increment: section;
    content: counter(section) " " ;
    display: inline-block;
    color: white;
    width: 20px;
    background-color: black;
    text-align: center;
    padding-top: 1%;
    margin-left: 10px;
    padding-bottom: 1%;
}

label[id=Bert_natter] {
    display: block;
    margin-top: 10px;
}

label[class=number], select {
 display: inline-block;
    margin-top: 20px;
    width: 345px;
}

#bestellen input[type=number], #bestellen input[type=text], select {
 width: 40px;
    margin-left: 102%;
    display: block;
    margin-top: -7%;
    border-color: skyblue;
    border-style: double;
}

input[type=range] {
    width: 40px;
    position: relative;
    margin-left: 102%;
    background-color: transparent;
    margin-top: -5%;
    display: block;
}

small {
 display: block;
    margin-left: 420px;
    margin-top: -1.5%;
}

<div style="white-space: nowrap;">
<form id="bestellen" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi">
        <label class="number" id="David_Vann">David Vann - Aquarium: <input size="3" name="David_Vann" type="number" min="1"></label><small> Max. 10 exemplaren</small>
        <label class="number" id="Robert_Seethaler">Robert Seethaler - Een heel leven: <input size="3" name="Robert_Seethaler" type="text" pattern="[0-9]{2}"></label><small> Max. 99 exemplaren</small>
        <label id="Paula" class="number">Paula Hawkins - Het meisje in de trein: <input name="Paula_Hawkins" type="range" min="0" max="15" step="5" list="Paula_Hawkins"></label><small>Bestel 0, 5, 10 of 15 exemplaren</small>
          <datalist id="Paula_Hawkins">
            <option value="0">
            <option value="5">
            <option value="10">
            <option value="15">
         </datalist>
        <label class="number" id="Ernest_van_der_kwast">Ernest van der Kwast - De ijsmakers: </label>
        <label> <input type="radio" name="Ernest van der kwast" value="1">1</label>
        <label> <input type="radio" name="Ernest van der kwast" value="10">10</label>
        <label> <input type="radio" name="Ernest van der kwast" value="20">20</label><br>
        <label class="number" id="Bert_natter">Bert Natter - Remington:
            <select name="Bert Natter">
              <option value="geen">geen</option>
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
             </select>
         </label>
   </form>
</div>


问:
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options
I am using Eclipse plugin "IBM Worklight Developer Edition".

I am trying to debug the adapter procedure code. For that I tried to do some debug configurations but it said Server already running(debug button disabled). So I stopped the server then again tried debug configuration, this time the button was enabled but on console I got "ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options."

Please help me to do debug configuration.

答: this is pretty straightforward. you have the same argument twice somewhere in your vm arguments. Try referring to this post: ERROR: Cannot load this JVM TI agent twice starting Oracle WebLogic Server 12.1.3.0</p>

ContentLicense: CC BY-SA 4.0


问:
CSS column element inside bug
I used column-count, but it looks like I found a bug when an element has an absolute position and overflowed from the parent.

```<code>#master {
    column-count: 2;
}

.Books {
    display: table;
    column-break-inside: avoid;
    -webkit-column-break-inside: avoid;
}
</code>```

JSFiddle

There are two issues. One, the two red elements are not balanced (see the purple line) and second, the red element dropped on the bottom.

答:
Just add margin-top: -1px; in the .bookmarkAds class.

And margin-top: 10px; in .books class .

#master {
    column-count: 2;
}

#rule {
    position: absolute;
    width: 100%;
    height: 1px;
    background: #9C27B0;
    top: 7px;
    left: 0;
}

.Books {
    width: 100%;
    font-family: tahoma;
    font-size: 12px;
    border: 1px solid #ddd;
    line-height: 150%;
    background: #FFFFF6;
    float: right;
    box-sizing: border-box;
    padding: 5px 5px 10px 5px;
    margin: 3px;
    margin-top: 10px;
    position: relative;
    display: table;
    column-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    min-height: 200px;
}

.bookmarkAds {
    margin-top: -1px;
    position: absolute;
    left: 4px;
    color: #9e9e9e;
    cursor: pointer;
    text-shadow: 1px 2px 2px rgba(0, 0, 0, 0.30);
    top: -10px;
    font-size: 22px;
    background: red;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="rule"></div>

<div id="master">
    <div class="Books">
          <div id="Bookmark" class="bookmarkAds RedHeart" title="" data-id="653373">x</div>
          Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.

    </div>
    <div class="Books">
        <div id="Bookmark" class="bookmarkAds RedHeart" title="" data-id="653373">x</div>
        Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
        Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
    </div>
</div></code>```

Title: CSS column element inside bug

Body:
I used column-count, but it looks like I found a bug when an element has an absolute position and overflowed from the parent.

#master {
    column-count: 2;
}

.Books {
    display: table;
    column-break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

JSFiddle

There are two issues. One, the two red elements are not balanced (see the purple line) and second, the red element dropped on the bottom.

Body:
Just add margin-top: -1px; in the .bookmarkAds class.

And margin-top: 10px; in .books class .

#master {
    column-count: 2;
}

#rule {
    position: absolute;
    width: 100%;
    height: 1px;
    background: #9C27B0;
    top: 7px;
    left: 0;
}

.Books {
    width: 100%;
    font-family: tahoma;
    font-size: 12px;
    border: 1px solid #ddd;
    line-height: 150%;
    background: #FFFFF6;
    float: right;
    box-sizing: border-box;
    padding: 5px 5px 10px 5px;
    margin: 3px;
    margin-top: 10px;
    position: relative;
    display: table;
    column-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    min-height: 200px;
}

.bookmarkAds {
    margin-top: -1px;
    position: absolute;
    left: 4px;
    color: #9e9e9e;
    cursor: pointer;
    text-shadow: 1px 2px 2px rgba(0, 0, 0, 0.30);
    top: -10px;
    font-size: 22px;
    background: red;
}

<div id="rule"></div>

<div id="master">
    <div class="Books">
          <div id="Bookmark" class="bookmarkAds RedHeart" title="" data-id="653373">x</div>
          Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.

    </div>
    <div class="Books">
        <div id="Bookmark" class="bookmarkAds RedHeart" title="" data-id="653373">x</div>
        Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
        Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
    </div>
</div>


问:
Order of evaluation
I wonder if construction like this (initialization list) has well defined EO (evaluation order):

```<code>struct MemoryManager
    {
        Pair* firstPair_;//<-beg
        Pair* currentPair_;
        Pair* lastPair_;//<-end

        MemoryManager():lastPair_(currentPair_ = firstPair_ = nullptr)
            {/*e.b.*/}
};
</code>```

If yes I personally would prefer this way to the more conventional:

```<code>    MemoryManager():firstPair_(nullptr),
                    currentPair_(nullptr),
                    lastPair_(nullptr)
    {/*e.b*/}
</code>```

答: No, but it doesn't matter. Your code does not depend on the order in which currentPair_ and firstPair_ are zeroed.

ContentLicense: CC BY-SA 2.5

Title: Order of evaluation

Body:
I wonder if construction like this (initialization list) has well defined EO (evaluation order):

struct MemoryManager
    {
        Pair* firstPair_;//<-beg
        Pair* currentPair_;
        Pair* lastPair_;//<-end

        MemoryManager():lastPair_(currentPair_ = firstPair_ = nullptr)
            {/*e.b.*/}
};

If yes I personally would prefer this way to the more conventional:

    MemoryManager():firstPair_(nullptr),
                    currentPair_(nullptr),
                    lastPair_(nullptr)
    {/*e.b*/}


答:
you can try with this approach way use Cartesian product</p>

```<code>select t1.stdid,
case when t1.csid = 'CSC111_EX' then t1.score
    else t2.score end
    as csc111_EX_score,
case when t1.csid = 'CSC111_ca' then t1.score
    else t2.score end
    as csc111_ca_score
from your_table t1, your_table t2
where t1.stdid = t2.stdid and t1.score != t2.score and t1.csid != t2.csid
group by t1.stdid
</code>```

Title: How to query a table to get two types of score dump in just one table

Body:
Hello Guyz i have a table like below

+-------------+-----------+-------+
| stdid       | csid      | score |
+-------------+-----------+-------+
| 20090204001 | CSC111_ca |    20 |
| 20090204001 | CSC111_EX |    10 |
| 20090204002 | CSC111_ca |    58 |
| 20090204002 | CSC111_EX |     3 |
| 20090204003 | CSC111_ca |    64 |
| 20090204003 | CSC111_EX |    45 |
| 20090204004 | CSC111_ca |    21 |
| 20090204004 | CSC111_EX |    11 |
| 20090204005 | CSC111_ca |    59 |
| 20090204005 | CSC111_EX |     4 |
| 20090204006 | CSC111_ca |    65 |
| 20090204006 | CSC111_EX |    46 |
| 20090204007 | CSC111_ca |    22 |
| 20090204007 | CSC111_EX |    12 |
| 20090204008 | CSC111_ca |    60 |
| 20090204008 | CSC111_EX |     5 |
| 20090204009 | CSC111_ca |    66 |
| 20090204009 | CSC111_EX |    47 |
| 20090204010 | CSC111_ca |    23 |
| 20090204010 | CSC111_EX |    13 |
| 20090204011 | CSC111_ca |    61 |
| 20090204011 | CSC111_EX |     6 |
| 20090204012 | CSC111_ca |    67 |
| 20090204012 | CSC111_EX |    48 |
| 20090204013 | CSC111_ca |    24 |
| 20090204013 | CSC111_EX |    14 |
| 20090204014 | CSC111_ca |    62 |
| 20090204014 | CSC111_EX |     7 |
| 20090204015 | CSC111_ca |    68 |
| 20090204015 | CSC111_EX |    49 |
| 20090204016 | CSC111_ca |    25 |
| 20090204016 | CSC111_EX |    15 |
| 20090204017 | CSC111_ca |    63 |
| 20090204017 | CSC111_EX |     8 |
| 20090204018 | CSC111_ca |    69 |
| 20090204018 | CSC111_EX |    50 |
| 20090204019 | CSC111_ca |    26 |
| 20090204019 | CSC111_EX |    16 |
| 20090204020 | CSC111_ca |    64 |
| 20090204020 | CSC111_EX |     9 |
| 20090204021 | CSC111_ca |    70 |
| 20090204021 | CSC111_EX |    51 |
| 20090204022 | CSC111_ca |    27 |
| 20090204022 | CSC111_EX |    17 |
| 20090204023 | CSC111_ca |    65 |
| 20090204023 | CSC111_EX |    10 |
| 20090204024 | CSC111_ca |    71 |
| 20090204024 | CSC111_EX |    52 |
| 20090204025 | CSC111_ca |    28 |
| 20090204025 | CSC111_EX |    18 |
| 20090204026 | CSC111_ca |    66 |
| 20090204026 | CSC111_EX |    11 |
| 20090204027 | CSC111_ca |    72 |
| 20090204027 | CSC111_EX |    53 |
+-------------+-----------+-------+

and i want to select so that i can have
stdid, csc111_ca_score, csc111_EX_score  on just one table using mysql

Body:
you can try with this approach way use Cartesian product

select t1.stdid,
case when t1.csid = 'CSC111_EX' then t1.score
    else t2.score end
    as csc111_EX_score,
case when t1.csid = 'CSC111_ca' then t1.score
    else t2.score end
    as csc111_ca_score
from your_table t1, your_table t2
where t1.stdid = t2.stdid and t1.score != t2.score and t1.csid != t2.csid
group by t1.stdid


问:
Pushing an object with unique_ptr into vector in C++
I have a simple class structure modelling a discrete simulation, with a vector of States, which each contain a number of Transitions, held as a vector of smart pointers. I've used smart pointers to hold the transitions as in my full application I need polymorphism.

```<code>#include <vector>
#include <memory>

class Transition {
    public:
        Transition() {}
};

class State {
    public:
        State(int num) : num(num), transitions() {}
        void add_transition(std::unique_ptr<Transition> trans) {
            transitions.push_back(std::move(trans));
        }

    private:
        int num;
        std::vector<std::unique_ptr<Transition>> transitions;
};

int main() {
    std::vector<State> states;
    for (int i = 0; i < 10; i++) {
        State nstate = State(i);
        for (int j = 0; j < 2; j++) {
            nstate.add_transition(std::move(std::unique_ptr<Transition>(new Transition())));
        }
        // This line causes compiler errors
        states.push_back(nstate);
    }
}
</code>```

I get compiler errors when adding the new state object to the vector:

```<code>Error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Transition; _Dp = std::default_delete<Transition>]’
 { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
</code>```

I imagine this is due to vector making a copy of the State object which is also trying to make a copy of the vector of unique_ptrs which isn't allowed. I've seen that emplace_back doesn't make copies like push_back does but I still get the same error.

Adding the State object directly into the vector works, but I'd prefer to avoid this workaround as in my actual code I do more work with the State object rather than just adding transitions and don't want to keep accessing the vector.

```<code>int main() {
    std::vector<State> states;
    for (int i = 0; i < 10; i++) {
        states.push_back(State(i));
        for (int j = 0; j < 2; j++) {
            states[i].add_transition(std::move(std::unique_ptr<Transition>(new Transition())));
        }
    }
}
</code>```

答:
You are passing std::unique_ptr<Transition> to function by value, which should create a local copy in void add_transition(std::unique_ptr<Transition> trans).

If you will pass value by reference std::unique_ptr<Transition>& trans, you wouldn't need any std::move outside add_transition function.

Also you may want to use std::make_unique<Transition>() instead of std::uniqye_ptr<Transition>(new Transition()).

Encapsulation of new keyword makes your code clearer and decreeses probability of creating memory leak.

Body:
I have a simple class structure modelling a discrete simulation, with a vector of States, which each contain a number of Transitions, held as a vector of smart pointers. I've used smart pointers to hold the transitions as in my full application I need polymorphism.

#include <vector>
#include <memory>

class Transition {
    public:
        Transition() {}
};

class State {
    public:
        State(int num) : num(num), transitions() {}
        void add_transition(std::unique_ptr<Transition> trans) {
            transitions.push_back(std::move(trans));
        }

    private:
        int num;
        std::vector<std::unique_ptr<Transition>> transitions;
};

int main() {
    std::vector<State> states;
    for (int i = 0; i < 10; i++) {
        State nstate = State(i);
        for (int j = 0; j < 2; j++) {
            nstate.add_transition(std::move(std::unique_ptr<Transition>(new Transition())));
        }
        // This line causes compiler errors
        states.push_back(nstate);
    }
}

I get compiler errors when adding the new state object to the vector:

Error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Transition; _Dp = std::default_delete<Transition>]’
 { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }

I imagine this is due to vector making a copy of the State object which is also trying to make a copy of the vector of unique_ptrs which isn't allowed. I've seen that emplace_back doesn't make copies like push_back does but I still get the same error.

Adding the State object directly into the vector works, but I'd prefer to avoid this workaround as in my actual code I do more work with the State object rather than just adding transitions and don't want to keep accessing the vector.

int main() {
    std::vector<State> states;
    for (int i = 0; i < 10; i++) {
        states.push_back(State(i));
        for (int j = 0; j < 2; j++) {
            states[i].add_transition(std::move(std::unique_ptr<Transition>(new Transition())));
        }
    }
}


问:
Which exceptions can HttpClient throw?
I am using HttpClient in a xamarin forms project

The class is documented, but I can not find any documentation about which exceptions its methods might throw.

For example the GetAsync Method does not have any documentation about possible exceptions. But I assume it throws, for example when the server is unreachable.

Is there somewhere a list of exceptions this class might throw?

答:
As others have commented it depend on what you are calling with HttpClient. I get what you meant though and so here are some exceptions thrown with typical method calls.

SendAsync can throw:

ArgumentNullException The request was null.

InvalidOperationException The request message was already sent by the HttpClient instance.

HttpRequestException The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate
validation or timeout.

TaskCanceledException The request timed-out or the user canceled the request's Task.

Source: Microsoft Docs -> HttpClient -> SendAsync

Similarly GetAsync PostAsync PutAsync GetStringAsync GetStreamAsync etc can throw ArgumentNullException, HttpRequestException and  as above (but not InvalidOperationException).

Source: Microsoft Docs -> HttpClient -> GetAsync

Once you have called SendAsync or GetAsync etc you will have a Task<HttpResponseMessage>. Once awaited I tend to call EnsureSuccessStatusCode() to throw a HttpRequestException if there is a non success HTTP status code returned. https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs#L161

Title: Which exceptions can HttpClient throw?


问:
pass the variable as class name in jquery
I have the class name 'views-row5' in a variable 'classN'.I want to pass this to the jquery for find the class name 'views-row5' using variable 'classN' and add the class 'hello'.

jQuery(document).ready(function($) {
var classN="views-row5"
$('.carousel-inner li').each(function()
  {$(this).find(classN).addClass('hello');});
 }); ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="carousel-inner">
  <li>
     <div class="views-row4">1</div>
     <div class="views-row5">2</div>
  </li>
  <li>
     <div class="views-row4">1</div>
     <div class="views-row5">2</div>
  </li>
</div></code>```

答:
In the variable assignment, you have to add the dot for the class. like var classN=".views-row5"

jQuery(document).ready(function($) {
var classN=".views-row5"
$('.carousel-inner li').each(function()
  {$(this).find(classN).addClass('hello');});
 });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.hello {
color: red;
}</code>```

1

2

1

2

```

Body:
I have the class name 'views-row5' in a variable 'classN'.I want to pass this to the jquery for find the class name 'views-row5' using variable 'classN' and add the class 'hello'.

jQuery(document).ready(function($) {
var classN="views-row5"
$('.carousel-inner li').each(function()
  {$(this).find(classN).addClass('hello');});
 });

1

2

1

2

Body:
In the variable assignment, you have to add the dot for the class. like var classN=".views-row5"

jQuery(document).ready(function($) {
var classN=".views-row5"
$('.carousel-inner li').each(function()
  {$(this).find(classN).addClass('hello');});
 });

.hello {
color: red;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="carousel-inner">
  <li>
     <div class="views-row4">1</div>
     <div class="views-row5">2</div>
  </li>
  <li>
     <div class="views-row4">1</div>
     <div class="views-row5">2</div>
  </li>
</div>


答:
Try this code: </p>

```<code>jQuery(document).ready(function($) {
   var classN="views-row5"
   $('.' + classN).addClass('hello');
});
</code>```

Title: pass the variable as class name in jquery

Body:
Try this code:

jQuery(document).ready(function($) {
   var classN="views-row5"
   $('.' + classN).addClass('hello');
});


问:
Grid loaded from JSON file its works in IE but not able to load in fireFox?
I am using ExtJS3.3.1 and try to load a Grid from file which contains a JSON Object.
It will work fine in IE loads grid with data but not works in Firefox.
here is simple code It doesn't give any error and warnning.

```<code>var store = new Ext.data.Store({

    url: 'http://localhost/Vaishali/src/survey.html',

    reader: new Ext.data.JsonReader({
        root: 'data',
        id: 'appeId',
        totalProperty: 'total'
    }, [{
        name: 'appeId',
        mapping: 'appeId'
    }, {
        name: 'survId',
        mapping: 'survId'
    }, {
        name: 'location',
        mapping: 'location'
    }, {
        name: 'surveyDate',
        mapping: 'surveyDate'
    }, {
        name: 'surveyTime',
        mapping: 'surveyTime'
    }, {
        name: 'inputUserId',
        mapping: 'inputUserId'
    }])
});

store.load();

var grid = new Ext.grid.GridPanel({
    store: store,
    columns: [{
        header: "appeId",
        width: 60,
        dataIndex: 'appeId',
        sortable: true
    }, {
        header: "survId",
        width: 60,
        dataIndex: 'survId',
        sortable: true
    }, {
        header: "location",
        width: 60,
        dataIndex: 'location',
        sortable: true
    }, {
        header: "surveyDate",
        width: 100,
        dataIndex: 'surveyDate',
        sortable: true
    }, {
        header: "surveyTime",
        width: 100,
        dataIndex: 'surveyTime',
        sortable: true
    }, {
        header: "inputUserId",
        width: 80,
        dataIndex: 'inputUserId',
        sortable: true
    }],
    width: 540,
    height: 200
});
</code>```

so can u please tell me why this happens.
oops
when I added the event onload and check the exception in mozilla firefox it will show exception in that status code show 0 and text "connection Failure'.
but in IE it will give proper connection and result.

答: I'd suspect you're not loading the page from http://localhost/ as well, so you're running afoul of the same origin policy. IE's more forgiving than it strictly speaking should be.

Body:
I am using ExtJS3.3.1 and try to load a Grid from file which contains a JSON Object.
It will work fine in IE loads grid with data but not works in Firefox.
here is simple code It doesn't give any error and warnning.

var store = new Ext.data.Store({

    url: 'http://localhost/Vaishali/src/survey.html',

    reader: new Ext.data.JsonReader({
        root: 'data',
        id: 'appeId',
        totalProperty: 'total'
    }, [{
        name: 'appeId',
        mapping: 'appeId'
    }, {
        name: 'survId',
        mapping: 'survId'
    }, {
        name: 'location',
        mapping: 'location'
    }, {
        name: 'surveyDate',
        mapping: 'surveyDate'
    }, {
        name: 'surveyTime',
        mapping: 'surveyTime'
    }, {
        name: 'inputUserId',
        mapping: 'inputUserId'
    }])
});

store.load();

var grid = new Ext.grid.GridPanel({
    store: store,
    columns: [{
        header: "appeId",
        width: 60,
        dataIndex: 'appeId',
        sortable: true
    }, {
        header: "survId",
        width: 60,
        dataIndex: 'survId',
        sortable: true
    }, {
        header: "location",
        width: 60,
        dataIndex: 'location',
        sortable: true
    }, {
        header: "surveyDate",
        width: 100,
        dataIndex: 'surveyDate',
        sortable: true
    }, {
        header: "surveyTime",
        width: 100,
        dataIndex: 'surveyTime',
        sortable: true
    }, {
        header: "inputUserId",
        width: 80,
        dataIndex: 'inputUserId',
        sortable: true
    }],
    width: 540,
    height: 200
});

so can u please tell me why this happens.
oops
when I added the event onload and check the exception in mozilla firefox it will show exception in that status code show 0 and text "connection Failure'.
but in IE it will give proper connection and result.


问:
Sum Result in List RoundResult in List HomPlayerResult
Hi I wan't to get the sum of Results in my list of HomPlayerResult.RoundResults.Result

For each HomePlayerResult have a list of RoundResult where Table is 1, 2, 3 or 4.

```<code>var H1R1 = matchResult.HomePlayerResults.ToList().ForEach(y => y.RoundResults.ToList().ForEach(z => z.Round == 1 && z.Table == 1));
</code>```

But I get error:

Only assignment, call, increment, decrement, await, and new object
  expressions can be used as a statement

答:
I didn't understand what you are doing in your code but I believe that you want to get sum of round results out from all the results by filtering them on round 1 and table 1:

```<code>var H1R1 = matchResult.HomePlayerResults.Where(r => z.Round == 1 && z.Table == 1).Select(z => z.RoundResults).Sum();
</code>```

Where condition is filtering list by round 1 and table 1

Next I selected round results out from filtered list and summarized

Body:
Hi I wan't to get the sum of Results in my list of HomPlayerResult.RoundResults.Result

For each HomePlayerResult have a list of RoundResult where Table is 1, 2, 3 or 4.

var H1R1 = matchResult.HomePlayerResults.ToList().ForEach(y => y.RoundResults.ToList().ForEach(z => z.Round == 1 && z.Table == 1));

But I get error:

Only assignment, call, increment, decrement, await, and new object
  expressions can be used as a statement

Body:
I didn't understand what you are doing in your code but I believe that you want to get sum of round results out from all the results by filtering them on round 1 and table 1:

var H1R1 = matchResult.HomePlayerResults.Where(r => z.Round == 1 && z.Table == 1).Select(z => z.RoundResults).Sum();

Where condition is filtering list by round 1 and table 1

Next I selected round results out from filtered list and summarized


问:
Android App Installation Failed: Package com.my.app has no certificates at entry AndroidManifest.xml
in Android Studio I generated a signed APK with keystore and so on. While installing the APK onto a device it fails with 'App could not be installed' and in Android Monitor I saw the following line:

```<code>Package com.my.app has no certificates at entry AndroidManifest.xml; ignoring!
</code>```

Does anybody know what's wrong?

答:
Try to signed your APK with version 1. Version 2 signed APK only
compatible from 7.0 so it will not working on below 7.0 devices or try
to generate v1 and v2 version APK.

[ Note: When you generate signed apk for above 7.0 devices and below 7.0 devices then please check v1 and v2 both option. ]

Here is the reference link for more about V2 version and here is the link for overview.

Try this out and Your issue will resolved.

Body:
in Android Studio I generated a signed APK with keystore and so on. While installing the APK onto a device it fails with 'App could not be installed' and in Android Monitor I saw the following line:

Package com.my.app has no certificates at entry AndroidManifest.xml; ignoring!

Does anybody know what's wrong?


问:
SurfaceView flashes black on load
I have a drawing app that takes about 2-5 seconds to load the drawing for complicated drawings (done via an AsyncTask). For a better user experience, during this time I flash the stored PNG version of the drawing I have from the app directory as an ImageView, and show a loading ProgressBar calling setContentView() in the Activity constructor:

```<code><?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
    android:id="@+id/flash"
    android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@color/note_bg_white"
        android:contentDescription="@string/content_desc_flash_img"
        android:focusable="false" />
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="6dp"
        android:paddingLeft="6dp"
    android:paddingRight="6dp"
        android:gravity="bottom|center_vertical">
        <ProgressBar
            style="?android:attr/progressBarStyleHorizontal"
    android:id="@+id/toolbar_progress"
    android:layout_width="match_parent"
    android:layout_height="18dp"
    android:gravity="bottom|center_vertical" />
    </RelativeLayout>
</FrameLayout>
</code>```

When the AsyncTask is complete, I then call setContentView() again with the new layout:

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">
    <com.my.package.DrawingCanvas
        android:id="@+id/canvas"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:background="#ffffff" />
</RelativeLayout>
</code>```

When I was using a simple Canvas model, this worked perfectly, as the custom DrawingCanvas View would draw the drawing to the screen on the initial onDraw() before being shown to the user, but now using the SurfaceView with a drawing loop, I am seeing the flashed layout, then when the drawing is loaded, a black screen for about a second, then finally the new DrawingCanvas.

I am assuming that the reason is related to the start-up time of the drawing loop thread, and I've left my overide of onDraw() in the SurfaceView, and it gets called, but the canvas available in onDraw() does not seem to draw to the SurfaceView. I've also tried setting a solid color background in the XML above hoping at a minimum to show a white background, but those never seem to take affect, even setting it from code.

Any advice or an explanation of what I am seeing with the black screen?

EDIT:

Ok, have confirmed that onDraw() is drawing to the same canvas, so left my draw ops in there as well hoping that on the initial showing of the SurfaceView, the user would see those drawings like in the regular Canvas implementation, and when the drawing thread had spun up, it would overwrite the Canvas.

However, if I clear the drawing thread operations, I do see the onDraw() results, but again, AFTER the black screen flash. And if I remove the onDraw() override completely, I still see the black flash and then I see the layout with the white background from the XML.

So, it looks like no matter what, I am always going to see the black screen, unless perhaps instead of switching the layouts, I simply modify the existing 'flash' layout that is already active?

EDIT2:

Have tried using a ViewStub so that I can inflate the SurfaceView into the existing View after the note is loaded, but the same issu still applies. As near as I can tell, there is a sizable (~200ms) delay between the SurfaceView constructor and the call to surfaceCreated() executing, but not sure that this is where the black screen is happening, or why the screen is being drawn to black...

EDIT3:

My final attempt for now includes making the SurfaceView transparent. This combined with leaving the existing layout in place and simply adding to that layout via the ViewStub would have resulted in a working solution I though, but still, for a split second when the SurfaceView is loading the screen flashes black before the SurfaceView is shown, as transparent. If anyone has any other ideas to try, please post them.

答:
CrazyOrr's solution worked for me, but it was deep in the comments for the top answer by Evos, so here it is again:

There is a less messy approach, just put
  getWindow().setFormat(PixelFormat.TRANSLUCENT); in the host activity's
  onCreate() callback before calling setContentView(). – CrazyOrr May 5
  '16 at 7:29

Simply putting

```<code>getWindow().setFormat(PixelFormat.TRANSLUCENT);
</code>```

in the activity's onCreate() worked for me.

Title: SurfaceView flashes black on load

Body:
I have a drawing app that takes about 2-5 seconds to load the drawing for complicated drawings (done via an AsyncTask). For a better user experience, during this time I flash the stored PNG version of the drawing I have from the app directory as an ImageView, and show a loading ProgressBar calling setContentView() in the Activity constructor:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
    android:id="@+id/flash"
    android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@color/note_bg_white"
        android:contentDescription="@string/content_desc_flash_img"
        android:focusable="false" />
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="6dp"
        android:paddingLeft="6dp"
    android:paddingRight="6dp"
        android:gravity="bottom|center_vertical">
        <ProgressBar
            style="?android:attr/progressBarStyleHorizontal"
    android:id="@+id/toolbar_progress"
    android:layout_width="match_parent"
    android:layout_height="18dp"
    android:gravity="bottom|center_vertical" />
    </RelativeLayout>
</FrameLayout>

When the AsyncTask is complete, I then call setContentView() again with the new layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">
    <com.my.package.DrawingCanvas
        android:id="@+id/canvas"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:background="#ffffff" />
</RelativeLayout>

When I was using a simple Canvas model, this worked perfectly, as the custom DrawingCanvas View would draw the drawing to the screen on the initial onDraw() before being shown to the user, but now using the SurfaceView with a drawing loop, I am seeing the flashed layout, then when the drawing is loaded, a black screen for about a second, then finally the new DrawingCanvas.

I am assuming that the reason is related to the start-up time of the drawing loop thread, and I've left my overide of onDraw() in the SurfaceView, and it gets called, but the canvas available in onDraw() does not seem to draw to the SurfaceView. I've also tried setting a solid color background in the XML above hoping at a minimum to show a white background, but those never seem to take affect, even setting it from code.

Any advice or an explanation of what I am seeing with the black screen?

EDIT:

Ok, have confirmed that onDraw() is drawing to the same canvas, so left my draw ops in there as well hoping that on the initial showing of the SurfaceView, the user would see those drawings like in the regular Canvas implementation, and when the drawing thread had spun up, it would overwrite the Canvas.

However, if I clear the drawing thread operations, I do see the onDraw() results, but again, AFTER the black screen flash. And if I remove the onDraw() override completely, I still see the black flash and then I see the layout with the white background from the XML.

So, it looks like no matter what, I am always going to see the black screen, unless perhaps instead of switching the layouts, I simply modify the existing 'flash' layout that is already active?

EDIT2:

Have tried using a ViewStub so that I can inflate the SurfaceView into the existing View after the note is loaded, but the same issu still applies. As near as I can tell, there is a sizable (~200ms) delay between the SurfaceView constructor and the call to surfaceCreated() executing, but not sure that this is where the black screen is happening, or why the screen is being drawn to black...

EDIT3:

My final attempt for now includes making the SurfaceView transparent. This combined with leaving the existing layout in place and simply adding to that layout via the ViewStub would have resulted in a working solution I though, but still, for a split second when the SurfaceView is loading the screen flashes black before the SurfaceView is shown, as transparent. If anyone has any other ideas to try, please post them.

Body:
CrazyOrr's solution worked for me, but it was deep in the comments for the top answer by Evos, so here it is again:

There is a less messy approach, just put
  getWindow().setFormat(PixelFormat.TRANSLUCENT); in the host activity's
  onCreate() callback before calling setContentView(). – CrazyOrr May 5
  '16 at 7:29

Simply putting

getWindow().setFormat(PixelFormat.TRANSLUCENT);

in the activity's onCreate() worked for me.


问:
Java apache poi: excel cell color
I'm trying to change the background of a cell with apache poi.

I know there are a lot of answers about this, but I'm using the lastest  version, (3.16) and they are all deprecated.

For example all the answers suggest that I use

```<code>CellStyle#setFillPattern(CellStyle.SOLID_FOREGROUND);
</code>```

but it's deprecated entirely.

So, following the apache docs, I replaced all the deprecated functions with the new ones and came up with this MCVE:

```<code>import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class Mcve{
    public static void main(String[] args) {

    //Make workbook and first sheet
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet("sheet1");

    //Make a style
    XSSFCellStyle style = workbook.createCellStyle();
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFillBackgroundColor(IndexedColors.RED.getIndex());

    //Fill first line
    Row row = sheet.createRow(0);

    int i = 0;
    while (i < 5) {

        Cell cell = row.createCell(i);
        cell.setCellValue("TestCell " + i++);
                    cell.setCellStyle(style);
    }

    //Write to file
    File f = new File("Yourfilepathhere/document.xlsx"); //<-- FILL HERE

    try (FileOutputStream out = new FileOutputStream(f)) {
        workbook.write(out);
        workbook.close();
    } catch (Exception e) {
        e.printStackTrace();

    }
}
}
</code>```

I suggest you paste it in an empty Maven project in your IDE of choice and please add these dependencies to your pom.xml:

https://pastebin.com/CXdViuW5

Now, on the lastest version of Excel, this either prints all-black cells or normal white-background cells, depending on the color.
I have tried several colors and styles, doesn't seem to be working. The text is always there, but the background just won't apply.

What am I doing wrong here guys?

答:
```<code>XSSFWorkbook workbook1 = new XSSFWorkbook();
XSSFCellStyle greyBackgroundBold = workbook1.createCellStyle();
greyBackgroundBold.setFont(font);
greyBackgroundBold.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
greyBackgroundBold.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
</code>```

Title: Java apache poi: excel cell color

Body:
I'm trying to change the background of a cell with apache poi.

I know there are a lot of answers about this, but I'm using the lastest  version, (3.16) and they are all deprecated.

For example all the answers suggest that I use

CellStyle#setFillPattern(CellStyle.SOLID_FOREGROUND);

but it's deprecated entirely.

So, following the apache docs, I replaced all the deprecated functions with the new ones and came up with this MCVE:

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class Mcve{
    public static void main(String[] args) {

    //Make workbook and first sheet
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet("sheet1");

    //Make a style
    XSSFCellStyle style = workbook.createCellStyle();
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFillBackgroundColor(IndexedColors.RED.getIndex());

    //Fill first line
    Row row = sheet.createRow(0);

    int i = 0;
    while (i < 5) {

        Cell cell = row.createCell(i);
        cell.setCellValue("TestCell " + i++);
                    cell.setCellStyle(style);
    }

    //Write to file
    File f = new File("Yourfilepathhere/document.xlsx"); //<-- FILL HERE

    try (FileOutputStream out = new FileOutputStream(f)) {
        workbook.write(out);
        workbook.close();
    } catch (Exception e) {
        e.printStackTrace();

    }
}
}

I suggest you paste it in an empty Maven project in your IDE of choice and please add these dependencies to your pom.xml:

https://pastebin.com/CXdViuW5

Now, on the lastest version of Excel, this either prints all-black cells or normal white-background cells, depending on the color.
I have tried several colors and styles, doesn't seem to be working. The text is always there, but the background just won't apply.

What am I doing wrong here guys?


问:
How to disable iOS 8 emoji keyboard?
Is there any option to stop showing the emoji keyboard in iOS 8? It is not available in numpad and secure text but for email it is there.
If it is not possible to disable it how to get the string values from the emoji? </p>

答:
Though The Question is super old,
I was Facing the same problem and was able to resolve it by the time this page loaded by this small trick :

Simply Select "ASCII Capable" or "Numbers and Punctuations" in Interface Builder Xcode 8.2.1

Output is No Emoji Keyboard =D

I'm sure it'll help Someone =)

Title: How to disable iOS 8 emoji keyboard?


问:
How to execute success method in Firebase?
I'm developing an Android+Firebase app but since I'm new to both techlogies I'm having a problem regarding async calls and I haven't found the solution yet so hope you can help me.

I have the following snippet in my Activity's onCreate method:

```<code>final ArrayList<AssetLocation> assetsLocations = new ArrayList<>();
        DatabaseReference assetsLocationReference = database.getReference(FirebaseReferences.ASSETSLOCATION_REFERENCE);
        assetsLocationReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                ArrayList<String> assetsLocationSpinner = new ArrayList<String>();
                // Create an ArrayAdapter using the string array and a default spinner layout
                for (DataSnapshot postSnapshot : snapshot.getChildren()) {
                    //Getting the data from snapshot
                    AssetLocation assetsLocation = postSnapshot.getValue(AssetLocation.class);
                    assetsLocations.add(AssetLocation);
                }
            }

            @Override
            public void onCancelled(DatabaseError firebaseError) {
                System.out.println("The read failed: " + firebaseError.getMessage());
            }
        });
</code>```

I also have a pretty similar call but instead of getting Locations, I'm getting Types.

After this code (inside the onCreate method as well), I'm calling setScreenInfo which is a function to fill both spinners (and do more stuff) with said data but since it is an async call, the spinners are blank when I execute it.

How can I execute setScreenInfo once the calls are made? I tried with .once()/.on() but it's not being recognised by Android Studio as a function.

Thanks for your help!

答:
Because of the asynchronously behaviour, you need to move the declaration of the assetsLocations ArrayList:

```<code>final ArrayList<AssetLocation> assetsLocations = new ArrayList<>();
</code>```

inside the onDataChange() method, as assetsLocationSpinner ArrayList is. So remember, onDataChange is always called asynchronously. This means that the statement that adds objects of AssetLocation class to the list is executed before onDataChange has been called. That's why your list is empty outside that method.

For other approach, please visit this post and this post.

Hope ot helps.

Body:
I'm developing an Android+Firebase app but since I'm new to both techlogies I'm having a problem regarding async calls and I haven't found the solution yet so hope you can help me.

I have the following snippet in my Activity's onCreate method:

final ArrayList<AssetLocation> assetsLocations = new ArrayList<>();
        DatabaseReference assetsLocationReference = database.getReference(FirebaseReferences.ASSETSLOCATION_REFERENCE);
        assetsLocationReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                ArrayList<String> assetsLocationSpinner = new ArrayList<String>();
                // Create an ArrayAdapter using the string array and a default spinner layout
                for (DataSnapshot postSnapshot : snapshot.getChildren()) {
                    //Getting the data from snapshot
                    AssetLocation assetsLocation = postSnapshot.getValue(AssetLocation.class);
                    assetsLocations.add(AssetLocation);
                }
            }

            @Override
            public void onCancelled(DatabaseError firebaseError) {
                System.out.println("The read failed: " + firebaseError.getMessage());
            }
        });

I also have a pretty similar call but instead of getting Locations, I'm getting Types.

After this code (inside the onCreate method as well), I'm calling setScreenInfo which is a function to fill both spinners (and do more stuff) with said data but since it is an async call, the spinners are blank when I execute it.

How can I execute setScreenInfo once the calls are made? I tried with .once()/.on() but it's not being recognised by Android Studio as a function.

Thanks for your help!

Body:
Because of the asynchronously behaviour, you need to move the declaration of the assetsLocations ArrayList:

final ArrayList<AssetLocation> assetsLocations = new ArrayList<>();

inside the onDataChange() method, as assetsLocationSpinner ArrayList is. So remember, onDataChange is always called asynchronously. This means that the statement that adds objects of AssetLocation class to the list is executed before onDataChange has been called. That's why your list is empty outside that method.

For other approach, please visit this post and this post.

Hope ot helps.


问:
How to find path for on submit text box
I'm trying to reference a URL in a local application and am having difficultly finding the correct path to reference.
It uses a value that the website transforms into another value for the page requested.

The main URL is http://exac.broadinstitute.org/

My inputs contain variations of rs113488022 , which the website will turn to a variant

http://exac.broadinstitute.org/variant/7-140453136-A-T

Unfortunately I do not have this variant value to pass directly,and am looking for the path of the on submit action from the front page.

答:
Yikes, that is some horrible HTML code.

But if you inspect the input element you find that the form has a simple action /awesome, and the input’s name is query. As a consequence, you can simply perform a GET on the following URI:

```<code>http://exac.broadinstitute.org/awesome?query=rs113488022
</code>```

Be prepared to process redirects, because the above will give you an HTTP response of 302 FOUND with a redirect location (which is the URI you found).

Title: How to find path for on submit text box

Body:
Yikes, that is some horrible HTML code.

But if you inspect the input element you find that the form has a simple action /awesome, and the input’s name is query. As a consequence, you can simply perform a GET on the following URI:

http://exac.broadinstitute.org/awesome?query=rs113488022

Be prepared to process redirects, because the above will give you an HTTP response of 302 FOUND with a redirect location (which is the URI you found).


问:
Does  have significance to search engines?
The corporate guidlines at my company stipulate that our product names are written in a strange and "wonderful" way [oh how we all love Marketing departments!].

A product name such as "iPhone" is written with the "i" as bold and italic. E.g.

iPhone

I don't want search engines to segment the context of the bold/italic text - for example the above should just be read by a search engine as "iPhone", and not !! I !! Phone.

Just want to check if anyone knows for sure that

```<code><span class="branding">i</span>Phone
</code>```

Would not apply any additional significance to the "i"?

Many thanks

答:
The  keywords are not intended to have meaning in HTML. It is intended to provide inline differentiation, such as font/color changes, etc.

Some search engines may use supplied  tags to differentiate meanings or importance, but truly it is the CONTENT of the page that is more important than the styling.

,  etc have meaning because they convey a concept, beyond segmentation.

Title: Does <span> have significance to search engines?

Body:
The corporate guidlines at my company stipulate that our product names are written in a strange and "wonderful" way [oh how we all love Marketing departments!].

A product name such as "iPhone" is written with the "i" as bold and italic. E.g.

iPhone

I don't want search engines to segment the context of the bold/italic text - for example the above should just be read by a search engine as "iPhone", and not !! I !! Phone.

Just want to check if anyone knows for sure that

iPhone

Would not apply any additional significance to the "i"?

Many thanks


问:
Can I get access from code behind (of a ResourceDictionary) to a named control?
Is it possible to get access from a code behind (of a ResourceDictionary) to a named control?

E.g. for me it is necessary to create lots of folder picking dialogs. A dialog may contain several rows for each folder that has to be chosen.
Each row consists of: Label (Name), TextBox (Chosen Path) and a Button (opens FileBrowserDialog).

So now I want to access the TextBox when the FileBrowserDialog is finished. But I can not access the "SelectedFolderTextBox" from CodeBehind.

Is there a better way to achieve what I want to do?

XAML

```<code><ResourceDictionary ...>
    ...

    <StackPanel x:Key="FolderSearchPanel"
                x:Shared="False">
        <Label Content="Foldername"/>
        <TextBox x:Name="SelectedFolderTextBox"
                 Text="C:\Folder\Path\"/>
        <Button Content="..."
                Click="Button_Click"/>
    </StackPanel>
</ResourceDictionary>
</code>```

CodeBehind

```<code>private void Button_Click(object sender, RoutedEventArgs e)
{
    // Initialize and show
    var dialog = new System.Windows.Forms.FolderBrowserDialog();
    System.Windows.Forms.DialogResult result = dialog.ShowDialog();

    // Process result
    if (result == System.Windows.Forms.DialogResult.OK)
    {
        string selectedPath = dialog.SelectedPath;

        SelectedFolderTextBox.Text = selectedPath;  // THIS DOES NOT WORK
                                                    // since I don't have access to it
                                                    // but describes best, what I want to do
    }
}
</code>```

答:
You should be able to cast the sender argument to a Button and then cast the Parent property of the Button to a StackPanel and find the controls in the Children collection of the StackPanel. Something like this:

```<code>private void Button_Click(object sender, RoutedEventArgs e)
{
    // Initialize and show
    var dialog = new System.Windows.Forms.FolderBrowserDialog();
    System.Windows.Forms.DialogResult result = dialog.ShowDialog();

    // Process result
    if (result == System.Windows.Forms.DialogResult.OK)
    {
        string selectedPath = dialog.SelectedPath;

        Button clickedButton = sender as Button;
        StackPanel sp = clickedButton.Parent as StackPanel;
        if (sp != null)
        {
            TextBox SelectedFolderTextBox = sp.Children.OfType<TextBox>().FirstOrDefault(x => x.Name == "SelectedFolderTextBox");
            if (SelectedFolderTextBox != null)
                SelectedFolderTextBox.Text = selectedPath;
        }
    }
}
</code>```

Body:
Is it possible to get access from a code behind (of a ResourceDictionary) to a named control?

E.g. for me it is necessary to create lots of folder picking dialogs. A dialog may contain several rows for each folder that has to be chosen.
Each row consists of: Label (Name), TextBox (Chosen Path) and a Button (opens FileBrowserDialog).

So now I want to access the TextBox when the FileBrowserDialog is finished. But I can not access the "SelectedFolderTextBox" from CodeBehind.

Is there a better way to achieve what I want to do?

XAML

<ResourceDictionary ...>
    ...

    <StackPanel x:Key="FolderSearchPanel"
                x:Shared="False">

        <TextBox x:Name="SelectedFolderTextBox"
                 Text="C:\Folder\Path\"/>
        <Button Content="..."
                Click="Button_Click"/>
    </StackPanel>
</ResourceDictionary>

CodeBehind

private void Button_Click(object sender, RoutedEventArgs e)
{
    // Initialize and show
    var dialog = new System.Windows.Forms.FolderBrowserDialog();
    System.Windows.Forms.DialogResult result = dialog.ShowDialog();

    // Process result
    if (result == System.Windows.Forms.DialogResult.OK)
    {
        string selectedPath = dialog.SelectedPath;

        SelectedFolderTextBox.Text = selectedPath;  // THIS DOES NOT WORK
                                                    // since I don't have access to it
                                                    // but describes best, what I want to do
    }
}

Body:
You should be able to cast the sender argument to a Button and then cast the Parent property of the Button to a StackPanel and find the controls in the Children collection of the StackPanel. Something like this:

private void Button_Click(object sender, RoutedEventArgs e)
{
    // Initialize and show
    var dialog = new System.Windows.Forms.FolderBrowserDialog();
    System.Windows.Forms.DialogResult result = dialog.ShowDialog();

    // Process result
    if (result == System.Windows.Forms.DialogResult.OK)
    {
        string selectedPath = dialog.SelectedPath;

        Button clickedButton = sender as Button;
        StackPanel sp = clickedButton.Parent as StackPanel;
        if (sp != null)
        {
            TextBox SelectedFolderTextBox = sp.Children.OfType<TextBox>().FirstOrDefault(x => x.Name == "SelectedFolderTextBox");
            if (SelectedFolderTextBox != null)
                SelectedFolderTextBox.Text = selectedPath;
        }
    }
}


问:
copy and running configfiles programatically in ansible
There is a ansible code i am writing. It does two tasks, first is to copy a configuration file to target instance in groups. Second is running that config file to install the application.

I am creating configuration file and inventory programtically so that same suffix is added to both configfile name & groupname in inventory:

```<code>Configfile name example :            Equivalent group names:
myappconf1                             [myapp1]
                                       hostname
myappconf2                             [myapp2]
                                       hostname
</code>```

This is my code for copying files

```<code>hosts: all
tasks:
name: Copy file.role1 to host1
 copy: src=/tmp/myconf1 dest=/tmp
 when:
  - "'myapp1' in group_names"

name: Copy Config File two to  to Ldap2
 copy: src=/tmp/myconf2 dest=/tmp
 when:
  - "'myapp2' in group_names"
</code>```

This is my code for running conf file

```<code>hosts: myapp1
tasks:
  - command: "/tmp/mainapp/update.sh -f myappconf1"

hosts: myapp2
tasks:
  - command: "/tmp/mainapp/update.sh -f myappconf1"
</code>```

But depending on user input uncertain number of conf files and groups can be created so I would like to do task more programatically. desired code may look like:

```<code>[task for copying file]
hosts: ~(myapp)
tasks:
- copy: copy the appropriate file to the host
        example: copy myappconf4 to myapp4
- command: run the commmand with appropirate file
           example: for myapp3, command: /tmp/mainapp/update.sh -f myappconf3
</code>```

Can someone please suggest me what i can use to make my code more generic and efficient ?

答:
You can use group variables like this,

```<code>#File : "myapp1/group_vars/all/vars_file.yml"
# Application settings
app_name: "myapp1"
copy_file: "myapp1conf1"
.
.
# other variables used for myapp1
</code>```

Then use 2nd folder for 2nd app

```<code>#File : "myapp2/group_vars/all/vars_file.yml"
# Application settings
copy_file: "myapp2conf2"
.
.
# other variables used for myapp2
</code>```

And In your code modify as below,

```<code>hosts: all
-tasks
    -name: Copy file.role1 to host1
     copy: src=/tmp/{{ copy_file }} dest=/tmp

    -name : execute script
     command: "/tmp/mainapp/update.sh -f {{ app_name }}"
</code>```

Now depending upon the environment use the user input during the play time as below,

```<code>ansible-play -i myapp1 main.yml
    or
ansible-play -i myapp2 main.yml
</code>```

Body:
There is a ansible code i am writing. It does two tasks, first is to copy a configuration file to target instance in groups. Second is running that config file to install the application.

I am creating configuration file and inventory programtically so that same suffix is added to both configfile name & groupname in inventory:

Configfile name example :            Equivalent group names:
myappconf1                             [myapp1]
                                       hostname
myappconf2                             [myapp2]
                                       hostname

This is my code for copying files

hosts: all
tasks:
name: Copy file.role1 to host1
 copy: src=/tmp/myconf1 dest=/tmp
 when:
  - "'myapp1' in group_names"

name: Copy Config File two to  to Ldap2
 copy: src=/tmp/myconf2 dest=/tmp
 when:
  - "'myapp2' in group_names"

This is my code for running conf file

hosts: myapp1
tasks:
  - command: "/tmp/mainapp/update.sh -f myappconf1"

hosts: myapp2
tasks:
  - command: "/tmp/mainapp/update.sh -f myappconf1"

But depending on user input uncertain number of conf files and groups can be created so I would like to do task more programatically. desired code may look like:

[task for copying file]
hosts: ~(myapp)
tasks:
- copy: copy the appropriate file to the host
        example: copy myappconf4 to myapp4
- command: run the commmand with appropirate file
           example: for myapp3, command: /tmp/mainapp/update.sh -f myappconf3

Can someone please suggest me what i can use to make my code more generic and efficient ?

Body:
You can use group variables like this,

#File : "myapp1/group_vars/all/vars_file.yml"
# Application settings
app_name: "myapp1"
copy_file: "myapp1conf1"
.
.
# other variables used for myapp1

Then use 2nd folder for 2nd app

#File : "myapp2/group_vars/all/vars_file.yml"
# Application settings
copy_file: "myapp2conf2"
.
.
# other variables used for myapp2

And In your code modify as below,

hosts: all
-tasks
    -name: Copy file.role1 to host1
     copy: src=/tmp/{{ copy_file }} dest=/tmp

    -name : execute script
     command: "/tmp/mainapp/update.sh -f {{ app_name }}"

Now depending upon the environment use the user input during the play time as below,

ansible-play -i myapp1 main.yml
    or
ansible-play -i myapp2 main.yml


问:
Android Firebase How to get the key of a pushed value
How do I get the push key (the one in the highlighted with blue pen)?
I want to get that value in order to change the value of subjectName child.

答: if you have unique subject code then you can use it and call updatechild method.it is in the firebase documentation.</p>


问:
how optimize this mysql query?
i have written this mysql query:

```<code>SELECT * , 1 AS haschild
       FROM table2
       WHERE parentid = '0'
             AND pid IN ( SELECT parentid FROM table2 )
UNION
SELECT * , 0
       FROM table2
       WHERE parentid = '0'
             AND pid NOT IN ( SELECT parentid FROM table2 )
ORDER BY pid
</code>```

but i think it is so silly query !!
hope you can get my meaning of this query and guide me to write a better one.

thanks.

答:
```<code>   SELECT t1.*,
          IF(t2.parentid IS NULL, 0, 1) AS haschild
     FROM table2 t1
LEFT JOIN table2 t2 ON t1.pid = t2.parentid
    WHERE t1.parentid = 0
 ORDER BY t1.pid
</code>```

Notes:

Create index on parentid field

If parentid is a number - don't put quotes around

Title: how optimize this mysql query?

Body:
i have written this mysql query:

SELECT * , 1 AS haschild
       FROM table2
       WHERE parentid = '0'
             AND pid IN ( SELECT parentid FROM table2 )
UNION
SELECT * , 0
       FROM table2
       WHERE parentid = '0'
             AND pid NOT IN ( SELECT parentid FROM table2 )
ORDER BY pid

but i think it is so silly query !!
hope you can get my meaning of this query and guide me to write a better one.

thanks.

Body:
   SELECT t1.*,
          IF(t2.parentid IS NULL, 0, 1) AS haschild
     FROM table2 t1
LEFT JOIN table2 t2 ON t1.pid = t2.parentid
    WHERE t1.parentid = 0
 ORDER BY t1.pid

Notes:

Create index on parentid field

If parentid is a number - don't put quotes around


问:
How to add an attention mechanism in keras?
I'm currently using this code that i get from one discussion on github
Here's the code of the attention mechanism:

```<code>_input = Input(shape=[max_length], dtype='int32')

# get the embedding layer
embedded = Embedding(
        input_dim=vocab_size,
        output_dim=embedding_size,
        input_length=max_length,
        trainable=False,
        mask_zero=False
    )(_input)

activations = LSTM(units, return_sequences=True)(embedded)

# compute importance for each step
attention = Dense(1, activation='tanh')(activations)
attention = Flatten()(attention)
attention = Activation('softmax')(attention)
attention = RepeatVector(units)(attention)
attention = Permute([2, 1])(attention)

sent_representation = merge([activations, attention], mode='mul')
sent_representation = Lambda(lambda xin: K.sum(xin, axis=-2), output_shape=(units,))(sent_representation)

probabilities = Dense(3, activation='softmax')(sent_representation)
</code>```

Is this the correct way to do it? i was sort of expecting the existence of time distributed layer since attention mechanism is distributed in every time step of the RNN. I need someone to confirm that this implementation(the code) is a correct implementation of attention mechanism. Thank you.

答:
If you want to have an attention along the time dimension, then this part of your code seems correct to me:

```<code>activations = LSTM(units, return_sequences=True)(embedded)

# compute importance for each step
attention = Dense(1, activation='tanh')(activations)
attention = Flatten()(attention)
attention = Activation('softmax')(attention)
attention = RepeatVector(units)(attention)
attention = Permute([2, 1])(attention)

sent_representation = merge([activations, attention], mode='mul')
</code>```

You've worked out the attention vector of shape (batch_size, max_length):

```<code>attention = Activation('softmax')(attention)
</code>```

I've never seen this code before, so I can't say if this one is actually correct or not:

```<code>K.sum(xin, axis=-2)
</code>```

Further reading (you might have a look):

https://github.com/philipperemy/keras-visualize-activations

https://github.com/philipperemy/keras-attention-mechanism

Body:
I'm currently using this code that i get from one discussion on github
Here's the code of the attention mechanism:

_input = Input(shape=[max_length], dtype='int32')

# get the embedding layer
embedded = Embedding(
        input_dim=vocab_size,
        output_dim=embedding_size,
        input_length=max_length,
        trainable=False,
        mask_zero=False
    )(_input)

activations = LSTM(units, return_sequences=True)(embedded)

# compute importance for each step
attention = Dense(1, activation='tanh')(activations)
attention = Flatten()(attention)
attention = Activation('softmax')(attention)
attention = RepeatVector(units)(attention)
attention = Permute([2, 1])(attention)

sent_representation = merge([activations, attention], mode='mul')
sent_representation = Lambda(lambda xin: K.sum(xin, axis=-2), output_shape=(units,))(sent_representation)

probabilities = Dense(3, activation='softmax')(sent_representation)

Is this the correct way to do it? i was sort of expecting the existence of time distributed layer since attention mechanism is distributed in every time step of the RNN. I need someone to confirm that this implementation(the code) is a correct implementation of attention mechanism. Thank you.

Body:
If you want to have an attention along the time dimension, then this part of your code seems correct to me:

activations = LSTM(units, return_sequences=True)(embedded)

# compute importance for each step
attention = Dense(1, activation='tanh')(activations)
attention = Flatten()(attention)
attention = Activation('softmax')(attention)
attention = RepeatVector(units)(attention)
attention = Permute([2, 1])(attention)

sent_representation = merge([activations, attention], mode='mul')

You've worked out the attention vector of shape (batch_size, max_length):

attention = Activation('softmax')(attention)

I've never seen this code before, so I can't say if this one is actually correct or not:

K.sum(xin, axis=-2)

Further reading (you might have a look):

https://github.com/philipperemy/keras-visualize-activations

https://github.com/philipperemy/keras-attention-mechanism


问:
Set last clicked checkbox element as checked on form submit
I have a form where user can choose between 4 options.

```<code><ul>
   <li><input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="1" {{ (Request::get('mediaChannelFilter')==1) ? "checked":"" }}> Option 1</li>
   <li><input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="2" {{ (Request::get('mediaChannelFilter')==2) ? "checked":"" }}> Option 2</li>
   <li><input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="3" {{ (Request::get('mediaChannelFilter')==3) ? "checked":"" }}> Option 3</li>
   <li><input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="4" {{ (Request::get('mediaChannelFilter')==4) ? "checked":"" }}> Option 4</li>
 </ul>
</code>```

And it works fine when I select first option, then second, then third and fourth. {{ (Request::get('mediaChannelFilter')}} works fine and makes last clicked element as checked. But problem occurs when I click last option first and then I want to click previous one.

In URL I get:

```<code>http://myapp.com?mediaChannelFilter=1&mediaChannelFilter=4
</code>```

And Option four stays checked. How can I make it unchecked and set, for example, Option two as checked.

Now it turns just into this:

```<code>http://myapp.com?mediaChannelFilter=2&mediaChannelFilter=4
</code>```

答:
Radios

I think you need radios because then it could be only one option that will be checked.

Through that you get the url like that

http://myapp.com?mediaChannelFilter=4

Checkboxes

Otherwise if you want to permit many values because many checkboxes are checked than you can change the parameter name into this name="mediaChannelFilter[]"

Through that you get the url like that

http://myapp.com?mediaChannelFilter[]=1&mediaChannelFilter[]=4

jQuery

You can solve it like this too

$(document).ready(function() {
  $('.test').on('change', function() {
    $(this).closest('ul').find('.test').not($(this)).prop('checked', false);
    $(this).closest('form').submit();
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul {
  padding: 0px;
  list-style: none;
}</code>```

<input type="checkbox" name="mediaChannelFilter" class="test" value="1" /> Option 1

<input type="checkbox" name="mediaChannelFilter" class="test" value="2" /> Option 2

<input type="checkbox" name="mediaChannelFilter" class="test" value="3" /> Option 3

<input type="checkbox" name="mediaChannelFilter" class="test" value="4" /> Option 4

```

Body:
I have a form where user can choose between 4 options.

<input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="1" {{ (Request::get('mediaChannelFilter')==1) ? "checked":"" }}> Option 1

<input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="2" {{ (Request::get('mediaChannelFilter')==2) ? "checked":"" }}> Option 2

<input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="3" {{ (Request::get('mediaChannelFilter')==3) ? "checked":"" }}> Option 3

<input type="checkbox" name="mediaChannelFilter" onchange="this.form.submit()" class="test" value="4" {{ (Request::get('mediaChannelFilter')==4) ? "checked":"" }}> Option 4

And it works fine when I select first option, then second, then third and fourth. {{ (Request::get('mediaChannelFilter')}} works fine and makes last clicked element as checked. But problem occurs when I click last option first and then I want to click previous one.

In URL I get:

http://myapp.com?mediaChannelFilter=1&mediaChannelFilter=4

And Option four stays checked. How can I make it unchecked and set, for example, Option two as checked.

Now it turns just into this:

http://myapp.com?mediaChannelFilter=2&mediaChannelFilter=4

Body:
Radios

I think you need radios because then it could be only one option that will be checked.

Through that you get the url like that

http://myapp.com?mediaChannelFilter=4

Checkboxes

Otherwise if you want to permit many values because many checkboxes are checked than you can change the parameter name into this name="mediaChannelFilter[]"

Through that you get the url like that

http://myapp.com?mediaChannelFilter[]=1&mediaChannelFilter[]=4

jQuery

You can solve it like this too

$(document).ready(function() {
  $('.test').on('change', function() {
    $(this).closest('ul').find('.test').not($(this)).prop('checked', false);
    $(this).closest('form').submit();
  });
});

ul {
  padding: 0px;
  list-style: none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<ul>
   <li><input type="checkbox" name="mediaChannelFilter" class="test" value="1" />&nbsp;Option 1</li>
   <li><input type="checkbox" name="mediaChannelFilter" class="test" value="2" />&nbsp;Option 2</li>
   <li><input type="checkbox" name="mediaChannelFilter" class="test" value="3" />&nbsp;Option 3</li>
   <li><input type="checkbox" name="mediaChannelFilter" class="test" value="4" />&nbsp;Option 4</li>
 </ul>


问:
Python. Connecting custom class to QThread
In my app I have controll class defined as follow:

```<code>class Controller(QtGui.QWidget, Ui_myUI):
</code>```

In this class in the button clicked action i would like to connect the finished() action of QThread to the done method defined in Controller class as follows:

```<code>def applyAction(self):
    self.myTread = MyTestTread()
    self.connect(self.myTread, QtCore.SIGNAL("finished()"), self.done)
    self.myTread.start()
</code>```

But this code returns the follwing error:

```<code>AttributeError: 'Controller' object has no attribute 'connect'
</code>```

What i'm doing wrong here?

答:
The connect function that you're trying to use is a staticmethod of QObject.  This example is from the docs:

```<code>button = QtGui.QPushButton("Call someFunc")
QtCore.QObject.connect(button, QtCore.SIGNAL ('clicked()'), someFunc)
</code>```

It seems to me you want to replace your second line in applyAction with:

```<code>QtCore.QObject.connect(self.myTread, QtCore.SIGNAL("finished()"), self.done)
</code>```

Note that this syntax is long ago deprecated (since Qt 4.5).  The new way is:

```<code>self.myTread.finished.connect(self.done)
</code>```

Body:
In my app I have controll class defined as follow:

class Controller(QtGui.QWidget, Ui_myUI):

In this class in the button clicked action i would like to connect the finished() action of QThread to the done method defined in Controller class as follows:

def applyAction(self):
    self.myTread = MyTestTread()
    self.connect(self.myTread, QtCore.SIGNAL("finished()"), self.done)
    self.myTread.start()

But this code returns the follwing error:

AttributeError: 'Controller' object has no attribute 'connect'

What i'm doing wrong here?

Body:
The connect function that you're trying to use is a staticmethod of QObject.  This example is from the docs:

button = QtGui.QPushButton("Call someFunc")
QtCore.QObject.connect(button, QtCore.SIGNAL ('clicked()'), someFunc)

It seems to me you want to replace your second line in applyAction with:

QtCore.QObject.connect(self.myTread, QtCore.SIGNAL("finished()"), self.done)

Note that this syntax is long ago deprecated (since Qt 4.5).  The new way is:

self.myTread.finished.connect(self.done)


问:
Load an existing page/form as a modal on button click
I have an existing webpage that contains a form for submitting questions.

Existing Form Page

I want to load that form as a modal/pop-up on my homepage when someone clicks a button.

I don't want the user to have to navigate away from the page they are on. They should be able to fill out the form and submit after clicking the button.

I thought I could use jQuery .load() but I think I am using it incorrectly.

I have placed the html/JQuery in the file containing my homepage.

I am not sure what to put as an argument in .load(), the page url or the file? I have tried both and neither work.

Homepage

```<code><div id="PopUpForm">Pop Up Form</div>
<a href="#" onclick="openDialog();">Button</a>

 <script type="text/javascript">
function openDialog() {
   $("#PopUpForm").load('question-submit-form.php').dialog({modal: true});
}
</script>
</code>```

答:
You have to make sure that the 'question-submit-form.php' is in the right directory. Also make sure to include jqueryUI script and css.
The following works fine for me.</p>

```<code><!--jqueryUI css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">

<!-- body -->

<div id="PopUpForm">Pop Up Form</div>
<a href="#" onclick="openDialog();">Button</a>

<!-- include jquery and jquery ui and jqueryUI js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<script type="text/javascript">
   function openDialog() {
     $("#PopUpForm").load('question-submit-form.php').dialog({model:true});
   }
</script>
</code>```

Body:
I have an existing webpage that contains a form for submitting questions.

Existing Form Page

I want to load that form as a modal/pop-up on my homepage when someone clicks a button.

I don't want the user to have to navigate away from the page they are on. They should be able to fill out the form and submit after clicking the button.

I thought I could use jQuery .load() but I think I am using it incorrectly.

I have placed the html/JQuery in the file containing my homepage.

I am not sure what to put as an argument in .load(), the page url or the file? I have tried both and neither work.

Homepage

Pop Up Form

Button

Body:
You have to make sure that the 'question-submit-form.php' is in the right directory. Also make sure to include jqueryUI script and css.
The following works fine for me.

<!--jqueryUI css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">

<!-- body -->

<div id="PopUpForm">Pop Up Form</div>
<a href="#" onclick="openDialog();">Button</a>

<!-- include jquery and jquery ui and jqueryUI js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<script type="text/javascript">
   function openDialog() {
     $("#PopUpForm").load('question-submit-form.php').dialog({model:true});
   }
</script>