问:
Unknown Files when sync project to get last version
I am using Visual studio 2017 Last Update (15.4.1) and Git source Control .

When I get Latest Update some files that My co-worker had added are unknown and I cant use them.
when I press Go to Definition  I've got this Message

cannot navigate to the symbol under the caret

but when I clone Project again from Source Control It works fine .

Is it related Not Same visual studio Version ?

答:
Please see the bug fix page from Microsoft at GitHub. This is the ticket #20779, which is fixed in the Visual Studio 2017 version 15.3 (However, you're using 15.4.1, It's should be fixed.)

Based on the ticket, the problem only happened with generic types. It turns out the problem only happens when trying to navigate to a type where one or more of the generic type arguments is a user defined type. So you can Go To Definition on List, but if you try on List, you'll get this error: "Cannot navigate to the symbol under the caret".

So, you can try to temporarily change types to int, then undo. See what's happen.

In your scenario, maybe you can use other approach, such as, empty the symbol cache, clean the solution and recompile, reset the visual studio user data, disable extensions, close all documents, clear various caches and temporary files first. Then you can sync project.


来源: stackexchange

问:
Visual Studio solution explorer out of memory exception
When I open the visual studio 2010 premium, Solution explorer doesn't show up.
It was working and now its not.

It is showing a out of memory exception. Any help would be greatly appreciated.

Attached is the screen shot

答:
try resetting visual studio by closing it out completely and running the following command.</p>

```<code>devenv /resetsettings
</code>```

ContentLicense: CC BY-SA 2.5

Body:
try resetting visual studio by closing it out completely and running the following command.

devenv /resetsettings


答:
I got the problem merging a project file with others. After a long r&d, I fund some of the help contents.
May these help you I also try them.
This one works for me.

Close all open files and then VS
Clean solution
Rebuild solution

this is the most preferred help content in my opinion.

ContentLicense: CC BY-SA 3.0

Title: Unknown Files when sync project to get last version

Body:
I am using Visual studio 2017 Last Update (15.4.1) and Git source Control .

When I get Latest Update some files that My co-worker had added are unknown and I cant use them.
when I press Go to Definition  I've got this Message

cannot navigate to the symbol under the caret

but when I clone Project again from Source Control It works fine .

Is it related Not Same visual studio Version ?


问:
Authentication token is not working
Not an issue with the gem but I just need some help with returning token.

I am using devise_auth_token gem in my rails-api app.

I have a route in my api app that will response

{ "url": google-oauth-login-url }
The frontend app use that route to put it in the login with google btn.

After a user click in the btn they will be redirected to google oauth page and after filling in the details they will be then redirected to the frontend home page with the google code in the url.

The frontend app will send a req to the api server with the code and the server will req to the google server again to exchange that google code for access-token, refresh token and all that.

After the server receives those token, the server again makes another req to the google server to fetch user profile.

The user is then saved to db with the access token as well.

```<code>password = Devise.friendly_token[0,10]
@resource = Employee.new({
                name: user_info["displayName"],
                admin: true,
                first_name: CustomRegex.japanese?(user_info["name"]["givenName"]) ? '' : user_info["name"]["givenName"],
                last_name: CustomRegex.japanese?(user_info["name"]["familyName"]) ? '' : user_info["name"]["familyName"],
                email: user_info["emails"][0]["value"],
                password: password,
                password_confirmation: password
                })

      @client_id = SecureRandom.urlsafe_base64(nil, false)
      @token     = SecureRandom.urlsafe_base64(nil, false)
      # @resource = Employee.find user.id
      @resource.tokens[@client_id] = {
              token: BCrypt::Password.create(@token),
              expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
      }
      @resource.skip_confirmation!
    @resource.save!
      # @resource.save!(validate: false)
      # sign_in @resource
            return render json: {client_id: @client_id, expiry: @resource.tokens[@client_id][:"expiry"],
                                                     token: @token, uid: @resource.uid
                                                    }
</code>```

I used the returned cliend_id expiry, token and uid in the header to make a req to my api and it gave me not authorized error. Can you tell me what I am doing wrong?

答:
This is how i solved my problem</p>

```<code>skip_after_action :update_auth_header, :only => [:token_for_code]
def log_in_or_create_employee(user_info)
    @resource = Employee.find_by email: user_info["emails"][0]["value"]
    if @resource.nil?
        password = Devise.friendly_token[0,10]
        @resource = Employee.new({
            name: user_info["displayName"],
            admin: true,
            first_name: CustomRegex.japanese?(user_info["name"]["givenName"]) ? '' : user_info["name"]["givenName"],
            last_name: CustomRegex.japanese?(user_info["name"]["familyName"]) ? '' : user_info["name"]["familyName"],
            email: user_info["emails"][0]["value"],
            password: password,
            password_confirmation: password
            })
    end
        @client_id = SecureRandom.urlsafe_base64(nil, false)
  @token     = SecureRandom.urlsafe_base64(nil, false)
  @resource.tokens[@client_id] = {
          token: BCrypt::Password.create(@token),
          expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
  }
  @resource.skip_confirmation!
        @resource.save!
        return render json: {client_id: @client_id, expiry: @resource.tokens[@client_id][:"expiry"],
                                                 token: @token, uid: @resource.uid
                                                }
end
</code>```

Title: Authentication token is not working

Body:
Not an issue with the gem but I just need some help with returning token.

I am using devise_auth_token gem in my rails-api app.

I have a route in my api app that will response

{ "url": google-oauth-login-url }
The frontend app use that route to put it in the login with google btn.

After a user click in the btn they will be redirected to google oauth page and after filling in the details they will be then redirected to the frontend home page with the google code in the url.

The frontend app will send a req to the api server with the code and the server will req to the google server again to exchange that google code for access-token, refresh token and all that.

After the server receives those token, the server again makes another req to the google server to fetch user profile.

The user is then saved to db with the access token as well.

password = Devise.friendly_token[0,10]
@resource = Employee.new({
                name: user_info["displayName"],
                admin: true,
                first_name: CustomRegex.japanese?(user_info["name"]["givenName"]) ? '' : user_info["name"]["givenName"],
                last_name: CustomRegex.japanese?(user_info["name"]["familyName"]) ? '' : user_info["name"]["familyName"],
                email: user_info["emails"][0]["value"],
                password: password,
                password_confirmation: password
                })

      @client_id = SecureRandom.urlsafe_base64(nil, false)
      @token     = SecureRandom.urlsafe_base64(nil, false)
      # @resource = Employee.find user.id
      @resource.tokens[@client_id] = {
              token: BCrypt::Password.create(@token),
              expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
      }
      @resource.skip_confirmation!
    @resource.save!
      # @resource.save!(validate: false)
      # sign_in @resource
            return render json: {client_id: @client_id, expiry: @resource.tokens[@client_id][:"expiry"],
                                                     token: @token, uid: @resource.uid
                                                    }

I used the returned cliend_id expiry, token and uid in the header to make a req to my api and it gave me not authorized error. Can you tell me what I am doing wrong?

Body:
This is how i solved my problem

skip_after_action :update_auth_header, :only => [:token_for_code]
def log_in_or_create_employee(user_info)
    @resource = Employee.find_by email: user_info["emails"][0]["value"]
    if @resource.nil?
        password = Devise.friendly_token[0,10]
        @resource = Employee.new({
            name: user_info["displayName"],
            admin: true,
            first_name: CustomRegex.japanese?(user_info["name"]["givenName"]) ? '' : user_info["name"]["givenName"],
            last_name: CustomRegex.japanese?(user_info["name"]["familyName"]) ? '' : user_info["name"]["familyName"],
            email: user_info["emails"][0]["value"],
            password: password,
            password_confirmation: password
            })
    end
        @client_id = SecureRandom.urlsafe_base64(nil, false)
  @token     = SecureRandom.urlsafe_base64(nil, false)
  @resource.tokens[@client_id] = {
          token: BCrypt::Password.create(@token),
          expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
  }
  @resource.skip_confirmation!
        @resource.save!
        return render json: {client_id: @client_id, expiry: @resource.tokens[@client_id][:"expiry"],
                                                 token: @token, uid: @resource.uid
                                                }
end


问:
OpenMP parallelizing matrix multiplication by a triple for loop (performance issue)
I'm writing a program for matrix multiplication with OpenMP, that, for cache convenience, implements the multiplication A x B(transpose) rows X rows instead of the classic A x B rows x columns, for better cache efficiency. Doing this I faced an interesting fact that for me is illogic: if in this code i parallelize the extern loop the program is slower than if I put the OpenMP directives in the most inner loop, in my computer the times are 10.9 vs 8.1 seconds.

//A and B are double* allocated with malloc, Nu is the lenght of the matrixes
//which are square

//#pragma omp parallel for
for (i=0; i<Nu; i++){
  for (j=0; j<Nu; j++){
    *(C+(i*Nu+j)) = 0.;
#pragma omp parallel for
    for(k=0;k<Nu ;k++){
      *(C+(i*Nu+j))+=*(A+(i*Nu+k)) * *(B+(j*Nu+k));//C(i,j)=sum(over k) A(i,k)*B(k,j)
    }
  }
}
```

答:
Try hitting the result less often.  This induces cacheline sharing and prevents the operation from running in parallel.  Using a local variable instead will allow most of the writes to take place in each core's L1 cache.

Also, use of restrict may help.  Otherwise the compiler can't guarantee that writes to C aren't changing A and B.

Try:

for (i=0; i<Nu; i++){
  const double* const Arow = A + i*Nu;
  double* const Crow = C + i*Nu;
#pragma omp parallel for
  for (j=0; j<Nu; j++){
    const double* const Bcol = B + j*Nu;
    double sum = 0.0;
    for(k=0;k<Nu ;k++){
      sum += Arow[k] * Bcol[k]; //C(i,j)=sum(over k) A(i,k)*B(k,j)
    }
    Crow[j] = sum;
  }
}
```

Also, I think Elalfer is right about needing reduction if you parallelize the innermost loop.

Body:
Try hitting the result less often.  This induces cacheline sharing and prevents the operation from running in parallel.  Using a local variable instead will allow most of the writes to take place in each core's L1 cache.

Also, use of restrict may help.  Otherwise the compiler can't guarantee that writes to C aren't changing A and B.

Try:

for (i=0; i<Nu; i++){
  const double* const Arow = A + i*Nu;
  double* const Crow = C + i*Nu;
#pragma omp parallel for
  for (j=0; j<Nu; j++){
    const double* const Bcol = B + j*Nu;
    double sum = 0.0;
    for(k=0;k<Nu ;k++){
      sum += Arow[k] * Bcol[k]; //C(i,j)=sum(over k) A(i,k)*B(k,j)
    }
    Crow[j] = sum;
  }
}

Also, I think Elalfer is right about needing reduction if you parallelize the innermost loop.


问:
How to display the dropdown & checkbox selected value in redirected page for confirmation IN PHP?
```<code><form action="action.php" method="POST"  target="_self">
<table class="main"  border="1"  height="100%" align="center">
<h3>
<p id="id1" style="background-color: #9FF" >Registration form</p></h3>

 <tr><td> First Name:<span style="color:red">*</span> </td>
<td> <input type="text"  name="fname" value="" placeholder="firstname"    required="required" maxlength="25"></td></tr>
 <tr><td> SurName:<span style="color:red">*</span></td>
 <td><input type="text"  name="sname" value=""  placeholder="lastname" required="required" maxlength="20"/> </td></tr>
 <tr><td>Age:<span style="color:red">*</span></td>
 <td> <input type="text" name="age" value="" required/></td></tr>
 <tr><td>Date of Birth:<span style="color:red">*</span></td>
 <td><input type="date" name="DOB" value="" required/></td></tr>
 <tr><td> Gender:<span style="color:red">*</span></td>
  <td><input type="radio" name="gender" value="male" required/>Male
   <input type="radio" name="gender" value="Female" />Female</td></tr>
  <tr><td>Qualification:<span style="color:red">*</span></td>
   <td> <select name="study" required>
   <option value="">---Select---</option>
  <option value="btech">B.Tech</option>
  <option value="BSc">BSc</option>
  <option value="BCom">BCom</option>
 </select></td></tr>
  <tr><td> State:<span style="color:red">*</span></td>
<td><Select name="state" required >
<option value="">---Select---</option>
<option valuie="AndhraPradesh">AndhraPradesh</option>
<option value="Telangana">Telangana</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Kerala">Kerala</option>
<option vgalue="Maharastra">Maharastra</option>
</Select></td></tr>

<tr><td>Profile:<span style="color:red">*</span></td><td><input type="checkbox" name="profile" value="Java" />Java
                            <input type="checkbox" name="profile" value="PHP" />PHP
                            <input type="checkbox" name="profile" val

    ue="Android" />Android</td> </tr>
    <tr><td> Address for Communication:</td><td><textarea name="adr" rows="5" cols="30" ></textarea></td></tr>
            <tr><td colspan="2" align="center"><input type="submit" value="submit" /></td></tr>
    </table></form>
</code>```

** this is my register form and now i want to display all the selected values in next page i.e in action.php and its code is as follows********

```<code>    <form action="store.php" method="post" align="center" target="_self">
    <label>Name of the person:</label>
   <input type="hidden" name="person" value="<?= $_POST['fname'];?>"></input><?=$_POST['fname'];?>  <br />
    <label>Name of the Surname:</label>
    <input type="hidden" name="surname" value="<?= $_POST['sname'];?>"></input><?=$_POST['sname'];?>  <br />
    <label>His Age:</label>
     <input type="hidden" name="age" value="<?= $_POST['age'];?>"></input><?=$_POST['age'];?> <br />
     <label>Date of Birth:</label>
     <input type="hidden" name="dob" value="<$_POST['DOB'];?>"></input><?=$_POST['DOB'];?>  <br />
      <label>Gender:</label>
     <input type="hidden" name="gender" value="<?= $_POST['gender'];?>"></input><?=$_POST['gender'];?> <br />
      <label>Education:</label>
     <input type="hidden" name="edu" value="<?php if(isset($_POST['submit']))echo $_POST['study']?>"></input><?php if(isset($_POST['submit'])) echo $_POST['study']?>;?>
      <br />
      <label>State:</label>
      <input type="hidden" name="state" value="<?if(isset($_POST['submit']))echo $_POST['state']?>"></input><?php if(isset($_POST['submit'])) echo $_POST['state']?>;?>
      <br />
      <label>Good At:</label>
     <input type="hidden" name="profile" value="<?= $_POST['profile'];?>"></input><?=$_POST['profile'];?>  <br />
      <label>Address:</label>
      <input type="hidden" name="adr" value="<?= $_POST['adr'];?>"></input><?=$_POST['adr'];?>  <br /><br /><br />
      <input type="submit" value="confirm" name="submit"></input>
</code>```

****the dropdown is not displaying and also please suggest if after click on confirm then the values that are confirmed has to be stored in database.For that shall I get the values from names of input hidden fields in action.php or  registration input field names?

答:
There's a lot of syntax errors in your code.

You haven't added a name attribute in the submit button. There should be name="submit" in it. Otherwise when displaying the drop down values, it is being check in your code, and it wouldn't be displayed (because no variable named submit was found in the $_POST array).

The check box is using the same name. So it should be an array. use name=profile[] instead of name=profile

Finally form.php should look like this:

```<code><form action="action.php" method="POST"  target="_self">
<table class="main"  border="1"  height="100%" align="center">
<h3>
<p id="id1" style="background-color: #9FF" >Registration form</p></h3>

 <tr><td> First Name:<span style="color:red">*</span> </td>
<td> <input type="text"  name="fname" value="" placeholder="firstname"    required="required" maxlength="25"></td></tr>
 <tr><td> SurName:<span style="color:red">*</span></td>
 <td><input type="text"  name="sname" value=""  placeholder="lastname" required="required" maxlength="20"/> </td></tr>
 <tr><td>Age:<span style="color:red">*</span></td>
 <td> <input type="text" name="age" value="" required/></td></tr>
 <tr><td>Date of Birth:<span style="color:red">*</span></td>
 <td><input type="date" name="DOB" value="" required/></td></tr>
 <tr><td> Gender:<span style="color:red">*</span></td>
  <td><input type="radio" name="gender" value="male" required/>Male
   <input type="radio" name="gender" value="Female" />Female</td></tr>
  <tr><td>Qualification:<span style="color:red">*</span></td>
   <td> <select name="study" required>
   <option value="">---Select---</option>
  <option value="btech">B.Tech</option>
  <option value="BSc">BSc</option>
  <option value="BCom">BCom</option>
 </select></td></tr>
  <tr><td> State:<span style="color:red">*</span></td>
<td><Select name="state" required >
<option value="">---Select---</option>
<option value="AndhraPradesh">AndhraPradesh</option>
<option value="Telangana">Telangana</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Kerala">Kerala</option>
<option vgalue="Maharastra">Maharastra</option>
</Select></td></tr>

<tr><td>Profile:<span style="color:red">*</span></td><td>

                <input type="checkbox" name="profile[]" value="Java" />Java
                            <input type="checkbox" name="profile[]" value="PHP" />PHP
                            <input type="checkbox" name="profile[]" value="Android" />Android</td> </tr>
    <tr><td> Address for Communication:</td><td><textarea name="adr" rows="5" cols="30" ></textarea></td></tr>
            <tr><td colspan="2" align="center"><input type="submit" name="submit" value="submit" /></td></tr>
    </table></form>
</code>```

And the action.php should be like this:

```<code><form action="store.php" method="post" align="center" target="_self">
    <label>Name of the person:</label>
   <input type="hidden" name="person" value="<?= $_POST['fname'];?>"></input><?=$_POST['fname'];?>  <br />
    <label>Name of the Surname:</label>
    <input type="hidden" name="surname" value="<?= $_POST['sname'];?>"></input><?=$_POST['sname'];?>  <br />
    <label>His Age:</label>
     <input type="hidden" name="age" value="<?= $_POST['age'];?>"></input><?=$_POST['age'];?> <br />
     <label>Date of Birth:</label>
     <input type="hidden" name="dob" value="<$_POST['DOB'];?>"></input><?=$_POST['DOB'];?>  <br />
      <label>Gender:</label>
     <input type="hidden" name="gender" value="<?= $_POST['gender'];?>"></input><?=$_POST['gender'];?> <br />
      <label>Education:</label>
     <input type="hidden" name="edu" value="<?php if(isset($_POST['submit'])) echo $_POST['study'];?>"></input><?php if(isset($_POST['submit'])) echo $_POST['study'];?>
      <br />
      <label>State:</label>
      <input type="hidden" name="state" value="<?if(isset($_POST['submit'])) echo $_POST['state'];?>"></input><?php if(isset($_POST['submit'])) echo $_POST['state'];?>
      <br />
      <label>Good At:</label>
     <input type="hidden" name="profile" value="<?php echo implode(", ", $_POST['profile']); ?>">
<?php
echo implode(", ", $_POST['profile']);
//print_r($_POST['profile']);
 ?>

<br />
      <label>Address:</label>
      <input type="hidden" name="adr" value="<?= $_POST['adr'];?>"></input><?=$_POST['adr'];?>  <br /><br /><br />
      <input type="submit" value="confirm" name="submit"></input>
</code>```

The data which you are going to store in the database, depends on your database design.

E.g.:- It depends on whether you are going to store the check box
  values as a comma separated string or, using a different table.

Any how at this point of your program, once you are in the action.php page, the data which you fetched using the registration form, could be sent to store.php using a session. Otherwise in the store.php if you use $_POST you'll get the input values which are in those hidden input fields of the action.php page.

Body:
<form action="action.php" method="POST"  target="_self">

Registration form

 First Name:*
 <input type="text"  name="fname" value="" placeholder="firstname"    required="required" maxlength="25">

 SurName:*
 <input type="text"  name="sname" value=""  placeholder="lastname" required="required" maxlength="20"/>

Age:*
  <input type="text" name="age" value="" required/>

Date of Birth:*
 <input type="date" name="DOB" value="" required/>

 Gender:*
  <input type="radio" name="gender" value="male" required/>Male
   <input type="radio" name="gender" value="Female" />Female

Qualification:*
    <select name="study" required>
   <option value="">---Select---</option>
  <option value="btech">B.Tech</option>
  <option value="BSc">BSc</option>
  <option value="BCom">BCom</option>
 </select>

 State:*
<Select name="state" required >
<option value="">---Select---</option>
<option valuie="AndhraPradesh">AndhraPradesh</option>
<option value="Telangana">Telangana</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Kerala">Kerala</option>
<option vgalue="Maharastra">Maharastra</option>
</Select>

Profile:*	<input type="checkbox" name="profile" value="Java" />Java
                            <input type="checkbox" name="profile" value="PHP" />PHP
                            <input type="checkbox" name="profile" val

    ue="Android" />Android

 Address for Communication:	<textarea name="adr" rows="5" cols="30" ></textarea>

<input type="submit" value="submit" />

</form>

** this is my register form and now i want to display all the selected values in next page i.e in action.php and its code is as follows********

    <form action="store.php" method="post" align="center" target="_self">
    Name of the person:
   <input type="hidden" name="person" value="<?= $_POST['fname'];?>"></input><?=$_POST['fname'];?>

    Name of the Surname:
    <input type="hidden" name="surname" value="<?= $_POST['sname'];?>"></input><?=$_POST['sname'];?>

    His Age:
     <input type="hidden" name="age" value="<?= $_POST['age'];?>"></input><?=$_POST['age'];?>

     Date of Birth:
     <input type="hidden" name="dob" value="<$_POST['DOB'];?>"></input><?=$_POST['DOB'];?>

      Gender:
     <input type="hidden" name="gender" value="<?= $_POST['gender'];?>"></input><?=$_POST['gender'];?>

      Education:
     <input type="hidden" name="edu" value="<?php if(isset($_POST['submit']))echo $_POST['study']?>"></input><?php if(isset($_POST['submit'])) echo $_POST['study']?>;?>

      State:
      <input type="hidden" name="state" value="<?if(isset($_POST['submit']))echo $_POST['state']?>"></input><?php if(isset($_POST['submit'])) echo $_POST['state']?>;?>

      Good At:
     <input type="hidden" name="profile" value="<?= $_POST['profile'];?>"></input><?=$_POST['profile'];?>

      Address:
      <input type="hidden" name="adr" value="<?= $_POST['adr'];?>"></input><?=$_POST['adr'];?>

      <input type="submit" value="confirm" name="submit"></input>

****the dropdown is not displaying and also please suggest if after click on confirm then the values that are confirmed has to be stored in database.For that shall I get the values from names of input hidden fields in action.php or  registration input field names?

Body:
There's a lot of syntax errors in your code.

You haven't added a name attribute in the submit button. There should be name="submit" in it. Otherwise when displaying the drop down values, it is being check in your code, and it wouldn't be displayed (because no variable named submit was found in the $_POST array).

The check box is using the same name. So it should be an array. use name=profile[] instead of name=profile

Finally form.php should look like this:

<form action="action.php" method="POST"  target="_self">
<table class="main"  border="1"  height="100%" align="center">
<h3>
<p id="id1" style="background-color: #9FF" >Registration form</p></h3>

 <tr><td> First Name:<span style="color:red">*</span> </td>
<td> <input type="text"  name="fname" value="" placeholder="firstname"    required="required" maxlength="25"></td></tr>
 <tr><td> SurName:<span style="color:red">*</span></td>
 <td><input type="text"  name="sname" value=""  placeholder="lastname" required="required" maxlength="20"/> </td></tr>
 <tr><td>Age:<span style="color:red">*</span></td>
 <td> <input type="text" name="age" value="" required/></td></tr>
 <tr><td>Date of Birth:<span style="color:red">*</span></td>
 <td><input type="date" name="DOB" value="" required/></td></tr>
 <tr><td> Gender:<span style="color:red">*</span></td>
  <td><input type="radio" name="gender" value="male" required/>Male
   <input type="radio" name="gender" value="Female" />Female</td></tr>
  <tr><td>Qualification:<span style="color:red">*</span></td>
   <td> <select name="study" required>
   <option value="">---Select---</option>
  <option value="btech">B.Tech</option>
  <option value="BSc">BSc</option>
  <option value="BCom">BCom</option>
 </select></td></tr>
  <tr><td> State:<span style="color:red">*</span></td>
<td><Select name="state" required >
<option value="">---Select---</option>
<option value="AndhraPradesh">AndhraPradesh</option>
<option value="Telangana">Telangana</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Kerala">Kerala</option>
<option vgalue="Maharastra">Maharastra</option>
</Select></td></tr>

<tr><td>Profile:<span style="color:red">*</span></td><td>

                <input type="checkbox" name="profile[]" value="Java" />Java
                            <input type="checkbox" name="profile[]" value="PHP" />PHP
                            <input type="checkbox" name="profile[]" value="Android" />Android</td> </tr>
    <tr><td> Address for Communication:</td><td><textarea name="adr" rows="5" cols="30" ></textarea></td></tr>
            <tr><td colspan="2" align="center"><input type="submit" name="submit" value="submit" /></td></tr>
    </table></form>

And the action.php should be like this:

<form action="store.php" method="post" align="center" target="_self">
    <label>Name of the person:</label>
   <input type="hidden" name="person" value="<?= $_POST['fname'];?>"></input><?=$_POST['fname'];?>  <br />
    <label>Name of the Surname:</label>
    <input type="hidden" name="surname" value="<?= $_POST['sname'];?>"></input><?=$_POST['sname'];?>  <br />
    <label>His Age:</label>
     <input type="hidden" name="age" value="<?= $_POST['age'];?>"></input><?=$_POST['age'];?> <br />
     <label>Date of Birth:</label>
     <input type="hidden" name="dob" value="<$_POST['DOB'];?>"></input><?=$_POST['DOB'];?>  <br />
      <label>Gender:</label>
     <input type="hidden" name="gender" value="<?= $_POST['gender'];?>"></input><?=$_POST['gender'];?> <br />
      <label>Education:</label>
     <input type="hidden" name="edu" value="<?php if(isset($_POST['submit'])) echo $_POST['study'];?>"></input><?php if(isset($_POST['submit'])) echo $_POST['study'];?>
      <br />
      <label>State:</label>
      <input type="hidden" name="state" value="<?if(isset($_POST['submit'])) echo $_POST['state'];?>"></input><?php if(isset($_POST['submit'])) echo $_POST['state'];?>
      <br />
      <label>Good At:</label>
     <input type="hidden" name="profile" value="<?php echo implode(", ", $_POST['profile']); ?>">
<?php
echo implode(", ", $_POST['profile']);
//print_r($_POST['profile']);
 ?>

<br />
      <label>Address:</label>
      <input type="hidden" name="adr" value="<?= $_POST['adr'];?>"></input><?=$_POST['adr'];?>  <br /><br /><br />
      <input type="submit" value="confirm" name="submit"></input>

The data which you are going to store in the database, depends on your database design.

E.g.:- It depends on whether you are going to store the check box
  values as a comma separated string or, using a different table.

Any how at this point of your program, once you are in the action.php page, the data which you fetched using the registration form, could be sent to store.php using a session. Otherwise in the store.php if you use $_POST you'll get the input values which are in those hidden input fields of the action.php page.


问:
Exception handling : Thread v/s Task
Thread version results in unhandled exception, which crashes the app but the task version doesn't. Both are running exactly the same method Can someone explain the reason for this difference in exception behavior ?

Thread version:

```<code>            try
            {
                new Thread(new ThreadStart(DoWork)).Start();  // do work throws exception
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        static void DoWork()
        {
            Console.WriteLine("in thread");
            throw new Exception();
        }
</code>```

Task version:

```<code>      var errorTask = Task.Factory.StartNew<Func<string>>(() =>
                {
                    Console.WriteLine("in task");
                    throw new Exception();
                });

            try
            {
                string result = errorTask.Result();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
</code>```

答:
To shed some light on the topic one could consult the documentation for Task.Result<TResult>() (or the one for Task.Wait() for what it's worth).

Under thrown exceptions (particularly AggregateException) is says

An exception was thrown during the execution of the task. The AggregateException.InnerExceptions collection contains information about the exception or exceptions.

A Task is kind of a managed thread (in very simple terms) which gives us some merits, e.g. this exception handling when accessing Result or Wait (or using await). On the other hand a Thread will execute separately from the method you are calling it from. You start the thread an (virtually) immediately leave the try / catch block. There is no way to know for the thread that there is an associated try / catch. Basically the thread does not know anything about the calling function. The other way round, if the calling function blocked its own thread to wait for the thread it created, just to make use of the try / catch this would basically render creating new threads useless.

Title: Exception handling : Thread v/s Task

Body:
Thread version results in unhandled exception, which crashes the app but the task version doesn't. Both are running exactly the same method Can someone explain the reason for this difference in exception behavior ?

Thread version:

            try
            {
                new Thread(new ThreadStart(DoWork)).Start();  // do work throws exception
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        static void DoWork()
        {
            Console.WriteLine("in thread");
            throw new Exception();
        }

Task version:

      var errorTask = Task.Factory.StartNew<Func<string>>(() =>
                {
                    Console.WriteLine("in task");
                    throw new Exception();
                });

            try
            {
                string result = errorTask.Result();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }


问:
Why are my buttons going out of screen in my Ionic app?
I have created a simple chat form in Ionic.

Problem: Buttons are going out of screen.

It looks like this this -

My chat.html

```<code><ion-header>

  <ion-navbar>
    <ion-title>communicationgiven</ion-title>
    <button ion-button (click)="close()" style="margin-left: 90%;margin-top: -3%">Close</button>
  </ion-navbar>

</ion-header>

<ion-content padding>

  <ion-list>
  <div>

  <p *ngFor="let list of list; let i = index;">
    <ion-item>
        <!-- <p style="color: #1bb0f4;font-size: 20px;">Tagto {{list.TAG_TO}}</p> -->
        <p style="color: #1bb0f4;"> {{list.TAG_FROM}}</p>
        <p style="color: #d2dce1;"> {{list.TAG}}</p>
    </ion-item>
  </p>
  </div>
    </ion-list>
</ion-content>

<ion-footer class="footer">
  <form #com="ngForm" (submit)="onsubmit(com.value)">
    <ion-input placeholder="TAG" type="text" name="TAG" ngModel ></ion-input>
    <button ion-button type="submit" style="margin-left: 90%;margin-top: -5%;">Submit</button>
  </form>

</ion-footer>
</code>```

I want to know why my buttons are going out of the page; how can I make sure they stay inside the screen, irrespective of the screen size?

What is the best practice here? I am fairly new in CSS.

答:
It's hard to answer this one as I can't replicate the issue locally with what you've provided.

I'd start by reducing the margin-left: 90% on the button element, see how that goes.

In regard to best practices, an important one is to not use inline styles. That is putting styles in the style html attribute. Instead try using an external style sheet or at least an internal style sheet, see: https://www.w3schools.com/css/css_howto.asp

ContentLicense: CC BY-SA 4.0

Body:
I have created a simple chat form in Ionic.

Problem: Buttons are going out of screen.

It looks like this this -

My chat.html

<ion-header>

  <ion-navbar>
    <ion-title>communicationgiven</ion-title>
    <button ion-button (click)="close()" style="margin-left: 90%;margin-top: -3%">Close</button>
  </ion-navbar>

</ion-header>

<ion-content padding>

  <ion-list>

    <ion-item>

 {{list.TAG_FROM}}

 {{list.TAG}}

    </ion-item>

    </ion-list>
</ion-content>

<ion-footer class="footer">
  <form #com="ngForm" (submit)="onsubmit(com.value)">
    <ion-input placeholder="TAG" type="text" name="TAG" ngModel ></ion-input>
    <button ion-button type="submit" style="margin-left: 90%;margin-top: -5%;">Submit</button>
  </form>

</ion-footer>

I want to know why my buttons are going out of the page; how can I make sure they stay inside the screen, irrespective of the screen size?

What is the best practice here? I am fairly new in CSS.


问:
how to get the count of specific letters occurances from a array of words
i want to get the count of some text that starts with specific letter with "/"
 just like as follows. i want the count of all "A/" occurancves in that array.</p>

```<code><?php
$arr_vals = array("A/V","A/B","B/A","D/D","A/v","A/A");

$count_A = count($arr_vals,"A/*");

?>
</code>```

答:
Simple and easy one..Here is your solution:-</p>

```<code>$input = preg_quote('A/', '~'); // don't forget to quote input string!
$arr_vals = array("A/V","A/B","B/A","D/D","A/v","A/A");
$result = preg_grep('~' . $input . '~', $arr_vals);
echo count($result); die;
</code>```

Body:
i want to get the count of some text that starts with specific letter with "/"
 just like as follows. i want the count of all "A/" occurancves in that array.

<?php
$arr_vals = array("A/V","A/B","B/A","D/D","A/v","A/A");

$count_A = count($arr_vals,"A/*");

?>

Body:
Simple and easy one..Here is your solution:-

$input = preg_quote('A/', '~'); // don't forget to quote input string!
$arr_vals = array("A/V","A/B","B/A","D/D","A/v","A/A");
$result = preg_grep('~' . $input . '~', $arr_vals);
echo count($result); die;


问:
Registry Editor - .bat file What to type in the file to get rid of the pop-up screen?
In my code (below) I added a file to the Registry Editor so my VHD is added at the start. When I boot up it shows a pop-up screen stating that the VHD was mounted. I'd like to have the mounting happen in the background without a pop-up screen showing. Is this possible to do in the .bat file or is it something I'd have to edit in the registry editor?</p>

```<code>@echo off
SET TEMPFILE="%TEMP%%RANDOM%.TXT"
echo SELECT VDISK FILE=F:\mount.vhd>%TEMPFILE%
echo ATTACH VDISK>>%TEMPFILE%
DISKPART /s %TEMPFILE%
del %TEMPFILE%
</code>```

答:
Try this out to attach vhd without UAC Prompt.

First Create a folder named C:\Scripts
Under Scripts Folder Create to Files.

C:\Scripts\myvhd.txt

C:\Scripts\StartMyVHD.bat

Using DiskPart to Attach VHD Silently

Create a text file "myvhd.txt"

Input VHD Info you want to attach with following two lines:

```<code>select vdisk file="<Full Path to VHD>"
attach vdisk
</code>```

For example:

```<code>select vdisk file="c:\Test.vhd"
attach vdisk
</code>```

Save the file and close.

create another file named as StartMyVHD.bat

```<code>@echo off
diskpart /s c:\Scripts\myvhd.txt
exit
</code>```

Now bypass the UAC Prompt

Open Task Scheduler -:

Create a New Task - Name it Something like - StartVHDTask

Select the Actions Tab and click New

Browse/Select the location of c:\Scripts\StartMyVHD.bat

Now goto General Tab and select/tick the Run with Highest privileges option

(Optional If Required)

Commandline to add to Task Scheduler

```<code>schtasks.exe /create /tn "StartVHDTask" /sc ONSTART /TR "C:\Scripts\StartMyVHD.bat" /ru SYSTEM /RL HIGHEST
</code>```

Body:
In my code (below) I added a file to the Registry Editor so my VHD is added at the start. When I boot up it shows a pop-up screen stating that the VHD was mounted. I'd like to have the mounting happen in the background without a pop-up screen showing. Is this possible to do in the .bat file or is it something I'd have to edit in the registry editor?

@echo off
SET TEMPFILE="%TEMP%%RANDOM%.TXT"
echo SELECT VDISK FILE=F:\mount.vhd>%TEMPFILE%
echo ATTACH VDISK>>%TEMPFILE%
DISKPART /s %TEMPFILE%
del %TEMPFILE%

Body:
Try this out to attach vhd without UAC Prompt.

First Create a folder named C:\Scripts
Under Scripts Folder Create to Files.

C:\Scripts\myvhd.txt

C:\Scripts\StartMyVHD.bat

Using DiskPart to Attach VHD Silently

Create a text file "myvhd.txt"

Input VHD Info you want to attach with following two lines:

select vdisk file="<Full Path to VHD>"
attach vdisk

For example:

select vdisk file="c:\Test.vhd"
attach vdisk

Save the file and close.

create another file named as StartMyVHD.bat

@echo off
diskpart /s c:\Scripts\myvhd.txt
exit

Now bypass the UAC Prompt

Open Task Scheduler -:

Create a New Task - Name it Something like - StartVHDTask

Select the Actions Tab and click New

Browse/Select the location of c:\Scripts\StartMyVHD.bat

Now goto General Tab and select/tick the Run with Highest privileges option

(Optional If Required)

Commandline to add to Task Scheduler

schtasks.exe /create /tn "StartVHDTask" /sc ONSTART /TR "C:\Scripts\StartMyVHD.bat" /ru SYSTEM /RL HIGHEST


问:
Why does password generated from "openssl passwd -1" has different length than md5sum?
Say password is 000000

```<code>cmd> openssl passwd -1 000000
$1$noyU0rJi$iZ7EgOhutl2aJItaBcF5v.

cmd> echo -n '000000noyU0rJi' | md5sum    #cmd might be incorrect
1be6132fd5be99229741e0b88700fe95  -
</code>```

md5sum hash should have 32 characters, but the hash from openssl is only 22 characters (iZ7EgOhutl2aJItaBcF5v). Why is that?

Edit: I got some downvote, would be helpful if you could explain why..

答:
At least part of the difference you are seeing is that the output of the openssl tool is in the base64 format associated with the Unix crypt function [ https://en.wikipedia.org/wiki/Crypt_(C) ], whereas the output of the md5 function is in hexadecimal (base16).

If you look carefully, you can see that the output of md5sum only has the digits 0-9 and the lowercase letters a-f.  The output of the openssl command has numbers and what appears to be the full alphabet, including upper and lowercase letters.

When you encode information more densely (base64), the length will naturally be shorter.

Body:
Say password is 000000

cmd> openssl passwd -1 000000
$1$noyU0rJi$iZ7EgOhutl2aJItaBcF5v.

cmd> echo -n '000000noyU0rJi' | md5sum    #cmd might be incorrect
1be6132fd5be99229741e0b88700fe95  -

md5sum hash should have 32 characters, but the hash from openssl is only 22 characters (iZ7EgOhutl2aJItaBcF5v). Why is that?

Edit: I got some downvote, would be helpful if you could explain why..


问:
Represent XML content as NSData - iPhone
I have an external XML file which I want to be represented in an NSData object

I am doing this;

```<code> NSError *error;
NSString* contents = [NSString stringWithContentsOfUrl:[NSURL URLWithString:@"http://www.apple.com/"]
                                              encoding:NSUTF8StringEncoding
                                                 error:&error];
NSData* xmlData = [contents dataUsingEncoding:NSUTF8StringEncoding];</code>```

But for some reasons, I am getting an error (does not respond)

Please help me.

答:
Don't have time to test this out but I think you may want to try looking into NSData's dataWithContentsOfURL: or dataWithContentsOfURL:options:error: and get it directly as data.

Also, unless you just threw http://www.apple.com/ in as a placeholder, I don't believe the source of that page is valid XML. The following feed is valid xml: https://stackoverflow.com/feeds You could try that. with what you have now first and see if it works.

Hope this helps.

Updated:

Without my knowing your project, you may get some benefit from using TouchXML - https://github.com/mrevilme/TouchXML which handles XML very well including what you are trying to do:

```<code>CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithContentsOfURL:(NSURL *)inURL encoding:(NSStringEncoding)encoding options:(NSUInteger)inOptions error:(NSError **)outError];
</code>```

Body:
I have an external XML file which I want to be represented in an NSData object

I am doing this;

 NSError *error;
NSString* contents = [NSString stringWithContentsOfUrl:[NSURL URLWithString:@"http://www.apple.com/"]
                                              encoding:NSUTF8StringEncoding
                                                 error:&error];
NSData* xmlData = [contents dataUsingEncoding:NSUTF8StringEncoding];

But for some reasons, I am getting an error (does not respond)

Please help me.

Body:
Don't have time to test this out but I think you may want to try looking into NSData's dataWithContentsOfURL: or dataWithContentsOfURL:options:error: and get it directly as data.

Also, unless you just threw http://www.apple.com/ in as a placeholder, I don't believe the source of that page is valid XML. The following feed is valid xml: https://stackoverflow.com/feeds You could try that. with what you have now first and see if it works.

Hope this helps.

Updated:

Without my knowing your project, you may get some benefit from using TouchXML - https://github.com/mrevilme/TouchXML which handles XML very well including what you are trying to do:

CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithContentsOfURL:(NSURL *)inURL encoding:(NSStringEncoding)encoding options:(NSUInteger)inOptions error:(NSError **)outError];


问:
Could not locate javascript files in react-split-pane
I installed react-split-pane through npm. But couldn't reference it to my project.
Please let me know how to reference this in the project.

The GitHub repo is https://github.com/tomkp/react-split-pane

答: usually you have to include this line in the header of your file import SplitPane from "react-split-pane" so you can use the library, I'm not sure if that's your problem since you did not provide any of your code


问:
C# Entity Framework complex join
Trying to figure this out since last 5 hours but couldn't find any solution.

Basically I am trying to create an excel with ExcelPackage from below data

```<code>Table1
    ID    Name
    1      t1_1
    2      t1_2

Table2
    ID    Name
    1      t2_1
    2      t2_2

Table12
    ID    Table1   Table2   Value
    1      1         1       v11
    2      2         2       v12
</code>```

from this trying to get any of the following

```<code>Table1Name, t2_1, t2_2
t1_1,       v11 ,
t1_2,           , v12
</code>```

is there a way in EF to get row in this format? Where I am stuck is for each record in Table1 I want to get all record of Table2 with Value (from Table12) null if empty without repeating Table1 record (kind of turning rows of Table12 into columns of Table1).

Thanks

答:
```<code>var info = (from t1 in Table1
            from t2 in Table2
            join t120 in Table12
            on new {Table1 = t1.ID, Table2 = t2.ID} equals new {t120.Table1, t120.Table2} into t12s
            from t12 in t12s.DefaultIfEmpty()
            group new { t2, t12 } by new { t1.ID, t1.Name } into sub
            select new
            {
                sub.Key.Name,
                data = sub.Select(x => new { x.t2.Name, x.t12 == null ? null : x.t12.Value }).ToList()
            }).ToList();

foreach(var item in info)
{
    Console.Write($"{item.Name}\t");
    foreach(sub in item.data.OrderBy(x => x.Name))
        Console.Write($"{sub.Name}:{sub.Value}\t");
    Console.WriteLine("");
}
</code>```

Title: C# Entity Framework complex join

Body:
Trying to figure this out since last 5 hours but couldn't find any solution.

Basically I am trying to create an excel with ExcelPackage from below data

Table1
    ID    Name
    1      t1_1
    2      t1_2

Table2
    ID    Name
    1      t2_1
    2      t2_2

Table12
    ID    Table1   Table2   Value
    1      1         1       v11
    2      2         2       v12

from this trying to get any of the following

Table1Name, t2_1, t2_2
t1_1,       v11 ,
t1_2,           , v12

is there a way in EF to get row in this format? Where I am stuck is for each record in Table1 I want to get all record of Table2 with Value (from Table12) null if empty without repeating Table1 record (kind of turning rows of Table12 into columns of Table1).

Thanks


问:
How to convert complex query to Model in a LINQ to Entities query
```<code>public class Gateway : ModelBase
    {
        public int Id { get; set; }
        public int SystemGroupId { get; set; }
        public string DeviceName { get; set; }
        public string MacAddress { get; set; }
        public bool Enabled { get; set; }
    }

public class SystemGroup : ModelBase
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
</code>```

I am joining these two tables.

```<code>var Query = (from g in dbContext.Gateways
join s in dbContext.SystemGroups on g.SystemGroupId equals s.Id
select new {
Id = g.Id,
SystemGroupId = g.SystemGroupId,
SystemGroupName = s.Name,
DeviceName = g.DeviceName,
MacAddress = g.MacAddress,
DeviceType = g.DeviceType,
Enabled = g.Enabled });
</code>```

and I am sorting these result set using the below code.

```<code>if (sortParameter == Resources.ViewResources.Views.SystemGroup)
   Query = Query.OrderBy(x => x.SystemGroupName);
else if (sortParameter == Resources.ViewResources.Views.DeviceName)
   Query = Query.OrderBy(x => x.DeviceName);
else
   Query = Query.OrderBy(x => x.Id);
</code>```

Till now it is working as expected. Finally, I want to convert it to Gateway.

```<code>return Query.Select(x => new Gateway {
 Id= x.Id,
 SystemGroupId = x.SystemGroupId,
 DeviceName = x.DeviceName,
 MacAddress=x.MacAddress,
 DeviceType= x.DeviceType,
 Enabled= x.Enabled}).ToList();
</code>```

While converting to Gateway, it is throwing the error:

The entity or complex type 'Models.Context.Gateway' cannot be constructed in a LINQ to Entities query.

答:
In Linq-to-Entities you can only project to an anonymous type or a regular class. You can't project to an existing entity type. You can with linq-to-objects like so

```<code>return Query.Select new {
Id= x.Id,
SystemGroupId = x.SystemGroupId,
DeviceName = x.DeviceName,
MacAddress=x.MacAddress,
DeviceType= x.DeviceType,
Enabled= x.Enabled}).AsEnumerable().Select(x => new Gateway {
        Id= x.Id,
SystemGroupId = x.SystemGroupId,
DeviceName = x.DeviceName,
MacAddress=x.MacAddress,
DeviceType= x.DeviceType,
Enabled= x.Enabled}).ToList();
</code>```

I didnt test this one,Please do comment after try this one.then i can help you to get your answer.

Body:
public class Gateway : ModelBase
    {
        public int Id { get; set; }
        public int SystemGroupId { get; set; }
        public string DeviceName { get; set; }
        public string MacAddress { get; set; }
        public bool Enabled { get; set; }
    }

public class SystemGroup : ModelBase
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

I am joining these two tables.

var Query = (from g in dbContext.Gateways
join s in dbContext.SystemGroups on g.SystemGroupId equals s.Id
select new {
Id = g.Id,
SystemGroupId = g.SystemGroupId,
SystemGroupName = s.Name,
DeviceName = g.DeviceName,
MacAddress = g.MacAddress,
DeviceType = g.DeviceType,
Enabled = g.Enabled });

and I am sorting these result set using the below code.

if (sortParameter == Resources.ViewResources.Views.SystemGroup)
   Query = Query.OrderBy(x => x.SystemGroupName);
else if (sortParameter == Resources.ViewResources.Views.DeviceName)
   Query = Query.OrderBy(x => x.DeviceName);
else
   Query = Query.OrderBy(x => x.Id);

Till now it is working as expected. Finally, I want to convert it to Gateway.

return Query.Select(x => new Gateway {
 Id= x.Id,
 SystemGroupId = x.SystemGroupId,
 DeviceName = x.DeviceName,
 MacAddress=x.MacAddress,
 DeviceType= x.DeviceType,
 Enabled= x.Enabled}).ToList();

While converting to Gateway, it is throwing the error:

The entity or complex type 'Models.Context.Gateway' cannot be constructed in a LINQ to Entities query.

Body:
In Linq-to-Entities you can only project to an anonymous type or a regular class. You can't project to an existing entity type. You can with linq-to-objects like so

return Query.Select new {
Id= x.Id,
SystemGroupId = x.SystemGroupId,
DeviceName = x.DeviceName,
MacAddress=x.MacAddress,
DeviceType= x.DeviceType,
Enabled= x.Enabled}).AsEnumerable().Select(x => new Gateway {
        Id= x.Id,
SystemGroupId = x.SystemGroupId,
DeviceName = x.DeviceName,
MacAddress=x.MacAddress,
DeviceType= x.DeviceType,
Enabled= x.Enabled}).ToList();

I didnt test this one,Please do comment after try this one.then i can help you to get your answer.


问:
Not getting desired behaviour of translucentstatusbar when navigation drawer is used
I'm getting the desired result of translucentstatusbar when I'm not having a navigation drawer in the activity. But when there is a navigation drawer, the status bar doesn't become translucent as desired. I do not have an AppBar or a ToolBar in the activity.

content_homey.xml

```<code>    <TextView
        android:id="@+id/check_internet_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:text="Please check your internet\n connection and try again"
        android:textColor="#000000"
        android:textSize="22sp"
        android:textStyle="bold"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/try_again_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:text="TRY AGAIN"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/check_internet_text"
        app:layout_constraintVertical_bias="0.163" />

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view_home_categories"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0" />

    <com.arlib.floatingsearchview.FloatingSearchView
        android:id="@+id/floating_search_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="32dp"
        app:floatingSearch_close_search_on_keyboard_dismiss="true"
        app:floatingSearch_leftActionMode="showHamburger"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/recycler_view_home_categories"
        app:layout_constraintVertical_bias="0.0" />

</android.support.constraint.ConstraintLayout>
</code>```

activity_homey.xml

```<code><android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:openDrawer="start"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme" >

    <include
        layout="@layout/content_homey"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_homey"
        app:menu="@menu/activity_homey_drawer" />

</android.support.v4.widget.DrawerLayout>
</code>```

nav_header_homey.xml

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_header_height"
    android:background="@drawable/side_nav_bar"
    android:gravity="bottom"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:theme="@style/AppTheme"
    android:fitsSystemWindows="true">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        android:text="Android Studio"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="android.studio@android.com" />

</LinearLayout>
</code>```

v21/styles.xml

```<code><style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">false</item>
    <item name="android:windowActivityTransitions">true</item>
    <item name="android:windowContentTransitions">true</item>

    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

</style>
</code>```

答:
try this code

```<code><style name="AppTheme" parent="AppTheme.Base"/>

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="actionModeBackground">@color/primary</item>
    <item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionModeOverlay">true</item>
</style>
</code>```

Apply theme to application in manifest

AndroidManifest.xml

```<code><application
    android:icon="@mipmap/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
</code>```

Body:
I'm getting the desired result of translucentstatusbar when I'm not having a navigation drawer in the activity. But when there is a navigation drawer, the status bar doesn't become translucent as desired. I do not have an AppBar or a ToolBar in the activity.

content_homey.xml

    <TextView
        android:id="@+id/check_internet_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:text="Please check your internet\n connection and try again"
        android:textColor="#000000"
        android:textSize="22sp"
        android:textStyle="bold"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/try_again_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:text="TRY AGAIN"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/check_internet_text"
        app:layout_constraintVertical_bias="0.163" />

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view_home_categories"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0" />

    <com.arlib.floatingsearchview.FloatingSearchView
        android:id="@+id/floating_search_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="32dp"
        app:floatingSearch_close_search_on_keyboard_dismiss="true"
        app:floatingSearch_leftActionMode="showHamburger"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/recycler_view_home_categories"
        app:layout_constraintVertical_bias="0.0" />

</android.support.constraint.ConstraintLayout>

activity_homey.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:openDrawer="start"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme" >

    <include
        layout="@layout/content_homey"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_homey"
        app:menu="@menu/activity_homey_drawer" />

</android.support.v4.widget.DrawerLayout>

nav_header_homey.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_header_height"
    android:background="@drawable/side_nav_bar"
    android:gravity="bottom"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:theme="@style/AppTheme"
    android:fitsSystemWindows="true">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        android:text="Android Studio"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="android.studio@android.com" />

</LinearLayout>

v21/styles.xml

Body:
try this code

<style name="AppTheme" parent="AppTheme.Base"/>

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="actionModeBackground">@color/primary</item>
    <item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionModeOverlay">true</item>
</style>

Apply theme to application in manifest

AndroidManifest.xml

<application
    android:icon="@mipmap/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">


答:
array_reduce can be used to take your entire array and compute a result, through the use of a callback function.  We can use regular expressions to define what your pattern is.  Combining these two things, we have your solution:

```<code>$arr_vals = array("A/V","A/B","B/A","D/D","A/v","A/A");

function match($carry, $item)  {
  return $carry + preg_match('/A\/./', $item);
}

var_dump(array_reduce($arr_vals, 'match', 0));  // Returns 4
</code>```

Title: how to get the count of specific letters occurances from a array of words

Body:
array_reduce can be used to take your entire array and compute a result, through the use of a callback function.  We can use regular expressions to define what your pattern is.  Combining these two things, we have your solution:

$arr_vals = array("A/V","A/B","B/A","D/D","A/v","A/A");

function match($carry, $item)  {
  return $carry + preg_match('/A\/./', $item);
}

var_dump(array_reduce($arr_vals, 'match', 0));  // Returns 4


问:
regular expression pattern to accept one or multiple ip addresses?
I am using below regular expression pattern

```<code>pattern="^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$|\s*
</code>```

It will accept any one of the below ip address

```<code>1.1.2.3 or 192.122.134.1 or 198.23.45.56
</code>```

But i want it should accept single as well as  ip addresses with comma separated as well like below

```<code>1.1.2.3,192.122.134.1,198.23.45.56
</code>```

What changes i have to do in my regular expression?

Body:
I am using below regular expression pattern

pattern="^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$|\s*

It will accept any one of the below ip address

1.1.2.3 or 192.122.134.1 or 198.23.45.56

But i want it should accept single as well as  ip addresses with comma separated as well like below

1.1.2.3,192.122.134.1,198.23.45.56

What changes i have to do in my regular expression?

Body:
<input type="text" name="country_code" pattern="^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])).(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])).(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])).(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))(,(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])).(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])).(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])).(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])))*$">

Use this input field in your HTML file


问:
Navigation controller is always nil
I am presenting UIViewController like:

```<code>UIStoryboard *storyboard  = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

PhotoViewController *resultVC = [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([PhotoViewController class])];
[self.navigationController presentViewController:resultVC animated:YES completion:^{}];
</code>```

I have logged console and result is:

```<code>po self.navigationController
<UINavigationController: 0x9c3e920>
</code>```

But when i am in PhotoViewController class i have logged console and result is :

```<code>po self.navigationController
nil
</code>```

its nil here. i don't know why this happens. Also i have present with this one but its nil always :

```<code>[self presentViewController:resultVC animated:YES completion:^{}];
</code>```

答:
I produce private navigationController(here is nav), then assign to the main window, following is the code:

self.nav = [[UINavigationController alloc] initWithRootViewController:self];

[[[UIApplication sharedApplication] delegate] window].rootViewController = self.nav;

you can push the view controller with the private navigationController

[self.nav pushViewController:vc animated:YES];

It works for me!

But you must export the property nav for next or child View Controller to use

Title: Navigation controller is always nil

Body:
I am presenting UIViewController like:

UIStoryboard *storyboard  = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

PhotoViewController *resultVC = [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([PhotoViewController class])];
[self.navigationController presentViewController:resultVC animated:YES completion:^{}];

I have logged console and result is:

po self.navigationController
<UINavigationController: 0x9c3e920>

But when i am in PhotoViewController class i have logged console and result is :

po self.navigationController
nil

its nil here. i don't know why this happens. Also i have present with this one but its nil always :

[self presentViewController:resultVC animated:YES completion:^{}];


问:
MS CRM 2011 CSV import (programatically)
How do I do that?

I need to import (and map) a CSV file to a custom entity in CRM 2011.

I am running an on-premise instance of CRM 2011 and need to use the late bound entities approach.

I have already tried following this example: Export and import a data map but failed miserably (ImportMap not found - what assembly is it in?).

答:
Hi you can do something like below programatically, without creating early-bound classes.

```<code>using (StreamReader reader = new StreamReader("D://yourfileFolder//file.txt"))
    {
       string line;
       while ((line = reader.ReadLine()) != null && line!=String.Empty)
       {
       var values = line.Split(','); //your data separator, it could be any character

       Entity customEntity = new Entity("entityLogicalName");

       //you should adjust the values according to the data-type on Dynamics CRM e.g
       // customEntity ["revenue"] = new Money(values[0].ToString());

       customEntity ["field1"] = values[0];
       customEntity ["field2"] = values[1];
       customEntity ["field3"] = values[2];
       orgService.Create(customEntity);
       }
  }
</code>```

Body:
Hi you can do something like below programatically, without creating early-bound classes.

using (StreamReader reader = new StreamReader("D://yourfileFolder//file.txt"))
    {
       string line;
       while ((line = reader.ReadLine()) != null && line!=String.Empty)
       {
       var values = line.Split(','); //your data separator, it could be any character

       Entity customEntity = new Entity("entityLogicalName");

       //you should adjust the values according to the data-type on Dynamics CRM e.g
       // customEntity ["revenue"] = new Money(values[0].ToString());

       customEntity ["field1"] = values[0];
       customEntity ["field2"] = values[1];
       customEntity ["field3"] = values[2];
       orgService.Create(customEntity);
       }
  }


问:
Python, Regex to replace strings contains “/”, “(” and “)”
I'd like to write a regex to replace matched string question.

A is the short string and B is a long one contains A.

```<code>A = "5456-module - PAN-12"
B = "5456-module - PAN-12 (100%); 2883-controller - CHG-24; 2898-battery - BAT-12-100 (12 V/100); 2917-panel - MKT-200 (4 x PAN-12-50)"
</code>```

I want to remove A part in B, as long as it contains A with “ (100%)”.

This line works well.

```<code>Print re.sub(A + r'\s[()]100%[()];\s', "", B)
</code>```

And it returns:

```<code>2883-controller - CHG-24; 2898-battery - BAT-12-100 (12 V/100); 2917-panel - MKT-200 (4 x PAN-12-50)
</code>```

However, when the A string contains “/” and “(”, “)”. It doesn’t work. Like:

```<code>new_A = "5456-module - PAN-12 V/50 Wp (1/2 Inch)"
new_B = "5456-module - PAN-12 V/50 Wp (1/2 Inch) (100%); 2883-controller - CHG-24; 2898-battery - BAT-12-100 (12 V/100); 2917-panel - MKT-200 (4 x PAN-12-50)"
</code>```

When I run the same line:

```<code>Print re.sub(new_A + r'\s[()]100%[()];\s', "", new_B).
</code>```

nothing happens.

How can I make the line work?

答:
A in your second example contains parentheses which the regex engine interprets as metacharacters (capture groups in this case). Since you want them matched literally, you'd need to escape them. This would involve appending a backslash before each such character.

re, however, provides a nice little convenience function, re.escape, that does this for you.

Here's what you'd need to pass as your modified regex:

```<code>r'{}\s\(100%\);\s'.format(re.escape(A))
</code>```

Body:
I'd like to write a regex to replace matched string question.

A is the short string and B is a long one contains A.

A = "5456-module - PAN-12"
B = "5456-module - PAN-12 (100%); 2883-controller - CHG-24; 2898-battery - BAT-12-100 (12 V/100); 2917-panel - MKT-200 (4 x PAN-12-50)"

I want to remove A part in B, as long as it contains A with “ (100%)”.

This line works well.

Print re.sub(A + r'\s[()]100%[()];\s', "", B)

And it returns:

2883-controller - CHG-24; 2898-battery - BAT-12-100 (12 V/100); 2917-panel - MKT-200 (4 x PAN-12-50)

However, when the A string contains “/” and “(”, “)”. It doesn’t work. Like:

new_A = "5456-module - PAN-12 V/50 Wp (1/2 Inch)"
new_B = "5456-module - PAN-12 V/50 Wp (1/2 Inch) (100%); 2883-controller - CHG-24; 2898-battery - BAT-12-100 (12 V/100); 2917-panel - MKT-200 (4 x PAN-12-50)"

When I run the same line:

Print re.sub(new_A + r'\s[()]100%[()];\s', "", new_B).

nothing happens.

How can I make the line work?

Body:
A in your second example contains parentheses which the regex engine interprets as metacharacters (capture groups in this case). Since you want them matched literally, you'd need to escape them. This would involve appending a backslash before each such character.

re, however, provides a nice little convenience function, re.escape, that does this for you.

Here's what you'd need to pass as your modified regex:

r'{}\s\(100%\);\s'.format(re.escape(A))


问:
TypeError: Must be str, not int error occuring
I am trying to send the data from a CGI script to a C server in order to write the data down to an XML file.

Client.cgi:

```<code>import cgi, cgitb
import os
import sys
import argparse
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings()
import sys
import socket

form = cgi.FieldStorage()

#--PARSING THE ARGUMENTS
#--To be used to get arguments from Command Line or Php Script
parser = argparse.ArgumentParser(description ='parser script')
parser.add_argument('--serverId', required=True, help='Server ID to find device info')
parser.add_argument('--name', required=True, help='Name Of the Policy')
parser.add_argument('--host', default='any', help='Host of the IP Address')
parser.add_argument('--port', default='any', help='Port used')
parser.add_argument('--proto', default='any', help='Protocol used')
parser.add_argument('--username', default='any', help='Username')
parser.add_argument('--password', default='any', help='Password')
parser.add_argument('--key', default='any', help='')
parser.add_argument('--companyName', default='any', help='Name of the Company')
parser.add_argument('--officeAddress', default='any', help='Address of the Company')
parser.add_argument('--state', default='any', help='State')
parser.add_argument('--country', default='any', help='Country')
parser.add_argument('--ladmin', default='any', help='Local Admin')
parser.add_argument('--phone', default='any', help='Phone Number')
parser.add_argument('--mobile', default='any', help='Mobile Number')
parser.add_argument('--email', default='any', help='Email Address')
parser.add_argument('--designation', default='any', help='Designation of the concerned')
parser.add_argument('--rManager', default='any', help='Reporting Manager of the concerned Person')

args = parser.parse_args()

#--Associating variables to parsed arguments
serverId = str(args.serverId)
name = str(args.name)
host = str(args.host)
port = str(args.port)
proto = str(args.proto)
user = str(args.username)
password = str(args.password)
key = str(args.key)
company = str(args.companyName)
officeAddr = str(args.officeAddress)
state = str(args.state)
country = str(args.country)
ladmin = str(args.ladmin)
phone = str(args.phone)
mobile = str(args.mobile)
email = str(args.email)
designation = str(args.designation)
reportingMgr = str(args.rManager)

def client_program():
    host = socket.gethostname()  # as both code is running on same pc
    port = 8888  # socket server port number

    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # instantiate
    client_socket.connect((host, port))  # connect to the server

    sum = serverId+";"+name+";"+host+";"+port+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr

    client_socket.sendall(sum.encode('utf-8'))
    data = client_socket.recv(1024)
    text = str(data)

    print('received:' +text)
    print('closing socket')
    client_socket.close()

if __name__ == '__main__':
    client_program()
</code>```

when passing arguments through command line like

```<code>python dscr.cgi --serverId PA124 --name Devanshu
</code>```

I get a traceback call as folowing

```<code>Traceback (most recent call last):
  File "dscr.cgi", line 90, in <module>
    client_program()
  File "dscr.cgi", line 79, in client_program
    sum = serverId+";"+name+";"+host+";"+port+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr
TypeError: must be str, not int
</code>```

I realise that its nothing but a silly mistake but I'm unable to find out what. Thanks for the help in advance.

答:
Replace following line

```<code>port = 8888  # socket server port number
</code>```

with

```<code>port = '8888'  # socket server port number
</code>```

Or you can type cast before forming connection string as string concat operations should be done only with another string i.e. replace

```<code>sum = serverId+";"+name+";"+host+";"+port+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr
</code>```

with

```<code>sum = serverId+";"+name+";"+host+";"+str(port)+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr
</code>```

Body:
I am trying to send the data from a CGI script to a C server in order to write the data down to an XML file.

Client.cgi:

import cgi, cgitb
import os
import sys
import argparse
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings()
import sys
import socket

form = cgi.FieldStorage()

#--PARSING THE ARGUMENTS
#--To be used to get arguments from Command Line or Php Script
parser = argparse.ArgumentParser(description ='parser script')
parser.add_argument('--serverId', required=True, help='Server ID to find device info')
parser.add_argument('--name', required=True, help='Name Of the Policy')
parser.add_argument('--host', default='any', help='Host of the IP Address')
parser.add_argument('--port', default='any', help='Port used')
parser.add_argument('--proto', default='any', help='Protocol used')
parser.add_argument('--username', default='any', help='Username')
parser.add_argument('--password', default='any', help='Password')
parser.add_argument('--key', default='any', help='')
parser.add_argument('--companyName', default='any', help='Name of the Company')
parser.add_argument('--officeAddress', default='any', help='Address of the Company')
parser.add_argument('--state', default='any', help='State')
parser.add_argument('--country', default='any', help='Country')
parser.add_argument('--ladmin', default='any', help='Local Admin')
parser.add_argument('--phone', default='any', help='Phone Number')
parser.add_argument('--mobile', default='any', help='Mobile Number')
parser.add_argument('--email', default='any', help='Email Address')
parser.add_argument('--designation', default='any', help='Designation of the concerned')
parser.add_argument('--rManager', default='any', help='Reporting Manager of the concerned Person')

args = parser.parse_args()

#--Associating variables to parsed arguments
serverId = str(args.serverId)
name = str(args.name)
host = str(args.host)
port = str(args.port)
proto = str(args.proto)
user = str(args.username)
password = str(args.password)
key = str(args.key)
company = str(args.companyName)
officeAddr = str(args.officeAddress)
state = str(args.state)
country = str(args.country)
ladmin = str(args.ladmin)
phone = str(args.phone)
mobile = str(args.mobile)
email = str(args.email)
designation = str(args.designation)
reportingMgr = str(args.rManager)

def client_program():
    host = socket.gethostname()  # as both code is running on same pc
    port = 8888  # socket server port number

    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # instantiate
    client_socket.connect((host, port))  # connect to the server

    sum = serverId+";"+name+";"+host+";"+port+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr

    client_socket.sendall(sum.encode('utf-8'))
    data = client_socket.recv(1024)
    text = str(data)

    print('received:' +text)
    print('closing socket')
    client_socket.close()

if __name__ == '__main__':
    client_program()

when passing arguments through command line like

python dscr.cgi --serverId PA124 --name Devanshu

I get a traceback call as folowing

Traceback (most recent call last):
  File "dscr.cgi", line 90, in <module>
    client_program()
  File "dscr.cgi", line 79, in client_program
    sum = serverId+";"+name+";"+host+";"+port+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr
TypeError: must be str, not int

I realise that its nothing but a silly mistake but I'm unable to find out what. Thanks for the help in advance.

Body:
Replace following line

port = 8888  # socket server port number

with

port = '8888'  # socket server port number

Or you can type cast before forming connection string as string concat operations should be done only with another string i.e. replace

sum = serverId+";"+name+";"+host+";"+port+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr

with

sum = serverId+";"+name+";"+host+";"+str(port)+";"+proto+";"+user+";"+password+";"+key+";"+company+";"+officeAddr+";"+state+";"+country+";"+ladmin+";"+phone+";"+mobile+";"+email+";"+designation+";"+reportingMgr


问:
React Native: Animation not working properly on android
I have been trying to fix issue for the past 2 days, it works fine on iOS

```<code>constructor(){
  super();

  this.animation = new Animated.Value(0)

  this.state = {
    expanded: false,
  };
}
toggle(){
  let initialValue = this.state.expanded? 1 : 0 ,
     finalValue = this.state.expanded? 0 : 1

  this.setState({
     expanded: !this.state.expanded,
  });

  this.animation.setValue(initialValue)
  Animated.timing(
    this.animation,
    {
      toValue: finalValue,
    }
  ).start();
}

render(){
  return(
    <Animated.View style={{{flex: 1, marginTop: 28, paddingLeft: 25, transform: [{ scale: this.animation }, {perspective: 1000 }]}}}>
     ....
    </Animated.View>

  );
}
</code>```

This component is child , used in parent like this: <FeedBack ref={ref => this.feedback = ref}/> without any conditions to check to show or not (because animation scale is set to Zero in the constructor, so no need)

the toggle() method is being called from parent when a button pressed.

Now this works fine on iOS , when component loads, the view is not there until a button is pressed (then scaled). but on android when the component loads, the view already there. When I press the button, the animated view disappears and re-appears (with animation scaling) and subsequent toggles work fine. The problem in android is that even though initialValue of the scale is Zero, the view is still there when it first loads.

答:
This has been an issue with react-native on the android side for a while now (sigh). It seems that setting the value to 0 strips it of its characteristics, basically deeming it as null and then reverting to using its actual value once it had animated to > 0

A work around is to set animation like so
    this.animation = new Animated.Value(0.01);

You can follow the issue here

Body:
I have been trying to fix issue for the past 2 days, it works fine on iOS

constructor(){
  super();

  this.animation = new Animated.Value(0)

  this.state = {
    expanded: false,
  };
}
toggle(){
  let initialValue = this.state.expanded? 1 : 0 ,
     finalValue = this.state.expanded? 0 : 1

  this.setState({
     expanded: !this.state.expanded,
  });

  this.animation.setValue(initialValue)
  Animated.timing(
    this.animation,
    {
      toValue: finalValue,
    }
  ).start();
}

render(){
  return(
    <Animated.View style={{{flex: 1, marginTop: 28, paddingLeft: 25, transform: [{ scale: this.animation }, {perspective: 1000 }]}}}>
     ....
    </Animated.View>

  );
}

This component is child , used in parent like this: <FeedBack ref={ref => this.feedback = ref}/> without any conditions to check to show or not (because animation scale is set to Zero in the constructor, so no need)

the toggle() method is being called from parent when a button pressed.

Now this works fine on iOS , when component loads, the view is not there until a button is pressed (then scaled). but on android when the component loads, the view already there. When I press the button, the animated view disappears and re-appears (with animation scaling) and subsequent toggles work fine. The problem in android is that even though initialValue of the scale is Zero, the view is still there when it first loads.


问:
Adding additional input fields dynamically (similar to SO careers)
Similar to the "add more experience" functionality in http://careers.stackoverflow.com/cv/edit, I want to provide a "Add another location" link which should display an additional row of a set of 4 dropdowns (country, state, city, region).  I'm actually using the CascadingDropDown jQuery Plugin for ASP.NET MVC (http://weblogs.asp.net/rajbk/archive/2010/05/20/cascadingdropdown-jquery-plugin-for-asp-net-mvc.aspx) for my location dropdown functionality, but I need to give the user the ability to add multiple locations.  What would be the easiest way to handle this in ASP.NET MVC and jQuery?</p>

答: I ended up using this: http://charlie.griefer.com/blog/index.cfm/2009/9/17/jQuery--Dynamically-Adding-Form-Elements</p>


问:
(sanic)[ERROR]: Connection lost before response written
I am using Sanic (Python) as a web server and facing an issue with some of the requests. It's returning an error when we get quite a few simultaneous requests. The error description is as below:

```<code>web_1  | 2017-10-03 09:24:49 - (network)[INFO][172.17.0.1:55372]: GET http://localhost:8000/api/order_items/123456  200 38
web_1  | 2017-10-03 09:24:50 - (network)[INFO][172.17.0.1:55382]: GET http://localhost:8000/api/order_items/123456 200 38
web_1  | 2017-10-03 09:24:55 - (network)[INFO][172.17.0.1:55392]: GET http://localhost:8000/api/order_items/123456 200 38
web_1  | 2017-10-03 09:24:56 - (sanic)[ERROR]: Connection lost before response 2343 written @ ('172.17.0.1', 55402)
web_1  | 2017-10-03 09:24:56 - (network)[INFO][172.17.0.1:55412]: GET http://localhost:8000/api/order_items/123456 200 38
web_1  | 2017-10-03 09:24:57 - (sanic)[ERROR]: Connection lost before response 2343 written @ ('172.17.0.1', 55424)
web_1  | 2017-10-03 09:24:57 - (network)[INFO][172.17.0.1:55430]: GET http://localhost:8000/api/order_items/123456 200 38
</code>```

This is where Sanic is reporting this error:
https://github.com/channelcat/sanic/blob/master/sanic/server.py#L333

So as per my understanding, HTTP connection is closing before Sanic can write to it which is fine but I should be able to override the behaviour and hide the error if I wish to which is something I need help with

答:
The issue has been permanently fixed in Sanic but it hasn't been released yet. So here's a temporary solution until Sanic releases 0.6.1.

```<code>class NoConnectionLostFilter(logging.Filter):
""" while issue not resolved https://github.com/channelcat/sanic/issues/959 """
def filter(record):
    return not record.getMessage().startswith('Connection lost before response written')

logging.getLogger('root').addFilter(NoConnectionLostFilter)
</code>```

Solution Credits: https://github.com/samael500
Github Issue link: https://github.com/channelcat/sanic/issues/959

Body:
I am using Sanic (Python) as a web server and facing an issue with some of the requests. It's returning an error when we get quite a few simultaneous requests. The error description is as below:

web_1  | 2017-10-03 09:24:49 - (network)[INFO][172.17.0.1:55372]: GET http://localhost:8000/api/order_items/123456  200 38
web_1  | 2017-10-03 09:24:50 - (network)[INFO][172.17.0.1:55382]: GET http://localhost:8000/api/order_items/123456 200 38
web_1  | 2017-10-03 09:24:55 - (network)[INFO][172.17.0.1:55392]: GET http://localhost:8000/api/order_items/123456 200 38
web_1  | 2017-10-03 09:24:56 - (sanic)[ERROR]: Connection lost before response 2343 written @ ('172.17.0.1', 55402)
web_1  | 2017-10-03 09:24:56 - (network)[INFO][172.17.0.1:55412]: GET http://localhost:8000/api/order_items/123456 200 38
web_1  | 2017-10-03 09:24:57 - (sanic)[ERROR]: Connection lost before response 2343 written @ ('172.17.0.1', 55424)
web_1  | 2017-10-03 09:24:57 - (network)[INFO][172.17.0.1:55430]: GET http://localhost:8000/api/order_items/123456 200 38

This is where Sanic is reporting this error:
https://github.com/channelcat/sanic/blob/master/sanic/server.py#L333

So as per my understanding, HTTP connection is closing before Sanic can write to it which is fine but I should be able to override the behaviour and hide the error if I wish to which is something I need help with

Body:
The issue has been permanently fixed in Sanic but it hasn't been released yet. So here's a temporary solution until Sanic releases 0.6.1.

class NoConnectionLostFilter(logging.Filter):
""" while issue not resolved https://github.com/channelcat/sanic/issues/959 """
def filter(record):
    return not record.getMessage().startswith('Connection lost before response written')

logging.getLogger('root').addFilter(NoConnectionLostFilter)

Solution Credits: https://github.com/samael500
Github Issue link: https://github.com/channelcat/sanic/issues/959


问:
How can you programmatically add contractions to a sentence?
I've seen many posts about expanding contractions to tokenize them correctly but I'd like to be able to add a contraction while retaining semantic accuracy. Are there any libraries addressing this or solutions available to this problem?

Positive Examples:

"You are going to the restaurant." becomes "You're going to the
restaurant."

"I am a happy boy." becomes "I'm a happy boy."

Negative Examples:

"Is that all you have?" should not become "Is that all you've?"

"Is that who you are?" should not become "Is that who you're?"

"You have a big heart." should not become "You've a big heart."

答:
I don't have an answer to the main question, but from the examples it seems that "have" and "be" only contract when they're used as an auxiliary. That is, they proceed another verb. Maybe something in POS tagging them, then checking if they're followed by a verb?

Edit: Nope, your second positive example disagrees with this.


问:
how to write conditional statement inside ionic html template
I am porting my application from jquery to ionic framework.
In jquery , i am writing javascript code to manually concatenate html tags.
Pasting a portion of the same from jquery code

```<code>  for ( count = start - 1; count < end ; count ++ )
            {
                if (tranList[count].tranType == "R" )
                    tranType = "Redeem" ;
                else
                    tranType = "Earn";

                text += "<tr> <td>"+ tranType +  "</td>" ;
</code>```

In Ionic , i am trying to write the same code using ionic list
Below is my html template

```<code> <ion-list>
    <ion-item *ngFor="let tran of transactions">
     <p> {{tran.pointsEarned}} </p>
    </ion-item>
  </ion-list>
</code>```

Next to pointsEarned , i need to print points are redeemed or earned similar to jquery code . How do i achieve this ?

答:
I'm not sure if we are on the same page, but this is another way for if...else statement:

```<code>  <div *ngIf = "tran.tranType == 'R'; else elsetag">
    Redeem
  </div>
  <ng-template #elsetag>
  <div>
    Earn
  </div>
  <ng-template>
</code>```

Body:
I am porting my application from jquery to ionic framework.
In jquery , i am writing javascript code to manually concatenate html tags.
Pasting a portion of the same from jquery code

  for ( count = start - 1; count < end ; count ++ )
            {
                if (tranList[count].tranType == "R" )
                    tranType = "Redeem" ;
                else
                    tranType = "Earn";

                text += "
 "+ tranType +  "	" ;

In Ionic , i am trying to write the same code using ionic list
Below is my html template

 <ion-list>
    <ion-item *ngFor="let tran of transactions">

 {{tran.pointsEarned}}

    </ion-item>
  </ion-list>

Next to pointsEarned , i need to print points are redeemed or earned similar to jquery code . How do i achieve this ?

Body:
I'm not sure if we are on the same page, but this is another way for if...else statement:

  <div *ngIf = "tran.tranType == 'R'; else elsetag">
    Redeem
  </div>
  <ng-template #elsetag>
  <div>
    Earn
  </div>
  <ng-template>


问:
modify a column in pandas data-frame selecting a sub-string
This is my pandas data-frame. I want to modify values of first column (System) by extracting just a,b,c,d. How can this be done in python</p>

```<code> System       mem
/vol/a/        10
/vol/b/        20
/vol/c/        30
/vol/d/        40
</code>```

答:
By using rsplit you can have as much stuff in front as you'd like.

```<code>df.assign(New=df.System.str.rsplit('/', 2).str[-2])

    System  mem New
0  /vol/a/   10   a
1  /vol/b/   20   b
2  /vol/c/   30   c
3  /vol/d/   40   d
</code>```

Body:
This is my pandas data-frame. I want to modify values of first column (System) by extracting just a,b,c,d. How can this be done in python

 System       mem
/vol/a/        10
/vol/b/        20
/vol/c/        30
/vol/d/        40

Body:
By using rsplit you can have as much stuff in front as you'd like.

df.assign(New=df.System.str.rsplit('/', 2).str[-2])

    System  mem New
0  /vol/a/   10   a
1  /vol/b/   20   b
2  /vol/c/   30   c
3  /vol/d/   40   d


问:
Regex for my custom URL
Good Day,

I cant create the regex exact for my url:

any-any.test.test2.com or ALL CAPS

http://any-any.test.test2.com or ALL CAPS

https://any-any.test.test2.com or ALL CAPS

can someone please help me how can I make a regex that can accept this url's.

Useful Link:
https://regex101.com/

Note: any means user can input any characters and after first any should have "-" , then all must contain :

.test.test2.com  or

.TEST.TEST2.COM

at the end.

答:
Try this one:

(http(s)?://)?.+-.+.test.test2.com

There is a useful open source tool:
https://sourceforge.net/projects/regulator/

```<code>Match match = Regex.Match("https://any-any.test.test2.com", "(http(s)?://)?.+-.+\.test.test2.com", RegexOptions.IgnoreCase);

if (match.Success) {
    Console.WriteLine("OK");
}
</code>```

Title: Regex for my custom URL

Body:
Try this one:

(http(s)?://)?.+-.+.test.test2.com

There is a useful open source tool:
https://sourceforge.net/projects/regulator/

Match match = Regex.Match("https://any-any.test.test2.com", "(http(s)?://)?.+-.+\.test.test2.com", RegexOptions.IgnoreCase);

if (match.Success) {
    Console.WriteLine("OK");
}