问:
Pytest fixture with scope "class" running on every method
I'm trying to create a test environment with Pytest. The idea is to group test methods into classes.

For every class/group, I want to attach a config fixture that is going to be parametrized. So that I can run all the tests with "configuration A" and then all tests with "configuration B" and so on.

But also, I want a reset fixture, that can be executed before specific methods or all methods of a class.

The problem I have there is, once I apply my reset fixture (to a method or to a whole class), the config fixture seems to work in the function scope instead of the class scope. So, once I apply the reset fixture, the config fixture is called before/after every method in the class.

The following piece of code reproduces the problem:

```<code>import pytest
from pytest import *

@fixture(scope='class')
def config(request):
    print("\nconfiguring with %s" % request.param)
    yield
    print("\ncleaning up config")

@fixture(scope='function')
def reset():
    print("\nreseting")

@mark.parametrize("config", ["config-A", "config-B"], indirect=True)
#@mark.usefixtures("reset")
class TestMoreStuff(object):

    def test_a(self, config):
        pass

    def test_b(self, config):
        pass

    def test_c(self, config):
        pass
</code>```

The test shows how the config fixture should work, being executed only once for the whole class. If you uncomment the usefixtures decoration, you can notice that the config fixture will be executed in every test method. Is it possible to use the reset fixture without triggering this behaviour?

答:
It depends on which version of pytest you are using.

There are some semantical problems to implement this in older versions of pytest. So, this idea is not yet implemented in older pytest. Someone has already given suggestion to implement the same. you can refer this

"Fixture scope doesn't work when parametrized tests use parametrized fixtures".
This was the bug.
You can refer this

This issue has been resolved in latest version of pytest. Here's the commit for the same with pytest 3.2.5

Hope it would help you.

Body:
I'm trying to create a test environment with Pytest. The idea is to group test methods into classes.

For every class/group, I want to attach a config fixture that is going to be parametrized. So that I can run all the tests with "configuration A" and then all tests with "configuration B" and so on.

But also, I want a reset fixture, that can be executed before specific methods or all methods of a class.

The problem I have there is, once I apply my reset fixture (to a method or to a whole class), the config fixture seems to work in the function scope instead of the class scope. So, once I apply the reset fixture, the config fixture is called before/after every method in the class.

The following piece of code reproduces the problem:

import pytest
from pytest import *

@fixture(scope='class')
def config(request):
    print("\nconfiguring with %s" % request.param)
    yield
    print("\ncleaning up config")

@fixture(scope='function')
def reset():
    print("\nreseting")

@mark.parametrize("config", ["config-A", "config-B"], indirect=True)
#@mark.usefixtures("reset")
class TestMoreStuff(object):

    def test_a(self, config):
        pass

    def test_b(self, config):
        pass

    def test_c(self, config):
        pass

The test shows how the config fixture should work, being executed only once for the whole class. If you uncomment the usefixtures decoration, you can notice that the config fixture will be executed in every test method. Is it possible to use the reset fixture without triggering this behaviour?


来源: stackexchange

问:
CMake does not find Visual C++ compiler
After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler.

```<code>The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (PROJECT):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:4 (PROJECT):
  No CMAKE_CXX_COMPILER could be found.
</code>```

I went searching for cl.exe in the Visual Studio folder,C:\Program Files\Microsoft Visual Studio 14.0, and could not find it.

How do I set up CMake to work on Windows with Visual Studio 2015?

答:
Menu → Visual Studio 2015 → MSBuild Command Prompt for Visual Studio 2015. Then CMake can find cl.exe.

```<code>set PATH="c:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\";%PATH%
</code>```

Change the upper path to where your Windows SDK is installed.

CMake can find rc.exe.

cd to the path of CMakeLists.txt and do:

```<code>md .build
cd .build
cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release
cmake --build .
</code>```

The param after -G should be fetched by CMake. Use --help; you may or may not have the generator.

ContentLicense: CC BY-SA 4.0

Title: CMake does not find Visual C++ compiler

Body:
After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler.

The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (PROJECT):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:4 (PROJECT):
  No CMAKE_CXX_COMPILER could be found.

I went searching for cl.exe in the Visual Studio folder,C:\Program Files\Microsoft Visual Studio 14.0, and could not find it.

How do I set up CMake to work on Windows with Visual Studio 2015?

Body:
Menu → Visual Studio 2015 → MSBuild Command Prompt for Visual Studio 2015. Then CMake can find cl.exe.

set PATH="c:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\";%PATH%

Change the upper path to where your Windows SDK is installed.

CMake can find rc.exe.

cd to the path of CMakeLists.txt and do:

md .build
cd .build
cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release
cmake --build .

The param after -G should be fetched by CMake. Use --help; you may or may not have the generator.


问:
Python - reordering items in list by moving some items to the front while keeping the rest in the same order
I am trying to reorder items in a list in a way illustrated by the following example:

Suppose the list before reordering is:

```<code>list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
</code>```

I want to implement a method called reorder_list(list, custom_order) such that:

```<code>list1 = reorder_list(list1, [3, 6, 12, 9])
print(list1)

Out: [3, 6, 9, 1, 2, 4, 5, 7, 8, 10]
</code>```

Explanation: [3, 6, 12, 9] is a custom order I am specifying. 12 is not in  list1 so it will be ignored. 3,6,9 are in list1, so they get moved to the front of the list and their order is the same as in [3, 6, 12, 9]. The remaining items in list1 are after 3,6,9 and in the original order.

Is there is an easier way (and a Pythonic way) than implementing the C-like loop code. For my purpose I care more about code simplicity than performance.

答:
The problem may be solved in the following way using itertools.chain and itertools.islice.

```<code>from itertools import chain, islice

lst = [1,2,3,4,5,6,7,8,9,10]
items_to_move = [9,6,3,12]

# move index i to front of list
def front(seq, i):
    item = islice(seq, i, i+1)
    start = islice(seq, 0, i, None)
    end = islice(seq, i+1, None)
    return list(chain(item,start,end))

for item in reversed(items_to_move):
    if item in lst:
        lst = front(lst, lst.index(item))
</code>```

Output:

```<code>[9, 6, 3, 1, 2, 4, 5, 7, 8, 10]
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to reorder items in a list in a way illustrated by the following example:

Suppose the list before reordering is:

list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

I want to implement a method called reorder_list(list, custom_order) such that:

list1 = reorder_list(list1, [3, 6, 12, 9])
print(list1)

Out: [3, 6, 9, 1, 2, 4, 5, 7, 8, 10]

Explanation: [3, 6, 12, 9] is a custom order I am specifying. 12 is not in  list1 so it will be ignored. 3,6,9 are in list1, so they get moved to the front of the list and their order is the same as in [3, 6, 12, 9]. The remaining items in list1 are after 3,6,9 and in the original order.

Is there is an easier way (and a Pythonic way) than implementing the C-like loop code. For my purpose I care more about code simplicity than performance.

Body:
The problem may be solved in the following way using itertools.chain and itertools.islice.

from itertools import chain, islice

lst = [1,2,3,4,5,6,7,8,9,10]
items_to_move = [9,6,3,12]

# move index i to front of list
def front(seq, i):
    item = islice(seq, i, i+1)
    start = islice(seq, 0, i, None)
    end = islice(seq, i+1, None)
    return list(chain(item,start,end))

for item in reversed(items_to_move):
    if item in lst:
        lst = front(lst, lst.index(item))

Output:

[9, 6, 3, 1, 2, 4, 5, 7, 8, 10]


问:
How to Filter ng-repeat list values Onclicking of Radio Button in Angularjs?
How can i filter category values in list, when clicking on a radio button?

My Plunker

Actually I want to filter category values in list of questions.

we have user data's and question data's in plunker.

user has two categories like "categories": ["Religion & Culture","Social Psychology"],.

question has various of categoryin list.

I am exactly looking to filter user categories values only, in that question category lists.

For Example :- in plunker we have displayed category values using of ng-repeat. the user categories array values are displayed using of two radio buttons, 1.Religion & Culture 2. Social Psychology. if we click the first radio button of Religion & Culture it's should filter only the Religion & Culture in question lists and if we click the second radio button of Social Psychology it's should filter only the religon & Culture values in question lists.  .

My HTML radio button:-

```<code>    <ul>
 <li ng-repeat="mani in users" ><input type="radio" name="myquestion" data-ng-model="myquestion" ng-value="{{mani.categories[0]}}"    id="{{mani.categories[0]}}"><label for="{{mani.categories[0]}" >{{mani.categories[0]}}</label>
 </li>

   <li ng-repeat="mani in users" ><input type="radio" name="myquestion" data-ng-model="myquestion" ng-value="{{mani.categories[1]}}"    id="{{mani.categories[1]}}"><label for="{{mani.categories[1]}" >{{mani.categories[1]}}</label>
      </li>

   </ul>
</code>```

My HTML Filter:-

```<code> ng-repeat="question in questions | filter:myquestion"
</code>```

My Html Data:-

```<code><div ng-repeat="question in questions | filter:myquestion">
  <small>
                <span >{{$index + 1}}.</span>
                  <span >{{question.category}}</span>
              </small>

 </div>
</code>```

My Controller User Data:-

```<code>    $scope.users=[
    {
"_id": "58e73c5c9e2f3f1421e241be",
"displayName": "sarawana kumar",
"provider": "local",
"location": "chennai",
"username": "sarawana",
"dob": "1991-10-04T18:30:00.000Z",
"phone": 7299345250,
"religion": "hindu",
"__v": 0,
"created": "2017-04-07T07:14:36.773Z",
"roles": [
"user"
],
"category": [],
"profileImageURL": "modules/users/client/img/profile/default.png",
"email": "sarawana@gmail.com",
"categories": [
"Religion & Culture",
"Social Psychology"
],
"lastName": "kumar",
"firstName": "sarawana"
}]
</code>```

My Question Data:-

```<code>    $scope.questions = [
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Religion & Culture",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},

{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Moral Ethics",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Social Psychology",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Environment & Health",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Religion & Culture",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Religion & Culture",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Social Psychology",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
}
]
</code>```

Plunker for reference.

We don't know where i did a mistake so please look my plunker for reference and help me.. please update the plunker as well to know the exact solution...thanks.

i have created similar answer please check this plunker http://plnkr.co/edit/1Zzc6nRylgETOvQp3SI2?p=preview i am exactly looking for the same answer in this plunker filtering the values but i want to filter user categories array values.....

答:
angular.module('myApp', []).controller('candidateCtrl', function($scope) {
    $scope.candidates = [
        {name:'Goutam',role:'Engineer',country:'Norway'},
        {name:'Carl',role:'Engineer',country:'Sweden'},
        {name:'Margareth',role:'Doctor',country:'England'},
        {name:'Hege',role:'Engineer',country:'Norway'},
        {name:'Joe',role:'Engineer',country:'Denmark'},
        {name:'Gustav',role:'Doctor',country:'Sweden'},
        {name:'Birgit',role:'Teacher',country:'Denmark'},
        {name:'Mary',role:'Engineer',country:'England'},
        {name:'Kai',role:'Teacher',country:'Norway'}
        ];

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

<body ng-app="myApp">

<div class="container" ng-controller="candidateCtrl">
<h2>Bootstrap inline Radio Buttons</h2>
<div class="row">
<div class="col-lg-4">
  <p>Angular JS Filter by Radio Button</p>
  <form>
    <label class="radio-inline">
      <input type="radio" name="optradio" ng-model="searchText.role" value="Engineer">Engineer
    </label>
    <label class="radio-inline">
      <input type="radio" name="optradio" ng-model="searchText.role" value="Doctor">Doctor
    </label>
    <label class="radio-inline">
      <input type="radio" name="optradio" ng-model="searchText.role" value="Teacher">Teacher
    </label>
  </form>

</div>
</div>

<div class="row">
<div class="col-lg-4">

  <table class="table table-hover">
    <thead>
      <tr>
        <th>Name</th>
        <th>Profession</th>
        <th>Country</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="candidate in candidates | filter:searchText:strict">
        <td>{{candidate.name}}</td>
        <td>{{candidate.role}}</td>
        <td>{{candidate.country}}</td>
      </tr>
    </tbody>
  </table>

</div>
</div>

</div></code>```

Body:
How can i filter category values in list, when clicking on a radio button?

My Plunker

Actually I want to filter category values in list of questions.

we have user data's and question data's in plunker.

user has two categories like "categories": ["Religion & Culture","Social Psychology"],.

question has various of categoryin list.

I am exactly looking to filter user categories values only, in that question category lists.

For Example :- in plunker we have displayed category values using of ng-repeat. the user categories array values are displayed using of two radio buttons, 1.Religion & Culture 2. Social Psychology. if we click the first radio button of Religion & Culture it's should filter only the Religion & Culture in question lists and if we click the second radio button of Social Psychology it's should filter only the religon & Culture values in question lists.  .

My HTML radio button:-

<input type="radio" name="myquestion" data-ng-model="myquestion" ng-value="{{mani.categories[0]}}"    id="{{mani.categories[0]}}">{{mani.categories[0]}}

<input type="radio" name="myquestion" data-ng-model="myquestion" ng-value="{{mani.categories[1]}}"    id="{{mani.categories[1]}}">{{mani.categories[1]}}

My HTML Filter:-

 ng-repeat="question in questions | filter:myquestion"

My Html Data:-

                {{$index + 1}}.
                  {{question.category}}

My Controller User Data:-

    $scope.users=[
    {
"_id": "58e73c5c9e2f3f1421e241be",
"displayName": "sarawana kumar",
"provider": "local",
"location": "chennai",
"username": "sarawana",
"dob": "1991-10-04T18:30:00.000Z",
"phone": 7299345250,
"religion": "hindu",
"__v": 0,
"created": "2017-04-07T07:14:36.773Z",
"roles": [
"user"
],
"category": [],
"profileImageURL": "modules/users/client/img/profile/default.png",
"email": "sarawana@gmail.com",
"categories": [
"Religion & Culture",
"Social Psychology"
],
"lastName": "kumar",
"firstName": "sarawana"
}]

My Question Data:-

    $scope.questions = [
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Religion & Culture",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},

{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Moral Ethics",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Social Psychology",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Environment & Health",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Religion & Culture",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Religion & Culture",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
},
{
"_id": "5863d3aaacaeddc00663bc07",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "2016-12-22T18:30:00.000Z",
"location": "chennai",
"religion": "hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136"
},

"friend_tag": [],
"emotion": "Confused",
"category": "Social Psychology",
"content": "mani",
"title": "Who Is the best Player?",
"created": "2016-12-28T15:00:58.777Z"
}
]

Plunker for reference.

We don't know where i did a mistake so please look my plunker for reference and help me.. please update the plunker as well to know the exact solution...thanks.

i have created similar answer please check this plunker http://plnkr.co/edit/1Zzc6nRylgETOvQp3SI2?p=preview i am exactly looking for the same answer in this plunker filtering the values but i want to filter user categories array values.....

Body:
angular.module('myApp', []).controller('candidateCtrl', function($scope) {
    $scope.candidates = [
        {name:'Goutam',role:'Engineer',country:'Norway'},
        {name:'Carl',role:'Engineer',country:'Sweden'},
        {name:'Margareth',role:'Doctor',country:'England'},
        {name:'Hege',role:'Engineer',country:'Norway'},
        {name:'Joe',role:'Engineer',country:'Denmark'},
        {name:'Gustav',role:'Doctor',country:'Sweden'},
        {name:'Birgit',role:'Teacher',country:'Denmark'},
        {name:'Mary',role:'Engineer',country:'England'},
        {name:'Kai',role:'Teacher',country:'Norway'}
        ];

});

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

<body ng-app="myApp">

<div class="container" ng-controller="candidateCtrl">
<h2>Bootstrap inline Radio Buttons</h2>
<div class="row">
<div class="col-lg-4">
  <p>Angular JS Filter by Radio Button</p>
  <form>
    <label class="radio-inline">
      <input type="radio" name="optradio" ng-model="searchText.role" value="Engineer">Engineer
    </label>
    <label class="radio-inline">
      <input type="radio" name="optradio" ng-model="searchText.role" value="Doctor">Doctor
    </label>
    <label class="radio-inline">
      <input type="radio" name="optradio" ng-model="searchText.role" value="Teacher">Teacher
    </label>
  </form>

</div>
</div>

<div class="row">
<div class="col-lg-4">

  <table class="table table-hover">
    <thead>
      <tr>
        <th>Name</th>
        <th>Profession</th>
        <th>Country</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="candidate in candidates | filter:searchText:strict">
        <td>{{candidate.name}}</td>
        <td>{{candidate.role}}</td>
        <td>{{candidate.country}}</td>
      </tr>
    </tbody>
  </table>

</div>
</div>

</div>


问:
Error "Read-only file system" in AWS Lambda when downloading a file from S3
I'm seeing the below error from my lambda function when I drop a file.csv into an S3 bucket. The file is not large and I even added a 60 second sleep prior to opening the file for reading, but for some reason the file has the extra ".6CEdFe7C" appended to it. Why is that?

```<code>[Errno 30] Read-only file system: u'/file.csv.6CEdFe7C': IOError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 75, in lambda_handler
s3.download_file(bucket, key, filepath)
File "/var/runtime/boto3/s3/inject.py", line 104, in download_file
extra_args=ExtraArgs, callback=Callback)
File "/var/runtime/boto3/s3/transfer.py", line 670, in download_file
extra_args, callback)
File "/var/runtime/boto3/s3/transfer.py", line 685, in _download_file
self._get_object(bucket, key, filename, extra_args, callback)
File "/var/runtime/boto3/s3/transfer.py", line 709, in _get_object
extra_args, callback)
File "/var/runtime/boto3/s3/transfer.py", line 723, in _do_get_object
with self._osutil.open(filename, 'wb') as f:
File "/var/runtime/boto3/s3/transfer.py", line 332, in open
return open(filename, mode)
IOError: [Errno 30] Read-only file system: u'/file.csv.6CEdFe7C'
</code>```

Code:

```<code>def lambda_handler(event, context):

    s3_response = {}
    counter = 0
    event_records = event.get("Records", [])

    s3_items = []
    for event_record in event_records:
        if "s3" in event_record:
            bucket = event_record["s3"]["bucket"]["name"]
            key = event_record["s3"]["object"]["key"]
            filepath = '/' + key
            print(bucket)
            print(key)
            print(filepath)
            s3.download_file(bucket, key, filepath)
</code>```

The result of the above is:

```<code>mytestbucket
file.csv
/file.csv
[Errno 30] Read-only file system: u'/file.csv.6CEdFe7C'
</code>```

If the key/file is "file.csv", then why does the s3.download_file method try to download "file.csv.6CEdFe7C"? I'm guessing when the function is triggered, the file is file.csv.xxxxx but by the time it gets to line 75, the file is renamed to file.csv?

答:
According to http://boto3.readthedocs.io/en/latest/guide/s3-example-download-file.html

The example shows how to use the first parameter for the cloud name and the second parameter for the local path to be downloaded.

in other hand, the amazaon docs, says

Thus, we have 512 MB for create files.
Here is my code on lambda aws, it works like charm.

```<code>.download_file(Key=nombre_archivo,Filename='/tmp/{}'.format(nuevo_nombre))
</code>```

Body:
I'm seeing the below error from my lambda function when I drop a file.csv into an S3 bucket. The file is not large and I even added a 60 second sleep prior to opening the file for reading, but for some reason the file has the extra ".6CEdFe7C" appended to it. Why is that?

[Errno 30] Read-only file system: u'/file.csv.6CEdFe7C': IOError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 75, in lambda_handler
s3.download_file(bucket, key, filepath)
File "/var/runtime/boto3/s3/inject.py", line 104, in download_file
extra_args=ExtraArgs, callback=Callback)
File "/var/runtime/boto3/s3/transfer.py", line 670, in download_file
extra_args, callback)
File "/var/runtime/boto3/s3/transfer.py", line 685, in _download_file
self._get_object(bucket, key, filename, extra_args, callback)
File "/var/runtime/boto3/s3/transfer.py", line 709, in _get_object
extra_args, callback)
File "/var/runtime/boto3/s3/transfer.py", line 723, in _do_get_object
with self._osutil.open(filename, 'wb') as f:
File "/var/runtime/boto3/s3/transfer.py", line 332, in open
return open(filename, mode)
IOError: [Errno 30] Read-only file system: u'/file.csv.6CEdFe7C'

Code:

def lambda_handler(event, context):

    s3_response = {}
    counter = 0
    event_records = event.get("Records", [])

    s3_items = []
    for event_record in event_records:
        if "s3" in event_record:
            bucket = event_record["s3"]["bucket"]["name"]
            key = event_record["s3"]["object"]["key"]
            filepath = '/' + key
            print(bucket)
            print(key)
            print(filepath)
            s3.download_file(bucket, key, filepath)

The result of the above is:

mytestbucket
file.csv
/file.csv
[Errno 30] Read-only file system: u'/file.csv.6CEdFe7C'

If the key/file is "file.csv", then why does the s3.download_file method try to download "file.csv.6CEdFe7C"? I'm guessing when the function is triggered, the file is file.csv.xxxxx but by the time it gets to line 75, the file is renamed to file.csv?

Body:
According to http://boto3.readthedocs.io/en/latest/guide/s3-example-download-file.html

The example shows how to use the first parameter for the cloud name and the second parameter for the local path to be downloaded.

in other hand, the amazaon docs, says

Thus, we have 512 MB for create files.
Here is my code on lambda aws, it works like charm.

.download_file(Key=nombre_archivo,Filename='/tmp/{}'.format(nuevo_nombre))


问:
When a function returns, how to close resource handles in C?
If I open a file handle, but the function encounters other error which is not file error,  before closing the handle, would the file handle be leaked?

```<code>FILE* fp = fopen("test.txt", "r");
if (other_condition) {
    perror("other error occurred!");
    return EXIT_FAILURE;
}
</code>```

How to use C to implement RAII template?

答:
In C, error checks should be manually written. (In C++, however, destructors are called automatically once an object expires.)</p>

```<code>FILE* fp = fopen("test.txt", "r");
if (fp == NULL) { file_open_error_code; } // Recommended
if (other_condition) {
    fclose(fp); // Manually close it
    perror("other error occurred!");
    return EXIT_FAILURE;
}
</code>```

Body:
If I open a file handle, but the function encounters other error which is not file error,  before closing the handle, would the file handle be leaked?

FILE* fp = fopen("test.txt", "r");
if (other_condition) {
    perror("other error occurred!");
    return EXIT_FAILURE;
}

How to use C to implement RAII template?

Body:
In C, error checks should be manually written. (In C++, however, destructors are called automatically once an object expires.)

FILE* fp = fopen("test.txt", "r");
if (fp == NULL) { file_open_error_code; } // Recommended
if (other_condition) {
    fclose(fp); // Manually close it
    perror("other error occurred!");
    return EXIT_FAILURE;
}


问:
div into a js button
I have a
 that I have formatted very carefully to look nice, and I need to make it have the functionality of a button. How would I go about doing this?

答:
```<code>document.getElementByID("#divID").addEventListenet('click',()=>{
//write your logic
})
</code>```

handle all button event similarly
e.g. doubleclick etc

Title: div into a js button

Body:
document.getElementByID("#divID").addEventListenet('click',()=>{
//write your logic
})

handle all button event similarly
e.g. doubleclick etc


问:
Python, using Full .NET?
I was trying out python in my browser using silverlight which is cool. Can i use python with .NET in a console or winform app? I hear silverlight is a stripped down .NET so it will load (or have a smaller download) on client machines. Can i use python with the full power of .NET? (perhaps outside of silver light)</p>

答:
You might try looking at IronPython.

Additionally, there's the Python for .NET project, but I haven't read much on it.

ContentLicense: CC BY-SA 2.5

Title: Python, using Full .NET?


问:
Hyperledger Composer BNA deployment results in 'TCP write failed'
I've followed the tutorial "Build your first network" for Hyperledger Fabric and added a CA. Now, when trying to deploy a BNA with composer, using composer network deploy -a maintenance-network.bna -p maintenance -i PeerAdmin -s randomString -A admin -S, i get an error:

```<code>~/network-setup$ composer network deploy -a ~/maintenance-
network/dist/maintenance-network.bna -p maint
enance -i PeerAdmin -s randomString -A admin -S
Deploying business network from archive: /home/vagrant/maintenance-
network/dist/maintenance-network.bna
Business network definition:
    Identifier: maintenance-network@0.1.11
    Description: Maintenance-network

✖ Deploying business network definition. This may take a minute...

Error: Error trying deploy. Error: Error trying install composer runtime.
Error: TCP Write failed
Command failed
</code>```

Does anyone know what the problem is ?

This is the output of docker ps:

```<code>IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                NAMES
2a4710a6805c        hyperledger/fabric-orderer   "orderer"                50 seconds ago      Up 48 seconds       0.0.0.0:7050->7050/tcp                               orderer.example.com
81b8cab17323        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 47 seconds       0.0.0.0:8051->8051/tcp, 0.0.0.0:8053->8053/tcp       peer1.org1.example.com
ed8f0148a402        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 48 seconds       0.0.0.0:9051->9051/tcp, 0.0.0.0:9053->9053/tcp       peer0.org2.example.com
9de5f3918f1d        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   50 seconds ago      Up 47 seconds       0.0.0.0:7054->7054/tcp                               ca_peerOrg1
d2d95dc6f20a        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   50 seconds ago      Up 48 seconds       7054/tcp, 0.0.0.0:8054->8054/tcp                     ca_peerOrg2
8396f528dc75        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 48 seconds       0.0.0.0:10051->10051/tcp, 0.0.0.0:10053->10053/tcp   peer1.org2.example.com
6b1185ea529a        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 48 seconds       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp       peer0.org1.example.com
</code>```

This is the connection.json i'm using:

```<code>    {
"type": "hlfv1",
"orderers": [
   { "url" : "grpc://localhost:7050" }
],
"ca": { "url": "http://localhost:7054",
        "name": "ca-org1"
},
"peers": [
        {
            "requestURL": "grpc://localhost:7051",
            "eventURL": "grpc://localhost:7053"
        },
        {
            "requestURL": "grpc://localhost:8051",
            "eventURL": "grpc://localhost:8053"
        },
        {
            "requestURL": "grpc://localhost:9051",
            "eventURL": "grpc://localhost:9053"
        },
        {
            "requestURL": "grpc://localhost:10051",
            "eventURL": "grpc://localhost:10053"
        }
],
"keyValStore": "/home/vagrant/.composer-credentials",
"channel": "mychannel",
"mspID": "Org1MSP",
"timeout": "300"
}
</code>```

The keyValStore contains the identity imported with:

```<code>composer identity import -p maintenance -u PeerAdmin -c crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem -k crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/*_sk
An identity was imported with name 'PeerAdmin' successfully
</code>```

The docker containers are started with this docker-compose-cli.yaml:

```<code>version: '2'

networks:
  byfn:
services:
  ca0:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_TLS_ENABLED=false
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg1
    networks:
      - byfn

  ca1:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org2
      - FABRIC_CA_SERVER_TLS_ENABLED=false
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY
    ports:
      - "8054:8054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2
    networks:
      - byfn

  orderer.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.example.com
    container_name: orderer.example.com
    networks:
      - byfn

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.example.com
    networks:
      - byfn

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org1.example.com
    networks:
      - byfn

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org2.example.com
    networks:
      - byfn

  peer1.org2.example.com:
    container_name: peer1.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org2.example.com
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools
    tty: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=false
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME} ${DELAY}; sleep $TIMEOUT'
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - ca0
      - ca1
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
      - peer0.org2.example.com
      - peer1.org2.example.com
    networks:
      - byfn
</code>```

And this is the output when running CHANNEL_NAME=mychannel docker-compose -f docker-compose-cli.yaml up -d:

```<code>|  ____    _____      _      ____    _____
| / ___|  |_   _|    / \    |  _ \  |_   _|
| \___ \    | |     / _ \   | |_) |   | |
|  ___) |   | |    / ___ \  |  _ <    | |
| |____/    |_|   /_/   \_\ |_| \_\   |_|
|
| Starting the network
|
| Channel name : mychannel
| Creating channel...
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org1MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer0.org1.example.com:7051
| 2017-11-15 09:31:36.011 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.012 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.017 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.018 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AC6060A074F7267314D535012BA062D...53616D706C65436F6E736F727469756D
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: D6E8392380793B24537309F14EA1C0D9CF3F18FF8292A65D09CF3AA92EA2094D
| 2017-11-15 09:31:36.019 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AFD060A1508021A0608F892B0D00522...628AB20AD0563C9EA2A482A301EA32D8
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 5A58E17C75478098A108CFCFA1E909639C7830022602D225A61C4D0BE9E8C5AD
| 2017-11-15 09:31:36.060 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
| 2017-11-15 09:31:36.060 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
| 2017-11-15 09:31:36.060 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
| 2017-11-15 09:31:36.060 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
| 2017-11-15 09:31:36.060 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0AFD060A1508021A0608F892B0D00522...5B18D1838ED112080A021A0012021A00
| 2017-11-15 09:31:36.060 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: 4309C46AA7BBA47AD146AA77CB1ABAC79114C9C3D66D41B833F82ED7F882E326
| 2017-11-15 09:31:36.082 UTC [channelCmd] readBlock -> DEBU 016 Received block: 0
| 2017-11-15 09:31:36.083 UTC [main] main -> INFO 017 Exiting.....
| ===================== Channel "mychannel" is created successfully =====================
|
| Having all peers join the channel...
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org1MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer0.org1.example.com:7051
| 2017-11-15 09:31:36.121 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.121 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.123 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.123 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC3070A5B08011A0B08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.123 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 5D870839DD3A368A48E2CED8314E3817CA48001BACBF74B36380408D851769AE
| 2017-11-15 09:31:36.158 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.158 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER0 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org1MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer1.org1.example.com:7051
| 2017-11-15 09:31:36.194 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.194 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.196 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.196 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC3070A5B08011A0B08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.196 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 0B0C3F308D78AC2FDD6FC89A71FED2DCB889038AE993980A6E4B540BB4D3C51A
| 2017-11-15 09:31:36.248 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.248 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER1 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org2MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer0.org2.example.com:7051
| 2017-11-15 09:31:36.288 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.288 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.289 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.290 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC4070A5C08011A0C08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.290 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 992F4939F777DD575F2753ADF6936A7E6FB9CC8548C188B31E25B06F9ECEA7E7
| 2017-11-15 09:31:36.335 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.335 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER2 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org2MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer1.org2.example.com:7051
| 2017-11-15 09:31:36.372 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.372 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.373 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.374 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC4070A5C08011A0C08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.374 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 6776D313E8DD88880918868C6BA2C93ECEB05425FE93A7E385762918FA2AF556
| 2017-11-15 09:31:36.419 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.419 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER3 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
|
| ========= All GOOD, BYFN execution completed ===========
</code>```

I'm using Ubuntu 16.04 and Composer v0.14.2.

答:
So, if anyone has the same issue: There were errors in the mapping of the docker ports. The ports of the peer docker containers should be 7051 and 7053, mapped to different ports on your host machine (e.g 8051, 9051, etc.).

Another error i found: I received the error Error: Failed to deserialize creator identity, err expected MSP ID Org2MSP, received Org1MSP. My peers at 7051 and 8051 have Org1MSP as MSP (Since they both belong to Org1), everyone else has Org2MSP. So, in the connection.json, you can't enter all peers at once. You have to create a connection.json for each MSP, with the peers connected to this MSP.

Body:
I've followed the tutorial "Build your first network" for Hyperledger Fabric and added a CA. Now, when trying to deploy a BNA with composer, using composer network deploy -a maintenance-network.bna -p maintenance -i PeerAdmin -s randomString -A admin -S, i get an error:

~/network-setup$ composer network deploy -a ~/maintenance-
network/dist/maintenance-network.bna -p maint
enance -i PeerAdmin -s randomString -A admin -S
Deploying business network from archive: /home/vagrant/maintenance-
network/dist/maintenance-network.bna
Business network definition:
    Identifier: maintenance-network@0.1.11
    Description: Maintenance-network

✖ Deploying business network definition. This may take a minute...

Error: Error trying deploy. Error: Error trying install composer runtime.
Error: TCP Write failed
Command failed

Does anyone know what the problem is ?

This is the output of docker ps:

IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                NAMES
2a4710a6805c        hyperledger/fabric-orderer   "orderer"                50 seconds ago      Up 48 seconds       0.0.0.0:7050->7050/tcp                               orderer.example.com
81b8cab17323        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 47 seconds       0.0.0.0:8051->8051/tcp, 0.0.0.0:8053->8053/tcp       peer1.org1.example.com
ed8f0148a402        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 48 seconds       0.0.0.0:9051->9051/tcp, 0.0.0.0:9053->9053/tcp       peer0.org2.example.com
9de5f3918f1d        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   50 seconds ago      Up 47 seconds       0.0.0.0:7054->7054/tcp                               ca_peerOrg1
d2d95dc6f20a        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   50 seconds ago      Up 48 seconds       7054/tcp, 0.0.0.0:8054->8054/tcp                     ca_peerOrg2
8396f528dc75        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 48 seconds       0.0.0.0:10051->10051/tcp, 0.0.0.0:10053->10053/tcp   peer1.org2.example.com
6b1185ea529a        hyperledger/fabric-peer      "peer node start"        50 seconds ago      Up 48 seconds       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp       peer0.org1.example.com

This is the connection.json i'm using:

    {
"type": "hlfv1",
"orderers": [
   { "url" : "grpc://localhost:7050" }
],
"ca": { "url": "http://localhost:7054",
        "name": "ca-org1"
},
"peers": [
        {
            "requestURL": "grpc://localhost:7051",
            "eventURL": "grpc://localhost:7053"
        },
        {
            "requestURL": "grpc://localhost:8051",
            "eventURL": "grpc://localhost:8053"
        },
        {
            "requestURL": "grpc://localhost:9051",
            "eventURL": "grpc://localhost:9053"
        },
        {
            "requestURL": "grpc://localhost:10051",
            "eventURL": "grpc://localhost:10053"
        }
],
"keyValStore": "/home/vagrant/.composer-credentials",
"channel": "mychannel",
"mspID": "Org1MSP",
"timeout": "300"
}

The keyValStore contains the identity imported with:

composer identity import -p maintenance -u PeerAdmin -c crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem -k crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/*_sk
An identity was imported with name 'PeerAdmin' successfully

The docker containers are started with this docker-compose-cli.yaml:

version: '2'

networks:
  byfn:
services:
  ca0:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_TLS_ENABLED=false
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg1
    networks:
      - byfn

  ca1:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org2
      - FABRIC_CA_SERVER_TLS_ENABLED=false
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY
    ports:
      - "8054:8054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2
    networks:
      - byfn

  orderer.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.example.com
    container_name: orderer.example.com
    networks:
      - byfn

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.example.com
    networks:
      - byfn

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org1.example.com
    networks:
      - byfn

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org2.example.com
    networks:
      - byfn

  peer1.org2.example.com:
    container_name: peer1.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org2.example.com
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools
    tty: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=false
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME} ${DELAY}; sleep $TIMEOUT'
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - ca0
      - ca1
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
      - peer0.org2.example.com
      - peer1.org2.example.com
    networks:
      - byfn

And this is the output when running CHANNEL_NAME=mychannel docker-compose -f docker-compose-cli.yaml up -d:

|  ____    _____      _      ____    _____
| / ___|  |_   _|    / \    |  _ \  |_   _|
| \___ \    | |     / _ \   | |_) |   | |
|  ___) |   | |    / ___ \  |  _ <    | |
| |____/    |_|   /_/   \_\ |_| \_\   |_|
|
| Starting the network
|
| Channel name : mychannel
| Creating channel...
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org1MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer0.org1.example.com:7051
| 2017-11-15 09:31:36.011 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.012 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.017 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.018 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AC6060A074F7267314D535012BA062D...53616D706C65436F6E736F727469756D
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: D6E8392380793B24537309F14EA1C0D9CF3F18FF8292A65D09CF3AA92EA2094D
| 2017-11-15 09:31:36.019 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
| 2017-11-15 09:31:36.019 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AFD060A1508021A0608F892B0D00522...628AB20AD0563C9EA2A482A301EA32D8
| 2017-11-15 09:31:36.019 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 5A58E17C75478098A108CFCFA1E909639C7830022602D225A61C4D0BE9E8C5AD
| 2017-11-15 09:31:36.060 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
| 2017-11-15 09:31:36.060 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
| 2017-11-15 09:31:36.060 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
| 2017-11-15 09:31:36.060 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
| 2017-11-15 09:31:36.060 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0AFD060A1508021A0608F892B0D00522...5B18D1838ED112080A021A0012021A00
| 2017-11-15 09:31:36.060 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: 4309C46AA7BBA47AD146AA77CB1ABAC79114C9C3D66D41B833F82ED7F882E326
| 2017-11-15 09:31:36.082 UTC [channelCmd] readBlock -> DEBU 016 Received block: 0
| 2017-11-15 09:31:36.083 UTC [main] main -> INFO 017 Exiting.....
| ===================== Channel "mychannel" is created successfully =====================
|
| Having all peers join the channel...
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org1MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer0.org1.example.com:7051
| 2017-11-15 09:31:36.121 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.121 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.123 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.123 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC3070A5B08011A0B08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.123 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 5D870839DD3A368A48E2CED8314E3817CA48001BACBF74B36380408D851769AE
| 2017-11-15 09:31:36.158 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.158 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER0 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org1MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer1.org1.example.com:7051
| 2017-11-15 09:31:36.194 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.194 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.196 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.196 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC3070A5B08011A0B08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.196 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 0B0C3F308D78AC2FDD6FC89A71FED2DCB889038AE993980A6E4B540BB4D3C51A
| 2017-11-15 09:31:36.248 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.248 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER1 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org2MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer0.org2.example.com:7051
| 2017-11-15 09:31:36.288 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.288 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.289 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.290 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC4070A5C08011A0C08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.290 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 992F4939F777DD575F2753ADF6936A7E6FB9CC8548C188B31E25B06F9ECEA7E7
| 2017-11-15 09:31:36.335 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.335 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER2 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
| CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
| CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
| CORE_PEER_LOCALMSPID=Org2MSP
| CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
| CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
| CORE_PEER_TLS_ENABLED=false
| CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
| CORE_PEER_ID=cli
| CORE_LOGGING_LEVEL=DEBUG
| CORE_PEER_ADDRESS=peer1.org2.example.com:7051
| 2017-11-15 09:31:36.372 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
| 2017-11-15 09:31:36.372 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
| 2017-11-15 09:31:36.373 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
| 2017-11-15 09:31:36.374 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AC4070A5C08011A0C08F892B0D00510...A1A603DD33A31A080A000A000A000A00
| 2017-11-15 09:31:36.374 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 6776D313E8DD88880918868C6BA2C93ECEB05425FE93A7E385762918FA2AF556
| 2017-11-15 09:31:36.419 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
| 2017-11-15 09:31:36.419 UTC [main] main -> INFO 007 Exiting.....
| ===================== PEER3 joined on the channel "mychannel" =====================
| sleep: missing operand
| Try 'sleep --help' for more information.
|
|
| ========= All GOOD, BYFN execution completed ===========

I'm using Ubuntu 16.04 and Composer v0.14.2.


问:
Error streaming BLOB from Spring MVC controller
I have some binary data stored in Blob in Postgres. I work with the db through JPA but that's not important in this case. I have a spring MVC @Controller which should be able to serve this data through an endpoint. And I want to stream the data because why to load it all into memory. Roughly like:

```<code>@Entity
class MyEntity {
    @Lob
    Blob data;
}

@RequestMapping(...)
public InputStreamResource getResource(...) {
    return new InputStreamResource(myEntityRepository.findById(id).getData().getBinaryStream());
}
</code>```

This unfortunately gives me:

java.io.IOException: org.postgresql.util.PSQLException: ERROR: invalid
  large-object descriptor: 1

And I know why: When you work with Blobs you need to run in transaction. Now what I have tried:

Annotating the whole controller method @Transactional - doesn't help because when Spring starts to copy the stream into the servlet response it is already outside of the transaction aspect. :'(

I also validated that if I inside the controller copy the input stream into byte[] it all works. But this is no streaming.

byte[] data = IOUtils.toByteArray(myEntityRepository.findById(id).getData().getBinaryStream());
    return new ByteArrayResource(data);

It is clearly the problem that the aspect doing @Transactional is closer to the controller method that the one which gets return value and turns it into servlet response.

Is there a way how to reorder the aspects? Any other solution?

Thanks!

Edit:
It seems it should work simply by doing @EnableTransactionManagement(order = Ordered.HIGHEST_PRECEDENCE) which unfortunately is not the case. Maybe due to @EnableAspectJAutoProxy(proxyTargetClass = true) ?

Edit2:
This is apparently yet more general problem. The @RequestMapping annotated method just returns the Stream but only after the invocation completes - including all aspects and @Transactional - the returned value (Stream) is processed further. So in fact I will be looking to broaden then transactional to the class which actually calls the controller's method, possibly the whole Servlet.doXXX method. No good news.

答: Turned out I overlooked the simplest yet a bit less elegant solution. I can still inject the HttpServletResponse or OutputStream into the controller's method and copy the Stream inside the controller's method. Not as nice as returning InputStreamResource but works.

Body:
I have some binary data stored in Blob in Postgres. I work with the db through JPA but that's not important in this case. I have a spring MVC @Controller which should be able to serve this data through an endpoint. And I want to stream the data because why to load it all into memory. Roughly like:

@Entity
class MyEntity {
    @Lob
    Blob data;
}

@RequestMapping(...)
public InputStreamResource getResource(...) {
    return new InputStreamResource(myEntityRepository.findById(id).getData().getBinaryStream());
}

This unfortunately gives me:

java.io.IOException: org.postgresql.util.PSQLException: ERROR: invalid
  large-object descriptor: 1

And I know why: When you work with Blobs you need to run in transaction. Now what I have tried:

Annotating the whole controller method @Transactional - doesn't help because when Spring starts to copy the stream into the servlet response it is already outside of the transaction aspect. :'(

I also validated that if I inside the controller copy the input stream into byte[] it all works. But this is no streaming.

byte[] data = IOUtils.toByteArray(myEntityRepository.findById(id).getData().getBinaryStream());
    return new ByteArrayResource(data);

It is clearly the problem that the aspect doing @Transactional is closer to the controller method that the one which gets return value and turns it into servlet response.

Is there a way how to reorder the aspects? Any other solution?

Thanks!

Edit:
It seems it should work simply by doing @EnableTransactionManagement(order = Ordered.HIGHEST_PRECEDENCE) which unfortunately is not the case. Maybe due to @EnableAspectJAutoProxy(proxyTargetClass = true) ?

Edit2:
This is apparently yet more general problem. The @RequestMapping annotated method just returns the Stream but only after the invocation completes - including all aspects and @Transactional - the returned value (Stream) is processed further. So in fact I will be looking to broaden then transactional to the class which actually calls the controller's method, possibly the whole Servlet.doXXX method. No good news.


问:
add a " once string matched using sed in multiple lines
while i am trying to replace a string using below command, all the strings are replaced which is having a 0.But, I need to replace only a string starting with 0 and combination of alpha numeric.Please help to exclude the others.Please find the sed command below what i used.

```<code>sed -r 's:((0\w+)):"&":g'  test >test.log
</code>```

input file:   test

```<code>0INTEL  GC  P   0servername     0.000       0I30019     12/02/15
0INTEL  GC  P   0servername     0.000       0I30019     12/02/15
</code>```

Expected output:  test.log

```<code>"0INTEL"    GC  P   "0servername"   0.000       I30019      12/02/15
"0INTEL"    GC  P   "0servername"   0.000       I30019      12/02/15
</code>```

Actual output:

```<code>"0INTEL"    GC  P   "0servername"   0."000"     I30019      12/"02"/15
"0INTEL"    GC  P   "0servername"   0."000"     I30019      12/"02"/15
</code>```

答:
Your "expected output" seems to have an error. The leading 0s from "0I30019" have been removed for some reason. Otherwise, what you need is something like this:

```<code>sed -r 's/((0[A-Za-z][A-Za-z0-9]*))/"&"/g' text
</code>```

Based on your example, the first character after the leading 0 should be an alphabet, but the word can contain numeric chars after that. The regex reflects that requirement. The output from this:

```<code>"0INTEL" GC P "0servername" 0.000 "0I30019" 12/02/15 "0INTEL" GC P "0servername" 0.000 "0I30019" 12/02/15
</code>```

Body:
while i am trying to replace a string using below command, all the strings are replaced which is having a 0.But, I need to replace only a string starting with 0 and combination of alpha numeric.Please help to exclude the others.Please find the sed command below what i used.

sed -r 's:((0\w+)):"&":g'  test >test.log

input file:   test

0INTEL  GC  P   0servername     0.000       0I30019     12/02/15
0INTEL  GC  P   0servername     0.000       0I30019     12/02/15

Expected output:  test.log

"0INTEL"    GC  P   "0servername"   0.000       I30019      12/02/15
"0INTEL"    GC  P   "0servername"   0.000       I30019      12/02/15

Actual output:

"0INTEL"    GC  P   "0servername"   0."000"     I30019      12/"02"/15
"0INTEL"    GC  P   "0servername"   0."000"     I30019      12/"02"/15

Body:
Your "expected output" seems to have an error. The leading 0s from "0I30019" have been removed for some reason. Otherwise, what you need is something like this:

sed -r 's/((0[A-Za-z][A-Za-z0-9]*))/"&"/g' text

Based on your example, the first character after the leading 0 should be an alphabet, but the word can contain numeric chars after that. The regex reflects that requirement. The output from this:

"0INTEL" GC P "0servername" 0.000 "0I30019" 12/02/15 "0INTEL" GC P "0servername" 0.000 "0I30019" 12/02/15


答:
with awk. For all fields, if field matches pattern, add quotes. Finally print the line (1 means the default action which is to print line)

```<code>awk '{ for (i=1;i<=NF;i++) if ($i ~ /^0[A-Za-z0-9]*$/) $i="\""$i"\"" } 1' file
</code>```

Title: add a " once string matched using sed in multiple lines

Body:
with awk. For all fields, if field matches pattern, add quotes. Finally print the line (1 means the default action which is to print line)

awk '{ for (i=1;i<=NF;i++) if ($i ~ /^0[A-Za-z0-9]*$/) $i="\""$i"\"" } 1' file


问:
deactivate CSS “user-select” globally
I’ve just come across a site using a CSS property -moz-user-select,
set to none, as an anti-user measure:

```<code>#content {
 -moz-user-select:none;
 -webkit-user-select:none;
 -ms-user-select:none;
 user-select:none
}
</code>```

How can user-select be disabled completely in Firefox? I’m looking
for a permanent, unconditional and non-overridable solution like a
compile flag or a configuration setting that is guaranteed to be
effective. The expected behavior is that the browser treat all text
as selectable again, as if the property didn’t exist in the first place.

答:
Try using this extension, which explicitly states a feature of "Add Custom JavaScript Codes or Styles (CSS) to an specific page or all pages."

If you add the following CSS to all pages, it should undo the effects, unless the dev (for some reason) used !important on one of their declarations.

```<code>* {
  -webkit-user-select: unset;
  -moz-user-select: unset;
  -ms-user-select: unset;
  user-select: unset;
}
</code>```

You could naturally put in a better selector if any specific site is giving you trouble - just increase the specificity.

Full disclosure: I have never used the extension I linked, so I can't vouch for it. I'm just going off what it claims to do.

Title: deactivate CSS “user-select” globally

Body:
I’ve just come across a site using a CSS property -moz-user-select,
set to none, as an anti-user measure:

#content {
 -moz-user-select:none;
 -webkit-user-select:none;
 -ms-user-select:none;
 user-select:none
}

How can user-select be disabled completely in Firefox? I’m looking
for a permanent, unconditional and non-overridable solution like a
compile flag or a configuration setting that is guaranteed to be
effective. The expected behavior is that the browser treat all text
as selectable again, as if the property didn’t exist in the first place.

Body:
Try using this extension, which explicitly states a feature of "Add Custom JavaScript Codes or Styles (CSS) to an specific page or all pages."

If you add the following CSS to all pages, it should undo the effects, unless the dev (for some reason) used !important on one of their declarations.

* {
  -webkit-user-select: unset;
  -moz-user-select: unset;
  -ms-user-select: unset;
  user-select: unset;
}

You could naturally put in a better selector if any specific site is giving you trouble - just increase the specificity.

Full disclosure: I have never used the extension I linked, so I can't vouch for it. I'm just going off what it claims to do.


问:
How to convert a float to binary using javascript
Here is the Example:

For example, suppose we have a float 13.4. In binary, it can be written as: 1101.01100110011001100110011001100110011兮.

Suppose the system stores bits up to 10 decimal places. So 13.4 is stored as: 1101.0110011001 (only 10 decimal places now)

Because of this change, if you convert 1101.0110011001 back to base 10, you get 13.399414. In essence 13.399414 is stored rather than 13.4 in this case!

So given a floating point in base 10, an integer n which represents the number of decimal places as defined above, output the stored value of the float to three decimal places.

So How can i convert using javascript:- input 13.4 and output 13.399

答:
Going off of the comment by @Jaromanda X</p>

```<code>function cut(num, base, len) {
    base = Math.pow(2, base);
    return (parseInt((num * base).toString(2), 2) / base).toFixed(len);
}
</code>```

Body:
Going off of the comment by @Jaromanda X

function cut(num, base, len) {
    base = Math.pow(2, base);
    return (parseInt((num * base).toString(2), 2) / base).toFixed(len);
}


问:
Jenssegers Blade Template Engine - page render error
I have views folder and my pages in views folder ( ex : home.blade.php,
test.blade.php) , I want to do page orientation but I have some error :

```<code><?php
require 'vendor/autoload.php';
use Jenssegers\Blade\Blade;

$page= isset($_GET['p']) ? $_GET['p'] : 'home';

$blade = new Blade('views', 'cache');

echo $blade->make('home');

$pages = array('home' =>["views" => 'home.blade.php'],
               'test' =>["views" => 'test.blade.php']);

echo array_key_exists($page,$pages) ? $blade->render($pages[$page]
['views']) : $blade-> render('404.blade.php');
?>
</code>```

Error:

Fatal error: Uncaught InvalidArgumentException: View [home.blade.php]
  not found. in
  /var/www/html/vendor/illuminate/view/FileViewFinder.php:137  Stack
  trace:
  #0

答:
You have to change your views name home.blade.php to home. Otherwise it considers it as directory hierarchy home->blade->php. In other words it's searching for a file with name php.blade.php, php.php or php.css under home/blade/ directory.

```<code>$pages = array('home' =>["views" => 'home'],
               'test' =>["views" => 'test']);
</code>```

Body:
I have views folder and my pages in views folder ( ex : home.blade.php,
test.blade.php) , I want to do page orientation but I have some error :

<?php
require 'vendor/autoload.php';
use Jenssegers\Blade\Blade;

$page= isset($_GET['p']) ? $_GET['p'] : 'home';

$blade = new Blade('views', 'cache');

echo $blade->make('home');

$pages = array('home' =>["views" => 'home.blade.php'],
               'test' =>["views" => 'test.blade.php']);

echo array_key_exists($page,$pages) ? $blade->render($pages[$page]
['views']) : $blade-> render('404.blade.php');
?>

Error:

Fatal error: Uncaught InvalidArgumentException: View [home.blade.php]
  not found. in
  /var/www/html/vendor/illuminate/view/FileViewFinder.php:137  Stack
  trace:
  #0

Body:
You have to change your views name home.blade.php to home. Otherwise it considers it as directory hierarchy home->blade->php. In other words it's searching for a file with name php.blade.php, php.php or php.css under home/blade/ directory.

$pages = array('home' =>["views" => 'home'],
               'test' =>["views" => 'test']);


问:
Laravel retrieve only the email address column in database for users table
Hi I had code that stated

```<code>    $users = User::all();
</code>```

But I only want the email addresses of the users in a collection. So I tried:

```<code>    $users = User::select('id', 'email')->first();
</code>```

This does not work as I want. When I do a var_dump I only want to see the users email addresses. Any tips?

UPDATE: I inserted my blade code as well. I use a Vue component that has a dropdown and I filter the data in the Vue method and insert the filtered data under userEmail:

The component:

```<code>    <commands-component
                :entity-config="commandConfig(command.id, command.signature, command.hasUser, command.title, command.groupID, command.groupName)">
                <input style="margin-right:10px;margin-bottom:10px;" type="button" class="btn btn-primary" v-bind:value="command.title" v-on:click='disableEmailText(command.hasUser)'>
        </commands-component>
</code>```

The Vue:

```<code>    var systemadmin = new Vue({
    el: "#sysadmin",
    data: function() {
        return {
          users: <?php echo $users ?>,
          userData: [],
          commands: <?php echo $commands ?>,
        }
    },

    methods: {
      commandConfig: function(ident, signature, hasUser, title, groupId, groupName){
        var that =  this;
        var commandsGetUsers = [];

        commandsGetUsers  = _.map(that.users, function(value) {
            var newValue = {};
            newValue.value = value.id;
            newValue.text = value.email;
            return newValue;
        });

        return {
          id: { text: 'commandModal' + ident, id: null },
          modalTitle: title,
          buttons: [
              {
                  buttonTitle: 'Run Command',
                  buttonClass: 'btn btn-success pull-right',
                  submitUrl: {
                      url: '/admin/artisan/commands/run',

                  },
              }
          ],
          attributes: [
            {name: "message", displayName: "Are you sure you want to proceed with the command?", type: "action-text",  col: "12" },
            {name: "signature", displayName: "Command Signature", type:'text', col:"6"},
            {name: "userEmail", displayName: "Users", type: 'select', options: commandsGetUsers, col:'6'}
          ],
          data: {
              signature:signature,
              hasUser:hasUser
          }
        };

      },
</code>```

答:
if you want the email addresses from single user, try this:

```<code>$user = User::find(1)->email;
</code>```

if you want the email addresses from all user/collection, try this:

```<code>$user = User::select('email')->get();
</code>```

Body:
Hi I had code that stated

    $users = User::all();

But I only want the email addresses of the users in a collection. So I tried:

    $users = User::select('id', 'email')->first();

This does not work as I want. When I do a var_dump I only want to see the users email addresses. Any tips?

UPDATE: I inserted my blade code as well. I use a Vue component that has a dropdown and I filter the data in the Vue method and insert the filtered data under userEmail:

The component:

    <commands-component
                :entity-config="commandConfig(command.id, command.signature, command.hasUser, command.title, command.groupID, command.groupName)">
                <input style="margin-right:10px;margin-bottom:10px;" type="button" class="btn btn-primary" v-bind:value="command.title" v-on:click='disableEmailText(command.hasUser)'>
        </commands-component>

The Vue:

    var systemadmin = new Vue({
    el: "#sysadmin",
    data: function() {
        return {
          users: <?php echo $users ?>,
          userData: [],
          commands: <?php echo $commands ?>,
        }
    },

    methods: {
      commandConfig: function(ident, signature, hasUser, title, groupId, groupName){
        var that =  this;
        var commandsGetUsers = [];

        commandsGetUsers  = _.map(that.users, function(value) {
            var newValue = {};
            newValue.value = value.id;
            newValue.text = value.email;
            return newValue;
        });

        return {
          id: { text: 'commandModal' + ident, id: null },
          modalTitle: title,
          buttons: [
              {
                  buttonTitle: 'Run Command',
                  buttonClass: 'btn btn-success pull-right',
                  submitUrl: {
                      url: '/admin/artisan/commands/run',

                  },
              }
          ],
          attributes: [
            {name: "message", displayName: "Are you sure you want to proceed with the command?", type: "action-text",  col: "12" },
            {name: "signature", displayName: "Command Signature", type:'text', col:"6"},
            {name: "userEmail", displayName: "Users", type: 'select', options: commandsGetUsers, col:'6'}
          ],
          data: {
              signature:signature,
              hasUser:hasUser
          }
        };

      },

Body:
if you want the email addresses from single user, try this:

$user = User::find(1)->email;

if you want the email addresses from all user/collection, try this:

$user = User::select('email')->get();


答:
IronPython, maybe? It's a CLR implementation of Python. Totally .NET and totally cool.

From their site:

IronPython is an implementation of the
  Python programming language running
  under .NET and Silverlight. It
  supports an interactive console with
  fully dynamic compilation. It's well
  integrated with the rest of the .NET
  Framework and makes all .NET libraries
  easily available to Python
  programmers, while maintaining
  compatibility with the Python
  language. There also is Visual Studio
  tooling integration.

Title: Python, using Full .NET?

Body: I was trying out python in my browser using silverlight which is cool. Can i use python with .NET in a console or winform app? I hear silverlight is a stripped down .NET so it will load (or have a smaller download) on client machines. Can i use python with the full power of .NET? (perhaps outside of silver light)


问:
iOS 11 random disconnection with external bluetooth device
I use CoreBluetooth framework to connect external bluetooth device, in all iOS don't have random disconnection, but on iOS 11 it disconnect.
Maybe some one has any idea what's wrong with ios 11 and corebluetooth, CBCentralManager?</p>

答:
My app worked disconnected every 5 minutes on iOS 11.0.x,(I'm sorry for the correct version), But in iOS 10 or eralier version is OK. So I try to change the peripheral deviece, change a Android phone to test, both of them are running OK.

Then I update the version to iOS 11.1.1, And the BUG looks like to be FIXed.


问:
how to get multiple records from static form in rails for database
The main form

```<code><%=  p.fields_for :prd_province_vise_deliveries  do |j| %>

   <%= render(:partial => 'prd_province_vise_delivery_field', :locals => {:k => j})%>
<% end %>
</code>```

and this is my prd_province_vise_delivery_field partial

```<code>       <div>
         <table class="table-striped">
            <thead>
            <tr>
              <th> Province name </th>
              <th> Delivery rate (Rs)</th>
              <th> Delivery period(Days) </th>
            </tr>
            </thead>
            <tbody>
            <tr>
              <td><%= k.label :province_name , 'Western'%></td>
              <td><%= k.text_field(:delivery_rate, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%> </td>
              <td> <%= k.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%></td>
            </tr>
            <tr>
              <td><%= k.label :province_name , 'Southern'%> </td>
              <td><%= k.text_field(:delivery_rate, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%> </td>
              <td> <%= k.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%></td>
            </tr>
            <tr>
              <td><%= k.label :province_name , 'Nothern'%> </td>
              <td><%= k.text_field(:delivery_rate, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%> </td>
              <td> <%= k.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%></td>
            </tr>
            </tbody>
         </table>
        </div>
</code>```

but with this approach i could not get the params for the request

can anyone suggest a method

答:
If you are using CoffeeScript to send the data from the FORM

create the array first, and loop through the text boxes and collect data

```<code>arr = []

$('input#day_id').each ->
  arr.push $(this).val()
</code>```

convert the array

```<code>  sample_array = JSON.stringify(arr)
</code>```

Call the ajax

```<code>  $.ajax '/controller',
            type: "POST",
            data: { schedule: { days: sample_array }},
            async: true
            success:(data) ->
</code>```

If you are submitting the form
create the form as follows

```<code><% @class_variable.each do |f| %>
  <%= text_field_tag 'delivery_rate[]', delivery_rate %>
  <%= text_field_tag 'delivery_amount[]', delivery_amount %>
<% end %>
</code>```

Body:
The main form

<%=  p.fields_for :prd_province_vise_deliveries  do |j| %>

   <%= render(:partial => 'prd_province_vise_delivery_field', :locals => {:k => j})%>
<% end %>

and this is my prd_province_vise_delivery_field partial

               Province name
               Delivery rate (Rs)
               Delivery period(Days)

              <%= k.label :province_name , 'Western'%>
              <%= k.text_field(:delivery_rate, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>
               <%= k.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>

              <%= k.label :province_name , 'Southern'%>
              <%= k.text_field(:delivery_rate, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>
               <%= k.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>

              <%= k.label :province_name , 'Nothern'%>
              <%= k.text_field(:delivery_rate, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>
               <%= k.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>

but with this approach i could not get the params for the request

can anyone suggest a method

Body:
If you are using CoffeeScript to send the data from the FORM

create the array first, and loop through the text boxes and collect data

arr = []

$('input#day_id').each ->
  arr.push $(this).val()

convert the array

  sample_array = JSON.stringify(arr)

Call the ajax

  $.ajax '/controller',
            type: "POST",
            data: { schedule: { days: sample_array }},
            async: true
            success:(data) ->

If you are submitting the form
create the form as follows

<% @class_variable.each do |f| %>
  <%= text_field_tag 'delivery_rate[]', delivery_rate %>
  <%= text_field_tag 'delivery_amount[]', delivery_amount %>
<% end %>