问:
Manipulating reactive objects in Shiny - Error in <-: invalid (NULL) left side of assignment
I'm running into the error "Error in <-: invalid (NULL) left side of assignment" over and over again as I attempt to take a reactive object in Shiny and further manipulate it. I've provided an illustrative example below.

```<code> testdf <- data.frame(row1 = c(1,3,6), row2 = c(7, 5, 1))

 ui <- fluidPage(

   titlePanel("Education in Tanzania"),

   sidebarLayout(
     sidebarPanel(

       #Select aggregation level of data
       selectInput("AggregationSelect",
                   label = "Aggregation",
                   choices = list("School" = 1,
                                  "District" = 2,
                                  "Region" = 3),
                   selected = 1)
     ),

     mainPanel(
       DT::dataTableOutput("OutputTable")
     )
   )
 )

 server <- function(input, output) {

     Output1 <- reactive({
         testdf
     })

   observe({
     if(2 %in% input$AggregationSelect) {
       observe({Output1()$name[3] <- "b"})
     } else  if(3 %in% input$AggregationSelect) {
       observe({Output1()$name[2] <- "c"})
     } else  if(1 %in% input$AggregationSelect) {
       observe({Output1()$name[1] <- "a"})
     }
   })

   output$OutputTable <- {DT::renderDataTable({
     DT::datatable(Output1(),
                   options = list(pagelength = 25,
                                  searching = TRUE,
                                  paging = TRUE,
                                  lengthChange = FALSE),
                   rownames = FALSE)
     })
   }
 }

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

What I need to do in my actual code is assemble a dataframe through the UI (which I am able to do and therefore have just subbed a random df in here) and then add some information (represented here with the added "names" column) based on what has been selected in the UI. It seems like it shouldn't be all that difficult to add a column to a df, but within the reactive object context, nothing I have attempted has worked. Other ways to modify reactive objects are welcome as long as they can be applied to more complex multi-step scenarios - there's no way I can get everything I need bundled into the initial assignment of the reactive object.

答:
Im not 100% what you're doing but I think its best if you use eventReactive that would listen to your selectInput. Note that I added the variable names to the dataframe:

```<code>library(shiny)
testdf <- data.frame(names = c(1,3,6), row2 = c(7, 5, 1))

ui <- fluidPage(
  titlePanel("Education in Tanzania"),
  sidebarLayout(
    sidebarPanel(
      #Select aggregation level of data
      selectInput("AggregationSelect", label = "Aggregation",
                  choices = list("School" = 1, "District" = 2, "Region" = 3),selected = 1)
    ),
    mainPanel(
      DT::dataTableOutput("OutputTable")
    )
  )
)

server <- function(input, output) {

  Output1 <- eventReactive(input$AggregationSelect,{
    if(input$AggregationSelect %in% "2"){
      testdf$name[3] <- "b"
      return(testdf)
    }
    else if(input$AggregationSelect %in% "3"){
      testdf$name[2] <- "c"
      return(testdf)
    }
    else if(input$AggregationSelect %in% "1"){
      testdf$name[1] <- "a"
      return(testdf)
    }
    else{
      return(testdf)
    }
  })

  output$OutputTable <- {DT::renderDataTable({
    print(Output1())
    DT::datatable(Output1(),options = list(pagelength = 25,searching = TRUE,paging = TRUE,lengthChange = FALSE),rownames = FALSE)
  })
  }
}

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

Body:
I'm running into the error "Error in <-: invalid (NULL) left side of assignment" over and over again as I attempt to take a reactive object in Shiny and further manipulate it. I've provided an illustrative example below.

 testdf <- data.frame(row1 = c(1,3,6), row2 = c(7, 5, 1))

 ui <- fluidPage(

   titlePanel("Education in Tanzania"),

   sidebarLayout(
     sidebarPanel(

       #Select aggregation level of data
       selectInput("AggregationSelect",
                   label = "Aggregation",
                   choices = list("School" = 1,
                                  "District" = 2,
                                  "Region" = 3),
                   selected = 1)
     ),

     mainPanel(
       DT::dataTableOutput("OutputTable")
     )
   )
 )

 server <- function(input, output) {

     Output1 <- reactive({
         testdf
     })

   observe({
     if(2 %in% input$AggregationSelect) {
       observe({Output1()$name[3] <- "b"})
     } else  if(3 %in% input$AggregationSelect) {
       observe({Output1()$name[2] <- "c"})
     } else  if(1 %in% input$AggregationSelect) {
       observe({Output1()$name[1] <- "a"})
     }
   })

   output$OutputTable <- {DT::renderDataTable({
     DT::datatable(Output1(),
                   options = list(pagelength = 25,
                                  searching = TRUE,
                                  paging = TRUE,
                                  lengthChange = FALSE),
                   rownames = FALSE)
     })
   }
 }

 shinyApp(ui = ui, server = server)

What I need to do in my actual code is assemble a dataframe through the UI (which I am able to do and therefore have just subbed a random df in here) and then add some information (represented here with the added "names" column) based on what has been selected in the UI. It seems like it shouldn't be all that difficult to add a column to a df, but within the reactive object context, nothing I have attempted has worked. Other ways to modify reactive objects are welcome as long as they can be applied to more complex multi-step scenarios - there's no way I can get everything I need bundled into the initial assignment of the reactive object.

Body:
Im not 100% what you're doing but I think its best if you use eventReactive that would listen to your selectInput. Note that I added the variable names to the dataframe:

library(shiny)
testdf <- data.frame(names = c(1,3,6), row2 = c(7, 5, 1))

ui <- fluidPage(
  titlePanel("Education in Tanzania"),
  sidebarLayout(
    sidebarPanel(
      #Select aggregation level of data
      selectInput("AggregationSelect", label = "Aggregation",
                  choices = list("School" = 1, "District" = 2, "Region" = 3),selected = 1)
    ),
    mainPanel(
      DT::dataTableOutput("OutputTable")
    )
  )
)

server <- function(input, output) {

  Output1 <- eventReactive(input$AggregationSelect,{
    if(input$AggregationSelect %in% "2"){
      testdf$name[3] <- "b"
      return(testdf)
    }
    else if(input$AggregationSelect %in% "3"){
      testdf$name[2] <- "c"
      return(testdf)
    }
    else if(input$AggregationSelect %in% "1"){
      testdf$name[1] <- "a"
      return(testdf)
    }
    else{
      return(testdf)
    }
  })

  output$OutputTable <- {DT::renderDataTable({
    print(Output1())
    DT::datatable(Output1(),options = list(pagelength = 25,searching = TRUE,paging = TRUE,lengthChange = FALSE),rownames = FALSE)
  })
  }
}

shinyApp(ui = ui, server = server)


来源: stackexchange

问:
why #control{} in CSS but not in html or JS
I was going through this code for Codeplayer in Codepen (see link below), there is a #control{} listed in the CSS code but not mentioned in either HTML or JS code. Could anyone tell me why. Is this a mistake? I'm a newbie to web development so would really like to understand if this is standard or a trick... Thank you!

https://codepen.io/likezli/pen/dXPdJL

CSS code:

```<code>    body {
      margin: 0;
      padding: 0;
      font-family: 'Lato', sans-serif;
    }

    li {
      list-style: none;
      float: left;
    }

    a {
      color: black;
    }

    .clear {
      clear: both;
    }

    #logo {
      font-weight: bold;
      padding: 10px 0 0 10px;
      float: left;
    }

    #menuBar {
      height: 40px;
      width: 100%;
      background-color: #EDEDED;
      border-bottom: 1px solid #C8C8C8;
      box-sizing: border-box;
    }

    #buttonDiv {
      float: right;
      padding: 5px 15px 0 0;
    }

    #runButton {
      font-size: 110%
    }

    #control {}

    #toggleDiv {
      height: 40px;
      margin: auto;
      width: 20%;
      box-sizing: border-box;
      padding-top: 5px;
      position: relative;
    }

    #toggles {
      float: left;
      margin: 0;
      list-style: none;
      padding-left: 0;
      box-sizing: border-box;
      border: 1px solid #D3D3D3;
      border-radius: 5px;
    }

    #toggles li {
      float: left;
      border-right: 1px solid #D3D3D3;
      box-sizing: border-box;
      padding: 5px 8px 4px 7px;
    }

    .codeContainer {
      height: 100%;
      width: 50%;
      float: left;
      position: relative;
    }

    .codeContainer textarea {
      width: 100%;
      height: 100%;
      border: none;
      border-right: 1px solid #E5E5E5;
      font-family: SourceCodeProRegular, Menlo, Monaco, consolas, monospace;
      font-size: 90%;
      box-sizing: border-box;
      padding: 30px 0 5px 5px;
    }

    .codeLabel {
      position: absolute;
      right: 10px;
      top: 10px;
    }

    #cssContainer,
    #jsContainer {
      display: none;
    }

    iframe {
      height: 100%;
      position: relative;
      width: 100%;
      border: none;
      padding-top: 30px;
    }

    .selected {
      background-color: #EAF3FF;
    }

    a {
      text-decoration: none;
    }

    a:visited {
      color: #000000;
    }

**here is the html code:**

        <div id="container">
      <div id="menuBar">
        <div id="logo">
          CodePlayer
        </div>

        <div id="buttonDiv">
          <button id="runButton">Run</button>
        </div>

        <div id="toggleDiv">
          <ul id="toggles">
            <a href="#">
              <li class="toggle selected">HTML</li>
            </a>
            <a href="#">
              <li class="toggle">CSS</li>
            </a>
            <a href="#">
              <li class="toggle">JS</li>
            </a>
            <a href="#">
              <li class="toggle selected" style="border:none">Result</li>
            </a>
          </ul>
        </div>

      </div>

      <div class="clear"></div>

      <div class="codeContainer" id="htmlContainer">
        <div class="codeLabel">HTML</div>
        <textarea id="htmlCode"><div id="test"></div></textarea>
      </div>

      <div class="codeContainer" id="cssContainer">
        <div class="codeLabel">CSS</div>
        <textarea id="cssCode"></textarea>
      </div>

      <div class="codeContainer" id="jsContainer">
        <div class="codeLabel">Javascript</div>
        <textarea id="jsCode"></textarea>
      </div>

      <div class="codeContainer" id="resultContainer">
        <div class="codeLabel">Output</div>
        <iframe id="resultFrame"></iframe>
      </div>
    </div>

**JS Code:**

var windowHeight = $(window).height();
var menuBarHeight = $("#menuBar").height();

// code container height calculated
var codeContainerHeight = windowHeight - menuBarHeight;
$(".codeContainer").height(codeContainerHeight + "px");

// Toggling between HTML, CSS, JS and Output
$(".toggle").click(function(event) {
  // toggle items in menuBar
  $(this).toggleClass("selected");

  // get html of list item (html, css, js or result) in lowercase
  var activeDiv = $(this).html().toLowerCase();

  // combine it to one of the cor container id's (htmlContainer, cssContainer, etc.)
  // toggle show or hide
  $("#" + activeDiv + "Container").toggle();

  // count the container id's which are not hidden (display != none)
  var showingDivs = $(".codeContainer").filter(function() {
    return ($(this).css("display") != "none");
  }).length;

  // 100% width divided by active divs
  var width = 100 / showingDivs;

  // set the width
  $(".codeContainer").width(width + "%");

});

$("#runButton").click(function(event) {
  // find html tag in iframe and set this to html("text")
  $("iframe").contents().find("html").html('<style>' + $("#cssCode").val() + '</style>' + $("#htmlCode").val());

  // run javascript code in iframe
  document.getElementById("resultFrame").contentWindow.eval($("#jsCode").val());
});
</code>```

答: We can create styles whatever for id, or class in css,,,like you said #control{},,If there is any id or class assigned to tag / element, then only the styles gets reflected,,otherwise css wont applied. </p>

ContentLicense: CC BY-SA 3.0

Body:
I was going through this code for Codeplayer in Codepen (see link below), there is a #control{} listed in the CSS code but not mentioned in either HTML or JS code. Could anyone tell me why. Is this a mistake? I'm a newbie to web development so would really like to understand if this is standard or a trick... Thank you!

https://codepen.io/likezli/pen/dXPdJL

CSS code:

    body {
      margin: 0;
      padding: 0;
      font-family: 'Lato', sans-serif;
    }

    li {
      list-style: none;
      float: left;
    }

    a {
      color: black;
    }

    .clear {
      clear: both;
    }

    #logo {
      font-weight: bold;
      padding: 10px 0 0 10px;
      float: left;
    }

    #menuBar {
      height: 40px;
      width: 100%;
      background-color: #EDEDED;
      border-bottom: 1px solid #C8C8C8;
      box-sizing: border-box;
    }

    #buttonDiv {
      float: right;
      padding: 5px 15px 0 0;
    }

    #runButton {
      font-size: 110%
    }

    #control {}

    #toggleDiv {
      height: 40px;
      margin: auto;
      width: 20%;
      box-sizing: border-box;
      padding-top: 5px;
      position: relative;
    }

    #toggles {
      float: left;
      margin: 0;
      list-style: none;
      padding-left: 0;
      box-sizing: border-box;
      border: 1px solid #D3D3D3;
      border-radius: 5px;
    }

    #toggles li {
      float: left;
      border-right: 1px solid #D3D3D3;
      box-sizing: border-box;
      padding: 5px 8px 4px 7px;
    }

    .codeContainer {
      height: 100%;
      width: 50%;
      float: left;
      position: relative;
    }

    .codeContainer textarea {
      width: 100%;
      height: 100%;
      border: none;
      border-right: 1px solid #E5E5E5;
      font-family: SourceCodeProRegular, Menlo, Monaco, consolas, monospace;
      font-size: 90%;
      box-sizing: border-box;
      padding: 30px 0 5px 5px;
    }

    .codeLabel {
      position: absolute;
      right: 10px;
      top: 10px;
    }

    #cssContainer,
    #jsContainer {
      display: none;
    }

    iframe {
      height: 100%;
      position: relative;
      width: 100%;
      border: none;
      padding-top: 30px;
    }

    .selected {
      background-color: #EAF3FF;
    }

    a {
      text-decoration: none;
    }

    a:visited {
      color: #000000;
    }

**here is the html code:**

          CodePlayer

          <button id="runButton">Run</button>

HTML

CSS

JS

Result

HTML

        <textarea id="htmlCode">

</textarea>

CSS

        <textarea id="cssCode"></textarea>

Javascript

        <textarea id="jsCode"></textarea>

Output

**JS Code:**

var windowHeight = $(window).height();
var menuBarHeight = $("#menuBar").height();

// code container height calculated
var codeContainerHeight = windowHeight - menuBarHeight;
$(".codeContainer").height(codeContainerHeight + "px");

// Toggling between HTML, CSS, JS and Output
$(".toggle").click(function(event) {
  // toggle items in menuBar
  $(this).toggleClass("selected");

  // get html of list item (html, css, js or result) in lowercase
  var activeDiv = $(this).html().toLowerCase();

  // combine it to one of the cor container id's (htmlContainer, cssContainer, etc.)
  // toggle show or hide
  $("#" + activeDiv + "Container").toggle();

  // count the container id's which are not hidden (display != none)
  var showingDivs = $(".codeContainer").filter(function() {
    return ($(this).css("display") != "none");
  }).length;

  // 100% width divided by active divs
  var width = 100 / showingDivs;

  // set the width
  $(".codeContainer").width(width + "%");

});

$("#runButton").click(function(event) {
  // find html tag in iframe and set this to html("text")
  $("iframe").contents().find("html").html('' + $("#htmlCode").val());

  // run javascript code in iframe
  document.getElementById("resultFrame").contentWindow.eval($("#jsCode").val());
});


问:
What's the difference between the variable name of an array and the address of that array?
In C++, the following code will compile:

```<code>int a[5];
int (*b)[5] = &a;
</code>```

while this won't:

```<code>int a[5];
int (*b)[5] = a;
</code>```

When compiling the second one, g++ gives me an error, saying "cannot convert 'int*' to 'int (*)[5]' in initialization".

However, I thought that a and &a are just the same because

```<code>std::cout << a << std::endl;
</code>```

and

```<code>std::cout << &a << std::endl;
</code>```

produce the same result.

Apparently, there is a difference between a, which is the name of the array variable, and &a, which is the address of that array. But what exactly is the difference?

答: In C and C++ an array within an expression decays to a pointer to it's first element. So, in you seconds example, the left is initialized with a int* to the right.</p>

Body:
In C++, the following code will compile:

int a[5];
int (*b)[5] = &a;

while this won't:

int a[5];
int (*b)[5] = a;

When compiling the second one, g++ gives me an error, saying "cannot convert 'int*' to 'int (*)[5]' in initialization".

However, I thought that a and &a are just the same because

std::cout << a << std::endl;

and

std::cout << &a << std::endl;

produce the same result.

Apparently, there is a difference between a, which is the name of the array variable, and &a, which is the address of that array. But what exactly is the difference?


问:
uwp random sized thumbnails make look adaptiveGridView ugly
In my app I am retrieving thumbnails of only the video files. and I am using AdaptiveGridview of uwp community toolkit with some other file properties to show on the UI.

Problem:

Some files return null thumbnail so I have to fill their BitmapImage with StoreLogo and then bind it to the Image on the UI. StoreLogo looks very weird on screen because it is larger in size.

Some other files return a relatively larger thumbnail size so it looks weird on the UI.

Both storeLogo and larger thumbnail cover more space and hence hide the title of the video file from the UI (because Image height and width are auto, as they must be responsive with AdaptiveGridView).

Expectation

I want to make a solution in which I can retrieve the same size of thumbnails in all 3 cases, i.e; normal thumbnail, larger thumbnail and storelogo alternative. And I want all of them to be Uniform to Fill and scaled according to the device screen PPI.

Tried

I tried to set decoderpixelheight and width on BitmapImage object but that fixes the size of the image and it looks constricted which isn't a pretty look for the user. I know it can be achieved by setting fixed height and width on image on the UI, but then it won't be responsive according to adaptive gridview.

CODE

XAML

```<code><controls:AdaptiveGridView Name="AllVideosGridView"
                           Style="{StaticResource MainGridView}"
                           ItemsSource="{x:Bind ViewModel.Videos}">
    <controls:AdaptiveGridView.ItemTemplate>
        <DataTemplate x:DataType="data:Video">
            <StackPanel Style="{StaticResource MainGridViewStack}" >
                <Grid>
                    <Image  Source="{x:Bind Display, Mode=OneWay}" x:Phase="3" Style="{StaticResource GridViewImage}" x:Name="ThumbImage"/>
                    <Border ... >
                        <TextBlock ..."/>
                    </Border>
                </Grid>
                <TextBlock .../>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" >
                    <TextBlock ...>
                    <TextBlock ..."/>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </controls:AdaptiveGridView.ItemTemplate>
</controls:AdaptiveGridView>
</code>```

<...Styles...>

```<code><Style TargetType="Image" x:Key="GridViewImage">
    <Setter Property="Stretch" Value="UniformToFill"/>
    <Setter Property="HorizontalAlignment" Value="Center"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
</Style>

<Style TargetType="controls:AdaptiveGridView" x:Key="MainGridView">
    <Setter Property="OneRowModeEnabled" Value="False"/>
    <Setter Property="DesiredWidth" Value="220"/>
    <Setter Property="SelectionMode" Value="Single"/>
    <Setter Property="StretchContentForSingleRow" Value="False"/>
    <Setter Property="IsItemClickEnabled" Value="True"/>
</Style>
</code>```

Function For getting BitmapImage

```<code> public static async Task<BitmapImage> GetDisplay(StorageFile MyVideoFile)
    {
        var bitm = new BitmapImage();
        using (var imgSource = await MyVideoFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.VideosView, 200, ThumbnailOptions.UseCurrentScale))
        {
            if (imgSource != null) { await bitm.SetSourceAsync(imgSource); }
            else
            {
                var storageLogoFile = await (await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"))
                                             .GetFileAsync("StoreLogo.png");
                bitm.UriSource = new Uri(storageLogoFile.Path);
            }
        }
        return bitm;
    }
</code>```

Code To assign value to Image element

```<code>Display = await FileHelper.GetDisplay(file) // Display is property of type ImageSource and is bind to Image element in the datatemplate.
</code>```

Update

Here are 2 screenshots showing the problem,

screenshot 1 :
Showing a thumbnail marked with red arrow on bottom left corner it has more height than other normal thumbnails, hence it overlaps other elements, i.e : video file name and other stuff below it.

screenshot 2 :
Showing the same kind of problem, 2 thumbnails returned null so replaced with StoreLogo.png from the assets and they are also showing same type of ugly UI.

I want to fix these 2 scenarios and want the size of the image to be exactly like all other normal thumbnails (as shown in the screenshots).

答:
I think your issue can be fixed by replacing the top level StackPanel inside the ItemTemplate with a Grid.

The reason being the StackPanel will give whatever the child asks for, where a Grid can restrict its children to proportional sizes. In your case, no matter how big or small each tile is, you want all images to have the same proportional size. An example is -

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="3*" />
        <RowDefinition Height="1*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Image Stretch="UniformToFill" Grid.Row="0" />
    <TextBlock Grid.Row="1" />
    <TextBlock Grid.Row="2" />
</Grid>
```

I actually did exactly this(0:06) in one of the apps I have developed. :) Note the images are all with different sizes but they appear to be the same on the tiles.

ContentLicense: CC BY-SA 4.0

Body:
In my app I am retrieving thumbnails of only the video files. and I am using AdaptiveGridview of uwp community toolkit with some other file properties to show on the UI.

Problem:

Some files return null thumbnail so I have to fill their BitmapImage with StoreLogo and then bind it to the Image on the UI. StoreLogo looks very weird on screen because it is larger in size.

Some other files return a relatively larger thumbnail size so it looks weird on the UI.

Both storeLogo and larger thumbnail cover more space and hence hide the title of the video file from the UI (because Image height and width are auto, as they must be responsive with AdaptiveGridView).

Expectation

I want to make a solution in which I can retrieve the same size of thumbnails in all 3 cases, i.e; normal thumbnail, larger thumbnail and storelogo alternative. And I want all of them to be Uniform to Fill and scaled according to the device screen PPI.

Tried

I tried to set decoderpixelheight and width on BitmapImage object but that fixes the size of the image and it looks constricted which isn't a pretty look for the user. I know it can be achieved by setting fixed height and width on image on the UI, but then it won't be responsive according to adaptive gridview.

CODE

XAML

<controls:AdaptiveGridView Name="AllVideosGridView"
                           Style="{StaticResource MainGridView}"
                           ItemsSource="{x:Bind ViewModel.Videos}">
    <controls:AdaptiveGridView.ItemTemplate>
        <DataTemplate x:DataType="data:Video">
            <StackPanel Style="{StaticResource MainGridViewStack}" >
                <Grid>
                    <Image  Source="{x:Bind Display, Mode=OneWay}" x:Phase="3" Style="{StaticResource GridViewImage}" x:Name="ThumbImage"/>
                    <Border ... >
                        <TextBlock ..."/>
                    </Border>
                </Grid>
                <TextBlock .../>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" >
                    <TextBlock ...>
                    <TextBlock ..."/>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </controls:AdaptiveGridView.ItemTemplate>
</controls:AdaptiveGridView>

<...Styles...>

Function For getting BitmapImage

 public static async Task<BitmapImage> GetDisplay(StorageFile MyVideoFile)
    {
        var bitm = new BitmapImage();
        using (var imgSource = await MyVideoFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.VideosView, 200, ThumbnailOptions.UseCurrentScale))
        {
            if (imgSource != null) { await bitm.SetSourceAsync(imgSource); }
            else
            {
                var storageLogoFile = await (await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"))
                                             .GetFileAsync("StoreLogo.png");
                bitm.UriSource = new Uri(storageLogoFile.Path);
            }
        }
        return bitm;
    }

Code To assign value to Image element

Display = await FileHelper.GetDisplay(file) // Display is property of type ImageSource and is bind to Image element in the datatemplate.

Update

Here are 2 screenshots showing the problem,

screenshot 1 :
Showing a thumbnail marked with red arrow on bottom left corner it has more height than other normal thumbnails, hence it overlaps other elements, i.e : video file name and other stuff below it.

screenshot 2 :
Showing the same kind of problem, 2 thumbnails returned null so replaced with StoreLogo.png from the assets and they are also showing same type of ugly UI.

I want to fix these 2 scenarios and want the size of the image to be exactly like all other normal thumbnails (as shown in the screenshots).

Body:
I think your issue can be fixed by replacing the top level StackPanel inside the ItemTemplate with a Grid.

The reason being the StackPanel will give whatever the child asks for, where a Grid can restrict its children to proportional sizes. In your case, no matter how big or small each tile is, you want all images to have the same proportional size. An example is -

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="3*" /> <!--This row will take 75% of the rest of the space (i.e. total height - the height of the 3rd row)-->
        <RowDefinition Height="1*" /> <!--This row will take 25% of the rest of the space (i.e. total height - the height of the 3rd row)-->
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Image Stretch="UniformToFill" Grid.Row="0" /> <!--0 is the default so you can safely remove Grid.Row="0" here-->
    <TextBlock Grid.Row="1" />
    <TextBlock Grid.Row="2" />
</Grid>

I actually did exactly this(0:06) in one of the apps I have developed. :) Note the images are all with different sizes but they appear to be the same on the tiles.


问:
R - read csv by chunks process them in parallel
How can I read a CSV file by chunks (its size is too large to read in once), and process all chunks using parallel package? Let's say I want to calculate the average of a column by chunks.

Without parallel I would use something like this:

```<code>library(readr)

f <- function(df_chunk, pos) mean(df_chunk$'mpg')

res <- read_csv_chunked(readr_example("mtcars.csv"), DataFrameCallback$new(f), chunk_size=10)
</code>```

The result is:

```<code>> res
      [,1]
[1,] 20.37
[2,] 19.89
[3,] 20.39
[4,] 18.20
</code>```

So I want these 4 average values to be calculated by child processes. Some code to achieve this could be something like this:

```<code>library(foreach)
library(doParallel)

registerDoParallel(6)

calc_avg <- function (iterable_df_chunks) {
  foreach(df_chunk = iterable_df_chunks, .combine = c) %dopar%
    mean(df_chunk$'mpg')
}

calc_avg(< some code with read_csv_chunked() >)

stopImplicitCluster()
</code>```

Thank you!

答:
Ok, I found a working solution. Function load_CPU only does some CPU intensive calculation to check that really the child processes do the job:

```<code>load_CPU <- function(n){
  i=3
  v=c(2)
  while (length(v)<=n-1){

    if (all((i%%v[v<ceiling(sqrt(i))])!=0)){
      v=c(v,i)
    }
    i=i+2;
  }
  return(v)
}

calc_avg <- function (path) foreach(y = read_csv_chunked(path, ListCallback$new(function (x, pos) x),
    chunk_size = 10), .combine = rbind, .export=c('load_CPU')) %dopar% {
        load_CPU(10000)
        mean(y$'mpg')
    }

calc_avg(readr_example("mtcars.csv"))
</code>```

The result is:

```<code>          [,1]
result.1 20.37
result.2 19.89
result.3 20.39
result.4 18.20
</code>```

Body:
How can I read a CSV file by chunks (its size is too large to read in once), and process all chunks using parallel package? Let's say I want to calculate the average of a column by chunks.

Without parallel I would use something like this:

library(readr)

f <- function(df_chunk, pos) mean(df_chunk$'mpg')

res <- read_csv_chunked(readr_example("mtcars.csv"), DataFrameCallback$new(f), chunk_size=10)

The result is:

> res
      [,1]
[1,] 20.37
[2,] 19.89
[3,] 20.39
[4,] 18.20

So I want these 4 average values to be calculated by child processes. Some code to achieve this could be something like this:

library(foreach)
library(doParallel)

registerDoParallel(6)

calc_avg <- function (iterable_df_chunks) {
  foreach(df_chunk = iterable_df_chunks, .combine = c) %dopar%
    mean(df_chunk$'mpg')
}

calc_avg(< some code with read_csv_chunked() >)

stopImplicitCluster()

Thank you!

Body:
Ok, I found a working solution. Function load_CPU only does some CPU intensive calculation to check that really the child processes do the job:

load_CPU <- function(n){
  i=3
  v=c(2)
  while (length(v)<=n-1){

    if (all((i%%v[v<ceiling(sqrt(i))])!=0)){
      v=c(v,i)
    }
    i=i+2;
  }
  return(v)
}

calc_avg <- function (path) foreach(y = read_csv_chunked(path, ListCallback$new(function (x, pos) x),
    chunk_size = 10), .combine = rbind, .export=c('load_CPU')) %dopar% {
        load_CPU(10000)
        mean(y$'mpg')
    }

calc_avg(readr_example("mtcars.csv"))

The result is:

          [,1]
result.1 20.37
result.2 19.89
result.3 20.39
result.4 18.20


问:
CSharpAddImportCodeFixProvider encountered an error and has been disabled
I had my PC re-imaged for me. I have Visual Studio Version 14.0.25123.00 Update 2 installed on my computer. I'm getting this error when I try to use VS intellisense to reference another project.

CSharpAddImportCodeFixProvider encountered an error and has been disabled

I have two projects. One of them using namespace ProjectName.Web. And the other project using ProjectName.Web.Controllers. The provider crashes when I reference ProjectName.Web.Controllers, I believe because it is setup as a project. Any idea how to fix this?

答:
There may be multiple reasons why this error occurs. So this answer may not apply to all situations, though it seems that it only occurs when another project is referenced.

The error does not occur for all statements. In my case I had the following code:

```<code>private System.Threading.Timer Timer;

public void Start()
{
    Timer.Change(0, 60000);
}
</code>```

As soon as intellisense would open for Timer.Change( the error occurred. Please note that I had no parameters at that point. If valid parameters are present there will be no error.

I could solve the issue by updating the version of the framework. I found out that both projects targetted different frameworks, resp. 4.5.2 and 4.6.

As long as the framework versions are different the error occurs. As soon as both are equal (either 4.5.2 or 4.6) the error no longer shows.

I have tested this with VisualStudioVersion = 14.0.25420.1 (Visual Studio Community 2015).

-- update --

I've reported this as a bug to Microsoft. Including steps to reproduce.

Body:
There may be multiple reasons why this error occurs. So this answer may not apply to all situations, though it seems that it only occurs when another project is referenced.

The error does not occur for all statements. In my case I had the following code:

private System.Threading.Timer Timer;

public void Start()
{
    Timer.Change(0, 60000);
}

As soon as intellisense would open for Timer.Change( the error occurred. Please note that I had no parameters at that point. If valid parameters are present there will be no error.

I could solve the issue by updating the version of the framework. I found out that both projects targetted different frameworks, resp. 4.5.2 and 4.6.

As long as the framework versions are different the error occurs. As soon as both are equal (either 4.5.2 or 4.6) the error no longer shows.

I have tested this with VisualStudioVersion = 14.0.25420.1 (Visual Studio Community 2015).

-- update --

I've reported this as a bug to Microsoft. Including steps to reproduce.


问:
How to use not equal to inside a Yii2 query
I want to use a yii2 query in which I want to check a not equal to condition.

I tried like this but it didn't give the desired results. How do I do it?

```<code>$details =  MovieShows::find()
   ->where(['movie_id'=>$id])
   ->andWhere(['location_id'=>$loc_id])
   ->andWhere(['cancel_date'=>!$date])
   ->all();
</code>```

答:
You can use this        </p>

```<code>$this->find()->where(['resource_id' => $resource_id]) ->andWhere(['>=', 'start_time', $start_time])->all();
</code>```

Body:
I want to use a yii2 query in which I want to check a not equal to condition.

I tried like this but it didn't give the desired results. How do I do it?

$details =  MovieShows::find()
   ->where(['movie_id'=>$id])
   ->andWhere(['location_id'=>$loc_id])
   ->andWhere(['cancel_date'=>!$date])
   ->all();

Body:
You can use this

$this->find()->where(['resource_id' => $resource_id]) ->andWhere(['>=', 'start_time', $start_time])->all();


问:
Java toString() using reflection?
I was writing a toString() for a class in Java the other day by manually writing out each element of the class to a String and it occurred to me that using reflection it might be possible to create a generic toString() method that could work on ALL classes. I.E. it would figure out the field names and values and send them out to a String.

Getting the field names is fairly simple, here is what a co-worker came up with:

```<code>public static List initFieldArray(String className) throws ClassNotFoundException {

    Class c = Class.forName(className);
    Field field[] = c.getFields();
    List<String> classFields = new ArrayList(field.length);

    for (int i = 0; i < field.length; i++) {
        String cf = field[i].toString();
        classFields.add(cf.substring(cf.lastIndexOf(".") + 1));
    }

    return classFields;
}
</code>```

Using a factory I could reduce the performance overhead by storing the fields once, the first time the toString() is called. However finding the values could be a lot more expensive.

Due to the performance of reflection this may be more hypothetical then practical. But I am interested in the idea of reflection and how I can use it to improve my everyday programming.

答:
W/reflection, as I hadn't been aware of the apache library:

(be aware that if you do this you'll probably need to deal with subobjects and make sure they print properly - in particular, arrays won't show you anything useful)

```<code>@Override
public String toString()
{
    StringBuilder b = new StringBuilder("[");
    for (Field f : getClass().getFields())
    {
        if (!isStaticField(f))
        {
            try
            {
                b.append(f.getName() + "=" + f.get(this) + " ");
            } catch (IllegalAccessException e)
            {
                // pass, don't print
            }
        }
    }
    b.append(']');
    return b.toString();
}

private boolean isStaticField(Field f)
{
    return Modifier.isStatic(f.getModifiers());
}
</code>```

OwnerDisplayName: nemo

ContentLicense: CC BY-SA 2.5

Title: Java toString() using reflection?

Body:
I was writing a toString() for a class in Java the other day by manually writing out each element of the class to a String and it occurred to me that using reflection it might be possible to create a generic toString() method that could work on ALL classes. I.E. it would figure out the field names and values and send them out to a String.

Getting the field names is fairly simple, here is what a co-worker came up with:

public static List initFieldArray(String className) throws ClassNotFoundException {

    Class c = Class.forName(className);
    Field field[] = c.getFields();
    List<String> classFields = new ArrayList(field.length);

    for (int i = 0; i < field.length; i++) {
        String cf = field[i].toString();
        classFields.add(cf.substring(cf.lastIndexOf(".") + 1));
    }

    return classFields;
}

Using a factory I could reduce the performance overhead by storing the fields once, the first time the toString() is called. However finding the values could be a lot more expensive.

Due to the performance of reflection this may be more hypothetical then practical. But I am interested in the idea of reflection and how I can use it to improve my everyday programming.

Body:
W/reflection, as I hadn't been aware of the apache library:

(be aware that if you do this you'll probably need to deal with subobjects and make sure they print properly - in particular, arrays won't show you anything useful)

@Override
public String toString()
{
    StringBuilder b = new StringBuilder("[");
    for (Field f : getClass().getFields())
    {
        if (!isStaticField(f))
        {
            try
            {
                b.append(f.getName() + "=" + f.get(this) + " ");
            } catch (IllegalAccessException e)
            {
                // pass, don't print
            }
        }
    }
    b.append(']');
    return b.toString();
}

private boolean isStaticField(Field f)
{
    return Modifier.isStatic(f.getModifiers());
}

OwnerDisplayName: Steve B.


问:
Detect Graphical Login In Bash
I am managing computers and accounts in my classroom, which is a CentOS 5.5 environment.  I am trying to figure out how to use the .bashrc file (or similar) to ensure that a task runs when a user logs in via Gnome/GDM, that is, logs into a GUI session, but that that task does not run when a user logs in via SSH or other terminal logins.  How can I accomplish this?</p>

答: check the value of $DISPLAY</p>

Title: Detect Graphical Login In Bash

Body: check the value of $DISPLAY


问:
how to dynamically highlight marker based on passed data to google map
How to highlight the marker based on the scroll of the div the div is shown below

My Html DOM

```<code><div data-value="data 1"></div>
<div data-value="data 2"></div>
<div data-value="data 3"></div>
<div data-value="data 4"></div>
</code>```

My javascript

```<code>var cutoff = $(window).scrollTop() + 200;

$('div').each(function(){
    if($(this).offset().top + $(this).height() > cutoff){
        $('div').removeClass('current');
        $(this).addClass('current');
        console.log($(this).data('value'));

        //callGoogleMapHere(data..);

        return false; // stops the iteration after the first one on
    }
});
</code>```

here is example of working code: http://jsfiddle.net/pdzTW/212/

As you have noted callGoogleMapHere(data..); in the above code, i want to call google map from there with data passed so that i can Highlight the Marker on map.

here is my map code link(thanks to geocodezip) : http://jsfiddle.net/2gz7h123/64/

Question: i want to highlight the marker dynamically on Google map passing data from this function  callGoogleMapHere(data..);

please help me thanks in advance!!!

答:
I appreciate that you are stuck and require help. However this is not a site in which people will simply do you work for you.

It appears that you lack the knowledge of what you are trying to achieve and simply want the work done. I therefore have a compromise which given the research you have conducted you should be able to obtain a plausible solution.

Given a set of divs

```<code> <div data-value="0" class="notmap"></div>
 <div data-value="1" class="notmap"></div>
 <div data-value="2" class="notmap"></div>
 <div data-value="3" class="notmap"></div>
 <div data-value="4" class="notmap"></div>
</code>```

we want to be able to call some function when they are hovered over. In your solution the same thing will be applied on the scroll.

using:

```<code>$(document).ready(function() {
  alert('please scroll output window and check the console');
  $(".notmap").hover(function() {
    highlightMarker($(this).data('value'));
  }, function() {
    stopHighlightMarker($(this).data('value'));
  });
});
</code>```

this will call the highlightMarkerfunction on hover and stopHighlightMarker when you stop hovering over the div.

The highlight marker does the following:

```<code>function highlightMarker(i) {
  if (markers[i].getAnimation() !== null) {
    markers[i].setAnimation(null);
  } else {
    markers[i].setAnimation(google.maps.Animation.BOUNCE);
  }
}
</code>```

Essentially I added an array of markers and it grabs the markers[i] element by passed through, the data-value number. Its a cheap way but hey-ho.

It then simple animates the icon so that it is visible and highlighted by bouncing up and down.

I appreciate that this is not really an answer to your question, but with the information I have provided should be sufficient to get your problem solved.

JSFIDDLE: http://jsfiddle.net/2gz7h123/68/

Body:
How to highlight the marker based on the scroll of the div the div is shown below

My Html DOM

My javascript

var cutoff = $(window).scrollTop() + 200;

$('div').each(function(){
    if($(this).offset().top + $(this).height() > cutoff){
        $('div').removeClass('current');
        $(this).addClass('current');
        console.log($(this).data('value'));

        //callGoogleMapHere(data..);

        return false; // stops the iteration after the first one on
    }
});

here is example of working code: http://jsfiddle.net/pdzTW/212/

As you have noted callGoogleMapHere(data..); in the above code, i want to call google map from there with data passed so that i can Highlight the Marker on map.

here is my map code link(thanks to geocodezip) : http://jsfiddle.net/2gz7h123/64/

Question: i want to highlight the marker dynamically on Google map passing data from this function  callGoogleMapHere(data..);

please help me thanks in advance!!!

Body:
I appreciate that you are stuck and require help. However this is not a site in which people will simply do you work for you.

It appears that you lack the knowledge of what you are trying to achieve and simply want the work done. I therefore have a compromise which given the research you have conducted you should be able to obtain a plausible solution.

Given a set of divs

 <div data-value="0" class="notmap"></div>
 <div data-value="1" class="notmap"></div>
 <div data-value="2" class="notmap"></div>
 <div data-value="3" class="notmap"></div>
 <div data-value="4" class="notmap"></div>

we want to be able to call some function when they are hovered over. In your solution the same thing will be applied on the scroll.

using:

$(document).ready(function() {
  alert('please scroll output window and check the console');
  $(".notmap").hover(function() {
    highlightMarker($(this).data('value'));
  }, function() {
    stopHighlightMarker($(this).data('value'));
  });
});

this will call the highlightMarkerfunction on hover and stopHighlightMarker when you stop hovering over the div.

The highlight marker does the following:

function highlightMarker(i) {
  if (markers[i].getAnimation() !== null) {
    markers[i].setAnimation(null);
  } else {
    markers[i].setAnimation(google.maps.Animation.BOUNCE);
  }
}

Essentially I added an array of markers and it grabs the markers[i] element by passed through, the data-value number. Its a cheap way but hey-ho.

It then simple animates the icon so that it is visible and highlighted by bouncing up and down.

I appreciate that this is not really an answer to your question, but with the information I have provided should be sufficient to get your problem solved.

JSFIDDLE: http://jsfiddle.net/2gz7h123/68/


问:
PHP if statement inside HTML attribute
I was wondering something. I'm looking at code from other trainees (who left, so I can't ask anything). I see the following:

```<code><input type="text"
name="name"
class="form-control"
placeholder="name"
value="<?php if (isset($something)): echo 'bla';
             else: if(!empty($somethingelse)): echo 'bla2'; endif;"
>
</code>```

This actually does look pretty ugly if I say so myself. I was wondering: is this actually a "good"/okay way to do it or is it really as bad as I think?

答:
Try this  </p>

```<code>  <input type="text"
    name="name"
    class="form-control"
    placeholder="name"
    value="<?php echo isset($something) ? 'bla' : (!empty($somethingelse) ? 'bla2' : ''); ?>" >
</code>```

Title: PHP if statement inside HTML attribute

Body:
I was wondering something. I'm looking at code from other trainees (who left, so I can't ask anything). I see the following:

<input type="text"
name="name"
class="form-control"
placeholder="name"
value="<?php if (isset($something)): echo 'bla';
             else: if(!empty($somethingelse)): echo 'bla2'; endif;"
>

This actually does look pretty ugly if I say so myself. I was wondering: is this actually a "good"/okay way to do it or is it really as bad as I think?

Body:
Try this

  <input type="text"
    name="name"
    class="form-control"
    placeholder="name"
    value="<?php echo isset($something) ? 'bla' : (!empty($somethingelse) ? 'bla2' : ''); ?>" >


问:
Center Input box and Font Awesome icons
Others have asked something similar but I seem to be struggling vertical aligning the font awesome icon with an input box.  It works okay when you don`t use the sizing to increase the font awesome icons, but as soon as you enter the fa-3x or something like that the margin-top gets added.

Does anybody have any ideas ?

Simple example would be:

```<code><div>
    <i class='icon icon-3x icon-camera'></i>
    <span id="inputfield">
      <input type="text" value="input here">
    </span>
</div>

div {
    border: 1px solid #ccc;
    height: 30px;
    margin: 60px;
    padding: 4px;
    vertical-align: middle;
}
i{
    float: left;
}
#inputfield{
    line-height: 30px;
    float: left;
}
</code>```

答:
Flexbox is magic, Flexbox is our savior.

div{
   border : blue dashed 1px;
   display : flex;
   align-items : center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
    <img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-camera-128.png"/>
    <input type="text" placeholder="input here">
</div></code>```

Title: Center Input box and Font Awesome icons

Body:
Others have asked something similar but I seem to be struggling vertical aligning the font awesome icon with an input box.  It works okay when you don`t use the sizing to increase the font awesome icons, but as soon as you enter the fa-3x or something like that the margin-top gets added.

Does anybody have any ideas ?

Simple example would be:

      <input type="text" value="input here">

div {
    border: 1px solid #ccc;
    height: 30px;
    margin: 60px;
    padding: 4px;
    vertical-align: middle;
}
i{
    float: left;
}
#inputfield{
    line-height: 30px;
    float: left;
}

Body:
Flexbox is magic, Flexbox is our savior.

div{
   border : blue dashed 1px;
   display : flex;
   align-items : center;
}

<div>
    <img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-camera-128.png"/>
    <input type="text" placeholder="input here">
</div>


问:
jsx style with condition
I know I can do condition with className but how about style?

```<code><span style={{float:'right'}}>Something</span>
</code>```

Like for above jsx, I want to float right if obj.name is equal to 'active'

答:
You can follow the below mentioned Pattern.

```<code>reder(){
return(
let myStyle = {float:right; marginBottom:10;} //in JSX/JS hyphen sign is replaced with Camel case notation, it will automatically detected by ReactDOM renderer.
<span style={myStyle}></span>
);
}
</code>```

for specifying any condition:

```<code>reder(){
return(
let myStyle = (obj.name == "active") ? {float:right; marginBottom:10;} : {};
<span style={myStyle}></span>
);
}
</code>```

Title: jsx style with condition

Body:
I know I can do condition with className but how about style?

Something

Like for above jsx, I want to float right if obj.name is equal to 'active'

Body:
You can follow the below mentioned Pattern.

reder(){
return(
let myStyle = {float:right; marginBottom:10;} //in JSX/JS hyphen sign is replaced with Camel case notation, it will automatically detected by ReactDOM renderer.
<span style={myStyle}></span>
);
}

for specifying any condition:

reder(){
return(
let myStyle = (obj.name == "active") ? {float:right; marginBottom:10;} : {};
<span style={myStyle}></span>
);
}


问:
rails 3 redirect_to pass params to a named route
I am not finding much info on how to do this even though there are lots of suggestions on how to pass params to a redirect using hashs like this redirect_to

```<code>:action => 'something', :controller => 'something'
</code>```

in my app I have the following in the routes file

```<code>match 'profile'   =>  'User#show'
</code>```

my show action loos like this

```<code>def show
 @user = User.find(params[:user])
  @title = @user.first_name
end
</code>```

the redirect happens in the same user controller like this

```<code>   def register
    @title = "Registration"
    @user = User.new(params[:user])

    if @user.save
      redirect_to  '/profile'
    end
  end
</code>```

The question is in the register action when I redirect_to how do I pass along the params so I can grab that user from the database or better yet ... I already have a user variable so how do I pass along the user object to the show action?

-matthew

答:
If you're doing a redirect, Rails will actually send a 302 Moved response with a URL to the browser and the browser will send another request to that URL. So you cannot "pass the user object" as in Ruby, you can only pass some url encoded parameters.

In this case you would probably want to change your routing definition to:

```<code>match 'profile/:id' => 'User#show'
</code>```

and then redirect like this:

```<code>redirect_to "/profile/#{@user.id}"
</code>```

Body:
I am not finding much info on how to do this even though there are lots of suggestions on how to pass params to a redirect using hashs like this redirect_to

:action => 'something', :controller => 'something'

in my app I have the following in the routes file

match 'profile'   =>  'User#show'

my show action loos like this

def show
 @user = User.find(params[:user])
  @title = @user.first_name
end

the redirect happens in the same user controller like this

   def register
    @title = "Registration"
    @user = User.new(params[:user])

    if @user.save
      redirect_to  '/profile'
    end
  end

The question is in the register action when I redirect_to how do I pass along the params so I can grab that user from the database or better yet ... I already have a user variable so how do I pass along the user object to the show action?

-matthew

Body:
If you're doing a redirect, Rails will actually send a 302 Moved response with a URL to the browser and the browser will send another request to that URL. So you cannot "pass the user object" as in Ruby, you can only pass some url encoded parameters.

In this case you would probably want to change your routing definition to:

match 'profile/:id' => 'User#show'

and then redirect like this:

redirect_to "/profile/#{@user.id}"


问:
TomEE CDI @Inject NullPointerException
I'm trying to get CDI to work in my application, but I only get NullPointerExceptions when I do.

When normally instantiating the playlistService, it works perfectly fine, but when I try to use CDI, it doesn't anymore.

The server is able to start, but when I add beans.xml to META-INF/ and WEB-INF/ it's also not able to start anymore.

PlaylistRESTController.java

```<code>import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.*;

@Path("/api/playlist")
public class PlaylistRESTController {

    @Inject
    PlaylistService playlistService; //This one

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Playlist[] getUsersPlaylists(
            @CookieParam("st-session") Cookie session,
            @Context HttpServletRequest httpServletRequest
    ) {
        User user = (User) httpServletRequest.getAttribute("user");

        Playlist[] playlist = playlistService.getAllPlaylists(user);

        return playlist;
    }
}
</code>```

PlaylistService.java

```<code>public class PlaylistService implements IPlaylistService {

    PlaylistJPA playlistJPA = new PlaylistJPA();

    public Playlist[] getAllPlaylists(User owner) {
        ArrayList<Playlist> playlist = this.playlistJPA.findByOwner(owner);

        return playlist.toArray(new Playlist[playlist.size()]);
    }
}
</code>```

pom.xml

```<code><dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.6.Final</version>
    </dependency>
</dependencies>
</code>```

EDIT:

resources/META-INF/persistence.xml

```<code><?xml version="1.0" encoding="UTF-8"?>

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
   http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit
            name="mysql">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <class>
            nl.han.dea.domain.Song
        </class>
        <class>
            nl.han.dea.domain.Playlist
        </class>
        <class>
            nl.han.dea.domain.Video
        </class>
        <class>
            nl.han.dea.domain.User
        </class>

        <properties>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
            <property name="hibernate.connection.url"
                      value="jdbc:mysql://localhost:3306/Spotitube?autoReconnect=true&useSSL=false&serverTimezone=UTC"/>
            <property name="hibernate.connection.username" value="spotitube"/>
            <property name="hibernate.connection.password" value="java"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="javax.persistence.sql-load-script-source" value="insert.sql"/>
            <property name="hibernate.flushMode" value="FLUSH_AUTO"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>

    </persistence-unit>
</persistence>
</code>```

答:
you just need to add a beans.xml in WEB-INF/

Also ensure javaee-api has the scope provided, ensure to exclude jpa and jta api from hibernate-entitymanager transitive dependencies to ensure your war has the right dependencies and no conflicting API with the EE server.

Side note: using org.apache.tomee:javaee-api:7.0-1:provided instead of javax:javaee-api can also make embedded tests working (openejb or tomee-embedded)

Title: TomEE CDI @Inject NullPointerException

Body:
I'm trying to get CDI to work in my application, but I only get NullPointerExceptions when I do.

When normally instantiating the playlistService, it works perfectly fine, but when I try to use CDI, it doesn't anymore.

The server is able to start, but when I add beans.xml to META-INF/ and WEB-INF/ it's also not able to start anymore.

PlaylistRESTController.java

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.*;

@Path("/api/playlist")
public class PlaylistRESTController {

    @Inject
    PlaylistService playlistService; //This one

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Playlist[] getUsersPlaylists(
            @CookieParam("st-session") Cookie session,
            @Context HttpServletRequest httpServletRequest
    ) {
        User user = (User) httpServletRequest.getAttribute("user");

        Playlist[] playlist = playlistService.getAllPlaylists(user);

        return playlist;
    }
}

PlaylistService.java

public class PlaylistService implements IPlaylistService {

    PlaylistJPA playlistJPA = new PlaylistJPA();

    public Playlist[] getAllPlaylists(User owner) {
        ArrayList<Playlist> playlist = this.playlistJPA.findByOwner(owner);

        return playlist.toArray(new Playlist[playlist.size()]);
    }
}

pom.xml

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.6.Final</version>
    </dependency>
</dependencies>

EDIT:

resources/META-INF/persistence.xml

<?xml version="1.0" encoding="UTF-8"?>

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
   http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit
            name="mysql">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <class>
            nl.han.dea.domain.Song
        </class>
        <class>
            nl.han.dea.domain.Playlist
        </class>
        <class>
            nl.han.dea.domain.Video
        </class>
        <class>
            nl.han.dea.domain.User
        </class>

        <properties>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
            <property name="hibernate.connection.url"
                      value="jdbc:mysql://localhost:3306/Spotitube?autoReconnect=true&useSSL=false&serverTimezone=UTC"/>
            <property name="hibernate.connection.username" value="spotitube"/>
            <property name="hibernate.connection.password" value="java"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="javax.persistence.sql-load-script-source" value="insert.sql"/>
            <property name="hibernate.flushMode" value="FLUSH_AUTO"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>

    </persistence-unit>
</persistence>


答:
I always prefer to keep separated php and html parts. Here my suggestion:

```<code><?php
    $value = isset($something)
        ? 'bla'
        : 'bla2'
    ;
?>
</code>```

and

```<code><input type="text"
    name="name"
    class="form-control"
    placeholder="name"
    value="<?php echo $value; ?>">
</code>```

You can improve it more and more if you start to use twig. As you can see, there is no code here: its just a view.

```<code><input type="text"
    name="field_name"
    class="form-control"
    placeholder="field name"
    value="{{ field_name }}">
</code>```

At some point you can sent to that view variables and keep separated model (data and variables) form the view:

```<code>$value = isset($something)
    ? 'bla'
    : 'bla2'
;

$this->render('path/to/template.html.twig', [
    'field_name' => $value,
]);
</code>```

Title: PHP if statement inside HTML attribute

Body:
I always prefer to keep separated php and html parts. Here my suggestion:

<?php
    $value = isset($something)
        ? 'bla'
        : 'bla2'
    ;
?>

and

<input type="text"
    name="name"
    class="form-control"
    placeholder="name"
    value="<?php echo $value; ?>">

You can improve it more and more if you start to use twig. As you can see, there is no code here: its just a view.

<input type="text"
    name="field_name"
    class="form-control"
    placeholder="field name"
    value="{{ field_name }}">

At some point you can sent to that view variables and keep separated model (data and variables) form the view:

$value = isset($something)
    ? 'bla'
    : 'bla2'
;

$this->render('path/to/template.html.twig', [
    'field_name' => $value,
]);


问:
Replace words taken from the list in txt file in python
i have txt file with one word in each line (library.txt) like:

```<code>Word1
Word2
</code>```

Second txt file look like this:

```<code>I have got many words.
I know Word1 is very interesting.
ButWord2 is awful because its connected with another word.
I think there is no Word3 at all.
</code>```

i need to search for those words from library.txt in Second txt file and replace them so those will look like this:

```<code>I have got many words.
For example <font=yellow>Word1</font> is very interesting.
But<font=yellow>Word2</font> is awful because its connected with another word.
I think there is no Word3 at all.
</code>```

Ive got such code but it doesnt work:

```<code>rules =[]
with open(library, 'r') as libraryfile:
    for line in libraryfile:
        rules.append(line.rstrip())

with open(second', 'r') as secondfile:
    with open(third', 'w') as thirdfile:
        for line in secondfile:
            if all(rule in line for rule in rules):
                thirdfile.write(line.replace(rule, '<font color=yellow>'+rule+'</font>'))
            else:
                thirdfile.write(line)
</code>```

答:
First, you have to use any and not all. As you want at least one of them to be in rules to make changes.
Then rule is not defined outside of if, plus you might have several words from rules to replace in line, so best is to iterate over rules and replace when needed. This gives:

```<code>with open(second, 'r') as secondfile:
    with open(third, 'w') as thirdfile:
        for line in secondfile:
            if any(rule in line for rule in rules):
                for r in rules:
                    line = line.replace(r, '<font color=yellow>'+r+'</font>')
            thirdfile.write(line)
</code>```

Body:
i have txt file with one word in each line (library.txt) like:

Word1
Word2

Second txt file look like this:

I have got many words.
I know Word1 is very interesting.
ButWord2 is awful because its connected with another word.
I think there is no Word3 at all.

i need to search for those words from library.txt in Second txt file and replace them so those will look like this:

I have got many words.
For example Word1 is very interesting.
ButWord2 is awful because its connected with another word.
I think there is no Word3 at all.

Ive got such code but it doesnt work:

rules =[]
with open(library, 'r') as libraryfile:
    for line in libraryfile:
        rules.append(line.rstrip())

with open(second', 'r') as secondfile:
    with open(third', 'w') as thirdfile:
        for line in secondfile:
            if all(rule in line for rule in rules):
                thirdfile.write(line.replace(rule, ''+rule+''))
            else:
                thirdfile.write(line)

Body:
First, you have to use any and not all. As you want at least one of them to be in rules to make changes.
Then rule is not defined outside of if, plus you might have several words from rules to replace in line, so best is to iterate over rules and replace when needed. This gives:

with open(second, 'r') as secondfile:
    with open(third, 'w') as thirdfile:
        for line in secondfile:
            if any(rule in line for rule in rules):
                for r in rules:
                    line = line.replace(r, '<font color=yellow>'+r+'</font>')
            thirdfile.write(line)


问:
show 100% width child within non 100% width parent
I have a div that has max-width of let's say 1024px and I have it's child that needs to take 100% width starting at the left of the screen.

Is it possible without introducing additional markup? I understand that can make child 100% with width: 100vw; but can't seem to push it to the left.

CODE

.parent {
  max-width: 800px;
  margin: 0 auto;
}

.child {
  margin-top: 20px;
  padding: 20px;
  width: 100vw;
  background: grey;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="parent">
  Toggle content
  <div class="child">Content</div>
</div></code>```

https://codepen.io/anon/pen/QgbPJj

答:
This works.</p>

```<code>.child {
  position: absolute;
  margin-top: 20px;
  padding: 20px;
  width: 100vw;
  background: grey;
  left: 0;
  box-sizing: border-box;
}
</code>```

Body:
I have a div that has max-width of let's say 1024px and I have it's child that needs to take 100% width starting at the left of the screen.

Is it possible without introducing additional markup? I understand that can make child 100% with width: 100vw; but can't seem to push it to the left.

CODE

.parent {
  max-width: 800px;
  margin: 0 auto;
}

.child {
  margin-top: 20px;
  padding: 20px;
  width: 100vw;
  background: grey;
}

  Toggle content

Content

https://codepen.io/anon/pen/QgbPJj

Body:
This works.

.child {
  position: absolute;
  margin-top: 20px;
  padding: 20px;
  width: 100vw;
  background: grey;
  left: 0;
  box-sizing: border-box;
}


问:
SonarQube 6.2 upgrade to 6.4 Missing projects and users
On Debian Jessie I had an installed version of SonarQube 6.2 using Postgresql (latest on Jessie )
Java 8 installed
I went through the upgrade process (to v. 6.4)Here

When it came back online all the projects were missing.  I can get to them by manually typing in the URL to the project like:

https://[address of server]/dashboard?id=[Name of Project]

Also the in the user admin section (Administration>Security>Users) I see no users.
However if I go to groups (Administration>Security>Groups) my sonar user group says it has users.  In my case its 14 - but I cannot see any of them.
Can anyone help bring this stuff back? I did do a DB back-up before the upgrade - so I can always go back, but I would like to not have to do that.

答: As answered here, this seems to be a bad ElasticSearch index. Stop your server. Delete $SONARQUBE_HOME/data and restart.


问:
Loop for monthly or yearly averages by day number (in Julian day format)
I have daily '.mat' files whose nomenclature is like 'Data_grid_day_ppt_ice003.mat', the last '003' is the date of the year in Julian day format, It can start from '001' and end in '365' and '366' depending on whether it is a leap year or not.

I need monthly averages of the data. Any idea how can I make loops for the date files?

Some dates can be missing also, so just counting the number of files would not work.

I am writing in Matlab, I was trying something like

```<code>year = linspace(2007,2016,10); % Years of data
months = linspace(01,12,12);% Months of the year
for n = 1:length(year)
    foldery = int2str(year(n));
    if ~exist(folderyear)
        continue
    else
        if mod(year,4) == 0 % if the year is divisible by four
            dpm = [31 60 91 121 152 182 213 244 274 305 335 366];
        else
           dpm = [31 59 90 120 151 181 212 243 273 304 334 365];
        end
        for j = 1:length(months) %loop over months
            if ~exist(months)
                continue
            else
                for ii = 1:dpm(j)   %loop over days
                    % ... Not sure what to do here ...
                end
            end
        end
    end
end
</code>```

However, I am not able to work out the next step...

答:
It is now coming if I do Num = regexp(dayofyear,'\d','Match');
                tt=cellstr(Num{:});
                pp = strcat(tt(1),tt(2),tt(3));
                dayofyear=str2double(pp); Though it is a bit childish, but it is returning error if I do it in one line :P Thanku Wolfie :)

Body:
I have daily '.mat' files whose nomenclature is like 'Data_grid_day_ppt_ice003.mat', the last '003' is the date of the year in Julian day format, It can start from '001' and end in '365' and '366' depending on whether it is a leap year or not.

I need monthly averages of the data. Any idea how can I make loops for the date files?

Some dates can be missing also, so just counting the number of files would not work.

I am writing in Matlab, I was trying something like

year = linspace(2007,2016,10); % Years of data
months = linspace(01,12,12);% Months of the year
for n = 1:length(year)
    foldery = int2str(year(n));
    if ~exist(folderyear)
        continue
    else
        if mod(year,4) == 0 % if the year is divisible by four
            dpm = [31 60 91 121 152 182 213 244 274 305 335 366];
        else
           dpm = [31 59 90 120 151 181 212 243 273 304 334 365];
        end
        for j = 1:length(months) %loop over months
            if ~exist(months)
                continue
            else
                for ii = 1:dpm(j)   %loop over days
                    % ... Not sure what to do here ...
                end
            end
        end
    end
end

However, I am not able to work out the next step...


问:
Setting Color through Javascript based on condition
I am generating a html table through C# code in an MVC Application .

I want to color the value in table cell as red and condition for this is (if column-x value is greater than value of column-y than set color of column-x as red).

column-x and column-y have their on id,s

Below is generated HTML and javascript code which I am using

$('#body table').each(function () {
    $('#' + this.id + ' ' + 'tr').each(function () {
        var v1 = $('#TodayPDue').html();
        var v2 = $('#TodayIntDue').html();

        if (v1 > v2){
            $('#TodayPDue').css('color','red');
        }
     })
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id='CollectionRPT' class='table table-bordered table-hover'>
     <tbody>
         <tr>
            <td>1</td>
            <td>BIHAR</td>
            <td id='TodayPDue'>2220515</td>
            <td id='TodayIntDue'>457565</td>
            <td id='TodayPCollected'>0</td>
            <td id='TodayIntCollected'>0</td>
            <td id='MonthPDue'>10232468</td>
            <td id='MonthIntDue'>2058526</td>
            <td id='MonthPCollected'>5912869</td>
            <td id='MonthIntCollected'>1167760</td>
            <td id='YearPDue'>6432342</td>
            <td id='YearIntDue'>1303773</td>
            <td id='YearPCollected'>2111473</td>
            <td id='YearIntCollected'>413023</td>
         </tr>
     </tbody>
</table></code>```

Any idea why it is showing no effect ?

答:
Preface: you are using the ID in the wrong way. An id must be unique in entire html page.

Solution: this is a solution for your problem, implicitly say that you can have more than one table and more than one row for each table. So:

$(document).ready(function() {

  $('body table').each(function(index, table) {
    $table = $(table);
    $table.find('tr').each(function(rowIndex, row) {
      $row = $(row);
      var v1 = parseInt($row.find('#TodayPDue').html());
      var v2 = parseInt($row.find('#TodayIntDue').html());

      if (v1 > v2) {
        $row.find('#TodayPDue').css('color', 'red');
      } else {
        $row.find('#TodayPDue').css('color', 'green');
      }
    });

  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id='CollectionRPT' class='table table-bordered table-hover'>
  <tbody>
    <tr>
      <td>1</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>4457565</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>2</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>2220515</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>3</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>457565</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>4</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>2220513</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>5</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>2220514</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
  </tbody>
</table></code>```

Body:
I am generating a html table through C# code in an MVC Application .

I want to color the value in table cell as red and condition for this is (if column-x value is greater than value of column-y than set color of column-x as red).

column-x and column-y have their on id,s

Below is generated HTML and javascript code which I am using

$('#body table').each(function () {
    $('#' + this.id + ' ' + 'tr').each(function () {
        var v1 = $('#TodayPDue').html();
        var v2 = $('#TodayIntDue').html();

        if (v1 > v2){
            $('#TodayPDue').css('color','red');
        }
     })
});

            1
            BIHAR
            2220515
            457565
            0
            0
            10232468
            2058526
            5912869
            1167760
            6432342
            1303773
            2111473
            413023

Any idea why it is showing no effect ?

Body:
Preface: you are using the ID in the wrong way. An id must be unique in entire html page.

Solution: this is a solution for your problem, implicitly say that you can have more than one table and more than one row for each table. So:

$(document).ready(function() {

  $('body table').each(function(index, table) {
    $table = $(table);
    $table.find('tr').each(function(rowIndex, row) {
      $row = $(row);
      var v1 = parseInt($row.find('#TodayPDue').html());
      var v2 = parseInt($row.find('#TodayIntDue').html());

      if (v1 > v2) {
        $row.find('#TodayPDue').css('color', 'red');
      } else {
        $row.find('#TodayPDue').css('color', 'green');
      }
    });

  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id='CollectionRPT' class='table table-bordered table-hover'>
  <tbody>
    <tr>
      <td>1</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>4457565</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>2</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>2220515</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>3</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>457565</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>4</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>2220513</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
    <tr>
      <td>5</td>
      <td>BIHAR</td>
      <td id='TodayPDue'>2220515</td>
      <td id='TodayIntDue'>2220514</td>
      <td id='TodayPCollected'>0</td>
      <td id='TodayIntCollected'>0</td>
      <td id='MonthPDue'>10232468</td>
      <td id='MonthIntDue'>2058526</td>
      <td id='MonthPCollected'>5912869</td>
      <td id='MonthIntCollected'>1167760</td>
      <td id='YearPDue'>6432342</td>
      <td id='YearIntDue'>1303773</td>
      <td id='YearPCollected'>2111473</td>
      <td id='YearIntCollected'>413023</td>
    </tr>
  </tbody>
</table>