问:
3 boxes inline, content alignment
I have 3 boxes with dynamic content, in each box there is a form with submit button, and some other things. How to get the effect from the picture.

Height of the each box is max from all boxes. Submit buttons in one line, on the bottom.

body {
  width: 720px;
}
form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}
form label {
  text-align: left;
  width: 100%;
  display: block;
}
.box-container {
  display: flex;
}
.box {
  border: 1px solid #000;
  flex: 1 1 auto;
  max-width: calc(33% - 2px);
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}
.box p {
  text-align: justify;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="box-container">
  <div class="box">
    <h1>bla bla bla</h1>
    <p> some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>
  </div>
  <div class="box">
    <h1>bla bla bladada das dasd asd</h1>
    <p>Longer information<br> some information dasd asd asd asd an</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <label>value 2</label>
      <input type="text"/>
      <label>value 3</label>
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>
  </div>
  <div class="box">
    <h1>bla bla b</h1>
    <p>Longer information</p>
    <form>
      <label>value 1</label>
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>
  </div>
<div></code>```

答:
Ok. Thanks to all of you for the answers. I resolved my problem.

form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}

form label {
  text-align: left;
  width: 100%;
  display: block;
}

.box-container {
  display: flex;
}

.box {
  border: 1px solid #000;
  flex: 1;
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}
.box form {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.box p {
  text-align: justify;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="box-container">
  <div class="box">
    <form>
      <div class="top">
      <h1>bla bla bla</h1>
      <p> some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s</p>
      <label>value 1</label>
      <input type="text" />
      <label>value 2</label>
      <input type="text" />
      </div>
      <div class="bottom">
      <input type="submit" value="submit" />
      </div>
    </form>
  </div>
  <div class="box">
    <form>
      <div class="top">
        <h1>bla bla bladada das dasd asd</h1>
        <p>Longer information<br> some information dasd asd asd asd an</p>
        <label>value 1</label>
        <input type="text" />
        <label>value 2</label>
        <input type="text" />
        <label>value 3</label>
        <input type="text" />
      </div>
     <div class="bottom">
      <input type="submit" value="submit" />
     </div>
     </form>
  </div>
  <div class="box">
    <form>
      <div class="top">
        <h1>bla bla b</h1>
        <p>Longer information</p>
        <label>value 1</label>
        <input type="text" />
      </div>
      <div class="bottom">
        <input type="submit" value="submit" />
      </div>
    </form>
  </div>
  <div></code>```

Title: 3 boxes inline, content alignment

Body:
I have 3 boxes with dynamic content, in each box there is a form with submit button, and some other things. How to get the effect from the picture.

Height of the each box is max from all boxes. Submit buttons in one line, on the bottom.

body {
  width: 720px;
}
form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}
form label {
  text-align: left;
  width: 100%;
  display: block;
}
.box-container {
  display: flex;
}
.box {
  border: 1px solid #000;
  flex: 1 1 auto;
  max-width: calc(33% - 2px);
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}
.box p {
  text-align: justify;
}

bla bla bla

 some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s

    <form>
      value 1
      <input type="text"/>
      value 2
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>

bla bla bladada das dasd asd

Longer information
 some information dasd asd asd asd an

    <form>
      value 1
      <input type="text"/>
      value 2
      <input type="text"/>
      value 3
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>

bla bla b

Longer information

    <form>
      value 1
      <input type="text"/>
      <input type="submit" value="submit"/>
    </form>

Body:
Ok. Thanks to all of you for the answers. I resolved my problem.

form input {
  display: block;
  margin-bottom: 15px;
  width: 100%;
}

form label {
  text-align: left;
  width: 100%;
  display: block;
}

.box-container {
  display: flex;
}

.box {
  border: 1px solid #000;
  flex: 1;
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}
.box form {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.box p {
  text-align: justify;
}

<div class="box-container">
  <div class="box">
    <form>
      <div class="top">
      <h1>bla bla bla</h1>
      <p> some information dasd asd asd asdasdasfs dsgd dfg sdfg fsdg sdfg s</p>
      <label>value 1</label>
      <input type="text" />
      <label>value 2</label>
      <input type="text" />
      </div>
      <div class="bottom">
      <input type="submit" value="submit" />
      </div>
    </form>
  </div>
  <div class="box">
    <form>
      <div class="top">
        <h1>bla bla bladada das dasd asd</h1>
        <p>Longer information<br> some information dasd asd asd asd an</p>
        <label>value 1</label>
        <input type="text" />
        <label>value 2</label>
        <input type="text" />
        <label>value 3</label>
        <input type="text" />
      </div>
     <div class="bottom">
      <input type="submit" value="submit" />
     </div>
     </form>
  </div>
  <div class="box">
    <form>
      <div class="top">
        <h1>bla bla b</h1>
        <p>Longer information</p>
        <label>value 1</label>
        <input type="text" />
      </div>
      <div class="bottom">
        <input type="submit" value="submit" />
      </div>
    </form>
  </div>
  <div>


来源: stackexchange

问:
ExtJs Two way binding between parent and child component
I have two components: A panel and a custom text field.

The panel has a viewmodel and I want to bind a value (called testData) from that viewmodel to a property (called test) of the custom text field.

That works fine ...basically.

But when the test property of the text field is changed, the testData in the viewmodel of the panel does not update accordingly. I mean when the test property of the child element (the textfield) is modified, the testData property of the panel's viewmodel should contain the same value that is in test, just like a normal two-way bind.

I'm not sure what I'm doing wrong, but here is what I've tried to far:
https://fiddle.sencha.com/#fiddle/20pu&view/editor

```<code>Ext.define('MyMain', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.main',

    width: '100%',
    bodyPadding: 10,

    viewModel: {
        data: {
            testData: 'Example Data'
        }
    },

    bind: {
        title: '{testData}'
    },

    items: {
        xtype: 'myField',
        bind: {
            test: '{testData}'
        }
    }
})

Ext.define('MyField', {
    extend: 'Ext.form.field.Text',
    alias: 'widget.myField',
    fieldLabel: 'Data',
    width: '100%',

    config: {
        test: null // when test is changed, it should also affect the {testData} bind of the main component, causing the title to change
    },

    setTest(value) {
        this.test = value + ' modified!' // because of the bind, this /should/ automatically get appied to the viewmodel's `testData` and thus to the panel title
        this.setValue(this.test) // whenever the `test` property is changed, we write the contents to the value of the text field (just to visualize the `test` property).
        // But as you can see, the panel title will still just say `Example Data` and not `Example Data modified!` as it should.
    },
    getTest(){
        return this.test
    }
})

Ext.application({
    name : 'Fiddle',

    launch : function() {
        Ext.create('Ext.container.Viewport', {
            items: [{
                xtype: 'main'
            }]
        })
    }
})
</code>```

答:
Update: (after reading your comments on other answers)

In general, mentioning the property in the config block and include it in publishes will make any property two-way bindable.

ExtJS will generate the getter and setter methods for it. The setter method takes care of binding. Now, whenever anyone updates the property value (using the setter), the new value will be passed on to the bound viewModel and in turn to the other components.

Accessing the property directly, this.test or this.viewModel.data.testData  and assigning values to them will not be reflected in the controls bound to this property.

In case you are providing an implementation for the setter function (setTest) of a published property, ensure that this.callParent(...) gets called from it.

The usage of field's value property to display the contents of test caused the earlier confusion. Here is a fiddle with two-way bindable test property without any special handling in the MyField class.

Click on the 'Get test' button, the value should be 'Example Data' (from viewModel).

'Set testData' button will update the value in the viewModel. Use the 'Get test' button again to verify that the value of test has also been updated.

'Set test' button assigns a new value to the field's test property and this will be reflected in the panel's title.

Have a look at this forked fiddle.

In your implementation, the setTest method is directly changing the value of this.test to value + ' modified!'. This will not update the value of testData in viewModel as binding works via the getter and setter functions implemented of the properties specified in the config.

ContentLicense: CC BY-SA 3.0

Body:
I have two components: A panel and a custom text field.

The panel has a viewmodel and I want to bind a value (called testData) from that viewmodel to a property (called test) of the custom text field.

That works fine ...basically.

But when the test property of the text field is changed, the testData in the viewmodel of the panel does not update accordingly. I mean when the test property of the child element (the textfield) is modified, the testData property of the panel's viewmodel should contain the same value that is in test, just like a normal two-way bind.

I'm not sure what I'm doing wrong, but here is what I've tried to far:
https://fiddle.sencha.com/#fiddle/20pu&view/editor

Ext.define('MyMain', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.main',

    width: '100%',
    bodyPadding: 10,

    viewModel: {
        data: {
            testData: 'Example Data'
        }
    },

    bind: {
        title: '{testData}'
    },

    items: {
        xtype: 'myField',
        bind: {
            test: '{testData}'
        }
    }
})

Ext.define('MyField', {
    extend: 'Ext.form.field.Text',
    alias: 'widget.myField',
    fieldLabel: 'Data',
    width: '100%',

    config: {
        test: null // when test is changed, it should also affect the {testData} bind of the main component, causing the title to change
    },

    setTest(value) {
        this.test = value + ' modified!' // because of the bind, this /should/ automatically get appied to the viewmodel's `testData` and thus to the panel title
        this.setValue(this.test) // whenever the `test` property is changed, we write the contents to the value of the text field (just to visualize the `test` property).
        // But as you can see, the panel title will still just say `Example Data` and not `Example Data modified!` as it should.
    },
    getTest(){
        return this.test
    }
})

Ext.application({
    name : 'Fiddle',

    launch : function() {
        Ext.create('Ext.container.Viewport', {
            items: [{
                xtype: 'main'
            }]
        })
    }
})


问:
Best way to communicate between forms?
I almost never used (advanced, or at all) graphical interfaces, or one simple form with simple controls... but this time I've got something a little more complex, and I don't have much experience with GUI.
I have one main form (and possibly more in the future) from which other sub-forms open (and they might have sub-forms of themselves) and I wonder what is, in your opinion, the best way to communicate between them?

I thought of passing the main form as a parameter to the constructors of the sub-forms, but it doesn't seem like a good way, especially if I'm going to need to communicate between other, distinct, sub-forms, not to mention I have to double check the input, or make a few methods, but it seems more like functional programming than object oriented programming...

Perhaps I can:

Create a static class (or Properties.Settings) for global settings. Cons: every change of data is needed to be copied to the class, I'm looking for something a bit more comfortable and elegant.

Use the ugly way of accessing the controls from Application.OpenForms - fixes the problem of passing the main form as parameter. Cons: not very stable.

Do something else I haven't thought of. Suggestions? Cons: don't know what it is yet.

答:
Your constructor idea is probably the most sound method of communication back to the main form. Your sub form would do something like the following:

```<code>public class SubForm : Form
{
    public SubForm(MainForm parentForm)
    {
        _parentForm = parentForm;
    }

    private MainForm _parentForm;

    private void btn_UpdateClientName_Click(object sender, EventArgs e)
    {
        _parentForm.UpdateClientName(txt_ClientName.Text);
    }
}
</code>```

And then you expose public methods on your MainForm:

```<code>public class MainForm : Form
{
    public void UpdateClientName(string clientName)
    {
        txt_MainClientName.Text = clientName;
    }
}
</code>```

Alternatively, you can go the other way around and subscribe to events from your SubForms:

```<code>public class MainForm : Form
{
    private SubForm1 _subForm1;
    private SubForm2 _subForm2;

    public MainForm()
    {
        _subForm1 = new SubForm1();
        _subForm2 = new SubForm2();

        _subForm1.ClientUpdated += new EventHandler(_subForm1_ClientUpdated);
        _subForm2.ClientUpdated += new EventHandler(_subForm2_ProductUpdated);
    }

    private void _subForm1_ClientUpdated(object sender, EventArgs e)
    {
        txt_ClientName.Text = _subForm1.ClientName; // Expose a public property
    }

    private void _subForm2_ProductUpdated(object sender, EventArgs e)
    {
        txt_ProductName.Text = _subForm2.ProductName; // Expose a public property
    }
}
</code>```

Title: Best way to communicate between forms?

Body:
Your constructor idea is probably the most sound method of communication back to the main form. Your sub form would do something like the following:

public class SubForm : Form
{
    public SubForm(MainForm parentForm)
    {
        _parentForm = parentForm;
    }

    private MainForm _parentForm;

    private void btn_UpdateClientName_Click(object sender, EventArgs e)
    {
        _parentForm.UpdateClientName(txt_ClientName.Text);
    }
}

And then you expose public methods on your MainForm:

public class MainForm : Form
{
    public void UpdateClientName(string clientName)
    {
        txt_MainClientName.Text = clientName;
    }
}

Alternatively, you can go the other way around and subscribe to events from your SubForms:

public class MainForm : Form
{
    private SubForm1 _subForm1;
    private SubForm2 _subForm2;

    public MainForm()
    {
        _subForm1 = new SubForm1();
        _subForm2 = new SubForm2();

        _subForm1.ClientUpdated += new EventHandler(_subForm1_ClientUpdated);
        _subForm2.ClientUpdated += new EventHandler(_subForm2_ProductUpdated);
    }

    private void _subForm1_ClientUpdated(object sender, EventArgs e)
    {
        txt_ClientName.Text = _subForm1.ClientName; // Expose a public property
    }

    private void _subForm2_ProductUpdated(object sender, EventArgs e)
    {
        txt_ProductName.Text = _subForm2.ProductName; // Expose a public property
    }
}

ContentLicense: CC BY-SA 2.5


问:
"Hello TensorFlow!" using the C API
For learning purposes, how to code this Python example using the TensorFlow C API ?

```<code>import tensorflow as tf
hello = tf.constant("hello TensorFlow!")
sess=tf.Session()
print(sess.run(hello))
</code>```

I have tried it this way:

```<code>#include <string.h>
#include <iostream.h>
#include "c_api.h"

int main( int argc, char ** argv )
{
  TF_Graph * graph = TF_NewGraph();
  TF_SessionOptions * options = TF_NewSessionOptions();
  TF_Status * status = TF_NewStatus();
  TF_Session * session = TF_NewSession( graph, options, status );
  char hello[] = "Hello TensorFlow!";
  TF_Tensor * tensor = TF_AllocateTensor( TF_STRING, 0, 0, 8 + TF_StringEncodedSize( strlen( hello ) ) );
  TF_OperationDescription * operationDescription = TF_NewOperation( graph, "Const", "hello" );
  TF_Operation * operation;
  struct TF_Output * output;

  TF_StringEncode( hello, strlen( hello ), 8 + ( char * ) TF_TensorData( tensor ), TF_StringEncodedSize( strlen( hello ) ), status );
  TF_SetAttrTensor( operationDescription, "value", tensor, status );
  TF_SetAttrType( operationDescription, "dtype", TF_TensorType( tensor ) );
  operation = TF_FinishOperation( operationDescription, status );

  output->oper = operation;
  output->index = 0;

  TF_SessionRun( session, 0,
                 0, 0, 0,  // Inputs
                 output, &tensor, 1,  // Outputs
                 &operation, 1,  // Operations
                 0, status );

  printf( "%i", TF_GetCode( status ) );

  TF_CloseSession( session, status );
  TF_DeleteSession( session, status );
  TF_DeleteStatus( status );
  TF_DeleteSessionOptions( options );

  return 0;
}
</code>```

I am testing it on Windows using the TensorFlow.dll from:
http://ci.tensorflow.org/view/Nightly/job/nightly-libtensorflow-windows/lastSuccessfulBuild/artifact/lib_package/libtensorflow-cpu-windows-x86_64.zip

The above code GPFs on the TF_SessionRun() call. Once we find a solution for that, how to retrieve the output ? Should a different tensor be used for the
output ? The above code reuses it in both the output and the operation.

many thanks

答:
There was a bug to solve beside the offset initialization. This version seems to work fine:

```<code>#include <iostream.h>
#include "c_api.h"

int main( int argc, char ** argv )
{
  TF_Graph * graph = TF_NewGraph();
  TF_SessionOptions * options = TF_NewSessionOptions();
  TF_Status * status = TF_NewStatus();
  TF_Session * session = TF_NewSession( graph, options, status );
  char hello[] = "Hello TensorFlow!";
  TF_Tensor * tensor = TF_AllocateTensor( TF_STRING, 0, 0, 8 + TF_StringEncodedSize( strlen( hello ) ) );
  TF_Tensor * tensorOutput;
  TF_OperationDescription * operationDescription = TF_NewOperation( graph, "Const", "hello" );
  TF_Operation * operation;
  struct TF_Output output;

  TF_StringEncode( hello, strlen( hello ), 8 + ( char * ) TF_TensorData( tensor ), TF_StringEncodedSize( strlen( hello ) ), status );
  memset( TF_TensorData( tensor ), 0, 8 );
  TF_SetAttrTensor( operationDescription, "value", tensor, status );
  TF_SetAttrType( operationDescription, "dtype", TF_TensorType( tensor ) );
  operation = TF_FinishOperation( operationDescription, status );

  output.oper = operation;
  output.index = 0;

  TF_SessionRun( session, 0,
                 0, 0, 0,  // Inputs
                 &output, &tensorOutput, 1,  // Outputs
                 &operation, 1,  // Operations
                 0, status );

  printf( "status code: %i\n", TF_GetCode( status ) );
  printf( "%s\n", ( ( char * ) TF_TensorData( tensorOutput ) ) + 9 );

  TF_CloseSession( session, status );
  TF_DeleteSession( session, status );
  TF_DeleteStatus( status );
  TF_DeleteSessionOptions( options );

  return 0;
}
</code>```

Do we have to delete the tensorOutput ? Not sure why we have to add 9 (instead of 8) to get the beginning of the string.

Title: "Hello TensorFlow!" using the C API

Body:
For learning purposes, how to code this Python example using the TensorFlow C API ?

import tensorflow as tf
hello = tf.constant("hello TensorFlow!")
sess=tf.Session()
print(sess.run(hello))

I have tried it this way:

#include <string.h>
#include <iostream.h>
#include "c_api.h"

int main( int argc, char ** argv )
{
  TF_Graph * graph = TF_NewGraph();
  TF_SessionOptions * options = TF_NewSessionOptions();
  TF_Status * status = TF_NewStatus();
  TF_Session * session = TF_NewSession( graph, options, status );
  char hello[] = "Hello TensorFlow!";
  TF_Tensor * tensor = TF_AllocateTensor( TF_STRING, 0, 0, 8 + TF_StringEncodedSize( strlen( hello ) ) );
  TF_OperationDescription * operationDescription = TF_NewOperation( graph, "Const", "hello" );
  TF_Operation * operation;
  struct TF_Output * output;

  TF_StringEncode( hello, strlen( hello ), 8 + ( char * ) TF_TensorData( tensor ), TF_StringEncodedSize( strlen( hello ) ), status );
  TF_SetAttrTensor( operationDescription, "value", tensor, status );
  TF_SetAttrType( operationDescription, "dtype", TF_TensorType( tensor ) );
  operation = TF_FinishOperation( operationDescription, status );

  output->oper = operation;
  output->index = 0;

  TF_SessionRun( session, 0,
                 0, 0, 0,  // Inputs
                 output, &tensor, 1,  // Outputs
                 &operation, 1,  // Operations
                 0, status );

  printf( "%i", TF_GetCode( status ) );

  TF_CloseSession( session, status );
  TF_DeleteSession( session, status );
  TF_DeleteStatus( status );
  TF_DeleteSessionOptions( options );

  return 0;
}

I am testing it on Windows using the TensorFlow.dll from:
http://ci.tensorflow.org/view/Nightly/job/nightly-libtensorflow-windows/lastSuccessfulBuild/artifact/lib_package/libtensorflow-cpu-windows-x86_64.zip

The above code GPFs on the TF_SessionRun() call. Once we find a solution for that, how to retrieve the output ? Should a different tensor be used for the
output ? The above code reuses it in both the output and the operation.

many thanks

Body:
There was a bug to solve beside the offset initialization. This version seems to work fine:

#include <iostream.h>
#include "c_api.h"

int main( int argc, char ** argv )
{
  TF_Graph * graph = TF_NewGraph();
  TF_SessionOptions * options = TF_NewSessionOptions();
  TF_Status * status = TF_NewStatus();
  TF_Session * session = TF_NewSession( graph, options, status );
  char hello[] = "Hello TensorFlow!";
  TF_Tensor * tensor = TF_AllocateTensor( TF_STRING, 0, 0, 8 + TF_StringEncodedSize( strlen( hello ) ) );
  TF_Tensor * tensorOutput;
  TF_OperationDescription * operationDescription = TF_NewOperation( graph, "Const", "hello" );
  TF_Operation * operation;
  struct TF_Output output;

  TF_StringEncode( hello, strlen( hello ), 8 + ( char * ) TF_TensorData( tensor ), TF_StringEncodedSize( strlen( hello ) ), status );
  memset( TF_TensorData( tensor ), 0, 8 );
  TF_SetAttrTensor( operationDescription, "value", tensor, status );
  TF_SetAttrType( operationDescription, "dtype", TF_TensorType( tensor ) );
  operation = TF_FinishOperation( operationDescription, status );

  output.oper = operation;
  output.index = 0;

  TF_SessionRun( session, 0,
                 0, 0, 0,  // Inputs
                 &output, &tensorOutput, 1,  // Outputs
                 &operation, 1,  // Operations
                 0, status );

  printf( "status code: %i\n", TF_GetCode( status ) );
  printf( "%s\n", ( ( char * ) TF_TensorData( tensorOutput ) ) + 9 );

  TF_CloseSession( session, status );
  TF_DeleteSession( session, status );
  TF_DeleteStatus( status );
  TF_DeleteSessionOptions( options );

  return 0;
}

Do we have to delete the tensorOutput ? Not sure why we have to add 9 (instead of 8) to get the beginning of the string.


问:
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

答: Try Build -> Clean Project andthen try it again</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


问:
Collection users - mLabs
I tried to obtain users API by mongolabs, but always return an empty list
It's strange because when I connect to mongo shell, users are displayed correctly.

Anybody know what is happening?

答:
I have the solution is:

https://api.mlab.com/api/1/databases/{database}/users?apiKey={myAPIKEy}

Title: Collection users - mLabs


问:
Kafka recommended system configuration
I'm expecting our influx in to Kafka to raise to around 2 TB/day over a period of time. I'm planning to setup a Kafka cluster with 2 brokers (each running on separate system). What is the recommended hardware configuration for handling 2 TB/day ?

答:
To use as a base you could look here: https://docs.confluent.io/4.1.1/installation/system-requirements.html#hardware

You need to know the amount of messages you get per second/hour because this will determine the size of your cluster. For HD, it's not necessary to get SSD because the system will use RAM to store the data first. Still you could need quite speed hard disk to ensure that the flushing process of the queue will not slow your system.

I would also recommend to use 3 kafka broker and 3 or 4 zookeeper server too.

Title: Kafka recommended system configuration

ContentLicense: CC BY-SA 4.0


问:
detecting indexPath row and pushing a new view controller to a split view controller
I have a split view controller that has a table on the left hand side, and a empty detail view controller on the right had side. For iphone, I know its possible to push a view controller and a nib in a navigational stack. I want to know if its possible to push a view controller + nib on the detail view, after a user taps the table cell.
I tried simply pushing the view i have after a user taps to the detail view, however nothing happens.</p>

答:
Have you tried just going to the developer.apple.com and use the standard example from Apple, which does exactly what ur saying?

Cell 1 = loads Xib1

Cell 2 = loads Xib2.

Maybe give that a go..


问:
How to set different colors for each word(dynamic words getting from server) in label?
I have multiple words in an array:

```<code>NSMutableArray * array = [[NSMutableArray alloc] initWithObjects:@"1 ball",@"2 ball",@"3 ball",@"4 ball", nil];
</code>```

I need to set these words into UILabel with different colors.

答:
For Swift you can use below code.</p>

```<code>import UIKit
var str = ["Hi", "Hello", "I", "am", "Prabhu"]
var newStr : [NSAttributedString] = []
var newS = NSMutableAttributedString()

func getRandomColor() -> UIColor{
  let randomRed:CGFloat = CGFloat(drand48())
  let randomGreen:CGFloat = CGFloat(drand48())
  let randomBlue:CGFloat = CGFloat(drand48())
  return UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0)
}

for s in str {
  let newString = NSMutableAttributedString.init(string: s + ",", attributes: [NSForegroundColorAttributeName : getRandomColor()])
  newS.append(newString)
}

print(newS)
</code>```

Body:
I have multiple words in an array:

NSMutableArray * array = [[NSMutableArray alloc] initWithObjects:@"1 ball",@"2 ball",@"3 ball",@"4 ball", nil];

I need to set these words into UILabel with different colors.

Body:
For Swift you can use below code.

import UIKit
var str = ["Hi", "Hello", "I", "am", "Prabhu"]
var newStr : [NSAttributedString] = []
var newS = NSMutableAttributedString()

func getRandomColor() -> UIColor{
  let randomRed:CGFloat = CGFloat(drand48())
  let randomGreen:CGFloat = CGFloat(drand48())
  let randomBlue:CGFloat = CGFloat(drand48())
  return UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0)
}

for s in str {
  let newString = NSMutableAttributedString.init(string: s + ",", attributes: [NSForegroundColorAttributeName : getRandomColor()])
  newS.append(newString)
}

print(newS)


问:
GPG Error Updating Ubuntu/Debian Packages
I am attempting to update my Ubuntu/Debian system and I am getting an error:

```<code>GPG error: http://deb.opera.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E585066A30C18A2B
</code>```

What does it mean, and how can I resolve it?

答:
Newer versions of apt also support

```<code>apt-key adv --fetch-keys https://deb.opera.com/archive.key
</code>```

instead of

```<code>wget -qO - https://deb.opera.com/archive.key | apt-key add -
</code>```

Additionally, you should always use https when loading the key.

Body:
I am attempting to update my Ubuntu/Debian system and I am getting an error:

GPG error: http://deb.opera.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E585066A30C18A2B

What does it mean, and how can I resolve it?

Body:
Newer versions of apt also support

apt-key adv --fetch-keys https://deb.opera.com/archive.key

instead of

wget -qO - https://deb.opera.com/archive.key | apt-key add -

Additionally, you should always use https when loading the key.


问:
Creating a GridView From Listview in ReactNative?(Without using libraries)
Consider a simple app in React Native that fetches listings from a remote JSON source and displays them on screen.

So far,I've managed to get the results to display using the ListView components in rows (i.e. 2 result per row, see screenshot).

in one row.both the grids display data of a single person,i want
details in a consecutive manner not repeating.

```<code>        </Content>
          <View style={{backgroundColor: 'white'}}>
           <Text style={{color: 'black',fontSize: 17,marginTop: 25,marginLeft: 15}}>Employees</Text>
          </View>
          <List dataArray={currentContext.props.employeeList}
            renderRow={(data) =>
              <ListItem>
                {this.renderRow(data)}
              </ListItem>
           } />
          </Content>
</code>```

The function renderRow(data) is given by

```<code>renderRow(data){
  return(
    typeOne()
  )
  function typeOne(){
    return(
      <View style={styles.gridContainer}>
        <Content contentContainerStyle={{
            padding:6,
            paddingBottom:0
          }}>
        <View style={{flex:1,}}>
            <Row>
              {renderCell(data.photo_url, 0,data.name)}
              {renderCell(data.photo_url, 1,data.name)}
            </Row>
        </View>
          </Content>
      </View>
    )
   function renderCell(bg,pos,title){
      if (pos%2==0) {
        return(
          <Col style={[{marginRight:3},styles.colStyle]}>
            {cellContent(bg,title)}
          </Col>
        )
      }else{
        return(
          <Col style={[{marginLeft:3},styles.colStyle]}>
            {cellContent(bg,title)}
          </Col>
        )
      }
      function cellContent(bg,title){
        if(bg==null){
          return null
        }
        return(
          <Button style={{flex:1,alignSelf:'stretch'}} underLayouColor='red'>
            <View style={styles.cellContent}>
              <Image style={{height:230,alignItems: 'stretch'}} source={{uri:bg}} blurRadius={1}/>
              <View style={[styles.cellTitleBg,{opacity: 0.5,marginTop: 10}]}>
              <Text style={[styles.cellTitle,{position:'absolute',bottom:0,right:5}]}>{title}</Text>
              </View>
            </View>
          </Button>
        )
      }
    }
  }
}
</code>```

How can get the list-view to return 2 data's per row ?

I will give you similar question for reference in the below link

ListView grid in React Native

please help me solve this issue.

The style part

```<code>const styles = StyleSheet.create({
    container: {
        flex:1,
        backgroundColor:'white',
    },
    button:{
        color:'white'
    },
    overLayView: {
        position:'absolute',
        alignSelf:'center',

    },
    gridContainer: {backgroundColor:'#EDF0F2',flex:1,},
    colStyle:{height:210,flex:1,marginBottom:6,marginRight:10,marginLeft:10},
    cellContent:{position:'absolute',left:0,right:0,top:0,bottom:0},
    cellTitleBg:{bottom:65,backgroundColor:'#778899',height:35},
    cellTitle:{bottom:65,color:'white',fontWeight:'bold',fontSize:17,right:0,textAlign:'right',right:0}
})
</code>```

答: Maybe use a wrapper library, I recommend this one: https://www.npmjs.com/package/react-native-easy-listview-gridview </p>

Body:
Consider a simple app in React Native that fetches listings from a remote JSON source and displays them on screen.

So far,I've managed to get the results to display using the ListView components in rows (i.e. 2 result per row, see screenshot).

in one row.both the grids display data of a single person,i want
details in a consecutive manner not repeating.

        </Content>
          <View style={{backgroundColor: 'white'}}>
           <Text style={{color: 'black',fontSize: 17,marginTop: 25,marginLeft: 15}}>Employees</Text>
          </View>
          <List dataArray={currentContext.props.employeeList}
            renderRow={(data) =>
              <ListItem>
                {this.renderRow(data)}
              </ListItem>
           } />
          </Content>

The function renderRow(data) is given by

renderRow(data){
  return(
    typeOne()
  )
  function typeOne(){
    return(
      <View style={styles.gridContainer}>
        <Content contentContainerStyle={{
            padding:6,
            paddingBottom:0
          }}>
        <View style={{flex:1,}}>
            <Row>
              {renderCell(data.photo_url, 0,data.name)}
              {renderCell(data.photo_url, 1,data.name)}
            </Row>
        </View>
          </Content>
      </View>
    )
   function renderCell(bg,pos,title){
      if (pos%2==0) {
        return(
          <Col style={[{marginRight:3},styles.colStyle]}>
            {cellContent(bg,title)}
          </Col>
        )
      }else{
        return(
          <Col style={[{marginLeft:3},styles.colStyle]}>
            {cellContent(bg,title)}
          </Col>
        )
      }
      function cellContent(bg,title){
        if(bg==null){
          return null
        }
        return(
          <Button style={{flex:1,alignSelf:'stretch'}} underLayouColor='red'>
            <View style={styles.cellContent}>
              <Image style={{height:230,alignItems: 'stretch'}} source={{uri:bg}} blurRadius={1}/>
              <View style={[styles.cellTitleBg,{opacity: 0.5,marginTop: 10}]}>
              <Text style={[styles.cellTitle,{position:'absolute',bottom:0,right:5}]}>{title}</Text>
              </View>
            </View>
          </Button>
        )
      }
    }
  }
}

How can get the list-view to return 2 data's per row ?

I will give you similar question for reference in the below link

ListView grid in React Native

please help me solve this issue.

The style part

const styles = StyleSheet.create({
    container: {
        flex:1,
        backgroundColor:'white',
    },
    button:{
        color:'white'
    },
    overLayView: {
        position:'absolute',
        alignSelf:'center',

    },
    gridContainer: {backgroundColor:'#EDF0F2',flex:1,},
    colStyle:{height:210,flex:1,marginBottom:6,marginRight:10,marginLeft:10},
    cellContent:{position:'absolute',left:0,right:0,top:0,bottom:0},
    cellTitleBg:{bottom:65,backgroundColor:'#778899',height:35},
    cellTitle:{bottom:65,color:'white',fontWeight:'bold',fontSize:17,right:0,textAlign:'right',right:0}
})


问:
Why does one action produce two jobs?
I use Spark 2.1.0.

Why does the following one action produce 2 identical jobs (same DAG in each one)? Shouldn't it produce just 1? Here you have the code:

```<code>val path = "/usr/lib/spark/examples/src/main/resources/people.txt"
val peopleDF = spark.
  sparkContext.
  textFile(path, 4).
  map(_.split(",")).
  map(attr => Person(attr(0), attr(1).trim.toInt)).
  toDF
peopleDF.show()
</code>```

I see that in the graphic interface when checking what is going on? I suppose it has something to do with all Data Frame transformation.

答:
Although in general, a single SQL query may lead to more than one Spark job in this particular case Spark 2.3.0-SNAPSHOT gives only one (contrary to what you see).

The Job 12 is also pretty nice, i.e. just a single-stage no-shuffle Spark job.

The reason to see more than one Spark job per Spark SQL's structured query (using SQL or Dataset API) is that Spark SQL offers a high level API atop RDDs and uses RDDs and actions freely to make your life as a Spark developer and a Spark performance tuning expert easier. In most cases (esp. when you wanted to build abstractions), you'd have to fire up the Spark jobs yourself to achieve the comparable performance.

Title: Why does one action produce two jobs?

Body:
I use Spark 2.1.0.

Why does the following one action produce 2 identical jobs (same DAG in each one)? Shouldn't it produce just 1? Here you have the code:

val path = "/usr/lib/spark/examples/src/main/resources/people.txt"
val peopleDF = spark.
  sparkContext.
  textFile(path, 4).
  map(_.split(",")).
  map(attr => Person(attr(0), attr(1).trim.toInt)).
  toDF
peopleDF.show()

I see that in the graphic interface when checking what is going on? I suppose it has something to do with all Data Frame transformation.


问:
get NullPointerException when calling constructor
I have class that extends AsyncTask :

```<code>    public class DailyCourse extends AsyncTask<Integer, Void , Object> {
           public DailyCourse (){
           }
    }
</code>```

I have Override necessary  functions and have my own functions too .

in main activity that implements my custom interface I try to call constructor :

```<code>    public class Luncher extends AppCompatActivity implements DailyCourseAsyncResponse {
              dailyCourse = new DailyCourse() ;
    }
</code>```

note that I do this after onCreate and problem is I get this error  :

```<code>      java.lang.NullPointerException: Attempt to invoke virtual method
     'java.lang.String android.content.res.Resources.getString(int)' on a
      null object reference
</code>```

what is the problem ?
NOTE : it's not duplicate with this , I know what is null exception , the problem "was" I did not know why I get that in my case (solved)

答:
I found the problem !
as @RobertK mentioned I was trying to access resources in a wrong way somewhere.
and "somewhere" is one of my class private final properties that I was trying to set value in wrong way . ( my Resource object was null )</p>

Body:
I have class that extends AsyncTask :

    public class DailyCourse extends AsyncTask<Integer, Void , Object> {
           public DailyCourse (){
           }
    }

I have Override necessary  functions and have my own functions too .

in main activity that implements my custom interface I try to call constructor :

    public class Luncher extends AppCompatActivity implements DailyCourseAsyncResponse {
              dailyCourse = new DailyCourse() ;
    }

note that I do this after onCreate and problem is I get this error  :

      java.lang.NullPointerException: Attempt to invoke virtual method
     'java.lang.String android.content.res.Resources.getString(int)' on a
      null object reference

what is the problem ?
NOTE : it's not duplicate with this , I know what is null exception , the problem "was" I did not know why I get that in my case (solved)


问:
How to download and play the song(.mp3,.m4a) if we know the url in android
I need to download a .mp3 or .m4a file from the server by using an URL, and then play that song.

Any ideas?

答:
Try this code in your file:

USE

```<code>url = "your url name+filename.jpg,mp3,etc..."
FileName = "/sdcard/savefilename" // save in your sdcard

  try{
        java.io.BufferedInputStream in = new java.io.BufferedInputStream(new java.net.URL(url).openStream());
        java.io.FileOutputStream fos = new java.io.FileOutputStream(FileName);
        java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
        byte[] data = new byte[1024];
        int x=0;
        while((x=in.read(data,0,1024))>=0){
            bout.write(data,0,x);
        }
        fos.flush();
        bout.flush();
        fos.close();
        bout.close();
        in.close();
  }
    catch (Exception ex)
    {
     }
</code>```

and after you want to use MediaPlayer
and create object of mediaplayer in your activity
and play.

```<code>mp.reset();
mp.start();
</code>```

like this.

Hope this will help you a lot.

Body:
Try this code in your file:

USE

url = "your url name+filename.jpg,mp3,etc..."
FileName = "/sdcard/savefilename" // save in your sdcard

  try{
        java.io.BufferedInputStream in = new java.io.BufferedInputStream(new java.net.URL(url).openStream());
        java.io.FileOutputStream fos = new java.io.FileOutputStream(FileName);
        java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
        byte[] data = new byte[1024];
        int x=0;
        while((x=in.read(data,0,1024))>=0){
            bout.write(data,0,x);
        }
        fos.flush();
        bout.flush();
        fos.close();
        bout.close();
        in.close();
  }
    catch (Exception ex)
    {
     }

and after you want to use MediaPlayer
and create object of mediaplayer in your activity
and play.

mp.reset();
mp.start();

like this.

Hope this will help you a lot.


问:
Hadoop mapreduce program fails with exitcode 127
Tyring to run some hadoop program. I see NameNode, Datanode, Yarn cluster URL up and running. i.e. 127.0.0.1:50070 /dfshealth.jsp, localhost:8088 /cluster/cluster, etc

But When i try to run my mapreduce program as : $ hadoop MySampleProgram hdfs://localhost/user/cyg_server/input/myfile.txt hdfs: //localhost/user/cyg_server/output/op

The program fails with logs:

INFO mapreduce.Job (Job.java:monitorAndPrintJob(1295)) - map 0% reduce
  0%

INFO mapreduce.Job (Job.java:monitorAndPrintJob(1308)) - Job
  job_1354496967950_0003 failed with state FAILED due to: Application
  application_1354496967950_0003 failed 1 times due to AM Container for
  appattempt_1354496967950_0003_000001 exited with exitCode: 127 due to:
  .Failing this attempt.. Failing the application.

2012-12-03 07:29:50,544 INFO mapreduce.Job
  (Job.java:monitorAndPrintJob(1313)) - Counters: 0

When i did through some of the logs i notice this: nodemanager.DefaultContainerExecutor (DefaultContainerExecutor.java:launchContainer(193)) - Exit code from task is : 127

I am running in Windows 7, with cygwin.

Any input is greatly appreciated.

:::ADDING MORE INFO HERE:::
As of now i can see that the following hadoop source while execution [trying to set launch container] fails... I am adding the source URL for that file here.... (note this is not hadoop error but i am pointing out but some thing i am missing)....
Class:DefaultContainerExecutor
Method:launchContainer
Lines: from the start of the method launchContainer to 195 where it print the code.

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.hadoop/hadoop-yarn-server-nodemanager/0.23.1/org/apache/hadoop/yarn/server/nodemanager/DefaultContainerExecutor.java#193

NODE MANAGER LOG EXTRACT

INFO nodemanager.DefaultContainerExecutor
  (DefaultContainerExecutor.java:launchContainer(175)) -
  launchContainer: [bash,
  /tmp/nm-local-...2936_0003/container_1354566282936_0003_01_000001/default_container_executor.sh]

WARN  nodemanager.DefaultContainerExecutor
  (DefaultContainerExecutor.java:launchContainer(193)) - Exit code from
  task is : 127

INFO  nodemanager.ContainerExecutor
  (ContainerExecutor.java:logOutput(167)) -

WARN  launcher.ContainerLaunch (ContainerLaunch.java:call(274)) -
  Container exited with a non-zero exit code 127

Thanks Hari

答:
Hard coding the java home path inside hadoop-env.sh solved the issue for me as follows:</p>

```<code>export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
</code>```

Body:
Hard coding the java home path inside hadoop-env.sh solved the issue for me as follows:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home


问:
Jboss server 6.x not starting
I am getting following problem while starting the server jboss 6.1
I have installed jboss 6.0 and tryning to run my project but while starting the server it is showing following error.

```<code>13:49:31,222 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Parse: name=vfs:///D:/Abhishek%20Kumar/NSAP/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_AS_6.x1496733181905/deploy/NSAP.war state=PreParse mode=Manual requiredState=Parse: org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfs:///D:/Abhishek%20Kumar/NSAP/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_AS_6.x1496733181905/deploy/NSAP.war
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:383) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:343) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:315) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.deploy(AbstractParsingDeployerWithOutput.java:255) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.2.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.2.GA]
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.2.GA]
at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.1.0.Final]
at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.SP2]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
at org.jboss.profileservice.AbstractProfileService.activateProfile(AbstractProfileService.java:154) [:0.2.2]
at org.jboss.system.tools.ProfileServiceToolsFacade.addURI(ProfileServiceToolsFacade.java:233) [:6.1.0.Final]
at org.jboss.system.tools.LegacyDeploymentScannerAdapter.addURL(LegacyDeploymentScannerAdapter.java:140) [:6.1.0.Final]
at org.jboss.system.tools.DeploymentScanner.addURL(DeploymentScanner.java:91) [:6.1.0.Final]
at org.jboss.system.tools.DeploymentScanner.addURL(DeploymentScanner.java:83) [:6.1.0.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.8.0_121]
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.GA]
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.GA]
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.GA]
at org.jboss.system.server.jmx.MBeanServerWrapper.invoke(MBeanServerWrapper.java:138) [:6.1.0.Final]
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.access$300(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.8.0_121]
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.Transport$1.run(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.Transport$1.run(Unknown Source) [:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) [:1.8.0_121]
at sun.rmi.transport.Transport.serviceCall(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source) [:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) [:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.8.0_121]
at java.lang.Thread.run(Unknown Source) [:1.8.0_121]
</code>```

Please help me to fix this error.

答:
The root cause is JDK8.
JBoss 6.1.0 was tested against JDK6, not on JDK7 or JDK8.

https://developer.jboss.org/thread/195264

You have two options:

Upgrade JBoss to a current and supported version

Downgrade to JDK6

Title: Jboss server 6.x not starting

Body:
I am getting following problem while starting the server jboss 6.1
I have installed jboss 6.0 and tryning to run my project but while starting the server it is showing following error.

13:49:31,222 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Parse: name=vfs:///D:/Abhishek%20Kumar/NSAP/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_AS_6.x1496733181905/deploy/NSAP.war state=PreParse mode=Manual requiredState=Parse: org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfs:///D:/Abhishek%20Kumar/NSAP/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_AS_6.x1496733181905/deploy/NSAP.war
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:383) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:343) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:315) [:2.2.2.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.deploy(AbstractParsingDeployerWithOutput.java:255) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.2.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.2.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.2.GA]
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.2.GA]
at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.1.0.Final]
at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.SP2]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
at org.jboss.profileservice.AbstractProfileService.activateProfile(AbstractProfileService.java:154) [:0.2.2]
at org.jboss.system.tools.ProfileServiceToolsFacade.addURI(ProfileServiceToolsFacade.java:233) [:6.1.0.Final]
at org.jboss.system.tools.LegacyDeploymentScannerAdapter.addURL(LegacyDeploymentScannerAdapter.java:140) [:6.1.0.Final]
at org.jboss.system.tools.DeploymentScanner.addURL(DeploymentScanner.java:91) [:6.1.0.Final]
at org.jboss.system.tools.DeploymentScanner.addURL(DeploymentScanner.java:83) [:6.1.0.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.8.0_121]
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.GA]
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.GA]
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.GA]
at org.jboss.system.server.jmx.MBeanServerWrapper.invoke(MBeanServerWrapper.java:138) [:6.1.0.Final]
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.access$300(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(Unknown Source) [:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.8.0_121]
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.Transport$1.run(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.Transport$1.run(Unknown Source) [:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) [:1.8.0_121]
at sun.rmi.transport.Transport.serviceCall(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source) [:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) [:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) [:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.8.0_121]
at java.lang.Thread.run(Unknown Source) [:1.8.0_121]

Please help me to fix this error.


问:
Could not find the ... dump file, Win32 error 0n87
I tried loading a SYS file into WinDbg via File/ Open Crash Dump and it keeps saying

Could not find the C:\Windows[...]\win32k.sys Dump File, Win32 error 0n87

Invalid parameter

I checked multiple times with different tools: the file exists. There must be a different problem.

答:
In the background, WinDbg shows the command window with additional information. Once you click the "Ok" button, that information disappears, so keep the dialog open.

In your case, it may show something like

```<code>Loading dump file [C:\Windows\[...]\win32k.sys]
Could not match Dump File signature - invalid file format
Could not open dump file [C:\Windows\[...]\win32k.sys], Win32 error 0n87
Invalid parameter
</code>```

The second line clearly indicates that WinDbg was able to find the file, but still unable to open the file.

If you have a hex editor available, you'll see that WinDbg cannot open SYS files that start with DCD (a file format that I don't know in more detail) but will be able to open SYS files that start with MZ (the Portable Executable format).

Thanks to @magicandre1981 in the comments: Windows compacts files in the WinSXS directory. lzmsexpand can uncompress those files.

Body:
In the background, WinDbg shows the command window with additional information. Once you click the "Ok" button, that information disappears, so keep the dialog open.

In your case, it may show something like

Loading dump file [C:\Windows\[...]\win32k.sys]
Could not match Dump File signature - invalid file format
Could not open dump file [C:\Windows\[...]\win32k.sys], Win32 error 0n87
Invalid parameter

The second line clearly indicates that WinDbg was able to find the file, but still unable to open the file.

If you have a hex editor available, you'll see that WinDbg cannot open SYS files that start with DCD (a file format that I don't know in more detail) but will be able to open SYS files that start with MZ (the Portable Executable format).

Thanks to @magicandre1981 in the comments: Windows compacts files in the WinSXS directory. lzmsexpand can uncompress those files.


问:
Pandas resampling to the existing index
I have a long timeseries that ends with the following data.

```<code>               ABC     CDE
Date
2017-05-26  107.00  241.71
2017-05-30  107.27  241.50
2017-05-31  107.32  241.44
2017-06-01  107.10  243.36
2017-06-02  107.57  244.17
</code>```

I would like to resample it so that it becomes monthly data but I am interested in retaining the actual last monthly dates in the time series. If I do,

```<code>df.resample('BM').last()
</code>```

gives the following tail-end output

```<code>2017-05-31  107.32  241.44
2017-06-30  107.57  244.17
</code>```

which does not give the correct last date of the dataframe. There are other dates within the resampled dataframe that are off as well. Essentially Pandas isn't using the existing index to find the month end but it's own business day calendar.

Is there an option I can feed into the Pandas resampling function so that it uses the existing index to achieve the desired result which is

```<code>2017-05-31  107.32  241.44
2017-06-02  107.57  244.17
</code>```

答:
You can drop duplicates based on year and month and only keep the last row.

```<code>df.assign(m=df.index.to_period('m')).drop_duplicates('m','last').drop('m',1)
Out[728]:
               ABC     CDE
Date
2017-05-31  107.32  241.44
2017-06-02  107.57  244.17
</code>```

Or you can use group by year and month and then take the last row from each group.

```<code>df.reset_index()\
  .sort_values('Date')\
  .assign(m=df.index.to_period('m'))\
  .groupby(by='m')\
  .last()\
  .set_index('Date')
Out[677]:
               ABC     CDE
Date
2017-05-31  107.32  241.44
2017-06-02  107.57  244.17
</code>```

Title: Pandas resampling to the existing index

Body:
I have a long timeseries that ends with the following data.

               ABC     CDE
Date
2017-05-26  107.00  241.71
2017-05-30  107.27  241.50
2017-05-31  107.32  241.44
2017-06-01  107.10  243.36
2017-06-02  107.57  244.17

I would like to resample it so that it becomes monthly data but I am interested in retaining the actual last monthly dates in the time series. If I do,

df.resample('BM').last()

gives the following tail-end output

2017-05-31  107.32  241.44
2017-06-30  107.57  244.17

which does not give the correct last date of the dataframe. There are other dates within the resampled dataframe that are off as well. Essentially Pandas isn't using the existing index to find the month end but it's own business day calendar.

Is there an option I can feed into the Pandas resampling function so that it uses the existing index to achieve the desired result which is

2017-05-31  107.32  241.44
2017-06-02  107.57  244.17

Body:
You can drop duplicates based on year and month and only keep the last row.

df.assign(m=df.index.to_period('m')).drop_duplicates('m','last').drop('m',1)
Out[728]:
               ABC     CDE
Date
2017-05-31  107.32  241.44
2017-06-02  107.57  244.17

Or you can use group by year and month and then take the last row from each group.

df.reset_index()\
  .sort_values('Date')\
  .assign(m=df.index.to_period('m'))\
  .groupby(by='m')\
  .last()\
  .set_index('Date')
Out[677]:
               ABC     CDE
Date
2017-05-31  107.32  241.44
2017-06-02  107.57  244.17


问:
receiving an intent when completing a browser download
I'm writing a software update application that (among other stuff) does the following:

When I find an image I want to download, I'm passing an ACTION_VIEW intent to the Browser application.
The browser starts the download, and when it completes, I see the download complete message in the notification bar.

now I am facing the following problem:
I would like to receive an intent when the download is complete.

Can anyone help?

答:
You can check the following question Android browser download manager.
Basically you will need to use HttpClient as MarvinLabs told you.

If you will be android 2.3 only compatible, which I doubt, you can use DownloadManager.


问:
How do I link curl library with clion?
```<code>#include <iostream>
#include <curl/curl.h>

int main() {
   std::cout << "Hello, World!" << std::endl;
   return 0;
}
</code>```

I get error "fatal error: curl/curl.h: No such file or directory
compilation terminated." I'm really not sure which curl lib to download. I'm using windows 10 and clion with minicygwin. Really not sure what to add to the CMAKE file as well. Can anyone help? Also not sure where to download the file to? just my c:/?

Thanks

答:
with Cygwin specifically (idk anything about minicygwin, but i'm guessing its similar to normal Cygwin), just install libcurl4, and you won't get THAT error.

but then you'll get some undefined reference to curl errors, until you start compiling with -lcurl , when you fix that too, it should compile just fine :)

Title: How do I link curl library with clion?

Body:
#include <iostream>
#include <curl/curl.h>

int main() {
   std::cout << "Hello, World!" << std::endl;
   return 0;
}

I get error "fatal error: curl/curl.h: No such file or directory
compilation terminated." I'm really not sure which curl lib to download. I'm using windows 10 and clion with minicygwin. Really not sure what to add to the CMAKE file as well. Can anyone help? Also not sure where to download the file to? just my c:/?

Thanks


问:
How can I return a stackpanel element from a ValueConverter and get it to display properly
I have a datagrid that i'm binding to, and I have a valueConverter that i send an object to in hopes of returning an image with some text after it(which is put inside a stackpanel). However, upon displaying all I see in the gridview cell is System.Windows.Control.StackPanel.

Here is the xaml. I am binding the GrieView ItemsSource correctly and the value coming into the converter is correct.

```<code><telerik:GridViewDataColumn DataMemberBinding="{Binding Converter={StaticResource MyConverter}}" IsReadOnly="True">
 <telerik:GridViewDataColumn.Header>
  <TextBlock FontWeight="Bold" Text="Text" />
 </telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>
</code>```

This is basically exactly what the converter does.

```<code>StackPanel stackpanel = new StackPanel();
stackpanel.Orientation = Orientation.Horizontal;
stackpanel.Children.Add(Adds a UI element);

TextBlock textBlock = new TextBlock();
textBlock.Text = appendingText;
stackpanel.Children.Add(textBlock);
return stackpanel;
</code>```

but in the gridviewCell all that shows is a string reading System.Windows.Controls.StackPanel. Any help would be appreciated, thanks!

答:
Try to use a GridViewColumn and bind the Content property of a ContentControl using your converter:

```<code><telerik:GridViewColumn IsReadOnly="True">
    <telerik:GridViewColumn.Header>
        <TextBlock FontWeight="Bold" Text="Text" />
    </telerik:GridViewColumn.Header>
    <telerik:GridViewColumn.CellTemplate>
        <DataTemplate>
            <ContentControl Content="{Binding Converter={StaticResource MyConverter}}" />
        </DataTemplate>
    </telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
</code>```

Body:
I have a datagrid that i'm binding to, and I have a valueConverter that i send an object to in hopes of returning an image with some text after it(which is put inside a stackpanel). However, upon displaying all I see in the gridview cell is System.Windows.Control.StackPanel.

Here is the xaml. I am binding the GrieView ItemsSource correctly and the value coming into the converter is correct.

<telerik:GridViewDataColumn DataMemberBinding="{Binding Converter={StaticResource MyConverter}}" IsReadOnly="True">
 <telerik:GridViewDataColumn.Header>
  <TextBlock FontWeight="Bold" Text="Text" />
 </telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>

This is basically exactly what the converter does.

StackPanel stackpanel = new StackPanel();
stackpanel.Orientation = Orientation.Horizontal;
stackpanel.Children.Add(Adds a UI element);

TextBlock textBlock = new TextBlock();
textBlock.Text = appendingText;
stackpanel.Children.Add(textBlock);
return stackpanel;

but in the gridviewCell all that shows is a string reading System.Windows.Controls.StackPanel. Any help would be appreciated, thanks!

Body:
Try to use a GridViewColumn and bind the Content property of a ContentControl using your converter:

<telerik:GridViewColumn IsReadOnly="True">
    <telerik:GridViewColumn.Header>
        <TextBlock FontWeight="Bold" Text="Text" />
    </telerik:GridViewColumn.Header>
    <telerik:GridViewColumn.CellTemplate>
        <DataTemplate>
            <ContentControl Content="{Binding Converter={StaticResource MyConverter}}" />
        </DataTemplate>
    </telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>


问:
Bind FormBuilder input value with another input's value
I have a form with name and milestone inputs. I want my milestones input value to be Milestone: + name and to be updated automatically as my user types a name.

I am trying to use ngModel binding in order to achieve this.

```<code><!-- My name input -->
<input mdInput [(ngModel)]="phaseName" formControlName="name" placeholder="Nom" required>
</code>```

And in my ts components constructor:

```<code>public phaseForm: FormGroup;
phaseName: string;

this.phaseForm = fb.group({
        'name': ['', Validators.required],
        'milestone': ['Milestone: ' + this.phaseName, Validators.required]
    });
</code>```

But as the default value of milestone is set in the constructor, it does not update as my user types a name, what should I add or do in order to achieve my binding?

答:
Html

```<code><input mdInput formControlName="name" placeholder="Nom" required>

* no need of ngModel
</code>```

Component

To get value

this.phaseForm.value

and to detect changes you can do

this.phaseForm.valueChanges
      .subscribe(data => this.onValueChanged(data));

for the single property, you could do like

```<code>nameChangeLog: string[] = [];
logNameChange() {
  const nameControl = this.heroForm.get('name');
  nameControl.valueChanges.forEach(
    (value: string) => this.nameChangeLog.push(value)
  );
}
</code>```

check the cookbook here

you can initialize value as suggested by Shailesh Ladumor or
at the place where you initialize the form.

Body:
I have a form with name and milestone inputs. I want my milestones input value to be Milestone: + name and to be updated automatically as my user types a name.

I am trying to use ngModel binding in order to achieve this.

<input mdInput [(ngModel)]="phaseName" formControlName="name" placeholder="Nom" required>

And in my ts components constructor:

public phaseForm: FormGroup;
phaseName: string;

this.phaseForm = fb.group({
        'name': ['', Validators.required],
        'milestone': ['Milestone: ' + this.phaseName, Validators.required]
    });

But as the default value of milestone is set in the constructor, it does not update as my user types a name, what should I add or do in order to achieve my binding?

Body:
Html

<input mdInput formControlName="name" placeholder="Nom" required>

* no need of ngModel

Component

To get value

this.phaseForm.value

and to detect changes you can do

this.phaseForm.valueChanges
      .subscribe(data => this.onValueChanged(data));

for the single property, you could do like

nameChangeLog: string[] = [];
logNameChange() {
  const nameControl = this.heroForm.get('name');
  nameControl.valueChanges.forEach(
    (value: string) => this.nameChangeLog.push(value)
  );
}

check the cookbook here

you can initialize value as suggested by Shailesh Ladumor or
at the place where you initialize the form.


问:
read the following link
i want to go to next page of the following link

```<code><a href="javascript: __doPostBack('ctl00$PlaceHolderMain$g_781eb52f_faa9_4d59_9cae_2baec06ac484','dvt_firstrow={51};dvt_startposition={Paged=TRUE&p_Created_x0020_Date=6%2f9%2f2009%208%3a33%3a19%20AM&p_ID=216}');">
<img src="/_layouts/images/next.gif" border="0" alt="Next"></a></td></tr></table></div></td>
</code>```

how can i go next in java program

答:
This is just an observation... but from the code you have given, the link is a postback, not an actual "link" in the traditional sense. You will need to click on the link, in the page, in context, for it to do anything meaningful.

Using the code out of context will not (should not) work. The codebehind for that page will determine exactly what will happen when the postback is sent.

In all likeliness, your session has expired and the postback will do nothing...

Do you own/control the page's code? If you do, can you post the ASP and codebehind?

Title: read the following link

Body:
i want to go to next page of the following link

how can i go next in java program


问:
Using Pyenchant on AWS Lambda, can load package but not provider dictionaries, have compiled from source on EC2 and extracted .so files
I am trying to use the Python spellchecking library Pyenchant in a Lambda function on AWS. Pyenchant is a wrapper for the C libenchant library which in turn relies on word dictionaries from providers such as Aspell.

In my python code running on Lambda I am able to successfully import the enchant library having compiled it and the C libraries (libenchant.so) on an AWS linux EC2 instance and copying the outputs to my Lambda deployment package.

However, the pyenchant library cannot load any of the word dictionaries when run on Lambda that it needs to work. I then installed Aspell on the EC2 instance using:

```<code>yum install aspell-en enchant-aspell
</code>```

I then copied the following additional .so files to my deployment package's /lib folder:

libaspell.so

libenchant_aspell.so

libenchant_ispell.so

libenchant_myspell.so

libenchant.so

I'm pretty sure libenchant_aspell.so is the actual dictionary but it's not picking it up and I cannot figure out where to go next.

Below is my lambda_handler python code:

```<code>from __future__ import print_function
import os
import sys
import re
import enchant

enchant.set_param("enchant.aspell.dictionary.path","/var/task/lib")

def lambda_handler(event, context):

    print("# List available enchant dictionary languages")
    print(enchant.list_languages())
    b = enchant.Broker()
    print("# List available enchant brokers")
    print(b.describe())
    d = enchant.Dict("en_GB")
    # print(d.provider.name)
    # print(d.provider.file)
    return "Done"
</code>```

And here is the output from invoking the Lambda function:

```<code>START RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4 Version: $LATEST
# List available enchant dictionary languages
[]
# List available enchant brokers
[]
Dictionary for language 'en_GB' could not be found: DictNotFoundError
Traceback (most recent call last):
  File "/var/task/package_test.py", line 16, in lambda_handler
    d = enchant.Dict("en_GB")
  File "/var/task/enchant/__init__.py", line 558, in __init__
    _EnchantObject.__init__(self)
  File "/var/task/enchant/__init__.py", line 168, in __init__
    self._init_this()
  File "/var/task/enchant/__init__.py", line 565, in _init_this
    this = self._broker._request_dict_data(self.tag)
  File "/var/task/enchant/__init__.py", line 310, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "/var/task/enchant/__init__.py", line 258, in _raise_error
    raise eclass(default)
DictNotFoundError: Dictionary for language 'en_GB' could not be found

END RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4
REPORT RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4  Duration: 1.03 ms   Billed Duration: 100 ms     Memory Size: 256 MB Max Memory Used: 16 MB
</code>```

As you can see import enchant works fine but it cannot find any of the dictionary files.

I'm really stuck on this, have spent best part of 6 hours trying to figure out how to get this working. Thanks in advance for your help.

答: Well, for anyone else who comes across this problem (which will probably be no-one...) it turned out that it was not possible to use this package on Lambda. Something to do with not having the right infrastructure to load shared object resources several levels deep. In the end I just used a flask web server on EC2 and it worked fine.</p>

Body:
I am trying to use the Python spellchecking library Pyenchant in a Lambda function on AWS. Pyenchant is a wrapper for the C libenchant library which in turn relies on word dictionaries from providers such as Aspell.

In my python code running on Lambda I am able to successfully import the enchant library having compiled it and the C libraries (libenchant.so) on an AWS linux EC2 instance and copying the outputs to my Lambda deployment package.

However, the pyenchant library cannot load any of the word dictionaries when run on Lambda that it needs to work. I then installed Aspell on the EC2 instance using:

yum install aspell-en enchant-aspell

I then copied the following additional .so files to my deployment package's /lib folder:

libaspell.so

libenchant_aspell.so

libenchant_ispell.so

libenchant_myspell.so

libenchant.so

I'm pretty sure libenchant_aspell.so is the actual dictionary but it's not picking it up and I cannot figure out where to go next.

Below is my lambda_handler python code:

from __future__ import print_function
import os
import sys
import re
import enchant

enchant.set_param("enchant.aspell.dictionary.path","/var/task/lib")

def lambda_handler(event, context):

    print("# List available enchant dictionary languages")
    print(enchant.list_languages())
    b = enchant.Broker()
    print("# List available enchant brokers")
    print(b.describe())
    d = enchant.Dict("en_GB")
    # print(d.provider.name)
    # print(d.provider.file)
    return "Done"

And here is the output from invoking the Lambda function:

START RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4 Version: $LATEST
# List available enchant dictionary languages
[]
# List available enchant brokers
[]
Dictionary for language 'en_GB' could not be found: DictNotFoundError
Traceback (most recent call last):
  File "/var/task/package_test.py", line 16, in lambda_handler
    d = enchant.Dict("en_GB")
  File "/var/task/enchant/__init__.py", line 558, in __init__
    _EnchantObject.__init__(self)
  File "/var/task/enchant/__init__.py", line 168, in __init__
    self._init_this()
  File "/var/task/enchant/__init__.py", line 565, in _init_this
    this = self._broker._request_dict_data(self.tag)
  File "/var/task/enchant/__init__.py", line 310, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "/var/task/enchant/__init__.py", line 258, in _raise_error
    raise eclass(default)
DictNotFoundError: Dictionary for language 'en_GB' could not be found

END RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4
REPORT RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4  Duration: 1.03 ms   Billed Duration: 100 ms     Memory Size: 256 MB Max Memory Used: 16 MB

As you can see import enchant works fine but it cannot find any of the dictionary files.

I'm really stuck on this, have spent best part of 6 hours trying to figure out how to get this working. Thanks in advance for your help.


问:
How to keep original word document open when saving copy in HTML?
The problem I'm having is when I run my macro to save the current Word Document as a HTML type, the document still remains open but not in the original .docx format, it's in the .htm format.

If I were to edit the document after the macro is ran, it wouldn't remain on the original .docx format later.

I would appreciate feedback on how to remain in the original format when also saving a copy with a different format. Thanks.

Here is my docx to html code in VBA

```<code>Sub DocToHTML()

    Dim slice As String
    Dim strDocName As String
    Dim PathOrg As String

    On Error Resume Next

    strDocName = ActiveDocument.Name
    slice = Left(strDocName, InStrRev(strDocName, ".") - 1)
    strDocName = ActiveDocument.Path + "\" + slice
    ActiveDocument.SaveAs2 FileName:=strDocName, FileFormat:=wdFormatHTML

End Sub
</code>```

答:
Before you write code to do things like this stop and think how you would do it in the UI without code. Any code that you write will simply automate that process.

So what would you do in the UI?

Save the original document to preserve any changes that you have made.

Save a copy as html.

Reopen the original document.

Possibly close the html version.

So your code can be rewritten as follows:

```<code>Sub DocToHTML()

    Dim origName As String
    Dim saveName As String
    Dim docHTML As Document

    If Not ActiveDocument.Saved Then ActiveDocument.Save
    origName = ActiveDocument.FullName
    saveName = Left(origName, InStrRev(origName, ".") - 1)
    ActiveDocument.SaveAs2 FileName:=saveName, FileFormat:=wdFormatHTML

    Set docHTML = ActiveDocument
    Documents.Open origName
    docHTML.Close wdDoNotSaveChanges

End Sub
</code>```

Body:
The problem I'm having is when I run my macro to save the current Word Document as a HTML type, the document still remains open but not in the original .docx format, it's in the .htm format.

If I were to edit the document after the macro is ran, it wouldn't remain on the original .docx format later.

I would appreciate feedback on how to remain in the original format when also saving a copy with a different format. Thanks.

Here is my docx to html code in VBA

Sub DocToHTML()

    Dim slice As String
    Dim strDocName As String
    Dim PathOrg As String

    On Error Resume Next

    strDocName = ActiveDocument.Name
    slice = Left(strDocName, InStrRev(strDocName, ".") - 1)
    strDocName = ActiveDocument.Path + "\" + slice
    ActiveDocument.SaveAs2 FileName:=strDocName, FileFormat:=wdFormatHTML

End Sub

Body:
Before you write code to do things like this stop and think how you would do it in the UI without code. Any code that you write will simply automate that process.

So what would you do in the UI?

Save the original document to preserve any changes that you have made.

Save a copy as html.

Reopen the original document.

Possibly close the html version.

So your code can be rewritten as follows:

Sub DocToHTML()

    Dim origName As String
    Dim saveName As String
    Dim docHTML As Document

    If Not ActiveDocument.Saved Then ActiveDocument.Save
    origName = ActiveDocument.FullName
    saveName = Left(origName, InStrRev(origName, ".") - 1)
    ActiveDocument.SaveAs2 FileName:=saveName, FileFormat:=wdFormatHTML

    Set docHTML = ActiveDocument
    Documents.Open origName
    docHTML.Close wdDoNotSaveChanges

End Sub


问:
Convert array to tuple?
Is it possible to convert array to tuple in C#? Something like this:</p>

```<code>var ar = new int[2] {5, 7};
Tuple<int,int> t = Tuple.Create(ar);
</code>```

答:
your idea is a bad idea... array and tuples don't "mix" in C#/.NET. There are languages where the distance between arrays and classes is small (like Javascript, where with the [...] operator you can use both arrays and objects). C# isn't one of those languages. Tuples don't define a this[int n] indexer for exactly this reason.

But you asked for code, and so I'll give you code.

The main problem here is that the size of the array (and the size of the Tuple<>) must be known at compile time: in the code you wrote, you explicitly wrote Tuple<int, int>. You can easily create a method that, given an array of two (or more) elements, returns a Tuple<T, T>, like:

```<code>public static Tuple<T, T> CreateTuple2<T>(T[] array)
{
    if (array == null || array.Length < 2)
    {
        throw new ArgumentException(nameof(array));
    }

    return Tuple.Create(array[0], array[1]);
}
</code>```

From this you can create other CreateTuple3(), CreateTuple4()...

Title: Convert array to tuple?

Body:
Is it possible to convert array to tuple in C#? Something like this:

var ar = new int[2] {5, 7};
Tuple<int,int> t = Tuple.Create(ar);

Body:
your idea is a bad idea... array and tuples don't "mix" in C#/.NET. There are languages where the distance between arrays and classes is small (like Javascript, where with the [...] operator you can use both arrays and objects). C# isn't one of those languages. Tuples don't define a this[int n] indexer for exactly this reason.

But you asked for code, and so I'll give you code.

The main problem here is that the size of the array (and the size of the Tuple<>) must be known at compile time: in the code you wrote, you explicitly wrote Tuple<int, int>. You can easily create a method that, given an array of two (or more) elements, returns a Tuple<T, T>, like:

public static Tuple<T, T> CreateTuple2<T>(T[] array)
{
    if (array == null || array.Length < 2)
    {
        throw new ArgumentException(nameof(array));
    }

    return Tuple.Create(array[0], array[1]);
}

From this you can create other CreateTuple3(), CreateTuple4()...