问:
Xcode 8 Fastlane build with TeamCity codesign failed with exit code 1
I've got a weird serious problem with Xcode 8.3.2 on macOS Sierra. I could build the app locally on build machine with fastlane or manually executing commands. Both development and ad-hoc build can be created locally.

```<code> $ fastlane <lane_name>
</code>```

But when tried the same from TeamCity it throws following error.

```<code> [exec]/usr/bin/codesign --force --sign 5609CEE02FBF256EDBF60DB28C1A2995A2153B5B --entitlements /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/IntermediateBuildFilesPath/<AppName>.build/Release-iphoneos/<AppName>.build/<AppName>.app.xcent --timestamp=none /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app
 [exec] /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app: unknown error -1=ffffffffffffffff
 [exec] Command /usr/bin/codesign failed with exit code 1
 [exec]
 [exec] ** ARCHIVE FAILED **
 [exec]
 [exec]
 [exec] The following build commands failed:
 [exec]     CodeSign /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/<AppName>/InstallationBuildProductsLocation/Applications/SabaMeeting.app
 [exec] (1 failure)
</code>```

TeamCity pulls the code and even executes the commands but fails.
           Build Step: Command Line is set TeamCity with a custom script.
Tried following ways but not working:

Xcode Preferences ->Accounts->Delete already added account and add it again

Generated new Distribution and Developer Certificate and installed in KeyChain. New Provisioning Profiles and installed in Xcode.

Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.

Reinstalled xcode 8.3.2, restarted the machine.

Apple Worldwide Developer Relations Certificate Authority is installed.

Verified resource fork, finder information, or similar detritus not allowed in the app and derived data directory. https://developer.apple.com/library/content/qa/qa1940/_index.html

The project doesn't use CocoaPods.

Tried clearing DerivedData.

Any many more r&d. Any help will be appreciated.

答:
How does your lane look like on your fastfile? Please share it...

My guess;

3 Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.

Teamcity is probably not accessing to your certificates and failing.

Try this;

Move certificates back to login from system.

Add following before your gym or whatever fastlane command is building the .ipa. This will let teamcity unlock and access to keychain.

lane :beta do |options|

```<code>  unlock_keychain(path:"login.keychain", password:"yoursystempassword")
  sh "security set-keychain-settings -t 3600 -l ~/Library/Keychains/login.keychain"
  gym(scheme: "yourapp", workspace:"probably you dont have a wokrspace so no need")
end
</code>```

Body:
I've got a weird serious problem with Xcode 8.3.2 on macOS Sierra. I could build the app locally on build machine with fastlane or manually executing commands. Both development and ad-hoc build can be created locally.

 $ fastlane <lane_name>

But when tried the same from TeamCity it throws following error.

 [exec]/usr/bin/codesign --force --sign 5609CEE02FBF256EDBF60DB28C1A2995A2153B5B --entitlements /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/IntermediateBuildFilesPath/<AppName>.build/Release-iphoneos/<AppName>.build/<AppName>.app.xcent --timestamp=none /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app
 [exec] /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app: unknown error -1=ffffffffffffffff
 [exec] Command /usr/bin/codesign failed with exit code 1
 [exec]
 [exec] ** ARCHIVE FAILED **
 [exec]
 [exec]
 [exec] The following build commands failed:
 [exec]     CodeSign /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/<AppName>/InstallationBuildProductsLocation/Applications/SabaMeeting.app
 [exec] (1 failure)

TeamCity pulls the code and even executes the commands but fails.
           Build Step: Command Line is set TeamCity with a custom script.
Tried following ways but not working:

Xcode Preferences ->Accounts->Delete already added account and add it again

Generated new Distribution and Developer Certificate and installed in KeyChain. New Provisioning Profiles and installed in Xcode.

Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.

Reinstalled xcode 8.3.2, restarted the machine.

Apple Worldwide Developer Relations Certificate Authority is installed.

Verified resource fork, finder information, or similar detritus not allowed in the app and derived data directory. https://developer.apple.com/library/content/qa/qa1940/_index.html

The project doesn't use CocoaPods.

Tried clearing DerivedData.

Any many more r&d. Any help will be appreciated.

Body:
How does your lane look like on your fastfile? Please share it...

My guess;

3 Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.

Teamcity is probably not accessing to your certificates and failing.

Try this;

Move certificates back to login from system.

Add following before your gym or whatever fastlane command is building the .ipa. This will let teamcity unlock and access to keychain.

lane :beta do |options|

  unlock_keychain(path:"login.keychain", password:"yoursystempassword")
  sh "security set-keychain-settings -t 3600 -l ~/Library/Keychains/login.keychain"
  gym(scheme: "yourapp", workspace:"probably you dont have a wokrspace so no need")
end


来源: stackexchange

问:
Why do we need lseek when pread accepts offset value?
I am having trouble to understand why lseek function is useful.
Assuming I got a parameter like this given to me from the user:

```<code>off_t offset = 10;
</code>```

And I wanted to read from the offset 100 bytes.
I can use pread like this:

```<code>void * buf = malloc(100);
if (buf == NULL) { exit(1);}
int res = pread(file_id, buf, 100, offset);
</code>```

On the other hand, I understand I can set the file with lseek like this:

```<code>off_t seek = lseek(file_id, offset, SEEK_SET);
</code>```

So I believe I achieve reading using pread already. What did I miss regarding lseek in what it can do to help me read the file?

答:
A function may have to read/write from/to a given file handle at a location that is not known to it (say current position), so you need to uncouple seeking from reading (or writing) because the caller may have a need to set the location.

More generally, many I/Os are just sequential so seeking is not necessary, while pread forces seeking.

ContentLicense: CC BY-SA 3.0

Body:
I am having trouble to understand why lseek function is useful.
Assuming I got a parameter like this given to me from the user:

off_t offset = 10;

And I wanted to read from the offset 100 bytes.
I can use pread like this:

void * buf = malloc(100);
if (buf == NULL) { exit(1);}
int res = pread(file_id, buf, 100, offset);

On the other hand, I understand I can set the file with lseek like this:

off_t seek = lseek(file_id, offset, SEEK_SET);

So I believe I achieve reading using pread already. What did I miss regarding lseek in what it can do to help me read the file?


问:
How do I compare current time to a preset time in PHP?
I want PHP to check if it's 8:30 AM and if it is, I want it to change a variable.
I tried,

```<code>$eightthirtyam = "08:30:00";
if(time() >= strtotime($eightthirtyam )){
    $refresh = true;
}
</code>```

But the boolean doesn't change. Any idea what I did wrong?

答:
This will help you:

```<code>date_default_timezone_set('Asia/Kolkata');
$eightthirtyam = "08:30:00";
$refresh = false;
if(strtotime(date('H:i:s') == strtotime($eightthirtyam )){
    $refresh = true;
}
</code>```

Reference:-/ strtotime

Body:
I want PHP to check if it's 8:30 AM and if it is, I want it to change a variable.
I tried,

$eightthirtyam = "08:30:00";
if(time() >= strtotime($eightthirtyam )){
    $refresh = true;
}

But the boolean doesn't change. Any idea what I did wrong?

Body:
This will help you:

date_default_timezone_set('Asia/Kolkata');
$eightthirtyam = "08:30:00";
$refresh = false;
if(strtotime(date('H:i:s') == strtotime($eightthirtyam )){
    $refresh = true;
}

Reference:-/ strtotime


问:
Controlling Browser using Python?
Is it possible to control a web browser like Firefox using Python?

I would want to do things like

launch the browser

force clicks on URLs

take screenshots

etc.

答: The question is a bit old but I see no references to pywebkitgtk, you should give it a try. I developed spynner using the pyqt.qtwebkit bindings, but programmers who prefer pygtk should try pywebketgtk (which feels more pythonic to me). Note though that Qt bindings are more complete (or at least it was last time I checked).</p>

ContentLicense: CC BY-SA 2.5

Title: Controlling Browser using Python?


问:
React JS event handler arguments
I was reading about "Lifting State Up" in React JS documentation and there is something I am not very clear about. The codepen can be found here: https://codepen.io/valscion/pen/jBNjja?editors=0010

In the TemperatureInput component, the onTemperatureChange event handler calls the handleCelsiusChange, but the latter contains a parameter of temperature. How are we passing this parameter? There is no argument passed in the onTemperatureChange. What am I missing here?

Hope someone can help me understand this.

```<code>class TemperatureInput extends React.Component {
  constructor(props) {
    super(props);
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(e) {
    this.props.onTemperatureChange(e.target.value);
  }

  render() {
    const temperature = this.props.temperature;
    const scale = this.props.scale;
    return (
      <fieldset>
        <legend>Enter temperature in {scaleNames[scale]}:</legend>
        <input value={temperature}
               onChange={this.handleChange} />
      </fieldset>
    );
  }
}
</code>```

```<code>class Calculator extends React.Component {
  constructor(props) {
    super(props);
    this.handleCelsiusChange = this.handleCelsiusChange.bind(this);
    this.handleFahrenheitChange = this.handleFahrenheitChange.bind(this);
    this.state = {temperature: '', scale: 'c'};
  }

  handleCelsiusChange(temperature) {
    this.setState({scale: 'c', temperature});
  }

  handleFahrenheitChange(temperature) {
    this.setState({scale: 'f', temperature});
  }

  render() {
    const scale = this.state.scale;
    const temperature = this.state.temperature;
    const celsius = scale === 'f' ? tryConvert(temperature, toCelsius) : temperature;
    const fahrenheit = scale === 'c' ? tryConvert(temperature, toFahrenheit) : temperature;

    return (
      <div>
        <TemperatureInput
          scale="c"
          temperature={celsius}
          onTemperatureChange={this.handleCelsiusChange} />
        <TemperatureInput
          scale="f"
          temperature={fahrenheit}
          onTemperatureChange={this.handleFahrenheitChange} />
        <BoilingVerdict
          celsius={parseFloat(celsius)} />
      </div>
    );
  }
}
</code>```

答:
Let's look at the TemperatureInput component first. When its input element fires a change event, this is handled by handleChange(e) (declared within the TemperatureInput component). You'll notice that it then calls this.props.onTemperatureChange with the parameter e.target.value (this is the value attribute of the input element).

Where does this.props.onTemperatureChange come from? It's set by the parent component Calculator that instantiates it. Looking at the render method of the Calculator component, you'll notice that the onTemperatureChange prop for each TemperatureInput instance is set to this.handle[Cel/Far]Change (both methods declared within the Calculator component).

So when the TemperatureInput component calls this.props.onTemperatureChange, it is in fact calling the handle[Cel/Far]Change method of the Calculator component.

Title: React JS event handler arguments

Body:
I was reading about "Lifting State Up" in React JS documentation and there is something I am not very clear about. The codepen can be found here: https://codepen.io/valscion/pen/jBNjja?editors=0010

In the TemperatureInput component, the onTemperatureChange event handler calls the handleCelsiusChange, but the latter contains a parameter of temperature. How are we passing this parameter? There is no argument passed in the onTemperatureChange. What am I missing here?

Hope someone can help me understand this.

class TemperatureInput extends React.Component {
  constructor(props) {
    super(props);
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(e) {
    this.props.onTemperatureChange(e.target.value);
  }

  render() {
    const temperature = this.props.temperature;
    const scale = this.props.scale;
    return (
      <fieldset>
        <legend>Enter temperature in {scaleNames[scale]}:</legend>
        <input value={temperature}
               onChange={this.handleChange} />
      </fieldset>
    );
  }
}

class Calculator extends React.Component {
  constructor(props) {
    super(props);
    this.handleCelsiusChange = this.handleCelsiusChange.bind(this);
    this.handleFahrenheitChange = this.handleFahrenheitChange.bind(this);
    this.state = {temperature: '', scale: 'c'};
  }

  handleCelsiusChange(temperature) {
    this.setState({scale: 'c', temperature});
  }

  handleFahrenheitChange(temperature) {
    this.setState({scale: 'f', temperature});
  }

  render() {
    const scale = this.state.scale;
    const temperature = this.state.temperature;
    const celsius = scale === 'f' ? tryConvert(temperature, toCelsius) : temperature;
    const fahrenheit = scale === 'c' ? tryConvert(temperature, toFahrenheit) : temperature;

    return (

        <TemperatureInput
          scale="c"
          temperature={celsius}
          onTemperatureChange={this.handleCelsiusChange} />
        <TemperatureInput
          scale="f"
          temperature={fahrenheit}
          onTemperatureChange={this.handleFahrenheitChange} />
        <BoilingVerdict
          celsius={parseFloat(celsius)} />

    );
  }
}


问:
Can't update ionic cordova / ionic 2
```<code>npm update -g ionic cordova
</code>```

As title says it won't let update it. I even ran cmd as admin in case I didn't have access to all the files for cordova/node/ionic.
I'm stressing over this because I need to use ionic 2 for college and my ionic is version 2.1.1.

答:
Firstly update node js

Clear NPM's cache:

```<code>sudo npm cache clean -f
</code>```

Install a little helper called 'n'

```<code>sudo npm install -g n
</code>```

Install latest stable Node.js version

```<code>sudo n stable
</code>```

Now Install Ionic

```<code>npm install -g cordova ionic
</code>```

Try uninstalling and installing again if not works

Title: Can't update ionic cordova / ionic 2

Body:
npm update -g ionic cordova

As title says it won't let update it. I even ran cmd as admin in case I didn't have access to all the files for cordova/node/ionic.
I'm stressing over this because I need to use ionic 2 for college and my ionic is version 2.1.1.

Body:
Firstly update node js

Clear NPM's cache:

sudo npm cache clean -f

Install a little helper called 'n'

sudo npm install -g n

Install latest stable Node.js version

sudo n stable

Now Install Ionic

npm install -g cordova ionic

Try uninstalling and installing again if not works


问:
The jquery $.each function console.log(this) ,prints result is string like "a" 'b' 'c'
```<code>var arr=["aaa","bbb","cccc"];
$.each(arr,function(a,b){
    console.log(this);
})
</code>```

the result is in the Chrome console following :

the Chrome console

i think the result is "aaa" "bbb","cccc",why the result is "a" "a" "a" 'b''b''b'....

答: The result in your provided image is correct. The console only displays the individual characters of the string and its length information, but if you look at the actual value (the primitive value), it indeed displays "aaa", "bbb", and "cccc".</p>

Body:
var arr=["aaa","bbb","cccc"];
$.each(arr,function(a,b){
    console.log(this);
})

the result is in the Chrome console following :

the Chrome console

i think the result is "aaa" "bbb","cccc",why the result is "a" "a" "a" 'b''b''b'....


答:
```<code>$hr= date('H:i');

  if(strtotime($hr)==strtotime(08:30)  ){
    $refresh = true;
  }
</code>```

Please try this way. It will work i your case.

Title: How do I compare current time to a preset time in PHP?

Body:
$hr= date('H:i');

  if(strtotime($hr)==strtotime(08:30)  ){
    $refresh = true;
  }

Please try this way. It will work i your case.


问:
Upload file using AJAX in CodeIgniter Still executed even the value is null/undefined
I want to execute another ajax if the file is not input yet. But it still posting the form action.

Here is my view code :

```<code><form method="POST" id="quiz_file" action="<?php echo site_url('home/upload_quiz/' . $kelas);?>" enctype="multipart/form-data">
   <input name="filequiz" id="filequiz" type="file" />
</form>
</code>```

And this is my JS :

```<code>$('#submitquiz').on('click', function(event) {
  var inputFile = $('input[name=filequiz]');
  document.getElementById('submitquiz').disabled = true;
  var fileToUpload = inputFile[0].files[0];
  // make sure there is file to upload
  if (undefined != fileToUpload)
  {
     var uploadURI = $('#quiz_file').attr('action');
     var formData = new FormData();
     formData.append("file", fileToUpload);
     alert('if');
     $.ajax({
        url: uploadURI,
        type: 'post',
        data:
        {
            formData : formData,
            asid : asid_quiz,
            value : cmbValue
        },
        processData: false,
        contentType: false,
        success: function(data)
        {

        }
    });
 }
 else
 {
   alert('else');
   $.ajax(
   {
     type: 'POST',
     url:'<?php echo site_url("home/assignment_score"); ?>',
     data:
     {
        asid : asid_quiz,
        value : cmbvalue,
        kelas : <?php echo $kelas;?>,
        dataType:"JSON"
     },
     success: function(data)
     {
        console.log('asdasd' + data);
        alert('Quiz score submitted');
     }
 });
</code>```

When i just executed it, it show alert message "else". But it still perform the upload action from form action.

How this could be happen ? How to stop performing the upload action and perform the another ajax request in  that 'else' side ?

答:
If your submitquiz button type is submit you have to prevent submit event on click or you can change it to input type button.

I prefer you too if you are send data using ajax then you have to use input button instead of submit

```<code>$('#submitquiz').on('click', function(event) {
event.preventDefault();
</code>```

Body:
I want to execute another ajax if the file is not input yet. But it still posting the form action.

Here is my view code :

<form method="POST" id="quiz_file" action="<?php echo site_url('home/upload_quiz/' . $kelas);?>" enctype="multipart/form-data">
   <input name="filequiz" id="filequiz" type="file" />
</form>

And this is my JS :

$('#submitquiz').on('click', function(event) {
  var inputFile = $('input[name=filequiz]');
  document.getElementById('submitquiz').disabled = true;
  var fileToUpload = inputFile[0].files[0];
  // make sure there is file to upload
  if (undefined != fileToUpload)
  {
     var uploadURI = $('#quiz_file').attr('action');
     var formData = new FormData();
     formData.append("file", fileToUpload);
     alert('if');
     $.ajax({
        url: uploadURI,
        type: 'post',
        data:
        {
            formData : formData,
            asid : asid_quiz,
            value : cmbValue
        },
        processData: false,
        contentType: false,
        success: function(data)
        {

        }
    });
 }
 else
 {
   alert('else');
   $.ajax(
   {
     type: 'POST',
     url:'<?php echo site_url("home/assignment_score"); ?>',
     data:
     {
        asid : asid_quiz,
        value : cmbvalue,
        kelas : <?php echo $kelas;?>,
        dataType:"JSON"
     },
     success: function(data)
     {
        console.log('asdasd' + data);
        alert('Quiz score submitted');
     }
 });

When i just executed it, it show alert message "else". But it still perform the upload action from form action.

How this could be happen ? How to stop performing the upload action and perform the another ajax request in  that 'else' side ?

Body:
If your submitquiz button type is submit you have to prevent submit event on click or you can change it to input type button.

I prefer you too if you are send data using ajax then you have to use input button instead of submit

$('#submitquiz').on('click', function(event) {
event.preventDefault();


问:
Slow git rev-list when iterating git commit history over time intervals
I wrote a tool that uses git rev-list -n1 --before=X to iterate a Git commit history using fixed time intervals, so that I see the last revision for every year, month, etc.

The problem is that rev-list kicks off a new revision walk on every call, and it takes longer the father back I go. Here are some samples from the Linux kernel source.

```<code>$ time git rev-list -n1 --before="Jan 1 2016" HEAD
a889331d759453fa7f424330f75ae4e2b9e02db4

real    0m1.395s
user    0m1.367s
sys 0m0.024s

$ time git rev-list -n1 --before="Jan 1 2015" HEAD
5b5e76218fbdbb71a01d5480f289ead624232876

real    0m2.349s
user    0m2.306s
sys 0m0.036s

$ time git rev-list -n1 --before="Jan 1 2005" HEAD

real    0m5.556s
user    0m5.435s
sys 0m0.105s
</code>```

If I want to call rev-list in a loop over N decreasing dates, that loop runs N walks that take longer on every iteration. The docs talk about bit-maps and object traversal strategies to speed up the history, but I am having trouble understanding them. I tried git repack -ab followed by git rev-list --use-bitmap-index, but that didn't improve results.

My only requirement is that given any position for HEAD, I can accurately pinpoint the first revision that appears before the date given to --before, following paths to ancestors if needed.

What is the best way to make rev-list faster for this use case?

答:
In the general case, there is no alternative to these two options:

pay the full cost of the walk, or

store much more information than git rev-list emits when you just ask for one node

because the graph walk effectively linearizes (via a priority queue, with the dates as the priorities) an arbitrarily bushy tree (this "tree" is formed by cutting off rejoins, by simply not re-visiting any already-visited node in the DAG).  For instance, suppose we have a commit DAG that looks much like this.  Assume all the directional arcs point left-ish (directly left, or up-and-left, or down-and-left).

```<code>       A-....--o
      /         \
...--o----...----o   <-- HEAD
      \         /
       B--...--o
</code>```

where there are any number of nodes anywhere there are two or three dots.  One of your selections might pick node A as the first one visited that meets the --before criteria.  Node B might come earlier than A and hence might be one selected by an earlier --before that starts from HEAD (since node B is reachable from HEAD).  But node B is not reachable from node A, so by simply starting from node A, you will never find node B.

If you somehow had git rev-list dump out its current priority queue contents (plus information about all the nodes it had visited thus far—though this is not, in the end, required to get the same results; that would just be an option for potentially speeding up some node-trimming) you could restart its graph-walk operation from those points in order to search for B, and thereby avoid revisiting many of the nodes in the large mesh-y area above.

If you strongly limit the graph walk, though, e.g., using --first-parent, you can simply restart the walk from the most-recently-found commit, since you know that the queue depth is always 1 and therefore the next node to visit is the first parent of the node you found earlier (which you can leave to git rev-list).

Body:
I wrote a tool that uses git rev-list -n1 --before=X to iterate a Git commit history using fixed time intervals, so that I see the last revision for every year, month, etc.

The problem is that rev-list kicks off a new revision walk on every call, and it takes longer the father back I go. Here are some samples from the Linux kernel source.

$ time git rev-list -n1 --before="Jan 1 2016" HEAD
a889331d759453fa7f424330f75ae4e2b9e02db4

real    0m1.395s
user    0m1.367s
sys 0m0.024s

$ time git rev-list -n1 --before="Jan 1 2015" HEAD
5b5e76218fbdbb71a01d5480f289ead624232876

real    0m2.349s
user    0m2.306s
sys 0m0.036s

$ time git rev-list -n1 --before="Jan 1 2005" HEAD

real    0m5.556s
user    0m5.435s
sys 0m0.105s

If I want to call rev-list in a loop over N decreasing dates, that loop runs N walks that take longer on every iteration. The docs talk about bit-maps and object traversal strategies to speed up the history, but I am having trouble understanding them. I tried git repack -ab followed by git rev-list --use-bitmap-index, but that didn't improve results.

My only requirement is that given any position for HEAD, I can accurately pinpoint the first revision that appears before the date given to --before, following paths to ancestors if needed.

What is the best way to make rev-list faster for this use case?

Body:
In the general case, there is no alternative to these two options:

pay the full cost of the walk, or

store much more information than git rev-list emits when you just ask for one node

because the graph walk effectively linearizes (via a priority queue, with the dates as the priorities) an arbitrarily bushy tree (this "tree" is formed by cutting off rejoins, by simply not re-visiting any already-visited node in the DAG).  For instance, suppose we have a commit DAG that looks much like this.  Assume all the directional arcs point left-ish (directly left, or up-and-left, or down-and-left).

       A-....--o
      /         \
...--o----...----o   <-- HEAD
      \         /
       B--...--o

where there are any number of nodes anywhere there are two or three dots.  One of your selections might pick node A as the first one visited that meets the --before criteria.  Node B might come earlier than A and hence might be one selected by an earlier --before that starts from HEAD (since node B is reachable from HEAD).  But node B is not reachable from node A, so by simply starting from node A, you will never find node B.

If you somehow had git rev-list dump out its current priority queue contents (plus information about all the nodes it had visited thus far—though this is not, in the end, required to get the same results; that would just be an option for potentially speeding up some node-trimming) you could restart its graph-walk operation from those points in order to search for B, and thereby avoid revisiting many of the nodes in the large mesh-y area above.

If you strongly limit the graph walk, though, e.g., using --first-parent, you can simply restart the walk from the most-recently-found commit, since you know that the queue depth is always 1 and therefore the next node to visit is the first parent of the node you found earlier (which you can leave to git rev-list).


问:
What does Java do with my "equals" implementations here?
Today, I've stumbled over the following:

Consider two classes NewClass and NewClass1, which have the following "equals"-methods:

NewClass:

```<code>@Override
public boolean equals(Object obj) {
    return false;
}

public boolean equals(NewClass obj) {
    return value == obj.getValue();
}
</code>```

NewClass1:

```<code>@Override
public boolean equals(Object obj) {
    if(!(obj instanceof NewClass1)) {
        return false;
    }
    return equals((NewClass1) obj);
}

public boolean equals(NewClass1 obj) {
    return value == obj.getValue();
}
</code>```

What I find weird is that the equals in NewClass1 seems to be exponentially slower than the one in NewClass (for 10.000.000 calls 14ms against 3000ms). At first, I thought this was related to the "instanceof" check, but if I replace "return equals((NewClass1) obj);" with "return false;" in NewClass1, suddenly it runs more or less equally fast. I don't really understand what is happening here, because in my opinion, the return statement in equals(Object) should never actually be called. What am I getting wrong here?

The following is my "benchmarking code", in case I made some mistake there:

```<code>public static void main(String[] args) {
    // TODO code application logic here

    NewClass i1 = new NewClass(1);
    NewClass i2 = new NewClass(1);
    NewClass i3 = new NewClass(5);

    NewClass1 j1 = new NewClass1(1);
    NewClass1 j2 = new NewClass1(1);
    NewClass1 j3 = new NewClass1(5);

    Object o1 = new Object();
    Object o2 = new Object();

    assert(i1.equals(i1));
    assert(i1.equals(i2));
    assert(i1.equals(i3) == false);
    assert(i1.equals(o1) == false);

    assert(j1.equals(j1));
    assert(j1.equals(j2));
    assert(j1.equals(j3) == false);
    assert(j1.equals(o1) == false);

    long start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        i1.equals(i1);
        i1.equals(i2);
        i1.equals(o1);
        i1.equals(o2);
    }

    long end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");

    start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        j1.equals(j1);
        j1.equals(j2);
        j1.equals(o1);
        j1.equals(o2);
    }

    end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");
}
</code>```

答: Well, the first example does nearly nothing.. You can descrease the iteration number to 100000, again you get the same result, 5 or 6 ms. It means that JVM optimizes aggressively that part of your code. </p>

Body:
Today, I've stumbled over the following:

Consider two classes NewClass and NewClass1, which have the following "equals"-methods:

NewClass:

@Override
public boolean equals(Object obj) {
    return false;
}

public boolean equals(NewClass obj) {
    return value == obj.getValue();
}

NewClass1:

@Override
public boolean equals(Object obj) {
    if(!(obj instanceof NewClass1)) {
        return false;
    }
    return equals((NewClass1) obj);
}

public boolean equals(NewClass1 obj) {
    return value == obj.getValue();
}

What I find weird is that the equals in NewClass1 seems to be exponentially slower than the one in NewClass (for 10.000.000 calls 14ms against 3000ms). At first, I thought this was related to the "instanceof" check, but if I replace "return equals((NewClass1) obj);" with "return false;" in NewClass1, suddenly it runs more or less equally fast. I don't really understand what is happening here, because in my opinion, the return statement in equals(Object) should never actually be called. What am I getting wrong here?

The following is my "benchmarking code", in case I made some mistake there:

public static void main(String[] args) {
    // TODO code application logic here

    NewClass i1 = new NewClass(1);
    NewClass i2 = new NewClass(1);
    NewClass i3 = new NewClass(5);

    NewClass1 j1 = new NewClass1(1);
    NewClass1 j2 = new NewClass1(1);
    NewClass1 j3 = new NewClass1(5);

    Object o1 = new Object();
    Object o2 = new Object();

    assert(i1.equals(i1));
    assert(i1.equals(i2));
    assert(i1.equals(i3) == false);
    assert(i1.equals(o1) == false);

    assert(j1.equals(j1));
    assert(j1.equals(j2));
    assert(j1.equals(j3) == false);
    assert(j1.equals(o1) == false);

    long start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        i1.equals(i1);
        i1.equals(i2);
        i1.equals(o1);
        i1.equals(o2);
    }

    long end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");

    start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        j1.equals(j1);
        j1.equals(j2);
        j1.equals(o1);
        j1.equals(o2);
    }

    end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");
}


问:
MySql Insert Query Problem
Whats wrong with insert query.

```<code>$result = $conn->query("insert into user (fullname,username,email,passwd) values
        ('".$data['fullname']."','".$data['username']."','".$data['email']."','".$data['fullname']."') " );
 if(!$result) {
    throw new Exception('Could not register you in database - please try again later.');
}
</code>```

thanks

答:
Check the message returned by MySQL via mysql_error/mysqli::error or add this to the end of your MySQL query to see the error on the browser.

```<code>die(mysql_error())
</code>```

Secondly it looks like you are inputting in the wrong field or column

Title: MySql Insert Query Problem

Body:
Whats wrong with insert query.

$result = $conn->query("insert into user (fullname,username,email,passwd) values
        ('".$data['fullname']."','".$data['username']."','".$data['email']."','".$data['fullname']."') " );
 if(!$result) {
    throw new Exception('Could not register you in database - please try again later.');
}

thanks

Body:
Check the message returned by MySQL via mysql_error/mysqli::error or add this to the end of your MySQL query to see the error on the browser.

die(mysql_error())

Secondly it looks like you are inputting in the wrong field or column


问:
How to calculate the difference between two dates using PHP?
I have two dates of the form:

```<code>Start Date: 2007-03-24
End Date: 2009-06-26
</code>```

Now I need to find the difference between these two in the following form:

```<code>2 years, 3 months and 2 days
</code>```

How can I do this in PHP?

答:
For php version >=5.3 : Create two date objects and then use date_diff() function. It will return php DateInterval object. see documentation

```<code>$date1=date_create("2007-03-24");
$date2=date_create("2009-06-26");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");
</code>```

OwnerDisplayName: gnanesh

Body:
I have two dates of the form:

Start Date: 2007-03-24
End Date: 2009-06-26

Now I need to find the difference between these two in the following form:

2 years, 3 months and 2 days

How can I do this in PHP?

Body:
For php version >=5.3 : Create two date objects and then use date_diff() function. It will return php DateInterval object. see documentation

$date1=date_create("2007-03-24");
$date2=date_create("2009-06-26");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");


问:
Cannot see trace details in zipkin
we are using elasticsearch as the storage of zipkin, the dependency are as follows:

```<code><dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>

    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-ui</artifactId>
        <version>1.26.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-server</artifactId>
        <version>1.26.0</version>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-elasticsearch</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <version>1.26.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-jmx</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin</artifactId>
    </dependency>
</dependencies>
</code>```

now, trace log was storaged in elasticsearch, and we can see trance spans in the zipkin ui,but cannot to see span details or find trace via traceid,with the exception of :

```<code>java.lang.AbstractMethodError: zipkin.storage.guava.InternalGuavaToAsyncSpanStoreAdapter.getTrace(JJLzipkin/storage/Callback;)V
    at zipkin.storage.InternalAsyncToBlockingSpanStoreAdapter.getTrace(InternalAsyncToBlockingSpanStoreAdapter.java:41) ~[zipkin-1.19.2.jar:na]
    at zipkin.server.ZipkinQueryApiV1.getTrace(ZipkinQueryApiV1.java:118) ~[zipkin-server-1.26.0.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:108) ~[spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.cloud.sleuth.instrument.web.TraceFilter.doFilter(TraceFilter.java:145) ~[spring-cloud-sleuth-core-1.2.0.RELEASE.jar:1.2.0.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106) ~[spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
</code>```

答:
The problem is casued by two reasons. First:just as Rafael Winterhalter said the version dismatched; second: you are lacking dependency for zipkin. Finally i fixed the problem by adding the whole 'io.zipkin.java:zipkin" library. Here is my final pom file with the storage type of elasticsearch:</p>

```<code> <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-storage-elasticsearch</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jmx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
        </dependency>
    </dependencies>
</code>```

Title: Cannot see trace details in zipkin

Body:
we are using elasticsearch as the storage of zipkin, the dependency are as follows:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>

    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-ui</artifactId>
        <version>1.26.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-server</artifactId>
        <version>1.26.0</version>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-elasticsearch</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <version>1.26.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-jmx</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin</artifactId>
    </dependency>
</dependencies>

now, trace log was storaged in elasticsearch, and we can see trance spans in the zipkin ui,but cannot to see span details or find trace via traceid,with the exception of :

java.lang.AbstractMethodError: zipkin.storage.guava.InternalGuavaToAsyncSpanStoreAdapter.getTrace(JJLzipkin/storage/Callback;)V
    at zipkin.storage.InternalAsyncToBlockingSpanStoreAdapter.getTrace(InternalAsyncToBlockingSpanStoreAdapter.java:41) ~[zipkin-1.19.2.jar:na]
    at zipkin.server.ZipkinQueryApiV1.getTrace(ZipkinQueryApiV1.java:118) ~[zipkin-server-1.26.0.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:108) ~[spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.cloud.sleuth.instrument.web.TraceFilter.doFilter(TraceFilter.java:145) ~[spring-cloud-sleuth-core-1.2.0.RELEASE.jar:1.2.0.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106) ~[spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

Body:
The problem is casued by two reasons. First:just as Rafael Winterhalter said the version dismatched; second: you are lacking dependency for zipkin. Finally i fixed the problem by adding the whole 'io.zipkin.java:zipkin" library. Here is my final pom file with the storage type of elasticsearch:

 <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-storage-elasticsearch</artifactId>
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jmx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
        </dependency>
    </dependencies>


问:
add new row in gridview
UPDATE

from this i bind gridview

```<code>Public Function uplif() As DataTable
        Dim dt As New DataTable()
        gridvieew1.Visible = True

        Try

            dt.Columns.AddRange(New DataColumn(1) {New DataColumn("ID", GetType(Integer)),
                                                   New DataColumn("Name", GetType(String))}
            Dim Content As String = Request.Form(textbox1.UniqueID)
            For Each row As String In Content .Split(ControlChars.Lf)
                If Not String.IsNullOrEmpty(row) Then
                    dt.Rows.Add()
                    Dim i As Integer = 0
                    For Each cell As String In row.Split(ControlChars.Tab)
                        If i > 1 Then
                            labelmessage.Text = "More than 2 columns not Allowed !!"
                            textbox1.Text = ""
                        Else
                            If cell.Trim() = "" Then
                                cell = "0"
                            End If
                            dt.Rows(dt.Rows.Count - 1)(i) = cell
                            i += 1
                        End If
                    Next
                End If
            Next
             gridvieew1.DataSource = dt
             gridvieew1.DataBind()

        Catch Ex As Exception
            labelmessage.CssClass = "alertNo"
            labelmessage.Text = Ex.Message
        End Try
        Return dt
    End Function

  Protected Sub PasteToGridView(sender As Object, e As EventArgs)
        uplif()

    End Sub
</code>```

now when i try to add new row like this

```<code>Private Sub AddNewRowToGrid()
        Dim dt As DataTable = uplif()
        Dim NewRow As DataRow = dt.NewRow()
        dt.Rows.Add(NewRow)
         gridvieew1.DataSource = dt
         gridvieew1.DataBind()
    End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        AddNewRowToGrid()
    End Sub
</code>```

this shows same output like add new row and replace previous data which is already in gridview and also this shows an error
Object reference not set to an instance of an object.

after click on add new row

```<code>ID Name
</code>```

where as i want like this

```<code>ID Name
1  abc
2  def
(here new empty row when click on button )
</code>```

答:
As was pointed out in a comment to your post, the problem is in these two lines:

```<code>Dim dt As New DataTable()
...
gridview1.DataSource = dt
</code>```

That creates a brand new DataTable and binds the grid view to it.  You don't copy data over, and you don't alter the existing gridview's table.

The correct fix here would be to get the DataTable from the gridview's DataSource and make any changes you need to to that.  Don't create a new DataTable.

Title: add new row in gridview

Body:
UPDATE

from this i bind gridview

Public Function uplif() As DataTable
        Dim dt As New DataTable()
        gridvieew1.Visible = True

        Try

            dt.Columns.AddRange(New DataColumn(1) {New DataColumn("ID", GetType(Integer)),
                                                   New DataColumn("Name", GetType(String))}
            Dim Content As String = Request.Form(textbox1.UniqueID)
            For Each row As String In Content .Split(ControlChars.Lf)
                If Not String.IsNullOrEmpty(row) Then
                    dt.Rows.Add()
                    Dim i As Integer = 0
                    For Each cell As String In row.Split(ControlChars.Tab)
                        If i > 1 Then
                            labelmessage.Text = "More than 2 columns not Allowed !!"
                            textbox1.Text = ""
                        Else
                            If cell.Trim() = "" Then
                                cell = "0"
                            End If
                            dt.Rows(dt.Rows.Count - 1)(i) = cell
                            i += 1
                        End If
                    Next
                End If
            Next
             gridvieew1.DataSource = dt
             gridvieew1.DataBind()

        Catch Ex As Exception
            labelmessage.CssClass = "alertNo"
            labelmessage.Text = Ex.Message
        End Try
        Return dt
    End Function

  Protected Sub PasteToGridView(sender As Object, e As EventArgs)
        uplif()

    End Sub

now when i try to add new row like this

Private Sub AddNewRowToGrid()
        Dim dt As DataTable = uplif()
        Dim NewRow As DataRow = dt.NewRow()
        dt.Rows.Add(NewRow)
         gridvieew1.DataSource = dt
         gridvieew1.DataBind()
    End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        AddNewRowToGrid()
    End Sub

this shows same output like add new row and replace previous data which is already in gridview and also this shows an error
Object reference not set to an instance of an object.

after click on add new row

ID Name

where as i want like this

ID Name
1  abc
2  def
(here new empty row when click on button )

Body:
As was pointed out in a comment to your post, the problem is in these two lines:

Dim dt As New DataTable()
...
gridview1.DataSource = dt

That creates a brand new DataTable and binds the grid view to it.  You don't copy data over, and you don't alter the existing gridview's table.

The correct fix here would be to get the DataTable from the gridview's DataSource and make any changes you need to to that.  Don't create a new DataTable.


问:
One to many correlation calculation in a matrix in R
Trying to calculate correlation of a specific gene (Here its Gene 1) with all others (35999 candidates) in a matrix

```<code>         samp1   samp2   samp3   samp4
Gene 1  3.7891  2.4487  1.1939  0.6013
Gene 2  1.4484  3.2316  2.841   1.9545
Gene 3  0.4505  2.6062  2.0729  0.6403
.
.
Gene 36000  1.8828  5.2633  2.7552  1.7335
</code>```

I used the following code

```<code>library(Hmisc)
A <- read.table("C:/Users/Desktop/exp.txt", header=T, sep="\t")
cor <- rcorr(as.matrix(A), type="pearson")

write.csv(cor$r,'C:/Users/Desktop/pCC VALUES.csv')
write.csv(cor$P,'C:/Users/Desktop/p VALUES.csv')
</code>```

But the above code is for matrix calculation of 36000*36000. However, I would like to get one to many correlation where the gene of interest is always the first gene. Here its gene 1. This would save the processing time. One method is obviously extract the 36000 pairs of my interest from the output. I would like to know if any other method is possible to find correlation of my gene against all others without many to many calculation.

Edit:

I am looking for output like in the format,

```<code>Gene 1 Gene 2   pcc  p-value
Gene 1 Gene 3   pcc  p-value
.
.
Gene 1 Gene 36000 pcc p-value
end
</code>```

答:
If I get you right (correlating first row with every other single row, taken one at a time), something along those lines might get you started:

```<code>dat <- as.matrix(read.table(text = "samp1;samp2;samp3;samp4
Gene 1;3.7891;2.4487;1.1939;0.6013
Gene 2;1.4484;3.2316;2.841;1.9545
Gene 3;0.4505;2.6062;2.0729;0.6403
Gene 4;0.4705;2.4062;1.0729;0.6003
Gene 5;1.8828;5.2633;2.7552;1.7335", sep=";"))

corr_list <- list()

for (i in 2:nrow(dat)) {
  r <- cor.test(dat[1,], dat[i,])
  corr_list[[paste("Genes 1 &", i)]] <- c(r$estimate, p.val=r$p.value)
}

# Results
corr_list

$`Genes 1 & 2`
       cor      p.val
-0.3070573  0.6929427

$`Genes 1 & 3`
       cor      p.val
-0.1417635  0.8582365

$`Genes 1 & 4`
       cor      p.val
0.04777015 0.95222985

$`Genes 1 & 5`
      cor     p.val
0.1425788 0.8574212
</code>```

You can also put results in a data.frame if more convenient:

```<code>corr_list <- data.frame(Gene1=numeric(), Gene2=numeric(), cor=numeric(), p.value=numeric())

for (i in 2:nrow(dat)) {
  r <- cor.test(dat[1,], dat[i,])
  corr_list[i-1,] <- c(1, i, r$estimate, r$p.value)
}

corr_list

  Gene1 Gene2         cor   p.value
1     1     2 -0.30705735 0.6929427
2     1     3 -0.14176355 0.8582365
3     1     4  0.04777015 0.9522299
4     1     5  0.14257884 0.8574212
</code>```

Body:
Trying to calculate correlation of a specific gene (Here its Gene 1) with all others (35999 candidates) in a matrix

         samp1   samp2   samp3   samp4
Gene 1  3.7891  2.4487  1.1939  0.6013
Gene 2  1.4484  3.2316  2.841   1.9545
Gene 3  0.4505  2.6062  2.0729  0.6403
.
.
Gene 36000  1.8828  5.2633  2.7552  1.7335

I used the following code

library(Hmisc)
A <- read.table("C:/Users/Desktop/exp.txt", header=T, sep="\t")
cor <- rcorr(as.matrix(A), type="pearson")

write.csv(cor$r,'C:/Users/Desktop/pCC VALUES.csv')
write.csv(cor$P,'C:/Users/Desktop/p VALUES.csv')

But the above code is for matrix calculation of 36000*36000. However, I would like to get one to many correlation where the gene of interest is always the first gene. Here its gene 1. This would save the processing time. One method is obviously extract the 36000 pairs of my interest from the output. I would like to know if any other method is possible to find correlation of my gene against all others without many to many calculation.

Edit:

I am looking for output like in the format,

Gene 1 Gene 2   pcc  p-value
Gene 1 Gene 3   pcc  p-value
.
.
Gene 1 Gene 36000 pcc p-value
end

Body:
If I get you right (correlating first row with every other single row, taken one at a time), something along those lines might get you started:

dat <- as.matrix(read.table(text = "samp1;samp2;samp3;samp4
Gene 1;3.7891;2.4487;1.1939;0.6013
Gene 2;1.4484;3.2316;2.841;1.9545
Gene 3;0.4505;2.6062;2.0729;0.6403
Gene 4;0.4705;2.4062;1.0729;0.6003
Gene 5;1.8828;5.2633;2.7552;1.7335", sep=";"))

corr_list <- list()

for (i in 2:nrow(dat)) {
  r <- cor.test(dat[1,], dat[i,])
  corr_list[[paste("Genes 1 &", i)]] <- c(r$estimate, p.val=r$p.value)
}

# Results
corr_list

$`Genes 1 & 2`
       cor      p.val
-0.3070573  0.6929427

$`Genes 1 & 3`
       cor      p.val
-0.1417635  0.8582365

$`Genes 1 & 4`
       cor      p.val
0.04777015 0.95222985

$`Genes 1 & 5`
      cor     p.val
0.1425788 0.8574212

You can also put results in a data.frame if more convenient:

corr_list <- data.frame(Gene1=numeric(), Gene2=numeric(), cor=numeric(), p.value=numeric())

for (i in 2:nrow(dat)) {
  r <- cor.test(dat[1,], dat[i,])
  corr_list[i-1,] <- c(1, i, r$estimate, r$p.value)
}

corr_list

  Gene1 Gene2         cor   p.value
1     1     2 -0.30705735 0.6929427
2     1     3 -0.14176355 0.8582365
3     1     4  0.04777015 0.9522299
4     1     5  0.14257884 0.8574212


问:
Why do Vue single file components compile to such large files?
I am new to Vue and Grunt/Gulp/Webpack. I got a Vue app to work fine (Grunt: browserify -> babel -> uglify) with a setup like this:

```<code>// app.js
const LoginComponent = require('./login.js')

// login.js
const template = `<some html>`
module.exports = Vue.component('login-component', {
    template: template,
    // component stuff
})
</code>```

Then, in order to make my components more readable, I switched to single file components (Webpack, Grunt: babel -> uglify) and go everything to work like this:

```<code>// app.js
import LoginComponent from './login.js'

// login.js
<template>
    <some html>
</template>
<script>
export defalut {
    // component stuff
}
</script>
</code>```

The problem is that when using webpack the file size is doubled. The first setup resulted in an app.min.js of 3.3kb, and the second setup with webpack was 7.0kb.

Is this normal or did I do something wrong?

My webpack.config.js looks like this:

```<code>var path = require('path')

module.exports = {
  entry: './resources/js/app.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'resources/js/temp')
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
    ]
  }
}
</code>```

答:
I don't see anything wrong with your config, sometimes webpack needs to generate some runtime code that might explain the increase of your bundle size.

However you can reduce it by using the DefinePlugin to set the NODE_ENV variable to production and leverage the UglifyjsWebpackPlugin, it will result in optimized code that will most likely be smaller, so something like the following

```<code>module.exports = {
  entry: './resources/js/app.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'resources/js/temp')
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify('production') },
    }),
    new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } }),
  ]
}
</code>```

You can also specify the option dead_code to uglify so it trims out code that is never used, which might help in your case.

Also, you should get rid of Grunt entirely using the babel-loader and the appropriate presets.

Body:
I am new to Vue and Grunt/Gulp/Webpack. I got a Vue app to work fine (Grunt: browserify -> babel -> uglify) with a setup like this:

// app.js
const LoginComponent = require('./login.js')

// login.js
const template = `<some html>`
module.exports = Vue.component('login-component', {
    template: template,
    // component stuff
})

Then, in order to make my components more readable, I switched to single file components (Webpack, Grunt: babel -> uglify) and go everything to work like this:

// app.js
import LoginComponent from './login.js'

// login.js
<template>
    <some html>
</template>

The problem is that when using webpack the file size is doubled. The first setup resulted in an app.min.js of 3.3kb, and the second setup with webpack was 7.0kb.

Is this normal or did I do something wrong?

My webpack.config.js looks like this:

var path = require('path')

module.exports = {
  entry: './resources/js/app.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'resources/js/temp')
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
    ]
  }
}

Body:
I don't see anything wrong with your config, sometimes webpack needs to generate some runtime code that might explain the increase of your bundle size.

However you can reduce it by using the DefinePlugin to set the NODE_ENV variable to production and leverage the UglifyjsWebpackPlugin, it will result in optimized code that will most likely be smaller, so something like the following

module.exports = {
  entry: './resources/js/app.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'resources/js/temp')
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify('production') },
    }),
    new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } }),
  ]
}

You can also specify the option dead_code to uglify so it trims out code that is never used, which might help in your case.

Also, you should get rid of Grunt entirely using the babel-loader and the appropriate presets.


问:
How to write query for created User, Created date, Modified User, Modified date for a table
I need help in knowing how to automatically make the table load the values for Created user , created date, modified user and modified date,

once any data goes into the table , we should have the Created user and created date column value to be fixed but the modified user and modified date should change

答:
Admiting your table structure looks like this -dont forget the DEFAULT GETDATE()- :

```<code>YourTable
---------
CreatedUser
CreatedDate  DEFAULT GETDATE()
ModifierUser
ModifierDate
</code>```

On the insertion you trigger a function that will update ModifiedUser and ModifiedDate to GETDATE()

Body:
Admiting your table structure looks like this -dont forget the DEFAULT GETDATE()- :

YourTable
---------
CreatedUser
CreatedDate  DEFAULT GETDATE()
ModifierUser
ModifierDate

On the insertion you trigger a function that will update ModifiedUser and ModifiedDate to GETDATE()


问:
Add multiple extensions in one filetypes mac - tkinter/filedialog/askopenfilename
I am trying to use tkinter.filedialog to choose the file in Mac.

It works fine with one filetype in this way:

```<code>filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx")])
</code>```

However, I want to choose either xlsx or xls files. I searched and found a question filedialog, tkinter and opening files. I use the similar way but it does not work with Mac if I change to this:

```<code>filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx; *.xls")])
</code>```

How should I change to choose either xlsx or xls files in the file dialog?

答:
It seems that you must separate the wildcard patterns with a space rather than ; (verified on Python 3.5.1):

```<code>from tkinter import filedialog

# add `, initialdir="..."` to set the initial directory shown in the dialog
filedialog.askopenfilename(filetypes=[("Excel files", ".xlsx .xls")])
</code>```

Note:

While "*.xlsx *.xls" would work too (at least on Windows and macOS), the initial * isn't necessary.[1]

Whether .* or *.* works (no filter) seems to be platform-dependent; omitting filetypes is the better option in that case.

Similarly, the behavior of matching part of the base filename - something like foo.txt or foo*.txt - appears to be platform-dependent: on Windows, these do work, with a prepended * (*foo.txt and *foo*.txt), whereas on macOS they seem to match nothing.

If the platform-dependent behaviors are instead / also linked to different tkinter versions, do let us know.

[1] Jakub Bláha reports that "*.xlsx *.xls" didn't actually work for him in Python 3.7.4 on Windows 10 version 1903 (though I don't see the same problem); to be safe, omit the * if not needed.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to use tkinter.filedialog to choose the file in Mac.

It works fine with one filetype in this way:

filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx")])

However, I want to choose either xlsx or xls files. I searched and found a question filedialog, tkinter and opening files. I use the similar way but it does not work with Mac if I change to this:

filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx; *.xls")])

How should I change to choose either xlsx or xls files in the file dialog?

Body:
It seems that you must separate the wildcard patterns with a space rather than ; (verified on Python 3.5.1):

from tkinter import filedialog

# add `, initialdir="..."` to set the initial directory shown in the dialog
filedialog.askopenfilename(filetypes=[("Excel files", ".xlsx .xls")])

Note:

While "*.xlsx *.xls" would work too (at least on Windows and macOS), the initial * isn't necessary.[1]

Whether .* or *.* works (no filter) seems to be platform-dependent; omitting filetypes is the better option in that case.

Similarly, the behavior of matching part of the base filename - something like foo.txt or foo*.txt - appears to be platform-dependent: on Windows, these do work, with a prepended * (*foo.txt and *foo*.txt), whereas on macOS they seem to match nothing.

If the platform-dependent behaviors are instead / also linked to different tkinter versions, do let us know.

[1] Jakub Bláha reports that "*.xlsx *.xls" didn't actually work for him in Python 3.7.4 on Windows 10 version 1903 (though I don't see the same problem); to be safe, omit the * if not needed.


问:
The support directory was not found
I installed "Android support Repository" in "Extras". But I can not find the folder "support". Please help me:

答:
The support library is found in this path,

```<code> {SDK path}\extras\android\m2repository\com\android\support
</code>```

If the support library exists there then you can just include any support library you want For eg: compile 'com.android.support:appcompat-v7:25.3.1' in your app level gradle file.

Title: The support directory was not found

Body:
The support library is found in this path,

 {SDK path}\extras\android\m2repository\com\android\support

If the support library exists there then you can just include any support library you want For eg: compile 'com.android.support:appcompat-v7:25.3.1' in your app level gradle file.


问:
Gradle sync failed Android studio 2.3.2
Gradle sync failed: A problem occurred configuring project ':app'. Consult IDE log for more details.

Hence I'm very new to the Android Studio just tried to setup for the first time.  Even I tried all the methods which mentioned for the gradle sync failed unfortunately nothing works. Please help to find the issue.

Classpath:

buildscript {
     repositories {
         jcenter()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:2.3.2'

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

}
  }

Wrapper Properties :

Wed May 24 08:00:32 IST 2017

distributionBase=GRADLE_USER_HOME
  distributionPath=wrapper/dists
  zipStoreBase=GRADLE_USER_HOME
  zipStorePath=wrapper/dists
  distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

Error while Re-Building :

```<code> Error:A problem occurred configuring project ':app'.
 > java.lang.NullPointerException (no error message)
</code>```

Thanks in advance

Update : Added Logs

Logs

答: Clean the project & try again. If that didn't help too, restart android studio.</p>

Title: Gradle sync failed Android studio 2.3.2

Body:
Gradle sync failed: A problem occurred configuring project ':app'. Consult IDE log for more details.

Hence I'm very new to the Android Studio just tried to setup for the first time.  Even I tried all the methods which mentioned for the gradle sync failed unfortunately nothing works. Please help to find the issue.

Classpath:

buildscript {
     repositories {
         jcenter()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:2.3.2'

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

}
  }

Wrapper Properties :

Wed May 24 08:00:32 IST 2017

distributionBase=GRADLE_USER_HOME
  distributionPath=wrapper/dists
  zipStoreBase=GRADLE_USER_HOME
  zipStorePath=wrapper/dists
  distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

Error while Re-Building :

 Error:A problem occurred configuring project ':app'.
 > java.lang.NullPointerException (no error message)

Thanks in advance

Update : Added Logs

Logs


问:
How to make multiple Axios requests using a dynamic array of links in Javascript?
linksArray is an array with six links.

I want to use this array to perform (6) get requests. Then, I want to take the response and setState after the response is mapped through to get the results I want.

Any help here?

```<code>getGistsDescriptions = () => {
let promiseArray = linksArray.map((url) => { return axios.get(url)});

axios.all(promiseArray)
     .then(axios.spread((...res) => {
       console.log(...res);

      /*let temp = res.map((element) => {
        return element.data;
      });*/

       //this.setState({ gistsDescriptions: temp });
     }))
     .catch((err) => {
    console.log(err);
  });
 }
</code>```

I also tried this:

```<code>getGistsDescriptions = () => {
let promiseArray = linksArray.map((url) => { return axios.get(url)});

axios.all(promiseArray)
     .then((results) => {
       console.log(results);

      /*let temp = results.map((element) => {
        return element.data;
      });*/

       //this.setState({ gistsDescriptions: temp });
     })
     .catch((err) => {
    console.log(err);
  });
}
</code>```

答:
They're just Promises

axios.all is basically Axios' polyfill for Promise.all. @D-reaper's use of fetch could just as easily implement Axios.

const getGistsDescriptions = () => {
  /*
  I assume `getGistDescriptions` is stored as a variable or a constant.
  If this is supposed to be a method inside a React component class,
  the arrow function + equal sign syntax is incorrect.
  */
  let promiseArray = linksArray.map( url=> axios.get(url) );
  Promise.all( promiseArray )
  .then(
    results => {
      const gistsDescriptions = results.map( el => el.data );
      this.setState({ gistsDescriptions })
      /*
      this is the same as
      `{ gistsDescriptions: gistsDescriptions }`
      */

    }
  )
  .catch(console.log)

}```
</div>
</div>
</p>

<p>If you're up for a challenge, you also could use <code>async/await</code>:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const getGistsDescriptions = async () => {

  const promiseArray = linksArray.map(url=>axios.get(url));

  try {

    const gistsDescriptions = (
      await Promise.all(promiseArray)
    ).map(res=>res.data)

    this.setState({ gistsDescriptions })

  } catch(error) {
    console.error(error)
  }

}</code>```

Body:
linksArray is an array with six links.

I want to use this array to perform (6) get requests. Then, I want to take the response and setState after the response is mapped through to get the results I want.

Any help here?

getGistsDescriptions = () => {
let promiseArray = linksArray.map((url) => { return axios.get(url)});

axios.all(promiseArray)
     .then(axios.spread((...res) => {
       console.log(...res);

      /*let temp = res.map((element) => {
        return element.data;
      });*/

       //this.setState({ gistsDescriptions: temp });
     }))
     .catch((err) => {
    console.log(err);
  });
 }

I also tried this:

getGistsDescriptions = () => {
let promiseArray = linksArray.map((url) => { return axios.get(url)});

axios.all(promiseArray)
     .then((results) => {
       console.log(results);

      /*let temp = results.map((element) => {
        return element.data;
      });*/

       //this.setState({ gistsDescriptions: temp });
     })
     .catch((err) => {
    console.log(err);
  });
}

Body:
They're just Promises

axios.all is basically Axios' polyfill for Promise.all. @D-reaper's use of fetch could just as easily implement Axios.

const getGistsDescriptions = () => {
  /*
  I assume `getGistDescriptions` is stored as a variable or a constant.
  If this is supposed to be a method inside a React component class,
  the arrow function + equal sign syntax is incorrect.
  */
  let promiseArray = linksArray.map( url=> axios.get(url) );
  Promise.all( promiseArray )
  .then(
    results => {
      const gistsDescriptions = results.map( el => el.data );
      this.setState({ gistsDescriptions })
      /*
      this is the same as
      `{ gistsDescriptions: gistsDescriptions }`
      */

    }
  )
  .catch(console.log)

}

If you're up for a challenge, you also could use async/await:

const getGistsDescriptions = async () => {

  const promiseArray = linksArray.map(url=>axios.get(url));

  try {

    const gistsDescriptions = (
      await Promise.all(promiseArray)
    ).map(res=>res.data)

    this.setState({ gistsDescriptions })

  } catch(error) {
    console.error(error)
  }

}


问:
How to provide a plugin with data capabilities?
I have an application in which i want to provide the people who write plugins to it (plugins are made by implementing a basic interface, then i load the .dll). I want to give them the possibility to create settings and save data in my existing database. I would like to do this without having to create a table for each plugin - but if its required im willing to do it. I have come up with two basic scenarios:

Give the plugin an interface, where it can get a Dictionary  and serialize it to xml and save it in my database.

The plugin must be contained within a .zip file with a manifest file (my own invention) where it has a create sql script and a drop script for tables.

The first has limitations towards complex data types. The second has a larger complexity in the plugin, since it needs to be within a .zip file and unpacked etc...

Please advice on either of these approaces, or alternatives.

Cheers

答:
It depends how complex the plugins are.

First approach is perfect if the pugins need only settings. In this situation I don't see any limitation of the first method.
The second method does not brig anything new. You can get the same info that is in the manifest file in a datastructure and retrieve it from the plugin interface method. This is easyer because you manage only the dll file. Also if the file is very complex you can put it in a resource in the dll.
In your database you can save in a table something like: plugin_name_settingname, value into a settings table that you use for all plugins.

I once had to suport a plugin mechanism where plugins nedded their own tables.
In this case you can retrieve the new tabels schema and names in the interface method that plugin implenet. Then you need to create that in the database. Is like an insall for the plugin.


问:
Simple C function returns nonsense
I need to make simple function that converts binary number (string) to decimal number (long). When it returns result, it's nonsense. I've tried to return all others variables and it returned correct numbers. There is something wrong with my result variable.</p>

```<code>#include "stdio.h"
#include "string.h"
#include "math.h"

long bintodec(const char *bin_num) {
        long DIGIT, SUBTOTAL, RESULT = 0, I, LEN;
        LEN = strlen(bin_num);
        for(I = 0; I != LEN; I++) {
                sscanf(&bin_num[I], "%li", &DIGIT);
                SUBTOTAL = DIGIT * pow(2, LEN - I - 1);
                RESULT = RESULT + SUBTOTAL;
        }
        return RESULT;
}

main() {
        clrscr();
        printf("%li", bintodec("101"));
        getch();
}
</code>```

答:
Rather than debug your code, I'll present a more elegant solution. Consider:

```<code>long bintodec(const char *bin_num)
{
    long sum = 0;
    for (; *bin_num != '\0'; bin_num++) /* move pointer through string */
    {
        sum <<= 1; /* shift bits left (meaningless on first pass) */
        sum |= (*bin_num == '1'); /* conditionally tack on new least significant bit */
    }
    return sum;
}
</code>```

Some notes:

The key point is that the bits that encode integer type variables are identical to the binary sequence that you pass in as a string. Thus: bitwise operators. The only ones we need here are left bit-shift, which shifts each of the underlying bits one place to the left, and bitwise-or, which logically or's the bits of two numbers against one another. The equivalent representations render valid a pictorial understanding of the problem.

Rather than having to pass through the entire string to determine its length, and using that to inform the pow function, we can slot incoming bits in on the right.

Here's what's going on within the for loop:

1st pass:

```<code>sum <<= :           00000        /* more zero's contained in a long */
string:            "10101"
ptr:                ^
sum |= :            00001
</code>```

2nd pass:

```<code>sum:                00010
string:            "10101"
ptr:                 ^
sum:                00010
</code>```

3rd pass:

```<code>sum:                00100
string:            "10101"
ptr:                  ^
sum:                00101
</code>```

... and so forth.

In general, rather than invoking

```<code>pow(2, arg)
</code>```

you should leverage the bit-shift operator, which exactly accomplishes multiplication by some power of two. (Appending a zero is multiplication by 10 in base 10).

Title: Simple C function returns nonsense

Body:
I need to make simple function that converts binary number (string) to decimal number (long). When it returns result, it's nonsense. I've tried to return all others variables and it returned correct numbers. There is something wrong with my result variable.

#include "stdio.h"
#include "string.h"
#include "math.h"

long bintodec(const char *bin_num) {
        long DIGIT, SUBTOTAL, RESULT = 0, I, LEN;
        LEN = strlen(bin_num);
        for(I = 0; I != LEN; I++) {
                sscanf(&bin_num[I], "%li", &DIGIT);
                SUBTOTAL = DIGIT * pow(2, LEN - I - 1);
                RESULT = RESULT + SUBTOTAL;
        }
        return RESULT;
}

main() {
        clrscr();
        printf("%li", bintodec("101"));
        getch();
}

Body:
Rather than debug your code, I'll present a more elegant solution. Consider:

long bintodec(const char *bin_num)
{
    long sum = 0;
    for (; *bin_num != '\0'; bin_num++) /* move pointer through string */
    {
        sum <<= 1; /* shift bits left (meaningless on first pass) */
        sum |= (*bin_num == '1'); /* conditionally tack on new least significant bit */
    }
    return sum;
}

Some notes:

The key point is that the bits that encode integer type variables are identical to the binary sequence that you pass in as a string. Thus: bitwise operators. The only ones we need here are left bit-shift, which shifts each of the underlying bits one place to the left, and bitwise-or, which logically or's the bits of two numbers against one another. The equivalent representations render valid a pictorial understanding of the problem.

Rather than having to pass through the entire string to determine its length, and using that to inform the pow function, we can slot incoming bits in on the right.

Here's what's going on within the for loop:

1st pass:

sum <<= :           00000        /* more zero's contained in a long */
string:            "10101"
ptr:                ^
sum |= :            00001

2nd pass:

sum:                00010
string:            "10101"
ptr:                 ^
sum:                00010

3rd pass:

sum:                00100
string:            "10101"
ptr:                  ^
sum:                00101

... and so forth.

In general, rather than invoking

pow(2, arg)

you should leverage the bit-shift operator, which exactly accomplishes multiplication by some power of two. (Appending a zero is multiplication by 10 in base 10).