答:
var app = angular.module('confusionApp', []);

app.controller('dishDetailController', function($scope) {

  var dish = {
    name: 'Uthapizza',
    image: 'images/uthapizza.png',
    category: 'mains',
    label: 'Hot',
    price: '4.99',
    description: 'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
    comments: [{
        rating: 5,
        comment: "Imagine all the eatables, living in conFusion!",
        author: "John Lemon",
        date: "2012-10-16T17:57:28.556094Z"
      }, {
        rating: 4,
        comment: "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
        author: "Paul McVites",
        date: "2014-09-05T17:57:28.556094Z"
      }, {
        rating: 3,
        comment: "Eat it, just eat it!",
        author: "Michael Jaikishan",
        date: "2015-02-13T17:57:28.556094Z"
      }, {
        rating: 4,
        comment: "Ultimate, Reaching for the stars!",
        author: "Ringo Starry",
        date: "2013-12-02T17:57:28.556094Z"
      }, {
        rating: 2,
        comment: "It's your birthday, we're gonna party!",
        author: "25 Cent",
        date: "2011-12-02T17:57:28.556094Z"
      }

    ]
  };

  $scope.dish = dish;

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" ng-app='confusionApp'>
  <div class="row row-content" ng-controller="dishDetailController as dish">
    <div class="col-xs-12" >
      <ul class="media-list">
        <li class="media">
          <div class="media-left media-middle">

              <img class="media-object img-thumbnail" ng-src="dish.image" alt="Uthapizza">

          </div>
          <div class="media-body">
            <h2 class="media-heading">{{dish.name}}
                                        <span class="label label-danger">{{dish.label}}</span>
                                        <span class="badge">{{dish.price | currency}}</span>
                                    </h2>
            <p>{{dish.description}}</p>
          </div>
        </li>
      </ul>

</div>
    <div class="col-xs-9 col-xs-offset-1">
      <h3>Customer Comments</h3>

      <blockquote ng-repeat="com in dish.comments">
        <!--In this blockquote. -->
        {{ com.comment }}
        {{ com.rating }}
        {{ com.author }}
      </blockquote>
    </div>
  </div>

  </div></code>```

The issue you are facing is that the controller is not valid in the blockquote segment.

The div with ng-controller="dishDetailController as dish" is being closed before this particular div.
To overcome this, you can move the segment to the above div.

```<code><div class="row row-content" ng-controller="dishDetailController as dish">
.
.
.
  <blockquote ng-repeat="com in dish.comments">
    <!--In this blockquote. -->
    {{ com.comment }}
    {{ com.rating }}
    {{ com.author }}
  </blockquote>
</div>
</code>```

Here is a working code pen:
http://codepen.io/BoyWithSilverWings/pen/bqzaaK

Title: Insert controller data on html page

Body:
var app = angular.module('confusionApp', []);

app.controller('dishDetailController', function($scope) {

  var dish = {
    name: 'Uthapizza',
    image: 'images/uthapizza.png',
    category: 'mains',
    label: 'Hot',
    price: '4.99',
    description: 'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
    comments: [{
        rating: 5,
        comment: "Imagine all the eatables, living in conFusion!",
        author: "John Lemon",
        date: "2012-10-16T17:57:28.556094Z"
      }, {
        rating: 4,
        comment: "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
        author: "Paul McVites",
        date: "2014-09-05T17:57:28.556094Z"
      }, {
        rating: 3,
        comment: "Eat it, just eat it!",
        author: "Michael Jaikishan",
        date: "2015-02-13T17:57:28.556094Z"
      }, {
        rating: 4,
        comment: "Ultimate, Reaching for the stars!",
        author: "Ringo Starry",
        date: "2013-12-02T17:57:28.556094Z"
      }, {
        rating: 2,
        comment: "It's your birthday, we're gonna party!",
        author: "25 Cent",
        date: "2011-12-02T17:57:28.556094Z"
      }

    ]
  };

  $scope.dish = dish;

});

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" ng-app='confusionApp'>
  <div class="row row-content" ng-controller="dishDetailController as dish">
    <div class="col-xs-12" >
      <ul class="media-list">
        <li class="media">
          <div class="media-left media-middle">
            <a href="#">
              <img class="media-object img-thumbnail" ng-src="dish.image" alt="Uthapizza">
            </a>
          </div>
          <div class="media-body">
            <h2 class="media-heading">{{dish.name}}
                                        <span class="label label-danger">{{dish.label}}</span>
                                        <span class="badge">{{dish.price | currency}}</span>
                                    </h2>
            <p>{{dish.description}}</p>
          </div>
        </li>
      </ul>

</div>
    <div class="col-xs-9 col-xs-offset-1">
      <h3>Customer Comments</h3>

      <blockquote ng-repeat="com in dish.comments">
        <!--In this blockquote. -->
        {{ com.comment }}
        {{ com.rating }}
        {{ com.author }}
      </blockquote>
    </div>
  </div>

  </div>

The issue you are facing is that the controller is not valid in the blockquote segment.

The div with ng-controller="dishDetailController as dish" is being closed before this particular div.
To overcome this, you can move the segment to the above div.

<div class="row row-content" ng-controller="dishDetailController as dish">
.
.
.
  <blockquote ng-repeat="com in dish.comments">
    <!--In this blockquote. -->
    {{ com.comment }}
    {{ com.rating }}
    {{ com.author }}
  </blockquote>
</div>

Here is a working code pen:
http://codepen.io/BoyWithSilverWings/pen/bqzaaK


来源: stackexchange

问:
"$()" or `` is not properly expanding the linux command in shell script
My code snippet has an echo line as below:

```<code>echo "$(wc -l prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"
</code>```

Expected output:

```<code>1054721 provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG
</code>```

Output getting:

```<code>1054721 prov_bulk provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG
</code>```

Why the file name "prov_bulk" also shows up ? How to get rid of this ?

答:
By simply adding a < should solve your problem.  The redirection omits the filename.

```<code>echo "$(wc -l < prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"
</code>```

ContentLicense: CC BY-SA 3.0

Body:
My code snippet has an echo line as below:

echo "$(wc -l prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"

Expected output:

1054721 provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG

Output getting:

1054721 prov_bulk provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG

Why the file name "prov_bulk" also shows up ? How to get rid of this ?

Body:
By simply adding a < should solve your problem.  The redirection omits the filename.

echo "$(wc -l < prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"


问:
RabbitConnectionFactoryBean and CachingConnectionFactory
I can't find a mechanism in spring-rabbitMQ to use CachingConnectionFactory with SSL using RabbitConnectionFactoryBean  . what is the best way to provide SSL support for CachingConnectionFactory preferably using XML.</p>

答:
Simply wrap the results from the factory bean in a CachingConnectionFactory...

```<code><bean id="rabbitFactory" class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
    ...
</bean>

<rabbit:connection-factory id="connectionFactory" connection-factory="rabbitFactory" host="localhost" />
</code>```

The <rabbit/> namespace creates a CachingConnectionFactory or you can declare it as a <bean/> and inject the rabbit factory with a <constructor-arg/>.

Body:
Simply wrap the results from the factory bean in a CachingConnectionFactory...

<bean id="rabbitFactory" class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
    ...
</bean>

<rabbit:connection-factory id="connectionFactory" connection-factory="rabbitFactory" host="localhost" />

The <rabbit/> namespace creates a CachingConnectionFactory or you can declare it as a <bean/> and inject the rabbit factory with a <constructor-arg/>.


问:
PHP Largest Possible Integer Constant
Was reading the PHP manual on integer overflow in the manual and was wondering: is there a PHP pre-defined constant for the current largest integer value possible? Something equivalent to the JavaScript Number.MAX_VALUE constant.

答:
The PHP_INT_MAX contant contains the largest possible integer (in PHP 4.4.0/5.0.5 and newer).

On 32-bit system, this would normally be 2147483647 (2.1 * 109). On a 64-bit system, it would usually be 9223372036854775807 (9.2 * 1018).

ContentLicense: CC BY-SA 2.5

Title: PHP Largest Possible Integer Constant


问:
Unable to filter data per user's inputs using eventReactive() function in Shiny
I'm building my first app in Shiny and I've been meaning to get a better idea about reactivity. I have gone through the tutorials on http://shiny.rstudio.com/tutorial/. I'm working on a tennis-related dataset and wanting to create a radarchart using the package 'radarchart'. I'm able to render the radio buttons and select input box successfully using reactive expressions.

However, upon clicking the 'Go!' button, the console shows the following error: "Error in filter_impl: incorrect length (0), expecting: 27". No error shows up in the app itself though, there's just no rendering on clicking the 'Go!' button.

Upon debugging, I see that this error occurs when I'm trying to filter data using the user's selection of input values(lines 60-63 in server.R). My main concern is filtering the data as per the user's selection, I'm unable to do that in any way. I've tried to use eventReactive(), observe() as well as reactiveValues() functions too without any success. I've wrapped the renderChartJSRadar function within the eventReactive function, but I'm not quite sure if that's the right way to go about it.

I'm confused as to how the reactivity in this case should work and what I'm missing to make it work. The code is as shown below. I'd really appreciate any kind of help.

ui.R

```<code>library(xlsx)
library(shiny)
library(dplyr)
source("chart.R")
library(radarchart)

shinyUI(fluidPage(

          titlePanel("Match Radar Chart"),

          sidebarLayout(
            sidebarPanel(
              selectInput("var",
                         label = "Choose a tournament",
                         choices = tour,
                         selected = "Auckland"),

              uiOutput("radioButtons"),
              uiOutput("selectControls"),
              actionButton("update", "Go!")
              ),

              mainPanel(
                 chartJSRadarOutput("radarChart", width = "450", height = "300")
              )
        )
 ))
</code>```

server.R

```<code>library(xlsx)
library(dplyr)
library(radarchart)
library(data.table)
source("chart.R")
library(shiny)
library(grDevices)

shinyServer(function(input, output, session) {

    output$radioButtons <- renderUI({
               dataInput <- reactive({input$var})
               z <- dataInput()
               buttons <- numrounds(z)
               radioButtons("button", "Select a round: ", choices = buttons, inline = FALSE)
      })

    output$selectControls <- renderUI({
               dataInput <- reactive({input$var})
               z <- dataInput()
               dataInput1 <- reactive({input$button})
               y <- dataInput1()
               winner <- mydata %>%
                      filter(tourney_name == z) %>%
                      filter(round == y) %>%
                      select(winner_name) %>%
                      sapply(as.character) %>%
                      as.vector()

               loser <- mydata %>%
                      filter(tourney_name == z) %>%
                      filter(round == y) %>%
                      select(loser_name) %>%
                      sapply(as.character) %>%
                      as.vector()

               players <- c(winner, loser)

               selectInput("select", "Select a match: ", choices = players, selected = 1, multiple = FALSE)

     })

          output$radarChart <- eventReactive(input$update, {
          renderChartJSRadar({
          dataInput1 <- reactive({input$var})
          z <- dataInput1()
          dataInput2 <- reactive({input$button})
          y <- dataInput2()
          dataInput3 <- reactive({input$select})
          x <- dataInput3()
          match <- mydata %>%
              filter(tourney_name == z) %>%
              filter(round == y) %>%
              filter(winner_name == x)

          scoresw <- vector()
          scoresl <- vector()
          for(j in 25:33) {
                  scoresw <- c(scoresw, match()[j])
          }
          for(j in 34:42) {
                  scoresl <- c(scoresl, match()[j])
          }

          scores <- list(winner = scoresw, loser = scoresl)
          labs <- c("Aces", "Double Faults", "Service points", "1st Service In", "1st Service won", "2nd Service won", "Service games", "Break points saved", "Break points faced")
          c <- grDevices::col2rgb(c("green", "red"))

          chartJSRadar(scores = scores, labs = labs, labelSize = 15, colMatrix = c)
     })
  })

 })
</code>```

chart.R

```<code>mydata <- read.csv("Match Radar/Data/atp_matches_2014_edited.csv", header = TRUE)
tour <- unique(data$tourney_name)

 numrounds <- function(z) {
   for(i in 1:64) {
     rounds <- mydata %>%
       filter(tourney_name == z) %>%
       summarise(number = n_distinct(round))

     if(rounds == 3){
         buttons <- c("RR", "SF", "F")
     }
     else if(rounds == 5){
         buttons <- c("R32", "R16", "QF", "SF", "F")
     }
     else if(rounds == 6){
         buttons <- c("R64", "R32", "R16", "QF", "SF", "F")
     }
     else {
         buttons <- c("R128", "R64", "R32", "R16", "QF", "SF", "F")
     }
   }
   buttons
}
</code>```

答:
I put your app in a single file for debugging simplicity.

The menus display correctly: the shiny part should work.  The basic idea is that the input variables are already reactive, so to build a reactive function out of them is redundant (at least in this case).

In renderChartJSRadar z,y and x are initialised correctly (once the initial, NULL cases are discarded). Also renderChartJSRadar is already reactive, but as it is "eagerly reactive" it starts when the other values are not set, hence the filtering for NULL.

In renderChartJSRadar there is debugging to do in the R logic that calculate the score.  Currently there is an error: unfortunately I cannot help as I cannot tell what you want to achieve - and I don't play tennis :)

```<code>library(xlsx)
library(dplyr)
library(radarchart)
# library(data.table)
# source("chart.R")
library(shiny)
library(grDevices)

#------------------------------------------------------------------------------

mydata <- read.csv("./data/atp_matches_2014.csv", header = TRUE)
tour <- unique(mydata$tourney_name)

numrounds <- function(z) {
  for(i in 1:64) {
    rounds <- mydata %>%
      filter(tourney_name == z) %>%
      summarise(number = n_distinct(round))

    if(rounds == 3){
      buttons <- c("RR", "SF", "F")
    }
    else if(rounds == 5){
      buttons <- c("R32", "R16", "QF", "SF", "F")
    }
    else if(rounds == 6){
      buttons <- c("R64", "R32", "R16", "QF", "SF", "F")
    }
    else {
      buttons <- c("R128", "R64", "R32", "R16", "QF", "SF", "F")
    }
  }
  return(buttons)
}

#------------------------------------------------------------------------------

ui <- fluidPage(

  titlePanel("Match Radar Chart"),

  sidebarLayout(
    sidebarPanel(
      selectInput("var",
                  label = "Choose a tournament",
                  choices = tour,
                  selected = "Auckland"),

      uiOutput("radioButtons"),
      uiOutput("selectControls"),
      actionButton("update", "Go!")
    ),

    mainPanel(
      chartJSRadarOutput("radarChart", width = "450", height = "300")
    )
  )
)

#------------------------------------------------------------------------------

server <-  function(input, output, session){
  session$onSessionEnded({  stopApp  })

  output$radioButtons <- renderUI({
    # dataInput <- reactive({input$var})

    z <- input$var
    buttons <- numrounds(z)
    radioButtons("button", "Select a round: ", choices = buttons, inline = FALSE)
  })

  output$selectControls <- renderUI({

    # dataInput <- reactive({input$var})
    z <- input$var
    # dataInput1 <- reactive({input$button})
    y <- input$button #dataInput1()
    winner <- mydata %>%
      filter(tourney_name == z) %>%
      filter(round == y) %>%
      select(winner_name) %>%
      sapply(as.character) %>%
      as.vector()

    loser <- mydata %>%
      filter(tourney_name == z) %>%
      filter(round == y) %>%
      select(loser_name) %>%
      sapply(as.character) %>%
      as.vector()

    players <- c(winner, loser)

    selectInput("select", "Select a match: ", choices = players, selected = 1, multiple = FALSE)

  })

  output$radarChart <- renderChartJSRadar({
    # browser()
      if(is.null(input$button )) return()
      if(is.null(input$select )) return()
      # dataInput1 <- reactive({input$var})
      z <- input$var # dataInput1()
      # dataInput2 <- reactive({input$button})
      y <- input$button # dataInput2()
      # dataInput3 <- reactive({input$select})
      x <- input$select # dataInput3()
      match <- mydata %>%
        filter(tourney_name == z) %>%
        filter(round == y) %>%
        filter(winner_name == x)

      scoresw <- vector()
      scoresl <- vector()
      for(j in 25:33) {
        scoresw <- c(scoresw, match()[j])
      }
      for(j in 34:42) {
        scoresl <- c(scoresl, match()[j])
      }

      scores <- list(winner = scoresw, loser = scoresl)
      labs <- c("Aces", "Double Faults", "Service points", "1st Service In", "1st Service won", "2nd Service won", "Service games", "Break points saved", "Break points faced")
      c <- grDevices::col2rgb(c("green", "red"))

      chartJSRadar(scores = scores, labs = labs, labelSize = 15, colMatrix = c)

  })

}
#------------------------------------------------------------------------------

shinyApp(ui, server)
</code>```

As far as preventing the radar chart to be drawn every time the user changes one of the three inputs, this is possible using isolate.

For example (code not tested, but it should work :) )

```<code>output$radarChart <- renderChartJSRadar({
      if(is.null(input$button )) return()
      isolate({
           if(is.null(input$select )) return()
           z <- input$var # dataInput1()
           y <- input$button # dataInput2()
           x <- input$select # dataInput3()
      })
</code>```

Or something very similar.  Take for example input$var.  As it is within isolate, any change by the user will not trigger the execution of renderChartJSRadar. In the code above only changes to input$button trigger the execution of renderChartJSRadar.

Body:
I'm building my first app in Shiny and I've been meaning to get a better idea about reactivity. I have gone through the tutorials on http://shiny.rstudio.com/tutorial/. I'm working on a tennis-related dataset and wanting to create a radarchart using the package 'radarchart'. I'm able to render the radio buttons and select input box successfully using reactive expressions.

However, upon clicking the 'Go!' button, the console shows the following error: "Error in filter_impl: incorrect length (0), expecting: 27". No error shows up in the app itself though, there's just no rendering on clicking the 'Go!' button.

Upon debugging, I see that this error occurs when I'm trying to filter data using the user's selection of input values(lines 60-63 in server.R). My main concern is filtering the data as per the user's selection, I'm unable to do that in any way. I've tried to use eventReactive(), observe() as well as reactiveValues() functions too without any success. I've wrapped the renderChartJSRadar function within the eventReactive function, but I'm not quite sure if that's the right way to go about it.

I'm confused as to how the reactivity in this case should work and what I'm missing to make it work. The code is as shown below. I'd really appreciate any kind of help.

ui.R

library(xlsx)
library(shiny)
library(dplyr)
source("chart.R")
library(radarchart)

shinyUI(fluidPage(

          titlePanel("Match Radar Chart"),

          sidebarLayout(
            sidebarPanel(
              selectInput("var",
                         label = "Choose a tournament",
                         choices = tour,
                         selected = "Auckland"),

              uiOutput("radioButtons"),
              uiOutput("selectControls"),
              actionButton("update", "Go!")
              ),

              mainPanel(
                 chartJSRadarOutput("radarChart", width = "450", height = "300")
              )
        )
 ))

server.R

library(xlsx)
library(dplyr)
library(radarchart)
library(data.table)
source("chart.R")
library(shiny)
library(grDevices)

shinyServer(function(input, output, session) {

    output$radioButtons <- renderUI({
               dataInput <- reactive({input$var})
               z <- dataInput()
               buttons <- numrounds(z)
               radioButtons("button", "Select a round: ", choices = buttons, inline = FALSE)
      })

    output$selectControls <- renderUI({
               dataInput <- reactive({input$var})
               z <- dataInput()
               dataInput1 <- reactive({input$button})
               y <- dataInput1()
               winner <- mydata %>%
                      filter(tourney_name == z) %>%
                      filter(round == y) %>%
                      select(winner_name) %>%
                      sapply(as.character) %>%
                      as.vector()

               loser <- mydata %>%
                      filter(tourney_name == z) %>%
                      filter(round == y) %>%
                      select(loser_name) %>%
                      sapply(as.character) %>%
                      as.vector()

               players <- c(winner, loser)

               selectInput("select", "Select a match: ", choices = players, selected = 1, multiple = FALSE)

     })

          output$radarChart <- eventReactive(input$update, {
          renderChartJSRadar({
          dataInput1 <- reactive({input$var})
          z <- dataInput1()
          dataInput2 <- reactive({input$button})
          y <- dataInput2()
          dataInput3 <- reactive({input$select})
          x <- dataInput3()
          match <- mydata %>%
              filter(tourney_name == z) %>%
              filter(round == y) %>%
              filter(winner_name == x)

          scoresw <- vector()
          scoresl <- vector()
          for(j in 25:33) {
                  scoresw <- c(scoresw, match()[j])
          }
          for(j in 34:42) {
                  scoresl <- c(scoresl, match()[j])
          }

          scores <- list(winner = scoresw, loser = scoresl)
          labs <- c("Aces", "Double Faults", "Service points", "1st Service In", "1st Service won", "2nd Service won", "Service games", "Break points saved", "Break points faced")
          c <- grDevices::col2rgb(c("green", "red"))

          chartJSRadar(scores = scores, labs = labs, labelSize = 15, colMatrix = c)
     })
  })

 })

chart.R

mydata <- read.csv("Match Radar/Data/atp_matches_2014_edited.csv", header = TRUE)
tour <- unique(data$tourney_name)

 numrounds <- function(z) {
   for(i in 1:64) {
     rounds <- mydata %>%
       filter(tourney_name == z) %>%
       summarise(number = n_distinct(round))

     if(rounds == 3){
         buttons <- c("RR", "SF", "F")
     }
     else if(rounds == 5){
         buttons <- c("R32", "R16", "QF", "SF", "F")
     }
     else if(rounds == 6){
         buttons <- c("R64", "R32", "R16", "QF", "SF", "F")
     }
     else {
         buttons <- c("R128", "R64", "R32", "R16", "QF", "SF", "F")
     }
   }
   buttons
}

Body:
I put your app in a single file for debugging simplicity.

The menus display correctly: the shiny part should work.  The basic idea is that the input variables are already reactive, so to build a reactive function out of them is redundant (at least in this case).

In renderChartJSRadar z,y and x are initialised correctly (once the initial, NULL cases are discarded). Also renderChartJSRadar is already reactive, but as it is "eagerly reactive" it starts when the other values are not set, hence the filtering for NULL.

In renderChartJSRadar there is debugging to do in the R logic that calculate the score.  Currently there is an error: unfortunately I cannot help as I cannot tell what you want to achieve - and I don't play tennis :)

library(xlsx)
library(dplyr)
library(radarchart)
# library(data.table)
# source("chart.R")
library(shiny)
library(grDevices)

#------------------------------------------------------------------------------

mydata <- read.csv("./data/atp_matches_2014.csv", header = TRUE)
tour <- unique(mydata$tourney_name)

numrounds <- function(z) {
  for(i in 1:64) {
    rounds <- mydata %>%
      filter(tourney_name == z) %>%
      summarise(number = n_distinct(round))

    if(rounds == 3){
      buttons <- c("RR", "SF", "F")
    }
    else if(rounds == 5){
      buttons <- c("R32", "R16", "QF", "SF", "F")
    }
    else if(rounds == 6){
      buttons <- c("R64", "R32", "R16", "QF", "SF", "F")
    }
    else {
      buttons <- c("R128", "R64", "R32", "R16", "QF", "SF", "F")
    }
  }
  return(buttons)
}

#------------------------------------------------------------------------------

ui <- fluidPage(

  titlePanel("Match Radar Chart"),

  sidebarLayout(
    sidebarPanel(
      selectInput("var",
                  label = "Choose a tournament",
                  choices = tour,
                  selected = "Auckland"),

      uiOutput("radioButtons"),
      uiOutput("selectControls"),
      actionButton("update", "Go!")
    ),

    mainPanel(
      chartJSRadarOutput("radarChart", width = "450", height = "300")
    )
  )
)

#------------------------------------------------------------------------------

server <-  function(input, output, session){
  session$onSessionEnded({  stopApp  })

  output$radioButtons <- renderUI({
    # dataInput <- reactive({input$var})

    z <- input$var
    buttons <- numrounds(z)
    radioButtons("button", "Select a round: ", choices = buttons, inline = FALSE)
  })

  output$selectControls <- renderUI({

    # dataInput <- reactive({input$var})
    z <- input$var
    # dataInput1 <- reactive({input$button})
    y <- input$button #dataInput1()
    winner <- mydata %>%
      filter(tourney_name == z) %>%
      filter(round == y) %>%
      select(winner_name) %>%
      sapply(as.character) %>%
      as.vector()

    loser <- mydata %>%
      filter(tourney_name == z) %>%
      filter(round == y) %>%
      select(loser_name) %>%
      sapply(as.character) %>%
      as.vector()

    players <- c(winner, loser)

    selectInput("select", "Select a match: ", choices = players, selected = 1, multiple = FALSE)

  })

  output$radarChart <- renderChartJSRadar({
    # browser()
      if(is.null(input$button )) return()
      if(is.null(input$select )) return()
      # dataInput1 <- reactive({input$var})
      z <- input$var # dataInput1()
      # dataInput2 <- reactive({input$button})
      y <- input$button # dataInput2()
      # dataInput3 <- reactive({input$select})
      x <- input$select # dataInput3()
      match <- mydata %>%
        filter(tourney_name == z) %>%
        filter(round == y) %>%
        filter(winner_name == x)

      scoresw <- vector()
      scoresl <- vector()
      for(j in 25:33) {
        scoresw <- c(scoresw, match()[j])
      }
      for(j in 34:42) {
        scoresl <- c(scoresl, match()[j])
      }

      scores <- list(winner = scoresw, loser = scoresl)
      labs <- c("Aces", "Double Faults", "Service points", "1st Service In", "1st Service won", "2nd Service won", "Service games", "Break points saved", "Break points faced")
      c <- grDevices::col2rgb(c("green", "red"))

      chartJSRadar(scores = scores, labs = labs, labelSize = 15, colMatrix = c)

  })

}
#------------------------------------------------------------------------------

shinyApp(ui, server)

As far as preventing the radar chart to be drawn every time the user changes one of the three inputs, this is possible using isolate.

For example (code not tested, but it should work :) )

output$radarChart <- renderChartJSRadar({
      if(is.null(input$button )) return()
      isolate({
           if(is.null(input$select )) return()
           z <- input$var # dataInput1()
           y <- input$button # dataInput2()
           x <- input$select # dataInput3()
      })

Or something very similar.  Take for example input$var.  As it is within isolate, any change by the user will not trigger the execution of renderChartJSRadar. In the code above only changes to input$button trigger the execution of renderChartJSRadar.


问:
Bootstrap modal goes away immediately after appearing
I am using following jQuery code to trigger the button to show bootstrap modal.
NOTE: i am using same jQuery code to trigger same modal on another page too and its working fine on that page. and i am only using bootstrap.js not bootstrap-modal.js, what could be the possible problem?

```<code> <script>

$(function(ready){
    $(".paypal1_form").submit(function( event ) {
        console.log('here');
      $('button.modal2').click();
      setTimeout(function() {
       return true;
       event.preventDefault();
      }, 2000);

    });
});
</script>
</code>```

Following is the code for bootstrap modal

```<code><button style="display:none;" type="button" class="btn btn-info btn-lg modal2" data-toggle="modal" data-target="#RedirectModal">Open Modal</button>

    <div id="RedirectModal" class="modal fade" role="dialog">
      <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
        <div class="modal-header">
            <p style="float:right;color:white;font-size:14px;margin-top:-12px;" class="close" data-dismiss="modal">X</p>
            <!--<h4 class="modal-title">Modal Header</h4>-->
          </div>
          <div class="modal-body">
            <h3 style="color:white;">We are now redirecting you to Paypal...</h3>

         </div>
          <div class="modal-footer">
            <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
          </div>
        </div>

      </div>
    </div>
</code>```

答: It worked when i put the jQuery code at the end of HTML code.</p>

Body:
I am using following jQuery code to trigger the button to show bootstrap modal.
NOTE: i am using same jQuery code to trigger same modal on another page too and its working fine on that page. and i am only using bootstrap.js not bootstrap-modal.js, what could be the possible problem?

Following is the code for bootstrap modal

<button style="display:none;" type="button" class="btn btn-info btn-lg modal2" data-toggle="modal" data-target="#RedirectModal">Open Modal</button>

X

We are now redirecting you to Paypal...


问:
Bootstrap 4 navbar - no height on mobile
How to set the bootstrap 4 navbar height in all viewport to 80px ?

I tried "min-height: 80px" in ".navbar" but the navbar is broken.

The sass code:

```<code>$navbar-bg:             #26f3fd;
$navbar-height:         80px;

.navbar {
    background-color: $navbar-bg;
    min-height: $navbar-height;
}
</code>```

The html code:

```<code><nav class="navbar navbar-toggleable-md navbar-light bg-faded" id="main-navbar" data-toggle="sticky-onscroll">
    <button class="navbar-toggler navbar-toggler-left" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse justify-content-md-center" id="navbar-content">
    <ul class="navbar-nav">
        <li class="nav-item active">
            <a class="nav-link" href="<?= esc_url(home_url('/')); ?>">Accueil</a>
        </li>
    </ul>
</div>
</code>```

http://codepen.io/juavenel/pen/xqMPrQ/

答:
The issue is because your navbar doesn't contain a navbar-brand so it's height collapses when the navbar stacks vertically.

This is a known issue that will be fixed in the beta release: https://github.com/twbs/bootstrap/pull/22230

The workaround is to include an empty placehold navbar-text or navbar-brand..

```<code><nav class="navbar navbar-toggleable-md navbar-light bg-faded py-3" id="main-navbar">
    <button class="navbar-toggler navbar-toggler-left" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <span class="navbar-text"> </span>
    <div class="collapse navbar-collapse justify-content-md-center" id="navbar-content">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Accueil</a>
        </li>
      </ul>
    </div>
</nav>
</code>```

http://www.codeply.com/go/FIKesgfDhL

Also, you can use vertical padding (py-3) instead to increase the height of the navbar and keep items vertically centered.

Body:
How to set the bootstrap 4 navbar height in all viewport to 80px ?

I tried "min-height: 80px" in ".navbar" but the navbar is broken.

The sass code:

$navbar-bg:             #26f3fd;
$navbar-height:         80px;

.navbar {
    background-color: $navbar-bg;
    min-height: $navbar-height;
}

The html code:

    <button class="navbar-toggler navbar-toggler-left" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="Toggle navigation">

    </button>

            <a class="nav-link" href="<?= esc_url(home_url('/')); ?>">Accueil

http://codepen.io/juavenel/pen/xqMPrQ/

Body:
The issue is because your navbar doesn't contain a navbar-brand so it's height collapses when the navbar stacks vertically.

This is a known issue that will be fixed in the beta release: https://github.com/twbs/bootstrap/pull/22230

The workaround is to include an empty placehold navbar-text or navbar-brand..

<nav class="navbar navbar-toggleable-md navbar-light bg-faded py-3" id="main-navbar">
    <button class="navbar-toggler navbar-toggler-left" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <span class="navbar-text">&nbsp;</span>
    <div class="collapse navbar-collapse justify-content-md-center" id="navbar-content">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Accueil</a>
        </li>
      </ul>
    </div>
</nav>

http://www.codeply.com/go/FIKesgfDhL

Also, you can use vertical padding (py-3) instead to increase the height of the navbar and keep items vertically centered.


问:
color percentage in image python opencv using histogram
I am beginner in python and image processing. I want to find the percentage of brown color from an image using histogram function.

I did the histogram function but I do not know how to find the percentage of the brown color in the image.

this is my python code

```<code>import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('C:\Users\MainUser\Desktop\histogram\dates.jpg', -1)
cv2.imshow('GoldenGate',img)

color = ('b','g','r')
for channel,col in enumerate(color):
    histr = cv2.calcHist([img],[channel],None,[256],[0,256])
    plt.plot(histr,color = col)
    plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()

while True:
    k = cv2.waitKey(0) & 0xFF
    if k == 27: break             # ESC key to exit
cv2.destroyAllWindows()
</code>```

the image that I use

I have this output of the code

答:
```<code>import numpy as np
import cv2

img = cv2.imread('J9MbW.jpg')

brown = [145, 80, 40]  # RGB
diff = 20
boundaries = [([brown[2]-diff, brown[1]-diff, brown[0]-diff],
               [brown[2]+diff, brown[1]+diff, brown[0]+diff])]
# in order BGR as opencv represents images as numpy arrays in reverse order

for (lower, upper) in boundaries:
    lower = np.array(lower, dtype=np.uint8)
    upper = np.array(upper, dtype=np.uint8)
    mask = cv2.inRange(img, lower, upper)
    output = cv2.bitwise_and(img, img, mask=mask)

    ratio_brown = cv2.countNonZero(mask)/(img.size/3)
    print('brown pixel percentage:', np.round(ratio_brown*100, 2))

    cv2.imshow("images", np.hstack([img, output]))
    cv2.waitKey(0)
</code>```

This should work for you. However, note that it is highly dependent on your RGB value of brown as well as your desired tolerance (diff).

If you have further questions on the details of the above code, feel free to ask.

Body:
I am beginner in python and image processing. I want to find the percentage of brown color from an image using histogram function.

I did the histogram function but I do not know how to find the percentage of the brown color in the image.

this is my python code

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('C:\Users\MainUser\Desktop\histogram\dates.jpg', -1)
cv2.imshow('GoldenGate',img)

color = ('b','g','r')
for channel,col in enumerate(color):
    histr = cv2.calcHist([img],[channel],None,[256],[0,256])
    plt.plot(histr,color = col)
    plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()

while True:
    k = cv2.waitKey(0) & 0xFF
    if k == 27: break             # ESC key to exit
cv2.destroyAllWindows()

the image that I use

I have this output of the code

Body:
import numpy as np
import cv2

img = cv2.imread('J9MbW.jpg')

brown = [145, 80, 40]  # RGB
diff = 20
boundaries = [([brown[2]-diff, brown[1]-diff, brown[0]-diff],
               [brown[2]+diff, brown[1]+diff, brown[0]+diff])]
# in order BGR as opencv represents images as numpy arrays in reverse order

for (lower, upper) in boundaries:
    lower = np.array(lower, dtype=np.uint8)
    upper = np.array(upper, dtype=np.uint8)
    mask = cv2.inRange(img, lower, upper)
    output = cv2.bitwise_and(img, img, mask=mask)

    ratio_brown = cv2.countNonZero(mask)/(img.size/3)
    print('brown pixel percentage:', np.round(ratio_brown*100, 2))

    cv2.imshow("images", np.hstack([img, output]))
    cv2.waitKey(0)

This should work for you. However, note that it is highly dependent on your RGB value of brown as well as your desired tolerance (diff).

If you have further questions on the details of the above code, feel free to ask.


问:
Using Imagemagick to convert PDFs having rasters in them results in white backgrounds behind the sections covered by the rasters
I tried to use ImageMagick (v6.8.9-9 Q16) to convert a PDF containing a PNG file embedded in it to a PNG file.

The original PNG file had a transparent background. In the PDF too it appears fine. But in the PNG obtained after conversion, the area originally occupied by the PNG in the PDF has a white background. Please see the links for more clarity.

The command I ran is as follows:

convert -colorspace sRGB dice.pdf converted_dice.png

I also tried setting the -transparent white switch but it ends up taking out whites that were actually required in the final image.

Are there any extra switches or parameters to pass to convert in order to get rid of just this white background?

答:
Kurt already explains the whole thing in great detail. So here is just how to assemble an image with ImageMagick after running it through pdfimages -png

```<code>pdfimages -png my.pdf my
</code>```

This resluts in two files

```<code>identify my-0*png
  my-000.png PNG 360x310 360x310+0+0 8-bit sRGB 256c 3.3KB 0.000u 0:00.000
  my-001.png PNG 360x310 360x310+0+0 8-bit sRGB 256c 9.44KB 0.000u 0:00.000
</code>```

my-001.png is the image labeled smask in pdfimages -list. To reassemble the image back to it's original form use -compose CopyOpacity with the ImageMagick command composite

```<code>composite -compose CopyOpacity my-001.png my-000.png my-reassembled.png
</code>```

See also http://www.imagemagick.org/Usage/masking/#masks for more information.

Body:
Kurt already explains the whole thing in great detail. So here is just how to assemble an image with ImageMagick after running it through pdfimages -png

pdfimages -png my.pdf my

This resluts in two files

identify my-0*png
  my-000.png PNG 360x310 360x310+0+0 8-bit sRGB 256c 3.3KB 0.000u 0:00.000
  my-001.png PNG 360x310 360x310+0+0 8-bit sRGB 256c 9.44KB 0.000u 0:00.000

my-001.png is the image labeled smask in pdfimages -list. To reassemble the image back to it's original form use -compose CopyOpacity with the ImageMagick command composite

composite -compose CopyOpacity my-001.png my-000.png my-reassembled.png

See also http://www.imagemagick.org/Usage/masking/#masks for more information.


问:
Insert controller data on html page
I'm trying to use ng-repeat to print a set of comments from the dishDetailController in blockquote. I've tried but I do not know how to do this. Any help would be appreciated, thanks. Here is the code. </p>

<p>
                </p>

```<code>            <head>
                <meta charset="utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                <!-- The above 3 meta tags *must* come first in the head; any other head
                     content must come *after* these tags -->
                <title>Ristorante Con Fusion: Menu</title>
                <!-- Bootstrap -->
                <link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
                <link href="../bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet">
                <link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
                <link href="styles/bootstrap-social.css" rel="stylesheet">
                <link href="styles/mystyles.css" rel="stylesheet">

                <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
                <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
                <!--[if lt IE 9]>
                <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
                <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
                <![endif]-->
            </head>

            <body>

            <div class="container">
                <div class="row row-content">
                    <div class="col-xs-12" ng-controller="dishDetailController as dish">
                        <ul class="media-list">
                            <li class="media">
                                <div class="media-left media-middle">
                                    <a href="#">
                                        <img class="media-object img-thumbnail"
                                             ng-src="{{dish.image}}" alt="Uthapizza">
                                    </a>
                                </div>
                                <div class="media-body">
                                    <h2 class="media-heading">{{dish.name}}
                                        <span class="label label-danger">{{dish.label}}</span>
                                        <span class="badge">{{dish.price | currency}}</span>
                                    </h2>
                                    <p>{{dish.description}}</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="col-xs-9 col-xs-offset-1">
                        <h3>Customer Comments</h3>
                        <blockquote>
                            <!--In this blockquote. -->
                        </blockquote>
                    </div>
                </div>

            </div>

            <script src="../bower_components/angular/angular.min.js"></script>
            <script>

                var app = angular.module('confusionApp', []);

                app.controller('dishDetailController', function ($scope) {

                    var dish = {
                        name: 'Uthapizza',
                        image: 'images/uthapizza.png',
                        category: 'mains',
                        label: 'Hot',
                        price: '4.99',
                        description: 'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
                        comments: [
                            {
                                rating: 5,
                                comment: "Imagine all the eatables, living in conFusion!",
                                author: "John Lemon",
                                date: "2012-10-16T17:57:28.556094Z"
                            },
                            {
                                rating: 4,
                                comment: "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
                                author: "Paul McVites",
                                date: "2014-09-05T17:57:28.556094Z"
                            },
                            {
                                rating: 3,
                                comment: "Eat it, just eat it!",
                                author: "Michael Jaikishan",
                                date: "2015-02-13T17:57:28.556094Z"
                            },
                            {
                                rating: 4,
                                comment: "Ultimate, Reaching for the stars!",
                                author: "Ringo Starry",
                                date: "2013-12-02T17:57:28.556094Z"
                            },
                            {
                                rating: 2,
                                comment: "It's your birthday, we're gonna party!",
                                author: "25 Cent",
                                date: "2011-12-02T17:57:28.556094Z"
                            }

                        ]
                    };

                    $scope.dish = dish;

                });

            </script>

            </body>

            </html>
</code>```

答:
First you should be assigning your ng-app and ng-controller to the parent container which will wrap your blockquote items, since it will not work from your current setup, and from your markup, I can't see any ng-app as well.

See below:

var app = angular.module("confusionApp", []);
app.controller("dishDetailController", function ($scope) {
                    var dish = {
                        name: 'Uthapizza',
                        image: 'images/uthapizza.png',
                        category: 'mains',
                        label: 'Hot',
                        price: '4.99',
                        description: 'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
                        comments: [
                            {
                                rating: 5,
                                comment: "Imagine all the eatables, living in conFusion!",
                                author: "John Lemon",
                                date: "2012-10-16T17:57:28.556094Z"
                            },
                            {
                                rating: 4,
                                comment: "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
                                author: "Paul McVites",
                                date: "2014-09-05T17:57:28.556094Z"
                            },
                            {
                                rating: 3,
                                comment: "Eat it, just eat it!",
                                author: "Michael Jaikishan",
                                date: "2015-02-13T17:57:28.556094Z"
                            },
                            {
                                rating: 4,
                                comment: "Ultimate, Reaching for the stars!",
                                author: "Ringo Starry",
                                date: "2013-12-02T17:57:28.556094Z"
                            },
                            {
                                rating: 2,
                                comment: "It's your birthday, we're gonna party!",
                                author: "25 Cent",
                                date: "2011-12-02T17:57:28.556094Z"
                            }

                        ]
                    };

                    $scope.dish = dish;

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="container" ng-controller="dishDetailController" ng-app="confusionApp">
                <div class="row row-content">
                    <div class="col-xs-12">
                        <ul class="media-list">
                            <li class="media">
                                <div class="media-left media-middle">

                                        <img class="media-object img-thumbnail"
                                             ng-src="{{dish.image}}" alt="Uthapizza">

                                </div>
                                <div class="media-body">
                                    <h2 class="media-heading">{{dish.name}}
                                        <span class="label label-danger">{{dish.label}}</span>
                                        <span class="badge">{{dish.price | currency}}</span>
                                    </h2>
                                    <p>{{dish.description}}</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="col-xs-9 col-xs-offset-1">
                        <h3>Customer Comments</h3>
                        <blockquote ng-repeat="item in dish.comments">
                            {{item}}
                        </blockquote>
                    </div>
                </div>

            </div></code>```

Title: Insert controller data on html page

Body:
I'm trying to use ng-repeat to print a set of comments from the dishDetailController in blockquote. I've tried but I do not know how to do this. Any help would be appreciated, thanks. Here is the code.

                <meta charset="utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1">

                <title>Ristorante Con Fusion: Menu</title>

                <link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
                <link href="../bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet">
                <link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
                <link href="styles/bootstrap-social.css" rel="stylesheet">
                <link href="styles/mystyles.css" rel="stylesheet">

{{dish.name}}
                                        {{dish.label}}
                                        {{dish.price | currency}}

{{dish.description}}

Customer Comments

Body:
First you should be assigning your ng-app and ng-controller to the parent container which will wrap your blockquote items, since it will not work from your current setup, and from your markup, I can't see any ng-app as well.

See below:

var app = angular.module("confusionApp", []);
app.controller("dishDetailController", function ($scope) {
                    var dish = {
                        name: 'Uthapizza',
                        image: 'images/uthapizza.png',
                        category: 'mains',
                        label: 'Hot',
                        price: '4.99',
                        description: 'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
                        comments: [
                            {
                                rating: 5,
                                comment: "Imagine all the eatables, living in conFusion!",
                                author: "John Lemon",
                                date: "2012-10-16T17:57:28.556094Z"
                            },
                            {
                                rating: 4,
                                comment: "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
                                author: "Paul McVites",
                                date: "2014-09-05T17:57:28.556094Z"
                            },
                            {
                                rating: 3,
                                comment: "Eat it, just eat it!",
                                author: "Michael Jaikishan",
                                date: "2015-02-13T17:57:28.556094Z"
                            },
                            {
                                rating: 4,
                                comment: "Ultimate, Reaching for the stars!",
                                author: "Ringo Starry",
                                date: "2013-12-02T17:57:28.556094Z"
                            },
                            {
                                rating: 2,
                                comment: "It's your birthday, we're gonna party!",
                                author: "25 Cent",
                                date: "2011-12-02T17:57:28.556094Z"
                            }

                        ]
                    };

                    $scope.dish = dish;

});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="container" ng-controller="dishDetailController" ng-app="confusionApp">
                <div class="row row-content">
                    <div class="col-xs-12">
                        <ul class="media-list">
                            <li class="media">
                                <div class="media-left media-middle">
                                    <a href="#">
                                        <img class="media-object img-thumbnail"
                                             ng-src="{{dish.image}}" alt="Uthapizza">
                                    </a>
                                </div>
                                <div class="media-body">
                                    <h2 class="media-heading">{{dish.name}}
                                        <span class="label label-danger">{{dish.label}}</span>
                                        <span class="badge">{{dish.price | currency}}</span>
                                    </h2>
                                    <p>{{dish.description}}</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="col-xs-9 col-xs-offset-1">
                        <h3>Customer Comments</h3>
                        <blockquote ng-repeat="item in dish.comments">
                            {{item}}
                        </blockquote>
                    </div>
                </div>

            </div>


问:
deis builder keep restart with liveness probe fail
I tried to delete the pods, or rescale the replicas, or delete the aws instances, but still cannot make the deis builder work normally. It keeps restart with failed liveness probe. Below the logs from the deis builder</p>

```<code>$ kubectl describe pods/deis-builder-2995120344-mz2zg -n deis
Name:       deis-builder-2995120344-mz2zg
    Namespace:  deis
    Node:       ip-10-0-48-189.ec2.internal/10.0.48.189
    Start Time: Wed, 15 Mar 2017 22:29:03 -0400
    Labels:     app=deis-builder
            pod-template-hash=2995120344
    Status:     Running
    IP:     10.34.184.7
    Controllers:    ReplicaSet/deis-builder-2995120344
    Containers:
      deis-builder:
        Container ID:   docker://f2b7799712c347759832270716057b6ac3be68298eef3057c25727b66024c84a
        Image:      quay.io/deis/builder:v2.7.1
        Image ID:       docker-pullable://quay.io/deis/builder@sha256:3dab1dd4e6359d1588fee1b4f93ef9f5c70f268f17de5bed4bc13faa210ce5d0
        Ports:      2223/TCP, 8092/TCP
        State:      Waiting
          Reason:       CrashLoopBackOff
        Last State:     Terminated
          Reason:       Error
          Exit Code:    2
          Started:      Wed, 15 Mar 2017 22:37:37 -0400
          Finished:     Wed, 15 Mar 2017 22:38:15 -0400
        Ready:      False
        Restart Count:  7
        Liveness:       http-get http://:8092/healthz delay=30s timeout=1s period=10s #success=1 #failure=3
        Readiness:      http-get http://:8092/readiness delay=30s timeout=1s period=10s #success=1 #failure=3
        Volume Mounts:
          /var/run/secrets/api/auth from builder-key-auth (ro)
          /var/run/secrets/deis/builder/ssh from builder-ssh-private-keys (ro)
          /var/run/secrets/deis/objectstore/creds from objectstore-creds (ro)
          /var/run/secrets/kubernetes.io/serviceaccount from deis-builder-token-qbqff (ro)
        Environment Variables:
          DEIS_REGISTRY_SERVICE_HOST:   127.0.0.1
          DEIS_REGISTRY_SERVICE_PORT:   5555
          HEALTH_SERVER_PORT:       8092
          EXTERNAL_PORT:            2223
          BUILDER_STORAGE:          s3
          DEIS_REGISTRY_LOCATION:       ecr
          DEIS_REGISTRY_SECRET_PREFIX:  private-registry
          GIT_LOCK_TIMEOUT:         10
          SLUGBUILDER_IMAGE_NAME:       <set to the key 'image' of config map 'slugbuilder-config'>
          SLUG_BUILDER_IMAGE_PULL_POLICY:   <set to the key 'pullpolicy' of config map 'slugbuilder-config'>
          DOCKERBUILDER_IMAGE_NAME:     <set to the key 'image' of config map 'dockerbuilder-config'>
          DOCKER_BUILDER_IMAGE_PULL_POLICY: <set to the key 'pullpolicy' of config map 'dockerbuilder-config'>
          DOCKERIMAGE:          1
          DEIS_DEBUG:           false
          POD_NAMESPACE:            deis (v1:metadata.namespace)
          DEIS_BUILDER_KEY:         <set to the key 'builder-key' in secret 'builder-key-auth'>
    Conditions:
      Type      Status
      Initialized   True
      Ready     False
      PodScheduled  True
    Volumes:
      builder-key-auth:
        Type:   Secret (a volume populated by a Secret)
        SecretName: builder-key-auth
      builder-ssh-private-keys:
        Type:   Secret (a volume populated by a Secret)
        SecretName: builder-ssh-private-keys
      objectstore-creds:
        Type:   Secret (a volume populated by a Secret)
        SecretName: objectstorage-keyfile
      deis-builder-token-qbqff:
        Type:   Secret (a volume populated by a Secret)
        SecretName: deis-builder-token-qbqff
    QoS Class:  BestEffort
    Tolerations:    <none>
    Events:
      FirstSeen LastSeen    Count   From                    SubObjectPath           Type        ReasonMessage
      --------- --------    -----   ----                    -------------           --------    -------------
      10m       10m     1   {default-scheduler }                            Normal      Scheduled   Successfully assigned deis-builder-2995120344-mz2zg to ip-10-0-48-189.ec2.internal
      10m       10m     1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 7eac3a357f61
      10m       10m     1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 7eac3a357f61; Security:[seccomp=unconfined]
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 8e730f2731ef; Security:[seccomp=unconfined]
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 8e730f2731ef
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 7eac3a357f61: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 5f4e695c595a; Security:[seccomp=unconfined]
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 8e730f2731ef: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 5f4e695c595a
      8m        8m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id c87d762fc118; Security:[seccomp=unconfined]
      8m        8m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id c87d762fc118
      8m        8m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 5f4e695c595a: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 416573d43fe4; Security:[seccomp=unconfined]
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 416573d43fe4
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id c87d762fc118: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 416573d43fe4: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m        6m      4   {kubelet ip-10-0-48-189.ec2.internal}                   Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "deis-builder" with CrashLoopBackOff: "Back-off 40s restarting failed container=deis-builder pod=deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)"

      6m    6m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Created     Created container with docker id bf5b29729c27; Security:[seccomp=unconfined]
      6m    6m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Started     Started container with docker id bf5b29729c27
      9m    5m  4   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning Unhealthy   Readiness probe failed: Get http://10.34.184.7:8092/readiness: dial tcp 10.34.184.7:8092: getsockopt: connection refused
      9m    5m  4   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning Unhealthy   Liveness probe failed: Get http://10.34.184.7:8092/healthz: dial tcp 10.34.184.7:8092: getsockopt: connection refused
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Started     Started container with docker id e457328db858
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Created     Created container with docker id e457328db858; Security:[seccomp=unconfined]
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Killing     Killing container with docker id bf5b29729c27: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Killing     Killing container with docker id e457328db858: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      5m    2m  13  {kubelet ip-10-0-48-189.ec2.internal}                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "deis-builder" with CrashLoopBackOff: "Back-off 2m40s restarting failed container=deis-builder pod=deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)"

      2m    2m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Started     Started container with docker id f2b7799712c3
      10m   2m  8   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Pulled      Container image "quay.io/deis/builder:v2.7.1" already present on machine
      2m    2m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Created     Created container with docker id f2b7799712c3; Security:[seccomp=unconfined]
      10m   1m  6   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning Unhealthy   Liveness probe failed: Get http://10.34.184.7:8092/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
      1m    1m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Killing     Killing container with docker id f2b7799712c3: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m    9s  26  {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning BackOff     Back-off restarting failed docker container
      1m    9s  9   {kubelet ip-10-0-48-189.ec2.internal}                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "deis-builder" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=deis-builder pod=deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)"
</code>```

答: My solution was to delete deis and redeploy it.</p>

Body:
I tried to delete the pods, or rescale the replicas, or delete the aws instances, but still cannot make the deis builder work normally. It keeps restart with failed liveness probe. Below the logs from the deis builder

$ kubectl describe pods/deis-builder-2995120344-mz2zg -n deis
Name:       deis-builder-2995120344-mz2zg
    Namespace:  deis
    Node:       ip-10-0-48-189.ec2.internal/10.0.48.189
    Start Time: Wed, 15 Mar 2017 22:29:03 -0400
    Labels:     app=deis-builder
            pod-template-hash=2995120344
    Status:     Running
    IP:     10.34.184.7
    Controllers:    ReplicaSet/deis-builder-2995120344
    Containers:
      deis-builder:
        Container ID:   docker://f2b7799712c347759832270716057b6ac3be68298eef3057c25727b66024c84a
        Image:      quay.io/deis/builder:v2.7.1
        Image ID:       docker-pullable://quay.io/deis/builder@sha256:3dab1dd4e6359d1588fee1b4f93ef9f5c70f268f17de5bed4bc13faa210ce5d0
        Ports:      2223/TCP, 8092/TCP
        State:      Waiting
          Reason:       CrashLoopBackOff
        Last State:     Terminated
          Reason:       Error
          Exit Code:    2
          Started:      Wed, 15 Mar 2017 22:37:37 -0400
          Finished:     Wed, 15 Mar 2017 22:38:15 -0400
        Ready:      False
        Restart Count:  7
        Liveness:       http-get http://:8092/healthz delay=30s timeout=1s period=10s #success=1 #failure=3
        Readiness:      http-get http://:8092/readiness delay=30s timeout=1s period=10s #success=1 #failure=3
        Volume Mounts:
          /var/run/secrets/api/auth from builder-key-auth (ro)
          /var/run/secrets/deis/builder/ssh from builder-ssh-private-keys (ro)
          /var/run/secrets/deis/objectstore/creds from objectstore-creds (ro)
          /var/run/secrets/kubernetes.io/serviceaccount from deis-builder-token-qbqff (ro)
        Environment Variables:
          DEIS_REGISTRY_SERVICE_HOST:   127.0.0.1
          DEIS_REGISTRY_SERVICE_PORT:   5555
          HEALTH_SERVER_PORT:       8092
          EXTERNAL_PORT:            2223
          BUILDER_STORAGE:          s3
          DEIS_REGISTRY_LOCATION:       ecr
          DEIS_REGISTRY_SECRET_PREFIX:  private-registry
          GIT_LOCK_TIMEOUT:         10
          SLUGBUILDER_IMAGE_NAME:       <set to the key 'image' of config map 'slugbuilder-config'>
          SLUG_BUILDER_IMAGE_PULL_POLICY:   <set to the key 'pullpolicy' of config map 'slugbuilder-config'>
          DOCKERBUILDER_IMAGE_NAME:     <set to the key 'image' of config map 'dockerbuilder-config'>
          DOCKER_BUILDER_IMAGE_PULL_POLICY: <set to the key 'pullpolicy' of config map 'dockerbuilder-config'>
          DOCKERIMAGE:          1
          DEIS_DEBUG:           false
          POD_NAMESPACE:            deis (v1:metadata.namespace)
          DEIS_BUILDER_KEY:         <set to the key 'builder-key' in secret 'builder-key-auth'>
    Conditions:
      Type      Status
      Initialized   True
      Ready     False
      PodScheduled  True
    Volumes:
      builder-key-auth:
        Type:   Secret (a volume populated by a Secret)
        SecretName: builder-key-auth
      builder-ssh-private-keys:
        Type:   Secret (a volume populated by a Secret)
        SecretName: builder-ssh-private-keys
      objectstore-creds:
        Type:   Secret (a volume populated by a Secret)
        SecretName: objectstorage-keyfile
      deis-builder-token-qbqff:
        Type:   Secret (a volume populated by a Secret)
        SecretName: deis-builder-token-qbqff
    QoS Class:  BestEffort
    Tolerations:    <none>
    Events:
      FirstSeen LastSeen    Count   From                    SubObjectPath           Type        ReasonMessage
      --------- --------    -----   ----                    -------------           --------    -------------
      10m       10m     1   {default-scheduler }                            Normal      Scheduled   Successfully assigned deis-builder-2995120344-mz2zg to ip-10-0-48-189.ec2.internal
      10m       10m     1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 7eac3a357f61
      10m       10m     1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 7eac3a357f61; Security:[seccomp=unconfined]
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 8e730f2731ef; Security:[seccomp=unconfined]
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 8e730f2731ef
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 7eac3a357f61: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 5f4e695c595a; Security:[seccomp=unconfined]
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 8e730f2731ef: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      9m        9m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 5f4e695c595a
      8m        8m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id c87d762fc118; Security:[seccomp=unconfined]
      8m        8m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id c87d762fc118
      8m        8m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 5f4e695c595a: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      CreatedCreated container with docker id 416573d43fe4; Security:[seccomp=unconfined]
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      StartedStarted container with docker id 416573d43fe4
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id c87d762fc118: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m        7m      1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal      KillingKilling container with docker id 416573d43fe4: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m        6m      4   {kubelet ip-10-0-48-189.ec2.internal}                   Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "deis-builder" with CrashLoopBackOff: "Back-off 40s restarting failed container=deis-builder pod=deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)"

      6m    6m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Created     Created container with docker id bf5b29729c27; Security:[seccomp=unconfined]
      6m    6m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Started     Started container with docker id bf5b29729c27
      9m    5m  4   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning Unhealthy   Readiness probe failed: Get http://10.34.184.7:8092/readiness: dial tcp 10.34.184.7:8092: getsockopt: connection refused
      9m    5m  4   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning Unhealthy   Liveness probe failed: Get http://10.34.184.7:8092/healthz: dial tcp 10.34.184.7:8092: getsockopt: connection refused
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Started     Started container with docker id e457328db858
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Created     Created container with docker id e457328db858; Security:[seccomp=unconfined]
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Killing     Killing container with docker id bf5b29729c27: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      5m    5m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Killing     Killing container with docker id e457328db858: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      5m    2m  13  {kubelet ip-10-0-48-189.ec2.internal}                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "deis-builder" with CrashLoopBackOff: "Back-off 2m40s restarting failed container=deis-builder pod=deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)"

      2m    2m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Started     Started container with docker id f2b7799712c3
      10m   2m  8   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Pulled      Container image "quay.io/deis/builder:v2.7.1" already present on machine
      2m    2m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Created     Created container with docker id f2b7799712c3; Security:[seccomp=unconfined]
      10m   1m  6   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning Unhealthy   Liveness probe failed: Get http://10.34.184.7:8092/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
      1m    1m  1   {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Normal  Killing     Killing container with docker id f2b7799712c3: pod "deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)" container "deis-builder" is unhealthy, it will be killed and re-created.
      7m    9s  26  {kubelet ip-10-0-48-189.ec2.internal}   spec.containers{deis-builder}   Warning BackOff     Back-off restarting failed docker container
      1m    9s  9   {kubelet ip-10-0-48-189.ec2.internal}                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "deis-builder" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=deis-builder pod=deis-builder-2995120344-mz2zg_deis(52027ebf-09f0-11e7-8bbf-0a73a2cd36e4)"


问:
colors not changing on pycharm
Installed PyCharm 2016.2. Playing with the color schemes.
I've noticed some colors are not the same from what I remember on previous PC.

I remember all the parameters to be types of oranges, while strings to be yellow or green. After playing with all the schemes, I realized that although most of the colors change, those remain the same.

Twilight

Default

Github

I even played with custom schemes and tried to change it on the General and specific language setting but nothing seems to work.

答:
Had the same issue, but had two projects running side by side, one yellow, other dark cyan, as in your case. The only difference was Python 2 vs Python 3...

Solution:

Settings -> Editor -> Colors & Fonts -> Python

Then choose "String (bytes)" and "String (Unicode)" - defaults are of different color!

Title: colors not changing on pycharm


答:
First, you need to add ng-app directive to your html code. For example:
.

Then you need to change ng-controller="dishDetailController as dish" to the ng-controller="dishDetailController".

You can read more about ng-controller directive (and when you have to use as) here.

To print set a set of comments you would use ng-repeat

Title: Insert controller data on html page

Body:
First, you need to add ng-app directive to your html code. For example:
<body ng-app="confusionApp">.

Then you need to change ng-controller="dishDetailController as dish" to the ng-controller="dishDetailController".

You can read more about ng-controller directive (and when you have to use as) here.

To print set a set of comments you would use ng-repeat


问:
jQuery's swap method time costly
I ran the profiler in firebug and found that the most time costly function being ran in our UI is jQuery's .swap(). I can see that this must be associated with the .css() method.

Here is an image of my profiler:

Obviously, to improve the speed here I need to cut back on calling .css(), but that is quite the project as I use it to set and correct styling of different elements, which has to be completely dynamic.

Is there a better way to speed this up?

I am using jquery.1.4.2. I haven't been able to move on to 1.4.4 because it breaks quite a few of my scripts for some reason. Would it be be of benefit to extend the swap method from 1.4.4 to 1.4.2? Or would that present more incompatibilities?

What is the swap method and why is it so time costly?

答:
From what I can see looking at the jQuery UI code, .swap() is not called directly by it, the only place in the jQuery framework itself that uses .swap() directly are the .height() and .width() calls when retrieving the computed height/width of an element.

What it does to calculate the sizes when not available directly from the browser is temporarily swaps the style out for the following:

```<code>cssShow = { position: "absolute", visibility: "hidden", display: "block" };
</code>```

Then performs the usual internal getWH() function whilst in that altered style state, and restores.

The partial code borrowed from jQuery:

```<code>jQuery.each(["height", "width"], function( i, name ) {
    jQuery.cssHooks[ name ] = {
        get: function( elem, computed, extra ) {
            var val;

            if ( computed ) {
                if ( elem.offsetWidth !== 0 ) {
                    val = getWH( elem, name, extra );

                } else {
                    jQuery.swap( elem, cssShow, function() {
                        val = getWH( elem, name, extra );
                    });
                }

                   // etc.
</code>```

jQuery UI uses height() and width() functions everywhere, so it is little wonder that the .swap() function figures highly in the profile.

Title: jQuery's swap method time costly

Body:
From what I can see looking at the jQuery UI code, .swap() is not called directly by it, the only place in the jQuery framework itself that uses .swap() directly are the .height() and .width() calls when retrieving the computed height/width of an element.

What it does to calculate the sizes when not available directly from the browser is temporarily swaps the style out for the following:

cssShow = { position: "absolute", visibility: "hidden", display: "block" };

Then performs the usual internal getWH() function whilst in that altered style state, and restores.

The partial code borrowed from jQuery:

jQuery.each(["height", "width"], function( i, name ) {
    jQuery.cssHooks[ name ] = {
        get: function( elem, computed, extra ) {
            var val;

            if ( computed ) {
                if ( elem.offsetWidth !== 0 ) {
                    val = getWH( elem, name, extra );

                } else {
                    jQuery.swap( elem, cssShow, function() {
                        val = getWH( elem, name, extra );
                    });
                }

                   // etc.

jQuery UI uses height() and width() functions everywhere, so it is little wonder that the .swap() function figures highly in the profile.


问:
IOS Swift - UIWebView jump to anchor tag
I am loading a local html file and would like to jump to an anchor tag somewhere on the page. I am using this code to load the file:

```<code>        let documentDirectoryURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
        let fileDestinationUrl = documentDirectoryURL.appendingPathComponent("page.html")
        let request = URLRequest(url: fileDestinationUrl)
        webView.loadRequest(request)
</code>```

Is there away to jump to an anchor tag on this page

答: I have just confirmed that they could work also in iPhone6, after updating its OS to iOS 10.3, the same version of the simulator. </p>

Body:
I am loading a local html file and would like to jump to an anchor tag somewhere on the page. I am using this code to load the file:

        let documentDirectoryURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
        let fileDestinationUrl = documentDirectoryURL.appendingPathComponent("page.html")
        let request = URLRequest(url: fileDestinationUrl)
        webView.loadRequest(request)

Is there away to jump to an anchor tag on this page


问:
how to convert xts index or time to year
For annual data (such as Annual Income Statements), I would like to keep xts format but I need to convert the index of the table to "only year". There are yearmon and yearqtr classes but I did not find "year" only class to work with xts.</p>
```<code># IS is annual reports of incomes. time(IS) is POSIXct.
library(quantmod)
IS <- viewFin(get(getFin("IBM")), "IS", "A") # Download data
IS <- as.xts(t(IS)) # Convert to xts
time(IS) <- as.yearqtr(time(IS))  ## works to have quarterly index
time(IS) <- as.yearmon(time(IS))  ## works to have monthly index
time(IS) <- ????(time(IS))  ## To have yearly index with xts class

</code>```

答:
It would be helpful if you explained why you need to have the index as "year" only. Xts has an indexFormat command that allows you to control how dates are displayed, and while I've never used it I assume it will allow you to display only the year of any given index entry.

A more extreme solution would be to convert every date to the first of the year in that year. Here's some code to help do this:

```<code>first.of.year <- function(x)           # Given a date, returns the first day of that year
     return(as.Date(paste(year(as.Date(x)),"-01-01", sep="")))

index(x) <- first.of.year(index(x))
</code>```

ContentLicense: CC BY-SA 4.0

Body:
For annual data (such as Annual Income Statements), I would like to keep xts format but I need to convert the index of the table to "only year". There are yearmon and yearqtr classes but I did not find "year" only class to work with xts.

# IS is annual reports of incomes. time(IS) is POSIXct.
library(quantmod)
IS <- viewFin(get(getFin("IBM")), "IS", "A") # Download data
IS <- as.xts(t(IS)) # Convert to xts
time(IS) <- as.yearqtr(time(IS))  ## works to have quarterly index
time(IS) <- as.yearmon(time(IS))  ## works to have monthly index
time(IS) <- ????(time(IS))  ## To have yearly index with xts class

Body:
It would be helpful if you explained why you need to have the index as "year" only. Xts has an indexFormat command that allows you to control how dates are displayed, and while I've never used it I assume it will allow you to display only the year of any given index entry.

A more extreme solution would be to convert every date to the first of the year in that year. Here's some code to help do this:

first.of.year <- function(x)           # Given a date, returns the first day of that year
     return(as.Date(paste(year(as.Date(x)),"-01-01", sep="")))

index(x) <- first.of.year(index(x))


问:
GUI not updating values in simple game
I am making a simple 2d platforming game using Swing library, where I am trying to constantly show different values in the GUI. The values update and work perfectly in the first level, however they remain the same for the next levels.

Code for the GUI:

```<code>public class MyView extends UserView {

    Player player;

    private Image background;
    private Image newBackground;

    public MyView(World world, Player player, int width, int height) {
        super(world, width, height);
        this.player = player;
        this.background = new ImageIcon("data/rainy.gif").getImage()
                .getScaledInstance(1000, 1000, 1000);
    }

    @Override
    protected void paintForeground(Graphics2D g) {
        g.drawString("Lives left: " + player.getLifeCount(), 650, 20);
        g.drawString("Blue hearts picked: " + player.getBlueHeartCount(), 650, 30);
        g.drawString("Time left: " + player.getTimeCounter(), 650, 50);
     }
    }
</code>```

When reaching the second level, player.getLifeCount(), player.getBlueHeartCount() and player.getTimeCounter(), freeze and stop updating.

Here is the relevant code (without imports) for level 1 and level 2 where the values are changed:

```<code>public class Level1 extends GameLevel implements ActionListener {

@Override
    public void actionPerformed(ActionEvent e) {
        if (getPlayer().heartPick) {
            timer.stop();
        } else if (player.getTimeCounter() <= 0) {
            System.exit(0);
        } else {
            counter -= 1;
            player.setTimeCounter(counter);
        }
    }
</code>```

Code for level 2:

```<code>public class Level2 extends GameLevel implements ActionListener {

@Override
    public void actionPerformed(ActionEvent e) {
//        System.out.println("Action event!");
        if (getPlayer().heartPick) {
            timer.stop();
        } else if (player.getTimeCounter() <= 0) {
            System.exit(0);
        } else {
            counter -= 1;
            player.setTimeCounter(counter);
        }
    }
}
</code>```

Here is the relevant code for the main class:

```<code>public class Game {
    private GameLevel world;

    private MyView view;

    private int level;

    // timer
    private Timer timer;

    public Game(){

        // make the world
        level = 1;
        world = new Level1();
        world.populate(this);

        // make a view
        view = new MyView(world, world.getPlayer(), 800, 600);

        // display the view in a frame
        final JFrame frame = new JFrame("Event handling");

        // start!
        world.start();
    }

    // return world
    public GameLevel getWorld() {
            return world;
    }

    // the player in current level
    public Player getPlayer() {
        return world.getPlayer();
    }

    // Progress to next level
    public void goNextLevel() {
        world.stop();

        switch (level) {
            case 4:
                System.exit(0);
            case 2:
                level++;

                // get a new world
                world = new Level2();

                // fill world
                world.populate(this);

                // show the new world in the view
                view.setWorld(world);

                view.setBackground(2);
                world.start();
                break;

            case 3:
                level++;

                //get new world
                world = new Level3();

                //fill world
                world.populate(this);

                // show the new world in the view
                view.setWorld(world);

                view.setBackground(3);
                world.start();
                break;

            default:
                level++;
                break;

        }
    }
}
</code>```

答: Your switch statement in goNextLevel is switching based on the level you are GOING to be on instead of the level you are currently on. So when you are on Level 1 and hit the goNextLevel block, it goes to default. You want to switch based on what the level used to be, not what it will be, because you are updating it in that statement.

Title: GUI not updating values in simple game

Body:
I am making a simple 2d platforming game using Swing library, where I am trying to constantly show different values in the GUI. The values update and work perfectly in the first level, however they remain the same for the next levels.

Code for the GUI:

public class MyView extends UserView {

    Player player;

    private Image background;
    private Image newBackground;

    public MyView(World world, Player player, int width, int height) {
        super(world, width, height);
        this.player = player;
        this.background = new ImageIcon("data/rainy.gif").getImage()
                .getScaledInstance(1000, 1000, 1000);
    }

    @Override
    protected void paintForeground(Graphics2D g) {
        g.drawString("Lives left: " + player.getLifeCount(), 650, 20);
        g.drawString("Blue hearts picked: " + player.getBlueHeartCount(), 650, 30);
        g.drawString("Time left: " + player.getTimeCounter(), 650, 50);
     }
    }

When reaching the second level, player.getLifeCount(), player.getBlueHeartCount() and player.getTimeCounter(), freeze and stop updating.

Here is the relevant code (without imports) for level 1 and level 2 where the values are changed:

public class Level1 extends GameLevel implements ActionListener {

@Override
    public void actionPerformed(ActionEvent e) {
        if (getPlayer().heartPick) {
            timer.stop();
        } else if (player.getTimeCounter() <= 0) {
            System.exit(0);
        } else {
            counter -= 1;
            player.setTimeCounter(counter);
        }
    }

Code for level 2:

public class Level2 extends GameLevel implements ActionListener {

@Override
    public void actionPerformed(ActionEvent e) {
//        System.out.println("Action event!");
        if (getPlayer().heartPick) {
            timer.stop();
        } else if (player.getTimeCounter() <= 0) {
            System.exit(0);
        } else {
            counter -= 1;
            player.setTimeCounter(counter);
        }
    }
}

Here is the relevant code for the main class:

public class Game {
    private GameLevel world;

    private MyView view;

    private int level;

    // timer
    private Timer timer;

    public Game(){

        // make the world
        level = 1;
        world = new Level1();
        world.populate(this);

        // make a view
        view = new MyView(world, world.getPlayer(), 800, 600);

        // display the view in a frame
        final JFrame frame = new JFrame("Event handling");

        // start!
        world.start();
    }

    // return world
    public GameLevel getWorld() {
            return world;
    }

    // the player in current level
    public Player getPlayer() {
        return world.getPlayer();
    }

    // Progress to next level
    public void goNextLevel() {
        world.stop();

        switch (level) {
            case 4:
                System.exit(0);
            case 2:
                level++;

                // get a new world
                world = new Level2();

                // fill world
                world.populate(this);

                // show the new world in the view
                view.setWorld(world);

                view.setBackground(2);
                world.start();
                break;

            case 3:
                level++;

                //get new world
                world = new Level3();

                //fill world
                world.populate(this);

                // show the new world in the view
                view.setWorld(world);

                view.setBackground(3);
                world.start();
                break;

            default:
                level++;
                break;

        }
    }
}