问:
Fill array with placeholders Javascript [IE supported]
I have an array which I get from response of google Analytics.

My array looks like this:

```<code>var mobileYesterday = [
 {hour: "00", date: "20171208", pageviews: "1"},
 {hour: "06", date: "20171208", pageviews: "1"},
 {hour: "07", date: "20171208", pageviews: "5"},
 {hour: "08", date: "20171208", pageviews: "7"},
 {hour: "09", date: "20171208", pageviews: "4"}
];
</code>```

Since a day exists out of 24 hours I would like to be able fill the array with placeholders, which will contain the date of today, the hour which isn't specified in the previous array and pageviews = 0. The array should also be ordered by hour, so that the array will look like this:

```<code> var mobileYesterday = [
     {hour: "00", date: "20171208", pageviews: "1"},
     {hour: "01", date: "20171208", pageviews: "0"},
     {hour: "02", date: "20171208", pageviews: "0"},
     {hour: "03", date: "20171208", pageviews: "0"},
     {hour: "04", date: "20171208", pageviews: "0"},
     {hour: "05", date: "20171208", pageviews: "0"},
     {hour: "06", date: "20171208", pageviews: "1"},
     {hour: "07", date: "20171208", pageviews: "5"},
     {hour: "08", date: "20171208", pageviews: "7"},
     {hour: "09", date: "20171208", pageviews: "4"},
     {hour: "10", date: "20171208", pageviews: "0"},
     {hour: "11", date: "20171208", pageviews: "0"},
     {hour: "12", date: "20171208", pageviews: "0"},
     {hour: "13", date: "20171208", pageviews: "0"}
     etc..
];
</code>```

I've tried to loop through the array with a for loop

```<code>var array = [];
    var date = moment().format("YYYYMMDD");

    var hourPlaceholder;
    for(var i = 0; i < 24; i++){
        if(i < 10){
            hourPlaceholder = '0'+i;
        }
        if(i > 9){
            hourPlaceholder = i;
        }

       for (var k = 0; k < mobileYesterday.length; k++){
           if(!mobileYesterday[k].uur == hourPlaceholder){
              var array_record = [
                  { "hour": hourPlaceholder, "date": date, "pageviews":0}
              ]
               array.push(array_record);
           }else{
               array.push(mobileYesterday[k]);
           }
       }
    }
    console.log(JSON.stringify(array));
</code>```

But this just returns the most weirdest array ever:

```[[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"}]
```

答:
You could take a simplified approach for the formatted hour and omit moment, because you could take the date from the given array.

The take an index for the given array and just check against with hour.

function fillArray(data) {
    var array = [],
        hour,
        i, j = 0;

    for (i = 0; i < 24; i++) {
        hour = ('0' + i).slice(-2);
        array.push(data[j] && data[j].hour === hour
            ? data[j++]
            : { hour: hour, date: data[0].date, pageviews: 0 }
        );
    }
    return array;
}

var mobileYesterday = [{ hour: "00", date: "20171208", pageviews: "1" }, { hour: "06", date: "20171208", pageviews: "1" }, { hour: "07", date: "20171208", pageviews: "5" }, { hour: "08", date: "20171208", pageviews: "7" }, { hour: "09", date: "20171208", pageviews: "4" }];

console.log(fillArray(mobileYesterday));```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code>```

Body:
I have an array which I get from response of google Analytics.

My array looks like this:

var mobileYesterday = [
 {hour: "00", date: "20171208", pageviews: "1"},
 {hour: "06", date: "20171208", pageviews: "1"},
 {hour: "07", date: "20171208", pageviews: "5"},
 {hour: "08", date: "20171208", pageviews: "7"},
 {hour: "09", date: "20171208", pageviews: "4"}
];

Since a day exists out of 24 hours I would like to be able fill the array with placeholders, which will contain the date of today, the hour which isn't specified in the previous array and pageviews = 0. The array should also be ordered by hour, so that the array will look like this:

 var mobileYesterday = [
     {hour: "00", date: "20171208", pageviews: "1"},
     {hour: "01", date: "20171208", pageviews: "0"},
     {hour: "02", date: "20171208", pageviews: "0"},
     {hour: "03", date: "20171208", pageviews: "0"},
     {hour: "04", date: "20171208", pageviews: "0"},
     {hour: "05", date: "20171208", pageviews: "0"},
     {hour: "06", date: "20171208", pageviews: "1"},
     {hour: "07", date: "20171208", pageviews: "5"},
     {hour: "08", date: "20171208", pageviews: "7"},
     {hour: "09", date: "20171208", pageviews: "4"},
     {hour: "10", date: "20171208", pageviews: "0"},
     {hour: "11", date: "20171208", pageviews: "0"},
     {hour: "12", date: "20171208", pageviews: "0"},
     {hour: "13", date: "20171208", pageviews: "0"}
     etc..
];

I've tried to loop through the array with a for loop

var array = [];
    var date = moment().format("YYYYMMDD");

    var hourPlaceholder;
    for(var i = 0; i < 24; i++){
        if(i < 10){
            hourPlaceholder = '0'+i;
        }
        if(i > 9){
            hourPlaceholder = i;
        }

       for (var k = 0; k < mobileYesterday.length; k++){
           if(!mobileYesterday[k].uur == hourPlaceholder){
              var array_record = [
                  { "hour": hourPlaceholder, "date": date, "pageviews":0}
              ]
               array.push(array_record);
           }else{
               array.push(mobileYesterday[k]);
           }
       }
    }
    console.log(JSON.stringify(array));

But this just returns the most weirdest array ever:

[[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],[{"hour":"00","date":"20171207","pageviews":0}],{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"},{"hour":"01","date":"20171207","pageviews":"1"},{"hour":"07","date":"20171207","pageviews":"5"},{"hour":"08","date":"20171207","pageviews":"7"},{"hour":"09","date":"20171207","pageviews":"8"},{"hour":"10","date":"20171207","pageviews":"8"},{"hour":"11","date":"20171207","pageviews":"9"},{"hour":"12","date":"20171207","pageviews":"9"},{"hour":"13","date":"20171207","pageviews":"6"},{"hour":"14","date":"20171207","pageviews":"5"},{"hour":"15","date":"20171207","pageviews":"6"},{"hour":"16","date":"20171207","pageviews":"7"},{"hour":"17","date":"20171207","pageviews":"7"},{"hour":"18","date":"20171207","pageviews":"4"},{"hour":"19","date":"20171207","pageviews":"7"},{"hour":"20","date":"20171207","pageviews":"5"},{"hour":"21","date":"20171207","pageviews":"8"},{"hour":"22","date":"20171207","pageviews":"5"},{"hour":"23","date":"20171207","pageviews":"3"}]

Body:
You could take a simplified approach for the formatted hour and omit moment, because you could take the date from the given array.

The take an index for the given array and just check against with hour.

function fillArray(data) {
    var array = [],
        hour,
        i, j = 0;

    for (i = 0; i < 24; i++) {
        hour = ('0' + i).slice(-2);
        array.push(data[j] && data[j].hour === hour
            ? data[j++]
            : { hour: hour, date: data[0].date, pageviews: 0 }
        );
    }
    return array;
}

var mobileYesterday = [{ hour: "00", date: "20171208", pageviews: "1" }, { hour: "06", date: "20171208", pageviews: "1" }, { hour: "07", date: "20171208", pageviews: "5" }, { hour: "08", date: "20171208", pageviews: "7" }, { hour: "09", date: "20171208", pageviews: "4" }];

console.log(fillArray(mobileYesterday));

.as-console-wrapper { max-height: 100% !important; top: 0; }


来源: stackexchange

问:
Counting words in string
I was trying to count words in a text in this way:

```<code>function WordCount(str) {
  var totalSoFar = 0;
  for (var i = 0; i < WordCount.length; i++)
    if (str(i) === " ") { // if a space is found in str
      totalSoFar = +1; // add 1 to total so far
  }
  totalsoFar += 1; // add 1 to totalsoFar to account for extra space since 1 space = 2 words
}

console.log(WordCount("Random String"));
</code>```

I think I have got this down pretty well, except I think that the if statement is wrong. The part that checks if str(i) contains a space and adds 1.

Edit:

I found out (thanks to Blender) that I can do this with a lot less code:

```<code>function WordCount(str) {
  return str.split(" ").length;
}

console.log(WordCount("hello world"));
</code>```

答:
```<code>let leng = yourString.split(' ').filter(a => a.trim().length > 0).length
</code>```

ContentLicense: CC BY-SA 4.0

Title: Counting words in string

Body:
I was trying to count words in a text in this way:

function WordCount(str) {
  var totalSoFar = 0;
  for (var i = 0; i < WordCount.length; i++)
    if (str(i) === " ") { // if a space is found in str
      totalSoFar = +1; // add 1 to total so far
  }
  totalsoFar += 1; // add 1 to totalsoFar to account for extra space since 1 space = 2 words
}

console.log(WordCount("Random String"));

I think I have got this down pretty well, except I think that the if statement is wrong. The part that checks if str(i) contains a space and adds 1.

Edit:

I found out (thanks to Blender) that I can do this with a lot less code:

function WordCount(str) {
  return str.split(" ").length;
}

console.log(WordCount("hello world"));

ContentLicense: CC BY-SA 3.0


问:
Error building ios with cordova
I have a problem when I build the ios platform with cordova. I have all the certificates for the app and device, but when I try to run in my ios device, doing ionic run ios, the console return this error:

```<code>Error: Source path does not exist: resources/ios/icon/icon-40@3x.png
</code>```

This path is written in config.xml file.

I tried to run it in xCode but the problem there was:

```<code>Cordova/CDVViewController.h not found
</code>```

I read a lot of possible solutions but any works for me.

My xCode version is 7.3.1, the cordova version is 6.3.0 and the cordova ios version is 4.2.0.

答:
I got similar issue with cordova-ios@~4.5.1

ionic cordova build ios

```<code>> cordova build ios
Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png

[ERROR] An error occurred while running cordova build ios (exit code 1).
</code>```

ionic cordova platform add ios

```<code>> cordova platform add ios --save
Using cordova-fetch for cordova-ios@~4.5.1

Adding ios project...

Creating Cordova project for the iOS platform:

Path: platforms/ios
Package: -
Name: -
iOS project created with cordova-ios@4.5.4

Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png
</code>```

I remove ios platform

```<code>ionic cordova platform remove ios
</code>```

And add ios platform with old one

```<code>ionic cordova platform add ios@4.0.0
</code>```

This worked for me, waiting for an Cordova update :)

Title: Error building ios with cordova

Body:
I have a problem when I build the ios platform with cordova. I have all the certificates for the app and device, but when I try to run in my ios device, doing ionic run ios, the console return this error:

Error: Source path does not exist: resources/ios/icon/icon-40@3x.png

This path is written in config.xml file.

I tried to run it in xCode but the problem there was:

Cordova/CDVViewController.h not found

I read a lot of possible solutions but any works for me.

My xCode version is 7.3.1, the cordova version is 6.3.0 and the cordova ios version is 4.2.0.

Body:
I got similar issue with cordova-ios@~4.5.1

ionic cordova build ios

> cordova build ios
Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png

[ERROR] An error occurred while running cordova build ios (exit code 1).

ionic cordova platform add ios

> cordova platform add ios --save
Using cordova-fetch for cordova-ios@~4.5.1

Adding ios project...

Creating Cordova project for the iOS platform:

Path: platforms/ios
Package: -
Name: -
iOS project created with cordova-ios@4.5.4

Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png

I remove ios platform

ionic cordova platform remove ios

And add ios platform with old one

ionic cordova platform add ios@4.0.0

This worked for me, waiting for an Cordova update :)


问:
Efficient way to process lines of file
Im trying to learn some go and I am trying to make a script that reads from a csv file, do some process and take some results.

I am following a pipeline pattern so that a goroutine reads from file per line with scanner, lines are sent to channel and different goroutines consume the channel content.

An example of what I am trying to do:
https://gist.github.com/pkulak/93336af9bb9c7207d592

My problem is: In csv file there are lots of records. I want to do some math between consequent lines. Lets say record1 is r1 record2 is r2 and so on.

When I read file I have r1. In the next scanner loop I have r2. I want to see if r1-r2 is a valid number for me. If yes do some math between them. Then check r3 r4 the same way. If r1-r2 is not valid, don't care about r2 and do r1-r3 and so on.

Should I handle this when reading the file, after I put lines of file in channel and handle channel content?

Any suggestion that does not break concurrency?

答:
I think you should determine "is r1-r2 valid numbers for you" inside Read the lines into the work queue function.

So, you should read current line, and read next lines one by one while you don't have valid numbers pair. When you got it -- you will send this pair inside workQueue channel and search for the next pair.

This is your code with changes:

```<code>package main

import (
    "bufio"
    "log"
    "os"
    "errors"
)

var concurrency = 100

type Pair struct {
    line1 string
    line2 string
}

func main() {

    // It will be better to receive file-path from somewhere (like args or something like this)
    filePath := "/path/to/file.csv"

    // This channel has no buffer, so it only accepts input when something is ready
    // to take it out. This keeps the reading from getting ahead of the writers.
    workQueue := make(chan Pair)

    // We need to know when everyone is done so we can exit.
    complete := make(chan bool)

    // Read the lines into the work queue.
    go func() {

        file, e := os.Open(filePath)
        if e != nil {
            log.Fatal(e)
        }
        // Close when the function returns
        defer file.Close()

        scanner := bufio.NewScanner(file)

        // Get pairs and send them into "workQueue" channel
        for {
            line1, e := getNextCorrectLine(scanner)
            if e != nil {
                break
            }
            line2, e := getNextCorrectLine(scanner)
            if e != nil {
                break
            }
            workQueue <- Pair{line1, line2}
        }

        // Close the channel so everyone reading from it knows we're done.
        close(workQueue)
    }()

    // Now read them all off, concurrently.
    for i := 0; i < concurrency; i++ {
        go startWorking(workQueue, complete)
    }

    // Wait for everyone to finish.
    for i := 0; i < concurrency; i++ {
        <-complete
    }
}

func getNextCorrectLine(scanner *bufio.Scanner) (string, error) {
    var line string
    for scanner.Scan() {
        line = scanner.Text()
        if isCorrect(line) {
            return line, nil
        }
    }
    return "", errors.New("no more lines")
}

func isCorrect(str string) bool {
    // Make your validation here
    return true
}

func startWorking(pairs <-chan Pair, complete chan<- bool) {
    for pair := range pairs {
        doTheWork(pair)
    }

    // Let the main process know we're done.
    complete <- true
}

func doTheWork(pair Pair) {
    // Do the work with the pair
}
</code>```

Title: Efficient way to process lines of file

Body:
I think you should determine "is r1-r2 valid numbers for you" inside Read the lines into the work queue function.

So, you should read current line, and read next lines one by one while you don't have valid numbers pair. When you got it -- you will send this pair inside workQueue channel and search for the next pair.

This is your code with changes:

package main

import (
    "bufio"
    "log"
    "os"
    "errors"
)

var concurrency = 100

type Pair struct {
    line1 string
    line2 string
}

func main() {

    // It will be better to receive file-path from somewhere (like args or something like this)
    filePath := "/path/to/file.csv"

    // This channel has no buffer, so it only accepts input when something is ready
    // to take it out. This keeps the reading from getting ahead of the writers.
    workQueue := make(chan Pair)

    // We need to know when everyone is done so we can exit.
    complete := make(chan bool)

    // Read the lines into the work queue.
    go func() {

        file, e := os.Open(filePath)
        if e != nil {
            log.Fatal(e)
        }
        // Close when the function returns
        defer file.Close()

        scanner := bufio.NewScanner(file)

        // Get pairs and send them into "workQueue" channel
        for {
            line1, e := getNextCorrectLine(scanner)
            if e != nil {
                break
            }
            line2, e := getNextCorrectLine(scanner)
            if e != nil {
                break
            }
            workQueue <- Pair{line1, line2}
        }

        // Close the channel so everyone reading from it knows we're done.
        close(workQueue)
    }()

    // Now read them all off, concurrently.
    for i := 0; i < concurrency; i++ {
        go startWorking(workQueue, complete)
    }

    // Wait for everyone to finish.
    for i := 0; i < concurrency; i++ {
        <-complete
    }
}

func getNextCorrectLine(scanner *bufio.Scanner) (string, error) {
    var line string
    for scanner.Scan() {
        line = scanner.Text()
        if isCorrect(line) {
            return line, nil
        }
    }
    return "", errors.New("no more lines")
}

func isCorrect(str string) bool {
    // Make your validation here
    return true
}

func startWorking(pairs <-chan Pair, complete chan<- bool) {
    for pair := range pairs {
        doTheWork(pair)
    }

    // Let the main process know we're done.
    complete <- true
}

func doTheWork(pair Pair) {
    // Do the work with the pair
}


问:
express js not serving the static css files from router
I am actually facing this problem in another bigger project but, I have made a simple one so as to explain it easily

Tree Structure of my project is as follows

```<code>demo
|____admin
|         |____admin.js
|____node_modules
|
|____static
|         |____bootstrap.min.css
|         |____headerStyle.min.css
|
|____views
|    |____admin
|    |    |____admin_home.ejs
|    |
|    |____partials
|                 |____admin_header.ejs
|
|____index.js
|____package-lock.json
|____package.json
</code>```

please bear with me, I am going to post the code of some of important files

code in 'index.js' is this

```<code>let express = require('express');
let app = express();
let path = require('path');

app.use(express.static(path.join(__dirname, 'static')));
app.set('view engine', 'ejs');
app.get('/',function(req,res)
{
  res.render('./admin/admin_home');
});

let admin = require('./admin/admin.js');
app.use('/admin',admin);

app.listen(9000,function(){
  console.log('listening to port : 9000');
});
</code>```

Code in 'admin/admin.js' is this

```<code>let express = require('express');
let router = express.Router();

router.get('/',function(req,res)
{
  res.render('./admin/admin_home');
});

router.get('/adminhome',function(req,res)
{
  res.render('./admin/admin_home');
});

module.exports = router;
</code>```

Code in 'views/admin/admin.ejs' is this

```<code><%- include('../partials/admin_header.ejs')  %>

<h1>Admin Home</h1>
</code>```

I am having problem with express js static file serving.

For the following URL's the webpages are rendered with all the styles from css files

```<code>http://localhost:9000
http://localhost:9000/admin
</code>```

they are served from these paths

```<code>http://localhost:9000/bootstrap.min.css
</code>```

and

```<code>http://localhost:9000/headerStyle.css
</code>```

but for the following URL webpages are rendered with plain html with out serving the css syles

```<code>http://localhost:9000/admin/adminhome
</code>```

the error is

```<code>Failed to load the resources: the server responded with 404
</code>```

css files are served from these paths

```<code>http://localhost:9000/admin/bootstrap.min.css
</code>```

and

```<code>http://localhost:9000/admin/headerStyle.css
</code>```

and the 'Link' tags in 'vies/partials/admin_header.ejs' are as follows

```<code><link rel="stylesheet" type="text/css" href="bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="headerStyle.css">
</code>```

versions of the modules are as follows

```<code>ejs:^2.5.7
express:^4.16.2
path:^0.12.7
</code>```

my nodejs version is
    v8.5.0

Please help me in finding the solution for this problem. Thank You

答:
You should add a line to index.js</p>

```<code>app.set('views', path.join(__dirname, 'views'));
</code>```

Body:
I am actually facing this problem in another bigger project but, I have made a simple one so as to explain it easily

Tree Structure of my project is as follows

demo
|____admin
|         |____admin.js
|____node_modules
|
|____static
|         |____bootstrap.min.css
|         |____headerStyle.min.css
|
|____views
|    |____admin
|    |    |____admin_home.ejs
|    |
|    |____partials
|                 |____admin_header.ejs
|
|____index.js
|____package-lock.json
|____package.json

please bear with me, I am going to post the code of some of important files

code in 'index.js' is this

let express = require('express');
let app = express();
let path = require('path');

app.use(express.static(path.join(__dirname, 'static')));
app.set('view engine', 'ejs');
app.get('/',function(req,res)
{
  res.render('./admin/admin_home');
});

let admin = require('./admin/admin.js');
app.use('/admin',admin);

app.listen(9000,function(){
  console.log('listening to port : 9000');
});

Code in 'admin/admin.js' is this

let express = require('express');
let router = express.Router();

router.get('/',function(req,res)
{
  res.render('./admin/admin_home');
});

router.get('/adminhome',function(req,res)
{
  res.render('./admin/admin_home');
});

module.exports = router;

Code in 'views/admin/admin.ejs' is this

<%- include('../partials/admin_header.ejs')  %>

Admin Home

I am having problem with express js static file serving.

For the following URL's the webpages are rendered with all the styles from css files

http://localhost:9000
http://localhost:9000/admin

they are served from these paths

http://localhost:9000/bootstrap.min.css

and

http://localhost:9000/headerStyle.css

but for the following URL webpages are rendered with plain html with out serving the css syles

http://localhost:9000/admin/adminhome

the error is

Failed to load the resources: the server responded with 404

css files are served from these paths

http://localhost:9000/admin/bootstrap.min.css

and

http://localhost:9000/admin/headerStyle.css

and the 'Link' tags in 'vies/partials/admin_header.ejs' are as follows

<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="headerStyle.css">

versions of the modules are as follows

ejs:^2.5.7
express:^4.16.2
path:^0.12.7

my nodejs version is
    v8.5.0

Please help me in finding the solution for this problem. Thank You

Body:
You should add a line to index.js

app.set('views', path.join(__dirname, 'views'));


问:
iPhone location button
Ya know the little location button in the lower-left corner of the Maps application?  Does anybody know where I can find that?  I looked in UIButtonType and UITabBarSystemItem but came up blank.

I'd prefer to use a system image or a system something-or-other, to help ensure consistency with other system functions.

答:
Have a look at https://github.com/myell0w/MTLocation

I mimiced Google Maps' Locate Me - Button, including 4 different states and the animation that is done when switching between states.

ContentLicense: CC BY-SA 2.5

Title: iPhone location button


问:
Kotlin – String formatting
Kotlin has an excellent feature called string templates.

```<code>val i = 10
val s = "i = $i" // evaluates to "i = 10"
</code>```

But is it possible to have any formatting in the templates? For example, I would like to format Double in string templates in kotlin, at least to set a number of digits after a decimal separator:

```<code>val pi = 3.14159265358979323
val s = "pi = $pi??" // How to make it "pi = 3.14"?
</code>```

答:
Since String.format is only an extension function (see here) which internally calls java.lang.String.format you could write your own extension function using Java's DecimalFormat if you need more flexibility:

```<code>fun Double.format(fracDigits: Int): String {
    val df = DecimalFormat()
    df.setMaximumFractionDigits(fracDigits)
    return df.format(this)
}

println(3.14159.format(2)) // 3.14
</code>```

Title: Kotlin – String formatting

Body:
Kotlin has an excellent feature called string templates.

val i = 10
val s = "i = $i" // evaluates to "i = 10"

But is it possible to have any formatting in the templates? For example, I would like to format Double in string templates in kotlin, at least to set a number of digits after a decimal separator:

val pi = 3.14159265358979323
val s = "pi = $pi??" // How to make it "pi = 3.14"?

Body:
Since String.format is only an extension function (see here) which internally calls java.lang.String.format you could write your own extension function using Java's DecimalFormat if you need more flexibility:

fun Double.format(fracDigits: Int): String {
    val df = DecimalFormat()
    df.setMaximumFractionDigits(fracDigits)
    return df.format(this)
}

println(3.14159.format(2)) // 3.14


问:
android studio gradle sync failed input string "<!"
when I open a project in android studio I have an error:

Gradle sync failed. input string "<!".

I tried to clean and rebuild a thousand times but it doesn't help me.

Can you help me fix this?

error

and this is my build.gradle content:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.ali.test"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.android.gms:play-services-maps:11.0.1'
    implementation 'com.google.android.gms:play-services-location:11.0.1'
}
</code>```

and this is my MainActivity file content:

```<code>package com.example.ali.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
</code>```

these are the default contents and I didn't change any of them at all.

答:
Please Remove the "!" from where you written checkprobably it's hold into your build.gradle file.

your question is simpler to This

You share nothing your code so right now i'll give a link and suggest you to Remove"!"

Hope this helps you.

Body:
when I open a project in android studio I have an error:

Gradle sync failed. input string "<!".

I tried to clean and rebuild a thousand times but it doesn't help me.

Can you help me fix this?

error

and this is my build.gradle content:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.ali.test"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.android.gms:play-services-maps:11.0.1'
    implementation 'com.google.android.gms:play-services-location:11.0.1'
}

and this is my MainActivity file content:

package com.example.ali.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

these are the default contents and I didn't change any of them at all.


问:
Fixed panel at the bottom of the screen

Hi I'm trying to have two floating buttons at the bottom of the screen. Right now I implement the following code:

```<code><ScrollViewer>
<RelativePanel>
// Main Content here
<StackPanel RelativePanel.AlignBottomWithPanel="True" >Two buttons appears at the bottom of the PAGE (not screen)</StackPanel>
</RelativePanel>
</ScrollViewer>
</code>```

As you may expect the buttons appear at the bottom of the page. I want the buttons to appear at the bottom of the screen.

Is there any kind of panels in XAML which I can use to implement:

```<code>====================
  Scrollable area

=====================
Button1       Button2
----------------------
</code>```

a scrollable content area

and a panel below the scrollable area which sticks to the bottom of the screen and won't fly on top of it.

答:
You can try this,

```<code>        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>

        <ScrollViewer Grid.Row="0">

        </ScrollViewer>

        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <Button/>
            <Button/>
        </StackPanel>   </Grid>
</code>```

Hope this helps you. Please mark it as answer if it helped you.

Title: Fixed panel at the bottom of the screen

Body:
Hi I'm trying to have two floating buttons at the bottom of the screen. Right now I implement the following code:

<ScrollViewer>
<RelativePanel>
// Main Content here
<StackPanel RelativePanel.AlignBottomWithPanel="True" >Two buttons appears at the bottom of the PAGE (not screen)</StackPanel>
</RelativePanel>
</ScrollViewer>

As you may expect the buttons appear at the bottom of the page. I want the buttons to appear at the bottom of the screen.

Is there any kind of panels in XAML which I can use to implement:

====================
  Scrollable area

=====================
Button1       Button2
----------------------

a scrollable content area

and a panel below the scrollable area which sticks to the bottom of the screen and won't fly on top of it.

Body:
You can try this,

        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>

        <ScrollViewer Grid.Row="0">

        </ScrollViewer>

        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <Button/>
            <Button/>
        </StackPanel>   </Grid>

Hope this helps you. Please mark it as answer if it helped you.


问:
Experience with the new Jackal PHP framework?
Do you guys have any experience with the new PHP framework Jackal?

http://www.jackalphp.com

It is fresh, just-released and I was wondering if it is a good one. Can it be a substitute of frameworks like Kohana, Symphony or Zend? Well Zend has too many pre-biuld modules and functionality. Maybe a comparison with Kohana is better.

I am asking cause I am looking for a framework to use in my future projects.

Thanks

答:
We probably released the framework a little prematurely, but we are very serious, and this is not a hobby project. We have been using it in commercial application development for over a year now.

You do raise some excellent points about things we are missing. We are currently using Assembla as a repository, but we will soon be moving to something else so that we can make it public.

Unit testing and licensing information are also on the way.

If those are the only things you are concerned about, that's great news =). Our biggest goal was to build a framework that leverages the advantages of a procedural language like PHP, speeds up development, and just makes sense. We have used a lot of frameworks before, and while they all have their strengths... none of them are what we, as developers, need in a framework. While that is a very subjective statement, I believe Jackal makes some serious improvements on other frameworks that developers will come to love.

In short, we really appreciate you taking the time to give Jackal a chance, and hope you will continue to follow our progress as we add more "professionalization" to our framework. =)

Best Regards,
Jackal Team


问:
Passing Data Array from Controller to View Codeigniter
I'm trying to simplify my menu, that i will pass into my view, the problem is menu and submenu is not active. This is my controller:

```<code>parent::__construct();
    $this->menu = array(
      'menu'    => 'definition',
      'submenu' => 'workplace'
    );
</code>```

And i have this in my controller method:

```<code>$data = array(
    $this->menu, // menu is right here
    'list_workplace_type' => get_wp_type()->result_array()
  );
var_dump($data);die;
$this->load->view('wp', $data);
</code>```

And the result is like below:

```<code>array (size=2)
  0 =>
    array (size=2)
      'menu' => 'definition'
      'submenu' => 'workplace'
  'list_workplace_type' =>
    array (size=2)
      0 =>
        array (size=1)
          'szWorkplaceTypeName' => 'Kantor Pusat'
      1 =>
        array (size=1)
          'szWorkplaceTypeName' => 'Kantor Cabang'
</code>```

What I expected is more like this:

```<code>array (size=2)
  'menu' => 'definition'
  'submenu' => 'workplace'
  'list_workplace_type' =>
    array (size=2)
      0 =>
        array (size=1)
          'workplaceTypeName' => 'Kantor Pusat'
      1 =>
        array (size=1)
          'workplaceTypeName' => 'Kantor Cabang'
</code>```

I used array_push() but still doesn't work properly.

答:
What I understand is that you're trying to add 'list_workplace_type' as another key in the Menu array so you need to change this

```<code>$data = array(
    $this->menu, // menu is right here
    'list_workplace_type' => get_wp_type()->result_array()
  );
</code>```

to

```<code>$data = $this->menu['list_workplace_type'] = get_wp_type()->result_array();
</code>```

and then you can pass to view

```<code>$this->load->view('wp', $data);
</code>```

Body:
I'm trying to simplify my menu, that i will pass into my view, the problem is menu and submenu is not active. This is my controller:

parent::__construct();
    $this->menu = array(
      'menu'    => 'definition',
      'submenu' => 'workplace'
    );

And i have this in my controller method:

$data = array(
    $this->menu, // menu is right here
    'list_workplace_type' => get_wp_type()->result_array()
  );
var_dump($data);die;
$this->load->view('wp', $data);

And the result is like below:

array (size=2)
  0 =>
    array (size=2)
      'menu' => 'definition'
      'submenu' => 'workplace'
  'list_workplace_type' =>
    array (size=2)
      0 =>
        array (size=1)
          'szWorkplaceTypeName' => 'Kantor Pusat'
      1 =>
        array (size=1)
          'szWorkplaceTypeName' => 'Kantor Cabang'

What I expected is more like this:

array (size=2)
  'menu' => 'definition'
  'submenu' => 'workplace'
  'list_workplace_type' =>
    array (size=2)
      0 =>
        array (size=1)
          'workplaceTypeName' => 'Kantor Pusat'
      1 =>
        array (size=1)
          'workplaceTypeName' => 'Kantor Cabang'

I used array_push() but still doesn't work properly.

Body:
What I understand is that you're trying to add 'list_workplace_type' as another key in the Menu array so you need to change this

$data = array(
    $this->menu, // menu is right here
    'list_workplace_type' => get_wp_type()->result_array()
  );

to

$data = $this->menu['list_workplace_type'] = get_wp_type()->result_array();

and then you can pass to view

$this->load->view('wp', $data);


问:
React Native expo create iOS app without mac?
Can I develop for IO using React Native? I don't have mac or money to buy it. I have listen about expo.io which do it on there servers.</p>

答:
React and Expo allow you to write your application in javascript. Thus, you will be able to develop your app that will eventually work on an ios device.

However, to test the app locally before you publish it you have two options:
1. Use a mac to spin up ios simulators.
2. Directly scan the barcode from the expo app to test your app on an actual IOS device.


问:
JQuery background image slider using images from one of three arrays

Scenario:

I have a background-image slider.

JQuery listens for resizing of the window, and depending on the screen size, sets a given array as the source of the image file paths.

There is a 6 second delay between transitions and it all seems to work fine except I cannot get an image to appear for the first 6 seconds.

Any efforts so far have resulted in the first image displaying twice, instead of a sequential cycling through of the array.

jsfiddle demo

```<code>$(function(){

var img_41 = "url('https://s33.postimg.org/e11jeeisv/lagoon-467.jpg')",
img_42 = "url('https://s33.postimg.org/68avmepof/christmas-467.jpg')",
img_43 = "url('https://s33.postimg.org/cyrcvu54f/cars-467.jpg')",
img_1 = "url('https://s33.postimg.org/vr37zgr8v/lagoon-720.jpg')",
img_2 = "url('https://s33.postimg.org/mw2doxfb3/christmas-720.jpg)",
img_3  = "url('https://s33.postimg.org/f3bpwyorj/cars-720.jpg')",
img_91 = "url('https://s33.postimg.org/qsfpkxv5r/lagoon-991.jpg')",
img_92 = "url('https://s33.postimg.org/5is3a2rpr/christmas-991.jpg')",
img_93 = "url('https://s33.postimg.org/a4o7ieidr/cars-991.jpg')",
slider1 =[img_1, img_2, img_3],
slider2 =[img_41, img_42, img_43],
slider3 =[img_91, img_92, img_93],
i =0;

var $target = $('.wrapper');
var $win=$(window);
var arr;

$win.on('resize', function() {
    var screen= $win.width();
    if(screen < 468){
        arr = slider2;
    }
    else if(screen > 991){
        arr = slider3;
    }
    else{
        arr = slider1;
    }

    $target.css({
        'background-repeat':'no-repeat',
        'background-position': 'center center',
        'display':'block'
    });
}).resize();

setInterval(function() {
    $target.animate({ opacity: 0 }, 500, function() {
        console.log(arr[i]);
        $target.css('background-image', arr[i]);
        i++;
        $target.animate({ opacity: 1 }, 500, function() {
            if(i === arr.length) i = 0;
        });
    });
   }, 6000);
});
</code>```

答:
as I checked you called your image function after 6 seconds. you need to call that animation once before 6 seconds. so it will display first. no waiting till 6 seconds.

Please check this link

CHECK THIS

HTML

```<code><div class="wrapper"></div>
</code>```

CSS

```<code>.wrapper{height:500px}
</code>```

jQuery

$(function(){

```<code>var img_41 = "url('https://s33.postimg.org/e11jeeisv/lagoon-467.jpg')",
img_42 = "url('https://s33.postimg.org/68avmepof/christmas-467.jpg')",
img_43 = "url('https://s33.postimg.org/cyrcvu54f/cars-467.jpg')",
img_1 = "url('https://s33.postimg.org/vr37zgr8v/lagoon-720.jpg')",
img_2 = "url('https://s33.postimg.org/mw2doxfb3/christmas-720.jpg)",
img_3  = "url('https://s33.postimg.org/f3bpwyorj/cars-720.jpg')",
img_91 = "url('https://s33.postimg.org/qsfpkxv5r/lagoon-991.jpg')",
img_92 = "url('https://s33.postimg.org/5is3a2rpr/christmas-991.jpg')",
img_93 = "url('https://s33.postimg.org/a4o7ieidr/cars-991.jpg')",
slider1 =[img_1, img_2, img_3],
slider2 =[img_41, img_42, img_43],
slider3 =[img_91, img_92, img_93],
i =0;

var $target = $('.wrapper');
var $win=$(window);
var arr;

$win.on('resize', function() {

        var screen= $win.width();
        if(screen < 468){
            arr = slider2;
        }
        else if(screen > 991){
            arr = slider3;
        }
        else{
            arr = slider1;
        }
        $target.css({
            'background-repeat':'no-repeat',
            'background-position': 'center center',
            'display':'block'
        });
        }).resize();

    rotateImages($target,arr,i)
    setInterval(function() {
    rotateImages($target,arr,i)
  }, 6000);
});

function rotateImages($target,arr,i) {
    $target.animate({ opacity: 0 }, 500, function() {
     $target.css('background-image', arr[i]);
     i++;
     $target.animate({ opacity: 1 }, 500, function() {
       if(i === arr.length) i = 0;
     });
   });
}
</code>```

Hope this will helps you :)

Body:
Scenario:

I have a background-image slider.

JQuery listens for resizing of the window, and depending on the screen size, sets a given array as the source of the image file paths.

There is a 6 second delay between transitions and it all seems to work fine except I cannot get an image to appear for the first 6 seconds.

Any efforts so far have resulted in the first image displaying twice, instead of a sequential cycling through of the array.

jsfiddle demo

$(function(){

var img_41 = "url('https://s33.postimg.org/e11jeeisv/lagoon-467.jpg')",
img_42 = "url('https://s33.postimg.org/68avmepof/christmas-467.jpg')",
img_43 = "url('https://s33.postimg.org/cyrcvu54f/cars-467.jpg')",
img_1 = "url('https://s33.postimg.org/vr37zgr8v/lagoon-720.jpg')",
img_2 = "url('https://s33.postimg.org/mw2doxfb3/christmas-720.jpg)",
img_3  = "url('https://s33.postimg.org/f3bpwyorj/cars-720.jpg')",
img_91 = "url('https://s33.postimg.org/qsfpkxv5r/lagoon-991.jpg')",
img_92 = "url('https://s33.postimg.org/5is3a2rpr/christmas-991.jpg')",
img_93 = "url('https://s33.postimg.org/a4o7ieidr/cars-991.jpg')",
slider1 =[img_1, img_2, img_3],
slider2 =[img_41, img_42, img_43],
slider3 =[img_91, img_92, img_93],
i =0;

var $target = $('.wrapper');
var $win=$(window);
var arr;

$win.on('resize', function() {
    var screen= $win.width();
    if(screen < 468){
        arr = slider2;
    }
    else if(screen > 991){
        arr = slider3;
    }
    else{
        arr = slider1;
    }

    $target.css({
        'background-repeat':'no-repeat',
        'background-position': 'center center',
        'display':'block'
    });
}).resize();

setInterval(function() {
    $target.animate({ opacity: 0 }, 500, function() {
        console.log(arr[i]);
        $target.css('background-image', arr[i]);
        i++;
        $target.animate({ opacity: 1 }, 500, function() {
            if(i === arr.length) i = 0;
        });
    });
   }, 6000);
});

Body:
as I checked you called your image function after 6 seconds. you need to call that animation once before 6 seconds. so it will display first. no waiting till 6 seconds.

Please check this link

CHECK THIS

HTML

<div class="wrapper"></div>

CSS

.wrapper{height:500px}

jQuery

$(function(){

var img_41 = "url('https://s33.postimg.org/e11jeeisv/lagoon-467.jpg')",
img_42 = "url('https://s33.postimg.org/68avmepof/christmas-467.jpg')",
img_43 = "url('https://s33.postimg.org/cyrcvu54f/cars-467.jpg')",
img_1 = "url('https://s33.postimg.org/vr37zgr8v/lagoon-720.jpg')",
img_2 = "url('https://s33.postimg.org/mw2doxfb3/christmas-720.jpg)",
img_3  = "url('https://s33.postimg.org/f3bpwyorj/cars-720.jpg')",
img_91 = "url('https://s33.postimg.org/qsfpkxv5r/lagoon-991.jpg')",
img_92 = "url('https://s33.postimg.org/5is3a2rpr/christmas-991.jpg')",
img_93 = "url('https://s33.postimg.org/a4o7ieidr/cars-991.jpg')",
slider1 =[img_1, img_2, img_3],
slider2 =[img_41, img_42, img_43],
slider3 =[img_91, img_92, img_93],
i =0;

var $target = $('.wrapper');
var $win=$(window);
var arr;

$win.on('resize', function() {

        var screen= $win.width();
        if(screen < 468){
            arr = slider2;
        }
        else if(screen > 991){
            arr = slider3;
        }
        else{
            arr = slider1;
        }
        $target.css({
            'background-repeat':'no-repeat',
            'background-position': 'center center',
            'display':'block'
        });
        }).resize();

    rotateImages($target,arr,i)
    setInterval(function() {
    rotateImages($target,arr,i)
  }, 6000);
});

function rotateImages($target,arr,i) {
    $target.animate({ opacity: 0 }, 500, function() {
     $target.css('background-image', arr[i]);
     i++;
     $target.animate({ opacity: 1 }, 500, function() {
       if(i === arr.length) i = 0;
     });
   });
}

Hope this will helps you :)


问:
common logic in multiple actions in Web API controllers
There is a similar question already asked by someone BUT it was related to ASP.NET MVC and not Web API. I have some common code which I want to execute in every action in Web API certain controllers. What is a good way for such situation?

答:
ASP.Net Web API and ASP.Net Wep MVC has the same core. Also you can use the same answer describe in your link :

creating a BaseController and inherit all your controllers

creating an ActionFilter like here


答:
Here is a fiddle.
You have to make all variables global. Then you create a funtion, that makes the change itself

and then on document.ready, you will call the function and then set the loop

```<code>/*global variables here*/
        function slide(){
         $target.animate({ opacity: 0 }, 500, function() {
            console.log(arr[i]);
             $target.css('background-image', arr[i]);
             i++;
             $target.animate({ opacity: 1 }, 500, function() {
               if(i === arr.length) i = 0;
             });
           });

        }

     $(function(){
    /*other code here*/
            slide();
            setInterval(function() {
          slide();
        }, 6000);

    });
</code>```

https://jsfiddle.net/4xs7rm2v/

Title: JQuery background image slider using images from one of three arrays

Body:
Here is a fiddle.
You have to make all variables global. Then you create a funtion, that makes the change itself

and then on document.ready, you will call the function and then set the loop

/*global variables here*/
        function slide(){
         $target.animate({ opacity: 0 }, 500, function() {
            console.log(arr[i]);
             $target.css('background-image', arr[i]);
             i++;
             $target.animate({ opacity: 1 }, 500, function() {
               if(i === arr.length) i = 0;
             });
           });

        }

     $(function(){
    /*other code here*/
            slide();
            setInterval(function() {
          slide();
        }, 6000);

    });

https://jsfiddle.net/4xs7rm2v/


问:
SVN How can i add 2 new files from one branch to another branch?
I have a branch which have 2 new files .I want to merge those files to another branch - NOT trunk?

Is it actually merge ?- because the new files are not in destination branch

I tried to do a check out of branchB and try to merge the files from BranchA

but gives me some error .What is the proper way to do it?

One more question - If i check out an existing branch , is it creating a new branch or
just its copy in my local system?

答:
If you have many files checked-in in branch A with revision number Ar, Now if you want to merge this revision Ar from Branch A to Branch B,

Simply checkout the branch B, inside src, right click -> SVN Tortoise -> Merge

Select the cross branch merge radio button (first one) , and give in the Branch A src URL, also give the revision number you want to merge into Branch B from Branch A.

Click the Test Merge button, to mock the merge

If all goes well, hit the actual merge button


问:
Charts.js sets canvas width/height to 0 and displays nothing
I am trying to use Charts.js to make the default line plot that they show in their example dynamically and put it in a div that I pop up on a user click.  My code is like this:

```<code>this.chartCanvas = document.createElement('canvas');
this.div.appendChild(this.chartCanvas);
this.chartCanvas.style.height = '480px';
this.chartCanvas.style.width = '900px';
this.chartCanvas.width = 900;
this.chartCanvas.height = 480;
this.ctx = this.chartCanvas.getContext('2d');

this.chart = new Chart(this.ctx).Line(data);
</code>```

When I make the call to "new Chart" my canvas height and width are set to 0 as I can see in the inspector.  When I comment out this call my canvas has the proper width/height and displays as one would expect.  If I manually change the canvas height/width in the inspector my chart still doesn't display.

My "data" object is just what I cut and paste directly from their line chart example here: http://www.chartjs.org/docs/#line-chart-example-usage

Can anyone provide some insight on where I might be going wrong, I am completely new to the library.

答: In my case the canvas needed to be wrapped inside an element with the CSS display: block;

Body:
I am trying to use Charts.js to make the default line plot that they show in their example dynamically and put it in a div that I pop up on a user click.  My code is like this:

this.chartCanvas = document.createElement('canvas');
this.div.appendChild(this.chartCanvas);
this.chartCanvas.style.height = '480px';
this.chartCanvas.style.width = '900px';
this.chartCanvas.width = 900;
this.chartCanvas.height = 480;
this.ctx = this.chartCanvas.getContext('2d');

this.chart = new Chart(this.ctx).Line(data);

When I make the call to "new Chart" my canvas height and width are set to 0 as I can see in the inspector.  When I comment out this call my canvas has the proper width/height and displays as one would expect.  If I manually change the canvas height/width in the inspector my chart still doesn't display.

My "data" object is just what I cut and paste directly from their line chart example here: http://www.chartjs.org/docs/#line-chart-example-usage

Can anyone provide some insight on where I might be going wrong, I am completely new to the library.


问:
Scipy: What's the difference between fit using loc=0, floc=0?
As I'm fitting a Weibull distribution, and also find in other questions as Fitting distribution with fixed parameters in SciPy

There is a difference between fit using floc=0, and loc=0

```<code>weibull_params = 1, 2.0755160030790547, 0, 16.273031221223277
data = sp.stats.exponweib.rvs(*weibull_params, size=50000)
data = data.astype(int)
x = linspace(0, 55)

weibull_params1 = sp.stats.weibull_min.fit(data)
weibull_params2 = sp.stats.weibull_min.fit(data, loc=0)
weibull_params3 = sp.stats.weibull_min.fit(data, floc=0)

for weibull_params, line_style in zip([weibull_params1, weibull_params2, weibull_params3],['-','--','-.']):
    plt.figure()
    plt.hist(data, bins=arange(0,55),alpha=0.5, normed=True)
    y_weibull = sp.stats.weibull_min.pdf(x, *weibull_params)
    plot(x, y_weibull, line_style, color='black')
    print(weibull_params)
</code>```

would produce the Weibull like these:

Weibull params:

```<code>(0.50240047370945606, -4.501644985259555e-28, 2.9918077253782287)
(2.0610053128948245, -0.45099484072568979, 16.299110670854041) #loc=0
(1.0, 0, 1.05) #floc=0
</code>```

What is the difference? When should I use which one?

答:
The short answer is: floc (and fscale for that matter) are used to specify that the location parameter (and scale parameter respectively) are to be kept fixed at the specified value. loc and scale merely give starting values for the fit.

sp.stats.weibull_min inherits the fit method from scipy.stat.rv_continuous. The documentation of scipy.stats.rv_continuous.fit specifies the fact, that floc and fscale keep said parameters fixed. loc, scale and other keyword arguments that are recognized by derived distributions are simply used as starting values.

So if you want to fit keeping the location fixed, you should use floc=0 if you only want to provide a starting parameter, you should use loc=0.

Body:
As I'm fitting a Weibull distribution, and also find in other questions as Fitting distribution with fixed parameters in SciPy

There is a difference between fit using floc=0, and loc=0

weibull_params = 1, 2.0755160030790547, 0, 16.273031221223277
data = sp.stats.exponweib.rvs(*weibull_params, size=50000)
data = data.astype(int)
x = linspace(0, 55)

weibull_params1 = sp.stats.weibull_min.fit(data)
weibull_params2 = sp.stats.weibull_min.fit(data, loc=0)
weibull_params3 = sp.stats.weibull_min.fit(data, floc=0)

for weibull_params, line_style in zip([weibull_params1, weibull_params2, weibull_params3],['-','--','-.']):
    plt.figure()
    plt.hist(data, bins=arange(0,55),alpha=0.5, normed=True)
    y_weibull = sp.stats.weibull_min.pdf(x, *weibull_params)
    plot(x, y_weibull, line_style, color='black')
    print(weibull_params)

would produce the Weibull like these:

Weibull params:

(0.50240047370945606, -4.501644985259555e-28, 2.9918077253782287)
(2.0610053128948245, -0.45099484072568979, 16.299110670854041) #loc=0
(1.0, 0, 1.05) #floc=0

What is the difference? When should I use which one?


问:
missing jquery even though it is inside file laravel
I need help with this problem, it keeps giving me this error in the developer tool even though the file is already in place.

It keep giving me this error:

Failed to load resource: the server responded with a status of 404
  (Not Found)

Which I know that it is because it is not at the correct location but I have put it there correctly. Why do I keep getting this? Just now it was working fine but not sure what happen

Here is the location where I keep all the js file:

C:\xampp\htdocs\Evaluation\public\js

test.blade.php

```<code><a class="word-export" href="javascript:void(0)">Export to Word (.doc)</a>

    <div class="word-content">
        <title>Test</title>
        <p>test somehting</p>
        <p>jadanjdwlb</p>
    </div>

<script src="js/signature_pad.js"></script>
<script src="js/test2.js"></script>

<script src="js/jquery.min.js"></script>
<script src="js/FileSaver.js"></script>
<script src="js/jquery.wordexport.js"></script>
<script>
    $('.word-export').click(function(events){
        $('.word-content').wordExport();
    });
</script>
</code>```

It also gave me this error at my script and I know there shouldn't be anything wrong with it.

Uncaught ReferenceError: $ is not defined

答:
There is a function available in laravel to load css and js and other assets.
So to use that, put your css and js folders in public/assets folder. (You need to make assets folder)

Then load your files like this:

```<code><script src="{{ asset('js/filename.js') }}"></script>
</code>```

Body:
I need help with this problem, it keeps giving me this error in the developer tool even though the file is already in place.

It keep giving me this error:

Failed to load resource: the server responded with a status of 404
  (Not Found)

Which I know that it is because it is not at the correct location but I have put it there correctly. Why do I keep getting this? Just now it was working fine but not sure what happen

Here is the location where I keep all the js file:

C:\xampp\htdocs\Evaluation\public\js

test.blade.php

Export to Word (.doc)

        <title>Test</title>

test somehting

jadanjdwlb

It also gave me this error at my script and I know there shouldn't be anything wrong with it.

Uncaught ReferenceError: $ is not defined

Body:
There is a function available in laravel to load css and js and other assets.
So to use that, put your css and js folders in public/assets folder. (You need to make assets folder)

Then load your files like this:

<script src="{{ asset('js/filename.js') }}"></script>