问:
Run plsql procedure from concurrent on Oracle
I am trying to create a stored procedure that send parameter input into table. When I tried to compile my store procedure from SQL Developer it was running well,but i want to run this procedure from Concurrent in Oracle EBS 12.

However, this is the Error Message :

Cause: FDPSTP failed due to ORA-06550: line 1, column 7:
  PLS-00201: identifier 'RUN_THIS_THING' must be declared
  ORA-06550: line 1, column 7:
  PL/SQL: Statement ignored
  .

And this is my code :

```<code>create or replace PROCEDURE  RUN_THIS_THING
(errbuf  out varchar2,retcode out varchar2, P_RUN_FROM IN NUMBER, P_RUN_TO IN NUMBER, P_USER IN VARCHAR2) IS

BEGIN
declare cursor c_header is
    select
        aia.party_id,
        aia.INVOICE_ID,
        aia.INVOICE_NUM,
        AIA.VENDOR_ID,
        AIA.INVOICE_CURRENCY_CODE,
        aia.INVOICE_AMOUNT,
        aia.DESCRIPTION,
        aia.INVOICE_DATE,
        aia.INVOICE_RECEIVED_DATE,
        AIA.GL_DATE,
        AIA.DOC_SEQUENCE_VALUE
        from
        AP.ap_invoices_all aiA
    where
         AIA.DOC_SEQUENCE_VALUE BETWEEN P_RUN_FROM  AND  P_RUN_TO;
    h_rec c_header%rowtype;

begin
    open c_header;
    loop
    fetch c_header into h_rec;
    exit when c_header%notfound;
    BEGIN
        insert into RUN_TEMP
        (
        INVOICE_ID               ,
        LAST_UPDATE_DATE         ,
        LAST_UPDATED_BY          ,
        VENDOR_ID                ,
        PARTY_ID                 ,
        INVOICE_NUM              ,
        TTDV_NUM                 ,
        CURRENCY                 ,
        INVOICE_AMOUNT           ,
        INVOICE_DATE             ,
        INVOICE_RECEIVED_DATE    ,
        GL_DATE                  ,
        DESCRIPTION
        )
        values
        (
        h_rec.INVOICE_ID,
        sysdate,
        p_user,
        h_rec.VENDOR_ID,
        h_rec.party_id,
        h_rec.INVOICE_NUM,
        h_rec.DOC_SEQUENCE_VALUE,
        h_rec.INVOICE_CURRENCY_CODE,
        h_rec.INVOICE_AMOUNT,
        h_rec.INVOICE_DATE,
        h_rec.INVOICE_RECEIVED_DATE,
        h_rec.GL_DATE  ,
        h_rec.DESCRIPTION
        );
        END;
    end loop;
  close c_header;
commit;
end;
END;
</code>```

It fails look like the procedure does not compile and I have already tried to grant my user execute rights to that package. It did not work. What else can I look at? What else could be causing this? Thanks!

答:
CREATE or REPLACE PUBLIC SYNONYM RUN_THIS_THING FOR RUN_THIS_THING;

Try this statement or change as needed. Synonym missing.

Body:
I am trying to create a stored procedure that send parameter input into table. When I tried to compile my store procedure from SQL Developer it was running well,but i want to run this procedure from Concurrent in Oracle EBS 12.

However, this is the Error Message :

Cause: FDPSTP failed due to ORA-06550: line 1, column 7:
  PLS-00201: identifier 'RUN_THIS_THING' must be declared
  ORA-06550: line 1, column 7:
  PL/SQL: Statement ignored
  .

And this is my code :

create or replace PROCEDURE  RUN_THIS_THING
(errbuf  out varchar2,retcode out varchar2, P_RUN_FROM IN NUMBER, P_RUN_TO IN NUMBER, P_USER IN VARCHAR2) IS

BEGIN
declare cursor c_header is
    select
        aia.party_id,
        aia.INVOICE_ID,
        aia.INVOICE_NUM,
        AIA.VENDOR_ID,
        AIA.INVOICE_CURRENCY_CODE,
        aia.INVOICE_AMOUNT,
        aia.DESCRIPTION,
        aia.INVOICE_DATE,
        aia.INVOICE_RECEIVED_DATE,
        AIA.GL_DATE,
        AIA.DOC_SEQUENCE_VALUE
        from
        AP.ap_invoices_all aiA
    where
         AIA.DOC_SEQUENCE_VALUE BETWEEN P_RUN_FROM  AND  P_RUN_TO;
    h_rec c_header%rowtype;

begin
    open c_header;
    loop
    fetch c_header into h_rec;
    exit when c_header%notfound;
    BEGIN
        insert into RUN_TEMP
        (
        INVOICE_ID               ,
        LAST_UPDATE_DATE         ,
        LAST_UPDATED_BY          ,
        VENDOR_ID                ,
        PARTY_ID                 ,
        INVOICE_NUM              ,
        TTDV_NUM                 ,
        CURRENCY                 ,
        INVOICE_AMOUNT           ,
        INVOICE_DATE             ,
        INVOICE_RECEIVED_DATE    ,
        GL_DATE                  ,
        DESCRIPTION
        )
        values
        (
        h_rec.INVOICE_ID,
        sysdate,
        p_user,
        h_rec.VENDOR_ID,
        h_rec.party_id,
        h_rec.INVOICE_NUM,
        h_rec.DOC_SEQUENCE_VALUE,
        h_rec.INVOICE_CURRENCY_CODE,
        h_rec.INVOICE_AMOUNT,
        h_rec.INVOICE_DATE,
        h_rec.INVOICE_RECEIVED_DATE,
        h_rec.GL_DATE  ,
        h_rec.DESCRIPTION
        );
        END;
    end loop;
  close c_header;
commit;
end;
END;

It fails look like the procedure does not compile and I have already tried to grant my user execute rights to that package. It did not work. What else can I look at? What else could be causing this? Thanks!


来源: stackexchange

问:
Python - split a list into many lists in a for loop
Given this input:

```<code>['1636 19 02 2F', '1637 19 02 2F', '1631 19 02 2F']
</code>```

I'd like to produce this output:

```<code>['1636']
['19']
['02']
['2F']
['1637']
['19']
['02']
['2F']
</code>```

I tried:

```<code>byte = ['1636 19 02 2F', '1637 19 02 2F', '1631 19 02 2F']

for i in byte:
    d = i.split(' ')
    list_byte = d # ('\n'.join(d))
    print(list(list_byte,))
</code>```

But its output is:

```<code>['1636', '19', '02', '2F']
['1637', '19', '02', '2F']
</code>```

I have also tried a nested loop but then it splits into every character and join but that just wrote out the wrong type.

How can I have the output in separate lists, like this?

```<code>['1636']
['19']
['02']
['2F']
['1637']
['19']
['02']
['2F']
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Given this input:

['1636 19 02 2F', '1637 19 02 2F', '1631 19 02 2F']

I'd like to produce this output:

['1636']
['19']
['02']
['2F']
['1637']
['19']
['02']
['2F']

I tried:

byte = ['1636 19 02 2F', '1637 19 02 2F', '1631 19 02 2F']

for i in byte:
    d = i.split(' ')
    list_byte = d # ('\n'.join(d))
    print(list(list_byte,))

But its output is:

['1636', '19', '02', '2F']
['1637', '19', '02', '2F']

I have also tried a nested loop but then it splits into every character and join but that just wrote out the wrong type.

How can I have the output in separate lists, like this?

['1636']
['19']
['02']
['2F']
['1637']
['19']
['02']
['2F']

Body:
byte = ['1636 19 02 2F', '1637 19 02 2F', '1631 19 02 2F']

for a in byte:
    a_list = a.split(' ')
#     print(a_list)
    for b in a_list:
        print([b])

Here you are.

['1636']
['19']
['02']
['2F']
['1637']
['19']
['02']
['2F']
['1631']
['19']
['02']
['2F']


问:
how to call subactivity of another application android?
To call main activity I saw componentName class in android.

```<code>intent = new Intent(new ComponentName(packageNam,classname);
</code>```

if same is used in case of child activity, I got error ,
"is activity delcared in andorid manifest?" like error.

how to call app1 child activity in app2 by using intent ?
In app1 the activity is declared like this in manifest

```<code><activity android:name=".activity.MessageCompose" android:label="@string/app_name" android:enabled="false">
- <intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <action android:name="android.intent.action.SENDTO" />
  <data android:scheme="mailto" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
  </activity>
</code>```

答: Please declare that activity in app1/AndroidManifest.xml</p>

ContentLicense: CC BY-SA 2.5

Body:
To call main activity I saw componentName class in android.

intent = new Intent(new ComponentName(packageNam,classname);

if same is used in case of child activity, I got error ,
"is activity delcared in andorid manifest?" like error.

how to call app1 child activity in app2 by using intent ?
In app1 the activity is declared like this in manifest

<activity android:name=".activity.MessageCompose" android:label="@string/app_name" android:enabled="false">
- <intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <action android:name="android.intent.action.SENDTO" />
  <data android:scheme="mailto" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
  </activity>


问:
Business Rule Composer (Not Responding)
I have BizTalk 2013r2 Dev VM with CU5 installed, apart from the this problem - the VM works great, I have several BizTalk apps deployed locally and all process ok.

When trying to load the Business Rule Composer, it displays but is unresponsive. The title bar reads Microsoft Business Rule Composer (Not Responding). At the foot of the page, in the status bar, there is the message "Loading...".

When I try to apply the CU6 update I get the following (see the Not Responding) in the title bar:

I have checked that all the usual suspect windows services are running, MSDTC, Sql Browser, SQl Server etc.

Any ideas what could be causing this? There are no clues in the Windows Event Log.

答: I was a able to fix this by running the BizTalk install MSI from the DVD image and selecting "Repair BizTalk"</p>

Title: Business Rule Composer (Not Responding)


问:
Add ONLY checked items from a checklistbox to a listView control
My situation:

I have a populated checklistbox control on Form1.
Then I have a listView control on Form2.

I would like for the user to be able to check items on the checklistbox on Form1, then click on a button on Form1 to open Form2.

Form2 contains the listView control, that I want to populate with only the checked items from checklistbox on Form1.

I tried

```<code>namespace Boodschappenlijst
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

    public static string[] strKruideniersw = new string[] { Boodschappenlijst.producten[0], Boodschappenlijst.producten[1], Boodschappenlijst.producten[2] };
    public static string[] strVerswaren = new string[] { Boodschappenlijst.producten[3], Boodschappenlijst.producten[4], Boodschappenlijst.producten[5] };
    public static string[] strVerzorgingspr = new string[] { Boodschappenlijst.producten[6], Boodschappenlijst.producten[7], Boodschappenlijst.producten[8], Boodschappenlijst.producten[9] };

    public static List<string> kruidenierswList = new List<string>(strKruideniersw);
    public static List<string> verswarenList = new List<string>(strVerswaren);
    public static List<string> verzproductenList = new List<string>(strVerzorgingspr);

    public static string[] strKruidenierswCh;

    public void Form1_Load(object sender, EventArgs e)
    {
        clbKruidenierswaren.Items.AddRange(strKruideniersw);
        clbVerswaren.Items.AddRange(strVerswaren);
        clbVerzproducten.Items.AddRange(strVerzorgingspr);
        strKruidenierswCh = clbKruidenierswaren.CheckedItems;
    }

    // TODO
    // public string kruidenierswChecked = clbKruidenierswaren.CheckedItems;

    private void button1_Click(object sender, EventArgs e)
    {
        // Create a new instance of the Form2 class
        Form2 form2 = new Form2();

        // Show the settings form
        form2.Show();
    }
}

public abstract class Boodschappenlijst : Form1
{
    public static string[] producten = new string[] { "Peper", "Zout", "Kruidnagel", "Sla", "Komkommer", "Tomaten", "Tandpasta", "Shampoo", "Wax", "Deodorant" };

    // Not working.. clbKruidenierswaren is not static.
    List<string> items = clbKruidenierswaren.CheckedItems.Cast<string>().ToList();

    // Make form1 controls accessible for other classes?
    // Form1 form1 = Application.OpenForms.OfType<Form1>().FirstOrDefault();

}
}
</code>```

but the I get the error

A field initializer cannot reference the non-static field, method, or property 'Form1.clbKruidenierswaren'.

Can you please direct me to a solution that works?

答:
The problem is you're passing UI objects around, you should be passing data around instead.  Here's an example of a Form that can be given data during construction.

```<code>public class BaseForm : Form
{
    public object InitialisationData { get; set; }
}

public partial class MagicForm : BaseForm
{
    public string MyBindableGuy;

    public MagicForm()
    {
        InitializeComponent();

        MyBindableGuy = InitialisationData as string;
    }
}
</code>```

and open it with:

```<code>var myForm = new MagicForm();
myForm.InitialisationData = "Hi, I'm a string.";
myForm.Show();
</code>```

Body:
My situation:

I have a populated checklistbox control on Form1.
Then I have a listView control on Form2.

I would like for the user to be able to check items on the checklistbox on Form1, then click on a button on Form1 to open Form2.

Form2 contains the listView control, that I want to populate with only the checked items from checklistbox on Form1.

I tried

namespace Boodschappenlijst
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

    public static string[] strKruideniersw = new string[] { Boodschappenlijst.producten[0], Boodschappenlijst.producten[1], Boodschappenlijst.producten[2] };
    public static string[] strVerswaren = new string[] { Boodschappenlijst.producten[3], Boodschappenlijst.producten[4], Boodschappenlijst.producten[5] };
    public static string[] strVerzorgingspr = new string[] { Boodschappenlijst.producten[6], Boodschappenlijst.producten[7], Boodschappenlijst.producten[8], Boodschappenlijst.producten[9] };

    public static List<string> kruidenierswList = new List<string>(strKruideniersw);
    public static List<string> verswarenList = new List<string>(strVerswaren);
    public static List<string> verzproductenList = new List<string>(strVerzorgingspr);

    public static string[] strKruidenierswCh;

    public void Form1_Load(object sender, EventArgs e)
    {
        clbKruidenierswaren.Items.AddRange(strKruideniersw);
        clbVerswaren.Items.AddRange(strVerswaren);
        clbVerzproducten.Items.AddRange(strVerzorgingspr);
        strKruidenierswCh = clbKruidenierswaren.CheckedItems;
    }

    // TODO
    // public string kruidenierswChecked = clbKruidenierswaren.CheckedItems;

    private void button1_Click(object sender, EventArgs e)
    {
        // Create a new instance of the Form2 class
        Form2 form2 = new Form2();

        // Show the settings form
        form2.Show();
    }
}

public abstract class Boodschappenlijst : Form1
{
    public static string[] producten = new string[] { "Peper", "Zout", "Kruidnagel", "Sla", "Komkommer", "Tomaten", "Tandpasta", "Shampoo", "Wax", "Deodorant" };

    // Not working.. clbKruidenierswaren is not static.
    List<string> items = clbKruidenierswaren.CheckedItems.Cast<string>().ToList();

    // Make form1 controls accessible for other classes?
    // Form1 form1 = Application.OpenForms.OfType<Form1>().FirstOrDefault();

}
}

but the I get the error

A field initializer cannot reference the non-static field, method, or property 'Form1.clbKruidenierswaren'.

Can you please direct me to a solution that works?

Body:
The problem is you're passing UI objects around, you should be passing data around instead.  Here's an example of a Form that can be given data during construction.

public class BaseForm : Form
{
    public object InitialisationData { get; set; }
}

public partial class MagicForm : BaseForm
{
    public string MyBindableGuy;

    public MagicForm()
    {
        InitializeComponent();

        MyBindableGuy = InitialisationData as string;
    }
}

and open it with:

var myForm = new MagicForm();
myForm.InitialisationData = "Hi, I'm a string.";
myForm.Show();


问:
colorchange animation for background
I Want to change background color slowly and use this code in css file:

```<code>body {
margin-top:60px;
font-family: sans-serif;
animation: colorchange 50s;
-webkit-animation: colorchange 50s;
     }

@keyframes colorchange{
    0%   {background: #FFCCff;}
   25%  {background: #FFFFCC;}
   50%  {background: #CCCC99;}
   75% {background: #CC9999}
   100%{background:#CCCCFF}
 }

  @-webkit-keyframes colorchange  {
     0%   {background:#FFCCFF;}
     25%  {background: #FFFFCC;}
    50%  {background:  #CCCC99;}
    75% {background: #CC9999;}
    100%{background:#CCCCFF;}
 }
</code>```

But I Want this change never stop ,How I can Do?

答:
Just add infinite to your property.

CSS3 animation Property

```<code>body {
margin-top:60px;
font-family: sans-serif;
animation: colorchange 50s infinite;
-webkit-animation: colorchange 50s infinite;
     }

@keyframes colorchange{
    0%   {background: #FFCCff;
   25%  {background: #FFFFCC;
   50%  {background: #CCCC99;
   75% {background: #CC9999
   100%{background:#CCCCFF
 }

  @-webkit-keyframes colorchange  {
     0%   {background:#FFCCFF;}
     25%  {background: #FFFFCC;}
    50%  {background:  #CCCC99;}
    75% {background: #CC9999}
    100%{background:#CCCCFF}
 }
</code>```

Title: colorchange animation for background

Body:
I Want to change background color slowly and use this code in css file:

body {
margin-top:60px;
font-family: sans-serif;
animation: colorchange 50s;
-webkit-animation: colorchange 50s;
     }

@keyframes colorchange{
    0%   {background: #FFCCff;}
   25%  {background: #FFFFCC;}
   50%  {background: #CCCC99;}
   75% {background: #CC9999}
   100%{background:#CCCCFF}
 }

  @-webkit-keyframes colorchange  {
     0%   {background:#FFCCFF;}
     25%  {background: #FFFFCC;}
    50%  {background:  #CCCC99;}
    75% {background: #CC9999;}
    100%{background:#CCCCFF;}
 }

But I Want this change never stop ,How I can Do?

Body:
Just add infinite to your property.

CSS3 animation Property

body {
margin-top:60px;
font-family: sans-serif;
animation: colorchange 50s infinite;
-webkit-animation: colorchange 50s infinite;
     }

@keyframes colorchange{
    0%   {background: #FFCCff;
   25%  {background: #FFFFCC;
   50%  {background: #CCCC99;
   75% {background: #CC9999
   100%{background:#CCCCFF
 }

  @-webkit-keyframes colorchange  {
     0%   {background:#FFCCFF;}
     25%  {background: #FFFFCC;}
    50%  {background:  #CCCC99;}
    75% {background: #CC9999}
    100%{background:#CCCCFF}
 }


问:
Using "Simple" XML Serialization to load data from res/raw on Android
I am new to Java and Android development, so please keep this in mind.  My goal is to deserialize data from xml files packaged into my application.  I'm attempting to do this using Simple 2.4 but I get an "Unhandled Exception type exception" error in the code when using .read or .write

My code looks something like this:

```<code>import java.io.InputStream;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

public class ftRoster extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Load in all available ship files here
    }

    public void myClickHandler(View view)
    {

     InputStream iStream = getResources().openRawResource(R.raw.ship);
     Serializer serializer = new Persister();
     ShipSystem newSystem = serializer.read(ShipSystem.class, iStream);

 }
}
</code>```

And my class looks like this:

```<code>import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root
public class ShipSystem
{
 @Element
 public String id = null;

 @Element
 public boolean destroyed = false;

 @Element
 public int systemValue = 0;

}
</code>```

If I put a try / catch around it, of course the error goes away, but then the deserilization never occurs as well.  There is little discussion on Simple and the documentation makes it look as simple as C# serialization.  Any help would be appreciated on the problem.

A global view of what I'm wanting to do is have an xml file for each "shipSystem" and at the boot of application deserialize each one into it's own class instance and have all of these available in an array for lookup.

Thanks for taking the time to read and think about this.

答:
I've changed myClickHandler as follows to validate the xml first:

```<code>public void myClickHandler(View view)
{
    InputStream iStream = getResources().openRawResource(R.raw.system);
    Serializer serializer = new Persister();

    if(serializer.validate(ShipSystem.class, iStream))
    {
        ShipSystem newSystem = serializer.read(ShipSystem.class, iStream);
    }
}
</code>```

I've changed my class to appear like this:

```<code>import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root(name="system")
public class ShipSystem
{
    @Attribute
    public String id = "0";

    @Element
    public boolean destroyed = false;

    @Element
    public int systemValue = 0;

}
</code>```

and the xml I'm attempting to deserialize looks this:

```<code><?xml version="1.0" encoding="UTF-8"?>
<system id="0">
    <destroyed>false</destroyed>
    <systemValue>0</systemValue>
</system>
</code>```

It seems that any method used with serializer causes an Unhandled exception of type exception because my use of serializer.validate also causes the same problem.  Am I missing something required by SimpleXML?

Body:
I am new to Java and Android development, so please keep this in mind.  My goal is to deserialize data from xml files packaged into my application.  I'm attempting to do this using Simple 2.4 but I get an "Unhandled Exception type exception" error in the code when using .read or .write

My code looks something like this:

import java.io.InputStream;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

public class ftRoster extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Load in all available ship files here
    }

    public void myClickHandler(View view)
    {

     InputStream iStream = getResources().openRawResource(R.raw.ship);
     Serializer serializer = new Persister();
     ShipSystem newSystem = serializer.read(ShipSystem.class, iStream);

 }
}

And my class looks like this:

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root
public class ShipSystem
{
 @Element
 public String id = null;

 @Element
 public boolean destroyed = false;

 @Element
 public int systemValue = 0;

}

If I put a try / catch around it, of course the error goes away, but then the deserilization never occurs as well.  There is little discussion on Simple and the documentation makes it look as simple as C# serialization.  Any help would be appreciated on the problem.

A global view of what I'm wanting to do is have an xml file for each "shipSystem" and at the boot of application deserialize each one into it's own class instance and have all of these available in an array for lookup.

Thanks for taking the time to read and think about this.

Body:
I've changed myClickHandler as follows to validate the xml first:

public void myClickHandler(View view)
{
    InputStream iStream = getResources().openRawResource(R.raw.system);
    Serializer serializer = new Persister();

    if(serializer.validate(ShipSystem.class, iStream))
    {
        ShipSystem newSystem = serializer.read(ShipSystem.class, iStream);
    }
}

I've changed my class to appear like this:

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root(name="system")
public class ShipSystem
{
    @Attribute
    public String id = "0";

    @Element
    public boolean destroyed = false;

    @Element
    public int systemValue = 0;

}

and the xml I'm attempting to deserialize looks this:

<?xml version="1.0" encoding="UTF-8"?>
<system id="0">
    <destroyed>false</destroyed>
    <systemValue>0</systemValue>
</system>

It seems that any method used with serializer causes an Unhandled exception of type exception because my use of serializer.validate also causes the same problem.  Am I missing something required by SimpleXML?


Title: Python - split a list into many lists in a for loop

Body:
May be this can help.

byte = ['1636 19 02 2F', '1637 19 02 2F', '1631 19 02 2F']

for temp in byte :
    for list in temp.split(' '):
        list = [list]

Output :

['1636']
['19']
['02']
['2F']
['1637']
['19']
['02']
['2F']
['1631']
['19']
['02']
['2F']


问:
Running two projects at once in Visual Studio Code
I develop web project. Server is node.js application written in TypeScript. Client also written in Typescript. I need two ability:

to compile different projects with different compiler options in different folders.

to debug both projects at the same time.

How can I do this?

答:
See our documentation on multitarget debugging: https://code.visualstudio.com/Docs/editor/debugging#_multitarget-debugging

In your launch.json, just create a compounds section that contains the targets you want to debug

```<code>{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Server",
            "program": "${workspaceRoot}/server.js",
            "cwd": "${workspaceRoot}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Client",
            "program": "${workspaceRoot}/client.js",
            "cwd": "${workspaceRoot}"
        }
    ],
    "compounds": [
        {
            "name": "Server/Client",
            "configurations": ["Server", "Client"]
        }
    ]
}
</code>```

Body:
See our documentation on multitarget debugging: https://code.visualstudio.com/Docs/editor/debugging#_multitarget-debugging

In your launch.json, just create a compounds section that contains the targets you want to debug

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Server",
            "program": "${workspaceRoot}/server.js",
            "cwd": "${workspaceRoot}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Client",
            "program": "${workspaceRoot}/client.js",
            "cwd": "${workspaceRoot}"
        }
    ],
    "compounds": [
        {
            "name": "Server/Client",
            "configurations": ["Server", "Client"]
        }
    ]
}


问:
Saltstack get grains of a minion in orchestration
I'm using salt-cloud to deploy VMs and I'm trying to get them registred in my DNS with the Saltstack Reactor system.

I have a reactor.conf with this trigger:

```<code>reactor:
  - 'salt/cloud/*/created':           # Add a VM
    - /srv/reactor/initialize_vm.sls
</code>```

initilize_vm.sls :

```<code>invoke_orchestrate_add_to_dns:
  runner.state.orchestrate:
    - mods: orch.add_to_dns
    - pillar:
        event_name: {{ name }}
        event_profile: {{ profile }}
</code>```

orch/add_to_dns.sls:

```<code>{% set name = pillar['event_name'] %}
{% set profile = pillar['event_profile'] %}

vm-add-dns-{{ name }}:
  sqlite3.row_present:
    - db: /var/lib/powerdns/pdns.sqlite3
    - table: records
    - where_sql: "name='{{ name }}' and type='A'"
    - data:
        domain_id: 1
        name: {{ name }}
        type: A
        content: {{ ??? }}
        ttl: 300
        prio: 0
        disabled: 0
</code>```

I just need to know the IP address of the new minion. But as the orchestration run on the master, I can't just do a content: {{ grains['fqdn_ip4'] }}.

Any ideas to get minions informations ?

答:
You can use the Salt Mine to get information from minions. To use the Salt Mine you need to know which minion you want to have information from. Luckily the reactor receives the data from the event bus. data['id'] contains the minion ID.

In the Salt Mine you can add a function to retrieve a minions IP like this:

```<code>mine_functions:
  public_ip4:
    - mine_function: grains.get
    - fqdn_ip4
</code>```

Now you can use mine.get in your sls files to get the IP address from a minion. In your case it will be the minion ID you just received from the event bus like this:

```<code>{%- for server, addrs in salt['mine.get'](data['id']', 'public_ip4') %}
  {{ addrs[0] }}
{% endfor %}
</code>```

Notes:

I don't use Salt Cloud and orchestration for DNS so I can't combine
your code with mine and check if it works. I hope it will be useful
for you :)

I named the mine public_ip4 instead of fqdn_ip4. It's to

clarify that this is a name in the Salt Mine and not the Grain you

are requesting.

Body:
I'm using salt-cloud to deploy VMs and I'm trying to get them registred in my DNS with the Saltstack Reactor system.

I have a reactor.conf with this trigger:

reactor:
  - 'salt/cloud/*/created':           # Add a VM
    - /srv/reactor/initialize_vm.sls

initilize_vm.sls :

invoke_orchestrate_add_to_dns:
  runner.state.orchestrate:
    - mods: orch.add_to_dns
    - pillar:
        event_name: {{ name }}
        event_profile: {{ profile }}

orch/add_to_dns.sls:

{% set name = pillar['event_name'] %}
{% set profile = pillar['event_profile'] %}

vm-add-dns-{{ name }}:
  sqlite3.row_present:
    - db: /var/lib/powerdns/pdns.sqlite3
    - table: records
    - where_sql: "name='{{ name }}' and type='A'"
    - data:
        domain_id: 1
        name: {{ name }}
        type: A
        content: {{ ??? }}
        ttl: 300
        prio: 0
        disabled: 0

I just need to know the IP address of the new minion. But as the orchestration run on the master, I can't just do a content: {{ grains['fqdn_ip4'] }}.

Any ideas to get minions informations ?

Body:
You can use the Salt Mine to get information from minions. To use the Salt Mine you need to know which minion you want to have information from. Luckily the reactor receives the data from the event bus. data['id'] contains the minion ID.

In the Salt Mine you can add a function to retrieve a minions IP like this:

mine_functions:
  public_ip4:
    - mine_function: grains.get
    - fqdn_ip4

Now you can use mine.get in your sls files to get the IP address from a minion. In your case it will be the minion ID you just received from the event bus like this:

{%- for server, addrs in salt['mine.get'](data['id']', 'public_ip4') %}
  {{ addrs[0] }}
{% endfor %}

Notes:

I don't use Salt Cloud and orchestration for DNS so I can't combine
your code with mine and check if it works. I hope it will be useful
for you :)

I named the mine public_ip4 instead of fqdn_ip4. It's to

clarify that this is a name in the Salt Mine and not the Grain you

are requesting.


问:
How to remove a header from express req object?
I'm trying to figure out how to remove header from req object in express. I believe this res.disable("Header Name") removes it from res object, but same doesn't work for req.headers

答:
You can simply delete headers from your request object, like i am doing below-

```<code>console.log(req.headers)

// { host: 'localhost:8081',
//   connection: 'keep-alive',
//   auth_token: 'c79d2f80029c1a1382b2e831643e5447b902a6f9',
//   'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36',
//   'postman-token': 'b2cef620-f85d-556c-acc1-8337da2d5e81',
//   'cache-control': 'no-cache',
//   api_key: 'FB499A4FF77901AFCD2278457658B7F7B17EAC112B489DAA304D3F2A059DFCC4',
//   'content-type': 'application/json',
//   accept: '*/*',
//   dnt: '1',
//   'accept-encoding': 'gzip, deflate, sdch, br',
//   'accept-language': 'en-US,en;q=0.8' }

// Now Delete the headers from your request object.

delete req.headers;

console.log(req.headers) // undefined
</code>```

If you want to remove any key from header then use below code:

```<code>delete req.headers['auth_token'];
</code>```

Body:
You can simply delete headers from your request object, like i am doing below-

console.log(req.headers)

// { host: 'localhost:8081',
//   connection: 'keep-alive',
//   auth_token: 'c79d2f80029c1a1382b2e831643e5447b902a6f9',
//   'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36',
//   'postman-token': 'b2cef620-f85d-556c-acc1-8337da2d5e81',
//   'cache-control': 'no-cache',
//   api_key: 'FB499A4FF77901AFCD2278457658B7F7B17EAC112B489DAA304D3F2A059DFCC4',
//   'content-type': 'application/json',
//   accept: '*/*',
//   dnt: '1',
//   'accept-encoding': 'gzip, deflate, sdch, br',
//   'accept-language': 'en-US,en;q=0.8' }

// Now Delete the headers from your request object.

delete req.headers;

console.log(req.headers) // undefined

If you want to remove any key from header then use below code:

delete req.headers['auth_token'];


问:
var in class gives error

Possible Duplicate:

  Using var outside of a method

```<code>class A {
string X;
}
// Proper
class A {
var X;
}
// Improper (gives error)
</code>```

Why is it, that i cant have var type variable declare in Class and what can be done in order to achieve it OR what is an alternative ?

In function/method, i can declare a var type variable,then why can't, i do it in class ?

Thanks.

答:
var in C# is a implicitly typed local variable used to infer the type from the RHS of the given expression, which needs to be resolved at compile time. When you declare a var with no RHS value in the class definition, there is no way for the compiler to know the type that you are trying to assign to var.

C# doesn't support implicit typing for class variables.

Title: var in class gives error

Body:
Possible Duplicate:

  Using var outside of a method

class A {
string X;
}
// Proper
class A {
var X;
}
// Improper (gives error)

Why is it, that i cant have var type variable declare in Class and what can be done in order to achieve it OR what is an alternative ?

In function/method, i can declare a var type variable,then why can't, i do it in class ?

Thanks.


问:
How to save .mat files of multiple files with their respective name
```<code>filename = ((fname{ind}) ,'.mat');
save((fname(ind)),'*.mat');
</code>```

where 'ind' is index of file name.I want to store result of each .wav file from workspace into .mat with respective .wav file name.

答:
Save('something.mat') alone will save all your workspace together in the .mat file. To do what (I think) you want you must loop through "ind" and edit your saving command:</p>

```<code>for ind = 1:X
filename = [fname{ind} '.mat']
save(filename,[fname{ind} '.wav']);
end
</code>```

Body:
filename = ((fname{ind}) ,'.mat');
save((fname(ind)),'*.mat');

where 'ind' is index of file name.I want to store result of each .wav file from workspace into .mat with respective .wav file name.

Body:
Save('something.mat') alone will save all your workspace together in the .mat file. To do what (I think) you want you must loop through "ind" and edit your saving command:

for ind = 1:X
filename = [fname{ind} '.mat']
save(filename,[fname{ind} '.wav']);
end


问:
React redux redirect after success post
I normally work as a Java programmer and I love the fact that with Java alot of the code design is standardized. For example you read Java example about Spring or Hibernate the code structurally looks the same for the whole world.

I am now working on ReactJS with redux and I just can't seem to understand it. Every example I have seen does everything completely different and it seams as if the entire JavaScript community just can't make up there minds on how to do something the same so I am hoping someone here can explain how ReactJS / redux works.

I have a login page and when I click on a button a http post must be done to a oauth2 auth server and on success a redirect must be done.

My Component works. It is LoginPage and I can confirm that when I click on the login button an action is called.

```<code>class LoginPage extends React.Component {
  render() {
    return (
      <div id="login-container">
        <LoginForm {...this.props} />
      </div>
    );
  }
}

const mapStateToProps = (state, ownProps) => {
  return {
  };
}

const mapDispatchToProps = (dispatch) => {
  return {
    handleSubmit: (evt) => {
      evt.preventDefault();

      performLogin(dispatch, evt.target.username.value, evt.target.password.value );
    }
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(LoginPage);
</code>```

The performLogin method is an action and my actions.js looks like this:

```<code>export function performLogin( dispatch, username, password ) {
    login(username, password).then(function (response) {
        dispatch({
            type: LOGIN_SUCCESS
        });
    })
    .catch(function (error) {
        dispatch({
            type: LOGIN_FAILURE
        });
    });
}
</code>```

The reducer looks like this:

```<code>const loginReducer = (state = initialState, action) => {
    switch (action.type) {
        case LOGIN_SUCCESS:
            return [
                ...state, {
                    auth: {
                        'login': true
                    }
                }
            ]
        case LOGIN_FAILURE:
            return [
                ...state, {
                    auth: {
                        'login': false
                    }
                }
            ]
        default:
            return state;
    }
};
</code>```

I have tried doing a axios post in the action but I got the error something like the action needs to be a plain object or something like that.

My question is where do you perform ajax calls and redirects in ReactJS/redux? In the action or the reducer?

This is a part of my packages.json:

```<code>"react": "^15.1.0",
"react-addons-test-utils": "^15.1.0",
"react-dom": "^15.1.0",
"react-redux": "^5.0.4",
"react-router": "^3.0.2",
"react-router-dom": "^4.1.1",
"react-router-redux": "^4.0.8",
"react-tap-event-plugin": "^2.0.1",
"redux": "^3.5.2",
"redux-form": "^6.8.0",
"redux-logger": "^2.6.1",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.1.0",
</code>```

答: Just use browserHistory.push("page-url"); method to change your route, after success promise

Title: React redux redirect after success post

Body:
I normally work as a Java programmer and I love the fact that with Java alot of the code design is standardized. For example you read Java example about Spring or Hibernate the code structurally looks the same for the whole world.

I am now working on ReactJS with redux and I just can't seem to understand it. Every example I have seen does everything completely different and it seams as if the entire JavaScript community just can't make up there minds on how to do something the same so I am hoping someone here can explain how ReactJS / redux works.

I have a login page and when I click on a button a http post must be done to a oauth2 auth server and on success a redirect must be done.

My Component works. It is LoginPage and I can confirm that when I click on the login button an action is called.

class LoginPage extends React.Component {
  render() {
    return (

        <LoginForm {...this.props} />

    );
  }
}

const mapStateToProps = (state, ownProps) => {
  return {
  };
}

const mapDispatchToProps = (dispatch) => {
  return {
    handleSubmit: (evt) => {
      evt.preventDefault();

      performLogin(dispatch, evt.target.username.value, evt.target.password.value );
    }
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(LoginPage);

The performLogin method is an action and my actions.js looks like this:

export function performLogin( dispatch, username, password ) {
    login(username, password).then(function (response) {
        dispatch({
            type: LOGIN_SUCCESS
        });
    })
    .catch(function (error) {
        dispatch({
            type: LOGIN_FAILURE
        });
    });
}

The reducer looks like this:

const loginReducer = (state = initialState, action) => {
    switch (action.type) {
        case LOGIN_SUCCESS:
            return [
                ...state, {
                    auth: {
                        'login': true
                    }
                }
            ]
        case LOGIN_FAILURE:
            return [
                ...state, {
                    auth: {
                        'login': false
                    }
                }
            ]
        default:
            return state;
    }
};

I have tried doing a axios post in the action but I got the error something like the action needs to be a plain object or something like that.

My question is where do you perform ajax calls and redirects in ReactJS/redux? In the action or the reducer?

This is a part of my packages.json:

"react": "^15.1.0",
"react-addons-test-utils": "^15.1.0",
"react-dom": "^15.1.0",
"react-redux": "^5.0.4",
"react-router": "^3.0.2",
"react-router-dom": "^4.1.1",
"react-router-redux": "^4.0.8",
"react-tap-event-plugin": "^2.0.1",
"redux": "^3.5.2",
"redux-form": "^6.8.0",
"redux-logger": "^2.6.1",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.1.0",


问:
Angular2 setting <textarea> as dirty when using placeholder text on IE 11
I did some R & D on this issue, same issue occurred with Angular1 as well and mostly people suggested that use ng-attr-placeholder, but there is no fix for this issue in Angular2.

I am asking about Angular2 not Angular1.

答:
I have found solution for this:

create a custom directive for placeholder text

TS:

```<code>import { Directive, ElementRef, Input } from '@angular/core';
import { NgControl } from "@angular/forms";
@Directive({
  selector: '[customPlaceholder]'
})
export class PlaceholderDirective {
  constructor(private el: ElementRef, private control : NgControl) { }
  @Input('customPlaceholder')
    public set defineInputType(pattern: string) {
        this.el.nativeElement.placeholder = pattern;
        setTimeout(() => {
            this.control.control.markAsPristine();
        }, 0);
    }
}
</code>```

and in your HTML

HTML:

```<code><textarea type="text" customPlaceholder="Message" class="form-control" formControlName="message" rows="10" >
</textarea>
</code>```

The thing is that it will set <textbox> back to pristine and it is achieved with setTimeOut. But for permanent solution angular team should look into it why IE is setting <textbox> to dirty.

Body:
I have found solution for this:

create a custom directive for placeholder text

TS:

import { Directive, ElementRef, Input } from '@angular/core';
import { NgControl } from "@angular/forms";
@Directive({
  selector: '[customPlaceholder]'
})
export class PlaceholderDirective {
  constructor(private el: ElementRef, private control : NgControl) { }
  @Input('customPlaceholder')
    public set defineInputType(pattern: string) {
        this.el.nativeElement.placeholder = pattern;
        setTimeout(() => {
            this.control.control.markAsPristine();
        }, 0);
    }
}

and in your HTML

HTML:

<textarea type="text" customPlaceholder="Message" class="form-control" formControlName="message" rows="10" >
</textarea>

The thing is that it will set <textbox> back to pristine and it is achieved with setTimeOut. But for permanent solution angular team should look into it why IE is setting <textbox> to dirty.

ContentLicense: CC BY-SA 4.0


问:
Put a string into dictionary Python
Basically, I have the following file:

```<code>Paris, 458 boulevard Saint-Germain
Paris, 343 boulevard Saint-Germain
Marseille, 343 boulevard Camille Flammarion
Marseille, 29 rue Camille Desmoulins
Marseille, 1 chemin des Aubagnens
Paris, 12 rue des singes
Paris, 34 quai VoLtAiRe
Paris, 34 rue Voltaire
Lille, 120 boulevard Victor Hugo
Marseille, 50 rue Voltaire
Toulouse, 90 rue Voltaire
Marseille, 78 boulevard de la libération
Lille, 30 rue Victor Danel
Mont Saint Martin, 42 rue de Lyon
Mont de Marsan, 100 avenue Pierre de Coubertin
Strasbourg, 391 boulevard de Nancy
Lyon, 56 rue du Docteur Albéric Pont
Lille, 90 rue d'Arras
Lille, 76 impasse Georges Pompidou
Lyon, 2 allée des fleurs
</code>```

Let's consider the first line

```<code>Paris, 458 boulevard Saint-Germain
</code>```

I'd like to split that string and then add 'Paris' as a key in a dictionary, and add "468 boulevard Saint-Germain" as a value.

Then, the following line is

```<code>Paris, 343 boulevard Saint-Germain
</code>```

As I already have Paris in my dictionary, I'd like to add "343 boulevard Saint-Germain" as a second value for Paris.

So far I have the following code:

```<code>import os, sys
import functions

class Addresses:

    def __init__(self):

        self.city = ""
        self.address = ""

addresses = {}

print("Hello")
userInput = input("Type a key : ")
if userInput == 'q':
    line = functions.myReadline(sys.argv[1])
    for line in line:
        addresses[line] = Addresses()
        addresses[line].city = line.split(',')
        addresses[line].address = line.split(',')
    for address in addresses.values():
        print("{0} : adresse correspondante {1}".format(address.city, address.address))
else:
    print("non")
</code>```

Basically I want {0} to be the city and {1} to be the address. But when I execute it, here is what it gives to me:

```<code>Hello
Type a key : q
['Paris', ' 458 boulevard Saint-Germain'] : adresse correspondante ['Paris', ' 458 boulevard Saint-Germain']
['Paris', ' 343 boulevard Saint-Germain'] : adresse correspondante ['Paris', ' 343 boulevard Saint-Germain']
['Marseille', ' 343 boulevard Camille Flammarion'] : adresse correspondante ['Marseille', ' 343 boulevard Camille Flammarion']
['Marseille', ' 29 rue Camille Desmoulins'] : adresse correspondante ['Marseille', ' 29 rue Camille Desmoulins']
['Marseille', ' 1 chemin des Aubagnens'] : adresse correspondante ['Marseille', ' 1 chemin des Aubagnens']
['Paris', ' 12 rue des singes'] : adresse correspondante ['Paris', ' 12 rue des singes']
['Paris', ' 34 quai VoLtAiRe'] : adresse correspondante ['Paris', ' 34 quai VoLtAiRe']
['Paris', ' 34 rue Voltaire'] : adresse correspondante ['Paris', ' 34 rue Voltaire']
['Lille', ' 120 boulevard Victor Hugo'] : adresse correspondante ['Lille', ' 120 boulevard Victor Hugo']
['Marseille', ' 50 rue Voltaire'] : adresse correspondante ['Marseille', ' 50 rue Voltaire']
['Toulouse', ' 90 rue Voltaire'] : adresse correspondante ['Toulouse', ' 90 rue Voltaire']
['Marseille', ' 78 boulevard de la libération'] : adresse correspondante ['Marseille', ' 78 boulevard de la libération']
['Lille', ' 30 rue Victor Danel'] : adresse correspondante ['Lille', ' 30 rue Victor Danel']
['Mont Saint Martin', ' 42 rue de Lyon'] : adresse correspondante ['Mont Saint Martin', ' 42 rue de Lyon']
['Mont de Marsan', ' 100 avenue Pierre de Coubertin'] : adresse correspondante ['Mont de Marsan', ' 100 avenue Pierre de Coubertin']
['Strasbourg', ' 391 boulevard de Nancy'] : adresse correspondante ['Strasbourg', ' 391 boulevard de Nancy']
['Lyon', ' 56 rue du Docteur Albéric Pont'] : adresse correspondante ['Lyon', ' 56 rue du Docteur Albéric Pont']
['Lille', " 90 rue d'Arras"] : adresse correspondante ['Lille', " 90 rue d'Arras"]
['Lille', ' 76 impasse Georges Pompidou'] : adresse correspondante ['Lille', ' 76 impasse Georges Pompidou']
['Lyon', ' 2 allée des fleurs'] : adresse correspondante ['Lyon', ' 2 allée des fleurs']
</code>```

Could you please help? Thanks

答:
I don't know if for line in line gives you any naming convention conflicts but it probably does

I reworked the structure because yours might already be flawed in terms of logic, and since it is a pretty short piece of code, so this should probably solve your problem:

```<code>dictionary = {}

for line in lines:
    city_and_address = line.split(",")
    if city_and_address[0] in dictionary:
        dictionary[city_and_address[0]].append(city_and_address[1])
    else:
        dictionary[city_and_address[0]] = [city_and_address[1]]
</code>```

Title: Put a string into dictionary Python

Body:
Basically, I have the following file:

Paris, 458 boulevard Saint-Germain
Paris, 343 boulevard Saint-Germain
Marseille, 343 boulevard Camille Flammarion
Marseille, 29 rue Camille Desmoulins
Marseille, 1 chemin des Aubagnens
Paris, 12 rue des singes
Paris, 34 quai VoLtAiRe
Paris, 34 rue Voltaire
Lille, 120 boulevard Victor Hugo
Marseille, 50 rue Voltaire
Toulouse, 90 rue Voltaire
Marseille, 78 boulevard de la libération
Lille, 30 rue Victor Danel
Mont Saint Martin, 42 rue de Lyon
Mont de Marsan, 100 avenue Pierre de Coubertin
Strasbourg, 391 boulevard de Nancy
Lyon, 56 rue du Docteur Albéric Pont
Lille, 90 rue d'Arras
Lille, 76 impasse Georges Pompidou
Lyon, 2 allée des fleurs

Let's consider the first line

Paris, 458 boulevard Saint-Germain

I'd like to split that string and then add 'Paris' as a key in a dictionary, and add "468 boulevard Saint-Germain" as a value.

Then, the following line is

Paris, 343 boulevard Saint-Germain

As I already have Paris in my dictionary, I'd like to add "343 boulevard Saint-Germain" as a second value for Paris.

So far I have the following code:

import os, sys
import functions

class Addresses:

    def __init__(self):

        self.city = ""
        self.address = ""

addresses = {}

print("Hello")
userInput = input("Type a key : ")
if userInput == 'q':
    line = functions.myReadline(sys.argv[1])
    for line in line:
        addresses[line] = Addresses()
        addresses[line].city = line.split(',')
        addresses[line].address = line.split(',')
    for address in addresses.values():
        print("{0} : adresse correspondante {1}".format(address.city, address.address))
else:
    print("non")

Basically I want {0} to be the city and {1} to be the address. But when I execute it, here is what it gives to me:

Hello
Type a key : q
['Paris', ' 458 boulevard Saint-Germain'] : adresse correspondante ['Paris', ' 458 boulevard Saint-Germain']
['Paris', ' 343 boulevard Saint-Germain'] : adresse correspondante ['Paris', ' 343 boulevard Saint-Germain']
['Marseille', ' 343 boulevard Camille Flammarion'] : adresse correspondante ['Marseille', ' 343 boulevard Camille Flammarion']
['Marseille', ' 29 rue Camille Desmoulins'] : adresse correspondante ['Marseille', ' 29 rue Camille Desmoulins']
['Marseille', ' 1 chemin des Aubagnens'] : adresse correspondante ['Marseille', ' 1 chemin des Aubagnens']
['Paris', ' 12 rue des singes'] : adresse correspondante ['Paris', ' 12 rue des singes']
['Paris', ' 34 quai VoLtAiRe'] : adresse correspondante ['Paris', ' 34 quai VoLtAiRe']
['Paris', ' 34 rue Voltaire'] : adresse correspondante ['Paris', ' 34 rue Voltaire']
['Lille', ' 120 boulevard Victor Hugo'] : adresse correspondante ['Lille', ' 120 boulevard Victor Hugo']
['Marseille', ' 50 rue Voltaire'] : adresse correspondante ['Marseille', ' 50 rue Voltaire']
['Toulouse', ' 90 rue Voltaire'] : adresse correspondante ['Toulouse', ' 90 rue Voltaire']
['Marseille', ' 78 boulevard de la libération'] : adresse correspondante ['Marseille', ' 78 boulevard de la libération']
['Lille', ' 30 rue Victor Danel'] : adresse correspondante ['Lille', ' 30 rue Victor Danel']
['Mont Saint Martin', ' 42 rue de Lyon'] : adresse correspondante ['Mont Saint Martin', ' 42 rue de Lyon']
['Mont de Marsan', ' 100 avenue Pierre de Coubertin'] : adresse correspondante ['Mont de Marsan', ' 100 avenue Pierre de Coubertin']
['Strasbourg', ' 391 boulevard de Nancy'] : adresse correspondante ['Strasbourg', ' 391 boulevard de Nancy']
['Lyon', ' 56 rue du Docteur Albéric Pont'] : adresse correspondante ['Lyon', ' 56 rue du Docteur Albéric Pont']
['Lille', " 90 rue d'Arras"] : adresse correspondante ['Lille', " 90 rue d'Arras"]
['Lille', ' 76 impasse Georges Pompidou'] : adresse correspondante ['Lille', ' 76 impasse Georges Pompidou']
['Lyon', ' 2 allée des fleurs'] : adresse correspondante ['Lyon', ' 2 allée des fleurs']

Could you please help? Thanks

Body:
I don't know if for line in line gives you any naming convention conflicts but it probably does

I reworked the structure because yours might already be flawed in terms of logic, and since it is a pretty short piece of code, so this should probably solve your problem:

dictionary = {}

for line in lines:
    city_and_address = line.split(",")
    if city_and_address[0] in dictionary:
        dictionary[city_and_address[0]].append(city_and_address[1])
    else:
        dictionary[city_and_address[0]] = [city_and_address[1]]


问:
Proper way to populate dropdownlist based off another value?
I'm running into a minor issue with some ASP.Net code I'm working on. For simplicity sake lets say I have two dropdownlists, one that is full of various items and another that is full of other items, but based off the selected item of the first dropdownlist. I currently set variables into hidden inputs to check to see if the item in the first dropdownlist has changed and if it has to change the second dropdownlist, but I'm also having to check to make sure that if something else causes a postback to NOT repopulate the second dropdownlist as to not lose what is currently selected by the user. This check also allows me to make sure that when I navigate away from the page, the correct values are selected and not something replaced by a postback repopulation.

I'm new to ASP.Net/HTML/CSS/Javascript and the like. I know while what I have works, it isn't even close to being the correct way to do things. Please help me correct my ways and figure out the BEST way to solve this current problem. Some good ASP.Net tutorial websites would be nice too as I need to keep improving my skills with it.

答:
Try autopostback true with the selected index changed event:

```<code><asp:DropDownList ID="DropDownList1" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server" />
<asp:DropDownList ID="DropDownList2" runat="server" />
</code>```

And have the event populate the second dropdown:

```<code>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
</code>```

EDIT
Well if you need it to populate from first page load you could do the following, or better still make a method which is called from both page load and selected index changed which will populate your dropdown.

```<code>if (!Page.IsPostBack)
{
   DropDownList1_SelectedIndexChanged(DropDownList1, EventArgs.Empty);
}
</code>```

Body:
Try autopostback true with the selected index changed event:

<asp:DropDownList ID="DropDownList1" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server" />
<asp:DropDownList ID="DropDownList2" runat="server" />

And have the event populate the second dropdown:

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}

EDIT
Well if you need it to populate from first page load you could do the following, or better still make a method which is called from both page load and selected index changed which will populate your dropdown.

if (!Page.IsPostBack)
{
   DropDownList1_SelectedIndexChanged(DropDownList1, EventArgs.Empty);
}


问:
How to create data in Json format for highcharts
I am getting below result through ajax and the data which I get in ajax success is

```<code>[{
  "plants_ref_id": "1",
  "plant_name": "MCW",
  "employees_data": "6,6,80,70,60,30,2,3,12,12,37.00,60.00,64666.666667,8000.0000"
},{
  "plants_ref_id": "3",
  "plant_name": "SJCPL",
  "employees_data": "4,5,6,7,7,7,6,4,4,5,20.00,3.00,176923.076923,38461.5385"
}]
</code>```

I am trying to convert this data to format

```<code>[{
  name: 'MCW',
  data: [6,6,80,70,60,30,2,3,12,12,37.00,60.00,64666.666667,8000.0000
]},{
  name: 'SJCPL',
  data: [4,5,6,7,7,7,6,4,4,5,20.00,3.00,176923.076923,38461.5385]
}]
</code>```

I am trying to convert to this format for generating highcharts as https://jsfiddle.net/mcj075jf/

How do I convert to the above format in jQuery using for loop or $.each. Please help.

答:
You can use map as follows:

var plants = [{
  "plants_ref_id": "1",
  "plant_name": "MCW",
  "employees_data": "6,6,80,70,60,30,2,3,12,12,37.00,60.00,64666.666667,8000.0000"
},{
  "plants_ref_id": "3",
  "plant_name": "SJCPL",
  "employees_data": "4,5,6,7,7,7,6,4,4,5,20.00,3.00,176923.076923,38461.5385"
}];

var formattedData = plants.map((plant) => ({
  name: plant.plant_name,
  data: plant.employees_data.split(',').map((data) => parseFloat(data))
}));

console.log(formattedData);```

Body:
I am getting below result through ajax and the data which I get in ajax success is

[{
  "plants_ref_id": "1",
  "plant_name": "MCW",
  "employees_data": "6,6,80,70,60,30,2,3,12,12,37.00,60.00,64666.666667,8000.0000"
},{
  "plants_ref_id": "3",
  "plant_name": "SJCPL",
  "employees_data": "4,5,6,7,7,7,6,4,4,5,20.00,3.00,176923.076923,38461.5385"
}]

I am trying to convert this data to format

[{
  name: 'MCW',
  data: [6,6,80,70,60,30,2,3,12,12,37.00,60.00,64666.666667,8000.0000
]},{
  name: 'SJCPL',
  data: [4,5,6,7,7,7,6,4,4,5,20.00,3.00,176923.076923,38461.5385]
}]

I am trying to convert to this format for generating highcharts as https://jsfiddle.net/mcj075jf/

How do I convert to the above format in jQuery using for loop or $.each. Please help.


问:
The csvtojson converter ignores my file name and just puts undefined
Basically, when I just run csvtojson module on node.js without any code, it works perfectly. But once I put it into the function, it just comes out with undefined even though my file path is still there.

Js code:

```<code>var Converter = require("csvtojson").Converter;
// create a new converter object
var converter = new Converter({});
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://localhost:27017/myproject';

// call the fromFile function which takes in the path to your
// csv file as well as a callback function

var  woops;

var createNewEntries = function(db, woops, callback) {

converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
                   New_2017.csv",function(err, result){
    // if an error has occured then handle it
    if(err){
        console.log("An Error Has Occured");
        console.log(err);
    }
    // the result of the conversion
        console.log(result);
        console.log('ohhhhh');
        woops=result;
});
console.log(woops);
};
    MongoClient.connect(url, function(err, db) {
        if(err) {
            console.log(err);
        }
        setTimeout(function(){
        createNewEntries(db, woops, function(){
            if(err)
                throw err;
            else{
                console.log(woops);
            }
            db.close();
        });
        },2000);

    });
</code>```

This is just testing out whether it converts inside a function and it just shows

undefined
[]
ohhhhh
without converting at all when in a function. So exactly what did I do wrong. By right it should have convert after calling the function. Does it have to do with my code executing before the function ? I already put a setTimeout just to give it some time to do so I assume it shouldn't have to do with the order of my code. Thanks in advance!

答:
According to your output,

```<code>undefined
[]
ohhhhh
</code>```

```<code>var  woops;

var createNewEntries = function(db, woops, callback) {

converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
                   New_2017.csv",function(err, result){
    // if an error has occured then handle it
    if(err){
        console.log("An Error Has Occured");
        console.log(err);
    }
    // the result of the conversion
        console.log(result);        // This is getting printed second
        console.log('ohhhhh');      // This is getting printed third
        woops=result;
});
console.log(woops);                 // This is getting printed first
};
    MongoClient.connect(url, function(err, db) {
        if(err) {
            console.log(err);
        }
        setTimeout(function(){
        createNewEntries(db, woops, function(){
            if(err)
                throw err;
            else{
                console.log(woops); // This is useless!
            }
            db.close();
        });
        },2000);

    });
</code>```

You can clearly see this as woops variable is just declared so it must be having undefined value. And something before ohhhhh must be the result variable.

Now, this definitely means that at least the woops variable is not getting printed after ohhhh or rather, the createNewEntries is getting executed or is returning the result after console.log(woops) is being executed which that means your setTimeout()'s time is not sufficient.

And why are you even using the callback and passing it a function when you're not even using it??? Use this instead-

```<code>var  woops;

var createNewEntries = function(db, woops) {

converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
                   New_2017.csv",function(err, result){
    // if an error has occured then handle it
    if(err){
        console.log("An Error Has Occured");
        console.log(err);
    }
    // the result of the conversion
        console.log(result);
        console.log('ohhhhh');
        woops=result;
}).then(console.log(woops));
};

MongoClient.connect(url, function(err, db) {
        if(err) {
            console.log(err);
        }
        createNewEntries(db, woops);
});
</code>```

Body:
Basically, when I just run csvtojson module on node.js without any code, it works perfectly. But once I put it into the function, it just comes out with undefined even though my file path is still there.

Js code:

var Converter = require("csvtojson").Converter;
// create a new converter object
var converter = new Converter({});
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://localhost:27017/myproject';

// call the fromFile function which takes in the path to your
// csv file as well as a callback function

var  woops;

var createNewEntries = function(db, woops, callback) {

converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
                   New_2017.csv",function(err, result){
    // if an error has occured then handle it
    if(err){
        console.log("An Error Has Occured");
        console.log(err);
    }
    // the result of the conversion
        console.log(result);
        console.log('ohhhhh');
        woops=result;
});
console.log(woops);
};
    MongoClient.connect(url, function(err, db) {
        if(err) {
            console.log(err);
        }
        setTimeout(function(){
        createNewEntries(db, woops, function(){
            if(err)
                throw err;
            else{
                console.log(woops);
            }
            db.close();
        });
        },2000);

    });

This is just testing out whether it converts inside a function and it just shows

undefined
[]
ohhhhh
without converting at all when in a function. So exactly what did I do wrong. By right it should have convert after calling the function. Does it have to do with my code executing before the function ? I already put a setTimeout just to give it some time to do so I assume it shouldn't have to do with the order of my code. Thanks in advance!

Body:
According to your output,

undefined
[]
ohhhhh

var  woops;

var createNewEntries = function(db, woops, callback) {

converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
                   New_2017.csv",function(err, result){
    // if an error has occured then handle it
    if(err){
        console.log("An Error Has Occured");
        console.log(err);
    }
    // the result of the conversion
        console.log(result);        // This is getting printed second
        console.log('ohhhhh');      // This is getting printed third
        woops=result;
});
console.log(woops);                 // This is getting printed first
};
    MongoClient.connect(url, function(err, db) {
        if(err) {
            console.log(err);
        }
        setTimeout(function(){
        createNewEntries(db, woops, function(){
            if(err)
                throw err;
            else{
                console.log(woops); // This is useless!
            }
            db.close();
        });
        },2000);

    });

You can clearly see this as woops variable is just declared so it must be having undefined value. And something before ohhhhh must be the result variable.

Now, this definitely means that at least the woops variable is not getting printed after ohhhh or rather, the createNewEntries is getting executed or is returning the result after console.log(woops) is being executed which that means your setTimeout()'s time is not sufficient.

And why are you even using the callback and passing it a function when you're not even using it??? Use this instead-

var  woops;

var createNewEntries = function(db, woops) {

converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
                   New_2017.csv",function(err, result){
    // if an error has occured then handle it
    if(err){
        console.log("An Error Has Occured");
        console.log(err);
    }
    // the result of the conversion
        console.log(result);
        console.log('ohhhhh');
        woops=result;
}).then(console.log(woops));
};

MongoClient.connect(url, function(err, db) {
        if(err) {
            console.log(err);
        }
        createNewEntries(db, woops);
});


问:
iOS Charts library - not able to bind data to chart view
I am using charts library and want to display a bar chart. I am facing issue for binding the data to the chart.This is my code.

```<code>class FirstViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

@IBOutlet weak var barChartView: BarChartView!
@IBOutlet weak var yearDropDown: UIPickerView!

@IBOutlet weak var rmDropDown: UIPickerView!

@IBOutlet weak var txtYear: UITextField!
@IBOutlet weak var txtRm: UITextField!

var months = [String]()

override func viewDidLoad() {
super.viewDidLoad()

        months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]

        getYear()
        setChart(dataPoints: months, values: unitsSold)

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func getYear()
{
    url = RestMonitorServer.baseUrl + "/foo/bar"
    Alamofire.request(url, method: .get, parameters: ["foo": bar,"foo":bar,"foo":bar])
        .responseJSON(){
    (response) in
            print("get year list response ",response)

            if ((response.result.value) != nil) {
                let jsonData = JSON(response.result.value!)

                if jsonData["duration"].arrayObject != nil {
                    self.durationArray.append("duration")
                    print("duration array ", self.durationArray)
                }

            } else if (((response.error)) != nil) {
                let jsonError = response.error
                print("Error in getting year list ", jsonError as Any)
            }

    }

}

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {

    return durationArray.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

    if pickerView == yearDropDown {

        let titleRow = durationArray[row]

        return titleRow
    }
    return ""
}

func setChart(dataPoints: [String], values: [Double]) {

    var dataEntries: [BarChartDataEntry] = []

    for i in 0..<dataPoints.count {
        let dataEntry = BarChartDataEntry(x:values[i],y:Double(i))
        dataEntries.append(dataEntry)
    }
    print("data entries ",dataEntries)
    let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold")
    print("chart data set ", chartDataSet)
    let chartData = BarChartData(dataSets: [chartDataSet])
    print("chart data ",chartData)
    barChartView.data = chartData //error at this line as fatal error: unexpectedly found nil while unwrapping an Optional value
    print("bar chart data" , barChartView.data!)
}
</code>```

}

This is my full code. And I am getting error for barChartView which I have initialised as above, but it still giving me error.

Thanks

答:
As per my exp you need to move your function to BarChartView extension like below :

```<code>extension BarChartView {

    func setBarChartData(xValues: [String], yValues: [Double], label: String) {

        var dataEntries: [BarChartDataEntry] = []

        for i in 0..<yValues.count {
            let dataEntry = BarChartDataEntry(x: Double(i), y: yValues[i])
            dataEntries.append(dataEntry)
        }

        let chartDataSet = BarChartDataSet(values: dataEntries, label: label)
        let chartData = BarChartData(dataSets: [chartDataSet])

        self.data = chartData

    }
}
</code>```

and Call it like below :

```<code>override func viewDidLoad() {
        super.viewDidLoad()
        barChartView.setBarChartData(xValues: months, yValues: unitsSold, label: "Monthly Sales")
}
</code>```

Try this and let me know is it working or not.

Also one more thing you are setting static data of months & values my question is where are you filling server response data ?

Body:
I am using charts library and want to display a bar chart. I am facing issue for binding the data to the chart.This is my code.

class FirstViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

@IBOutlet weak var barChartView: BarChartView!
@IBOutlet weak var yearDropDown: UIPickerView!

@IBOutlet weak var rmDropDown: UIPickerView!

@IBOutlet weak var txtYear: UITextField!
@IBOutlet weak var txtRm: UITextField!

var months = [String]()

override func viewDidLoad() {
super.viewDidLoad()

        months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]

        getYear()
        setChart(dataPoints: months, values: unitsSold)

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func getYear()
{
    url = RestMonitorServer.baseUrl + "/foo/bar"
    Alamofire.request(url, method: .get, parameters: ["foo": bar,"foo":bar,"foo":bar])
        .responseJSON(){
    (response) in
            print("get year list response ",response)

            if ((response.result.value) != nil) {
                let jsonData = JSON(response.result.value!)

                if jsonData["duration"].arrayObject != nil {
                    self.durationArray.append("duration")
                    print("duration array ", self.durationArray)
                }

            } else if (((response.error)) != nil) {
                let jsonError = response.error
                print("Error in getting year list ", jsonError as Any)
            }

    }

}

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {

    return durationArray.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

    if pickerView == yearDropDown {

        let titleRow = durationArray[row]

        return titleRow
    }
    return ""
}

func setChart(dataPoints: [String], values: [Double]) {

    var dataEntries: [BarChartDataEntry] = []

    for i in 0..<dataPoints.count {
        let dataEntry = BarChartDataEntry(x:values[i],y:Double(i))
        dataEntries.append(dataEntry)
    }
    print("data entries ",dataEntries)
    let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold")
    print("chart data set ", chartDataSet)
    let chartData = BarChartData(dataSets: [chartDataSet])
    print("chart data ",chartData)
    barChartView.data = chartData //error at this line as fatal error: unexpectedly found nil while unwrapping an Optional value
    print("bar chart data" , barChartView.data!)
}

}

This is my full code. And I am getting error for barChartView which I have initialised as above, but it still giving me error.

Thanks

Body:
As per my exp you need to move your function to BarChartView extension like below :

extension BarChartView {

    func setBarChartData(xValues: [String], yValues: [Double], label: String) {

        var dataEntries: [BarChartDataEntry] = []

        for i in 0..<yValues.count {
            let dataEntry = BarChartDataEntry(x: Double(i), y: yValues[i])
            dataEntries.append(dataEntry)
        }

        let chartDataSet = BarChartDataSet(values: dataEntries, label: label)
        let chartData = BarChartData(dataSets: [chartDataSet])

        self.data = chartData

    }
}

and Call it like below :

override func viewDidLoad() {
        super.viewDidLoad()
        barChartView.setBarChartData(xValues: months, yValues: unitsSold, label: "Monthly Sales")
}

Try this and let me know is it working or not.

Also one more thing you are setting static data of months & values my question is where are you filling server response data ?


问:
how to call subactivity of another application android?
To call main activity I saw componentName class in android.

```<code>intent = new Intent(new ComponentName(packageNam,classname);
</code>```

if same is used in case of child activity, I got error ,
"is activity delcared in andorid manifest?" like error.

how to call app1 child activity in app2 by using intent ?
In app1 the activity is declared like this in manifest

```<code><activity android:name=".activity.MessageCompose" android:label="@string/app_name" android:enabled="false">
- <intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <action android:name="android.intent.action.SENDTO" />
  <data android:scheme="mailto" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
  </activity>
</code>```

答:
Read up on how intents work in Android. Since the component you're launching is in another app, you can't access the component directly. In short, you need some way to identify the app1 child activity with an intent filter, then call that from app2 using something like this:</p>

```<code>Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
</code>```

Body:
To call main activity I saw componentName class in android.

intent = new Intent(new ComponentName(packageNam,classname);

if same is used in case of child activity, I got error ,
"is activity delcared in andorid manifest?" like error.

how to call app1 child activity in app2 by using intent ?
In app1 the activity is declared like this in manifest

<activity android:name=".activity.MessageCompose" android:label="@string/app_name" android:enabled="false">
- <intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <action android:name="android.intent.action.SENDTO" />
  <data android:scheme="mailto" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
- <intent-filter android:label="@string/app_name">
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <data android:mimeType="*/*" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
  </activity>

Body:
Read up on how intents work in Android. Since the component you're launching is in another app, you can't access the component directly. In short, you need some way to identify the app1 child activity with an intent filter, then call that from app2 using something like this:

Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);


问:
Is it possible to enable keyboard navigation in PrimeNg ContextMenu?
I'm building a Angular 4 site using PrimeNg. Does anybody know if it's possible to implement keyboard navigation in the contextmenu. Any ideas on how?</p>

答:
you could capture keyboard and set some css styles to emulate focus</p>

```<code>@Component({
  ....
  host: {'(document:keydown)': 'handleKeyboardEvents($event)'}
})

  private handleKeyboardEvents(event: KeyboardEvent) {
    if (event.keyCode === 40 && MenuPressed) {//down
      //implement here your logic
</code>```

Body:
you could capture keyboard and set some css styles to emulate focus

@Component({
  ....
  host: {'(document:keydown)': 'handleKeyboardEvents($event)'}
})

  private handleKeyboardEvents(event: KeyboardEvent) {
    if (event.keyCode === 40 && MenuPressed) {//down
      //implement here your logic


问:
How to set build path configuration in spring boot webapp
I am in new to spring boot. I have created a web app using spring boot. My application require some properties file to do the processing. In eclipse What I do i set the path on Run configuration like bellow.

  Now When I run the application I gets the require file on path and run smoothly.
Now I want to deploy the war file on some server. How do i provide this path to my application.

Bellow is the project structure of my project. and files are here
highlighted

How do I set this file path using application.properties or any other way so that, I don't have to provide the path from run configuration, and the .war can be deploy on any server.

Update 1 : This what I tried.
Created a customStart.bat
content of the file is

```<code>set CATALINA_OPTS="-engine.home="/src/main/resources/" -Dlog4j.configuration=config/log4j.xml -Dlog4j.debug=true"
call startup.bat %CATALINA_OPTS%
</code>```

But still that argument is not set. How do I do that?

答:
As an option you can add your properties to %tomcat_home%\conf\catalina.properties

Just put them at the end of the file as follows:

log4j.configuration=config/log4j.xml
.....

Body:
I am in new to spring boot. I have created a web app using spring boot. My application require some properties file to do the processing. In eclipse What I do i set the path on Run configuration like bellow.

  Now When I run the application I gets the require file on path and run smoothly.
Now I want to deploy the war file on some server. How do i provide this path to my application.

Bellow is the project structure of my project. and files are here
highlighted

How do I set this file path using application.properties or any other way so that, I don't have to provide the path from run configuration, and the .war can be deploy on any server.

Update 1 : This what I tried.
Created a customStart.bat
content of the file is

set CATALINA_OPTS="-engine.home="/src/main/resources/" -Dlog4j.configuration=config/log4j.xml -Dlog4j.debug=true"
call startup.bat %CATALINA_OPTS%

But still that argument is not set. How do I do that?


问:
Tiki: Unexpected return from trackerlib -> get_item_creators
I upgraded my tiki from 15.4 to 16.2. Everything runs fine. The problem is the site registration does not work. I have a tracker to extend my user information. In the tracker, I created a field called "Network" that allows the users to choose a group that them want to be in. Hence, they won't see each other content due to different group permission. This registration broke. The error message showed:

Cannot add nonexistent user xxx to group students

I found out the problem was that there is a change in trackerlib.php line 3671. Instead of returning "null", it now returns an empty array().

```<code>else {
    return array();
}
</code>```

In GroupSelector.php, line 124, the condition check

```<code>if (empty ($creators))) $creators=array($user);
</code>```

This if will never be executed since the function now return an array not null. Hence causing the problem that no one can be registered if they choose a group in the registration form.

Propose solution, change the if condition in line 124 to:

```<code>if (empty($creators[0]))
</code>```

答: My fix has now been improved by our colleague kroky6 (thanks!) and is now in the 16.x branch, so you can test it by using the 16.x nightly tarball from here tomorrow and will be in 16.3 (and 17.0 onwards) coming soon...

Body:
I upgraded my tiki from 15.4 to 16.2. Everything runs fine. The problem is the site registration does not work. I have a tracker to extend my user information. In the tracker, I created a field called "Network" that allows the users to choose a group that them want to be in. Hence, they won't see each other content due to different group permission. This registration broke. The error message showed:

Cannot add nonexistent user xxx to group students

I found out the problem was that there is a change in trackerlib.php line 3671. Instead of returning "null", it now returns an empty array().

else {
    return array();
}

In GroupSelector.php, line 124, the condition check

if (empty ($creators))) $creators=array($user);

This if will never be executed since the function now return an array not null. Hence causing the problem that no one can be registered if they choose a group in the registration form.

Propose solution, change the if condition in line 124 to:

if (empty($creators[0]))


问:
How to get facebook friend list in ios?
I am trying this from the last two days but not getting any solution.
Please help me. i want to fetch the friend list of facebook friends, i am using this code

```<code>loginButton.readPermissions =
    @[@"public_profile", @"email", @"user_friends", @"read_custom_friendlists"];

if ([FBSDKAccessToken currentAccessToken]) {
        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error) {
                 NSLog(@"fetched user:%@", result);
             }
         }];

         FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:@"/me/taggable_friends"
                              parameters:@{@"fields": @"id, name"}
                              HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    NSLog(@"%@",result);
}];

    }

   but in the response i am getting :

fetched user:{
    id = 102045934964446131;
    name = "xyz zyz";
}
      id = "AaKwxUJHqY8miA_dKdOIEoDc1NDF4nTw_K4s-JKAYvFqDdyXYe_dsOyDiUuKPh285CNlc5pAvtHhD7K9PbrpfP8pZmsYwujUenNjdfrUOkrm8g";
        name = "Anshul Katiyar";
    },
            {
        id = "AaLx7VNhGwdmA0vyZjy-Ry7II2kEVeQweLp54HiJC2TU5yIN6Qkl-aT811aqm0aea6pjRy-amUTz3gEXanjuQIKvHXiu-cICJ-VXjnchyL1kug";
        name = "Madhu Verma";

    },
            {
        id = "AaLPkAwYvi6aFu8uTgLfTc0QAbS1tlSM600NF07QOezuwEibLjp8Tq2N7TFKuUrXrwsTmAY5bFhtxEg6XmcVJMZ1xLhrQiMR_hNasPsCpiPpYQ";
        name = "Manojsharma Manojsharma";
    },
            {
        id = "AaIyxf6jtQT_c05h3JdJ18pWNYwRYREKf2A5hIiz9qdp-ehXbvYkwMgTbqF4RptgiyxgdUObU8tLcKDTt2JNpPOWFrXty00OsbMqBrK_Up0Xpg";
        name = "Aarti Tripathi";
    },
            {
        id = "AaJPoNnjzzIT6ELXyl56NTpkGx7xtT5J1wf_WOsX4BD4AFvDTcAOt0sn9m51VaJhSTDwC7eUkU7Gw5hPBHyZn8YxsD9HpwgGnZzxnE7yN853jA";
        name = "Vaibhaw Singh";
    },
            {
        id = AaJE5GA9QFr7oD8KY3Gak4h5aJqrHHHh4WYWKWCvpg97V2HSDm8UjSuygfMMg08QIDPWe20qRqY4eP3R9N82AhJ9Lzg1TpjzNdDZsJoy1hWrmg;
        name = "Saurabh Verma";
    },
            {
        id = "AaKGTx-vlLOyuNExGrlcqoFpwQRMtAHqwtCeuslQfriLeN8pDyB0D_qQeIpIULSIcwVB2fGltbOkMW9Mp94AzX2Y2egxgJw0lAHRCE45DJlkIg";
        name = "Udit Katiyar Nitiya";
    }
);
paging =     {
    cursors =         {
        after = QWFMRWdjYUM1aVlpYW00U2t6Ym5oUnpqdW0tdm1xZA2RSQTc3dk16N1d3WnNEaG81Q2V1ekNTRHNCSEtjYjVPam1XbGZAVRGE0UGsxSEdxZADJZAZAkkwX3BHYlZAodGFBQmNPUmlYWTRfNUtkeVVLUmcZD;
        before = QWFJLXktdTVqeEFOR05ueHRWSWE4eWs0WE5nQVJUN0o5eC03YWVpcW10YkRObjMtNmZAXeTRXTDh5WUNrLV9tQnZAiWWdOSFNrVk8wZATl5a3ZAYWVpsRUxDVnpORG5POG1jZAlpIbm5DS0FFcHZAxb3cZD;
    };
    next = "https://graph.facebook.com/v2.9/10204593496146131/taggable_friends?access_token=EAAasBqLeUy0BAIRjZCZBlRXD4Hleg3J8712Drm5BZA6DC3bvLZCcPy6iklwPi77ymOoj888GjZBhyWdZAyI4nK1hSr2D1ZAvpTjYrc4L2cVZAVuYoeRe39mxVPczuH5GZBHHngGIoTAPv5AdnXPjsybJlt2t4fAmRFGaw8ZC1GiJHLtZCsbYEyvsKYCpGCaWJNNVOFcwUZBaKwM5xZB9DoJw7wFzL&fields=id%2C+name&limit=25&after=QWFMRWdjYUM1aVlpYW00U2t6Ym5oUnpqdW0tdm1xZA2RSQTc3dk16N1d3WnNEaG81Q2V1ekNTRHNCSEtjYjVPam1XbGZAVRGE0UGsxSEdxZADJZAZAkkwX3BHYlZAodGFBQmNPUmlYWTRfNUtkeVVLUmcZD";
};
</code>```

i am getting this output but this is not the full list of friends i want full list how to get that list.
i want to get the email, name and id of all the friends.
I have total friends of 267 but not showing any details of the friends.
 please help.

Thanks In advance

答:
Here is my working code to get friends from Facebook. Hope it will help you.</p>

```<code>-(void)getFacebookFriend
{
    if (FBSession.activeSession.isOpen)
    {
           [self ListFriend];
    }
    else
    {
        NSArray *permissions = [[NSArray alloc] initWithObjects:@"email",@"user_friends",@"public_profile", nil];

        [FBSession openActiveSessionWithReadPermissions:permissions
                                           allowLoginUI:YES
                                      completionHandler:
         ^(FBSession *session,
           FBSessionState state, NSError *error) {
             if(!error)
             {

                 [SVProgressHUD showWithStatus:PLEASE_WAIT];
                 [self performSelector:@selector(ListFriend) withObject:nil afterDelay:0.2];
             }
             else
                 [SVProgressHUD dismiss];
         }];
    }
}
-(void)ListFriend
{

    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setObject:@"id, first_name, last_name, middle_name, name, email, picture" forKey:@"fields"];
    [params setObject:[NSString stringWithFormat:@"500"] forKey:@"limit"];
    if(_strPageToken.length > 0)
    {
        [params setObject:_strPageToken forKey:@"paging_token"];
        [params setObject:_strUntill forKey:@"until"];

    }

    [[FBRequest requestWithGraphPath:@"me/taggable_friends" parameters:params HTTPMethod:nil] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
     {
         NSArray *aryFriend = result[@"data"];
         [_aryContact addObjectsFromArray:aryFriend];
         NSLog(@"%lu",(unsigned long)aryFriend.count);
         NSMutableDictionary *dicPaging = result[@"paging"];

         if(dicPaging[@"next"])
         {

             _strNextURL = [NSString stringWithFormat:@"%@",dicPaging[@"next"]];
         }
         else
         {
             NSLog(@"Final Array count:    %lu",(unsigned long)_aryContact.count);
         }
     }];
}
</code>```

Title: How to get facebook friend list in ios?

Body:
I am trying this from the last two days but not getting any solution.
Please help me. i want to fetch the friend list of facebook friends, i am using this code

loginButton.readPermissions =
    @[@"public_profile", @"email", @"user_friends", @"read_custom_friendlists"];

if ([FBSDKAccessToken currentAccessToken]) {
        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error) {
                 NSLog(@"fetched user:%@", result);
             }
         }];

         FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:@"/me/taggable_friends"
                              parameters:@{@"fields": @"id, name"}
                              HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    NSLog(@"%@",result);
}];

    }

   but in the response i am getting :

fetched user:{
    id = 102045934964446131;
    name = "xyz zyz";
}
      id = "AaKwxUJHqY8miA_dKdOIEoDc1NDF4nTw_K4s-JKAYvFqDdyXYe_dsOyDiUuKPh285CNlc5pAvtHhD7K9PbrpfP8pZmsYwujUenNjdfrUOkrm8g";
        name = "Anshul Katiyar";
    },
            {
        id = "AaLx7VNhGwdmA0vyZjy-Ry7II2kEVeQweLp54HiJC2TU5yIN6Qkl-aT811aqm0aea6pjRy-amUTz3gEXanjuQIKvHXiu-cICJ-VXjnchyL1kug";
        name = "Madhu Verma";

    },
            {
        id = "AaLPkAwYvi6aFu8uTgLfTc0QAbS1tlSM600NF07QOezuwEibLjp8Tq2N7TFKuUrXrwsTmAY5bFhtxEg6XmcVJMZ1xLhrQiMR_hNasPsCpiPpYQ";
        name = "Manojsharma Manojsharma";
    },
            {
        id = "AaIyxf6jtQT_c05h3JdJ18pWNYwRYREKf2A5hIiz9qdp-ehXbvYkwMgTbqF4RptgiyxgdUObU8tLcKDTt2JNpPOWFrXty00OsbMqBrK_Up0Xpg";
        name = "Aarti Tripathi";
    },
            {
        id = "AaJPoNnjzzIT6ELXyl56NTpkGx7xtT5J1wf_WOsX4BD4AFvDTcAOt0sn9m51VaJhSTDwC7eUkU7Gw5hPBHyZn8YxsD9HpwgGnZzxnE7yN853jA";
        name = "Vaibhaw Singh";
    },
            {
        id = AaJE5GA9QFr7oD8KY3Gak4h5aJqrHHHh4WYWKWCvpg97V2HSDm8UjSuygfMMg08QIDPWe20qRqY4eP3R9N82AhJ9Lzg1TpjzNdDZsJoy1hWrmg;
        name = "Saurabh Verma";
    },
            {
        id = "AaKGTx-vlLOyuNExGrlcqoFpwQRMtAHqwtCeuslQfriLeN8pDyB0D_qQeIpIULSIcwVB2fGltbOkMW9Mp94AzX2Y2egxgJw0lAHRCE45DJlkIg";
        name = "Udit Katiyar Nitiya";
    }
);
paging =     {
    cursors =         {
        after = QWFMRWdjYUM1aVlpYW00U2t6Ym5oUnpqdW0tdm1xZA2RSQTc3dk16N1d3WnNEaG81Q2V1ekNTRHNCSEtjYjVPam1XbGZAVRGE0UGsxSEdxZADJZAZAkkwX3BHYlZAodGFBQmNPUmlYWTRfNUtkeVVLUmcZD;
        before = QWFJLXktdTVqeEFOR05ueHRWSWE4eWs0WE5nQVJUN0o5eC03YWVpcW10YkRObjMtNmZAXeTRXTDh5WUNrLV9tQnZAiWWdOSFNrVk8wZATl5a3ZAYWVpsRUxDVnpORG5POG1jZAlpIbm5DS0FFcHZAxb3cZD;
    };
    next = "https://graph.facebook.com/v2.9/10204593496146131/taggable_friends?access_token=EAAasBqLeUy0BAIRjZCZBlRXD4Hleg3J8712Drm5BZA6DC3bvLZCcPy6iklwPi77ymOoj888GjZBhyWdZAyI4nK1hSr2D1ZAvpTjYrc4L2cVZAVuYoeRe39mxVPczuH5GZBHHngGIoTAPv5AdnXPjsybJlt2t4fAmRFGaw8ZC1GiJHLtZCsbYEyvsKYCpGCaWJNNVOFcwUZBaKwM5xZB9DoJw7wFzL&fields=id%2C+name&limit=25&after=QWFMRWdjYUM1aVlpYW00U2t6Ym5oUnpqdW0tdm1xZA2RSQTc3dk16N1d3WnNEaG81Q2V1ekNTRHNCSEtjYjVPam1XbGZAVRGE0UGsxSEdxZADJZAZAkkwX3BHYlZAodGFBQmNPUmlYWTRfNUtkeVVLUmcZD";
};

i am getting this output but this is not the full list of friends i want full list how to get that list.
i want to get the email, name and id of all the friends.
I have total friends of 267 but not showing any details of the friends.
 please help.

Thanks In advance

Body:
Here is my working code to get friends from Facebook. Hope it will help you.

-(void)getFacebookFriend
{
    if (FBSession.activeSession.isOpen)
    {
           [self ListFriend];
    }
    else
    {
        NSArray *permissions = [[NSArray alloc] initWithObjects:@"email",@"user_friends",@"public_profile", nil];

        [FBSession openActiveSessionWithReadPermissions:permissions
                                           allowLoginUI:YES
                                      completionHandler:
         ^(FBSession *session,
           FBSessionState state, NSError *error) {
             if(!error)
             {

                 [SVProgressHUD showWithStatus:PLEASE_WAIT];
                 [self performSelector:@selector(ListFriend) withObject:nil afterDelay:0.2];
             }
             else
                 [SVProgressHUD dismiss];
         }];
    }
}
-(void)ListFriend
{

    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setObject:@"id, first_name, last_name, middle_name, name, email, picture" forKey:@"fields"];
    [params setObject:[NSString stringWithFormat:@"500"] forKey:@"limit"];
    if(_strPageToken.length > 0)
    {
        [params setObject:_strPageToken forKey:@"paging_token"];
        [params setObject:_strUntill forKey:@"until"];

    }

    [[FBRequest requestWithGraphPath:@"me/taggable_friends" parameters:params HTTPMethod:nil] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
     {
         NSArray *aryFriend = result[@"data"];
         [_aryContact addObjectsFromArray:aryFriend];
         NSLog(@"%lu",(unsigned long)aryFriend.count);
         NSMutableDictionary *dicPaging = result[@"paging"];

         if(dicPaging[@"next"])
         {

             _strNextURL = [NSString stringWithFormat:@"%@",dicPaging[@"next"]];
         }
         else
         {
             NSLog(@"Final Array count:    %lu",(unsigned long)_aryContact.count);
         }
     }];
}


问:
Angular 4 GET 403 response
I write an app in Angular 4 that calls a REST API (DJANGO).
The code is as followed:

```<code>export class ForecastUnitService {

private path = 'forecastunit/';
private options;
constructor (private http: Http, private c:CentralService) {
this.options=this.c.createOptions();
}

getForecastUnits(): Observable<ForecastUnit[]> {
return this.http.get(this.c.createURL(this.path),this.options)
  .map(this.extractData)
  .catch(this.handleError);
}
...
}
</code>```

I add options that contains an authorization header, but still I get
a 403 forbidden. However when I try the call with cUrl or Postman or in swagger, with the same token I get results.
So first tought, the headers aren't correct but when I log options I get:

```<code>{"method":null,"headers":{"Authorization":["**Correct Token**"],"Content-Type":["application/json"]},"body":null,"url":null,"withCredentials":null,"responseType":null}
</code>```

So that is not the problem, when I look in the response from Chrome I see the following:

```<code>{"detail":"Authentication credentials were not provided."}
</code>```

So again no credentials, but I really passed them, what is going wrong?

答:
Angular's http module changes all header names to lowercase. This might be an issue because some API services aren't following the spec and their header checks are case-sensitive when these should be case-insensitive.

Check the configuration of your API.

I assume that your CentralService creates valid options.

```<code>interface RequestOptionsArgs {
  url: string|null
  method: string|RequestMethod|null
  search: string|URLSearchParams|{[key: string]: any | any[]}|null
  params: string|URLSearchParams|{[key: string]: any | any[]}|null
  headers: Headers|null
  body: any
  withCredentials: boolean|null
  responseType: ResponseContentType|null
}
</code>```

Headers:

```<code>class Headers {
  static fromResponseHeaderString(headersString: string): Headers
  constructor(headers?: Headers|{[name: string]: any}|null)
  append(name: string, value: string): void
  delete(name: string): void
  forEach(fn: (values: string[], name: string|undefined, headers: Map<string, string[]>) => void): void
  get(name: string): string|null
  has(name: string): boolean
  keys(): string[]
  set(name: string, value: string|string[]): void
  values(): string[][]
  toJSON(): {[name: string]: any}
  getAll(name: string): string[]|null
  entries()
}
</code>```

Title: Angular 4 GET 403 response

Body:
I write an app in Angular 4 that calls a REST API (DJANGO).
The code is as followed:

export class ForecastUnitService {

private path = 'forecastunit/';
private options;
constructor (private http: Http, private c:CentralService) {
this.options=this.c.createOptions();
}

getForecastUnits(): Observable<ForecastUnit[]> {
return this.http.get(this.c.createURL(this.path),this.options)
  .map(this.extractData)
  .catch(this.handleError);
}
...
}

I add options that contains an authorization header, but still I get
a 403 forbidden. However when I try the call with cUrl or Postman or in swagger, with the same token I get results.
So first tought, the headers aren't correct but when I log options I get:

{"method":null,"headers":{"Authorization":["**Correct Token**"],"Content-Type":["application/json"]},"body":null,"url":null,"withCredentials":null,"responseType":null}

So that is not the problem, when I look in the response from Chrome I see the following:

{"detail":"Authentication credentials were not provided."}

So again no credentials, but I really passed them, what is going wrong?

Body:
Angular's http module changes all header names to lowercase. This might be an issue because some API services aren't following the spec and their header checks are case-sensitive when these should be case-insensitive.

Check the configuration of your API.

I assume that your CentralService creates valid options.

interface RequestOptionsArgs {
  url: string|null
  method: string|RequestMethod|null
  search: string|URLSearchParams|{[key: string]: any | any[]}|null
  params: string|URLSearchParams|{[key: string]: any | any[]}|null
  headers: Headers|null
  body: any
  withCredentials: boolean|null
  responseType: ResponseContentType|null
}

Headers:

class Headers {
  static fromResponseHeaderString(headersString: string): Headers
  constructor(headers?: Headers|{[name: string]: any}|null)
  append(name: string, value: string): void
  delete(name: string): void
  forEach(fn: (values: string[], name: string|undefined, headers: Map<string, string[]>) => void): void
  get(name: string): string|null
  has(name: string): boolean
  keys(): string[]
  set(name: string, value: string|string[]): void
  values(): string[][]
  toJSON(): {[name: string]: any}
  getAll(name: string): string[]|null
  entries()
}