问:
Java Split file lines into two lists
I'm currently writing an app that takes the data from the file. I need to sort the data in different ways. The problem is that the file is in format:

```<code>NAME1(tab)A(tab)B
NAME2(tab)C(tab)D
</code>```

I want to split data into two ArrayLists, one will gather NAME1, NAME2 etc, so the first element of line, the second list will gather the rest.

Here's my code:

```<code>Scanner scan = new Scanner(new File(fname));

while(scan.hasNext()){

}
scan.close();

System.out.println("Lang: ");
for(String item : lang)
    System.out.print(item + " ");

} catch (FileNotFoundException e) {
    e.printStackTrace();
}
</code>```

I tried to play with scanner methods, but there are no results and I have no idea what to do.

答:
Here is the recipe </p>

```<code>fileInputStreamObj = StreamTests.class.getResourceAsStream(your_file_path);
bufferedReaderObj = new BufferedReader(new InputStreamReader(fileInputStreamObj));

bufferedReaderObj
  .lines()
  .map(s -> {
    String[] splitStrings = s.split("\t", -1);
    return Arrays.asList(splitStrings);
  }).forEach(System.out::println);
</code>```

<p>Some thing that I tested . </p>

Title: Java Split file lines into two lists

Body:
I'm currently writing an app that takes the data from the file. I need to sort the data in different ways. The problem is that the file is in format:

NAME1(tab)A(tab)B
NAME2(tab)C(tab)D

I want to split data into two ArrayLists, one will gather NAME1, NAME2 etc, so the first element of line, the second list will gather the rest.

Here's my code:

Scanner scan = new Scanner(new File(fname));

while(scan.hasNext()){

}
scan.close();

System.out.println("Lang: ");
for(String item : lang)
    System.out.print(item + " ");

} catch (FileNotFoundException e) {
    e.printStackTrace();
}

I tried to play with scanner methods, but there are no results and I have no idea what to do.

Body:
Here is the recipe

fileInputStreamObj = StreamTests.class.getResourceAsStream(your_file_path);
bufferedReaderObj = new BufferedReader(new InputStreamReader(fileInputStreamObj));

bufferedReaderObj
  .lines()
  .map(s -> {
    String[] splitStrings = s.split("\t", -1);
    return Arrays.asList(splitStrings);
  }).forEach(System.out::println);

Some thing that I tested .


来源: stackexchange

问:
Need to Run a vbscipt via Batch file in Silent mode
I know this is a duplicate. But I am stuck and not able to understand those properly.

The first vbs file:

```<code>Msgbox "Success"
</code>```

The Bat File:

```<code>@echo off
Start "C:\Success.vbs" %*
</code>```

I need to run the bat file in silent mode. Could anyone explain me how i can do that.

答:
Change you batch file to this

If you want to use 32-bit,

```<code>@echo off
@%WINDIR%\SysWOW64\cmd.exe /c call cscript "C:\Success.vbs"
</code>```

Else,

```<code>@echo off
cscript "C:\Success.vbs"
</code>```

This will hide additional cmd window, but it won't hide the bat file cmd window.

ContentLicense: CC BY-SA 3.0

Body:
I know this is a duplicate. But I am stuck and not able to understand those properly.

The first vbs file:

Msgbox "Success"

The Bat File:

@echo off
Start "C:\Success.vbs" %*

I need to run the bat file in silent mode. Could anyone explain me how i can do that.

Body:
Change you batch file to this

If you want to use 32-bit,

@echo off
@%WINDIR%\SysWOW64\cmd.exe /c call cscript "C:\Success.vbs"

Else,

@echo off
cscript "C:\Success.vbs"

This will hide additional cmd window, but it won't hide the bat file cmd window.


问:
Several actions with same name in react-redux
I have actions from different packages which have the same name like this:

```<code>import { bindActionCreators } from 'redux';
import { setActiveLanguage } from 'react-localize-redux';
import * as actionCreators from '../actions/actionCreators';
import * as toggleActions from '../actions/toggleActions';
import {actions as rrfActions} from 'react-redux-form';

function mapDispatchToProps(dispatch) {
    return bindActionCreators(
      {
        ...actionCreators,
        ...toggleActions,
        setActiveLanguage,
        ...rrfActions
      },
      dispatch);
  }

export default mapDispatchToProps
</code>```

As both toggleActions and rrfActions have a toggle action, nesting the rrfActions could do the trick (?) to call the action, but I can't prevent the reducers from listening to the same TOGGLE action type. Is there a workaround other than not having a general mapDispatchToProps for all connected components, rather very specific ones

Cheers!

答:
Same action types are being served by same reducer listeners by design of the redux. If you want different listeners to be responsible for your actions, that actions must have different types. Why don't you want to use prefixes/suffixes?

```<code>MY_SIMPLE_ACTION
MY_SIMPLE_ACTION_AREA1
MY_SIMPLE_ACTION_AREA2
</code>```

In action dispatcher you may pass an additional argument specifying the area:

```<code>export function onDoSomething(param1, param2, referer) {
  return dispatch({
    type: MY_SIMPLE_ACTION + (referer ? `_${referer}` : ''),
    payload: { param1, param2 }
  })
}
</code>```

Body:
I have actions from different packages which have the same name like this:

import { bindActionCreators } from 'redux';
import { setActiveLanguage } from 'react-localize-redux';
import * as actionCreators from '../actions/actionCreators';
import * as toggleActions from '../actions/toggleActions';
import {actions as rrfActions} from 'react-redux-form';

function mapDispatchToProps(dispatch) {
    return bindActionCreators(
      {
        ...actionCreators,
        ...toggleActions,
        setActiveLanguage,
        ...rrfActions
      },
      dispatch);
  }

export default mapDispatchToProps

As both toggleActions and rrfActions have a toggle action, nesting the rrfActions could do the trick (?) to call the action, but I can't prevent the reducers from listening to the same TOGGLE action type. Is there a workaround other than not having a general mapDispatchToProps for all connected components, rather very specific ones

Cheers!

Body:
Same action types are being served by same reducer listeners by design of the redux. If you want different listeners to be responsible for your actions, that actions must have different types. Why don't you want to use prefixes/suffixes?

MY_SIMPLE_ACTION
MY_SIMPLE_ACTION_AREA1
MY_SIMPLE_ACTION_AREA2

In action dispatcher you may pass an additional argument specifying the area:

export function onDoSomething(param1, param2, referer) {
  return dispatch({
    type: MY_SIMPLE_ACTION + (referer ? `_${referer}` : ''),
    payload: { param1, param2 }
  })
}


问:
Oracle Apex.Stop a page unload(when clicked on a navigable link) if there are any unsaved changes
I'm currently using oracle apex. I created a wizard progress list for my page with the labels in the list as navigable links. But when the user clicks on these links to navigate to another page i need to ask the user if he's sure as there are unsaved changes, probably using apex.message.confirm().
I made it navigable by using href="my_link" in the list entry label while creating list in shared components. I know if i add onClick="my_function();"i can direct add functionality to that link.But where to add this javascript function at the application level?
How do i do that? any ideas?

Note : I cant use warn on unsaved changes option at the page level. Because iam submitting the values in my page to the db through dynamic action(pl/sql code). So even after clicking on save and inserting data into DB, when i try to navigate to other page it will show warning on unsaved changes. I cant use submit page on click of save button as it is refreshing the whole page and it is not desired.

答:
Page properties -> Navigation -> Warn on Unsaved Changes set to Yes. After that it will work automatically. Works in APEX 5.

To cancel checks of unsaved changes, use JavaScript function apex.page.cancelWarnOnUnsavedChanges();. For example, if you save data with the DynamicAction, add additional true action with type Execute JavaScript Code and call it there.


问:
SQL RowVersion incrementing before data has been augmented in Trigger
I've just started using T-SQL's RowVersion and I've noticed something very interesting. I created a Proc to update a table with a RowVersion column and at the end of this proc I print out a humanreadable date representation of RowVersion. I also added a Trigger which updates data in the table and prints out RowVersion before and after. It's given some interesting results...

From Insert Proc after data is inserted = 1900-01-01 05:43:13.373

From start of Trigger before we change any data =  1900-01-01 05:43:13.377

From end of trigger after data has changed = 1900-01-01 05:43:13.377

The start of the trigger value for the RowVersion column has changed from the end of the proc value for the RowVersion Column despite the fact we have not augmented any data yet. It's also the same as the end of the Trigger. Why is this? Is it something to do with the sequencing of SQL statement execution? Any help understanding this would be appreciated. The proc and trigger are listed below:

```<code>CREATE PROCEDURE [dbo].[TestRowVersionProc]
AS
    INSERT INTO TestRowversion (ID, Number)
    VALUES ('6', '6')

    DECLARE @rv DATETIME
    SELECT @rv = GenerationNumber FROM TestRowversion WHERE ID = '6'
    SELECT CONVERT(VARCHAR(50), @rv , 121)
GO

CREATE TRIGGER [dbo].[TestRowversion_AfterInsertUpdate] ON [dbo].[TestRowversion] AFTER INSERT,UPDATE
AS
    if @@rowcount = 0 return
    set nocount on

    DECLARE @rv DATETIME
    SELECT @rv = GenerationNumber FROM TestRowversion WHERE ID = '6'
    SELECT CONVERT(VARCHAR(50), @rv , 121)

    DECLARE @Id NVARCHAR(1)
    SELECT @Id = ID FROM inserted

    UPDATE TestRowversion
    SET Number = 'FromTrigger'
    WHERE ID = '6'

    SELECT @rv = GenerationNumber FROM TestRowversion WHERE ID = '6'
    SELECT CONVERT(VARCHAR(50), @rv , 121)

GO
</code>```

答:
The order of execution is, using some actual timestamp values:

```<code>| Event time                | Event time                  | RowVersion |
|---------------------------|-----------------------------|------------|
| Start of trigger          | 2017-12-05 10:50:26.8506034 | 28,804,001 |
|  End  of trigger          | 2017-12-05 10:50:26.8506034 | 28,804,002 |
| After insert              | 2017-12-05 10:50:26.8662212 | 28,804,002 |
</code>```

You can turn the rowversion into a human readable form with:

```<code>SELECT CAST(GenerationNumber AS bigint) FROM TestRowVersion --timestamp is an 8-byte (64-bit) integer
</code>```

Your mental model of the ordering was wrong.

Table:

```<code>CREATE TABLE TestRowVersion (
    ID varchar(50),
    Number varchar(50),
    GenerationNumber timestamp
)
</code>```

Inserting procedure:

```<code>ALTER PROCEDURE [dbo].[TestRowVersionProc]
AS
    INSERT INTO TestRowversion (ID, Number)
    VALUES ('6', '6')

    DECLARE @rv bigint
    SELECT @rv = CAST(GenerationNumber AS bigint) FROM TestRowversion WHERE ID = '6'
    SELECT CAST(SYSDATETIME() AS varchar(50))+' After insert    '+CAST(@rv AS varchar(50))
GO
</code>```

Trigger:

```<code>CREATE TRIGGER [dbo].[TestRowversion_AfterInsertUpdate] ON [dbo].[TestRowversion] AFTER INSERT,UPDATE
AS
    if @@rowcount = 0 return
    set nocount on

    DECLARE @rv bigint
    SELECT @rv = CAST(GenerationNumber AS bigint) FROM TestRowversion WHERE ID = '6'
    SELECT CAST(SYSDATETIME() AS varchar(50))+' Start of trigger    '+CAST(@rv AS varchar(50))

    DECLARE @Id NVARCHAR(1)
    SELECT @Id = ID FROM inserted

    UPDATE TestRowversion
    SET Number = 'FromTrigger'
    WHERE ID = '6'

    SELECT @rv = CAST(GenerationNumber AS bigint) FROM TestRowversion WHERE ID = '6'
    SELECT CAST(SYSDATETIME() AS varchar(50))+' End of trigger  '+CAST(@rv AS varchar(50))
</code>```

Body:
I've just started using T-SQL's RowVersion and I've noticed something very interesting. I created a Proc to update a table with a RowVersion column and at the end of this proc I print out a humanreadable date representation of RowVersion. I also added a Trigger which updates data in the table and prints out RowVersion before and after. It's given some interesting results...

From Insert Proc after data is inserted = 1900-01-01 05:43:13.373

From start of Trigger before we change any data =  1900-01-01 05:43:13.377

From end of trigger after data has changed = 1900-01-01 05:43:13.377

The start of the trigger value for the RowVersion column has changed from the end of the proc value for the RowVersion Column despite the fact we have not augmented any data yet. It's also the same as the end of the Trigger. Why is this? Is it something to do with the sequencing of SQL statement execution? Any help understanding this would be appreciated. The proc and trigger are listed below:

CREATE PROCEDURE [dbo].[TestRowVersionProc]
AS
    INSERT INTO TestRowversion (ID, Number)
    VALUES ('6', '6')

    DECLARE @rv DATETIME
    SELECT @rv = GenerationNumber FROM TestRowversion WHERE ID = '6'
    SELECT CONVERT(VARCHAR(50), @rv , 121)
GO

CREATE TRIGGER [dbo].[TestRowversion_AfterInsertUpdate] ON [dbo].[TestRowversion] AFTER INSERT,UPDATE
AS
    if @@rowcount = 0 return
    set nocount on

    DECLARE @rv DATETIME
    SELECT @rv = GenerationNumber FROM TestRowversion WHERE ID = '6'
    SELECT CONVERT(VARCHAR(50), @rv , 121)

    DECLARE @Id NVARCHAR(1)
    SELECT @Id = ID FROM inserted

    UPDATE TestRowversion
    SET Number = 'FromTrigger'
    WHERE ID = '6'

    SELECT @rv = GenerationNumber FROM TestRowversion WHERE ID = '6'
    SELECT CONVERT(VARCHAR(50), @rv , 121)

GO

Body:
The order of execution is, using some actual timestamp values:

| Event time                | Event time                  | RowVersion |
|---------------------------|-----------------------------|------------|
| Start of trigger          | 2017-12-05 10:50:26.8506034 | 28,804,001 |
|  End  of trigger          | 2017-12-05 10:50:26.8506034 | 28,804,002 |
| After insert              | 2017-12-05 10:50:26.8662212 | 28,804,002 |

You can turn the rowversion into a human readable form with:

SELECT CAST(GenerationNumber AS bigint) FROM TestRowVersion --timestamp is an 8-byte (64-bit) integer

Your mental model of the ordering was wrong.

Table:

CREATE TABLE TestRowVersion (
    ID varchar(50),
    Number varchar(50),
    GenerationNumber timestamp
)

Inserting procedure:

ALTER PROCEDURE [dbo].[TestRowVersionProc]
AS
    INSERT INTO TestRowversion (ID, Number)
    VALUES ('6', '6')

    DECLARE @rv bigint
    SELECT @rv = CAST(GenerationNumber AS bigint) FROM TestRowversion WHERE ID = '6'
    SELECT CAST(SYSDATETIME() AS varchar(50))+' After insert    '+CAST(@rv AS varchar(50))
GO

Trigger:

CREATE TRIGGER [dbo].[TestRowversion_AfterInsertUpdate] ON [dbo].[TestRowversion] AFTER INSERT,UPDATE
AS
    if @@rowcount = 0 return
    set nocount on

    DECLARE @rv bigint
    SELECT @rv = CAST(GenerationNumber AS bigint) FROM TestRowversion WHERE ID = '6'
    SELECT CAST(SYSDATETIME() AS varchar(50))+' Start of trigger    '+CAST(@rv AS varchar(50))

    DECLARE @Id NVARCHAR(1)
    SELECT @Id = ID FROM inserted

    UPDATE TestRowversion
    SET Number = 'FromTrigger'
    WHERE ID = '6'

    SELECT @rv = CAST(GenerationNumber AS bigint) FROM TestRowversion WHERE ID = '6'
    SELECT CAST(SYSDATETIME() AS varchar(50))+' End of trigger  '+CAST(@rv AS varchar(50))


问:
git log, show files for specific username and branch
I'd like to combine git log and git show so that I can list all changes files for a given user, for a given branch. My aim is to be able to see what files I have personally changes, over the life of a branch (as opposed to files changes in my branch from a merge)

What is the best way to achieve this?

答:
This is a git alias that I use; If I understand the question, I think this does what you want.

```<code>if $(git rev-parse --verify --quiet $1 >/dev/null); then
    COMMIT=$1;
    shift;
else
    COMMIT=HEAD;
fi;
git log "$@" $(git merge-base origin/master $COMMIT)..$COMMIT;
</code>```

Usage: git <alias_name> [commit] [extra_args], so I would do git lo --author="John Doe".  You can add extra git log arguments like -p and --stat to find the information you are looking for.

Body:
This is a git alias that I use; If I understand the question, I think this does what you want.

if $(git rev-parse --verify --quiet $1 >/dev/null); then
    COMMIT=$1;
    shift;
else
    COMMIT=HEAD;
fi;
git log "$@" $(git merge-base origin/master $COMMIT)..$COMMIT;

Usage: git <alias_name> [commit] [extra_args], so I would do git lo --author="John Doe".  You can add extra git log arguments like -p and --stat to find the information you are looking for.


问:
Populate the array in php using mysql dynamically
I have the database and i want to create a matrix or probably 2d array in PHP where the first column comes from first query and then i loop again another query. I am getting it but when it comes to the matrix i want first column populate from the first column and the rest of the column in that row should populate depending on the data for that particular query. you might better understand after looking at the code

```<code> <!DOCTYPE html>

<html>

<?php
require ('connect.php');
$pro_name = $_POST['project'];
$sheet_type = $_POST['sheet_set'];
echo $pro_name ."-";
echo $sheet_type . "<br/>";

?>

<?php
$doc_num_data = array();
$qry_doc_num = "SELECT DISTINCT document_number FROM `$pro_name`.Instruments";
$result_doc_num = mysqli_query($connection, $qry_doc_num) or die(mysqli_error($connection));

while($doc_num = mysqli_fetch_row($result_doc_num)){

    if($doc_num[0] != ''){
        $qry_ins = "SELECT CONCAT(tag_letters,'-',tag_numbers) FROM `$pro_name`.Instruments WHERE document_number = '$doc_num[0]'";
        $result_qry_ins = mysqli_query($connection, $qry_ins) or die(mysqli_error($connection));
     //   array_push($doc_num_data, $doc_num);
       // $doc_num_data = array();
        while($ins_doc = mysqli_fetch_row($result_qry_ins)){
            $instruments_tag = $ins_doc[0];
            array_push($doc_num_data, $doc_num);
        }
    }
}
echo "```";
print_r($doc_num_data);
echo "```";
?>

</html>
</code>```

I want something like this

```<code>[doc1] [ins1] [ins2] []
[doc2] [ins1] []     []
[doc3] [ins1] [ins2] [ins3]
[doc4] [ins1] [ins2] []
</code>```

thats the result what i get basically each element is saving in different array

```<code>Array (
 [0] => Array
     (
         [0] => test1
     )

 [1] => Array
     (
         [0] => PIT-100
     )

 [2] => Array
     (
         [0] => test1
     )

 [3] => Array
     (
         [0] => PIT-330
     )

 [4] => Array
     (
         [0] => PIT-330
     )

 [5] => Array
     (
         [0] => PIT-330
     )

 [6] => Array
     (
         [0] => test2
     )

 [7] => Array
     (
         [0] => PIT-300
     )

 [8] => Array
     (
         [0] => PIT-300
     )

 [9] => Array
     (
         [0] => PIT-300
     )

 [10] => Array
     (
         [0] => PIT-300
     )

 [11] => Array
     (
         [0] => PIT-300
     )
</code>```

答:
The problem you're having is with array_push().  All that is going to do (as you can see) is stack the values into a LIST, not a hash / multi-dimensional array.

What you want is a  list of things that are referenced by that doc ID, right?

Try this:

```<code>if($instruments_tag != null) array_push($doc_num_data[$doc_num], $instruments_tag);
</code>```

I think that is what you're looking for, or close to it at any rate, and it won't add that empty value at the end.  If you want that, remove the if.

Body:
I have the database and i want to create a matrix or probably 2d array in PHP where the first column comes from first query and then i loop again another query. I am getting it but when it comes to the matrix i want first column populate from the first column and the rest of the column in that row should populate depending on the data for that particular query. you might better understand after looking at the code

 <!DOCTYPE html>

<?php
require ('connect.php');
$pro_name = $_POST['project'];
$sheet_type = $_POST['sheet_set'];
echo $pro_name ."-";
echo $sheet_type . "
";

?>

<?php
$doc_num_data = array();
$qry_doc_num = "SELECT DISTINCT document_number FROM `$pro_name`.Instruments";
$result_doc_num = mysqli_query($connection, $qry_doc_num) or die(mysqli_error($connection));

while($doc_num = mysqli_fetch_row($result_doc_num)){

    if($doc_num[0] != ''){
        $qry_ins = "SELECT CONCAT(tag_letters,'-',tag_numbers) FROM `$pro_name`.Instruments WHERE document_number = '$doc_num[0]'";
        $result_qry_ins = mysqli_query($connection, $qry_ins) or die(mysqli_error($connection));
     //   array_push($doc_num_data, $doc_num);
       // $doc_num_data = array();
        while($ins_doc = mysqli_fetch_row($result_qry_ins)){
            $instruments_tag = $ins_doc[0];
            array_push($doc_num_data, $doc_num);
        }
    }
}
echo "
";
print_r($doc_num_data);
echo "
";
?>

I want something like this

[doc1] [ins1] [ins2] []
[doc2] [ins1] []     []
[doc3] [ins1] [ins2] [ins3]
[doc4] [ins1] [ins2] []

thats the result what i get basically each element is saving in different array

Array (
 [0] => Array
     (
         [0] => test1
     )

 [1] => Array
     (
         [0] => PIT-100
     )

 [2] => Array
     (
         [0] => test1
     )

 [3] => Array
     (
         [0] => PIT-330
     )

 [4] => Array
     (
         [0] => PIT-330
     )

 [5] => Array
     (
         [0] => PIT-330
     )

 [6] => Array
     (
         [0] => test2
     )

 [7] => Array
     (
         [0] => PIT-300
     )

 [8] => Array
     (
         [0] => PIT-300
     )

 [9] => Array
     (
         [0] => PIT-300
     )

 [10] => Array
     (
         [0] => PIT-300
     )

 [11] => Array
     (
         [0] => PIT-300
     )

Body:
The problem you're having is with array_push().  All that is going to do (as you can see) is stack the values into a LIST, not a hash / multi-dimensional array.

What you want is a  list of things that are referenced by that doc ID, right?

Try this:

if($instruments_tag != null) array_push($doc_num_data[$doc_num], $instruments_tag);

I think that is what you're looking for, or close to it at any rate, and it won't add that empty value at the end.  If you want that, remove the if.


问:
Getting the value of an input field, which gets dynamically placed (not via js) onclick
I spent a few hours searching and trying stuff out, but I can't get my ajax form submit working. (I'm also really not a front-end person, so sorry if I mess up my explanation)

I have a site that dynamically inserts HTML content (through JSP, not javascript). I have a simple form with a submit button inside that inserted html. This is the piece of html I have:

```<code><tr>
    <td>Change stock by:</td>
    <td>
        <div id="quantityinput" class="field has-addons">
            <div class="control"> <input class="input" type="text" id="mutation" placeholder="0">

            </div>
            <a href="#" class="button is-success" id="quantityConfirm">update</a>
        </div>
    </td>
</tr>
</code>```

I managed to link the button to the right ajax-function, like this:
(.editor__product is the direct parent of the form, but there is a bunch of non-form information there)

```<code>$(".editor__product").on("click", "#quantityConfirm", function ($) {

    $.ajax({
            method: "POST",
            url: '/bullet-journal/mutateitem',
            data: {
                product_id: product_id,
                product_mutate: product_mutate
            }
        })
        .done(function (html) {

            $('#main').load(document.URL + ' #main');
            $(".editor__product").load('${pageContext.request.contextPath}/refreshinfo');
        });

});
</code>```

But the problem is, I have no idea how to get the value from my "#mutation" input field. I tried various ways to append it to my document and get it, but it either results in a new text field somewhere on the bottom of my page, or simply in a NULL value error. I have more ajax forms in the website which work fine, but they use elements that are hardcoded.

Every solution I could find was specifically for javascript-generated content, while my input doesn't get generated by javascript.

How would I go about extracting the value from my mutation input? Thanks a lot for any advice, the browser console isn't very helpful.

答:
Get the value using js :

```<code>var mutation = document.getElementById('mutation').value;
</code>```

or with jquery

```<code>var mutation = $('#mutation').val();
</code>```

And pass mutation in your data or do what you need to with it

Body:
I spent a few hours searching and trying stuff out, but I can't get my ajax form submit working. (I'm also really not a front-end person, so sorry if I mess up my explanation)

I have a site that dynamically inserts HTML content (through JSP, not javascript). I have a simple form with a submit button inside that inserted html. This is the piece of html I have:

    Change stock by:

 <input class="input" type="text" id="mutation" placeholder="0">

            update

I managed to link the button to the right ajax-function, like this:
(.editor__product is the direct parent of the form, but there is a bunch of non-form information there)

$(".editor__product").on("click", "#quantityConfirm", function ($) {

    $.ajax({
            method: "POST",
            url: '/bullet-journal/mutateitem',
            data: {
                product_id: product_id,
                product_mutate: product_mutate
            }
        })
        .done(function (html) {

            $('#main').load(document.URL + ' #main');
            $(".editor__product").load('${pageContext.request.contextPath}/refreshinfo');
        });

});

But the problem is, I have no idea how to get the value from my "#mutation" input field. I tried various ways to append it to my document and get it, but it either results in a new text field somewhere on the bottom of my page, or simply in a NULL value error. I have more ajax forms in the website which work fine, but they use elements that are hardcoded.

Every solution I could find was specifically for javascript-generated content, while my input doesn't get generated by javascript.

How would I go about extracting the value from my mutation input? Thanks a lot for any advice, the browser console isn't very helpful.

Body:
Get the value using js :

var mutation = document.getElementById('mutation').value;

or with jquery

var mutation = $('#mutation').val();

And pass mutation in your data or do what you need to with it


问:
Sharing a Vagrant box
I have a new developer coming to work with me soon, and I'd like to make it as simple as possible for them to get a development environment set up.

I'm currently using a Vagrant (Laravel Homestead) box with about 15 domains set up, each with different configurations (different PHP versions etc), and I'd like to just share the existing box with them if possible.

Is it as simple setting up a repository with the VagrantFile, getting them to clone it and provision the box, or are there more steps involved?

Also, I've had to edit the MySQL configuration on the box, is there any way I can include these updates in what I share with them, or will they just need to reconfigure their own version manually?

Any advice appreciated.

Thanks

答:
The easiest way to share the Homestead environment is to use the after.sh file to to perform any customization you may need beyond what Homestead gives you.

You can also copy your Homestead.yaml file to Homestead.yaml.example for the new coworker to easily copy and paste the sites & any other configuration changes.

Title: Sharing a Vagrant box


问:
Angular 4 routing, navigate..multiple redirectTo in child does not support
I'm having a problem while routing my app. I tried all possible way that I know but nothing worked for me. It navigates to auth but when children routes added doesn't load anything and yes in auth.component two links are given but none of them is working..

app-routing.module.ts

```<code>import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { AuthComponent} from './auth/auth.component';
import {LoginComponent} from './auth/login/login.component';
import { RegisterComponent} from './auth/register/register.component';
import { AuthGuard } from './authguard';

const routes: Routes = [
  { path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule' },
  { path: 'auth' , component: AuthComponent,
    children: [ {
      path: '',
      component: LoginComponent},
    {
      path: 'login',
      component: LoginComponent },
    {
      path: 'register',
      component: RegisterComponent},
],
},
  { path: '', redirectTo: 'pages', pathMatch: 'full' },
  { path: '**', redirectTo: 'pages' },
];

const config: ExtraOptions = {
  useHash: true,
};

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule],
})
export class AppRoutingModule {
}
</code>```

auth-routing.module.ts

```<code>import { NgModule } from '@angular/core';
import { ExtraOptions, RouterModule, Routes } from '@angular/router';

import { AuthComponent } from './auth.component';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';

const routes: Routes = [{
  path: '',
  component: AuthComponent,
    children: [ {
    path: '',
    component: LoginComponent,
  },
  {
    path: 'login',
    component: LoginComponent,
  },
  {
    path: 'register',
    component: RegisterComponent,
},
],
}];

const config: ExtraOptions = {
  useHash: true,
};
@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports : [RouterModule],
})
export class AuthRoutingModule { }
</code>```

auth.component.html

```<code><h1>Angular Router</h1>
<nav>
  <a routerLink="/login" routerLinkActive="active">Crisis Center</a>
  <a routerLink="/register" routerLinkActive="active">Heroes</a>
</nav>
<router-outlet></router-outlet>
</code>```

答:
For child modules routing, you need to use

```<code>[RouterModule.forChild(routes)],
</code>```

Also,

try importing AuthRoutingModule in app module since its not lazy loaded module. The routes from AuthRoutingModule are not getting loaded since its a separate module

Body:
I'm having a problem while routing my app. I tried all possible way that I know but nothing worked for me. It navigates to auth but when children routes added doesn't load anything and yes in auth.component two links are given but none of them is working..

app-routing.module.ts

import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { AuthComponent} from './auth/auth.component';
import {LoginComponent} from './auth/login/login.component';
import { RegisterComponent} from './auth/register/register.component';
import { AuthGuard } from './authguard';

const routes: Routes = [
  { path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule' },
  { path: 'auth' , component: AuthComponent,
    children: [ {
      path: '',
      component: LoginComponent},
    {
      path: 'login',
      component: LoginComponent },
    {
      path: 'register',
      component: RegisterComponent},
],
},
  { path: '', redirectTo: 'pages', pathMatch: 'full' },
  { path: '**', redirectTo: 'pages' },
];

const config: ExtraOptions = {
  useHash: true,
};

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule],
})
export class AppRoutingModule {
}

auth-routing.module.ts

import { NgModule } from '@angular/core';
import { ExtraOptions, RouterModule, Routes } from '@angular/router';

import { AuthComponent } from './auth.component';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';

const routes: Routes = [{
  path: '',
  component: AuthComponent,
    children: [ {
    path: '',
    component: LoginComponent,
  },
  {
    path: 'login',
    component: LoginComponent,
  },
  {
    path: 'register',
    component: RegisterComponent,
},
],
}];

const config: ExtraOptions = {
  useHash: true,
};
@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports : [RouterModule],
})
export class AuthRoutingModule { }

auth.component.html

Angular Router

  Crisis Center
  Heroes

<router-outlet></router-outlet>

Body:
For child modules routing, you need to use

[RouterModule.forChild(routes)],

Also,

try importing AuthRoutingModule in app module since its not lazy loaded module. The routes from AuthRoutingModule are not getting loaded since its a separate module


问:
Add to linked list via tail pointer without 3 levels of indirection
I am working on a project that requires an implementation of a linked list. Before I started the project, I was reviewing the classic method of creating a linked list.

I realized that in the past, I had been adding elements to a linked list via the head pointer that traverses the list until it reaches the null pointer.

I figured out that there is no need to do it this way, and to implement it in a way that involves a tail pointer, but the only way I could think of is a one that involves a triple pointer or a global pointer. I was wondering, is there an easier approach that uses less levels of indirection?

```<code>#include <stdio.h>
#include <stdlib.h>

typedef struct list {
    int val;
    struct list *next;
} list;

void printlist(list *head);
void freelist(list *head);

void AddList(list ***tail, int val);

int main(void)
{
    /* create first node */
    list *head = (list *)malloc(sizeof(*head));

    /* assign members of first node */
    head->val = 1;
    head->next = NULL;

    /* create tail */
    list **tail = &head->next;

    /* add values to list */
    AddList(&tail, 2);
    AddList(&tail, 3);
    AddList(&tail, 4);
    AddList(&tail, 5);
    AddList(&tail, 6);
    AddList(&tail, 7);
    AddList(&tail, 8);
    AddList(&tail, 9);

    /* print list */
    printlist(head);

    /* free list */
    freelist(head);

    /* exit program */
    system("pause");
    return 0;
}

void AddList(list ***tail, int val)
{
    list *node = (list *)malloc(sizeof(*node));

    node->val = val;
    node->next = NULL;

    **tail = node;

    *tail = &node->next;
}

void printlist(list *head)
{
    while (head) {
        printf("%d\n", head->val);
        head = head->next;
    }
}

void freelist(list *head)
{
    list *tmp = head;
    while (head) {
        head = head->next;
        free(tmp);
        tmp = head;
    }
}
</code>```

答:
The tail pointer should point to the last node, not the next pointer of the last node:

In main:

```<code>/* create tail */
list *tail = head;
</code>```

In AddList:

```<code>void AddList(list **tail, int val)
{
    list *node = malloc(sizeof(*node));

    node->val = val;
    node->next = NULL;

    (*tail)->next = node;
    *tail = node;
}
</code>```

Body:
I am working on a project that requires an implementation of a linked list. Before I started the project, I was reviewing the classic method of creating a linked list.

I realized that in the past, I had been adding elements to a linked list via the head pointer that traverses the list until it reaches the null pointer.

I figured out that there is no need to do it this way, and to implement it in a way that involves a tail pointer, but the only way I could think of is a one that involves a triple pointer or a global pointer. I was wondering, is there an easier approach that uses less levels of indirection?

#include <stdio.h>
#include <stdlib.h>

typedef struct list {
    int val;
    struct list *next;
} list;

void printlist(list *head);
void freelist(list *head);

void AddList(list ***tail, int val);

int main(void)
{
    /* create first node */
    list *head = (list *)malloc(sizeof(*head));

    /* assign members of first node */
    head->val = 1;
    head->next = NULL;

    /* create tail */
    list **tail = &head->next;

    /* add values to list */
    AddList(&tail, 2);
    AddList(&tail, 3);
    AddList(&tail, 4);
    AddList(&tail, 5);
    AddList(&tail, 6);
    AddList(&tail, 7);
    AddList(&tail, 8);
    AddList(&tail, 9);

    /* print list */
    printlist(head);

    /* free list */
    freelist(head);

    /* exit program */
    system("pause");
    return 0;
}

void AddList(list ***tail, int val)
{
    list *node = (list *)malloc(sizeof(*node));

    node->val = val;
    node->next = NULL;

    **tail = node;

    *tail = &node->next;
}

void printlist(list *head)
{
    while (head) {
        printf("%d\n", head->val);
        head = head->next;
    }
}

void freelist(list *head)
{
    list *tmp = head;
    while (head) {
        head = head->next;
        free(tmp);
        tmp = head;
    }
}

Body:
The tail pointer should point to the last node, not the next pointer of the last node:

In main:

/* create tail */
list *tail = head;

In AddList:

void AddList(list **tail, int val)
{
    list *node = malloc(sizeof(*node));

    node->val = val;
    node->next = NULL;

    (*tail)->next = node;
    *tail = node;
}


问:
How can my Workflow's performance be upgraded by Implementing ESB
We are trying to move our complete workflow to ESB.

Here ,all the Operations We are performing in our project!

1.Get an input file from a sftp server.

2.then copy that file to the app server(another server) where java is installed..

3.from there we are accessing DB SERVER(which is another server)..and perform some validations.

4.then we are generating some files and post it back to sftp server..

5.from there through web service we have to transfer that files to another server.

we had implemented all these through JAVA. How can ESB can help when implementing this through any ESB.

答:
we had implemented all these through JAVA. How can ESB can help when implementing this through any ESB.

Looking from here what I can see is that you may use Apache Camel to route this sample workflow you posted with ease, saving a lot of boilerplate code. Quoting from this question:

Apache Camel is an open source Java framework that focuses on making integration easier and more accessible to developers. It does this by providing:

concrete implementations of all the widely used Enterprise Integration Patterns (EIPs)

connectivity to a great variety of transports and APIs

easy to use Domain Specific Languages (DSLs) to wire EIPs and transports together

Camel has a lot of components available to build your workflow/route and save work.

Speaking about ESB topic, there's a nice definition about ESB and Apache Camel in this FAQ:

Is Camel an ESB?

Typically vendors claim practically everything is an ESB these days, so the answer is probably yes :)

However our view is that an ESB is more of a container of integration components, so we view Apache ServiceMix to be a true ESB based around OSGi (and optionally JBI) to provide a standards based integration platform of components.

We view Camel as being a rule based routing & mediation engine which can be used inside a full blown ESB, a message broker or a web services smart client. Though if you want to, you could consider that Camel is a small, lightweight embeddable ESB since it can provide many of the common ESB services like smart routing, transformation, mediation, monitoring, orchestration etc.


问:
Form submit only after modal validation
I'm using this package to create my forms.
And I'm currently using this code to confirm the suppresion of an item

```<code>{!! Form::open( ['method' => 'delete', 'url' => route($entity.'.destroy', [$entity => $id]), 'style' => 'display: inline', 'onSubmit' => 'confirm("Do you really want to delete that?")']) !!}
    <button type="submit" class="btn-delete btn btn-xs btn-danger">
        <i class="glyphicon glyphicon-trash"></i>
    </button>
{!! Form::close() !!}
</code>```

This works fine but I would like to replace this ugly js confirm by a modal

So I tried this

```<code>{!! Form::open( ['method' => 'delete', 'url' => route($entity.'.destroy', [$entity => $id]), 'style' => 'display: inline', 'onSubmit' => '$("#modal_' . $id. '").modal("show");']) !!}
    <button type="submit" class="btn-delete btn btn-xs btn-danger">
        <i class="glyphicon glyphicon-trash"></i>
    </button>
{!! Form::close() !!}

<!-- Modal -->
<div id="modal_{{ $id }}" class="modal fade" role="dialog">
    <div class="vertical-alignment-helper">
        <div class="modal-dialog vertical-align-center">
            <div class="modal-content">
                <div class="modal-body">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <p>You are about to delete.</p>
                    <p>Do you want to proceed?</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary pull-left" data-dismiss="modal">Cancel</button>
                    <button type="button" class="btn btn-danger">
                        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Confirm
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
</code>```

But the item is deleted before any click on the modal.

Is it possible to trigger the modal properly by using this package or should I just go by writing my old school html form ?

答:
The purpose of the Form package is to just help you create html form elements. Changing the package for a plain html form would end up with the same results, because all it does is generate the same elements tags that are written with html with the help of PHP.

Changing the first button to trigger the modal, and using the modal confirm button to submit the form would work.

```<code><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#modal_{{ $id }}">
    <i class="glyphicon glyphicon-trash"></i>
</button>

<!-- Modal -->
<div id="modal_{{ $id }}" class="modal fade" role="dialog">
    <div class="vertical-alignment-helper">
        <div class="modal-dialog vertical-align-center">
            <div class="modal-content">
                <div class="modal-body">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <p>You are about to delete.</p>
                    <p>Do you want to proceed?</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary pull-left" data-dismiss="modal">Cancel</button>
                    {!! Form::open( ['method' => 'delete', 'url' => route($entity . '.destroy', [$entity => $id]) ]) !!}
                        <button type="submit" class="btn-delete btn btn-xs btn-danger">
                            <i class="glyphicon glyphicon-trash"></i>
                        </button>
                    {!! Form::close() !!}
                </div>
            </div>
        </div>
    </div>
</div>
</code>```

Title: Form submit only after modal validation

Body:
I'm using this package to create my forms.
And I'm currently using this code to confirm the suppresion of an item

{!! Form::open( ['method' => 'delete', 'url' => route($entity.'.destroy', [$entity => $id]), 'style' => 'display: inline', 'onSubmit' => 'confirm("Do you really want to delete that?")']) !!}
    <button type="submit" class="btn-delete btn btn-xs btn-danger">

    </button>
{!! Form::close() !!}

This works fine but I would like to replace this ugly js confirm by a modal

So I tried this

{!! Form::open( ['method' => 'delete', 'url' => route($entity.'.destroy', [$entity => $id]), 'style' => 'display: inline', 'onSubmit' => '$("#modal_' . $id. '").modal("show");']) !!}
    <button type="submit" class="btn-delete btn btn-xs btn-danger">

    </button>
{!! Form::close() !!}

                    <button type="button" class="close" data-dismiss="modal">×</button>

You are about to delete.

Do you want to proceed?

                    <button type="button" class="btn btn-primary pull-left" data-dismiss="modal">Cancel</button>
                    <button type="button" class="btn btn-danger">
                         Confirm
                    </button>

But the item is deleted before any click on the modal.

Is it possible to trigger the modal properly by using this package or should I just go by writing my old school html form ?

Body:
The purpose of the Form package is to just help you create html form elements. Changing the package for a plain html form would end up with the same results, because all it does is generate the same elements tags that are written with html with the help of PHP.

Changing the first button to trigger the modal, and using the modal confirm button to submit the form would work.

<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#modal_{{ $id }}">
    <i class="glyphicon glyphicon-trash"></i>
</button>

<!-- Modal -->
<div id="modal_{{ $id }}" class="modal fade" role="dialog">
    <div class="vertical-alignment-helper">
        <div class="modal-dialog vertical-align-center">
            <div class="modal-content">
                <div class="modal-body">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <p>You are about to delete.</p>
                    <p>Do you want to proceed?</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary pull-left" data-dismiss="modal">Cancel</button>
                    {!! Form::open( ['method' => 'delete', 'url' => route($entity . '.destroy', [$entity => $id]) ]) !!}
                        <button type="submit" class="btn-delete btn btn-xs btn-danger">
                            <i class="glyphicon glyphicon-trash"></i>
                        </button>
                    {!! Form::close() !!}
                </div>
            </div>
        </div>
    </div>
</div>


问:
Does escape analysis handles Thread.holdsLock() properly?
This example works fine (prints true) when I run it with -XX:+DoEscapeAnalysis -server:

```<code>final Object lock = new Object();
synchronized (lock) {
    System.out.println(Thread.holdsLock(lock)); // prints true
}
</code>```

On the other hand, the short and not too detailed Java HotSpot™ Virtual Machine Performance Enhancements documentation says the following:

The server compiler also eliminates locks for all non-globally escaping objects.

So, if escape analysis eliminates the unnecessary synchronization here it should print false.

I guess escape analysis handles holdsLock properly (eliminates locks does not broke holdsLock()) but I would like to see some official reference or maybe relevant JVM source code snippets.

答:
Thread.holdsLock is a native method in JDK, and it is not a JVM intrinsic.

This means, the implementation of Thread.holdsLock is a black box for JIT compiler. Since this method accepts lock as an argument, lock can no longer be considered as a local non-escapable object. JVM knows for sure, that lock does escape, so neither allocation nor synchronization may be eliminated in this example.

But, as @Holger noticed, even if holdsLock was a JVM intrinsic, it should never return false, otherwise this would be a specification violation. No JVM optimization may break the correctness of a program.

Body:
This example works fine (prints true) when I run it with -XX:+DoEscapeAnalysis -server:

final Object lock = new Object();
synchronized (lock) {
    System.out.println(Thread.holdsLock(lock)); // prints true
}

On the other hand, the short and not too detailed Java HotSpot™ Virtual Machine Performance Enhancements documentation says the following:

The server compiler also eliminates locks for all non-globally escaping objects.

So, if escape analysis eliminates the unnecessary synchronization here it should print false.

I guess escape analysis handles holdsLock properly (eliminates locks does not broke holdsLock()) but I would like to see some official reference or maybe relevant JVM source code snippets.


问:
Hiding the error message for time and date input fields

$("#tym").keydown(function() {
  if (!($(this).val())) {
    $('#error5').html('
Enter time
');
  } else {
    $('#error5').html('');
  }
});

$('#sal').keyup(function() {
  if (!($(this).val())) {
    $('#error6').html('
Enter salary
');

    $('#sal').focus();

  } else {
    $('#error6').html('');
  }
});

$('#sald').keyup(function() {
  if (!($(this).val())) {
    $('#error7').html('
Enter Salarydate
');

    $('#sald').focus();

  } else {
    $('#error7').html('');
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </br>
  </br>

  <form method="POST" align="center" id="ins">
    </br>

    <label>Available Time:</label>
    <input type="time" name="availabletime" id="tym" />
    <span id="error5"></span>
    <br/><br/>

    <label>Salary:</label>
    <input type="text" name="amount" id="sal" />
    <span id="error6"></span>
    <br/><br/>

    <label>Salary Date:</label>
    <input type="date" name="salarydate" id="sald" />
    <span id="error7"></span>
    <br/><br/>
    </br>
    <input type="submit" name="submit" value="Enter" />
  </form>\</code>```

Context:
This is code for a form validation.The validation is working but i want to hide the error message for time and date when clicking the corresponding field.All other feilds validation is working including error message hiding.I changed the function keydown to mouseup ,but not working.Is there any function like keyup for input fields for time and date.

答:
You can use the input event that will call your error handling when the input is changed</p>

```<code>$("#tym").on("input", function() {
  if (!($(this).val())) {
    $('#error5').html('<p style="color:red;font-size:14px;"align="center">Enter time</p>');
  } else {
    $('#error5').html('');
  }
});
</code>```

Body:
$("#tym").keydown(function() {
  if (!($(this).val())) {
    $('#error5').html('
Enter time
');
  } else {
    $('#error5').html('');
  }
});

$('#sal').keyup(function() {
  if (!($(this).val())) {
    $('#error6').html('
Enter salary
');

    $('#sal').focus();

  } else {
    $('#error6').html('');
  }
});

$('#sald').keyup(function() {
  if (!($(this).val())) {
    $('#error7').html('
Enter Salarydate
');

    $('#sald').focus();

  } else {
    $('#error7').html('');
  }
});

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

  <form method="POST" align="center" id="ins">

    Available Time:
    <input type="time" name="availabletime" id="tym" />

    Salary:
    <input type="text" name="amount" id="sal" />

    Salary Date:
    <input type="date" name="salarydate" id="sald" />

    <input type="submit" name="submit" value="Enter" />
  </form>\

Context:
This is code for a form validation.The validation is working but i want to hide the error message for time and date when clicking the corresponding field.All other feilds validation is working including error message hiding.I changed the function keydown to mouseup ,but not working.Is there any function like keyup for input fields for time and date.

Body:
You can use the input event that will call your error handling when the input is changed

$("#tym").on("input", function() {
  if (!($(this).val())) {
    $('#error5').html('<p style="color:red;font-size:14px;"align="center">Enter time</p>');
  } else {
    $('#error5').html('');
  }
});


答:
You can limit log output to a given author and/or committer

```<code>git log --author=my_username
</code>```

You can have log give the history of a branch simply by naming the branch, but be aware this alone may not to exactly what you expect (see below):

```<code>git log --author=my_username my_branch
</code>```

The thing is, this will list all commits reachable from the branch.  (A branch is a pointer to a single commit; log then follows "parent commit" pointers (by default) to provide a history for the branch.

That will include commits that, perhaps, you think are "on the parent branch" rather than "on this branch".  For example

```<code>A -- B -- C -- D <--(master)
      \
       E -- F <--(my_branch)
</code>```

Here all of A, B, E and F are reachable from my_branch.  So if you think of A and B as "not on the branch", you need something more.  And what that is depends on the situation, because the idea of commits "on a particular branch" (rather than "reachable from any number of branches") is an artificial concept users like to impose on git, but that git doesn't really know about.

In the above case, you would say

```<code>git log --author=my_username master..my_branch
</code>```

to exclude anything reachable from master, leaving E and F only (and filtering those based on author info).

Lastly, you appear to want to see the patch from each change.  (You said "combine with show".)  So you could use -p:

```<code>git log -p --author=my_username master..my_branch
</code>```

Or if you decide you'd rather list the files instead

```<code>git log --name-only --author=my_username master..my_branch
</code>```

Title: git log, show files for specific username and branch

Body:
I'd like to combine git log and git show so that I can list all changes files for a given user, for a given branch. My aim is to be able to see what files I have personally changes, over the life of a branch (as opposed to files changes in my branch from a merge)

What is the best way to achieve this?

Body:
You can limit log output to a given author and/or committer

git log --author=my_username

You can have log give the history of a branch simply by naming the branch, but be aware this alone may not to exactly what you expect (see below):

git log --author=my_username my_branch

The thing is, this will list all commits reachable from the branch.  (A branch is a pointer to a single commit; log then follows "parent commit" pointers (by default) to provide a history for the branch.

That will include commits that, perhaps, you think are "on the parent branch" rather than "on this branch".  For example

A -- B -- C -- D <--(master)
      \
       E -- F <--(my_branch)

Here all of A, B, E and F are reachable from my_branch.  So if you think of A and B as "not on the branch", you need something more.  And what that is depends on the situation, because the idea of commits "on a particular branch" (rather than "reachable from any number of branches") is an artificial concept users like to impose on git, but that git doesn't really know about.

In the above case, you would say

git log --author=my_username master..my_branch

to exclude anything reachable from master, leaving E and F only (and filtering those based on author info).

Lastly, you appear to want to see the patch from each change.  (You said "combine with show".)  So you could use -p:

git log -p --author=my_username master..my_branch

Or if you decide you'd rather list the files instead

git log --name-only --author=my_username master..my_branch


问:
Problem applying texture to square in OpenGL
I'm stuck at not being able to map texture to a square in openGLES. I'm trying to display a jpg image on the screen, and in order for me to do that, I draw a square that I want to then map image onto. However all I get as an output is a white square. I don't know what am I doing wrong. And this problem is preventing me from moving forward with my project. I'm using Managed OpenGL ES wrapper for Windows Mobile.
I verified that the texture is loading correctly, but I can't apply it to my object. I uploaded sample project that shows my problem here. You would need VS2008 with Windows Mobile 6 SDK to be able to run it. I'm also posting the code of the Form that renders and textures an object here. Any suggestions would be much appreciated, since I've been stuck on this problem for a while, and I can't figure out what am I doing wrong.</p>

```<code>    public partial class Form1 : Form
{
    [DllImport("coredll")]
    extern static IntPtr GetDC(IntPtr hwnd);

    EGLDisplay myDisplay;
    EGLSurface mySurface;
    EGLContext myContext;

    public Form1()
    {
        InitializeComponent();
        myDisplay = egl.GetDisplay(new EGLNativeDisplayType(this));

        int major, minor;
        egl.Initialize(myDisplay, out major, out minor);

        EGLConfig[] configs = new EGLConfig[10];
        int[] attribList = new int[]
        {
            egl.EGL_RED_SIZE, 5,
            egl.EGL_GREEN_SIZE, 6,
            egl.EGL_BLUE_SIZE, 5,
            egl.EGL_DEPTH_SIZE, 16 ,
            egl.EGL_SURFACE_TYPE, egl.EGL_WINDOW_BIT,
            egl.EGL_STENCIL_SIZE, egl.EGL_DONT_CARE,
            egl.EGL_NONE, egl.EGL_NONE
        };

        int numConfig;
        if (!egl.ChooseConfig(myDisplay, attribList, configs, configs.Length, out numConfig) || numConfig < 1)
            throw new InvalidOperationException("Unable to choose config.");

        EGLConfig config = configs[0];
        mySurface = egl.CreateWindowSurface(myDisplay, config, Handle, null);
        myContext = egl.CreateContext(myDisplay, config, EGLContext.None, null);

        egl.MakeCurrent(myDisplay, mySurface, mySurface, myContext);
        gl.ClearColor(0, 0, 0, 0);
        InitGL();
    }

    void InitGL()
    {
        gl.ShadeModel(gl.GL_SMOOTH);
        gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
        gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
        gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
    }

    public unsafe void DrawGLScene()
    {
        gl.MatrixMode(gl.GL_PROJECTION);
        gl.LoadIdentity();
        gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, 0, 1);
        gl.Disable(gl.GL_DEPTH_TEST);

        gl.MatrixMode(gl.GL_MODELVIEW);
        gl.LoadIdentity();

        Texture myImage;
        Bitmap Image = new Bitmap(@"\Storage Card\Texture.jpg");
        using (MemoryStream ms = new MemoryStream())
        {
            Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            myImage = Texture.LoadStream(ms, false);
        }

        float[] rectangle = new float[] {
                0, 0,
                myImage.Width, 0,
                0,  myImage.Height,
                myImage.Width,  myImage.Height
            };

        float[] texturePosition = new float[] {
                0, 0,
                myImage.Width, 0,
                0,  myImage.Height,
                myImage.Width,  myImage.Height
            };

        //Bind texture
        gl.BindTexture(gl.GL_TEXTURE_2D, myImage.Name);
        gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
        gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
        gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);
        gl.EnableClientState(gl.GL_VERTEX_ARRAY);

        //draw square and texture it.
        fixed (float* rectanglePointer = &rectangle[0], positionPointer = &texturePosition[0])
        {
            gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)positionPointer);
            gl.VertexPointer(2, gl.GL_FLOAT, 0, (IntPtr)rectanglePointer);
            gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
        }

        gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
        gl.DisableClientState(gl.GL_VERTEX_ARRAY);

    }

    protected override void OnPaintBackground(PaintEventArgs e)
    {

    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        gl.Clear(gl.GL_COLOR_BUFFER_BIT);

        DrawGLScene();
        egl.SwapBuffers(myDisplay, mySurface);
        gl.Clear(gl.GL_COLOR_BUFFER_BIT);
    }

    protected override void OnClosing(CancelEventArgs e)
    {
        if (!egl.DestroySurface(myDisplay, mySurface))
            throw new Exception("Error while destroying surface.");
        if (!egl.DestroyContext(myDisplay, myContext))
            throw new Exception("Error while destroying context.");
        if (!egl.Terminate(myDisplay))
            throw new Exception("Error while terminating display.");
        base.OnClosing(e);
    }
}
</code>```

答:
Thanks for the help! However your suggestion didn't fix the issue. Now the square is black instead of white, but still no texture. I've tried adding gl.Enable(gl.GL_TEXTURE_2D) at every possible position, but the result is still black square.

EDIT:
Upps, sorry, top-left corner of my image was black that's why I didn't see anything. Changed the image to have different colors, and now I can see part of the image rendered. It's not mapped propertly, but I can figure that part out.
Thanks a lot of the help!!!

OwnerDisplayName: Ilya Volodin

ContentLicense: CC BY-SA 2.5

Body:
I'm stuck at not being able to map texture to a square in openGLES. I'm trying to display a jpg image on the screen, and in order for me to do that, I draw a square that I want to then map image onto. However all I get as an output is a white square. I don't know what am I doing wrong. And this problem is preventing me from moving forward with my project. I'm using Managed OpenGL ES wrapper for Windows Mobile.
I verified that the texture is loading correctly, but I can't apply it to my object. I uploaded sample project that shows my problem here. You would need VS2008 with Windows Mobile 6 SDK to be able to run it. I'm also posting the code of the Form that renders and textures an object here. Any suggestions would be much appreciated, since I've been stuck on this problem for a while, and I can't figure out what am I doing wrong.

    public partial class Form1 : Form
{
    [DllImport("coredll")]
    extern static IntPtr GetDC(IntPtr hwnd);

    EGLDisplay myDisplay;
    EGLSurface mySurface;
    EGLContext myContext;

    public Form1()
    {
        InitializeComponent();
        myDisplay = egl.GetDisplay(new EGLNativeDisplayType(this));

        int major, minor;
        egl.Initialize(myDisplay, out major, out minor);

        EGLConfig[] configs = new EGLConfig[10];
        int[] attribList = new int[]
        {
            egl.EGL_RED_SIZE, 5,
            egl.EGL_GREEN_SIZE, 6,
            egl.EGL_BLUE_SIZE, 5,
            egl.EGL_DEPTH_SIZE, 16 ,
            egl.EGL_SURFACE_TYPE, egl.EGL_WINDOW_BIT,
            egl.EGL_STENCIL_SIZE, egl.EGL_DONT_CARE,
            egl.EGL_NONE, egl.EGL_NONE
        };

        int numConfig;
        if (!egl.ChooseConfig(myDisplay, attribList, configs, configs.Length, out numConfig) || numConfig < 1)
            throw new InvalidOperationException("Unable to choose config.");

        EGLConfig config = configs[0];
        mySurface = egl.CreateWindowSurface(myDisplay, config, Handle, null);
        myContext = egl.CreateContext(myDisplay, config, EGLContext.None, null);

        egl.MakeCurrent(myDisplay, mySurface, mySurface, myContext);
        gl.ClearColor(0, 0, 0, 0);
        InitGL();
    }

    void InitGL()
    {
        gl.ShadeModel(gl.GL_SMOOTH);
        gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
        gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
        gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
    }

    public unsafe void DrawGLScene()
    {
        gl.MatrixMode(gl.GL_PROJECTION);
        gl.LoadIdentity();
        gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, 0, 1);
        gl.Disable(gl.GL_DEPTH_TEST);

        gl.MatrixMode(gl.GL_MODELVIEW);
        gl.LoadIdentity();

        Texture myImage;
        Bitmap Image = new Bitmap(@"\Storage Card\Texture.jpg");
        using (MemoryStream ms = new MemoryStream())
        {
            Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            myImage = Texture.LoadStream(ms, false);
        }

        float[] rectangle = new float[] {
                0, 0,
                myImage.Width, 0,
                0,  myImage.Height,
                myImage.Width,  myImage.Height
            };

        float[] texturePosition = new float[] {
                0, 0,
                myImage.Width, 0,
                0,  myImage.Height,
                myImage.Width,  myImage.Height
            };

        //Bind texture
        gl.BindTexture(gl.GL_TEXTURE_2D, myImage.Name);
        gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
        gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
        gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);
        gl.EnableClientState(gl.GL_VERTEX_ARRAY);

        //draw square and texture it.
        fixed (float* rectanglePointer = &rectangle[0], positionPointer = &texturePosition[0])
        {
            gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)positionPointer);
            gl.VertexPointer(2, gl.GL_FLOAT, 0, (IntPtr)rectanglePointer);
            gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
        }

        gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
        gl.DisableClientState(gl.GL_VERTEX_ARRAY);

    }

    protected override void OnPaintBackground(PaintEventArgs e)
    {

    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        gl.Clear(gl.GL_COLOR_BUFFER_BIT);

        DrawGLScene();
        egl.SwapBuffers(myDisplay, mySurface);
        gl.Clear(gl.GL_COLOR_BUFFER_BIT);
    }

    protected override void OnClosing(CancelEventArgs e)
    {
        if (!egl.DestroySurface(myDisplay, mySurface))
            throw new Exception("Error while destroying surface.");
        if (!egl.DestroyContext(myDisplay, myContext))
            throw new Exception("Error while destroying context.");
        if (!egl.Terminate(myDisplay))
            throw new Exception("Error while terminating display.");
        base.OnClosing(e);
    }
}

LastEditorDisplayName: aib

LastEditorDisplayName: Ilya Volodin


问:
Trouble deploying multiple HTTPS sites to single host in TFS 2015
I'm trying to deploy multiple websites to a single host running IIS from TFS 2015.  I'm trying to have all sites use the "Server Name Indication Required" option so that they all can run under the same IP address.  (This setup works fine in IIS if I manually set everything up -- my question / problem comes from deploying from TFS 2015).

The FIRST site in the deploy chain works fine, but the any subsequent one seems to fail with the following error:

```<code>System.Exception:  SSL Certificate add failed, Error: 183 Cannot create a file when that file already exists.
</code>```

Each of the sites I'm deploying has a different SSL certificate and I've imported them all properly to the Local Machine\Personal store.

A screenshot of the release definition with the "IIS Web App Management" task highlighted is shown below.

Any suggestions on how to resolve this error within the release definition so that I can deploy cleanly without manual intervention?

I guess one thing I could try is to do ALL of the IIS management steps from PowerShell but was hoping to use the tools a little more fully rather than rolling new scripts to do what it seems that they SHOULD be able to do natively.

Any insight is appreciated.

答:
I got things working - but I had to basically eliminate the binding configuration from the WinRM - IIS App Management tasks.  I kept everything the same but specified NO binding information at all in those tasks, then added a target machine power shell script that looked like this (thumbprints and site domains changed):</p>

```<code>Import-Module WebAdministration

if ($null -eq (Get-WebBinding | Where-Object {$_.BindingInformation -eq "*:443:iddev.mydomain.com"}))
{
    New-WebBinding -Name "Identity-B2B" -Port 443 -Protocol "https" -HostHeader "iddev.mydomain.com" -SslFlags 1
    New-Item -Path "IIS:\SslBindings\!443!iddev.mydomain.com" -Thumbprint "88E811B7A9417DACAAAAAAAAAA1C36AA0BA238FF1E0F" -SSLFlags 1
}

if ($null -eq (Get-WebBinding | Where-Object {$_.BindingInformation -eq "*:443:iddev.myotherdomain.com"}))
{
    New-WebBinding -Name "Identity-B2C" -Port 443 -Protocol "https" -HostHeader "iddev.myotherdomain.com" -SslFlags 1
    New-Item -Path "IIS:\SslBindings\!443!iddev.myotherdomain.com" -Thumbprint "BE38195A2BBBBBBBBBBBBBBB1C2AB5762C9" -SSLFlags 1
}
</code>```

Body:
I'm trying to deploy multiple websites to a single host running IIS from TFS 2015.  I'm trying to have all sites use the "Server Name Indication Required" option so that they all can run under the same IP address.  (This setup works fine in IIS if I manually set everything up -- my question / problem comes from deploying from TFS 2015).

The FIRST site in the deploy chain works fine, but the any subsequent one seems to fail with the following error:

System.Exception:  SSL Certificate add failed, Error: 183 Cannot create a file when that file already exists.

Each of the sites I'm deploying has a different SSL certificate and I've imported them all properly to the Local Machine\Personal store.

A screenshot of the release definition with the "IIS Web App Management" task highlighted is shown below.

Any suggestions on how to resolve this error within the release definition so that I can deploy cleanly without manual intervention?

I guess one thing I could try is to do ALL of the IIS management steps from PowerShell but was hoping to use the tools a little more fully rather than rolling new scripts to do what it seems that they SHOULD be able to do natively.

Any insight is appreciated.

Body:
I got things working - but I had to basically eliminate the binding configuration from the WinRM - IIS App Management tasks.  I kept everything the same but specified NO binding information at all in those tasks, then added a target machine power shell script that looked like this (thumbprints and site domains changed):

Import-Module WebAdministration

if ($null -eq (Get-WebBinding | Where-Object {$_.BindingInformation -eq "*:443:iddev.mydomain.com"}))
{
    New-WebBinding -Name "Identity-B2B" -Port 443 -Protocol "https" -HostHeader "iddev.mydomain.com" -SslFlags 1
    New-Item -Path "IIS:\SslBindings\!443!iddev.mydomain.com" -Thumbprint "88E811B7A9417DACAAAAAAAAAA1C36AA0BA238FF1E0F" -SSLFlags 1
}

if ($null -eq (Get-WebBinding | Where-Object {$_.BindingInformation -eq "*:443:iddev.myotherdomain.com"}))
{
    New-WebBinding -Name "Identity-B2C" -Port 443 -Protocol "https" -HostHeader "iddev.myotherdomain.com" -SslFlags 1
    New-Item -Path "IIS:\SslBindings\!443!iddev.myotherdomain.com" -Thumbprint "BE38195A2BBBBBBBBBBBBBBB1C2AB5762C9" -SSLFlags 1
}


问:
Phrets is giving Invalid Type error using getobject
can any one help me how to get images of property using reso phrets.

Below is my code which is executing :

```<code>$rets   = new \PHRETS\Session($config);
$search = $rets->Search("Property","Residential","*",
    array(
        'QueryType'           => 'DMQL2',
        "Count"               => 1,
        "Format"              => "COMPACT-DECODED",
        "Limit"               => 5,
        "Offset"              => 0,
        "Select"              => "ListingKeyNumeric,BuyerAgentLastName,buyerAgentFirstName,buyerOfficeName,City,Country,CurrentPrice,StreetName,PostalCode,StateOrProvince,StreetNumberNumeric,BedroomsTotal,BathroomsTotalInteger,LotSizeSquareFeet,YearBuilt,StandardStatus,LotSizeAcres,ListOfficeMlsId,ListPrice,BathroomsFull,BathroomsHalf,PropertySubType,ArchitecturalStyle,MLSAreaMajor,CountyOrParish,Utilities,ParkingTotal,ParkingFeatures,GarageSpaces,View,PoolPrivateYN,PoolFeatures,InteriorFeatures,Appliances,Heating,Cooling,FireplaceYN,FireplaceFeatures,StoriesTotal,ExteriorFeatures,LotSizeDimensions,WindowFeatures,Roof,ConstructionMaterials,FoundationDetails,HighSchoolDistrict,ElementarySchool,MiddleOrJuniorSchool,OriginalEntryTimestamp,DaysOnMarket,Zoning,AssociationFee,AssociationFeeFrequency,ListOfficeName,PricePerSquareFoot,ListAgentFirstName,ListAgentLastName,ListAgentMlsId,InternetAddressDisplayYN,ListingId,PhotosCount",
        "RestrictedIndicator" => "****",
        "StandardNames"       => 1
    )
);

foreach ($search as $r) {

    $rets_resource = 'Property';
    $object_type   = 'photo';
    $listing_id    = $r['ListingId'];
    $photos        = $rets->GetObject('Property',$classes->first()->getClassName(),'OC17206923,217009806DA,PW17081942','*',0);
    print_r($photos);
}
</code>```

Result What i am getting :

```<code>Illuminate\Support\Collection Object
(    [items:protected] => Array
    (
      [0] => PHRETS\Models\Object Object
      (
       [content_type:protected] => text/xml
       [content_id:protected] =>
       [object_id:protected] =>
       [mime_version:protected] => 1.0
       [location:protected] =>
       [content_description:protected] =>
       [content_sub_description:protected] =>
       [content:protected] =>

       [preferred:protected] =>
       [error:protected] => PHRETS\Models\RETSError Object
      (
        [code:protected] => 20401
        [message:protected] => Invalid Type
      )
    )
  )
)
</code>```

答:
What's the value of $classes->first()->getClassName() for the type parameter in the getObject() call?

Maybe you want to use 'photo' or $object_type instead?

Body:
can any one help me how to get images of property using reso phrets.

Below is my code which is executing :

$rets   = new \PHRETS\Session($config);
$search = $rets->Search("Property","Residential","*",
    array(
        'QueryType'           => 'DMQL2',
        "Count"               => 1,
        "Format"              => "COMPACT-DECODED",
        "Limit"               => 5,
        "Offset"              => 0,
        "Select"              => "ListingKeyNumeric,BuyerAgentLastName,buyerAgentFirstName,buyerOfficeName,City,Country,CurrentPrice,StreetName,PostalCode,StateOrProvince,StreetNumberNumeric,BedroomsTotal,BathroomsTotalInteger,LotSizeSquareFeet,YearBuilt,StandardStatus,LotSizeAcres,ListOfficeMlsId,ListPrice,BathroomsFull,BathroomsHalf,PropertySubType,ArchitecturalStyle,MLSAreaMajor,CountyOrParish,Utilities,ParkingTotal,ParkingFeatures,GarageSpaces,View,PoolPrivateYN,PoolFeatures,InteriorFeatures,Appliances,Heating,Cooling,FireplaceYN,FireplaceFeatures,StoriesTotal,ExteriorFeatures,LotSizeDimensions,WindowFeatures,Roof,ConstructionMaterials,FoundationDetails,HighSchoolDistrict,ElementarySchool,MiddleOrJuniorSchool,OriginalEntryTimestamp,DaysOnMarket,Zoning,AssociationFee,AssociationFeeFrequency,ListOfficeName,PricePerSquareFoot,ListAgentFirstName,ListAgentLastName,ListAgentMlsId,InternetAddressDisplayYN,ListingId,PhotosCount",
        "RestrictedIndicator" => "****",
        "StandardNames"       => 1
    )
);

foreach ($search as $r) {

    $rets_resource = 'Property';
    $object_type   = 'photo';
    $listing_id    = $r['ListingId'];
    $photos        = $rets->GetObject('Property',$classes->first()->getClassName(),'OC17206923,217009806DA,PW17081942','*',0);
    print_r($photos);
}

Result What i am getting :

Illuminate\Support\Collection Object
(    [items:protected] => Array
    (
      [0] => PHRETS\Models\Object Object
      (
       [content_type:protected] => text/xml
       [content_id:protected] =>
       [object_id:protected] =>
       [mime_version:protected] => 1.0
       [location:protected] =>
       [content_description:protected] =>
       [content_sub_description:protected] =>
       [content:protected] =>

       [preferred:protected] =>
       [error:protected] => PHRETS\Models\RETSError Object
      (
        [code:protected] => 20401
        [message:protected] => Invalid Type
      )
    )
  )
)


问:
How to fix Error:Could not find com.google.gms: google-services: 3.0.0.?
I am trying to add firebase addmob in my app.

In build.gradle(Project) i have following code

```<code>buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms: google-services: 3.0.0'
        classpath 'com.android.tools.build:gradle:2.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
</code>```

In build.gradle(module)

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.myname.examp.myapp"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.google.firebase: firebase-ads: 9.0.0'
}
apply plugin: 'com.google.gms.google-services'
</code>```

I have updated version of google play service and repository

When I sync project still i am getting following error

```<code>Error:Could not find com.google.gms: google-services: 3.0.0.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio2/gradle/m2repository/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.pom
    file:/C:/Program Files/Android/Android Studio2/gradle/m2repository/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.jar
    https://jcenter.bintray.com/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.pom
    https://jcenter.bintray.com/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.jar
Required by:
    :MyApplication:unspecified
</code>```

Can some one help me how to fix this error

答:
add the classpath in the build.gradle at your project level not the one in module level. </p>

```<code>dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'
    classpath 'com.google.gms:google-services:3.+'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
</code>```

<p>and then apply it in the module level. </p>

```<code>apply plugin: 'com.google.gms.google-services'
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to add firebase addmob in my app.

In build.gradle(Project) i have following code

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms: google-services: 3.0.0'
        classpath 'com.android.tools.build:gradle:2.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

In build.gradle(module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.myname.examp.myapp"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.google.firebase: firebase-ads: 9.0.0'
}
apply plugin: 'com.google.gms.google-services'

I have updated version of google play service and repository

When I sync project still i am getting following error

Error:Could not find com.google.gms: google-services: 3.0.0.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio2/gradle/m2repository/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.pom
    file:/C:/Program Files/Android/Android Studio2/gradle/m2repository/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.jar
    https://jcenter.bintray.com/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.pom
    https://jcenter.bintray.com/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.jar
Required by:
    :MyApplication:unspecified

Can some one help me how to fix this error

Body:
add the classpath in the build.gradle at your project level not the one in module level.

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'
    classpath 'com.google.gms:google-services:3.+'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

and then apply it in the module level.

apply plugin: 'com.google.gms.google-services'


问:
How to read excel file to content status
I would like read to excel file (this file is not open) "content status" with VBA macros.
It is possible?
I attached picture what I want to read.

Thanks for your help.

答:
Code posted by Florent B works correctly. However, I didn't get the desired property on mentioned index i.e. 127. Instead I got it on 129 on my computer. I am not sure about its reason.

My suggestion is as below. Create a custom function.

Important: Set reference as indicated or else it will not work. I tried late binding but the code fails so this setting is critical.

```<code>Public Function GetExtendedProperty(strFolder As String, _
                                    strFile As String, _
                                    strProperty As String) As String
'\\ Set Reference to "Microsoft Shell Controls and Automation" Library (shell32.dll) in VBE
Dim wShell As Shell
Dim fld As folder
Dim itm As FolderItem
Dim i As Long

Set wShell = CreateObject("Shell.Application")
Set fld = wShell.Namespace(strFolder)
Set itm = fld.ParseName(strFile)

For i = 0 To 255
    If CStr(fld.GetDetailsOf(fld.Items, i)) = strProperty Then
        GetExtendedProperty = fld.GetDetailsOf(itm, i)
    End If
Next i

Set itm = Nothing
Set fld = Nothing
Set wShell = Nothing
End Function
</code>```

Then it can be used like below in the actual code.

```<code>Sub Test()
Dim strComplStatus As String
strComplStatus = GetExtendedProperty("C:\Temp", "Book1.xlsx", "Content status")
MsgBox strComplStatus
End Sub
</code>```

Body:
Code posted by Florent B works correctly. However, I didn't get the desired property on mentioned index i.e. 127. Instead I got it on 129 on my computer. I am not sure about its reason.

My suggestion is as below. Create a custom function.

Important: Set reference as indicated or else it will not work. I tried late binding but the code fails so this setting is critical.

Public Function GetExtendedProperty(strFolder As String, _
                                    strFile As String, _
                                    strProperty As String) As String
'\\ Set Reference to "Microsoft Shell Controls and Automation" Library (shell32.dll) in VBE
Dim wShell As Shell
Dim fld As folder
Dim itm As FolderItem
Dim i As Long

Set wShell = CreateObject("Shell.Application")
Set fld = wShell.Namespace(strFolder)
Set itm = fld.ParseName(strFile)

For i = 0 To 255
    If CStr(fld.GetDetailsOf(fld.Items, i)) = strProperty Then
        GetExtendedProperty = fld.GetDetailsOf(itm, i)
    End If
Next i

Set itm = Nothing
Set fld = Nothing
Set wShell = Nothing
End Function

Then it can be used like below in the actual code.

Sub Test()
Dim strComplStatus As String
strComplStatus = GetExtendedProperty("C:\Temp", "Book1.xlsx", "Content status")
MsgBox strComplStatus
End Sub


问:
Config File Checksum guessing (CRC)
I'm currently "hacking" an old 3d Printer, built in 1996. There is Software running on an old Windows PC. I need to modify some parameters which are not accessible from the front end, so I wanted to modify the config files. But if I modify something, it could not be read anymore. I noticed, that there is a checksum at the end of the file, and I'm not really an checksum expert. I assume that, while loading the file, this checksum is calculated again and compared to the one at the end.
I'm having trouble finding out which checksum algorithm is used.

What I already found out: I think it's not just an addition of the bits in the file. When I'm switching two characters, an checksum, that is generated with addition, would not change. But the software won't take that file.

I'm guessing its some kind of CRC16, because a checksum looks like that:

```<code>0x4f20
</code>```

As I have calculated that number with several usual CRC16 parameters and could not find a match with the "4f20", I assume that it must be an custom CRC16..

Here is a complete sample file:

```<code>PACKET noname
  style 502
  last_modified 1511855084 # Tue Nov 28 08:44:44 2017

  STRUCTURE MACHINE_OVRL
    PARAM distance_units
      Value = "millimeters"
    ENDPARAM
    PARAM language
      Value = "English"
    ENDPARAM
  ENDSTRUCTURE
ENDPACKET
checksum 0x4f20
</code>```

I think either the checksum itself or the complete line "checksum 0x4f20" is not being considered while calculated, because thats not possible (?)

Any help is appreciated.

Edit: I got some more files with checksums of course, but these are a lot longer than this file. If needed, I could provide them too..

答: RevEng was written for this purpose. Given several examples of the input and the associated CRCs, RevEng will derive the CRC parameters. If it is a CRC.</p>

Title: Config File Checksum guessing (CRC)

Body:
I'm currently "hacking" an old 3d Printer, built in 1996. There is Software running on an old Windows PC. I need to modify some parameters which are not accessible from the front end, so I wanted to modify the config files. But if I modify something, it could not be read anymore. I noticed, that there is a checksum at the end of the file, and I'm not really an checksum expert. I assume that, while loading the file, this checksum is calculated again and compared to the one at the end.
I'm having trouble finding out which checksum algorithm is used.

What I already found out: I think it's not just an addition of the bits in the file. When I'm switching two characters, an checksum, that is generated with addition, would not change. But the software won't take that file.

I'm guessing its some kind of CRC16, because a checksum looks like that:

0x4f20

As I have calculated that number with several usual CRC16 parameters and could not find a match with the "4f20", I assume that it must be an custom CRC16..

Here is a complete sample file:

PACKET noname
  style 502
  last_modified 1511855084 # Tue Nov 28 08:44:44 2017

  STRUCTURE MACHINE_OVRL
    PARAM distance_units
      Value = "millimeters"
    ENDPARAM
    PARAM language
      Value = "English"
    ENDPARAM
  ENDSTRUCTURE
ENDPACKET
checksum 0x4f20

I think either the checksum itself or the complete line "checksum 0x4f20" is not being considered while calculated, because thats not possible (?)

Any help is appreciated.

Edit: I got some more files with checksums of course, but these are a lot longer than this file. If needed, I could provide them too..


问:
How to format date in MM/DD/YYYY in Delphi
I have array of string as mentioned below.

```<code>Param : array[1..5] of string = ('US','Dollor','27/03/2017','IND','INR');
</code>```

I need to find the string which contains date and format it in MM/DD/YYYY.
To achieve this I am running for loop and passing each string in TryStrToDate. If string is of date type, it will return true and then I will format that string in desired format. My code is as below

```<code> for i := 1 to ParamCount do
  begin
   if TryStrToDate(Param[i],DateValue)=true then
   begin
    Param[i] := DateToStr(StrToDate(Param[i]));
    ShowMessage(Param[i]);
   end;
 end;
</code>```

Here date in Param[] is in DD/MM/YYYY so TryStrToDate is unable to understand. How can i change the code?
After this final result should be as below

```<code>Param : array[1..5] of string = ('US','Dollor','03/27/2017','IND','INR');
</code>```

Used Mark's solution as below:

```<code>  GetLocaleFormatSettings(ALocID, AFormatSettings);
  AFormatSettings.ShortDateFormat := 'DD/MM/YYYY';
  for i := 1 to ParamCount do
  begin
    if TryStrToDate(param[i], DateValue, AFormatSettings) = False then
      Continue;
    try
      DateVal := StrToDate(param[i], AFormatSettings);
      param[i] := DateToStr(DateVal);
      Continue;
    except
      Continue;
    end;
  end;
</code>```

答:
TryStrToDate is a Delphi library function that will try to convert a string into a TDateTime type. In my code there were some formats that I wanted to accept that are not allowed by the TryStrToDate function. To convert those dates if the first method fails I call VarToDateTime. That calls a variant function that supports additional formats.

As Remy commented there is an option parameter of a TFormatSettings type that allows you some measure of control over the formats accepted. I still needed to use VarToDateTime in order to covert dates that spelled out the month instead of using numeric values.

```<code>var
  DateValue: TDateTime;

for i:= 1 to ParamCount do
begin
  // If we don't have a valid date see if it looks like a different
  // normal date field.
  if TryStrToDate(Param[i], DateValue) = false then
    continue;

  // If the simple TryStrToDate does not work use the Variants function,
  // there is no "Try" version so catch the error here.
  try
    DateValue := VarToDateTime(Param[i]);
  except
    continue;
  end;

  // Use/Reformat DateValue here
 Param[i] := FormatDateTime('MM/DD/YYYY', DateValue);
end;
</code>```

Additional Information on using TFormatSettings

The TFormatSettings parameter can change if a date is interpreted to have the days or the month listed first. If you do not specify a Format Setting you will be using the Operating System Default. TryStrToDate looks at the short date format string to determine what order to expect. It looks at the string format for the first matching letter to decide on acceptable formats:

```<code>case Chr(Ord(DateFormat[I]) and $DF) of
  'E': Result := doYMD;
  'Y': Result := doYMD;
  'M': Result := doMDY;
  'D': Result := doDMY;
</code>```

Here is a test procedure that can show you the difference. You can create a FormatSettings based on a locale, or you can set the short date format directly.

```<code>procedure TForm7.Button3Click(Sender: TObject);
var
  s: string;
  d: TDateTime;
  FormatUS: TFormatSettings;
  FormatGB: TFormatSettings;
begin
  s := '5/10/2017';

  Memo1.Lines.Append('Testing GB');
  FormatGB := TFormatSettings.Create('en-GB');
  if TryStrToDate(s, d, FormatGB) = false then
  begin
    Memo1.Lines.Append(s + ' is not a valid date');
  end
  else
  begin
    Memo1.Lines.Append('Found Date: ' + FormatDateTime('dd MMMM YYYY', d));
    // will print: Found Date: 05 October 2017
  end;

  Memo1.Lines.Append('');
  Memo1.Lines.Append('Testing US');
  FormatUS := TFormatSettings.Create('en-US');
  if TryStrToDate(s, d, FormatUS) = false then
  begin
    Memo1.Lines.Append(s + ' is not a valid date');
  end
  else
  begin
    Memo1.Lines.Append('Found Date: ' + FormatDateTime('dd MMMM YYYY', d));
  end;

  Memo1.Lines.Append('');
  Memo1.Lines.Append('Testing with modified ShortDate Format');
  FormatUS.ShortDateFormat := 'yyyy/mm/dd';
  if TryStrToDate(s, d, FormatUS) = false then
  begin
    Memo1.Lines.Append(s + ' is not a valid date');
  end
  else
  begin
    Memo1.Lines.Append('Found Date: ' + FormatDateTime('dd MMMM YYYY', d));
  end;

end;
</code>```

The output will show:

Testing GB

  Found Date: 05 October 2017

Testing US

  Found Date: 10 May 2017

Testing with modified ShortDate Format

  5/10/2017 is not a valid date

Body:
I have array of string as mentioned below.

Param : array[1..5] of string = ('US','Dollor','27/03/2017','IND','INR');

I need to find the string which contains date and format it in MM/DD/YYYY.
To achieve this I am running for loop and passing each string in TryStrToDate. If string is of date type, it will return true and then I will format that string in desired format. My code is as below

 for i := 1 to ParamCount do
  begin
   if TryStrToDate(Param[i],DateValue)=true then
   begin
    Param[i] := DateToStr(StrToDate(Param[i]));
    ShowMessage(Param[i]);
   end;
 end;

Here date in Param[] is in DD/MM/YYYY so TryStrToDate is unable to understand. How can i change the code?
After this final result should be as below

Param : array[1..5] of string = ('US','Dollor','03/27/2017','IND','INR');

Used Mark's solution as below:

  GetLocaleFormatSettings(ALocID, AFormatSettings);
  AFormatSettings.ShortDateFormat := 'DD/MM/YYYY';
  for i := 1 to ParamCount do
  begin
    if TryStrToDate(param[i], DateValue, AFormatSettings) = False then
      Continue;
    try
      DateVal := StrToDate(param[i], AFormatSettings);
      param[i] := DateToStr(DateVal);
      Continue;
    except
      Continue;
    end;
  end;

Body:
TryStrToDate is a Delphi library function that will try to convert a string into a TDateTime type. In my code there were some formats that I wanted to accept that are not allowed by the TryStrToDate function. To convert those dates if the first method fails I call VarToDateTime. That calls a variant function that supports additional formats.

As Remy commented there is an option parameter of a TFormatSettings type that allows you some measure of control over the formats accepted. I still needed to use VarToDateTime in order to covert dates that spelled out the month instead of using numeric values.

var
  DateValue: TDateTime;

for i:= 1 to ParamCount do
begin
  // If we don't have a valid date see if it looks like a different
  // normal date field.
  if TryStrToDate(Param[i], DateValue) = false then
    continue;

  // If the simple TryStrToDate does not work use the Variants function,
  // there is no "Try" version so catch the error here.
  try
    DateValue := VarToDateTime(Param[i]);
  except
    continue;
  end;

  // Use/Reformat DateValue here
 Param[i] := FormatDateTime('MM/DD/YYYY', DateValue);
end;

Additional Information on using TFormatSettings

The TFormatSettings parameter can change if a date is interpreted to have the days or the month listed first. If you do not specify a Format Setting you will be using the Operating System Default. TryStrToDate looks at the short date format string to determine what order to expect. It looks at the string format for the first matching letter to decide on acceptable formats:

case Chr(Ord(DateFormat[I]) and $DF) of
  'E': Result := doYMD;
  'Y': Result := doYMD;
  'M': Result := doMDY;
  'D': Result := doDMY;

Here is a test procedure that can show you the difference. You can create a FormatSettings based on a locale, or you can set the short date format directly.

procedure TForm7.Button3Click(Sender: TObject);
var
  s: string;
  d: TDateTime;
  FormatUS: TFormatSettings;
  FormatGB: TFormatSettings;
begin
  s := '5/10/2017';

  Memo1.Lines.Append('Testing GB');
  FormatGB := TFormatSettings.Create('en-GB');
  if TryStrToDate(s, d, FormatGB) = false then
  begin
    Memo1.Lines.Append(s + ' is not a valid date');
  end
  else
  begin
    Memo1.Lines.Append('Found Date: ' + FormatDateTime('dd MMMM YYYY', d));
    // will print: Found Date: 05 October 2017
  end;

  Memo1.Lines.Append('');
  Memo1.Lines.Append('Testing US');
  FormatUS := TFormatSettings.Create('en-US');
  if TryStrToDate(s, d, FormatUS) = false then
  begin
    Memo1.Lines.Append(s + ' is not a valid date');
  end
  else
  begin
    Memo1.Lines.Append('Found Date: ' + FormatDateTime('dd MMMM YYYY', d));
  end;

  Memo1.Lines.Append('');
  Memo1.Lines.Append('Testing with modified ShortDate Format');
  FormatUS.ShortDateFormat := 'yyyy/mm/dd';
  if TryStrToDate(s, d, FormatUS) = false then
  begin
    Memo1.Lines.Append(s + ' is not a valid date');
  end
  else
  begin
    Memo1.Lines.Append('Found Date: ' + FormatDateTime('dd MMMM YYYY', d));
  end;

end;

The output will show:

Testing GB

  Found Date: 05 October 2017

Testing US

  Found Date: 10 May 2017

Testing with modified ShortDate Format

  5/10/2017 is not a valid date