问:
Can JSDoc document dynamically generated methods?
Here is a constructor function A that gives instances 2 methods: printThing and printBall.  I use JSDoc to document methods like this:

```<code>var A = function () {

    /**
     * Prints 'Thing'
     * @param {Number} N - The number of times to print.
     */
    this.printThing = function (N) {
        var i = 0;
        while (i < N) {
            console.log('Thing');
            i++
        }
    };

    /**
     * Prints 'Ball'
     * @param {Number} N - The number of times to print.
     */
    this.printBall = function (N) {
        var i = 0;
        while (i < N) {
            console.log('Ball');
            i++
        }
    };

};
</code>```

Here is an equivalent constructor function that dynamically generates the same methods like this:

```<code>var A = function () {

    var me = this;
    var registerPrinter = function (name) {
        me['print' + name] = function (N) {
            var i = 0;
            while (i < N) {
                console.log(name);
                i++;
            }
        };
    };

    registerPrinter('Thing');
    registerPrinter('Ball');
}
</code>```

The behaviour of the instances generated by the two constructor functions are identical:

```<code>> var a = new A();
> a.printBall(4);
Ball
Ball
Ball
Ball
</code>```

How can I use JSDoc to document the generated methods in the second A constructor function?

EDIT: registerPrinter is private within the scope of the constructor function.  It can (and should) be documented, but it's just used internally.  This question is about documenting the resulting public interface of A instances.

答:
@name is made for this:

This tag is best used in "virtual comments" for symbols that are not readily visible in the code...

ES6:

```<code>/** Class A */
class A {
    constructor () {
        ['Thing', 'Ball'].map((name) => {
            this['print' + name] = (N) => {
                let i = 0;
                while (i < N) {
                    console.log(name);
                    i++;
                }
            };
        });
    }
}

/**
 * @name A#printThing
 * @function
 * @memberof A
 * @description Prints 'Thing'
 * @param {Number} N - The number of times to print.
 */

/**
 * @name A#printBall
 * @function
 * @memberof A
 * @description Prints 'Ball'
 * @param {Number} N - The number of times to print.
 */
</code>```

ES5:

```<code>/**
 * @class A
 */
var A = function () {

    var me = this;
    var registerPrinter = function (name) {
        me['print' + name] = function (N) {
            var i = 0;
            while (i < N) {
                console.log(name);
                i++;
            }
        };
    };

    ['Thing', 'Ball'].map(registerPrinter);

    /**
     * @name A#printThing
     * @function
     * @memberof A
     * @description Prints 'Thing'
     * @param {Number} N - The number of times to print.
     */

    /**
     * @name A#printBall
     * @function
     * @memberof A
     * @description Prints 'Ball'
     * @param {Number} N - The number of times to print.
     */
}
</code>```

Body:
Here is a constructor function A that gives instances 2 methods: printThing and printBall.  I use JSDoc to document methods like this:

var A = function () {

    /**
     * Prints 'Thing'
     * @param {Number} N - The number of times to print.
     */
    this.printThing = function (N) {
        var i = 0;
        while (i < N) {
            console.log('Thing');
            i++
        }
    };

    /**
     * Prints 'Ball'
     * @param {Number} N - The number of times to print.
     */
    this.printBall = function (N) {
        var i = 0;
        while (i < N) {
            console.log('Ball');
            i++
        }
    };

};

Here is an equivalent constructor function that dynamically generates the same methods like this:

var A = function () {

    var me = this;
    var registerPrinter = function (name) {
        me['print' + name] = function (N) {
            var i = 0;
            while (i < N) {
                console.log(name);
                i++;
            }
        };
    };

    registerPrinter('Thing');
    registerPrinter('Ball');
}

The behaviour of the instances generated by the two constructor functions are identical:

> var a = new A();
> a.printBall(4);
Ball
Ball
Ball
Ball

How can I use JSDoc to document the generated methods in the second A constructor function?

EDIT: registerPrinter is private within the scope of the constructor function.  It can (and should) be documented, but it's just used internally.  This question is about documenting the resulting public interface of A instances.

Body:
@name is made for this:

This tag is best used in "virtual comments" for symbols that are not readily visible in the code...

ES6:

/** Class A */
class A {
    constructor () {
        ['Thing', 'Ball'].map((name) => {
            this['print' + name] = (N) => {
                let i = 0;
                while (i < N) {
                    console.log(name);
                    i++;
                }
            };
        });
    }
}

/**
 * @name A#printThing
 * @function
 * @memberof A
 * @description Prints 'Thing'
 * @param {Number} N - The number of times to print.
 */

/**
 * @name A#printBall
 * @function
 * @memberof A
 * @description Prints 'Ball'
 * @param {Number} N - The number of times to print.
 */

ES5:

/**
 * @class A
 */
var A = function () {

    var me = this;
    var registerPrinter = function (name) {
        me['print' + name] = function (N) {
            var i = 0;
            while (i < N) {
                console.log(name);
                i++;
            }
        };
    };

    ['Thing', 'Ball'].map(registerPrinter);

    /**
     * @name A#printThing
     * @function
     * @memberof A
     * @description Prints 'Thing'
     * @param {Number} N - The number of times to print.
     */

    /**
     * @name A#printBall
     * @function
     * @memberof A
     * @description Prints 'Ball'
     * @param {Number} N - The number of times to print.
     */
}


来源: stackexchange

问:
What is the unit for spark.network.timeout property without postfix? Seconds or milliseconds?
If the spark.network.timeout defined without any postfix (s or ms) like this:

```<code>spark.network.timeout 600
</code>```

is that second or millisecond?

The default value on the https://spark.apache.org/docs/latest/configuration.html
is also defined with postfix "120s"

答:
Given the lines in HeartbeatReceiver it seems that spark.network.timeout is in seconds.

```<code>// "spark.network.timeout" uses "seconds", while `spark.storage.blockManagerSlaveTimeoutMs` uses
// "milliseconds"
private val slaveTimeoutMs =
  sc.conf.getTimeAsMs("spark.storage.blockManagerSlaveTimeoutMs", "120s")
private val executorTimeoutMs =
  sc.conf.getTimeAsSeconds("spark.network.timeout", s"${slaveTimeoutMs}ms") * 1000
</code>```

The official documentation of Spark in Spark Properties says:

Properties that specify some time duration should be configured with a unit of time.

Properties that specify a byte size should be configured with a unit of size.

Hard to find, but hopefully it becomes easier with your question and my answer.

ContentLicense: CC BY-SA 3.0

Body:
If the spark.network.timeout defined without any postfix (s or ms) like this:

spark.network.timeout 600

is that second or millisecond?

The default value on the https://spark.apache.org/docs/latest/configuration.html
is also defined with postfix "120s"

Body:
Given the lines in HeartbeatReceiver it seems that spark.network.timeout is in seconds.

// "spark.network.timeout" uses "seconds", while `spark.storage.blockManagerSlaveTimeoutMs` uses
// "milliseconds"
private val slaveTimeoutMs =
  sc.conf.getTimeAsMs("spark.storage.blockManagerSlaveTimeoutMs", "120s")
private val executorTimeoutMs =
  sc.conf.getTimeAsSeconds("spark.network.timeout", s"${slaveTimeoutMs}ms") * 1000

The official documentation of Spark in Spark Properties says:

Properties that specify some time duration should be configured with a unit of time.

Properties that specify a byte size should be configured with a unit of size.

Hard to find, but hopefully it becomes easier with your question and my answer.


问:
Run a query multiple times with same values
I'm using c# and trying to insert into sql same query multiple times:
  Here is my code:

```<code> SqlCommand cmd = new  SqlCommand ("insert into InventoryTransTemp (name) values ('test')",con);
 cmd.ExecuteNonQuery();
</code>```

How can i run this same query example 5 times??

Can i use a string for doing this? Example if string count=5 then run query 5 times

答:
If you want to specific query, you can use in the method. Maybe firstly you should search how many same string is counted like this:</p>

```<code>public void run() {
  SqlCommand cmd = new SqlCommand("insert into InventoryTransTemp (name) values ('test')", con);
  cmd.ExecuteNonQuery();
}

public int findString() {
  int i = 0;
  SqlDataReader stRead = new sqlCommand("SELECT * FROM database ", con);
  while (stRead.Read()) {
    i++;
  }
  return i;
}
int i = findString();
for (int j = 0; j < i; j++) {
  run();
}
</code>```

Body:
I'm using c# and trying to insert into sql same query multiple times:
  Here is my code:

 SqlCommand cmd = new  SqlCommand ("insert into InventoryTransTemp (name) values ('test')",con);
 cmd.ExecuteNonQuery();

How can i run this same query example 5 times??

Can i use a string for doing this? Example if string count=5 then run query 5 times

Body:
If you want to specific query, you can use in the method. Maybe firstly you should search how many same string is counted like this:

public void run() {
  SqlCommand cmd = new SqlCommand("insert into InventoryTransTemp (name) values ('test')", con);
  cmd.ExecuteNonQuery();
}

public int findString() {
  int i = 0;
  SqlDataReader stRead = new sqlCommand("SELECT * FROM database ", con);
  while (stRead.Read()) {
    i++;
  }
  return i;
}
int i = findString();
for (int j = 0; j < i; j++) {
  run();
}


问:
Ajax doesn't return json if there is text in php file
I'm pretty new to Jquery Ajax and sorry if that's a simple thing.

So my problem here is that I want to retrieve a json object from my php file, but it only works when I echo only one Json object like this :

```<code><?php
header('Content-type: application/json; charset=utf-8');
$arr = array ('Lastname'=>'Doe','Firstname'=>'John','Age'=>109);
echo json_encode($arr);
</code>```

When I want to echo another json or some text returned as json in my javascript file, I don't get anything back from the ajax call.

```<code>  <?php
// This code doesn't work
    header('Content-type: application/json; charset=utf-8');
    $arr = array ('Lastname'=>'Doe','Firstname'=>'John','Age'=>109);
    echo 'hi there';
    $json = 'Hello people';
    echo json_encode($json);
    echo json_encode($arr);
</code>```

My ajax call is this :

```<code>$.ajax({
        url: 'test.php',
        type: 'GET',
        success: function (response) {
            console.log(response);
        }
    });
</code>```

So my final question is : what's wrong in my code, and what's not allowed in ajax call

答:
You cannot merge two JSON encoded objects as this results in invalid JSON syntax.

What you can do is build a single array/object, encode into JSON and echo the resulting string.

The encoded string is the only output you can send back to the client.

Body:
I'm pretty new to Jquery Ajax and sorry if that's a simple thing.

So my problem here is that I want to retrieve a json object from my php file, but it only works when I echo only one Json object like this :

<?php
header('Content-type: application/json; charset=utf-8');
$arr = array ('Lastname'=>'Doe','Firstname'=>'John','Age'=>109);
echo json_encode($arr);

When I want to echo another json or some text returned as json in my javascript file, I don't get anything back from the ajax call.

  <?php
// This code doesn't work
    header('Content-type: application/json; charset=utf-8');
    $arr = array ('Lastname'=>'Doe','Firstname'=>'John','Age'=>109);
    echo 'hi there';
    $json = 'Hello people';
    echo json_encode($json);
    echo json_encode($arr);

My ajax call is this :

$.ajax({
        url: 'test.php',
        type: 'GET',
        success: function (response) {
            console.log(response);
        }
    });

So my final question is : what's wrong in my code, and what's not allowed in ajax call


问:
How to integrate a local repository with current unity project?
I am trying to integrate a version/source control system with my unity project. This answer directed me towards using source/version control. (I dont know the difference.)

The answer links to a tutorial which explains creating the repository and pushing it to a remote service. I followed the whole tutorial. But I still don't understand how this integrates with my current projects.

My question is that.

how can I do this locally

how will this make it possible to revert to previously-saved versions?

答:
First you install Git (or SVN, Sourcetree,...).

Navigate to the project using cd.

git init (initiate a git repo, it adds a .git folder)

Do changes to your project

git status (shows if any differences)

git diff (see the differences, can be real long)

git add . (this stages your changes, you can cherry pick with git add myfile.txt for instance)

git commit -m 'Changes made' (this commits locally)

Then if you use a remote service like github or BitBucket you would push to remote with

```<code>git remote add origin http://IP/path/to/repository (only once no need to do each time)
git push origin master
</code>```

In order to revert, you first look at the commits:

```<code>git log
</code>```

then you jump to the commit with

```<code>git reset --hard sshcommitNumber
</code>```

More on this there How to revert Git repository to a previous commit?

Body:
First you install Git (or SVN, Sourcetree,...).

Navigate to the project using cd.

git init (initiate a git repo, it adds a .git folder)

Do changes to your project

git status (shows if any differences)

git diff (see the differences, can be real long)

git add . (this stages your changes, you can cherry pick with git add myfile.txt for instance)

git commit -m 'Changes made' (this commits locally)

Then if you use a remote service like github or BitBucket you would push to remote with

git remote add origin http://IP/path/to/repository (only once no need to do each time)
git push origin master

In order to revert, you first look at the commits:

git log

then you jump to the commit with

git reset --hard sshcommitNumber

More on this there How to revert Git repository to a previous commit?


问:
How to Deserialize from web service JSON array or object?
I created one web service application in windows phone 7. this is JSON array get from belowed uri.
...[{"id":4,"name":"Bangalore"},{"id":1,"name":"Chennai"},{"id":3,"name":"Hyderabad"},{"id":2,"name":"Mumbai"}]...

List item = (List)ds.ReadObject(msnew);
In this line one bug(it says while run).

There was an error deserializing the object of type.Data at the root level is invalid. Line 1, position 1.

coding:

public MainPage()
        {
            InitializeComponent();
        }

```<code>    [DataContract]
    public class Item
    {

        [DataMember]
        public int id
        {
            get;
            set;
        }

        [DataMember]
        public string name
        {
            get;
            set;
        }
    }
    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        WebClient wc = new WebClient();
        wc.DownloadStringAsync(new Uri("http://75.101.161.83:8080/CityGuide/Cities?authId=CITY4@$pir*$y$t*m$13GUID*5"));
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
    }

    void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
       string MyJsonString = e.Result;
      // MessageBox.Show(e.Result);
       DataContractSerializer ds = new DataContractSerializer(typeof(Item));
       MemoryStream msnew = new MemoryStream(Encoding.UTF8.GetBytes(MyJsonString));
       List<Item> item = (List<Item>)ds.ReadObject(msnew);
    }
</code>```

答:
There are 2 mistakes in what you're trying to do.

You're using DataContractSerializer instead of DataContractJsonSerializer. The one you're trying to use is expecting XML, not JSON.

You're trying to deserialize to a single Item and then convert that to a List<Item>, rather than an array, which is what json contains.

Try this instead:

```<code>  var ds = new DataContractJsonSerializer(typeof(Item[]));
  var msnew = new MemoryStream(Encoding.UTF8.GetBytes(MyJsonString));
  Item[] items = (Item[])ds.ReadObject(msnew);
</code>```

If you later wanted to, you could convert the array to a list.

ContentLicense: CC BY-SA 2.5

Body:
I created one web service application in windows phone 7. this is JSON array get from belowed uri.
...[{"id":4,"name":"Bangalore"},{"id":1,"name":"Chennai"},{"id":3,"name":"Hyderabad"},{"id":2,"name":"Mumbai"}]...

List item = (List)ds.ReadObject(msnew);
In this line one bug(it says while run).

There was an error deserializing the object of type.Data at the root level is invalid. Line 1, position 1.

coding:

public MainPage()
        {
            InitializeComponent();
        }

    [DataContract]
    public class Item
    {

        [DataMember]
        public int id
        {
            get;
            set;
        }

        [DataMember]
        public string name
        {
            get;
            set;
        }
    }
    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        WebClient wc = new WebClient();
        wc.DownloadStringAsync(new Uri("http://75.101.161.83:8080/CityGuide/Cities?authId=CITY4@$pir*$y$t*m$13GUID*5"));
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
    }

    void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
       string MyJsonString = e.Result;
      // MessageBox.Show(e.Result);
       DataContractSerializer ds = new DataContractSerializer(typeof(Item));
       MemoryStream msnew = new MemoryStream(Encoding.UTF8.GetBytes(MyJsonString));
       List<Item> item = (List<Item>)ds.ReadObject(msnew);
    }

Body:
There are 2 mistakes in what you're trying to do.

You're using DataContractSerializer instead of DataContractJsonSerializer. The one you're trying to use is expecting XML, not JSON.

You're trying to deserialize to a single Item and then convert that to a List<Item>, rather than an array, which is what json contains.

Try this instead:

  var ds = new DataContractJsonSerializer(typeof(Item[]));
  var msnew = new MemoryStream(Encoding.UTF8.GetBytes(MyJsonString));
  Item[] items = (Item[])ds.ReadObject(msnew);

If you later wanted to, you could convert the array to a list.


问:
Call a method of a class, when that class calls a method in an instance of another class, Javascript
Weird question

I have an object, which creates an instance of a class like so:

```<code>main = new Main();

Main.proto.setup() {
  ...
  this.sys = new System(args)
  ...
}
</code>```

And for this class System, there's a method setMode, so that it can be called like:

```<code>main.sys.setMode(args)
</code>```

setMode is called in various places in Main. I have a method in Main:

```<code>Main.proto.update() {
  ...(No args)
}
</code>```

Which I'd like to be called everytime setMode is called. But I don't want to have to put it everywhere that setMode is called. How can I accomplish this?

答:
You can create function setMode in Main, which will call this.sys.setMode and this.update, and call this function instead of directly calling main.sys.setMode.

```<code>Main.prototype.setMode = function(...args) {
  this.sys.setMode(...args);
  this.update();
}
</code>```

You can also overwrite the main.sys.setMode method like that:

```<code>(function(setModeCopy) {
  main.sys.setMode = function(...args) {
    main.update();
    setModeCopy.call(main.sys, ...args);
  }
}(main.sys.setMode));
</code>```

Body:
Weird question

I have an object, which creates an instance of a class like so:

main = new Main();

Main.proto.setup() {
  ...
  this.sys = new System(args)
  ...
}

And for this class System, there's a method setMode, so that it can be called like:

main.sys.setMode(args)

setMode is called in various places in Main. I have a method in Main:

Main.proto.update() {
  ...(No args)
}

Which I'd like to be called everytime setMode is called. But I don't want to have to put it everywhere that setMode is called. How can I accomplish this?

Body:
You can create function setMode in Main, which will call this.sys.setMode and this.update, and call this function instead of directly calling main.sys.setMode.

Main.prototype.setMode = function(...args) {
  this.sys.setMode(...args);
  this.update();
}

You can also overwrite the main.sys.setMode method like that:

(function(setModeCopy) {
  main.sys.setMode = function(...args) {
    main.update();
    setModeCopy.call(main.sys, ...args);
  }
}(main.sys.setMode));


答:
Just commit changes, they will be saved on your local repository.

you can revert commits, to remove some changes or checkout any commit to return to commited state of project.

In Editor Settings set Asset Serialisation to Text, that allow You to see all the changes you have made in your project.

Title: How to integrate a local repository with current unity project?

Body:
I am trying to integrate a version/source control system with my unity project. This answer directed me towards using source/version control. (I dont know the difference.)

The answer links to a tutorial which explains creating the repository and pushing it to a remote service. I followed the whole tutorial. But I still don't understand how this integrates with my current projects.

My question is that.

how can I do this locally

how will this make it possible to revert to previously-saved versions?


问:
NestedScrollView size is not fit to CollapsingToolbarLayout
I am tring to apply CollapsingToolbarLayout in my app.

Below XML works fine.

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                    xmlns:ads="http://schemas.android.com/apk/res-auto"
                                    xmlns:app="http://schemas.android.com/apk/res-auto"
                                    xmlns:tools="http://schemas.android.com/tools"
                                    android:id="@+id/drawer_layout"
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/tilTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="24dp"
                android:layout_marginStart="56dp"
                android:layout_marginTop="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/Toolbar"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

                <ViewSwitcher
                    android:id="@+id/switcherTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <TextView
                        android:id="@+id/tvTitle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/title"
                        android:textSize="36sp"/>

                    <EditText
                        android:id="@+id/etTitle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:hint="@string/title"
                        android:inputType="textMultiLine"
                        android:textSize="36sp"/>
                </ViewSwitcher>
            </android.support.design.widget.TextInputLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/Toolbar"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <FrameLayout
            android:id="@+id/contentFrame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_save_confirm_action_item"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:src="@drawable/ic_done_white_36dp"
        app:fabSize="normal"
        app:layout_anchor="@id/collapsingToolbar"
        app:layout_anchorGravity="bottom|right|end"/>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adBannerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-5185146194441120/1301019297"/>
</android.support.design.widget.CoordinatorLayout>
</code>```

But there is one issue.

NestedScrollView over the screen.

It is not fit in its parent height.

When I apply below code, it is helpful.

```<code>android:layout_marginBottom="?attr/actionBarSize"
</code>```

This mean that should I control using "actionBarHeight"?

Is there any other smart way?

答:
You need to call setSupportActionBar with your toolbar in the Activity onCreate method.

i.e.

```<code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
</code>```

Body:
I am tring to apply CollapsingToolbarLayout in my app.

Below XML works fine.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                    xmlns:ads="http://schemas.android.com/apk/res-auto"
                                    xmlns:app="http://schemas.android.com/apk/res-auto"
                                    xmlns:tools="http://schemas.android.com/tools"
                                    android:id="@+id/drawer_layout"
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/tilTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="24dp"
                android:layout_marginStart="56dp"
                android:layout_marginTop="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/Toolbar"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

                <ViewSwitcher
                    android:id="@+id/switcherTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <TextView
                        android:id="@+id/tvTitle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/title"
                        android:textSize="36sp"/>

                    <EditText
                        android:id="@+id/etTitle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:hint="@string/title"
                        android:inputType="textMultiLine"
                        android:textSize="36sp"/>
                </ViewSwitcher>
            </android.support.design.widget.TextInputLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/Toolbar"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <FrameLayout
            android:id="@+id/contentFrame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_save_confirm_action_item"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:src="@drawable/ic_done_white_36dp"
        app:fabSize="normal"
        app:layout_anchor="@id/collapsingToolbar"
        app:layout_anchorGravity="bottom|right|end"/>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adBannerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-5185146194441120/1301019297"/>
</android.support.design.widget.CoordinatorLayout>

But there is one issue.

NestedScrollView over the screen.

It is not fit in its parent height.

When I apply below code, it is helpful.

android:layout_marginBottom="?attr/actionBarSize"

This mean that should I control using "actionBarHeight"?

Is there any other smart way?

Body:
You need to call setSupportActionBar with your toolbar in the Activity onCreate method.

i.e.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}


问:
Pushing an image to Google Container Registry from inside a Docker container
I'm currently trying to push a Docker image to my Container Registry this is the only command that is used in the documentation:

```<code>gcloud docker -- push gcr.io/my_project/foo:v1
</code>```

But since I run the google-cloud-sdk inside a Docker container I can't use gcloud docker ... because Docker is running on the host.

Is there some way I could push the image to the Container Registry without having to install the google-cloud-sdk on my local filesystem?

答:
I managed to find an answer myself but for reference I won't delete the question but instead just post the answer.

In order to push Docker images directly from the docker client to the Google Container Registry you need to use the docker login command together with the authentication token for your Google Cloud project.

To get an authentication token for your Google Cloud project use:

```<code>gcloud auth application-default print-access-token
</code>```

Then use that token to log in to the Google Cloud with docker:

```<code>docker login -u oauth2accesstoken -p "token_goes_here" https://gcr.io
</code>```

If the login has been successfull you should now be able to push images directly to the Google Container Registry:

```<code>docker push gcr.io/my_project/foo:v1
</code>```

Body:
I'm currently trying to push a Docker image to my Container Registry this is the only command that is used in the documentation:

gcloud docker -- push gcr.io/my_project/foo:v1

But since I run the google-cloud-sdk inside a Docker container I can't use gcloud docker ... because Docker is running on the host.

Is there some way I could push the image to the Container Registry without having to install the google-cloud-sdk on my local filesystem?

Body:
I managed to find an answer myself but for reference I won't delete the question but instead just post the answer.

In order to push Docker images directly from the docker client to the Google Container Registry you need to use the docker login command together with the authentication token for your Google Cloud project.

To get an authentication token for your Google Cloud project use:

gcloud auth application-default print-access-token

Then use that token to log in to the Google Cloud with docker:

docker login -u oauth2accesstoken -p "token_goes_here" https://gcr.io

If the login has been successfull you should now be able to push images directly to the Google Container Registry:

docker push gcr.io/my_project/foo:v1


问:
Error while running desktop app converter on VLC installer
I'm getting E_STARTING_ISOLATED_ENV_FAILED error while running the converter on VLC installer. I chose VLC because in one of the channel 9 videos, VLC was used as an example. I want to first try running converter on a sample exe installer before running it on an actual exe installer.

I even tried -Cleanup All and did the setup again but still the same error. Any idea how to trouble shoot and fix this issue? Below is the error message from converter :

```<code>PS C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe> DesktopAppConverter.exe -Installer C:\Project\vlc\vlc-2.2.6-win32.exe -InstallerArguments  "/S /L=1033" -Destination C:\Project\MSI\Output -PackageName "VLC" -Publisher "CN=VLC" -Version 0.0.0.1 -Verbose
VERBOSE: Log file can be found in
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\logs\DesktopAppConverter.log
VERBOSE: Desktop App Converter
2.0.2.release_2017-04-20_15-32_d5d861e622cd5bd166242b726909575b22b31f27
VERBOSE: --------------------------------------------------

Checking Prerequisites

VERBOSE: Checking Windows Version to ensure it meets minimum requirements
VERBOSE: Minimum Windows Version requirement is met.
VERBOSE: Checking if Microsoft Windows 10 SDK is installed
VERBOSE: Checking Windows SDK version to ensure it meets minimum requirements.
VERBOSE: The installed Windows SDK version 10.0.15063.400 is supported
VERBOSE: Checking if MAKEAPPX.exe is available in the Microsoft Windows 10 SDK tools
VERBOSE: Checking if SIGNTOOL.exe is available in the Microsoft Windows 10 SDK tools
VERBOSE: Checking if MAKEPRI.exe is available in the Microsoft Windows 10 SDK tools
VERBOSE: Ensuring the provided Installer (C:\Project\vlc\vlc-2.2.6-win32.exe) exists
VERBOSE: Testing for required feature enabled...
VERBOSE: Target Image Version 10.0.14393.0
VERBOSE: Required feature is enabled. Checking if reboot is required
VERBOSE: Target Image Version 10.0.14393.0
VERBOSE: Required feature is enabled.
VERBOSE: Checking network config...
VERBOSE: Checking virtual network: "Windows Desktop App Converter Network"
VERBOSE: Using virtual network: "Windows Desktop App Converter Network"
VERBOSE: --------------------------------------------------

Initializing AppxManifest.xml

VERBOSE: Creating working directory structure at
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58
VERBOSE: Attempting to set appx manifest property 'Package.Identity.Name' to 'VLC'.
VERBOSE: Attempting to set appx manifest property 'Package.Identity.Publisher' to 'CN=VLC'.
VERBOSE: Attempting to set appx manifest property 'Package.Identity.Version' to '0.0.0.1'.
VERBOSE: No value provided for appx manifest property 'Package.Properties.PublisherDisplayName'.
Attempting to set it to the default value 'VLC'
VERBOSE: Attempting to set appx manifest property 'Package.Properties.PublisherDisplayName' to
'VLC'.
VERBOSE: No value provided for appx manifest property 'Package.Properties.DisplayName'. Attempting
 to set it to the default value 'VLC'
VERBOSE: Attempting to set appx manifest property 'Package.Properties.DisplayName' to 'VLC'.
VERBOSE: No value provided for appx manifest property
'Package.Applications.Application.VisualElement.Description'. Attempting to set it to the default
value 'VLC'
VERBOSE: Attempting to set appx manifest property
'Package.Applications.Application.VisualElement.Description' to 'VLC'.
VERBOSE: No value provided for appx manifest property
'Package.Applications.Application.VisualElement.DisplayName'. Attempting to set it to the default
value 'VLC'
VERBOSE: Attempting to set appx manifest property
'Package.Applications.Application.VisualElement.DisplayName' to 'VLC'.
VERBOSE: No value provided for appx manifest property 'Package.Applications.Application.Id'.
Attempting to set it to the default value 'VLC'
VERBOSE: Attempting to set appx manifest property 'Package.Applications.Application.Id' to 'VLC'.
VERBOSE: --------------------------------------------------

Validating Input

VERBOSE: Expanded base image(s) found at C:\ProgramData\Microsoft\Windows\Images. Attempting to
choose the most recent one compatible with your version of Windows.
VERBOSE: Testing if expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
 is compatible with your OS
VERBOSE: Your Windows version was determined to be 10.0.14393.0
VERBOSE: Attempting to determine Windows version for expanded base image at
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Attempting to determine version from version file
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json if it exists
VERBOSE: Version found in 'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json'
is: 10.0.14393.0
VERBOSE: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 is of windows version
10.0.14393.0
VERBOSE: The expanded base image version was determined to be 10.0.14393.0
VERBOSE: Ignoring revision numbers
VERBOSE: Expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 IS
compatible with your OS
VERBOSE: Expanded base image with compatible Windows version found:
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Using expanded base image: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Checking that the ExpandedBaseImage
'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393' is valid
VERBOSE: Testing if expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
 is compatible with your OS
VERBOSE: Your Windows version was determined to be 10.0.14393.0
VERBOSE: Attempting to determine Windows version for expanded base image at
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Attempting to determine version from version file
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json if it exists
VERBOSE: Version found in 'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json'
is: 10.0.14393.0
VERBOSE: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 is of windows version
10.0.14393.0
VERBOSE: The expanded base image version was determined to be 10.0.14393.0
VERBOSE: Ignoring revision numbers
VERBOSE: Expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 IS
compatible with your OS
VERBOSE: Attempting to determine Windows version for expanded base image at
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Attempting to determine version from version file
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json if it exists
VERBOSE: Version found in 'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json'
is: 10.0.14393.0
VERBOSE: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 is of windows version
10.0.14393.0
VERBOSE: Ensuring the provided Installer (C:\Project\vlc\vlc-2.2.6-win32.exe) exists
VERBOSE: Ensuring the provided Installer (C:\Project\vlc\vlc-2.2.6-win32.exe) exists
VERBOSE: Checking if Destination (C:\Project\MSI\Output\VLC) exists
VERBOSE: C:\Project\MSI\Output\VLC exists
VERBOSE: C:\Project\MSI\Output\VLC exists but is not empty
VERBOSE: Moving files currently at 'C:\Project\MSI\Output\VLC' to 'C:\Project\MSI\Output\VLC.old3'
VERBOSE: Ensuring that this script has write permissions to C:\Project\MSI\Output\VLC...
VERBOSE: Checking that installer is not sibling to working directory
VERBOSE: --------------------------------------------------

Setting up Conversion Environment

VERBOSE: Copying contents of C:\Project\vlc to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\installer to be shared with
isolated environment
VERBOSE: Copying KnownFolderDump.exe and its dependencies to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\dac\bin
VERBOSE: --------------------------------------------------

Running Installer in Isolated Environment

VERBOSE: No installer valid exit codes specified. Using defaults: 0
VERBOSE: Replace any occurence of <log_folder> in -InstallerArguments with C:\shared\logs
VERBOSE: Creating Isolated Environment
VERBOSE: Starting the Isolated Environment
VERBOSE: An error occurred running your installer in isolation
VERBOSE: Disposing of the Isolated Environment
VERBOSE: Moving any logs in
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\logs to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\logs
VERBOSE: Moving any dac output in
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\dac\out to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\output\dac
VERBOSE: Cleaning up by removing isolated environment shared folder
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared
VERBOSE: An error occurred converting your application. Here is the full error record:
VERBOSE:

PowerShell Error Record:
DesktopAppConverter : error 'E_STARTING_ISOLATED_ENV_FAILED': Failed to start the isolated
environment. See inner exception for more details.
PowerShell Stack Trace:
at RaiseUserException, C:\Program
Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\converter_util\DACLogge
r.ps1: line 154
at Invoke-IsolatedInstall, C:\Program
Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\converter_util\Isolated
EnvironmentOps.ps1: line 162
at <ScriptBlock><Process>, C:\Program
Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\DesktopAppConverter.ps1
: line 684
at <ScriptBlock>, <No file>: line 1

Inner Exception[0]:
System.Management.Automation.RuntimeException: DesktopAppConverter : error
'E_STARTING_ISOLATED_ENV_FAILED': Failed to start the isolated environment. See inner exception
for more details. ---> System.Management.Automation.MethodInvocationException: Exception calling
"Start" with "0" argument(s): "One or more errors occurred." ---> System.AggregateException: One
or more errors occurred. ---> Microsoft.Windows.ComputeVirtualization.HcsException: HCS function
call returned error. ---> System.Runtime.InteropServices.COMException: This operation returned
because the timeout period expired. (Exception from HRESULT: 0x800705B4)
   --- End of inner exception stack trace ---
   at Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.ProcessHcsCall(Int32 resultCode,
String result)
   at
Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.Microsoft.Windows.ComputeVirtualization.IHc
s.StartComputeSystem(IntPtr computeSystem, String options)
   at Microsoft.Windows.ComputeVirtualization.Container.<StartAsync>d__8.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken
cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Microsoft.Windows.ComputeVirtualization.Container.Start()
   at CallSite.Target(Closure , CallSite , Object )
   --- End of inner exception stack trace ---
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
   --- End of inner exception stack trace ---
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
Inner Exception Stack Trace[0]
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)

Inner Exception[1]:
System.Management.Automation.MethodInvocationException: Exception calling "Start" with "0"
argument(s): "One or more errors occurred." ---> System.AggregateException: One or more errors
occurred. ---> Microsoft.Windows.ComputeVirtualization.HcsException: HCS function call returned
error. ---> System.Runtime.InteropServices.COMException: This operation returned because the
timeout period expired. (Exception from HRESULT: 0x800705B4)
   --- End of inner exception stack trace ---
   at Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.ProcessHcsCall(Int32 resultCode,
String result)
   at
Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.Microsoft.Windows.ComputeVirtualization.IHc
s.StartComputeSystem(IntPtr computeSystem, String options)
   at Microsoft.Windows.ComputeVirtualization.Container.<StartAsync>d__8.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken
cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Microsoft.Windows.ComputeVirtualization.Container.Start()
   at CallSite.Target(Closure , CallSite , Object )
   --- End of inner exception stack trace ---
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
Inner Exception Stack Trace[1]
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
   at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)

Inner Exception[2]:
System.AggregateException: One or more errors occurred. --->
Microsoft.Windows.ComputeVirtualization.HcsException: HCS function call returned error. --->
System.Runtime.InteropServices.COMException: This operation returned because the timeout period
expired. (Exception from HRESULT: 0x800705B4)
   --- End of inner exception stack trace ---
   at Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.ProcessHcsCall(Int32 resultCode,
String result)
   at
Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.Microsoft.Windows.ComputeVirtualization.IHc
s.StartComputeSystem(IntPtr computeSystem, String options)
   at Microsoft.Windows.ComputeVirtualization.Container.<StartAsync>d__8.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken
cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Microsoft.Windows.ComputeVirtualization.Container.Start()
   at CallSite.Target(Closure , CallSite , Object )
---> (Inner Exception #0) Microsoft.Windows.ComputeVirtualization.HcsException: HCS function call
returned error. ---> System.Runtime.InteropServices.COMException: This operation returned because
the timeout period expired. (Exception from HRESULT: 0x800705B4)
   --- End of inner exception stack trace ---
   at Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.ProcessHcsCall(Int32 resultCode,
String result)
   at
Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.Microsoft.Windows.ComputeVirtualization.IHc
s.StartComputeSystem(IntPtr computeSystem, String options)
   at Microsoft.Windows.ComputeVirtualization.Container.<StartAsync>d__8.MoveNext()<---

Inner Exception Stack Trace[2]
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken
cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Microsoft.Windows.ComputeVirtualization.Container.Start()
   at CallSite.Target(Closure , CallSite , Object )

Inner Exception[3]:
Microsoft.Windows.ComputeVirtualization.HcsException: HCS function call returned error. --->
System.Runtime.InteropServices.COMException: This operation returned because the timeout period
expired. (Exception from HRESULT: 0x800705B4)
   --- End of inner exception stack trace ---
   at Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.ProcessHcsCall(Int32 resultCode,
String result)
   at
Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.Microsoft.Windows.ComputeVirtualization.IHc
s.StartComputeSystem(IntPtr computeSystem, String options)
   at Microsoft.Windows.ComputeVirtualization.Container.<StartAsync>d__8.MoveNext()
Inner Exception Stack Trace[3]
   at Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.ProcessHcsCall(Int32 resultCode,
String result)
   at
Microsoft.Windows.ComputeVirtualization.HcsFactory.Hcs.Microsoft.Windows.ComputeVirtualization.IHc
s.StartComputeSystem(IntPtr computeSystem, String options)
   at Microsoft.Windows.ComputeVirtualization.Container.<StartAsync>d__8.MoveNext()

Inner Exception[4]:
System.Runtime.InteropServices.COMException (0x800705B4): This operation returned because the
timeout period expired. (Exception from HRESULT: 0x800705B4)
VERBOSE: The full error record is saved in the logs at
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\logs
C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\DesktopAppCo
nverter.ps1 : DesktopAppConverter : error 'E_STARTING_ISOLATED_ENV_FAILED': Failed to start the
isolated environment. See inner exception for more details.
At line:1 char:1
+ &'C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,DesktopAppConvert
   er.ps1

Output Paths:

Name                           Value
----                           -----
CertPath
PackageFilesPath
PackagePath
LogFilesPath                   C:\Project\MSI\Output\VLC\logs

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe>
</code>```

答:
Currently the only other workaround would be to try the conversion on a different build or machine, you can also try using a VM.

Can you please reach out to us at converter@microsoft.com to help us investigate the error and debug.

Thanks!

Body:
I'm getting E_STARTING_ISOLATED_ENV_FAILED error while running the converter on VLC installer. I chose VLC because in one of the channel 9 videos, VLC was used as an example. I want to first try running converter on a sample exe installer before running it on an actual exe installer.

I even tried -Cleanup All and did the setup again but still the same error. Any idea how to trouble shoot and fix this issue? Below is the error message from converter :

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe> DesktopAppConverter.exe -Installer C:\Project\vlc\vlc-2.2.6-win32.exe -InstallerArguments  "/S /L=1033" -Destination C:\Project\MSI\Output -PackageName "VLC" -Publisher "CN=VLC" -Version 0.0.0.1 -Verbose
VERBOSE: Log file can be found in
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\logs\DesktopAppConverter.log
VERBOSE: Desktop App Converter
2.0.2.release_2017-04-20_15-32_d5d861e622cd5bd166242b726909575b22b31f27
VERBOSE: --------------------------------------------------

Checking Prerequisites

VERBOSE: Checking Windows Version to ensure it meets minimum requirements
VERBOSE: Minimum Windows Version requirement is met.
VERBOSE: Checking if Microsoft Windows 10 SDK is installed
VERBOSE: Checking Windows SDK version to ensure it meets minimum requirements.
VERBOSE: The installed Windows SDK version 10.0.15063.400 is supported
VERBOSE: Checking if MAKEAPPX.exe is available in the Microsoft Windows 10 SDK tools
VERBOSE: Checking if SIGNTOOL.exe is available in the Microsoft Windows 10 SDK tools
VERBOSE: Checking if MAKEPRI.exe is available in the Microsoft Windows 10 SDK tools
VERBOSE: Ensuring the provided Installer (C:\Project\vlc\vlc-2.2.6-win32.exe) exists
VERBOSE: Testing for required feature enabled...
VERBOSE: Target Image Version 10.0.14393.0
VERBOSE: Required feature is enabled. Checking if reboot is required
VERBOSE: Target Image Version 10.0.14393.0
VERBOSE: Required feature is enabled.
VERBOSE: Checking network config...
VERBOSE: Checking virtual network: "Windows Desktop App Converter Network"
VERBOSE: Using virtual network: "Windows Desktop App Converter Network"
VERBOSE: --------------------------------------------------

Initializing AppxManifest.xml

VERBOSE: Creating working directory structure at
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58
VERBOSE: Attempting to set appx manifest property 'Package.Identity.Name' to 'VLC'.
VERBOSE: Attempting to set appx manifest property 'Package.Identity.Publisher' to 'CN=VLC'.
VERBOSE: Attempting to set appx manifest property 'Package.Identity.Version' to '0.0.0.1'.
VERBOSE: No value provided for appx manifest property 'Package.Properties.PublisherDisplayName'.
Attempting to set it to the default value 'VLC'
VERBOSE: Attempting to set appx manifest property 'Package.Properties.PublisherDisplayName' to
'VLC'.
VERBOSE: No value provided for appx manifest property 'Package.Properties.DisplayName'. Attempting
 to set it to the default value 'VLC'
VERBOSE: Attempting to set appx manifest property 'Package.Properties.DisplayName' to 'VLC'.
VERBOSE: No value provided for appx manifest property
'Package.Applications.Application.VisualElement.Description'. Attempting to set it to the default
value 'VLC'
VERBOSE: Attempting to set appx manifest property
'Package.Applications.Application.VisualElement.Description' to 'VLC'.
VERBOSE: No value provided for appx manifest property
'Package.Applications.Application.VisualElement.DisplayName'. Attempting to set it to the default
value 'VLC'
VERBOSE: Attempting to set appx manifest property
'Package.Applications.Application.VisualElement.DisplayName' to 'VLC'.
VERBOSE: No value provided for appx manifest property 'Package.Applications.Application.Id'.
Attempting to set it to the default value 'VLC'
VERBOSE: Attempting to set appx manifest property 'Package.Applications.Application.Id' to 'VLC'.
VERBOSE: --------------------------------------------------

Validating Input

VERBOSE: Expanded base image(s) found at C:\ProgramData\Microsoft\Windows\Images. Attempting to
choose the most recent one compatible with your version of Windows.
VERBOSE: Testing if expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
 is compatible with your OS
VERBOSE: Your Windows version was determined to be 10.0.14393.0
VERBOSE: Attempting to determine Windows version for expanded base image at
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Attempting to determine version from version file
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json if it exists
VERBOSE: Version found in 'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json'
is: 10.0.14393.0
VERBOSE: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 is of windows version
10.0.14393.0
VERBOSE: The expanded base image version was determined to be 10.0.14393.0
VERBOSE: Ignoring revision numbers
VERBOSE: Expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 IS
compatible with your OS
VERBOSE: Expanded base image with compatible Windows version found:
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Using expanded base image: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Checking that the ExpandedBaseImage
'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393' is valid
VERBOSE: Testing if expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
 is compatible with your OS
VERBOSE: Your Windows version was determined to be 10.0.14393.0
VERBOSE: Attempting to determine Windows version for expanded base image at
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Attempting to determine version from version file
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json if it exists
VERBOSE: Version found in 'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json'
is: 10.0.14393.0
VERBOSE: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 is of windows version
10.0.14393.0
VERBOSE: The expanded base image version was determined to be 10.0.14393.0
VERBOSE: Ignoring revision numbers
VERBOSE: Expanded base image at C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 IS
compatible with your OS
VERBOSE: Attempting to determine Windows version for expanded base image at
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393
VERBOSE: Attempting to determine version from version file
C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json if it exists
VERBOSE: Version found in 'C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393\version.json'
is: 10.0.14393.0
VERBOSE: C:\ProgramData\Microsoft\Windows\Images\BaseImage-14393 is of windows version
10.0.14393.0
VERBOSE: Ensuring the provided Installer (C:\Project\vlc\vlc-2.2.6-win32.exe) exists
VERBOSE: Ensuring the provided Installer (C:\Project\vlc\vlc-2.2.6-win32.exe) exists
VERBOSE: Checking if Destination (C:\Project\MSI\Output\VLC) exists
VERBOSE: C:\Project\MSI\Output\VLC exists
VERBOSE: C:\Project\MSI\Output\VLC exists but is not empty
VERBOSE: Moving files currently at 'C:\Project\MSI\Output\VLC' to 'C:\Project\MSI\Output\VLC.old3'
VERBOSE: Ensuring that this script has write permissions to C:\Project\MSI\Output\VLC...
VERBOSE: Checking that installer is not sibling to working directory
VERBOSE: --------------------------------------------------

Setting up Conversion Environment

VERBOSE: Copying contents of C:\Project\vlc to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\installer to be shared with
isolated environment
VERBOSE: Copying KnownFolderDump.exe and its dependencies to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\dac\bin
VERBOSE: --------------------------------------------------

Running Installer in Isolated Environment

VERBOSE: No installer valid exit codes specified. Using defaults: 0
VERBOSE: Replace any occurence of <log_folder> in -InstallerArguments with C:\shared\logs
VERBOSE: Creating Isolated Environment
VERBOSE: Starting the Isolated Environment
VERBOSE: An error occurred running your installer in isolation
VERBOSE: Disposing of the Isolated Environment
VERBOSE: Moving any logs in
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\logs to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\logs
VERBOSE: Moving any dac output in
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared\dac\out to
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\output\dac
VERBOSE: Cleaning up by removing isolated environment shared folder
C:\DesktopAppConverter\9848b14c-013f-48d3-bc43-3b10b5987c58\shared
VERBOSE: An error occurred converting your application. Here is the full error record:
VERBOSE:

PowerShell Error Record:
DesktopAppConverter : error 'E_STARTING_ISOLATED_ENV_FAILED': Failed to start the isolated
environment. See inner exception for more details.
PowerShell Stack Trace:
at RaiseUserException, C:\Program
Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\converter_util\DACLogge
r.ps1: line 154
at Invoke-IsolatedInstall, C:\Program
Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\converter_util\Isolated
EnvironmentOps.ps1: line 162
at


答:
You cannot send multiple JSON responses via single output. Use Websockets  for that or group responses into bag:</p>

```<code>json_decode([$json, $arr])
</code>```

Title: Ajax doesn't return json if there is text in php file

Body:
You cannot send multiple JSON responses via single output. Use Websockets  for that or group responses into bag:

json_decode([$json, $arr])


问:
ElasticSearch 5.x Context Suggester - single context multiple value
I am trying to use completion context with multiple value.
Context accept only one value.

```<code>string contextValue = "10";
List<string> listOfContextValues = new List<string> {"10", "20","30"};
var a = Client.Search<Post>(s => s
            .Suggest(su => su
                .Completion("categories", cs => cs
                    .Field(f => f.CSuggest)
                    .Prefix(query)
                    .Contexts(co => co
                        .Context("sourceid",
                            cd => cd.Context(contextValue)
                    )
                )
            )
        ));
</code>```

I don't know how to filter my suggest field with listOfContextValues.

Update

When i using a for loop and passing single context as filter and storing result in a list.

And also using Russ suggested code and storing result in a list.
But Some result are missing in second list.

As you can see in below:

```<code>var socialNetworks = srvUser.GetUserSocialNetworks(userId);

List<string> tags = new List<string>();
foreach (var socialNetwork in socialNetworks)
{
    var result = Client.Search<Post>(s => s
        .Suggest(su => su
            .Completion("categories", cs => cs
                .Field(f => f.CSuggest)
                .Prefix(query)
                .Contexts(co => co
                    .Context("sourceid",
                        cd => cd.Context(socialNetwork)
                    )
                )
            )
        ));
    List<string> br = result.Suggest["categories"].SelectMany(x => x.Options)
        .Select(y => y.Text).Distinct().ToList();
    tags.AddRange(br);
}

var searchResponse = Client.Search<Post>(s => s
    .Suggest(su => su
        .Completion("categories", cs => cs
            .Field(f => f.CSuggest)
            .Prefix(query)
            .Contexts(co => co
                .Context("sourceid", socialNetworks
                    .Select<string, Func<SuggestContextQueryDescriptor<Post>, ISuggestContextQuery>>(v => cd => cd.Context(v))
                    .ToArray()

                )
            )
        )
    )
);
List<string> sa = searchResponse.Suggest["categories"].SelectMany(x => x.Options).Select(y => y.Text).Distinct().ToList();
if (sa.Count != tags.Count)
{
    // >>>>> counts are not the same
}
</code>```

答:
Are you looking for size ?</p>

```<code>  ...s =>
         s.Completion("categories",
            cs=> cs.
               Field(p => p.Suggestion)
                    .Contexts(
                        ctx =>
                            ctx.Context("sid", d => d.Context(value))
                    .Prefix(searchText)
                    .Size(10);
</code>```

Body:
I am trying to use completion context with multiple value.
Context accept only one value.

string contextValue = "10";
List<string> listOfContextValues = new List<string> {"10", "20","30"};
var a = Client.Search<Post>(s => s
            .Suggest(su => su
                .Completion("categories", cs => cs
                    .Field(f => f.CSuggest)
                    .Prefix(query)
                    .Contexts(co => co
                        .Context("sourceid",
                            cd => cd.Context(contextValue)
                    )
                )
            )
        ));

I don't know how to filter my suggest field with listOfContextValues.

Update

When i using a for loop and passing single context as filter and storing result in a list.

And also using Russ suggested code and storing result in a list.
But Some result are missing in second list.

As you can see in below:

var socialNetworks = srvUser.GetUserSocialNetworks(userId);

List<string> tags = new List<string>();
foreach (var socialNetwork in socialNetworks)
{
    var result = Client.Search<Post>(s => s
        .Suggest(su => su
            .Completion("categories", cs => cs
                .Field(f => f.CSuggest)
                .Prefix(query)
                .Contexts(co => co
                    .Context("sourceid",
                        cd => cd.Context(socialNetwork)
                    )
                )
            )
        ));
    List<string> br = result.Suggest["categories"].SelectMany(x => x.Options)
        .Select(y => y.Text).Distinct().ToList();
    tags.AddRange(br);
}

var searchResponse = Client.Search<Post>(s => s
    .Suggest(su => su
        .Completion("categories", cs => cs
            .Field(f => f.CSuggest)
            .Prefix(query)
            .Contexts(co => co
                .Context("sourceid", socialNetworks
                    .Select<string, Func<SuggestContextQueryDescriptor<Post>, ISuggestContextQuery>>(v => cd => cd.Context(v))
                    .ToArray()

                )
            )
        )
    )
);
List<string> sa = searchResponse.Suggest["categories"].SelectMany(x => x.Options).Select(y => y.Text).Distinct().ToList();
if (sa.Count != tags.Count)
{
    // >>>>> counts are not the same
}

Body:
Are you looking for size ?

  ...s =>
         s.Completion("categories",
            cs=> cs.
               Field(p => p.Suggestion)
                    .Contexts(
                        ctx =>
                            ctx.Context("sid", d => d.Context(value))
                    .Prefix(searchText)
                    .Size(10);


问:
How to fix the TypeError (list indices must be integers, not str) in this program?
In one of the program I am using, I am getting a TypeError when trying to mine/parse a value out of dict type data.

Below is a brief part of that python program:

```<code>for c in results:
        print('value of c : ', c, type(c)) # what I added to see the issue with dict data
        for ci, lr in c['chain_info'].iteritems():
            outfile = open(lr.output_file, 'a')
            write = outfile.write

            if lr.number_vcf_lines > 0:
                write(CHAIN_STRING.format(CHAIN_STRING,
                            from_chr=c['chrom'], from_length=lr.chromosome_length,
                            from_start=0, from_end=lr.chromosome_length,
                            to_chr=c['chrom'], to_length=lr.end_length,
                            to_start=0, to_end=lr.sums[0] + lr.last_fragment_size + lr.sums[2], id=c['chrom']))
                write("\n")
</code>```

Full traceback error message

Error Type: <type 'exceptions.TypeError'>
Error Value: list indices must be integers, not str
/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools/vcf2chain.py:456
Traceback (most recent call last):
  File "/home/everestial007/anaconda3/envs/g2gtools/bin/g2gtools", line 4, in <module>
__import__('pkg_resources').run_script('g2gtools==0.1.31', 'g2gtools')
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg/pkg_resources/__init__.py", line 744, in run_script
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg/pkg_resources/__init__.py", line 1499, in run_script
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools-0.1.31-py2.7.egg-info/scripts/g2gtools", line 117, in <module>
    G2GToolsApp()
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools-0.1.31-py2.7.egg-info/scripts/g2gtools", line 75, in __init__
    getattr(self, args.command)()
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools-0.1.31-py2.7.egg-info/scripts/g2gtools", line 90, in vcf2chain
    g2gtools.g2g_commands.command_vcf2chain(sys.argv[2:], self.script_name + ' vcf2chain')
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools/g2g_commands.py", line 375, in command_vcf2chain
    vcf2chain(args.input, args.fasta, args.strain, args.output, args.keep, args.passed, args.quality, args.diploid)
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools/vcf2chain.py", line 493, in vcf2chain
    raise G2GError("Execution halted")
g2gtools.exceptions.G2GError: Execution halted
```

<p>The github location of the file: https://github.com/churchill-lab/g2gtools/blob/master/g2gtools/vcf2chain.py</p>

<p>Looks like problem is with line:</p>

```from_chr=c['chrom'], from_length=lr.chromosome_length,
```

<p>And, the Chain_string is something Author created as:</p>

```CHAIN_STRING = "chain 1000 {from_chr} {from_length} + {from_start} {from_end} " + "{to_chr} {to_length} + {to_start} {to_end} {id}"
```

<p>I tried to print the values of that dict (by adding a print statement) to see what was the issue.</p>

```print('value of c : ', c, type(c)) # gave me
('value of c : ', {'chrom': '1', 'stats': OrderedDict([('ACCEPTED', 0)]), 'chain_info': {'right': <g2gtools.vcf2chain.VCFtoChainInfo object at 0x7fe9de396dd0>, 'left': <g2gtools.vcf2chain.VCFtoChainInfo object at 0x7fe9d9252d50>}}, <type 'dict'>)
```

So, what is the issue here?
What is the problem with this data/program??

答:
In your comment, you say c is a string, then
from_chr=c['chrom'] does not work, because you cannot give a string an index which is a string.

```<code>In [3]: c = 'my string'

In [4]: c['chrom']
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-a201470ce4c5> in <module>()
----> 1 c['chrom']

TypeError: string indices must be integers
</code>```

Your error message says list indices must be integers, not str. I guess c is a list then. In both cases, you cannot give c a string as an index.

Body:
In one of the program I am using, I am getting a TypeError when trying to mine/parse a value out of dict type data.

Below is a brief part of that python program:

for c in results:
        print('value of c : ', c, type(c)) # what I added to see the issue with dict data
        for ci, lr in c['chain_info'].iteritems():
            outfile = open(lr.output_file, 'a')
            write = outfile.write

            if lr.number_vcf_lines > 0:
                write(CHAIN_STRING.format(CHAIN_STRING,
                            from_chr=c['chrom'], from_length=lr.chromosome_length,
                            from_start=0, from_end=lr.chromosome_length,
                            to_chr=c['chrom'], to_length=lr.end_length,
                            to_start=0, to_end=lr.sums[0] + lr.last_fragment_size + lr.sums[2], id=c['chrom']))
                write("\n")

Full traceback error message

Error Type: <type 'exceptions.TypeError'>
Error Value: list indices must be integers, not str
/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools/vcf2chain.py:456
Traceback (most recent call last):
  File "/home/everestial007/anaconda3/envs/g2gtools/bin/g2gtools", line 4, in <module>
__import__('pkg_resources').run_script('g2gtools==0.1.31', 'g2gtools')
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg/pkg_resources/__init__.py", line 744, in run_script
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg/pkg_resources/__init__.py", line 1499, in run_script
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools-0.1.31-py2.7.egg-info/scripts/g2gtools", line 117, in <module>
    G2GToolsApp()
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools-0.1.31-py2.7.egg-info/scripts/g2gtools", line 75, in __init__
    getattr(self, args.command)()
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools-0.1.31-py2.7.egg-info/scripts/g2gtools", line 90, in vcf2chain
    g2gtools.g2g_commands.command_vcf2chain(sys.argv[2:], self.script_name + ' vcf2chain')
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools/g2g_commands.py", line 375, in command_vcf2chain
    vcf2chain(args.input, args.fasta, args.strain, args.output, args.keep, args.passed, args.quality, args.diploid)
  File "/home/everestial007/anaconda3/envs/g2gtools/lib/python2.7/site-packages/g2gtools/vcf2chain.py", line 493, in vcf2chain
    raise G2GError("Execution halted")
g2gtools.exceptions.G2GError: Execution halted

The github location of the file: https://github.com/churchill-lab/g2gtools/blob/master/g2gtools/vcf2chain.py

Looks like problem is with line:

from_chr=c['chrom'], from_length=lr.chromosome_length,

And, the Chain_string is something Author created as:

CHAIN_STRING = "chain 1000 {from_chr} {from_length} + {from_start} {from_end} " + "{to_chr} {to_length} + {to_start} {to_end} {id}"

I tried to print the values of that dict (by adding a print statement) to see what was the issue.

print('value of c : ', c, type(c)) # gave me
('value of c : ', {'chrom': '1', 'stats': OrderedDict([('ACCEPTED', 0)]), 'chain_info': {'right': <g2gtools.vcf2chain.VCFtoChainInfo object at 0x7fe9de396dd0>, 'left': <g2gtools.vcf2chain.VCFtoChainInfo object at 0x7fe9d9252d50>}}, <type 'dict'>)

So, what is the issue here?
What is the problem with this data/program??

Body:
In your comment, you say c is a string, then
from_chr=c['chrom'] does not work, because you cannot give a string an index which is a string.

In [3]: c = 'my string'

In [4]: c['chrom']
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-a201470ce4c5> in <module>()
----> 1 c['chrom']

TypeError: string indices must be integers

Your error message says list indices must be integers, not str. I guess c is a list then. In both cases, you cannot give c a string as an index.


问:
WebStorm doesn't understand Angular 2 syntax
I have installed Angular CLI and generated new project. I'm working in WebStorm, and it seems like it doesn't understand Angular 2 syntax (highlights *ngFor for example) and there is no autocomplete.

Can someone please help to get autocomplete and correct highlight for Angular 2 code and html tags/attributes?

答: Looks like the Webstorm 16.1 doesn't work with Angular 2 correctly. Working with Angular presents like a feature of 17.1 version. From Webstorm website (17.1 release): "WebStorm provides advanced coding assistance for Angular, React, Vue.js and Meteor...". The update to latest version for now (2017.1) solved my problem.</p>


问:
undefined reference to `rectangle::rectangle()
I'm trying to declare an object of type rectangle but it keeps showing me this error

this is the rectangle class which inherits from shape class:

```<code>class rectangle: public shape{

int width, height;
public:
    rectangle();

 void draw(int width, int height){
    for(int i = 1; i <= height; i++){
            for(int j = 1; j <= width; j++){
                if( i == 1 && i == height)
                    cout<<"*";
                else if( j == 1 && j == width)
                    cout<<"*";
                else
                    cout<<" ";
            }
            cout<<endl;
        }
    }

};
</code>```

this is the shape class:

```<code>class shape
{
int x, y;
char letter;
public:
    shape(int x, int y, char letter, int length){
        int X = x;
        int Y = y;
        int L = letter;
    }
    void verLine(){
        for(int i = 0; i < 5; i++){
            cout<<"*"<<endl;
        }
    }
    void horLine(){
        for(int i = 0; i < 5; i++){
            cout<<"*";
        }
    }
    char setLetter(char letter){
        int newLetter = letter;
        return newLetter;
    }
    void gotoxy(int x, int y){
        HANDLE hConsole;
        COORD cursorLoe;
        std::cout.flush();
        cursorLoe.X = x;
        cursorLoe.Y = y;
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleCursorPosition(hConsole, cursorLoe);
    }
};
</code>```

and this is the main:

```<code> int main()
 {
     rectangle r1;
     cout<<endl;
     r1.draw(5,5);
     return 0;
 }
</code>```

I think the problem is with the default constructor I have in the rectangle class, but I din't find any other way to code it

答: You declared the default constructor but didn't define it. You need to define the function rectangle::rectangle() somewhere. If you don't need the constructor to actually do anything, then you don't need to declare it at all. So either define the constructor or don't declare it.

Body:
I'm trying to declare an object of type rectangle but it keeps showing me this error

this is the rectangle class which inherits from shape class:

class rectangle: public shape{

int width, height;
public:
    rectangle();

 void draw(int width, int height){
    for(int i = 1; i <= height; i++){
            for(int j = 1; j <= width; j++){
                if( i == 1 && i == height)
                    cout<<"*";
                else if( j == 1 && j == width)
                    cout<<"*";
                else
                    cout<<" ";
            }
            cout<<endl;
        }
    }

};

this is the shape class:

class shape
{
int x, y;
char letter;
public:
    shape(int x, int y, char letter, int length){
        int X = x;
        int Y = y;
        int L = letter;
    }
    void verLine(){
        for(int i = 0; i < 5; i++){
            cout<<"*"<<endl;
        }
    }
    void horLine(){
        for(int i = 0; i < 5; i++){
            cout<<"*";
        }
    }
    char setLetter(char letter){
        int newLetter = letter;
        return newLetter;
    }
    void gotoxy(int x, int y){
        HANDLE hConsole;
        COORD cursorLoe;
        std::cout.flush();
        cursorLoe.X = x;
        cursorLoe.Y = y;
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleCursorPosition(hConsole, cursorLoe);
    }
};

and this is the main:

 int main()
 {
     rectangle r1;
     cout<<endl;
     r1.draw(5,5);
     return 0;
 }

I think the problem is with the default constructor I have in the rectangle class, but I din't find any other way to code it


问:
How to replace value of a specific node in an XML string?
My specific case is that I have an XML result from an ASMX service.
I need to scan this XML string for a specific node and "ToLower()" the value in the node.
I can't access the service to simply change the return at that level.</p>

答: Maybe something like this would help get you started: How to change XML Attribute</p>


问:
Renaming Columns in an SQL SELECT Statement
I would like to rename the columns in the results of a SELECT expression.  Of course, the following doesn't work:

```<code>SELECT * AS foobar_* FROM `foobar`
</code>```

As I'm new to SQL, I think I'm just missing a concept, tool, or keyword that would lead to the answer.  A hint in the right direction would be appreciated.  Thanks!

UPDATE

I'm looking for a generic way to do this, and MySQL-specific techniques are absolutely fine.

In short, I'm writing a tool that "exports" the results of MySQL queries to Google Spreadsheets (via the Google Data API).  Some queries are joins, so to make columns unique I wanted to prefix all column names with their respective table names.

答:
```<code>select column1 as xyz,
      column2 as pqr,
.....

from TableName;
</code>```

Body:
I would like to rename the columns in the results of a SELECT expression.  Of course, the following doesn't work:

SELECT * AS foobar_* FROM `foobar`

As I'm new to SQL, I think I'm just missing a concept, tool, or keyword that would lead to the answer.  A hint in the right direction would be appreciated.  Thanks!

UPDATE

I'm looking for a generic way to do this, and MySQL-specific techniques are absolutely fine.

In short, I'm writing a tool that "exports" the results of MySQL queries to Google Spreadsheets (via the Google Data API).  Some queries are joins, so to make columns unique I wanted to prefix all column names with their respective table names.


问:
How to add gravity to multiple bodies 'automatically'?
I know how to add gravity to any given object/element. Just add acceleration Y downwards. But "what if want my hero to fly?" or "what if I want to turn gravity off for one particular object? I'll have to set gravity = 0 which will turn off for everyone obviously. I also thought giving every shape their own 'gravity' variable, but I figured that would be too much and it's probably not how it's done...

How would I go from creating shapes

(Using EaseJS)

```<code>function spawnShape(x, y, w, h) {
    var shape = new createjs.Shape();
    shape.graphics.beginFill("black").drawRect(x, y, w, h);
    stage.addChild(shape);
}

spawnShape(20, 250, 600, 30);
spawnShape(200, 150, 5, 5);

stage.update();
</code>```

to adding gravity "automatically"? (every shape inheriting downwards acceleration) I know there's 2D physics engines made but I want to do/understand this myself, and I did try to use PhysicsJS but failed to do so.. I'll probably be using an engine but for now I want to know how to do this :P

答:
You can create an object:

```<code>function Shape(x, y, w, h, gravity){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.gravity = gravity;
    this.shape = new createjs.Shape();
    stage.addChild(shape);
    this.draw = function(){
        shape.graphics.beginFill("black").drawRect(x, y, w, h);
    }
}
</code>```

Thus, you can call it as:

```<code>> x = new Shape(200, 200, 10, 10, 0.5)
Shape {x: 200, y: 200, w: 10, h: 10, gravity: 0.5}
> y = new Shape(400, 100, 50, 100, 0.75)
Shape {x: 400, y: 100, w: 50, h: 100, gravity: 0.75}
> x.gravity = 0
0
> y.gravity
0.75
</code>```

I haven't worked with EaseJS so the specifics may be inaccurate but the overarching logic will be as demonstrated above.

Body:
I know how to add gravity to any given object/element. Just add acceleration Y downwards. But "what if want my hero to fly?" or "what if I want to turn gravity off for one particular object? I'll have to set gravity = 0 which will turn off for everyone obviously. I also thought giving every shape their own 'gravity' variable, but I figured that would be too much and it's probably not how it's done...

How would I go from creating shapes

(Using EaseJS)

function spawnShape(x, y, w, h) {
    var shape = new createjs.Shape();
    shape.graphics.beginFill("black").drawRect(x, y, w, h);
    stage.addChild(shape);
}

spawnShape(20, 250, 600, 30);
spawnShape(200, 150, 5, 5);

stage.update();

to adding gravity "automatically"? (every shape inheriting downwards acceleration) I know there's 2D physics engines made but I want to do/understand this myself, and I did try to use PhysicsJS but failed to do so.. I'll probably be using an engine but for now I want to know how to do this :P

Body:
You can create an object:

function Shape(x, y, w, h, gravity){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.gravity = gravity;
    this.shape = new createjs.Shape();
    stage.addChild(shape);
    this.draw = function(){
        shape.graphics.beginFill("black").drawRect(x, y, w, h);
    }
}

Thus, you can call it as:

> x = new Shape(200, 200, 10, 10, 0.5)
Shape {x: 200, y: 200, w: 10, h: 10, gravity: 0.5}
> y = new Shape(400, 100, 50, 100, 0.75)
Shape {x: 400, y: 100, w: 50, h: 100, gravity: 0.75}
> x.gravity = 0
0
> y.gravity
0.75

I haven't worked with EaseJS so the specifics may be inaccurate but the overarching logic will be as demonstrated above.


答:
You can insert multiple rows with a single INSERT command by separating your parenthesis-enclosed row data with commas. So you can create a loop for the number of rows you want to add, and then add the row data values (and a comma) to your query string on each iteration:

```<code>var queryString = "INSERT INTO InventoryTransTemp ([name]) VALUES ";
var rowData = "('test')";
int numRows = 5;

for (int i = 0; i < numRows; i++)
{
    queryString += rowData;
    if (i < numRows - 1) queryString += ", ";
}

// At this point, query string looks like:
// "INSERT INTO InventoryTransTemp ([name]) VALUES ('test'), ('test'), ('test'), ('test'), ('test')"

SqlCommand cmd = new SqlCommand(queryString, con);
cmd.ExecuteNonQuery();
</code>```

Title: Run a query multiple times with same values

Body:
I'm using c# and trying to insert into sql same query multiple times:
  Here is my code:

 SqlCommand cmd = new  SqlCommand ("insert into InventoryTransTemp (name) values ('test')",con);
 cmd.ExecuteNonQuery();

How can i run this same query example 5 times??

Can i use a string for doing this? Example if string count=5 then run query 5 times

Body:
You can insert multiple rows with a single INSERT command by separating your parenthesis-enclosed row data with commas. So you can create a loop for the number of rows you want to add, and then add the row data values (and a comma) to your query string on each iteration:

var queryString = "INSERT INTO InventoryTransTemp ([name]) VALUES ";
var rowData = "('test')";
int numRows = 5;

for (int i = 0; i < numRows; i++)
{
    queryString += rowData;
    if (i < numRows - 1) queryString += ", ";
}

// At this point, query string looks like:
// "INSERT INTO InventoryTransTemp ([name]) VALUES ('test'), ('test'), ('test'), ('test'), ('test')"

SqlCommand cmd = new SqlCommand(queryString, con);
cmd.ExecuteNonQuery();


问:
Why is this controller variable not getting through to this javascript code?
I am trying now to use my javascript to render a new view on click of an element, with this code;

```<code>$(document).ready(function() {
    $('.link-panel').click( function() {
        window.location.replace('/quotes/'+gon.gon_quote_id);
    });
});
</code>```

and i get the following error:

```<code>Couldn't find Quote with 'id'=undefined [WHERE "quotes"."user_id" = $1]
</code>```

quote_controller.rb:

```<code>  def show
    @quote = current_user.quotes.find(params[:id])
    gon.gon_quote_id = @quote.id
  end

def index
@quotes = current_user.quotes.all
# how to pass the individual quote object's id to gon here
</code>```

end

I think that it must be the way that I've given the url argument to the replace method, can you help me with what it is that I'm doing wrong?

(gon setup is working fine as alert tests demonstrate.)

Thanks

答:
You should use the id parameter in the URL:

```<code>window.location.replace('/quotes/?id=' + gon.gon_quote_id);
</code>```

Body:
I am trying now to use my javascript to render a new view on click of an element, with this code;

$(document).ready(function() {
    $('.link-panel').click( function() {
        window.location.replace('/quotes/'+gon.gon_quote_id);
    });
});

and i get the following error:

Couldn't find Quote with 'id'=undefined [WHERE "quotes"."user_id" = $1]

quote_controller.rb:

  def show
    @quote = current_user.quotes.find(params[:id])
    gon.gon_quote_id = @quote.id
  end

def index
@quotes = current_user.quotes.all
# how to pass the individual quote object's id to gon here

end

I think that it must be the way that I've given the url argument to the replace method, can you help me with what it is that I'm doing wrong?

(gon setup is working fine as alert tests demonstrate.)

Thanks

Body:
You should use the id parameter in the URL:

window.location.replace('/quotes/?id=' + gon.gon_quote_id);


问:
wpf , binding and datacontext
This is my ViewModel -

```<code> public class ViewModel
{
    public ObservableCollection<Person> Persons { get; set; }
}
</code>```

and this is Class Person:

```<code>public class Person : INotifyPropertyChanged
{
    private string _firstName;
    public string FirstName
    {
        get { return _firstName; }
        set
        {
            _firstName = value;
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("FirstName"));
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}
</code>```

Now, every time one of the persons's FirstName is changing I want to do some tasks,
lets say raise a messagebox.

How do I do that ?

答:
Typically your person class will use the interface INotifyPropertyChanged, firing the PropertyChanged event whenever FirstName changes. This allows you to bind items in a view to your Person class and the view will be updated when the data changes.

To pop up a message box when any FirstName however, you will need some code behind in your view. One way to do it is to, as before, use INotifyProperty changed and subscribe to that on all Person objects in your view, using MessageBox.Show whenever an event changing FirstName is invoked. You can use the CollectionChanged event in the ObservableCollection to track Person objects in and out of the list to make sure that they are all connected to your Person FirstName changed event handler.

The best way to do it, in my opinion, is to have an event in the ViewModel rather than the Person class which fires whenever a change is made to any Person class (with the specific Person object as an argument). This will only work if the ViewModel is the only thing which can change Person.FirstName, and your View will have to bind to the ViewModel in an appropriate way to effect this.

Title: wpf , binding and datacontext

Body:
This is my ViewModel -

 public class ViewModel
{
    public ObservableCollection<Person> Persons { get; set; }
}

and this is Class Person:

public class Person : INotifyPropertyChanged
{
    private string _firstName;
    public string FirstName
    {
        get { return _firstName; }
        set
        {
            _firstName = value;
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("FirstName"));
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}

Now, every time one of the persons's FirstName is changing I want to do some tasks,
lets say raise a messagebox.

How do I do that ?


问:
PHP says Undefined even when it is clearly defined in AJAX call?
I'm working on some function which needs to call php using ajax and get some values. How ever I'll post my JS function part below.

JavaScript

```<code>$.ajax({
        type: "POST",
        url: 'php/getAccountJobs.php',
        ContentType:"application/json",
        dataType:'json',
        data:{email:$.cookie("email")},
        success : function(arr)
        {
            for(var i=0 ; i<parseInt(response); i++) // number of jobs are the response we use there
            {
                var jobmsg = arr[2*i] ;
                var imgurl = arr[2*i+1];
                $.ajax({
                        type: "POST",
                        url: "php/addDivAccountJobs.php",
                        dataType:'json',
                        data: {imgURL:imgurl,message:jobmsg},
                        }).done(function( html ){ alert(html);});
            }
        }
        });
</code>```

So I checked the console log and saw this following error.

```<code>Notice: Undefined index:imgURL
</code>```

So what I thought was to use isset function to test whether imgURL value is being set or not.

PHP

```<code><?php
session_start();
if(isset($_POST["imgURL"]) && isset($_POST["message"]))
{
    $username = $_SESSION["firstname"]." ".$_SESSION["lastname"];
    $imgurl = $_POST["imgURL"];
    $msg = $_POST["message"];
    $fullecho = '<div class="col-md-4">
                    <div class="profile-card text-center">
                        <img class="img-responsive"src="'.$imgurl.'">
                        <div class="profile-info">
                          <h2 class="hvr-underline-from-center" id="jobOwnerName">'.$username.'</h2>
                          <div id="jobMessage">'.$msg.'.</div>
                        </div>
                     </div>
                </div>';
    echo json_encode($fullecho);
    die();
}
else
    echo json_encode("error");
?>
</code>```

As I expected what I received was error message in alert box.

My Problem

I went through every stackexchange question and tried to find the reason behind it and fix it. but none of those solutions gave me a proper answer. Please can someone help me to find the problem?

答: when your json property has undefined value its completely disapear from json. so it because arr[2*i] or arr[2*i+1] somewhere get undefined value in the loop</p>

Body:
I'm working on some function which needs to call php using ajax and get some values. How ever I'll post my JS function part below.

JavaScript

$.ajax({
        type: "POST",
        url: 'php/getAccountJobs.php',
        ContentType:"application/json",
        dataType:'json',
        data:{email:$.cookie("email")},
        success : function(arr)
        {
            for(var i=0 ; i<parseInt(response); i++) // number of jobs are the response we use there
            {
                var jobmsg = arr[2*i] ;
                var imgurl = arr[2*i+1];
                $.ajax({
                        type: "POST",
                        url: "php/addDivAccountJobs.php",
                        dataType:'json',
                        data: {imgURL:imgurl,message:jobmsg},
                        }).done(function( html ){ alert(html);});
            }
        }
        });

So I checked the console log and saw this following error.

Notice: Undefined index:imgURL

So what I thought was to use isset function to test whether imgURL value is being set or not.

PHP

<?php
session_start();
if(isset($_POST["imgURL"]) && isset($_POST["message"]))
{
    $username = $_SESSION["firstname"]." ".$_SESSION["lastname"];
    $imgurl = $_POST["imgURL"];
    $msg = $_POST["message"];
    $fullecho = '

'.$username.'

'.$msg.'.

';
    echo json_encode($fullecho);
    die();
}
else
    echo json_encode("error");
?>

As I expected what I received was error message in alert box.

My Problem

I went through every stackexchange question and tried to find the reason behind it and fix it. but none of those solutions gave me a proper answer. Please can someone help me to find the problem?