问:
What attributes does d3 transition change?
I am trying to understand what exactly gets transition in d3.

For example

```<code>var bars = svg.selectAll(null)
  .data(my_values)
  .enter()
  .append("rect") // statement before transition
  .attr("x", 10)  // statement before transition
  .transition()   // transition
  .delay(200)
  .duration(1500)
  .attr("height", 10) // statement after transition
  .transition()   // another transition
  .delay(200)
  .duration(1500);
</code>```

Does the transition effect any statement before the transition or does the transition effect only statement after the transition

How does multiple transition work?

答:
Your second question...

How does multiple transition work?

Is quite simple to answer. Here, the API is clear:

transition.transition()

Returns a new transition on the same selected elements as this transition, scheduled to start when this transition ends.

So, the new transition will start when the previous one finishes, and so on. Let's see it:

var rect = d3.select("svg").append("rect")
  .attr("width", 100)
  .attr("height", 0)
  .style("fill", "black")
  .transition()
  .duration(1000)
  .attr("height", 100)
  .transition()
  .duration(1000)
  .style("fill", "teal")```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg></code>```

The interesting question

However, the interesting question here is your first one:

Does the transition effect any statement before the transition or does the transition effect only statement after the transition?

Well, this is also quite basic: the transition() method creates a transition between a starting value and a target value. You have to set the attribute before the transition (the starting value) and after the transition (the target value).

The problem is that attributes not previously set will have a null value.

Let's see it: without specifying the height of the rectangle, it is null:

var rect = d3.select("svg").append("rect");

console.log(rect.attr("height"))```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg></code>```

Therefore, there is no smooth transition regarding the height if you don't set it before the transition:

var rect = d3.select("svg").append("rect")
  .attr("width", 100)
  .transition()
  .duration(1000)
  .attr("height", 100);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg></code>```

And here comes the interesting point: I wrote an answer (now deleted, users with >10k can see it) explaining that the interpolator cannot interpolate from null to a given value. However, it can interpolate:

var interpolator = d3.interpolateNumber(null, 100);
d3.range(0,1.1,.1).forEach(function(d){
 console.log(interpolator(d))
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://d3js.org/d3.v4.min.js"></script></code>```

So, what is happening here is a bit more complicated. Using interpolateNumber we can interpolate from null to a given value. Look at this demo, where the height was not set:

var rect = d3.select("svg").append("rect")
  .attr("width", 100)
  .transition()
  .duration(1000)
  .attrTween("height", function() {
    return d3.interpolateNumber(d3.select(this).attr("height"), 100);
  });```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg></code>```

Why the default transition.attr() doesn't work when you don't set the attribute before the transition?

After some investigation, it seems to me that transition() is converting the numeric target value to a string (like 100 to "100"). This is very strange, because the API explicitly says that...

... an interpolator is chosen based on the type of the target value, using the following algorithm:

If value is a number, use interpolateNumber.

If value is a color or a string coercible to a color, use interpolateRgb.

Use interpolateString.

Here is the source code, look at the last line:

```<code>export default function(name, value) {
    var fullname = namespace(name),
        i = fullname === "transform" ? interpolateTransform : interpolate;
    return this.attrTween(name, typeof value === "function"
        ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value))
        : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
        : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value + ""));
        //converting to string here ------------------------------------------^
}
</code>```

As we can see, it's coercing the value to a string. Therefore, the transition will not work because it will use interpolateString instead of interpolateNumber:

var interpolator = d3.interpolateString(null, "100");
d3.range(0,1.1,.1).forEach(function(d){
 console.log(interpolator(d))
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://d3js.org/d3.v4.min.js"></script></code>```

Conclusion

transition() creates a transition from a starting value to a target value. If the starting value is not set, it will default to null. However, as transition() uses interpolateString, the interpolation will not work properly.

Update in 18/11/2017

According to Mike Bostock (D3 creator), the source code is correct (and, therefore, the documentation is wrong). As he says in this GitHub issue:

interpolateString (or interpolateRgb) is the correct behavior here. interpolateNumber should never be used for attributes.

The explanation is that values like "100px" or "1.3em" would not work with interpolateNumber. So, again, don't rely on null starting values: always set the attribute before and after the transition().

Thanks to @altocumulus for commenting on the GitHub issue.

Body:
I am trying to understand what exactly gets transition in d3.

For example

var bars = svg.selectAll(null)
  .data(my_values)
  .enter()
  .append("rect") // statement before transition
  .attr("x", 10)  // statement before transition
  .transition()   // transition
  .delay(200)
  .duration(1500)
  .attr("height", 10) // statement after transition
  .transition()   // another transition
  .delay(200)
  .duration(1500);

Does the transition effect any statement before the transition or does the transition effect only statement after the transition

How does multiple transition work?

Body:
Your second question...

How does multiple transition work?

Is quite simple to answer. Here, the API is clear:

transition.transition()

Returns a new transition on the same selected elements as this transition, scheduled to start when this transition ends.

So, the new transition will start when the previous one finishes, and so on. Let's see it:

var rect = d3.select("svg").append("rect")
  .attr("width", 100)
  .attr("height", 0)
  .style("fill", "black")
  .transition()
  .duration(1000)
  .attr("height", 100)
  .transition()
  .duration(1000)
  .style("fill", "teal")

<script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg>

The interesting question

However, the interesting question here is your first one:

Does the transition effect any statement before the transition or does the transition effect only statement after the transition?

Well, this is also quite basic: the transition() method creates a transition between a starting value and a target value. You have to set the attribute before the transition (the starting value) and after the transition (the target value).

The problem is that attributes not previously set will have a null value.

Let's see it: without specifying the height of the rectangle, it is null:

var rect = d3.select("svg").append("rect");

console.log(rect.attr("height"))

<script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg>

Therefore, there is no smooth transition regarding the height if you don't set it before the transition:

var rect = d3.select("svg").append("rect")
  .attr("width", 100)
  .transition()
  .duration(1000)
  .attr("height", 100);

<script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg>

And here comes the interesting point: I wrote an answer (now deleted, users with >10k can see it) explaining that the interpolator cannot interpolate from null to a given value. However, it can interpolate:

var interpolator = d3.interpolateNumber(null, 100);
d3.range(0,1.1,.1).forEach(function(d){
 console.log(interpolator(d))
});

<script src="https://d3js.org/d3.v4.min.js"></script>

So, what is happening here is a bit more complicated. Using interpolateNumber we can interpolate from null to a given value. Look at this demo, where the height was not set:

var rect = d3.select("svg").append("rect")
  .attr("width", 100)
  .transition()
  .duration(1000)
  .attrTween("height", function() {
    return d3.interpolateNumber(d3.select(this).attr("height"), 100);
  });

<script src="https://d3js.org/d3.v4.min.js"></script>
<svg></svg>

Why the default transition.attr() doesn't work when you don't set the attribute before the transition?

After some investigation, it seems to me that transition() is converting the numeric target value to a string (like 100 to "100"). This is very strange, because the API explicitly says that...

... an interpolator is chosen based on the type of the target value, using the following algorithm:

If value is a number, use interpolateNumber.

If value is a color or a string coercible to a color, use interpolateRgb.

Use interpolateString.

Here is the source code, look at the last line:

export default function(name, value) {
    var fullname = namespace(name),
        i = fullname === "transform" ? interpolateTransform : interpolate;
    return this.attrTween(name, typeof value === "function"
        ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value))
        : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
        : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value + ""));
        //converting to string here ------------------------------------------^
}

As we can see, it's coercing the value to a string. Therefore, the transition will not work because it will use interpolateString instead of interpolateNumber:

var interpolator = d3.interpolateString(null, "100");
d3.range(0,1.1,.1).forEach(function(d){
 console.log(interpolator(d))
});

<script src="https://d3js.org/d3.v4.min.js"></script>

Conclusion

transition() creates a transition from a starting value to a target value. If the starting value is not set, it will default to null. However, as transition() uses interpolateString, the interpolation will not work properly.

Update in 18/11/2017

According to Mike Bostock (D3 creator), the source code is correct (and, therefore, the documentation is wrong). As he says in this GitHub issue:

interpolateString (or interpolateRgb) is the correct behavior here. interpolateNumber should never be used for attributes.

The explanation is that values like "100px" or "1.3em" would not work with interpolateNumber. So, again, don't rely on null starting values: always set the attribute before and after the transition().

Thanks to @altocumulus for commenting on the GitHub issue.


来源: stackexchange

问:
Does pandas.Series.unique() preserve order?
Simple question I haven't been able to find an answer to yet:

Given a pandas Series, I think the order of values given by Series.unique() is that in which they are first encountered in the series, and not any sort sorted order. I.e.

```<code>from pandas import Series
s = Series(['b','b','b','a','a','b'])

s.unique()
>>> array(['b', 'a'], dtype=object)
</code>```

This is the behavior I want for my application, but can someone tell me if I'm guaranteed to get this order? The documentation is not clear.

答: As of now, the pandas documentation contains this line: Uniques are returned in order of appearance, this does NOT sort.</p>

ContentLicense: CC BY-SA 3.0

Body:
Simple question I haven't been able to find an answer to yet:

Given a pandas Series, I think the order of values given by Series.unique() is that in which they are first encountered in the series, and not any sort sorted order. I.e.

from pandas import Series
s = Series(['b','b','b','a','a','b'])

s.unique()
>>> array(['b', 'a'], dtype=object)

This is the behavior I want for my application, but can someone tell me if I'm guaranteed to get this order? The documentation is not clear.


问:
If else statement not being executed correctly
I am facing a very strange problem. I have written the below code.

```<code>    if (verifiedStatus.equals("1")) {
    imageView.setImageResource(R.drawable.ic_verified_user_black_24dp);
    }
    else if (verifiedStatus.equals("0")) {
    imageView.setImageResource(R.drawable.ic_not_interested_black_24dp);
    } else {}
</code>```

As the code runs, if the value is 1, first the verified image comes but later it changes to the not interested image. I tried debugging and I saw that the code goes into an internal file/code and in the below lines, it changes the image to the other image.

```<code>for (;;) {
    Message msg = queue.next(); // might block
    if (msg == null) {
        // No message indicates that the message queue is quitting.
        return;
    }
</code>```

Can someone help me in resolving this issue?

答:
you must do like this:</p>

```<code>if (verifiedStatus.equals("1")) {
    imageView.setImageResource(R.drawable.ic_verified_user_black_24dp);
    }
    else if (verifiedStatus.equals("0") {
    imageView.setImageResource(R.drawable.ic_not_interested_black_24dp);
    } else {}
</code>```

Body:
I am facing a very strange problem. I have written the below code.

    if (verifiedStatus.equals("1")) {
    imageView.setImageResource(R.drawable.ic_verified_user_black_24dp);
    }
    else if (verifiedStatus.equals("0")) {
    imageView.setImageResource(R.drawable.ic_not_interested_black_24dp);
    } else {}

As the code runs, if the value is 1, first the verified image comes but later it changes to the not interested image. I tried debugging and I saw that the code goes into an internal file/code and in the below lines, it changes the image to the other image.

for (;;) {
    Message msg = queue.next(); // might block
    if (msg == null) {
        // No message indicates that the message queue is quitting.
        return;
    }

Can someone help me in resolving this issue?

Body:
you must do like this:

if (verifiedStatus.equals("1")) {
    imageView.setImageResource(R.drawable.ic_verified_user_black_24dp);
    }
    else if (verifiedStatus.equals("0") {
    imageView.setImageResource(R.drawable.ic_not_interested_black_24dp);
    } else {}


问:
Dropdown menu hidden behind slideshow container?
We have a main index page with a dropdown menu and slide show, and the z-index works fine, but in our other pages, we removed the slideshow and left the dropdown menu. But for some reason in the pages without the slideshow, the dropdown menu gets hidden behind the container the slideshow used to be, despite the removal of all slideshow HTML. This leads me to believe it is a CSS issue.

Any suggestions would be well appreciated!

Here's the HTML

```<code><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Stigler Public Schools</title>
  <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
  <link rel="stylesheet" type="text/css" href="\\stigler-web\web\New Website\caleab\stiglerstylesheet.css"/>
</head>
<body>
    <img class="logo" src="sps_logo.png" alt="Stigler Public Schools">
    <p class="header">Stigler Public Schools</p>
    <div class="nav">
      <ul class="navigation">
      <a class="main" href="#url">District</a>
  <li class="n1"><a href="\\stigler-web\web\New Website\caleab\District\hs\hs.html">High School</a></li>
  <li class="n2"><a href="\\stigler-web\web\New Website\caleab\District\ms\ms.html">Middle School</a></li>
  <li class="n3"><a href="\\stigler-web\web\New Website\caleab\District\gs\gs.html">Grade School</a></li>
  <li class="n4"><a href="\\stigler-web\web\New Website\caleab\District\admin\admin.html">Administration</a></li>
    </ul>
    <ul class="navigation">
      <a class="main" href="#url">Resources</a>
      <li class="n1"><a href="school_calendar.html" target="main">School Calender</a></li>
      <li class="n2"><a href="cafeteria_menus.html" target="main">Menus</a></li>
      <li class="n3"><a href="employment_opportunities.html" target="main">Employment</a></li>
      <li class="n4"><a href="counselor.html" target="main">Counseling</a></li>
      <li class="n5"><a href="https://wengage.com/Stigler/Login/AttemptLogin?ReturnUrl=%2fstigler.html">Grade Book</a></li>
      <li class="n6"><a href="http://www.jostens.com/yearbooks/high-school-yearbooks.html">Yearbook</a></li>
    </ul>
    </td>
    <ul class="navigation">
      <a class="main" href="#url">Organizations</a>
      <li class="n1"><a href="" target="main">Athletics</a></li>
      <li class="n2"><a href="#" target="main">Music</a></li>
      <li class="n3"><a href="" target="main">Drama</a></li>
      <li class="n4"><a href="#">FFA</a></li>
      <li class="n5"><a href="#">A-Z</a></li>
    </ul>

    <ul class="navigation">
      <a class="main" href="#url">Board Of Education</a>
        <li class="n1"><a href="board_of_education.html" target="main">Information</a></li>
      <li class="n2"><a href="policy.html#" target="main">Meetings</a></li>
      <li class="n3"><a href="#">Policies</a></li>
    </ul>
  </div>

  </body>
</html>
</code>```

And Here's the CSS

* {
  margin: 0px;
  padding: 0px;
  outline: none;
  border: 0px;
}

body {
  background-image: url(background.png);
  background-repeat: no-repeat;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  background-size: cover;
  margin: 0px auto;
  padding: 0px;
  width: 100%;
  overflow: hidden;
}

h1 {
  border-top: none;
  border-left: none;
  border-bottom: 5px groove red;
  border-right: none;
  color: #e60000;
  font-family: century gothic;
  text-align: center;
  color: #FF000;
}

h2 {
  font-family: century gothic;
}

h3 {
  font-family: century gothic;
}

h5 {
  font-family: californian fb;
  font-szie: 1.15em;
}

p {
  border-top: none;
  border-left: none;
  border-bottom: none;
  border-right: none;
  font-family: californian fb;
  font-size: 1.15em;
}

table#sitelinks td {
  font-size: 1.15em;
}

table#sitelinks tr:nth-child(odd) {
  background-color: #fff
}

table tr:nth-child(even) {
  background-color: #fff
}

table tr:nth-child(odd) {
  background-color: #eee
}

hr {
  border-top: none;
  border-left: none;
  border-bottom: 5px groove red;
  border-right: none;
  font-family: californian fb;
  font-size: 1.15em;
}

th {
  text-align: left;
  font-family: century gothic;
  padding: 10px 0px 0px 0px;
  font-size: 1.15em;
}

td {
  font-family: century gothic;
  border: 1px solid black;
  padding: 5px 5px 5px 5px;
  text-align: center;
  font-size: 1em;
}

.center {
  text-align: center;
}

.blue {
  color: blue;
}

.bottomborder {
  text-align: center;
  border-bottom: 5px groove red;
}

a:link {
  color: #e60000;
  text-decoration: none
}

a:visited {
  color: #e60000;
  text-decoration: none
}

a:hover {
  color: #e60000;
  text-decoration: none
}

a:active {
  color: #e60000;
  text-decoration: none
}

.logo {
  display: block;
  margin: 0 auto;
  height: 160px;
  width: 160px;
}

.header {
  padding-left: 140px
}

a {
  display: block;
  text-decoration: none;
  width: 100%;
  height: 100%;
  color: #999;
}

.navwrapper {}

.nav {
  width: 79.31%;
  text-align: center;
  margin: 0px auto;
  z-index: 2;
  position: relative;
}

a:hover {
  color: #FF0000;
}

/* NAVIGATION */

.navigation {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 40px;
  margin: 10px auto;
  background: #FF0000;
  float: left;
  position: relative;
  z-index: 10
}

.navigation,
.navigation a.main {
  border-radius: 0px;
  -webkit-border-radius: 0px;
  -moz-border-radius: 0px;
}

.navigation:hover,
.navigation:hover a.main {
  border-radius: 0px 0px 0 0;
  -webkit-border-radius: 0px 0px 0 0;
  -moz-border-radius: 0px 0px 0 0;
}

.navigation a.main {
  display: inline-block;
  height: 40px;
  font: bold 15px/40px arial, sans-serif;
  text-align: center;
  text-decoration: none;
  color: #FFF;
  -webkit-transition: 0.2s ease-in-out;
  -o-transition: 0.2s ease-in-out;
  transition: 0.2s ease-in-out;
}

.navigation:hover a.main {
  color: rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.04);
}

.navigation li {
  width: 250px;
  height: 40px;
  background: #F7F7F7;
  font: normal 12px/40px arial, sans-serif !important;
  color: #999;
  text-align: center;
  margin: 0;
  -webkit-transform-origin: 50% 0%;
  -o-transform-origin: 50% 0%;
  transform-origin: 50% 0%;
  -webkit-transform: perspective(350px) rotateX(-90deg);
  -o-transform: perspective(350px) rotateX(-90deg);
  transform: perspective(350px) rotateX(-90deg);
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.05);
  -webkit-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 30;
  overflow: visible;
}

.navigation li:nth-child(even) {
  background: #F5F5F5;
}

.navigation li:nth-child(odd) {
  background: #EFEFEF;
}

.navigation li.n1 {
  -webkit-transition: 0.2s linear 0.4s;
  -o-transition: 0.2s linear 0.4s;
  transition: 0.2s linear 0.4s;
}

.navigation li.n2 {
  -webkit-transition: 0.2s linear 0.3s;
  -o-transition: 0.2s linear 0.3s;
  transition: 0.2s linear 0.3s;
}

.navigation li.n3 {
  -webkit-transition: 0.2s linear 0.2s;
  -o-transition: 0.2s linear 0.2s;
  transition: 0.2s linear 0.2s;
}

.navigation li.n4 {
  -webkit-transition: 0.2s linear 0.1s;
  -o-transition: 0.2s linear 0.1s;
  transition: 0.2s linear 0.1s;
}

.navigation li.n5 {
  border-radius: 0px 0px 4px 4px;
  -webkit-transition: 0.2s linear 0s;
  -o-transition: 0.2s linear 0s;
  transition: 0.2s linear 0s;
}

.navigation:hover li {
  -webkit-transform: perspective(350px) rotateX(0deg);
  -o-transform: perspective(350px) rotateX(0deg);
  transform: perspective(350px) rotateX(0deg);
  -webkit-transition: 0.2s linear 0s;
  -o-transition: 0.2s linear 0s;
  transition: 0.2s linear 0s;
}

.navigation:hover .n2 {
  -webkit-transition-delay: 0.1s;
  -o-transition-delay: 0.1s;
  transition-delay: 0.1s;
}

.navigation:hover .n3 {
  -webkit-transition-delay: 0.2s;
  -o-transition-delay: 0.2s;
  transition-delay: 0.2s;
}

.navigation:hover .n4 {
  transition-delay: 0.3s;
  -o-transition-delay: 0.3s;
  transition-delay: 0.3s;
}

.navigation:hover .n5 {
  -webkit-transition-delay: 0.4s;
  -o-transition-delay: 0.4s;
  transition-delay: 0.4s;
}

.navigation:hover .n6 {
  -webkit-transition-delay: 0.5s;
  -o-transition-delay: 0.5s;
  transition-delay: 0.5s
}

/* End Navigation */

/*Slideshow */

* {
  box-sizing: border-box
}

body {
  font-family: Verdana, sans-serif;
}

.mySlides {
  display: none;
  overflow: hidden;
}

.slideshowimg {
  min-width: 100%;
  max-width: 100%;
  max-height: none;
  border: 2px solid #ffffff
}

/* Slideshow container */

.slideshow-container {
  max-width: 1000px;
  min-width: 1000px;
  min-height: 500px;
  max-height: 500px;
  position: fixed;
  margin: 0px auto;
  clear: both;
  z-index: 1;
  position: relative;
  overflow: hidden;
}

/* Caption text */

.text {
  color: #f2f2f2;
  font-size: 30px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */

.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */

.dot {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active {
  background-color: #717171;
}

/* Fading animation */

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

/* On smaller screens, decrease text size */

@media only screen and (max-width: 300px) {
  .text {
    font-size: 11px
  }
}

/* End Slideshow */
```

答: I fixed this on my own. I realized that since there was no more content under the drop-down menu, the page technically ended, hence the disappearing menu. At least that's my conclusion. After adding the intended content to the page, they worked just fine.</p>

Body:
We have a main index page with a dropdown menu and slide show, and the z-index works fine, but in our other pages, we removed the slideshow and left the dropdown menu. But for some reason in the pages without the slideshow, the dropdown menu gets hidden behind the container the slideshow used to be, despite the removal of all slideshow HTML. This leads me to believe it is a CSS issue.

Any suggestions would be well appreciated!

Here's the HTML

<!DOCTYPE html>

  <meta charset="utf-8">
  <title>Stigler Public Schools</title>
  <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
  <link rel="stylesheet" type="text/css" href="\\stigler-web\web\New Website\caleab\stiglerstylesheet.css"/>

Stigler Public Schools

      District

High School

Middle School

Grade School

Administration

      Resources

School Calender

Menus

Employment

Counseling

Grade Book

Yearbook

      Organizations

Athletics

Music

Drama

FFA

A-Z

      Board Of Education

Information

Meetings

Policies

And Here's the CSS

* {
  margin: 0px;
  padding: 0px;
  outline: none;
  border: 0px;
}

body {
  background-image: url(background.png);
  background-repeat: no-repeat;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  background-size: cover;
  margin: 0px auto;
  padding: 0px;
  width: 100%;
  overflow: hidden;
}

h1 {
  border-top: none;
  border-left: none;
  border-bottom: 5px groove red;
  border-right: none;
  color: #e60000;
  font-family: century gothic;
  text-align: center;
  color: #FF000;
}

h2 {
  font-family: century gothic;
}

h3 {
  font-family: century gothic;
}

h5 {
  font-family: californian fb;
  font-szie: 1.15em;
}

p {
  border-top: none;
  border-left: none;
  border-bottom: none;
  border-right: none;
  font-family: californian fb;
  font-size: 1.15em;
}

table#sitelinks td {
  font-size: 1.15em;
}

table#sitelinks tr:nth-child(odd) {
  background-color: #fff
}

table tr:nth-child(even) {
  background-color: #fff
}

table tr:nth-child(odd) {
  background-color: #eee
}

hr {
  border-top: none;
  border-left: none;
  border-bottom: 5px groove red;
  border-right: none;
  font-family: californian fb;
  font-size: 1.15em;
}

th {
  text-align: left;
  font-family: century gothic;
  padding: 10px 0px 0px 0px;
  font-size: 1.15em;
}

td {
  font-family: century gothic;
  border: 1px solid black;
  padding: 5px 5px 5px 5px;
  text-align: center;
  font-size: 1em;
}

.center {
  text-align: center;
}

.blue {
  color: blue;
}

.bottomborder {
  text-align: center;
  border-bottom: 5px groove red;
}

a:link {
  color: #e60000;
  text-decoration: none
}

a:visited {
  color: #e60000;
  text-decoration: none
}

a:hover {
  color: #e60000;
  text-decoration: none
}

a:active {
  color: #e60000;
  text-decoration: none
}

.logo {
  display: block;
  margin: 0 auto;
  height: 160px;
  width: 160px;
}

.header {
  padding-left: 140px
}

a {
  display: block;
  text-decoration: none;
  width: 100%;
  height: 100%;
  color: #999;
}

.navwrapper {}

.nav {
  width: 79.31%;
  text-align: center;
  margin: 0px auto;
  z-index: 2;
  position: relative;
}

a:hover {
  color: #FF0000;
}

/* NAVIGATION */

.navigation {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 40px;
  margin: 10px auto;
  background: #FF0000;
  float: left;
  position: relative;
  z-index: 10
}

.navigation,
.navigation a.main {
  border-radius: 0px;
  -webkit-border-radius: 0px;
  -moz-border-radius: 0px;
}

.navigation:hover,
.navigation:hover a.main {
  border-radius: 0px 0px 0 0;
  -webkit-border-radius: 0px 0px 0 0;
  -moz-border-radius: 0px 0px 0 0;
}

.navigation a.main {
  display: inline-block;
  height: 40px;
  font: bold 15px/40px arial, sans-serif;
  text-align: center;
  text-decoration: none;
  color: #FFF;
  -webkit-transition: 0.2s ease-in-out;
  -o-transition: 0.2s ease-in-out;
  transition: 0.2s ease-in-out;
}

.navigation:hover a.main {
  color: rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.04);
}

.navigation li {
  width: 250px;
  height: 40px;
  background: #F7F7F7;
  font: normal 12px/40px arial, sans-serif !important;
  color: #999;
  text-align: center;
  margin: 0;
  -webkit-transform-origin: 50% 0%;
  -o-transform-origin: 50% 0%;
  transform-origin: 50% 0%;
  -webkit-transform: perspective(350px) rotateX(-90deg);
  -o-transform: perspective(350px) rotateX(-90deg);
  transform: perspective(350px) rotateX(-90deg);
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.05);
  -webkit-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 30;
  overflow: visible;
}

.navigation li:nth-child(even) {
  background: #F5F5F5;
}

.navigation li:nth-child(odd) {
  background: #EFEFEF;
}

.navigation li.n1 {
  -webkit-transition: 0.2s linear 0.4s;
  -o-transition: 0.2s linear 0.4s;
  transition: 0.2s linear 0.4s;
}

.navigation li.n2 {
  -webkit-transition: 0.2s linear 0.3s;
  -o-transition: 0.2s linear 0.3s;
  transition: 0.2s linear 0.3s;
}

.navigation li.n3 {
  -webkit-transition: 0.2s linear 0.2s;
  -o-transition: 0.2s linear 0.2s;
  transition: 0.2s linear 0.2s;
}

.navigation li.n4 {
  -webkit-transition: 0.2s linear 0.1s;
  -o-transition: 0.2s linear 0.1s;
  transition: 0.2s linear 0.1s;
}

.navigation li.n5 {
  border-radius: 0px 0px 4px 4px;
  -webkit-transition: 0.2s linear 0s;
  -o-transition: 0.2s linear 0s;
  transition: 0.2s linear 0s;
}

.navigation:hover li {
  -webkit-transform: perspective(350px) rotateX(0deg);
  -o-transform: perspective(350px) rotateX(0deg);
  transform: perspective(350px) rotateX(0deg);
  -webkit-transition: 0.2s linear 0s;
  -o-transition: 0.2s linear 0s;
  transition: 0.2s linear 0s;
}

.navigation:hover .n2 {
  -webkit-transition-delay: 0.1s;
  -o-transition-delay: 0.1s;
  transition-delay: 0.1s;
}

.navigation:hover .n3 {
  -webkit-transition-delay: 0.2s;
  -o-transition-delay: 0.2s;
  transition-delay: 0.2s;
}

.navigation:hover .n4 {
  transition-delay: 0.3s;
  -o-transition-delay: 0.3s;
  transition-delay: 0.3s;
}

.navigation:hover .n5 {
  -webkit-transition-delay: 0.4s;
  -o-transition-delay: 0.4s;
  transition-delay: 0.4s;
}

.navigation:hover .n6 {
  -webkit-transition-delay: 0.5s;
  -o-transition-delay: 0.5s;
  transition-delay: 0.5s
}

/* End Navigation */

/*Slideshow */

* {
  box-sizing: border-box
}

body {
  font-family: Verdana, sans-serif;
}

.mySlides {
  display: none;
  overflow: hidden;
}

.slideshowimg {
  min-width: 100%;
  max-width: 100%;
  max-height: none;
  border: 2px solid #ffffff
}

/* Slideshow container */

.slideshow-container {
  max-width: 1000px;
  min-width: 1000px;
  min-height: 500px;
  max-height: 500px;
  position: fixed;
  margin: 0px auto;
  clear: both;
  z-index: 1;
  position: relative;
  overflow: hidden;
}

/* Caption text */

.text {
  color: #f2f2f2;
  font-size: 30px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */

.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */

.dot {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active {
  background-color: #717171;
}

/* Fading animation */

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

/* On smaller screens, decrease text size */

@media only screen and (max-width: 300px) {
  .text {
    font-size: 11px
  }
}

/* End Slideshow */


问:
How to send an single email for multiples jobs in jenkins
In my jenkins i have 2 different jobs, will be scheduled to call at 15 mins timelap. I am sending an separate emails for both the jobs with status.

I want to send an single email for both the jobs, once both jobs are get executed
Could some suggest me how to send 1 email for n number of jobs with each jobs status is noted in body of the email.

答:
The easiest way would be to trigger both jobs with a pipeline job something like (untested)</p>

```<code>def resulta
def resultb
parallel a: {
   resulta = build 'joba'
}, b: {
   resultb = build 'jobb'
}
emailext body: "Joba: ${resulta.result} Jobb: ${resultb.result}", subject: 'Job Status', to: 'test@example.com'
</code>```

ContentLicense: CC BY-SA 4.0

Body:
The easiest way would be to trigger both jobs with a pipeline job something like (untested)

def resulta
def resultb
parallel a: {
   resulta = build 'joba'
}, b: {
   resultb = build 'jobb'
}
emailext body: "Joba: ${resulta.result} Jobb: ${resultb.result}", subject: 'Job Status', to: 'test@example.com'


问:
Multi DB test - Create a dynamic ChoiceField for admin interface?
I am testing a multi-database setup and need to populate a ChoiceField in the admin interface. I need a pull down for the movie_title field in movies.MovieEvent populated from the title field of calendar_app.Event via the foreign key in calendar_app.EventOccurence.
With a foreign key in play I can't make movie_title a foreign key to the EventOccurence model so I'm attempting to pull the records and then create a tuple to populate the pull down.

Here's what I have, this throws ValueError, not enough values to unpack (expected 2, got 1):

These models are routed to database #1:

```<code># calendar_app/models.py
class Event(models.Model):
    title = models.CharField(max_length=100)
    tags = models.ManyToManyField(Tag)
    ...

class EventOccurence(models.Model):
    event = models.ForeignKey(Event, related_name='event')
    event_date = models.DateField()
    ...
</code>```

This Model is routed to database #2:

```<code>#movies/models.py
class MovieEvent(models.Model):
    movie_title = models.CharField(max_length=80)
    ...
</code>```

Admin:

```<code>#admin.py
from calendar_app.models import EventOccurrence
...
class MovieEventAdminForm(forms.ModelForm):
    movie_events = EventOccurrence.objects.filter(Q(event__tags__slug__exact='movie')).distinct()
    y = ", (".join(str("'" + x.event.title + "', '" + x.event.title + "')") for x in movie_events)
    movie_choices = str("(" + "(" + y + ")")
    movie_title = forms.ChoiceField(choices=movie_choices)
    class Meta:
        model = MovieEvent
        fields = (
            ...
            'movie_title',
            ...
        )

class MovieEventAdmin(admin.ModelAdmin):
        form = MovieEventAdminForm
</code>```

The above throws the ValueError but when test my tuple creation it returns it just fine.

```<code>>>> movie_events = EventOccurrence.objects.filter(Q(event__tags__slug__exact='movie')).distinct()
>>> y = ", (".join(str("'" + x.event.title + "', '" + x.event.title + "')") for x in movie_events)
>>> movie_choices = str("(" + "(" + y + ")")
>>> print(movie_choices)
(('Halloween', 'Halloween'), ('Star Wars', 'Star Wars'), ('Chappie', 'Chappie'))
</code>```

What am I doing wrong?

答:
I have the solution. I did not know about ModelChoiceField which makes it very easy:</p>

```<code>#admin.py
from calendar_app.models import EventOccurrence
...
class MovieEventAdminForm(forms.ModelForm):
    movie_title = forms.ModelChoiceField(queryset= EventOccurrence.objects.filter(Q(event__tags__slug__exact='movie')).distinct())

    class Meta:
        model = MovieEvent
        fields = (
        ...
        'movie_title',
        ...
    )

class MovieEventAdmin(admin.ModelAdmin):
    form = MovieEventAdminForm
</code>```

Body:
I am testing a multi-database setup and need to populate a ChoiceField in the admin interface. I need a pull down for the movie_title field in movies.MovieEvent populated from the title field of calendar_app.Event via the foreign key in calendar_app.EventOccurence.
With a foreign key in play I can't make movie_title a foreign key to the EventOccurence model so I'm attempting to pull the records and then create a tuple to populate the pull down.

Here's what I have, this throws ValueError, not enough values to unpack (expected 2, got 1):

These models are routed to database #1:

# calendar_app/models.py
class Event(models.Model):
    title = models.CharField(max_length=100)
    tags = models.ManyToManyField(Tag)
    ...

class EventOccurence(models.Model):
    event = models.ForeignKey(Event, related_name='event')
    event_date = models.DateField()
    ...

This Model is routed to database #2:

#movies/models.py
class MovieEvent(models.Model):
    movie_title = models.CharField(max_length=80)
    ...

Admin:

#admin.py
from calendar_app.models import EventOccurrence
...
class MovieEventAdminForm(forms.ModelForm):
    movie_events = EventOccurrence.objects.filter(Q(event__tags__slug__exact='movie')).distinct()
    y = ", (".join(str("'" + x.event.title + "', '" + x.event.title + "')") for x in movie_events)
    movie_choices = str("(" + "(" + y + ")")
    movie_title = forms.ChoiceField(choices=movie_choices)
    class Meta:
        model = MovieEvent
        fields = (
            ...
            'movie_title',
            ...
        )

class MovieEventAdmin(admin.ModelAdmin):
        form = MovieEventAdminForm

The above throws the ValueError but when test my tuple creation it returns it just fine.

>>> movie_events = EventOccurrence.objects.filter(Q(event__tags__slug__exact='movie')).distinct()
>>> y = ", (".join(str("'" + x.event.title + "', '" + x.event.title + "')") for x in movie_events)
>>> movie_choices = str("(" + "(" + y + ")")
>>> print(movie_choices)
(('Halloween', 'Halloween'), ('Star Wars', 'Star Wars'), ('Chappie', 'Chappie'))

What am I doing wrong?

Body:
I have the solution. I did not know about ModelChoiceField which makes it very easy:

#admin.py
from calendar_app.models import EventOccurrence
...
class MovieEventAdminForm(forms.ModelForm):
    movie_title = forms.ModelChoiceField(queryset= EventOccurrence.objects.filter(Q(event__tags__slug__exact='movie')).distinct())

    class Meta:
        model = MovieEvent
        fields = (
        ...
        'movie_title',
        ...
    )

class MovieEventAdmin(admin.ModelAdmin):
    form = MovieEventAdminForm


问:
Precompile Assets Error By Undefined Method
I've been doing some work on my app and I recently ran

rake assets:precompile:primary RAILS_ENV=production --trace

The end result is this error:

NoMethodError: undefined method 'bytesize' for nil:NilClass

Not informative at all and the trace does little to help me

```<code>** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
NoMethodError: undefined method `bytesize' for nil:NilClass
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rack-1.4.7/lib/rack/utils.rb:300:in `bytesize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:13:in `initialize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `new'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:270:in `circular_call_protection'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:248:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:105:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:16:in `initialize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `new'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:270:in `circular_call_protection'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:248:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:252:in `new'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:252:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/environment.rb:78:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/static_compiler.rb:19:in `block in compile'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:219:in `block in each_logical_path'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:196:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:196:in `each_entry'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:204:in `block in each_file'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:203:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:203:in `each_file'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:217:in `each_logical_path'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/assets.rake:56:in `internal_precompile'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/jasontanner/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/rake:19:in `load'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/rake:19:in `<main>'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile:primary
</code>```

This is my production environment file.

```<code>Galapal::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = true

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger
  config.active_support.deprecation = :log

  # For angular js compression
  config.assets.js_compressor = Uglifier.new(mangle: false)

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin

  # Raise exception on mass assignment protection for Active Record models
  config.active_record.mass_assignment_sanitizer = :strict

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  config.active_record.auto_explain_threshold_in_seconds = 0.5

  # Do not compress assets
  config.assets.compress = true

  config.assets..serve_static_assets = true

  # Expands the lines which load the assets
  config.assets.debug = false

  # Expands the lines which load the assets
  config.assets.debug = false

  #ActiveRecord::Base.logger = Logger.new STDOUT

end
</code>```

So my question is this. Why can't I precompile my assets and how do I fix this? I'm running Rails 3.2.22.

答:
I had this issue do to a JavaScript file that had some sort of odd formatting (from the prettier library) that Rails took issue with .

```<code>NoMethodError: undefined method `bytesize' for nil:NilClass
/Users/joel/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.8/lib/rack/utils.rb:380:in `bytesize'
/Users/joel/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:13:in `initialize'
</code>```

To figure out which file, I dug into the  gem path and added some code to sprockets/processed_asset.rb to print the file:

```<code>  context = environment.context_class.new(environment, logical_path, pathname)
  @source = context.evaluate(pathname)
  p pathname
  @length = Rack::Utils.bytesize(source)
</code>```

The next time I compiled assets, it showed me the culprit.

Body:
I've been doing some work on my app and I recently ran

rake assets:precompile:primary RAILS_ENV=production --trace

The end result is this error:

NoMethodError: undefined method 'bytesize' for nil:NilClass

Not informative at all and the trace does little to help me

** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
NoMethodError: undefined method `bytesize' for nil:NilClass
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rack-1.4.7/lib/rack/utils.rb:300:in `bytesize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:13:in `initialize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `new'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:270:in `circular_call_protection'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:248:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:105:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/processed_asset.rb:16:in `initialize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `new'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:249:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:270:in `circular_call_protection'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:248:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:252:in `new'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:252:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/environment.rb:78:in `find_asset'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/static_compiler.rb:19:in `block in compile'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:219:in `block in each_logical_path'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:196:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:196:in `each_entry'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:204:in `block in each_file'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:203:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:203:in `each_file'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/sprockets-2.2.3/lib/sprockets/base.rb:217:in `each_logical_path'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/assets.rake:56:in `internal_precompile'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/actionpack-3.2.22.1/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/jasontanner/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/rake:19:in `load'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/rake:19:in `'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
/Users/jasontanner/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `'
Tasks: TOP => assets:precompile:primary

This is my production environment file.

Galapal::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = true

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger
  config.active_support.deprecation = :log

  # For angular js compression
  config.assets.js_compressor = Uglifier.new(mangle: false)

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin

  # Raise exception on mass assignment protection for Active Record models
  config.active_record.mass_assignment_sanitizer = :strict

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  config.active_record.auto_explain_threshold_in_seconds = 0.5

  # Do not compress assets
  config.assets.compress = true

  config.assets..serve_static_assets = true

  # Expands the lines which load the assets
  config.assets.debug = false

  # Expands the lines which load the assets
  config.assets.debug = false

  #ActiveRecord::Base.logger = Logger.new STDOUT

end

So my question is this. Why can't I precompile my assets and how do I fix this? I'm running Rails 3.2.22.

Body:
I had this issue do to a JavaScript file that had some sort of odd formatting (from the prettier library) that Rails took issue with .

NoMethodError: undefined method `bytesize' for nil:NilClass
/Users/joel/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.8/lib/rack/utils.rb:380:in `bytesize'
/Users/joel/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:13:in `initialize'

To figure out which file, I dug into the  gem path and added some code to sprockets/processed_asset.rb to print the file:

  context = environment.context_class.new(environment, logical_path, pathname)
  @source = context.evaluate(pathname)
  p pathname
  @length = Rack::Utils.bytesize(source)

The next time I compiled assets, it showed me the culprit.


问:
Write a string containing commas and double quotes to CSV
I'm trying to produce a Google Shopping feed of 30,000+ items in NetSuite, a CRM system that runs server-side JavaScript that it calls Suitescript 2.0. Essentially, it's just JavaScript with a few more restrictions. I've been tasked with outputting this product feed as a CSV.

The problem is that the product descriptions of these items contain variables amounts of commas, double quotes, single quotes and HTML. At first, it was just the commas causing me problems, so after a bit of research, I wrapped the strings I was outputting in double quotes:

```<code>//This function isn't terribly important, but is referenced below

function sanitizeString (desc) {
    var itemDesc;
    if (desc) {
        itemDesc = desc.replace(/(\r\n|\n|\r|\s+|\t| )/gm,' ');
        itemDesc = itemDesc.replace(/,/g, '\,');
        itemDesc = itemDesc.replace(/"/g, '\"');
        itemDesc = itemDesc.replace(/'/g, '\'');
        itemDesc = itemDesc.replace(/ +(?= )/g,'');
    } else {
        itemDesc = '';
    }
    return itemDesc;
}

var row = '';

for (var i = 0; i < columns.length; i++) {
    var col = columns[i];
    row += '"' + sanitizeString(val[col]) + '"';
    if (i != columns.length - 1) {
        row += ',';
    }
}
newFeed.appendLine({value: row});
</code>```

However, it seems that these double quotes are interacting strangely with double quotes within the string causing some weird formatting, even though my sanitizeString() function should be escaping them. Any time that a description contains a double quote, the next row doesn't get it's own line. It gets appended to the last column.

So, naturally, I escaped the external quotes like this:

```<code>row += '\"' + sanitizeString(val[col]) + '\"';
</code>```

Doing that makes things go completely haywire, a lot of items don't get pushed to new lines and I max out the number of columns I'm allowed because it just keeps on going.

The other natural solution would be to go edit the product descriptions, but I'm not terribly anxious to do that for 30,000+ items...

Does anybody know what might be going on here? I feel like there's something really simple I'm overlooking...

答:
I use this simple function to convert an string[][] to a csv file. It quotes the cell, if it contains a ", a , or other whitespace (except blanks):

```<code>/**
 * Takes an array of arrays and returns a `,` sparated csv file.
 * @param {string[][]} table
 * @returns {string}
 */
export function toCSV(table: string[][]) {
    return table
        .map(row =>
            row
                .map(cell => {
                    // We remove blanks and check if the column contains
                    // other whitespace,`,` or `"`.
                    // In that case, we need to quote the column.
                    if (cell.replace(/ /g, '').match(/[\s,"]/)) {
                        return '"' + cell.replace(/"/g, '""') + '"';
                    }
                    return cell;
                })
                .join(',')
        )
        .join('\n');
}
</code>```

Body:
I'm trying to produce a Google Shopping feed of 30,000+ items in NetSuite, a CRM system that runs server-side JavaScript that it calls Suitescript 2.0. Essentially, it's just JavaScript with a few more restrictions. I've been tasked with outputting this product feed as a CSV.

The problem is that the product descriptions of these items contain variables amounts of commas, double quotes, single quotes and HTML. At first, it was just the commas causing me problems, so after a bit of research, I wrapped the strings I was outputting in double quotes:

//This function isn't terribly important, but is referenced below

function sanitizeString (desc) {
    var itemDesc;
    if (desc) {
        itemDesc = desc.replace(/(\r\n|\n|\r|\s+|\t| )/gm,' ');
        itemDesc = itemDesc.replace(/,/g, '\,');
        itemDesc = itemDesc.replace(/"/g, '\"');
        itemDesc = itemDesc.replace(/'/g, '\'');
        itemDesc = itemDesc.replace(/ +(?= )/g,'');
    } else {
        itemDesc = '';
    }
    return itemDesc;
}

var row = '';

for (var i = 0; i < columns.length; i++) {
    var col = columns[i];
    row += '"' + sanitizeString(val[col]) + '"';
    if (i != columns.length - 1) {
        row += ',';
    }
}
newFeed.appendLine({value: row});

However, it seems that these double quotes are interacting strangely with double quotes within the string causing some weird formatting, even though my sanitizeString() function should be escaping them. Any time that a description contains a double quote, the next row doesn't get it's own line. It gets appended to the last column.

So, naturally, I escaped the external quotes like this:

row += '\"' + sanitizeString(val[col]) + '\"';

Doing that makes things go completely haywire, a lot of items don't get pushed to new lines and I max out the number of columns I'm allowed because it just keeps on going.

The other natural solution would be to go edit the product descriptions, but I'm not terribly anxious to do that for 30,000+ items...

Does anybody know what might be going on here? I feel like there's something really simple I'm overlooking...

Body:
I use this simple function to convert an string[][] to a csv file. It quotes the cell, if it contains a ", a , or other whitespace (except blanks):

/**
 * Takes an array of arrays and returns a `,` sparated csv file.
 * @param {string[][]} table
 * @returns {string}
 */
export function toCSV(table: string[][]) {
    return table
        .map(row =>
            row
                .map(cell => {
                    // We remove blanks and check if the column contains
                    // other whitespace,`,` or `"`.
                    // In that case, we need to quote the column.
                    if (cell.replace(/ /g, '').match(/[\s,"]/)) {
                        return '"' + cell.replace(/"/g, '""') + '"';
                    }
                    return cell;
                })
                .join(',')
        )
        .join('\n');
}


问:
How to stop spinner after DOM is loaded
I am loading a lot of data and it seems to take a few seconds to paint the page even after the data has been received.

I'm simplifying my code below so please excuse any syntax errors in this toy example.
My angularjs code is structured more or less like this

```<code>$scope.isLoading = true;
$http.get(url)
  .then(function(resp) {
    $scope.mydata = resp.data;
  })
  .finally(function() {
    $scope.isLoading = false;
  })
</code>```

And my html is

```<code><div class="spinner" ng-show="isLoading">
...
<!-- lots of data and complex DOM manipulation below -->
</code>```

I also tried

```<code><div class="spinner" ng-hide="mydata">
...
<!-- lots of data and complex DOM manipulation below -->
</code>```

In both cases, I get a spinner, then the spinner disappears, then several seconds go by, before the data finally shows up. If the data is smaller, then the delay is much less noticeable.

When I look at my browser's developer tools, the data is received and the spinner immediately goes away. Then the multi-second delay happens before the page finally loads. So I suspect the browser is trying to write the DOM

I would like to trim the delay between the spinner disappearing and the page appearing.

Is there some sort of hook/callback that's invoked after all the DOM is written?

答:
Since visual delay is caused by the fact that DOM is updated synchronosly on digest synchronously and blocks main thread, spinner removal should be postponed at least for one tick:

```<code>$http.get(url)
  .then(function(resp) {
    $scope.mydata = resp.data;
  })
  .finally(function() {
    return $timeout(function () {
      $scope.isLoading = false;
    })
  })
</code>```

Timeout delay can be increased to non-zero value (e.g. 20), depending on how the parts of the application that cause a freeze work. A new digest caused by $timeout can cause a new freeze, so the problem possibly should be solved with optimizations.

Title: How to stop spinner after DOM is loaded

Body:
I am loading a lot of data and it seems to take a few seconds to paint the page even after the data has been received.

I'm simplifying my code below so please excuse any syntax errors in this toy example.
My angularjs code is structured more or less like this

$scope.isLoading = true;
$http.get(url)
  .then(function(resp) {
    $scope.mydata = resp.data;
  })
  .finally(function() {
    $scope.isLoading = false;
  })

And my html is

...

I also tried

...

In both cases, I get a spinner, then the spinner disappears, then several seconds go by, before the data finally shows up. If the data is smaller, then the delay is much less noticeable.

When I look at my browser's developer tools, the data is received and the spinner immediately goes away. Then the multi-second delay happens before the page finally loads. So I suspect the browser is trying to write the DOM

I would like to trim the delay between the spinner disappearing and the page appearing.

Is there some sort of hook/callback that's invoked after all the DOM is written?

Body:
Since visual delay is caused by the fact that DOM is updated synchronosly on digest synchronously and blocks main thread, spinner removal should be postponed at least for one tick:

$http.get(url)
  .then(function(resp) {
    $scope.mydata = resp.data;
  })
  .finally(function() {
    return $timeout(function () {
      $scope.isLoading = false;
    })
  })

Timeout delay can be increased to non-zero value (e.g. 20), depending on how the parts of the application that cause a freeze work. A new digest caused by $timeout can cause a new freeze, so the problem possibly should be solved with optimizations.


问:
Where do i get and how to install _namemapper.pyd for Python 2.7 on Windows
I have Python 2.7 installed on my windows system with Cheetah. Below is the error i am getting, when i try to use the cheetah.template object with the .tmpl file.

```<code>from Cheetah.Template import Template
t = Template(file='home.tmpl')
C:\wamp\bin\Python27\lib\site-packages\Cheetah\Compiler.py:1509: UserWarning:
You don't have the C version of NameMapper installed! I'm disabling Cheetah's us
eStackFrames option as it is painfully slow with the Python version of NameMappe
r. You should get a copy of Cheetah with the compiled C version of NameMapper.
  "\nYou don't have the C version of NameMapper installed! "

from Cheetah.Template import Template
t = Template(file='home.tmpl')
print t

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\Template.py", line 1005,
in __str__
    rc = getattr(self, mainMethName)()
  File "_wamp_www_b121pyraw_b121pycheetah_home_tmpl.py", line 89, in respond
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\NameMapper.py", line 246,
 in valueFromSearchList
    _raiseNotFoundException(key, searchList)
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\NameMapper.py", line 167,
 in _raiseNotFoundException
    raise NotFound(excString)
Cheetah.NameMapper.NotFound: cannot find 'firstdivcontents'
</code>```

I searched for _namemapper.pyd for python 2.7, but i am not getting. I found the file for upto 2.6 only.
Do i have to downgrade to python 2.6, or is there any other method to install it.

And also how to install _namemapper.pyd  to work with python, if at all i find it ?

答:
The pyd files are created by compiling the C files which comes with the Package. This is done on installing, if you have a C compiler handy. If not, you in this case get a Python fall back. Some packages will just refuse to install.

The solution for Windows people without a C compiler is to install pre-compiled C binary packages. Cheetah seems to not have any: http://pypi.python.org/pypi/Cheetah/2.4.4

So you would need to install a C-compiler. MinGW is a good option, I hear.

However, I don't think that is your problem at all. Your actual error seems to have nothing to do with this warning.

So if you include your failing code, people more used to Cheetah than me can probably tell you what is wrong.

ContentLicense: CC BY-SA 2.5

Body:
I have Python 2.7 installed on my windows system with Cheetah. Below is the error i am getting, when i try to use the cheetah.template object with the .tmpl file.

from Cheetah.Template import Template
t = Template(file='home.tmpl')
C:\wamp\bin\Python27\lib\site-packages\Cheetah\Compiler.py:1509: UserWarning:
You don't have the C version of NameMapper installed! I'm disabling Cheetah's us
eStackFrames option as it is painfully slow with the Python version of NameMappe
r. You should get a copy of Cheetah with the compiled C version of NameMapper.
  "\nYou don't have the C version of NameMapper installed! "

from Cheetah.Template import Template
t = Template(file='home.tmpl')
print t

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\Template.py", line 1005,
in __str__
    rc = getattr(self, mainMethName)()
  File "_wamp_www_b121pyraw_b121pycheetah_home_tmpl.py", line 89, in respond
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\NameMapper.py", line 246,
 in valueFromSearchList
    _raiseNotFoundException(key, searchList)
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\NameMapper.py", line 167,
 in _raiseNotFoundException
    raise NotFound(excString)
Cheetah.NameMapper.NotFound: cannot find 'firstdivcontents'

I searched for _namemapper.pyd for python 2.7, but i am not getting. I found the file for upto 2.6 only.
Do i have to downgrade to python 2.6, or is there any other method to install it.

And also how to install _namemapper.pyd  to work with python, if at all i find it ?


问:
Visual Studio 2017 Angular 4 Templates
I am looking for a good Angular 4 template for Visual Studio 2017.  Or what is the best template to use and the way to proceed?  This will be for a Angular 4 SPA web page.</p>

答:
If you are looking for a more robust template, I found that the Emonney QuickApp template has some nice features, including login, REST API, EF, boostrap and webpack setup already.

Getting it going wasn't too difficult, just make sure you read the installation notes on their documentation page.

Title: Visual Studio 2017 Angular 4 Templates


问:
Flatten List<Observable<X[]> into Observable<X[]>
In my project i need to make subsequent calls to an API to retrieve summaries from different courses, and its all stored in a List like so:

```<code>List<Observable<Summaries[]>> summaries
</code>```

Then, i need to perform an action on those observables, and im using something along this lines:

```<code>Observable
    .switchOnNext(Observable.from(summaries))
    .doOnNext(summaries -> { actionToBeDone() })
</code>```

However, this performs the action for each Observable present in the list, and in the project implementation i am only able to execute the action to all at once, so my question is:

Is it possible to

```<code>List<Observable<Summaries[]>>
</code>```

into

```<code>Observable<Summaries[]>
</code>```

If not, is there any workaround to this?

答:
Based on the comments, you still have to use concat for example, then collect into an ArrayList followed by a toArray mapping:

```<code>Observable.concat(summaries)
.collect(ArrayList::new, (list, summary) -> list.addAll(Arrays.asList(summary)))
.map(list -> list.toArray(new Summaries[list.size()]))
.subscribe(/* ... */);
</code>```

Body:
In my project i need to make subsequent calls to an API to retrieve summaries from different courses, and its all stored in a List like so:

List<Observable<Summaries[]>> summaries

Then, i need to perform an action on those observables, and im using something along this lines:

Observable
    .switchOnNext(Observable.from(summaries))
    .doOnNext(summaries -> { actionToBeDone() })

However, this performs the action for each Observable present in the list, and in the project implementation i am only able to execute the action to all at once, so my question is:

Is it possible to

List<Observable<Summaries[]>>

into

Observable<Summaries[]>

If not, is there any workaround to this?

Body:
Based on the comments, you still have to use concat for example, then collect into an ArrayList followed by a toArray mapping:

Observable.concat(summaries)
.collect(ArrayList::new, (list, summary) -> list.addAll(Arrays.asList(summary)))
.map(list -> list.toArray(new Summaries[list.size()]))
.subscribe(/* ... */);


问:
C# Can I display images in a list box?
C# In a nut shell can I display images in a list box? I have a list of users and I want to display a green tick next to some of the names, is this possible?

Thanks

答:
The following code displays how to do custom drawing in a listbox.</p>

```<code>using System.Windows.Forms;
using System.Drawing;

namespace Toolset.Controls
{
    public class CustomDrawListBox : ListBox
    {
        public CustomDrawListBox()
        {
            this.DrawMode = DrawMode.OwnerDrawVariable; // We're using custom drawing.
            this.ItemHeight = 40; // Set the item height to 40.
        }

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            // Make sure we're not trying to draw something that isn't there.
            if (e.Index >= this.Items.Count || e.Index <= -1)
                return;

            // Get the item object.
            object item = this.Items[e.Index];
            if (item == null)
                return;

            // Draw the background color depending on
            // if the item is selected or not.
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                // The item is selected.
                // We want a blue background color.
                e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
            }
            else
            {
                // The item is NOT selected.
                // We want a white background color.
                e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
            }

            // Draw the item.
            string text = item.ToString();
            SizeF stringSize = e.Graphics.MeasureString(text, this.Font);
            e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.White),
                new PointF(5, e.Bounds.Y + (e.Bounds.Height - stringSize.Height) / 2));
        }
    }
}
</code>```

OwnerDisplayName: Steve

LastEditorDisplayName: Steve

Title: C# Can I display images in a list box?

Body:
The following code displays how to do custom drawing in a listbox.

using System.Windows.Forms;
using System.Drawing;

namespace Toolset.Controls
{
    public class CustomDrawListBox : ListBox
    {
        public CustomDrawListBox()
        {
            this.DrawMode = DrawMode.OwnerDrawVariable; // We're using custom drawing.
            this.ItemHeight = 40; // Set the item height to 40.
        }

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            // Make sure we're not trying to draw something that isn't there.
            if (e.Index >= this.Items.Count || e.Index <= -1)
                return;

            // Get the item object.
            object item = this.Items[e.Index];
            if (item == null)
                return;

            // Draw the background color depending on
            // if the item is selected or not.
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                // The item is selected.
                // We want a blue background color.
                e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
            }
            else
            {
                // The item is NOT selected.
                // We want a white background color.
                e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
            }

            // Draw the item.
            string text = item.ToString();
            SizeF stringSize = e.Graphics.MeasureString(text, this.Font);
            e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.White),
                new PointF(5, e.Bounds.Y + (e.Bounds.Height - stringSize.Height) / 2));
        }
    }
}

OwnerDisplayName: Patrik


问:
C++ template class inheritance
I have been porting some C++ code, which was written long time ago, and is normally compiled with Visual C++ (Visual Studio 7.1 version) and Intel C++ Compiler 11.0, the target platform is Linux (Suse x86-64), with GCC 4.3.2 and Intel C++ Compiler 11.1

The problem is that code like this

FileA.h

```<code>template<typename T, int dim>
class A
{
 public:
  A(){};
  ~A(){};
 protected:
  void foo1(){};
}
</code>```

FileB.h

```<code>#include "FileA.h"
template<typename T>
class B : public A<T, 2>
{
 public:
  B(){};
  ~B(){};
  void foo(){ foo1(); }
}
</code>```

main.cpp

```<code>#include "FileB.h"
int main()
{
 B<float> b = B<float>();
}
</code>```

does not compile on Linux (Intel C++ 11.1, GCC 4.3.2), but perfectly compiles on Windows (Visual C++ 7.1, Intel C++ 11.0), althow it surely must not depend on platform.
GCC tells that if I change foo1() to foo1(T a) it will work (and it does), but I can not change the code, and have to use Intel C++ for final release.

I would be glad if anyone could help with any advice.

答:
foo1 is not a dependent expression so the base class, which is a dependent type, is not used to resolve the foo1 call.

As you can't change the code, you are stuffed. If you could change the code you would need to change the expression to be dependent. Typically this is done by changing it to this->foo1().

Title: C++ template class inheritance

Body:
I have been porting some C++ code, which was written long time ago, and is normally compiled with Visual C++ (Visual Studio 7.1 version) and Intel C++ Compiler 11.0, the target platform is Linux (Suse x86-64), with GCC 4.3.2 and Intel C++ Compiler 11.1

The problem is that code like this

FileA.h

template<typename T, int dim>
class A
{
 public:
  A(){};
  ~A(){};
 protected:
  void foo1(){};
}

FileB.h

#include "FileA.h"
template<typename T>
class B : public A<T, 2>
{
 public:
  B(){};
  ~B(){};
  void foo(){ foo1(); }
}

main.cpp

#include "FileB.h"
int main()
{
 B<float> b = B<float>();
}

does not compile on Linux (Intel C++ 11.1, GCC 4.3.2), but perfectly compiles on Windows (Visual C++ 7.1, Intel C++ 11.0), althow it surely must not depend on platform.
GCC tells that if I change foo1() to foo1(T a) it will work (and it does), but I can not change the code, and have to use Intel C++ for final release.

I would be glad if anyone could help with any advice.


问:
Dynamically generate query with diff number of "where"?
How can I dynamically generate query to the db if I don't know how much filter and update -  values will be in the $filters and $updates arrays?
Template of the query is below:

```<code>$model::where($key_1, '=', $filter1)
    ->where($key_2, '=', $filter_2)
    ->where($key_n, '=', $filter_n)
    ->update([$key_1 => $update_1,
        $key_2 => $update_2,
        $key_n => $update_n
    ]);
</code>```

答:
loop through your arrays and call each method per filter:

```<code>foreach($filters as $key =>$value){
   $model->where($key, $value);
}
</code>```

and then build your $updates array in the same way and call update:

```<code>$model->update($updates);
</code>```

Body:
How can I dynamically generate query to the db if I don't know how much filter and update -  values will be in the $filters and $updates arrays?
Template of the query is below:

$model::where($key_1, '=', $filter1)
    ->where($key_2, '=', $filter_2)
    ->where($key_n, '=', $filter_n)
    ->update([$key_1 => $update_1,
        $key_2 => $update_2,
        $key_n => $update_n
    ]);

Body:
loop through your arrays and call each method per filter:

foreach($filters as $key =>$value){
   $model->where($key, $value);
}

and then build your $updates array in the same way and call update:

$model->update($updates);


问:
Calculating modulus by recursion without using modulo division
I'm doing a problem with recursive functions for a class project.  I'm trying to write a program that uses a recursive function that calculates a modulus without actually using the modulus operator.  I'm trying to use a reference parameter because I think that's the easiest way to do this, however my program is not functioning as intended.  </p>

```<code>//Michael Hery
//COP 2001
//11/15/2017
//Recursive Modulus

#include <iostream>
#include <iomanip>

using namespace std;

int recursiveMod(int &, int);

int main()
{
    int num;
    int den;
    int displayNum;
    int total;

    cout << "Please input the numerator (an integer) >> ";
    cin >> num;
    while (num < 0)
    {
        cout << "Integer must be greater than or equal to zero. >> ";
        cin >> num;
    }
    displayNum = num;
    cout << "Please input the denominator (an integer) >> ";
    cin >> den;
    while (den <= 0)
    {
        cout << "Integer must be greater than zero. >> ";
        cin >> den;
    }
    cout << "You have entered " << num << " % " << den << endl;

    total = recursiveMod(num, den);

    cout << "Modulus result: " << displayNum << " % " << den << " = " << total << endl;

    system("PAUSE");
    return 0;
}

int recursiveMod(int &num, int den)
{
    if (num == 0)
        return 0;

    num = num - den;

    if ((num - den) > den)
    {
        recursiveMod(num, den);
    }
    return num;
}
</code>```

答:
There are two errors with your code. Firstly you need to include cstdlib for system("pause") to work.

```<code>#include <cstdlib>
</code>```

Secondly, in your

```<code>int recusive mod(int &num, int den)
</code>```

the condition should be num > den and return must be put.

```<code>if (num > den)
    {
        return recursiveMod(num, den);
    }
</code>```

Body:
I'm doing a problem with recursive functions for a class project.  I'm trying to write a program that uses a recursive function that calculates a modulus without actually using the modulus operator.  I'm trying to use a reference parameter because I think that's the easiest way to do this, however my program is not functioning as intended.

//Michael Hery
//COP 2001
//11/15/2017
//Recursive Modulus

#include <iostream>
#include <iomanip>

using namespace std;

int recursiveMod(int &, int);

int main()
{
    int num;
    int den;
    int displayNum;
    int total;

    cout << "Please input the numerator (an integer) >> ";
    cin >> num;
    while (num < 0)
    {
        cout << "Integer must be greater than or equal to zero. >> ";
        cin >> num;
    }
    displayNum = num;
    cout << "Please input the denominator (an integer) >> ";
    cin >> den;
    while (den <= 0)
    {
        cout << "Integer must be greater than zero. >> ";
        cin >> den;
    }
    cout << "You have entered " << num << " % " << den << endl;

    total = recursiveMod(num, den);

    cout << "Modulus result: " << displayNum << " % " << den << " = " << total << endl;

    system("PAUSE");
    return 0;
}

int recursiveMod(int &num, int den)
{
    if (num == 0)
        return 0;

    num = num - den;

    if ((num - den) > den)
    {
        recursiveMod(num, den);
    }
    return num;
}

Body:
There are two errors with your code. Firstly you need to include cstdlib for system("pause") to work.

#include <cstdlib>

Secondly, in your

int recusive mod(int &num, int den)

the condition should be num > den and return must be put.

if (num > den)
    {
        return recursiveMod(num, den);
    }


问:
Routing query strings in Kohana3
I am trying to route the url http://host/order?servertype=1&plan=1 with the following entry in bootstrap.php

```<code>Route::set('order', 'order(/<action>)?servertype=<id1>&plan=<id2>', array('id1'=>'[0-9]+','id2'=>'[0-9]+'))
  ->defaults(array(
      'controller' => 'order',
      'action' => 'index',
  ));
</code>```

I am getting error:Unable to find a route to match the URI. What am I doing wrong?

答:
Kohana's routing system is not designed to work with the query string (and the same is true for most frameworks, I believe). If you really need to manipulate the query string in this way, then you'll have to move the logic out of Kohana and into an .htaccess file, using mod_rewrite.

However, the preferred way to perform routing is to use a hierarchical (path-style) URL structure and then use the query string for any information that cannot be represented hierarhically (which can then be accessed directly from the controller via $_GET).

This would mean using a URL structure like http://host/order/<id1>/<id2> and a routing scheme like:

```<code>Route::set('order', 'order(/<action>)/<id1>/<id2>', array('id1'=>'[0-9]+','id2'=>'[0-9]+'))
  ->defaults(array(
      'controller' => 'order',
      'action' => 'index',
  ));
</code>```

However, when using this type of URL structure, it's better to use more descriptive tokens in the URL than plain numeric IDs. So you might consider using "slugs" to identify your server types and plan types, which would give your more readable and SEO-friendlu URLs like http://host/order/server-type/plan.

Title: Routing query strings in Kohana3

Body:
I am trying to route the url http://host/order?servertype=1&plan=1 with the following entry in bootstrap.php

Route::set('order', 'order(/<action>)?servertype=<id1>&plan=<id2>', array('id1'=>'[0-9]+','id2'=>'[0-9]+'))
  ->defaults(array(
      'controller' => 'order',
      'action' => 'index',
  ));

I am getting error:Unable to find a route to match the URI. What am I doing wrong?

Body:
Kohana's routing system is not designed to work with the query string (and the same is true for most frameworks, I believe). If you really need to manipulate the query string in this way, then you'll have to move the logic out of Kohana and into an .htaccess file, using mod_rewrite.

However, the preferred way to perform routing is to use a hierarchical (path-style) URL structure and then use the query string for any information that cannot be represented hierarhically (which can then be accessed directly from the controller via $_GET).

This would mean using a URL structure like http://host/order/<id1>/<id2> and a routing scheme like:

Route::set('order', 'order(/<action>)/<id1>/<id2>', array('id1'=>'[0-9]+','id2'=>'[0-9]+'))
  ->defaults(array(
      'controller' => 'order',
      'action' => 'index',
  ));

However, when using this type of URL structure, it's better to use more descriptive tokens in the URL than plain numeric IDs. So you might consider using "slugs" to identify your server types and plan types, which would give your more readable and SEO-friendlu URLs like http://host/order/server-type/plan.


问:
Specify several commands with variable number of args for qmake target
in a Qt project using QMake I have a target with a custom command my_tool that can take any number of arguments:

```<code>target.commands = my_tool.exe arg01 arg02  # works fine
</code>```

If I now need to run that command twice ...

```<code>target.commands = my_tool.exe arg01 arg02
target.commands += my_tool.exe another_arg01 another_arg02  # breaks
</code>```

... for that target, the first command fails because the second command is used as arguments for the first. As in: when I output the arguments of the first command, it says:

```<code>ARGV[0]: my_tool.exe
ARGV[1]: arg01
ARGV[2]: arg02
ARGV[3]: my_tool.exe
ARGV[4]: another_arg01
ARGV[5]: another_arg02
</code>```

How would I add a second command so that it is treated separately?

Thank you for any help or pointers. :)

答:
Way 1

One possibility is to simply use two separate targets:

```<code>target1.commands = my_tool.exe arg01 arg02
target2.commands = my_tool.exe another_arg01 another_arg02
</code>```

... and make one depend on the other:

```<code>target1.depends = target2
</code>```

Way 2

Another way is to specify $$escape_expand(\n\t) or && between the commands:

```<code>target.commands = my_tool.exe arg01 arg02  $$escape_expand(\n\t)  my_tool.exe another_arg01 another_arg02

target.commands = my_tool.exe arg01 arg02  &&  my_tool.exe another_arg01 another_arg02
</code>```

So there's plenty of ways to chosse from. :)

Body:
in a Qt project using QMake I have a target with a custom command my_tool that can take any number of arguments:

target.commands = my_tool.exe arg01 arg02  # works fine

If I now need to run that command twice ...

target.commands = my_tool.exe arg01 arg02
target.commands += my_tool.exe another_arg01 another_arg02  # breaks

... for that target, the first command fails because the second command is used as arguments for the first. As in: when I output the arguments of the first command, it says:

ARGV[0]: my_tool.exe
ARGV[1]: arg01
ARGV[2]: arg02
ARGV[3]: my_tool.exe
ARGV[4]: another_arg01
ARGV[5]: another_arg02

How would I add a second command so that it is treated separately?

Thank you for any help or pointers. :)

Body:
Way 1

One possibility is to simply use two separate targets:

target1.commands = my_tool.exe arg01 arg02
target2.commands = my_tool.exe another_arg01 another_arg02

... and make one depend on the other:

target1.depends = target2

Way 2

Another way is to specify $$escape_expand(\n\t) or && between the commands:

target.commands = my_tool.exe arg01 arg02  $$escape_expand(\n\t)  my_tool.exe another_arg01 another_arg02

target.commands = my_tool.exe arg01 arg02  &&  my_tool.exe another_arg01 another_arg02

So there's plenty of ways to chosse from. :)


问:
TvOS - Invalid Bundle
I am trying to submit my tvOS app to the store but I am getting this error message:

Invalid Bundle - The app cannot be processed because options not
  allowed to be embedded in bitcode are detected in the submission. It
  is likely that you are not building the app with the toolchain
  provided in Xcode. Rebuild your entire app with the latest GM Xcode
  and submit the app again.

According to Apple documentation bitcode is required for tvOS apps:

For iOS apps, bitcode is the default, but optional. For watchOS and
  tvOS apps, bitcode is required. If you provide bitcode, all apps and
  frameworks in the app bundle (all targets in the project) need to
  include bitcode.

What should I do to submit my app?

答:
Yup every static lib and dynamic framework in your tvOS target needs to be bitcode enabled. You can verify if your static libs are bitcode enabled by running otool as shown below. If it is bitcode enabled, you ought to get a bunch of __LLVM segnames in your output. If you get no results, then in all probability that library is not bitcode enabled, and is the offending component.

```<code>dbox:lib oz$ otool -l libmDialogtvOSSmartStreamSDK.a | grep __LLVM
</code>```

Here's the output as this particular static lib is bitcode enabled:

```<code>segname __LLVM
segname __LLVM
segname __LLVM
</code>```

Title: TvOS - Invalid Bundle

Body:
Yup every static lib and dynamic framework in your tvOS target needs to be bitcode enabled. You can verify if your static libs are bitcode enabled by running otool as shown below. If it is bitcode enabled, you ought to get a bunch of __LLVM segnames in your output. If you get no results, then in all probability that library is not bitcode enabled, and is the offending component.

dbox:lib oz$ otool -l libmDialogtvOSSmartStreamSDK.a | grep __LLVM

Here's the output as this particular static lib is bitcode enabled:

segname __LLVM
segname __LLVM
segname __LLVM


问:
Run a list of String through a list of filters
I have List<String> and List<Filter>.

```<code>public interface Filter{
     List<String> filter(List<String> strToFilter);
}
</code>```

How can I pass the List<String> through the list of filters and use the output of one filter as an input to the other filter? I can do this using for-loop. I wanted to know how to achieve this using java 8 stream and lambda

答:
A "filter" is a Predicate, so just chain them up:

```<code>List<String> filter(List<String> strToFilter) {
    return strToFilter.stream()
        // these predicates are just examples
        .filter(s -> s.contains("foo"))
        .filter(s -> s.length() > 5)
        .collect(Collectors.toList());
}
</code>```

Body:
I have List<String> and List<Filter>.

public interface Filter{
     List<String> filter(List<String> strToFilter);
}

How can I pass the List<String> through the list of filters and use the output of one filter as an input to the other filter? I can do this using for-loop. I wanted to know how to achieve this using java 8 stream and lambda

Body:
A "filter" is a Predicate, so just chain them up:

List<String> filter(List<String> strToFilter) {
    return strToFilter.stream()
        // these predicates are just examples
        .filter(s -> s.contains("foo"))
        .filter(s -> s.length() > 5)
        .collect(Collectors.toList());
}