问:
Espresso : How to get the exact TextView from an LinearLayout?
I have started using Espresso for automating my tests and the problem I face is, am not able to match the exact textview from my xml file.

Sample xml be like:

```<code>xmlns:app="http://schemas.xx.com/apk/res-auto"

android:id="@+id/filter_sort_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="2dp">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:layout_marginEnd="10dp"
    android:layout_marginStart="10dp"
    android:animateLayoutChanges="true"
    android:shrinkColumns="0">

    <TableRow>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/dropdown_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="5dp"
                android:clickable="true"
                android:ellipsize="end"
                android:focusable="true"
                android:gravity="center_vertical"
                android:maxLines="1"
                android:paddingBottom="15dp"
                android:paddingEnd="5dp"
                android:paddingTop="15dp"
                android:textColor="@color/colorAccent" />

            <android.support.v7.widget.AppCompatImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginTop="3dp"
                app:srcCompat="@drawable/ic_triangle" />
        </LinearLayout>
</code>```

Am trying to check whether the id 'dropdown_title' is present and have to get the text from it. Code I used:

```<code>    onView(allOf(
    withId(R.id.dropdown_title),
    withParent(withId(R.id.filter_sort_layout)))).
    check(matches(isDisplayed();
</code>```

But, it throws me error saying,

'android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with id: xx.debug:id/dropdown_title and has parent matching: with id: xx/filter_sort_layout)

View Hierarchy:

```<code>    +>DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
    |
    +->LinearLayout{id=-1, visibility=VISIBLE, width=1080, height=1776, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
    |
    +-->ViewStub{id=16909227, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
    |
    +-->FrameLayout{id=-1, visibility=VISIBLE, width=1080, height=1704, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=72.0, child-count=1}
    |
    +--->FitWindowsLinearLayout{id=2131820663, res-name=action_bar_root, visibility=VISIBLE, width=1080, height=1704, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
    |'
</code>```

I have tried using descendantOfA() and also hasSibling() methods. Doesn't work. Please help me out.

答:
I think your current code is failing because dropdown_title is not an immediate child of filter_sort_layout.  Rather, dropdown_title is a descendant of filter_sort_layout.  Use isDescendantOfA instead:

```<code>onView(allOf(withId(R.id.dropdown_title),
       isDescendantOfA(withId(R.id.filter_sort_layout))))
    .check(matches(isDisplayed()));
</code>```

Edit:

From comments below it appears that the OP actually has multiples views in the app all with the same name.  The duplicate link covers how to handle this scenario.

Body:
I have started using Espresso for automating my tests and the problem I face is, am not able to match the exact textview from my xml file.

Sample xml be like:

xmlns:app="http://schemas.xx.com/apk/res-auto"

android:id="@+id/filter_sort_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="2dp">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:layout_marginEnd="10dp"
    android:layout_marginStart="10dp"
    android:animateLayoutChanges="true"
    android:shrinkColumns="0">

    <TableRow>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/dropdown_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="5dp"
                android:clickable="true"
                android:ellipsize="end"
                android:focusable="true"
                android:gravity="center_vertical"
                android:maxLines="1"
                android:paddingBottom="15dp"
                android:paddingEnd="5dp"
                android:paddingTop="15dp"
                android:textColor="@color/colorAccent" />

            <android.support.v7.widget.AppCompatImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginTop="3dp"
                app:srcCompat="@drawable/ic_triangle" />
        </LinearLayout>

Am trying to check whether the id 'dropdown_title' is present and have to get the text from it. Code I used:

    onView(allOf(
    withId(R.id.dropdown_title),
    withParent(withId(R.id.filter_sort_layout)))).
    check(matches(isDisplayed();

But, it throws me error saying,

'android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with id: xx.debug:id/dropdown_title and has parent matching: with id: xx/filter_sort_layout)

View Hierarchy:

    +>DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
    |
    +->LinearLayout{id=-1, visibility=VISIBLE, width=1080, height=1776, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
    |
    +-->ViewStub{id=16909227, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
    |
    +-->FrameLayout{id=-1, visibility=VISIBLE, width=1080, height=1704, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=72.0, child-count=1}
    |
    +--->FitWindowsLinearLayout{id=2131820663, res-name=action_bar_root, visibility=VISIBLE, width=1080, height=1704, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
    |'

I have tried using descendantOfA() and also hasSibling() methods. Doesn't work. Please help me out.

Body:
I think your current code is failing because dropdown_title is not an immediate child of filter_sort_layout.  Rather, dropdown_title is a descendant of filter_sort_layout.  Use isDescendantOfA instead:

onView(allOf(withId(R.id.dropdown_title),
       isDescendantOfA(withId(R.id.filter_sort_layout))))
    .check(matches(isDisplayed()));

Edit:

From comments below it appears that the OP actually has multiples views in the app all with the same name.  The duplicate link covers how to handle this scenario.


来源: stackexchange

问:
How to allow users to change their own passwords in Django?
Can any one point me to code where users can change their own passwords in Django?</p>

答:
This is the command i used, just in case you are having problem in that throw AttributeError: Manager isn't available; 'auth.User' has been swapped for 'users.User'.

```<code>python manage.py shell -c "from django.contrib.auth import get_user_model;
User = get_user_model();
u = User.objects.get(username='admin');
u.set_password('password123');
u.save()"
</code>```

ContentLicense: CC BY-SA 3.0

Body:
This is the command i used, just in case you are having problem in that throw AttributeError: Manager isn't available; 'auth.User' has been swapped for 'users.User'.

python manage.py shell -c "from django.contrib.auth import get_user_model;
User = get_user_model();
u = User.objects.get(username='admin');
u.set_password('password123');
u.save()"


问:
i want the link style like in the picture
html code:

```<code> <ul class="info-link">
   <li><a href="#"><i class="fa fa-map-marker"></i>  3588 N Stelling road, Brooklyn, NYC, United State.</a> </li>
   <li><a href="#"><i class="fa fa-phone"></i>  1900-167-168-99 EXT: 001</a></li>
   <li><a href="#"><i class="fa fa-mobile"></i>  (05) 132-564-3333</a></li>
   <li><a href="#"><i class="fa fa-envelope"></i>  logohere@support.com</a></li>
 </ul>
</code>```

css code :

```<code>ul li {
  list-style: none;
}
</code>```

result picture:
code-result

desire result picture:
desire-result

答:
Have a look:

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.parent {
  padding: 20px;
  width: 300px;
  background: #ddd;
}

.title {
  margin-top: 0;
  margin-bottom: 20px;
}

ul {
  list-style: none;
  padding-left: 0;
}

ul li {
  margin-bottom: 10px;
}

.inner {
  display: flex;
}

ul li i {
  min-width: 20px;
  text-align: center;
  margin-top: 2px;
  margin-right: 10px;
}

ul li a {
  text-decoration: none;
  color: #777;
}

ul li a:hover {
  color: #444;
}

.scaleup {
  display: inline-block;
  transform: scale(1.5);
}

.scaledown {
  display: inline-block;
  transform: scale(0.9);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="parent">

  <h3 class="title">Contact Info</h3>

  <ul class="info-link">
    <li>
     <div class="inner">
      <i class="fa fa-map-marker"></i>
      3588 N Stelling road, Brooklyn, NYC, United State.
     </div>
   </li>
    <li>
     <div class="inner">
      <i class="fa fa-phone"></i>
      1900-167-168-99 EXT: 001
     </div>
   </li>
    <li>
     <div class="inner">
      <i class="scaleup fa fa-mobile"></i>
      (05) 132-564-3333
     </div>
   </li>
    <li>
     <div class="inner">
      <i class="scaledown fa fa-envelope"></i>
      logohere@support.com
     </div>
   </li>
  </ul>

</div></code>```

Hope this helps!

Body:
html code:

  3588 N Stelling road, Brooklyn, NYC, United State.

  1900-167-168-99 EXT: 001

  (05) 132-564-3333

  logohere@support.com

css code :

ul li {
  list-style: none;
}

result picture:
code-result

desire result picture:
desire-result

Body:
Have a look:

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.parent {
  padding: 20px;
  width: 300px;
  background: #ddd;
}

.title {
  margin-top: 0;
  margin-bottom: 20px;
}

ul {
  list-style: none;
  padding-left: 0;
}

ul li {
  margin-bottom: 10px;
}

.inner {
  display: flex;
}

ul li i {
  min-width: 20px;
  text-align: center;
  margin-top: 2px;
  margin-right: 10px;
}

ul li a {
  text-decoration: none;
  color: #777;
}

ul li a:hover {
  color: #444;
}

.scaleup {
  display: inline-block;
  transform: scale(1.5);
}

.scaledown {
  display: inline-block;
  transform: scale(0.9);
}

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="parent">

  <h3 class="title">Contact Info</h3>

  <ul class="info-link">
    <li>
     <div class="inner">
      <i class="fa fa-map-marker"></i>
      <a href="">3588 N Stelling road, Brooklyn, NYC, United State.</a>
     </div>
   </li>
    <li>
     <div class="inner">
      <i class="fa fa-phone"></i>
      <a href="">1900-167-168-99 EXT: 001</a>
     </div>
   </li>
    <li>
     <div class="inner">
      <i class="scaleup fa fa-mobile"></i>
      <a href="">(05) 132-564-3333</a>
     </div>
   </li>
    <li>
     <div class="inner">
      <i class="scaledown fa fa-envelope"></i>
      <a href="">logohere@support.com</a>
     </div>
   </li>
  </ul>

</div>

Hope this helps!


问:
Add new rows to a gridview before submit to database
Good afternoon,

I'm developing a form to place orders online.

I get the article from a combobox and get the details of that article using a sql query. So far, so good.

I put that article to a gridview. For one article, it's all ok.

I make the selection of the article, click on insert button, and the article with the details is inserted on the gridview.

My problem is on how to add more rows. When i click the insert button, with a different article and details, i only get one row, with overwritten data.

After all rows are in the gridview, i finally can submit that rows and process the order.

What should i use to add so many rows as i need? ViewState? Session State?

I read some articles, but none of them helped me as i needed.

Thank you.

EDIT:

I use a datatable to store the data.

```<code> DataTable DT = new DataTable();

        DT.Columns.Add("Artigo");
        DT.Columns.Add("Descricao");
        DT.Columns.Add("IVA");
        DT.Columns.Add("PU");
        DT.Columns.Add("UN");
        DT.Columns.Add("Qtd");
        DT.Columns.Add("TotalLiq");

        try
        {
            int Qtd = Convert.ToInt32(Quantidade.Text);
            int PrecoUnit = glb._precolente;
            float TotalLiq = Qtd * PrecoUnit;

            string str = "SELECT TOP 1 A.Artigo as Artigo, A.Descricao as Descricao, (SELECT Taxa FROM prisalviani.dbo.Iva WHERE Iva = A.Iva)AS IVA, A.UnidadeBase as UN FROM prisalviani.dbo.ARTIGO A where A.Artigo='" + result.ToString() + "'";

            ListaLentes = Motor.Consulta(ref str);

            while (!ListaLentes.NoFim())
            {
                DT.Rows.Add(ListaLentes.Valor("Artigo"),
                            ListaLentes.Valor("Descricao"),
                            ListaLentes.Valor("IVA"),
                            PrecoUnit,
                ListaLentes.Valor("UN"),
                Qtd,
                TotalLiq
                );
                ListaLentes.Seguinte();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
</code>```

答:
Assuming that your datagridview holds 3 cells of type String,

You can use:

```<code>object [] row1 = new object[] { "StringInCell1","StringInCell2","StringInCell3" }
dataGridView.Rows.Add(row1);
</code>```

And if you need to edit a specific cell you can do it using:

```<code>dataGridView.Rows[rowIndex].Cells[cellIndex].Value = "newValue";
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Good afternoon,

I'm developing a form to place orders online.

I get the article from a combobox and get the details of that article using a sql query. So far, so good.

I put that article to a gridview. For one article, it's all ok.

I make the selection of the article, click on insert button, and the article with the details is inserted on the gridview.

My problem is on how to add more rows. When i click the insert button, with a different article and details, i only get one row, with overwritten data.

After all rows are in the gridview, i finally can submit that rows and process the order.

What should i use to add so many rows as i need? ViewState? Session State?

I read some articles, but none of them helped me as i needed.

Thank you.

EDIT:

I use a datatable to store the data.

 DataTable DT = new DataTable();

        DT.Columns.Add("Artigo");
        DT.Columns.Add("Descricao");
        DT.Columns.Add("IVA");
        DT.Columns.Add("PU");
        DT.Columns.Add("UN");
        DT.Columns.Add("Qtd");
        DT.Columns.Add("TotalLiq");

        try
        {
            int Qtd = Convert.ToInt32(Quantidade.Text);
            int PrecoUnit = glb._precolente;
            float TotalLiq = Qtd * PrecoUnit;

            string str = "SELECT TOP 1 A.Artigo as Artigo, A.Descricao as Descricao, (SELECT Taxa FROM prisalviani.dbo.Iva WHERE Iva = A.Iva)AS IVA, A.UnidadeBase as UN FROM prisalviani.dbo.ARTIGO A where A.Artigo='" + result.ToString() + "'";

            ListaLentes = Motor.Consulta(ref str);

            while (!ListaLentes.NoFim())
            {
                DT.Rows.Add(ListaLentes.Valor("Artigo"),
                            ListaLentes.Valor("Descricao"),
                            ListaLentes.Valor("IVA"),
                            PrecoUnit,
                ListaLentes.Valor("UN"),
                Qtd,
                TotalLiq
                );
                ListaLentes.Seguinte();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }

Body:
Assuming that your datagridview holds 3 cells of type String,

You can use:

object [] row1 = new object[] { "StringInCell1","StringInCell2","StringInCell3" }
dataGridView.Rows.Add(row1);

And if you need to edit a specific cell you can do it using:

dataGridView.Rows[rowIndex].Cells[cellIndex].Value = "newValue";


问:
Get the No of Pending, Accepted and Rejected Users from two tables
I have two tables namely register and expressinterest

Where register table contains (user related columns) some are -

```<code>i) matri_id (unique but not primary)

ii) mobile

iii) email

iv) last_login
</code>```

and expressinterest table contains data related to the matches details where columns are namely

```<code>i) ei_sender

ii) ei_receiver

iii) ei_response

iv) ei_sent_date
</code>```

I am comparing the matri_id of register table to ei_sender and ei_receiver of expressinterest table, where one user can send requests to another users and he can receive request from another users.

I have to get the count of Pending, Accepted and Rejected status of all the users present in the register table, but when I am running the query it's running very slow, It takes around 45-60 seconds to fetch only 5000 rows in which the data is not proper (a single ID is coming in 3 rows like Accepted in one row, Rejected in one row and Pending in one row), But I want all the counts to come in a single row like this

```<code>r.matri_id | r._email | r.mobile | pending_count | accepted_ count | rejected_count| r.last_login
</code>```

Some queries which I had tried so far are

```<code>select r.matri_id, r.email, r.mobile, r.last_login, e.receiver_response, count(e.receiver_response), e.ei_sender, e.ei_receiver from register r, expressinterest e where r.matri_id = e.ei_sender or r.matri_id = e.ei_receiver GROUP BY e.receiver_response, r.matri_id ORDER BY r.last_login DESC
</code>```

This is what I want but its taking 5-6 seconds to execute

```<code>select matri_id, email, mobile, last_login, (select count(ei_sender) from expressinterest where ei_receiver=matri_id and receiver_response = 'Pending') AS pending_count_mine,
(select count(ei_sender) from expressinterest where ei_sender=matri_id and receiver_response = 'Accepted') AS accepted_count,
(select count(ei_sender) from expressinterest where ei_sender=matri_id and receiver_response = 'Rejected') AS rejected_count FROM register ORDER BY last_login DESC
</code>```

Thanks

答:
You can replace the multiple correlated subqueries with a single subquery and a left join:</p>

```<code>select r.matri_id,
    r.email,
    r.mobile,
    r.last_login,
    t.accepted_count,
    t.rejected_count,
    t.pending_count
from register r
left join (
    select ei_sender,
        sum(receiver_response = 'Accepted') as accepted_count,
        sum(receiver_response = 'Rejected') as rejected_count,
        sum(receiver_response = 'Pending') as pending_count
    from expressinterest
    where receiver_response in ('Rejected', 'Accepted', 'Pending')
    group by ei_sender
    ) t on r.matri_id = t.ei_sender;
</code>```

Body:
I have two tables namely register and expressinterest

Where register table contains (user related columns) some are -

i) matri_id (unique but not primary)

ii) mobile

iii) email

iv) last_login

and expressinterest table contains data related to the matches details where columns are namely

i) ei_sender

ii) ei_receiver

iii) ei_response

iv) ei_sent_date

I am comparing the matri_id of register table to ei_sender and ei_receiver of expressinterest table, where one user can send requests to another users and he can receive request from another users.

I have to get the count of Pending, Accepted and Rejected status of all the users present in the register table, but when I am running the query it's running very slow, It takes around 45-60 seconds to fetch only 5000 rows in which the data is not proper (a single ID is coming in 3 rows like Accepted in one row, Rejected in one row and Pending in one row), But I want all the counts to come in a single row like this

r.matri_id | r._email | r.mobile | pending_count | accepted_ count | rejected_count| r.last_login

Some queries which I had tried so far are

select r.matri_id, r.email, r.mobile, r.last_login, e.receiver_response, count(e.receiver_response), e.ei_sender, e.ei_receiver from register r, expressinterest e where r.matri_id = e.ei_sender or r.matri_id = e.ei_receiver GROUP BY e.receiver_response, r.matri_id ORDER BY r.last_login DESC

This is what I want but its taking 5-6 seconds to execute

select matri_id, email, mobile, last_login, (select count(ei_sender) from expressinterest where ei_receiver=matri_id and receiver_response = 'Pending') AS pending_count_mine,
(select count(ei_sender) from expressinterest where ei_sender=matri_id and receiver_response = 'Accepted') AS accepted_count,
(select count(ei_sender) from expressinterest where ei_sender=matri_id and receiver_response = 'Rejected') AS rejected_count FROM register ORDER BY last_login DESC

Thanks

Body:
You can replace the multiple correlated subqueries with a single subquery and a left join:

select r.matri_id,
    r.email,
    r.mobile,
    r.last_login,
    t.accepted_count,
    t.rejected_count,
    t.pending_count
from register r
left join (
    select ei_sender,
        sum(receiver_response = 'Accepted') as accepted_count,
        sum(receiver_response = 'Rejected') as rejected_count,
        sum(receiver_response = 'Pending') as pending_count
    from expressinterest
    where receiver_response in ('Rejected', 'Accepted', 'Pending')
    group by ei_sender
    ) t on r.matri_id = t.ei_sender;


问:
rxjs/Subject.d.ts error : Class 'Subject<T>' incorrectly extends base class 'Observable<T>'
I extracted sample template code from this tutorial and did below two steps to get started -

npm install // worked fine and created node_modules folder with all dependencies

npm start
// failed with below error-

```<code>node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>'
  incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
  Type '<T, R>(operator: Operator<T, R>) => Observable<T>' is not assignable
  to type '<R>(operator: Operator<T, R>) => Observable<R>'.
  Type 'Observable<T>' is not assignable to type 'Observable<R>'.
  Type 'T' is not assignable to type 'R'.
  npm ERR! code ELIFECYCLE
  npm ERR! errno 2
</code>```

I see that in the subject.d.ts declaration of lift is as below -

```<code> lift<T, R>(operator: Operator<T, R>): Observable<T>;
</code>```

And in Observable.ts it is defined as below-

```<code> lift<R>(operator: Operator<T, R>): Observable<R> {
</code>```

Note:-
1. I am new to Angular2 and trying to get hold of things.

The error might be due to incompatible definitions of lift method

I read through this github thread

If I need to install some different version of rxjs then please tell how to uninstall and install the correct rxjs.

Edit1:
I might be a bit late in responding here but I still get the same error even after using typescript 2.3.4 or rxjs 6 alpha. Below is my package.json,

```<code>{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "@angular/upgrade": "2.0.0",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "6.0.0-alpha.0",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.23",
    "angular2-in-memory-web-api": "0.0.20",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.2",
    "typescript": "2.3.4",
    "typings": "^1.3.2"
  }
}
</code>```

答:
Keep the noStrictGeneric option true in tsconfig.config file </p>

```<code>{
    "compilerOptions": {
        "noStrictGenericChecks": true
    }
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I extracted sample template code from this tutorial and did below two steps to get started -

npm install // worked fine and created node_modules folder with all dependencies

npm start
// failed with below error-

node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>'
  incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
  Type '<T, R>(operator: Operator<T, R>) => Observable<T>' is not assignable
  to type '<R>(operator: Operator<T, R>) => Observable<R>'.
  Type 'Observable<T>' is not assignable to type 'Observable<R>'.
  Type 'T' is not assignable to type 'R'.
  npm ERR! code ELIFECYCLE
  npm ERR! errno 2

I see that in the subject.d.ts declaration of lift is as below -

 lift<T, R>(operator: Operator<T, R>): Observable<T>;

And in Observable.ts it is defined as below-

 lift<R>(operator: Operator<T, R>): Observable<R> {

Note:-
1. I am new to Angular2 and trying to get hold of things.

The error might be due to incompatible definitions of lift method

I read through this github thread

If I need to install some different version of rxjs then please tell how to uninstall and install the correct rxjs.

Edit1:
I might be a bit late in responding here but I still get the same error even after using typescript 2.3.4 or rxjs 6 alpha. Below is my package.json,

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "@angular/upgrade": "2.0.0",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "6.0.0-alpha.0",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.23",
    "angular2-in-memory-web-api": "0.0.20",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.2",
    "typescript": "2.3.4",
    "typings": "^1.3.2"
  }
}

Body:
Keep the noStrictGeneric option true in tsconfig.config file

{
    "compilerOptions": {
        "noStrictGenericChecks": true
    }
}


问:
Instagram Login - How do they do it without even going to the Instagram website?
I've seen some Instagram likers and other tools like follow unfollow apps, login and get access to an instagram account without redirecting to instagram's website.
I mean they have their own custom form built and they ask us to login with our instagram innit.

How do they do that? Does Instagram API allow that? And how do they beat the limit? I heard that instagram has an API limit of Max 5000 calls per day and 2000 follows. But they follow like a ton of people in the same website. How'd they do it?

Below are some examples of Instagram logins that I've used my fake accounts with (I'm sure nobody wanna get their accounts hacked)

答:
They are not using the official but the internal instagram API. This means that they simulate an android or iOS device and login with your credentials so instagram thinks you are logged in from a mobile device. This gives you access to all instagram features (like, follow, upload photo and video and etc)! There are a lot of unofficial instagram APIs on github that do exactly this.

They also use a proxy for each account so they stay beyond the rate limits and don't get flagged.


问:
Partition key predicate must include all partition key columns
I'm trying to create query in spark using scala language, the data is available in cassandra database as a table. In Cassandra table i have two keys, 1) Primary Key
2) Partition Key

Cassandra DDL will be something like this:

```<code>CREATE TABLE A.B (
    id1 text,
    id2 text,
    timing timestamp,
    value float,
    PRIMARY KEY ((id1, id2), timing)
) WITH CLUSTERING ORDER BY (timing DESC)
</code>```

My Spark Programming:

```<code>val conf = new SparkConf(true).set("spark.cassandra.connection.host","192.168.xx.xxx").set("spark.cassandra.auth.username","test").set("spark.cassandra.auth.password","test")
val sc = new SparkContext(conf)
var ctable = sc.cassandraTable("A", "B").select("id1","id2","timing","value").where("id1=?","1001")
</code>```

When i query the same for "value" I'm obtaining the result, but when i query for id1 or id2 i'm receiving an error.

Error Obtained:
java.lang.UnsupportedOperationException: Partition key predicate must include all partition key columns or partition key columns need to be indexed. Missing columns: id2

I'm Using spark-2.2.0-bin-hadoop2.7, Cassandra 3.9, scala 2.11.8.

Thanks in advance.

答:
The Output i required was obtained by using following program.

```<code>val conf = new SparkConf(true).set("spark.cassandra.connection.host","192.168.xx.xxx").set("spark.cassandra.auth.username","test").set("spark.cassandra.auth.password","test")
val sc = new SparkContext(conf)
var ctable = sc.cassandraTable("A", "B").select("id1","id2","timing","value").where("id1=?","1001").where("id2=?","1002")
</code>```

This is how we can access to partition key in cassandra database through Spark.

Body:
I'm trying to create query in spark using scala language, the data is available in cassandra database as a table. In Cassandra table i have two keys, 1) Primary Key
2) Partition Key

Cassandra DDL will be something like this:

CREATE TABLE A.B (
    id1 text,
    id2 text,
    timing timestamp,
    value float,
    PRIMARY KEY ((id1, id2), timing)
) WITH CLUSTERING ORDER BY (timing DESC)

My Spark Programming:

val conf = new SparkConf(true).set("spark.cassandra.connection.host","192.168.xx.xxx").set("spark.cassandra.auth.username","test").set("spark.cassandra.auth.password","test")
val sc = new SparkContext(conf)
var ctable = sc.cassandraTable("A", "B").select("id1","id2","timing","value").where("id1=?","1001")

When i query the same for "value" I'm obtaining the result, but when i query for id1 or id2 i'm receiving an error.

Error Obtained:
java.lang.UnsupportedOperationException: Partition key predicate must include all partition key columns or partition key columns need to be indexed. Missing columns: id2

I'm Using spark-2.2.0-bin-hadoop2.7, Cassandra 3.9, scala 2.11.8.

Thanks in advance.

Body:
The Output i required was obtained by using following program.

val conf = new SparkConf(true).set("spark.cassandra.connection.host","192.168.xx.xxx").set("spark.cassandra.auth.username","test").set("spark.cassandra.auth.password","test")
val sc = new SparkContext(conf)
var ctable = sc.cassandraTable("A", "B").select("id1","id2","timing","value").where("id1=?","1001").where("id2=?","1002")

This is how we can access to partition key in cassandra database through Spark.


问:
QueryException (23000) SQLSTATE[23000]: Integrity constraint v1452
I am sucked by this error since this week could any one help me please !
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (practice2.posts, CONSTRAINT posts_category_id_foreign FOREIGN KEY (category_id) REFERENCES categories (id)) (SQL: insert into posts (author_id, updated_at, created_at) values (2, 2017-11-13 05:48:53, 2017-11-13 05:48:53))

my codes are:
Blog controller :

```<code> public function store(Requests\PostRequest $request)
        {
            $request->user()->posts()->create($request->all());
            redirect('/backend/blog')->with('message', 'Your post was created successfully!');
        }

**migration:**

 public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('author_id')->unsigned();
            $table->foreign('author_id')->references('id')->on('users')->onDelete('restrict');
            $table->string('tittle');
            $table->string('slug')->unique;
            $table->text('excerpt');
            $table->text('body');
            $table->string('image')-> nullable();
            $table->timestamps();
        });
    }
</code>```

alter_post_migration :

```<code>public function up()
    {
        Schema::table('posts', function (Blueprint $table) {
            $table->integer('category_id')->unsigned();
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('restrict');
            //
        });
    }
</code>```

create post form:

```<code><div class="box-body ">
                    {!! Form::model($post, [
                        'method' => 'POST',
                        'route' => 'back.store'
                    ]) !!}

                    <div class="form-group {{ $errors->has('tittle') ? 'has-error' : '' }}">
                        {!! Form::label('tittle') !!}
                        {!! Form::text('tittle', null, ['class' => 'form-control']) !!}

                        @if($errors->has('tittle'))
                            <span class="help-block">{{ $errors->first('tittle') }}</span>
                        @endif
                    </div>
                    <div class="form-group {{ $errors->has('slug') ? 'has-error' : '' }}">
                        {!! Form::label('slug') !!}
                        {!! Form::text('slug', null, ['class' => 'form-control']) !!}

                        @if($errors->has('slug'))
                            <span class="help-block">{{ $errors->first('slug') }}</span>
                        @endif
                    </div>
                    <div class="form-group">
                        {!! Form::label('excerpt') !!}
                        {!! Form::textarea('excerpt', null, ['class' => 'form-control']) !!}
                    </div>
                    <div class="form-group {{ $errors->has('body') ? 'has-error' : '' }}">
                        {!! Form::label('body') !!}
                        {!! Form::textarea('body', null, ['class' => 'form-control']) !!}

                        @if($errors->has('body'))
                            <span class="help-block">{{ $errors->first('body') }}</span>
                        @endif
                    </div>
                    <div class="form-group {{ $errors->has('published_at') ? 'has-error' : '' }}">
                        {!! Form::label('published_at', 'Publish Date') !!}
                        {!! Form::text('published_at', null, ['class' => 'form-control', 'placeholder' => 'Y-m-d H:i:s']) !!}

                        @if($errors->has('published_at'))
                            <span class="help-block">{{ $errors->first('published_at') }}</span>
                        @endif
                    </div>
                    <div class="form-group {{ $errors->has('category_id') ? 'has-error' : '' }}">
                        {!! Form::label('category_id', 'Category') !!}
                        {!! Form::select('category_id', App\Category::pluck('tittle', 'id'), null, ['class' => 'form-control', 'placeholder' => 'Choose category']) !!}

                        @if($errors->has('category_id'))
                            <span class="help-block">{{ $errors->first('category_id') }}</span>
                        @endif
                    </div>

                    <hr>

                    {!! Form::submit('Create new post', ['class' => 'btn btn-primary']) !!}

                    {!! Form::close() !!}
                </div>
</code>```

答:
The error:

Integrity constraint violation: 1452 Cannot add or update a child row:
  a foreign key constraint fails (practice2.posts, CONSTRAINT
  posts_category_id_foreign FOREIGN KEY (category_id) REFERENCES
  categories (id))

comes when two table share a relationship of foreign key and you are trying to add some data in child table and its associated record does not exist in the parent table. So check the data accordingly and try again.

Body:
I am sucked by this error since this week could any one help me please !
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (practice2.posts, CONSTRAINT posts_category_id_foreign FOREIGN KEY (category_id) REFERENCES categories (id)) (SQL: insert into posts (author_id, updated_at, created_at) values (2, 2017-11-13 05:48:53, 2017-11-13 05:48:53))

my codes are:
Blog controller :

 public function store(Requests\PostRequest $request)
        {
            $request->user()->posts()->create($request->all());
            redirect('/backend/blog')->with('message', 'Your post was created successfully!');
        }

**migration:**

 public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('author_id')->unsigned();
            $table->foreign('author_id')->references('id')->on('users')->onDelete('restrict');
            $table->string('tittle');
            $table->string('slug')->unique;
            $table->text('excerpt');
            $table->text('body');
            $table->string('image')-> nullable();
            $table->timestamps();
        });
    }

alter_post_migration :

public function up()
    {
        Schema::table('posts', function (Blueprint $table) {
            $table->integer('category_id')->unsigned();
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('restrict');
            //
        });
    }

create post form:

                    {!! Form::model($post, [
                        'method' => 'POST',
                        'route' => 'back.store'
                    ]) !!}

has('tittle') ? 'has-error' : '' }}">
                        {!! Form::label('tittle') !!}
                        {!! Form::text('tittle', null, ['class' => 'form-control']) !!}

                        @if($errors->has('tittle'))
                            {{ $errors->first('tittle') }}
                        @endif

has('slug') ? 'has-error' : '' }}">
                        {!! Form::label('slug') !!}
                        {!! Form::text('slug', null, ['class' => 'form-control']) !!}

                        @if($errors->has('slug'))
                            {{ $errors->first('slug') }}
                        @endif

                        {!! Form::label('excerpt') !!}
                        {!! Form::textarea('excerpt', null, ['class' => 'form-control']) !!}

has('body') ? 'has-error' : '' }}">
                        {!! Form::label('body') !!}
                        {!! Form::textarea('body', null, ['class' => 'form-control']) !!}

                        @if($errors->has('body'))
                            {{ $errors->first('body') }}
                        @endif

has('published_at') ? 'has-error' : '' }}">
                        {!! Form::label('published_at', 'Publish Date') !!}
                        {!! Form::text('published_at', null, ['class' => 'form-control', 'placeholder' => 'Y-m-d H:i:s']) !!}

                        @if($errors->has('published_at'))
                            {{ $errors->first('published_at') }}
                        @endif

has('category_id') ? 'has-error' : '' }}">
                        {!! Form::label('category_id', 'Category') !!}
                        {!! Form::select('category_id', App\Category::pluck('tittle', 'id'), null, ['class' => 'form-control', 'placeholder' => 'Choose category']) !!}

                        @if($errors->has('category_id'))
                            {{ $errors->first('category_id') }}
                        @endif

                    {!! Form::submit('Create new post', ['class' => 'btn btn-primary']) !!}

                    {!! Form::close() !!}


问:
implement financial microservice using node.js | python | R
I'm developing a tourist web app with node.js and microservics.

I need to develop a pricing service which will do all the calculation for the guest (price for night, taxes, VAT, discounts etc).

Moreover, I need those calculation will be easy to dynamically change and control.

From my past experience, doing those calcs in common web programming languages and/or storing math formulas in the db end with a mess.

Are there any alternative solutions for this? From what I read so far language like python, R or Java can fit to the job. However, is there any specific library within those which aimed for pricing?

答:
@wizard I would share here something .

If you have complex calculation or any type of calculation do it in db end if feasible.

The best approach
postgres

to do this type of process is to make function (PL\SQL) block . If you are using postgres create all calculation in postgres .

This is why node.js was design , no calculation in node.js end .

mongodb

if you are working with mongodb with this approach then i will recommend you to go with

Stored JavaScript in MongoDB


问:
Rotate image math (C#)
I have an image with two points, aligned something like this:

```<code>|----------------|
|                |
|    .           |
|                |
|          .     |
|                |
|----------------|
</code>```

I have both X, Y coordinates for both points and I need to rotate the image X degrees so it looks like this instead:

```<code>|----------------|
|                |
|                |
|    .     .     |
|                |
|                |
|----------------|
</code>```

Basically so they align next to eachother, what's the math for this? (A code example in C# would be even better but not required)

答:
Performing a general 2D transformation involves solving a pair of eqautions with 6 unknowns.

'x = xA + yB + C

'y = xD + yE + D

Given 3 corresponding points, you will have 6 knowns and the system can be solved. You only have 4 points in this case, since you don't care about shear, but you could imagine introducing a 3rd point at 90 degrees to the line formed by the other two points. Creating a rotated image is then ( pseudo codedily ) just something like:

```<code>for ( y = 0; y < height; y++ )
 for ( x = 0; x < width; x++ )
  {
    newx = x*A + y*B + C;
    newy = x*D + y*D + E;
    newimage(x,y ) = oldimage( newx, newy );
  }
}
</code>```

If performance is important, the multiplies in the inner loop can be optimised away by noting that y*B only changes in the outer look and that newx,newy change by constants A and D in the inner loop.

OwnerDisplayName: fredrikholmstrom

Title: Rotate image math (C#)

Body:
I have an image with two points, aligned something like this:

|----------------|
|                |
|    .           |
|                |
|          .     |
|                |
|----------------|

I have both X, Y coordinates for both points and I need to rotate the image X degrees so it looks like this instead:

|----------------|
|                |
|                |
|    .     .     |
|                |
|                |
|----------------|

Basically so they align next to eachother, what's the math for this? (A code example in C# would be even better but not required)

Body:
Performing a general 2D transformation involves solving a pair of eqautions with 6 unknowns.

'x = xA + yB + C

'y = xD + yE + D

Given 3 corresponding points, you will have 6 knowns and the system can be solved. You only have 4 points in this case, since you don't care about shear, but you could imagine introducing a 3rd point at 90 degrees to the line formed by the other two points. Creating a rotated image is then ( pseudo codedily ) just something like:

for ( y = 0; y < height; y++ )
 for ( x = 0; x < width; x++ )
  {
    newx = x*A + y*B + C;
    newy = x*D + y*D + E;
    newimage(x,y ) = oldimage( newx, newy );
  }
}

If performance is important, the multiplies in the inner loop can be optimised away by noting that y*B only changes in the outer look and that newx,newy change by constants A and D in the inner loop.

OwnerDisplayName: Tom Grove

LastEditorDisplayName: Tom Grove


问:
How to enable jQuery support in Aptana Studio 3
How Can I Enable jQuery In Aptana Studio 3 (beta) ?

I didn't see any document for this version.

Does Aptana Studio 3 (beta) Supporting jQuery?

答:
In Studio 3 much of this sort of functionality is still coming as Aptana is going more of a TextMate bundle route for a great deal of their features, which I think is really cool.

That said, there is already a jQuery bundle. The jQuery bundle, if you don't have it installed yet, can be installed from Aptana via the Commands menu (Commands->Bundle Development->Install Bundle and then select jQuery from the list).

This support discussion has some details about jQuery code assist in Aptana:
https://aptanastudio.tenderapp.com/discussions/problems/2006-studio-3-jquery-support-is-lacking

In particular, it mentions adding a jquery vs doc file (http://code.jquery.com/jquery-1.4.1-vsdoc.js) to your project. This seems to be the key.

If you install the jQuery bundle and add the aforementioned JS file, you can get jQuery code hints in your Aptana editor(s). I just ran through this in one of my Rails projects and it does work (I'm on the latest beta of Studio 3 for Mac).


答:
.icon{
float:left;
text-align:right;
margin-right:5px;
}
.link-desc{
float:left;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><ul class="info-link">
   <li>

       <div class="icon"><i class="fa fa-map-marker"></i></div>
       <div class="link-desc">3588 N Stelling road, Brooklyn, NYC, United State</div>
       <div style="clear:both"></div>

  </li>
   <li>

       <div class="icon"><i class="fa fa-phone"></i></div>
       <div class="link-desc">1900-167-168-99 EXT: 001</div>
       <div style="clear:both"></div>

  </li>
   <li>

       <div class="icon"><i class="fa fa-mobile"></i></div>
       <div class="link-desc">(05) 132-564-3333</div>
       <div style="clear:both"></div>

  </li>
  <li>

       <div class="icon"><i class="fa fa-envelope"></i></div>
       <div class="link-desc">logohere@support.com</div>
       <div style="clear:both"></div>

  </li>

 </ul></code>```

Title: i want the link style like in the picture

Body:
.icon{
float:left;
text-align:right;
margin-right:5px;
}
.link-desc{
float:left;
}

<ul class="info-link">
   <li>
     <a href="#">
       <div class="icon"><i class="fa fa-map-marker"></i></div>
       <div class="link-desc">3588 N Stelling road, Brooklyn, NYC, United State</div>
       <div style="clear:both"></div>
     </a>
  </li>
   <li>
     <a href="#">
       <div class="icon"><i class="fa fa-phone"></i></div>
       <div class="link-desc">1900-167-168-99 EXT: 001</div>
       <div style="clear:both"></div>
     </a>
  </li>
   <li>
     <a href="#">
       <div class="icon"><i class="fa fa-mobile"></i></div>
       <div class="link-desc">(05) 132-564-3333</div>
       <div style="clear:both"></div>
     </a>
  </li>
  <li>
     <a href="#">
       <div class="icon"><i class="fa fa-envelope"></i></div>
       <div class="link-desc">logohere@support.com</div>
       <div style="clear:both"></div>
     </a>
  </li>

 </ul>


问:
iOS how to set app icon and launch images
How do I set the images so that I can archive and validate my app? The screen looks like this now:

So the first one says 29pt, but then it also says 2x. So do I put a 29x29 image or a 58x58 image? And where do I put all of the other ones? (I know that there are more sizes than 29, 40, and 60).

Anyway, what I tried was I dragged a 29x29 png onto the first slot, a 40x40 onto the second, and a 60x60 onto the third and fourth. When I went to Product->Archive, I get

/Users/kendon/Documents/iPhone Apps/Sales Tool/Sales Tool/Images.xcassets: The app icon set named "AppIcon" did not have any applicable content.

答:
As per updated version(Xcode 8.3.3) I saw that below resolution are required for all fields of AppIcon sets.

```<code>40x40
58x58
60x60
80x80
87x87
120x120
180x180
</code>```

It comes with hdpi, xhdpi, xxhdpi etc.
Hope it will helps others.

Edited to 120x120

Body:
As per updated version(Xcode 8.3.3) I saw that below resolution are required for all fields of AppIcon sets.

40x40
58x58
60x60
80x80
87x87
120x120
180x180

It comes with hdpi, xhdpi, xxhdpi etc.
Hope it will helps others.

Edited to 120x120


问:
Manifest merge failed : Android Studio
my project and android studio worked fine last night.but when i open android studio today getting below error.i didn't change anything.how can i fix this?

```<code>Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.0) from [com.android.support:design:25.3.0] AndroidManifest.xml:27:9-31
    is also present at [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.
</code>```

this is my build.gradle

```<code> android {
        compileSdkVersion 25
        buildToolsVersion '25.0.0'
        defaultConfig {
            applicationId "com.android.my.app"
            minSdkVersion 17
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        compile 'com.android.support:appcompat-v7:25.1.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'io.reactivex:rxandroid:1.2.1'
        compile 'io.reactivex:rxjava:1.1.6'
        compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
        compile 'com.android.support:design:25.1.0'
        compile 'com.jakewharton:butterknife:7.0.1'
        compile 'com.gdacciaro:iosdialog:1.0.2'
        compile 'com.roughike:bottom-bar:2.3.1'
        testCompile 'junit:junit:4.12'
    }
</code>```

答:
The problem is because there is implicit dependency for support library in your dependencies block.

You can find that iOSDialog is using support library version 26.+ implicitly from its build.gradle. Please look at its module build.gradle

So, you need to decide to exclude the support library from iOsDialog or updating your build.gradle to use compileSdkVersion, buildToolsVersion, targetSdkVersion, and Support Library to version 26.

```<code>dependencies {
  ...
  compile('com.gdacciaro:iosdialog:1.0.2') {
    exclude group: 'com.android.support'
    exclude module: 'support-v7'
    exclude module: 'appcompat-v7'
    exclude module: 'support-v4'
  }
}
</code>```

I'm strongly against using configurations.all {} block because you can't isolate the problem of a specific dependency.

Title: Manifest merge failed : Android Studio

Body:
my project and android studio worked fine last night.but when i open android studio today getting below error.i didn't change anything.how can i fix this?

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.0) from [com.android.support:design:25.3.0] AndroidManifest.xml:27:9-31
    is also present at [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

this is my build.gradle

 android {
        compileSdkVersion 25
        buildToolsVersion '25.0.0'
        defaultConfig {
            applicationId "com.android.my.app"
            minSdkVersion 17
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        compile 'com.android.support:appcompat-v7:25.1.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'io.reactivex:rxandroid:1.2.1'
        compile 'io.reactivex:rxjava:1.1.6'
        compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
        compile 'com.android.support:design:25.1.0'
        compile 'com.jakewharton:butterknife:7.0.1'
        compile 'com.gdacciaro:iosdialog:1.0.2'
        compile 'com.roughike:bottom-bar:2.3.1'
        testCompile 'junit:junit:4.12'
    }

Body:
The problem is because there is implicit dependency for support library in your dependencies block.

You can find that iOSDialog is using support library version 26.+ implicitly from its build.gradle. Please look at its module build.gradle

So, you need to decide to exclude the support library from iOsDialog or updating your build.gradle to use compileSdkVersion, buildToolsVersion, targetSdkVersion, and Support Library to version 26.

dependencies {
  ...
  compile('com.gdacciaro:iosdialog:1.0.2') {
    exclude group: 'com.android.support'
    exclude module: 'support-v7'
    exclude module: 'appcompat-v7'
    exclude module: 'support-v4'
  }
}

I'm strongly against using configurations.all {} block because you can't isolate the problem of a specific dependency.


问:
Facing "The token contains no permissions, or permissions can not be understood." issue in EWS with Oauth
We have requirement in which we need to add appointment to user outlook account on behalf of that user using delegate access. All mails are in same domain or same network. We are trying this by using Oauth with office365, by creating Azure application and providing application level "calendar read and write" delegate permission.
I have referred https://blogs.msdn.microsoft.com/exchangedev/2015/01/21/building-daemon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow/ article to setup azure application, which will provide me a access token.
   While fetching access token I have used following code

```<code> private static string GetTokenUsingCertificate()
    {
        string authority = string.Format("https://login.windows.net/{0}/oauth2/authorize", tenantID); ;
        string outlookUri = "https://outlook.office365.com/";
        var authenticationContext = new AuthenticationContext(authority, false);
        var clientCertificate = new ClientAssertionCertificate(clientId, GetClientCertificate());
        AuthenticationResult authenticationResult = null;
        try
        {

            authenticationResult = authenticationContext.AcquireTokenAsync(outlookUri, clientCertificate).Result;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        return authenticationResult?.AccessToken;
    }
</code>```

above function is providing me access token but when I try to add appointment to user outlook calendar using Exchnage Service, I am getting  "The token contains no permissions, or permissions can not be understood." exception.
   While adding appointment I am using following code

```<code>private void AddAppointment()
    {
        ExchangeService exchangeService = new ExchangeService();
            exchangeService.Credentials = new OAuthCredentials(accessToken);
        exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
        Appointment appointment = new Appointment(service)
        {
            Subject = "EWS OAuth: Appointment 2",
            Body = "EWS OAuth Auth: Body",
            Start = DateTime.Now.AddMinutes(10)
        };
        appointment.Save(
                             new FolderId(WellKnownFolderName.Calendar, new Mailbox("mail@outlook.com/")),
                             SendInvitationsMode.SendToNone);
    }
</code>```

Please help me to resolve this issue.

Blockquote

答:
EWS doesn't allow the same level of OAuth permissions scope (or permission restriction) that the REST API allows for which is one of the big benefit of using REST vs EWS. If you have Office365 why are trying to use EWS over REST ?

To answer the question you will need

OAuth authentication for EWS is only available in Exchange as part of Office 365. EWS applications require the "Full access to user's mailbox" permission.

as per https://msdn.microsoft.com/en-us/library/office/dn903761%28v=exchg.150%29.aspx .

Body:
We have requirement in which we need to add appointment to user outlook account on behalf of that user using delegate access. All mails are in same domain or same network. We are trying this by using Oauth with office365, by creating Azure application and providing application level "calendar read and write" delegate permission.
I have referred https://blogs.msdn.microsoft.com/exchangedev/2015/01/21/building-daemon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow/ article to setup azure application, which will provide me a access token.
   While fetching access token I have used following code

 private static string GetTokenUsingCertificate()
    {
        string authority = string.Format("https://login.windows.net/{0}/oauth2/authorize", tenantID); ;
        string outlookUri = "https://outlook.office365.com/";
        var authenticationContext = new AuthenticationContext(authority, false);
        var clientCertificate = new ClientAssertionCertificate(clientId, GetClientCertificate());
        AuthenticationResult authenticationResult = null;
        try
        {

            authenticationResult = authenticationContext.AcquireTokenAsync(outlookUri, clientCertificate).Result;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        return authenticationResult?.AccessToken;
    }

above function is providing me access token but when I try to add appointment to user outlook calendar using Exchnage Service, I am getting  "The token contains no permissions, or permissions can not be understood." exception.
   While adding appointment I am using following code

private void AddAppointment()
    {
        ExchangeService exchangeService = new ExchangeService();
            exchangeService.Credentials = new OAuthCredentials(accessToken);
        exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
        Appointment appointment = new Appointment(service)
        {
            Subject = "EWS OAuth: Appointment 2",
            Body = "EWS OAuth Auth: Body",
            Start = DateTime.Now.AddMinutes(10)
        };
        appointment.Save(
                             new FolderId(WellKnownFolderName.Calendar, new Mailbox("mail@outlook.com/")),
                             SendInvitationsMode.SendToNone);
    }

Please help me to resolve this issue.

Blockquote


问:
Having a select option stay selected after POST with Flask
I'm trying to get a select option that is selected to stay after the page refresh using Flask. I have attempted to do so with Jinga2, but it's is not working:

    <select class="form-control" id="myselect" name="thing" required>
        <option value="" {% if thing=='' %} selected {% endif %} ></option>
        <option value="Foo" name="Foo" id="Foo" {% if thing =="Foo" %} selected {% endif %}>Foo</option>
        <option value="Bar" name="Bar" id="Bar" {% if thing =="Bar" %} selected {% endif %}>Bar</option>
    </select>

```
<p>Where the variable <code>energy</code> is populated and passed through with Python. After looking into this, I feel that this is the way to make this work in Flask, though apparently not. Any assistance would be appreciated!</p>
<pre class="lang-py prettyprint-override"><code>@app,route('/things', methods=['POST']
def things()
    if len(facts['thing']) > 11:
        energy = [facts['thing'][0:8],facts['thing'][9:]]
    else:
        energy = [facts['things']]
    ...
    return render_template('thing.html', thing=energy)
</code>```

答:
try this,  if you have not already</p>

```<code>{% if thing == "Foo" %}
    <option value = "Foo" name ="Foo" id="Foo" selected>Foo</option>
    <option value = "Bar" name ="Bar" id="Bar">Bar</option>
{% elif thing == "Bar" %}
    <option value = "Foo" name ="Foo" id="Foo">Foo</option>
    <option value = "Bar" name ="Bar" id="Bar" selected>Bar</option>
{% endif %}
</code>```

Body:
I'm trying to get a select option that is selected to stay after the page refresh using Flask. I have attempted to do so with Jinga2, but it's is not working:

    <select class="form-control" id="myselect" name="thing" required>
        <option value="" {% if thing=='' %} selected {% endif %} ></option>
        <option value="Foo" name="Foo" id="Foo" {% if thing =="Foo" %} selected {% endif %}>Foo</option>
        <option value="Bar" name="Bar" id="Bar" {% if thing =="Bar" %} selected {% endif %}>Bar</option>
    </select>

Where the variable energy is populated and passed through with Python. After looking into this, I feel that this is the way to make this work in Flask, though apparently not. Any assistance would be appreciated!

@app,route('/things', methods=['POST']
def things()
    if len(facts['thing']) > 11:
        energy = [facts['thing'][0:8],facts['thing'][9:]]
    else:
        energy = [facts['things']]
    ...
    return render_template('thing.html', thing=energy)

Body:
try this,  if you have not already

{% if thing == "Foo" %}
    <option value = "Foo" name ="Foo" id="Foo" selected>Foo</option>
    <option value = "Bar" name ="Bar" id="Bar">Bar</option>
{% elif thing == "Bar" %}
    <option value = "Foo" name ="Foo" id="Foo">Foo</option>
    <option value = "Bar" name ="Bar" id="Bar" selected>Bar</option>
{% endif %}


问:
Disabled all other radio button if name and value not same
I am making one form where I need to disable all other radio button and submit button if Radio button name or Id or class name not same to each other.

ID or name or class, I am generating through dynamic way. (name=radio_1, id= radio_1).

or

if I click on Group-1 radio button then other group should be disable.

Please have a look.

```<code><label class="radio-inline">
<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="submit" name="start_<?=$value['task_id']?>" value="Save" class="btn sm btn-primary group_<?=$value['task_id']?>">
</label>

<label class="radio-inline">
<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="submit" name="start_<?=$value['task_id']?>" value="Save" class="btn sm btn-primary group_<?=$value['task_id']?>">
</label>
</code>```

HTML Output:

```<code><label class="radio-inline">
<input type="radio" name="start_1" class="group_1" value="start_1">
<input type="radio" name="start_1" class="group_1" value="start_1">
<input type="submit" name="start_1" value="Save" class="btn sm btn-primary group_1">
</label>

<label class="radio-inline">
<input type="radio" name="start_2" class="group_2" value="start_2">
<input type="radio" name="start_2" class="group_2" value="start_2">
<input type="submit" name="start_2" value="Save" class="btn sm btn-primary group_2">
</label>
</code>```

My Query:

```<code>$(document).ready(function() {
$("input:radio").click(function() {
    var val = $(this).val();
    var name = $(this).attr('name');
    if(val != name){
      $(this).attr("disabled", true);
    }
    else{
    $(this).attr("disabled", false);
    }
});

});
</code>```

Please guide me how can I do this.

答:
Try this:

```<code>$(document).on("click", "input[type='radio']", function() {
  var val = $(this).val();
  $("input[type='radio']").each(function() {
    var name = $(this).attr('name');
    if (val != name) {
      $(this).attr("disabled", true);
    } else {
      $(this).attr("disabled", false);
    }
  });
});
</code>```

FIDDLE

Body:
I am making one form where I need to disable all other radio button and submit button if Radio button name or Id or class name not same to each other.

ID or name or class, I am generating through dynamic way. (name=radio_1, id= radio_1).

or

if I click on Group-1 radio button then other group should be disable.

Please have a look.

<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="submit" name="start_<?=$value['task_id']?>" value="Save" class="btn sm btn-primary group_<?=$value['task_id']?>">

<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="radio" name="start_<?=$value['task_id']?>" class="group_<?=$value['task_id']?>" value="start_<?=$value['task_id']?>">
<input type="submit" name="start_<?=$value['task_id']?>" value="Save" class="btn sm btn-primary group_<?=$value['task_id']?>">

HTML Output:

<input type="radio" name="start_1" class="group_1" value="start_1">
<input type="radio" name="start_1" class="group_1" value="start_1">
<input type="submit" name="start_1" value="Save" class="btn sm btn-primary group_1">

<input type="radio" name="start_2" class="group_2" value="start_2">
<input type="radio" name="start_2" class="group_2" value="start_2">
<input type="submit" name="start_2" value="Save" class="btn sm btn-primary group_2">

My Query:

$(document).ready(function() {
$("input:radio").click(function() {
    var val = $(this).val();
    var name = $(this).attr('name');
    if(val != name){
      $(this).attr("disabled", true);
    }
    else{
    $(this).attr("disabled", false);
    }
});

});

Please guide me how can I do this.

Body:
Try this:

$(document).on("click", "input[type='radio']", function() {
  var val = $(this).val();
  $("input[type='radio']").each(function() {
    var name = $(this).attr('name');
    if (val != name) {
      $(this).attr("disabled", true);
    } else {
      $(this).attr("disabled", false);
    }
  });
});

FIDDLE


问:
how can i add action event on notification action
I want to stop mediaplayer and cancel the notification when i click on stop action of notification

this is my alarm function

```<code>public void alarmstart(String idd,int alarmmonth,int alarmyear,int alarmday,int alarmhour,int alarmmin)
    {
        AlarmManager manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
        Intent myIntent;
        PendingIntent pendingIntent;

        myIntent = new Intent(Create.this,AlarmNotificationReceiver.class);
        myIntent.putExtra("title",tii);
        myIntent.putExtra("note",noo);
        myIntent.putExtra("id",id);
        pendingIntent =
        PendingIntent.getBroadcast(this,Integer.valueOf(idd),myIntent,0);

        Calendar cal1=Calendar.getInstance();
        cal1.set(Calendar.MONTH,alarmmonth-1);
        cal1.set(Calendar.YEAR,alarmyear);
        cal1.set(Calendar.DAY_OF_MONTH,alarmday);

        cal1.set(Calendar.HOUR_OF_DAY,alarmhour);
        cal1.set(Calendar.MINUTE,alarmmin);
        cal1.set(Calendar.SECOND,0);

        manager.set(AlarmManager.RTC_WAKEUP,cal1.getTimeInMillis() ,pendingIntent);

    }
</code>```

this is my notification class broadcast receiver

```<code>public class AlarmNotificationReceiver extends BroadcastReceiver {

    MediaPlayer mMediaPlayer;
    PendingIntent pintent;
    static String id;

    @Override
    public void onReceive(Context context, Intent intent) {
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

        String ti,no;
        ti=intent.getExtras().getString("title");
        no=intent.getExtras().getString("note");
        id=intent.getExtras().getString("id");

        builder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(ti)
                .setContentText(no)
                .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
                .addAction(new android.support.v4.app.NotificationCompat.Action(
                        R.mipmap.stop,
                        "Stop",
                        PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)))

                .setContentInfo("Info");
          mMediaPlayer = MediaPlayer.create(context, R.raw.teri);
         mMediaPlayer.start();

        NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(Integer.valueOf(id),builder.build());

    }

}
</code>```

please can anyone help me on this I am newbie on this almost read the all previous posts related to this topic but not able to do this

答:
you should use IntentService in AlarmNotificationReceiver class and handle mMediaPlayer object for stop , pause , play or anything else that you want to do ,the same as following code :

```<code>  public static class NotificationActionService extends IntentService {
    public NotificationActionService() {
        super(NotificationActionService.class.getSimpleName());
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        String action = intent.getAction();

        if ("StopSound".equals(action)) {
            // TODO: handle action StopSound.
           mMediaPlayer.stop();
            // If you want to cancel the notification:
   NotificationManagerCompat.from(this).cancel(NOTIFICATION_ID);
   // NOTIFICATION_ID : you can (set and get) notificationid (to/from) intent
        }
    }
</code>```

in onReceive method of AlarmNotificationReceiver you should set intent and call  NotificationActionService

```<code> Intent stopSoundIntent = new Intent(context,
 NotificationActionService.class)
        .setAction("StopSound");

    PendingIntent stopSoundPendingIntent = PendingIntent.getService(context, 0,
            stopSoundIntent, PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContentTitle("Sample Notification")
                    .setContentText("Notification text goes here")
                    .addAction(new NotificationCompat.Action(R.drawable.ic_launcher,
                            "StopSound", stopSoundPendingIntent));

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
</code>```

you can edit this solution according to what you need.

i hope this solution be benefit for you.

for more detail you can see this link

Body:
I want to stop mediaplayer and cancel the notification when i click on stop action of notification

this is my alarm function

public void alarmstart(String idd,int alarmmonth,int alarmyear,int alarmday,int alarmhour,int alarmmin)
    {
        AlarmManager manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
        Intent myIntent;
        PendingIntent pendingIntent;

        myIntent = new Intent(Create.this,AlarmNotificationReceiver.class);
        myIntent.putExtra("title",tii);
        myIntent.putExtra("note",noo);
        myIntent.putExtra("id",id);
        pendingIntent =
        PendingIntent.getBroadcast(this,Integer.valueOf(idd),myIntent,0);

        Calendar cal1=Calendar.getInstance();
        cal1.set(Calendar.MONTH,alarmmonth-1);
        cal1.set(Calendar.YEAR,alarmyear);
        cal1.set(Calendar.DAY_OF_MONTH,alarmday);

        cal1.set(Calendar.HOUR_OF_DAY,alarmhour);
        cal1.set(Calendar.MINUTE,alarmmin);
        cal1.set(Calendar.SECOND,0);

        manager.set(AlarmManager.RTC_WAKEUP,cal1.getTimeInMillis() ,pendingIntent);

    }

this is my notification class broadcast receiver

public class AlarmNotificationReceiver extends BroadcastReceiver {

    MediaPlayer mMediaPlayer;
    PendingIntent pintent;
    static String id;

    @Override
    public void onReceive(Context context, Intent intent) {
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

        String ti,no;
        ti=intent.getExtras().getString("title");
        no=intent.getExtras().getString("note");
        id=intent.getExtras().getString("id");

        builder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(ti)
                .setContentText(no)
                .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
                .addAction(new android.support.v4.app.NotificationCompat.Action(
                        R.mipmap.stop,
                        "Stop",
                        PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)))

                .setContentInfo("Info");
          mMediaPlayer = MediaPlayer.create(context, R.raw.teri);
         mMediaPlayer.start();

        NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(Integer.valueOf(id),builder.build());

    }

}

please can anyone help me on this I am newbie on this almost read the all previous posts related to this topic but not able to do this

Body:
you should use IntentService in AlarmNotificationReceiver class and handle mMediaPlayer object for stop , pause , play or anything else that you want to do ,the same as following code :

  public static class NotificationActionService extends IntentService {
    public NotificationActionService() {
        super(NotificationActionService.class.getSimpleName());
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        String action = intent.getAction();

        if ("StopSound".equals(action)) {
            // TODO: handle action StopSound.
           mMediaPlayer.stop();
            // If you want to cancel the notification:
   NotificationManagerCompat.from(this).cancel(NOTIFICATION_ID);
   // NOTIFICATION_ID : you can (set and get) notificationid (to/from) intent
        }
    }

in onReceive method of AlarmNotificationReceiver you should set intent and call  NotificationActionService

 Intent stopSoundIntent = new Intent(context,
 NotificationActionService.class)
        .setAction("StopSound");

    PendingIntent stopSoundPendingIntent = PendingIntent.getService(context, 0,
            stopSoundIntent, PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContentTitle("Sample Notification")
                    .setContentText("Notification text goes here")
                    .addAction(new NotificationCompat.Action(R.drawable.ic_launcher,
                            "StopSound", stopSoundPendingIntent));

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());

you can edit this solution according to what you need.

i hope this solution be benefit for you.

for more detail you can see this link


问:
Good database for superfast storage of large amounts of financial data?
I'm storing large amounts of financial data for options. Recommendations for a database to store this data?

Edit

"large amounts" is 1GB initially, scaling up to around 100GB at some point in the future.

Fine with either commercial and open source.

Developing with Microsoft Visual Studio 2010 and C#.

Latency/retention periods: need to store streaming realtime data in such a way that I don't lose any of the data coming in (probably about 10KByte/sec maximum data to store). Querying can be performed outside of market hours, so speed of querying is not an issue.

答:
Since this is a Microsoft-based project the obvious choice is Microsoft SQL Server, which has very good integration with C# and Visual Studio.

100GB is not large.


问:
wildcard loading for every route in angular
I have added the wildcard route to my application in angular .
The issue is after adding the wildcard.

I'm not sure what is the issue!
 below id the routes array:

```<code>const appRoutes: Routes = [
    { path: 'login', redirectTo: '/login', pathMatch: 'full' },
    { path: 'settings', redirectTo: '/settings', pathMatch: 'full' },
    { path: '**', component: PageNotFoundComponent }
];
</code>```

Login and setting are modules and they have their own routing files.
Before adding the wildcard and default route, on start the app was redirected to login screen .

But now every url is redirected to PageNotFoundComponent .

The order of the routes in the configuration matters and this is by
  design. The router uses a first-match wins strategy when matching
  routes, so more specific routes should be placed above less specific
  routes. In the configuration above, routes with a static path are
  listed first, followed by an empty path route, that matches the
  default route. The wildcard route comes last because it matches every
  URL and should be selected only if no other routes are matched first.

Please guide!
Thanks

答:
Please use component instead of  wildcards:</p>

```<code> { path: 'login', component: LoginComponent , pathMatch: 'full'}
</code>```

Body:
I have added the wildcard route to my application in angular .
The issue is after adding the wildcard.

I'm not sure what is the issue!
 below id the routes array:

const appRoutes: Routes = [
    { path: 'login', redirectTo: '/login', pathMatch: 'full' },
    { path: 'settings', redirectTo: '/settings', pathMatch: 'full' },
    { path: '**', component: PageNotFoundComponent }
];

Login and setting are modules and they have their own routing files.
Before adding the wildcard and default route, on start the app was redirected to login screen .

But now every url is redirected to PageNotFoundComponent .

The order of the routes in the configuration matters and this is by
  design. The router uses a first-match wins strategy when matching
  routes, so more specific routes should be placed above less specific
  routes. In the configuration above, routes with a static path are
  listed first, followed by an empty path route, that matches the
  default route. The wildcard route comes last because it matches every
  URL and should be selected only if no other routes are matched first.

Please guide!
Thanks

Body:
Please use component instead of  wildcards:

 { path: 'login', component: LoginComponent , pathMatch: 'full'}


问:
How can we send email on our Local host in php?

Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS
  command first. k9sm14645324wrk.88 - gsmtp in
  C:\xampp\htdocs\contact-form\form.php on line 34 Error sending email.

How can i send email on our Local host in PHP?
i am beginner and i want to send email on our localhost in php. Kindly tell me how can i do this in php?

答:
You can use http://www.toolheap.com/test-mail-server-tool/ => mail server tool and update php.ini, remove semicolon ;smtp = localhost and put semicolon before sendmail_path

You may want to check the below thread.

How to configure XAMPP to send mail from localhost?


问:
Get element from xml string in c#
I have following xml string which is best way to read tempTxnId

```<code><MMP>
  <MERCHANT>
    <RESPONSE>
      <url>https://test</url>
      <param name="ttype">NBFund</param>
      <param name="tempTxnId">100000552091</param>
      <param name="token">5PY8i988hsEqLftDl7V2m69y5VGp</param>
      <param name="txnStage">1</param>
    </RESPONSE>
  </MERCHANT>
</MMP>
</code>```

答:
first you'd have to know a little about XML. namely:

Reading XML, what is a tag, node, attribute, etc. A cursory search on the web for "Learn XML" produced: https://www.w3schools.com/xml/

The next step is understanding a little XPath. XPath is a query language used on XML. again, web search: https://www.w3schools.com/xml/xml_xpath.asp

The third piece to this puzzle is how to incorporate this into C#. a short web search of "read xml c# xpath" revealed this tidbit. Using XPath to parse an XML document

this is a basic web search research project. this is the way I learned most of my programming, by searching the web, reading, learning.

Learning to research is probably the most important skill of a modern day programmer.

Title: Get element from xml string in c#

Body:
I have following xml string which is best way to read tempTxnId

<MMP>
  <MERCHANT>
    <RESPONSE>
      <url>https://test</url>
      <param name="ttype">NBFund</param>
      <param name="tempTxnId">100000552091</param>
      <param name="token">5PY8i988hsEqLftDl7V2m69y5VGp</param>
      <param name="txnStage">1</param>
    </RESPONSE>
  </MERCHANT>
</MMP>


问:
AudioSource.VOICE_CALL not working in android 4.0 but working in android 2.3
```<code>VOICE_CALL, VOICE_DOWNLINK ,VOICE_UPLINK
</code>```

not working on android 4.0 but working on android 2.3 (Actual Device),I have uploaded a dummy project to record all outgoing call so that you can see it for your self

http://www.mediafire.com/?img6dg5y9ri5c7rrtcajwc5ycgpo2nf

you just have to change audioSource = MediaRecorder.AudioSource.MIC; to audioSource = MediaRecorder.AudioSource.VOICE_CALL; on line 118 in TService.java

If you come across any error, tell me. Any suggestion related to it will be accepted.

答:
OK, in my case this code (thank you eyal!) worked for Samsung Galaxy Note 6:</p>

```<code>String manufacturer = Build.MANUFACTURER;
if (manufacturer.toLowerCase().contains("samsung")) {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
} else {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
}
</code>```

Body:
VOICE_CALL, VOICE_DOWNLINK ,VOICE_UPLINK

not working on android 4.0 but working on android 2.3 (Actual Device),I have uploaded a dummy project to record all outgoing call so that you can see it for your self

http://www.mediafire.com/?img6dg5y9ri5c7rrtcajwc5ycgpo2nf

you just have to change audioSource = MediaRecorder.AudioSource.MIC; to audioSource = MediaRecorder.AudioSource.VOICE_CALL; on line 118 in TService.java

If you come across any error, tell me. Any suggestion related to it will be accepted.

Body:
OK, in my case this code (thank you eyal!) worked for Samsung Galaxy Note 6:

String manufacturer = Build.MANUFACTURER;
if (manufacturer.toLowerCase().contains("samsung")) {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
} else {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
}


问:
How do I clone a list so that it doesn't change unexpectedly after assignment?
While using new_list = my_list, any modifications to new_list changes my_list every time. Why is this, and how can I clone or copy the list to prevent it?

答:
Let's start from the beginning and explore this question.

So let's suppose you have two lists:

```<code>list_1 = ['01', '98']
list_2 = [['01', '98']]
</code>```

And we have to copy both lists, now starting from the first list:

So first let's try by setting the variable copy to our original list, list_1:

```<code>copy = list_1
</code>```

Now if you are thinking copy copied the list_1, then you are wrong. The id function can show us if two variables can point to the same object. Let's try this:

```<code>print(id(copy))
print(id(list_1))
</code>```

The output is:

```<code>4329485320
4329485320
</code>```

Both variables are the exact same argument. Are you surprised?

So as we know, Python doesn't store anything in a variable, Variables are just referencing to the object and object store the value. Here object is a list but we created two references to that same object by two different variable names. This means that both variables are pointing to the same object, just with different names.

When you do copy = list_1, it is actually doing:

Here in the image list_1 and copy are two variable names, but the object is same for both variable which is list.

So if you try to modify copied list then it will modify the original list too because the list is only one there, you will modify that list no matter you do from the copied list or from the original list:

```<code>copy[0] = "modify"

print(copy)
print(list_1)
</code>```

Output:

```<code>['modify', '98']
['modify', '98']
</code>```

So it modified the original list:

Now let's move onto a Pythonic method for copying lists.

```<code>copy_1 = list_1[:]
</code>```

This method fixes the first issue we had:

```<code>print(id(copy_1))
print(id(list_1))

4338792136
4338791432
</code>```

So as we can see our both list having different id and it means that both variables are pointing to different objects. So what actually going on here is:

Now let's try to modify the list and let's see if we still face the previous problem:

```<code>copy_1[0] = "modify"

print(list_1)
print(copy_1)
</code>```

The output is:

```<code>['01', '98']
['modify', '98']
</code>```

As you can see, it only modified the copied list. That means it worked.

Do you think we're done? No. Let's try to copy our nested list.

```<code>copy = list_1
</code>```0

list_2 should reference to another object which is copy of list_2. Let's check:

```<code>copy = list_1
</code>```1

We get the output:

```<code>copy = list_1
</code>```2

Now we can assume both lists are pointing different object, so now let's try to modify it and let's see it is giving what we want:

```<code>copy = list_1
</code>```3

This gives us the output:

```<code>copy = list_1
</code>```4

This may seem a little bit confusing, because the same method we previously used worked. Let's try to understand this.

When you do:

```<code>copy = list_1
</code>```5

You're only copying the outer list, not the inside list. We can use the id function once again to check this.

```<code>copy = list_1
</code>```6

The output is:

```<code>copy = list_1
</code>```7

When we do copy_2 = list_2[:], this happens:

It creates the copy of list, but only outer list copy, not the nested list copy. The nested list is same for both variable, so if you try to modify the nested list then it will modify the original list too as the nested list object is same for both lists.

What is the solution? The solution is the deepcopy function.

```<code>copy = list_1
</code>```8

Let's check this:

```<code>copy = list_1
</code>```9

Both outer lists have different IDs. Let's try this on the inner nested lists.

```<code>print(id(copy))
print(id(list_1))
</code>```0

The output is:

```<code>print(id(copy))
print(id(list_1))
</code>```1

As you can see both IDs are different, meaning we can assume that both nested lists are pointing different object now.

This means when you do deep = deepcopy(list_2) what actually happens:

Both nested lists are pointing different object and they have separate copy of nested list now.

Now let's try to modify the nested list and see if it solved the previous issue or not:

```<code>print(id(copy))
print(id(list_1))
</code>```2

It outputs:

```<code>[['01', '98']] [['01', 'modify']]
</code>```

As you can see, it didn't modify the original nested list, it only modified the copied list.

Body:
Let's start from the beginning and explore this question.

So let's suppose you have two lists:

list_1 = ['01', '98']
list_2 = [['01', '98']]

And we have to copy both lists, now starting from the first list:

So first let's try by setting the variable copy to our original list, list_1:

copy = list_1

Now if you are thinking copy copied the list_1, then you are wrong. The id function can show us if two variables can point to the same object. Let's try this:

print(id(copy))
print(id(list_1))

The output is:

4329485320
4329485320

Both variables are the exact same argument. Are you surprised?

So as we know, Python doesn't store anything in a variable, Variables are just referencing to the object and object store the value. Here object is a list but we created two references to that same object by two different variable names. This means that both variables are pointing to the same object, just with different names.

When you do copy = list_1, it is actually doing:

Here in the image list_1 and copy are two variable names, but the object is same for both variable which is list.

So if you try to modify copied list then it will modify the original list too because the list is only one there, you will modify that list no matter you do from the copied list or from the original list:

copy[0] = "modify"

print(copy)
print(list_1)

Output:

['modify', '98']
['modify', '98']

So it modified the original list:

Now let's move onto a Pythonic method for copying lists.

copy_1 = list_1[:]

This method fixes the first issue we had:

print(id(copy_1))
print(id(list_1))

4338792136
4338791432

So as we can see our both list having different id and it means that both variables are pointing to different objects. So what actually going on here is:

Now let's try to modify the list and let's see if we still face the previous problem:

copy_1[0] = "modify"

print(list_1)
print(copy_1)

The output is:

['01', '98']
['modify', '98']

As you can see, it only modified the copied list. That means it worked.

Do you think we're done? No. Let's try to copy our nested list.

copy_2 = list_2[:]

list_2 should reference to another object which is copy of list_2. Let's check:

print(id((list_2)), id(copy_2))

We get the output:

4330403592 4330403528

Now we can assume both lists are pointing different object, so now let's try to modify it and let's see it is giving what we want:

copy_2[0][1] = "modify"

print(list_2, copy_2)

This gives us the output:

[['01', 'modify']] [['01', 'modify']]

This may seem a little bit confusing, because the same method we previously used worked. Let's try to understand this.

When you do:

copy_2 = list_2[:]

You're only copying the outer list, not the inside list. We can use the id function once again to check this.

print(id(copy_2[0]))
print(id(list_2[0]))

The output is:

4329485832
4329485832

When we do copy_2 = list_2[:], this happens:

It creates the copy of list, but only outer list copy, not the nested list copy. The nested list is same for both variable, so if you try to modify the nested list then it will modify the original list too as the nested list object is same for both lists.

What is the solution? The solution is the deepcopy function.

from copy import deepcopy
deep = deepcopy(list_2)

Let's check this:

print(id((list_2)), id(deep))

4322146056 4322148040

Both outer lists have different IDs. Let's try this on the inner nested lists.

print(id(deep[0]))
print(id(list_2[0]))

The output is:

4322145992
4322145800

As you can see both IDs are different, meaning we can assume that both nested lists are pointing different object now.

This means when you do deep = deepcopy(list_2) what actually happens:

Both nested lists are pointing different object and they have separate copy of nested list now.

Now let's try to modify the nested list and see if it solved the previous issue or not:

deep[0][1] = "modify"
print(list_2, deep)

It outputs:

[['01', '98']] [['01', 'modify']]

As you can see, it didn't modify the original nested list, it only modified the copied list.