问:
Error in using UIAutomatorviewer for testing Android app in Appium
I have to automate an Android application, I am doing the same through Appium.

The problem I am facing is after launching the Appium server, the app is getting installed in the emulator 4.4.2.  To inspect the element I am using UIAutomatorviewer which comes default with SDK. But while inspecting the element of the app, I am getting the error:

```<code>Error obtaining UI hierarchy
Reason:Error while obtaining UI hierarchy XML file.com.android.ddmlb.SynchException.Remote object doesn't exist.
</code>```

I tried to find the solution so that I can inspect the element so that I can script, but in vain.

Can someone please tell how to fix the issue so that I can inspect elements?

Is there any other way I can inspect element in the app apart from using UIAutomator viewer?

答: I got also the same issue (Also if Appium Server was not running). After switch, OFF / ON USB-Debugging was working for me.</p>

Body:
I have to automate an Android application, I am doing the same through Appium.

The problem I am facing is after launching the Appium server, the app is getting installed in the emulator 4.4.2.  To inspect the element I am using UIAutomatorviewer which comes default with SDK. But while inspecting the element of the app, I am getting the error:

Error obtaining UI hierarchy
Reason:Error while obtaining UI hierarchy XML file.com.android.ddmlb.SynchException.Remote object doesn't exist.

I tried to find the solution so that I can inspect the element so that I can script, but in vain.

Can someone please tell how to fix the issue so that I can inspect elements?

Is there any other way I can inspect element in the app apart from using UIAutomator viewer?


来源: stackexchange

问:
How to set the image to image view that is downloaded to your application in android local
I have a image downloaded locally in application

```<code>/data/data/com.starboard.stella/files/Stella/FragranceFinder/QuestionImages/option1_woman.png
</code>```

How do I access the image to set for image view?

答:
Creating a File type using your filepath, creating a Bitmap out of that File and setting the Image bitmap of your ImageView using setImageBitmap is probably the best way to go.

Paresh Mayani gives a great solution with code here: https://stackoverflow.com/a/4182060/5920187

ContentLicense: CC BY-SA 3.0

Body:
I have a image downloaded locally in application

/data/data/com.starboard.stella/files/Stella/FragranceFinder/QuestionImages/option1_woman.png

How do I access the image to set for image view?


问:
unix pipe is streaming?
zcat big.txt.gz  |  split  -l 1000000  - prefix

where big.txt.gz is 150 GB, say it has ~1 billion lines.

In this case, does the unix pipe "stream" the data into split, or is the  zcat operation completed, and then split is performed afterwards?

It was not clear to me from other pages if the above command would crash because it couldn't hold all of the gunzipped data in the pipe buffer before executing split, or if the gunzipped data would be "streamed" into split.

In general, the streaming behavior of unix pipe is unclear - when does pipe wait until all previous operations are finished before feeding input into the next commands stdin?

For example, if I were to link several more commands, would it crash due to lack of memory? e.g.

zcat big.txt.gz | tr 'a' 'b' | sed 's/foo/bar/g' | grep 'hello'

答:
A pipe has a limited capacity. [...] Applications should not rely on a particular capacity: an application should be designed so that a reading process consumes data as soon as it is available, so that a writing process does not remain blocked.

I'm not sure why there's any doubt here: the processes are running simultaneously, and the upstream process is writing while the downstream process is reading. Or at least that's the ideal specifically requested by this man page.

Now, it's possible that a given command may try to suck in all of its input before doing anything, and that too large an input may crash that command. But that's very different from the pipe buffer getting overfilled.

Title: unix pipe is streaming?


问:
Luigi passing small data between tasks
Using Luigi I want to do a query on my postgres DB to get a lat/lng coordinate pair then pass that pair onto another task.

I have a task QueryPostgres() that takes a SQL string as an input and performs the query. Is there a more concise way of passing the query result onto the next task rather than writing it to a local file? After all it is only two numbers I need to pass.

Thanks!

答: You could write the result out into another table in the database, redis, etc. Check the luigi.contrib package for a wide variety of output target types. http://luigi.readthedocs.io/en/stable/api/luigi.contrib.html</p>

Title: Luigi passing small data between tasks


问:
how to post data in API in angularJS in ionic app
I am new to this field so need help.I have to post data to API but i am unable to do this.Please help me and let me now the process.

API is:     http://trendytoday.in/ers/api/DeviceAlarms

And JSOn format in which i have to send data is:

```<code>{
  "ers": {
    "agency_device_id": "1"
  }

}
</code>```

答:
AngularJS provides the $http service, which has a method most. This can be used like:

var app = angular.module("app", []);
app.controller("HttpGetController", function($scope, $http) {

  $scope.SendData = function() {
    var data = {
      "ers": {
        "agency_device_id": "1"
      }
    }
    $http.post('http://trendytoday.in/ers/api/DeviceAlarms', data)
      .then(function(res) {
        console.log(res);
      }, function(err) {
        console.error(err);
      })
  };

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="app" ng-controller="HttpGetController">
  <button ng-click="SendData()">Submit</button>
  <hr /> {{ PostDataResponse }}
</div></code>```

This should be called from a controller or a service, and whichever you choose should have the $http service included as a dependency.

Body:
I am new to this field so need help.I have to post data to API but i am unable to do this.Please help me and let me now the process.

API is:     http://trendytoday.in/ers/api/DeviceAlarms

And JSOn format in which i have to send data is:

{
  "ers": {
    "agency_device_id": "1"
  }

}

Body:
AngularJS provides the $http service, which has a method most. This can be used like:

var app = angular.module("app", []);
app.controller("HttpGetController", function($scope, $http) {

  $scope.SendData = function() {
    var data = {
      "ers": {
        "agency_device_id": "1"
      }
    }
    $http.post('http://trendytoday.in/ers/api/DeviceAlarms', data)
      .then(function(res) {
        console.log(res);
      }, function(err) {
        console.error(err);
      })
  };

});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="app" ng-controller="HttpGetController">
  <button ng-click="SendData()">Submit</button>
  <hr /> {{ PostDataResponse }}
</div>

This should be called from a controller or a service, and whichever you choose should have the $http service included as a dependency.


问:
C++ standard default namespace
I am unsure if the two data member declarations in class B are equivalent.

```<code>//file0.h
namespace C
{
   typedef int Id;
}
//file1.h
namespace A
{
   typedef int Id;
}

//file2.h
namespace A
{
   class B
   {
      public:
      // ...
      //Want to add data member theId as:
      //Id theId;
      //or
      //A::Id theId;
   }
}
</code>```

That is, in the absence of A::, is there a default namespace the C++ standard uses in cases like this one? e.g., it may default to namespace A because the class is being declared in it.

If one uses Id theId, which namespace would it use, A or C?

Edit 1: Commented out code to avoid confusion.
Edit 2: Added another "theId" with a different namespace to illustrate better the question.

答:
Answer is Id results in A::Id theId.

Why?

Id (without the A::) is an unqualified name. C++ then resorts to this rule to find the right Id:

Member function definition For a name used inside a member function
  body, a default argument of a member function, exception specification
  of a member function, default member initializer, or inside a nested
  class definition (including names of the bases from which the nested
  class is derived), the scopes searched are the same as in class
  definition,[...]

[Class definition] the following scopes are searched:

d) if this class
  is a member of a namespace, or is nested in a class that is a member
  of a namespace, or is a local class in a function that is a member of
  a namespace, the scope of the namespace is searched until the
  definition of the class, enclosing class, or function. if the lookup
  of for a name introduced by a friend declaration: in this case only
  the innermost enclosing namespace is considered, otherwise lookup
  continues to enclosing namespaces until the global scope as usual.

Reference: http://en.cppreference.com/w/cpp/language/unqualified_lookup

Title: C++ standard default namespace

Body:
I am unsure if the two data member declarations in class B are equivalent.

//file0.h
namespace C
{
   typedef int Id;
}
//file1.h
namespace A
{
   typedef int Id;
}

//file2.h
namespace A
{
   class B
   {
      public:
      // ...
      //Want to add data member theId as:
      //Id theId;
      //or
      //A::Id theId;
   }
}

That is, in the absence of A::, is there a default namespace the C++ standard uses in cases like this one? e.g., it may default to namespace A because the class is being declared in it.

If one uses Id theId, which namespace would it use, A or C?

Edit 1: Commented out code to avoid confusion.
Edit 2: Added another "theId" with a different namespace to illustrate better the question.


问:
Why does Double.TryParse() return false for a string containing double.MaxValue or double.MinValue?
I have static method that takes a string for input and returns the original input string if the string represents a number.  If the string does not represent a number the the input string is processed and a transformed string is returned.  I'm writing test cases.  I'm trying to verify that an input string containing either double.MinValue or double.MaxValue is returned unchanged.  I've read through a number of forums, including StackOverflow, and have come up with the following logic:

```<code>string doubleMax = double.MaxValue.ToString();
double d;
CultureInfo cultureInfo = new CultureInfo("en-US", true);
if (Double.TryParse(doubleMax, NumberStyles.Any, cultureInfo.NumberFormat, out d))
{
    Console.WriteLine("parsed");
}
else
{
    Console.WriteLine("couldn't parse");
}
</code>```

Problem is the Double.TryParse() always returns false.  I've called TryParse() in a bunch of different ways, but the result is always the same, false.

This logic works if I use decimal.MinValue(), int.MinValue(), or float.MinValue().

Can someone tell me why my logic isn't working for double.MinValue?

答: The problem is in the rounding of the ToString() method. The actual MaxValue according to the documentation is 1.7976931348623157E+308, but the ToString() of that gives you 1,79769313486232E+308, which is rounded up and thus too large to parse.</p>

ContentLicense: CC BY-SA 2.5

Body:
I have static method that takes a string for input and returns the original input string if the string represents a number.  If the string does not represent a number the the input string is processed and a transformed string is returned.  I'm writing test cases.  I'm trying to verify that an input string containing either double.MinValue or double.MaxValue is returned unchanged.  I've read through a number of forums, including StackOverflow, and have come up with the following logic:

string doubleMax = double.MaxValue.ToString();
double d;
CultureInfo cultureInfo = new CultureInfo("en-US", true);
if (Double.TryParse(doubleMax, NumberStyles.Any, cultureInfo.NumberFormat, out d))
{
    Console.WriteLine("parsed");
}
else
{
    Console.WriteLine("couldn't parse");
}

Problem is the Double.TryParse() always returns false.  I've called TryParse() in a bunch of different ways, but the result is always the same, false.

This logic works if I use decimal.MinValue(), int.MinValue(), or float.MinValue().

Can someone tell me why my logic isn't working for double.MinValue?


问:
Can't insert texts with ' symbol in database using php
So I've got this problem where I can't seem to insert texts into my database which contain the following character: ' (as in for example:  It's). I've had this problem before and I just stripped the symbol, but now I really need a solution and nowhere on the entire web or stack overflow I can't seem to find a decent and clear answer.

This is how my data is displayed:

HTML

```<code><textarea name="text_from_form">
      This is the kind of stuff I need and It's awesome (user input example)
</textarea>
</code>```

PHP

```<code><?php

  $my_text = $_POST["text_from_form"};
  $my_text_new = htmlentities($my_text);

  $sql = "INSERT INTO tableName (text)
  VALUES ('$my_text_new')";
?>
</code>```

THE ERROR

```<code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's awesome ')' at line 2
</code>```

Thank you in advance for the help!

答: The htmlentities() function doesn't escape single quotes ' in default flag (ENT_COMPACT), use htmlentities($text, ENT_QUOTES) or function mysql_real_escape_string() or mysqli_real_escape_string() depending on which library you use.

Body:
So I've got this problem where I can't seem to insert texts into my database which contain the following character: ' (as in for example:  It's). I've had this problem before and I just stripped the symbol, but now I really need a solution and nowhere on the entire web or stack overflow I can't seem to find a decent and clear answer.

This is how my data is displayed:

HTML

<textarea name="text_from_form">
      This is the kind of stuff I need and It's awesome (user input example)
</textarea>

PHP

<?php

  $my_text = $_POST["text_from_form"};
  $my_text_new = htmlentities($my_text);

  $sql = "INSERT INTO tableName (text)
  VALUES ('$my_text_new')";
?>

THE ERROR

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's awesome ')' at line 2

Thank you in advance for the help!

ContentLicense: CC BY-SA 4.0


问:
Register Golang gorilla/mux routes in external package
In my API I'm going to have a lot of completely separate handlers for each path like "/api/v1/handler_one" and "/api/v1/handler_two". I'm trying to put every handler in it's own package to make it easier to maintain.

I added an example. It's not working since it's not even loading "handlers/handler_one.go". What am I missing?

main.go

```<code>package main

import (
    "net/http"
    "git/myapp/router"
)

func main() {

  myRouter := router.APIRouter

    srv := &http.Server{
        Handler: myRouter,
        Addr:    "0.0.0.0:8080",
    }

    log.Fatal(srv.ListenAndServe())
}
</code>```

router/router.go

```<code>package router

import (
    "github.com/gorilla/mux"
)

var Router = mux.NewRouter().StrictSlash(true)
var APIRouter = Router.PathPrefix("/api/v1").Subrouter()
</code>```

handlers/handler_one.go

```<code>package handler_one

import (
    "git/myapp/router"
)

type Route struct {
    Name        string
    Method      string
    Pattern     string
    HandlerFunc http.HandlerFunc
}

type APIRoutes []Route

var apiRoutes = APIRoutes{
    Route{ "OneIndex", "GET", "/one", OneIndex, },
}

func init() {
    // Register routes
    for _, route := range apiRoutes {
        var handler http.Handler

        handler = route.HandlerFunc
        handler = Logger(handler, route.Name)

        router.APIRouter.
            Methods(route.Method).Path(route.Pattern).Name(route.Name).Handler(handler)
    }
}

// OneIndex is handling the requests to /api/v1/one
func OneIndex(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json; charset=UTF-8")
    w.WriteHeader(http.StatusOK)

  fmt.Println("Doing something...")
}
</code>```

答:
It's not working since it's not even loading "handlers/handler_one.go"

Do you mean that the init function in handlers/handler_one.go is not being executed?

That would be expected since in the code you pasted you are not importing that package anywhere.

Try importing that package in your main.go.

You can import as _ if the only reason for importing it would be for the init function to run.

Body:
In my API I'm going to have a lot of completely separate handlers for each path like "/api/v1/handler_one" and "/api/v1/handler_two". I'm trying to put every handler in it's own package to make it easier to maintain.

I added an example. It's not working since it's not even loading "handlers/handler_one.go". What am I missing?

main.go

package main

import (
    "net/http"
    "git/myapp/router"
)

func main() {

  myRouter := router.APIRouter

    srv := &http.Server{
        Handler: myRouter,
        Addr:    "0.0.0.0:8080",
    }

    log.Fatal(srv.ListenAndServe())
}

router/router.go

package router

import (
    "github.com/gorilla/mux"
)

var Router = mux.NewRouter().StrictSlash(true)
var APIRouter = Router.PathPrefix("/api/v1").Subrouter()

handlers/handler_one.go

package handler_one

import (
    "git/myapp/router"
)

type Route struct {
    Name        string
    Method      string
    Pattern     string
    HandlerFunc http.HandlerFunc
}

type APIRoutes []Route

var apiRoutes = APIRoutes{
    Route{ "OneIndex", "GET", "/one", OneIndex, },
}

func init() {
    // Register routes
    for _, route := range apiRoutes {
        var handler http.Handler

        handler = route.HandlerFunc
        handler = Logger(handler, route.Name)

        router.APIRouter.
            Methods(route.Method).Path(route.Pattern).Name(route.Name).Handler(handler)
    }
}

// OneIndex is handling the requests to /api/v1/one
func OneIndex(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json; charset=UTF-8")
    w.WriteHeader(http.StatusOK)

  fmt.Println("Doing something...")
}


问:
Display date in ng-repeat input field - angularjs
I want to display the date in ng-repeat from an array inside the input field. I am able to display but the first index value gets reflected in all the fields.</p>

```<code>$scope.trackPaymentDetails = [{"itemNo": 1, "nextduedate": "Jan 02, 2010", "Status": "Paid", "amount": 1000}, {"itemNo": 2, "Status": "Unpaid", "amount": 5000}];

<table class="table table-hover" novalidate>

<tr>
<th>  S.No.</th>
<th>  Amount</th>
<th>  Due Date</th>
</tr>

<tbody>
<tr dir-paginate="item in trackPaymentDetails |orderBy:sortkey:reverse|itemsPerPage:2">
<td>  {{$index + 1}}</td>
<td>  {{item.amount}}</td>
<td><input class="form-control7" type="text" id="trackPaymentDueDate_{{$index}}"  name="duedate" ng-model="model.nextduedate" required readonly="readonly" datepicker-popup="MMM dd, yyyy" placeholder=" " style="background-color: transparent;" value={{item.nextduedate}}></td>
</tr>
</tbody>
</table>
</code>```

答:
you are not using ng-repeat. you are using dir-paginate. change it first. then in the input add the item.nextduedate as the ng-model value.

angular.module("app",[])
.controller("ctrl",function($scope){

$scope.model = {};

$scope.trackPaymentDetails = [{"itemNo": 1, "nextduedate": "Jan 02, 2010", "Status": "Paid", "amount": 1000}, {"itemNo": 2, "Status": "Unpaid", "amount": 5000}];

})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
 <table class="table table-hover" novalidate>

<tr>
<th>  S.No.</th>
<th>  Amount</th>
<th>  Due Date</th>
</tr>

<tbody>
<tr ng-repeat="item in trackPaymentDetails">
<td>  {{$index + 1}}</td>
<td>  {{item.amount}}</td>
<td><input class="form-control7" type="text" id="trackPaymentDueDate_{{$index}}"  name="duedate" ng-model="item.nextduedate" required readonly="readonly" datepicker-popup="MMM dd, yyyy" placeholder=" " style="background-color: transparent;" ></td>
</tr>
</tbody>
</table>
</div></code>```

Body:
I want to display the date in ng-repeat from an array inside the input field. I am able to display but the first index value gets reflected in all the fields.

$scope.trackPaymentDetails = [{"itemNo": 1, "nextduedate": "Jan 02, 2010", "Status": "Paid", "amount": 1000}, {"itemNo": 2, "Status": "Unpaid", "amount": 5000}];

  S.No.
  Amount
  Due Date

  {{$index + 1}}
  {{item.amount}}
<input class="form-control7" type="text" id="trackPaymentDueDate_{{$index}}"  name="duedate" ng-model="model.nextduedate" required readonly="readonly" datepicker-popup="MMM dd, yyyy" placeholder=" " style="background-color: transparent;" value={{item.nextduedate}}>

Body:
you are not using ng-repeat. you are using dir-paginate. change it first. then in the input add the item.nextduedate as the ng-model value.

angular.module("app",[])
.controller("ctrl",function($scope){

$scope.model = {};

$scope.trackPaymentDetails = [{"itemNo": 1, "nextduedate": "Jan 02, 2010", "Status": "Paid", "amount": 1000}, {"itemNo": 2, "Status": "Unpaid", "amount": 5000}];

})

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
 <table class="table table-hover" novalidate>

<tr>
<th>&nbsp;&nbsp;S.No.</th>
<th>&nbsp;&nbsp;Amount</th>
<th>&nbsp;&nbsp;Due Date</th>
</tr>

<tbody>
<tr ng-repeat="item in trackPaymentDetails">
<td>&nbsp;&nbsp;{{$index + 1}}</td>
<td>&nbsp;&nbsp;{{item.amount}}</td>
<td><input class="form-control7" type="text" id="trackPaymentDueDate_{{$index}}"  name="duedate" ng-model="item.nextduedate" required readonly="readonly" datepicker-popup="MMM dd, yyyy" placeholder=" " style="background-color: transparent;" ></td>
</tr>
</tbody>
</table>
</div>


问:
Append element to a list based on the values of the nested list
I want to append the values of the specific indices of a nested list based on the values of the same list but on different indices.

So, basically, if my initial list looks like the following:

a = [(1,2,1,[1,2,3]) , (1,2,2,[3,2,4]) , (1,2,3,[7,3,4]) , (1,2,3,[11,2,7]) ,..., (2,1,1,[5,6,3]) , (2,1,2,[3,1,8]) , ...]

I would like to firstly have a list of all the values of the 3rd index of the list a, which share the same value of the 1st and 2nd index in the list a. So, the 1st output will look like the following:

b = [[1,2,3] , [3,2,4] , [7,3,4] , [11,2,7]]

Then, I would like to run some calculations on the output, save the data and get the other set of data that share the same value of the 1st and 2nd index from the initial list (list a).

This process should be repeated for all the values of the initial list, till there is non left in that list.

With the following code, I get the 1st set of data, but I face problems to get the next set:

```<code>od = 1

ri = 1

q=0

for i in range(len(a)):

    while q<len(a):

        if a[q][0]==od and a[q][1]==ri:

            b.append(Net_info[q][3])

        q+=1
    ri += 1

od += 1
</code>```

答:
Simply use a defaultdict and append the third element based on the first two elements, like:

```<code>from collections import defaultdict

result = defaultdict(list)

for ai in a:
    result[ai[:2]].append(ai[3])
</code>```

This generates a dictionary like:

```<code>>>> result
defaultdict(<class 'list'>, {(1, 2): [[1, 2, 3], [3, 2, 4], [7, 3, 4], [11, 2, 7]], (2, 1): [[5, 6, 3], [3, 1, 8]]})
</code>```

So a dictionary that maps the first two elements of the tuple onto a list of those elements associated with index three.

Now we can process these lists individually, like:

```<code>for k,b in result.items():
    print('%s: %s'%(k,b))
</code>```

This generates:

```<code>>>> for k,b in result.items():
...     print('%s: %s'%(k,b))
...
(1, 2): [[1, 2, 3], [3, 2, 4], [7, 3, 4], [11, 2, 7]]
(2, 1): [[5, 6, 3], [3, 1, 8]]
</code>```

This algorithm will perform a single pass over a. And will not look for configurations of the first two items of tuples that are nowhere to be found in a.

Body:
I want to append the values of the specific indices of a nested list based on the values of the same list but on different indices.

So, basically, if my initial list looks like the following:

a = [(1,2,1,[1,2,3]) , (1,2,2,[3,2,4]) , (1,2,3,[7,3,4]) , (1,2,3,[11,2,7]) ,..., (2,1,1,[5,6,3]) , (2,1,2,[3,1,8]) , ...]

I would like to firstly have a list of all the values of the 3rd index of the list a, which share the same value of the 1st and 2nd index in the list a. So, the 1st output will look like the following:

b = [[1,2,3] , [3,2,4] , [7,3,4] , [11,2,7]]

Then, I would like to run some calculations on the output, save the data and get the other set of data that share the same value of the 1st and 2nd index from the initial list (list a).

This process should be repeated for all the values of the initial list, till there is non left in that list.

With the following code, I get the 1st set of data, but I face problems to get the next set:

od = 1

ri = 1

q=0

for i in range(len(a)):

    while q<len(a):

        if a[q][0]==od and a[q][1]==ri:

            b.append(Net_info[q][3])

        q+=1
    ri += 1

od += 1

Body:
Simply use a defaultdict and append the third element based on the first two elements, like:

from collections import defaultdict

result = defaultdict(list)

for ai in a:
    result[ai[:2]].append(ai[3])

This generates a dictionary like:

>>> result
defaultdict(<class 'list'>, {(1, 2): [[1, 2, 3], [3, 2, 4], [7, 3, 4], [11, 2, 7]], (2, 1): [[5, 6, 3], [3, 1, 8]]})

So a dictionary that maps the first two elements of the tuple onto a list of those elements associated with index three.

Now we can process these lists individually, like:

for k,b in result.items():
    print('%s: %s'%(k,b))

This generates:

>>> for k,b in result.items():
...     print('%s: %s'%(k,b))
...
(1, 2): [[1, 2, 3], [3, 2, 4], [7, 3, 4], [11, 2, 7]]
(2, 1): [[5, 6, 3], [3, 1, 8]]

This algorithm will perform a single pass over a. And will not look for configurations of the first two items of tuples that are nowhere to be found in a.


问:
How to test search result via nightwatch.js
I'm using nightwatch.js to do some end-to-end tests. Now I want to check if a specific search results matches my expectation. The result looks like this:

```<code><div id="results" role="list" class="ui list">
    <div role="listitem" class="item">
        <span><strong>Samp</strong>le One</span>
    </div>
    <div role="listitem" class="item multiple pointer ">
        <div class="ui accordion">
            <div class="title pointer">
                <span><strong>Samp</strong>le Subcategory</span>
            </div>
            <div class="content pointer">
                <div role="list" class="ui list">
                    <div role="listitem" class="item pointer">Sub 1</div>
                    <div role="listitem" class="item pointer">Sub 2</div>
                </div>
            </div>
        </div>
    </div>
    <div role="listitem" class="item pointer">
        <span><strong>Samp</strong>le Three</span>
    </div>
</div>
</code>```

That means there are three results: Sample One, Sample Subcategory and Sample Three. The second one has also to subresults Sub 1 and Sub 2

I did not find something like getElements and check the number and each value of the results elements. So I tried to use getText but I think that is the wrong way...

```<code>this.searchTest = function (browser) {
  browser.getText("#results", function(result) {
    // ???
  });
};
</code>```

答:
getElements does not exist, indeed. But you can use elements instead!

The following script gives you the number of results and the text content for each result:

```<code>module.exports = {
  'getElements': function (browser) {

    function getInfo(elements) {
      console.log('Number of results: ' + elements.value.length);

      elements.value.forEach(function (element) {
        browser.elementIdText(element.ELEMENT, function (res) {
          console.log('RESULT ' + element.ELEMENT + '\n', res.value);
        });
      });
    }

    browser
      .url('http://www.website.com/') // <--- Don't forget to change this!
      .waitForElementPresent('body', 1000)
      .elements('css selector', '#results > div[role="listitem"]', getInfo)
      .end();

  }
};
</code>```

Body:
I'm using nightwatch.js to do some end-to-end tests. Now I want to check if a specific search results matches my expectation. The result looks like this:

        Sample One

                Sample Subcategory

Sub 1

Sub 2

        Sample Three

That means there are three results: Sample One, Sample Subcategory and Sample Three. The second one has also to subresults Sub 1 and Sub 2

I did not find something like getElements and check the number and each value of the results elements. So I tried to use getText but I think that is the wrong way...

this.searchTest = function (browser) {
  browser.getText("#results", function(result) {
    // ???
  });
};

Body:
getElements does not exist, indeed. But you can use elements instead!

The following script gives you the number of results and the text content for each result:

module.exports = {
  'getElements': function (browser) {

    function getInfo(elements) {
      console.log('Number of results: ' + elements.value.length);

      elements.value.forEach(function (element) {
        browser.elementIdText(element.ELEMENT, function (res) {
          console.log('RESULT ' + element.ELEMENT + '\n', res.value);
        });
      });
    }

    browser
      .url('http://www.website.com/') // <--- Don't forget to change this!
      .waitForElementPresent('body', 1000)
      .elements('css selector', '#results > div[role="listitem"]', getInfo)
      .end();

  }
};


问:
rollover effect using Jquery
Would you please help me in making a rollover effect using jquery, what i want to do is when someone hover over any of the menu items the text slide down and disappear and a picture slides from the top down to the center (e.g. you could see this effect here panda as you can see the picture slide down from the top but the text does not slide down which is not what want).

I know it can be easily done using flash but i don't want my menu in flash as that would be a bad practice.

can you tell me what do i need to change in my menu HTML and what jquery functions should i use.

Thanks So much for your help

P.S. this my menu HTML and you can see my menu here

```<code><ul class="nav">

<li class="active first"><a href="#" class="home">Home</a></li>
<li><a href="#" class="news">News</a></li>
<li><a href="#" class="offers">Special offers</a></li>
<li><a href="#" class="private">Private label</a></li>
<li><a href="#" class="locations">Locations</a></li>
<li><a href="#" class="about">About us</a></li>
<li><a href="#" class="jobs">Jobs</a></li>
<li><a href="#" class="contact">Contact us</a></li>
<li><a href="#" class="mm">Multimedia</a></li>

</ul>
</code>```

MENU:

答:
First things first, you'll really want to give your independent anchor tags ids, as it will make accomplishing what you're wanting much easier.

Look at the slideDown(), and slideToggle() functions, and it would basically require you setting up hidden divs and then on the mouseover event, you would slidetoggle your text out and the hidden image div in, and on mouseout do the opposite.

Good luck, jQuery is a lot of fun to work with.  Play with it and see what you can blow up!

Title: rollover effect using Jquery

Body:
Would you please help me in making a rollover effect using jquery, what i want to do is when someone hover over any of the menu items the text slide down and disappear and a picture slides from the top down to the center (e.g. you could see this effect here panda as you can see the picture slide down from the top but the text does not slide down which is not what want).

I know it can be easily done using flash but i don't want my menu in flash as that would be a bad practice.

can you tell me what do i need to change in my menu HTML and what jquery functions should i use.

Thanks So much for your help

P.S. this my menu HTML and you can see my menu here

Home

News

Special offers

Private label

Locations

About us

Jobs

Contact us

Multimedia

MENU:

OwnerDisplayName: riceboyler


问:
implementing an abstract base class function in another template base class
I have a Visual Studio 2008 C++ project where I have a class that inherits from an abstract base class and another template class that implements a function in the abstract base class. For example:

```<code>class Foo;

struct Buzz
{
    virtual ~Buzz() {};
    virtual void Buzz_Do( Foo* ) = 0;
};

class Base
{
public:
    virtual ~Base() {};
    virtual void Base_Do( Buzz* ) = 0;
};

template< class T >
class Bar
{
public:
    virtual void Base_Do( Buzz* v )
    {
        v->Buzz_Do( static_cast< T* >( this ) );
    };
};

class Foo : public Base, public Bar< Foo >
{
};

int _tmain(int argc, _TCHAR* argv[])
{
    Foo c;
    return 0;
}
</code>```

Unfortunately, this yields the compiler error:

```<code>1>MyApp.cpp(39) : error C2259: 'Foo' : cannot instantiate abstract class
1>        due to following members:
1>        'void Base::Base_Do(Buzz *)' : is abstract
1>        MyApp.cpp(17) : see declaration of 'Base::Base_Do'
</code>```

I've tried adding a public using Bar< Foo >::Base_Do; to class Foo, but that did not help.

Is there a way to make this work or will I need to put a concrete Base_Do() implementation in Foo and not use Bar<>?

Thanks,
PaulH

答:
Look at the error:

```<code>> 1>MyApp.cpp(39) : error C2259: 'Foo' :
> cannot instantiate abstract class 1>
> due to following members: 1>
> 'void Base::Base_Do(Buzz *)' : is
> abstract 1>        MyApp.cpp(17) : see
> declaration of 'Base::Base_Do'
</code>```

Foo is an abstract class. You cannot create instance of it. First implements all the virtual functions it inherits from the base classes.

Body:
I have a Visual Studio 2008 C++ project where I have a class that inherits from an abstract base class and another template class that implements a function in the abstract base class. For example:

class Foo;

struct Buzz
{
    virtual ~Buzz() {};
    virtual void Buzz_Do( Foo* ) = 0;
};

class Base
{
public:
    virtual ~Base() {};
    virtual void Base_Do( Buzz* ) = 0;
};

template< class T >
class Bar
{
public:
    virtual void Base_Do( Buzz* v )
    {
        v->Buzz_Do( static_cast< T* >( this ) );
    };
};

class Foo : public Base, public Bar< Foo >
{
};

int _tmain(int argc, _TCHAR* argv[])
{
    Foo c;
    return 0;
}

Unfortunately, this yields the compiler error:

1>MyApp.cpp(39) : error C2259: 'Foo' : cannot instantiate abstract class
1>        due to following members:
1>        'void Base::Base_Do(Buzz *)' : is abstract
1>        MyApp.cpp(17) : see declaration of 'Base::Base_Do'

I've tried adding a public using Bar< Foo >::Base_Do; to class Foo, but that did not help.

Is there a way to make this work or will I need to put a concrete Base_Do() implementation in Foo and not use Bar<>?

Thanks,
PaulH

Body:
Look at the error:

> 1>MyApp.cpp(39) : error C2259: 'Foo' :
> cannot instantiate abstract class 1>
> due to following members: 1>
> 'void Base::Base_Do(Buzz *)' : is
> abstract 1>        MyApp.cpp(17) : see
> declaration of 'Base::Base_Do'

Foo is an abstract class. You cannot create instance of it. First implements all the virtual functions it inherits from the base classes.


问:
Old Browsers TLS 1.0 and 1.1
We've removed older versions of TLS and ciphers from our site that is an HTTPS e-commerce hosted on a Windows 2008 R2 Server.

We've had people using older browsers/operating systems saying that they now can't access the site but as we're PCI complaint I'm reluctant to reverse the changes.

I can't think of a way to catch these people and at least redirect them to a http site to show a nicer message to the customers

Is anyone able to suggest a way this can be achieved or is it a case of the older browsers won't even communicate with the the old browsers over https to redirect them with the old protocols disabled

答: With IIS there is no way to do this. And you should'nt: https://community.qualys.com/thread/12758</p>

Title: Old Browsers TLS 1.0 and 1.1


问:
PHP preg_replace all matches
I want to replace all matches with using preg_replace but it only works once.

Here is function i used:

```<code>function bbc2html($text) {
    $find = array(
        '~\[spoiler\](.*?)\[/spoiler\]~s'
    );
    $replace = array(
        '<font color="red"><b>ATTENTION: SPOILER ALARM!</b></font><br>$1'
    );
    return preg_replace($find,$replace,$text);
}
</code>```

Input:

```<code>echo bbc2html('[spoiler]Its a spoiler[/spoiler]');
echo bbc2html('[spoiler][spoiler]Its a multiple spoiler[/spoiler][/spoiler]');
</code>```

Output:

```<code><font color="red"><b>ATTENTION: SPOILER ALARM!</b></font><br>Its a spoiler
<font color="red"><b>ATTENTION: SPOILER ALARM!</b></font><br>[spoiler]Its a multiple spoiler[/spoiler]
</code>```

答:
this is another function:</p>

```<code>function bbc2html($text) {
$find = array(
    '~(\[spoiler\]\w*)+(.*?)(\[/spoiler\])+~s'
);
$replace = array(
    '<font color="red"><b>ATTENTION: SPOILER ALARM!</b></font><br>$2'
);
return preg_replace($find,$replace,$text);
}
</code>```

Title: PHP preg_replace all matches

Body:
I want to replace all matches with using preg_replace but it only works once.

Here is function i used:

function bbc2html($text) {
    $find = array(
        '~\[spoiler\](.*?)\[/spoiler\]~s'
    );
    $replace = array(
        'ATTENTION: SPOILER ALARM!
$1'
    );
    return preg_replace($find,$replace,$text);
}

Input:

echo bbc2html('[spoiler]Its a spoiler[/spoiler]');
echo bbc2html('[spoiler][spoiler]Its a multiple spoiler[/spoiler][/spoiler]');

Output:

ATTENTION: SPOILER ALARM!
Its a spoiler
ATTENTION: SPOILER ALARM!
[spoiler]Its a multiple spoiler[/spoiler]

Body:
this is another function:

function bbc2html($text) {
$find = array(
    '~(\[spoiler\]\w*)+(.*?)(\[/spoiler\])+~s'
);
$replace = array(
    '<font color="red"><b>ATTENTION: SPOILER ALARM!</b></font><br>$2'
);
return preg_replace($find,$replace,$text);
}


答:
To load an image </p>

```<code>File imgFile = new  File(pathToPicture);
Bitmap bitmap = BitmapFactory.decodeFile(pathToPicture);
</code>```

<p>then </p>

```<code>imageView.setImageBitmap(bitmap);
</code>```

Title: How to set the image to image view that is downloaded to your application in android local

Body:
I have a image downloaded locally in application

/data/data/com.starboard.stella/files/Stella/FragranceFinder/QuestionImages/option1_woman.png

How do I access the image to set for image view?

Body:
To load an image

File imgFile = new  File(pathToPicture);
Bitmap bitmap = BitmapFactory.decodeFile(pathToPicture);

then

imageView.setImageBitmap(bitmap);


问:
How can I change a given JSON file (Python)?
I'm new to Python and I'm currently building a python application (via Flask). I'm half way there, but I need to change a given JSON file to a different structure.

I have this JSON file given:

```<code>{
    "apps": [
        {
            "app_id": 27,
            "organization_id": "Organization_1"
        },
        {
            "app_id": 87,
            "organization_id": "Organization_2"
        },
        {
            "app_id": 88,
            "organization_id": "Organization_3"
        },
        {
            "app_id": 36,
            "organization_id": "Organization_1"
        }
    ]
}
</code>```

And I want to bring it into a new structure like this:

```<code>{
    "organizations" : [
        {
            "organization_id": "Organization_!",
            "apps": [
                27,
                36
            ]
        },
        {
            "organization_id": "Organization_2",
            "apps": [
                87
            ]
        },
        {
            "organization_id": "Organization_3",
            "apps": [
                88
            ]
        }
    ]
}
</code>```

Do you have an idea how to create this output?
Thanks for your advice!

答:
Basically, the first format is a mapping (similar a Python dict) from app_id to organization and you want to convert it to a mapping of organization to list of app_ids.  Given a list of apps where each element maps one app to one organizaiton, I would use that list to create a new map using a dict, i.e. if apps is the list from the first file:

```<code>from collections import defaultdict
d = defaultdict(lambda: [])

apps = json.load(firstfile)['apps']
# d is mapping from organization_id to list of app_ids
for app in apps:
    org = app['organization_id']
    app_id = app['app_id']
    d[org].append(app_id)

# Create list of orgs from d
orgs = [{'organization_id': org, 'apps': apps} for org,apps in d.items()]

json.dump({'organizations': orgs}, secondfile)
</code>```

Body:
I'm new to Python and I'm currently building a python application (via Flask). I'm half way there, but I need to change a given JSON file to a different structure.

I have this JSON file given:

{
    "apps": [
        {
            "app_id": 27,
            "organization_id": "Organization_1"
        },
        {
            "app_id": 87,
            "organization_id": "Organization_2"
        },
        {
            "app_id": 88,
            "organization_id": "Organization_3"
        },
        {
            "app_id": 36,
            "organization_id": "Organization_1"
        }
    ]
}

And I want to bring it into a new structure like this:

{
    "organizations" : [
        {
            "organization_id": "Organization_!",
            "apps": [
                27,
                36
            ]
        },
        {
            "organization_id": "Organization_2",
            "apps": [
                87
            ]
        },
        {
            "organization_id": "Organization_3",
            "apps": [
                88
            ]
        }
    ]
}

Do you have an idea how to create this output?
Thanks for your advice!

Body:
Basically, the first format is a mapping (similar a Python dict) from app_id to organization and you want to convert it to a mapping of organization to list of app_ids.  Given a list of apps where each element maps one app to one organizaiton, I would use that list to create a new map using a dict, i.e. if apps is the list from the first file:

from collections import defaultdict
d = defaultdict(lambda: [])

apps = json.load(firstfile)['apps']
# d is mapping from organization_id to list of app_ids
for app in apps:
    org = app['organization_id']
    app_id = app['app_id']
    d[org].append(app_id)

# Create list of orgs from d
orgs = [{'organization_id': org, 'apps': apps} for org,apps in d.items()]

json.dump({'organizations': orgs}, secondfile)


问:
Create an array of arrays with Linq
I've the following XML :

```<code><datarow>
  <datacol><![CDATA[Value1]]></datacol>
  <datacol><![CDATA[Value2]]></datacol>
  <datacol><![CDATA[Value3]]></datacol>
</datarow>
<datarow>
  <datacol><![CDATA[Value5]]></datacol>
  <datacol><![CDATA[Value6]]></datacol>
  <datacol><![CDATA[Value7]]></datacol>
</datarow>
// ...
</code>```

How can I create an bi-dimensional array using linq?

I'll avoid doing :

```<code>foreach("datarow") {
    foreach ("datacol") { ... }
}
</code>```

Thanks !

[EDIT] Final array should be like this:

array[,] = {{ "Value1", "Value2", "Value3"} , { "Value4", "Value5", "Value6"}}

答:
Here is an example to create a jagged array from XML data.

```<code>var xmlStr = "<table><dataRow><dataCol>1</dataCol><dataCol>2</dataCol></dataRow><dataRow><dataCol>5</dataCol><dataCol>6</dataCol></dataRow></table>";
var rows = from r in XElement.Parse(xmlStr).Elements("dataRow") select r;

int[][] intJagArray = (from r in rows select (from c in r.Elements("dataCol") select Int32.Parse(c.Value)).ToArray()).ToArray();
</code>```

Here's the page that helped me figure this out. http://www.daniweb.com/code/snippet267931.html

Title: Create an array of arrays with Linq

Body:
I've the following XML :

<datarow>
  <datacol><![CDATA[Value1]]></datacol>
  <datacol><![CDATA[Value2]]></datacol>
  <datacol><![CDATA[Value3]]></datacol>
</datarow>
<datarow>
  <datacol><![CDATA[Value5]]></datacol>
  <datacol><![CDATA[Value6]]></datacol>
  <datacol><![CDATA[Value7]]></datacol>
</datarow>
// ...

How can I create an bi-dimensional array using linq?

I'll avoid doing :

foreach("datarow") {
    foreach ("datacol") { ... }
}

Thanks !

[EDIT] Final array should be like this:

array[,] = {{ "Value1", "Value2", "Value3"} , { "Value4", "Value5", "Value6"}}

Body:
Here is an example to create a jagged array from XML data.

var xmlStr = "<table><dataRow><dataCol>1</dataCol><dataCol>2</dataCol></dataRow><dataRow><dataCol>5</dataCol><dataCol>6</dataCol></dataRow></table>";
var rows = from r in XElement.Parse(xmlStr).Elements("dataRow") select r;

int[][] intJagArray = (from r in rows select (from c in r.Elements("dataCol") select Int32.Parse(c.Value)).ToArray()).ToArray();

Here's the page that helped me figure this out. http://www.daniweb.com/code/snippet267931.html


问:
Tensorflow: traning by batch stuck forever in sess.run
I'm trying to train my model batch by batch, as I couldn't find any example to how to do it properly. This is as far as I can do, on my mission to find how to train a model batch by batch in Tensorflow.

```<code>queue=tf.FIFOQueue(capacity=50,dtypes=[tf.float32,tf.float32],shapes=[[10],[2]])
enqueue_op=queue.enqueue_many([X,Y])
dequeue_op=queue.dequeue()

qr=tf.train.QueueRunner(queue,[enqueue_op]*2)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    X_train_batch,y_train_batch=tf.train.batch(dequeue_op,batch_size=2)
    coord=tf.train.Coordinator()
    enqueue_threads=qr.create_threads(sess,coord,start=True)
    sess.run(tf.local_variables_initializer())
    for epoch in range(100):
        print("inside loop1")
        for iter in range(5):
            print("inside loop2")
            if coord.should_stop():
                break
            batch_x,batch_y=sess.run([X_train_batch,y_train_batch])
            print("after sess.run")
            print(batch_x.shape)
            _=sess.run(optimizer,feed_dict={x_place:batch_x,y_place:batch_y})
        coord.request_stop()
        coord.join(enqueue_threads)
</code>```

Which outputs,

```<code>inside loop1
inside loop2
</code>```

As you can see,
Which stuck forever when it runs the batch_x,batch_y=sess.run([X_train_batch,y_train_batch]) line.
I don't know how could I solve this, or is this the proper way to train a model batch by batch?

答:
After couple hour of searching, I found the Solution myself. So, I'm answering my own question now below.
The queues are filled by background threads, which are created when you call tf.train.start_queue_runners() If you don't call this method, the background threads will not start, the queues will remain empty, and the training op will block indefinitely waiting for input.

FIX:
call tf.train.start_queue_runners(sess) just before the training loop.
Like I did below:

```<code>queue=tf.FIFOQueue(capacity=50,dtypes=[tf.float32,tf.float32],shapes=[[10],[2]])
enqueue_op=queue.enqueue_many([X,Y])
dequeue_op=queue.dequeue()

qr=tf.train.QueueRunner(queue,[enqueue_op]*2)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    X_train_batch,y_train_batch=tf.train.batch(dequeue_op,batch_size=2)
    coord=tf.train.Coordinator()
    enqueue_threads=qr.create_threads(sess,coord,start=True)
    tf.train.start_queue_runners(sess)
    for epoch in range(100):
        print("inside loop1")
        for iter in range(5):
            print("inside loop2")
            if coord.should_stop():
                break
            batch_x,batch_y=sess.run([X_train_batch,y_train_batch])
            print("after sess.run")
            print(batch_x.shape)
            _=sess.run(optimizer,feed_dict={x_place:batch_x,y_place:batch_y})
        coord.request_stop()
        coord.join(enqueue_threads)
</code>```

Body:
I'm trying to train my model batch by batch, as I couldn't find any example to how to do it properly. This is as far as I can do, on my mission to find how to train a model batch by batch in Tensorflow.

queue=tf.FIFOQueue(capacity=50,dtypes=[tf.float32,tf.float32],shapes=[[10],[2]])
enqueue_op=queue.enqueue_many([X,Y])
dequeue_op=queue.dequeue()

qr=tf.train.QueueRunner(queue,[enqueue_op]*2)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    X_train_batch,y_train_batch=tf.train.batch(dequeue_op,batch_size=2)
    coord=tf.train.Coordinator()
    enqueue_threads=qr.create_threads(sess,coord,start=True)
    sess.run(tf.local_variables_initializer())
    for epoch in range(100):
        print("inside loop1")
        for iter in range(5):
            print("inside loop2")
            if coord.should_stop():
                break
            batch_x,batch_y=sess.run([X_train_batch,y_train_batch])
            print("after sess.run")
            print(batch_x.shape)
            _=sess.run(optimizer,feed_dict={x_place:batch_x,y_place:batch_y})
        coord.request_stop()
        coord.join(enqueue_threads)

Which outputs,

inside loop1
inside loop2

As you can see,
Which stuck forever when it runs the batch_x,batch_y=sess.run([X_train_batch,y_train_batch]) line.
I don't know how could I solve this, or is this the proper way to train a model batch by batch?

Body:
After couple hour of searching, I found the Solution myself. So, I'm answering my own question now below.
The queues are filled by background threads, which are created when you call tf.train.start_queue_runners() If you don't call this method, the background threads will not start, the queues will remain empty, and the training op will block indefinitely waiting for input.

FIX:
call tf.train.start_queue_runners(sess) just before the training loop.
Like I did below:

queue=tf.FIFOQueue(capacity=50,dtypes=[tf.float32,tf.float32],shapes=[[10],[2]])
enqueue_op=queue.enqueue_many([X,Y])
dequeue_op=queue.dequeue()

qr=tf.train.QueueRunner(queue,[enqueue_op]*2)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    X_train_batch,y_train_batch=tf.train.batch(dequeue_op,batch_size=2)
    coord=tf.train.Coordinator()
    enqueue_threads=qr.create_threads(sess,coord,start=True)
    tf.train.start_queue_runners(sess)
    for epoch in range(100):
        print("inside loop1")
        for iter in range(5):
            print("inside loop2")
            if coord.should_stop():
                break
            batch_x,batch_y=sess.run([X_train_batch,y_train_batch])
            print("after sess.run")
            print(batch_x.shape)
            _=sess.run(optimizer,feed_dict={x_place:batch_x,y_place:batch_y})
        coord.request_stop()
        coord.join(enqueue_threads)


问:
Angular 2: ng build --prod errors while ng serve run without erros
I tried to deploy my angular 2 app to heroku, but when I try to build for production, a long list of error appears. I should mention, that on ng serve, the app is running without problems and errors.
The list of errors is showed in attached photo

I'm cannot find any solution for this problems. All main modules are updated to latest version. Thank you

答:
The first couple of lines are related to the fact that your property/method _centerMap is set as private. If you want to use a property/method in the template, it needs to be public (I am not sure about protected).

The lines Property X does not exist on type 'Object' is most likely related to your types. I think the type checking is more strict when you build for production compared to serving a development server. I assume somewhere in your code you have an object with properties and it looks something like this:

```<code>public myObject: Object = {
    fillColor: 'someValue',
    // other properties
};
</code>```

In that case the type checking fails because those properties are not defined on the default Object. To fix that error, either remove the type all together or change it to something like this:

```<code>public myObject: { fillColor: string } = {
    fillColor: 'someValue',
    // other properties
};
</code>```

In case you have a lot of properties in that object, I would suggest creating an Interface.

```<code>export default interface MyObject {
    fillColor: string;
}
</code>```

Which you could use like this:

```<code>import MyObject from '/path/to/the/interface';

public myObject: MyObject = {
    fillColor: 'someValue',
    // other properties
};
</code>```

The Property 'height' is private ... error is the same problem as you first couple of lines - property/method is set as private instead of public. The problem is just in a different file.

Body:
The first couple of lines are related to the fact that your property/method _centerMap is set as private. If you want to use a property/method in the template, it needs to be public (I am not sure about protected).

The lines Property X does not exist on type 'Object' is most likely related to your types. I think the type checking is more strict when you build for production compared to serving a development server. I assume somewhere in your code you have an object with properties and it looks something like this:

public myObject: Object = {
    fillColor: 'someValue',
    // other properties
};

In that case the type checking fails because those properties are not defined on the default Object. To fix that error, either remove the type all together or change it to something like this:

public myObject: { fillColor: string } = {
    fillColor: 'someValue',
    // other properties
};

In case you have a lot of properties in that object, I would suggest creating an Interface.

export default interface MyObject {
    fillColor: string;
}

Which you could use like this:

import MyObject from '/path/to/the/interface';

public myObject: MyObject = {
    fillColor: 'someValue',
    // other properties
};

The Property 'height' is private ... error is the same problem as you first couple of lines - property/method is set as private instead of public. The problem is just in a different file.


问:
python luigi localTarget pickle
I am running on Windows 7, Python 2.7 via Anaconda 4.3.17, Luigi 2.4.0, Pandas 0.18, sklearn version 0.18.  Per below, I am trying to have a luigi.LocalTarget output be a pickle to store a few different objects (using firstJob) and then read from that pickle in a dependent job (secondJob).  firstJob completes successfully if I run the following from the command line:

"python -m luigi --module luigiPickle firstJob --date 2017-06-07 --local-scheduler"

However, if I try running secondJob i.e.,

"python -m luigi --module luigiPickle secondJob --date 2017-06-07 --local-scheduler"

I get

```<code>Traceback (most recent call last):
  File "C:\Anaconda2\lib\site-packages\luigi-2.4.0-py2.7.egg\luigi\worker.py", l
ine 191, in run
    new_deps = self._run_get_new_deps()
  File "C:\Anaconda2\lib\site-packages\luigi-2.4.0-py2.7.egg\luigi\worker.py", l
ine 129, in _run_get_new_deps
    task_gen = self.task.run()
  File "luigiPickle.py", line 41, in run
    ret2 = pickle.load(inFile)
  File "C:\Anaconda2\lib\pickle.py", line 1384, in load
    return Unpickler(file).load()
  File "C:\Anaconda2\lib\pickle.py", line 864, in load
    dispatch[key](self)
  File "C:\Anaconda2\lib\pickle.py", line 1096, in load_global
    klass = self.find_class(module, name)
  File "C:\Anaconda2\lib\pickle.py", line 1130, in find_class
    __import__(module)
ImportError: No module named frame
</code>```

It appears that luigi is having trouble reading the pickle due to not recognizing the pandas.DataFrame() object (perhaps a scope issue?).

```<code>import luigi
import pandas as pd
import pickle
from sklearn.linear_model import LinearRegression

class firstJob(luigi.Task):
    date = luigi.DateParameter()

    def requires(self):
        return None

    def output(self):
        return luigi.LocalTarget('%s_first.pickle' % self.date)

    def run(self):
        ret = {}
        ret['a'] = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
        ret['b'] = pd.DataFrame({'a': [3, 4], 'd': [0, 0]})
        ret['c'] = LinearRegression()
        outFile = self.output().open('wb')
        pickle.dump(ret, outFile, protocol=pickle.HIGHEST_PROTOCOL)
        outFile.close()

class secondJob(luigi.Task):
    date = luigi.DateParameter()

    def requires(self):
        return firstJob(self.date)

    def output(self):
        return luigi.LocalTarget('%s_second.pickle' % self.date)

    def run(self):
        inFile = self.input().open('rb')
        ret2 = pickle.load(inFile)
        inFile.close()

if __name__ == '__main__':
    luigi.run()
</code>```

答:
The luigi open command doesn't work with the b flag for binary- it strips it out of the options string. (not sure why). Better to just use standard open with the path attribute:

open(self.input().path, 'rb') and open(self.output().path, 'wb').

Title: python luigi localTarget pickle

Body:
I am running on Windows 7, Python 2.7 via Anaconda 4.3.17, Luigi 2.4.0, Pandas 0.18, sklearn version 0.18.  Per below, I am trying to have a luigi.LocalTarget output be a pickle to store a few different objects (using firstJob) and then read from that pickle in a dependent job (secondJob).  firstJob completes successfully if I run the following from the command line:

"python -m luigi --module luigiPickle firstJob --date 2017-06-07 --local-scheduler"

However, if I try running secondJob i.e.,

"python -m luigi --module luigiPickle secondJob --date 2017-06-07 --local-scheduler"

I get

Traceback (most recent call last):
  File "C:\Anaconda2\lib\site-packages\luigi-2.4.0-py2.7.egg\luigi\worker.py", l
ine 191, in run
    new_deps = self._run_get_new_deps()
  File "C:\Anaconda2\lib\site-packages\luigi-2.4.0-py2.7.egg\luigi\worker.py", l
ine 129, in _run_get_new_deps
    task_gen = self.task.run()
  File "luigiPickle.py", line 41, in run
    ret2 = pickle.load(inFile)
  File "C:\Anaconda2\lib\pickle.py", line 1384, in load
    return Unpickler(file).load()
  File "C:\Anaconda2\lib\pickle.py", line 864, in load
    dispatch[key](self)
  File "C:\Anaconda2\lib\pickle.py", line 1096, in load_global
    klass = self.find_class(module, name)
  File "C:\Anaconda2\lib\pickle.py", line 1130, in find_class
    __import__(module)
ImportError: No module named frame

It appears that luigi is having trouble reading the pickle due to not recognizing the pandas.DataFrame() object (perhaps a scope issue?).

import luigi
import pandas as pd
import pickle
from sklearn.linear_model import LinearRegression

class firstJob(luigi.Task):
    date = luigi.DateParameter()

    def requires(self):
        return None

    def output(self):
        return luigi.LocalTarget('%s_first.pickle' % self.date)

    def run(self):
        ret = {}
        ret['a'] = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
        ret['b'] = pd.DataFrame({'a': [3, 4], 'd': [0, 0]})
        ret['c'] = LinearRegression()
        outFile = self.output().open('wb')
        pickle.dump(ret, outFile, protocol=pickle.HIGHEST_PROTOCOL)
        outFile.close()

class secondJob(luigi.Task):
    date = luigi.DateParameter()

    def requires(self):
        return firstJob(self.date)

    def output(self):
        return luigi.LocalTarget('%s_second.pickle' % self.date)

    def run(self):
        inFile = self.input().open('rb')
        ret2 = pickle.load(inFile)
        inFile.close()

if __name__ == '__main__':
    luigi.run()


问:
plus minus collapse with css javascript and jquery
I want this to be solved only using css javascript/ jquery I want these accordion to get fa-minus when expanded and fa-plus when collapsed

I want the class to change to fa-minus when expanded and fa-plus when collapsed

CSS

```<code><style>
p.accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
}

i.accordion , p.accordion {
    background-color: #ddd;
}
ul {
    padding: 0 18px;
    display: none;
    background-color: white;
}
</style>
</head>
</code>```

HTML

```<code><h2>Accordion</h2>

          <p class="accordion">Service <i style="padding-right:100px;" class="accordion fa fa-plus" aria-hidden="true"></i></p>
          <ul class="panel footer-links">
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Order Status</a></li>
            <li><a href="#">faq</a></li>
            <li><a href="#">shipping policy</a></li>
            <li><a href="#">return policy</a></li>
            <li><a href="#">Newsletter</a></li>
            <li><a href="#">My Account</a></li>
            <li><a href="#">Live Chat</a></li>
          </ul>

   <p class="accordion">shop <i class="accordion fa fa-plus" aria-hidden="true"></i></p>
          <ul class="panel footer-links">
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Order Status</a></li>
            <li><a href="#">faq</a></li>
            <li><a href="#">shipping policy</a></li>
            <li><a href="#">return policy</a></li>
            <li><a href="#">Newsletter</a></li>
            <li><a href="#">My Account</a></li>
            <li><a href="#">Live Chat</a></li>
          </ul>
</code>```

JS

```<code><script>
var acc = document.getElementsByClassName("accordion");
var i;
var plus = document.getElementsByClassName("fa-plus");

for (i = 0; i < acc.length; i++) {
    acc[i].onclick = function(){

        this.classList.toggle("active");
        console.log(this);
        $(this>i).hide();
        $('<i>').addClass('fa-minus');

        var ul = this.nextElementSibling;

        if (ul.style.display === "block") {
            ul.style.display = "none";
            //    $("").show();
        } else {
            ul.style.display = "block";

        }
    }
}
</script>
</code>```

答:
change $('').addClass('fa-minus'); to $(this).find('i').toggleClass('fa-minus');

var acc = document.getElementsByClassName("accordion");
var i;
var plus = document.getElementsByClassName("fa-plus");

for (i = 0; i < acc.length; i++) {
    acc[i].onclick = function(){

        this.classList.toggle("active");
        console.log(this);
        $(this>i).hide();
        $(this).find('i').toggleClass('fa-minus');

        var ul = this.nextElementSibling;

        if (ul.style.display === "block") {
            ul.style.display = "none";
            //    $("").show();
        } else {
            ul.style.display = "block";

        }
    }
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>p.accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
}

i.accordion , p.accordion {
    background-color: #ddd;
}
ul {
    padding: 0 18px;
    display: none;
    background-color: white;
}</code>```

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

Accordion

Service

Contact Us

Order Status

faq

shipping policy

return policy

Newsletter

My Account

Live Chat

shop

Contact Us

Order Status

faq

shipping policy

return policy

Newsletter

My Account

Live Chat

```

Body:
I want this to be solved only using css javascript/ jquery I want these accordion to get fa-minus when expanded and fa-plus when collapsed

I want the class to change to fa-minus when expanded and fa-plus when collapsed

CSS

HTML

Accordion

Service

Contact Us

Order Status

faq

shipping policy

return policy

Newsletter

My Account

Live Chat

shop

Contact Us

Order Status

faq

shipping policy

return policy

Newsletter

My Account

Live Chat

JS

Body:
change $('<i>').addClass('fa-minus'); to $(this).find('i').toggleClass('fa-minus');

var acc = document.getElementsByClassName("accordion");
var i;
var plus = document.getElementsByClassName("fa-plus");

for (i = 0; i < acc.length; i++) {
    acc[i].onclick = function(){

        this.classList.toggle("active");
        console.log(this);
        $(this>i).hide();
        $(this).find('i').toggleClass('fa-minus');

        var ul = this.nextElementSibling;

        if (ul.style.display === "block") {
            ul.style.display = "none";
            //    $("").show();
        } else {
            ul.style.display = "block";

        }
    }
}

p.accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
}

i.accordion , p.accordion {
    background-color: #ddd;
}
ul {
    padding: 0 18px;
    display: none;
    background-color: white;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<h2>Accordion</h2>

          <p class="accordion">Service <i style="padding-right:100px;" class="accordion fa fa-plus" aria-hidden="true"></i></p>
          <ul class="panel footer-links">
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Order Status</a></li>
            <li><a href="#">faq</a></li>
            <li><a href="#">shipping policy</a></li>
            <li><a href="#">return policy</a></li>
            <li><a href="#">Newsletter</a></li>
            <li><a href="#">My Account</a></li>
            <li><a href="#">Live Chat</a></li>
          </ul>

   <p class="accordion">shop <i class="accordion fa fa-plus" aria-hidden="true"></i></p>
          <ul class="panel footer-links">
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Order Status</a></li>
            <li><a href="#">faq</a></li>
            <li><a href="#">shipping policy</a></li>
            <li><a href="#">return policy</a></li>
            <li><a href="#">Newsletter</a></li>
            <li><a href="#">My Account</a></li>
            <li><a href="#">Live Chat</a></li>
          </ul>


问:
Remove comments following # (number sign) in shell
I have a text file text0.txt like

```<code># text0.txt
# This is comment
Hello, I like banana.  # more comments
bra bra bra...
</code>```

The question is what is the command

```<code>$ some_command text0.txt
</code>```

which outputs

```<code>Hello, I like banana.
bra bra bra...
</code>```

to standard output.

I'm using bash.
Thanks.

Body:
I have a text file text0.txt like

# text0.txt
# This is comment
Hello, I like banana.  # more comments
bra bra bra...

The question is what is the command

$ some_command text0.txt

which outputs

Hello, I like banana.
bra bra bra...

to standard output.

I'm using bash.
Thanks.

Body:
with awk:

awk '{a=length($0);gsub("#.*","",$0); if(a==0 || length($0)>0)print $0}' filename


问:
summernote - resized image showing without resize in html
I am using angular-summernote.

When I try to resize an image using summernotes option, it is being resized in the editor but when I render that html somewhere, original one is being shown but not the resized one.

Any idea what I missed ?

答:
I had the same problem with summernote--the answer here worked for me:
ng-bind-html strips elements attributes

From sylwester's answer:

in your js please add method:

```<code>$scope.to_trusted = function(html_code) {
return $sce.trustAsHtml(html_code);
</code>```

and in view :

```<code><p ng-bind-html="to_trusted(message)"></p>
</code>```

Don't forget to inject the $sce service to your controller.

Edit: node XSS will also strip the style tags if you are using it, so check that as well.

Body:
I had the same problem with summernote--the answer here worked for me:
ng-bind-html strips elements attributes

From sylwester's answer:

in your js please add method:

$scope.to_trusted = function(html_code) {
return $sce.trustAsHtml(html_code);

and in view :

<p ng-bind-html="to_trusted(message)"></p>

Don't forget to inject the $sce service to your controller.

Edit: node XSS will also strip the style tags if you are using it, so check that as well.


问:
Regular expression to replace all ' between two tags
How do I replace all ' with ' between <?php and ?> tags with regular expression in PHP?

My string: <?php $test = 'hello'; ?>

答:
```<code>use str_replace

$test =" 'hello';"

str_replace("&apos","'",$test )
</code>```

Body:
use str_replace

$test =" &apos;hello&apos;;"

str_replace("&apos","'",$test )


问:
How to disable animation for md-tabs in Angular JS?
I want to disable the animation for the content while tab switching. I want animation only for tabs not for the content.

I tried md-no-ink, but its not working for me. I tied moving the tab contents to outside md-tabs tags also. But this is also not working.

```<code><md-tabs md-dynamic-height md-border-bottom md-no-ink md-no-bar>
      <md-tab label="Re-Iterate Inputs" ng-if="models.length<3">
        <md-content class="md-padding">
          <div id="model_detail">
            <div class="jqx-table" style="margin-bottom: 20px; " >
                <div id="jqxModelParamRe"></div>
            </div>
            <h4 class="s-title">Input Parameters</h4>
            <form id="paraForm" name="paraForm">
                <div layout>
                <div flex=20 layout="column">
                    <label class="input-label">No. of Trees</label>
                    <md-input-container md-no-float>
                        <input type="number" step="1" min="1"  onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" ng-disabled="model.readOnlyBtn" placeholder=">0 Integer " name=nTree ng-model="model.nTree" class="input-div" required>
                            <div ng-messages="paraForm.nTree.$error" multiple md-auto-hide="false">
                              <div ng-message="required">
                                This field is required
                              </div>
                              <div ng-message="min">
                                Value should be greater than 0
                              </div>
                            </div>
                    </md-input-container>
                </div>
                <div flex=20 flex-offset=5 layout="column">
                    <label class="input-label">Depth of Trees</label>
                    <md-input-container md-no-float>
                        <input ng-disabled="model.readOnlyBtn" type="number" step="1" min="1"  onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57"
                  name="dTree" placeholder=">0 Integer " ng-model="model.dTree" class="input-div" required>
                        <div ng-messages="paraForm.dTree.$error" multiple md-auto-hide="false">
                          <div ng-message="required">
                            This field is required
                          </div>
                          <div ng-message="min">
                            Value should be greater than 0
                          </div>
                        </div>
                    </md-input-container>
                </div>
                <div flex=20 flex-offset=5 layout="column">
                    <label class="input-label">Learning Rate</label>
                    <md-input-container md-no-float>
                        <input ng-disabled="model.readOnlyBtn" type="number" min=0 max=1 placeholder="from 0.0 to 1.0"
                  name="l_rate" ng-model="model.learning_rate" class="input-div" required>
                        <div ng-messages="paraForm.l_rate.$error" multiple md-auto-hide="false">
                          <div ng-message="required">
                            This field is required
                          </div>

                          <div ng-message="min">
                            Value should be greater than 0
                          </div>

                          <div ng-message="max">
                             Value should be smaller than 1
                          </div>
                        </div>
                    </md-input-container>
                </div>
               </div>
               <div style="clear: both;"></div>
                <md-button ng-disabled="model.readOnlyBtn" type=submit id="step-btn"
              class="build-model md-raised step-btn md-primary md-button md-ink-ripple"
              ng-click="setReIterate()">
                Build Model</md-button>
              </form>
          </div>
        </md-content>
      </md-tab>
      <md-tab label="Set Schedule">
        <md-content class="md-padding">
          <div id="schedule">
            <form id="schedule_form" name="schedule_form" novalidate>
            <h2 class="img-title"><img src="img/time.png" style="margin-right:8px;">Schedule</h2>

            <p style="text-transform: uppercase;
                    font-weight: 500;
                    box-sizing: border-box;font-size:14px;padding-top:20px;">
                  Select Iteration
            </p>
            <div layout="row" style="margin-bottom:40px;">
              <div ng-repeat="i in models track by $index" layout="column" ng-class="i_class[$index]" ng-click="i_activate($index)">
                Iteration {{$index+1}}
              </div>
            </div>

            <p style="text-transform: uppercase;
                    font-weight: 500;
                    box-sizing: border-box;
                    font-size:14px;">
                  Deployment Options
            </p>
            <div layout="row" style="margin-bottom:40px;">
              <div ng-repeat="i in d_class track by $index" layout="column" ng-click="d_activate($index)">
                <span ng-show="$index == 0" ng-class="d_class[$index]">Continue Without Deployment</span>
                <span ng-show="$index == 1" ng-class="d_class[$index]">Deploy To Production</span>
              </div>
            </div>
            <div layout="column">
            <p style="text-transform: uppercase;
                    font-weight: 500;
                    box-sizing: border-box;
                    font-size:14px;" ng-show="d_selected == 1">
                  Select Server
            </p>
            <div ng-show="d_selected == 1">
            <select ng-model="deploy_server" class="form-control"
                 ng-options="x.ref_key as x.ref_value for x in master_data.deploy_server" required style="width:300px;margin-bottom:40px;">
           </select>
            </div>
            </div>

            <div layout>
                <div flex=20 layout="column">
                    <label>Start Date</label>
                <md-datepicker md-placeholder="Start date" ng-model="schedule.start_date" required >
                </md-datepicker>
                </div>
                <div flex=20 layout="column">
                    <label>End Date</label>
                <md-datepicker md-placeholder="End Date" ng-model="schedule.end_date" required md-min-date="schedule.start_date">
                </md-datepicker>
                </div>
            </div>
            <div layout="row" flex style="margin-top:10px;">
                <div flex=20 layout="column">
                    <label class="input-label">Frequency to Retrain </label>
                    <md-input-container>
                  <select ng-disabled="model.readOnly" ng-model="schedule.frequency" required
                       ng-options="x.ref_key as x.ref_value for x in master_data.sch_freq" required style="height: 33px;
                      width: 140px; padding-left:5px">
                 </select>
                        <div ng-messages="schedule_form.frequency.$error">
                            <div ng-message="required">Required</div>
                        </div>
                    </md-input-container>
                </div>
              <div layout="column" flex=40></div>
            </div>
            <h4 class="s-title">File Settings</h4>
           <div ng-repeat="item in trainObject" class="train_setting">
            <div id="train_setting" style="margin-bottom: 20px;">
            <div class="sep-hr"></div>
              <div layout>
                <div flex=40 layout="column">
                <div>
                    <label class="input-label">Training Folder Path</label>
                </div>
                  <div layout  id="train_folder_path">
                  <md-input-container  md-no-float flex=100>
                      <input  ng-change="changeTrainName($index)" ng-model="item.folder_path" name="item.folder_path" placeholder="Enter full file path/Select Time array options from below" class="input-div" required>
                </md-input-container>
                    </div>
              </div>
                </div>
              <div layout class="s-title" style="color:rgb(53, 151, 218); margin-bottom:20px; font-size:14px; ">Add any delimiter between the wild characters as per your file name</div>

             <div layout>
                <div flex=40 layout="column">
                <div style="margin-bottom: 5px;">
                    <label class="input-label">File Time Array</label>
                </div>
                <div layout>
                    <div flex=20>
                        <md-checkbox  ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{YYYY}',item.yyyy,$index);"
                        ng-model="item.yyyy" aria-label="Checkbox 1">
                            YYYY
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{MM}',item.mm,$index)"
                        ng-model="item.mm" aria-label="Checkbox 1">
                            MM
                        </md-checkbox>
                    </div>
                    <div flex=20>
                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{Week}',item.week,$index)" ng-model="item.week" aria-label="Checkbox 1">
                            Week
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{DD}',item.dd,$index)"
                        ng-model="item.dd" aria-label="Checkbox 1">
                            DD
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{Hr}',item.hr,$index)"
                        ng-model="item.hr" aria-label="Checkbox 1">
                            Hr
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{Min}',item.min,$index)"
                        ng-model="item.min" aria-label="Checkbox 1">
                            Min
                        </md-checkbox>
                    </div>
                </div>
              </div>
             </div>

             <div layout>
               <span style="padding-top:5px;padding-right:20px;">Select Last</span>
               <input type="number" step="1" min="1"
                      style="width: 50px;margin-right: 30px;" ng-model="item.file_range"/>
              <select ng-model="item.file_range_unit" required
                    ng-options="x.ref_key as x.ref_value for x in master_data.sch_files" required style="height: 33px;
                   width: 140px; padding-left:5px" >
              </select>
             </div>

             </div>
             </div>
             <div class="sep-hr"></div>
              <div layout style="margin-bottom: 20px;">

                  <div ng-click="addTrainObject()" flex=9>
                    <span  class="path-plus-btn" style="cursor: pointer; font-size:20px; color:rgb(53, 151, 218);">
                    <i class="fa fa-plus-circle" aria-hidden="true"></i>
                    <span style="font-size: 14px;">Add training folder</span>
                    </span>

                  </div>

                  <div flex=20>
                    <span ng-click="deleteTrainObject()" class="path-minus-btn" style="cursor: pointer; font-size:20px; color:rgb(53, 151, 218); margin-left: 10px;">
                        <i class="fa fa-minus-circle" aria-hidden="true"></i>
                        <span style="font-size: 14px;">Delete last training folder</span>
                    </span>
                </div>
            </div>

          <!--<hr style="width:900px;margin:20px 0px 30px 0px;">-->
            <div id="validation-folder">
            <div layout>
                <div flex=40 layout="column">
                <div>
                    <label class="input-label">Validation Folder Path  <span style="color:rgb(53, 151, 218); margin-left:20px;font-size:14px;">Only the latest file will be selected</span></label>
                </div>
                <md-input-container md-no-float>
                    <input  ng-change="changeValidName()" ng-model="schedule.valid_folder_path"  class="input-div" placeholder="Enter full file path/Select Time array options from below" required>
                   </md-input-container>
              </div>
               </div>
              <div layout class="s-title" style="color:rgb(53, 151, 218); margin-bottom: 20px;font-size:14px;">Add any delimiter between the wild characters as per your file name</div>

               <div layout>
                <div flex=40 layout="column">
                <div style="margin-bottom: 5px;">
                    <label class="input-label">File Time Array</label>
                </div>
                <div layout>
                    <div flex=20>
                        <md-checkbox ng-change="changeValidTimeArray('{YYYY}',schedule.valid_yy)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_yy" aria-label="Checkbox 1">
                            YYYY
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-change="changeValidTimeArray('{MM}',schedule.valid_mm)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_mm" aria-label="Checkbox 1">
                            MM
                        </md-checkbox>
                    </div>
                    <div flex=20>
                        <md-checkbox ng-change="changeValidTimeArray('{Week}',schedule.valid_week)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_week" aria-label="Checkbox 1">
                            Week
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-change="changeValidTimeArray('{DD}',schedule.valid_dd)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_dd" aria-label="Checkbox 1">
                            DD
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-change="changeValidTimeArray('{Hr}',schedule.valid_hr)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_hr" aria-label="Checkbox 1">
                            Hr
                        </md-checkbox>
                    </div>
                    <div flex=15>
                        <md-checkbox ng-change="changeValidTimeArray('{Min}',schedule.valid_min)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_min" aria-label="Checkbox 1">
                            Min
                        </md-checkbox>
                    </div>
                </div>
              </div>

             </div>
            </div>

            <div class="sep-hr"></div>
            <div class="clearfix"></div>
            <md-button ng-click="setFinalize('schedule')" type=submit id="step-btn" class="build-model md-raised step-btn md-primary md-button md-ink-ripple">Schedule</md-button>

             </form>

             <!-- end of form -->
             </div>

        </md-content>

      </md-tab>

      <md-tab label="Skip & Finalize">
        <md-content class="md-padding">
          <p style="text-transform: uppercase;
                  font-weight: 500;
                  box-sizing: border-box;
                  font-size:14px;">
                Select Iteration
          </p>
          <div layout="row" style="margin-bottom:40px;">
            <div ng-repeat="i in models track by $index" layout="column" ng-class="i_class[$index]" ng-click="i_activate($index)">
              Iteration {{$index+1}}
            </div>
          </div>
          <p style="text-transform: uppercase;
                  font-weight: 500;
                  box-sizing: border-box;
                  font-size:14px;">
                Deployment Options
          </p>
          <div layout="row" style="margin-bottom:40px;">
            <div ng-repeat="i in d_class track by $index" layout="column" ng-click="d_activate($index)">
              <span ng-show="$index == 0" ng-class="d_class[$index]">Continue Without Deployment</span>
              <span ng-show="$index == 1" ng-class="d_class[$index]">Deploy To Production</span>
            </div>
          </div>

          <p style="text-transform: uppercase; font-weight: 500; box-sizing: border-box; font-size:14px;" ng-show="d_selected == 1">Select server</p>
          <div ng-show="d_selected == 1">
            <select ng-model="deploy_server" class="form-control" ng-options="x.ref_key as x.ref_value for x in master_data.deploy_server" required style="width:300px;margin-bottom:40px;"></select>
          </div>
          <md-button type=submit id="step-btn" class="build-model md-raised step-btn md-primary md-button md-ink-ripple" ng-click="setFinalize()">Save</md-button>
        </md-content>
      </md-tab>
    </md-tabs>
</code>```

答:
I have tried with your demo and its working with md-no-ink.
check my codepen

See the Pen Material Tabs by Bhavan Patel (@BhavanPatel).

Body:
I want to disable the animation for the content while tab switching. I want animation only for tabs not for the content.

I tried md-no-ink, but its not working for me. I tied moving the tab contents to outside md-tabs tags also. But this is also not working.

<md-tabs md-dynamic-height md-border-bottom md-no-ink md-no-bar>
      <md-tab label="Re-Iterate Inputs" ng-if="models.length<3">
        <md-content class="md-padding">

Input Parameters

            <form id="paraForm" name="paraForm">

                    No. of Trees
                    <md-input-container md-no-float>
                        <input type="number" step="1" min="1"  onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" ng-disabled="model.readOnlyBtn" placeholder=">0 Integer " name=nTree ng-model="model.nTree" class="input-div" required>

                                This field is required

                                Value should be greater than 0

                    </md-input-container>

                    Depth of Trees
                    <md-input-container md-no-float>
                        <input ng-disabled="model.readOnlyBtn" type="number" step="1" min="1"  onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57"
                  name="dTree" placeholder=">0 Integer " ng-model="model.dTree" class="input-div" required>

                            This field is required

                            Value should be greater than 0

                    </md-input-container>

                    Learning Rate
                    <md-input-container md-no-float>
                        <input ng-disabled="model.readOnlyBtn" type="number" min=0 max=1 placeholder="from 0.0 to 1.0"
                  name="l_rate" ng-model="model.learning_rate" class="input-div" required>

                            This field is required

                            Value should be greater than 0

                             Value should be smaller than 1

                    </md-input-container>

                <md-button ng-disabled="model.readOnlyBtn" type=submit id="step-btn"
              class="build-model md-raised step-btn md-primary md-button md-ink-ripple"
              ng-click="setReIterate()">
                Build Model</md-button>
              </form>

        </md-content>
      </md-tab>
      <md-tab label="Set Schedule">
        <md-content class="md-padding">

            <form id="schedule_form" name="schedule_form" novalidate>

Schedule

                  Select Iteration

                Iteration {{$index+1}}

                  Deployment Options

                Continue Without Deployment
                Deploy To Production

                  Select Server

            <select ng-model="deploy_server" class="form-control"
                 ng-options="x.ref_key as x.ref_value for x in master_data.deploy_server" required style="width:300px;margin-bottom:40px;">
           </select>

                    Start Date
                <md-datepicker md-placeholder="Start date" ng-model="schedule.start_date" required >
                </md-datepicker>

                    End Date
                <md-datepicker md-placeholder="End Date" ng-model="schedule.end_date" required md-min-date="schedule.start_date">
                </md-datepicker>

                    Frequency to Retrain
                    <md-input-container>
                  <select ng-disabled="model.readOnly" ng-model="schedule.frequency" required
                       ng-options="x.ref_key as x.ref_value for x in master_data.sch_freq" required style="height: 33px;
                      width: 140px; padding-left:5px">
                 </select>

Required

                    </md-input-container>

File Settings

                    Training Folder Path

                  <md-input-container  md-no-float flex=100>
                      <input  ng-change="changeTrainName($index)" ng-model="item.folder_path" name="item.folder_path" placeholder="Enter full file path/Select Time array options from below" class="input-div" required>
                </md-input-container>

Add any delimiter between the wild characters as per your file name

                    File Time Array

                        <md-checkbox  ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{YYYY}',item.yyyy,$index);"
                        ng-model="item.yyyy" aria-label="Checkbox 1">
                            YYYY
                        </md-checkbox>

                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{MM}',item.mm,$index)"
                        ng-model="item.mm" aria-label="Checkbox 1">
                            MM
                        </md-checkbox>

                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{Week}',item.week,$index)" ng-model="item.week" aria-label="Checkbox 1">
                            Week
                        </md-checkbox>

                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{DD}',item.dd,$index)"
                        ng-model="item.dd" aria-label="Checkbox 1">
                            DD
                        </md-checkbox>

                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{Hr}',item.hr,$index)"
                        ng-model="item.hr" aria-label="Checkbox 1">
                            Hr
                        </md-checkbox>

                        <md-checkbox ng-disabled="model.readOnly" class="md-warn" ng-change="changeTimeArray('{Min}',item.min,$index)"
                        ng-model="item.min" aria-label="Checkbox 1">
                            Min
                        </md-checkbox>

               Select Last
               <input type="number" step="1" min="1"
                      style="width: 50px;margin-right: 30px;" ng-model="item.file_range"/>
              <select ng-model="item.file_range_unit" required
                    ng-options="x.ref_key as x.ref_value for x in master_data.sch_files" required style="height: 33px;
                   width: 140px; padding-left:5px" >
              </select>

                    Add training folder

                        Delete last training folder

                    Validation Folder Path  Only the latest file will be selected

                <md-input-container md-no-float>
                    <input  ng-change="changeValidName()" ng-model="schedule.valid_folder_path"  class="input-div" placeholder="Enter full file path/Select Time array options from below" required>
                   </md-input-container>

Add any delimiter between the wild characters as per your file name

                    File Time Array

                        <md-checkbox ng-change="changeValidTimeArray('{YYYY}',schedule.valid_yy)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_yy" aria-label="Checkbox 1">
                            YYYY
                        </md-checkbox>

                        <md-checkbox ng-change="changeValidTimeArray('{MM}',schedule.valid_mm)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_mm" aria-label="Checkbox 1">
                            MM
                        </md-checkbox>

                        <md-checkbox ng-change="changeValidTimeArray('{Week}',schedule.valid_week)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_week" aria-label="Checkbox 1">
                            Week
                        </md-checkbox>

                        <md-checkbox ng-change="changeValidTimeArray('{DD}',schedule.valid_dd)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_dd" aria-label="Checkbox 1">
                            DD
                        </md-checkbox>

                        <md-checkbox ng-change="changeValidTimeArray('{Hr}',schedule.valid_hr)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_hr" aria-label="Checkbox 1">
                            Hr
                        </md-checkbox>

                        <md-checkbox ng-change="changeValidTimeArray('{Min}',schedule.valid_min)" ng-disabled="model.readOnly" class="md-warn" ng-model="schedule.valid_min" aria-label="Checkbox 1">
                            Min
                        </md-checkbox>

            <md-button ng-click="setFinalize('schedule')" type=submit id="step-btn" class="build-model md-raised step-btn md-primary md-button md-ink-ripple">Schedule</md-button>

             </form>

        </md-content>

      </md-tab>

      <md-tab label="Skip & Finalize">
        <md-content class="md-padding">

                Select Iteration

              Iteration {{$index+1}}

                Deployment Options

              Continue Without Deployment
              Deploy To Production

Select server

            <select ng-model="deploy_server" class="form-control" ng-options="x.ref_key as x.ref_value for x in master_data.deploy_server" required style="width:300px;margin-bottom:40px;"></select>

          <md-button type=submit id="step-btn" class="build-model md-raised step-btn md-primary md-button md-ink-ripple" ng-click="setFinalize()">Save</md-button>
        </md-content>
      </md-tab>
    </md-tabs>


问:
mysql failover: how to choose slave as new master?
I'm mysql newbie.

when it comes to fail-over, which slave should be promoted to the new master?

For example, A is master, B and C are slaves, and A does async replication to B and C.

At some point of time, B receives more data from A than C, A crashes.

If we promote C to new master, and changes B's master to C, then what happens to B? It truncates its data to match C?

Obviously, B is the best new master candidate, but my question is, how to determine this fact?

答:
From the MySQL documentation, there two ways to set up a master-slave architecture. The traditional way, using the log files to replicate transactions and the new version (5.6+) using GTIDs (global transaction identifiers).

If you choose to use GTIDs to make the failover handling you will use the mysqlfailover utility. The utility handles fails of master in one of three ways defined by the database administrator:

auto (default): A search is made in a list of prefered slaves to become master, if none are available another slave is chosen. The chosen slave first becomes the slave to all others slaves and has all the changes from the other slaves copied to it, this way the new master will be the most up to date version possible.

elect: the same as above, except that if no slaves from the list are available it returns an error and finishes (no failover)

fail: No failover happens mysqlfailover will just monitor the database and return an error if a fail happens.

The traditional way requires that you implement your own script to database management and is better explained here.