问:
Reset Filter for Google Map Markers Using KnockoutJS
I'm attempting to create a map of filterable sports venues using Google Maps API and KnockoutJS. The markers are filtering just fine, other than when the user types an input and deletes all characters (no characters in search bars...all markers should return to visibility). I've tried several different things to make all of the markers visible on this occurrence, including using the setVisible function various places, however, just can't seem to pinpoint the solution. I know it is probably something simple, but I'm having a block.

Any help would be much appreciated.

Here is my code:

HTML:

```<code><!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' href='css/bootstrap-theme.min.css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
<link rel='stylesheet' href='css/main.css'>
</head>

<body>
  <container>
    <nav>
      <ul>
        <div id='menu'>
        <li>
          <i class='material-icons'>&#xE5D2</i>
        </li>
      </div>
      </ul>
    </nav>
    <div id='overmap'>
    <div id='filter'>
      <div class='filter-bar'>
        <h2>Search Pittsburgh Sports Venues</h2>
        <input id='userFilter' data-bind="value:userSearch, valueUpdate: 'input'" placeholder="Type a venue name..."/>
      </div>
     <ul id="list" data-bind="foreach: filterVenues">
      <a href='#'>   <li>
      <h3 data-bind="text: name, click: $parent.setVenue"></h3>
    </li></a>

      </ul>
      </div>
    </div>
</div>
    <div id='map'>
    </div>
  </container>

  <script type='text/javascript' src='js/jquery-3.2.1.min.js'></script>
  <script type='text/javascript' src='js/knockout-3.4.2.js'></script>
  <script type='text/javascript' async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA_WObUiYD7YpoYufR84re1LZHAJeAGXkY&v=3&callback=initMap">
  </script>
  <script type='text/javascript' src='js/app.js'></script>
  <script type='text/javascript' src='js/menu.js'></script>
</body>
</html>
</code>```

app.js:

```<code>var map;
var marker;
var infowindow;
var wikiURL;
var text;
var venueInfo;
var markers = [];
var markerNames = [];
var wikiURLs = [];
var venueArray = [];
var blackMarker = ('https://www.google.com/mapfiles/marker_black.png');
var yellowMarker = ('https://www.google.com/mapfiles/marker_yellow.png');
var currentMarker;
var currentVenue;
var venueList;
var filterVenues;
var clicker;
var venueMatch;
var venue;
var i;
var userSearch;
var setVenue;
var clickedVenue;

//The Model - Pro/Collegiate Stadiums in PGH, Pa.
var venues = [
  {
    name: "PNC Park",
    lat: 40.446855,
    lng: -80.0056666,
    marker: '',
    info: ''
  },
  {
    name: "Heinz Field",
    lat: 40.4466765,
    lng: -80.01576,
    marker: '',
    info: ''
  },
  {
    name: "PPG Paints Arena",
    lat: 40.439593,
    lng: -79.989338,
    marker: '',
    info: ''
  },
  {
    name: "Highmark Stadium",
    lat: 40.4362358,
    lng: -80.00959209999999,
    marker: '',
    info: ''
  },
  {
    name: "Peterson Events Center",
    lat: 40.443828,
    lng: -79.962283,
    marker: '',
    info: ''
  }
];

function ajaxCall(i){
  var venue = venues[i];
  wikiURL = 'http://en.wikipedia.org/w/api.php?action=opensearch&search=' +venue.name+ '&format=json&callback=wikiCallback';

  wikiURLs.push(wikiURL);

  $.ajax ({
      url: wikiURL,
      dataType: "jsonp",
      success: function(data){
            text = data[2];
            venues[i].info = text[0];

              if (venue.info === undefined) {
                venue.info = 'Whoops! Our data never showed up. Check out '+venue.name+' on Wikipedia for more!';
              }
              marker = new google.maps.Marker({
                position: {lat: venue.lat, lng: venue.lng},
                icon: blackMarker,
                map: map,
                name: venue.name,
                draggable: false,
                content: '<h2>'+venue.name+'</h2><p>'+venue.info+'</p>',
                visible: true
              });

                markers.push(marker);
                venue.marker = marker;
                markerNames.push(marker.name);

            infowindow = new google.maps.InfoWindow({
                  content: this.content
                });

                marker.addListener('click', function(){
                  infowindow.setContent(this.content);
                  infowindow.open(map, this);
                  for (var i = 0; i<markers.length; i++){
                    markers[i].setIcon(blackMarker);
                  }
                  this.setIcon(yellowMarker);

                });
        }
      });

  }

//capturing locations and names in arrays as we iterate through createMarker function
//marker creator

function createMarker(venue){
for (var i=0; i < venues.length; i++){
ajaxCall(i);
}
}

var viewmodel = function() {

var self = this;

self.userSearch = ko.observable("");
self.venues = ko.observableArray(venues);
this.currentVenue = ko.observable(self.venues()[0]);
this.setVenue = function(clickedVenue) {
  self.currentVenue(clickedVenue);
  google.maps.event.trigger(clickedVenue.marker, 'click');
};

self.filterVenues = ko.computed(function(venue) {
  var search = self.userSearch().toLowerCase();
  if (!search) {
    return self.venues();

  } else {
    return ko.utils.arrayFilter(self.venues(), function(venue) {
    if (venue.name.toLowerCase().indexOf(search) !== -1) {
      venue.marker.setVisible(true);
      return true;
    } else {
      venue.marker.setVisible(false);
      return false;

    }

    });
    }

});
};

//Map Initializer

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 40.446855, lng: -80.0056666},
    zoom: 14,
    mapTypeId: 'satellite'
  });

createMarker();

ko.applyBindings(new viewmodel());

}
</code>```

答:
Probably the simplest way to display all the markers once the filter is empty would be to update filterVenues observable to:

```<code> self.filterVenues = ko.computed(function (venue) {
    var search = self.userSearch().toLowerCase();
    return ko.utils.arrayFilter(self.venues(), function (venue) {
        if (venue.name.toLowerCase().indexOf(search) !== -1) {
            venue.marker.setVisible(true);
            return true;
        } else {
            venue.marker.setVisible(false);
            return false;
        }
    });
});
</code>```

2)There is at one more flaw with the provided example. Since the markers are added asynchronously, there is no any guarantee that when the map is getting displayed, all the markers are available per every venue.

I would suggest to change the way how filter control is initialized, in particular bind filter control once the all the markers are initialized.

```<code>initMarkers(map, infowindow)
    .done(function () {
        ko.applyBindings(new viewmodel());
        console.log("map is ready");
    });
</code>```

where we introduce a function to initialize markers:

```<code>function initMarkers(map, infowindow) {
    var promises = [];
    for (var i = 0; i < venues.length; i++) {

        var request = (function (venue) {
            return loadDetails(venue)
                .then(function (data) {
                    venue.info = data[2];
                    if (venue.info === undefined) {
                        venue.info = 'Whoops! Our data never showed up. Check out ' + venue.name + ' on Wikipedia for more!';
                    }
                    createMarker(map, infowindow, venue);
                });
        })(venues[i]);
    }
    promises.push(request);
    return $.when.apply(null, promises);
}
</code>```

and a function for loading Wikipedia data using CORS instead of JSONP (without callback parameter):

```<code>function loadDetails(venue) {
    var wikiURL = 'https://en.wikipedia.org/w/api.php?&origin=*&action=opensearch&search=' + venue.name + '&format=json';
    return $.ajax({
        url: wikiURL
    });
}
</code>```

3)Last but not least, there is no need to create the instance of info window per every marker, instead you could create a single instance.

Below is provided the modified example

var blackMarker = ('https://www.google.com/mapfiles/marker_black.png');
var yellowMarker = ('https://www.google.com/mapfiles/marker_yellow.png');
//The Model - Pro/Collegiate Stadiums in PGH, Pa.
var venues = [
    {
        name: "PNC Park",
        lat: 40.446855,
        lng: -80.0056666,
        marker: '',
        info: ''
    },
    {
        name: "Heinz Field",
        lat: 40.4466765,
        lng: -80.01576,
        marker: '',
        info: ''
    },
    {
        name: "PPG Paints Arena",
        lat: 40.439593,
        lng: -79.989338,
        marker: '',
        info: ''
    },
    {
        name: "Highmark Stadium",
        lat: 40.4362358,
        lng: -80.00959209999999,
        marker: '',
        info: ''
    },
    {
        name: "Peterson Events Center",
        lat: 40.443828,
        lng: -79.962283,
        marker: '',
        info: ''
    }
];

function loadDetails(venue) {
    var wikiURL = 'https://en.wikipedia.org/w/api.php?&origin=*&action=opensearch&search=' + venue.name + '&format=json';
    return $.ajax({
        url: wikiURL
    });
}

function createMarker(map, infowindow, venue) {
    var marker = new google.maps.Marker({
        position: { lat: venue.lat, lng: venue.lng },
        icon: blackMarker,
        map: map,
        name: venue.name,
        draggable: false,
        content: '
' + venue.name + '

' + venue.info + '
',
        visible: true
    });
    //console.log(marker.name);

    marker.addListener('click', function () {
        if (infowindow.prevMarker)
            infowindow.prevMarker.setIcon(blackMarker);
        infowindow.setContent(this.content);
        infowindow.open(map, this);
        this.setIcon(yellowMarker);
        infowindow.prevMarker = this;
    });
    venue.marker = marker;
    return marker;
}

function initMarkers(map, infowindow) {
    var promises = [];
    for (var i = 0; i < venues.length; i++) {

        var request = (function (venue) {
            return loadDetails(venue)
                .then(function (data) {
                    venue.info = data[2];
                    if (venue.info === undefined) {
                        venue.info = 'Whoops! Our data never showed up. Check out ' + venue.name + ' on Wikipedia for more!';
                    }
                    return createMarker(map, infowindow, venue);
                });
        })(venues[i]);
    }
    promises.push(request);
    return $.when.apply(null, promises);
}

var viewmodel = function () {
    var self = this;
    self.userSearch = ko.observable("");
    self.venues = ko.observableArray(venues);
    self.currentVenue = ko.observable(self.venues()[0]);
    self.setVenue = function (clickedVenue) {
        self.currentVenue(clickedVenue);
        google.maps.event.trigger(clickedVenue.marker, 'click');
    };

    self.filterVenues = ko.computed(function (venue) {
        var search = self.userSearch().toLowerCase();
        return ko.utils.arrayFilter(self.venues(), function (venue) {
            if (venue.name.toLowerCase().indexOf(search) !== -1) {
                venue.marker.setVisible(true);
                return true;
            } else {
                venue.marker.setVisible(false);
                return false;
            }
        });
    });
};

function initMap() {
    var map = new google.maps.Map(document.getElementById('map'), {
        center: { lat: 40.446855, lng: -80.0056666 },
        zoom: 14,
        mapTypeId: 'satellite'
    });

    var infowindow = new google.maps.InfoWindow({
        content: ""
    });

    initMarkers(map, infowindow)
        .done(function () {
            ko.applyBindings(new viewmodel());
            //console.log("map is ready");
        });

}

google.maps.event.addDomListener(window, 'load', initMap);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#map{
    width: 100%;
    height: 420px;
}</code>```

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

Search Pittsburgh Sports Venues

          <input id='userFilter' data-bind="value:userSearch, valueUpdate: 'input'" placeholder="Type a venue name..." />

```

Body:
I'm attempting to create a map of filterable sports venues using Google Maps API and KnockoutJS. The markers are filtering just fine, other than when the user types an input and deletes all characters (no characters in search bars...all markers should return to visibility). I've tried several different things to make all of the markers visible on this occurrence, including using the setVisible function various places, however, just can't seem to pinpoint the solution. I know it is probably something simple, but I'm having a block.

Any help would be much appreciated.

Here is my code:

HTML:

<!DOCTYPE html>

<link rel='stylesheet' href='css/bootstrap-theme.min.css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
<link rel='stylesheet' href='css/main.css'>

  <container>

          &#xE5D2

Search Pittsburgh Sports Venues

        <input id='userFilter' data-bind="value:userSearch, valueUpdate: 'input'" placeholder="Type a venue name..."/>

  </container>

app.js:

var map;
var marker;
var infowindow;
var wikiURL;
var text;
var venueInfo;
var markers = [];
var markerNames = [];
var wikiURLs = [];
var venueArray = [];
var blackMarker = ('https://www.google.com/mapfiles/marker_black.png');
var yellowMarker = ('https://www.google.com/mapfiles/marker_yellow.png');
var currentMarker;
var currentVenue;
var venueList;
var filterVenues;
var clicker;
var venueMatch;
var venue;
var i;
var userSearch;
var setVenue;
var clickedVenue;

//The Model - Pro/Collegiate Stadiums in PGH, Pa.
var venues = [
  {
    name: "PNC Park",
    lat: 40.446855,
    lng: -80.0056666,
    marker: '',
    info: ''
  },
  {
    name: "Heinz Field",
    lat: 40.4466765,
    lng: -80.01576,
    marker: '',
    info: ''
  },
  {
    name: "PPG Paints Arena",
    lat: 40.439593,
    lng: -79.989338,
    marker: '',
    info: ''
  },
  {
    name: "Highmark Stadium",
    lat: 40.4362358,
    lng: -80.00959209999999,
    marker: '',
    info: ''
  },
  {
    name: "Peterson Events Center",
    lat: 40.443828,
    lng: -79.962283,
    marker: '',
    info: ''
  }
];

function ajaxCall(i){
  var venue = venues[i];
  wikiURL = 'http://en.wikipedia.org/w/api.php?action=opensearch&search=' +venue.name+ '&format=json&callback=wikiCallback';

  wikiURLs.push(wikiURL);

  $.ajax ({
      url: wikiURL,
      dataType: "jsonp",
      success: function(data){
            text = data[2];
            venues[i].info = text[0];

              if (venue.info === undefined) {
                venue.info = 'Whoops! Our data never showed up. Check out '+venue.name+' on Wikipedia for more!';
              }
              marker = new google.maps.Marker({
                position: {lat: venue.lat, lng: venue.lng},
                icon: blackMarker,
                map: map,
                name: venue.name,
                draggable: false,
                content: '
'+venue.name+'

'+venue.info+'
',
                visible: true
              });

                markers.push(marker);
                venue.marker = marker;
                markerNames.push(marker.name);

            infowindow = new google.maps.InfoWindow({
                  content: this.content
                });

                marker.addListener('click', function(){
                  infowindow.setContent(this.content);
                  infowindow.open(map, this);
                  for (var i = 0; i<markers.length; i++){
                    markers[i].setIcon(blackMarker);
                  }
                  this.setIcon(yellowMarker);

                });
        }
      });

  }

//capturing locations and names in arrays as we iterate through createMarker function
//marker creator

function createMarker(venue){
for (var i=0; i < venues.length; i++){
ajaxCall(i);
}
}

var viewmodel = function() {

var self = this;

self.userSearch = ko.observable("");
self.venues = ko.observableArray(venues);
this.currentVenue = ko.observable(self.venues()[0]);
this.setVenue = function(clickedVenue) {
  self.currentVenue(clickedVenue);
  google.maps.event.trigger(clickedVenue.marker, 'click');
};

self.filterVenues = ko.computed(function(venue) {
  var search = self.userSearch().toLowerCase();
  if (!search) {
    return self.venues();

  } else {
    return ko.utils.arrayFilter(self.venues(), function(venue) {
    if (venue.name.toLowerCase().indexOf(search) !== -1) {
      venue.marker.setVisible(true);
      return true;
    } else {
      venue.marker.setVisible(false);
      return false;

    }

    });
    }

});
};

//Map Initializer

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 40.446855, lng: -80.0056666},
    zoom: 14,
    mapTypeId: 'satellite'
  });

createMarker();

ko.applyBindings(new viewmodel());

}

Body:
Probably the simplest way to display all the markers once the filter is empty would be to update filterVenues observable to:

 self.filterVenues = ko.computed(function (venue) {
    var search = self.userSearch().toLowerCase();
    return ko.utils.arrayFilter(self.venues(), function (venue) {
        if (venue.name.toLowerCase().indexOf(search) !== -1) {
            venue.marker.setVisible(true);
            return true;
        } else {
            venue.marker.setVisible(false);
            return false;
        }
    });
});

2)There is at one more flaw with the provided example. Since the markers are added asynchronously, there is no any guarantee that when the map is getting displayed, all the markers are available per every venue.

I would suggest to change the way how filter control is initialized, in particular bind filter control once the all the markers are initialized.

initMarkers(map, infowindow)
    .done(function () {
        ko.applyBindings(new viewmodel());
        console.log("map is ready");
    });

where we introduce a function to initialize markers:

function initMarkers(map, infowindow) {
    var promises = [];
    for (var i = 0; i < venues.length; i++) {

        var request = (function (venue) {
            return loadDetails(venue)
                .then(function (data) {
                    venue.info = data[2];
                    if (venue.info === undefined) {
                        venue.info = 'Whoops! Our data never showed up. Check out ' + venue.name + ' on Wikipedia for more!';
                    }
                    createMarker(map, infowindow, venue);
                });
        })(venues[i]);
    }
    promises.push(request);
    return $.when.apply(null, promises);
}

and a function for loading Wikipedia data using CORS instead of JSONP (without callback parameter):

function loadDetails(venue) {
    var wikiURL = 'https://en.wikipedia.org/w/api.php?&origin=*&action=opensearch&search=' + venue.name + '&format=json';
    return $.ajax({
        url: wikiURL
    });
}

3)Last but not least, there is no need to create the instance of info window per every marker, instead you could create a single instance.

Below is provided the modified example

var blackMarker = ('https://www.google.com/mapfiles/marker_black.png');
var yellowMarker = ('https://www.google.com/mapfiles/marker_yellow.png');
//The Model - Pro/Collegiate Stadiums in PGH, Pa.
var venues = [
    {
        name: "PNC Park",
        lat: 40.446855,
        lng: -80.0056666,
        marker: '',
        info: ''
    },
    {
        name: "Heinz Field",
        lat: 40.4466765,
        lng: -80.01576,
        marker: '',
        info: ''
    },
    {
        name: "PPG Paints Arena",
        lat: 40.439593,
        lng: -79.989338,
        marker: '',
        info: ''
    },
    {
        name: "Highmark Stadium",
        lat: 40.4362358,
        lng: -80.00959209999999,
        marker: '',
        info: ''
    },
    {
        name: "Peterson Events Center",
        lat: 40.443828,
        lng: -79.962283,
        marker: '',
        info: ''
    }
];

function loadDetails(venue) {
    var wikiURL = 'https://en.wikipedia.org/w/api.php?&origin=*&action=opensearch&search=' + venue.name + '&format=json';
    return $.ajax({
        url: wikiURL
    });
}

function createMarker(map, infowindow, venue) {
    var marker = new google.maps.Marker({
        position: { lat: venue.lat, lng: venue.lng },
        icon: blackMarker,
        map: map,
        name: venue.name,
        draggable: false,
        content: '<h2>' + venue.name + '</h2><p>' + venue.info + '</p>',
        visible: true
    });
    //console.log(marker.name);

    marker.addListener('click', function () {
        if (infowindow.prevMarker)
            infowindow.prevMarker.setIcon(blackMarker);
        infowindow.setContent(this.content);
        infowindow.open(map, this);
        this.setIcon(yellowMarker);
        infowindow.prevMarker = this;
    });
    venue.marker = marker;
    return marker;
}

function initMarkers(map, infowindow) {
    var promises = [];
    for (var i = 0; i < venues.length; i++) {

        var request = (function (venue) {
            return loadDetails(venue)
                .then(function (data) {
                    venue.info = data[2];
                    if (venue.info === undefined) {
                        venue.info = 'Whoops! Our data never showed up. Check out ' + venue.name + ' on Wikipedia for more!';
                    }
                    return createMarker(map, infowindow, venue);
                });
        })(venues[i]);
    }
    promises.push(request);
    return $.when.apply(null, promises);
}

var viewmodel = function () {
    var self = this;
    self.userSearch = ko.observable("");
    self.venues = ko.observableArray(venues);
    self.currentVenue = ko.observable(self.venues()[0]);
    self.setVenue = function (clickedVenue) {
        self.currentVenue(clickedVenue);
        google.maps.event.trigger(clickedVenue.marker, 'click');
    };

    self.filterVenues = ko.computed(function (venue) {
        var search = self.userSearch().toLowerCase();
        return ko.utils.arrayFilter(self.venues(), function (venue) {
            if (venue.name.toLowerCase().indexOf(search) !== -1) {
                venue.marker.setVisible(true);
                return true;
            } else {
                venue.marker.setVisible(false);
                return false;
            }
        });
    });
};

function initMap() {
    var map = new google.maps.Map(document.getElementById('map'), {
        center: { lat: 40.446855, lng: -80.0056666 },
        zoom: 14,
        mapTypeId: 'satellite'
    });

    var infowindow = new google.maps.InfoWindow({
        content: ""
    });

    initMarkers(map, infowindow)
        .done(function () {
            ko.applyBindings(new viewmodel());
            //console.log("map is ready");
        });

}

google.maps.event.addDomListener(window, 'load', initMap);

#map{
    width: 100%;
    height: 420px;
}

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
 <script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
  <script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js'></script>
 <script type='text/javascript' src="https://maps.googleapis.com/maps/api/js">
 </script>

  <div id='overmap'>
      <div id='filter'>
        <div class='filter-bar'>
          <h2>Search Pittsburgh Sports Venues</h2>
          <input id='userFilter' data-bind="value:userSearch, valueUpdate: 'input'" placeholder="Type a venue name..." />
        </div>
        <ul id="list" data-bind="foreach: filterVenues">
          <a href='#'>
            <li>
              <h3 data-bind="text: name, click: $parent.setVenue"></h3>
            </li>
          </a>

        </ul>
      </div>
    </div>
    </div>
    <div id='map'></div>


来源: stackexchange

问:
What is the role of server in Push Notification for Android and IOS?
I am a bit Confused in Push Notification concept,
I mean can I send notification to all registered users from firebase console after my application is live.
If yes then What is the role of server (like MS Azure or AWS etc) if we can directly send notifications from firebase console ?
If No then why and what is the best way to use this service?

I really need logical explanation.

please answer me. Thanks

答:
"if we can directly send notifications from firebase console"

You can't directly send the notification. It will have first go through APNS.

APNS is there to:

Avoid spamming. If you're sending it every 3 seconds, APNS will restrict you.

Help preserve battery. This becomes more important for silent notifications. Imagine an app sending a silent notification every 30 seconds. This would affect the battery—without the user knowing about it. He's like I'm not opening any apps, yet my battery is dying faster than normal. This would allow Apple to batch notifications from different apps. Imagine if you had 20 apps each trying to send their silent notification at a specific time, so you would be on for 20 different moments. Now imagine if your device told APNS: "Hey there, I have good battery and a good connection, send me what you got!"

ContentLicense: CC BY-SA 3.0


问:
Is it safe to make a empty field non-empty for a existing database?

Hi, I'm trying to alter my current django project schema, the data migration tool is south. django version is 1.6.9.

It is a existing database so I don't want to mess up with my historical data.

What I'm trying to alter is making a blank=true field non-empty(blank=false)

here is my model class:

```<code>class Post(DraftableModel, EditTrackingModel):
    title = models.CharField(max_length=120,
                             verbose_name='headline')

    description = models.CharField(max_length=260,
                                   blank=True,
                                   verbose_name='lead-in',
                                   help_text="260 character limit")
    /*rest of the code*/
</code>```

I want change the description from models.CharField(blank=True) to models.CharField(blank=False), which is the default blank value

considering the existence of my database, some of my old Post model do have empty description.
After my migration and change of database schema, will my database be corrupted?

答:
When you try to migrate, django will warn you about those empty fields. so you have few options.

You can add a default value in your model like default="Some Default Value" and django will chose that default value for all empty fields on migration.

You can just send the migrate request and on the terminal, django will ask you to add an one-off value to be added to all the empty fields.

Also you can edit the migrate files and add different values for those empty fields based on conditions you have in mind.

You can write a function to check for all the empty fields for exiting rows and add some data based on some conditions.

Also i highly recommend to make a backup first. Doesn't matter how small the changes are or how good you are in coding.

Body:
Hi, I'm trying to alter my current django project schema, the data migration tool is south. django version is 1.6.9.

It is a existing database so I don't want to mess up with my historical data.

What I'm trying to alter is making a blank=true field non-empty(blank=false)

here is my model class:

class Post(DraftableModel, EditTrackingModel):
    title = models.CharField(max_length=120,
                             verbose_name='headline')

    description = models.CharField(max_length=260,
                                   blank=True,
                                   verbose_name='lead-in',
                                   help_text="260 character limit")
    /*rest of the code*/

I want change the description from models.CharField(blank=True) to models.CharField(blank=False), which is the default blank value

considering the existence of my database, some of my old Post model do have empty description.
After my migration and change of database schema, will my database be corrupted?


问:
HTML Form JS Validation
I'm trying to validate my login form so that the field will have a min/max length before the values being posted to my PHP file.

JavaScript:

```<code>function loginValidation() {
    var user = document.login.username.value;
    var pass = document.login.password.value;

    if (user.length <= 6 || user.length > 20) {
        alert("Please make sure the username is between 7 and 20 characters.");
        return false;
    }

    if (pass.length <= 8 || pass.length > 50) {
        alert("Please make sure the password field is between 9 and 50 characters.");
        return false;
    }
}
</code>```

HTML:

```<code><form name="login" onsubmit="loginValidation()" action="login.php" method="post">
    <div class="form-group row">
        <label for="username" class="lead para col-sm-4">Username</label>
        <input type="text" class="form-control transparent col-sm" id="username" name="username" placeholder="Username">
    </div>
    <div class="form-group row">
        <label for="password" class="lead para col-sm-4">Password</label>
        <input type="password" class="form-control col-sm" id="password" name="password" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-outline-primary">LOGIN</button>
</form>
</code>```

It seems that the code is ignoring the Function or that it just doesn't work (errors maybe?).

Other information that might be useful to know is that the JavaScript file with all my functions is external.

```<code><script src="/JS/functions.js"></script>
</code>```

答:
Working fiddle.

You are just missing the return in the function call in your onsubmit, should be like :

```<code><form name="login" onsubmit="return loginValidation()" action="login.php" method="post">
_____________________________^^^^^^
</code>```

It will be better to attach the event in your JS part :

```<code>document.querySelector('form[name="login"]').addEventListener("submit", loginValidation);
</code>```

function loginValidation() {
  var user = document.login.username.value;
  var pass = document.login.password.value;

  if (user.length <= 6 || user.length > 20) {
    alert("Please make sure the username is between 7 and 20 characters.");
    return false;
  }

  if (pass.length <= 8 || pass.length > 50) {
    alert("Please make sure the password field is between 9 and 50 characters.");
    return false;
  }
  return true;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form name="login" onsubmit="return loginValidation()" action="login.php" method="post">
  <div class="form-group row">
    <label for="username" class="lead para col-sm-4">Username</label>
    <input type="text" class="form-control transparent col-sm" id="username" name="username" placeholder="Username">
  </div>
  <div class="form-group row">
    <label for="password" class="lead para col-sm-4">Password</label>
    <input type="password" class="form-control col-sm" id="password" name="password" placeholder="Password">
  </div>
  <button type="submit" class="btn btn-outline-primary">LOGIN</button>
</form></code>```

Title: HTML Form JS Validation

Body:
I'm trying to validate my login form so that the field will have a min/max length before the values being posted to my PHP file.

JavaScript:

function loginValidation() {
    var user = document.login.username.value;
    var pass = document.login.password.value;

    if (user.length <= 6 || user.length > 20) {
        alert("Please make sure the username is between 7 and 20 characters.");
        return false;
    }

    if (pass.length <= 8 || pass.length > 50) {
        alert("Please make sure the password field is between 9 and 50 characters.");
        return false;
    }
}

HTML:

<form name="login" onsubmit="loginValidation()" action="login.php" method="post">

        Username
        <input type="text" class="form-control transparent col-sm" id="username" name="username" placeholder="Username">

        Password
        <input type="password" class="form-control col-sm" id="password" name="password" placeholder="Password">

    <button type="submit" class="btn btn-outline-primary">LOGIN</button>
</form>

It seems that the code is ignoring the Function or that it just doesn't work (errors maybe?).

Other information that might be useful to know is that the JavaScript file with all my functions is external.

Body:
Working fiddle.

You are just missing the return in the function call in your onsubmit, should be like :

<form name="login" onsubmit="return loginValidation()" action="login.php" method="post">
_____________________________^^^^^^

It will be better to attach the event in your JS part :

document.querySelector('form[name="login"]').addEventListener("submit", loginValidation);

function loginValidation() {
  var user = document.login.username.value;
  var pass = document.login.password.value;

  if (user.length <= 6 || user.length > 20) {
    alert("Please make sure the username is between 7 and 20 characters.");
    return false;
  }

  if (pass.length <= 8 || pass.length > 50) {
    alert("Please make sure the password field is between 9 and 50 characters.");
    return false;
  }
  return true;
}

<form name="login" onsubmit="return loginValidation()" action="login.php" method="post">
  <div class="form-group row">
    <label for="username" class="lead para col-sm-4">Username</label>
    <input type="text" class="form-control transparent col-sm" id="username" name="username" placeholder="Username">
  </div>
  <div class="form-group row">
    <label for="password" class="lead para col-sm-4">Password</label>
    <input type="password" class="form-control col-sm" id="password" name="password" placeholder="Password">
  </div>
  <button type="submit" class="btn btn-outline-primary">LOGIN</button>
</form>


问:
Is it possible to define a type for property names in TypeScript

So i have this constants class which defines the names of the variables that i save to the localStorage / chrome.storage and what their default value is if the items doesn't exist in the storage.

SettingsConstants.ts

```<code>export class SettingsConstants {
  public static SETTINGS_ALLOWED: string = "settingsAllowed";
  public static QUIT_ALLOWED: string = "quitAllowed";

  public static DEFAULTS: any = () => {
    const defaults = {};
    defaults[SettingsConstant.SETTINGS_ALLOWED] = true;
    defaults[SettingsConstant.QUIT_ALLOWED] = true;
    return defaults;
  };

  public static STORAGE_STRINGS: string[] = [
      SettingsConstant.SETTINGS_ALLOWED,
      SettingsConstant.QUIT_ALLOWED
    ]
}
</code>```

Then i have SettingsService which uses these constants in the getItemsFromStorage() method. Basically what it does is that it loops through the strings defined in SettingsConstants and sets it own properties equal to the value it got from the storage, otherwise set the default value.

SettingsService.ts

```<code>export class SettingsService implements ISettingsService {

  private settingsAllowed: boolean = undefined;
  private quitAllowed: boolean = undefined;

   constructor(logger: Logger) {
     this.logger = logger;
     this.getItemsFromStorage();
   }

   private getItemsFromStorage(): void {
    const storageStrings: string[] = SettingsConstant.STORAGE_STRINGS;
    for (let i = 0; i < storageStrings.length; i++) {
      const currentString = storageStrings[i];
      if (!this.hasOwnProperty(currentString)) {
        throw "The property is not defined, " +
        "check if it matches the STORAGE_STRING in SettingsConstants";
      }
      const currentItem = this.getItem(currentString);
      this[currentString] = currentItem === undefined
        ? SettingsConstant.DEFAULTS()[currentString]
        : currentItem;
      this.logger.log(currentString, "=", this[currentString]);
    }
  }

  private getItem(item: any): any {
    const localItem: string = localStorage.getItem(item);
    if (localItem === undefined || localItem === null || localItem === 'undefined') {
      return undefined;
    } else {
      return JSON.parse(localItem);
    }
  }
}
</code>```

The code works, but it isn't statically checked, which is what i desire. The current way to check if SettingsService has a property is to set the property to undefined then use

```<code>if (!this.hasOwnProperty(currentString)) {
    throw "The property is not defined, " +
    "check if it matches the STORAGE_STRING in SettingsConstants";
}
</code>```

To check if the variable exists in the class, if it doesn't then it must mean that we might have misspelled it, or forgotten to add it.

I could solve this problem by adding them to the ISettingsService interface, that would however mean that the property would become public which is not the intention

My desired solution

I would like to define a type where i could define the names of the variables that were allowed to be used. Similar to this

```<code>export declare namespace SettingsTypes{
  type SettingsType = "settingsAllowed" | "quitAllowed";
}
</code>```

Then in SettingsService i could write the following

```<code>private settingsAllowed: SettingsTypes.SettingType: boolean;
</code>```

So its like settingsAllowed name has to be of type SettingsTypes.SettingType and its return type would be boolean

However this does not seem to make much sense, and it seems like there is no way to do this properly, so i was wondering if any of you bright heads might have a great solution for this problem.

答:
It’s an interesting question. I went to read some documentation. Have a look at the section of the type guards in particular. Perhaps you can do something similar where you do a type guard for boolean?

```<code>function isSetting(setting: any): setting is Settings {
return typeof  setting === SettingsTypes.SettingType;
}
</code>```

Something similar to this. It’s just a possible idea

Advanced Types

Body:
So i have this constants class which defines the names of the variables that i save to the localStorage / chrome.storage and what their default value is if the items doesn't exist in the storage.

SettingsConstants.ts

export class SettingsConstants {
  public static SETTINGS_ALLOWED: string = "settingsAllowed";
  public static QUIT_ALLOWED: string = "quitAllowed";

  public static DEFAULTS: any = () => {
    const defaults = {};
    defaults[SettingsConstant.SETTINGS_ALLOWED] = true;
    defaults[SettingsConstant.QUIT_ALLOWED] = true;
    return defaults;
  };

  public static STORAGE_STRINGS: string[] = [
      SettingsConstant.SETTINGS_ALLOWED,
      SettingsConstant.QUIT_ALLOWED
    ]
}

Then i have SettingsService which uses these constants in the getItemsFromStorage() method. Basically what it does is that it loops through the strings defined in SettingsConstants and sets it own properties equal to the value it got from the storage, otherwise set the default value.

SettingsService.ts

export class SettingsService implements ISettingsService {

  private settingsAllowed: boolean = undefined;
  private quitAllowed: boolean = undefined;

   constructor(logger: Logger) {
     this.logger = logger;
     this.getItemsFromStorage();
   }

   private getItemsFromStorage(): void {
    const storageStrings: string[] = SettingsConstant.STORAGE_STRINGS;
    for (let i = 0; i < storageStrings.length; i++) {
      const currentString = storageStrings[i];
      if (!this.hasOwnProperty(currentString)) {
        throw "The property is not defined, " +
        "check if it matches the STORAGE_STRING in SettingsConstants";
      }
      const currentItem = this.getItem(currentString);
      this[currentString] = currentItem === undefined
        ? SettingsConstant.DEFAULTS()[currentString]
        : currentItem;
      this.logger.log(currentString, "=", this[currentString]);
    }
  }

  private getItem(item: any): any {
    const localItem: string = localStorage.getItem(item);
    if (localItem === undefined || localItem === null || localItem === 'undefined') {
      return undefined;
    } else {
      return JSON.parse(localItem);
    }
  }
}

The code works, but it isn't statically checked, which is what i desire. The current way to check if SettingsService has a property is to set the property to undefined then use

if (!this.hasOwnProperty(currentString)) {
    throw "The property is not defined, " +
    "check if it matches the STORAGE_STRING in SettingsConstants";
}

To check if the variable exists in the class, if it doesn't then it must mean that we might have misspelled it, or forgotten to add it.

I could solve this problem by adding them to the ISettingsService interface, that would however mean that the property would become public which is not the intention

My desired solution

I would like to define a type where i could define the names of the variables that were allowed to be used. Similar to this

export declare namespace SettingsTypes{
  type SettingsType = "settingsAllowed" | "quitAllowed";
}

Then in SettingsService i could write the following

private settingsAllowed: SettingsTypes.SettingType: boolean;

So its like settingsAllowed name has to be of type SettingsTypes.SettingType and its return type would be boolean

However this does not seem to make much sense, and it seems like there is no way to do this properly, so i was wondering if any of you bright heads might have a great solution for this problem.

Body:
It’s an interesting question. I went to read some documentation. Have a look at the section of the type guards in particular. Perhaps you can do something similar where you do a type guard for boolean?

function isSetting(setting: any): setting is Settings {
return typeof  setting === SettingsTypes.SettingType;
}

Something similar to this. It’s just a possible idea

Advanced Types


问:
How to parse xml file using php script
This is may xml file

```<code><?xml version="1.0" encoding="utf-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>werwer</title>
<link>werwerwe</link>

<item>
<g:id>704667</g:id>
<title>Nike</title>
<description>erterterter</description>
</item>

<item>
<g:id>4456456</g:id>
<title>Nike</title>
<description>erterterter</description>
</item>

</channel></rss>
</code>```

how to parse that xml file, I have script but it doesnt work

```<code>if (file_exists('products.xml')) {
    $xml = simplexml_load_file('products.xml');

    print_r($xml);
} else {
    exit('Failed to open products.xml.');
}
</code>```

any idea how to get information between g:id?

答:
You need to get an apply the namespace to the children. http://php.net/manual/en/simplexmlelement.getnamespaces.php

```<code><?php
$xml = '<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
    <channel>
        <title>werwer</title>
        <link>werwerwe</link>

        <item>
            <g:id>704667</g:id>
            <title>Nike</title>
            <description>erterterter</description>
        </item>

        <item>
            <g:id>4456456</g:id>
            <title>Nike</title>
            <description>erterterter</description>
        </item>

    </channel>
</rss>';

$xml = simplexml_load_string($xml);
$ns = $xml->getNamespaces(true);

foreach ($xml->channel->item as $item) {
    echo $item->children($ns['g'])->id.PHP_EOL;
}
/*
704667
4456456
*/
</code>```

https://3v4l.org/t2D84

Title: How to parse xml file using php script

Body:
This is may xml file

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>werwer</title>
<link>werwerwe</link>

<item>
<g:id>704667</g:id>
<title>Nike</title>
<description>erterterter</description>
</item>

<item>
<g:id>4456456</g:id>
<title>Nike</title>
<description>erterterter</description>
</item>

</channel></rss>

how to parse that xml file, I have script but it doesnt work

if (file_exists('products.xml')) {
    $xml = simplexml_load_file('products.xml');

    print_r($xml);
} else {
    exit('Failed to open products.xml.');
}

any idea how to get information between g:id?

Body:
You need to get an apply the namespace to the children. http://php.net/manual/en/simplexmlelement.getnamespaces.php

<?php
$xml = '<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
    <channel>
        <title>werwer</title>
        <link>werwerwe</link>

        <item>
            <g:id>704667</g:id>
            <title>Nike</title>
            <description>erterterter</description>
        </item>

        <item>
            <g:id>4456456</g:id>
            <title>Nike</title>
            <description>erterterter</description>
        </item>

    </channel>
</rss>';

$xml = simplexml_load_string($xml);
$ns = $xml->getNamespaces(true);

foreach ($xml->channel->item as $item) {
    echo $item->children($ns['g'])->id.PHP_EOL;
}
/*
704667
4456456
*/

https://3v4l.org/t2D84


问:
change password user laravel 5.3
I want to create form with 3 field (old_password, new_password, confirm_password) with laravel 5.

View

old password :
{!! Form::password('old_password',['class' => 'form-control']) !!}

New Password : {!! Form::password('password',['class' => 'form-control']) !!}

Confirm New Password : {!! Form::password('verify_password',['class' => 'form-control']) !!}

Controller when user register

```<code>public function postRegister(Request $request)
{
    $rules = [
        'email'             =>  'required|email|unique:users',
        'confirm_email'     =>  'required|same:email',
        'password'          =>  'required|min:8|regex:/^(?=\S*[a-z])(?=\S*[!@#$&*])(?=\S*[A-Z])(?=\S*[\d])\S*$/',
        'verify_password'   =>  'required|same:password',
    ];

    $messages = [
        'email.required'            => 'email tidak boleh kosong',
        'password.required'         => 'password tidak boleh kosong',
        'password.min'              => 'Password harus minimal 8 karakter',
        'password.regex'            => 'Format password harus terdiri dari kombinasi huruf besar, angka dan karakter spesial (contoh:!@#$%^&*?><).',
        'verify_password.required'  => 'Verify Password tidak boleh kosong',
        'email.email'               => 'Format Email tidak valid',
        'email.unique'              => 'Email yang anda masukkan telah digunakan',
        'verify_password.same'      => 'Password tidak sama!',
    ];

    $this->validate($request,$rules,$messages);

    $newUser = $this->user->create([
        'email'         =>  $request->email,
        'password'      =>  \Hash::make($request->password),
    ]);
    $this->activationService->sendActivationMail($newUser);

    return redirect('/account/login')->with('success', 'Check your email');
}
</code>```

I'm new in laravel, i've read some similar problem to change password in stackoverflow but it didn't help me.

How should I write code in my controller for change password user?.
Thanks in Advance.

答:
changePassword.blade.php

```<code>@extends('layouts.app')

@section('content')
    <!-- header logo: style can be found in header.less -->
    <header class="header">
        <div class="container">
            <div class="row">
                <div class="col-lg-6">
                <a href="index.php" class="logo">
                    <!-- Add the class icon to your logo image or logo icon to add the margining -->
                    <img src="img/airbus-logo.png" />
                </a></div>
                <!-- Header Navbar: style can be found in header.less -->
                <div class="col-lg-6">
                    @include('partials._userModal')
                    @include('partials._menu')
                </div>
            </div>
        </div>
    </header>
    <div class="wrapper">
        <div class="container">
            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="content files-list clearfix">
                <h2>
                @if(Auth::check())
                Welcome {{ Auth::user()->fullName }}
                @endif
                </h2>
                    <div class="col-xs-5">
                        <h4>Change password</h4><br />
                        @if($errors->any())
                            @foreach($errors->all() as $error)
                                <p style='padding:15px;' class='bg-danger'>{{ $error }}</p>
                            @endforeach
                        @endif
                        @if(Request::get('errorMessage') !== null)
                            <p style='padding:15px;' class='bg-danger'>{{ Request::get('errorMessage') }}</p>
                        @endif
                        <form method="post">
                            {{ csrf_field() }}
                           <div class="placeholder">Current Password</div>
                            <input style="max-width:200px;" placeholder='Current password' name="oldpass" id="oldpass"  class="form-control" type="password"><br>
                            <div class="placeholder">New password</div>
                            <input style="max-width:200px;" placeholder='New password' name="password" id="password"  class="form-control" type="password"><br>
                            <div class="placeholder">Confirm password</div>
                            <input id="password_confirmation" style="max-width:200px;" placeholder='Confirm password' name="password_confirmation"  class="form-control" type="password">
                            <hr>
                            <input type="submit" class="btn btn-primary" value="Save">
                        </form>
                    </div>
            </aside>
            <!-- /.right-side -->
        </div>
        <div style="  height: 155px;"></div>
        <div id="footer">
            <div class="container"> © Airbus Group 2015 </div>
        </div>
    </div>
    <!-- ./wrapper -->
    <!-- <script src="js/hub/demo.js" type="text/javascript"></script> -->
<script type="text/javascript">
    $(document).ready(function(){
        var bHeight = $("body").height();
        var wHeight = $( window ).height();
        if(bHeight < wHeight){
            $("#footer").addClass("absolute");
        }else{
            $("#footer").removeClass("absolute");
        }
        if (!$.support.htmlSerialize && !$.support.opacity){
            $(".placeholder").show();
        }
    });
</script>
@endsection
</code>```

Controller Post Function

```<code>public function postChangePassword(Request $request)
    {
        $validatedData = $request->validate([
            'oldpass' => 'required|min:6',
            'password' => 'required|string|min:6',
            'password_confirmation' => 'required|same:password',
        ],[
            'oldpass.required' => 'Old password is required',
            'oldpass.min' => 'Old password needs to have at least 6 characters',
            'password.required' => 'Password is required',
            'password.min' => 'Password needs to have at least 6 characters',
            'password_confirmation.required' => 'Passwords do not match'
        ]);

        $current_password = \Auth::User()->password;
        if(\Hash::check($request->input('oldpass'), $current_password))
        {
          $user_id = \Auth::User()->id;
          $obj_user = User::find($user_id);
          $obj_user->password = \Hash::make($request->input('password'));
          $obj_user->save();
          return view('auth.passwords.changeConfirmation');
        }
        else
        {
          $data['errorMessage'] = 'Please enter correct current password';
          return redirect()->route('user.getChangePassword', $data);
        }
    }
</code>```

Title: change password user laravel 5.3

Body:
I want to create form with 3 field (old_password, new_password, confirm_password) with laravel 5.

View

old password :
{!! Form::password('old_password',['class' => 'form-control']) !!}

New Password : {!! Form::password('password',['class' => 'form-control']) !!}

Confirm New Password : {!! Form::password('verify_password',['class' => 'form-control']) !!}

Controller when user register

public function postRegister(Request $request)
{
    $rules = [
        'email'             =>  'required|email|unique:users',
        'confirm_email'     =>  'required|same:email',
        'password'          =>  'required|min:8|regex:/^(?=\S*[a-z])(?=\S*[!@#$&*])(?=\S*[A-Z])(?=\S*[\d])\S*$/',
        'verify_password'   =>  'required|same:password',
    ];

    $messages = [
        'email.required'            => 'email tidak boleh kosong',
        'password.required'         => 'password tidak boleh kosong',
        'password.min'              => 'Password harus minimal 8 karakter',
        'password.regex'            => 'Format password harus terdiri dari kombinasi huruf besar, angka dan karakter spesial (contoh:!@#$%^&*?><).',
        'verify_password.required'  => 'Verify Password tidak boleh kosong',
        'email.email'               => 'Format Email tidak valid',
        'email.unique'              => 'Email yang anda masukkan telah digunakan',
        'verify_password.same'      => 'Password tidak sama!',
    ];

    $this->validate($request,$rules,$messages);

    $newUser = $this->user->create([
        'email'         =>  $request->email,
        'password'      =>  \Hash::make($request->password),
    ]);
    $this->activationService->sendActivationMail($newUser);

    return redirect('/account/login')->with('success', 'Check your email');
}

I'm new in laravel, i've read some similar problem to change password in stackoverflow but it didn't help me.

How should I write code in my controller for change password user?.
Thanks in Advance.

Body:
changePassword.blade.php

@extends('layouts.app')

@section('content')
    <!-- header logo: style can be found in header.less -->
    <header class="header">
        <div class="container">
            <div class="row">
                <div class="col-lg-6">
                <a href="index.php" class="logo">
                    <!-- Add the class icon to your logo image or logo icon to add the margining -->
                    <img src="img/airbus-logo.png" />
                </a></div>
                <!-- Header Navbar: style can be found in header.less -->
                <div class="col-lg-6">
                    @include('partials._userModal')
                    @include('partials._menu')
                </div>
            </div>
        </div>
    </header>
    <div class="wrapper">
        <div class="container">
            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="content files-list clearfix">
                <h2>
                @if(Auth::check())
                Welcome {{ Auth::user()->fullName }}
                @endif
                </h2>
                    <div class="col-xs-5">
                        <h4>Change password</h4><br />
                        @if($errors->any())
                            @foreach($errors->all() as $error)
                                <p style='padding:15px;' class='bg-danger'>{{ $error }}</p>
                            @endforeach
                        @endif
                        @if(Request::get('errorMessage') !== null)
                            <p style='padding:15px;' class='bg-danger'>{{ Request::get('errorMessage') }}</p>
                        @endif
                        <form method="post">
                            {{ csrf_field() }}
                           <div class="placeholder">Current Password</div>
                            <input style="max-width:200px;" placeholder='Current password' name="oldpass" id="oldpass"  class="form-control" type="password"><br>
                            <div class="placeholder">New password</div>
                            <input style="max-width:200px;" placeholder='New password' name="password" id="password"  class="form-control" type="password"><br>
                            <div class="placeholder">Confirm password</div>
                            <input id="password_confirmation" style="max-width:200px;" placeholder='Confirm password' name="password_confirmation"  class="form-control" type="password">
                            <hr>
                            <input type="submit" class="btn btn-primary" value="Save">
                        </form>
                    </div>
            </aside>
            <!-- /.right-side -->
        </div>
        <div style="  height: 155px;"></div>
        <div id="footer">
            <div class="container"> © Airbus Group 2015 </div>
        </div>
    </div>
    <!-- ./wrapper -->
    <!-- <script src="js/hub/demo.js" type="text/javascript"></script> -->
<script type="text/javascript">
    $(document).ready(function(){
        var bHeight = $("body").height();
        var wHeight = $( window ).height();
        if(bHeight < wHeight){
            $("#footer").addClass("absolute");
        }else{
            $("#footer").removeClass("absolute");
        }
        if (!$.support.htmlSerialize && !$.support.opacity){
            $(".placeholder").show();
        }
    });
</script>
@endsection

Controller Post Function

public function postChangePassword(Request $request)
    {
        $validatedData = $request->validate([
            'oldpass' => 'required|min:6',
            'password' => 'required|string|min:6',
            'password_confirmation' => 'required|same:password',
        ],[
            'oldpass.required' => 'Old password is required',
            'oldpass.min' => 'Old password needs to have at least 6 characters',
            'password.required' => 'Password is required',
            'password.min' => 'Password needs to have at least 6 characters',
            'password_confirmation.required' => 'Passwords do not match'
        ]);

        $current_password = \Auth::User()->password;
        if(\Hash::check($request->input('oldpass'), $current_password))
        {
          $user_id = \Auth::User()->id;
          $obj_user = User::find($user_id);
          $obj_user->password = \Hash::make($request->input('password'));
          $obj_user->save();
          return view('auth.passwords.changeConfirmation');
        }
        else
        {
          $data['errorMessage'] = 'Please enter correct current password';
          return redirect()->route('user.getChangePassword', $data);
        }
    }


问:
Outlook addin (AppointmentOrganizerCommandSurface): how can ItemId be got for an existing event/meeting?
We've recently enabled AppointmentOrganizerCommandSurface in our Outlook addin and noticed that it is always the Compose mode in which ItemId is not available, even when editing an existing appointment/meeting.

This sort of does not make sense for an existing appointment/meeting. Is there a way to get the ItemId?

Thank you

答:
The itemId property is not available in compose mode, which includes editing an existing appointment. If an item identifier is required, the saveAsync method can be used to save the item to the store, which will return the item identifier in the AsyncResult.value parameter in the callback function. (source)

However, saveAsync is currently not working as expected in Calendar. When calling Office.context.mailbox.item.saveAsync on a new Calendar item that has not been sent yet, the API will not save. We are aware of this issue and are looking into a solution to resolve this so that the API can be used as designed.

The API should behave as designed in Mail and on existing Calendar items. Note that for existing Calendar items, calling saveAsync will send out an update to attendees if the user or the add-in make changes in the compose form.


问:
Java heap is full but all regions are empty
I am trying to tune G1 GC. Application run for sometimes then heap gets full but it shows regions of Eden, survivor and old is 0 and the full GC get called to free up space.

Flags I used:
Xmx:30G -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+UseStringDeduplication -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled
-XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=12 -XX:ConcGCThreads=4

GC LOG:

```<code>    {Heap before GC invocations=629 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
2017-12-07T14:47:41.979+0000: [GC pause (G1 Evacuation Pause) (young)
Desired survivor size 100663296 bytes, new threshold 15 (max 15)
 18116.906: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 0, predicted base time: 48.13 ms, remaining time: 151.87 ms, target pause time: 200.00 ms]
 18116.906: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 0 regions, survivors: 0 regions, predicted young region time: 0.00 ms]
 18116.906: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 0 regions, survivors: 0 regions, old: 0 regions, predicted pause time: 48.13 ms, target pause time: 200.00 ms]
2017-12-07T14:47:41.981+0000: [SoftReference, 0 refs, 0.0004177 secs]2017-12-07T14:47:41.981+0000: [WeakReference, 0 refs, 0.0002174 secs]2017-12-07T14:47:41.981+0000: [FinalReference, 0 refs, 0.0003298 secs]2017-12-07T14:47:41.982+0000: [PhantomReference, 0 refs, 0 refs, 0.0004635 secs]2017-12-07T14:47:41.982+0000: [JNI Weak Reference, 0.0000152 secs], 0.0439856 secs]
   [Parallel Time: 1.4 ms, GC Workers: 12]
      [GC Worker Start (ms): Min: 18116906.3, Avg: 18116906.3, Max: 18116906.4, Diff: 0.1]
      [Ext Root Scanning (ms): Min: 0.5, Avg: 0.6, Max: 0.9, Diff: 0.4, Sum: 6.9]
      [Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
         [Processed Buffers: Min: 0, Avg: 0.1, Max: 1, Diff: 1, Sum: 1]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.4]
      [Termination (ms): Min: 0.0, Avg: 0.6, Max: 0.7, Diff: 0.7, Sum: 6.8]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 12]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 1.2, Avg: 1.2, Max: 1.3, Diff: 0.1, Sum: 15.0]
      [GC Worker End (ms): Min: 18116907.6, Avg: 18116907.6, Max: 18116907.6, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [String Dedup Fixup: 39.9 ms, GC Workers: 12]
      [Queue Fixup (ms): Min: 0.0, Avg: 11.3, Max: 18.1, Diff: 18.1, Sum: 135.1]
      [Table Fixup (ms): Min: 21.7, Avg: 27.8, Max: 35.2, Diff: 13.5, Sum: 333.3]
   [Clear CT: 0.1 ms]
   [Other: 2.5 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 1.6 ms]
      [Ref Enq: 0.1 ms]
      [Redirty Cards: 0.1 ms]
      [Humongous Register: 0.2 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.1 ms]
   [Eden: 0.0B(1536.0M)->0.0B(1536.0M) Survivors: 0.0B->0.0B Heap: 30.0G(30.0G)->30.0G(30.0G)]
Heap after GC invocations=630 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
}
 [Times: user=0.49 sys=0.01, real=0.05 secs]
{Heap before GC invocations=630 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
2017-12-07T14:47:42.024+0000: [GC pause (G1 Evacuation Pause) (young)
Desired survivor size 100663296 bytes, new threshold 15 (max 15)
 18116.952: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 0, predicted base time: 47.06 ms, remaining time: 152.94 ms, target pause time: 200.00 ms]
 18116.952: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 0 regions, survivors: 0 regions, predicted young region time: 0.00 ms]
 18116.952: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 0 regions, survivors: 0 regions, old: 0 regions, predicted pause time: 47.06 ms, target pause time: 200.00 ms]
2017-12-07T14:47:42.026+0000: [SoftReference, 0 refs, 0.0003988 secs]2017-12-07T14:47:42.027+0000: [WeakReference, 0 refs, 0.0003844 secs]2017-12-07T14:47:42.027+0000: [FinalReference, 0 refs, 0.0002286 secs]2017-12-07T14:47:42.027+0000: [PhantomReference, 0 refs, 0 refs, 0.0004361 secs]2017-12-07T14:47:42.028+0000: [JNI Weak Reference, 0.0000169 secs], 0.0433898 secs]
   [Parallel Time: 1.5 ms, GC Workers: 12]
      [GC Worker Start (ms): Min: 18116952.0, Avg: 18116952.1, Max: 18116952.1, Diff: 0.1]
      [Ext Root Scanning (ms): Min: 0.7, Avg: 0.8, Max: 0.9, Diff: 0.1, Sum: 9.5]
      [Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.2, Diff: 0.2, Sum: 0.2]
         [Processed Buffers: Min: 0, Avg: 0.1, Max: 1, Diff: 1, Sum: 1]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.5]
      [Termination (ms): Min: 0.0, Avg: 0.4, Max: 0.5, Diff: 0.5, Sum: 5.3]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 12]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 1.3, Avg: 1.3, Max: 1.4, Diff: 0.1, Sum: 16.1]
      [GC Worker End (ms): Min: 18116953.4, Avg: 18116953.4, Max: 18116953.4, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [String Dedup Fixup: 39.2 ms, GC Workers: 12]
      [Queue Fixup (ms): Min: 0.0, Avg: 11.4, Max: 15.4, Diff: 15.4, Sum: 136.9]
      [Table Fixup (ms): Min: 23.7, Avg: 27.7, Max: 39.1, Diff: 15.4, Sum: 332.3]
   [Clear CT: 0.1 ms]
   [Other: 2.5 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 1.6 ms]
      [Ref Enq: 0.1 ms]
      [Redirty Cards: 0.1 ms]
      [Humongous Register: 0.2 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.1 ms]
   [Eden: 0.0B(1536.0M)->0.0B(1536.0M) Survivors: 0.0B->0.0B Heap: 30.0G(30.0G)->30.0G(30.0G)]
Heap after GC invocations=631 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
}
 [Times: user=0.49 sys=0.00, real=0.04 secs]
 18116.996: [G1Ergonomics (Heap Sizing) attempt heap expansion, reason: allocation request failed, allocation request: 16 bytes]
 18116.997: [G1Ergonomics (Heap Sizing) expand the heap, requested expansion amount: 8388608 bytes, attempted expansion amount: 8388608 bytes]
 18116.997: [G1Ergonomics (Heap Sizing) did not expand the heap, reason: heap already fully expanded]
{Heap before GC invocations=631 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
2017-12-07T14:47:42.069+0000: [Full GC (Allocation Failure) 2017-12-07T14:48:06.386+0000: [SoftReference, 122 refs, 0.0001069 secs]2017-12-07T14:48:06.386+0000: [WeakReference, 22631 refs, 0.0079235 secs]2017-12-07T14:48:06.394+0000: [FinalReference, 395 refs, 0.0005771 secs]2017-12-07T14:48:06.394+0000: [PhantomReference, 0 refs, 0 refs, 0.0000163 secs]2017-12-07T14:48:06.394+0000: [JNI Weak Reference, 0.0000357 secs] 29G->14G(30G), 53.8180666 secs]
   [Eden: 0.0B(1536.0M)->0.0B(1536.0M) Survivors: 0.0B->0.0B Heap: 30.0G(30.0G)->14.4G(30.0G)], [Metaspace: 41962K->41951K(1087488K)]
Heap after GC invocations=632 (full 1):
 garbage-first heap   total 31457280K, used 15144510K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41951K, capacity 42406K, committed 42956K, reserved 1087488K
  class space    used 4587K, capacity 4746K, committed 4812K, reserved 1048576K
}
</code>```

Please help me to figure out the problem and how to avoid full GC.

答:
This is probably OpenJDK bug 8165150, meaning you are experiencing noop young gen collections before a Full GC. This is suboptimal, but as long as the full GC occurs and can free memory the JVM should recover.

You can avoid this problem by ensuring that there is enough free space in the heap, that your application does not leak and a that concurrent cycle is initiated before it fills up, e.g. by tuning the IHOP.

Your life set size after the Full GC is only 14GiB, so a an IHOP around 60% may help.

Body:
I am trying to tune G1 GC. Application run for sometimes then heap gets full but it shows regions of Eden, survivor and old is 0 and the full GC get called to free up space.

Flags I used:
Xmx:30G -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+UseStringDeduplication -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled
-XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=12 -XX:ConcGCThreads=4

GC LOG:

    {Heap before GC invocations=629 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
2017-12-07T14:47:41.979+0000: [GC pause (G1 Evacuation Pause) (young)
Desired survivor size 100663296 bytes, new threshold 15 (max 15)
 18116.906: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 0, predicted base time: 48.13 ms, remaining time: 151.87 ms, target pause time: 200.00 ms]
 18116.906: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 0 regions, survivors: 0 regions, predicted young region time: 0.00 ms]
 18116.906: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 0 regions, survivors: 0 regions, old: 0 regions, predicted pause time: 48.13 ms, target pause time: 200.00 ms]
2017-12-07T14:47:41.981+0000: [SoftReference, 0 refs, 0.0004177 secs]2017-12-07T14:47:41.981+0000: [WeakReference, 0 refs, 0.0002174 secs]2017-12-07T14:47:41.981+0000: [FinalReference, 0 refs, 0.0003298 secs]2017-12-07T14:47:41.982+0000: [PhantomReference, 0 refs, 0 refs, 0.0004635 secs]2017-12-07T14:47:41.982+0000: [JNI Weak Reference, 0.0000152 secs], 0.0439856 secs]
   [Parallel Time: 1.4 ms, GC Workers: 12]
      [GC Worker Start (ms): Min: 18116906.3, Avg: 18116906.3, Max: 18116906.4, Diff: 0.1]
      [Ext Root Scanning (ms): Min: 0.5, Avg: 0.6, Max: 0.9, Diff: 0.4, Sum: 6.9]
      [Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
         [Processed Buffers: Min: 0, Avg: 0.1, Max: 1, Diff: 1, Sum: 1]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.4]
      [Termination (ms): Min: 0.0, Avg: 0.6, Max: 0.7, Diff: 0.7, Sum: 6.8]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 12]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 1.2, Avg: 1.2, Max: 1.3, Diff: 0.1, Sum: 15.0]
      [GC Worker End (ms): Min: 18116907.6, Avg: 18116907.6, Max: 18116907.6, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [String Dedup Fixup: 39.9 ms, GC Workers: 12]
      [Queue Fixup (ms): Min: 0.0, Avg: 11.3, Max: 18.1, Diff: 18.1, Sum: 135.1]
      [Table Fixup (ms): Min: 21.7, Avg: 27.8, Max: 35.2, Diff: 13.5, Sum: 333.3]
   [Clear CT: 0.1 ms]
   [Other: 2.5 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 1.6 ms]
      [Ref Enq: 0.1 ms]
      [Redirty Cards: 0.1 ms]
      [Humongous Register: 0.2 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.1 ms]
   [Eden: 0.0B(1536.0M)->0.0B(1536.0M) Survivors: 0.0B->0.0B Heap: 30.0G(30.0G)->30.0G(30.0G)]
Heap after GC invocations=630 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
}
 [Times: user=0.49 sys=0.01, real=0.05 secs]
{Heap before GC invocations=630 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
2017-12-07T14:47:42.024+0000: [GC pause (G1 Evacuation Pause) (young)
Desired survivor size 100663296 bytes, new threshold 15 (max 15)
 18116.952: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 0, predicted base time: 47.06 ms, remaining time: 152.94 ms, target pause time: 200.00 ms]
 18116.952: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 0 regions, survivors: 0 regions, predicted young region time: 0.00 ms]
 18116.952: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 0 regions, survivors: 0 regions, old: 0 regions, predicted pause time: 47.06 ms, target pause time: 200.00 ms]
2017-12-07T14:47:42.026+0000: [SoftReference, 0 refs, 0.0003988 secs]2017-12-07T14:47:42.027+0000: [WeakReference, 0 refs, 0.0003844 secs]2017-12-07T14:47:42.027+0000: [FinalReference, 0 refs, 0.0002286 secs]2017-12-07T14:47:42.027+0000: [PhantomReference, 0 refs, 0 refs, 0.0004361 secs]2017-12-07T14:47:42.028+0000: [JNI Weak Reference, 0.0000169 secs], 0.0433898 secs]
   [Parallel Time: 1.5 ms, GC Workers: 12]
      [GC Worker Start (ms): Min: 18116952.0, Avg: 18116952.1, Max: 18116952.1, Diff: 0.1]
      [Ext Root Scanning (ms): Min: 0.7, Avg: 0.8, Max: 0.9, Diff: 0.1, Sum: 9.5]
      [Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.2, Diff: 0.2, Sum: 0.2]
         [Processed Buffers: Min: 0, Avg: 0.1, Max: 1, Diff: 1, Sum: 1]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.5]
      [Termination (ms): Min: 0.0, Avg: 0.4, Max: 0.5, Diff: 0.5, Sum: 5.3]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 12]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 1.3, Avg: 1.3, Max: 1.4, Diff: 0.1, Sum: 16.1]
      [GC Worker End (ms): Min: 18116953.4, Avg: 18116953.4, Max: 18116953.4, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [String Dedup Fixup: 39.2 ms, GC Workers: 12]
      [Queue Fixup (ms): Min: 0.0, Avg: 11.4, Max: 15.4, Diff: 15.4, Sum: 136.9]
      [Table Fixup (ms): Min: 23.7, Avg: 27.7, Max: 39.1, Diff: 15.4, Sum: 332.3]
   [Clear CT: 0.1 ms]
   [Other: 2.5 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 1.6 ms]
      [Ref Enq: 0.1 ms]
      [Redirty Cards: 0.1 ms]
      [Humongous Register: 0.2 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.1 ms]
   [Eden: 0.0B(1536.0M)->0.0B(1536.0M) Survivors: 0.0B->0.0B Heap: 30.0G(30.0G)->30.0G(30.0G)]
Heap after GC invocations=631 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
}
 [Times: user=0.49 sys=0.00, real=0.04 secs]
 18116.996: [G1Ergonomics (Heap Sizing) attempt heap expansion, reason: allocation request failed, allocation request: 16 bytes]
 18116.997: [G1Ergonomics (Heap Sizing) expand the heap, requested expansion amount: 8388608 bytes, attempted expansion amount: 8388608 bytes]
 18116.997: [G1Ergonomics (Heap Sizing) did not expand the heap, reason: heap already fully expanded]
{Heap before GC invocations=631 (full 0):
 garbage-first heap   total 31457280K, used 31434556K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41962K, capacity 42424K, committed 42956K, reserved 1087488K
  class space    used 4589K, capacity 4749K, committed 4812K, reserved 1048576K
2017-12-07T14:47:42.069+0000: [Full GC (Allocation Failure) 2017-12-07T14:48:06.386+0000: [SoftReference, 122 refs, 0.0001069 secs]2017-12-07T14:48:06.386+0000: [WeakReference, 22631 refs, 0.0079235 secs]2017-12-07T14:48:06.394+0000: [FinalReference, 395 refs, 0.0005771 secs]2017-12-07T14:48:06.394+0000: [PhantomReference, 0 refs, 0 refs, 0.0000163 secs]2017-12-07T14:48:06.394+0000: [JNI Weak Reference, 0.0000357 secs] 29G->14G(30G), 53.8180666 secs]
   [Eden: 0.0B(1536.0M)->0.0B(1536.0M) Survivors: 0.0B->0.0B Heap: 30.0G(30.0G)->14.4G(30.0G)], [Metaspace: 41962K->41951K(1087488K)]
Heap after GC invocations=632 (full 1):
 garbage-first heap   total 31457280K, used 15144510K [0x0000000080000000, 0x0000000080807800, 0x0000000800000000)
  region size 8192K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 41951K, capacity 42406K, committed 42956K, reserved 1087488K
  class space    used 4587K, capacity 4746K, committed 4812K, reserved 1048576K
}

Please help me to figure out the problem and how to avoid full GC.


问:
How to have different value between model and input box (Angular 5)
I have an application in Angular 5, and I need to have an input formatted with thousand separators (space), but my model is a number and don't allow spaces (number expected).

My application is already developped and I don't want to change all typescript, I only want to create a directive or pipe.

Example like i want :

Is it possible to have a different model of Input box ?

Version :

Angular5

Steven

答:
you can create an loval variable and bind to your input. then in change event of input box cast variable to your model.

if this is helpfull tell me.


问:
GNSDK for Android crashing on x86 AVD
The GNSDK for Android sample application crashes over signal 4 (SIGILL), code 2 (ILL_ILLOPN) when run on an x86 AVD.  I tried both a Nexus 5 AVD and a Pixel XL AVD at API levels 22 and 25, and the same SIGILL crash occurs on both as soon as the sample app tries to engage the native GNSDK libraries in onCreate().  It looks like libgnsdk_storage_sqlite.3.12.1.so in particular may be the culprit, judging from the backtrace.  The same crash occurs in my own application when I engage the GNSDK native libs for x86, so the problem is not unique to the sample app.  What could be causing this?

I've confirmed that the sample app works on arm hardware and an arm AVD.  I don't have any x86 hardware, so I can't confirm whether this is truly an x86 ABI issue or some oddment with AVDs vs. real hardware.

```<code>    --------- beginning of crash
11-17 14:07:43.446 3019-3043/? A/libc: Fatal signal 4 (SIGILL), code 2, fault addr 0xa2e70276 in tid 3043 (Thread-174)
11-17 14:07:43.450 3019-3047/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-17 14:07:43.450 1184-3049/? I/AudioFlinger: AudioFlinger's thread 0xb551b000 ready to run

                                               [ 11-17 14:07:43.451  3019: 3019 D/         ]
                                               HostConnection::get() New Host Connection established 0xb43fc600, tid 3019

                                               [ 11-17 14:07:43.452  3019: 3019 W/         ]
                                               Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1
11-17 14:07:43.452 3019-3019/? D/Atlas: Validating map...
11-17 14:07:43.453 1550-2750/system_process V/WindowManager: Adding window Window{3e690683 u0 com.customer.example/com.customer.example.GracenoteMusicID} at 2 of 8 (before Window{2bf1a8da u0 Starting com.customer.example})

                                                             [ 11-17 14:07:43.475  3019: 3047 D/         ]
                                                             HostConnection::get() New Host Connection established 0xae90f380, tid 3047

                                                             [ 11-17 14:07:43.476  3019: 3047 W/         ]
                                                             Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1
11-17 14:07:43.478 3019-3047/? I/OpenGLRenderer: Initialized EGL, version 1.4
11-17 14:07:43.481 3019-3047/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
11-17 14:07:43.544 3019-3047/? D/EGL_emulation: eglCreateContext: 0xae90e460: maj 2 min 0 rcv 2
11-17 14:07:43.546 1178-1178/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-17 14:07:43.546 1178-1178/? I/DEBUG: Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:5.1.1/LMY48X/4409265:userdebug/test-keys'
11-17 14:07:43.546 1178-1178/? I/DEBUG: Revision: '0'
11-17 14:07:43.546 1178-1178/? I/DEBUG: ABI: 'x86'
11-17 14:07:43.547 1178-1178/? I/DEBUG: pid: 3019, tid: 3043, name: Thread-174  >>> com.customer.example <<<
11-17 14:07:43.547 1178-1178/? I/DEBUG: signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0xa2e70276
11-17 14:07:43.551 1178-1178/? I/DEBUG:     eax a40519ec  ebx a2ef3e2c  ecx a4051e34  edx 00000000
11-17 14:07:43.552 1178-1178/? I/DEBUG:     esi b438684c  edi b437866c
11-17 14:07:43.552 1178-1178/? I/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000077  xss 0000007b
11-17 14:07:43.552 1178-1178/? I/DEBUG:     eip a2e70276  ebp 00000000  esp a2c67f70  flags 00210246
11-17 14:07:43.552 1178-1178/? I/DEBUG: backtrace:
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #00 pc 00058276  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #01 pc 000816de  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #02 pc 0008189f  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #03 pc 00081952  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #04 pc 0008babb  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #05 pc 0008da49  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #06 pc 00093842  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #07 pc 00093f93  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #08 pc 0009465d  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #09 pc 00080df4  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so (sqlite3_exec+164)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #10 pc 00015567  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #11 pc 00015f65  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so (_sqlite_storage_connection_get+485)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #12 pc 0000f9d3  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so (_sqlite_storage_provider_storage_open+483)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #13 pc 0010627d  /data/app/com.customer.example-2/lib/x86/libgnsdk_manager.3.12.1.so (_sdkmgr_storage_open+365)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #14 pc 0001ce56  /data/app/com.customer.example-2/lib/x86/libgnsdk_lookup_localstream.3.12.1.so (localstream2_storage_gdb_create+870)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #15 pc 0001a7d9  /data/app/com.customer.example-2/lib/x86/libgnsdk_lookup_localstream.3.12.1.so (localstream2_storage_create+233)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #16 pc 00011a7e  /data/app/com.customer.example-2/lib/x86/libgnsdk_lookup_localstream.3.12.1.so (gnsdk_lookup_localstream_ingest_create+414)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #17 pc 0004bb52  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (gnsdk_lookup_localstream_ingest_create+146)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #18 pc 0005cdc4  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (gracenote::lookup_localstream::GnLookupLocalStreamIngest::create()+68)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #19 pc 0005d015  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (gracenote::lookup_localstream::GnLookupLocalStreamIngest::GnLookupLocalStreamIngest(gracenote::lookup_localstream::IGnLookupLocalStreamIngestEvents*)+101)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #20 pc 000bb2a2  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (Java_com_gracenote_gnsdk_gnsdk_1javaJNI_new_1GnLookupLocalStreamIngest+82)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #21 pc 00052bd2  /data/dalvik-cache/x86/data@app@com.customer.example-2@base.apk@classes.dex
11-17 14:07:43.614 1184-3049/? W/AudioFlinger: RecordThread: buffer overflow
11-17 14:07:43.670 1178-1178/? I/DEBUG: Tombstone written to: /data/tombstones/tombstone_03
11-17 14:07:43.670 1550-1574/system_process I/BootReceiver: Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)
11-17 14:07:43.675 1550-1603/system_process W/InputDispatcher: channel '3e690683 com.customer.example/com.customer.example.GracenoteMusicID (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
11-17 14:07:43.675 1550-1603/system_process E/InputDispatcher: channel '3e690683 com.customer.example/com.customer.example.GracenoteMusicID (server)' ~ Channel is unrecoverably broken and will be disposed!
11-17 14:07:43.675 1187-1187/? I/Zygote: Process 3019 exited due to signal (4)
11-17 14:07:43.689 1550-2746/system_process I/WindowState: WIN DEATH: Window{3e690683 u0 com.customer.example/com.customer.example.GracenoteMusicID}
</code>```

答:
not a good answer perhaps, but if you comment the calls to

```<code>GnStorageSqlite.enable();
GnLookupLocalStream.enable();
</code>```

which the sample app makes, the crash goes away and online lookup still works.  I guess these calls must engage native libraries that have some incompatibility with x86.

Title: GNSDK for Android crashing on x86 AVD

Body:
The GNSDK for Android sample application crashes over signal 4 (SIGILL), code 2 (ILL_ILLOPN) when run on an x86 AVD.  I tried both a Nexus 5 AVD and a Pixel XL AVD at API levels 22 and 25, and the same SIGILL crash occurs on both as soon as the sample app tries to engage the native GNSDK libraries in onCreate().  It looks like libgnsdk_storage_sqlite.3.12.1.so in particular may be the culprit, judging from the backtrace.  The same crash occurs in my own application when I engage the GNSDK native libs for x86, so the problem is not unique to the sample app.  What could be causing this?

I've confirmed that the sample app works on arm hardware and an arm AVD.  I don't have any x86 hardware, so I can't confirm whether this is truly an x86 ABI issue or some oddment with AVDs vs. real hardware.

    --------- beginning of crash
11-17 14:07:43.446 3019-3043/? A/libc: Fatal signal 4 (SIGILL), code 2, fault addr 0xa2e70276 in tid 3043 (Thread-174)
11-17 14:07:43.450 3019-3047/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-17 14:07:43.450 1184-3049/? I/AudioFlinger: AudioFlinger's thread 0xb551b000 ready to run

                                               [ 11-17 14:07:43.451  3019: 3019 D/         ]
                                               HostConnection::get() New Host Connection established 0xb43fc600, tid 3019

                                               [ 11-17 14:07:43.452  3019: 3019 W/         ]
                                               Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1
11-17 14:07:43.452 3019-3019/? D/Atlas: Validating map...
11-17 14:07:43.453 1550-2750/system_process V/WindowManager: Adding window Window{3e690683 u0 com.customer.example/com.customer.example.GracenoteMusicID} at 2 of 8 (before Window{2bf1a8da u0 Starting com.customer.example})

                                                             [ 11-17 14:07:43.475  3019: 3047 D/         ]
                                                             HostConnection::get() New Host Connection established 0xae90f380, tid 3047

                                                             [ 11-17 14:07:43.476  3019: 3047 W/         ]
                                                             Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1
11-17 14:07:43.478 3019-3047/? I/OpenGLRenderer: Initialized EGL, version 1.4
11-17 14:07:43.481 3019-3047/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
11-17 14:07:43.544 3019-3047/? D/EGL_emulation: eglCreateContext: 0xae90e460: maj 2 min 0 rcv 2
11-17 14:07:43.546 1178-1178/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-17 14:07:43.546 1178-1178/? I/DEBUG: Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:5.1.1/LMY48X/4409265:userdebug/test-keys'
11-17 14:07:43.546 1178-1178/? I/DEBUG: Revision: '0'
11-17 14:07:43.546 1178-1178/? I/DEBUG: ABI: 'x86'
11-17 14:07:43.547 1178-1178/? I/DEBUG: pid: 3019, tid: 3043, name: Thread-174  >>> com.customer.example <<<
11-17 14:07:43.547 1178-1178/? I/DEBUG: signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0xa2e70276
11-17 14:07:43.551 1178-1178/? I/DEBUG:     eax a40519ec  ebx a2ef3e2c  ecx a4051e34  edx 00000000
11-17 14:07:43.552 1178-1178/? I/DEBUG:     esi b438684c  edi b437866c
11-17 14:07:43.552 1178-1178/? I/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000077  xss 0000007b
11-17 14:07:43.552 1178-1178/? I/DEBUG:     eip a2e70276  ebp 00000000  esp a2c67f70  flags 00210246
11-17 14:07:43.552 1178-1178/? I/DEBUG: backtrace:
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #00 pc 00058276  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #01 pc 000816de  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #02 pc 0008189f  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #03 pc 00081952  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #04 pc 0008babb  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #05 pc 0008da49  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #06 pc 00093842  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #07 pc 00093f93  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #08 pc 0009465d  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #09 pc 00080df4  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so (sqlite3_exec+164)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #10 pc 00015567  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #11 pc 00015f65  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so (_sqlite_storage_connection_get+485)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #12 pc 0000f9d3  /data/app/com.customer.example-2/lib/x86/libgnsdk_storage_sqlite.3.12.1.so (_sqlite_storage_provider_storage_open+483)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #13 pc 0010627d  /data/app/com.customer.example-2/lib/x86/libgnsdk_manager.3.12.1.so (_sdkmgr_storage_open+365)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #14 pc 0001ce56  /data/app/com.customer.example-2/lib/x86/libgnsdk_lookup_localstream.3.12.1.so (localstream2_storage_gdb_create+870)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #15 pc 0001a7d9  /data/app/com.customer.example-2/lib/x86/libgnsdk_lookup_localstream.3.12.1.so (localstream2_storage_create+233)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #16 pc 00011a7e  /data/app/com.customer.example-2/lib/x86/libgnsdk_lookup_localstream.3.12.1.so (gnsdk_lookup_localstream_ingest_create+414)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #17 pc 0004bb52  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (gnsdk_lookup_localstream_ingest_create+146)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #18 pc 0005cdc4  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (gracenote::lookup_localstream::GnLookupLocalStreamIngest::create()+68)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #19 pc 0005d015  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (gracenote::lookup_localstream::GnLookupLocalStreamIngest::GnLookupLocalStreamIngest(gracenote::lookup_localstream::IGnLookupLocalStreamIngestEvents*)+101)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #20 pc 000bb2a2  /data/app/com.customer.example-2/lib/x86/libgnsdk_java_marshal.1.3.1.so (Java_com_gracenote_gnsdk_gnsdk_1javaJNI_new_1GnLookupLocalStreamIngest+82)
11-17 14:07:43.552 1178-1178/? I/DEBUG:     #21 pc 00052bd2  /data/dalvik-cache/x86/data@app@com.customer.example-2@base.apk@classes.dex
11-17 14:07:43.614 1184-3049/? W/AudioFlinger: RecordThread: buffer overflow
11-17 14:07:43.670 1178-1178/? I/DEBUG: Tombstone written to: /data/tombstones/tombstone_03
11-17 14:07:43.670 1550-1574/system_process I/BootReceiver: Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)
11-17 14:07:43.675 1550-1603/system_process W/InputDispatcher: channel '3e690683 com.customer.example/com.customer.example.GracenoteMusicID (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
11-17 14:07:43.675 1550-1603/system_process E/InputDispatcher: channel '3e690683 com.customer.example/com.customer.example.GracenoteMusicID (server)' ~ Channel is unrecoverably broken and will be disposed!
11-17 14:07:43.675 1187-1187/? I/Zygote: Process 3019 exited due to signal (4)
11-17 14:07:43.689 1550-2746/system_process I/WindowState: WIN DEATH: Window{3e690683 u0 com.customer.example/com.customer.example.GracenoteMusicID}

Body:
not a good answer perhaps, but if you comment the calls to

GnStorageSqlite.enable();
GnLookupLocalStream.enable();

which the sample app makes, the crash goes away and online lookup still works.  I guess these calls must engage native libraries that have some incompatibility with x86.