问:
UINavigationController Subview not Scrolling
I am having a navigation controller and a view, which i attached to the subview of navigation controller, i used the below code to hide the navigation bar while swiping up

```<code>    [self.navigationController.view addSubview: categoryView];
    self.navigationController.hidesBarsOnSwipe = YES;
</code>```

it is hiding to the top while swiping the tableview up, but i want that subview should move up along with the navigation controller and it should fit at the top, while swiping down navigation bar should come down along with the subview.

I tried this

[self.navigationController.navigationBar addSubview: categoryView];

In this both navigationBar and the subview is hiding to the top. I guess some simple solutions will be there for this, I searched a lot but didn't find a perfect one. I tried some libraries too, those are not fitting for iPhone X and having some issues in iOS 11.

Update:  adding images for the issue before scrolling
and
after scrolling the tableview

答:
Follow this awesome tutorial by Brian Voong on LetsBuildThatApp Youtube channel. He explains the same feature which you are referring to with awful amount of details.

NavBarView Sliding Feature

Hope this helps..

Body:
I am having a navigation controller and a view, which i attached to the subview of navigation controller, i used the below code to hide the navigation bar while swiping up

    [self.navigationController.view addSubview: categoryView];
    self.navigationController.hidesBarsOnSwipe = YES;

it is hiding to the top while swiping the tableview up, but i want that subview should move up along with the navigation controller and it should fit at the top, while swiping down navigation bar should come down along with the subview.

I tried this

[self.navigationController.navigationBar addSubview: categoryView];

In this both navigationBar and the subview is hiding to the top. I guess some simple solutions will be there for this, I searched a lot but didn't find a perfect one. I tried some libraries too, those are not fitting for iPhone X and having some issues in iOS 11.

Update:  adding images for the issue before scrolling
and
after scrolling the tableview


来源: stackexchange

问:
I have written a findClosestPrime() in C++, but Xcode complains that "Control may reach end of non-void function"
I've written a function in C++ to find the closest prime number after the input number. Let's assume the input number is larger than 100, so there is no special check for the cases when the input number is 1 or 2 or etc.

```<code>int getClosestPrime(int inputNum){
    bool isPrime = false;
    inputNum++;
    while (!isPrime){
        for (int i = 2; i <= inputNum/2; i++){
            if (inputNum % i == 0){
                isPrime = false;
                break; //if at any time found it's not a prime, break the for loop
            }
            isPrime = true;
        }
        if (isPrime == false){
            inputNum++;
        } else {
            return inputNum;
        }
    }
}
</code>```

I think the logic should be good enough as I tested here on ideone: https://ideone.com/hcUpvK it's giving the right results.

However, when I use Xcode to run the code, it always complains that "Control may reach end of non-void function".

Could anybody explain? Thanks!

答:
There is a set of assignments to your variables that makes the loop finish without a return; inside the loop, the for loop may complete (i.e. inputNum / 2 is < 2), then isPrime is false, then somehow magically becomes true by the time the while loop resumes.

We know as humans that, in reality, this will never happen. You'll always end up returning inputNum unless isPrime is false, in which case you reenter the loop. However, your compiler isn't that smart - it can't work out that invariant, as it requires more complex logic than it's capable of reasoning with. So, it warns about the hypothetical case.

Most of the time, it's easier just to throw a return 0 at the end to shut it up, with a comment noting why it can never actually happen.

ContentLicense: CC BY-SA 3.0

Body:
I've written a function in C++ to find the closest prime number after the input number. Let's assume the input number is larger than 100, so there is no special check for the cases when the input number is 1 or 2 or etc.

int getClosestPrime(int inputNum){
    bool isPrime = false;
    inputNum++;
    while (!isPrime){
        for (int i = 2; i <= inputNum/2; i++){
            if (inputNum % i == 0){
                isPrime = false;
                break; //if at any time found it's not a prime, break the for loop
            }
            isPrime = true;
        }
        if (isPrime == false){
            inputNum++;
        } else {
            return inputNum;
        }
    }
}

I think the logic should be good enough as I tested here on ideone: https://ideone.com/hcUpvK it's giving the right results.

However, when I use Xcode to run the code, it always complains that "Control may reach end of non-void function".

Could anybody explain? Thanks!


问:
ORA-01843: not a valid month error in oracle while updating
I want to update my date column with the format as dd-mm-yy. And in my database the column is of date datatype. So while Updating I am sending data as

05-12-2017 but getting error as

ORA-01843: not a valid month

in my stored procedure I am sending it as

HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'dd-m-yy'),

My full procedure:

```<code>PROCEDURE UPD_WF_BY_FIBER_ENG
(
  PJOB_PROGRESS_ID IN TBL_FIBER_INV_JOB_PROGRESS.JOB_PROGRESS_ID%TYPE,
  PSTATUS_ID IN TBL_FIBER_INV_JOB_PROGRESS.STATUS_ID%TYPE,
  --PLIT_OFFERED_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_OFFERED_LENGTH%TYPE,
  PHOTO_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACTUAL_LENGTH%TYPE,
  PLIT_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACTUAL_LENGTH%TYPE,

  PHOTO_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACCEPTENCE_DATE%TYPE,
  PLIT_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACCEPTENCE_DATE%TYPE,

  PAPPROVED_BY IN TBL_FIBER_INV_JOB_PROGRESS.APPROVED_BY%TYPE,
  PREJECTED_BY IN TBL_FIBER_INV_JOB_PROGRESS.REJECTED_BY%TYPE,

  PAPPROV_REJECT_REMARK IN TBL_FIBER_INV_JOB_PROGRESS.APPROV_REJECT_REMARK%TYPE,

  PMODIFIED_BY IN TBL_FIBER_INV_JOB_PROGRESS.MODIFIED_BY%TYPE,
  PUMS_GROUP_ASS_BY_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_ID%TYPE,
  PUMS_GROUP_ASS_BY_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_NAME%TYPE,
  PUMS_GROUP_ASS_TO_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_ID%TYPE,
  PUMS_GROUP_ASS_TO_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_NAME%TYPE,
  PISABDMISSING IN TBL_FIBER_INV_JOB_PROGRESS.ISABDMISSING%TYPE,
  --PSPVENDORXML IN XMLTYPE,
  POUTMSG OUT NVARCHAR2
)
AS
VCNTSPVENCNT NUMBER :=0;
BEGIN

  UPDATE TBL_FIBER_INV_JOB_PROGRESS
    SET STATUS_ID = PSTATUS_ID,
       -- LIT_OFFERED_LENGTH = PLIT_OFFERED_LENGTH,
        HOTO_ACTUAL_LENGTH = PHOTO_ACTUAL_LENGTH,
        LIT_ACTUAL_LENGTH = PLIT_ACTUAL_LENGTH,
        HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'DD-MM-YY'),
        LIT_ACCEPTENCE_DATE = TO_DATE(PLIT_ACCEPTENCE_DATE,  'DD-MM-YY'),
        APPROVED_BY = PAPPROVED_BY,
        APPROVED_DATE = DECODE(PAPPROVED_BY,NULL,NULL,SYSDATE),
        REJECTED_BY = PREJECTED_BY,
        REJECTED_DATE = DECODE(PREJECTED_BY,NULL,NULL,SYSDATE),
        APPROV_REJECT_REMARK = PAPPROV_REJECT_REMARK,
        MODIFIED_BY = PMODIFIED_BY,
        MODIFIED_DATE = SYSDATE,
        UMS_GROUP_ASS_BY_ID = PUMS_GROUP_ASS_BY_ID,
        UMS_GROUP_ASS_BY_NAME = PUMS_GROUP_ASS_BY_NAME,
        UMS_GROUP_ASS_TO_ID = PUMS_GROUP_ASS_TO_ID,
        UMS_GROUP_ASS_TO_NAME = PUMS_GROUP_ASS_TO_NAME,
        ISABDMISSING = PISABDMISSING
    WHERE JOB_PROGRESS_ID   = PJOB_PROGRESS_ID;
</code>```

update

```<code>try
        {
            DBObject ObjDBObject = new DBObject(strConnectionString);
            string strProcedureName = strPackageName + ".UPD_WF_BY_FIBER_ENG";

            List<OracleParameter> lstParameters = new List<OracleParameter>();

            OracleParameter ObjOracleParameter = new OracleParameter("PJOB_PROGRESS_ID", FiberDataInsertion.PROG_ID);
            OracleParameter ObjOracleParameter1 = new OracleParameter("PSTATUS_ID", 1);
            OracleParameter ObjOracleParameter2 = new OracleParameter("PHOTO_ACTUAL_LENGTH", FiberDataInsertion.HOTO_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter3 = new OracleParameter("PLIT_ACTUAL_LENGTH", FiberDataInsertion.LIT_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter4 = new OracleParameter("PHOTO_ACCEPTENCE_DATE", FiberDataInsertion.HOTO_ACCP_DATE);
            OracleParameter ObjOracleParameter5 = new OracleParameter("PLIT_ACCEPTENCE_DATE", FiberDataInsertion.LIT_ACCP_DATE);
            OracleParameter ObjOracleParameter6 = new OracleParameter("PAPPROVED_BY", "NADEEM5.KHAN");
            OracleParameter ObjOracleParameter7 = new OracleParameter("PREJECTED_BY", "DB");
            OracleParameter ObjOracleParameter8 = new OracleParameter("PAPPROV_REJECT_REMARK", "this is test");
            OracleParameter ObjOracleParameter9 = new OracleParameter("PMODIFIED_BY", FiberDataInsertion.MODIFIED_BY);
            OracleParameter ObjOracleParameter10 = new OracleParameter("PUMS_GROUP_ASS_BY_ID", FiberDataInsertion.UMS_GROUP_ASS_BY_ID);
            OracleParameter ObjOracleParameter11 = new OracleParameter("PUMS_GROUP_ASS_BY_NAME", FiberDataInsertion.UMS_GROUP_ASS_BY_NAME);
            OracleParameter ObjOracleParameter12 = new OracleParameter("PUMS_GROUP_ASS_TO_ID", FiberDataInsertion.UMS_GROUP_ASS_TO_ID);
            OracleParameter ObjOracleParameter13 = new OracleParameter("PUMS_GROUP_ASS_TO_NAME", FiberDataInsertion.UMS_GROUP_ASS_TO_NAME);
            OracleParameter ObjOracleParameter14 = new OracleParameter("PISABDMISSING", FiberDataInsertion.MISS_ASBUILT);

            OracleParameter ObjOracleParameter15 = new OracleParameter
            {
                ParameterName = "POUTMSG",
                Size = 500,
                OracleDbType = OracleDbType.NVarchar2,
                Direction = ParameterDirection.Output
            };

            lstParameters.Add(ObjOracleParameter);
            lstParameters.Add(ObjOracleParameter1);
            lstParameters.Add(ObjOracleParameter2);
            lstParameters.Add(ObjOracleParameter3);
            lstParameters.Add(ObjOracleParameter4);
            lstParameters.Add(ObjOracleParameter5);
            lstParameters.Add(ObjOracleParameter6);
            lstParameters.Add(ObjOracleParameter7);
            lstParameters.Add(ObjOracleParameter8);
            lstParameters.Add(ObjOracleParameter9);
            lstParameters.Add(ObjOracleParameter10);
            lstParameters.Add(ObjOracleParameter11);
            lstParameters.Add(ObjOracleParameter12);
            lstParameters.Add(ObjOracleParameter13);
            lstParameters.Add(ObjOracleParameter14);
            lstParameters.Add(ObjOracleParameter15);

            strMessage = ObjDBObject.ExecuteNonQuery(strProcedureName, lstParameters);

        }
        catch (Exception)
        {
            throw;
        }
        return strMessage;
</code>```

Also the error details

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
   at FiberInventoryPortal.Models.DAL.DBObject.ExecuteNonQuery(String strProcedureName, List1 lstParameters) in d:\Nadeem\FiberInventory_214\FiberInventoryPortal\FiberInventoryPortal\Models\DAL\DBObject.cs:line 114`

答:
You can try using

```<code>HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'dd-mm-yy'),
</code>```

see the document for possible combinations

Body:
I want to update my date column with the format as dd-mm-yy. And in my database the column is of date datatype. So while Updating I am sending data as

05-12-2017 but getting error as

ORA-01843: not a valid month

in my stored procedure I am sending it as

HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'dd-m-yy'),

My full procedure:

PROCEDURE UPD_WF_BY_FIBER_ENG
(
  PJOB_PROGRESS_ID IN TBL_FIBER_INV_JOB_PROGRESS.JOB_PROGRESS_ID%TYPE,
  PSTATUS_ID IN TBL_FIBER_INV_JOB_PROGRESS.STATUS_ID%TYPE,
  --PLIT_OFFERED_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_OFFERED_LENGTH%TYPE,
  PHOTO_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACTUAL_LENGTH%TYPE,
  PLIT_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACTUAL_LENGTH%TYPE,

  PHOTO_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACCEPTENCE_DATE%TYPE,
  PLIT_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACCEPTENCE_DATE%TYPE,

  PAPPROVED_BY IN TBL_FIBER_INV_JOB_PROGRESS.APPROVED_BY%TYPE,
  PREJECTED_BY IN TBL_FIBER_INV_JOB_PROGRESS.REJECTED_BY%TYPE,

  PAPPROV_REJECT_REMARK IN TBL_FIBER_INV_JOB_PROGRESS.APPROV_REJECT_REMARK%TYPE,

  PMODIFIED_BY IN TBL_FIBER_INV_JOB_PROGRESS.MODIFIED_BY%TYPE,
  PUMS_GROUP_ASS_BY_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_ID%TYPE,
  PUMS_GROUP_ASS_BY_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_NAME%TYPE,
  PUMS_GROUP_ASS_TO_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_ID%TYPE,
  PUMS_GROUP_ASS_TO_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_NAME%TYPE,
  PISABDMISSING IN TBL_FIBER_INV_JOB_PROGRESS.ISABDMISSING%TYPE,
  --PSPVENDORXML IN XMLTYPE,
  POUTMSG OUT NVARCHAR2
)
AS
VCNTSPVENCNT NUMBER :=0;
BEGIN

  UPDATE TBL_FIBER_INV_JOB_PROGRESS
    SET STATUS_ID = PSTATUS_ID,
       -- LIT_OFFERED_LENGTH = PLIT_OFFERED_LENGTH,
        HOTO_ACTUAL_LENGTH = PHOTO_ACTUAL_LENGTH,
        LIT_ACTUAL_LENGTH = PLIT_ACTUAL_LENGTH,
        HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'DD-MM-YY'),
        LIT_ACCEPTENCE_DATE = TO_DATE(PLIT_ACCEPTENCE_DATE,  'DD-MM-YY'),
        APPROVED_BY = PAPPROVED_BY,
        APPROVED_DATE = DECODE(PAPPROVED_BY,NULL,NULL,SYSDATE),
        REJECTED_BY = PREJECTED_BY,
        REJECTED_DATE = DECODE(PREJECTED_BY,NULL,NULL,SYSDATE),
        APPROV_REJECT_REMARK = PAPPROV_REJECT_REMARK,
        MODIFIED_BY = PMODIFIED_BY,
        MODIFIED_DATE = SYSDATE,
        UMS_GROUP_ASS_BY_ID = PUMS_GROUP_ASS_BY_ID,
        UMS_GROUP_ASS_BY_NAME = PUMS_GROUP_ASS_BY_NAME,
        UMS_GROUP_ASS_TO_ID = PUMS_GROUP_ASS_TO_ID,
        UMS_GROUP_ASS_TO_NAME = PUMS_GROUP_ASS_TO_NAME,
        ISABDMISSING = PISABDMISSING
    WHERE JOB_PROGRESS_ID   = PJOB_PROGRESS_ID;

update

try
        {
            DBObject ObjDBObject = new DBObject(strConnectionString);
            string strProcedureName = strPackageName + ".UPD_WF_BY_FIBER_ENG";

            List<OracleParameter> lstParameters = new List<OracleParameter>();

            OracleParameter ObjOracleParameter = new OracleParameter("PJOB_PROGRESS_ID", FiberDataInsertion.PROG_ID);
            OracleParameter ObjOracleParameter1 = new OracleParameter("PSTATUS_ID", 1);
            OracleParameter ObjOracleParameter2 = new OracleParameter("PHOTO_ACTUAL_LENGTH", FiberDataInsertion.HOTO_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter3 = new OracleParameter("PLIT_ACTUAL_LENGTH", FiberDataInsertion.LIT_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter4 = new OracleParameter("PHOTO_ACCEPTENCE_DATE", FiberDataInsertion.HOTO_ACCP_DATE);
            OracleParameter ObjOracleParameter5 = new OracleParameter("PLIT_ACCEPTENCE_DATE", FiberDataInsertion.LIT_ACCP_DATE);
            OracleParameter ObjOracleParameter6 = new OracleParameter("PAPPROVED_BY", "NADEEM5.KHAN");
            OracleParameter ObjOracleParameter7 = new OracleParameter("PREJECTED_BY", "DB");
            OracleParameter ObjOracleParameter8 = new OracleParameter("PAPPROV_REJECT_REMARK", "this is test");
            OracleParameter ObjOracleParameter9 = new OracleParameter("PMODIFIED_BY", FiberDataInsertion.MODIFIED_BY);
            OracleParameter ObjOracleParameter10 = new OracleParameter("PUMS_GROUP_ASS_BY_ID", FiberDataInsertion.UMS_GROUP_ASS_BY_ID);
            OracleParameter ObjOracleParameter11 = new OracleParameter("PUMS_GROUP_ASS_BY_NAME", FiberDataInsertion.UMS_GROUP_ASS_BY_NAME);
            OracleParameter ObjOracleParameter12 = new OracleParameter("PUMS_GROUP_ASS_TO_ID", FiberDataInsertion.UMS_GROUP_ASS_TO_ID);
            OracleParameter ObjOracleParameter13 = new OracleParameter("PUMS_GROUP_ASS_TO_NAME", FiberDataInsertion.UMS_GROUP_ASS_TO_NAME);
            OracleParameter ObjOracleParameter14 = new OracleParameter("PISABDMISSING", FiberDataInsertion.MISS_ASBUILT);

            OracleParameter ObjOracleParameter15 = new OracleParameter
            {
                ParameterName = "POUTMSG",
                Size = 500,
                OracleDbType = OracleDbType.NVarchar2,
                Direction = ParameterDirection.Output
            };

            lstParameters.Add(ObjOracleParameter);
            lstParameters.Add(ObjOracleParameter1);
            lstParameters.Add(ObjOracleParameter2);
            lstParameters.Add(ObjOracleParameter3);
            lstParameters.Add(ObjOracleParameter4);
            lstParameters.Add(ObjOracleParameter5);
            lstParameters.Add(ObjOracleParameter6);
            lstParameters.Add(ObjOracleParameter7);
            lstParameters.Add(ObjOracleParameter8);
            lstParameters.Add(ObjOracleParameter9);
            lstParameters.Add(ObjOracleParameter10);
            lstParameters.Add(ObjOracleParameter11);
            lstParameters.Add(ObjOracleParameter12);
            lstParameters.Add(ObjOracleParameter13);
            lstParameters.Add(ObjOracleParameter14);
            lstParameters.Add(ObjOracleParameter15);

            strMessage = ObjDBObject.ExecuteNonQuery(strProcedureName, lstParameters);

        }
        catch (Exception)
        {
            throw;
        }
        return strMessage;

Also the error details

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
   at FiberInventoryPortal.Models.DAL.DBObject.ExecuteNonQuery(String strProcedureName, List1 lstParameters) in d:\Nadeem\FiberInventory_214\FiberInventoryPortal\FiberInventoryPortal\Models\DAL\DBObject.cs:line 114`

Body:
You can try using

HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'dd-mm-yy'),

see the document for possible combinations


问:
WPF Databinding combobox in a datagrid
I'm pretty new to WPF and MVVM, so I might be missing some basic understanding.

I am trying to build a list of feed that can be ordered. Every order demands the name, an amount and a unit.

The units should be placed in a combobox, and that's the problem. Depending on the method, the combobox doesn't appear, or is just plain empty.

The following is the XAML.

```<code><UserControl x:Class="TestProject.View.FruitFoodList"
         DataContext="{Binding Test, Source={StaticResource Locator}}">
<Grid>
    <DataGrid ItemsSource="{Binding DummyFruitList}" IsReadOnly="True" Name="dgFeedList" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Feed" Binding="{Binding Name}" Width="*"/>
            <DataGridTemplateColumn Header="Amount">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <!-- Code for amount here -->
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridComboBoxColumn Header="Unit">
                <!--Combobox for units here-->
            </DataGridComboBoxColumn>
        </DataGrid.Columns>
    </DataGrid>
</Grid>
</code>```

Here's the viewmodel:

```<code>public class DummyViewModel : ViewModelBase
{
    private List<DummyProduct> _dummyFruit = new List<DummyProduct>();

    public List<DummyProduct> DummyFruitList
    {
        get { return _dummyFruit; }
        set { _dummyFruit = value; }
    }

    public List<Unit> DummyUnitList = new List<Unit> {
        new Unit { Name = "kg"},
        new Unit { Name = "piece(s)" },
        new Unit { Name = "box(es)" }
    };

    public DummyViewModel()
    {
        string[] lines = File.ReadAllLines("../../DummyFruit.txt", Encoding.UTF7);
        foreach (string product in lines)
        {
            DummyProduct dummyProduct = new DummyProduct(product);
            dummyProduct.Units = DummyUnitList;
            DummyFruitList.Add(dummyProduct);
        }
    }
}
</code>```

And DummyProduct:

```<code>public class DummyProduct
{
    public DummyProduct(string product)
    {
        Name = product;
    }

    public string Name { get; set; }
    public List<Unit> Units;
}
</code>```

The units might not be the same for every product.
I have, without luck, tried the following solutions:
Binding WPF ComboBox to a Custom List
Binding ItemsSource of a ComboBoxColumn in WPF DataGrid

The above solutions didn't show a combobox at all for me.
But again, I might be doing it wrong.

Making a stackpanel with a combobox in a datagridtemplate has so far been the only solution that got a combobox to appear, but the bindings makes no sense here.

答:
ItemsSource of ComboBox is missing and please use ObservableCollection instead of List. That should work; </p>

```<code>   <DataGridComboBoxColumn Header="Unit" >
                <DataGridComboBoxColumn.ElementStyle>
                    <Style TargetType="ComboBox">
                        <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.DummyUnitList}"/>
                    </Style>
                </DataGridComboBoxColumn.ElementStyle>
            </DataGridComboBoxColumn>
</code>```

Title: WPF Databinding combobox in a datagrid

Body:
I'm pretty new to WPF and MVVM, so I might be missing some basic understanding.

I am trying to build a list of feed that can be ordered. Every order demands the name, an amount and a unit.

The units should be placed in a combobox, and that's the problem. Depending on the method, the combobox doesn't appear, or is just plain empty.

The following is the XAML.

<UserControl x:Class="TestProject.View.FruitFoodList"
         DataContext="{Binding Test, Source={StaticResource Locator}}">
<Grid>
    <DataGrid ItemsSource="{Binding DummyFruitList}" IsReadOnly="True" Name="dgFeedList" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Feed" Binding="{Binding Name}" Width="*"/>
            <DataGridTemplateColumn Header="Amount">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>

                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridComboBoxColumn Header="Unit">

            </DataGridComboBoxColumn>
        </DataGrid.Columns>
    </DataGrid>
</Grid>

Here's the viewmodel:

public class DummyViewModel : ViewModelBase
{
    private List<DummyProduct> _dummyFruit = new List<DummyProduct>();

    public List<DummyProduct> DummyFruitList
    {
        get { return _dummyFruit; }
        set { _dummyFruit = value; }
    }

    public List<Unit> DummyUnitList = new List<Unit> {
        new Unit { Name = "kg"},
        new Unit { Name = "piece(s)" },
        new Unit { Name = "box(es)" }
    };

    public DummyViewModel()
    {
        string[] lines = File.ReadAllLines("../../DummyFruit.txt", Encoding.UTF7);
        foreach (string product in lines)
        {
            DummyProduct dummyProduct = new DummyProduct(product);
            dummyProduct.Units = DummyUnitList;
            DummyFruitList.Add(dummyProduct);
        }
    }
}

And DummyProduct:

public class DummyProduct
{
    public DummyProduct(string product)
    {
        Name = product;
    }

    public string Name { get; set; }
    public List<Unit> Units;
}

The units might not be the same for every product.
I have, without luck, tried the following solutions:
Binding WPF ComboBox to a Custom List
Binding ItemsSource of a ComboBoxColumn in WPF DataGrid

The above solutions didn't show a combobox at all for me.
But again, I might be doing it wrong.

Making a stackpanel with a combobox in a datagridtemplate has so far been the only solution that got a combobox to appear, but the bindings makes no sense here.

Body:
ItemsSource of ComboBox is missing and please use ObservableCollection instead of List. That should work;

   <DataGridComboBoxColumn Header="Unit" >
                <DataGridComboBoxColumn.ElementStyle>
                    <Style TargetType="ComboBox">
                        <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.DummyUnitList}"/>
                    </Style>
                </DataGridComboBoxColumn.ElementStyle>
            </DataGridComboBoxColumn>


问:
how to set font-awesome check icon when click then check
i want to set font-awesome check icon that when ic click on it then its check when i click again its uncheck how this is possible .... i not use checkbox so plz tell me in this font-awesome check ....if its possible with jquery then tell me plzz how its done..
my code ....

<!DOCTYPE html>

 <title> </title>
 <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

    first

    second

    third

```

答:
If you just want to let the checkboxes toggle:

<!DOCTYPE html>

  <title> </title>
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

       first

       second

       third

```

The thing is to reasign the click function after the action. In this case if simply reasign that for every checkbox, but that could also be done in a more elegant way.

Body:
If you just want to let the checkboxes toggle:

<!DOCTYPE html>
<html>

<head>
  <title> </title>
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
</head>

<body>
  <ul>
    <li>
      <label> first
      <i class="fa fa-check-square" aria-hidden="true"></i>
    </label>
    </li>
    <li>
      <label> second
      <i class="fa fa-check-square" aria-hidden="true"></i>
    </label>
    </li>
    <li>
      <label> third
      <i class="fa fa-check-square" aria-hidden="true"></i>
    </label>
    </li>
  </ul>
</body>
<script type="text/javascript">
  function asign_click_functions() {
    $(".fa-check-square").click(function() {
      $(this).removeClass("fa-check-square").addClass("fa-check-square-o");
      asign_click_functions();
    });
    $(".fa-check-square-o").click(function() {
      $(this).removeClass("fa-check-square-o").addClass("fa-check-square");
      asign_click_functions();
    });
  };
  asign_click_functions();
</script>

</html>

The thing is to reasign the click function after the action. In this case if simply reasign that for every checkbox, but that could also be done in a more elegant way.


答:
Considering the format you posted, 'dd-m-yy', it seems that the month part is incorrect. It should be MM instead of M.

Ref.:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm

Title: ORA-01843: not a valid month error in oracle while updating


问:
Asp.Net Core 2 (full framework) deployment to IIS creates an unwanted folder on the disk root
I have deployed a Asp.Net Core 2 app to IIS. The app is running fine but it keeps creating the following directory structure in the disk root:
D:\MYAPPNAME\MYAPPNAME\1.0.0

Even if i manually delete the folder, it gets created again when the app runs. What may cause this behaviour?

EDIT
After further investigation, i reproduced the issue using the VS 2017 template for asp-net core2 mvc application.

After adding Microsoft.Extensions.Logging.TraceSource nuget package and configuring  the logs in app.config the unwated folder gets created...

This is the relevant part of the App.config

```<code><system.diagnostics>
    <sources>
      <source name="TestApp" switchValue="All">
        <listeners>
          <clear />
          <add name="RotatingFileLog" />
        </listeners>
      </source>
      <source name="Microsoft" switchValue="All">
        <listeners>
          <clear />
          <add name="RotatingFileLog" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="RotatingFileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" logFileCreationSchedule="Daily" traceOutputOptions="DateTime" BaseFileName="test" location="Custom" CustomLocation="E:\logs\test\" Delimiter="|" AutoFlush="True" Append="True"></add>
    </sharedListeners>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <clear />
        <add name="RotatingFileLog" />
      </listeners>
    </trace>
  </system.diagnostics>
</code>```

答: It has turned out that Microsoft.VisualBasic.Logging.FileLogTraceListener was creating the folder. I switched to another listener, in this case Essential.Diagnostics.RollingFileTraceListener</p>

Body:
I have deployed a Asp.Net Core 2 app to IIS. The app is running fine but it keeps creating the following directory structure in the disk root:
D:\MYAPPNAME\MYAPPNAME\1.0.0

Even if i manually delete the folder, it gets created again when the app runs. What may cause this behaviour?

EDIT
After further investigation, i reproduced the issue using the VS 2017 template for asp-net core2 mvc application.

After adding Microsoft.Extensions.Logging.TraceSource nuget package and configuring  the logs in app.config the unwated folder gets created...

This is the relevant part of the App.config

<system.diagnostics>
    <sources>
      <source name="TestApp" switchValue="All">
        <listeners>
          <clear />
          <add name="RotatingFileLog" />
        </listeners>
      </source>
      <source name="Microsoft" switchValue="All">
        <listeners>
          <clear />
          <add name="RotatingFileLog" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="RotatingFileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" logFileCreationSchedule="Daily" traceOutputOptions="DateTime" BaseFileName="test" location="Custom" CustomLocation="E:\logs\test\" Delimiter="|" AutoFlush="True" Append="True"></add>
    </sharedListeners>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <clear />
        <add name="RotatingFileLog" />
      </listeners>
    </trace>
  </system.diagnostics>


答:
Note that this is a warning, not an error.  The problem is that XCode cannot see that you will only ever reach the end of the loop with isPrime set false - and therefor thinks you can break out of the loop ... and reach the end of the function.

Given that isPrime doesn't actually control the loop, why not get rid of it?  Also, I suggest only considering odd numbers and only testing up to the square root of the potential prime.

```<code>int getClosestPrime(int inputNum){

    // The first prime number is 2.  Any smaller inputs should return this.
    if (inputNum <= 2)
         return 2;

    inputNum |= 1; // Force input to be odd.

    while (true){
        const int limit = sqrt(inputNum);  // Only need to look for prime factors
                                           // up to the square root.
        bool isPrime = true;
        for (int i = 3; i <= limit; i+=2){ // Only look for *odd* prime factors.
            if (inputNum % i == 0){
                isPrime = false;
                break; //if at any time found it's not a prime, break the for loop
            }
        }
        if (isPrime){
            return inputNum;
        }
        inputNum += 2;
    }
}
</code>```

For values of inputNum > 100, I would expect this to be about 10 times faster (and the speed-up improves as the value gets higher).  Note that there are some staggeringly fast ways of testing for whether a number is prime or not.  Miller-Rabin with a rather small list of numbers can deterministically check up to 2^64; using a sieve of Erothosenes to find all primes upto sqrt(2*original-input), and then only testing with those primes could be simpler to understand.

Title: I have written a findClosestPrime() in C++, but Xcode complains that "Control may reach end of non-void function"

Body:
Note that this is a warning, not an error.  The problem is that XCode cannot see that you will only ever reach the end of the loop with isPrime set false - and therefor thinks you can break out of the loop ... and reach the end of the function.

Given that isPrime doesn't actually control the loop, why not get rid of it?  Also, I suggest only considering odd numbers and only testing up to the square root of the potential prime.

int getClosestPrime(int inputNum){

    // The first prime number is 2.  Any smaller inputs should return this.
    if (inputNum <= 2)
         return 2;

    inputNum |= 1; // Force input to be odd.

    while (true){
        const int limit = sqrt(inputNum);  // Only need to look for prime factors
                                           // up to the square root.
        bool isPrime = true;
        for (int i = 3; i <= limit; i+=2){ // Only look for *odd* prime factors.
            if (inputNum % i == 0){
                isPrime = false;
                break; //if at any time found it's not a prime, break the for loop
            }
        }
        if (isPrime){
            return inputNum;
        }
        inputNum += 2;
    }
}

For values of inputNum > 100, I would expect this to be about 10 times faster (and the speed-up improves as the value gets higher).  Note that there are some staggeringly fast ways of testing for whether a number is prime or not.  Miller-Rabin with a rather small list of numbers can deterministically check up to 2^64; using a sieve of Erothosenes to find all primes upto sqrt(2*original-input), and then only testing with those primes could be simpler to understand.


问:
LEFT JOIN confusion -- I need to retrieve a student count
I have four tables:

```<code>students
classes
teachers
teacher_assignments
</code>```

classes and teachers has a many-to-many relationship and so teacher_assignments acts as the xref table (with fields teacher_id and class_id).

Each student in students has a class_id (many-to-one -- many students to one class).

I should also mention that teacher_assignments has an active column (BOOL) which indicates whether that assignment is currently active

What I want to do:

I want to retrieve the following:

class_name -- a concat of its level and sub_level, e.g. 3 and A

teacher_names -- the names of the teachers currently assigned to that class

student_count -- a count of the students in each class

At first, I tried retrieving just the class_name and teacher_names, like so:

```<code>SELECT
    CONCAT(CONVERT(classes.level, CHAR(8)), classes.sub_level) AS class_name,
    GROUP_CONCAT(DISTINCT teachers.name SEPARATOR ',') AS teacher_names

FROM
    teacher_assignments
        LEFT JOIN teachers
            ON teachers.id = teacher_assignments.teacher_id
            AND teacher_assignments.active = TRUE
        LEFT JOIN classes
            ON classes.id = teacher_assignments.class_id

GROUP BY classes.id
</code>```

This works fine and outputs:

```<code> class_name | teacher_names
 --------------------------------------
 1A         | NULL
 2A         | John, Sam
 3B         | Sam, Sarah
</code>```

(Class 1A has no teachers currently, and so the NULL is expected)

... BUT, now I have no idea how to work the student_count into this.

My question:

How exactly should the students table be joined with the others in the above query so I can produce a student_count column?

答:
Just thinking off the top of my head...

Join classes and students tables to get the student count...

Instead of doing a left join on classes in your above query, you will do a left join with the result from #1 (essentially an inner join between classes and students tables) that allows you to pull the student count.

ContentLicense: CC BY-SA 2.5

Body:
I have four tables:

students
classes
teachers
teacher_assignments

classes and teachers has a many-to-many relationship and so teacher_assignments acts as the xref table (with fields teacher_id and class_id).

Each student in students has a class_id (many-to-one -- many students to one class).

I should also mention that teacher_assignments has an active column (BOOL) which indicates whether that assignment is currently active

What I want to do:

I want to retrieve the following:

class_name -- a concat of its level and sub_level, e.g. 3 and A

teacher_names -- the names of the teachers currently assigned to that class

student_count -- a count of the students in each class

At first, I tried retrieving just the class_name and teacher_names, like so:

SELECT
    CONCAT(CONVERT(classes.level, CHAR(8)), classes.sub_level) AS class_name,
    GROUP_CONCAT(DISTINCT teachers.name SEPARATOR ',') AS teacher_names

FROM
    teacher_assignments
        LEFT JOIN teachers
            ON teachers.id = teacher_assignments.teacher_id
            AND teacher_assignments.active = TRUE
        LEFT JOIN classes
            ON classes.id = teacher_assignments.class_id

GROUP BY classes.id

This works fine and outputs:

 class_name | teacher_names
 --------------------------------------
 1A         | NULL
 2A         | John, Sam
 3B         | Sam, Sarah

(Class 1A has no teachers currently, and so the NULL is expected)

... BUT, now I have no idea how to work the student_count into this.

My question:

How exactly should the students table be joined with the others in the above query so I can produce a student_count column?


问:
Parse: Update Object from Cloud Code
I have created a background job to run every minute. The purpose of it is to delete old or outdated data within the database. In this case, the user submits a time which has an attached timestamp to it, and the two values are stored in arrays times and timestamp. So I wrote my cloud code to check if the times are older than an hour via their timestamps. If so, delete them from the database. However, that's the part I'm having trouble with. Here's my cloud code so you can see what's going on:

```<code>Parse.Cloud.job("expireTimes", function(request, response){
Parse.Cloud.useMasterKey();
var currentTime = new Date().getTime() / 1000;
var query = new Parse.Query("Wait");
query.find().then(function(results) {
    var times = (results.length>0)? results[0].get("times") : "n/a";
    var timestamps = (results.length>0)? results[0].get("timestamp") : "n/a";
    console.log("Got " + results.length + " Times: " + times);
    console.log("Got " + results.length + " Timestamps: " + timestamps);
    for (var i = 0; i < timestamps.length; i++) {
        if (currentTime >= timestamps[i] + 3600) {
            // Delete old wait times
            timestamps.splice(i, 1);
            times.splice(i, 1);
            i--;
        } else {
            break;
        }
    };

    response.success("success");
}, function(error) {
    response.error(error);
});
})
</code>```

How do I update the database and delete the values within the array. Because when a user submits the time, it just adds to the times array. Well, if I have the background job going every minute, some entries aren't going to be over an hour old. I want to keep those, but get rid of the other ones.

Any ideas? Any help is much appreciated. Thank you

答:
Currently, i didn't find the best solution, but it's working for me now.</p>

```<code>var Progress = Parse.Object.extend(PROGRESS);
var progressQuery = new Parse.Query(Progress);
progressQuery.equalTo("userId", userId)
progressQuery.find({
    success: function (progress){
        for (i = 0; i < progress.length; i++){
            progress[i].set("lastUse", false)
            progress[i].save()
        }

    },
    error: function(object, error) {
        console.log(error)
    }
})
</code>```

Title: Parse: Update Object from Cloud Code

Body:
I have created a background job to run every minute. The purpose of it is to delete old or outdated data within the database. In this case, the user submits a time which has an attached timestamp to it, and the two values are stored in arrays times and timestamp. So I wrote my cloud code to check if the times are older than an hour via their timestamps. If so, delete them from the database. However, that's the part I'm having trouble with. Here's my cloud code so you can see what's going on:

Parse.Cloud.job("expireTimes", function(request, response){
Parse.Cloud.useMasterKey();
var currentTime = new Date().getTime() / 1000;
var query = new Parse.Query("Wait");
query.find().then(function(results) {
    var times = (results.length>0)? results[0].get("times") : "n/a";
    var timestamps = (results.length>0)? results[0].get("timestamp") : "n/a";
    console.log("Got " + results.length + " Times: " + times);
    console.log("Got " + results.length + " Timestamps: " + timestamps);
    for (var i = 0; i < timestamps.length; i++) {
        if (currentTime >= timestamps[i] + 3600) {
            // Delete old wait times
            timestamps.splice(i, 1);
            times.splice(i, 1);
            i--;
        } else {
            break;
        }
    };

    response.success("success");
}, function(error) {
    response.error(error);
});
})

How do I update the database and delete the values within the array. Because when a user submits the time, it just adds to the times array. Well, if I have the background job going every minute, some entries aren't going to be over an hour old. I want to keep those, but get rid of the other ones.

Any ideas? Any help is much appreciated. Thank you

Body:
Currently, i didn't find the best solution, but it's working for me now.

var Progress = Parse.Object.extend(PROGRESS);
var progressQuery = new Parse.Query(Progress);
progressQuery.equalTo("userId", userId)
progressQuery.find({
    success: function (progress){
        for (i = 0; i < progress.length; i++){
            progress[i].set("lastUse", false)
            progress[i].save()
        }

    },
    error: function(object, error) {
        console.log(error)
    }
})


问:
wrapping process.nextTick leads to Maximum call stack size exceeded
I am trying to wrap process.nextTick function but that leads to recursion.

```<code>var actual = process.nextTick;

process.nextTick = function(callback)
{
console.log('next tick called');
actual.apply(this, arguments);
}

console.log('starts');
setTimeout(function(){
console.log('set timeout called');
}, 100);
</code>```

this code produces

```<code>starts
next tick called
next tick called
...
RangeError: Maximum call stack size exceeded
</code>```

can anyone explain the workflow???

答:
I'm pretty much sure that console.log() is calling process.nextTick() and causing the recursion.

Have a look on the following example:

```<code>var counter = 0;
var actual = process.nextTick;

process.nextTick = function ()
{
    counter++;
    actual.apply(this, arguments);
}

console.log('starts ...'); // This will increment counter with 1, counter = 1
process.nextTick(function () {
    console.log('nextTick callback'); // This will increment counter with 1, counter = 3
    console.log(counter); // This will increment counter with 1, counter = 4
});
console.log('something else ...'); // This will increment counter with 1, counter = 2

/*
 *   OUTPUT
 */
starts ...
something else ...
nextTick callback
4
</code>```

Now if we remove one of the console.log() calls, we can see the following:

```<code>var counter = 0;
var actual = process.nextTick;

process.nextTick = function ()
{
    counter++;
    actual.apply(this, arguments);
}

console.log('starts ...'); // This will increment counter with 1, counter = 1
process.nextTick(function () {
    console.log(counter); // This will increment counter with 1, counter = 3
});
console.log('something else ...'); // This will increment counter with 1, counter = 2

/*
 *   OUTPUT
 */
starts ...
something else ...
3
</code>```

Note that counter is 3 now.

So my conclusion is that console.log() inside process.nextTick() overwrite function is causing the recursion.

I hope this example will help you to clear the things :)

Body:
I am trying to wrap process.nextTick function but that leads to recursion.

var actual = process.nextTick;

process.nextTick = function(callback)
{
console.log('next tick called');
actual.apply(this, arguments);
}

console.log('starts');
setTimeout(function(){
console.log('set timeout called');
}, 100);

this code produces

starts
next tick called
next tick called
...
RangeError: Maximum call stack size exceeded

can anyone explain the workflow???

Body:
I'm pretty much sure that console.log() is calling process.nextTick() and causing the recursion.

Have a look on the following example:

var counter = 0;
var actual = process.nextTick;

process.nextTick = function ()
{
    counter++;
    actual.apply(this, arguments);
}

console.log('starts ...'); // This will increment counter with 1, counter = 1
process.nextTick(function () {
    console.log('nextTick callback'); // This will increment counter with 1, counter = 3
    console.log(counter); // This will increment counter with 1, counter = 4
});
console.log('something else ...'); // This will increment counter with 1, counter = 2

/*
 *   OUTPUT
 */
starts ...
something else ...
nextTick callback
4

Now if we remove one of the console.log() calls, we can see the following:

var counter = 0;
var actual = process.nextTick;

process.nextTick = function ()
{
    counter++;
    actual.apply(this, arguments);
}

console.log('starts ...'); // This will increment counter with 1, counter = 1
process.nextTick(function () {
    console.log(counter); // This will increment counter with 1, counter = 3
});
console.log('something else ...'); // This will increment counter with 1, counter = 2

/*
 *   OUTPUT
 */
starts ...
something else ...
3

Note that counter is 3 now.

So my conclusion is that console.log() inside process.nextTick() overwrite function is causing the recursion.

I hope this example will help you to clear the things :)


问:
Lambda works, defined function does not
This is working:

```<code>represent_dict_order = lambda self, data: self.represent_mapping('tag:yaml.org,2002:map', data.items())
yaml.add_representer(OrderedDict, represent_dict_order)
</code>```

But gives me a PyCharm warning: PEP8: do not assign a lambda expression, use a def

I follow the advice, but this is not working:

```<code>def represent_dict_order(self, data):
    self.represent_mapping('tag:yaml.org,2002:map', data.items())
yaml.add_representer(OrderedDict, represent_dict_order)
</code>```

I get:

```<code>yaml.emitter.EmitterError: expected NodeEvent, but got DocumentEndEvent()
</code>```

I have two questions:

Why is the lambda working and the def not? Aren't they supposed to be equivalent?

How can I stop PyCharm complaining about this specific error? I tried preceeding the lambda with #noinspection but it is not recognized.

答: Lambda expressions come with an implicit return. Therefore your lambda expression is returning the return value of self.represent_mapping but your function definition is not due to the missing return.

Title: Lambda works, defined function does not

Body:
This is working:

represent_dict_order = lambda self, data: self.represent_mapping('tag:yaml.org,2002:map', data.items())
yaml.add_representer(OrderedDict, represent_dict_order)

But gives me a PyCharm warning: PEP8: do not assign a lambda expression, use a def

I follow the advice, but this is not working:

def represent_dict_order(self, data):
    self.represent_mapping('tag:yaml.org,2002:map', data.items())
yaml.add_representer(OrderedDict, represent_dict_order)

I get:

yaml.emitter.EmitterError: expected NodeEvent, but got DocumentEndEvent()

I have two questions:

Why is the lambda working and the def not? Aren't they supposed to be equivalent?

How can I stop PyCharm complaining about this specific error? I tried preceeding the lambda with #noinspection but it is not recognized.


问:
how to automatically backup docker Containers
I'm running a gitlab instance in a docker container. What could be a good and smart solution to automatically make backups of this docker container?

Or is it a better way to make backups of the gitlab data?

Thanks in advance.

答: Do the backup of your data and it is not required to backup the Docker instance. You can bring Docker instance from the Docker image at any time. But if you did some changes in the running Docker instance, then I would recommend you to create a new image from the running Docker instance using 'docker commit' command.  We can always run 'docker commit' on the running docker instance without stopping the Docker instance.</p>


问:
Need to make a specific column editable upon clicking edit
I have a gridview with "Edit Update Cancel" command field.
When I click Edit, all the columns in the particular row becomes editable.
I just need to have 2 specific columns editable.  How is that made possible ?

(Screen Shot Attached)

[In the screen shot all 3 columns are editable, I just need the second and third to be editable]

Thanks in Advance.

答:
Just set the other columsn to read-only:</p>

```<code> <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"  />
</code>```

Body:
Just set the other columsn to read-only:

 <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"  />


问:
Getting an error when using com.google.android.gms:play-services-maps:11.2.0 in my application
I am trying to create a simple Android application. I have the latest version of Android Studio and i think both my gradle build files are correct.

I have placed

implementation 'com.google.android.gms:play-services-maps:11.2.0'

in app gradle dependencies.

Due to this I get the following error:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:11.2.0.

I have looked at various links and tried out proposed solutions but none have worked for me.

Below are both my gradle build files.

project build.gradle:

```<code>//Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
</code>```

app build.gradle:

```<code>apply plugin: 'com.android.application'

android {
compileSdkVersion 26

defaultConfig {
    applicationId "demo.situm.situmapp"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    //testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
        matchingFallbacks = ['release', 'debug']
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.1'
//androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'

}

//apply plugin: 'com.google.gms.google-services'
</code>```

Hope you can help.

Thanks,
Kabir

答:
try this i found:

Failed to resolve com.google.android.gms play-services-auth:11.2.0

Add maven to your root level build.gradle file

```<code>allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
</code>```

This maven repo is required starting from 11.2.0.

Or add google() repository to your "build.gradle" file. This gradle method is equivalent to

maven { url "https://maven.google.com" }.

```<code>repositories {
    jcenter()
    google()
}
</code>```

Body:
I am trying to create a simple Android application. I have the latest version of Android Studio and i think both my gradle build files are correct.

I have placed

implementation 'com.google.android.gms:play-services-maps:11.2.0'

in app gradle dependencies.

Due to this I get the following error:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:11.2.0.

I have looked at various links and tried out proposed solutions but none have worked for me.

Below are both my gradle build files.

project build.gradle:

//Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

app build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26

defaultConfig {
    applicationId "demo.situm.situmapp"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    //testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
        matchingFallbacks = ['release', 'debug']
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.1'
//androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'

}

//apply plugin: 'com.google.gms.google-services'

Hope you can help.

Thanks,
Kabir

Body:
try this i found:

Failed to resolve com.google.android.gms play-services-auth:11.2.0

Add maven to your root level build.gradle file

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

This maven repo is required starting from 11.2.0.

Or add google() repository to your "build.gradle" file. This gradle method is equivalent to

maven { url "https://maven.google.com" }.

repositories {
    jcenter()
    google()
}


问:
Xcode - Target specific localization
My project includes several targets, each target is used for a different customer. Some customers need specific localization, and I don't want all the customers to get this specific localization. Since localization is handled on the project level, I couldn't find a way to add localization only for a specific target.

Any suggestions how to do it?

Looking for stable option without the need to delete unused localization before each build.

答:
Create a separate "Localizeable.strings" for each target.

link the correct strings files with each "group" of strings.

Then set it in the Build Phases for each target the correct "strings" like this:

ContentLicense: CC BY-SA 4.0

Title: Xcode - Target specific localization


问:
Background image not loading
I am new to html/css and I do not understand why my background image is not showing up. This is part of a simple test CSS sheet and HTML code for a simple site. I am trying to add a background-image and I have done this once and it worked and I do not know why it does not work now.</p>

```<code>.timeline{
    width: 100%;
    height: 400px;
    display: inline-flex;
    background-image:url("img/back.jpg");
}
</code>```

答:
Your syntax for background-image is incorrect

You need to use background-repeat: repeat; for repeat. Here is doc background-image

```<code>.timeline{
  width: 100%;
  height: 400px;
  display: inline-flex;
  background-image:url("img/back.jpg");
  background-repeat: repeat;
}
</code>```

Title: Background image not loading

Body:
I am new to html/css and I do not understand why my background image is not showing up. This is part of a simple test CSS sheet and HTML code for a simple site. I am trying to add a background-image and I have done this once and it worked and I do not know why it does not work now.

.timeline{
    width: 100%;
    height: 400px;
    display: inline-flex;
    background-image:url("img/back.jpg");
}

Body:
Your syntax for background-image is incorrect

You need to use background-repeat: repeat; for repeat. Here is doc background-image

.timeline{
  width: 100%;
  height: 400px;
  display: inline-flex;
  background-image:url("img/back.jpg");
  background-repeat: repeat;
}


问:
Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent
On application launch, app starts the service that should to do some network task.
After targeting API level 26, my application fails to start service on Android 8.0 on background.

Caused by: java.lang.IllegalStateException: Not allowed to start
  service Intent {
  cmp=my.app.tt/com.my.service
  }: app is in background uid UidRecord{90372b1 u0a136 CEM  idle procs:1
  seq(0,0,0)}

as I understand it related to:
Background execution limits

The startService() method now throws an IllegalStateException if an
  app targeting Android 8.0 tries to use that method in a situation when
  it isn't permitted to create background services.

"in a situation when it isn't permitted" - what it's actually mean?? And how to fix it. I don't want to set my service as "foreground"

答:
If the service is running in a background thread by extending IntentService, you can replace IntentService with JobIntentService which is provided as part of Android Support Library

The advantage of using JobIntentService is, it behaves as an IntentService on pre-O devices and on O and higher, it dispatches it as a job

JobScheduler can also be used for periodic/on demand jobs. But, ensure to handle backward compatibility as JobScheduler API is available only from API 21


问:
Keyboard not opening second time in ionic 3 app with ion item

When I clicked on input filed my keyboard does not appear when I tap on input box a second time. And if I put my ion-input outside from ion-item it is working, But in ion item, it is not working.

```<code><ion-list class='list' [@flyInBottomSlow]="cloudState">
            <div class="box">
                <ion-item class='input-field'>
                    <ion-label floating >
                        <i class="fa fa-user"></i>Employee Code or Email</ion-label>
                    <ion-input  type="text" [(ngModel)]='username'></ion-input>
                </ion-item>

                <ion-item class='input-field'>
                    <ion-label floating>
                        <i class="fa fa-key"></i>Password</ion-label>
                        <ion-input type="password" [(ngModel)]='password'></ion-input>
                </ion-item>

                <ion-item class='item'>
                    <button ion-button class='button' full (tap)="login()">SUBMIT</button>
                </ion-item>

                <ion-item class="forgot-password">
                    <a (click)="forgotPassword()">Forgot Password?</a>
                </ion-item>
            </div>
            <ion-item class="or_row">
                <span>OR</span>
            </ion-item>

            <ion-item class='item'>
                <button ion-button class='button google' full (tap)="loginWithGoogle()">
                    <i class="fa fa-google-plus"></i> LOGIN WITH GOOGLE</button>
            </ion-item>
        </ion-list>
</code>```

When I click on input field I should appear always.

答:
I added disabled false and now it is working.
Like

```<code><ion-item class='input-field'>
                    <ion-label floating>
                        <i class="fa fa-key"></i>Password</ion-label>
                        <ion-input type="password" [(ngModel)]='password' disabled=false></ion-input>
                </ion-item>
</code>```

Note: This is a temporary solution. Hope Ionic team will look into it.

Body:
When I clicked on input filed my keyboard does not appear when I tap on input box a second time. And if I put my ion-input outside from ion-item it is working, But in ion item, it is not working.

<ion-list class='list' [@flyInBottomSlow]="cloudState">

                <ion-item class='input-field'>
                    <ion-label floating >
                        Employee Code or Email</ion-label>
                    <ion-input  type="text" [(ngModel)]='username'></ion-input>
                </ion-item>

                <ion-item class='input-field'>
                    <ion-label floating>
                        Password</ion-label>
                        <ion-input type="password" [(ngModel)]='password'></ion-input>
                </ion-item>

                <ion-item class='item'>
                    <button ion-button class='button' full (tap)="login()">SUBMIT</button>
                </ion-item>

                <ion-item class="forgot-password">
                    Forgot Password?
                </ion-item>

            <ion-item class="or_row">
                OR
            </ion-item>

            <ion-item class='item'>
                <button ion-button class='button google' full (tap)="loginWithGoogle()">
                     LOGIN WITH GOOGLE</button>
            </ion-item>
        </ion-list>

When I click on input field I should appear always.

Body:
I added disabled false and now it is working.
Like

<ion-item class='input-field'>
                    <ion-label floating>
                        <i class="fa fa-key"></i>Password</ion-label>
                        <ion-input type="password" [(ngModel)]='password' disabled=false></ion-input>
                </ion-item>

Note: This is a temporary solution. Hope Ionic team will look into it.


问:
Do you make safe and unsafe version of your functions or just stick to the safe version? (Embedded System)
let's say you have a function that set an index and then update few variables based on the value stored in the array element which the index is pointing to. Do you check the index to make sure it is in range? (In embedded system environment to be specific Arduino)
So far I have made a safe and unsafe version for all functions, is that a good idea? In some of my other codes I noticed that having only safe functions result in checking conditions multiple time as the libraries get larger, so I started to develop both. The safe function checks the condition and call the unsafe function as shown in example below for the case explained above.

Safe version:

```<code>bool RcChannelModule::setFactorIndexAndUpdateBoundaries(factorIndex_T factorIndex)
{
    if(factorIndex < N_FACTORS)
    {
        setFactorIndexAndUpdateBoundariesUnsafe(factorIndex);
        return true;
    }

    return false;
}
</code>```

Unsafe version:

```<code>void RcChannelModule::setFactorIndexAndUpdateBoundariesUnsafe(factorIndex_T factorIndex)
{
    setCuurentFactorIndexUnsafe(factorIndex);
    updateOutputBoundaries();
}
</code>```

If I am doing it wrong fundamentally please let me know why and how I could avoid that. Also I would like to know, generally when you program, do you consider the future user to be a fool or you expect them to follow the minimal documentation provided? (the reason I say minimal is because I do not have the time to write a proper documentation)

```<code>void RcChannelModule::setCuurentFactorIndexUnsafe(const factorIndex_T factorIndex)
{
    currentFactorIndex_ = factorIndex;
}
</code>```

答:
Since you tagged this Arduino and embedded, you have a very resource-constrained system, one of the crappiest processors still manufactured.

On such a system you cannot afford extra error handling. It is better to properly document what values the parameters passed to the function must have, then leave the checking of this to the caller.

The caller can then either check this in run-time, if needed, or otherwise in compile-time with a static assert. Your function would however not be able to implement it as a static assert, as it can't know if factorIndex is a run-time variable or a compile-time constant.

As for "I have no time to write proper documentation", that's nonsense. It takes far less time to document this function than to post this SO question. You don't necessarily have to write an essay in some Word file. You don't necessarily have to use Doxygen or similar.

But you do need to write the bare minimum of documentation: In the header file, document the purpose and expected values of all function parameters in the form of comments. Preferably you should have a coding standard for how to document such functions. A minimal documentation of public API functions in the form of comments is part of your job as programmer. The code is not complete until this is written.

Body:
let's say you have a function that set an index and then update few variables based on the value stored in the array element which the index is pointing to. Do you check the index to make sure it is in range? (In embedded system environment to be specific Arduino)
So far I have made a safe and unsafe version for all functions, is that a good idea? In some of my other codes I noticed that having only safe functions result in checking conditions multiple time as the libraries get larger, so I started to develop both. The safe function checks the condition and call the unsafe function as shown in example below for the case explained above.

Safe version:

bool RcChannelModule::setFactorIndexAndUpdateBoundaries(factorIndex_T factorIndex)
{
    if(factorIndex < N_FACTORS)
    {
        setFactorIndexAndUpdateBoundariesUnsafe(factorIndex);
        return true;
    }

    return false;
}

Unsafe version:

void RcChannelModule::setFactorIndexAndUpdateBoundariesUnsafe(factorIndex_T factorIndex)
{
    setCuurentFactorIndexUnsafe(factorIndex);
    updateOutputBoundaries();
}

If I am doing it wrong fundamentally please let me know why and how I could avoid that. Also I would like to know, generally when you program, do you consider the future user to be a fool or you expect them to follow the minimal documentation provided? (the reason I say minimal is because I do not have the time to write a proper documentation)

void RcChannelModule::setCuurentFactorIndexUnsafe(const factorIndex_T factorIndex)
{
    currentFactorIndex_ = factorIndex;
}


答:
Your rule is wrong. You are trying to set background-image, background-position and other rules, but rule name is only background-image.

Use background instead of background-image

Title: Background image not loading


问:
Sum values grouped by key in list of dict
I have a list of dicts and now I am trying to find the total jobs for each remote identifier.

In this case I am expecting  for the id 64 -> 11 jobs and 68 -> 0 jobs

```<code>[{
    'jobs': {
        'count': 4
    },
    'remote_identifier': {
        'id': '64'
    }
}, {
    'jobs': {
        'count': 0
    },
    'remote_identifier': {
        'id': '68'
    }
}, {
    'jobs': {
        'count': 7
    },
    'remote_identifier': {
        'id': '64'
    }
}]
</code>```

I already tried something like this, but I don't know how to adapt it to my needs, since that only counts the number of occurrences.

```<code>from collections import Counter
print Counter(item['remote_identifier']['id'] for item in items )
</code>```

答:
Another solution is as follows:

```<code>input = [{
    'jobs': {
        'count': 4
    },
    'remote_identifier': {
        'id': '64'
    }
}, {
    'jobs': {
        'count': 0
    },
    'remote_identifier': {
        'id': '68'
    }
}, {
    'jobs': {
        'count': 7
    },
    'remote_identifier': {
        'id': '64'
    }
}]

res = dict()
for item in input:

    if item['remote_identifier']['id'] in res:
        total = res[item['remote_identifier']['id']] + item['jobs']['count']
    else:
        total = item['jobs']['count']
    res.update({item['remote_identifier']['id']: total})

print res
</code>```

output:

```<code>{'68': 0, '64': 11}
</code>```

Body:
I have a list of dicts and now I am trying to find the total jobs for each remote identifier.

In this case I am expecting  for the id 64 -> 11 jobs and 68 -> 0 jobs

[{
    'jobs': {
        'count': 4
    },
    'remote_identifier': {
        'id': '64'
    }
}, {
    'jobs': {
        'count': 0
    },
    'remote_identifier': {
        'id': '68'
    }
}, {
    'jobs': {
        'count': 7
    },
    'remote_identifier': {
        'id': '64'
    }
}]

I already tried something like this, but I don't know how to adapt it to my needs, since that only counts the number of occurrences.

from collections import Counter
print Counter(item['remote_identifier']['id'] for item in items )

Body:
Another solution is as follows:

input = [{
    'jobs': {
        'count': 4
    },
    'remote_identifier': {
        'id': '64'
    }
}, {
    'jobs': {
        'count': 0
    },
    'remote_identifier': {
        'id': '68'
    }
}, {
    'jobs': {
        'count': 7
    },
    'remote_identifier': {
        'id': '64'
    }
}]

res = dict()
for item in input:

    if item['remote_identifier']['id'] in res:
        total = res[item['remote_identifier']['id']] + item['jobs']['count']
    else:
        total = item['jobs']['count']
    res.update({item['remote_identifier']['id']: total})

print res

output:

{'68': 0, '64': 11}


问:
Entity Framework 6 with Mysql "System.InvalidOperationException"
I'm new with .net
I'm trying building console app with EF6 and MySql

i always got this error when running it

this is my app.conf

```<code><?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <connectionStrings>
    <add name="MyContext" providerName="MySql.Data.MySqlClient"
        connectionString="server=192.168.1.212;port=3306;database=zkatt;uid=fanta;password=040506"/>
  </connectionStrings>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient"
          type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/>
      <provider invariantName="System.Data.SqlClient"
          type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description="MySQL Database Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
    </DbProviderFactories>
  </system.data>
</configuration>
</code>```

my context class

```<code>[DbConfigurationType(typeof(MySqlEFConfiguration))]
public partial class Entities : DbContext
{
    public Entities()
        : base("name=MyContext")
    {
    }
</code>```

anything i miss?

*edit
this is full report error

答: Downgrade mysql entity to 6.9.10, now its work, wasted my 6 hours.</p>

Body:
I'm new with .net
I'm trying building console app with EF6 and MySql

i always got this error when running it

this is my app.conf

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>

  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <connectionStrings>
    <add name="MyContext" providerName="MySql.Data.MySqlClient"
        connectionString="server=192.168.1.212;port=3306;database=zkatt;uid=fanta;password=040506"/>
  </connectionStrings>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient"
          type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/>
      <provider invariantName="System.Data.SqlClient"
          type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description="MySQL Database Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
    </DbProviderFactories>
  </system.data>
</configuration>

my context class

[DbConfigurationType(typeof(MySqlEFConfiguration))]
public partial class Entities : DbContext
{
    public Entities()
        : base("name=MyContext")
    {
    }

anything i miss?

*edit
this is full report error


问:
PDF compressor for DELPHI 2007
Need a PDF compressor that I can use from DELPHI 2007.

What is the best one out there?

UPDATE ---

By PDF compressor I mean some way to compress an existing PDF. I don’t need to create new PDF files.

The usage that I’ll do with it, simple, I have in my applications the possibility to associate a file to a product, an entity, equipment whatever, and if the file is a PDF I want to be able reduce its size.

There some tools that can do this with no need to actually zip the file, what would mean that to see it you would have to decompress(unzip), this tools jut reduce the size.

So a PDF compressor, or call it what you will, is just this.

答:
Arguably the best is the Acrobat family of software from Adobe itself.

Edit 2:

Adobe has quite some extensive documentation on their API and docs on their Acrobat.com services.

Their Acrobat products are in use by a lot of vendors, even the affordable ones, to provide PDF support.

Edit 1:

Downvoters: it is for two reasons I mentioned Arguably in my original answer.

First of all just stating best without adding more criteria will always get a subjective answer.

Second: Adobe is the inventor of PDF, and the PDF support of their software is great. I know there are drawbacks of Adobe software too, but the question was the 'best', which I interpreted as the best PDF support.

Title: PDF compressor for DELPHI 2007


问:
Javascript - Tetris - How to turn around the blocks
I'm working on a Tetris Game with a friend. How can we turn around the blocks?

We know how to calculate the position of the blocks but we don't know how to add it to the code :

```<code>i' = a * i + b * j

j' = c * i + d * j

newJ = -i;

newI =  j;
</code>```

What we were thinking of is adding Arrays but as I said we are not sure.. how to start it

This is our code so far:

function stylingSquares() {
  var i;
  var j;

  for (i = 1; i > -2; i--) {
    for (j = -1; j < 2; j++) {
      var myDiv = document.createElement("div");

      myDiv.style.width = "100px";
      myDiv.style.height = "100px";
      myDiv.style.backgroundColor = "black";

      myDiv.setAttribute("class", "quad");
      document.getElementById("game").appendChild(myDiv);

      if ((i === 0 && j === 0) ||
        (i === 1 && j === -1) ||
        (i === 0 && j === -1) ||
        (i === 0 && j === 1) ||
        (i === 0 && j === 0)) {
        myDiv.style.backgroundColor = "red";
      } else {

      }
    }
  }

  setInterval(function() {
    document.body.onkeyup = function(e) {
      if (e.keyCode == 32) {

      }
    }
  }, 300);
}

stylingSquares();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.quad {
  float: left;
  margin: 1 1 1 1;
}

#game {
  position: relative;
  width: 308px;
  height: 308px;
  background-color: black;
}</code>```

```

答:
I would create a 2D-array of the play field (to keep track of the current piece, already placed blocks, borders), select a rotation point for the current piece and finally attempt to move the piece's blocks around that point, 1 or 2 "steps" at a time (as needed).

If the new location collides with something else in the array, try to move the piece one step in the opposite direction. If that's not possible then the piece cannot be rotated.

Body:
I'm working on a Tetris Game with a friend. How can we turn around the blocks?

We know how to calculate the position of the blocks but we don't know how to add it to the code :

i' = a * i + b * j

j' = c * i + d * j

newJ = -i;

newI =  j;

What we were thinking of is adding Arrays but as I said we are not sure.. how to start it

This is our code so far:

function stylingSquares() {
  var i;
  var j;

  for (i = 1; i > -2; i--) {
    for (j = -1; j < 2; j++) {
      var myDiv = document.createElement("div");

      myDiv.style.width = "100px";
      myDiv.style.height = "100px";
      myDiv.style.backgroundColor = "black";

      myDiv.setAttribute("class", "quad");
      document.getElementById("game").appendChild(myDiv);

      if ((i === 0 && j === 0) ||
        (i === 1 && j === -1) ||
        (i === 0 && j === -1) ||
        (i === 0 && j === 1) ||
        (i === 0 && j === 0)) {
        myDiv.style.backgroundColor = "red";
      } else {

      }
    }
  }

  setInterval(function() {
    document.body.onkeyup = function(e) {
      if (e.keyCode == 32) {

      }
    }
  }, 300);
}

stylingSquares();

.quad {
  float: left;
  margin: 1 1 1 1;
}

#game {
  position: relative;
  width: 308px;
  height: 308px;
  background-color: black;
}


问:
local collection types not allowed in SQL statements - Oracle
```<code>SET SERVEROUTPUT ON;
DECLARE
    type r05_id_type is TABLE  of r01_table.R01_ID%TYPE;

    r01_ids r05_id_type;
BEGIN

SELECT r1.r01_ID as R01_ID
BULK COLLECT INTO r01_ids
FROM r01_table r1, r05_table r5
WHERE r1.r01_ID= r5.r05_R01_ID_FK
AND r5.r05_status='D' AND  r5.r05_date_time_captured <= TRUNC(SYSDATE) - 1095
AND r1.r01_id NOT IN(select r01.r01_ID
                FROM r01_table r01, r05_table r05
                WHERE r05.r05_status !='D'
                AND r01.r01_ID= r05.r05_R01_ID_FK);

  dbms_output.put_line(r01_ids.COUNT);

  FOR indx IN 1 .. r01_ids.COUNT
  LOOP
     dbms_output.put_line(r01_ids(indx));
     insert all into r01_table_archived (R01_ID_TYPE,R01_IDENTITY_NUMBER,R01_PASSPORT_COUNTRY,R01_DATE_TIME_CAPTURED)
     values(rr1_R01_ID_TYPE,rr1_R01_IDENTITY_NUMBER,rr1_R01_PASSPORT_COUNTRY,rr1_R01_DATE_TIME_CAPTURED)
     select rr1_R01_ID_TYPE,rr1_R01_IDENTITY_NUMBER,rr1_R01_PASSPORT_COUNTRY,rr1_R01_DATE_TIME_CAPTURED
     FROM (SELECT R01_ID_TYPE,R01_IDENTITY_NUMBER,R01_PASSPORT_COUNTRY,R01_DATE_TIME_CAPTURED
            FROM r01_table
            WHERE r01_id IN (r01_ids));
  END LOOP;

END;
</code>```

I am writing the above procedure in order to check some records between two tables and storing the matching ID (r01_ID) in an inner table call r01_ids.
dbms_output.put_line(r01_ids(indx)) prints the correct values which indicates that the values are correctly inserting to r01_ids.
but the issue happens when I try to insert the values to the  r01_table_archived table within the LOOP.

I am getting the below error

PLS-00642: local collection types not allowed in SQL statements

Can't I get the values of r01_ids from the insert query like this? If I am wrong, someone please help me to find what's the issue and how to perform it in the right way.

答:
Until Oracle 11g, if you declare type under the scope of a PLSQL block, it cannot be called in SQL statement within the block and this is the reason you are getting this error:

```<code>PLS-00642: local collection types not allowed in SQL statements
</code>```

You can create a type outside the SCOPE of PLSQL block and then use it in SQL. See below:

```<code>--Created a type of Number assuming ID is number
CREATE OR REPLACE TYPE R05_ID_TYPE IS TABLE OF NUMBER;
/
--Block
DECLARE
    --TYPE R05_ID_TYPE IS TABLE OF R01_TABLE.R01_ID%TYPE;

     R01_IDS                       R05_ID_TYPE;
BEGIN
     SELECT R1.R01_ID AS R01_ID
     BULK COLLECT INTO R01_IDS
       FROM R01_TABLE R1,
            R05_TABLE R5
      WHERE R1.R01_ID = R5.R05_R01_ID_FK
            AND R5.R05_STATUS = 'D'
            AND R5.R05_DATE_TIME_CAPTURED <= TRUNC (SYSDATE) - 1095
            AND R1.R01_ID NOT IN (
                    SELECT R01.R01_ID
                      FROM R01_TABLE R01,
                           R05_TABLE R05
                     WHERE R05.R05_STATUS != 'D'
                           AND R01.R01_ID = R05.R05_R01_ID_FK);

     DBMS_OUTPUT.PUT_LINE (R01_IDS.COUNT);

     FOR INDX IN 1 .. R01_IDS.COUNT
     LOOP
          DBMS_OUTPUT.PUT_LINE (R01_IDS (INDX) );
          INSERT
                INTO R01_TABLE_ARCHIVED
                     (R01_ID_TYPE,
                      R01_IDENTITY_NUMBER,
                      R01_PASSPORT_COUNTRY,
                      R01_DATE_TIME_CAPTURED)
               SELECT RR1_R01_ID_TYPE,
                      RR1_R01_IDENTITY_NUMBER,
                      RR1_R01_PASSPORT_COUNTRY,
                      RR1_R01_DATE_TIME_CAPTURED
                 FROM (SELECT R01_ID_TYPE,
                              R01_IDENTITY_NUMBER,
                              R01_PASSPORT_COUNTRY,
                              R01_DATE_TIME_CAPTURED
                         FROM R01_TABLE
                        --Using the collection in SQL statement
                        WHERE R01_ID IN (Select column_value from table(R01_IDS) );
     END LOOP;
COMMIT;
END;
</code>```

Body:
SET SERVEROUTPUT ON;
DECLARE
    type r05_id_type is TABLE  of r01_table.R01_ID%TYPE;

    r01_ids r05_id_type;
BEGIN

SELECT r1.r01_ID as R01_ID
BULK COLLECT INTO r01_ids
FROM r01_table r1, r05_table r5
WHERE r1.r01_ID= r5.r05_R01_ID_FK
AND r5.r05_status='D' AND  r5.r05_date_time_captured <= TRUNC(SYSDATE) - 1095
AND r1.r01_id NOT IN(select r01.r01_ID
                FROM r01_table r01, r05_table r05
                WHERE r05.r05_status !='D'
                AND r01.r01_ID= r05.r05_R01_ID_FK);

  dbms_output.put_line(r01_ids.COUNT);

  FOR indx IN 1 .. r01_ids.COUNT
  LOOP
     dbms_output.put_line(r01_ids(indx));
     insert all into r01_table_archived (R01_ID_TYPE,R01_IDENTITY_NUMBER,R01_PASSPORT_COUNTRY,R01_DATE_TIME_CAPTURED)
     values(rr1_R01_ID_TYPE,rr1_R01_IDENTITY_NUMBER,rr1_R01_PASSPORT_COUNTRY,rr1_R01_DATE_TIME_CAPTURED)
     select rr1_R01_ID_TYPE,rr1_R01_IDENTITY_NUMBER,rr1_R01_PASSPORT_COUNTRY,rr1_R01_DATE_TIME_CAPTURED
     FROM (SELECT R01_ID_TYPE,R01_IDENTITY_NUMBER,R01_PASSPORT_COUNTRY,R01_DATE_TIME_CAPTURED
            FROM r01_table
            WHERE r01_id IN (r01_ids));
  END LOOP;

END;

I am writing the above procedure in order to check some records between two tables and storing the matching ID (r01_ID) in an inner table call r01_ids.
dbms_output.put_line(r01_ids(indx)) prints the correct values which indicates that the values are correctly inserting to r01_ids.
but the issue happens when I try to insert the values to the  r01_table_archived table within the LOOP.

I am getting the below error

PLS-00642: local collection types not allowed in SQL statements

Can't I get the values of r01_ids from the insert query like this? If I am wrong, someone please help me to find what's the issue and how to perform it in the right way.

Body:
Until Oracle 11g, if you declare type under the scope of a PLSQL block, it cannot be called in SQL statement within the block and this is the reason you are getting this error:

PLS-00642: local collection types not allowed in SQL statements

You can create a type outside the SCOPE of PLSQL block and then use it in SQL. See below:

--Created a type of Number assuming ID is number
CREATE OR REPLACE TYPE R05_ID_TYPE IS TABLE OF NUMBER;
/
--Block
DECLARE
    --TYPE R05_ID_TYPE IS TABLE OF R01_TABLE.R01_ID%TYPE;

     R01_IDS                       R05_ID_TYPE;
BEGIN
     SELECT R1.R01_ID AS R01_ID
     BULK COLLECT INTO R01_IDS
       FROM R01_TABLE R1,
            R05_TABLE R5
      WHERE R1.R01_ID = R5.R05_R01_ID_FK
            AND R5.R05_STATUS = 'D'
            AND R5.R05_DATE_TIME_CAPTURED <= TRUNC (SYSDATE) - 1095
            AND R1.R01_ID NOT IN (
                    SELECT R01.R01_ID
                      FROM R01_TABLE R01,
                           R05_TABLE R05
                     WHERE R05.R05_STATUS != 'D'
                           AND R01.R01_ID = R05.R05_R01_ID_FK);

     DBMS_OUTPUT.PUT_LINE (R01_IDS.COUNT);

     FOR INDX IN 1 .. R01_IDS.COUNT
     LOOP
          DBMS_OUTPUT.PUT_LINE (R01_IDS (INDX) );
          INSERT
                INTO R01_TABLE_ARCHIVED
                     (R01_ID_TYPE,
                      R01_IDENTITY_NUMBER,
                      R01_PASSPORT_COUNTRY,
                      R01_DATE_TIME_CAPTURED)
               SELECT RR1_R01_ID_TYPE,
                      RR1_R01_IDENTITY_NUMBER,
                      RR1_R01_PASSPORT_COUNTRY,
                      RR1_R01_DATE_TIME_CAPTURED
                 FROM (SELECT R01_ID_TYPE,
                              R01_IDENTITY_NUMBER,
                              R01_PASSPORT_COUNTRY,
                              R01_DATE_TIME_CAPTURED
                         FROM R01_TABLE
                        --Using the collection in SQL statement
                        WHERE R01_ID IN (Select column_value from table(R01_IDS) );
     END LOOP;
COMMIT;
END;


问:
float is not displaying the right format . looking for xxxxxx.xx
```<code>float fRealEsate = 360000.00 * 0.04;
 Toast.makeText(v.getContext(), "Real Estate Brokerage Fee: "
                     + fRealEsate, Toast.LENGTH_SHORT).show();
</code>```

I need it to display 15600.00 but its displaying 15600.0

答:
Read up on:

http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html

Body:
float fRealEsate = 360000.00 * 0.04;
 Toast.makeText(v.getContext(), "Real Estate Brokerage Fee: "
                     + fRealEsate, Toast.LENGTH_SHORT).show();

I need it to display 15600.00 but its displaying 15600.0


问:
Working setup for Weblogic 12c, Jersey and Swagger
I have a working Tomcat setup with Jersey and Swagger, but now I have to make it work on Weblogic 12c (12.2.1). I have tried several different ways of getting it to work, but I have ended up in various dead ends. I'm doing this in JDeveloper.

I've ended up with Jackson version issues and other similar collisions every way I've tried. I've gotten Jersey to work with Weblogic, but not Swagger.

I can use older versions if that helps.

This is a part of my pom from my latest failure:

```<code>    <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-jersey2-jaxrs</artifactId>
        <version>1.5.10</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle.weblogic</groupId>
        <artifactId>javax.ws.rs.javax.ws.rs-api</artifactId>
        <version>12.2.1-0-0</version>
    </dependency>
</code>```

This gives

```<code>org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
</code>```

which I understand is due to a Glassfish/Jackson version issue.

tl;dr

I'm looking for a Hello World for Weblogic 12/Jersey/Swagger

答:
WebLogic Server provides an older version of Jackson that conflicts with the one needed by Swagger.
To tell WebLogic to use the one embedded in your war, add the following to your weblogic.xml :

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
    (...)
    <container-descriptor>
        <prefer-application-packages>
            <package-name>com.fasterxml.jackson.*</package-name>
        </prefer-application-packages>
    </container-descriptor>
    (...)
</weblogic-web-app>
```

Body:
I have a working Tomcat setup with Jersey and Swagger, but now I have to make it work on Weblogic 12c (12.2.1). I have tried several different ways of getting it to work, but I have ended up in various dead ends. I'm doing this in JDeveloper.

I've ended up with Jackson version issues and other similar collisions every way I've tried. I've gotten Jersey to work with Weblogic, but not Swagger.

I can use older versions if that helps.

This is a part of my pom from my latest failure:

    <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-jersey2-jaxrs</artifactId>
        <version>1.5.10</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle.weblogic</groupId>
        <artifactId>javax.ws.rs.javax.ws.rs-api</artifactId>
        <version>12.2.1-0-0</version>
    </dependency>

This gives

org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;

which I understand is due to a Glassfish/Jackson version issue.

tl;dr

I'm looking for a Hello World for Weblogic 12/Jersey/Swagger