问:
how to pass variables inside a <href> tag in the google map's infoWindow
The sample_id shows in the infoWidow but how can it be passed inside the href tag?</p>

```<code>(function (marker, sample) {
    google.maps.event.addListener(marker, "mouseover", function (e) {
    infoWindow.setContent(sample.id+ ' - ' + sample.name + '</br>' +
    '<a href="SampleDetail.aspx?sample_id="'+ sample.id + '> Detail...</a>' );
    infoWindow.open(map, marker);
    });
})(marker, sample);
</code>```

答:
You have problem with mismatched string quotes:

```<code> infoWindow.setContent(sample.id+ ' - ' + sample.name + '</br>' +
'<a href="SampleDetail.aspx?sample_id="'+ sample.id + '> Detail...</a>' );
                                      ^
                                      |
                                     this
infoWindow.setContent(sample.id+ ' - ' + sample.name + '</br>' +
'<a href="SampleDetail.aspx?sample_id='+ sample.id + '"> Detail...</a>' );
                                                      ^
                                                      |
                                         should be here
</code>```

This works:

```<code>(function(marker, sample) {
    google.maps.event.addListener(marker, "mouseover", function(e) {
      infoWindow.setContent(sample.id + ' - ' + sample.name + '</br>' +
        '<a href="SampleDetail.aspx?sample_id=' + sample.id + '"> Detail...</a>');
      infoWindow.open(map, marker);
    });
  })(marker, sample);
</code>```

proof of concept fiddle

code snippet:

function initialize() {
  var map = new google.maps.Map(
    document.getElementById("map_canvas"), {
      center: new google.maps.LatLng(37.4419, -122.1419),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var infoWindow = new google.maps.InfoWindow();
  var marker = new google.maps.Marker({
    position: map.getCenter(),
    map: map
  });
  var sample = {
    id: 5,
    name: "frank"
  };
  (function(marker, sample) {
    google.maps.event.addListener(marker, "mouseover", function(e) {
      infoWindow.setContent(sample.id + ' - ' + sample.name + '
' +
        ' Detail...');
      infoWindow.open(map, marker);
    });
  })(marker, sample);
}
google.maps.event.addDomListener(window, "load", initialize);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>html,
body,
#map_canvas {
  height: 100%;
  width: 100%;
  margin: 0px;
  padding: 0px
}</code>```

```

Body:
The sample_id shows in the infoWidow but how can it be passed inside the href tag?

(function (marker, sample) {
    google.maps.event.addListener(marker, "mouseover", function (e) {
    infoWindow.setContent(sample.id+ ' - ' + sample.name + '
' +
    ' Detail...' );
    infoWindow.open(map, marker);
    });
})(marker, sample);

Body:
You have problem with mismatched string quotes:

 infoWindow.setContent(sample.id+ ' - ' + sample.name + '</br>' +
'<a href="SampleDetail.aspx?sample_id="'+ sample.id + '> Detail...</a>' );
                                      ^
                                      |
                                     this
infoWindow.setContent(sample.id+ ' - ' + sample.name + '</br>' +
'<a href="SampleDetail.aspx?sample_id='+ sample.id + '"> Detail...</a>' );
                                                      ^
                                                      |
                                         should be here

This works:

(function(marker, sample) {
    google.maps.event.addListener(marker, "mouseover", function(e) {
      infoWindow.setContent(sample.id + ' - ' + sample.name + '</br>' +
        '<a href="SampleDetail.aspx?sample_id=' + sample.id + '"> Detail...</a>');
      infoWindow.open(map, marker);
    });
  })(marker, sample);

proof of concept fiddle

code snippet:

function initialize() {
  var map = new google.maps.Map(
    document.getElementById("map_canvas"), {
      center: new google.maps.LatLng(37.4419, -122.1419),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var infoWindow = new google.maps.InfoWindow();
  var marker = new google.maps.Marker({
    position: map.getCenter(),
    map: map
  });
  var sample = {
    id: 5,
    name: "frank"
  };
  (function(marker, sample) {
    google.maps.event.addListener(marker, "mouseover", function(e) {
      infoWindow.setContent(sample.id + ' - ' + sample.name + '</br>' +
        '<a href="SampleDetail.aspx?sample_id=' + sample.id + '"> Detail...</a>');
      infoWindow.open(map, marker);
    });
  })(marker, sample);
}
google.maps.event.addDomListener(window, "load", initialize);

html,
body,
#map_canvas {
  height: 100%;
  width: 100%;
  margin: 0px;
  padding: 0px
}

<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map_canvas"></div>


来源: stackexchange

问:
Is there an ARM template solution for binding a Logic App to an OMS workspace?
As of this moment the Logic app connector for OMS is in preview, so I may just be too early with this inquiry. I'm looking to deploy a number of Logic Apps and would like to configure all of them to pump analytics into the same OMS workspace which our operations team will be monitoring.

I found a great script to link resources in an Azure subscription to an OMS workspace, but I was hoping to find a way to accomplish this using an ARM template. Binding a logic app to a workspace doesn't impact the generated 'Automation Script' for the resource group in the portal.

Is anyone in the know?

答:
The following template is a good basis for getting started
https://gallery.azure.com/artifact/20161101/Microsoft.EmptyWorkflow.1.0.9/DeploymentTemplates/LogicApp_ConsumptionPlan_OmsWorkspaceWithSolution.json

(This template is used by the create resource blade in the Azure portal)

ContentLicense: CC BY-SA 3.0


问:
How to log application crash and system crash using nodejs and express?
I am very happy with logging using npm module morgan but not sure how to log system crash or system shutdown in node application. Is it possible? Please guide.

Thanks

答:
You can use the Process API to watch for uncaught exceptions.

process
  .on('unhandledRejection', (reason, p) => {
    // Use your own logger here
    console.error(reason, 'Unhandled Rejection at Promise', p);
  })
  .on('uncaughtException', err => {
    // Use your own logger here
    console.error(err, 'Uncaught Exception thrown');

    // Optional: Ensure process will stop after this
    process.exit(1);
  });
```

For a detailed explanation check this answer to a similar question here on Stack Overflow. There's also this great blog post:  https://shapeshed.com/uncaught-exceptions-in-node/.

As an extra, check this other one to send emails with the crash information: https://coderwall.com/p/4yis4w/node-js-uncaught-exceptions

Body:
You can use the Process API to watch for uncaught exceptions.

process
  .on('unhandledRejection', (reason, p) => {
    // Use your own logger here
    console.error(reason, 'Unhandled Rejection at Promise', p);
  })
  .on('uncaughtException', err => {
    // Use your own logger here
    console.error(err, 'Uncaught Exception thrown');

    // Optional: Ensure process will stop after this
    process.exit(1);
  });

For a detailed explanation check this answer to a similar question here on Stack Overflow. There's also this great blog post:  https://shapeshed.com/uncaught-exceptions-in-node/.

As an extra, check this other one to send emails with the crash information: https://coderwall.com/p/4yis4w/node-js-uncaught-exceptions


问:
whether pandas.decribe() excludes missing value rows?
pandas.describe() function generate descriptive statistics that summarize the dataset, excluding NaN values. But does the exclusion here means that the total count (i.e., rows of a variable) vary or fixed?

For example, I calculate the mean by using describe() for a df with missing values:

```<code>varA
 1
 1
 1
 1
 NaN
</code>```

Is the mean = 4/5 or 4/4 here?

And how does it apply to other results in describe? For example, the standard deviation, quartiles?

Thanks!

答:
As ayhan pointed out, in the current 0.21 release NaN values are excluded from all summary statistics provided by pandas.DataFrame.describe().

With NaN:

```<code>data_with_nan = list(range(20)) + [np.NaN]*20
df = pd.DataFrame(data=data_with_nan, columns=['col1'])
df.describe()
</code>```

```
           col1
count  20.00000
mean    9.50000
std     5.91608
min     0.00000
25%     4.75000
50%     9.50000
75%    14.25000
max    19.00000```

Without:

```<code>data_without_nan = list(range(20))
df = pd.DataFrame(data=data_without_nan, columns=['col1'])
df.describe()
</code>```

```
           col1
count  20.00000
mean    9.50000
std     5.91608
min     0.00000
25%     4.75000
50%     9.50000
75%    14.25000
max    19.00000```

Body:
pandas.describe() function generate descriptive statistics that summarize the dataset, excluding NaN values. But does the exclusion here means that the total count (i.e., rows of a variable) vary or fixed?

For example, I calculate the mean by using describe() for a df with missing values:

varA
 1
 1
 1
 1
 NaN

Is the mean = 4/5 or 4/4 here?

And how does it apply to other results in describe? For example, the standard deviation, quartiles?

Thanks!

Body:
As ayhan pointed out, in the current 0.21 release NaN values are excluded from all summary statistics provided by pandas.DataFrame.describe().

With NaN:

data_with_nan = list(range(20)) + [np.NaN]*20
df = pd.DataFrame(data=data_with_nan, columns=['col1'])
df.describe()

           col1
count  20.00000
mean    9.50000
std     5.91608
min     0.00000
25%     4.75000
50%     9.50000
75%    14.25000
max    19.00000

Without:

data_without_nan = list(range(20))
df = pd.DataFrame(data=data_without_nan, columns=['col1'])
df.describe()

           col1
count  20.00000
mean    9.50000
std     5.91608
min     0.00000
25%     4.75000
50%     9.50000
75%    14.25000
max    19.00000


问:
why taking too long time to insert rows in a mysql table even after using multithreading when table has some relationship
I wanted to insert 200000 rows into a table through JDBC mysql connection.My table has three columns DISTRICT1(Id,Name,country).I used multi-threads to perform insert operation ,and it inserted data in less than 1 minutes.Then again I tried to perform similar operation on DISTRICT2(Id,Name,country) table ,in this case it is taking very very long time (more than 2hours) to insert rows (just like it does with single thread).The only difference between the tow tables is that DISTRICT2 table has a  field Id which is linked to other tables through foreign-key-relationship while DISTRICT1 table has no such relationship.Also the other difference is of mysql engine ,DISTRICT1  has ENGINE=MyISAM while it is ENGINE=INNODB for DISTRICT2
Also it gave java.lang.OutOfMemoryError when I used PreparedStatement instead of Statement .Does it has some relation with connection pooling?

Please tell why does it take so long time when table has some relationship?I used same program code to insert both the tables.I used following code to do so:

```<code>public static void main(String[] args) {
  ExecutorService executor = Executors.newFixedThreadPool(10);
  for (int i = 1; i <200001; i=i+10000) {
      Runnable worker = new MyRunnable4District(i);
          executor.execute(worker);
      }
  executor.shutdown();
 }
</code>```

the class MyRunnable4District is shown below

```<code>public class MyRunnable4District implements Runnable {
 public int size;

 public MyRunnable4District(int n) {
  this.size = n;
 }

 public void run() {
  Connection con = null;
  try {

   Class.forName("com.mysql.jdbc.Driver");
   con = DriverManager.getConnection("jdbc:mysql://localhost/project",
     "root", "root");

   String[] countries = { "ARGENTINA", "US", "UK", "INDIA", "UKRAINE",
     "CHINA" };

   for (int id = size; id < size + 10001; id++) {
    int districtId = id;
    String districtName ="columbia"+id;
    String districtCountry = countries[id % 6];
    String query="INSERT INTO district "+"VALUES ("+districtId+",'"+districtName+"','"+districtCountry+"')";
    //PreparedStatement stmnt =con.prepareStatement(query);
    Statement stmnt =con.createStatement();
    stmnt.executeUpdate(query);
   }

  } catch (ClassNotFoundException e) {
   System.out.println(e.getMessage());
  } catch (SQLException e) {
   System.out.println(e.getMessage());
  } finally {
   try {
    con.close();
    System.out.println("thread number with size "+size+" completed");
   } catch (SQLException e) {
    e.printStackTrace();
   }

  }

 }
}
</code>```

答:
You should try multi-value inserts. For example:

```<code>INSERT INTO district VALUES (id1,name1,country1),(id2,name2,country2),(id3,name3,country3);
</code>```

This can provide a significant performance boost, especially if you need to do this when connecting to a remote server. In addition to reducing network roundtrips (or even out of process calls on a local machine), the server will have to process fewer queries. Also, if you leave auto commit enabled for InnoDB, you will now have one transaction per batch instead of one per statement.

The Connector/J JDBC driver will do this for you if you set the rewriteBatchedStatements option true. I think this feature was added in a 3.1.x driver release for simple INSERTs like yours. In later versions, rewriteBatchedStatements has been enhanced to support more complex statements. Search on this page for rewriteBatchedStatements.

Or you can rewrite your code to manually construct multi-value insert statements. One thing to watch out for is the maximum packet size. You need to make sure the insert statement stays below that. So, either make max_allowed_packet very large while importing the data or break up your batches as they get close to max_allowed_packet.

ContentLicense: CC BY-SA 2.5

Body:
I wanted to insert 200000 rows into a table through JDBC mysql connection.My table has three columns DISTRICT1(Id,Name,country).I used multi-threads to perform insert operation ,and it inserted data in less than 1 minutes.Then again I tried to perform similar operation on DISTRICT2(Id,Name,country) table ,in this case it is taking very very long time (more than 2hours) to insert rows (just like it does with single thread).The only difference between the tow tables is that DISTRICT2 table has a  field Id which is linked to other tables through foreign-key-relationship while DISTRICT1 table has no such relationship.Also the other difference is of mysql engine ,DISTRICT1  has ENGINE=MyISAM while it is ENGINE=INNODB for DISTRICT2
Also it gave java.lang.OutOfMemoryError when I used PreparedStatement instead of Statement .Does it has some relation with connection pooling?

Please tell why does it take so long time when table has some relationship?I used same program code to insert both the tables.I used following code to do so:

public static void main(String[] args) {
  ExecutorService executor = Executors.newFixedThreadPool(10);
  for (int i = 1; i <200001; i=i+10000) {
      Runnable worker = new MyRunnable4District(i);
          executor.execute(worker);
      }
  executor.shutdown();
 }

the class MyRunnable4District is shown below

public class MyRunnable4District implements Runnable {
 public int size;

 public MyRunnable4District(int n) {
  this.size = n;
 }

 public void run() {
  Connection con = null;
  try {

   Class.forName("com.mysql.jdbc.Driver");
   con = DriverManager.getConnection("jdbc:mysql://localhost/project",
     "root", "root");

   String[] countries = { "ARGENTINA", "US", "UK", "INDIA", "UKRAINE",
     "CHINA" };

   for (int id = size; id < size + 10001; id++) {
    int districtId = id;
    String districtName ="columbia"+id;
    String districtCountry = countries[id % 6];
    String query="INSERT INTO district "+"VALUES ("+districtId+",'"+districtName+"','"+districtCountry+"')";
    //PreparedStatement stmnt =con.prepareStatement(query);
    Statement stmnt =con.createStatement();
    stmnt.executeUpdate(query);
   }

  } catch (ClassNotFoundException e) {
   System.out.println(e.getMessage());
  } catch (SQLException e) {
   System.out.println(e.getMessage());
  } finally {
   try {
    con.close();
    System.out.println("thread number with size "+size+" completed");
   } catch (SQLException e) {
    e.printStackTrace();
   }

  }

 }
}

Body:
You should try multi-value inserts. For example:

INSERT INTO district VALUES (id1,name1,country1),(id2,name2,country2),(id3,name3,country3);

This can provide a significant performance boost, especially if you need to do this when connecting to a remote server. In addition to reducing network roundtrips (or even out of process calls on a local machine), the server will have to process fewer queries. Also, if you leave auto commit enabled for InnoDB, you will now have one transaction per batch instead of one per statement.

The Connector/J JDBC driver will do this for you if you set the rewriteBatchedStatements option true. I think this feature was added in a 3.1.x driver release for simple INSERTs like yours. In later versions, rewriteBatchedStatements has been enhanced to support more complex statements. Search on this page for rewriteBatchedStatements.

Or you can rewrite your code to manually construct multi-value insert statements. One thing to watch out for is the maximum packet size. You need to make sure the insert statement stays below that. So, either make max_allowed_packet very large while importing the data or break up your batches as they get close to max_allowed_packet.