问:
Oracle SQL - Why would I manually drop a 'NOT NULL' constraint instead of using a 'Modify'?
THE SCENARIO
I am working on an educational problem in which I need to convert some 'NOT NULL' constraints into 'NULL's and vice-versa.

PREVIOUS RESEARCH
I have read up a few sources that tell me /how/ I can do this (with methods that I will describe below) but they don't explain why I would want to use a seemingly longer and more convoluted method over a seemingly faster method.

How can I drop a "not null" constraint in Oracle when I don't know the name of the constraint?

How to fetch the system generated check constraint name of table column in oracle

THE PROBLEM
I've been instructed to query the table that I want to amend as follows:

```<code>SELECT constraint_name, constraint_type
FROM all_constraints
WHERE table_name = 'FILM'
AND owner = 'SAKILA'
</code>```

This gives me all the constraints on the table including what appear to be a bunch of constraints that were automatically created by the database:

```<code>FK_FILM_LANGUAGE
FK_FILM_LANGUAGE_ORIGINAL
PK_FILM
SYS_C00738336
SYS_C00738337
SYS_C00738338
SYS_C00738339
SYS_C00738340
</code>```

I am then being instructed to manually work out which SYS_**** relates to which item in the table and then manually drop those constraints and write in new ones as follows:

```<code>ALTER TABLE film DROP CONSTRAINT SYS_C00738336;
ALTER TABLE film ADD CONSTRAINT constraint_name;
CONSTRAINT complete_nn CHECK (complete IS NOT NULL);
</code>```

What I'm struggling to understand is why do I have to go through all of that when it appears that I can just use a 'modify' statement such as:

```<code>alter table
    film
modify
    (film_title NOT NULL);
</code>```

My understanding is that if you set something to 'NOT NULL' when you create it, the system automatically generates the constraint and that you don't need to manually drop it, which would save me quite a lot of time as there are a fairly large number of NULL and NOT NULL values that need to be altered.

Thank you in advance for any help you're able to provide.

答:
This depends on how the table was created.

There are essentially three ways to define a not null column:

film_title varchar(100) not null,

film_title varchar(100) constraint nn_film_title not null

film_title varchar(100) check (film_title is not null)

With option 3 the column is still marked as "NULLABLE" in USER_TAB_COLUMNS. In that case running alter table film3 modify film_title null will not remove the check constraint.

For option 1. and 2. the not null constraint can be removed either by using modify or by dropping the implicitly created check constraint by name.

I would also agree that for 1. and 2. using modify film_title null is the more stable (and less error-prone) approach.

However, dropping the check constraint is the only way that guarantees that the column is nullable afterwards - regardless on how the restriction was defined.

But it's extremely difficult to actually find out if a check constraint defines (only) a not null condition.

Body:
THE SCENARIO
I am working on an educational problem in which I need to convert some 'NOT NULL' constraints into 'NULL's and vice-versa.

PREVIOUS RESEARCH
I have read up a few sources that tell me /how/ I can do this (with methods that I will describe below) but they don't explain why I would want to use a seemingly longer and more convoluted method over a seemingly faster method.

How can I drop a "not null" constraint in Oracle when I don't know the name of the constraint?

How to fetch the system generated check constraint name of table column in oracle

THE PROBLEM
I've been instructed to query the table that I want to amend as follows:

SELECT constraint_name, constraint_type
FROM all_constraints
WHERE table_name = 'FILM'
AND owner = 'SAKILA'

This gives me all the constraints on the table including what appear to be a bunch of constraints that were automatically created by the database:

FK_FILM_LANGUAGE
FK_FILM_LANGUAGE_ORIGINAL
PK_FILM
SYS_C00738336
SYS_C00738337
SYS_C00738338
SYS_C00738339
SYS_C00738340

I am then being instructed to manually work out which SYS_**** relates to which item in the table and then manually drop those constraints and write in new ones as follows:

ALTER TABLE film DROP CONSTRAINT SYS_C00738336;
ALTER TABLE film ADD CONSTRAINT constraint_name;
CONSTRAINT complete_nn CHECK (complete IS NOT NULL);

What I'm struggling to understand is why do I have to go through all of that when it appears that I can just use a 'modify' statement such as:

alter table
    film
modify
    (film_title NOT NULL);

My understanding is that if you set something to 'NOT NULL' when you create it, the system automatically generates the constraint and that you don't need to manually drop it, which would save me quite a lot of time as there are a fairly large number of NULL and NOT NULL values that need to be altered.

Thank you in advance for any help you're able to provide.


来源: stackexchange

问:
How to create a number menu in python
i need a simple python code which makes a number menu, that doesn't take up many lines

```<code>    print ("Pick an option")
    menu =0
    Menu = input("""
    1. Check Password
    2. Generate Password
    3. Quit
    """)
    if (menu) == 1:
        Password = input("Please enter the password you want to check")
        points =0
</code>```

i tried this but it did not work how i thought it would. i thought this code would work as i have tried it before and it worked but i must have made a mistake in this one.

anyone have any suggestions?

thanks

this is my full code:

```<code>    print ("Pick an option")
    menu =0
    Menu = input("""
    1. Check Password
    2. Generate Password
    3. Quit
    """)
        if (menu) == 1:
        Password = input("Please enter the password you want to check")
        points =0
        smybols = ['!','%','^','&','*','(',')','-','_','=','+',]
        querty =
      ["qwertyuiop","QWERTYUIOP","asdfghjl","ASDFGHJKL","zxcvbnm","ZXCVBNM"]
if len(password) >24:
    print ('password is too long It must be between 8 and 24 characters')
elif len(password) <8:
    print ('password is too short It must be between 8 and 24 characters')
elif len(password) >=8 and len(password) <= 24:
    print ('password ok\n')
</code>```

答:
Because you are comparing a str and int. convert it into int

```<code>print ("Pick an option")
Menu = int(input("""
1. Check Password
2. Generate Password
3. Quit
"""))
if Menu == 1:
  Password = input("Please enter the password you want to check")
  points =0
</code>```

ContentLicense: CC BY-SA 3.0

Title: How to create a number menu in python

Body:
i need a simple python code which makes a number menu, that doesn't take up many lines

    print ("Pick an option")
    menu =0
    Menu = input("""
    1. Check Password
    2. Generate Password
    3. Quit
    """)
    if (menu) == 1:
        Password = input("Please enter the password you want to check")
        points =0

i tried this but it did not work how i thought it would. i thought this code would work as i have tried it before and it worked but i must have made a mistake in this one.

anyone have any suggestions?

thanks

this is my full code:

    print ("Pick an option")
    menu =0
    Menu = input("""
    1. Check Password
    2. Generate Password
    3. Quit
    """)
        if (menu) == 1:
        Password = input("Please enter the password you want to check")
        points =0
        smybols = ['!','%','^','&','*','(',')','-','_','=','+',]
        querty =
      ["qwertyuiop","QWERTYUIOP","asdfghjl","ASDFGHJKL","zxcvbnm","ZXCVBNM"]
if len(password) >24:
    print ('password is too long It must be between 8 and 24 characters')
elif len(password) <8:
    print ('password is too short It must be between 8 and 24 characters')
elif len(password) >=8 and len(password) <= 24:
    print ('password ok\n')

Body:
Because you are comparing a str and int. convert it into int

print ("Pick an option")
Menu = int(input("""
1. Check Password
2. Generate Password
3. Quit
"""))
if Menu == 1:
  Password = input("Please enter the password you want to check")
  points =0


问:
How to check if the object exists in Firebase using AngularFire $asObject()?
I'm using angularFire 0.8.2 and I'm trying to check a uniqueness of an user.

This user is stored in users/[id] where [id] is the simpleLogin generated id for login/password users and social uid for one that comes from social networks (i.e: facebook:891239120).

So when I'm logging with facebook, I need to check if that user is already in firebase, so I'm using (from angularFire-seed):

```<code>var userData = fbutil.syncObject('users/' + user.uid);
userData.$loaded()
         .then(function (data) {
         if(data) {
              console.log('EXISTS');
              console.log(data.$id);
         } else {
              console.log('NOT EXISTS');
         }
          }, function (err) {
              console.error(err);
          });
</code>```

But this not work because the data object is always returned (even if the object not with key user.uid not exists)

I found that obj.$value is filled with null when the obj is empty, and not present when the obj has not primitive value, but I'm not sure if this is the correct way to check it.

And I also don't know if I use $asArray on /users it will load EVERY user on firebase than in production it could have performance problems?

答:
For primitives: use data.$value !== null

For objects: check at least for a key the object must have i.e. data.id !== null.

For an everycase check, merge them in

if(data.$value === null && data.id === null) {
    //not exist
}else{
    // exist
};

Body:
I'm using angularFire 0.8.2 and I'm trying to check a uniqueness of an user.

This user is stored in users/[id] where [id] is the simpleLogin generated id for login/password users and social uid for one that comes from social networks (i.e: facebook:891239120).

So when I'm logging with facebook, I need to check if that user is already in firebase, so I'm using (from angularFire-seed):

var userData = fbutil.syncObject('users/' + user.uid);
userData.$loaded()
         .then(function (data) {
         if(data) {
              console.log('EXISTS');
              console.log(data.$id);
         } else {
              console.log('NOT EXISTS');
         }
          }, function (err) {
              console.error(err);
          });

But this not work because the data object is always returned (even if the object not with key user.uid not exists)

I found that obj.$value is filled with null when the obj is empty, and not present when the obj has not primitive value, but I'm not sure if this is the correct way to check it.

And I also don't know if I use $asArray on /users it will load EVERY user on firebase than in production it could have performance problems?


问:
Multiple unrelated queries in Neo4j Cypher?
Does http://localhost:7474/browser/ not support multiple unrelated queries?

This code:

```<code>MATCH (a {cond:'1'}), (b {cond:'x'}) CREATE a-[:rel]->b
MATCH (a {cond:'2'}), (b {cond:'y'}) CREATE a-[:rel]->b
MATCH (a {cond:'3'}), (b {cond:'z'}) CREATE a-[:rel]->b
</code>```

causes an error:

WITH is required between CREATE and MATCH

But since my queries aren't related, I don't think I shall need a WITH.

How do I do the above without having to enter it one-line-at-a-time?

答:
You can send multiple queries to Neo4j via the cypher-shell command line tool:

```<code>cypher-shell --format plain < query.txt
</code>```

where query.txt contains multiple independent queries separated by semi-colons. This also works interactively once you have started cypher-shell.

Body:
Does http://localhost:7474/browser/ not support multiple unrelated queries?

This code:

MATCH (a {cond:'1'}), (b {cond:'x'}) CREATE a-[:rel]->b
MATCH (a {cond:'2'}), (b {cond:'y'}) CREATE a-[:rel]->b
MATCH (a {cond:'3'}), (b {cond:'z'}) CREATE a-[:rel]->b

causes an error:

WITH is required between CREATE and MATCH

But since my queries aren't related, I don't think I shall need a WITH.

How do I do the above without having to enter it one-line-at-a-time?

Body:
You can send multiple queries to Neo4j via the cypher-shell command line tool:

cypher-shell --format plain < query.txt

where query.txt contains multiple independent queries separated by semi-colons. This also works interactively once you have started cypher-shell.


问:
Different css margins for mobile & desktop without multiple {% block content %} in Django template
I need to change the margin-left that is applied to my main {% block content %} in my base.html template (that contains my navbar and other common elements) based on if the viewer is using mobile or desktop.

My current base.html is like:

```<code><div class="content container-fluid">
    <div class="row">
        <div class="col-md-8">
            {% block content %}
            {% endblock %}
        </div>
    </div>
</div>
</code>```

with a css file containing:

```<code>.content {
    margin-left: 40px;
}

.content_mobile {
    margin-left: 10px;
}
</code>```

Given that in other parts of my application I've accomplished something similar by using the following dedicated Bootstrap classes, my first thought was to do the same using something like:

```<code><div class=".visible-xs-block, hidden-xs">
    <div class="content container-fluid">
        <div class="row">
            <div class="col-md-8">
                <!-- This is hidden from mobile view -->
                {% block content %}
                {% endblock %}
            </div>
        </div>
    </div>
</div>

<div class=".visible-lg-block, hidden-lg .visible-md-block, hidden-md .visible-sm-block, hidden-sm">
    <div class="content_mobile container-fluid">
        <div class="row">
            <div class="col-md-8">
                <!-- This is hidden from all other views (including desktop) -->
                {% block content %}
                {% endblock %}
            </div>
        </div>
    </div>
</div>
</code>```

But Django raises an exception because it can only render 1 {% block content %} per template!

Any ideas how I can do this without using multiple blocks?

答:
example :

```<code><div class="content">Some thing </div>
</code>```

you want to give different margin based on size of display

than do this

In your common css :

```<code>@media (max-width: 480px) {
    .content{
       margin-left: 20px;
    }
}

@media (max-width: 320px) {
    .content{
       margin-left: 10px;
    }
}
</code>```

and

```<code>@media (min-width:320px)  { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px)  { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px)  { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px)  { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }
</code>```

Body:
I need to change the margin-left that is applied to my main {% block content %} in my base.html template (that contains my navbar and other common elements) based on if the viewer is using mobile or desktop.

My current base.html is like:

            {% block content %}
            {% endblock %}

with a css file containing:

.content {
    margin-left: 40px;
}

.content_mobile {
    margin-left: 10px;
}

Given that in other parts of my application I've accomplished something similar by using the following dedicated Bootstrap classes, my first thought was to do the same using something like:

                {% block content %}
                {% endblock %}

                {% block content %}
                {% endblock %}

But Django raises an exception because it can only render 1 {% block content %} per template!

Any ideas how I can do this without using multiple blocks?

Body:
example :

<div class="content">Some thing </div>

you want to give different margin based on size of display

than do this

In your common css :

@media (max-width: 480px) {
    .content{
       margin-left: 20px;
    }
}

@media (max-width: 320px) {
    .content{
       margin-left: 10px;
    }
}

and

@media (min-width:320px)  { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px)  { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px)  { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px)  { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }


问:
UIStackView subviews with size classes
Trying to achieve UIStackView with 2 labels for iPhone and 3 labels for iPad using size classes.

View hierarchy

Default size class

```<code>[UIStackView]
  [UILabel 1] [UILabel2]
[UIStackView]
</code>```

RxR size class

```<code>[UIStackView]
  [UILabel 1] [UILabel2] [UILabel3]
[UIStackView]
</code>```

It looks exactly as expected in Storyboard as you can see in the above screenshots but on simulator iPad view is messed up.

iPhone Output (okay)

iPad Portrait Output (messed up)

iPad Landscape Output (messed up)

What's happening in iPad?? Is it a bug or I'm missing something?
Thanks.

I have created a sample project.

答: It seems you are hiding one of the labels on iPhone using the "installed" checkbox in Interface Builder. Using the "hidden" checkbox instead seems to solve the problem. Which I guess is a bug.</p>

Title: UIStackView subviews with size classes

Body:
Trying to achieve UIStackView with 2 labels for iPhone and 3 labels for iPad using size classes.

View hierarchy

Default size class

[UIStackView]
  [UILabel 1] [UILabel2]
[UIStackView]

RxR size class

[UIStackView]
  [UILabel 1] [UILabel2] [UILabel3]
[UIStackView]

It looks exactly as expected in Storyboard as you can see in the above screenshots but on simulator iPad view is messed up.

iPhone Output (okay)

iPad Portrait Output (messed up)

iPad Landscape Output (messed up)

What's happening in iPad?? Is it a bug or I'm missing something?
Thanks.

I have created a sample project.


问:
problem in an update form
when i was trying to work on update form I found that there is something wrong in it . the form works well but the new data don't insert to the database but show in the URL

code :

```<code>include"connection.php";

$gid = intval($_GET['id']);
$id = $_POST['product_id'];
$content = $_POST['content'];
$link = $_POST['link'];

if(isset($_POST['saveedit']) && $_POST['saveedit']=='products'){
    $update = mysql_query(" UPDATE products SET
                            content='$content',
                            link='$link'
                            WHERE product_id='$id' ") or die (mysql_error());

    if(isset($update)){
        echo "<b>update is done</b>";
    }
}

$query = mysql_query(" SELECT * FROM products WHERE product_id='".$gid."' ") or die (mysql_error());
$re = mysql_fetch_assoc($query);

if($_REQUEST['do'] == 'edit'){

echo"
<form action='".$_SERVER['PHP_SELF']."' metho='post'>
    <table>
    <tr>
    <td>Link : </td>
    <td><input type='text' name='link' value='".$re['link']."'/></td
    </tr>
    <tr>
    <td>Content :</td>
    <td><textarea name='content'>".$re['content']."</textarea></td>
    </tr>
    <tr>
    <td colspan='2'>
    <input type='submit' name='saveedit' value='save'/>
    <input type='hidden' name='id' value='".$gid."'/>
    <input type='hidden' name='productedit' value='products'/>
    </td>
    </tr>
    </table>
</form>
";
}

$data = mysql_query("SELECT * FROM products ORDER BY product_id");

echo"
    <table width='500' border='1'>
    <tr>
        <td>Link</td>
        <td>Content</td>
        <td>Option</td>
    </tr>
";

while($row = mysql_fetch_assoc($data)){
    echo"
        <tr>
        <td>".$row['link']."</td>
        <td>".$row['content']."</td>
        <td>
            <a href='edit.php?do=edit&id=".$row['product_id']."'> Edit </a>
        </td>
        </tr>
    ";
}
echo"</table>";
</code>```

?>

答:
PS. Not a answer but I dont know how to create a small comment underneath the main post.

You should really sanitize your code before you update your database, even if it is in the administration section.

ContentLicense: CC BY-SA 2.5

Title: problem in an update form

Body:
when i was trying to work on update form I found that there is something wrong in it . the form works well but the new data don't insert to the database but show in the URL

code :

include"connection.php";

$gid = intval($_GET['id']);
$id = $_POST['product_id'];
$content = $_POST['content'];
$link = $_POST['link'];

if(isset($_POST['saveedit']) && $_POST['saveedit']=='products'){
    $update = mysql_query(" UPDATE products SET
                            content='$content',
                            link='$link'
                            WHERE product_id='$id' ") or die (mysql_error());

    if(isset($update)){
        echo "update is done";
    }
}

$query = mysql_query(" SELECT * FROM products WHERE product_id='".$gid."' ") or die (mysql_error());
$re = mysql_fetch_assoc($query);

if($_REQUEST['do'] == 'edit'){

echo"
<form action='".$_SERVER['PHP_SELF']."' metho='post'>

    Link :
    <input type='text' name='link' value='".$re['link']."'/></td

    Content :
    <textarea name='content'>".$re['content']."</textarea>

    <input type='submit' name='saveedit' value='save'/>
    <input type='hidden' name='id' value='".$gid."'/>
    <input type='hidden' name='productedit' value='products'/>

</form>
";
}

$data = mysql_query("SELECT * FROM products ORDER BY product_id");

echo"

        Link
        Content
        Option

";

while($row = mysql_fetch_assoc($data)){
    echo"

        ".$row['link']."
        ".$row['content']."

             Edit

    ";
}
echo"
";

?>


问:
How to bind Wpf datagrid to dynamically created column name,value pairs?
I have multiple sets of Lists, which contain data regarding the column header and the value for that column.For any particular set the column headers remain the same.But they are different for different sets.Each list in a set will represent a row in the data grid.At a particular time one set's data will be displayed in the grid.Hence, the columns headers will be same for the all the list within that set.And the values in the list will be shown in rows. Suppose we have two lists:

```<code>List<Data> l1 = new List<Data>(){new Data(){Header="A",Value="A1"},new Data(){Header="B",Value="B1"}};
List<Data> l2 = new List<Data>(){new Data(){Header="A",Value="A2"},new Data(){Header="B",Value="B2"}};
</code>```

The data should be displayed in the grid as:

```<code>  A       B
  A1      B1
  A2      B2
</code>```

So, how do I achieve this , as for creating bindings I have to create public properties.And I can not hard code these properties, as they are dynamic.

答:
I solved this problem by using the ASh's suggestion of using DataTable.Below is the code that I used for converting my data to DataTable.

```<code>public static DataTable GenerateDataGridFromMetaData(List<ObservableCollection<DocumentMetaData>> dataList)
{
    try
    {
        if (dataList.Count > 0)
        {
                    DataTable dataTable = new DataTable();
                    List<int> skipColumn = new List<int>();
                    for (int index = 0; index < dataList.Count; index++)
                    {
                        ObservableCollection<DocumentMetaData> metaDataList = dataList[index];
                        List<string> values = new List<string>();
                        for (int metaDataIndex = 0; metaDataIndex < metaDataList.Count; metaDataIndex++)
                        {
                            DocumentMetaData docMetaData = metaDataList[metaDataIndex];
                            if (index == 0)
                            {
                                if (!dataTable.Columns.Contains(docMetaData.Title))
                                {
                                    dataTable.Columns.Add(docMetaData.Title);
                                    values.Add(docMetaData.Value);
                                }
                                else
                                {
                                    skipColumn.Add(metaDataIndex);
                                }
                            }
                            else
                            {
                                if (!skipColumn.Contains(metaDataIndex))
                                {
                                    values.Add(docMetaData.Value);
                                }
                            }
                        }
                        dataTable.Rows.Add(values);
                    }
                    return dataTable;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
            }
        }
</code>```

And this is the code that I used to bind data table to grid.

```<code>DataTable table = GridViewConverter.GenerateDataGridFromMetaData(dataList);
DataGrid.ItemsSource = table.DefaultView;
</code>```

Please, ensure that AutoGenerateColumns property is set to true, else grid will not display data.

Body:
I have multiple sets of Lists, which contain data regarding the column header and the value for that column.For any particular set the column headers remain the same.But they are different for different sets.Each list in a set will represent a row in the data grid.At a particular time one set's data will be displayed in the grid.Hence, the columns headers will be same for the all the list within that set.And the values in the list will be shown in rows. Suppose we have two lists:

List<Data> l1 = new List<Data>(){new Data(){Header="A",Value="A1"},new Data(){Header="B",Value="B1"}};
List<Data> l2 = new List<Data>(){new Data(){Header="A",Value="A2"},new Data(){Header="B",Value="B2"}};

The data should be displayed in the grid as:

  A       B
  A1      B1
  A2      B2

So, how do I achieve this , as for creating bindings I have to create public properties.And I can not hard code these properties, as they are dynamic.

Body:
I solved this problem by using the ASh's suggestion of using DataTable.Below is the code that I used for converting my data to DataTable.

public static DataTable GenerateDataGridFromMetaData(List<ObservableCollection<DocumentMetaData>> dataList)
{
    try
    {
        if (dataList.Count > 0)
        {
                    DataTable dataTable = new DataTable();
                    List<int> skipColumn = new List<int>();
                    for (int index = 0; index < dataList.Count; index++)
                    {
                        ObservableCollection<DocumentMetaData> metaDataList = dataList[index];
                        List<string> values = new List<string>();
                        for (int metaDataIndex = 0; metaDataIndex < metaDataList.Count; metaDataIndex++)
                        {
                            DocumentMetaData docMetaData = metaDataList[metaDataIndex];
                            if (index == 0)
                            {
                                if (!dataTable.Columns.Contains(docMetaData.Title))
                                {
                                    dataTable.Columns.Add(docMetaData.Title);
                                    values.Add(docMetaData.Value);
                                }
                                else
                                {
                                    skipColumn.Add(metaDataIndex);
                                }
                            }
                            else
                            {
                                if (!skipColumn.Contains(metaDataIndex))
                                {
                                    values.Add(docMetaData.Value);
                                }
                            }
                        }
                        dataTable.Rows.Add(values);
                    }
                    return dataTable;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
            }
        }

And this is the code that I used to bind data table to grid.

DataTable table = GridViewConverter.GenerateDataGridFromMetaData(dataList);
DataGrid.ItemsSource = table.DefaultView;

Please, ensure that AutoGenerateColumns property is set to true, else grid will not display data.


问:
how to drag and drop a letter from one textField to another in Swift iOS
I have five textFields I want to shuffle the letters from one textField to another.

Let's say I want to replace the letter A by B by drag and drop features. I will drag the A on B & B on A.

I have research this, but it is written in C#

How can I do that in Swift 4? Should I have to use UIPanGesture or something else (libraries).

答:
I doubt if textfield is a correct approach.
I would suggest you to use UICollectionView as it already has the functionality of drag and drop.

Basically you need to have textField in the cells of UICollectionView and implement drag and drop functionality.
You may consider following:

Apple docs

RAReorderableLayout GitHub Library


问:
Wordress index page redirects to another page
I have change the directory of my wordpress project from

/root/demoweb/web to /root

but index page still redirecting to old one.

I have changed the .htaccess configurations and settings/ general admin settings also.

what should i do ?

答: you have to change root path in your apache server file which is apache.conf .</p>


问:
Xamarin.Forms Android StackOverflowError with TabbedPage
I'm facing to an issue with Xamarin.Forms and more particulary with TabbedPage on Android.

I have created a TabbedPage that contains 4 ContentPage. Each ContentPage contains a ListView with a custom ItemTemplate (more than 50 lines in XAML). It's working fine on iOS but not on Android and I received this exception :

```<code>Java.Lang.StackOverflowError:
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:31
  at Android.Views.View.Draw (Android.Graphics.Canvas canvas) [0x0002c] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12837
  at Xamarin.Forms.Platform.Android.ScrollViewRenderer.Draw (Android.Graphics.Canvas canvas) [0x0000d] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:99
  at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12825
  at at (wrapper dynamic-method) System.Object:75413b68-d1a4-4864-b7a4-6d3fd2662bd8 (intptr,intptr,intptr)
  at java.lang.StackOverflowError
  at at android.graphics.Paint.getTextRunAdvances(Paint.java:2221)
  at at android.text.TextLine.handleText(TextLine.java:815)
  at at android.text.TextLine.handleRun(TextLine.java:970)
  at at android.text.TextLine.measureRun(TextLine.java:482)
  at at android.text.TextLine.measure(TextLine.java:361)
  at at android.text.TextLine.metrics(TextLine.java:335)
  at at android.text.Layout.getLineExtent(Layout.java:1001)
  at at android.text.Layout.drawText(Layout.java:332)
  at at android.text.Layout.draw(Layout.java:208)
  at at android.text.BoringLayout.draw(BoringLayout.java:403)
  at at android.widget.TextView.onDraw(TextView.java:6286)
  at at android.view.View.draw(View.java:15312)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.widget.ListView.drawChild(ListView.java:3403)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.widget.AbsListView.dispatchDraw(AbsListView.java:2931)
  at at android.widget.ListView.dispatchDraw(ListView.java:3398)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.AbsListView.draw(AbsListView.java:5153)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3151)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.widget.ScrollView.draw(ScrollView.java:2156)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ScrollViewRenderer.n_draw(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ScrollViewRenderer.draw(ScrollViewRenderer.java:59)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3151)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.support.v4.view.ViewPager.draw(ViewPager.java:2336)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2540)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
  at at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
  at at android.view.ViewRootImpl.draw(ViewRootImpl.java:2667)
  at at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2533)
  at at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2107)
  at at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
  at at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
  at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
  at at android.view.Choreographer.doCallbacks(Choreographer.java:603)
  at at android.view.Choreographer.doFrame(Choreographer.java:573)
  at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
  at at android.os.Handler.handleCallback(Handler.java:733)
  at at android.os.Handler.dispatchMessage(Handler.java:95)
  at at android.os.Looper.loop(Looper.java:157)
  at at android.app.ActivityThread.main(ActivityThread.java:5335)
  at at java.lang.reflect.Method.invokeNative(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:515)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  at at dalvik.system.NativeStart.main(Native Method)
</code>```

After some researches on Google I found this same issue https://forums.xamarin.com/discussion/48144/stackoverflowerror-on-android but the workaround could not be applied in my case (I can't reduce the number of line of my itemtemplate).
However, I'm not sure that the source of the issue is the number of elements in the ItemTemplate because the same ContentPage works fine in a MasterDetailPage on Android

If I cannot use the TabbedPage, do you know a component/sample that I can use to create a TabBar in Xamarin.Forms.

Thank you in advance for your help.
Regards.
Olivier.

答:
I had the same problem when I had ListView wrapped in ScrollView at TabbedPage.
You need to remove ScrollView from this layout. because ListView has its own inner scrolling</p>

Body:
I'm facing to an issue with Xamarin.Forms and more particulary with TabbedPage on Android.

I have created a TabbedPage that contains 4 ContentPage. Each ContentPage contains a ListView with a custom ItemTemplate (more than 50 lines in XAML). It's working fine on iOS but not on Android and I received this exception :

Java.Lang.StackOverflowError:
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:31
  at Android.Views.View.Draw (Android.Graphics.Canvas canvas) [0x0002c] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12837
  at Xamarin.Forms.Platform.Android.ScrollViewRenderer.Draw (Android.Graphics.Canvas canvas) [0x0000d] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:99
  at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12825
  at at (wrapper dynamic-method) System.Object:75413b68-d1a4-4864-b7a4-6d3fd2662bd8 (intptr,intptr,intptr)
  at java.lang.StackOverflowError
  at at android.graphics.Paint.getTextRunAdvances(Paint.java:2221)
  at at android.text.TextLine.handleText(TextLine.java:815)
  at at android.text.TextLine.handleRun(TextLine.java:970)
  at at android.text.TextLine.measureRun(TextLine.java:482)
  at at android.text.TextLine.measure(TextLine.java:361)
  at at android.text.TextLine.metrics(TextLine.java:335)
  at at android.text.Layout.getLineExtent(Layout.java:1001)
  at at android.text.Layout.drawText(Layout.java:332)
  at at android.text.Layout.draw(Layout.java:208)
  at at android.text.BoringLayout.draw(BoringLayout.java:403)
  at at android.widget.TextView.onDraw(TextView.java:6286)
  at at android.view.View.draw(View.java:15312)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.widget.ListView.drawChild(ListView.java:3403)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.widget.AbsListView.dispatchDraw(AbsListView.java:2931)
  at at android.widget.ListView.dispatchDraw(ListView.java:3398)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.AbsListView.draw(AbsListView.java:5153)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3151)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.widget.ScrollView.draw(ScrollView.java:2156)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ScrollViewRenderer.n_draw(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ScrollViewRenderer.draw(ScrollViewRenderer.java:59)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3151)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.support.v4.view.ViewPager.draw(ViewPager.java:2336)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2540)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
  at at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
  at at android.view.ViewRootImpl.draw(ViewRootImpl.java:2667)
  at at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2533)
  at at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2107)
  at at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
  at at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
  at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
  at at android.view.Choreographer.doCallbacks(Choreographer.java:603)
  at at android.view.Choreographer.doFrame(Choreographer.java:573)
  at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
  at at android.os.Handler.handleCallback(Handler.java:733)
  at at android.os.Handler.dispatchMessage(Handler.java:95)
  at at android.os.Looper.loop(Looper.java:157)
  at at android.app.ActivityThread.main(ActivityThread.java:5335)
  at at java.lang.reflect.Method.invokeNative(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:515)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  at at dalvik.system.NativeStart.main(Native Method)

After some researches on Google I found this same issue https://forums.xamarin.com/discussion/48144/stackoverflowerror-on-android but the workaround could not be applied in my case (I can't reduce the number of line of my itemtemplate).
However, I'm not sure that the source of the issue is the number of elements in the ItemTemplate because the same ContentPage works fine in a MasterDetailPage on Android

If I cannot use the TabbedPage, do you know a component/sample that I can use to create a TabBar in Xamarin.Forms.

Thank you in advance for your help.
Regards.
Olivier.


问:
Transfer List<String> to another activity ListView
MainActivity:

```<code>import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import java.util.*;
import android.content.Intent;

public class MainActivity extends Activity {

    private Spinner spinner1;
    private Button btnSubmit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        addListenerOnButton();
        addListenerOnSpinnerItemSelection();
    }

    public void addListenerOnSpinnerItemSelection() {
        spinner1 = (Spinner) findViewById(R.id.spinner1);
        spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());
    }

    // get the selected dropdown list value
    public void addListenerOnButton() {

        spinner1 = (Spinner) findViewById(R.id.spinner1);
        btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                //Get Value from EditText                    //Save value to a Variable
                EditText person0 = findViewById(R.id.spot0); String saved_spot0 = person0.getText().toString();
                EditText person1 = findViewById(R.id.spot1); String saved_spot1 = person1.getText().toString();
                EditText person2 = findViewById(R.id.spot2); String saved_spot2 = person2.getText().toString();
                EditText person3 = findViewById(R.id.spot3); String saved_spot3 = person3.getText().toString();
                EditText person4 = findViewById(R.id.spot4); String saved_spot4 = person4.getText().toString();
                EditText person5 = findViewById(R.id.spot5); String saved_spot5 = person5.getText().toString();
                EditText person6 = findViewById(R.id.spot6); String saved_spot6 = person6.getText().toString();
                EditText person7 = findViewById(R.id.spot7); String saved_spot7 = person7.getText().toString();
                EditText person8 = findViewById(R.id.spot8); String saved_spot8 = person8.getText().toString();
                EditText person9 = findViewById(R.id.spot9); String saved_spot9 = person9.getText().toString();

                List<String> filled_spots = Arrays.asList(saved_spot0, saved_spot1, saved_spot2, saved_spot3, saved_spot4, saved_spot5, saved_spot6, saved_spot7, saved_spot8, saved_spot9);

                Collections.shuffle(filled_spots); //Shuffle List
                Collections.sort(filled_spots); //Sort List

                Intent teams_Screen = new Intent (MainActivity.this, DisplayTeamsActivity.class);
                teams_Screen.putStringArrayListExtra ("mylist", (ArrayList<String>) filled_spots);

                startActivity(teams_Screen);
            }

        });
    }
}
</code>```

DisplayTeamsActivity:

```<code>import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;

public class DisplayTeamsActivity extends AppCompatActivity {

    private ListView lv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_teams);

        ArrayList<String> stringList = getIntent().getStringArrayListExtra("mylist");

    }
}
</code>```

I need to pass the List array from one activity to another and populate the listView I have from the shuffeld array, but something is crashing my app when i click on the button that takes me to the next activity. I dont know if this is correctly done and what is the problem causing it to entirely crash...

答:
you can try this

in first acticity

Intent intent = new Intent(context, NewActivity.class);

intent.putExtra("mylist", yourlist_array);

context.startActivity(intent);

in second activity

Intent intent = getIntent();

List stringArray = intent.getStringArrayExtra("mylist");

Body:
MainActivity:

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import java.util.*;
import android.content.Intent;

public class MainActivity extends Activity {

    private Spinner spinner1;
    private Button btnSubmit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        addListenerOnButton();
        addListenerOnSpinnerItemSelection();
    }

    public void addListenerOnSpinnerItemSelection() {
        spinner1 = (Spinner) findViewById(R.id.spinner1);
        spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());
    }

    // get the selected dropdown list value
    public void addListenerOnButton() {

        spinner1 = (Spinner) findViewById(R.id.spinner1);
        btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                //Get Value from EditText                    //Save value to a Variable
                EditText person0 = findViewById(R.id.spot0); String saved_spot0 = person0.getText().toString();
                EditText person1 = findViewById(R.id.spot1); String saved_spot1 = person1.getText().toString();
                EditText person2 = findViewById(R.id.spot2); String saved_spot2 = person2.getText().toString();
                EditText person3 = findViewById(R.id.spot3); String saved_spot3 = person3.getText().toString();
                EditText person4 = findViewById(R.id.spot4); String saved_spot4 = person4.getText().toString();
                EditText person5 = findViewById(R.id.spot5); String saved_spot5 = person5.getText().toString();
                EditText person6 = findViewById(R.id.spot6); String saved_spot6 = person6.getText().toString();
                EditText person7 = findViewById(R.id.spot7); String saved_spot7 = person7.getText().toString();
                EditText person8 = findViewById(R.id.spot8); String saved_spot8 = person8.getText().toString();
                EditText person9 = findViewById(R.id.spot9); String saved_spot9 = person9.getText().toString();

                List<String> filled_spots = Arrays.asList(saved_spot0, saved_spot1, saved_spot2, saved_spot3, saved_spot4, saved_spot5, saved_spot6, saved_spot7, saved_spot8, saved_spot9);

                Collections.shuffle(filled_spots); //Shuffle List
                Collections.sort(filled_spots); //Sort List

                Intent teams_Screen = new Intent (MainActivity.this, DisplayTeamsActivity.class);
                teams_Screen.putStringArrayListExtra ("mylist", (ArrayList<String>) filled_spots);

                startActivity(teams_Screen);
            }

        });
    }
}

DisplayTeamsActivity:

import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;

public class DisplayTeamsActivity extends AppCompatActivity {

    private ListView lv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_teams);

        ArrayList<String> stringList = getIntent().getStringArrayListExtra("mylist");

    }
}

I need to pass the List array from one activity to another and populate the listView I have from the shuffeld array, but something is crashing my app when i click on the button that takes me to the next activity. I dont know if this is correctly done and what is the problem causing it to entirely crash...


问:
Does the Either type constructor contain a phantom type each for the left/right case?
AFAIK, only types are inhabited by values in Haskell, not type constructors. Either is a binary type constructor of kind * -> * -> *. Left and Right both apply this type constructor to a single type, which is provided by the passed value. Doesn't that mean that in both cases Either is merely partially applied and thus still a type constructor awaiting the missing type argument?

```<code>let x = Right 'x' -- Either a Char
</code>```

x has the type Either a Char. I would assume that this type would have the kind * -> *. This is clearly a polymorphic type, not a ground one. Yet Either a Char can be inhabited by values like 'x'.

My suspicion is that the type variable a is a phantom type for the Right case resp. b for Left. I know phantom types in connection with  Const, where the respective type variable isn't used at all. Am I on the right tack?

答:
I would argue that a type variable is phantom if and only if the choice of the type variable does not restrict what values can be passed to the type's constructors. The important part is that this is a type-centric definition. It is determined by looking only at the type definition, not at some particular value of the type.

So does it matter that no value of type String appears in the value Left 5 :: Either Int String? Not at all. What matters is that the choice of String in Either Int String prevents Right () from type-checking.

Body:
AFAIK, only types are inhabited by values in Haskell, not type constructors. Either is a binary type constructor of kind * -> * -> *. Left and Right both apply this type constructor to a single type, which is provided by the passed value. Doesn't that mean that in both cases Either is merely partially applied and thus still a type constructor awaiting the missing type argument?

let x = Right 'x' -- Either a Char

x has the type Either a Char. I would assume that this type would have the kind * -> *. This is clearly a polymorphic type, not a ground one. Yet Either a Char can be inhabited by values like 'x'.

My suspicion is that the type variable a is a phantom type for the Right case resp. b for Left. I know phantom types in connection with  Const, where the respective type variable isn't used at all. Am I on the right tack?


问:
bootstrap drop-down menu auto dropup according to screen position?
I was wondering if any of you has what I am asking for ready, to save me from the trouble. What I am looking for is for a dropdown menu to have the dropup class automatically added according to its position on the screen - and also change automatically when the user scrolls or resizes window.

What I am looking for is already implemented in the bootstrap-select plugin, but the plugin is too 'heavy' to use.

答:
I found the answer from Zoltán Tamási to be a good starting point but not enough when the dropdown should appear within a div with a vertical scrollbar. I needed the height of that div (the scrollHeight variable in the code below) to figure out if the dropdown will take to much space at the bottom.</p>

```<code>jquery(document).on("show.bs.dropdown", ".dropdown", function () {
  var $ul = jquery(this).children(".dropdown-menu");
  var menuHeight = $ul.height()
  var buttonHeight = jquery(this).children(".dropdown-toggle").height();
  var scrollHeight = $ul.parent().offsetParent().height();
  var menuAnchorTop = $ul.parent().position().top + buttonHeight;

  // how much space would be left at the top
  var spaceUp = (menuAnchorTop - buttonHeight - menuHeight);
  // how much space would be left at the bottom
  var spaceDown = scrollHeight - (menuAnchorTop + menuHeight);
  // Switch to dropup if more space there
  if (spaceDown < 0 && (spaceUp >= 0 || spaceUp > spaceDown))
    jquery(this).addClass("dropup");
}).on("hidden.bs.dropdown", ".dropdown", function() {
  // always reset after close
  jquery(this).removeClass("dropup");
});
</code>```

Body:
I found the answer from Zoltán Tamási to be a good starting point but not enough when the dropdown should appear within a div with a vertical scrollbar. I needed the height of that div (the scrollHeight variable in the code below) to figure out if the dropdown will take to much space at the bottom.

jquery(document).on("show.bs.dropdown", ".dropdown", function () {
  var $ul = jquery(this).children(".dropdown-menu");
  var menuHeight = $ul.height()
  var buttonHeight = jquery(this).children(".dropdown-toggle").height();
  var scrollHeight = $ul.parent().offsetParent().height();
  var menuAnchorTop = $ul.parent().position().top + buttonHeight;

  // how much space would be left at the top
  var spaceUp = (menuAnchorTop - buttonHeight - menuHeight);
  // how much space would be left at the bottom
  var spaceDown = scrollHeight - (menuAnchorTop + menuHeight);
  // Switch to dropup if more space there
  if (spaceDown < 0 && (spaceUp >= 0 || spaceUp > spaceDown))
    jquery(this).addClass("dropup");
}).on("hidden.bs.dropdown", ".dropdown", function() {
  // always reset after close
  jquery(this).removeClass("dropup");
});


问:
YAML Parsing Issue in Rails
I have an issue on Elastic Beanstalk deployment which is:

```<code>YAML syntax error occurred while parsing /var/app/ondeck/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `<main>'

Caused by: Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `<main>' Tasks: TOP => environment (See full trace by running task with --trace).
</code>```

As what I have read, this is because YAML forbids using tabs, instead it uses spaces.

The problem is that I manually checked every YAML file for tabs, and never found one. I think I missed something so my question is: is there any script that can go through my entire source code replacing tabs with 2 spaces in every YAML file?

答:
It’s ruby after all: it’s easier and faster to write the script rather than ask questions on SO and google for it.</p>

```<code>Dir['*/**/*.yml'].each do |f|
  File.write(f, File.read(f).gsub(/\t/, '  '))
end
</code>```

Title: YAML Parsing Issue in Rails

Body:
I have an issue on Elastic Beanstalk deployment which is:

YAML syntax error occurred while parsing /var/app/ondeck/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `'

Caused by: Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `' Tasks: TOP => environment (See full trace by running task with --trace).

As what I have read, this is because YAML forbids using tabs, instead it uses spaces.

The problem is that I manually checked every YAML file for tabs, and never found one. I think I missed something so my question is: is there any script that can go through my entire source code replacing tabs with 2 spaces in every YAML file?

Body:
It’s ruby after all: it’s easier and faster to write the script rather than ask questions on SO and google for it.

Dir['*/**/*.yml'].each do |f|
  File.write(f, File.read(f).gsub(/\t/, '  '))
end


问:
existing vuejs data not displaying using v-for
In console.log(e.data) I am getting values, but when I try to display using v-for the data is not displaying. Can anybody please sort tell me why this is happening?

The following is the HTML code to display values

```<code><div id="feed12">
  <div v-for="row in data">
    {{row.bussinessName}}
  </div>
</div>
</code>```

My vue js code is

```<code><script type="text/javascript">
  new Vue({
    el: '#feed12' ,
    data: {
      data: {},
    },
    mounted() {
      navigator.geolocation.getCurrentPosition(success, error);
      function success(position) {
        var GEOCODING = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' + position.coords.latitude + '%2C' + position.coords.longitude + '&language=en';
        $.getJSON(GEOCODING).done(function(location) {
        $('#country').html(location.results[0].address_components[5].long_name);
          $('#state').html(location.results[0].address_components[4].long_name);
          $('#city').html(location.results[0].address_components[2].long_name);
          $('#address').html(location.results[0].formatted_address);
          $('#latitude').html(position.coords.latitude);
          $('#longitude').html(position.coords.longitude);
        })

        var lat = position.coords.latitude;
        $.ajax({
          url: 'https://n2s.herokuapp.com/api/post/filter/',
          data: {
            lat: position.coords.latitude,
            lon: position.coords.longitude,
          },
          type: "POST",
          dataType: 'json',
          success: function (e) {
            if (e.status == 1) {
              self.data = e.data;
              console.log(e.data)
            }
          }
        });
        console.log(lat);
      }

      function error(err) {
        console.log(err)
      }
    }
  })
</script>
</code>```

答:
From what I see you forgot to assign your self to this.
Just change

```<code>mounted() {
  navigator.geolocation.getCurrentPosition(success, error);
</code>```

to

```<code>mounted() {
  var self = this;
  navigator.geolocation.getCurrentPosition(success, error);
</code>```

Normally your code should show an error in debugging in such a case. You can use Vue-Devtools to find conflicts within your Vue code easily through the console. I am using the chrome addon. Make sure to have Vue.config.devtools = true or use the dev build of Vue.js (not the minified version).

https://github.com/vuejs/vue-devtools.

Body:
In console.log(e.data) I am getting values, but when I try to display using v-for the data is not displaying. Can anybody please sort tell me why this is happening?

The following is the HTML code to display values

    {{row.bussinessName}}

My vue js code is

Body:
From what I see you forgot to assign your self to this.
Just change

mounted() {
  navigator.geolocation.getCurrentPosition(success, error);

to

mounted() {
  var self = this;
  navigator.geolocation.getCurrentPosition(success, error);

Normally your code should show an error in debugging in such a case. You can use Vue-Devtools to find conflicts within your Vue code easily through the console. I am using the chrome addon. Make sure to have Vue.config.devtools = true or use the dev build of Vue.js (not the minified version).

https://github.com/vuejs/vue-devtools.


问:
CORS Strange behaviour
I am using axios client with angular2 to make a RESTFull post to a specific endpoint.

I get this CORS error:

Failed to load http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

When I check my preflight request in the chrome dev tools network tab everything seems to be in order. The network tab shows this:

```<code>Request URL:http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute
Request Method:OPTIONS
Status Code:200 OK
Remote Address:[::1]:57772
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
ACCESS-CONTROL-ALLOW-CREDENTIALS:true
ACCESS-CONTROL-ALLOW-HEADERS:authorization,content-type
ACCESS-CONTROL-ALLOW-METHODS:POST
ACCESS-CONTROL-ALLOW-ORIGIN:http://localhost:4200
ALLOW:POST,OPTIONS
</code>```

The comes the actual post :

```<code> Request URL:http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute
Request Method:POST
Status Code:200 OK
Remote Address:[::1]:57772
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
CACHE-CONTROL:no-cache
Connection:Keep-Alive
CONTENT-LENGTH:179
Content-Type:application/json; charset=utf-8
Date:Tue, 14 Nov 2017 12:53:46 GMT
EXPIRES:Thu, 29 Oct 1998 17:04:19 GMT
Keep-Alive:timeout=120
PRAGMA:no-cache
Server:Apache
</code>```

答: It sounds like you're only including the response headers in the OPTIONS response, not the POST response. You need to include them in both responses.

Title: CORS Strange behaviour

Body:
I am using axios client with angular2 to make a RESTFull post to a specific endpoint.

I get this CORS error:

Failed to load http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

When I check my preflight request in the chrome dev tools network tab everything seems to be in order. The network tab shows this:

Request URL:http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute
Request Method:OPTIONS
Status Code:200 OK
Remote Address:[::1]:57772
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
ACCESS-CONTROL-ALLOW-CREDENTIALS:true
ACCESS-CONTROL-ALLOW-HEADERS:authorization,content-type
ACCESS-CONTROL-ALLOW-METHODS:POST
ACCESS-CONTROL-ALLOW-ORIGIN:http://localhost:4200
ALLOW:POST,OPTIONS

The comes the actual post :

 Request URL:http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute
Request Method:POST
Status Code:200 OK
Remote Address:[::1]:57772
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
CACHE-CONTROL:no-cache
Connection:Keep-Alive
CONTENT-LENGTH:179
Content-Type:application/json; charset=utf-8
Date:Tue, 14 Nov 2017 12:53:46 GMT
EXPIRES:Thu, 29 Oct 1998 17:04:19 GMT
Keep-Alive:timeout=120
PRAGMA:no-cache
Server:Apache


问:
NullInjectorError: No provider for MatDialogRef
I can't inject MatDialogRef as it described in documentation: https://material.angular.io/components/dialog/overview

When i'm trying to do it i'v got error:

ERROR Error: StaticInjectorError[MatDialogRef]:
StaticInjectorError[MatDialogRef]:
NullInjectorError: No provider for MatDialogRef!

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';

import {
 MatInputModule,
 MatDialogModule,
 MatProgressSpinnerModule,
 MatButtonModule,
 MatDialog,
 MatDialogRef
} from '@angular/material';

import { ApiModule } from '../api/api.module';
import { RoutingModule } from '../routing/routing.module';

import { RegistrationComponent } from './components/registration.component';
import { LoginComponent } from './components/login.component';

import { AccountService } from './services/account.service';

@NgModule({
 imports: [
  BrowserModule,
  MatInputModule,
  MatDialogModule,
  MatProgressSpinnerModule,
  MatButtonModule,
  FormsModule,
  RoutingModule,
  ApiModule
 ],
 declarations: [
  RegistrationComponent,
  LoginComponent
 ],
 entryComponents: [
  LoginComponent,
  RegistrationComponent
 ],
 providers: [
  AccountService,
  MatDialog,
  MatDialogRef
 ]
})
export class AccountModule {}```
</div>
</div>
</p>

<p>home.component.ts</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { Component } from '@angular/core';

import { MatDialog } from '@angular/material';
import { RegistrationComponent } from '../account/components/registration.component';

@Component({
    moduleId: module.id.replace('compiled', 'app'),
    templateUrl: 'home.component.html'
})
export class HomeComponent
{
    constructor(private modalService: MatDialog) {}

    public openModal() : void
    {
        let dialog = this.modalService.open(RegistrationComponent, {});
    }
}</code>```

registration.component.ts

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { MatDialogRef } from '@angular/material/dialog';

import { User } from '../../../models/domain/User';
import { ApiUserService } from '../../api/entity-services/user.service';
import { AuthService } from '../../auth/auth.service';
import { AccountService } from '../services/account.service'

@Component({
 selector: 'registration-component',
 templateUrl: 'app/modules/account/templates/registration.component.html'
})
export class RegistrationComponent
{
 public user :User = new User();

 public errorMessage :string;

 public isLoading :boolean;

 constructor
 (
  private userService :ApiUserService,
  private authService :AuthService,
  private accountService :AccountService,
  private router :Router,
  public dialogRef :MatDialogRef<RegistrationComponent>
 )
 {
  this.isLoading = false;
 }

 public onSubmit(e) :void
 {
  e.preventDefault();
  this.isLoading = true;

  this.userService
   .Create(this.user)
   .subscribe(
    user =>
    {
     this.user.id = user.id;
     this.user.login = user.login;

     this.authService
      .Login(this.user)
      .subscribe(
       token =>
       {
        this.accountService.Load()
         .subscribe(
          account =>
          {
           this.user = account;
           this.isLoading = false;
           this.dialogRef.close();

           let redirectRoute = account.activeScopeId
            ? `/scope/${account.activeScopeId}`
            : '/scope-list/';

           this.router.navigate([redirectRoute]);
          },
          error => this.errorMessage = <any>error
         );
       },
       error => this.errorMessage = <any>error
      );
    },
    error => this.errorMessage = <any>error
   );
 }
}```

答:
It could be due to you not including a Web Animations API polyfill which is required for Angular animations to work since it relies on the API.

Here's a caniuse for the browsers that support it natively. Currently only Chrome, Firefox and Opera support the Web Animations API.

Anyway, you have to follow these steps to get a polyfill:

In the terminal, type the following in your console:

npm install web-animations-js
```</li>
<li><p>Once you have finished installing, uncomment the line for Angular Animations in <code>polyfills.ts</code> (or add it if it's not there):</p>

<pre class="lang-ts prettyprint-override"><code>import 'web-animations-js'; // Uncomment this line
</code>```

Alternatively, you can try importing the modules from the separate endpoints, like so:

From:

import { MatButtonModule, MatDialogModule } from '@angular/material';
```

<p>To:</p>

<pre class="lang-ts prettyprint-override"><code>import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
</code>```

Body:
I can't inject MatDialogRef as it described in documentation: https://material.angular.io/components/dialog/overview

When i'm trying to do it i'v got error:

ERROR Error: StaticInjectorError[MatDialogRef]:
StaticInjectorError[MatDialogRef]:
NullInjectorError: No provider for MatDialogRef!

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';

import {
 MatInputModule,
 MatDialogModule,
 MatProgressSpinnerModule,
 MatButtonModule,
 MatDialog,
 MatDialogRef
} from '@angular/material';

import { ApiModule } from '../api/api.module';
import { RoutingModule } from '../routing/routing.module';

import { RegistrationComponent } from './components/registration.component';
import { LoginComponent } from './components/login.component';

import { AccountService } from './services/account.service';

@NgModule({
 imports: [
  BrowserModule,
  MatInputModule,
  MatDialogModule,
  MatProgressSpinnerModule,
  MatButtonModule,
  FormsModule,
  RoutingModule,
  ApiModule
 ],
 declarations: [
  RegistrationComponent,
  LoginComponent
 ],
 entryComponents: [
  LoginComponent,
  RegistrationComponent
 ],
 providers: [
  AccountService,
  MatDialog,
  MatDialogRef
 ]
})
export class AccountModule {}

home.component.ts

import { Component } from '@angular/core';

import { MatDialog } from '@angular/material';
import { RegistrationComponent } from '../account/components/registration.component';

@Component({
    moduleId: module.id.replace('compiled', 'app'),
    templateUrl: 'home.component.html'
})
export class HomeComponent
{
    constructor(private modalService: MatDialog) {}

    public openModal() : void
    {
        let dialog = this.modalService.open(RegistrationComponent, {});
    }
}

registration.component.ts

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { MatDialogRef } from '@angular/material/dialog';

import { User } from '../../../models/domain/User';
import { ApiUserService } from '../../api/entity-services/user.service';
import { AuthService } from '../../auth/auth.service';
import { AccountService } from '../services/account.service'

@Component({
 selector: 'registration-component',
 templateUrl: 'app/modules/account/templates/registration.component.html'
})
export class RegistrationComponent
{
 public user :User = new User();

 public errorMessage :string;

 public isLoading :boolean;

 constructor
 (
  private userService :ApiUserService,
  private authService :AuthService,
  private accountService :AccountService,
  private router :Router,
  public dialogRef :MatDialogRef<RegistrationComponent>
 )
 {
  this.isLoading = false;
 }

 public onSubmit(e) :void
 {
  e.preventDefault();
  this.isLoading = true;

  this.userService
   .Create(this.user)
   .subscribe(
    user =>
    {
     this.user.id = user.id;
     this.user.login = user.login;

     this.authService
      .Login(this.user)
      .subscribe(
       token =>
       {
        this.accountService.Load()
         .subscribe(
          account =>
          {
           this.user = account;
           this.isLoading = false;
           this.dialogRef.close();

           let redirectRoute = account.activeScopeId
            ? `/scope/${account.activeScopeId}`
            : '/scope-list/';

           this.router.navigate([redirectRoute]);
          },
          error => this.errorMessage = <any>error
         );
       },
       error => this.errorMessage = <any>error
      );
    },
    error => this.errorMessage = <any>error
   );
 }
}

Body:
It could be due to you not including a Web Animations API polyfill which is required for Angular animations to work since it relies on the API.

Here's a caniuse for the browsers that support it natively. Currently only Chrome, Firefox and Opera support the Web Animations API.

Anyway, you have to follow these steps to get a polyfill:

In the terminal, type the following in your console:

npm install web-animations-js

Once you have finished installing, uncomment the line for Angular Animations in polyfills.ts (or add it if it's not there):

import 'web-animations-js'; // Uncomment this line

Alternatively, you can try importing the modules from the separate endpoints, like so:

From:

import { MatButtonModule, MatDialogModule } from '@angular/material';

To:

import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';


答:
Do this:

```<code>ArrayList<String> filled_spots = new ArrayList<>(Arrays.asList("nome1", "nome2"));

Collections.shuffle(filled_spots); //Shuffle List
Collections.sort(filled_spots); //Sort List

Intent teams_Screen = new Intent (MainActivity.this, DisplayTeamsActivity.class);
teams_Screen.putStringArrayListExtra("mylist", filled_spots);
</code>```

At DisplayTeamsActivity you'll need do this:

```<code>    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ArrayList<String> stringList = getIntent().getStringArrayListExtra("mylist");
    }
</code>```

Title: Transfer List<String> to another activity ListView

Body:
Do this:

ArrayList<String> filled_spots = new ArrayList<>(Arrays.asList("nome1", "nome2"));

Collections.shuffle(filled_spots); //Shuffle List
Collections.sort(filled_spots); //Sort List

Intent teams_Screen = new Intent (MainActivity.this, DisplayTeamsActivity.class);
teams_Screen.putStringArrayListExtra("mylist", filled_spots);

At DisplayTeamsActivity you'll need do this:

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ArrayList<String> stringList = getIntent().getStringArrayListExtra("mylist");
    }


问:
How to pass multiple statements into Spark SQL HiveContext
For example I have few Hive HQL statements which I want to pass into Spark SQL:

set parquet.compression=SNAPPY;
create table MY_TABLE stored as parquet as select * from ANOTHER_TABLE;
select * from MY_TABLE limit 5;
```

<p>Following doesn't work:</p>

<pre class="lang-java prettyprint-override"><code>hiveContext.sql("set parquet.compression=SNAPPY; create table MY_TABLE stored as parquet as select * from ANOTHER_TABLE; select * from MY_TABLE limit 5;")
</code>```

How to pass the statements into Spark SQL?

答:
I worked on a scenario where i needed to read a sql file and run all the; separated queries present in that file.

One simple way to do it is like this:

```<code>val hsc = new org.apache.spark.sql.hive.HiveContext(sc)
val sql_file = "/hdfs/path/to/file.sql"
val f = sc.wholeTextFiles(s"$sql_file")
val queries = f.take(1)(0)._2
Predef.refArrayOps(queries.split(';')).map(query => hsc.sql(query))
</code>```

Body:
For example I have few Hive HQL statements which I want to pass into Spark SQL:

set parquet.compression=SNAPPY;
create table MY_TABLE stored as parquet as select * from ANOTHER_TABLE;
select * from MY_TABLE limit 5;

Following doesn't work:

hiveContext.sql("set parquet.compression=SNAPPY; create table MY_TABLE stored as parquet as select * from ANOTHER_TABLE; select * from MY_TABLE limit 5;")

How to pass the statements into Spark SQL?

Body:
I worked on a scenario where i needed to read a sql file and run all the; separated queries present in that file.

One simple way to do it is like this:

val hsc = new org.apache.spark.sql.hive.HiveContext(sc)
val sql_file = "/hdfs/path/to/file.sql"
val f = sc.wholeTextFiles(s"$sql_file")
val queries = f.take(1)(0)._2
Predef.refArrayOps(queries.split(';')).map(query => hsc.sql(query))

ContentLicense: CC BY-SA 4.0