问:
Logic for static triangular plot
I have been trying to make a static d3 v5 version based off this block for the past few days. I have the coordinate plane drawn, but I am having trouble adapting the plot logic to a static variant. Here is my progress:

var margins = {top:50, bottom:50, left:50, right:50};

var height = 900;
var width = 900;

var totalWidth = width+margins.left+margins.right;
var totalHeight = height+margins.top+margins.bottom;

var side = 700;
var axis_labels = ['Journalist','Developer','Designer'];
var axis_ticks = [0,20,40,60,80,100];
var tickLabelMargin = 10;
var axisLabelMargin = 40;
var minor_axis_ticks = d3.range(0, 101, 5);
console.log(minor_axis_ticks)
var w = side;
var h = Math.sqrt( side*side - (side/2)*(side/2));

var corners = [
  [margins.left, h + margins.top], // a
  [ w + margins.left, h + margins.top], //b
  [(w/2) + margins.left, margins.top] ]; //c

var svg = d3.select('body')
    .append('svg')
    .attr('width', totalWidth)
    .attr('height', totalHeight);

var graphGroup = svg.append('g')
    .attr('transform', "translate("+margins.left+","+margins.top+")");

var axes = graphGroup.append('g').attr('class','axes');

var plot = {
  dataset:[]
};

var data = [
  {journalist:75,developer:25,designer:0,label:'point 1'},
  {journalist:70,developer:10,designer:20,label:'point 2'},
  {journalist:75,developer:20,designer:5,label:'point 3'},

  {journalist:5,developer:60,designer:35,label:'point 4'},
  {journalist:10,developer:80,designer:10,label:'point 5'},
  {journalist:10,developer:90,designer:0,label:'point 6'},
  {journalist:20,developer:70,designer:10,label:'point 7'},

  {journalist:10,developer:20,designer:70,label:'point 8'},
  {journalist:15,developer:5,designer:80,label:'point 9'},
  {journalist:10,developer:10,designer:80,label:'point 10'},
  {journalist:20,developer:10,designer:70,label:'point 11'},
 ];

  function lineAttributes(p1, p2){
      return { x1:p1[0], y1:p1[1],
           x2:p2[0], y2:p2[1] };
  }

axes.selectAll('.axis-title')
  .data(axis_labels)
  .enter()
   .append('g')
    .attr('class', 'axis-title')
    .attr('transform',function(d,i){
     return 'translate('+corners[i][0]+','+corners[i][1]+')';
    })
    .append('text')
    .text(function(d){ return d; })
    .attr('text-anchor', function(d,i){
     if(i===0) return 'end';
     if(i===2) return 'middle';
     return 'start';

    })
    .attr('transform', function(d,i){
     var theta = 0;
     if(i===0) theta = 120;
     if(i===1) theta = 60;
     if(i===2) theta = -90;

     var x = axisLabelMargin * Math.cos(theta * 0.0174532925),
      y = axisLabelMargin * Math.sin(theta * 0.0174532925);
     return 'translate('+x+','+y+')'
    });

        var n = axis_ticks.length;
         if(minor_axis_ticks){
          minor_axis_ticks.forEach(function(v) {
           var coord1 = coord( [v, 0, 100-v] );
           var coord2 = coord( [v, 100-v, 0] );
           var coord3 = coord( [0, 100-v, v] );
           var coord4 = coord( [100-v, 0, v] );

           axes.append("line")
            .attr('x1', lineAttributes(coord1, coord2).x1 )
                .attr('x2', lineAttributes(coord1, coord2).x2 )
                .attr('y1', lineAttributes(coord1, coord2).y1 )
                .attr('y2', lineAttributes(coord1, coord2).y2 )
            .classed('a-axis minor-tick', true);

           axes.append("line")
                .attr('x1', lineAttributes(coord2, coord3).x1 )
                .attr('x2', lineAttributes(coord2, coord3).x2 )
                .attr('y1', lineAttributes(coord2, coord3).y1 )
                .attr('y2', lineAttributes(coord2, coord3).y2 )
            .classed('b-axis minor-tick', true);

           axes.append("line")
                .attr('x1', lineAttributes(coord3, coord4).x1 )
                .attr('x2', lineAttributes(coord3, coord4).x2 )
                .attr('y1', lineAttributes(coord3, coord4).y1 )
                .attr('y2', lineAttributes(coord3, coord4).y2 )
            .classed('c-axis minor-tick', true);
          });
         }

          axis_ticks.forEach(function(v) {
          var coord1 = coord( [v, 0, 100-v] );
          var coord2 = coord( [v, 100-v, 0] );
          var coord3 = coord( [0, 100-v, v] );
          var coord4 = coord( [100-v, 0, v] );

          axes.append("line")
              .attr('x1', lineAttributes(coord1, coord2).x1 )
              .attr('x2', lineAttributes(coord1, coord2).x2 )
              .attr('y1', lineAttributes(coord1, coord2).y1 )
              .attr('y2', lineAttributes(coord1, coord2).y2 )
           .classed('a-axis tick', true);

          axes.append("line")
              .attr('x1', lineAttributes(coord2, coord3).x1 )
              .attr('x2', lineAttributes(coord2, coord3).x2 )
              .attr('y1', lineAttributes(coord2, coord3).y1 )
              .attr('y2', lineAttributes(coord2, coord3).y2 )
           .classed('b-axis tick', true);

          axes.append("line")
              .attr('x1', lineAttributes(coord3, coord4).x1 )
              .attr('x2', lineAttributes(coord3, coord4).x2 )
              .attr('y1', lineAttributes(coord3, coord4).y1 )
              .attr('y2', lineAttributes(coord3, coord4).y2 )
           .classed('c-axis tick', true);

              //tick labels
            axes.append('g')
             .attr('transform',function(d){
              return 'translate(' + coord1[0] + ',' + coord1[1] + ')'
             })
             .append("text")
              .attr('transform','rotate(60)')
              .attr('text-anchor','end')
              .attr('x',-tickLabelMargin)
              .text( function (d) { return v; } )
              .classed('a-axis tick-text', true );

            axes.append('g')
             .attr('transform',function(d){
              return 'translate(' + coord2[0] + ',' + coord2[1] + ')'
             })
             .append("text")
              .attr('transform','rotate(-60)')
              .attr('text-anchor','end')
              .attr('x',-tickLabelMargin)
              .text( function (d) { return (100- v); } )
              .classed('b-axis tick-text', true);

            axes.append('g')
             .attr('transform',function(d){
              return 'translate(' + coord3[0] + ',' + coord3[1] + ')'
             })
             .append("text")
              .text( function (d) { return v; } )
              .attr('x',tickLabelMargin)
              .classed('c-axis tick-text', true);

           })

          function coord(arr){
            var a = arr[0], b=arr[1], c=arr[2];
            var sum, pos = [0,0];
              sum = a + b + c;
              if(sum !== 0) {
                a /= sum;
                b /= sum;
                c /= sum;
              pos[0] =  corners[0][0]  * a + corners[1][0]  * b + corners[2][0]  * c;
              pos[1] =  corners[0][1]  * a + corners[1][1]  * b + corners[2][1]  * c;
            }
              return pos;
          }

          function scale(p, factor) {
             return [p[0] * factor, p[1] * factor];
         }

          plot.data = function(data, accessor, bindBy){ //bind by is the dataset property used as an id for the join
          plot.dataset = data;
            console.log(data)

          var circles = graphGroup.selectAll("circle")
           .data( data.map( function(d){ return coord(accessor(d)); }), function(d,i){
            if(bindBy){
             return plot.dataset[i][bindBy];
            }
            return i;
           } );

          circles.enter().append("circle");

          circles.transition().attr("cx", function (d) { return d[0]; })
           .attr("cy", function (d) { return d[1]; })
           .attr("r", 6);

          return this;
         }

          plot.getPosition = coord;
         plot.getTripple = function(x, y){
          //TODO, get percentages for a give x, y
         }
plot.data(data);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>line.tick {
   stroke-width: 0.5;
  }

  line.minor-tick {
   stroke-width: 1;
   stroke-opacity:0.1;
  }

  .a-axis{
   stroke: #333;
  }

  .b-axis{
   stroke: #333;
  }

  .c-axis{
   stroke: #333;
  }

  .axis-title{
   font-family: TW Cen MT;
   font-size: 1.5rem;
  }

  text.tick-text {
   font-family: TW Cen MT;
   font-weight: lighter;
   font-size: 1rem;
   fill: #333;
   stroke:none;
  }

  circle {
   fill: #fff1e0;
   stroke: #DB7365;
   stroke-width: 2px;
  }</code>```

```

For the moment I'm trying to stay close to the original code and am using plot.data(data); to draw the graph. Again, my goal is to make a static version of the chart, and I'd rather not have to call any functions to "draw" the plot. I just want the chart to be drawn without having to fuss with passing different parameters to different functions. I am not making progress anymore, and have become lost in all the criss-crossing of functions.

It is at this point that I am hit with the error:

Uncaught TypeError: accessor is not a function

citing line 257:

.data( data.map( function(d){ return coord(accessor(d)); }), function(d,i){

Question

Given I wish to make a static visual, what is the appropriate choice for "accessor" when I call plot.data()? Once I figure out what exactly "accessor" is supposed to be, I will seek to recode to remove the necessity to pass values to the function.

Context for accessor pertains to this function (line 252):

plot.data = function(data, accessor, bindBy){

答:
Well, your real question is quite a big one: a huge refactor in that bl.ocks.

Therefore, I'll address only your strict question here. The accessor in this argument list...

```<code>plot.data = function(data, accessor, bindBy)
</code>```

...is this function:

```<code>function(d){
    return [d.journalist, d.developer, d.designer]
};
</code>```

That is, it just creates an array with the three variables in each object of the data array.

That array, as you probably know, will be used by coord():

```<code>function coord(arr) {
    var a = arr[0],
        b = arr[1],
        c = arr[2];
    var sum, pos = [0, 0];
    sum = a + b + c;
    if (sum !== 0) {
        a /= sum;
        b /= sum;
        c /= sum;
        pos[0] = corners[0][0] * a + corners[1][0] * b + corners[2][0] * c;
        pos[1] = corners[0][1] * a + corners[1][1] * b + corners[2][1] * c;
    }
    return pos;
}
</code>```

Title: Logic for static triangular plot

Body:
I have been trying to make a static d3 v5 version based off this block for the past few days. I have the coordinate plane drawn, but I am having trouble adapting the plot logic to a static variant. Here is my progress:

var margins = {top:50, bottom:50, left:50, right:50};

var height = 900;
var width = 900;

var totalWidth = width+margins.left+margins.right;
var totalHeight = height+margins.top+margins.bottom;

var side = 700;
var axis_labels = ['Journalist','Developer','Designer'];
var axis_ticks = [0,20,40,60,80,100];
var tickLabelMargin = 10;
var axisLabelMargin = 40;
var minor_axis_ticks = d3.range(0, 101, 5);
console.log(minor_axis_ticks)
var w = side;
var h = Math.sqrt( side*side - (side/2)*(side/2));

var corners = [
  [margins.left, h + margins.top], // a
  [ w + margins.left, h + margins.top], //b
  [(w/2) + margins.left, margins.top] ]; //c

var svg = d3.select('body')
    .append('svg')
    .attr('width', totalWidth)
    .attr('height', totalHeight);

var graphGroup = svg.append('g')
    .attr('transform', "translate("+margins.left+","+margins.top+")");

var axes = graphGroup.append('g').attr('class','axes');

var plot = {
  dataset:[]
};

var data = [
  {journalist:75,developer:25,designer:0,label:'point 1'},
  {journalist:70,developer:10,designer:20,label:'point 2'},
  {journalist:75,developer:20,designer:5,label:'point 3'},

  {journalist:5,developer:60,designer:35,label:'point 4'},
  {journalist:10,developer:80,designer:10,label:'point 5'},
  {journalist:10,developer:90,designer:0,label:'point 6'},
  {journalist:20,developer:70,designer:10,label:'point 7'},

  {journalist:10,developer:20,designer:70,label:'point 8'},
  {journalist:15,developer:5,designer:80,label:'point 9'},
  {journalist:10,developer:10,designer:80,label:'point 10'},
  {journalist:20,developer:10,designer:70,label:'point 11'},
 ];

  function lineAttributes(p1, p2){
      return { x1:p1[0], y1:p1[1],
           x2:p2[0], y2:p2[1] };
  }

axes.selectAll('.axis-title')
  .data(axis_labels)
  .enter()
   .append('g')
    .attr('class', 'axis-title')
    .attr('transform',function(d,i){
     return 'translate('+corners[i][0]+','+corners[i][1]+')';
    })
    .append('text')
    .text(function(d){ return d; })
    .attr('text-anchor', function(d,i){
     if(i===0) return 'end';
     if(i===2) return 'middle';
     return 'start';

    })
    .attr('transform', function(d,i){
     var theta = 0;
     if(i===0) theta = 120;
     if(i===1) theta = 60;
     if(i===2) theta = -90;

     var x = axisLabelMargin * Math.cos(theta * 0.0174532925),
      y = axisLabelMargin * Math.sin(theta * 0.0174532925);
     return 'translate('+x+','+y+')'
    });

        var n = axis_ticks.length;
         if(minor_axis_ticks){
          minor_axis_ticks.forEach(function(v) {
           var coord1 = coord( [v, 0, 100-v] );
           var coord2 = coord( [v, 100-v, 0] );
           var coord3 = coord( [0, 100-v, v] );
           var coord4 = coord( [100-v, 0, v] );

           axes.append("line")
            .attr('x1', lineAttributes(coord1, coord2).x1 )
                .attr('x2', lineAttributes(coord1, coord2).x2 )
                .attr('y1', lineAttributes(coord1, coord2).y1 )
                .attr('y2', lineAttributes(coord1, coord2).y2 )
            .classed('a-axis minor-tick', true);

           axes.append("line")
                .attr('x1', lineAttributes(coord2, coord3).x1 )
                .attr('x2', lineAttributes(coord2, coord3).x2 )
                .attr('y1', lineAttributes(coord2, coord3).y1 )
                .attr('y2', lineAttributes(coord2, coord3).y2 )
            .classed('b-axis minor-tick', true);

           axes.append("line")
                .attr('x1', lineAttributes(coord3, coord4).x1 )
                .attr('x2', lineAttributes(coord3, coord4).x2 )
                .attr('y1', lineAttributes(coord3, coord4).y1 )
                .attr('y2', lineAttributes(coord3, coord4).y2 )
            .classed('c-axis minor-tick', true);
          });
         }

          axis_ticks.forEach(function(v) {
          var coord1 = coord( [v, 0, 100-v] );
          var coord2 = coord( [v, 100-v, 0] );
          var coord3 = coord( [0, 100-v, v] );
          var coord4 = coord( [100-v, 0, v] );

          axes.append("line")
              .attr('x1', lineAttributes(coord1, coord2).x1 )
              .attr('x2', lineAttributes(coord1, coord2).x2 )
              .attr('y1', lineAttributes(coord1, coord2).y1 )
              .attr('y2', lineAttributes(coord1, coord2).y2 )
           .classed('a-axis tick', true);

          axes.append("line")
              .attr('x1', lineAttributes(coord2, coord3).x1 )
              .attr('x2', lineAttributes(coord2, coord3).x2 )
              .attr('y1', lineAttributes(coord2, coord3).y1 )
              .attr('y2', lineAttributes(coord2, coord3).y2 )
           .classed('b-axis tick', true);

          axes.append("line")
              .attr('x1', lineAttributes(coord3, coord4).x1 )
              .attr('x2', lineAttributes(coord3, coord4).x2 )
              .attr('y1', lineAttributes(coord3, coord4).y1 )
              .attr('y2', lineAttributes(coord3, coord4).y2 )
           .classed('c-axis tick', true);

              //tick labels
            axes.append('g')
             .attr('transform',function(d){
              return 'translate(' + coord1[0] + ',' + coord1[1] + ')'
             })
             .append("text")
              .attr('transform','rotate(60)')
              .attr('text-anchor','end')
              .attr('x',-tickLabelMargin)
              .text( function (d) { return v; } )
              .classed('a-axis tick-text', true );

            axes.append('g')
             .attr('transform',function(d){
              return 'translate(' + coord2[0] + ',' + coord2[1] + ')'
             })
             .append("text")
              .attr('transform','rotate(-60)')
              .attr('text-anchor','end')
              .attr('x',-tickLabelMargin)
              .text( function (d) { return (100- v); } )
              .classed('b-axis tick-text', true);

            axes.append('g')
             .attr('transform',function(d){
              return 'translate(' + coord3[0] + ',' + coord3[1] + ')'
             })
             .append("text")
              .text( function (d) { return v; } )
              .attr('x',tickLabelMargin)
              .classed('c-axis tick-text', true);

           })

          function coord(arr){
            var a = arr[0], b=arr[1], c=arr[2];
            var sum, pos = [0,0];
              sum = a + b + c;
              if(sum !== 0) {
                a /= sum;
                b /= sum;
                c /= sum;
              pos[0] =  corners[0][0]  * a + corners[1][0]  * b + corners[2][0]  * c;
              pos[1] =  corners[0][1]  * a + corners[1][1]  * b + corners[2][1]  * c;
            }
              return pos;
          }

          function scale(p, factor) {
             return [p[0] * factor, p[1] * factor];
         }

          plot.data = function(data, accessor, bindBy){ //bind by is the dataset property used as an id for the join
          plot.dataset = data;
            console.log(data)

          var circles = graphGroup.selectAll("circle")
           .data( data.map( function(d){ return coord(accessor(d)); }), function(d,i){
            if(bindBy){
             return plot.dataset[i][bindBy];
            }
            return i;
           } );

          circles.enter().append("circle");

          circles.transition().attr("cx", function (d) { return d[0]; })
           .attr("cy", function (d) { return d[1]; })
           .attr("r", 6);

          return this;
         }

          plot.getPosition = coord;
         plot.getTripple = function(x, y){
          //TODO, get percentages for a give x, y
         }
plot.data(data);

line.tick {
   stroke-width: 0.5;
  }

  line.minor-tick {
   stroke-width: 1;
   stroke-opacity:0.1;
  }

  .a-axis{
   stroke: #333;
  }

  .b-axis{
   stroke: #333;
  }

  .c-axis{
   stroke: #333;
  }

  .axis-title{
   font-family: TW Cen MT;
   font-size: 1.5rem;
  }

  text.tick-text {
   font-family: TW Cen MT;
   font-weight: lighter;
   font-size: 1rem;
   fill: #333;
   stroke:none;
  }

  circle {
   fill: #fff1e0;
   stroke: #DB7365;
   stroke-width: 2px;
  }

For the moment I'm trying to stay close to the original code and am using plot.data(data); to draw the graph. Again, my goal is to make a static version of the chart, and I'd rather not have to call any functions to "draw" the plot. I just want the chart to be drawn without having to fuss with passing different parameters to different functions. I am not making progress anymore, and have become lost in all the criss-crossing of functions.

It is at this point that I am hit with the error:

Uncaught TypeError: accessor is not a function

citing line 257:

.data( data.map( function(d){ return coord(accessor(d)); }), function(d,i){

Question

Given I wish to make a static visual, what is the appropriate choice for "accessor" when I call plot.data()? Once I figure out what exactly "accessor" is supposed to be, I will seek to recode to remove the necessity to pass values to the function.

Context for accessor pertains to this function (line 252):

plot.data = function(data, accessor, bindBy){

Body:
Well, your real question is quite a big one: a huge refactor in that bl.ocks.

Therefore, I'll address only your strict question here. The accessor in this argument list...

plot.data = function(data, accessor, bindBy)

...is this function:

function(d){
    return [d.journalist, d.developer, d.designer]
};

That is, it just creates an array with the three variables in each object of the data array.

That array, as you probably know, will be used by coord():

function coord(arr) {
    var a = arr[0],
        b = arr[1],
        c = arr[2];
    var sum, pos = [0, 0];
    sum = a + b + c;
    if (sum !== 0) {
        a /= sum;
        b /= sum;
        c /= sum;
        pos[0] = corners[0][0] * a + corners[1][0] * b + corners[2][0] * c;
        pos[1] = corners[0][1] * a + corners[1][1] * b + corners[2][1] * c;
    }
    return pos;
}


来源: stackexchange

问:
IBM MQ - Message reading & invoking down-line services transactional
I am working on consumer for IBM MQ messages, I want to make each message processing transactional after reading with acknowledgement.

Once I read each message from IBM MQ - i need to invoke about 4 to 5 different rest services.  There will be approximately 1500 - 2000 inserts in different tables through services.

If any of the service fails for any reason, I want to roll back previous inserts happened in processing that particular message and leave message in Queue.

How can I achieve the same? I am quite new to IBM MQs/Jms

I am planning to do it by browsing through messages using

```<code>QueueBrowser queueBrowser = context.createBrowser(queue, "JMSCorrelationID='ID:c9d5e2d7c5c3e3c9d6d54040404040404040404040404040c9d5e2d7c5c3e3c9d6d54040404040404040404040404040'");
</code>```

答:
If all these queues are on the same MQ Queue Manager, you should use 'local JMS transactions' for this. So create your IBM MQ JMS connection and make your session transacted (first argument is set to true):

```<code>session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
</code>```

Note: The second argument is ignored in case the first argument is true.

Create your JMS queues and the receiver and then read your first message, for example:

```<code>Message msg = msgConsumer.receive(100);
</code>```

This implicitly starts an MQ transaction on the first message received if there is no current transaction.

Next do your processing and if all goes well, call commit.

If not, rollback the transaction and you will see all rolled back messages again. So it could work something like this:

```<code>Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageConsumer msgConsumer = session.createConsumer(destination, null);
while( !isStopped() ) {

  try {

    Message msg = msgConsumer.receive(100);
    if( msg!=null ) {
      ... call your REST services ...
      session.commit();
    }
    ... test for end condition ...
  }
  catch (Exception e) {
    ... error handling ...
    session.rollback();
  }
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am working on consumer for IBM MQ messages, I want to make each message processing transactional after reading with acknowledgement.

Once I read each message from IBM MQ - i need to invoke about 4 to 5 different rest services.  There will be approximately 1500 - 2000 inserts in different tables through services.

If any of the service fails for any reason, I want to roll back previous inserts happened in processing that particular message and leave message in Queue.

How can I achieve the same? I am quite new to IBM MQs/Jms

I am planning to do it by browsing through messages using

QueueBrowser queueBrowser = context.createBrowser(queue, "JMSCorrelationID='ID:c9d5e2d7c5c3e3c9d6d54040404040404040404040404040c9d5e2d7c5c3e3c9d6d54040404040404040404040404040'");

Body:
If all these queues are on the same MQ Queue Manager, you should use 'local JMS transactions' for this. So create your IBM MQ JMS connection and make your session transacted (first argument is set to true):

session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);

Note: The second argument is ignored in case the first argument is true.

Create your JMS queues and the receiver and then read your first message, for example:

Message msg = msgConsumer.receive(100);

This implicitly starts an MQ transaction on the first message received if there is no current transaction.

Next do your processing and if all goes well, call commit.

If not, rollback the transaction and you will see all rolled back messages again. So it could work something like this:

Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageConsumer msgConsumer = session.createConsumer(destination, null);
while( !isStopped() ) {

  try {

    Message msg = msgConsumer.receive(100);
    if( msg!=null ) {
      ... call your REST services ...
      session.commit();
    }
    ... test for end condition ...
  }
  catch (Exception e) {
    ... error handling ...
    session.rollback();
  }
}


问:
Problems found loading Plugins in Android Studio
After updating Gradle as suggested in this answer the following error appears while using Android Studio 0.2.0

How to get over this one?

答: Unchecking the gradle plugin and checking it again then restarting android studio and selecting the SDK location and downloading the missing dependencies worked for me </p>

ContentLicense: CC BY-SA 3.0


问:
Unable to Import BACPAC files to SSMS2017
I'm trying to import .BACPAC file to Sql server management studio and i'm facing the below error.

Kindly note I'm having the latest version "Microsoft SQL Server Management Studio   14.0.17289.0"

答: I have Installed SMMS2018. It solves the BACPAC Import problem.</p>


问:
log4j2 not working in spring boot application
I am trying to use log4j2 instead of logback in my spring application but it keep throwing error.
The pom file looks like

```<code><parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.7.RELEASE</version>
    <relativePath />
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>
</dependencies>
</code>```

The log4j2 xml files looks like

```<code><?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60">
    <Properties>
        <Property name="path">logs</Property>
    </Properties>
    <Appenders>
        <Console name="Console-Appender" target="SYSTEM_OUT">
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>>
            </PatternLayout>
        </Console>
        <File name="App-Appender" fileName="${path}/app_log.log" >
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>
            </PatternLayout>
        </File>
        <File name="SpringBoot-Appender" fileName="${path}/springboot_log.log" >
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Logger name="master.dt" level="info" additivity="false">
            <AppenderRef ref="SpringBoot-Appender"/>
            <AppenderRef ref="Console-Appender"/>
        </Logger>
        <Logger name="master.dt" level="info" additivity="false">
            <AppenderRef ref="App-Appender"/>
            <AppenderRef ref="Console-Appender"/>
         </Logger>
        <Root>
            <AppenderRef ref="Console-Appender"/>
        </Root>
    </Loggers>
</Configuration>
</code>```

however when i run the spring boot app it throws an error

```<code>SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/asd.asd/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/asd.asd/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
[WARNING]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:483)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from file:/Users/karan.shah/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.apache.logging.slf4j.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
    at org.springframework.util.Assert.isInstanceOf(Assert.java:346)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:221)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLogger(LogbackLoggingSystem.java:213)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:98)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartedEvent(LoggingApplicationListener.java:222)
</code>```

I followed multiple blog but none of them are working. What is the correct way to get log4j2 work?

答:
I faced this issue in Microservice based project which is based on many services. Because of lot of conflicts between log4j, slf4j , apache common logging etc. Hence log files is not  creating even sufficient privileged are there.
First run command to resolved the jar conflict from dependency tree.

```<code>**mvn dependency:tree**
Exclude those jars from spring-boot starter dependencies and other component dependencies.

Following Code is perfectly working for me after lot of struggle.

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
</code>```

****Log4j.xml files:****

```<code>        <?xml version="1.0" encoding="UTF-8"?>
        <Configuration>
            <Appenders>
                <Console name="Console" target="SYSTEM_OUT">
                    <PatternLayout
                        pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
                </Console>

                <RollingFile name="RollingFile"
                    fileName="./logs/gateway-log4j2.log"
                    filePattern="./logs/$${date:yyyy-MM}/spring-boot-logger-log4j2-%d{-dd-MMMM-yyyy}-%i.log.gz">
                    <PatternLayout>
                        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
                    </PatternLayout>
                    <Policies>
                        <!-- rollover on startup, daily and when the file reaches
                            10 MegaBytes -->
                        <OnStartupTriggeringPolicy />
                        <SizeBasedTriggeringPolicy
                            size="10 MB" />
                        <TimeBasedTriggeringPolicy />
                    </Policies>
                </RollingFile>
            </Appenders>

            <Loggers>
                <!-- LOG everything at INFO level -->
                <Root level="info">
                    <AppenderRef ref="Console" />
                    <AppenderRef ref="RollingFile" />
                </Root>

                <!-- LOG "com.mytest.project*" at TRACE level -->
                <Logger name="com.mytest.project" level="trace"></Logger>
            </Loggers>

        </Configuration>

        Try it. It perfectly working for me.
</code>```

Body:
I am trying to use log4j2 instead of logback in my spring application but it keep throwing error.
The pom file looks like

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.7.RELEASE</version>
    <relativePath />
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>
</dependencies>

The log4j2 xml files looks like

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60">
    <Properties>
        <Property name="path">logs</Property>
    </Properties>
    <Appenders>
        <Console name="Console-Appender" target="SYSTEM_OUT">
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>>
            </PatternLayout>
        </Console>
        <File name="App-Appender" fileName="${path}/app_log.log" >
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>
            </PatternLayout>
        </File>
        <File name="SpringBoot-Appender" fileName="${path}/springboot_log.log" >
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Logger name="master.dt" level="info" additivity="false">
            <AppenderRef ref="SpringBoot-Appender"/>
            <AppenderRef ref="Console-Appender"/>
        </Logger>
        <Logger name="master.dt" level="info" additivity="false">
            <AppenderRef ref="App-Appender"/>
            <AppenderRef ref="Console-Appender"/>
         </Logger>
        <Root>
            <AppenderRef ref="Console-Appender"/>
        </Root>
    </Loggers>
</Configuration>

however when i run the spring boot app it throws an error

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/asd.asd/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/asd.asd/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
[WARNING]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:483)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from file:/Users/karan.shah/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.apache.logging.slf4j.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
    at org.springframework.util.Assert.isInstanceOf(Assert.java:346)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:221)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLogger(LogbackLoggingSystem.java:213)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:98)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartedEvent(LoggingApplicationListener.java:222)

I followed multiple blog but none of them are working. What is the correct way to get log4j2 work?

Body:
I faced this issue in Microservice based project which is based on many services. Because of lot of conflicts between log4j, slf4j , apache common logging etc. Hence log files is not  creating even sufficient privileged are there.
First run command to resolved the jar conflict from dependency tree.

**mvn dependency:tree**
Exclude those jars from spring-boot starter dependencies and other component dependencies.

Following Code is perfectly working for me after lot of struggle.

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

****Log4j.xml files:****

        <?xml version="1.0" encoding="UTF-8"?>
        <Configuration>
            <Appenders>
                <Console name="Console" target="SYSTEM_OUT">
                    <PatternLayout
                        pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
                </Console>

                <RollingFile name="RollingFile"
                    fileName="./logs/gateway-log4j2.log"
                    filePattern="./logs/$${date:yyyy-MM}/spring-boot-logger-log4j2-%d{-dd-MMMM-yyyy}-%i.log.gz">
                    <PatternLayout>
                        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
                    </PatternLayout>
                    <Policies>
                        <!-- rollover on startup, daily and when the file reaches
                            10 MegaBytes -->
                        <OnStartupTriggeringPolicy />
                        <SizeBasedTriggeringPolicy
                            size="10 MB" />
                        <TimeBasedTriggeringPolicy />
                    </Policies>
                </RollingFile>
            </Appenders>

            <Loggers>
                <!-- LOG everything at INFO level -->
                <Root level="info">
                    <AppenderRef ref="Console" />
                    <AppenderRef ref="RollingFile" />
                </Root>

                <!-- LOG "com.mytest.project*" at TRACE level -->
                <Logger name="com.mytest.project" level="trace"></Logger>
            </Loggers>

        </Configuration>

        Try it. It perfectly working for me.


问:
Fill li with content depending on database results
I'm working with fat free framework and am currently working on a bracket generation for competitions.

What I do is passing multiple competitors (from different "layers") to the view to display them in a tree. The basic styling comes from this codepen.

Now the problem is, that I don't know every field from beginning on, as the result of the first two competitions decide how the next level looks (quarter finals in that case). The problem is though, that if I don't put the fields there, then the complete layout is destroyed, thats why I put empty
 elements for the layer, where the competitors are not clear so far, just like so:

```<code><li class="team-item"> </li>
<li class="team-item"> </li>
<li class="team-item"> </li>
<li class="team-item"> </li>
</code>```

Same for semi finals and finals then, just with 2 and 1
s then.

Now in some of the cells of quarter/seminfinals I already have something in my database. So for example, if there's 8 competitions in "layer1", then I would have 4 empty fields in "layer2", respectively in the quarter finals. These 4 fields have to be predefined in order to keep the layout. Now maybe I only have 1 or 2 of these fields filled already, because the other competitions are not over yet.

So I have to always predefine the fields like in the code above. Now the question is: How do I either replace one empty
 with the filled one or alternatively, how do I fill the empty
 with information, if provided.

```<code><ul class="bracket bracket-2">
      <repeat group="{{ @bracket }}" value="{{ @item }}">
        <check if="{{@item.layer == 2}}">
        <!-- li should be filled with this content, if the condition is true, so if in here -->
        <li class="team-item">{{ @item.Vorname1  }} {{ @item.Name1  }} <a href="/getFighterInformation/{{@item.fighter1ID}}"<i class="fa fa-pencil-alt"></i></a> <i class="fa fa-trophy"></i></li>
      <li class="team-item">{{ @item.Vorname2  }} {{ @item.Name2  }} <a href="/getFighterInformation/{{@item.fighter2ID}}"<i class="fa fa-pencil-alt"></i></a> <i class="fa fa-trophy"></i></li>
  </check>
    </repeat>
  <!-- This should be predefined -->
  <li class="team-item"> </li>
  <li class="team-item"> </li>
  <li class="team-item"> </li>
  <li class="team-item"> </li>
  <!-------------------------------->
    </ul>
</code>```

That's an example for layer 2 with 8 competitions in layer 1.

I hope you get what I mean, but its pretty hard to explain...

So summarized, the question is: Is it possible to predefine list elements and then fill or replace them, if an if-condition matches?

EDIT:

This is what I get from database, filled into the bracket variable:

```<code>array(4){
   [
      0
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "1"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "21"      [
         "Vorname1"
      ]      => string(5) "one"      [
         "Name1"
      ]      => string(4) "one"      [
         "Geburtsdatum1"
      ]      => string(10) "1999-04-04"      [
         "fighter1Pos"
      ]      => string(1) "0"      [
         "fighter2ID"
      ]      => string(2) "19"      [
         "Vorname2"
      ]      => string(8) "two"      [
         "Name2"
      ]      => string(4) "two"      [
         "Geburtsdatum2"
      ]      => string(10) "1988-12-11"      [
         "fighter2Pos"
      ]      => string(1) "1"      [
         "result"
      ]      => string(1) "0"
   }   [
      1
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "2"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "25"      [
         "Vorname1"
      ]      => string(5) "three"      [
         "Name1"
      ]      => string(4) "three"      [
         "Geburtsdatum1"
      ]      => string(10) "1988-08-18"      [
         "fighter1Pos"
      ]      => string(1) "2"      [
         "fighter2ID"
      ]      => string(2) "24"      [
         "Vorname2"
      ]      => string(5) "four"      [
         "Name2"
      ]      => string(4) "four"      [
         "Geburtsdatum2"
      ]      => string(10) "1985-08-17"      [
         "fighter2Pos"
      ]      => string(1) "3"      [
         "result"
      ]      => string(1) "0"
   }   [
      2
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "3"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "23"      [
         "Vorname1"
      ]      => string(5) "five"      [
         "Name1"
      ]      => string(4) "five"      [
         "Geburtsdatum1"
      ]      => string(10) "1966-06-16"      [
         "fighter1Pos"
      ]      => string(1) "4"      [
         "fighter2ID"
      ]      => string(2) "20"      [
         "Vorname2"
      ]      => string(8) "six"      [
         "Name2"
      ]      => string(4) "six"      [
         "Geburtsdatum2"
      ]      => string(10) "1966-03-03"      [
         "fighter2Pos"
      ]      => string(1) "5"      [
         "result"
      ]      => string(1) "0"
   }   [
      3
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "4"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "18"      [
         "Vorname1"
      ]      => string(6) "seven"      [
         "Name1"
      ]      => string(4) "seven"      [
         "Geburtsdatum1"
      ]      => string(10) "1985-08-17"      [
         "fighter1Pos"
      ]      => string(1) "6"      [
         "fighter2ID"
      ]      => string(2) "22"      [
         "Vorname2"
      ]      => string(9) "eight"      [
         "Name2"
      ]      => string(4) "eight"      [
         "Geburtsdatum2"
      ]      => string(10) "1995-09-15"      [
         "fighter2Pos"
      ]      => string(1) "7"      [
         "result"
      ]      => string(1) "0"
   }
}
</code>```

One box should contain one fighter only, not two fighters. So each array element represents one fight, containing two fighters (referencable by fighter1ID/fighter2ID, respectively Name1, Name2, etc.). fighter1Pos and fighter2Pos then, together with the value "ebene", which is the layer (3, 2, 1 or 0), determine the position in the bracket, so layer 3 with fighter1Pos 7 would be the last "box" in the layer 3 (counting from 0 - 7).

答:
I think you should better prepare data before passing it to the template.

If your $brackets array looks like:

```<code>$brackets = [
  // first bracket
  1 => [
    [
      'A' => ['name' => 'John', 'id' => 123],
      'B' => ['name' => 'Jim', 'id' => 110],
      'time' => '20:00',
    ],
    [
      'A' => ['name' => 'Mary', 'id' => 141],
      'B' => ['name' => 'Bill', 'id' => 190],
      'time' => '14:00',
    ],
    //etc. (8 competitions)
  ],
  // second bracket
  2 => [
    [
      'A' => ['name' => 'John', 'id' => 123],
      'B' => ['name' => 'Mary', 'id' => 141],
      'time' => '18:00',
    ],
    //etc. (4 competitions)
  ],
  // third bracket
  3 => [
    [
      'A' => ['name' => 'John', 'id' => 123],
      'B' => NULL, // competitor B not known yet
      'time' => '16:00',
    ],
    //etc. (2 competitions)
  ],
  // last bracket (final)
  4 => [
    [
      'A' => NULL, // competitor A not known yet
      'B' => NULL, // competitor B not known yet
      'time' => '20:00',
    ],
  ],
];
</code>```

Then your template would simply look like:

```<code><div class="tournament-brackets">
  <repeat group="@brackets" key="@k" value="@competitions">
    <ul class="bracket bracket-{{ @k}}">
      <repeat group="@competitions" value="@competition">
        <li class="team-item">
          <check if="@competition.A">
            <true>
              {{ @competition.A.name }}
              <a href="/getFighterInformation/{{ @competition.A.id }}
            </true>
            <false>
              Unknown competitor
            </false>
          </check>
          <time>{{ @competition.time }}</time>
          <check if="@competition.B">
            <true>
              {{ @competition.B.name }}
              <a href="/getFighterInformation/{{ @competition.B.id }}
            </true>
            <false>
              Unknown competitor
            </false>
          </check>
        </li>
      </repeat>
    </ul>
  </repeat>
</code>```

Body:
I'm working with fat free framework and am currently working on a bracket generation for competitions.

What I do is passing multiple competitors (from different "layers") to the view to display them in a tree. The basic styling comes from this codepen.

Now the problem is, that I don't know every field from beginning on, as the result of the first two competitions decide how the next level looks (quarter finals in that case). The problem is though, that if I don't put the fields there, then the complete layout is destroyed, thats why I put empty
 elements for the layer, where the competitors are not clear so far, just like so:

Same for semi finals and finals then, just with 2 and 1
s then.

Now in some of the cells of quarter/seminfinals I already have something in my database. So for example, if there's 8 competitions in "layer1", then I would have 4 empty fields in "layer2", respectively in the quarter finals. These 4 fields have to be predefined in order to keep the layout. Now maybe I only have 1 or 2 of these fields filled already, because the other competitions are not over yet.

So I have to always predefine the fields like in the code above. Now the question is: How do I either replace one empty
 with the filled one or alternatively, how do I fill the empty
 with information, if provided.

      <repeat group="{{ @bracket }}" value="{{ @item }}">
        <check if="{{@item.layer == 2}}">

{{ @item.Vorname1  }} {{ @item.Name1  }} <a href="/getFighterInformation/{{@item.fighter1ID}}"

{{ @item.Vorname2  }} {{ @item.Name2  }} <a href="/getFighterInformation/{{@item.fighter2ID}}"

  </check>
    </repeat>

That's an example for layer 2 with 8 competitions in layer 1.

I hope you get what I mean, but its pretty hard to explain...

So summarized, the question is: Is it possible to predefine list elements and then fill or replace them, if an if-condition matches?

EDIT:

This is what I get from database, filled into the bracket variable:

array(4){
   [
      0
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "1"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "21"      [
         "Vorname1"
      ]      => string(5) "one"      [
         "Name1"
      ]      => string(4) "one"      [
         "Geburtsdatum1"
      ]      => string(10) "1999-04-04"      [
         "fighter1Pos"
      ]      => string(1) "0"      [
         "fighter2ID"
      ]      => string(2) "19"      [
         "Vorname2"
      ]      => string(8) "two"      [
         "Name2"
      ]      => string(4) "two"      [
         "Geburtsdatum2"
      ]      => string(10) "1988-12-11"      [
         "fighter2Pos"
      ]      => string(1) "1"      [
         "result"
      ]      => string(1) "0"
   }   [
      1
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "2"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "25"      [
         "Vorname1"
      ]      => string(5) "three"      [
         "Name1"
      ]      => string(4) "three"      [
         "Geburtsdatum1"
      ]      => string(10) "1988-08-18"      [
         "fighter1Pos"
      ]      => string(1) "2"      [
         "fighter2ID"
      ]      => string(2) "24"      [
         "Vorname2"
      ]      => string(5) "four"      [
         "Name2"
      ]      => string(4) "four"      [
         "Geburtsdatum2"
      ]      => string(10) "1985-08-17"      [
         "fighter2Pos"
      ]      => string(1) "3"      [
         "result"
      ]      => string(1) "0"
   }   [
      2
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "3"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "23"      [
         "Vorname1"
      ]      => string(5) "five"      [
         "Name1"
      ]      => string(4) "five"      [
         "Geburtsdatum1"
      ]      => string(10) "1966-06-16"      [
         "fighter1Pos"
      ]      => string(1) "4"      [
         "fighter2ID"
      ]      => string(2) "20"      [
         "Vorname2"
      ]      => string(8) "six"      [
         "Name2"
      ]      => string(4) "six"      [
         "Geburtsdatum2"
      ]      => string(10) "1966-03-03"      [
         "fighter2Pos"
      ]      => string(1) "5"      [
         "result"
      ]      => string(1) "0"
   }   [
      3
   ]   => array(15)   {
      [
         "ID"
      ]      => string(1) "4"      [
         "eventID"
      ]      => string(1) "1"      [
         "kategorie"
      ]      => string(4) "FA62"      [
         "ebene"
      ]      => string(1) "3"      [
         "fighter1ID"
      ]      => string(2) "18"      [
         "Vorname1"
      ]      => string(6) "seven"      [
         "Name1"
      ]      => string(4) "seven"      [
         "Geburtsdatum1"
      ]      => string(10) "1985-08-17"      [
         "fighter1Pos"
      ]      => string(1) "6"      [
         "fighter2ID"
      ]      => string(2) "22"      [
         "Vorname2"
      ]      => string(9) "eight"      [
         "Name2"
      ]      => string(4) "eight"      [
         "Geburtsdatum2"
      ]      => string(10) "1995-09-15"      [
         "fighter2Pos"
      ]      => string(1) "7"      [
         "result"
      ]      => string(1) "0"
   }
}

One box should contain one fighter only, not two fighters. So each array element represents one fight, containing two fighters (referencable by fighter1ID/fighter2ID, respectively Name1, Name2, etc.). fighter1Pos and fighter2Pos then, together with the value "ebene", which is the layer (3, 2, 1 or 0), determine the position in the bracket, so layer 3 with fighter1Pos 7 would be the last "box" in the layer 3 (counting from 0 - 7).

Body:
I think you should better prepare data before passing it to the template.

If your $brackets array looks like:

$brackets = [
  // first bracket
  1 => [
    [
      'A' => ['name' => 'John', 'id' => 123],
      'B' => ['name' => 'Jim', 'id' => 110],
      'time' => '20:00',
    ],
    [
      'A' => ['name' => 'Mary', 'id' => 141],
      'B' => ['name' => 'Bill', 'id' => 190],
      'time' => '14:00',
    ],
    //etc. (8 competitions)
  ],
  // second bracket
  2 => [
    [
      'A' => ['name' => 'John', 'id' => 123],
      'B' => ['name' => 'Mary', 'id' => 141],
      'time' => '18:00',
    ],
    //etc. (4 competitions)
  ],
  // third bracket
  3 => [
    [
      'A' => ['name' => 'John', 'id' => 123],
      'B' => NULL, // competitor B not known yet
      'time' => '16:00',
    ],
    //etc. (2 competitions)
  ],
  // last bracket (final)
  4 => [
    [
      'A' => NULL, // competitor A not known yet
      'B' => NULL, // competitor B not known yet
      'time' => '20:00',
    ],
  ],
];

Then your template would simply look like:

<div class="tournament-brackets">
  <repeat group="@brackets" key="@k" value="@competitions">
    <ul class="bracket bracket-{{ @k}}">
      <repeat group="@competitions" value="@competition">
        <li class="team-item">
          <check if="@competition.A">
            <true>
              {{ @competition.A.name }}
              <a href="/getFighterInformation/{{ @competition.A.id }}
            </true>
            <false>
              Unknown competitor
            </false>
          </check>
          <time>{{ @competition.time }}</time>
          <check if="@competition.B">
            <true>
              {{ @competition.B.name }}
              <a href="/getFighterInformation/{{ @competition.B.id }}
            </true>
            <false>
              Unknown competitor
            </false>
          </check>
        </li>
      </repeat>
    </ul>
  </repeat>


问:
Sum by unique variable pairs
I'm looking for a way to cleanly sum the unique pairings of my two variables, preferably, in data.table.

Here's my data:

```<code> > x_base
    State SA2 Population_SA2
 1:     A   x            304
 2:     A   x            304
 3:     A   y             79
 4:     A   y             79
 5:     A   y             79
 6:     B   z            961
 7:     B   z            961
 8:     B   z            961
 9:     B   z            961
10:     B   w             90
11:     B   w             90
12:     B   u            550
13:     C   v            113
14:     C   v            113
15:     C   t            425
16:     C   t            425
17:     C   t            425
</code>```

What I want to do is to calculate the sum of Population_SA2 by State. However, I've got multiple entries for each State and SA2 pair, for instance I've got two pairs of State == A & SA2 == x, but when i sum over Population_SA2, it would be incorrect to count 304 twice, likewise it would be incorrect to count 79 three times. The population for State A should be 383 (304 + 79).

Here's my current solution:

1) Find the unique State and SA2 pairs:

```<code>> x_unique <- unique(x_base)
> x_unique
   State SA2 Population_SA2
1:     A   x            304
2:     A   y             79
3:     B   z            961
4:     B   w             90
5:     B   u            550
6:     C   v            113
7:     C   t            425
</code>```

2) Sum Population_SA2 by State:

```<code>> x_unique <- x_unique[,.(sum_by_state = sum(Population_SA2)), by = State]
> x_unique
   State sum_by_state
1:     A          383
2:     B         1601
3:     C          538
</code>```

3) Merge back onto the initial data.table:

```<code>> x_final <- merge(x_base, x_unique[,.(State,sum_by_state)], by = "State")
> x_final
    State SA2 Population_SA2 sum_by_state
 1:     A   x            304          383
 2:     A   x            304          383
 3:     A   y             79          383
 4:     A   y             79          383
 5:     A   y             79          383
 6:     B   z            961         1601
 7:     B   z            961         1601
 8:     B   z            961         1601
 9:     B   z            961         1601
10:     B   w             90         1601
11:     B   w             90         1601
12:     B   u            550         1601
13:     C   v            113          538
14:     C   v            113          538
15:     C   t            425          538
16:     C   t            425          538
17:     C   t            425          538
</code>```

I'd be really keen to know if this can be done in a cleaner, more concise way, where I don't have to create any intermediate objects.

Much appreciated!

Not sure if necessary, but here's a dput()

```<code>structure(list(State = c("A", "A", "A", "A", "A", "B", "B", "B",
"B", "B", "B", "B", "C", "C", "C", "C", "C"), SA2 = c("x", "x",
"y", "y", "y", "z", "z", "z", "z", "w", "w", "u", "v", "v", "t",
"t", "t"), Population_SA2 = c(304L, 304L, 79L, 79L, 79L, 961L,
961L, 961L, 961L, 90L, 90L, 550L, 113L, 113L, 425L, 425L, 425L
)), row.names = c(NA, -17L), class = c("data.table", "data.frame"
), .internal.selfref = <pointer: 0x0000000000121ef0>)
</code>```

Title: Sum by unique variable pairs

Body:
I'm looking for a way to cleanly sum the unique pairings of my two variables, preferably, in data.table.

Here's my data:

 > x_base
    State SA2 Population_SA2
 1:     A   x            304
 2:     A   x            304
 3:     A   y             79
 4:     A   y             79
 5:     A   y             79
 6:     B   z            961
 7:     B   z            961
 8:     B   z            961
 9:     B   z            961
10:     B   w             90
11:     B   w             90
12:     B   u            550
13:     C   v            113
14:     C   v            113
15:     C   t            425
16:     C   t            425
17:     C   t            425

What I want to do is to calculate the sum of Population_SA2 by State. However, I've got multiple entries for each State and SA2 pair, for instance I've got two pairs of State == A & SA2 == x, but when i sum over Population_SA2, it would be incorrect to count 304 twice, likewise it would be incorrect to count 79 three times. The population for State A should be 383 (304 + 79).

Here's my current solution:

1) Find the unique State and SA2 pairs:

> x_unique <- unique(x_base)
> x_unique
   State SA2 Population_SA2
1:     A   x            304
2:     A   y             79
3:     B   z            961
4:     B   w             90
5:     B   u            550
6:     C   v            113
7:     C   t            425

2) Sum Population_SA2 by State:

> x_unique <- x_unique[,.(sum_by_state = sum(Population_SA2)), by = State]
> x_unique
   State sum_by_state
1:     A          383
2:     B         1601
3:     C          538

3) Merge back onto the initial data.table:

> x_final <- merge(x_base, x_unique[,.(State,sum_by_state)], by = "State")
> x_final
    State SA2 Population_SA2 sum_by_state
 1:     A   x            304          383
 2:     A   x            304          383
 3:     A   y             79          383
 4:     A   y             79          383
 5:     A   y             79          383
 6:     B   z            961         1601
 7:     B   z            961         1601
 8:     B   z            961         1601
 9:     B   z            961         1601
10:     B   w             90         1601
11:     B   w             90         1601
12:     B   u            550         1601
13:     C   v            113          538
14:     C   v            113          538
15:     C   t            425          538
16:     C   t            425          538
17:     C   t            425          538

I'd be really keen to know if this can be done in a cleaner, more concise way, where I don't have to create any intermediate objects.

Much appreciated!

Not sure if necessary, but here's a dput()

structure(list(State = c("A", "A", "A", "A", "A", "B", "B", "B",
"B", "B", "B", "B", "C", "C", "C", "C", "C"), SA2 = c("x", "x",
"y", "y", "y", "z", "z", "z", "z", "w", "w", "u", "v", "v", "t",
"t", "t"), Population_SA2 = c(304L, 304L, 79L, 79L, 79L, 961L,
961L, 961L, 961L, 90L, 90L, 550L, 113L, 113L, 425L, 425L, 425L
)), row.names = c(NA, -17L), class = c("data.table", "data.frame"
), .internal.selfref = <pointer: 0x0000000000121ef0>)

Body:
A data.table solution is

x_base[, sum_by_state := sum(Population_SA2[!duplicated(SA2)]), by = State]
x_base
#     State SA2 Population_SA2 sum_by_state
#  1:     A   x            304          383
#  2:     A   x            304          383
#  3:     A   y             79          383
#  4:     A   y             79          383
#  5:     A   y             79          383
#  6:     B   z            961         1601
#  7:     B   z            961         1601
#  8:     B   z            961         1601
#  9:     B   z            961         1601
# 10:     B   w             90         1601
# 11:     B   w             90         1601
# 12:     B   u            550         1601
# 13:     C   v            113          538
# 14:     C   v            113          538
# 15:     C   t            425          538
# 16:     C   t            425          538
# 17:     C   t            425          538

A dplyr-solution would be:

library(dplyr)

x_base %>%
  group_by(State) %>%
  mutate(sum_by_state = sum(Population_SA2[!duplicated(SA2)]))

# A tibble: 17 x 4
# Groups:   State [3]
#    State SA2   Population_SA2 sum_by_state
#    <chr> <chr>          <int>        <int>
# 1  A     x                304          383
# 2  A     x                304          383
# 3  A     y                 79          383
# 4  A     y                 79          383
# 5  A     y                 79          383
# 6  B     z                961         1601
# 7  B     z                961         1601
# 8  B     z                961         1601
# 9  B     z                961         1601
# 10 B     w                 90         1601
# 11 B     w                 90         1601
# 12 B     u                550         1601
# 13 C     v                113          538
# 14 C     v                113          538
# 15 C     t                425          538
# 16 C     t                425          538
# 17 C     t                425          538


问:
How to model your pub/sub topics name for future versioning
We are using kafka topics in the classic way.

Many times we found ourself in a need to update our topic consumers due to the json modification or consumer change logic. so what we do:

we version our topics e.g my_topic_v1.

Now when some modification happens e.g json changes, consumer logic changes we upgrade the topic into v2 and we need to release new producer/consumer as well (so it can broadcast to v2 and the new versioned consumer will consume from v2)

Thats of course adding huge overheard to our devops infra and the whole syncing thing (adding producer before consumer and vice versa) as this is real-time system we cannot afford leg

Any other suggestions how to do this better ? as we think we are not doing it all right

Thanks

答:
Try to have topics name as <topicname>.<version>.

eg. mytopic.ver1

Producer end will be affected during a release as data would be pushed to new topic post-release while the consumer side can be handled by defining the topics name as a regex - mytopic.*.

checkout the docs - topics.regex - link
subscribe


问:
Obtaining motion vectors from raw video
I'd like to know if there is any good (and freely available) text, on how to obtain motion vectors of macro blocks in raw video stream. This is often used in video compression, although my application of it is not video encoding.

Code that does this is available in OSS codecs, but understanding the method by reading the code is kinda hard.

My actual goal is to determine camera motion in 2D projection space, assuming the camera is only changing it's orientation (NOT the position). What I'd like to do is divide the frames into macro blocks, obtain their motion vectors, and get the camera motion by averaging those vectors.

I guess OpenCV could help with this problem, but it's not available on my target platform.

答:
The usual way is simple brute force: Compare a macro block to each macro block from the reference frame and use the one that gives the smallest residual error. The code gets complex primarily because this is usually the slowest part of mv-based compression, so they put a lot of work into optimizing it, often at the expense of anything even approaching readability.

Especially for real-time compression, some reduce the workload a bit by (for example) restricting the search to the original position +/- some maximum delta. This can often gain quite a bit of compression speed in exchange for a fairly small loss of compression.

Title: Obtaining motion vectors from raw video


问:
Calculating working days between 2 dates in SSRS 2016
I am using the below code, found on this website. It somehow works but not properly when the FromDate falls on a Friday as it adds another day on top.

See the screenshot for the demonstration.

What is it wrong in the code itself?

```<code>= (DateDiff(DateInterval.day,Fields!FromDate.Value,Fields!UntilDate.Value)+1)
- (DateDiff(DateInterval.WeekOfYear,Fields!FromDate.Value,Fields!UntilDate.Value)*2)
- IIF(Weekday(Fields!FromDate.Value,1) = 1,1,0)
- IIF(Weekday(Fields!FromDate.Value,1) = 7,1,0)
- IIF(Weekday(Fields!UntilDate.Value,1) = 1,1,0)
- IIF(Weekday(Fields!UntilDate.Value,1) = 7,1,0)
</code>```

答:
SOLUTION

In my case I had to introduce the CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")) in order for the days to be calculated correctly

```<code>I had to use the CDATE() in the code:
=(DateDiff(DateInterval.day,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),
CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))+1)
-(DateDiff(DateInterval.WeekOfYear,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),
CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))*2)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
</code>```

Body:
I am using the below code, found on this website. It somehow works but not properly when the FromDate falls on a Friday as it adds another day on top.

See the screenshot for the demonstration.

What is it wrong in the code itself?

= (DateDiff(DateInterval.day,Fields!FromDate.Value,Fields!UntilDate.Value)+1)
- (DateDiff(DateInterval.WeekOfYear,Fields!FromDate.Value,Fields!UntilDate.Value)*2)
- IIF(Weekday(Fields!FromDate.Value,1) = 1,1,0)
- IIF(Weekday(Fields!FromDate.Value,1) = 7,1,0)
- IIF(Weekday(Fields!UntilDate.Value,1) = 1,1,0)
- IIF(Weekday(Fields!UntilDate.Value,1) = 7,1,0)

Body:
SOLUTION

In my case I had to introduce the CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")) in order for the days to be calculated correctly

I had to use the CDATE() in the code:
=(DateDiff(DateInterval.day,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),
CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))+1)
-(DateDiff(DateInterval.WeekOfYear,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),
CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))*2)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 7,1,0)


问:
IOs in app purchase - reports / transaction log for sandbox
We have successfully integrated in app purchase and are able to test it in sandbox mode. However, I cannot find anywhere in the docs where to test the records of all purchases made using sandbox account. Somewhere I can test the total amount earned at-least.

I have tried - App analytics, Sales and Trends,  and Payments and Financial Reports   section on appstoreconnect.apple.com

答:
It seems there is no way to check sale/trends for test users. as the Test purchases are sandboxed.

refer to this link:

https://forums.developer.apple.com/thread/29632


问:
Multipling Long into float number results wrong in some case
See this below simple code:

```<code>public static void main(String[] args) {
    Long value = 91000L;
    System.out.println(value * 0.1);
    System.out.println(value * 0.2);
    System.out.println(value * 0.3);
    System.out.println(value * 0.4);
    System.out.println(value * 0.5);
    System.out.println(value * 0.6);
    System.out.println(value * 0.7);
    System.out.println(value * 0.8);
    System.out.println(value * 0.9);
}
</code>```

the result is this:

```<code>9100.0
18200.0
27300.0
36400.0
45500.0
54600.0
63699.99999999999 //incorrect!
72800.0
81900.0
</code>```

答:
This is a correct result because working with double is not precise as working with integer types.

This is why in case you compare two double numbers, you have to do smth. like this:

```<code>public static boolean isEqual(double one, double two) {
    return one >= two - 1E6 && one <= two + 1E6;
}
</code>```

P.S. 4.2.3. Floating-Point Types, Formats, and Values

In case you want to print correct value, you have to use BigDecimal:

```<code>BigDecimal val = BigDecimal.valueOf(91000);
BigDecimal res = val.multiply(BigDecimal.valueOf(0.7));
System.out.println(res); // 63000.0
</code>```

In some cases, you could increase precision:

```<code>long value = 91000L;
System.out.println(value * 0.7);    // 63699.99999999999
System.out.println((value * 7) / 10);   // 63700
</code>```

Body:
See this below simple code:

public static void main(String[] args) {
    Long value = 91000L;
    System.out.println(value * 0.1);
    System.out.println(value * 0.2);
    System.out.println(value * 0.3);
    System.out.println(value * 0.4);
    System.out.println(value * 0.5);
    System.out.println(value * 0.6);
    System.out.println(value * 0.7);
    System.out.println(value * 0.8);
    System.out.println(value * 0.9);
}

the result is this:

9100.0
18200.0
27300.0
36400.0
45500.0
54600.0
63699.99999999999 //incorrect!
72800.0
81900.0

Body:
This is a correct result because working with double is not precise as working with integer types.

This is why in case you compare two double numbers, you have to do smth. like this:

public static boolean isEqual(double one, double two) {
    return one >= two - 1E6 && one <= two + 1E6;
}

P.S. 4.2.3. Floating-Point Types, Formats, and Values

In case you want to print correct value, you have to use BigDecimal:

BigDecimal val = BigDecimal.valueOf(91000);
BigDecimal res = val.multiply(BigDecimal.valueOf(0.7));
System.out.println(res); // 63000.0

In some cases, you could increase precision:

long value = 91000L;
System.out.println(value * 0.7);    // 63699.99999999999
System.out.println((value * 7) / 10);   // 63700


问:
When controller call method from another class produce produce invalid operation
Calling a method from controller produce the error InvalidOperationException: Unable to resolve service for type 'AwardManagement.Class.Season' while attempting to activate 'AwardManagement.Controllers.TabsController'.

This is the code call from Controller

```<code>
   public TabsController(AwardContext context,Season seasons)
   {
       _context = context;
       _seasons = seasons;
   }
   public ActionResult GetTabs(int id)
   {
       var tabs =  _context.Tabs.Find(id);
       if (tabs == null)
       {
          return NotFound();
       }
       var season = _seasons.GetSingle(tabs.SeasonId);
       var result = new { tab = tabs, season = season };
       return  Ok(result);
   }
</code>```

GetSingle() Definition in Season Class

```<code>public class Season
{
     private readonly AwardContext _context;
     public Season(AwardContext context)
     {
        _context = context;
     }
     public  Seasons GetSingle(int? id)
     {
        return _context.Seasons.FirstOrDefault(x => x.Id == id);
     }
 }
</code>```

答:
For a clear solution, register Season in the Startup.cs like

```<code>public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<Season>();
    }
}
</code>```

Body:
Calling a method from controller produce the error InvalidOperationException: Unable to resolve service for type 'AwardManagement.Class.Season' while attempting to activate 'AwardManagement.Controllers.TabsController'.

This is the code call from Controller

   public TabsController(AwardContext context,Season seasons)
   {
       _context = context;
       _seasons = seasons;
   }
   public ActionResult GetTabs(int id)
   {
       var tabs =  _context.Tabs.Find(id);
       if (tabs == null)
       {
          return NotFound();
       }
       var season = _seasons.GetSingle(tabs.SeasonId);
       var result = new { tab = tabs, season = season };
       return  Ok(result);
   }

GetSingle() Definition in Season Class

public class Season
{
     private readonly AwardContext _context;
     public Season(AwardContext context)
     {
        _context = context;
     }
     public  Seasons GetSingle(int? id)
     {
        return _context.Seasons.FirstOrDefault(x => x.Id == id);
     }
 }

Body:
For a clear solution, register Season in the Startup.cs like

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<Season>();
    }
}


问:
SQL Import from Excel using non-contiguous range?
I have some Excel spreadsheets that I cannot change as they are used by another department and they will not change them in future. They are .xlsm with over 500 columns (A:TH). I'm trying to import them into SQL server 2008 on a 64bit machine but I'm having huge problems. All forms of Excel import appear to truncate the columns I select to the first 255.

Ultimately there will 5 separate tables to store this data with 1 common key. I could write a short VBA script to sort the data in Excel into arranged columns of tables at source but I wanted to ask if the following was possible first...

This works fine and selects the columns A:IV

```<code>SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                         'Excel 12.0;Database=C:\NEW.xlsm',
                         'SELECT * FROM [Details Sheet$A:IV]')
</code>```

Is there a clever way to do something similar with a non-contiguous range such as

```<code>SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                         'Excel 12.0;Database=C:\NEW.xlsm',
                         'SELECT * FROM [Details Sheet$C:C,IW:LZ]')
</code>```

ie. pick up the key in column C and the additional columns IW:LZ? The problem for me is that using the full range C:LZ and SELECT [ID],[THIS],[THAT] FROM etc won't work for fields beyond 255 columns in the range, very annoying!

答:
Have you tried using SSIS to import the Excel files? It can be very picky about data types, but I've never run into a limitation that I couldn't work around with a bit of a Script Component.

It's designed to be a high-performance ETL tool for jobs like what you're trying to accomplish. If you're new to it, check out this article on importing the entirety of Wikipedia as XML into multiple tables.

A quick note is that you may need to install additional Office drivers to read Excel 2007 format, especially on 64-bit machine.

Body:
I have some Excel spreadsheets that I cannot change as they are used by another department and they will not change them in future. They are .xlsm with over 500 columns (A:TH). I'm trying to import them into SQL server 2008 on a 64bit machine but I'm having huge problems. All forms of Excel import appear to truncate the columns I select to the first 255.

Ultimately there will 5 separate tables to store this data with 1 common key. I could write a short VBA script to sort the data in Excel into arranged columns of tables at source but I wanted to ask if the following was possible first...

This works fine and selects the columns A:IV

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                         'Excel 12.0;Database=C:\NEW.xlsm',
                         'SELECT * FROM [Details Sheet$A:IV]')

Is there a clever way to do something similar with a non-contiguous range such as

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                         'Excel 12.0;Database=C:\NEW.xlsm',
                         'SELECT * FROM [Details Sheet$C:C,IW:LZ]')

ie. pick up the key in column C and the additional columns IW:LZ? The problem for me is that using the full range C:LZ and SELECT [ID],[THIS],[THAT] FROM etc won't work for fields beyond 255 columns in the range, very annoying!


问:
Why is my nested setTimeout not firing removeAttr?
I've got two setTimeout functions that are operating properly but my removeAttr function is not firing. I have no idea why this is.

EDIT: The actual goal is to animate feGaussianBlur's variable "stdDeviation" from 0 to 7 on mouse in.... and 7 to 0 on mouse out... not just once, but an unlimited number of times. While the first path object is still animating, the second path object should also be able to animate separately.

Below is my code but because I'm using a plugin, please follow this link to Codepen: https://codepen.io/ownage/pen/MdzvjW

var polyhoveron = TweenMax.to("#feGaussianBlur", .5, {
  paused:true,
  attr:{"stdDeviation":7},
  onUpdateParams:["{self}"]
});
var polyhoveroff = TweenMax.to("#feGaussianBlur2", .5, {
  paused:true,
  attr:{"stdDeviation":0},
  onUpdateParams:["{self}"]
});

$("svg path").mouseenter(function() {
    $(this).attr("filter", "url(#f1)");
    polyhoveron.play();
    $("p").text("Mouse has entered");
}).mouseleave(function() {
    $(this).attr("filter", "url(#f2)");
    $("p").text("Mouse has left");
    setTimeout(function() {
        setTimeout(function() {
            $(this).removeAttr("filter");
            $("p").text("Why didn't removeAttr work? Now it's broken and can't be started over.");
        }, 500);
        polyhoveroff.play();
        $("p").text("<polyhoveroff function>")
    }, 500);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>html,body,svg {height:100%}
body {background:cornsilk;}
img,svg path {cursor:pointer;}</code>```

Ready to hover. Problem: This only animates once so enjoy it.

<svg viewBox="90 -10 300 200">

  <defs>

    <filter id="f1" x="-40%" y="-40%" height="200%" width="200%">
      <feOffset result="offOut" in="SourceAlpha" dx="0" dy="0" />
      <feGaussianBlur id="feGaussianBlur" result="blurOut" in="offOut" stdDeviation="0" />
      <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
    </filter>

    <filter id="f2" x="-40%" y="-40%" height="200%" width="200%">
      <feOffset result="offOut" in="SourceAlpha" dx="0" dy="0" />
      <feGaussianBlur id="feGaussianBlur2" result="blurOut" in="offOut" stdDeviation="7" />
      <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
    </filter>

  </defs>

  <path d="m 156.29028,68.019096 c 4.67931,-1.988204 -0.12418,-10.666555 10.32783,-11.26589 1.83984,-0.1055 3.04194,0.379201 5.51291,0.764346 0.069,-1.457882 0.39368,-7.513956 0.18783,-9.0114 -0.20581,-1.497443 -2.17888,-0.886775 -3.88749,-1.604662 -2.9137,-2.004347 -3.60967,-4.508091 -4.90279,-7.066947 -1.43623,-2.842048 -2.74829,-5.873666 -3.08935,-9.039685 -0.38465,-3.570722 1.01485,-7.116117 1.23297,-10.703361 1.08612,-0.941004 2.17224,-1.882009 3.25836,-2.823013 -0.40015,-1.882008 -0.8003,-3.764017 -1.20045,-5.646025 -1.881,-1.240819 -5.47796,-1.429412 -4.39448,-4.3669975 0.12147,-1.7496304 0.24294,-3.4992608 0.36441,-5.2488912 -1.71492,0 -3.42985,0 -5.14477,0 1.55912,1.9274484 0.0233,3.2815506 -1.44728,4.4870662 -4.33942,4.6764345 -17.98037,9.8959195 -21.082,8.7530705 -0.2683,-2.332216 -2.37086,2.393413 -3.28353,0.596362 1.34212,2.644214 0.18957,5.899268 -2.70665,6.345448 -2.3295,-1.915206 -4.30895,-5.103085 -7.56114,-3.218799 -3.12217,0.22867 -5.92518,-1.40308 -8.60189,-2.759866 -1.57069,-0.466831 -4.99248,0.07945 -1.89293,1.516781 2.16684,0.932005 4.2283,1.962703 3.53082,4.572657 0,1.793017 0,3.586035 0,5.379053 3.17614,1.071151 2.57339,6.821091 5.18841,6.882203 6.54256,0.152896 6.52233,0.756564 8.9075,3.546429 5.61657,6.569528 3.49195,14.688396 5.04055,24.775964 0.71231,4.639968 4.29374,10.456375 8.59444,10.753658 2.6538,0.183442 4.77082,-4.041744 6.62733,-5.400138 6.44957,-2.977631 3.60533,1.641529 10.42139,-0.217363 z"></path>

  <path d="m 260.769,66.023156 c 3.8349,-4.788158 8.79324,-8.576249 12.7991,-13.224205 1.75034,-2.886256 3.43676,-4.132595 5.93865,-4.863527 1.36048,-1.366469 0.7359,-3.785632 1.10386,-5.678447 -0.76366,-0.838347 -1.35457,-2.029861 -2.22664,-2.646575 -0.99259,-0.08879 -2.12712,0.169001 -3.03839,-0.118352 -1.30495,-1.404354 -2.86845,-2.614797 -4.1339,-4.011836 -2.15241,-6.618271 -4.5275,-13.195742 -5.71384,-20.074944 -1.99173,-9.307097 -2.15055,-5.084229 -4.23803,-2.694703 -1.89331,2.261054 -3.97742,4.394485 -5.75197,6.734975 -2.17919,4.369109 -4.35839,8.738218 -6.53758,13.107327 -1.71492,1.11744 -3.42985,2.234883 -5.14477,3.352328 -1.4828,-0.470312 -2.96182,-1.251763 -4.44692,-1.533208 -4.79877,2.860083 -3.39481,-3.099681 -4.61322,-1.645561 -0.83557,0.646548 -3.16443,2.417752 -4.33214,2.171548 -2.60394,0.20477 -3.7511,-0.08068 -6.2436,-0.757161 -3.3e-4,1.040982 -0.36041,4.077489 1.15977,3.597984 1.14715,0.14345 2.47104,-0.492629 3.62131,0.0082 3.61471,1.043297 7.56377,3.356319 10.11497,7.322839 4.58458,7.718114 4.36102,8.17007 5.13813,13.923417 0.58204,4.309185 2.91437,2.859459 4.04981,4.539599 1.2544,1.856164 1.73521,3.698395 2.9847,6.021742 1.82746,3.202236 1.66695,4.37289 3.5547,4.410115 1.50738,0.02972 2.06302,-2.206341 2.97507,-3.406861 1.09428,-1.440386 1.85013,-3.122803 2.98093,-4.534694 z"></path>

</svg>```

答:
```<code>$("svg path").mouseenter(function() {
    $(this).attr("filter", "url(#f1)");
    polyhoveron.play();
    $("p").text("Mouse has entered");
}).mouseleave(function() {
    $(this).attr("filter", "url(#f2)");
    $("p").text("Mouse has left");
    setTimeout(function() {
        setTimeout(function() {
            $(this).removeAttr("filter");
            $("p").text("Why didn't removeAttr work? Now it's broken and can't be started over.");
        }, 500);
        polyhoveroff.play();
        $("p").text("<polyhoveroff function>")
    }, 500);
});
</code>```

When you have adding attribute at that this is the scope of (svg Path), But after mouseover, You are trting to remove attribute after two nested setTimeout, then this scope will change to event action, Mean this has not scope of (svg path),

so for the same you need to store (svg path) instance to other scope variable, this remove Attribute by using that variable

```<code>$("svg path").mouseenter(function() {
    $(this).attr("filter", "url(#f1)");
    polyhoveron.play();
    $("p").text("Mouse has entered");
}).mouseleave(function() {
    var $this = this;
    $(this).attr("filter", "url(#f2)");
    $("p").text("Mouse has left");
    setTimeout(function() {
        setTimeout(function() {
            console.log($($this).attr('filter'));
            $($this).removeAttr("filter");
            console.log($($this).attr('filter'));

            $("p").text("Why didn't removeAttr work? Now it's broken and can't be started over.");
        }, 500);
        polyhoveroff.play();
        $("p").text("<polyhoveroff function>")
    }, 500);
});
</code>```

Body:
I've got two setTimeout functions that are operating properly but my removeAttr function is not firing. I have no idea why this is.

EDIT: The actual goal is to animate feGaussianBlur's variable "stdDeviation" from 0 to 7 on mouse in.... and 7 to 0 on mouse out... not just once, but an unlimited number of times. While the first path object is still animating, the second path object should also be able to animate separately.

Below is my code but because I'm using a plugin, please follow this link to Codepen: https://codepen.io/ownage/pen/MdzvjW

var polyhoveron = TweenMax.to("#feGaussianBlur", .5, {
  paused:true,
  attr:{"stdDeviation":7},
  onUpdateParams:["{self}"]
});
var polyhoveroff = TweenMax.to("#feGaussianBlur2", .5, {
  paused:true,
  attr:{"stdDeviation":0},
  onUpdateParams:["{self}"]
});

$("svg path").mouseenter(function() {
    $(this).attr("filter", "url(#f1)");
    polyhoveron.play();
    $("p").text("Mouse has entered");
}).mouseleave(function() {
    $(this).attr("filter", "url(#f2)");
    $("p").text("Mouse has left");
    setTimeout(function() {
        setTimeout(function() {
            $(this).removeAttr("filter");
            $("p").text("Why didn't removeAttr work? Now it's broken and can't be started over.");
        }, 500);
        polyhoveroff.play();
        $("p").text("<polyhoveroff function>")
    }, 500);
});

html,body,svg {height:100%}
body {background:cornsilk;}
img,svg path {cursor:pointer;}

Ready to hover. Problem: This only animates once so enjoy it.

<svg viewBox="90 -10 300 200">

  <defs>

    <filter id="f1" x="-40%" y="-40%" height="200%" width="200%">
      <feOffset result="offOut" in="SourceAlpha" dx="0" dy="0" />
      <feGaussianBlur id="feGaussianBlur" result="blurOut" in="offOut" stdDeviation="0" />
      <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
    </filter>

    <filter id="f2" x="-40%" y="-40%" height="200%" width="200%">
      <feOffset result="offOut" in="SourceAlpha" dx="0" dy="0" />
      <feGaussianBlur id="feGaussianBlur2" result="blurOut" in="offOut" stdDeviation="7" />
      <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
    </filter>

  </defs>

  <path d="m 156.29028,68.019096 c 4.67931,-1.988204 -0.12418,-10.666555 10.32783,-11.26589 1.83984,-0.1055 3.04194,0.379201 5.51291,0.764346 0.069,-1.457882 0.39368,-7.513956 0.18783,-9.0114 -0.20581,-1.497443 -2.17888,-0.886775 -3.88749,-1.604662 -2.9137,-2.004347 -3.60967,-4.508091 -4.90279,-7.066947 -1.43623,-2.842048 -2.74829,-5.873666 -3.08935,-9.039685 -0.38465,-3.570722 1.01485,-7.116117 1.23297,-10.703361 1.08612,-0.941004 2.17224,-1.882009 3.25836,-2.823013 -0.40015,-1.882008 -0.8003,-3.764017 -1.20045,-5.646025 -1.881,-1.240819 -5.47796,-1.429412 -4.39448,-4.3669975 0.12147,-1.7496304 0.24294,-3.4992608 0.36441,-5.2488912 -1.71492,0 -3.42985,0 -5.14477,0 1.55912,1.9274484 0.0233,3.2815506 -1.44728,4.4870662 -4.33942,4.6764345 -17.98037,9.8959195 -21.082,8.7530705 -0.2683,-2.332216 -2.37086,2.393413 -3.28353,0.596362 1.34212,2.644214 0.18957,5.899268 -2.70665,6.345448 -2.3295,-1.915206 -4.30895,-5.103085 -7.56114,-3.218799 -3.12217,0.22867 -5.92518,-1.40308 -8.60189,-2.759866 -1.57069,-0.466831 -4.99248,0.07945 -1.89293,1.516781 2.16684,0.932005 4.2283,1.962703 3.53082,4.572657 0,1.793017 0,3.586035 0,5.379053 3.17614,1.071151 2.57339,6.821091 5.18841,6.882203 6.54256,0.152896 6.52233,0.756564 8.9075,3.546429 5.61657,6.569528 3.49195,14.688396 5.04055,24.775964 0.71231,4.639968 4.29374,10.456375 8.59444,10.753658 2.6538,0.183442 4.77082,-4.041744 6.62733,-5.400138 6.44957,-2.977631 3.60533,1.641529 10.42139,-0.217363 z"></path>

  <path d="m 260.769,66.023156 c 3.8349,-4.788158 8.79324,-8.576249 12.7991,-13.224205 1.75034,-2.886256 3.43676,-4.132595 5.93865,-4.863527 1.36048,-1.366469 0.7359,-3.785632 1.10386,-5.678447 -0.76366,-0.838347 -1.35457,-2.029861 -2.22664,-2.646575 -0.99259,-0.08879 -2.12712,0.169001 -3.03839,-0.118352 -1.30495,-1.404354 -2.86845,-2.614797 -4.1339,-4.011836 -2.15241,-6.618271 -4.5275,-13.195742 -5.71384,-20.074944 -1.99173,-9.307097 -2.15055,-5.084229 -4.23803,-2.694703 -1.89331,2.261054 -3.97742,4.394485 -5.75197,6.734975 -2.17919,4.369109 -4.35839,8.738218 -6.53758,13.107327 -1.71492,1.11744 -3.42985,2.234883 -5.14477,3.352328 -1.4828,-0.470312 -2.96182,-1.251763 -4.44692,-1.533208 -4.79877,2.860083 -3.39481,-3.099681 -4.61322,-1.645561 -0.83557,0.646548 -3.16443,2.417752 -4.33214,2.171548 -2.60394,0.20477 -3.7511,-0.08068 -6.2436,-0.757161 -3.3e-4,1.040982 -0.36041,4.077489 1.15977,3.597984 1.14715,0.14345 2.47104,-0.492629 3.62131,0.0082 3.61471,1.043297 7.56377,3.356319 10.11497,7.322839 4.58458,7.718114 4.36102,8.17007 5.13813,13.923417 0.58204,4.309185 2.91437,2.859459 4.04981,4.539599 1.2544,1.856164 1.73521,3.698395 2.9847,6.021742 1.82746,3.202236 1.66695,4.37289 3.5547,4.410115 1.50738,0.02972 2.06302,-2.206341 2.97507,-3.406861 1.09428,-1.440386 1.85013,-3.122803 2.98093,-4.534694 z"></path>

</svg>

Body:
$("svg path").mouseenter(function() {
    $(this).attr("filter", "url(#f1)");
    polyhoveron.play();
    $("p").text("Mouse has entered");
}).mouseleave(function() {
    $(this).attr("filter", "url(#f2)");
    $("p").text("Mouse has left");
    setTimeout(function() {
        setTimeout(function() {
            $(this).removeAttr("filter");
            $("p").text("Why didn't removeAttr work? Now it's broken and can't be started over.");
        }, 500);
        polyhoveroff.play();
        $("p").text("<polyhoveroff function>")
    }, 500);
});

When you have adding attribute at that this is the scope of (svg Path), But after mouseover, You are trting to remove attribute after two nested setTimeout, then this scope will change to event action, Mean this has not scope of (svg path),

so for the same you need to store (svg path) instance to other scope variable, this remove Attribute by using that variable

$("svg path").mouseenter(function() {
    $(this).attr("filter", "url(#f1)");
    polyhoveron.play();
    $("p").text("Mouse has entered");
}).mouseleave(function() {
    var $this = this;
    $(this).attr("filter", "url(#f2)");
    $("p").text("Mouse has left");
    setTimeout(function() {
        setTimeout(function() {
            console.log($($this).attr('filter'));
            $($this).removeAttr("filter");
            console.log($($this).attr('filter'));

            $("p").text("Why didn't removeAttr work? Now it's broken and can't be started over.");
        }, 500);
        polyhoveroff.play();
        $("p").text("<polyhoveroff function>")
    }, 500);
});


问:
Kotlin - How do I concatenate a String to an Int value?
A very basic question, What is the right approach to concatenate String to an Int?

I'm new in Kotlin and want to print an Integer value preceding with String and getting the following error message.

```<code>for (i in 15 downTo 10){
  print(i + " "); //error: None of the following function can be called with the argument supplied:
  print(i); //It's Working but I need some space after the integer value.
}
</code>```

Expected Outcome

15 14 13 12 11 10

答:
$ dollar – Dollar symbol is used in String templates that we’ll be seeing next

```<code>for (i in 15 downTo 10){
  print("$i ")
}
</code>```

Output : 15  14  13  12  11  10

Body:
A very basic question, What is the right approach to concatenate String to an Int?

I'm new in Kotlin and want to print an Integer value preceding with String and getting the following error message.

for (i in 15 downTo 10){
  print(i + " "); //error: None of the following function can be called with the argument supplied:
  print(i); //It's Working but I need some space after the integer value.
}

Expected Outcome

15 14 13 12 11 10

Body:
$ dollar – Dollar symbol is used in String templates that we’ll be seeing next

for (i in 15 downTo 10){
  print("$i ")
}

Output : 15  14  13  12  11  10


问:
How to make a shadow for png or svg drawable along the contour?
It is necessary to drop the shadow from the view element. There is a picture in svg and png format. But it is impossible to do this correctly.
Option without shadow:enter image description here
The option with the shadow that you need to get:enter image description here

答: The easiest way to do it is to just use this image as a background image, with the shadow already in it, and add an amount of padding to all sides equal to the size of the cutout so you don't draw over it</p>


问:
Get contents of a particular row
I want to locate 'td' where text is 'xyz' so that I can find other attributes in the row. I only have 'xyz' with me and want to get other elements in that row.

```<code>.
.
.

<tr>
    <td>
        <a>xyz</a>
    </td>
    <td>address</td>
    <td>phone number</td>
</tr>

.
.
.
</code>```

I can get 'xyz' easily by using

```<code>required = soup.find('a', text = 'xyz')
print(required[0].text)
</code>```

but I'm not able to locate 'td' so that I can use find_next_siblings() to get other columns.

Expected output:

```<code>xyz
address
phone number
</code>```

答:
Replace your code with this:

```<code>from bs4 import BeautifulSoup

html = '''<tr>
    <td>
        <a>xyz</a>
    </td>
    <td>address</td>
    <td>phone number</td>
</tr>'''

soup = BeautifulSoup(html, 'lxml')
required = soup.find('a', text = 'xyz')
print(required.text)
td = required.parent
siblingsArray = td.find_next_siblings()

for siblings in siblingsArray:
    print(siblings.text)
</code>```

O/P:

```<code>xyz
address
phone number
</code>```

Where parent is Get immediate parent tag and find_next_siblings return list of next siblings tag.

Title: Get contents of a particular row

Body:
I want to locate 'td' where text is 'xyz' so that I can find other attributes in the row. I only have 'xyz' with me and want to get other elements in that row.

.
.
.

        xyz

    address
    phone number

.
.
.

I can get 'xyz' easily by using

required = soup.find('a', text = 'xyz')
print(required[0].text)

but I'm not able to locate 'td' so that I can use find_next_siblings() to get other columns.

Expected output:

xyz
address
phone number

Body:
Replace your code with this:

from bs4 import BeautifulSoup

html = '''<tr>
    <td>
        <a>xyz</a>
    </td>
    <td>address</td>
    <td>phone number</td>
</tr>'''

soup = BeautifulSoup(html, 'lxml')
required = soup.find('a', text = 'xyz')
print(required.text)
td = required.parent
siblingsArray = td.find_next_siblings()

for siblings in siblingsArray:
    print(siblings.text)

O/P:

xyz
address
phone number

Where parent is Get immediate parent tag and find_next_siblings return list of next siblings tag.