问:
Edits in List not being saved when partial view loaded MVC
I'm new to MVC.  I have a view which displays the products attached to a Quote (the QuoteDetails).  I also have an Ajax.ActionLink)_ for "Add product" which loads a partial view for another product to be entered.  The problem is that when the partial view is loaded, edits to the other products not in the partial view are not saved.  If no partial view is loaded, edits to the listed products are saved just fine.

Here is the relevant code for the main view:

```<code>@model CMSUsersAndRoles.Models.QuoteViewModel
....
@Scripts.Render("~/Scripts/jquery.unobtrusive-ajax.min.js")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="~/Scripts/jquery.mask.min.js"></script>
@using (Html.BeginForm())
{
    ....
    @Html.HiddenFor(model => model.CustomerId)

    @Html.LabelFor(model => model.QuoteId)
    @Html.EditorFor(model => model.QuoteId, new { htmlAttributes = new { @readonly = "readonly", @class = "form-control" } })
    @Html.ValidationMessageFor(model => model.QuoteId)

    .... // more controls for properties of Quote

    @Html.LabelFor(model => model.QuoteDetail)
    <div id="QuoteDetails">
        @for (int i = 0; i < Model.QuoteDetail.Count; i++)
        {
            @Html.HiddenFor(model => model.QuoteDetail[i].QuoteId, new { htmlAttributes = new { @class = "form-control" } })
            ....
            @Html.EditorFor(model => model.QuoteDetail[i].SKU, new { htmlAttributes = new { @readonly = "readonly", @id = "SKU", @class = "form-control", style = "width: 100px" } })
            @Html.EditorFor(model => model.QuoteDetail[i].Amount, new { htmlAttributes = new { @class = "form-control amount", style = "width: 95px" } })
            @Html.ValidationMessageFor(model => model.QuoteDetail[i].Amount)

            .... // more for controls for properties of QuoteDetail

            @Ajax.ActionLink(" ", "DeleteProduct", "QuoteViewModel", new { quoteId = Model.QuoteDetail[i].QuoteId, quoteDetailId = (Model.QuoteDetail[i].QuoteDetailId) },
                new AjaxOptions
                {
                    HttpMethod = "POST",
                    Confirm = "Are you Sure You Want to Delete " + Model.QuoteDetail[i].ProductName,
                }, new { @class = "btn btn-danger glyphicon glyphicon-trash" })
                    </div>
            }
           @Html.EditorFor(model => model.Subtotal, new { htmlAttributes = new { @class = "form-control subTotal", style = "width: 100px; float:right; clear:left; text-align:right" } })

           @Ajax.ActionLink("Add product", "AddProduct", "QuoteViewModel", new { quoteId = Model.QuoteId, quoteDetailId = (Model.QuoteDetail.Count + 1) },
               new AjaxOptions
               {
                   UpdateTargetId = "QuoteDetails",
                   InsertionMode = InsertionMode.InsertAfter
               })
            }
</code>```

Here is the partial view:

```<code>@model CMSUsersAndRoles.Models.QuoteDetail

@{
    ViewBag.Title = "EditQuoteDetail";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
    <div id="row" class="row">
        <table>
            @using (Html.BeginCollectionItem("quoteDetail"))
            {
                <tr>
                    @Html.HiddenFor(model => model.QuoteId, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.EditorFor(model => model.SKU, new { htmlAttributes = new { @readonly = "readonly", @id = "SKU", @class = "form-control", style = "width: 100px" } })
                    @Html.DropDownListFor(model => model.ProductId, new SelectList(ViewBag.ProductData, "ProductId", "Name"), "---Select one---", new { style = "width: 300px !important", htmlAttributes = new { @id = "ProductName", @class = "ProductList" } });

                    .... // more controls for properties of QuoteDetail

                    @Ajax.ActionLink(" ", "DeleteProduct", "QuoteViewModel", new { quoteId = Model.QuoteId, quoteDetailId = (Model.QuoteDetailId) },
                          new AjaxOptions
                          {
                              HttpMethod = "POST",
                              Confirm = "Are you Sure You Want to Delete " + Model.ProductName,
                          }, new { @class = "btn btn-danger glyphicon glyphicon-trash" })
                </tr>
            }
        </table>
    </div>
</code>```

And here is the controller action:

```<code>[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(QuoteViewModel qvm,
    [Bind(Include = "CustomerId,SalesRep,FirstName,LastName,Company,Address1,Address2,City,State,PostalCode,WorkPhone,CellPhone,Email,Discount,PaymentTerms")] Customer customer,
    [Bind(Include = "QuoteId,QuoteDetailId,ProductId,ProductName,Amount,ListPrice,Discount,Price")] List<QuoteDetail> quoteDetails,
    [Bind(Include = "QuoteId,CustomerId,Subtotal,Tax,Total,QuoteDate,GoodUntil,QuoteSent,DateApproved,DateOrdered")] Quote quote)
{
    ....
}
</code>```

Can anyone help with this?  Any help will be much appreciated.

答:
Your using 2 different techniques here to generate your collection which is causing the issue.

In the main view you have a for loop to generate controls for existing items which is generating the zero-based consecutive indexers, which is what the DefaultModelBinder uses by default. Your html will include name attributes that are for example

```<code><input name="QuoteDetail[0].QuoteId"..../>
<input name="QuoteDetail[1].QuoteId"..../>
<input name="QuoteDetail[2].QuoteId"..../>
</code>```

But then you add new items using the BeginCollectionItem helper method which generates the collection indexer as a Guid so that new inputs will be (where xxx is a Guid)

```<code><input name="QuoteDetail[xxxx].QuoteId"..../>
</code>```

and also includes a

```<code><input name="QuoteDetail.Index" value="xxxx" ... />
</code>```

which is used by the DefaultModelBinder to match non zero-based non consecutive indexers. You cannot use both techniques.

To solve this, you can either add an input for the indexer in the for loop

```<code>@for (int i = 0; i < Model.QuoteDetail.Count; i++)
{
    ....
    <input type="hidden" name="QuoteDetail.Index" value="@i" />
}
</code>```

or change the loop to use the partial view containing the BeginCollectionItem method in each iteration

```<code>@foreach(var item in Model.QuoteDetail)
{
    @Html.Partial("xxxx", item) // replace xxxx with the name of your partial
}
</code>```

Body:
I'm new to MVC.  I have a view which displays the products attached to a Quote (the QuoteDetails).  I also have an Ajax.ActionLink)_ for "Add product" which loads a partial view for another product to be entered.  The problem is that when the partial view is loaded, edits to the other products not in the partial view are not saved.  If no partial view is loaded, edits to the listed products are saved just fine.

Here is the relevant code for the main view:

@model CMSUsersAndRoles.Models.QuoteViewModel
....
@Scripts.Render("~/Scripts/jquery.unobtrusive-ajax.min.js")

@using (Html.BeginForm())
{
    ....
    @Html.HiddenFor(model => model.CustomerId)

    @Html.LabelFor(model => model.QuoteId)
    @Html.EditorFor(model => model.QuoteId, new { htmlAttributes = new { @readonly = "readonly", @class = "form-control" } })
    @Html.ValidationMessageFor(model => model.QuoteId)

    .... // more controls for properties of Quote

    @Html.LabelFor(model => model.QuoteDetail)

        @for (int i = 0; i < Model.QuoteDetail.Count; i++)
        {
            @Html.HiddenFor(model => model.QuoteDetail[i].QuoteId, new { htmlAttributes = new { @class = "form-control" } })
            ....
            @Html.EditorFor(model => model.QuoteDetail[i].SKU, new { htmlAttributes = new { @readonly = "readonly", @id = "SKU", @class = "form-control", style = "width: 100px" } })
            @Html.EditorFor(model => model.QuoteDetail[i].Amount, new { htmlAttributes = new { @class = "form-control amount", style = "width: 95px" } })
            @Html.ValidationMessageFor(model => model.QuoteDetail[i].Amount)

            .... // more for controls for properties of QuoteDetail

            @Ajax.ActionLink(" ", "DeleteProduct", "QuoteViewModel", new { quoteId = Model.QuoteDetail[i].QuoteId, quoteDetailId = (Model.QuoteDetail[i].QuoteDetailId) },
                new AjaxOptions
                {
                    HttpMethod = "POST",
                    Confirm = "Are you Sure You Want to Delete " + Model.QuoteDetail[i].ProductName,
                }, new { @class = "btn btn-danger glyphicon glyphicon-trash" })

            }
           @Html.EditorFor(model => model.Subtotal, new { htmlAttributes = new { @class = "form-control subTotal", style = "width: 100px; float:right; clear:left; text-align:right" } })

           @Ajax.ActionLink("Add product", "AddProduct", "QuoteViewModel", new { quoteId = Model.QuoteId, quoteDetailId = (Model.QuoteDetail.Count + 1) },
               new AjaxOptions
               {
                   UpdateTargetId = "QuoteDetails",
                   InsertionMode = InsertionMode.InsertAfter
               })
            }

Here is the partial view:

@model CMSUsersAndRoles.Models.QuoteDetail

@{
    ViewBag.Title = "EditQuoteDetail";
    Layout = null;
}
<!DOCTYPE html>

            @using (Html.BeginCollectionItem("quoteDetail"))
            {

                    @Html.HiddenFor(model => model.QuoteId, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.EditorFor(model => model.SKU, new { htmlAttributes = new { @readonly = "readonly", @id = "SKU", @class = "form-control", style = "width: 100px" } })
                    @Html.DropDownListFor(model => model.ProductId, new SelectList(ViewBag.ProductData, "ProductId", "Name"), "---Select one---", new { style = "width: 300px !important", htmlAttributes = new { @id = "ProductName", @class = "ProductList" } });

                    .... // more controls for properties of QuoteDetail

                    @Ajax.ActionLink(" ", "DeleteProduct", "QuoteViewModel", new { quoteId = Model.QuoteId, quoteDetailId = (Model.QuoteDetailId) },
                          new AjaxOptions
                          {
                              HttpMethod = "POST",
                              Confirm = "Are you Sure You Want to Delete " + Model.ProductName,
                          }, new { @class = "btn btn-danger glyphicon glyphicon-trash" })

            }

And here is the controller action:

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(QuoteViewModel qvm,
    [Bind(Include = "CustomerId,SalesRep,FirstName,LastName,Company,Address1,Address2,City,State,PostalCode,WorkPhone,CellPhone,Email,Discount,PaymentTerms")] Customer customer,
    [Bind(Include = "QuoteId,QuoteDetailId,ProductId,ProductName,Amount,ListPrice,Discount,Price")] List<QuoteDetail> quoteDetails,
    [Bind(Include = "QuoteId,CustomerId,Subtotal,Tax,Total,QuoteDate,GoodUntil,QuoteSent,DateApproved,DateOrdered")] Quote quote)
{
    ....
}

Can anyone help with this?  Any help will be much appreciated.

Body:
Your using 2 different techniques here to generate your collection which is causing the issue.

In the main view you have a for loop to generate controls for existing items which is generating the zero-based consecutive indexers, which is what the DefaultModelBinder uses by default. Your html will include name attributes that are for example

<input name="QuoteDetail[0].QuoteId"..../>
<input name="QuoteDetail[1].QuoteId"..../>
<input name="QuoteDetail[2].QuoteId"..../>

But then you add new items using the BeginCollectionItem helper method which generates the collection indexer as a Guid so that new inputs will be (where xxx is a Guid)

<input name="QuoteDetail[xxxx].QuoteId"..../>

and also includes a

<input name="QuoteDetail.Index" value="xxxx" ... />

which is used by the DefaultModelBinder to match non zero-based non consecutive indexers. You cannot use both techniques.

To solve this, you can either add an input for the indexer in the for loop

@for (int i = 0; i < Model.QuoteDetail.Count; i++)
{
    ....
    <input type="hidden" name="QuoteDetail.Index" value="@i" />
}

or change the loop to use the partial view containing the BeginCollectionItem method in each iteration

@foreach(var item in Model.QuoteDetail)
{
    @Html.Partial("xxxx", item) // replace xxxx with the name of your partial
}


来源: stackexchange

问:
A quickie: python, terminal "print command not found"
Been using terminal to run python scripts written in textwrangler for about 18 months. Decided to look at possibility of moving to an IDE so downloaded a couple of trial versions. Just downloaded BBEedit and suddenly having problems executing script, either from BBedit or Textwrangler. The following code:

```<code>print "Please work"

for i in range(50):
    print i
</code>```

yields the following error message:

```<code>/Users/paulpatterson/Documents/Python/Scripts/t.py: line 1: print: command not found
/Users/paulpatterson/Documents/Python/Scripts/t.py: line 3: syntax error near unexpected token `('
/Users/paulpatterson/Documents/Python/Scripts/t.py: line 3: `for i in range(50):'
</code>```

Some files still work okay, but I'm struggling to figure out why others now aren't -
not even sure if BBedit download has caused the problem.
Can anyone help?

答:
Try putting

```<code>#!/usr/bin/env python
</code>```

at the top of the script. The program is trying to execute it like a shell script instead of running it through python.

ContentLicense: CC BY-SA 2.5

Body:
Been using terminal to run python scripts written in textwrangler for about 18 months. Decided to look at possibility of moving to an IDE so downloaded a couple of trial versions. Just downloaded BBEedit and suddenly having problems executing script, either from BBedit or Textwrangler. The following code:

print "Please work"

for i in range(50):
    print i

yields the following error message:

/Users/paulpatterson/Documents/Python/Scripts/t.py: line 1: print: command not found
/Users/paulpatterson/Documents/Python/Scripts/t.py: line 3: syntax error near unexpected token `('
/Users/paulpatterson/Documents/Python/Scripts/t.py: line 3: `for i in range(50):'

Some files still work okay, but I'm struggling to figure out why others now aren't -
not even sure if BBedit download has caused the problem.
Can anyone help?

Body:
Try putting

#!/usr/bin/env python

at the top of the script. The program is trying to execute it like a shell script instead of running it through python.


问:
Using DTS Variable for file path using XDocument.Load
I am trying to load an XML file in an SSIS Script task.

This works:

```<code>var fullpath = "E:/perforce_ws/EnterpriseTrunk/SSIS/Inbox/RCT_Import_1.xml";
var xml = XDocument.Load(fullpath);
</code>```

But this doesn't:

```<code>var fullpath = Dts.Variables["XMLFullPath"].Value.ToString;
var xml = XDocument.Load(fullpath);
</code>```

The error being returned is

"Cannot assign method group to an implicitly-typed variable".

Where have I gone wrong?

答:
ToString is a method group.

ToString() is a method call.

The assignment code you were looking for is

```<code>var fullpath = Dts.Variables["XMLFullPath"].Value.ToString();
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to load an XML file in an SSIS Script task.

This works:

var fullpath = "E:/perforce_ws/EnterpriseTrunk/SSIS/Inbox/RCT_Import_1.xml";
var xml = XDocument.Load(fullpath);

But this doesn't:

var fullpath = Dts.Variables["XMLFullPath"].Value.ToString;
var xml = XDocument.Load(fullpath);

The error being returned is

"Cannot assign method group to an implicitly-typed variable".

Where have I gone wrong?

Body:
ToString is a method group.

ToString() is a method call.

The assignment code you were looking for is

var fullpath = Dts.Variables["XMLFullPath"].Value.ToString();


问:
Processing won't run on Ubuntu 16.04 raises Exception
I am trying to setup Processing alongside my Arduino IDE on Ubuntu 16.04. Post install, I go in and attempt running an example program and processing dumps this on me. What should I be doing?
For reference, I have JDK-8 installed. </p>

```<code>Exception in thread "Thread-29" java.lang.RuntimeException: Could not open /home/user/Desktop/Processing/processing_3.3/java/bin/java -agentlib:jdwp=transport=dt_socket,address=8633,server=y,suspend=y,quiet=y -Djna.nosys=true -Djava.ext.dirs=/home/user/Desktop/Processing/processing_3.3/java/lib/ext -Djava.library.path=:/home/user/Desktop/Processing/processing_3.3/core/library:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib -cp /tmp/Sequential810704108564722622temp:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/core.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-amd64.jar:/home/userDesktop/Processing/processing_3.3/core/library/gluegen-rt-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-amd64.jar:/home/user/Desktop/Processing/processing_3.3/java/lib/rt.jar:/home/user/Desktop/Processing/processing_3.3/lib/ant-launcher.jar:/home/user/Desktop/Processing/processing_3.3/lib/ant.jar:/home/user/Desktop/Processing/processing_3.3/lib/jna-platform.jar:/home/user/Desktop/Processing/processing_3.3/lib/jna.jar:/home/user/Desktop/Processing/processing_3.3/lib/pde.jar:/home/user/Desktop/Processing/processing_3.3/core/library/core.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/JavaMode.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/antlr.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/classpath-explorer-

    1.0.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/com.ibm.icu.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jdi.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jdimodel.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jdtCompilerAdapter.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jsoup-1.7.1.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.contenttype.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.jobs.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.resources.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.runtime.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.equinox.common.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.equinox.preferences.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.jdt.core.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.osgi.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.text.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.netbeans.swing.outline.jar -ea processing.core.PApplet --editor-location=65,24 --external --display=1 --sketch-path=/home/user/Desktop/Processing/processing_3.3/modes/java/examples/Topics/Animation/Sequential Sequential
        at processing.core.PApplet.exec(PApplet.java:3510)
        at processing.mode.java.runner.Runner$1.run(Runner.java:485)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.io.IOException: Cannot run program "/home/user/Desktop/Processing/processing_3.3/java/bin/java": error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:620)
        at java.lang.Runtime.exec(Runtime.java:485)
        at processing.core.PApplet.exec(PApplet.java:3508)
        ... 2 more
    Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
        at java.lang.ProcessImpl.start(ProcessImpl.java:134)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 5 more
</code>```

答: Found the issue. Installed a 64-bit copy of everything and a 32-bit copy of Processing. Got the 64-bit processing, everything working okay now.</p>

Body:
I am trying to setup Processing alongside my Arduino IDE on Ubuntu 16.04. Post install, I go in and attempt running an example program and processing dumps this on me. What should I be doing?
For reference, I have JDK-8 installed.

Exception in thread "Thread-29" java.lang.RuntimeException: Could not open /home/user/Desktop/Processing/processing_3.3/java/bin/java -agentlib:jdwp=transport=dt_socket,address=8633,server=y,suspend=y,quiet=y -Djna.nosys=true -Djava.ext.dirs=/home/user/Desktop/Processing/processing_3.3/java/lib/ext -Djava.library.path=:/home/user/Desktop/Processing/processing_3.3/core/library:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib -cp /tmp/Sequential810704108564722622temp:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/core.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-amd64.jar:/home/userDesktop/Processing/processing_3.3/core/library/gluegen-rt-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-amd64.jar:/home/user/Desktop/Processing/processing_3.3/java/lib/rt.jar:/home/user/Desktop/Processing/processing_3.3/lib/ant-launcher.jar:/home/user/Desktop/Processing/processing_3.3/lib/ant.jar:/home/user/Desktop/Processing/processing_3.3/lib/jna-platform.jar:/home/user/Desktop/Processing/processing_3.3/lib/jna.jar:/home/user/Desktop/Processing/processing_3.3/lib/pde.jar:/home/user/Desktop/Processing/processing_3.3/core/library/core.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/gluegen-rt.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-armv6hf.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-linux-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-macosx-universal.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-amd64.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all-natives-windows-i586.jar:/home/user/Desktop/Processing/processing_3.3/core/library/jogl-all.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/JavaMode.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/antlr.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/classpath-explorer-

    1.0.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/com.ibm.icu.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jdi.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jdimodel.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jdtCompilerAdapter.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/jsoup-1.7.1.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.contenttype.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.jobs.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.resources.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.core.runtime.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.equinox.common.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.equinox.preferences.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.jdt.core.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.osgi.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.eclipse.text.jar:/home/user/Desktop/Processing/processing_3.3/modes/java/mode/org.netbeans.swing.outline.jar -ea processing.core.PApplet --editor-location=65,24 --external --display=1 --sketch-path=/home/user/Desktop/Processing/processing_3.3/modes/java/examples/Topics/Animation/Sequential Sequential
        at processing.core.PApplet.exec(PApplet.java:3510)
        at processing.mode.java.runner.Runner$1.run(Runner.java:485)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.io.IOException: Cannot run program "/home/user/Desktop/Processing/processing_3.3/java/bin/java": error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:620)
        at java.lang.Runtime.exec(Runtime.java:485)
        at processing.core.PApplet.exec(PApplet.java:3508)
        ... 2 more
    Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
        at java.lang.ProcessImpl.start(ProcessImpl.java:134)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 5 more


问:
Am I right about the meaning of coupling?
I'm gonna try to write some ideas ideas about software coupling and cohesion, but I'm not sure they mean anything practical at all. So if you want to explain your answers with examples please use simple algebraic expressions imagining that algebra is a sequential programming language so we all can understand what you´re talking about...

Read about it in wikipedia

So here is what I want to believe (is this correct?):

```<code>'Implementation of A with Low Cohesion
'(Coincidental cohesion because there is no
' good reason or need to group the functions
' in this way)
a(x) = 2x + 1
b(x) = 3x + 2
r(x) = a(x) + b(x)
</code>```

...

```<code>'Implementation of A with High Cohesion (Almost Atomic)
r(x) = 5x + 3
</code>```

...

```<code>'Implementation of A with Low Cohesion too
a(x) = 2x + 1
r(x) = a(x) + 3x + 2
</code>```

...

```<code>'Implementations of A with Functional Cohesion
a(x, y) = x * y   'Groups multiplication
b(x, y) = x + y   'Groups addition
r(x) = b(a(5,x), 3)
</code>```

答:
Reading a little further (thanks to Cade Perkins), it looks like I was wrong.

The examples were actually about cohesion (according to wikipedia):

```<code>'Implementation of A with Low Cohesion
'(Random cohesion because there is )
' no reason to group the functions
' in this way)
a(x) = 2x + 1
b(x) = 3x + 2
r(x) = a(x) + b(x)
</code>```

...

```<code>'Implementation of A with High Cohesion (Almost Atomic)
r(x) = 5x + 3
</code>```

...

```<code>'Implementation of A with Another Random Cohesion
a(x) = 2x + 1
r(x) = a(x) + 3x + 2
</code>```

...

```<code>'Implementation of A with Functional Cohesion
a(x, y) = x + y       ' Groups Addition
b(x, y) = x * y       ' Groups Multiplications
r(x) = a(b(5, x), 3)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm gonna try to write some ideas ideas about software coupling and cohesion, but I'm not sure they mean anything practical at all. So if you want to explain your answers with examples please use simple algebraic expressions imagining that algebra is a sequential programming language so we all can understand what you´re talking about...

Read about it in wikipedia

So here is what I want to believe (is this correct?):

'Implementation of A with Low Cohesion
'(Coincidental cohesion because there is no
' good reason or need to group the functions
' in this way)
a(x) = 2x + 1
b(x) = 3x + 2
r(x) = a(x) + b(x)

...

'Implementation of A with High Cohesion (Almost Atomic)
r(x) = 5x + 3

...

'Implementation of A with Low Cohesion too
a(x) = 2x + 1
r(x) = a(x) + 3x + 2

...

'Implementations of A with Functional Cohesion
a(x, y) = x * y   'Groups multiplication
b(x, y) = x + y   'Groups addition
r(x) = b(a(5,x), 3)

Body:
Reading a little further (thanks to Cade Perkins), it looks like I was wrong.

The examples were actually about cohesion (according to wikipedia):

'Implementation of A with Low Cohesion
'(Random cohesion because there is )
' no reason to group the functions
' in this way)
a(x) = 2x + 1
b(x) = 3x + 2
r(x) = a(x) + b(x)

...

'Implementation of A with High Cohesion (Almost Atomic)
r(x) = 5x + 3

...

'Implementation of A with Another Random Cohesion
a(x) = 2x + 1
r(x) = a(x) + 3x + 2

...

'Implementation of A with Functional Cohesion
a(x, y) = x + y       ' Groups Addition
b(x, y) = x * y       ' Groups Multiplications
r(x) = a(b(5, x), 3)


问:
PyCharm error: 'No Module' when trying to import own module (python script)
I have written a module (a file my_mod.py file residing in the folder my_module).
Currently, I am working in the file cool_script.py that resides in the folder cur_proj. I have opened the folder in PyCharm using File -- open (and I assume, hence, it is a PyCharm project).

In ProjectView (CMD-7), I can see my project cur_proj (in red) and under "External Libraries" I do see my_module. In cool_script.py, I can write

```<code>from my_module import my_mod as mm
</code>```

and PyCharm even makes suggestion for my_mod. So far so good.

However, when I try to run cool_script.py, PyCharm tells me
"No module named my_module"

This seems strange to me, because

A) in the terminal (OS 10.10.2), in python, I can import the module no problem -- there is a corresponding entry in the PYTHONPATH in .bashrc

B) in PyCharm -- Settings -- Project cur_proj -- Project Interpreter -- CogWheel next to python interpreter -- more -- show paths for selected interpreter icon, the paths from PYTHONPATH do appear (as I think they should)

Hence, why do I get the error when I try to run cool_script.py?  -- What am I missing?

Notes:

I am not declaring a different / special python version at the top of cool_script.py

I made sure that the path to my_module is correct

I put __init__.py files (empty files) both in my_module and in cur_proj

I am not using virtualenv

Addendum 2015-Feb-25

When I go in PyCharm to Run -- Edit Configurations, for my current project, there are two options that are selected with a check mark: "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH". When I have both unchecked, I can load my module.

So it works now -- but why?

Further questions emerged:

What are "content roots" and what are "source roots"? And why does adding something to the PYTHONPATH make it somehow break?

should I uncheck both of those options all the time (so also in the defaults, not only the project specific configurations (left panel of the Run/Debug Configurations dialog)?

答:
The key confusing step that must be done is to recreate the run configuration for the source file that you're trying to execute, so that the IDE picks up the new paths.

The way that actually worked for me was to go to Run/Edit Configurations..., select the configuration for the file that you're trying to run on the left side, uncheck the "Add source roots to PYTHONPATH" box, save, and then go back and check the box and save.  THEN it would work.

Body:
I have written a module (a file my_mod.py file residing in the folder my_module).
Currently, I am working in the file cool_script.py that resides in the folder cur_proj. I have opened the folder in PyCharm using File -- open (and I assume, hence, it is a PyCharm project).

In ProjectView (CMD-7), I can see my project cur_proj (in red) and under "External Libraries" I do see my_module. In cool_script.py, I can write

from my_module import my_mod as mm

and PyCharm even makes suggestion for my_mod. So far so good.

However, when I try to run cool_script.py, PyCharm tells me
"No module named my_module"

This seems strange to me, because

A) in the terminal (OS 10.10.2), in python, I can import the module no problem -- there is a corresponding entry in the PYTHONPATH in .bashrc

B) in PyCharm -- Settings -- Project cur_proj -- Project Interpreter -- CogWheel next to python interpreter -- more -- show paths for selected interpreter icon, the paths from PYTHONPATH do appear (as I think they should)

Hence, why do I get the error when I try to run cool_script.py?  -- What am I missing?

Notes:

I am not declaring a different / special python version at the top of cool_script.py

I made sure that the path to my_module is correct

I put __init__.py files (empty files) both in my_module and in cur_proj

I am not using virtualenv

Addendum 2015-Feb-25

When I go in PyCharm to Run -- Edit Configurations, for my current project, there are two options that are selected with a check mark: "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH". When I have both unchecked, I can load my module.

So it works now -- but why?

Further questions emerged:

What are "content roots" and what are "source roots"? And why does adding something to the PYTHONPATH make it somehow break?

should I uncheck both of those options all the time (so also in the defaults, not only the project specific configurations (left panel of the Run/Debug Configurations dialog)?


问:
Radio Button group in separate place in yii2
So, I want to have two radio button in separate place, I have been trying to search for the solution and everyone suggests to use radiolist which is not possible in my case.

If I put it like this (work_part_time button) : (below)

```<code><div class="row">
    <div class="col-sm-2">
        <?= $form->field($model, 'work_part_time')->radio(['label' => 'yes', 'value' => 1])?>
    </div>-

    <div class="col-sm-3">
        <?= $form->field($model, 'hour_week')->textInput(['type' => 'number', 'placeholder' => 'Hour/Week'])->label(false)?>
    </div>

    <div class="col-sm-3">
        <?= $form->field($model, 'part_time_rate')->textInput(['type' => 'number', 'placeholder' => 'rate/hour(SGD)'])->label(false)?>
    </div>
</div>

<div class="form-group">
    <?= $form->field($model, 'work_part_time')->radio( [0 => 'No'])->label('No')?>
</div>
<hr>
<div class="row">
    <div class="col-sm-2">
        <?= $form->field($model, 'work_part_time')->radio(['label' => 'yes', 'value' => 1])?>
    </div>-

    <div class="col-sm-3">
        <?= $form->field($model, 'hour_week')->textInput(['type' => 'number', 'placeholder' => 'Hour/Week'])->label(false)?>
    </div>

    <div class="col-sm-3">
        <?= $form->field($model, 'part_time_rate')->textInput(['type' => 'number', 'placeholder' => 'rate/hour(SGD)'])->label(false)?>
    </div>
</div>

<div class="form-group">
    <?= $form->field($model, 'work_part_time')->radio( [0 => 'No'])->label('No')?>
</div>
<hr>
</code>```

I only can get 0 for the value.

Anyone has found the solution for this?

答:
If you substitute "uncheck" with "uncheckValue", the voted answer will work, except it will only post the value of the last radio on the list if selected and 0 for the rest. To make it work and post selected values as intended, I added some JS code to it. Hope it will help someone down the road.

```<code><!-- Complete solution for Radio buttons on separate places Yii2 together with its JS function-->
<php use  yii\web\View; ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option 1', 'value' => 1, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){ var radioValue = 1;$(this).val(radioValue); var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option 2', 'value' => 0, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){ var radioValue = 0; $(this).val(radioValue); var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option 3', 'value' => 2, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){ var radioValue = 2; $(this).val(radioValue); var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option4', 'value' => 3, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){var radioValue = 3; $(this).val(radioValue);  var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?php
//JS Function
$RadioONSeparatePlaceJS = <<<JS
function RadioSelected(radioName,radioValue)
{
   $('input[name="' + radioName + '"]').val(radioValue);
}

JS;
$this->registerJs($RadioONSeparatePlaceJS,View::POS_HEAD);
?>
</code>```

Thank you for the great answer Joe Miller.

Body:
So, I want to have two radio button in separate place, I have been trying to search for the solution and everyone suggests to use radiolist which is not possible in my case.

If I put it like this (work_part_time button) : (below)

        <?= $form->field($model, 'work_part_time')->radio(['label' => 'yes', 'value' => 1])?>

-

        <?= $form->field($model, 'hour_week')->textInput(['type' => 'number', 'placeholder' => 'Hour/Week'])->label(false)?>

        <?= $form->field($model, 'part_time_rate')->textInput(['type' => 'number', 'placeholder' => 'rate/hour(SGD)'])->label(false)?>

    <?= $form->field($model, 'work_part_time')->radio( [0 => 'No'])->label('No')?>

        <?= $form->field($model, 'work_part_time')->radio(['label' => 'yes', 'value' => 1])?>

-

        <?= $form->field($model, 'hour_week')->textInput(['type' => 'number', 'placeholder' => 'Hour/Week'])->label(false)?>

        <?= $form->field($model, 'part_time_rate')->textInput(['type' => 'number', 'placeholder' => 'rate/hour(SGD)'])->label(false)?>

    <?= $form->field($model, 'work_part_time')->radio( [0 => 'No'])->label('No')?>

I only can get 0 for the value.

Anyone has found the solution for this?

Body:
If you substitute "uncheck" with "uncheckValue", the voted answer will work, except it will only post the value of the last radio on the list if selected and 0 for the rest. To make it work and post selected values as intended, I added some JS code to it. Hope it will help someone down the road.

<!-- Complete solution for Radio buttons on separate places Yii2 together with its JS function-->
<php use  yii\web\View; ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option 1', 'value' => 1, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){ var radioValue = 1;$(this).val(radioValue); var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option 2', 'value' => 0, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){ var radioValue = 0; $(this).val(radioValue); var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option 3', 'value' => 2, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){ var radioValue = 2; $(this).val(radioValue); var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?= $form->field($model, 'work_part_time')->radio(['label' => 'Option4', 'value' => 3, 'uncheckValue' => null,'onChange'=>' if($(this).prop("checked")){var radioValue = 3; $(this).val(radioValue);  var radioName = "Model[work_part_time]"; RadioSelected(radioName,radioValue);}else{$(this).val("")};']) ?>
<?php
//JS Function
$RadioONSeparatePlaceJS = <<<JS
function RadioSelected(radioName,radioValue)
{
   $('input[name="' + radioName + '"]').val(radioValue);
}

JS;
$this->registerJs($RadioONSeparatePlaceJS,View::POS_HEAD);
?>

Thank you for the great answer Joe Miller.


问:
How to save my listview data and read again while my application pause or resume
This is my code.I am studing a simple budget calculater application.My only purpose is how much I spend seeing in one mount ? But when I closed my application or pressed the back button on my telephone , I lost all my items. How can I fix this problem ?</p>

```<code> public class MainActivity extends ListActivity {
    private static final String[] items={"31.03.2017 Harcama ve Kazanç Tablosu"};
    public static final int MENU_ADD = Menu.FIRST+1;
    String ilk = "31.03.2017 Harcama ve Kazanç Tablosu";
    public static final int MENU_RESET = Menu.FIRST+2;
    public static final int MENU_REMOVE = Menu.FIRST+4 ;
     ArrayList<String> words=null;

    @Override
    public void onCreate(Bundle SavedInstanceState ) {
    super.onCreate(SavedInstanceState );

    initadapter();
    registerForContextMenu(getListView());

    }

    private void initadapter() {
        words=new ArrayList<String>();
        for (String s : items) {
        words.add(s);
        }
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, words));// TODO Auto-generated method stub

    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenu.ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, MENU_ADD, Menu.NONE, "Ekle");
    menu.add(Menu.NONE, MENU_REMOVE, Menu.NONE, "Sil");
    }
    @Override
    public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info= (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
    ArrayAdapter<String> adapter=(ArrayAdapter<String>)getListAdapter();
     {
    }
    switch (item.getItemId()) {
    case MENU_REMOVE:
    adapter.remove(words.get(info.position));
    case MENU_ADD:
    add();
    return(true);
    }
    return(super.onContextItemSelected(item));
    }{
    }
    private void add() {

    final View addView=getLayoutInflater().inflate(R.layout.activity_main, null);
    new AlertDialog.Builder(this)
    .setTitle("Gider veya gelir ekle.")
    .setView(addView)
    .setPositiveButton("Tamam",
    new DialogInterface.OnClickListener() {
    @SuppressWarnings("unchecked")
    public void onClick(DialogInterface dialog,
    int whichButton) {
    ArrayAdapter<String> adapter=(ArrayAdapter<String>)getListAdapter();
    EditText yazı=(EditText)addView.findViewById(R.id.title);
    adapter.add(yazı.getText().toString());
    }
    })
    .setNegativeButton("Geri", null)
    .show();

    }
    }
</code>```

答:
There are lots of ways to save data from your application.
I suggest you take a look at the developer guidelines here first.

Shared Preferences is the most straight-forward approach with their Key-Value sets, especially for simple applications.

You usually can save the data you need in the onPause() method and load it back into the activity next time it is launched.

Body:
This is my code.I am studing a simple budget calculater application.My only purpose is how much I spend seeing in one mount ? But when I closed my application or pressed the back button on my telephone , I lost all my items. How can I fix this problem ?

 public class MainActivity extends ListActivity {
    private static final String[] items={"31.03.2017 Harcama ve Kazanç Tablosu"};
    public static final int MENU_ADD = Menu.FIRST+1;
    String ilk = "31.03.2017 Harcama ve Kazanç Tablosu";
    public static final int MENU_RESET = Menu.FIRST+2;
    public static final int MENU_REMOVE = Menu.FIRST+4 ;
     ArrayList<String> words=null;

    @Override
    public void onCreate(Bundle SavedInstanceState ) {
    super.onCreate(SavedInstanceState );

    initadapter();
    registerForContextMenu(getListView());

    }

    private void initadapter() {
        words=new ArrayList<String>();
        for (String s : items) {
        words.add(s);
        }
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, words));// TODO Auto-generated method stub

    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenu.ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, MENU_ADD, Menu.NONE, "Ekle");
    menu.add(Menu.NONE, MENU_REMOVE, Menu.NONE, "Sil");
    }
    @Override
    public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info= (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
    ArrayAdapter<String> adapter=(ArrayAdapter<String>)getListAdapter();
     {
    }
    switch (item.getItemId()) {
    case MENU_REMOVE:
    adapter.remove(words.get(info.position));
    case MENU_ADD:
    add();
    return(true);
    }
    return(super.onContextItemSelected(item));
    }{
    }
    private void add() {

    final View addView=getLayoutInflater().inflate(R.layout.activity_main, null);
    new AlertDialog.Builder(this)
    .setTitle("Gider veya gelir ekle.")
    .setView(addView)
    .setPositiveButton("Tamam",
    new DialogInterface.OnClickListener() {
    @SuppressWarnings("unchecked")
    public void onClick(DialogInterface dialog,
    int whichButton) {
    ArrayAdapter<String> adapter=(ArrayAdapter<String>)getListAdapter();
    EditText yazı=(EditText)addView.findViewById(R.id.title);
    adapter.add(yazı.getText().toString());
    }
    })
    .setNegativeButton("Geri", null)
    .show();

    }
    }


问:
Converting function signature from compiler language to c++
Hey guys, I need to make a list of some functions that are listed in the linker output. The syntax i get is as follows:

```<code>int foo(int num,double dnum, Temp & temp) (in namespace "funcsns")
</code>```

Turns into:

```<code>.text._ZN7funcsns3fooEidRNS_4TempE
</code>```

(You might know it from the "undefined symbol" and some other linking errors that print functions names)

Now, i can write a script that somehow turns it into something readable but i wonder if there is a smart way of doing it.

Please share your ideas!

thanks.

答:
This is called decoration or name mangling.  Here is some information on how it works for various compilers

http://www.kegel.com/mangle.html

Body:
Hey guys, I need to make a list of some functions that are listed in the linker output. The syntax i get is as follows:

int foo(int num,double dnum, Temp & temp) (in namespace "funcsns")

Turns into:

.text._ZN7funcsns3fooEidRNS_4TempE

(You might know it from the "undefined symbol" and some other linking errors that print functions names)

Now, i can write a script that somehow turns it into something readable but i wonder if there is a smart way of doing it.

Please share your ideas!

thanks.


问:
Remove dead code before linking
In a project that consists of several statically linked object files, I am replacing one of them with a separate implementation. I would like to test my code even before I have implemented every symbol which the replaced object file provided, so I am using -Wl,--unresolved-symbols=ignore-all to have the linker not complain about the missing symbols.

But as I test the code, it simply crashes when trying to use one of the undefined symbols. Therefore, I am looking for a way to tell the linker “please remove all unreferenced code before linking, and then tell me if in the code reachable from the entry point, there still are unreferenced symbols”. Is that possible?

答:
Writing up an answer closely based on the comments as I've found a use for this in my own code base and checked that the method works OK for me.

```<code>int do_things(void);

int application_main(void)
{
  return do_things();
}

int test_main(void)
{
  return 42;
}

int main(void)
{
  return test_main();
}
</code>```

The layout approximately reflects my use case. A given block of IR may have two entry points, one for running unit tests and one for doing whatever the code is used for. The unit tests need a subset of the symbols needed by the entire module. There is an advantage to being able to build the unit test part without building everything else.

Deadstripping is a definite improvement over my previous method of -Wl,--unresolved-symbols=ignore-all

```<code>clang demo.c     # undefined reference to `do_things'
clang -O3 demo.c # undefined reference to `do_things'
clang demo.c -c -emit-llvm -o demo.bc # OK

llvm-nm demo.bc
---------------- T application_main
                 U do_things
---------------- T main
---------------- T test_main
clang demo.bc    # undefined reference to `do_things'

opt -o stripped.bc -internalize -internalize-public-api-list=main -globaldce demo.bc
llvm-nm stripped.bc
---------------- T main
---------------- t test_main
clang stripped.bc # OK
</code>```

The list of public symbols can be derived from ir files (in my case at least) so the opt invocation is actually

```<code> opt -internalize -internalize-public-api-list=`llvm-nm -extern-only -defined-only -just-symbol-name some-file.bc` -globaldce -O2
</code>```

Title: Remove dead code before linking

Body:
Writing up an answer closely based on the comments as I've found a use for this in my own code base and checked that the method works OK for me.

int do_things(void);

int application_main(void)
{
  return do_things();
}

int test_main(void)
{
  return 42;
}

int main(void)
{
  return test_main();
}

The layout approximately reflects my use case. A given block of IR may have two entry points, one for running unit tests and one for doing whatever the code is used for. The unit tests need a subset of the symbols needed by the entire module. There is an advantage to being able to build the unit test part without building everything else.

Deadstripping is a definite improvement over my previous method of -Wl,--unresolved-symbols=ignore-all

clang demo.c     # undefined reference to `do_things'
clang -O3 demo.c # undefined reference to `do_things'
clang demo.c -c -emit-llvm -o demo.bc # OK

llvm-nm demo.bc
---------------- T application_main
                 U do_things
---------------- T main
---------------- T test_main
clang demo.bc    # undefined reference to `do_things'

opt -o stripped.bc -internalize -internalize-public-api-list=main -globaldce demo.bc
llvm-nm stripped.bc
---------------- T main
---------------- t test_main
clang stripped.bc # OK

The list of public symbols can be derived from ir files (in my case at least) so the opt invocation is actually

 opt -internalize -internalize-public-api-list=`llvm-nm -extern-only -defined-only -just-symbol-name some-file.bc` -globaldce -O2


问:
Kendo Grid doesn't show any data despite having data within DataSource
So, I'm trying to make a readyonly grid with kendo that shows data, but whatever I do, the data does not get shown.

The grid looks like this

And here's the code:

```<code>    $("#Materials")
        .kendoGrid({
            dataSource: {
                data: [],
                schema: {
                    model: {
                        id: "ID",
                        fields: {
                            ID: { type: "number", editable: false },
                            Code: { type: "string", editable: false },
                            Name: { type: "string", editable: false },
                            ExtDeviceCode: { type: "string", editable: false , nullable: true },
                            BaseUomLOVString: { type: "string", editable: false }
                        }
                    }
                },
                pageSize: 20
            },
            filterable: {
                extra: true
            },
            pageable: true,
            columns: [
                { field: "Code", title:"Code"},
                { field: "Name", title: "Name"},
                { field: "ExtDeviceCode", title:"External device code"},
                { field: "BaseUomLOVString", title: "UnitsOfMeasure" }
            ],
            editable: false
        });
</code>```

This makes an empty grid with no data, which I later on fill with an Ajax call. As you can see from above picture, the grid contains the data but does not display it. The data inside the dataSource looks like this. or as Json:

```<code>[{
    "ID": 21150,
    "Code": "3",
    "ExtDeviceCode": null,
    "Name": "Avio benzin",
    "BaseUomLOVString": "Kilogram"
}, {
    "ID": 21400,
    "Code": "5003",
    "ExtDeviceCode": null,
    "Name": "Bencin 95",
    "BaseUomLOVString": "Litre"
}]
</code>```

EDIT 1:  I'm filling the data with an Ajax call like this:

```<code>            $.ajax({
                url: '@SimpleUrlHelper.UrlObjectToRoot(Url)/FuelPointMaterialTankMask/LookupMaterials',
                data: {
                    //Send list of IDs
                    'materialIDs': materialList
                },
                type: "POST",
                success: function (response) {

                    var tmp = [];
                    if (typeof response !== "undefined" &&
                    response !== null) {
                        response.forEach(function(item) {
                            tmp.push(item);
                        });
                    }
                    grid = $("#Materials").data("kendoGrid");
                    originalMaterialDataSource = grid.dataSource;
                    originalMaterialDataSource.data(tmp);
                    originalMaterialDataSource._destroyed = [];
                    originalMaterialDataSource.pageSize(pageSize);
                    originalMaterialDataSource.page(1);
                    originalMaterialDataSource._total = tmp.length;
                    grid.pager.refresh();
                }
            });
</code>```

答:
You can set your data in your dataSource after your ajax call.

```<code>var dataArray = [{
    "ID": 21150,
    "Code": "3",
    "ExtDeviceCode": null,
    "Name": "Avio benzin",
    "BaseUomLOVString": "Kilogram"
}, {
    "ID": 21400,
    "Code": "5003",
    "ExtDeviceCode": null,
    "Name": "Bencin 95",
    "BaseUomLOVString": "Litre"
}];
</code>```

Use .data() to set:

```<code>$("#Materials").data('kendoGrid').dataSource.data(dataArray );
</code>```

Body:
So, I'm trying to make a readyonly grid with kendo that shows data, but whatever I do, the data does not get shown.

The grid looks like this

And here's the code:

    $("#Materials")
        .kendoGrid({
            dataSource: {
                data: [],
                schema: {
                    model: {
                        id: "ID",
                        fields: {
                            ID: { type: "number", editable: false },
                            Code: { type: "string", editable: false },
                            Name: { type: "string", editable: false },
                            ExtDeviceCode: { type: "string", editable: false , nullable: true },
                            BaseUomLOVString: { type: "string", editable: false }
                        }
                    }
                },
                pageSize: 20
            },
            filterable: {
                extra: true
            },
            pageable: true,
            columns: [
                { field: "Code", title:"Code"},
                { field: "Name", title: "Name"},
                { field: "ExtDeviceCode", title:"External device code"},
                { field: "BaseUomLOVString", title: "UnitsOfMeasure" }
            ],
            editable: false
        });

This makes an empty grid with no data, which I later on fill with an Ajax call. As you can see from above picture, the grid contains the data but does not display it. The data inside the dataSource looks like this. or as Json:

[{
    "ID": 21150,
    "Code": "3",
    "ExtDeviceCode": null,
    "Name": "Avio benzin",
    "BaseUomLOVString": "Kilogram"
}, {
    "ID": 21400,
    "Code": "5003",
    "ExtDeviceCode": null,
    "Name": "Bencin 95",
    "BaseUomLOVString": "Litre"
}]

EDIT 1:  I'm filling the data with an Ajax call like this:

            $.ajax({
                url: '@SimpleUrlHelper.UrlObjectToRoot(Url)/FuelPointMaterialTankMask/LookupMaterials',
                data: {
                    //Send list of IDs
                    'materialIDs': materialList
                },
                type: "POST",
                success: function (response) {

                    var tmp = [];
                    if (typeof response !== "undefined" &&
                    response !== null) {
                        response.forEach(function(item) {
                            tmp.push(item);
                        });
                    }
                    grid = $("#Materials").data("kendoGrid");
                    originalMaterialDataSource = grid.dataSource;
                    originalMaterialDataSource.data(tmp);
                    originalMaterialDataSource._destroyed = [];
                    originalMaterialDataSource.pageSize(pageSize);
                    originalMaterialDataSource.page(1);
                    originalMaterialDataSource._total = tmp.length;
                    grid.pager.refresh();
                }
            });

Body:
You can set your data in your dataSource after your ajax call.

var dataArray = [{
    "ID": 21150,
    "Code": "3",
    "ExtDeviceCode": null,
    "Name": "Avio benzin",
    "BaseUomLOVString": "Kilogram"
}, {
    "ID": 21400,
    "Code": "5003",
    "ExtDeviceCode": null,
    "Name": "Bencin 95",
    "BaseUomLOVString": "Litre"
}];

Use .data() to set:

$("#Materials").data('kendoGrid').dataSource.data(dataArray );


问:
push key generated in firebase not equal one being retrieved android
I am trying to retrieve the push key that is being generated when i am sign up and creating a new user in my android app. But the key being retrieved is not the same as the one that was created.How is this possible? This is my code.How do i correct it?</p>

```<code> firebaseAuth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {

                        //checking if success
                        if(task.isSuccessful()){

                              id = firebaseAuth.getCurrentUser().getUid();
                             key = databaseReference1.child(sexs).push().getKey();
                            Log.d("User key", key);
                            User user = new User(username, halls, levels, downloadUrl, id, key );

                            databaseReference1.child(sexs).push().setValue(user);
</code>```

答:
You seem to be confusing Firebase Authentication user IDs (often called UID) with Firebase Database push IDs (generate when you call push() in a DatabaseReference. They are very different beasts - pretty much the only things they have in common is that they identify something and thus are made to be unique.

If I understand your code correctly, you want to store the newly created user's information in the Firebase Database. The code for that is:

```<code>databaseReference.child(id).setValue(user);
</code>```

Update:

Every time you call push() it will generate a new location with a new unique ID. Since your code calls push() twice (once where you extract the key and once where you set the value to the database), those will be two separate locations.

To get the key for the location, make sure you call push() only once:

```<code>id = firebaseAuth.getCurrentUser().getUid();
User user = new User(username, halls, levels, downloadUrl, id, key );

DatabaseReference newRef = databaseReference1.child(sexs).push();
key = newRef.getKey();
Log.d("User key", key);
newRef.setValue(user);
</code>```

Body:
I am trying to retrieve the push key that is being generated when i am sign up and creating a new user in my android app. But the key being retrieved is not the same as the one that was created.How is this possible? This is my code.How do i correct it?

 firebaseAuth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {

                        //checking if success
                        if(task.isSuccessful()){

                              id = firebaseAuth.getCurrentUser().getUid();
                             key = databaseReference1.child(sexs).push().getKey();
                            Log.d("User key", key);
                            User user = new User(username, halls, levels, downloadUrl, id, key );

                            databaseReference1.child(sexs).push().setValue(user);

Body:
You seem to be confusing Firebase Authentication user IDs (often called UID) with Firebase Database push IDs (generate when you call push() in a DatabaseReference. They are very different beasts - pretty much the only things they have in common is that they identify something and thus are made to be unique.

If I understand your code correctly, you want to store the newly created user's information in the Firebase Database. The code for that is:

databaseReference.child(id).setValue(user);

Update:

Every time you call push() it will generate a new location with a new unique ID. Since your code calls push() twice (once where you extract the key and once where you set the value to the database), those will be two separate locations.

To get the key for the location, make sure you call push() only once:

id = firebaseAuth.getCurrentUser().getUid();
User user = new User(username, halls, levels, downloadUrl, id, key );

DatabaseReference newRef = databaseReference1.child(sexs).push();
key = newRef.getKey();
Log.d("User key", key);
newRef.setValue(user);


问:
Wagtail - how do I add extra form fields (not from page model) to admin page edit form and get wagtail rendering
This is what I tried. It works but the extra field text1 is rendered as a plain input field with no label and no cool wagtail rendering. How can I add extra fields to the form and get cool wagtail rendering please?

Here is a link to the WagtailAdminPageForm documentation:

```<code>class Review(models.Model):

    page = models.OneToOneField(
        'wagtailcore.Page',
        verbose_name=('page'),
        related_name='review',
        on_delete=models.CASCADE)
    text1 = models.CharField(null=True, blank=True, max_length=50)

class RandomPageForm(WagtailAdminPageForm):
    """ Custom form for RandomPage """

    text1 = forms.CharField() # <-- extra field here!

    def __init__(self, data=None, files=None, parent_page=None, *args, **kwargs):
        super(RandomPageForm, self).__init__(data, files, *args, **kwargs)

        if self.instance.id:
            review, created = Review.objects.get_or_create(page_id=self.instance.id)
            print "set form.text1 to model.text1"
            self.fields['text1'].initial = review.text1

        # !!! Below has no effect
        self.instance.content_panels = Page.content_panels + [
            FieldPanel('body'),
            FieldPanel('text1'),
        ]

    def save(self, commit=True):
        page = super(RandomPageForm, self).save(commit=False)
        review, created = Review.objects.get_or_create(page=page)
        review.text1 = self.data["text1"]
        review.save()
        return page

class RandomPage(Page):

    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full"),
    ]

    base_form_class = RandomPageForm
</code>```

答:
I just realised that snippets might solve my problem. It sounds exactly what I need. So I register my non-page model as a snippet and get wagtaill rendering. I will check this out and confirm.

Documentation on snippets:
http://docs.wagtail.io/en/v1.9/topics/snippets.html

Body:
This is what I tried. It works but the extra field text1 is rendered as a plain input field with no label and no cool wagtail rendering. How can I add extra fields to the form and get cool wagtail rendering please?

Here is a link to the WagtailAdminPageForm documentation:

class Review(models.Model):

    page = models.OneToOneField(
        'wagtailcore.Page',
        verbose_name=('page'),
        related_name='review',
        on_delete=models.CASCADE)
    text1 = models.CharField(null=True, blank=True, max_length=50)

class RandomPageForm(WagtailAdminPageForm):
    """ Custom form for RandomPage """

    text1 = forms.CharField() # <-- extra field here!

    def __init__(self, data=None, files=None, parent_page=None, *args, **kwargs):
        super(RandomPageForm, self).__init__(data, files, *args, **kwargs)

        if self.instance.id:
            review, created = Review.objects.get_or_create(page_id=self.instance.id)
            print "set form.text1 to model.text1"
            self.fields['text1'].initial = review.text1

        # !!! Below has no effect
        self.instance.content_panels = Page.content_panels + [
            FieldPanel('body'),
            FieldPanel('text1'),
        ]

    def save(self, commit=True):
        page = super(RandomPageForm, self).save(commit=False)
        review, created = Review.objects.get_or_create(page=page)
        review.text1 = self.data["text1"]
        review.save()
        return page

class RandomPage(Page):

    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full"),
    ]

    base_form_class = RandomPageForm


问:
How do you version your home? I would like some info about subrepos
I've started to put some files in version control in mercurial. It started with .vim, and then with .bashrc, and now I realized a lot of other files could be versioned as well (such as .zshrc, .task directory created by taskwarrior, etc)

Fact is I would like to know which approachs are available and how people here in SO do it.

Versioning home is not a good idea since I would need to edit my .hgignore, and each time a new folder I don't want versioned is added I would need to edit .hgignore as well.

So I think of 2 approaches:

Create a "dotfiles" repo with everything inside it (vim, bash, screenrc), clone it in home and create symbolic links in home to them;

Create a "dotfiles" repo and a repo for each configuration (vim, bash, screenrc, cvsrc, etc). This "dotfiles" repo will just have the other repositories as submodules, but creation of symbolic links in home is still needed.

Do you think it's overkill to create a repository for each configuration in the second approach? Do you have another suggestions? I would like to use this approach on linux/mac. I use vim on windows as well, that's why I tought of making different repositories with submodules - in windows I would just clone the vim repo: the home repo would have vim as a submodule.

(I'm using a bitbucket private account. Is it possible to have submodules in there? And one more thing: is it possible to have git submodules inside a mercurial repository as submodules as well? How?)

Thanks!

答:
Most folks who do this put something like this in their ~/.hgignore file:

```<code>.*
</code>```

which automatically ignores everything.  Then they just hg add the files they do want tracked -- hg add overrides ignore rules (unlike in CVS/svn).

One thing to beware of is that mercurial doesn't track file permissions (excepting the execute bit) so you have to be careful of things like .ssh/authorized_keys getting permissions other than the 600 it needs.  Tools like etckeeper automate the permissions (and ownership) handling parts of this making hg (or git) suitable for use on not just ~ but also system things like /etc.

Body:
Most folks who do this put something like this in their ~/.hgignore file:

.*

which automatically ignores everything.  Then they just hg add the files they do want tracked -- hg add overrides ignore rules (unlike in CVS/svn).

One thing to beware of is that mercurial doesn't track file permissions (excepting the execute bit) so you have to be careful of things like .ssh/authorized_keys getting permissions other than the 600 it needs.  Tools like etckeeper automate the permissions (and ownership) handling parts of this making hg (or git) suitable for use on not just ~ but also system things like /etc.


问:
Core Data classes not generated for test target
I use Core Data's automatically generated classes. My project has 3 targets in addition to the test target. For each target, the Core Data classes are properly generated which I verified by inspecting the Derived Data folder. However, classes are not generated for the Test Target despite it being ticked in the Core Data model file. This causes an "undeclared identifier" and "Use of undeclared type" errors when I try to reference one of the Core Data classes in the test target. How can I fix this please?</p>

答:
You do not need extra classes generated for each test target - your import process should import everything, and no files should need to be added to other targets.

Declaring @testable import MyProject should take care of everything.

In Objective C

```<code>@import MyProject;
</code>```

Body:
You do not need extra classes generated for each test target - your import process should import everything, and no files should need to be added to other targets.

Declaring @testable import MyProject should take care of everything.

In Objective C

@import MyProject;


问:
Customizing JSQMessage bubble appearance
Is there an easy way to remove these chat bubble 'stalks' from certain messages? (I'd like to remove it from ones that are not next to an avatar image)

答:
Ya just create a variable for tailessBubble there is a tailess bubble image asset included in the library

```<code>let tailessIncomingBubble = JSQMessagesBubbleImageFactory(bubble: UIImage(named: "tailessMessageBubble"), capInsets: UIEdgeInsets.zero).incomingMessagesBubbleImage(with: WeaveColor.Grey.incomingBubble)
</code>```

Then just override the messageBubbleImageDataForItemAt method

```<code>override func collectionView(_ collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAt indexPath: IndexPath!) -> JSQMessageBubbleImageDataSource! {
    let currentMessage = messages[safe: indexPath.item]
    return firstMessageInSet(indexOfMessage: indexPath) ? currentMessage?.senderId() == currentUser.senderID() ? tailessOutgoingBubble : tailessIncomingBubble : currentMessage?.senderId() == currentUser.senderID() ? outgoingBubble : incomingBubble
}
</code>```

That should do it for you let me know if you need more help

Body:
Ya just create a variable for tailessBubble there is a tailess bubble image asset included in the library

let tailessIncomingBubble = JSQMessagesBubbleImageFactory(bubble: UIImage(named: "tailessMessageBubble"), capInsets: UIEdgeInsets.zero).incomingMessagesBubbleImage(with: WeaveColor.Grey.incomingBubble)

Then just override the messageBubbleImageDataForItemAt method

override func collectionView(_ collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAt indexPath: IndexPath!) -> JSQMessageBubbleImageDataSource! {
    let currentMessage = messages[safe: indexPath.item]
    return firstMessageInSet(indexOfMessage: indexPath) ? currentMessage?.senderId() == currentUser.senderID() ? tailessOutgoingBubble : tailessIncomingBubble : currentMessage?.senderId() == currentUser.senderID() ? outgoingBubble : incomingBubble
}

That should do it for you let me know if you need more help


问:
Remove Seaborn barplot legend title
I use seaborn to plot a grouped bar plot as in https://seaborn.pydata.org/examples/factorplot_bars.html

Giving me:
https://seaborn.pydata.org/_images/factorplot_bars.png

there is a title (sex) on the legend which I would like to remove.

How could I achieve that?

答:
This may be a hacky solution but it works: if you tell Seaborn to leave it off at the time of plotting and then add it back it doesn't have the legend title:

```<code>g = sns.factorplot(x='Age Group',y='ED',hue='Became Member',col='Coverage Type',
                   col_wrap=3,data=gdf,kind='bar',ci=None,legend=False,palette='muted')
#                                                         ^^^^^^^^^^^^
plt.suptitle('ED Visit Rate per 1,000 Members per Year',size=16)
plt.legend(loc='best')
plt.subplots_adjust(top=.925)
plt.show()
</code>```

Example result:

Title: Remove Seaborn barplot legend title

Body:
This may be a hacky solution but it works: if you tell Seaborn to leave it off at the time of plotting and then add it back it doesn't have the legend title:

g = sns.factorplot(x='Age Group',y='ED',hue='Became Member',col='Coverage Type',
                   col_wrap=3,data=gdf,kind='bar',ci=None,legend=False,palette='muted')
#                                                         ^^^^^^^^^^^^
plt.suptitle('ED Visit Rate per 1,000 Members per Year',size=16)
plt.legend(loc='best')
plt.subplots_adjust(top=.925)
plt.show()

Example result:


问:
--region versus --regions argument in cloudml-samples/flowers/sample.sh
In Google's sample code found at cloudml-samples/flowers/sample.sh, between lines 66 and 69, is the argument "region":

```<code># Tell CloudML about a new type of model coming.  Think of a "model" here as
# a namespace for deployed Tensorflow graphs.
gcloud ml-engine models create "$MODEL_NAME" \
  --region us-central1
</code>```

Shouldn't "region" be replaced with "regions" to avoid an error?

(I'm not in position to submit a PR about this.)

答: This has been fixed and will be pushed in the next couple of days.</p>

Body:
In Google's sample code found at cloudml-samples/flowers/sample.sh, between lines 66 and 69, is the argument "region":

# Tell CloudML about a new type of model coming.  Think of a "model" here as
# a namespace for deployed Tensorflow graphs.
gcloud ml-engine models create "$MODEL_NAME" \
  --region us-central1

Shouldn't "region" be replaced with "regions" to avoid an error?

(I'm not in position to submit a PR about this.)