问:
How to change CSS elements of an element when hovering on another
I'm experimenting with a design. I have a text element that changes colors and glows on hover. It's an a element wrapped in a p. I have the text in the middle of a circular image. I'd like for the image to change it's border color from transparent to white when a is hovered over. I've done some research but can't seem to get any of the solutions to work.

What I've tried,

a:hover > img { border-color: #fff; }

a:hover + img { border-color: #fff; }

a:hover img { border-color: #fff; }

a:hover ~ img { border-color: #fff; }

Same as above but p a:hover + img

Adding a class and id to img

Please help, here's the code:

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <p>Welcome</p>
  <img class="logo" src="https://placehold.it/940x940" alt="">

</div></code>```

答:
CSS has no ability to look outside of the currently specified range of selectors, CSS can only cascade down, it cannot traverse back.

As it stands now, you could achieve the desired behaviour, using the adjacent sibling combinator +, with the following selectors: p:hover + img { border-color: #fff; }, without any further amendments to the DOM.

Although, this wouldn't be advised as these selectors are too general and not specific enough, the chances of only having one instance of a img tag following a generic p tag could be slim and unexpected knock-on effects could occur as a result.

Consider the following adjustments in order to have any one of the below specified range of selectors apply and provide the intended behaviour.

a:hover > img { border-color: #fff; }

1. Child Combinator >:

Type: Combinator

Syntax: A > B

See: Child combinator - CSS | MDN

The > combinator selects nodes that are direct children of the first
  element

Example:

HTML

```<code><div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
  <img class="logo" src="https://placehold.it/940x940" alt="">
</div>
</code>```

CSS

```<code>.welcome:hover > img {
  border-color: white;
}
</code>```

/* Additional */

.welcome:hover > img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p>Welcome</p>
    <img class="logo" src="https://placehold.it/940x940" alt="">
  </div>

</div></code>```

a:hover + img { border-color: #fff; }

2. Adjacent Sibling Combinator +:

Type: Combinator

Syntax: A + B

See: Adjacent sibling combinator - CSS | MDN

The + combinator selects adjacent siblings. This means that the
  second element directly follows the first, and both share the same
  parent.

Example:

HTML

```<code><div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
  <img class="logo" src="https://placehold.it/940x940" alt="">
</div>
</code>```

CSS

```<code>.welcome p:hover + img {
  border-color: white;
}
</code>```

/* Additional */

.welcome p:hover + img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p>Welcome</p>
    <img class="logo" src="https://placehold.it/940x940" alt="">
  </div>

</div></code>```

a:hover ~ img { border-color: #fff; }

3. General Sibling Combinator ~:

Type: Combinator

Syntax: A ~ B

See: General sibling combinator - CSS | MDN

The ~ combinator selects siblings. This means that the second
  element follows the first (though not necessarily immediately), and
  both share the same parent.

Example:

HTML

```<code><div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
  <p>arbitrary element</p>
  <p>another arbitrary element</p>
  <img class="logo" src="https://placehold.it/940x940" alt="">
</div>
</code>```

CSS

```<code>.welcome p:hover ~ img {
  border-color: white;
}
</code>```

/* Additional */

.welcome p:hover ~ img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p>Welcome</p>
    <p>arbitrary element</p>
    <p>another arbitrary element</p>
    <img class="logo" src="https://placehold.it/940x940" alt="">
  </div>

</div></code>```

a:hover img { border-color: #fff; }

4. Descendant Combinator :

Type: Combinator

Syntax: A B

See: Descendant combinator - CSS | MDN

The    combinator selects nodes that are descendants of the first
  element.

Example:

HTML

```<code><div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a>
     <img class="logo" src="https://placehold.it/940x940" alt="">
  </p>
</div>
</code>```

CSS

```<code>.welcome p:hover img {
  border-color: white;
}
</code>```

/* Additional */

.welcome p:hover img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p>
      Welcome
      <img class="logo" src="https://placehold.it/940x940" alt="">
    </p>
  </div>

</div></code>```

More on CSS Selectors

Body:
I'm experimenting with a design. I have a text element that changes colors and glows on hover. It's an a element wrapped in a p. I have the text in the middle of a circular image. I'd like for the image to change it's border color from transparent to white when a is hovered over. I've done some research but can't seem to get any of the solutions to work.

What I've tried,

a:hover > img { border-color: #fff; }

a:hover + img { border-color: #fff; }

a:hover img { border-color: #fff; }

a:hover ~ img { border-color: #fff; }

Same as above but p a:hover + img

Adding a class and id to img

Please help, here's the code:

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}

Welcome

Body:
CSS has no ability to look outside of the currently specified range of selectors, CSS can only cascade down, it cannot traverse back.

As it stands now, you could achieve the desired behaviour, using the adjacent sibling combinator +, with the following selectors: p:hover + img { border-color: #fff; }, without any further amendments to the DOM.

Although, this wouldn't be advised as these selectors are too general and not specific enough, the chances of only having one instance of a img tag following a generic p tag could be slim and unexpected knock-on effects could occur as a result.

Consider the following adjustments in order to have any one of the below specified range of selectors apply and provide the intended behaviour.

a:hover > img { border-color: #fff; }

1. Child Combinator >:

Type: Combinator

Syntax: A > B

See: Child combinator - CSS | MDN

The > combinator selects nodes that are direct children of the first
  element

Example:

HTML

<div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
  <img class="logo" src="https://placehold.it/940x940" alt="">
</div>

CSS

.welcome:hover > img {
  border-color: white;
}

/* Additional */

.welcome:hover > img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}

<div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
    <img class="logo" src="https://placehold.it/940x940" alt="">
  </div>

</div>

a:hover + img { border-color: #fff; }

2. Adjacent Sibling Combinator +:

Type: Combinator

Syntax: A + B

See: Adjacent sibling combinator - CSS | MDN

The + combinator selects adjacent siblings. This means that the
  second element directly follows the first, and both share the same
  parent.

Example:

HTML

<div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
  <img class="logo" src="https://placehold.it/940x940" alt="">
</div>

CSS

.welcome p:hover + img {
  border-color: white;
}

/* Additional */

.welcome p:hover + img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}

<div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
    <img class="logo" src="https://placehold.it/940x940" alt="">
  </div>

</div>

a:hover ~ img { border-color: #fff; }

3. General Sibling Combinator ~:

Type: Combinator

Syntax: A ~ B

See: General sibling combinator - CSS | MDN

The ~ combinator selects siblings. This means that the second
  element follows the first (though not necessarily immediately), and
  both share the same parent.

Example:

HTML

<div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
  <p>arbitrary element</p>
  <p>another arbitrary element</p>
  <img class="logo" src="https://placehold.it/940x940" alt="">
</div>

CSS

.welcome p:hover ~ img {
  border-color: white;
}

/* Additional */

.welcome p:hover ~ img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}

<div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p><a href="dojo/frontend/photography/index.html">Welcome</a></p>
    <p>arbitrary element</p>
    <p>another arbitrary element</p>
    <img class="logo" src="https://placehold.it/940x940" alt="">
  </div>

</div>

a:hover img { border-color: #fff; }

4. Descendant Combinator :

Type: Combinator

Syntax: A B

See: Descendant combinator - CSS | MDN

The    combinator selects nodes that are descendants of the first
  element.

Example:

HTML

<div class="welcome">
  <p><a href="dojo/frontend/photography/index.html">Welcome</a>
     <img class="logo" src="https://placehold.it/940x940" alt="">
  </p>
</div>

CSS

.welcome p:hover img {
  border-color: white;
}

/* Additional */

.welcome p:hover img {
  border-color: white;
}

/* End Additional */

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: rgb(24, 24, 24);
}

.Hero {
  position: fixed;
  z-index: -1000;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  object-fit: cover;
}

img {
  display: block;
  width: 940px;
  height: 940px;
  margin: 0 auto;
  position: absolute;
  top: 10px;
  right: 485px;
  z-index: -999;
  border: 5px solid transparent;
  border-radius: 50%;
}

p {
  text-align: center;
  font-size: 70px;
  margin-top: 415px;
  text-shadow: -.75px -.75px 0 #25343f, .75px -.75px 0 #25343f, -.75px .75px 0 #25343f, .75px .75px 0 #25343f;
}

a {
  text-decoration: none;
  -webkit-transition: all 0.7s;
  -moz-transition: all 0.7s;
  transition: all .7s;
}

p a {
  color: #405c71;
  font-family: Pacifico, cursive;
}

p a:hover {
  -webkit-animation: neon .9s ease-in-out infinite alternate;
  -moz-animation: neon .9s ease-in-out infinite alternate;
  animation: neon .65s ease-in-out infinite alternate;
  color: #fff;
}

@-webkit-keyframes neon {
  from {
    text-shadow: 0 0 5px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #405c71, 0 0 70px #405c71, 0 0 80px #405c71, 0 0 100px #405c71, 0 0 150px #405c71;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #405c71, 0 0 35px #405c71, 0 0 40px #405c71, 0 0 50px #405c71, 0 0 75px #405c71;
  }
}

<div class="Container">

  <!-- <div class="Hero">
     <video src="dojo/frontend/photography/images/editor.mp4" preload="auto" autoplay="true" loop="loop"></video>
  </div> -->

  <div class="welcome">
    <p>
      <a href="dojo/frontend/photography/index.html">Welcome</a>
      <img class="logo" src="https://placehold.it/940x940" alt="">
    </p>
  </div>

</div>

More on CSS Selectors


来源: stackexchange

问:
Sleep breaks the script
I want simply to set a sleep in a loop. But it doesn't work as expected

```<code>for ($i = 1; $i <= 6; $i++) {
    echo $i;
    sleep(1);
}
</code>```

if the loop takes more than 5 seconds. It doesn't work (don't print at all).

I tested it in Teh Playground, and this error appears :

Execution took longer than 5 seconds, sent SIGTERM and terminated

Edit : Modifying set_time_limit doesn't change anything...

It seems it's related to my server's config...

答:
I don't think there's anything wrong with your code, do you get any error on your own server?

I tried your code and it worked properly, just copy pasted it.

I think the error you're getting is just TehPlayground not liking something executing for more than 5 seconds because I set the for loop to less than 4 and didn't get the error message.

```<code>for ($i = 1; $i <= 4; $i++) {
    echo $i;
    sleep(1);
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Sleep breaks the script

Body:
I want simply to set a sleep in a loop. But it doesn't work as expected

for ($i = 1; $i <= 6; $i++) {
    echo $i;
    sleep(1);
}

if the loop takes more than 5 seconds. It doesn't work (don't print at all).

I tested it in Teh Playground, and this error appears :

Execution took longer than 5 seconds, sent SIGTERM and terminated

Edit : Modifying set_time_limit doesn't change anything...

It seems it's related to my server's config...

Body:
I don't think there's anything wrong with your code, do you get any error on your own server?

I tried your code and it worked properly, just copy pasted it.

I think the error you're getting is just TehPlayground not liking something executing for more than 5 seconds because I set the for loop to less than 4 and didn't get the error message.

for ($i = 1; $i <= 4; $i++) {
    echo $i;
    sleep(1);
}


问:
What does the '...rest' stand for in this object destructuring?
I'm reading about unknown-prop warnings in react, particularly because I'm using the react-bootstrap package and have stumbled upon them there.

i've read that: 'To fix this, composite components should "consume" any prop that is intended for the composite component and not intended for the child component', on here:

https://gist.github.com/jimfb/d99e0678e9da715ccf6454961ef04d1b

and an example is given for how the spread operator can be used to pull variables off props, and put the remaining props into a variable.

the example code:

```<code>function MyDiv(props) {
  const { layout, ...rest } = props
  if (layout === 'horizontal') {
    return <div {...rest} style={getHorizontalStyle()} />
  } else {
    return <div {...rest} style={getVerticalStyle()} />
  }
}
</code>```

Here is what the PROBLEM is: In the example given, I don't understand what the '...rest' in this code here stands for. I get that the '...' = spread syntax, but where did the word 'rest' come from and what does it stand for?

答:
This is object rest operator, it creates an object from all properties that weren't explicitly destructured.

Note: since object rest/spread is still a stage 3 proposal, and requires a babel transform to work.

const obj = { a: 1, b: 2, c: 3};

const { a, ...everythingElse } = obj;

console.log(a);

console.log(everythingElse);```
</div>
</div>
</p>

<p>It's equivalent to array rest operator:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const arr = [1, 2, 3];

const [a, ...rest] = arr;

console.log(a);
console.log(rest);</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm reading about unknown-prop warnings in react, particularly because I'm using the react-bootstrap package and have stumbled upon them there.

i've read that: 'To fix this, composite components should "consume" any prop that is intended for the composite component and not intended for the child component', on here:

https://gist.github.com/jimfb/d99e0678e9da715ccf6454961ef04d1b

and an example is given for how the spread operator can be used to pull variables off props, and put the remaining props into a variable.

the example code:

function MyDiv(props) {
  const { layout, ...rest } = props
  if (layout === 'horizontal') {
    return

  } else {
    return

  }
}

Here is what the PROBLEM is: In the example given, I don't understand what the '...rest' in this code here stands for. I get that the '...' = spread syntax, but where did the word 'rest' come from and what does it stand for?

Body:
This is object rest operator, it creates an object from all properties that weren't explicitly destructured.

Note: since object rest/spread is still a stage 3 proposal, and requires a babel transform to work.

const obj = { a: 1, b: 2, c: 3};

const { a, ...everythingElse } = obj;

console.log(a);

console.log(everythingElse);

It's equivalent to array rest operator:

const arr = [1, 2, 3];

const [a, ...rest] = arr;

console.log(a);
console.log(rest);


问:
datatable search option and paging not displaying in the mvc view
i have one data table . I'm fetching data from dataset and populating into the datatable. I'm referring https://datatables.net/examples/basic_init/zero_configuration.html.i have added references of data table and jquery still im facing issues to view the data table features. im not able to see the search box and paging option.

view

```<code>@using System.Data
@model DataSet
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <meta name="viewport" content="width=device-width" />
    <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" />
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="    https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"></script>
    <title>Index</title>
    <table id="example" class="display" width="100%" cellspacing="0">
        <tr>
            <th>Date</th>
            <th>Use case</th>
            <th>Id</th>
            <th>SMS</th>
        </tr>
        @foreach (DataRow row in Model.Tables[0].Rows)
        {
            <tr>
                <td>@row["updtd_date"]</td>
                <td>@row["usecase"]</td>
                <td>@row["id"]</td>
                <td>@row["sms"]</td>

            </tr>
        }
    </table>

@section scripts{
    <script>
        $(document).ready(function () {
            $('#example').DataTable();
        });
</script>
    }
</code>```

答:
1- Add reference to datatables script.

2- Add thead and tbody to your table.

```<code><table id="example" class="display" width="100%" cellspacing="0">
 <thead>
    <tr>
     <th>Date</th>
     <th>Use case</th>
     <th>Id</th>
     <th>SMS</th>
    </tr>
 </thead>
 <tbody>
   @foreach (DataRow row in Model.Tables[0].Rows)
   {
    <tr>
     <td>@row["updtd_date"]</td>
      <td>@row["usecase"]</td>
      <td>@row["id"]</td>
      <td>@row["sms"]</td>
     </tr>
   }
 </tbody>
</table>
</code>```

Body:
i have one data table . I'm fetching data from dataset and populating into the datatable. I'm referring https://datatables.net/examples/basic_init/zero_configuration.html.i have added references of data table and jquery still im facing issues to view the data table features. im not able to see the search box and paging option.

view

@using System.Data
@model DataSet
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <meta name="viewport" content="width=device-width" />
    <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" />

    <title>Index</title>

            Date
            Use case
            Id
            SMS

        @foreach (DataRow row in Model.Tables[0].Rows)
        {

                @row["updtd_date"]
                @row["usecase"]
                @row["id"]
                @row["sms"]

        }

@section scripts{

    }

Body:
1- Add reference to datatables script.

2- Add thead and tbody to your table.

<table id="example" class="display" width="100%" cellspacing="0">
 <thead>
    <tr>
     <th>Date</th>
     <th>Use case</th>
     <th>Id</th>
     <th>SMS</th>
    </tr>
 </thead>
 <tbody>
   @foreach (DataRow row in Model.Tables[0].Rows)
   {
    <tr>
     <td>@row["updtd_date"]</td>
      <td>@row["usecase"]</td>
      <td>@row["id"]</td>
      <td>@row["sms"]</td>
     </tr>
   }
 </tbody>
</table>


答:
Don't confuse rest operator (...) and spread operator (that is also ...):

'...' acts as a rest operator in the code below:

```<code>const { layout, ...rest } = props
</code>```

but in the code below, '...' acts as a spread operator:

```<code>return <div {...rest} style={getHorizontalStyle()} />
</code>```

Title: What does the '...rest' stand for in this object destructuring?

Body:
Don't confuse rest operator (...) and spread operator (that is also ...):

'...' acts as a rest operator in the code below:

const { layout, ...rest } = props

but in the code below, '...' acts as a spread operator:

return <div {...rest} style={getHorizontalStyle()} />


问:
How to write this PHP regex?
I have a string of numbers surrounded by parenthesis:

```<code>(2)(56)(9)(12)(2)
</code>```

I was given the following regex by someone to split the numbers out of their parentheses:

```<code><?php

$string = '(2)(56)(9)(12)(2)';

$pattern = "/\\)\\(|\\(|\\)?/";

$numbers = preg_split($pattern, $string);

foreach ($numbers as $number) {
    echo $number.'<br />';
}

?>
</code>```

This outputs:

```<code><br />
<br />
2<br />
<br />
5<br />
6<br />
<br />
9<br />
<br />
1<br />
2<br />
<br />
2<br />
<br />
<br />
</code>```

When I really need it to output:

```<code>2<br />
56<br />
9<br />
12<br />
2<br />
</code>```

How can the regex be altered to make it work?

p.s. each number in between the parenthesis can be of an unlimited length.

答:
Pass the flag PREG_SPLIT_NO_EMPTY to not return empty tokens and remove the ? which allows for an empty separator. You also don't need to double-escape the ()'s in PHP. Using preg_match on (\d+) looks like it would be a simpler solution to your problem though.

```<code>$string = '(2)(56)(9)(12)(2)';
$pattern = "/\)\(|\(|\)/";
$numbers = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY);
foreach ($numbers as $number) {
    echo "$number<br />\n";
}
</code>```

Output:

```<code>2<br />
56<br />
9<br />
12<br />
2<br />
</code>```

http://ideone.com/zxvYi

ContentLicense: CC BY-SA 2.5

Title: How to write this PHP regex?

Body:
I have a string of numbers surrounded by parenthesis:

(2)(56)(9)(12)(2)

I was given the following regex by someone to split the numbers out of their parentheses:

<?php

$string = '(2)(56)(9)(12)(2)';

$pattern = "/\\)\\(|\\(|\\)?/";

$numbers = preg_split($pattern, $string);

foreach ($numbers as $number) {
    echo $number.'
';
}

?>

This outputs:

2

5

6

9

1

2

2

When I really need it to output:

2

56

9

12

2

How can the regex be altered to make it work?

p.s. each number in between the parenthesis can be of an unlimited length.

Body:
Pass the flag PREG_SPLIT_NO_EMPTY to not return empty tokens and remove the ? which allows for an empty separator. You also don't need to double-escape the ()'s in PHP. Using preg_match on (\d+) looks like it would be a simpler solution to your problem though.

$string = '(2)(56)(9)(12)(2)';
$pattern = "/\)\(|\(|\)/";
$numbers = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY);
foreach ($numbers as $number) {
    echo "$number<br />\n";
}

Output:

2<br />
56<br />
9<br />
12<br />
2<br />

http://ideone.com/zxvYi


问:
How to use map function instead of for loop in javascript?
This is my array :

```<code>var filteredData = [{ id: 1, phoneno: '91888888888', sender: 'test' },{ id: 2, phoneno: '9199999999999', sender: 'hel' }]
</code>```

I use for loop

```<code>for (var i = 0; i < filteredData.length; i++) {
   if (filteredData[i].sender === test) {
       console.log('worked');
   }else{
       console.log('not worked');
   }
}
</code>```

How to exactly do this with map ? in javascript instead of for loop.

答:
By using underscore.js,</p>

```<code>var filteredData = [{ id: 1, phoneno: '917418306474', sender: 'test' },{ id: 2, phoneno: '917338966917', sender: 'hel' }];

 _.map(filteredData, function(data){
   if (data.sender === test) {
    console.log('worked');
   }else {
    console.log('not worked');}
});
</code>```

Body:
This is my array :

var filteredData = [{ id: 1, phoneno: '91888888888', sender: 'test' },{ id: 2, phoneno: '9199999999999', sender: 'hel' }]

I use for loop

for (var i = 0; i < filteredData.length; i++) {
   if (filteredData[i].sender === test) {
       console.log('worked');
   }else{
       console.log('not worked');
   }
}

How to exactly do this with map ? in javascript instead of for loop.

Body:
By using underscore.js,

var filteredData = [{ id: 1, phoneno: '917418306474', sender: 'test' },{ id: 2, phoneno: '917338966917', sender: 'hel' }];

 _.map(filteredData, function(data){
   if (data.sender === test) {
    console.log('worked');
   }else {
    console.log('not worked');}
});


问:
Async sockets and AutoResetEvent
I have an application where the main app creates a loop and waits for a method return some data.
i.e

```<code>Main.cs
var obj = new MySuperClass();
MyData data;
while (obj.ReadData(out data)) {
  // do something with data
}
</code>```

The data itself comes from an Async socket connection, thus I'm using an AutoResetEvent to signal when data is ready so the main app can consume it.

```<code>class MySuperClass {
  private MyData _dataFromSocket;
  private AutoResetEvent _ev = new AutoResetEvent(false);
  public bool ReadData(out MyData data) {
    _autoResetEvent.WaitOne();
    data = _dataFromSocket;
    // here more logic to return false, but that's not the case or the issue
    return true;

  }

  /// async socket callback and data parse
  private void MyAsyncCallback(byte rawData) {
    while (canParse(rawData, out _dataFromSocket)) { // somehow parse the raw bytes
      //if we could parse, signal that we have a packet
      _ev.Set(); // set the signal
    }
  }
}
</code>```

When the _ev is set, the Read returns, the main app gets the data and everybody is happy.
But in some cases, when AsyncCallback is called with a large buffer where I can deserialize multiple packets, i.e. 5, the main app will receive only 2 or 3, is like the event Skips reseting and Read method doesn't return immediately.

Any idea how to fix this? Is there a faster Event implementation that would signal faster.

I cannot change the architecture of the app, these were the requirements, it must work in the main thread, how data comes it doesn't care, and in this case, I must use async sockets.

Thx for any ideas.

答:
I recommend to use a synchronized queue (FIFO). You assign in your MyAsyncCallback the result to a global variable and read it in ReadData any time in the future without any synchronization. That's suboptimal and cannot work.

Simplified improvement:

```<code>class MySuperClass
{
  private readonly object _syncRoot  = new object();
  private Queue<MyData>   _dataQueue = new Queue<MyData>();
  private AutoResetEvent  _ev        = new AutoResetEvent(false);

  public bool ReadData(out List<MyData> dataList)
  {
    dataList = new List<MyData>();

    _autoResetEvent.WaitOne();

    lock(_syncRoot) // lock access to queue for other threads
    {
      while(_dataQueue.Count > 0)
      {
        dataList.Add(_dataQueue.Dequeue());
      }
    }

    return true;
  }

  /// async socket callback and data parse
  private void MyAsyncCallback(byte rawData)
  {
    MyData data;

    while (canParse(rawData, out data))
    { // somehow parse the raw bytes
      //if we could parse, signal that we have a packet

      lock(_syncRoot) // lock access to queue for other threads
      {
        _dataQueue.Enqueue(data);
      }
    }
    _ev.Set(); // set the signal after all packets parsed, depends on your requirements, maybe after each?
  }
}
</code>```

Title: Async sockets and AutoResetEvent

Body:
I have an application where the main app creates a loop and waits for a method return some data.
i.e

Main.cs
var obj = new MySuperClass();
MyData data;
while (obj.ReadData(out data)) {
  // do something with data
}

The data itself comes from an Async socket connection, thus I'm using an AutoResetEvent to signal when data is ready so the main app can consume it.

class MySuperClass {
  private MyData _dataFromSocket;
  private AutoResetEvent _ev = new AutoResetEvent(false);
  public bool ReadData(out MyData data) {
    _autoResetEvent.WaitOne();
    data = _dataFromSocket;
    // here more logic to return false, but that's not the case or the issue
    return true;

  }

  /// async socket callback and data parse
  private void MyAsyncCallback(byte rawData) {
    while (canParse(rawData, out _dataFromSocket)) { // somehow parse the raw bytes
      //if we could parse, signal that we have a packet
      _ev.Set(); // set the signal
    }
  }
}

When the _ev is set, the Read returns, the main app gets the data and everybody is happy.
But in some cases, when AsyncCallback is called with a large buffer where I can deserialize multiple packets, i.e. 5, the main app will receive only 2 or 3, is like the event Skips reseting and Read method doesn't return immediately.

Any idea how to fix this? Is there a faster Event implementation that would signal faster.

I cannot change the architecture of the app, these were the requirements, it must work in the main thread, how data comes it doesn't care, and in this case, I must use async sockets.

Thx for any ideas.

Body:
I recommend to use a synchronized queue (FIFO). You assign in your MyAsyncCallback the result to a global variable and read it in ReadData any time in the future without any synchronization. That's suboptimal and cannot work.

Simplified improvement:

class MySuperClass
{
  private readonly object _syncRoot  = new object();
  private Queue<MyData>   _dataQueue = new Queue<MyData>();
  private AutoResetEvent  _ev        = new AutoResetEvent(false);

  public bool ReadData(out List<MyData> dataList)
  {
    dataList = new List<MyData>();

    _autoResetEvent.WaitOne();

    lock(_syncRoot) // lock access to queue for other threads
    {
      while(_dataQueue.Count > 0)
      {
        dataList.Add(_dataQueue.Dequeue());
      }
    }

    return true;
  }

  /// async socket callback and data parse
  private void MyAsyncCallback(byte rawData)
  {
    MyData data;

    while (canParse(rawData, out data))
    { // somehow parse the raw bytes
      //if we could parse, signal that we have a packet

      lock(_syncRoot) // lock access to queue for other threads
      {
        _dataQueue.Enqueue(data);
      }
    }
    _ev.Set(); // set the signal after all packets parsed, depends on your requirements, maybe after each?
  }
}


问:
jdbc driver to connect oracle from python
Do you know of any library to use a jdbc url to connect oracle using python?
i tried using pyodbc but its slow while retrieving million records.
note: pyodbc uses odbc connections

Thanks in advance
sreeni

答:
cx_Oracle Python Database Drivers is one option

Refer the following Link

https://dzone.com/articles/oracle-database-python-driver-cx-oracle-now-on-git

My work for you


问:
How can I emit the result of storm botl to kafka brokers using kafkabolt?
I'm trying to change the wordcount example in storm: instead of displaying the result, I want to send it to kafka cluster.
This is code which build the topology:

```<code> Config config = new Config();
    config.setDebug(true);
    config.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
//set producer properties.
    Properties props = new Properties();
    props.put("bootstrap.servers", "localhost:9092");
    props.put("acks", "1");
    props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
config.put("kafka.broker.config", props);
KafkaBolt bolt = new KafkaBolt()
            .withTopicSelector(new DefaultTopicSelector("tt"))
            .withTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper())
                        .withProducerProperties(props);

    BrokerHosts hosts = new ZkHosts("localhost:2181");
    SpoutConfig spoutConfig = new SpoutConfig(hosts, "test", "", "id1");
    spoutConfig.scheme = new SchemeAsMultiScheme(new KafkaBoltKeyValueScheme());
    KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("line-reader-spout", kafkaSpout);
    builder.setBolt("word-spitter", new WordSpitterBolt()).shuffleGrouping("line-reader-spout");
    builder.setBolt("word-counter", new WordCounterBolt()).shuffleGrouping("word-spitter");
    builder.setBolt("forwardToKafka", bolt,1).shuffleGrouping("word-counter");
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("HelloStorm", config, builder.createTopology());
</code>```

As you can see, I want to send the result of wordcounter bolt to kafka topic. However, I'm getting this exception:

```<code>java.lang.IllegalArgumentException: message does not exist
at org.apache.storm.tuple.Fields.fieldIndex(Fields.java:95) ~[storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.tuple.TupleImpl.fieldIndex(TupleImpl.java:100) ~[storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.tuple.TupleImpl.getValueByField(TupleImpl.java:149) ~[storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.kafka.bolt.mapper.FieldNameBasedTupleToKafkaMapper.getMessageFromTuple(FieldNameBasedTupleToKafkaMapper.java:46) ~[storm-kafka-1.0.5.jar:1.0.5]
at org.apache.storm.kafka.bolt.KafkaBolt.process(KafkaBolt.java:120) [storm-kafka-1.0.5.jar:1.0.5]
at org.apache.storm.topology.base.BaseTickTupleAwareRichBolt.execute(BaseTickTupleAwareRichBolt.java:38) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.daemon.executor$fn__4963$tuple_action_fn__4965.invoke(executor.clj:731) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.daemon.executor$mk_task_receiver$fn__4884.invoke(executor.clj:461) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.disruptor$clojure_handler$reify__4398.onEvent(disruptor.clj:40) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:453) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:432) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.daemon.executor$fn__4963$fn__4976$fn__5029.invoke(executor.clj:850) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.util$async_loop$fn__557.invoke(util.clj:484) [storm-core-1.0.5.jar:1.0.5]
at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
</code>```

7793 [Thread-18-forwardToKafka-executor[2 2]] INFO  o.a.s.d.executor - BOLT fail TASK: 2 TIME: -1 TUPLE: source: word-counter:4, stream: default, id: {}, ["publish"}]

In word count bolt, I have done this:

```<code>String str = input.getString(0);
collector.emit(new Values(str));
    collector.ack(input);
</code>```

答:
Try add declarer.declare(new Fields("message")) in your bolt's public void declareOutputFields(OutputFieldsDeclarer declarer) function
like is :

```<code>public class MessageBolt extends BaseBasicBolt {

    @Override
    public void execute(Tuple input, BasicOutputCollector collector) {
        String word = (String) input.getValue(0);
        String out = word ;
        collector.emit(new Values(out));
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {
        declarer.declare(new Fields("message"));
    }
}
</code>```

Body:
I'm trying to change the wordcount example in storm: instead of displaying the result, I want to send it to kafka cluster.
This is code which build the topology:

 Config config = new Config();
    config.setDebug(true);
    config.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
//set producer properties.
    Properties props = new Properties();
    props.put("bootstrap.servers", "localhost:9092");
    props.put("acks", "1");
    props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
config.put("kafka.broker.config", props);
KafkaBolt bolt = new KafkaBolt()
            .withTopicSelector(new DefaultTopicSelector("tt"))
            .withTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper())
                        .withProducerProperties(props);

    BrokerHosts hosts = new ZkHosts("localhost:2181");
    SpoutConfig spoutConfig = new SpoutConfig(hosts, "test", "", "id1");
    spoutConfig.scheme = new SchemeAsMultiScheme(new KafkaBoltKeyValueScheme());
    KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("line-reader-spout", kafkaSpout);
    builder.setBolt("word-spitter", new WordSpitterBolt()).shuffleGrouping("line-reader-spout");
    builder.setBolt("word-counter", new WordCounterBolt()).shuffleGrouping("word-spitter");
    builder.setBolt("forwardToKafka", bolt,1).shuffleGrouping("word-counter");
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("HelloStorm", config, builder.createTopology());

As you can see, I want to send the result of wordcounter bolt to kafka topic. However, I'm getting this exception:

java.lang.IllegalArgumentException: message does not exist
at org.apache.storm.tuple.Fields.fieldIndex(Fields.java:95) ~[storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.tuple.TupleImpl.fieldIndex(TupleImpl.java:100) ~[storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.tuple.TupleImpl.getValueByField(TupleImpl.java:149) ~[storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.kafka.bolt.mapper.FieldNameBasedTupleToKafkaMapper.getMessageFromTuple(FieldNameBasedTupleToKafkaMapper.java:46) ~[storm-kafka-1.0.5.jar:1.0.5]
at org.apache.storm.kafka.bolt.KafkaBolt.process(KafkaBolt.java:120) [storm-kafka-1.0.5.jar:1.0.5]
at org.apache.storm.topology.base.BaseTickTupleAwareRichBolt.execute(BaseTickTupleAwareRichBolt.java:38) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.daemon.executor$fn__4963$tuple_action_fn__4965.invoke(executor.clj:731) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.daemon.executor$mk_task_receiver$fn__4884.invoke(executor.clj:461) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.disruptor$clojure_handler$reify__4398.onEvent(disruptor.clj:40) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:453) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:432) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.daemon.executor$fn__4963$fn__4976$fn__5029.invoke(executor.clj:850) [storm-core-1.0.5.jar:1.0.5]
at org.apache.storm.util$async_loop$fn__557.invoke(util.clj:484) [storm-core-1.0.5.jar:1.0.5]
at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]

7793 [Thread-18-forwardToKafka-executor[2 2]] INFO  o.a.s.d.executor - BOLT fail TASK: 2 TIME: -1 TUPLE: source: word-counter:4, stream: default, id: {}, ["publish"}]

In word count bolt, I have done this:

String str = input.getString(0);
collector.emit(new Values(str));
    collector.ack(input);

Body:
Try add declarer.declare(new Fields("message")) in your bolt's public void declareOutputFields(OutputFieldsDeclarer declarer) function
like is :

public class MessageBolt extends BaseBasicBolt {

    @Override
    public void execute(Tuple input, BasicOutputCollector collector) {
        String word = (String) input.getValue(0);
        String out = word ;
        collector.emit(new Values(out));
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {
        declarer.declare(new Fields("message"));
    }
}


问:
NodaTime timezone parse: Etc/GMT+3 offset in negative
This is a little code sample to illustrate the issue:

```<code>enter code here
var offset1 = DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Moscow")
            .GetUtcOffset(Instant.FromDateTimeUtc(DateTime.UtcNow));
var offset2 = DateTimeZoneProviders.Tzdb.GetZoneOrNull("Etc/GMT+3")
            .GetUtcOffset(Instant.FromDateTimeUtc(DateTime.UtcNow));

Console.WriteLine(offset1 + " vs " + offset2);
</code>```

Results in "{+03} vs {-03}"

答:
Yes, that's correct. That's because the "Etc/GMT+X" zone IDs are confusing. They match POSIX TZ strings, which for some reason represent "the offset of UTC from local time" instead of the normal "offset of local time from UTC". See the Wikipedia list of tz database time zone for confirmation of that.

From the etcetra file:

```<code># Be consistent with POSIX TZ settings in the Zone names,
# even though this is the opposite of what many people expect.
# POSIX has positive signs west of Greenwich, but many people expect
# positive signs east of Greenwich.  For example, TZ='Etc/GMT+4' uses
# the abbreviation "-04" and corresponds to 4 hours behind UT
# (i.e. west of Greenwich) even though many people would expect it to
# mean 4 hours ahead of UT (i.e. east of Greenwich).
</code>```

If you want to create a time zone representing a fixed offset, you can either use an identifier of "UTC+X" or use DateTimeZone.ForOffset.

Body:
This is a little code sample to illustrate the issue:

enter code here
var offset1 = DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Moscow")
            .GetUtcOffset(Instant.FromDateTimeUtc(DateTime.UtcNow));
var offset2 = DateTimeZoneProviders.Tzdb.GetZoneOrNull("Etc/GMT+3")
            .GetUtcOffset(Instant.FromDateTimeUtc(DateTime.UtcNow));

Console.WriteLine(offset1 + " vs " + offset2);

Results in "{+03} vs {-03}"

Body:
Yes, that's correct. That's because the "Etc/GMT+X" zone IDs are confusing. They match POSIX TZ strings, which for some reason represent "the offset of UTC from local time" instead of the normal "offset of local time from UTC". See the Wikipedia list of tz database time zone for confirmation of that.

From the etcetra file:

# Be consistent with POSIX TZ settings in the Zone names,
# even though this is the opposite of what many people expect.
# POSIX has positive signs west of Greenwich, but many people expect
# positive signs east of Greenwich.  For example, TZ='Etc/GMT+4' uses
# the abbreviation "-04" and corresponds to 4 hours behind UT
# (i.e. west of Greenwich) even though many people would expect it to
# mean 4 hours ahead of UT (i.e. east of Greenwich).

If you want to create a time zone representing a fixed offset, you can either use an identifier of "UTC+X" or use DateTimeZone.ForOffset.


问:
How to trim string from right in PHP?
I have a string example

```<code>this-is-the-example/exa
</code>```

I want to trim /exa from the above line

```<code>$string1 = "this-is-the-example/exa";
$string2 = "/exa";
</code>```

I am using rtrim($string1, $sting2)

But the output is this-is-the-exampl

I want to this-is-the-example as output.

Both string are dynamic and may have multiple occurrences within the string. But I only want to remove the last part. Also its not compulsory that the string2 has / in it. this may be normal string too. like a, abc too..

答:
To allow for error handling, if the substring is not found in the search string ...

```<code><?php

$myString = 'this-is-the-example/exa';

//[Edit: see comment below] use strrpos, not strpos, to find the LAST occurrence
$endPosition = strrpos($myString, '/exa');

// TodO; if endPosition === False then handle error, substring not found

$leftPart = substr($myString, 0, $endPosition);

echo($leftPart);

?>
</code>```

outputs

this-is-the-example

Title: How to trim string from right in PHP?

Body:
I have a string example

this-is-the-example/exa

I want to trim /exa from the above line

$string1 = "this-is-the-example/exa";
$string2 = "/exa";

I am using rtrim($string1, $sting2)

But the output is this-is-the-exampl

I want to this-is-the-example as output.

Both string are dynamic and may have multiple occurrences within the string. But I only want to remove the last part. Also its not compulsory that the string2 has / in it. this may be normal string too. like a, abc too..

Body:
To allow for error handling, if the substring is not found in the search string ...

<?php

$myString = 'this-is-the-example/exa';

//[Edit: see comment below] use strrpos, not strpos, to find the LAST occurrence
$endPosition = strrpos($myString, '/exa');

// TodO; if endPosition === False then handle error, substring not found

$leftPart = substr($myString, 0, $endPosition);

echo($leftPart);

?>

outputs

this-is-the-example


问:
How can I create a nested list given a string where a new nested list is formed when specific punctuation is seen in the string?
If I am given a string for example, "I like ham. I like cheese too! Do you?", and I want to create a nested list where a new list is created in the main list when a ".", "?", or"!" is seen. I have tried:

```<code>string = "I like ham. I like cheese too! Do you?"
for i in string:
    if i == "?" or i == "." or i == "!":
        list = string.split(i)
print(list)
</code>```

This however, only works once and does not work if there is more than one period, question mark, or exclamation mark in the string. What I am trying to get as output is:

```<code>[['I', 'like', 'ham'], ['I', 'like', 'cheese', 'too'], ['Do', 'you']]
</code>```

If anyone could help me that was be great! Thank you in advanced.

答:
This does what you are looking for:

```<code>>>> s = "I like ham. I like cheese too! Do you?"
>>> import re
>>> [sentence.split() for sentence in re.split('[?.!]', s) if sentence]
[['I', 'like', 'ham'], ['I', 'like', 'cheese', 'too'], ['Do', 'you']]
</code>```

How it works

re.split will split a string on a regular expression:

```<code>>>> re.split('[?.!]', s)
['I like ham', ' I like cheese too', ' Do you', '']
</code>```

where [?.!] is a regular expression that matches any of ?, ., or !.

Once that we have split the string into sentences, we need to do one more step and that is split the sentences into words. So, as an example taking a single sentence:

```<code>>>> sentence = 'I like ham'
>>> sentence.split()
['I', 'like', 'ham']
</code>```

We do the same to all sentences with:

```<code>>>> [sentence.split() for sentence in re.split('[?.!]', s) if sentence]
[['I', 'like', 'ham'], ['I', 'like', 'cheese', 'too'], ['Do', 'you']]
</code>```

Notes

list is a python builtin and string is the name of a python standard library.  Since you might need them in the future, it is poor practice to overwrite them.  So, it is good form to pick other names for script variables.

Body:
If I am given a string for example, "I like ham. I like cheese too! Do you?", and I want to create a nested list where a new list is created in the main list when a ".", "?", or"!" is seen. I have tried:

string = "I like ham. I like cheese too! Do you?"
for i in string:
    if i == "?" or i == "." or i == "!":
        list = string.split(i)
print(list)

This however, only works once and does not work if there is more than one period, question mark, or exclamation mark in the string. What I am trying to get as output is:

[['I', 'like', 'ham'], ['I', 'like', 'cheese', 'too'], ['Do', 'you']]

If anyone could help me that was be great! Thank you in advanced.

Body:
This does what you are looking for:

>>> s = "I like ham. I like cheese too! Do you?"
>>> import re
>>> [sentence.split() for sentence in re.split('[?.!]', s) if sentence]
[['I', 'like', 'ham'], ['I', 'like', 'cheese', 'too'], ['Do', 'you']]

How it works

re.split will split a string on a regular expression:

>>> re.split('[?.!]', s)
['I like ham', ' I like cheese too', ' Do you', '']

where [?.!] is a regular expression that matches any of ?, ., or !.

Once that we have split the string into sentences, we need to do one more step and that is split the sentences into words. So, as an example taking a single sentence:

>>> sentence = 'I like ham'
>>> sentence.split()
['I', 'like', 'ham']

We do the same to all sentences with:

>>> [sentence.split() for sentence in re.split('[?.!]', s) if sentence]
[['I', 'like', 'ham'], ['I', 'like', 'cheese', 'too'], ['Do', 'you']]

Notes

list is a python builtin and string is the name of a python standard library.  Since you might need them in the future, it is poor practice to overwrite them.  So, it is good form to pick other names for script variables.


问:
Find duplicate enteries from collection node js?
I want to find out duplicate entries on the basis of field " name " and in the result, I want to fetch " name " and " _id ".

I have tried using aggregate function and it is returning all the result from database as null:

here is my code:

```<code> ModelRestaurant.aggregate((
    // { "$group": { "_id": "$name", "count": { "$sum": 1 } } },
    // { "$match": { "_id": { "$ne": null }, "count": { "$gt": 1 } } },
    // { "$project": { "name": "$_id", "_id": 0 } }
    { $group: { "_id": "$name", "name": { $first: "$name" }, "count": { $sum: 1 } } },
    { $match: { "count": { $gt: 1 } } },
    { $project: { "name": 1, "_id": 0 } },
    { $group: { "_id": null, "duplicateNames": { $push: "$name" } } },
    { $project: { "_id": 0, "duplicateNames": 1 } }
), function (err, result) {
    if (result) {
        console.log(result)
    }
})
</code>```

from above commented code it is giving me all id but now it is giving me null values and all the result json of 6000 with null value.

here is the field of data in collection:

My Schema is :

```<code>  var mongoose = require('mongoose');
  var uniqueValidator = require('mongoose-unique-validator');
  var autoIncrement = require('mongoose-auto-increment');

  var ModelRestaurant = new mongoose.Schema({
      name: String,
      ownerName: String, // to be removed by checking code
      ownerID: Number,
      ownerEmail: String, // to be removed by checking code
      city: String,
      zipCode: String,
      image: [String],
      restaurantType: String,
      address: String,
      landmark: String,
      isAddedByCustomer: {
          type: Boolean,
          default: false
      },
      location: {
          lat: String,
          long: String
      }
  },
  {
      timestamps: true
  });
  ModelRestaurant.plugin(autoIncrement.plugin, 'Restaurants');
  ModelRestaurant.plugin(uniqueValidator);
  mongoose.model('Restaurants', ModelRestaurant);
</code>```

答:
The following code should print all the duplicates:</p>

```<code>db.ModelRestaurant.aggregate([
    {$group:{"_id":"$name","name":{$first:"$name"},"count":{$sum:1}}},
    {$match:{"count":{$gt:1}}}
])
</code>```

Body:
I want to find out duplicate entries on the basis of field " name " and in the result, I want to fetch " name " and " _id ".

I have tried using aggregate function and it is returning all the result from database as null:

here is my code:

 ModelRestaurant.aggregate((
    // { "$group": { "_id": "$name", "count": { "$sum": 1 } } },
    // { "$match": { "_id": { "$ne": null }, "count": { "$gt": 1 } } },
    // { "$project": { "name": "$_id", "_id": 0 } }
    { $group: { "_id": "$name", "name": { $first: "$name" }, "count": { $sum: 1 } } },
    { $match: { "count": { $gt: 1 } } },
    { $project: { "name": 1, "_id": 0 } },
    { $group: { "_id": null, "duplicateNames": { $push: "$name" } } },
    { $project: { "_id": 0, "duplicateNames": 1 } }
), function (err, result) {
    if (result) {
        console.log(result)
    }
})

from above commented code it is giving me all id but now it is giving me null values and all the result json of 6000 with null value.

here is the field of data in collection:

My Schema is :

  var mongoose = require('mongoose');
  var uniqueValidator = require('mongoose-unique-validator');
  var autoIncrement = require('mongoose-auto-increment');

  var ModelRestaurant = new mongoose.Schema({
      name: String,
      ownerName: String, // to be removed by checking code
      ownerID: Number,
      ownerEmail: String, // to be removed by checking code
      city: String,
      zipCode: String,
      image: [String],
      restaurantType: String,
      address: String,
      landmark: String,
      isAddedByCustomer: {
          type: Boolean,
          default: false
      },
      location: {
          lat: String,
          long: String
      }
  },
  {
      timestamps: true
  });
  ModelRestaurant.plugin(autoIncrement.plugin, 'Restaurants');
  ModelRestaurant.plugin(uniqueValidator);
  mongoose.model('Restaurants', ModelRestaurant);

Body:
The following code should print all the duplicates:

db.ModelRestaurant.aggregate([
    {$group:{"_id":"$name","name":{$first:"$name"},"count":{$sum:1}}},
    {$match:{"count":{$gt:1}}}
])


问:
How to add external native dependency dll?
I have two projects. First is a Windows Forms Application project and second is a class library project. Сlass library project works with FANN. Windows Forms is Startup Project.

I should have Fann.Net.dll and fanndoubleMT.dll to work with the FANN. I downloaded these libraries and put their in a folder lib, located in the root of the solution.

I added Fann.Net.dll as external dll to the class library project. I compiled the project. I got an error that says "Unable to load DLL 'fanndoubleMT.dll'. I fixed this error by adding fanndoubleMT.dll to the folder Windows_Forms_Application\bin\Debug.

I think this is a terrible solution to the problem, because I use git, and every time you need to transfer dll to this folder on the new workplace.

Sincerely, Denis.

答:
If the dll is not in the project bin file, you should allow the dll to be copied.

Right click on your dll

Click properties

If the Copy to Output Directory is Do not copy, select Copy always

Rebuild the project. It will appear.


问:
dual for loops to find missing number from the entered sequence
Need help to complete this learner with for loops

Program:

```<code>import java.util.Scanner;

public class Main1 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int id[] = new int[n];
        for(int i=0; i<=n; i++) {
            id[i] = scan.nextInt();
        }
    }
}
</code>```

Input Format:

The first input consists of an integer n corresponding to the number of IDs.
Next n inputs corresponds to the Ids.

Output Format:

Output should display the missing Id.

答:
I just write a function that may help you:

```<code>  public class Enrollment {
    public static void prinMiss(int arr[],int size)
    {
        int y=arr[0];
        //System.out.println(y);
        int y1=arr[size-1];
        //System.out.println(y1);

        int counter=y;
        int flag=0;
        for(int i=0;i<size;i++)
        {
            if(arr[i]==counter)
            {
                //System.out.println(counter);
                counter++;
            }
            else
            {
                flag=1;
                break;
            }
        }
        if(flag==1){
        System.out.println(counter);
        }
        else
            System.out.println("Nothing is missing");
    }
public static void main(String ars[])
{
    Scanner in =new Scanner(System.in);
    int n;
    n=in.nextInt();
    int id[]=new int[n];
    for(int i=0;i<n;i++)
    {
        id[i]=in.nextInt();
    }
    prinMiss(id,n);
}
}
</code>```

In above prinMiss function i have assumed that the IDs will always be in sequence and only 1 ID is out of sequence.

Body:
Need help to complete this learner with for loops

Program:

import java.util.Scanner;

public class Main1 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int id[] = new int[n];
        for(int i=0; i<=n; i++) {
            id[i] = scan.nextInt();
        }
    }
}

Input Format:

The first input consists of an integer n corresponding to the number of IDs.
Next n inputs corresponds to the Ids.

Output Format:

Output should display the missing Id.

Body:
I just write a function that may help you:

  public class Enrollment {
    public static void prinMiss(int arr[],int size)
    {
        int y=arr[0];
        //System.out.println(y);
        int y1=arr[size-1];
        //System.out.println(y1);

        int counter=y;
        int flag=0;
        for(int i=0;i<size;i++)
        {
            if(arr[i]==counter)
            {
                //System.out.println(counter);
                counter++;
            }
            else
            {
                flag=1;
                break;
            }
        }
        if(flag==1){
        System.out.println(counter);
        }
        else
            System.out.println("Nothing is missing");
    }
public static void main(String ars[])
{
    Scanner in =new Scanner(System.in);
    int n;
    n=in.nextInt();
    int id[]=new int[n];
    for(int i=0;i<n;i++)
    {
        id[i]=in.nextInt();
    }
    prinMiss(id,n);
}
}

In above prinMiss function i have assumed that the IDs will always be in sequence and only 1 ID is out of sequence.


问:
Variable rnn/gru_cell/gates/weights already exists, disallowed
I want to implement the code in th book Tesorflow for Machine Intelligence, the code runs well at the first time,but when run it again ,the error
"Variable rnn/gru_cell/gates/weights already exists, disallowed" occurs. when I restart the console the error disapear and it occurs after the first running or debug. the code is below:

```<code>def prediction(self):

    output, _ = tf.nn.dynamic_rnn(tf.contrib.rnn.GRUCell(300),
                                  self.data,
                                  dtype = tf.float32,
                                  sequence_length = self.length)
    last = self._last_relevant(output, self.length)
    #softmax层
    num_classes  =int(self.target.get_shape()[1])
    weight = tf.Variable(tf.truncated_normal([self.params.rnn_hidden, num_classes], stddev = 0.01))
    bias = tf.Variable(tf.constant(0.1, shape = [num_classes]))
    prediction = tf.nn.softmax(tf.matmul(last, weight) + bias)
    return prediction
</code>```

anyone can help me with the problem?

答:
Code that adds things to your graph (which includes pretty much everything in the function you posted) should usually only be run once.  When you want to train your model or have it make a prediction, you would use something like sess.run with a feed_dict and the ops you want output from.

If you actually want to delete your graph without restarting the console, you can use tf.reset_default_graph().

Body:
I want to implement the code in th book Tesorflow for Machine Intelligence, the code runs well at the first time,but when run it again ,the error
"Variable rnn/gru_cell/gates/weights already exists, disallowed" occurs. when I restart the console the error disapear and it occurs after the first running or debug. the code is below:

def prediction(self):

    output, _ = tf.nn.dynamic_rnn(tf.contrib.rnn.GRUCell(300),
                                  self.data,
                                  dtype = tf.float32,
                                  sequence_length = self.length)
    last = self._last_relevant(output, self.length)
    #softmax层
    num_classes  =int(self.target.get_shape()[1])
    weight = tf.Variable(tf.truncated_normal([self.params.rnn_hidden, num_classes], stddev = 0.01))
    bias = tf.Variable(tf.constant(0.1, shape = [num_classes]))
    prediction = tf.nn.softmax(tf.matmul(last, weight) + bias)
    return prediction

anyone can help me with the problem?


问:
css-grids, max-height on Chrome not working?
I want to build a Website Applikation with a fixed Size.

Only a content div should be scrollable.

On FireFox my App worked correctly, but on Chrome i get a strange behaviour and i cannot figure out why?

I extract the problem in a small example as follows.

```<code><!DOCTYPE html>
<html>
<head>
    <title>App</title>
    <style>
        html, body
        {
            left: 0;
            top: 0;
            margin: 0;
            width: 100vw;
            height: 100vh;
        }

        .app
        {
            height : 100vh;
            width : 100vw;
            /*overflow: hidden;*/
            display: grid;
            grid-template-rows: 100px auto;
        }

        .content
        {
            display: grid;
            grid-template-columns: 500px auto;
            height: 100%;
            max-height: 100%;
        }

        .scrollable
        {
            overflow: auto;
            max-height: 100%;
        }

        .red
        {
            background-color: red;
        }

        .yellow
        {
            background-color: yellow;
        }

        .blue
        {
          background-color: blue;
        }
    </style>
</head>

<body>
  <div class="app">
    <div class="yellow"></div>
    <div class="content">
      <div class="red scrollable">
        some content <br />
        some content <br />
        .
        .
        .
        some content <br />
        some content <br />
      </div>

      <div class="blue scrollable"></div>
    </div>
  </div>
</body>

</html>
</code>```

in firefox just the red div got a scrollbar, but in chrome the whole page get one. Why they behave differently and how can i fix this in chrome?

答:
add height: 100%; to .app it'll work

```<code>.app {
    min-height: 100%;
    display: grid;
    grid-template-rows: 100px auto;
    height: 100%;
}
</code>```

Body:
I want to build a Website Applikation with a fixed Size.

Only a content div should be scrollable.

On FireFox my App worked correctly, but on Chrome i get a strange behaviour and i cannot figure out why?

I extract the problem in a small example as follows.

<!DOCTYPE html>

    <title>App</title>

        some content

        some content

        .
        .
        .
        some content

        some content

in firefox just the red div got a scrollbar, but in chrome the whole page get one. Why they behave differently and how can i fix this in chrome?

Body:
add height: 100%; to .app it'll work

.app {
    min-height: 100%;
    display: grid;
    grid-template-rows: 100px auto;
    height: 100%;
}


问:
Different lines between two files, when one line contains trailing whitespace (Python, difflib)
I want to compare two text files in Python, and return the lines that are different.  My attempt uses difflib, but I'm open to other suggestions.  I need to get the lines that are different, as well as the lines that appear in one file but not the other.  Order is somewhat important, but if a good solution exists that doesn't take order into consideration, I can let go of that.

The problem is that one file has lines that have multiple trailing characters \t and \n, while the other doesn't; I don't want to consider that as a difference.  For other files, the first file has only \n and the other files has \t characters at the end.  The lines contain elements that are separated by tabs or spaces, so those are important; I just don't care for the trailing characters \t and \n.

My solution:

```<code>from difflib import Differ

with open(file_path) as actual:
    with open(test_file_path) as test:
        differ = Differ()

        for line in differ.compare(actual.readlines(), test.readlines()):
            if line.startswith('-'):
                log.error('EXPECTED:  {}'.format(line[2:]))
            if line.startswith('+'):
                log.error('TEST FILE: {}'.format(line[2:]))
</code>```

I expect the output to show EXPECTED and TEST FILE lines when there's a difference, and just EXPECTED or just TEST FILE when one contains a line the other doesn't.  Right now, I'm seeing a lot of the following types of errors:

```<code>00:02:40: ERROR EXPECTED:  Issuer   Type    OBal    Net WAC OTerm   WAM Age GrossCpn    HighRemTerm Grp

00:02:40: ERROR TEST FILE: Issuer   Type    OBal    Net WAC OTerm   WAM Age GrossCpn    HighRemTerm Grp
</code>```

As you can see (if you highlight it), the first line contains a number of spaces after 'Grp' and the other line doesn't.  I want to consider these two lines the same.

I've tried to explicitly specify the tabs and line breaks:

```<code>actual_file = actual.readlines()
expected_file = []
for line in actual_file:
    if line[-1] == '\n':
        expected_file.append(line.rstrip('\n').rstrip('\t') + '\n')
    else:
        expected_file.append(line.rstrip('\t'))
</code>```

However, it (a) slows the process down quite a bit, and (b) is required for every file type in a different way, since some files have trailing tabs followed by line breaks, some have just line breaks, and some have nothing at all.  If there's no better way, I can strip every line of every trailing tab and linebreak, but it seems like a lot of processing power (I have to run a lot of files) for something that seems fairly easy to resolve.

答:
Take a look at string.rstrip() here: https://docs.python.org/2/library/string.html#string.rstrip

string.rstrip() should do exactly what you need by stripping whitespace off the end of a string, while leaving \t and \n characters before the end alone.

Check it out:

```<code>>>> import string
>>> s = "This \t is \t a \t line \t\t\t\n\n\n"
>>> print(s)
This     is      a   line

>>>
>>> s = string.rstrip(s)
>>> s
'This \t is \t a \t line'
>>> print(s)
This     is      a   line
>>>
</code>```

Hope this helps!

Body:
I want to compare two text files in Python, and return the lines that are different.  My attempt uses difflib, but I'm open to other suggestions.  I need to get the lines that are different, as well as the lines that appear in one file but not the other.  Order is somewhat important, but if a good solution exists that doesn't take order into consideration, I can let go of that.

The problem is that one file has lines that have multiple trailing characters \t and \n, while the other doesn't; I don't want to consider that as a difference.  For other files, the first file has only \n and the other files has \t characters at the end.  The lines contain elements that are separated by tabs or spaces, so those are important; I just don't care for the trailing characters \t and \n.

My solution:

from difflib import Differ

with open(file_path) as actual:
    with open(test_file_path) as test:
        differ = Differ()

        for line in differ.compare(actual.readlines(), test.readlines()):
            if line.startswith('-'):
                log.error('EXPECTED:  {}'.format(line[2:]))
            if line.startswith('+'):
                log.error('TEST FILE: {}'.format(line[2:]))

I expect the output to show EXPECTED and TEST FILE lines when there's a difference, and just EXPECTED or just TEST FILE when one contains a line the other doesn't.  Right now, I'm seeing a lot of the following types of errors:

00:02:40: ERROR EXPECTED:  Issuer   Type    OBal    Net WAC OTerm   WAM Age GrossCpn    HighRemTerm Grp

00:02:40: ERROR TEST FILE: Issuer   Type    OBal    Net WAC OTerm   WAM Age GrossCpn    HighRemTerm Grp

As you can see (if you highlight it), the first line contains a number of spaces after 'Grp' and the other line doesn't.  I want to consider these two lines the same.

I've tried to explicitly specify the tabs and line breaks:

actual_file = actual.readlines()
expected_file = []
for line in actual_file:
    if line[-1] == '\n':
        expected_file.append(line.rstrip('\n').rstrip('\t') + '\n')
    else:
        expected_file.append(line.rstrip('\t'))

However, it (a) slows the process down quite a bit, and (b) is required for every file type in a different way, since some files have trailing tabs followed by line breaks, some have just line breaks, and some have nothing at all.  If there's no better way, I can strip every line of every trailing tab and linebreak, but it seems like a lot of processing power (I have to run a lot of files) for something that seems fairly easy to resolve.

Body:
Take a look at string.rstrip() here: https://docs.python.org/2/library/string.html#string.rstrip

string.rstrip() should do exactly what you need by stripping whitespace off the end of a string, while leaving \t and \n characters before the end alone.

Check it out:

>>> import string
>>> s = "This \t is \t a \t line \t\t\t\n\n\n"
>>> print(s)
This     is      a   line

>>>
>>> s = string.rstrip(s)
>>> s
'This \t is \t a \t line'
>>> print(s)
This     is      a   line
>>>

Hope this helps!


答:
Say hi to strstr()

```<code>$str = 'this-is-the-example/exa';
$trim = '/exa';
$result = strstr($str, $trim, true);
echo $result;
</code>```

Title: How to trim string from right in PHP?

Body:
Say hi to strstr()

$str = 'this-is-the-example/exa';
$trim = '/exa';
$result = strstr($str, $trim, true);
echo $result;


问:
How can I normalize a sparse matrix in R by both rows and columns?
I have created a sparse matrix using the R package "Matrix". The matrix is not square, and its dimensions are 4561 by 68825.

I'm looking to standardize this matrix so that each value x is equal to x / row sum + column sum. I've found a solution on stack which I could alter to solve this problem here. However, in the solution seen in the linked question, the problem uses a square matrix, so Diaganal can be used.In my case, my matrix is not square so I can't make this solution work.

How can I normalize a sparse matrix in R by both rows and columns?

Body:
Hope this helps!

m_final <- t(t(m/rowSums(m)) + rowSums(t(m)))
m_final

Output is:

           [,1]     [,2]       [,3]
 [1,] 0.9748283 3.326324 -0.8274075
 [2,] 1.4574957 2.776025 -0.7597753
 [3,] 1.9265464 2.937874 -1.3906749
 [4,] 0.7105211 3.337394 -0.5741696
 [5,] 1.4808831 3.030777 -1.0379153
 [6,] 2.2123599 2.537209 -1.2758243
 [7,] 2.8672471 2.437124 -1.8306263
 [8,] 4.8144351 6.952963 -8.2936531
 [9,] 1.9486587 3.382196 -1.8571098
[10,] 0.8897446 3.329129 -0.7451281

#sample data:
set.seed(1)
m <- replicate(3,rnorm(10))
> m
            [,1]        [,2]        [,3]
 [1,] -0.6264538  1.51178117  0.91897737
 [2,]  0.1836433  0.38984324  0.78213630
 [3,] -0.8356286 -0.62124058  0.07456498
 [4,]  1.5952808 -2.21469989 -1.98935170
 [5,]  0.3295078  1.12493092  0.61982575
 [6,] -0.8204684 -0.04493361 -0.05612874
 [7,]  0.4874291 -0.01619026 -0.15579551
 [8,]  0.7383247  0.94383621 -1.47075238
 [9,]  0.5757814  0.82122120 -0.47815006
[10,] -0.3053884  0.59390132  0.41794156

Edit:

In case you want to have below calculation then you can try

m/(row_sum + col_sum)

m/outer(rowSums(m), colSums(m), FUN = "+")


问:
How can I sum strings in one column into one row in Microsoft SQL? Group by does not work since it is MSSQL
for example we have table with three columns

```<code>Column A |  Column B | Column C
-------------------------------
P1       |    10     |    A
P1       |    20     |    B
P1       |    30     |    C
P2       |    30     |    D
P2       |    40     |    E
</code>```

How do I have to write SELECT query in Microsoft SQL to have this kind of result

```<code>Column A |     Column B      |   Column C
------------------------------------------
P1       |    10, 20, 30     |    A, B, C
P2       |    30, 40         |    D, E
</code>```

答:
```<code>SELECT DISTINCT COLA,
      STUFF((select ', '+ColB from T1 AS B where A.ColA=B.ColA FOR XML PATH(''),Type).value('.','NVARCHAR(MAX)'),1,2,'') AS ColB,
      STUFF((select ', '+ColC from T1 AS B where A.ColA=B.ColA FOR XML PATH(''),Type).value('.','NVARCHAR(MAX)'),1,2,'') AS ColC

      FROM T1 A
</code>```

Body:
for example we have table with three columns

Column A |  Column B | Column C
-------------------------------
P1       |    10     |    A
P1       |    20     |    B
P1       |    30     |    C
P2       |    30     |    D
P2       |    40     |    E

How do I have to write SELECT query in Microsoft SQL to have this kind of result

Column A |     Column B      |   Column C
------------------------------------------
P1       |    10, 20, 30     |    A, B, C
P2       |    30, 40         |    D, E


问:
Grouping consecutive elements together using Javascript
I have an array of elements like so:

messages[i], where messages[i] may only exist for certain values of i. For instance messages[0] and messages[2] may exist but not messages[1].

Now I would like to group together elements with continuous indices, for example if the indices for which messages existed were:

2, 3, 4, 5, 8, 9, 12, 13, 14, 15, 16, 17, 20

I would like to group them like so:

2, 3, 4, 5

8, 9

12, 13, 14, 15, 16, 17

20

What would be an effective way to do so using Javascript?

EDIT:

```<code>for (i = 0; i < messages.length; i++) {
   if (messages[i].from_user_id == current_user_id) {
   // group the continuous messages together
      } else {
  //group these continuous messages together
   }
}
</code>```

答:
Another approach would be something like this. I'm using a library called lodash for my array manipulation.

Basically I'm sorting the array in ascending order. And then for every increment, I'm storing the current element to a temporary array and comparing the last value of that array to the current element if they are in sequence if not I push the values of the temporary array to my result array and so on. If my loop reaches the end I just push the values of my temporary array to my results array.

```<code>var _ = require('lodash');
var arr = [2, 3, 4, 5, 8, 9, 12, 13, 14, 15, 16, 17, 20];
arr = _.sortBy(arr, function (o) {
    return o;
});
var tmp = [];
var res = [];
for (var i = 0; i < arr.length; i++) {
    if (tmp.length === 0) {
        tmp.push(arr[i]);
    }
    else {
        var lastEl = _.last(tmp);
        if ((lastEl + 1) === arr[i]) {
            tmp.push(arr[i]);
        }
        else {
            res.push(tmp);
            tmp = [];
            tmp.push(arr[i]);
        }
        if (i === (arr.length - 1)) {
            res.push(tmp);
            tmp = [];
        }
    }
}
// Outputs: [ [ 2, 3, 4, 5 ], [ 8, 9 ], [ 12, 13, 14, 15, 16, 17 ], [ 20 ] ]
</code>```

Body:
I have an array of elements like so:

messages[i], where messages[i] may only exist for certain values of i. For instance messages[0] and messages[2] may exist but not messages[1].

Now I would like to group together elements with continuous indices, for example if the indices for which messages existed were:

2, 3, 4, 5, 8, 9, 12, 13, 14, 15, 16, 17, 20

I would like to group them like so:

2, 3, 4, 5

8, 9

12, 13, 14, 15, 16, 17

20

What would be an effective way to do so using Javascript?

EDIT:

for (i = 0; i < messages.length; i++) {
   if (messages[i].from_user_id == current_user_id) {
   // group the continuous messages together
      } else {
  //group these continuous messages together
   }
}

Body:
Another approach would be something like this. I'm using a library called lodash for my array manipulation.

Basically I'm sorting the array in ascending order. And then for every increment, I'm storing the current element to a temporary array and comparing the last value of that array to the current element if they are in sequence if not I push the values of the temporary array to my result array and so on. If my loop reaches the end I just push the values of my temporary array to my results array.

var _ = require('lodash');
var arr = [2, 3, 4, 5, 8, 9, 12, 13, 14, 15, 16, 17, 20];
arr = _.sortBy(arr, function (o) {
    return o;
});
var tmp = [];
var res = [];
for (var i = 0; i < arr.length; i++) {
    if (tmp.length === 0) {
        tmp.push(arr[i]);
    }
    else {
        var lastEl = _.last(tmp);
        if ((lastEl + 1) === arr[i]) {
            tmp.push(arr[i]);
        }
        else {
            res.push(tmp);
            tmp = [];
            tmp.push(arr[i]);
        }
        if (i === (arr.length - 1)) {
            res.push(tmp);
            tmp = [];
        }
    }
}
// Outputs: [ [ 2, 3, 4, 5 ], [ 8, 9 ], [ 12, 13, 14, 15, 16, 17 ], [ 20 ] ]


问:
What is the difference between Cloud config server and Eureka
In Cloud config, we store config which can be accessed by other micro services. In Eureka also we store config info. So what is the difference and when to use what?</p>

答: After learning some more I understood that Eureka is not meant for storing config. It is meant for service registry and discovery. Cloud Config acts as a centralized config mechanism. Eureka on the other hand is meant so that services can discover each other without having to hard code the host and port anywhere.</p>


问:
I'd like to produce a function like split (arr, i, j) which divides array arr by axis i, j
I'd like to produce a function like split(arr, i, j), which divides array arr by axis i, j?

But I do not know how to do it. In the following method using array_split. It is impossible for me to obtain the two-dimensional array that we are seeking by merely dividing N-dimensional arrays into N-1 dimensional arrays.

```<code>import numpy as np

arr = np.arange(36).reshape(4,9)
dim = arr.ndim
ax = np.arange(dim)
arritr = [np.array_split(arr, arr.shape[ax[i]], ax[i]) for i in range(dim)]
print(arritr[0])
print(arritr[1])
</code>```

How can I achieve this?

答:
I believe you would like to slice array by axis(row, column). Here is the doc. https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html</p>

```<code>arr[1,:] # will return all values at index 1(row index 1)
arr[:,1] # will return all values at column 1
</code>```

Body:
I'd like to produce a function like split(arr, i, j), which divides array arr by axis i, j?

But I do not know how to do it. In the following method using array_split. It is impossible for me to obtain the two-dimensional array that we are seeking by merely dividing N-dimensional arrays into N-1 dimensional arrays.

import numpy as np

arr = np.arange(36).reshape(4,9)
dim = arr.ndim
ax = np.arange(dim)
arritr = [np.array_split(arr, arr.shape[ax[i]], ax[i]) for i in range(dim)]
print(arritr[0])
print(arritr[1])

How can I achieve this?

Body:
I believe you would like to slice array by axis(row, column). Here is the doc. https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

arr[1,:] # will return all values at index 1(row index 1)
arr[:,1] # will return all values at column 1


问:
Set checkbox is checked or not from json data
I have checkbox and I want to change it's value using jquery depending on values come by json data
I restore string in database that determine the value of every html element
like this

```<code>bandwidthcap:=false,download:=,upload:=,restrict:=true
</code>```

the bandwidthcap is  toggle checkbox
but the program every time set it as checked even if the value is false as you can see.
this is the jquery code to get json data and set it to html elements

```<code> var jsonData = $.ajax({
      url: "Save.php?id=gettallemplate&tempname="+name,

      dataType: "json",
      async: false
      }).responseText;
        //}
//alert(jsonData);
var obj = $.parseJSON(jsonData);
    var array = obj['data'].split(",");
    $.each(array,function(i){ var array2 = array[i].split(":=");

        $('#'+array2[0]).val(array2[1]);
        $('#'+array2[0]).attr('checked', array2[1]);

});
</code>```

array2[0] contain the element ID and the array2[1] contain value
for bandwidthcap checkbox
$('#bandwidthcap').attr('checked',false)
but it give checked
I searched alote without result

答:
true and false are being treated as string and hence you can't use/treat them as boolean.

You need to check:

```<code>var flag = (array2[1] === "true");
</code>```

And use flag to set checkbox as checked or unchecked:

var someData = 'bandwidthcap:=false,download:=,upload:=,restrict:=true';
var array = someData.split(",");
$.each(array, function(i) {
  var array2 = array[i].split(":=");
  var flag = (array2[1] === "true");
  $('#' + array2[0]).val(array2[1]);
  $('#' + array2[0]).attr('checked', flag);
});```
<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>
<input type='checkbox' id='bandwidthcap' />
<input type='checkbox' id='download' />
<input type='checkbox' id='upload' />
<input type='checkbox' id='restrict' /></code>```

Body:
I have checkbox and I want to change it's value using jquery depending on values come by json data
I restore string in database that determine the value of every html element
like this

bandwidthcap:=false,download:=,upload:=,restrict:=true

the bandwidthcap is  toggle checkbox
but the program every time set it as checked even if the value is false as you can see.
this is the jquery code to get json data and set it to html elements

 var jsonData = $.ajax({
      url: "Save.php?id=gettallemplate&tempname="+name,

      dataType: "json",
      async: false
      }).responseText;
        //}
//alert(jsonData);
var obj = $.parseJSON(jsonData);
    var array = obj['data'].split(",");
    $.each(array,function(i){ var array2 = array[i].split(":=");

        $('#'+array2[0]).val(array2[1]);
        $('#'+array2[0]).attr('checked', array2[1]);

});

array2[0] contain the element ID and the array2[1] contain value
for bandwidthcap checkbox
$('#bandwidthcap').attr('checked',false)
but it give checked
I searched alote without result

Body:
true and false are being treated as string and hence you can't use/treat them as boolean.

You need to check:

var flag = (array2[1] === "true");

And use flag to set checkbox as checked or unchecked:

var someData = 'bandwidthcap:=false,download:=,upload:=,restrict:=true';
var array = someData.split(",");
$.each(array, function(i) {
  var array2 = array[i].split(":=");
  var flag = (array2[1] === "true");
  $('#' + array2[0]).val(array2[1]);
  $('#' + array2[0]).attr('checked', flag);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type='checkbox' id='bandwidthcap' />
<input type='checkbox' id='download' />
<input type='checkbox' id='upload' />
<input type='checkbox' id='restrict' />


问:
Exporting OBIEE Dashboard page to Excel
When exporting a dashboard page to excel, using the export to excel button, the page is displayed in multiple pages in excel.

How can the exported page display in a single page in excel?

答:
Add a text control with HTML layout to your dashboard, and paste the below definitions into the control:</p>

```<code><script type="text/javascript">
function ExportXLS()
{
saw.dashboard.exportToExcel('/shared/Folder Path/','Report Name', true);
}
</script>
<a href=# OnClick='javascript:ExportXLS();'>Export To Excel</a>
</code>```

Title: Exporting OBIEE Dashboard page to Excel

Body:
Add a text control with HTML layout to your dashboard, and paste the below definitions into the control:

<script type="text/javascript">
function ExportXLS()
{
saw.dashboard.exportToExcel('/shared/Folder Path/','Report Name', true);
}
</script>
<a href=# OnClick='javascript:ExportXLS();'>Export To Excel</a>


问:
Android : I would like to put Custom Chrome Tab inside a Fragment in an Activity
I have an activity that has a TabLayout. Inside each Tab, there is a Fragment. I want to show different webcontent form a URL in each Fragment.

Is this possible ?

From what I researched, Chrome Tabs seems to show it on a separate full page by itself with an X or <- icon on the left side. But this fails my requirement.

I can achieve this using a WebView but given that ChromeTabs can do prefetch and token etc. I would like to investigate this option.

I went through lot of documentation, so please dont cut this off as no research.

Appreciate any help.

答: No you cannot put use Chrome Tabs for that purpose. I moved ahead with WebView.


问:
How to break a line of chained methods in Python?
I have a line of the following code (don't blame for naming conventions, they are not mine):

```<code>subkeyword = Session.query(
    Subkeyword.subkeyword_id, Subkeyword.subkeyword_word
).filter_by(
    subkeyword_company_id=self.e_company_id
).filter_by(
    subkeyword_word=subkeyword_word
).filter_by(
    subkeyword_active=True
).one()
</code>```

I don't like how it looks like (not too readable) but I don't have any better idea to limit lines to 79 characters in this situation. Is there a better way of breaking it (preferably without backslashes)?

答:
Just store the intermediate result/object and invoke the next method on it,
e.g.</p>

```<code>q = Session.query(Subkeyword.subkeyword_id, Subkeyword.subkeyword_word)
q = q.filter_by(subkeyword_company_id=self.e_company_id)
q = q.filter_by(subkeyword_word=subkeyword_word)
q = q.filter_by(subkeyword_active=True)
subkeyword = q.one()
</code>```

Body:
I have a line of the following code (don't blame for naming conventions, they are not mine):

subkeyword = Session.query(
    Subkeyword.subkeyword_id, Subkeyword.subkeyword_word
).filter_by(
    subkeyword_company_id=self.e_company_id
).filter_by(
    subkeyword_word=subkeyword_word
).filter_by(
    subkeyword_active=True
).one()

I don't like how it looks like (not too readable) but I don't have any better idea to limit lines to 79 characters in this situation. Is there a better way of breaking it (preferably without backslashes)?

Body:
Just store the intermediate result/object and invoke the next method on it,
e.g.

q = Session.query(Subkeyword.subkeyword_id, Subkeyword.subkeyword_word)
q = q.filter_by(subkeyword_company_id=self.e_company_id)
q = q.filter_by(subkeyword_word=subkeyword_word)
q = q.filter_by(subkeyword_active=True)
subkeyword = q.one()