问:
Trigger multiple links to download files
I have a webpage where I can find a random number of files to download. I wanted to develop a little FireFox extension to download all files at once. So far I have the following function to download these files:

```<code>function getFilesJQ () {
    var $dlLinks = $('a').filter(function(index) { return $(this).text() === "Download"; });

    $dlLinks.each(function () {
        $(this).trigger('click');
    });
}
</code>```

The problem is, that only the first link is clicked and the corresponding file starts to download. The others are not triggered.

Where lies the problem? Is this even possible?

Edit:

This is how $dlLinks looks like:

```<code>{…}
0: <a id="exerciseResourcesForm:a3:0:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:0:linkDownload':'exerciseResourcesForm:a3:0:linkDownload'},'');}return false">
1: <a id="exerciseResourcesForm:a3:1:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:1:linkDownload':'exerciseResourcesForm:a3:1:linkDownload'},'');}return false">
2: <a id="exerciseResourcesForm:a3:2:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:2:linkDownload':'exerciseResourcesForm:a3:2:linkDownload'},'');}return false">
3: <a id="exerciseResourcesForm:a3:3:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:3:linkDownload':'exerciseResourcesForm:a3:3:linkDownload'},'');}return false">
length: 4
prevObject: Object { 0: a, 1: a, 2: a, … }
__proto__: Object { jquery: "3.2.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector", constructor: r(), length: 0, … }
jack_download.js:10:2
</code>```

When one of those links is clicked, to POST requests are issued:

```<code>POST
https://*******/emp/ExerciseEdit.jsf
[HTTP/1.1 200 OK 28ms]
POST
https://sb-ssl.google.com/safebrowsing/clientreport/download
[HTTP/2.0 200 OK 109ms]
</code>```

答:
```<code>$(this).trigger('click');
</code>```

This probably opens the link on the current page, which terminates the current page. You may try to open it in a new one:

```<code>window.open(this.href, "Download");
</code>```

Body:
I have a webpage where I can find a random number of files to download. I wanted to develop a little FireFox extension to download all files at once. So far I have the following function to download these files:

function getFilesJQ () {
    var $dlLinks = $('a').filter(function(index) { return $(this).text() === "Download"; });

    $dlLinks.each(function () {
        $(this).trigger('click');
    });
}

The problem is, that only the first link is clicked and the corresponding file starts to download. The others are not triggered.

Where lies the problem? Is this even possible?

Edit:

This is how $dlLinks looks like:

{…}
0:
1:
2:
3:
length: 4
prevObject: Object { 0: a, 1: a, 2: a, … }
__proto__: Object { jquery: "3.2.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector", constructor: r(), length: 0, … }
jack_download.js:10:2

When one of those links is clicked, to POST requests are issued:

POST
https://*******/emp/ExerciseEdit.jsf
[HTTP/1.1 200 OK 28ms]
POST
https://sb-ssl.google.com/safebrowsing/clientreport/download
[HTTP/2.0 200 OK 109ms]

Body:
$(this).trigger('click');

This probably opens the link on the current page, which terminates the current page. You may try to open it in a new one:

window.open(this.href, "Download");


来源: stackexchange

问:
When to use method over computed property setter and vice versa?
When using Vue.js, when should you use a method or a computed property setter? There seems to be little distinction in the documentation, or numerous articles. Usually articles present computed property setters as little more than a footnote.

Given that both methods and setters accept parameters, is there a particular reason you'd use one or the other? As far as I can see methods would be all you need.

Edit:

This is literally not a repost because the linked SO answer contains the word setter once and only in vague passing:

computed properties are converted into a property of the Vue with a getter and sometimes a setter.

Great, so how does this elaborate on the subject of this post, when to use a SETTER vs a method?

答: Computed properties should be used to display data relative to existing data. While methods should be used to do an action and/or change data.</p>

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 3.0


问:
jQuery serialize() leaves out textarea
When I submit a form using jQuery's serialize() method, everything gets submitted except the textarea in the form. Is this a common issue? I can't figure it out. The form works except for just the textarea which stays undefined???</p>

```<code><textarea form="new_note_form" id="note_text" name="note_text" required="required"></textarea>
</code>```

答: If the textarea is controlled by an editor like tinyMCE, you may need to call tinyMCE.triggerSave(), as described in this answer.

Title: jQuery serialize() leaves out textarea

Body:
When I submit a form using jQuery's serialize() method, everything gets submitted except the textarea in the form. Is this a common issue? I can't figure it out. The form works except for just the textarea which stays undefined???

<textarea form="new_note_form" id="note_text" name="note_text" required="required"></textarea>


问:
How to include the days for the past week in a datepicker/calendar?
I'm trying to create a datepicker with a header format that has the days abbreviated to match the day number.

The current month has 31 days, and there are 31 days printed out, but the 1st of december started last Friday, I'd like to be able to either show the days for the past week or just have the number 1 which refers to the 1st of december begin iterating under the current day, in this case it the 1 should be under F, like shown in the image below:

Here is the code that I came up with:

```<code>var currentMonthDays = [];
var monthDays = dateFns.eachDay(dateFns.startOfMonth(new Date()), dateFns.lastDayOfMonth(new Date()));

for(var day in monthDays){
  currentMonthDays.push(dateFns.format(monthDays[day], 'D'));
}

var numbers = document.querySelector('.picker-days');
for(var key in currentMonthDays){
  var htmlString = '<span class="picker-daysNumber">' + currentMonthDays[key] + '</span>';
    numbers.insertAdjacentHTML('beforeend', htmlString);
}
</code>```

https://jsfiddle.net/cw5oyurp/3/

答:
I'm not sure if it's buggy, I'll have to check further, but this is what I was able to come up with to fix the problem.

First, I got the date for the first week of december, then I checked the difference in days between the first week first day and the first day of the month.

First day of the first week of the december began on the 26th, Sunday.
The 1st of december was on Friday.

The difference in days was 5 days, so I just pushed empty values to the currentMonthDays array and so far it's working. Maybe I'll get the day number instead.

```<code>// organize the days in the calendar to be under the correct day abbreviation
var firstDayOfTheMonth = new Date(this.currentMonthDays.original[0]);
var monthWeekStartedOn = startOfWeek(new Date(this.currentMonthDays.original[0]));
var dayDiff = differenceInDays(firstDayOfTheMonth, monthWeekStartedOn);
for(var i = 0; i < dayDiff; i++){
    this.currentMonthDays.formatted.unshift(' ')[i];
}

console.log(this.currentMonthDays);
</code>```

Body:
I'm trying to create a datepicker with a header format that has the days abbreviated to match the day number.

The current month has 31 days, and there are 31 days printed out, but the 1st of december started last Friday, I'd like to be able to either show the days for the past week or just have the number 1 which refers to the 1st of december begin iterating under the current day, in this case it the 1 should be under F, like shown in the image below:

Here is the code that I came up with:

var currentMonthDays = [];
var monthDays = dateFns.eachDay(dateFns.startOfMonth(new Date()), dateFns.lastDayOfMonth(new Date()));

for(var day in monthDays){
  currentMonthDays.push(dateFns.format(monthDays[day], 'D'));
}

var numbers = document.querySelector('.picker-days');
for(var key in currentMonthDays){
  var htmlString = '' + currentMonthDays[key] + '';
    numbers.insertAdjacentHTML('beforeend', htmlString);
}

https://jsfiddle.net/cw5oyurp/3/

Body:
I'm not sure if it's buggy, I'll have to check further, but this is what I was able to come up with to fix the problem.

First, I got the date for the first week of december, then I checked the difference in days between the first week first day and the first day of the month.

First day of the first week of the december began on the 26th, Sunday.
The 1st of december was on Friday.

The difference in days was 5 days, so I just pushed empty values to the currentMonthDays array and so far it's working. Maybe I'll get the day number instead.

// organize the days in the calendar to be under the correct day abbreviation
var firstDayOfTheMonth = new Date(this.currentMonthDays.original[0]);
var monthWeekStartedOn = startOfWeek(new Date(this.currentMonthDays.original[0]));
var dayDiff = differenceInDays(firstDayOfTheMonth, monthWeekStartedOn);
for(var i = 0; i < dayDiff; i++){
    this.currentMonthDays.formatted.unshift(' ')[i];
}

console.log(this.currentMonthDays);


问:
Css - Align
s
I am new to web design and I have 2
 tags that contain Announcement and Welcome data. I would like to align these next to eachother. But instead they are on top of each other.

I have tried floating one div left and the other right while giving widths to the divs. But I am still having a few issues. I am trying to align the announcement-area and welcome-area divs. Here is my code:

HTML:

```<code><body>
        <div id="page-wrap">
            <ul id="nav" align="center">
                <li class="home"><a href="#">Home</a></li>
            <li class="directory"><a ref="#">Directory</a></li>
                <li class="calender"><a href="#">Calender</a></li>
                <li class="photos"><a href="#">Photos</a></li>
                <li class="links"><a href="#">Links</a></li>
            </ul>

            <div id="main-content">
                <div id="welcome-area">
                    <img src="Images/welcome-header.jpg" alt="header top" />
                    <div id="welcome-content">
                        <p>
                            Welcome to the official website of the Lambda Chi Alpha Delta Beta Zeta Chapter at NSU.
                            This site will be used to inform members of events and show everyone what the fraternity
                            is up too. Take a look around!
                        </p>
                    </div>
                </div>

                <div id="announcements-area">
                    <img src="Images/announcements-top.jpg" alt="announcement top" />
                    <div id="announcements-content">
                        <h4 class="announcement-header">Website is Live!</h4>
                        <p class="metadata">Friday, 1/21/2011</p>

                        <p>
                            The new website for the Delta Beta Zeta Chapter
                            of Lambda Chi Alpha is now live. Welcome!
                        </p>
                    </div>
                </div>

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

            <div id="footer">
            </div>
        </div>
</body>
</code>```

CSS:

```<code>#page-wrap{
    width:1040px;
    margin: 0 auto;
    background-image: url('../Images/content-background.jpg');
    background-repeat:repeat-y;
    }
    #main-content{
        padding-top:10x;
        padding-right:50px;
        padding-left:70px;
        }
        #announcements-area{
            background-image: url('../Images/announcements-content.jpg');
            background-repeat: repeat-y;
            float:left;
            }
            #announcements-content{
                padding-left:15px;
                padding-right:730px;
                padding-bottom:10px;
            }
        #welcome-area{
            background-image: url('../Images/welcome-content.jpg');
            background-repeat: repeat-y;
            float:right;
            }
            #welcome-content{

                padding-left:15px;
                padding-right:350px;
                padding-bottom:10px;
            }
#footer{
    min-height:185px;
    background-image: url('../Images/footer.jpg');
    background-repeat:no-repeat;
}
</code>```

Here is a screenshot of what the divs look like right now. They are on top of eachother. I want them next to eachother.

答:
Try this:

```<code><div id="container" style="width:100%;">
   <div id="left" style="width:50%;float:left;border:1px solid red;">asdfasdf</div>
   <div id="right" style="border:1px solid blue;">asdfasdf</div>
   <div style="clear:both;"></div>
</div>
</code>```

I have borders in their for illustrative purposes only.

ContentLicense: CC BY-SA 2.5

Title: Css - Align <Div>s

Body:
I am new to web design and I have 2
 tags that contain Announcement and Welcome data. I would like to align these next to eachother. But instead they are on top of each other.

I have tried floating one div left and the other right while giving widths to the divs. But I am still having a few issues. I am trying to align the announcement-area and welcome-area divs. Here is my code:

HTML:

Home

Directory

Calender

Photos

Links

                            Welcome to the official website of the Lambda Chi Alpha Delta Beta Zeta Chapter at NSU.
                            This site will be used to inform members of events and show everyone what the fraternity
                            is up too. Take a look around!

Website is Live!

Friday, 1/21/2011

                            The new website for the Delta Beta Zeta Chapter
                            of Lambda Chi Alpha is now live. Welcome!

CSS:

#page-wrap{
    width:1040px;
    margin: 0 auto;
    background-image: url('../Images/content-background.jpg');
    background-repeat:repeat-y;
    }
    #main-content{
        padding-top:10x;
        padding-right:50px;
        padding-left:70px;
        }
        #announcements-area{
            background-image: url('../Images/announcements-content.jpg');
            background-repeat: repeat-y;
            float:left;
            }
            #announcements-content{
                padding-left:15px;
                padding-right:730px;
                padding-bottom:10px;
            }
        #welcome-area{
            background-image: url('../Images/welcome-content.jpg');
            background-repeat: repeat-y;
            float:right;
            }
            #welcome-content{

                padding-left:15px;
                padding-right:350px;
                padding-bottom:10px;
            }
#footer{
    min-height:185px;
    background-image: url('../Images/footer.jpg');
    background-repeat:no-repeat;
}

Here is a screenshot of what the divs look like right now. They are on top of eachother. I want them next to eachother.

Body:
Try this:

<div id="container" style="width:100%;">
   <div id="left" style="width:50%;float:left;border:1px solid red;">asdfasdf</div>
   <div id="right" style="border:1px solid blue;">asdfasdf</div>
   <div style="clear:both;"></div>
</div>

I have borders in their for illustrative purposes only.


问:
How to use groupby and take the difference between the two groups?
Let say I have this simplified dataframe with three variables:

```<code> ID    sample  test_result
 P1    Normal           9
 P2    Normal           7
 P3    Normal           2
 P1     Tumor           6
 P2     Tumor           5
 P3     Tumor           3
</code>```

I want to know the difference between the normal and tumor test_results, but I am not sure how to approach it.

I have tried using groupby on sample column and then use the diff() method on test_result column but that did not work.

Here is what I have tried:

```<code>df.groupby('sample')['test_result'].diff()
</code>```

The output I am expecting is like:

```<code>ID   test_result
P1             3 # the difference between P1 Normal and P1 Tumor (i.e. 9-6)
P2             2
P3            -1
</code>```

Any idea how to tackle this?

答:
You can pivot sample column to the headers and then subtract between Normal and Tumor:

```<code>df.pivot('ID', 'sample', 'test_result').assign(diff = lambda x: x.Normal - x.Tumor)['diff']

#ID
#P1    3
#P2    2
#P3   -1
#Name: diff, dtype: int64
</code>```

Body:
Let say I have this simplified dataframe with three variables:

 ID    sample  test_result
 P1    Normal           9
 P2    Normal           7
 P3    Normal           2
 P1     Tumor           6
 P2     Tumor           5
 P3     Tumor           3

I want to know the difference between the normal and tumor test_results, but I am not sure how to approach it.

I have tried using groupby on sample column and then use the diff() method on test_result column but that did not work.

Here is what I have tried:

df.groupby('sample')['test_result'].diff()

The output I am expecting is like:

ID   test_result
P1             3 # the difference between P1 Normal and P1 Tumor (i.e. 9-6)
P2             2
P3            -1

Any idea how to tackle this?

Body:
You can pivot sample column to the headers and then subtract between Normal and Tumor:

df.pivot('ID', 'sample', 'test_result').assign(diff = lambda x: x.Normal - x.Tumor)['diff']

#ID
#P1    3
#P2    2
#P3   -1
#Name: diff, dtype: int64


问:
No match for 'Operator<<'
In this program I got the error

[Error] no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream}' and 'numcall')

I can't understand how to get rid of it!!

```<code>#include<iostream>

using namespace::std;

class numcall
{
int a,b;

public:
     numcall(int c,int d)
    {
        c = a;
        c = b;
        cout<<"Your First num is " << c << endl << "Your Second num is "<< d << endl;
        cout << "You are in PARAMETER CONSTRUCTOR";
    }

    numcall(int u)
    {
        u = a;
        b = 0;
        cout << "Your First num is " << u << endl << "Your Second num is " << b << endl;
        cout << "You are in PARAMETER CONSTRUCTOR";
    }

    numcall()
    {

    }
};

int main(void)
{
    numcall x = numcall();
    numcall y = numcall(3,4);
    numcall z = numcall(3);
    cout << x << endl << endl << y << endl << endl << z << endl;
}
</code>```

答:
You haven't defined the << operator for your class numcall, so the compiler doesn't know how to apply it.

So define it.

Title: No match for 'Operator<<'

Body:
In this program I got the error

[Error] no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream}' and 'numcall')

I can't understand how to get rid of it!!

#include<iostream>

using namespace::std;

class numcall
{
int a,b;

public:
     numcall(int c,int d)
    {
        c = a;
        c = b;
        cout<<"Your First num is " << c << endl << "Your Second num is "<< d << endl;
        cout << "You are in PARAMETER CONSTRUCTOR";
    }

    numcall(int u)
    {
        u = a;
        b = 0;
        cout << "Your First num is " << u << endl << "Your Second num is " << b << endl;
        cout << "You are in PARAMETER CONSTRUCTOR";
    }

    numcall()
    {

    }
};

int main(void)
{
    numcall x = numcall();
    numcall y = numcall(3,4);
    numcall z = numcall(3);
    cout << x << endl << endl << y << endl << endl << z << endl;
}


问:
Submit an HTML form with empty checkboxes
I have an HTML form - with PHP, I am sending the data of the form into a MySQL database. Some of the answers to the questions on the form have checkboxes. Obviously, the user does not have to tick all checkboxes for one question. I also want to make the other questions (including radio groups) optional.

However, if I submit the form with empty boxes, radio-groups etc, I received a long list of 'Undefined index' error messages for each of them.

How can I get around this? Thanks.

答:
Use this

```<code>$myvalue = (isset($_POST['checkbox']) ? $_POST['checkbox'] : 0;
</code>```

Or substituting whatever your no value is for the 0

OwnerDisplayName: Tray

LastEditorDisplayName: fmsf

Body:
Use this

$myvalue = (isset($_POST['checkbox']) ? $_POST['checkbox'] : 0;

Or substituting whatever your no value is for the 0

OwnerDisplayName: Cruachan


问:
Difference between an object and a dictionary?
What exactly is the difference between an object and a dictionary in Actionscript?

```<code>var obj:Object = new Object();
obj.something = "something";

var dict:Dictionary = new Dictionary();
dict.something = "something";

trace(obj.something, dict.something);
</code>```

The trace statement seems identical...

答:
I think the example here highlights at least one of the most significant differences, which is strict equality in comparing keys.

In summary, dictionary[key] does NOT necessarily return the same value as dictionary["key"], even if key.toString() equals "key".

However, object[key] will return the same value as object["key"], if key.toString() equals "key".

Body:
What exactly is the difference between an object and a dictionary in Actionscript?

var obj:Object = new Object();
obj.something = "something";

var dict:Dictionary = new Dictionary();
dict.something = "something";

trace(obj.something, dict.something);

The trace statement seems identical...


问:
Explanation regarding modulo operator and Math.floor function
I have two functions:

```<code>function getDigitsSum(number) {
  var sum = 0;

  while (number > 0) {

    sum += number % 10;
    number = Math.floor(number / 10);
  }

  return sum;
}

function findNumbers() {

   var results = [];

   for (var i = 1; i <= 100; i++) {
      if (getDigitsSum(i) == 8) {
        results.push(i);
      }
   }

   return results;
}
</code>```

Essentially I am displaying numbers from 1 to 100 whose sum of digits equal 8. I understand the second function completely but not the first function.

This I don't understand:

```<code>while (number > 0) {

    sum += number % 10;
    number = Math.floor(number / 10);
  }
</code>```

My questions would be:

What is the role of the modulo operator in this part of the code? I always thought it simply returns the remainder left over when one operand is divided by a second operand. Here it seems to have a different purpose of which I wasn't aware of. Why does it do what it does and how?

I understand what the Math.floor function is supposed to do but not what (number / 10) means while concerning the rest of the code. Why exactly is number divided by 10?

If there is an alternative code to this one, which of course gives the same result, I would be glad to see it.

答:
Like the function's name tells, it builds the sum over all digits of a number. I.e. getDigitsSum(12345) => 15.

To your first question:
The modulo operator (in this case) does what you thought it does. It divides number by 10, leaving the rest as return value. Hence, 11 % 10 would be 1, 12 % 10 would be 2 and 5 % 3 is also 2.

So number % 10 gives you the 'rightmost' digit of a number: 12345 => 5

Your second question:
number is divided by 10 to cut off the rightmost digit. This is done, so the next iteration in the loop will operate on 1234 instead of 12345.

edit:
Concerning your last question about alternatives. There's plenty of them. Depending on your input, you could operate on the String rather than the Number:

```<code>function getDigitsSum(number) {
    return ('' + number).split('').reduce(function(sum, digit) {
        return sum + Number(digit);
    }, 0)
}
</code>```

Wether this is any clearer or more efficient is open to debate, though.

Body:
I have two functions:

function getDigitsSum(number) {
  var sum = 0;

  while (number > 0) {

    sum += number % 10;
    number = Math.floor(number / 10);
  }

  return sum;
}

function findNumbers() {

   var results = [];

   for (var i = 1; i <= 100; i++) {
      if (getDigitsSum(i) == 8) {
        results.push(i);
      }
   }

   return results;
}

Essentially I am displaying numbers from 1 to 100 whose sum of digits equal 8. I understand the second function completely but not the first function.

This I don't understand:

while (number > 0) {

    sum += number % 10;
    number = Math.floor(number / 10);
  }

My questions would be:

What is the role of the modulo operator in this part of the code? I always thought it simply returns the remainder left over when one operand is divided by a second operand. Here it seems to have a different purpose of which I wasn't aware of. Why does it do what it does and how?

I understand what the Math.floor function is supposed to do but not what (number / 10) means while concerning the rest of the code. Why exactly is number divided by 10?

If there is an alternative code to this one, which of course gives the same result, I would be glad to see it.

Body:
Like the function's name tells, it builds the sum over all digits of a number. I.e. getDigitsSum(12345) => 15.

To your first question:
The modulo operator (in this case) does what you thought it does. It divides number by 10, leaving the rest as return value. Hence, 11 % 10 would be 1, 12 % 10 would be 2 and 5 % 3 is also 2.

So number % 10 gives you the 'rightmost' digit of a number: 12345 => 5

Your second question:
number is divided by 10 to cut off the rightmost digit. This is done, so the next iteration in the loop will operate on 1234 instead of 12345.

edit:
Concerning your last question about alternatives. There's plenty of them. Depending on your input, you could operate on the String rather than the Number:

function getDigitsSum(number) {
    return ('' + number).split('').reduce(function(sum, digit) {
        return sum + Number(digit);
    }, 0)
}

Wether this is any clearer or more efficient is open to debate, though.


问:
Disabling string interning within Jaxb2 speeds up unmarshalling from a Fastinfoset stream. Why is it so hard to disable?
I've measured the time cost of unmarshalling XML to objects using Jaxb2 using a large (1.7mb) XML payload with somewhat long (48 character) tag names. I observed via JProfiler running in sampling mode that string interning work was a solid portion of the time spent.

I did some research and found that Jaxb can be run in a mode where it doesn't intern strings. My theory was that in some cases not interning strings during unmarshalling could improve performance at the expense of using more heap memory due to not having to hash every tag name string during the interning process.

The method that I used to suppress Jaxb's interning behavior was to set on my Fastinfoset "StAXDocumentParser" (which implements XMLStreamReader) the "org.codehaus.stax2.internNames" and "org.codehaus.stax2.internNsUris" properties. It's not 100% clear to me why you must set these to "true" in order to prevent Jaxb from interning strings but that is how it works.

These JUnit-driven tests are what I used to conclude that disabling Jaxb's string interning behavior makes a big performance difference:

https://github.com/gjd6640/fastinfoset-performance-evaluation

So my question is multi-part:

1) Am I misunderstanding something important and shouldn't be trying to disable Jaxb's string interning behavior in the first place?

2) Is there a better way to direct Jaxb not to intern strings? The "StAXManager" class doesn't allow you to set these Woodstox-oriented properties. For this test I ended up extending StAXManager as shown below to hack around the problem. This is a hack that I'd prefer not to use in production. I suspect that the idea here is that when Jaxb is unmarshalling from a Woodstox stream it looks to see if Woodstox is already doing interning and when "yes" Jaxb reacts by disabling that step of the process. I'm cheating by piggybacking on that logic in the Jaxb library so would like a better way to go about this.

```<code>package com.sun.xml.fastinfoset.stax;
public class JaxbStringInternSuppressionStaxManager extends StAXManager {
    public JaxbStringInternSuppressionStaxManager() {
        // Add to the allowable list of feature names so that the user may set these "StAXInputFactory" properties
        super.features.put("org.codehaus.stax2.internNames", null);
        super.features.put("org.codehaus.stax2.internNsUris", null);
    }
}
</code>```

Update:

As usual, "A question well-put is half-answered". I've just noticed while drafting this question that "com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector" checks to see if class "com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser" is assignable from the XMLStreamReader that you're using and if so does not enable string interning. In my case my stream object is a "com.sun.xml.fastinfoset.stax.StAXDocumentParser" so interning doesn't get disabled. Now the question is "why does it do this only for the internal flavor of the Fastinfoset library?" Maybe I'll find the answer by carefully reading this post.

Also, if there's a better forum for this sort of question such as an active developer user group please share that info and I'll see about linking them over to this post so that the right people will see this question.

答:
Solution option 1: Simple approach that swaps the entire app over to a different jaxb implementation

Pull in jaxb-impl to use a version of Jaxb that performs better with this Fastinfoset library:

```<code><!-- Both of these libs must be here in order to get performant behavior out of Jaxb by default.
-->
<dependency>
        <groupId>com.sun.xml.fastinfoset</groupId>
        <artifactId>FastInfoset</artifactId>
        <version>1.2.13</version>
        <scope>compile</scope>
</dependency>
<dependency> <!-- This artifactId also exists under javax.xml.bind but it appears that nobody uses that one... -->
    <groupId>javax.xml</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.1</version>
    <scope>runtime</scope>
</dependency>
<!-- End: Both of these libs... -->
</code>```

This will have the side-effect of updating the jaxb version used by the rest of your code. In some situations may not be desirable. For example, if you're creating a shared library that needs to be usable in various apps it is rude to go and change this functionality when they pull in your shared component.

Solution option 2: Use the JVM's jaxb implementation and a performance hack to trick it into trusting that the strings are already interned (more complex to implement)

Use "maven-shade-plugin" to shade and repackage the Fastinfoset library's classes. The result should be a logic-less maven component. This is optional and is meant to ensure that people using your Fastinfoset codec component won't have classpath collisions due to transitive dependencies pulled in by your codec library.

Create a my-fastinfoset-codec library that provides a simple API to encode and decode Fastinfoset payloads (consider using InputStreams and OutputStreams for arguments and XMLStreamReader for the return type of the decoder). Add a dependency on your repackaged Fastinfoset library. Note that if you use Eclipse it doesn't deal well with shaded libraries when m2e's "Workspace Resolution" is enabled so disable that for your codec project.

Add to my-fastinfoset-codec a class that extends the repackaged Fastinfoset library's "StAXManager". This class should facilitate setting the properties that tell jaxb that the XMLStreamReader that it was given has already interned the NS and tag name strings. Example is below:

```
    package myrepackagedfastinfosetclassespackageprefix.shaded.com.sun.xml.fastinfoset.stax;
    import myrepackagedfastinfosetclassespackageprefix.shaded.com.sun.xml.fastinfoset.stax.StAXManager;
    public class JaxbStringInternSuppressionStaxManager extends StAXManager {
        public JaxbStringInternSuppressionStaxManager() {
            // Add to the allowable list of feature names so that the user may set these "StAXInputFactory" properties
            super.features.put("org.codehaus.stax2.internNames", null);
            super.features.put("org.codehaus.stax2.internNsUris", null);
        }

        /**
         * This is an optimization. The FastInfoset libraries already intern strings and the JVM's jaxb implementation by default
         * unnecessarily repeats that work. This is true at least for the 64 bit version of jdk1.8.0_121.
         *
         * The way that this workaround works is by piggybacking on a Jaxb optimization for the Woodstox parser. When we set
         * these properties it tells jaxb that Woodstox has already interned the strings which causes it to disable its
         * string interning.
         *
         * We did explore the cleaner option of pulling in the Maven "javax.xml:jaxb-impl" artifact as a dependency instead of using
         * the JVM's jaxb library. That external jaxb library when used with the FastInfoset library does perform substantially better
         * than the JVM's but isn't 100% as fast as the JVM's with interning disabled. The key reason that we quit exploring that solution
         * is that when you repackage (via maven-shade-plugin) the jaxb libraries they no longer work with our standard jaxb binding
         * maven components due to statements like "if ( instanceof my_repackaging_project.shaded.XMLElement)"
         * used during the data mapping process.
         */
        public JaxbStringInternSuppressionStaxManager enableTrickToStopJaxbFromInterningStrings() {
            super.setProperty("org.codehaus.stax2.internNames", true);
            super.setProperty("org.codehaus.stax2.internNsUris", true);
            return this;
        }
    }
```

Solution option 3: Enough people who have a JVM support contract with Oracle raise tickets asking for non-internal fastinfoset support of some sort.

I'd expect it to be fairly simple for Oracle to teach the JVM-provided jaxb implementation to determine from the given XMLStreamReader that this Fastinfoset implementation is configured to intern strings.

Solution possibility that didn't pan out:  Repackage the two jars from solution 1 above

One can use "maven-shade-plugin" or similar to create new jars with custom-prefixed package names. This did work with these libraries after some fiddling. However, the end-result that I came to was that the repackaged jaxb libraries now wanted the jaxb-RI produced OXM objects to have annotations from the new shaded package name. Mine were built the standard way so my repackaged solution wouldn't map any data to my objects. I'm not willing to dictate that our OXM binding libraries use a repackaged jaxb library nor did I like this approach enough to explore ways to repackage more carefully so as not to change the package used for those annotations.

Solution option that I didn't explore:

Use the JVM's fastinfoset classes that have ".internal." in their package names. Those would likely perform well with the jaxb implementation that comes with the JVM but I refuse to expose "future me" to the support costs that come with using internal apis.

Body:
I've measured the time cost of unmarshalling XML to objects using Jaxb2 using a large (1.7mb) XML payload with somewhat long (48 character) tag names. I observed via JProfiler running in sampling mode that string interning work was a solid portion of the time spent.

I did some research and found that Jaxb can be run in a mode where it doesn't intern strings. My theory was that in some cases not interning strings during unmarshalling could improve performance at the expense of using more heap memory due to not having to hash every tag name string during the interning process.

The method that I used to suppress Jaxb's interning behavior was to set on my Fastinfoset "StAXDocumentParser" (which implements XMLStreamReader) the "org.codehaus.stax2.internNames" and "org.codehaus.stax2.internNsUris" properties. It's not 100% clear to me why you must set these to "true" in order to prevent Jaxb from interning strings but that is how it works.

These JUnit-driven tests are what I used to conclude that disabling Jaxb's string interning behavior makes a big performance difference:

https://github.com/gjd6640/fastinfoset-performance-evaluation

So my question is multi-part:

1) Am I misunderstanding something important and shouldn't be trying to disable Jaxb's string interning behavior in the first place?

2) Is there a better way to direct Jaxb not to intern strings? The "StAXManager" class doesn't allow you to set these Woodstox-oriented properties. For this test I ended up extending StAXManager as shown below to hack around the problem. This is a hack that I'd prefer not to use in production. I suspect that the idea here is that when Jaxb is unmarshalling from a Woodstox stream it looks to see if Woodstox is already doing interning and when "yes" Jaxb reacts by disabling that step of the process. I'm cheating by piggybacking on that logic in the Jaxb library so would like a better way to go about this.

package com.sun.xml.fastinfoset.stax;
public class JaxbStringInternSuppressionStaxManager extends StAXManager {
    public JaxbStringInternSuppressionStaxManager() {
        // Add to the allowable list of feature names so that the user may set these "StAXInputFactory" properties
        super.features.put("org.codehaus.stax2.internNames", null);
        super.features.put("org.codehaus.stax2.internNsUris", null);
    }
}

Update:

As usual, "A question well-put is half-answered". I've just noticed while drafting this question that "com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector" checks to see if class "com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser" is assignable from the XMLStreamReader that you're using and if so does not enable string interning. In my case my stream object is a "com.sun.xml.fastinfoset.stax.StAXDocumentParser" so interning doesn't get disabled. Now the question is "why does it do this only for the internal flavor of the Fastinfoset library?" Maybe I'll find the answer by carefully reading this post.

Also, if there's a better forum for this sort of question such as an active developer user group please share that info and I'll see about linking them over to this post so that the right people will see this question.

Body:
Solution option 1: Simple approach that swaps the entire app over to a different jaxb implementation

Pull in jaxb-impl to use a version of Jaxb that performs better with this Fastinfoset library:

<!-- Both of these libs must be here in order to get performant behavior out of Jaxb by default.
-->
<dependency>
        <groupId>com.sun.xml.fastinfoset</groupId>
        <artifactId>FastInfoset</artifactId>
        <version>1.2.13</version>
        <scope>compile</scope>
</dependency>
<dependency> <!-- This artifactId also exists under javax.xml.bind but it appears that nobody uses that one... -->
    <groupId>javax.xml</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.1</version>
    <scope>runtime</scope>
</dependency>
<!-- End: Both of these libs... -->

This will have the side-effect of updating the jaxb version used by the rest of your code. In some situations may not be desirable. For example, if you're creating a shared library that needs to be usable in various apps it is rude to go and change this functionality when they pull in your shared component.

Solution option 2: Use the JVM's jaxb implementation and a performance hack to trick it into trusting that the strings are already interned (more complex to implement)

Use "maven-shade-plugin" to shade and repackage the Fastinfoset library's classes. The result should be a logic-less maven component. This is optional and is meant to ensure that people using your Fastinfoset codec component won't have classpath collisions due to transitive dependencies pulled in by your codec library.

Create a my-fastinfoset-codec library that provides a simple API to encode and decode Fastinfoset payloads (consider using InputStreams and OutputStreams for arguments and XMLStreamReader for the return type of the decoder). Add a dependency on your repackaged Fastinfoset library. Note that if you use Eclipse it doesn't deal well with shaded libraries when m2e's "Workspace Resolution" is enabled so disable that for your codec project.

Add to my-fastinfoset-codec a class that extends the repackaged Fastinfoset library's "StAXManager". This class should facilitate setting the properties that tell jaxb that the XMLStreamReader that it was given has already interned the NS and tag name strings. Example is below:

    package myrepackagedfastinfosetclassespackageprefix.shaded.com.sun.xml.fastinfoset.stax;
    import myrepackagedfastinfosetclassespackageprefix.shaded.com.sun.xml.fastinfoset.stax.StAXManager;
    public class JaxbStringInternSuppressionStaxManager extends StAXManager {
        public JaxbStringInternSuppressionStaxManager() {
            // Add to the allowable list of feature names so that the user may set these "StAXInputFactory" properties
            super.features.put("org.codehaus.stax2.internNames", null);
            super.features.put("org.codehaus.stax2.internNsUris", null);
        }

        /**
         * This is an optimization. The FastInfoset libraries already intern strings and the JVM's jaxb implementation by default
         * unnecessarily repeats that work. This is true at least for the 64 bit version of jdk1.8.0_121.
         *
         * The way that this workaround works is by piggybacking on a Jaxb optimization for the Woodstox parser. When we set
         * these properties it tells jaxb that Woodstox has already interned the strings which causes it to disable its
         * string interning.
         *
         * We did explore the cleaner option of pulling in the Maven "javax.xml:jaxb-impl" artifact as a dependency instead of using
         * the JVM's jaxb library. That external jaxb library when used with the FastInfoset library does perform substantially better
         * than the JVM's but isn't 100% as fast as the JVM's with interning disabled. The key reason that we quit exploring that solution
         * is that when you repackage (via maven-shade-plugin) the jaxb libraries they no longer work with our standard jaxb binding
         * maven components due to statements like "if ( instanceof my_repackaging_project.shaded.XMLElement)"
         * used during the data mapping process.
         */
        public JaxbStringInternSuppressionStaxManager enableTrickToStopJaxbFromInterningStrings() {
            super.setProperty("org.codehaus.stax2.internNames", true);
            super.setProperty("org.codehaus.stax2.internNsUris", true);
            return this;
        }
    }

Solution option 3: Enough people who have a JVM support contract with Oracle raise tickets asking for non-internal fastinfoset support of some sort.

I'd expect it to be fairly simple for Oracle to teach the JVM-provided jaxb implementation to determine from the given XMLStreamReader that this Fastinfoset implementation is configured to intern strings.

Solution possibility that didn't pan out:  Repackage the two jars from solution 1 above

One can use "maven-shade-plugin" or similar to create new jars with custom-prefixed package names. This did work with these libraries after some fiddling. However, the end-result that I came to was that the repackaged jaxb libraries now wanted the jaxb-RI produced OXM objects to have annotations from the new shaded package name. Mine were built the standard way so my repackaged solution wouldn't map any data to my objects. I'm not willing to dictate that our OXM binding libraries use a repackaged jaxb library nor did I like this approach enough to explore ways to repackage more carefully so as not to change the package used for those annotations.

Solution option that I didn't explore:

Use the JVM's fastinfoset classes that have ".internal." in their package names. Those would likely perform well with the jaxb implementation that comes with the JVM but I refuse to expose "future me" to the support costs that come with using internal apis.


问:
Force redraw as resizing NSTableColumn in NSTableView?
I've implemented - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row in my NSTableView's delegate to resize the height of my table's rows as the width of the leftmost column changes. The problem is that only that column redraws during the resizing (and any column that slide into view during the resize).

This results in the funky visual below after resizing. What I'd like is a way to tell the table view to completely redraw while the user is resizing a column. Right now the most I've been able to do is call setNeedsDisplay after that column finishes resizing.

答: It may not be the only way, but giving the table view a Core Animation layer fixed it. It's not 100% smooth, but the average user would probably never notice.</p>


问:
Reversing words in shell
Task is to reverse all letters (a-zA-Z) in words that have 5 or less characters.

EDIT: Let's assume word is a not interrupted sequence of letters from english alphabet.

( letter: ASCII range A-Z && a-z)

Example:

Input: "One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them."

Output: "enO gnir ot elur meht lla, eno gnir ot dnif meht, enO gnir ot gnirb meht lla dna ni eht darkness dnib meht."

I have been able to write this script, but it sruggles with words with special chracters such as {,.} that are not supposed to be reversed.

```<code>#!/bin/bash

    word_length=0
    touch tmp

    for word in $(cat ./TEXT)
    do
            word_length=$(echo -n $word | wc -c )
            if [ $word_length -le 5 ]
            then
                    echo -n $word | rev >> tmp
                    echo -n " " >> tmp
            else
                    echo -n $word >> tmp
                    echo -n " " >> tmp
            fi
    done

    cat tmp > TEXT
    echo " " >> TEXT
    rm -rf tmp
</code>```

Output of this script:
"enO gnir ot elur meht ,lla eno gnir ot dnif ,meht enO gnir ot gnirb meht lla dna ni eht darkness dnib .meht"

You can see that {,.} are in the wrong place.

答:
You'll have to separate the . and , from your words.
You can:

change the first cat ./TEXT with sed -r 's/([,.])/ \1/g' ./TEXT which add a space before those character

then when the output is done reverse the sed sed -r 's/ ([,.])/\1/g' ./TEXT which remove the white space added before (In your example your TEXT file has one word by line but I took the hypothesis you'll will correct this)

But, this will be limited to the character put in the sed like ,.':; if new characters occurs you'll have to change the script

Beside, why a limit of 5 characters to reverse a word ? In your example darkness is not reverse because of this.

Title: Reversing words in shell

Body:
Task is to reverse all letters (a-zA-Z) in words that have 5 or less characters.

EDIT: Let's assume word is a not interrupted sequence of letters from english alphabet.

( letter: ASCII range A-Z && a-z)

Example:

Input: "One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them."

Output: "enO gnir ot elur meht lla, eno gnir ot dnif meht, enO gnir ot gnirb meht lla dna ni eht darkness dnib meht."

I have been able to write this script, but it sruggles with words with special chracters such as {,.} that are not supposed to be reversed.

#!/bin/bash

    word_length=0
    touch tmp

    for word in $(cat ./TEXT)
    do
            word_length=$(echo -n $word | wc -c )
            if [ $word_length -le 5 ]
            then
                    echo -n $word | rev >> tmp
                    echo -n " " >> tmp
            else
                    echo -n $word >> tmp
                    echo -n " " >> tmp
            fi
    done

    cat tmp > TEXT
    echo " " >> TEXT
    rm -rf tmp

Output of this script:
"enO gnir ot elur meht ,lla eno gnir ot dnif ,meht enO gnir ot gnirb meht lla dna ni eht darkness dnib .meht"

You can see that {,.} are in the wrong place.


问:
Java local vs instance variable access speed
So my question is about variable accessing speed in Java. Today in my "CS" (if you can call it that) the teacher presented a similar example to the following of a List:

```<code>public class ListExample<T> {
    private Node<T> head;
    private Node<T> tail;

    private class Node<T> { /* ... */ }

    public void append(T content) {
        if (!isEmpty()) {
            Node<T> dummy = new Node<T>(content);
            head = dummy;
            tail = dummy;

            head.setNext(head);
            // or this
            dummy.setNext(dummy);

        } else { /* ... */ }
    }

    // more methods
    // ...
}
</code>```

My question is: Would the call to head.setNext(head) be slower than dummy.setNext(dummy) ? Even if it's not noticeable.
I was wondering this since head is obviously and instance var of the class and dummy is local, so would the local access be faster?

答:
I can assure you that whatever performance gains one might gain from this will be offset by the headache of looking at confusingly written code. Let the compiler figure this out. I will concede that all things being equal, the local variable is probably slightly faster, if only because there are fewer bytecode instructions involved. However, who is to say that future versions of the JVM won't change this?

In short, write code that is easy to read first. If, after that, you have a performance concern, profile.

Body:
So my question is about variable accessing speed in Java. Today in my "CS" (if you can call it that) the teacher presented a similar example to the following of a List:

public class ListExample<T> {
    private Node<T> head;
    private Node<T> tail;

    private class Node<T> { /* ... */ }

    public void append(T content) {
        if (!isEmpty()) {
            Node<T> dummy = new Node<T>(content);
            head = dummy;
            tail = dummy;

            head.setNext(head);
            // or this
            dummy.setNext(dummy);

        } else { /* ... */ }
    }

    // more methods
    // ...
}

My question is: Would the call to head.setNext(head) be slower than dummy.setNext(dummy) ? Even if it's not noticeable.
I was wondering this since head is obviously and instance var of the class and dummy is local, so would the local access be faster?


问:
Fermat Primality Test Haskell
I have implemented the following two functions for establishing if n is a fermat prime number (will return n if its true, -1 if not), but it returns always -1, can't figure out why (gc is a funct taht calculates gcd)</p>

```<code>fermatPT :: Int -> Int
fermatPT n = fermatPT' n list
  where
    list = [a | a <- [1..n-1]]

-- | heper function
fermatPT' :: Int -> [Int] -> Int
fermatPT' n l      | gc (n, head l) == 1 && fermatTest n (head l) = fermatPT' n (tail l)
                   | null l                                       = n
                   | otherwise                                    = -1
                where
                  fermatTest n a = mod (a^(n-1)) n == 1
</code>```

答:
Your function should return a boolean indicating if the given number is a prime. If you do that, you can use the all function to define this simply as

```<code>fermatPT :: Integer -> Bool
fermatPT n = all (fermatTest n) (filter (\a -> gcd n a == 1) [1..n-1])
             where fermatTest n a = mod (a^(n-1)) n == 1
</code>```

gcd is defined in the Prelude.

all avoids the explicit recursion that requires you to apply the test to one element of [1..n-1] at a time; its definition is effectively

```<code>all _ [] = True
all p (x:xs) = p x && all p xs
</code>```

Note that mod (a ^ (n - 1)) n is inefficient, since it may require computing an absurdly large number before ultimately reducing it to the range [0..n-1]. Instead, take advantage of the fact that ab mod n == (a mod n * b mod n) mod n, and reduce the value after each multiplication. One way to implement this (not the fastest, but it's simple):

```<code>modN :: Integer -> Integer -> Integer -> Integer
modN a 0 _ = 1
modN a b n = ((a `mod` n) * (modN a (b - 1) n)) `mod` n
</code>```

Then use

```<code>fermatTest n a = modN a (n-1) n == 1
</code>```

Note that you could use this (with Int instead of Integer) to correctly implement fermatPT :: Int -> Bool; although the input would still be restricted to smaller integers, it won't suffer from overflow.

Title: Fermat Primality Test Haskell

Body:
I have implemented the following two functions for establishing if n is a fermat prime number (will return n if its true, -1 if not), but it returns always -1, can't figure out why (gc is a funct taht calculates gcd)

fermatPT :: Int -> Int
fermatPT n = fermatPT' n list
  where
    list = [a | a <- [1..n-1]]

-- | heper function
fermatPT' :: Int -> [Int] -> Int
fermatPT' n l      | gc (n, head l) == 1 && fermatTest n (head l) = fermatPT' n (tail l)
                   | null l                                       = n
                   | otherwise                                    = -1
                where
                  fermatTest n a = mod (a^(n-1)) n == 1

Body:
Your function should return a boolean indicating if the given number is a prime. If you do that, you can use the all function to define this simply as

fermatPT :: Integer -> Bool
fermatPT n = all (fermatTest n) (filter (\a -> gcd n a == 1) [1..n-1])
             where fermatTest n a = mod (a^(n-1)) n == 1

gcd is defined in the Prelude.

all avoids the explicit recursion that requires you to apply the test to one element of [1..n-1] at a time; its definition is effectively

all _ [] = True
all p (x:xs) = p x && all p xs

Note that mod (a ^ (n - 1)) n is inefficient, since it may require computing an absurdly large number before ultimately reducing it to the range [0..n-1]. Instead, take advantage of the fact that ab mod n == (a mod n * b mod n) mod n, and reduce the value after each multiplication. One way to implement this (not the fastest, but it's simple):

modN :: Integer -> Integer -> Integer -> Integer
modN a 0 _ = 1
modN a b n = ((a `mod` n) * (modN a (b - 1) n)) `mod` n

Then use

fermatTest n a = modN a (n-1) n == 1

Note that you could use this (with Int instead of Integer) to correctly implement fermatPT :: Int -> Bool; although the input would still be restricted to smaller integers, it won't suffer from overflow.


问:
Internet Explorer button:active inner-padding
Trident <=9 seems to append something like an inner-padding to active button elements.

Is it possible to disable this feature by using css ?

答:
```<code><button><span>Submit</span></button>
</code>```

<hr>

```<code>button:active > span {
 -ms-transform: translate(0px, -0.5px);
}
</code>```

Body:
<button><span>Submit</span></button>

button:active > span {
 -ms-transform: translate(0px, -0.5px);
}


问:
Hibernate 5.2.7 - java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
while using Hibernate 5.2.7 in a Gradle Java Project to connect to a MariaDB 10.1.19, I am getting an Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;

The complete stacktrace

```<code> Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:71)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:58)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:77)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:240)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at quantitativeAnalysis.backend.dataCollector.dataCollectorManager.createFactory(dataCollectorManager.java:280)
at quantitativeAnalysis.volatilityAnalyzer.volatilityDynamicImpl.openInstance(volatilityDynamicImpl.java:18)
at frontend.MainFrame.main(MainFrame.java:96)
</code>```

I have tried several approaches (other Hibernate Versions 5.2.6 and 5.2.3) and searched the internet for help, but none of the suggestions worked.

The Exception occur here:

```<code>    Configuration configuration = new Configuration().configure();

    StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
    try{
        factory = configuration.buildSessionFactory(ssrb.build());
    }catch(Exception ex){
    System.err.println("Failed to configure Sessionfactory");
    ex.printStackTrace();
}
</code>```

I have also tried the following code leading to the same result:

```<code>    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
    .configure() // configures settings from hibernate.cfg.xml
    .build();

try {
    factory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
    }catch(Exception ex){
    System.err.println("Failed to configure Sessionfactory");
    ex.printStackTrace();
    }
</code>```

My hibernate.cfg.xml looks like this

```<code><session-factory>

    <!-- Database connection settings -->
    <!-- <property name="connection.driver_class">com.mysql.jdbc.Driver</property> -->
    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost:3307/VolatilityData</property>
    <property name="connection.username">XXX</property>
    <property name="connection.password">XXX</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>

    <!--  -->
    <property name="hbm2dll.auto">create</property>

    <!-- mapping content -->
    <mapping resource="resources/BitcoinDaysDestroyed.hbm.xml"/>
    <mapping resource="resources/BitcoinPrice.hbm.xml"/>
    <mapping resource="resources/BitcoinTransactions.hbm.xml"/>

</session-factory>
</code>```

The jars I include with Gradle are the following:

```<code>// Apply the java plugin to add support for Java
apply plugin: 'java'

// In this section you declare where to find the dependencies of your   project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
//jcenter()
mavenCentral()

maven {
url "https://maven.elasticsearch.org/releases"
  }
}

dependencies {
// The production code uses Guava
compile 'com.google.guava:guava:20.0'

//QuantitativeAnalysis

// https://mvnrepository.com/artifact/com.toedter/jcalendar
compile group: 'com.toedter', name: 'jcalendar', version: '1.4'

// https://mvnrepository.com/artifact/javax.persistence/persistence-api
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0.2'

// https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'

// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.5'

// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
//compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.6.Final'

//antlr-2.7.7.jar, compiled from src
compile files('libs/antlr-2.7.7.jar')

//classmate-1.3.0.jar, compiled from src
compile files('libs/classmate-1.3.0.jar')

//dom4j-1.6.1.jar, compiled from src
compile files('libs/dom4j-1.6.1.jar')

//antlr-2.7.7.jar, compiled from src
compile files('libs/geronimo-jta_1.1_spec-1.1.1.jar')

//jandex-2.0.3.Final.jar, compiled from src
compile files('libs/jandex-2.0.3.Final.jar')

//javassist-3.20.0-GA.jar, compiled from src
compile files('libs/javassist-3.20.0-GA.jar')

//jboss-logging-3.3.0.Final.jar, compiled from src
compile files('libs/jboss-logging-3.3.0.Final.jar')

//hibernate-commons-annotations-5.0.1.Final.jar, compiled from src
compile files('libs/hibernate-commons-annotations-5.0.1.Final.jar')

//hibernate-jpa-2.1-api-1.0.0.Final.jar, compiled from src
compile files('libs/hibernate-jpa-2.1-api-1.0.0.Final.jar')

//hibernate-core-5.2.7.Final.jar, compiled from src
compile files('libs/hibernate-core-5.2.7.Final.jar')

//c3p0-0.9.5.2, compiled from src
compile files('libs/c3p0-0.9.5.2.jar')

//hibernate-c3p0-5.2.7.Final.jar, compiled from src
compile files('libs/hibernate-c3p0-5.2.7.Final.jar')

//mchange-commons-java-0.2.11.jar, compiled from src
compile files('libs/mchange-commons-java-0.2.11.jar')

// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'

//QualitatitveAnalysis

// https://mvnrepository.com/artifact/log4j/log4j
compile group: 'log4j', name: 'log4j', version: '1.2.17'

// https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch
compile group: 'org.elasticsearch', name: 'elasticsearch', version: '2.1.0'

// https://mvnrepository.com/artifact/org.elasticsearch.plugin/shield
compile group: 'org.elasticsearch.plugin', name: 'shield', version: '2.1.0'

// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'

// https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.6'

// https://mvnrepository.com/artifact/javax.json/javax.json-api
compile group: 'javax.json', name: 'javax.json-api', version: '1.0'

//jReddit Jar, compiled from src
compile files('libs/jReddit-1.0.4-SNAPSHOT.jar')

// Use JUnit test framework
testCompile 'junit:junit:4.12'
}
</code>```

Any help or advice is highly appreciated

答:
What version of the Gradle do you have?

I ask, because I have the same error which occurs after upgrade Gradle from 3.5 to 4.3. The same Hibernate version (5.2.9), the same Spring Boot (1.5.8) but in Gradle 3.5. - OK, 4.3 fail.

I've tested and latest version working fine was for me 3.5.1. I've tested versions from 4.0 to 4.4-rc-6 (latest at this moment).

```<code>distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
</code>```

Body:
while using Hibernate 5.2.7 in a Gradle Java Project to connect to a MariaDB 10.1.19, I am getting an Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;

The complete stacktrace

 Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:71)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:58)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:77)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:240)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at quantitativeAnalysis.backend.dataCollector.dataCollectorManager.createFactory(dataCollectorManager.java:280)
at quantitativeAnalysis.volatilityAnalyzer.volatilityDynamicImpl.openInstance(volatilityDynamicImpl.java:18)
at frontend.MainFrame.main(MainFrame.java:96)

I have tried several approaches (other Hibernate Versions 5.2.6 and 5.2.3) and searched the internet for help, but none of the suggestions worked.

The Exception occur here:

    Configuration configuration = new Configuration().configure();

    StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
    try{
        factory = configuration.buildSessionFactory(ssrb.build());
    }catch(Exception ex){
    System.err.println("Failed to configure Sessionfactory");
    ex.printStackTrace();
}

I have also tried the following code leading to the same result:

    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
    .configure() // configures settings from hibernate.cfg.xml
    .build();

try {
    factory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
    }catch(Exception ex){
    System.err.println("Failed to configure Sessionfactory");
    ex.printStackTrace();
    }

My hibernate.cfg.xml looks like this

<session-factory>

    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost:3307/VolatilityData</property>
    <property name="connection.username">XXX</property>
    <property name="connection.password">XXX</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>

    <property name="hbm2dll.auto">create</property>

    <mapping resource="resources/BitcoinDaysDestroyed.hbm.xml"/>
    <mapping resource="resources/BitcoinPrice.hbm.xml"/>
    <mapping resource="resources/BitcoinTransactions.hbm.xml"/>

</session-factory>

The jars I include with Gradle are the following:

// Apply the java plugin to add support for Java
apply plugin: 'java'

// In this section you declare where to find the dependencies of your   project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
//jcenter()
mavenCentral()

maven {
url "https://maven.elasticsearch.org/releases"
  }
}

dependencies {
// The production code uses Guava
compile 'com.google.guava:guava:20.0'

//QuantitativeAnalysis

// https://mvnrepository.com/artifact/com.toedter/jcalendar
compile group: 'com.toedter', name: 'jcalendar', version: '1.4'

// https://mvnrepository.com/artifact/javax.persistence/persistence-api
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0.2'

// https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'

// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.5'

// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
//compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.6.Final'

//antlr-2.7.7.jar, compiled from src
compile files('libs/antlr-2.7.7.jar')

//classmate-1.3.0.jar, compiled from src
compile files('libs/classmate-1.3.0.jar')

//dom4j-1.6.1.jar, compiled from src
compile files('libs/dom4j-1.6.1.jar')

//antlr-2.7.7.jar, compiled from src
compile files('libs/geronimo-jta_1.1_spec-1.1.1.jar')

//jandex-2.0.3.Final.jar, compiled from src
compile files('libs/jandex-2.0.3.Final.jar')

//javassist-3.20.0-GA.jar, compiled from src
compile files('libs/javassist-3.20.0-GA.jar')

//jboss-logging-3.3.0.Final.jar, compiled from src
compile files('libs/jboss-logging-3.3.0.Final.jar')

//hibernate-commons-annotations-5.0.1.Final.jar, compiled from src
compile files('libs/hibernate-commons-annotations-5.0.1.Final.jar')

//hibernate-jpa-2.1-api-1.0.0.Final.jar, compiled from src
compile files('libs/hibernate-jpa-2.1-api-1.0.0.Final.jar')

//hibernate-core-5.2.7.Final.jar, compiled from src
compile files('libs/hibernate-core-5.2.7.Final.jar')

//c3p0-0.9.5.2, compiled from src
compile files('libs/c3p0-0.9.5.2.jar')

//hibernate-c3p0-5.2.7.Final.jar, compiled from src
compile files('libs/hibernate-c3p0-5.2.7.Final.jar')

//mchange-commons-java-0.2.11.jar, compiled from src
compile files('libs/mchange-commons-java-0.2.11.jar')

// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'

//QualitatitveAnalysis

// https://mvnrepository.com/artifact/log4j/log4j
compile group: 'log4j', name: 'log4j', version: '1.2.17'

// https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch
compile group: 'org.elasticsearch', name: 'elasticsearch', version: '2.1.0'

// https://mvnrepository.com/artifact/org.elasticsearch.plugin/shield
compile group: 'org.elasticsearch.plugin', name: 'shield', version: '2.1.0'

// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'

// https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.6'

// https://mvnrepository.com/artifact/javax.json/javax.json-api
compile group: 'javax.json', name: 'javax.json-api', version: '1.0'

//jReddit Jar, compiled from src
compile files('libs/jReddit-1.0.4-SNAPSHOT.jar')

// Use JUnit test framework
testCompile 'junit:junit:4.12'
}

Any help or advice is highly appreciated

Body:
What version of the Gradle do you have?

I ask, because I have the same error which occurs after upgrade Gradle from 3.5 to 4.3. The same Hibernate version (5.2.9), the same Spring Boot (1.5.8) but in Gradle 3.5. - OK, 4.3 fail.

I've tested and latest version working fine was for me 3.5.1. I've tested versions from 4.0 to 4.4-rc-6 (latest at this moment).

distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip


问:
cron file to update the database sequentially after every run
im redesigning a mmorpg game and im in a bit of a pickle on this one.
i have the following code on the daily cron file.

```<code>dbn("update mygame set event = '11' where event = '10'");
</code>```

now...

this file runs once a day. i would like to update the database in a way such
day 1 ----- event =10,
day 2 ----- event =11,
day 3 ----- event =12 ...etc,
in other words,
once the event is set it will automatically update itself till it dies out.
Hence day 1

```<code>dbn("update mygame set event = '10' where event = '9'");
</code>```

day 2

```<code>dbn("update mygame set event = '11' where event = '10'");
</code>```

so on and so forth.

Any ideas?
Thank you in advance for reading.

答:
```<code>UPDATE mygame
  SET event=event+1
  WHERE <useful condition>
</code>```

Body:
im redesigning a mmorpg game and im in a bit of a pickle on this one.
i have the following code on the daily cron file.

dbn("update mygame set event = '11' where event = '10'");

now...

this file runs once a day. i would like to update the database in a way such
day 1 ----- event =10,
day 2 ----- event =11,
day 3 ----- event =12 ...etc,
in other words,
once the event is set it will automatically update itself till it dies out.
Hence day 1

dbn("update mygame set event = '10' where event = '9'");

day 2

dbn("update mygame set event = '11' where event = '10'");

so on and so forth.

Any ideas?
Thank you in advance for reading.


问:
Why won't my nested function call after the conditional?
Trying to call 'dialogue_b1_a()' using the input function within a function named dialogue_b1(). When I call dialogue_b1() normally, the prompt works, but after I type begin, it simply says that 'process executed with exit code 0', instead of calling the function I put if continue_b1 == begin. What am I doing wrong? Thanks.    </p>

```<code>def dialogue_b1():
    begin = 0
    print("You identify as a male.")
    print("...")
    continue_b1 = input('Type "begin" to continue.')
    if continue_b1 == begin:
        dialogue_b1_a()
    return
</code>```

答:
There is something wrong here. Either you mistyped the code in your question, or you applied the wrong label 'Python 2.7'. When I copy the code you posted and type begin at the prompt it does indeed attempt to call dialogue_b1_a().

Never use input() in Python 2.7, always use raw_input().

When you type begin in response to the input() call, Python 2.7 evaluates what you type as an expression. That is why you needed the begin=0 at the top of the function.

If on the other hand you ran this code under Python 3.x typing begin will simply return the string "begin" from the input() call and the condition will not match. In that case the condition could never match as Python 3 input() will always return a string.

Corrected code for Python 2.7:

```<code>def dialogue_b1():
    print("You identify as a male.")
    print("...")
    continue_b1 = raw_input('Type "begin" to continue.')
    if continue_b1 == "begin":
        dialogue_b1_a()
    return
</code>```

or for Python 3:

```<code>def dialogue_b1():
    print("You identify as a male.")
    print("...")
    continue_b1 = input('Type "begin" to continue.')
    if continue_b1 == "begin":
        dialogue_b1_a()
    return
</code>```

Body:
Trying to call 'dialogue_b1_a()' using the input function within a function named dialogue_b1(). When I call dialogue_b1() normally, the prompt works, but after I type begin, it simply says that 'process executed with exit code 0', instead of calling the function I put if continue_b1 == begin. What am I doing wrong? Thanks.

def dialogue_b1():
    begin = 0
    print("You identify as a male.")
    print("...")
    continue_b1 = input('Type "begin" to continue.')
    if continue_b1 == begin:
        dialogue_b1_a()
    return

Body:
There is something wrong here. Either you mistyped the code in your question, or you applied the wrong label 'Python 2.7'. When I copy the code you posted and type begin at the prompt it does indeed attempt to call dialogue_b1_a().

Never use input() in Python 2.7, always use raw_input().

When you type begin in response to the input() call, Python 2.7 evaluates what you type as an expression. That is why you needed the begin=0 at the top of the function.

If on the other hand you ran this code under Python 3.x typing begin will simply return the string "begin" from the input() call and the condition will not match. In that case the condition could never match as Python 3 input() will always return a string.

Corrected code for Python 2.7:

def dialogue_b1():
    print("You identify as a male.")
    print("...")
    continue_b1 = raw_input('Type "begin" to continue.')
    if continue_b1 == "begin":
        dialogue_b1_a()
    return

or for Python 3:

def dialogue_b1():
    print("You identify as a male.")
    print("...")
    continue_b1 = input('Type "begin" to continue.')
    if continue_b1 == "begin":
        dialogue_b1_a()
    return


答:
The answer above works! Just a small addition(if statement) to have the app running locally say from an IDE like eclipse</p>

```<code>@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
    return (container -> {
        container.setContextPath("");
        if(System.getenv("PORT")!=null) {
            container.setPort(Integer.valueOf(System.getenv("PORT")));

        }
    });
</code>```

Title: Spring Boot on Heroku - Web process failed to bind to $PORT within 90 seconds of launch

Body:
I'm trying to deploy a simple Spring Boot Application on a brand new Heroku App. The logs look fine and it seems that it does load all the beans and rest endpoints I created.

2017-08-08T01:13:06.328318+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-08-08T01:13:06.331742+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-08-08T01:13:07.492271+00:00 app[web.1]:
2017-08-08T01:13:07.492313+00:00 app[web.1]:   .   ____          _            __ _ _
2017-08-08T01:13:07.492368+00:00 app[web.1]:  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2017-08-08T01:13:07.492440+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2017-08-08T01:13:07.492513+00:00 app[web.1]:  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2017-08-08T01:13:07.492575+00:00 app[web.1]:   '  |____| .__|_| |_|_| |_\__, | / / / /
2017-08-08T01:13:07.492635+00:00 app[web.1]:  =========|_|==============|___/=/_/_/_/
2017-08-08T01:13:07.495462+00:00 app[web.1]:  :: Spring Boot ::        (v1.5.6.RELEASE)
2017-08-08T01:13:07.495498+00:00 app[web.1]:
2017-08-08T01:13:07.656174+00:00 app[web.1]: 2017-08-08 01:13:07.651  INFO 4 --- [           main] com.nem.swift.bc.main.Application        : Starting Application v0.0.1-SNAPSHOT on fcd985c5-8723-4bd9-a4f5-14dcb623f5e0 with PID 4 (/app/target/nem-swift-blockchain-service-0.0.1-SNAPSHOT.jar started by u48179 in /app)
2017-08-08T01:13:07.656569+00:00 app[web.1]: 2017-08-08 01:13:07.656  INFO 4 --- [           main] com.nem.swift.bc.main.Application        : No active profile set, falling back to default profiles: default
2017-08-08T01:13:07.821929+00:00 app[web.1]: 2017-08-08 01:13:07.821  INFO 4 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a1bec0: startup date [Tue Aug 08 01:13:07 UTC 2017]; root of context hierarchy
2017-08-08T01:13:10.509132+00:00 app[web.1]: 2017-08-08 01:13:10.508  INFO 4 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8013 (http)
2017-08-08T01:13:10.530905+00:00 app[web.1]: 2017-08-08 01:13:10.530  INFO 4 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-08-08T01:13:10.532394+00:00 app[web.1]: 2017-08-08 01:13:10.532  INFO 4 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-08-08T01:13:10.701693+00:00 app[web.1]: 2017-08-08 01:13:10.701  INFO 4 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/nemswiftsvc]   : Initializing Spring embedded WebApplicationContext
2017-08-08T01:13:10.701872+00:00 app[web.1]: 2017-08-08 01:13:10.701  INFO 4 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2884 ms
2017-08-08T01:13:11.059057+00:00 app[web.1]: 2017-08-08 01:13:11.058  INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-08-08T01:13:11.074497+00:00 app[web.1]: 2017-08-08 01:13:11.074  INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-08-08T01:13:11.084607+00:00 app[web.1]: 2017-08-08 01:13:11.084  INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-08-08T01:13:11.085008+00:00 app[web.1]: 2017-08-08 01:13:11.084  INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-08-08T01:13:11.085246+00:00 app[web.1]: 2017-08-08 01:13:11.085  INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-08-08T01:13:11.940954+00:00 app[web.1]: 2017-08-08 01:13:11.940  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a1bec0: startup date [Tue Aug 08 01:13:07 UTC 2017]; root of context hierarchy
2017-08-08T01:13:12.127417+00:00 app[web.1]: 2017-08-08 01:13:12.127  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.nem.swift.bc.service.HelloWorldService.ahoy()
2017-08-08T01:13:12.128759+00:00 app[web.1]: 2017-08-08 01:13:12.128  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/helloworld],methods=[GET]}" onto public java.lang.String com.nem.swift.bc.service.HelloWorldService.index()
2017-08-08T01:13:12.134591+00:00 app[web.1]: 2017-08-08 01:13:12.134  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/transaction/decode],methods=[POST],produces=[application/json]}" onto public com.nem.swift.bc.object.TransactionDecodeResponse com.nem.swift.bc.service.TransactionService.getDecodedMessage(com.nem.swift.bc.object.TransactionRequest)
2017-08-08T01:13:12.139337+00:00 app[web.1]: 2017-08-08 01:13:12.139  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/transaction/send],methods=[POST]}" onto public com.nem.swift.bc.object.TransactionResponse com.nem.swift.bc.service.TransactionService.sendTransaction(com.nem.swift.bc.object.TransactionRequest)
2017-08-08T01:13:12.146150+00:00 app[web.1]: 2017-08-08 01:13:12.144  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-08-08T01:13:12.146830+00:00 app[web.1]: 2017-08-08 01:13:12.146  INFO 4 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-08-08T01:13:12.253484+00:00 app[web.1]: 2017-08-08 01:13:12.253  INFO 4 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-08T01:13:12.254373+00:00 app[web.1]: 2017-08-08 01:13:12.253  INFO 4 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-08T01:13:12.326795+00:00 app[web.1]: 2017-08-08 01:13:12.326  INFO 4 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-08T01:13:12.667000+00:00 app[web.1]: 2017-08-08 01:13:12.666  INFO 4 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-08-08T01:13:12.790208+00:00 app[web.1]: 2017-08-08 01:13:12.789  INFO 4 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8013 (http)
2017-08-08T01:13:12.795047+00:00 app[web.1]: Let's inspect the beans provided by Spring Boot:
2017-08-08T01:13:12.795337+00:00 app[web.1]: application
2017-08-08T01:13:12.795396+00:00 app[web.1]: basicErrorController
2017-08-08T01:13:12.795637+00:00 app[web.1]: beanNameHandlerMapping
2017-08-08T01:13:12.795694+00:00 app[web.1]: beanNameViewResolver
2017-08-08T01:13:12.795742+00:00 app[web.1]: characterEncodingFilter
2017-08-08T01:13:12.795796+00:00 app[web.1]: commandLineRunner
2017-08-08T01:13:12.795851+00:00 app[web.1]: containerCustomizer
2017-08-08T01:13:12.795920+00:00 app[web.1]: conventionErrorViewResolver
2017-08-08T01:13:12.795971+00:00 app[web.1]: defaultServletHandlerMapping
2017-08-08T01:13:12.796021+00:00 app[web.1]: defaultValidator
2017-08-08T01:13:12.796094+00:00 app[web.1]: defaultViewResolver
2017-08-08T01:13:12.796130+00:00 app[web.1]: dispatcherServlet
2017-08-08T01:13:12.796185+00:00 app[web.1]: dispatcherServletRegistration
2017-08-08T01:13:12.796613+00:00 app[web.1]: duplicateServerPropertiesDetector
2017-08-08T01:13:12.796670+00:00 app[web.1]: embeddedServletContainerCustomizerBeanPostProcessor
2017-08-08T01:13:12.796721+00:00 app[web.1]: error
2017-08-08T01:13:12.796785+00:00 app[web.1]: errorAttributes
2017-08-08T01:13:12.796835+00:00 app[web.1]: errorPageCustomizer
2017-08-08T01:13:12.796888+00:00 app[web.1]: errorPageRegistrarBeanPostProcessor
2017-08-08T01:13:12.796956+00:00 app[web.1]: faviconHandlerMapping
2017-08-08T01:13:12.796987+00:00 app[web.1]: faviconRequestHandler
2017-08-08T01:13:12.797042+00:00 app[web.1]: handlerExceptionResolver
2017-08-08T01:13:12.797101+00:00 app[web.1]: helloWorldService
2017-08-08T01:13:12.797504+00:00 app[web.1]: hiddenHttpMethodFilter
2017-08-08T01:13:12.797663+00:00 app[web.1]: httpPutFormContentFilter
2017-08-08T01:13:12.797716+00:00 app[web.1]: httpRequestHandlerAdapter
2017-08-08T01:13:12.797769+00:00 app[web.1]: jacksonObjectMapper
2017-08-08T01:13:12.797835+00:00 app[web.1]: jacksonObjectMapperBuilder
2017-08-08T01:13:12.797867+00:00 app[web.1]: jsonComponentModule
2017-08-08T01:13:12.797935+00:00 app[web.1]: localeCharsetMappingsCustomizer
2017-08-08T01:13:12.797988+00:00 app[web.1]: mappingJackson2HttpMessageConverter
2017-08-08T01:13:12.798051+00:00 app[web.1]: mbeanExporter
2017-08-08T01:13:12.798094+00:00 app[web.1]: mbeanServer
2017-08-08T01:13:12.798145+00:00 app[web.1]: messageConverters
2017-08-08T01:13:12.798184+00:00 app[web.1]: methodValidationPostProcessor
2017-08-08T01:13:12.798236+00:00 app[web.1]: multipartConfigElement
2017-08-08T01:13:12.798290+00:00 app[web.1]: multipartResolver
2017-08-08T01:13:12.798359+00:00 app[web.1]: mvcContentNegotiationManager
2017-08-08T01:13:12.798389+00:00 app[web.1]: mvcConversionService
2017-08-08T01:13:12.798441+00:00 app[web.1]: mvcPathMatcher
2017-08-08T01:13:12.798499+00:00 app[web.1]: mvcResourceUrlProvider
2017-08-08T01:13:12.798537+00:00 app[web.1]: mvcUriComponentsContributor
2017-08-08T01:13:12.798956+00:00 app[web.1]: mvcUrlPathHelper
2017-08-08T01:13:12.798999+00:00 app[web.1]: mvcValidator
2017-08-08T01:13:12.799058+00:00 app[web.1]: mvcViewResolver
2017-08-08T01:13:12.799118+00:00 app[web.1]: objectNamingStrategy
2017-08-08T01:13:12.799547+00:00 app[web.1]: org.springframework.boot.autoconfigure.AutoConfigurationPackages
2017-08-08T01:13:12.808878+00:00 app[web.1]: org.springframework.boot.autoconfigure.condition.BeanTypeRegistry
2017-08-08T01:13:12.808950+00:00 app[web.1]: org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
2017-08-08T01:13:12.809036+00:00 app[web.1]: org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
2017-08-08T01:13:12.809096+00:00 app[web.1]: org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
2017-08-08T01:13:12.809172+00:00 app[web.1]: org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory
2017-08-08T01:13:12.809227+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
2017-08-08T01:13:12.809284+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration
2017-08-08T01:13:12.809444+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration
2017-08-08T01:13:12.809496+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration
2017-08-08T01:13:12.809547+00:00 app[web.1]: org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration
2017-08-08T01:13:12.809600+00:00 app[web.1]: org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration
2017-08-08T01:13:12.809688+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
2017-08-08T01:13:12.809763+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration
2017-08-08T01:13:12.809822+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration
2017-08-08T01:13:12.809878+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
2017-08-08T01:13:12.809936+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat
2017-08-08T01:13:12.809990+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration
2017-08-08T01:13:12.810044+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration
2017-08-08T01:13:12.810116+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration
2017-08-08T01:13:12.810166+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration
2017-08-08T01:13:12.810217+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
2017-08-08T01:13:12.810298+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration
2017-08-08T01:13:12.810371+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration
2017-08-08T01:13:12.810428+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration
2017-08-08T01:13:12.810484+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration
2017-08-08T01:13:12.810541+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
2017-08-08T01:13:12.810596+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration
2017-08-08T01:13:12.810651+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration$RestTemplateConfiguration
2017-08-08T01:13:12.810705+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
2017-08-08T01:13:12.810761+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration
2017-08-08T01:13:12.810817+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter
2017-08-08T01:13:12.810874+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$FaviconConfiguration
2017-08-08T01:13:12.810926+00:00 app[web.1]: org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration
2017-08-08T01:13:12.810975+00:00 app[web.1]: org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration
2017-08-08T01:13:12.811038+00:00 app[web.1]: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor
2017-08-08T01:13:12.811092+00:00 app[web.1]: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store
2017-08-08T01:13:12.811149+00:00 app[web.1]: org.springframework.context.annotation.internalAsyncAnnotationProcessor
2017-08-08T01:13:12.811208+00:00 app[web.1]: org.springframework.context.annotation.internalAutowiredAnnotationProcessor
2017-08-08T01:13:12.811262+00:00 app[web.1]: org.springframework.context.annotation.internalCommonAnnotationProcessor
2017-08-08T01:13:12.811316+00:00 app[web.1]: org.springframework.context.annotation.internalConfigurationAnnotationProcessor
2017-08-08T01:13:12.811373+00:00 app[web.1]: org.springframework.context.annotation.internalRequiredAnnotationProcessor
2017-08-08T01:13:12.811428+00:00 app[web.1]: org.springframework.context.event.internalEventListenerFactory
2017-08-08T01:13:12.811485+00:00 app[web.1]: org.springframework.context.event.internalEventListenerProcessor
2017-08-08T01:13:12.811539+00:00 app[web.1]: org.springframework.scheduling.annotation.ProxyAsyncConfiguration
2017-08-08T01:13:12.811595+00:00 app[web.1]: preserveErrorControllerTargetClassPostProcessor
2017-08-08T01:13:12.811649+00:00 app[web.1]: propertySourcesPlaceholderConfigurer
2017-08-08T01:13:12.811699+00:00 app[web.1]: requestContextFilter
2017-08-08T01:13:12.811745+00:00 app[web.1]: requestMappingHandlerAdapter
2017-08-08T01:13:12.811796+00:00 app[web.1]: requestMappingHandlerMapping
2017-08-08T01:13:12.811855+00:00 app[web.1]: resourceHandlerMapping
2017-08-08T01:13:12.811926+00:00 app[web.1]: restTemplateBuilder
2017-08-08T01:13:12.811975+00:00 app[web.1]: serverProperties
2017-08-08T01:13:12.812029+00:00 app[web.1]: simpleControllerHandlerAdapter
2017-08-08T01:13:12.812105+00:00 app[web.1]: spring.http.encoding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties
2017-08-08T01:13:12.812167+00:00 app[web.1]: spring.http.multipart-org.springframework.boot.autoconfigure.web.MultipartProperties
2017-08-08T01:13:12.812232+00:00 app[web.1]: spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties
2017-08-08T01:13:12.812288+00:00 app[web.1]: spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties
2017-08-08T01:13:12.812349+00:00 app[web.1]: spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties
2017-08-08T01:13:12.812403+00:00 app[web.1]: spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties
2017-08-08T01:13:12.812465+00:00 app[web.1]: standardJacksonObjectMapperBuilderCustomizer
2017-08-08T01:13:12.812512+00:00 app[web.1]: stringHttpMessageConverter
2017-08-08T01:13:12.812564+00:00 app[web.1]: tomcatEmbeddedServletContainerFactory
2017-08-08T01:13:12.812620+00:00 app[web.1]: transactionService
2017-08-08T01:13:12.812676+00:00 app[web.1]: viewControllerHandlerMapping
2017-08-08T01:13:12.812729+00:00 app[web.1]: viewResolver
2017-08-08T01:13:12.812778+00:00 app[web.1]: websocketContainerCustomizer
2017-08-08T01:13:12.812835+00:00 app[web.1]: welcomePageHandlerMapping
2017-08-08T01:13:12.815244+00:00 app[web.1]: 2017-08-08 01:13:12.815  INFO 4 --- [           main] com.nem.swift.bc.main.Application        : Started Application in 5.799 seconds (JVM running for 6.483)
2017-08-08T01:14:34.970454+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2017-08-08T01:14:34.970566+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-08-08T01:14:35.118469+00:00 heroku[web.1]: Process exited with status 137
2017-08-08T01:14:35.129172+00:00 heroku[web.1]: State changed from starting to crashed
2017-08-08T01:14:45.059295+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/nemswiftsvc/" host=swift-nem-bc.herokuapp.com request_id=af10beda-567b-429f-80a5-085c386a1f4c fwd="24.212.200.163" dyno= connect= service= status=503 bytes= protocol=https
2017-08-08T01:14:45.911470+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=swift-nem-bc.herokuapp.com request_id=7ca9c313-93ff-49fd-af77-4c629664ed98 fwd="24.212.200.163" dyno= connect= service= status=503 bytes= protocol=https

However, whenever I tried accessing the test endpoints, it crashes. It seems to crash whenever I tried accessing a basic GET endpoint.

Anyone experience this issue with Heroku?

TIA

Body:
The answer above works! Just a small addition(if statement) to have the app running locally say from an IDE like eclipse

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
    return (container -> {
        container.setContextPath("");
        if(System.getenv("PORT")!=null) {
            container.setPort(Integer.valueOf(System.getenv("PORT")));

        }
    });


问:
How to open SlidingUpPanel from Right,Left and Bottom
I am using SlidingUpPanel Library https://github.com/umano/AndroidSlidingUpPanel but it open the panel only from bottom and top,i want to use it from left and right side too.
i want the user to select on runtime that panel will open from which side?
any one help me please?
Thanks</p>

答: That library doesn't support it.  There's a reason why its called "UpPanel".  Look for another solution, like DrawerLayout, which is in the support library.</p>