问:
How to store variable from option value to controller and save it in database with Laravel?
I'm trying to save variables from my view to controller and then save it in databases but im getting MethodNotAllowedHttpException.

Here are my view

```<code><form method="POST" action="{{ route('absensi.store') }}">

      <div class="form-group">
        <label name="nim"><h3>NIM :</h3></label>
        <select name ="mahasiswasn" class="selectpicker" data-live-search="true" data-width="500px" title="Choose the Student Number">
        @foreach($nim as $nm)
          <option value="{{ $nm->nim }}">{{ $nm->nim}}</option>
        @endforeach
      </select>
      </div>

      <div class="form-group">
        <label name="matkul"><h3> MK :</h3></label>
        <select name ="matkulsn" class="selectpicker" data-live-search="true" data-width="500px" title="Choose the subject">
        @foreach($matkul as $mkl)
          <option value="{{ $mkl->nama }}">{{ $mkl->nama}}</option>
        @endforeach
      </select>
      </div>

      <div class="form-group">
        <label name="hari">Hari :</label>
        <input id="hari" name="hari" class="form-control">
      </div>

      <div class="form-group">
        <label name="status">Status :</label>
        <input id="status" name="status" class="form-control">
      </div>

      <input type="submit" value="Add Absensi " class="btn btn-success btn-lg btn-block">
      <input type="hidden" name="_token" value="{{ Session::token() }}">

    </form>
</code>```

My Controller (AbsensiController)

```<code>public function store(Request $request)
    {
           $this->validate($request,array(
                'nim' =>'required',
                'matkul' =>'required',
                'hari' =>'required',
                'status' =>'required'
                ));

            //store in database
            $post = new PostAbsensi;

            $post->nim = $request->get('mahasiswasn');
            $post->mk = $request->get('matkulsn');
            $post->hari = $request->get('hari');
            $post->status = $request->get('status');

            $post->save();

            Session::flash('success','data successfully saved!');

            return redirect()->route('absensi.show', $post->id);
    }
</code>```

My Routes :

```<code>Route::resource('absensi','AbsensiController');
</code>```

Please Help, thank you for your attention.

Edit :

Here are my other view(IndexAbsensi)

```<code><form method="POST" action="{{ url('absensi.create') }}">
                      <input type="submit" value=" + Tambah Absensi " class="btn btn-success btn-lg btn-block">
                      <input type="hidden" name="_token" value="{{ csrf_token() }}">
  </form>
</code>```

so my thought is that when i press the button it will go to the AbsensiController@create and then return my form view, however im also getting Methodnotallowedhttpexception with this.

答: Thank you guys, i finally found the solution. It was quite strange but somehow laravel might just execute some commented form codes in my view. I wasn't expecting that at all. I deleted the commented codes and it works perfectly.</p>

Body:
I'm trying to save variables from my view to controller and then save it in databases but im getting MethodNotAllowedHttpException.

Here are my view

<form method="POST" action="{{ route('absensi.store') }}">

NIM :

        <select name ="mahasiswasn" class="selectpicker" data-live-search="true" data-width="500px" title="Choose the Student Number">
        @foreach($nim as $nm)
          <option value="{{ $nm->nim }}">{{ $nm->nim}}</option>
        @endforeach
      </select>

 MK :

        <select name ="matkulsn" class="selectpicker" data-live-search="true" data-width="500px" title="Choose the subject">
        @foreach($matkul as $mkl)
          <option value="{{ $mkl->nama }}">{{ $mkl->nama}}</option>
        @endforeach
      </select>

        Hari :
        <input id="hari" name="hari" class="form-control">

        Status :
        <input id="status" name="status" class="form-control">

      <input type="submit" value="Add Absensi " class="btn btn-success btn-lg btn-block">
      <input type="hidden" name="_token" value="{{ Session::token() }}">

    </form>

My Controller (AbsensiController)

public function store(Request $request)
    {
           $this->validate($request,array(
                'nim' =>'required',
                'matkul' =>'required',
                'hari' =>'required',
                'status' =>'required'
                ));

            //store in database
            $post = new PostAbsensi;

            $post->nim = $request->get('mahasiswasn');
            $post->mk = $request->get('matkulsn');
            $post->hari = $request->get('hari');
            $post->status = $request->get('status');

            $post->save();

            Session::flash('success','data successfully saved!');

            return redirect()->route('absensi.show', $post->id);
    }

My Routes :

Route::resource('absensi','AbsensiController');

Please Help, thank you for your attention.

Edit :

Here are my other view(IndexAbsensi)

<form method="POST" action="{{ url('absensi.create') }}">
                      <input type="submit" value=" + Tambah Absensi " class="btn btn-success btn-lg btn-block">
                      <input type="hidden" name="_token" value="{{ csrf_token() }}">
  </form>

so my thought is that when i press the button it will go to the AbsensiController@create and then return my form view, however im also getting Methodnotallowedhttpexception with this.


来源: stackexchange

问:
Python: Programatically create an xml file which lists all the contents of a directory Recursively
My directory structure looks like this. Here test is root directory, which contains directories a and b. a and b further contains subdirectories a1 ,a2 and b1 ,b2 respectively. Also a1 contains file named text.

I have created xml file for this structure using The ElementTree XML API as follows.

```<code>#!/usr/bin/env python3
import xml.etree.ElementTree as ET

test =  ET.Element('test')
a = ET.SubElement(test,'a')
a1 = ET.SubElement(a,'a1')
text = ET.SubElement(a1,'text')
a2 = ET.SubElement(a,'a2')
b = ET.SubElement(test,'b')
b1 = ET.SubElement(b,'b1')
b2 = ET.SubElement(b,'b2')
ET.dump(test)
</code>```

The output of above program is

```<code><test>
    <a>
        <a1>
            <text />
        </a1>
        <a2 />
    </a>
    <b>
        <b1 />
        <b2 />
    </b>
</test>
</code>```

But, I need to generate the xml  Programatically for any given directory.
Is this is possible?

答:
this is a recursive attempt using pathlib:

```<code>from pathlib import Path
import xml.etree.ElementTree as ET

def xml_dir(pth, et_element=None):

    if et_element is None:
        et_element = ET.Element(pth.name)
    else:
        et_element = ET.SubElement(et_element, pth.name)

    for file in (fle for fle in pth.iterdir() if fle.is_file()):
        ET.SubElement(et_element, file.name)

    for directory in (fle for fle in pth.iterdir() if fle.is_dir()):
        xml_dir(directory, et_element)

    return et_element

ret = xml_dir(Path('/home/user/startdir/'))
</code>```

this creates a fresh ET.Element at the beginning and then attaches ET.SubElements for every sub-directory.

you may want to additionally sort the files and directories...

if you need a pretty-printed xml output you need this indent function (from http://effbot.org/zone/element-lib.htm#prettyprint)

```<code>def indent(elem, level=0):
    i = "\n" + level*"  "
    if len(elem):
        if not elem.text or not elem.text.strip():
            elem.text = i + "  "
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
        for elem in elem:
            indent(elem, level+1)
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
    else:
        if level and (not elem.tail or not elem.tail.strip()):
            elem.tail = i
</code>```

and using that you get a nice string representation of the element tree:

```<code>ret = xml_dir(Path('/home/user/startdir/'))
indent(ret)
ET.dump(ret)
</code>```

or, if you want to save the string in a variable:

```<code>strg = ET.tostring(ret, method='xml').decode()
</code>```

ContentLicense: CC BY-SA 3.0

Body:
My directory structure looks like this. Here test is root directory, which contains directories a and b. a and b further contains subdirectories a1 ,a2 and b1 ,b2 respectively. Also a1 contains file named text.

I have created xml file for this structure using The ElementTree XML API as follows.

#!/usr/bin/env python3
import xml.etree.ElementTree as ET

test =  ET.Element('test')
a = ET.SubElement(test,'a')
a1 = ET.SubElement(a,'a1')
text = ET.SubElement(a1,'text')
a2 = ET.SubElement(a,'a2')
b = ET.SubElement(test,'b')
b1 = ET.SubElement(b,'b1')
b2 = ET.SubElement(b,'b2')
ET.dump(test)

The output of above program is

<test>

        <a1>
            <text />
        </a1>
        <a2 />

        <b1 />
        <b2 />

</test>

But, I need to generate the xml  Programatically for any given directory.
Is this is possible?

Body:
this is a recursive attempt using pathlib:

from pathlib import Path
import xml.etree.ElementTree as ET

def xml_dir(pth, et_element=None):

    if et_element is None:
        et_element = ET.Element(pth.name)
    else:
        et_element = ET.SubElement(et_element, pth.name)

    for file in (fle for fle in pth.iterdir() if fle.is_file()):
        ET.SubElement(et_element, file.name)

    for directory in (fle for fle in pth.iterdir() if fle.is_dir()):
        xml_dir(directory, et_element)

    return et_element

ret = xml_dir(Path('/home/user/startdir/'))

this creates a fresh ET.Element at the beginning and then attaches ET.SubElements for every sub-directory.

you may want to additionally sort the files and directories...

if you need a pretty-printed xml output you need this indent function (from http://effbot.org/zone/element-lib.htm#prettyprint)

def indent(elem, level=0):
    i = "\n" + level*"  "
    if len(elem):
        if not elem.text or not elem.text.strip():
            elem.text = i + "  "
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
        for elem in elem:
            indent(elem, level+1)
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
    else:
        if level and (not elem.tail or not elem.tail.strip()):
            elem.tail = i

and using that you get a nice string representation of the element tree:

ret = xml_dir(Path('/home/user/startdir/'))
indent(ret)
ET.dump(ret)

or, if you want to save the string in a variable:

strg = ET.tostring(ret, method='xml').decode()


问:
in 'for loops and range', although same range, two result differs. wanna know why
I'm currently learning python, and I found my self encountered some issue.

```<code>a={}
for i in range(0,10):
    for j in str(i):
        a[i]='%sth number'%(j)
b={}
for i in range(0,10):
    for j in range(0,10):
        b[i]='%sth number'%(j)

print(a)
print(b)
</code>```

anyone could tell why does this two are different?

答:
In the first case you are going for each element only once inside and you are looking at the version of your number as a string.

In the second case for each number from 0 to 9 you are going again from 0 till 9 and the LAST case will overwrite all the precedence (thus you are getting always 9th)

In particularly replying your query, you can add an additional if cause:

```<code>if i == j: as below. In your second case I will explain a bit more:

i=1....then j=1; b[1] =1th
still i=1...then j=2; b[1] = 2th
still i=1...then j=3; b[1] = 3th
still...
....
....
still i=1...then LAST j=9; b[1] = 9th

now you are going into i=2:
i=2....then j=1; b[2] =1th
still i=2...then j=2; b[2] = 2th
still i=2...then j=3; b[2] = 3th
still...
....
....
still i=2...then LAST j=9; b[2] = 9th
</code>```

And same will happen for all the i :-) Is it now clear?
Hope this clarify your query.

```<code>a={}
for i in range(0,10):
    for j in str(i):
        a[i]='%sth number'%(j)
b={}
for i in range(0,10):
    for j in range(0,10):
        if i == j:
            b[i]='%sth number'%(j)

print(a)
print(b)
</code>```

Body:
I'm currently learning python, and I found my self encountered some issue.

a={}
for i in range(0,10):
    for j in str(i):
        a[i]='%sth number'%(j)
b={}
for i in range(0,10):
    for j in range(0,10):
        b[i]='%sth number'%(j)

print(a)
print(b)

anyone could tell why does this two are different?

Body:
In the first case you are going for each element only once inside and you are looking at the version of your number as a string.

In the second case for each number from 0 to 9 you are going again from 0 till 9 and the LAST case will overwrite all the precedence (thus you are getting always 9th)

In particularly replying your query, you can add an additional if cause:

if i == j: as below. In your second case I will explain a bit more:

i=1....then j=1; b[1] =1th
still i=1...then j=2; b[1] = 2th
still i=1...then j=3; b[1] = 3th
still...
....
....
still i=1...then LAST j=9; b[1] = 9th

now you are going into i=2:
i=2....then j=1; b[2] =1th
still i=2...then j=2; b[2] = 2th
still i=2...then j=3; b[2] = 3th
still...
....
....
still i=2...then LAST j=9; b[2] = 9th

And same will happen for all the i :-) Is it now clear?
Hope this clarify your query.

a={}
for i in range(0,10):
    for j in str(i):
        a[i]='%sth number'%(j)
b={}
for i in range(0,10):
    for j in range(0,10):
        if i == j:
            b[i]='%sth number'%(j)

print(a)
print(b)


问:
How to detect in Jenkins Workflow if parameterized build parameter exists or not?
What is the best way that I can detect if a parameter in a parameterized build exists or not?
The closest solution I found was to do this in groovy:

```<code>node {
   groovy.lang.Binding myBinding = getBinding()
   boolean mybool = myBinding.hasVariable("STRING_PARAM1")
   echo mybool.toString()
   if (mybool) {
       echo STRING_PARAM1
       echo getProperty("STRING_PARAM1")
   } else {
       echo "STRING_PARAM1 is not defined"
   }

   mybool = myBinding.hasVariable("DID_NOT_DEFINE_THIS")
   if (mybool) {
       echo DID_NOT_DEFINE_THIS
       echo getProperty("DID_NOT_DEFINE_THIS")
   } else {
       echo "DID_NOT_DEFINE_THIS is not defined"
   }
}
</code>```

Is using getBinding() the proper API to do this, or is there a better way?

答:
You could use the params variable in the newer versions of Jenkins.

Here is how I read the PLATFORM parameter of a parametrized build. It is a String parameter.

```<code>def platform = params?.PLATFORM?.trim()

stage("checkPlatform") {
  if (platform) {
    echo "Going to build for platform: ${platform}"
    // ...
  } else {
    echo "No platform given. Cancelling build"
    error("No platform given")
  }
}
stage("..."){
    ///...
}
</code>```

There is a tutorial here: https://st-g.de/2016/12/parametrized-jenkins-pipelines

I wrote "newer versions of Jenkins" above. Here is the definition from that tutorial:

As of workflow-cps version 2.18, a new params global variable provides sane access also on the first run (by returning specified default values).

Body:
What is the best way that I can detect if a parameter in a parameterized build exists or not?
The closest solution I found was to do this in groovy:

node {
   groovy.lang.Binding myBinding = getBinding()
   boolean mybool = myBinding.hasVariable("STRING_PARAM1")
   echo mybool.toString()
   if (mybool) {
       echo STRING_PARAM1
       echo getProperty("STRING_PARAM1")
   } else {
       echo "STRING_PARAM1 is not defined"
   }

   mybool = myBinding.hasVariable("DID_NOT_DEFINE_THIS")
   if (mybool) {
       echo DID_NOT_DEFINE_THIS
       echo getProperty("DID_NOT_DEFINE_THIS")
   } else {
       echo "DID_NOT_DEFINE_THIS is not defined"
   }
}

Is using getBinding() the proper API to do this, or is there a better way?

Body:
You could use the params variable in the newer versions of Jenkins.

Here is how I read the PLATFORM parameter of a parametrized build. It is a String parameter.

def platform = params?.PLATFORM?.trim()

stage("checkPlatform") {
  if (platform) {
    echo "Going to build for platform: ${platform}"
    // ...
  } else {
    echo "No platform given. Cancelling build"
    error("No platform given")
  }
}
stage("..."){
    ///...
}

There is a tutorial here: https://st-g.de/2016/12/parametrized-jenkins-pipelines

I wrote "newer versions of Jenkins" above. Here is the definition from that tutorial:

As of workflow-cps version 2.18, a new params global variable provides sane access also on the first run (by returning specified default values).


问:
Find the smallest function in a c file
I have a c(java,c++) file with t functions in it. Is there any way, I can find out the function with smallest no. of words. </p>

<p>Given a function, I can calculate the no.of words in it using yylex(). </p>

答:
Since you haven't specified the language for implementation of the solution, I will propose a description of the algorith I would use.

You can iterate through the file and use regex to detect function prototipes (such as "^(\w+( )?){2,}\([^!@#$+%^]+?\)" for C functions). Once you've detected you have a function, you iterate through the next lines and count the words. Once you detect a line containing another function definition, you will store the function with its word count and get to the next until you reach the end of the file.

If we consider you need only the function with the least number of words, you can just store the function name only if it has fewer words than the previous one.

Title: Find the smallest function in a c file

Body:
I have a c(java,c++) file with t functions in it. Is there any way, I can find out the function with smallest no. of words.

Given a function, I can calculate the no.of words in it using yylex().


问:
List all Kafka 0.10 topics using - -zookeeper flag without access to Zookeeper
I'm using kafka 0.10 without zookeeper. I want to get kafka topics list. This command is not working since we're not using zookeeper:
bin/kafka-topics.sh --list --zookeeper localhost:2181. How can I get the same output without zookeeper?

答:
Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one.

If you do not want to install and have a separate zookeeper server, you can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.

Starting the single-node Zookeeper instance:

```<code>bin/zookeeper-server-start.sh config/zookeeper.properties
</code>```

Starting the Kafka Server:

```<code>bin/kafka-server-start.sh config/server.properties
</code>```

Listing the Topics available in Kafka:

```<code>bin/kafka-topics.sh --list --zookeeper localhost:2181
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one.

If you do not want to install and have a separate zookeeper server, you can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.

Starting the single-node Zookeeper instance:

bin/zookeeper-server-start.sh config/zookeeper.properties

Starting the Kafka Server:

bin/kafka-server-start.sh config/server.properties

Listing the Topics available in Kafka:

bin/kafka-topics.sh --list --zookeeper localhost:2181


问:
Database structure and querying hierarchal data and trees of data

Possible Duplicate:

  What is the most efficient/elegant way to parse a flat table into a tree?

This I am finding rather tricky and would like some opinions on the matter.
I am trying to store hierarchal data (tree like) with an unknown number of levels and branches. I am wanting to be able to add new ones and delete any at any time.

I need to be able to query from any node in the hierarchy for all of the children id's in one go and efficiently due to large user base.

Lets take a hypothetical example of a website where families socialise and update their status like in facebook and at any time you can be viewing a family members "Wall" which will also include all of the recent status updates form the people below them in the hierarchy in chronological order.

Obviously the fetching posts once you have the array of family members id's who are children of this family members node is easy enough in a loop.

Lets take an example simple table structure of:

```<code>id  |  parentId  |  name
________________________

1   |    NULL    |  John
2   |     1      |  Peter
3   |     1      |  Bob
4   |     3      |  Emma
5   |     2      |  Sam
6   |     4      |  Gill
</code>```

etc.... You get the idea.

I need to be able to do the above with something like this unless you think the structure needs to be adapted.

I have read up on mySql nested set model.
This seems very fiddly and could be unreliable if something was not to update correctly and would mess everything up.

I am used to using php and mysql but have been reading a bit on cassandra and thrift. Not sure if this would be easier?

答:
So I think I have come up with an idea.

The reason I am against the nested set model is because it seems like it is still not the best way and is not going to be the ideal performance solution.

I am going to cover a proposed solution I have been thinking about.
The concept means creating an hierarchal map table to keep track of all the relationships between each family member/node.

The way it would work is:

Using map table structure of this:

```<code>id  |  fMemberId   |   parentid
=====================================
1   |      3       |       2
2   |      4       |       3
3   |      4       |       2
</code>```

1) As a new family member is created as a child of a parent we would take the parents id and create a new row in our family members table with the parent id set for future additional uses and functionality.

2) As this row is created we will create new rows with all of the parent id's for the new family member.

A quick way to do this would be to take the parent id from the new family member and do a query to the map table to find all the rows with the family member id the same as the new family members parent id and then store an array in php of the subsequent parent ids required for storing alongside the new family members id in the map table. This would then only require one sql query for grabbing all the parent id's for adding them rather than a number of queries based on the number of nodes

This would mean when we are viewing a family members feed of posts we would be able to query the db for simply the rows in the map table to get all the children id's of the current family member and subsequently query other tables for the post data.

The main trade off being the amount of potential storage required for this kind of system.
However I believe reading speed would be quicker as there is no conditional SQL statements and also maybe just as quick to write to db in this way.

We could overcome this by using InnoDB's cluster id's assigning an initial family id index and creating a new table with the "next family members id" based on the family id.

Also reliability, if a row wasn't written it would be easy enough to add it in. It prevents having to continually edit rows just to create a member.

What are your thoughts on this?

So far this seems to be a good way in my opinion. Took a lot of thinking to get to here. I also believe it could maybe be improved with time and being able to store arrays of id's per member rather than all of them. Still trying to work that one out!

Body:
Possible Duplicate:

  What is the most efficient/elegant way to parse a flat table into a tree?

This I am finding rather tricky and would like some opinions on the matter.
I am trying to store hierarchal data (tree like) with an unknown number of levels and branches. I am wanting to be able to add new ones and delete any at any time.

I need to be able to query from any node in the hierarchy for all of the children id's in one go and efficiently due to large user base.

Lets take a hypothetical example of a website where families socialise and update their status like in facebook and at any time you can be viewing a family members "Wall" which will also include all of the recent status updates form the people below them in the hierarchy in chronological order.

Obviously the fetching posts once you have the array of family members id's who are children of this family members node is easy enough in a loop.

Lets take an example simple table structure of:

id  |  parentId  |  name
________________________

1   |    NULL    |  John
2   |     1      |  Peter
3   |     1      |  Bob
4   |     3      |  Emma
5   |     2      |  Sam
6   |     4      |  Gill

etc.... You get the idea.

I need to be able to do the above with something like this unless you think the structure needs to be adapted.

I have read up on mySql nested set model.
This seems very fiddly and could be unreliable if something was not to update correctly and would mess everything up.

I am used to using php and mysql but have been reading a bit on cassandra and thrift. Not sure if this would be easier?

Body:
So I think I have come up with an idea.

The reason I am against the nested set model is because it seems like it is still not the best way and is not going to be the ideal performance solution.

I am going to cover a proposed solution I have been thinking about.
The concept means creating an hierarchal map table to keep track of all the relationships between each family member/node.

The way it would work is:

Using map table structure of this:

id  |  fMemberId   |   parentid
=====================================
1   |      3       |       2
2   |      4       |       3
3   |      4       |       2

1) As a new family member is created as a child of a parent we would take the parents id and create a new row in our family members table with the parent id set for future additional uses and functionality.

2) As this row is created we will create new rows with all of the parent id's for the new family member.

A quick way to do this would be to take the parent id from the new family member and do a query to the map table to find all the rows with the family member id the same as the new family members parent id and then store an array in php of the subsequent parent ids required for storing alongside the new family members id in the map table. This would then only require one sql query for grabbing all the parent id's for adding them rather than a number of queries based on the number of nodes

This would mean when we are viewing a family members feed of posts we would be able to query the db for simply the rows in the map table to get all the children id's of the current family member and subsequently query other tables for the post data.

The main trade off being the amount of potential storage required for this kind of system.
However I believe reading speed would be quicker as there is no conditional SQL statements and also maybe just as quick to write to db in this way.

We could overcome this by using InnoDB's cluster id's assigning an initial family id index and creating a new table with the "next family members id" based on the family id.

Also reliability, if a row wasn't written it would be easy enough to add it in. It prevents having to continually edit rows just to create a member.

What are your thoughts on this?

So far this seems to be a good way in my opinion. Took a lot of thinking to get to here. I also believe it could maybe be improved with time and being able to store arrays of id's per member rather than all of them. Still trying to work that one out!

ContentLicense: CC BY-SA 2.5


问:
Deploying a webapp to a websphere application server that checks the health of the host server
If i have a webapp deployed to a specific server or host, and this webapp checks the health of the local server its deployed on when you call a get request on its URI.

The problem I am having is that if the server goes down, you can't even make a get request to the health webapp (webapp simply uses a URL object with the localhost and port path and gets the connection code).

Would creating a seperate JVM for the webapp solve this problem? or does the webapp need to be hosted entirely on another server?

i'm a beginner so have mercy.

答:
I think it's totally reasonable to use a small JSP for a health check of the server itself.

If you can't reach the JSP, it's a pretty extreme case of the server being in trouble.
If you can reach the JSP, you can query some mbeans to summarize a more detailed/nuance health.


问:
overflow on flex item embedded block
I have a flex element with fixed size, containing one flex item. This flex item have a child with overflow. I expected the overflow to be activated to allow flex item to fit into the flex element (because flex items can shrink by default). But It's not the case.

.wrapper {
  width: 500px;
  height: 100px;
  display: flex;
  flex-direction: column;
}
.pane {
  overflow: auto;
}
div {
  padding: 10px;
  background-color: rgba(255, 0, 0, 0.3);
  border: 1px solid
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrapper">
  <div class="body">
    <div class="pane">
       Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vehicula eget metus at maximus. Proin at nunc nibh. Curabitur elementum ipsum urna, ut rutrum justo consequat nec. Integer volutpat ornare nunc, ac pellentesque magna pharetra nec. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut sed turpis vitae dolor consequat elementum. Aenean in tempus nisi. Mauris varius finibus nunc, nec feugiat odio pharetra eget. Morbi maximus velit id tellus congue dignissim. Suspendisse potenti. Duis mattis ligula non purus dapibus, ac ornare urna tincidunt. Integer orci turpis, iaculis ac ornare a, dignissim sit amet libero. Cras libero risus, finibus tincidunt neque scelerisque, elementum tempus sapien.
    </div>
  </div>
</div></code>```

Here a sample
https://codepen.io/anon/pen/zzvmNR?editors=1100

It's kind of easy to fix with a display flex in the .body class but I'm trying to understand why it's not working with the first attempt.

Can someone explain me what happen?

Thanks.

答: You need to set the height or max-height to the .pane in order to have scrollbar when content overflows.</p>

Title: overflow on flex item embedded block

Body:
I have a flex element with fixed size, containing one flex item. This flex item have a child with overflow. I expected the overflow to be activated to allow flex item to fit into the flex element (because flex items can shrink by default). But It's not the case.

.wrapper {
  width: 500px;
  height: 100px;
  display: flex;
  flex-direction: column;
}
.pane {
  overflow: auto;
}
div {
  padding: 10px;
  background-color: rgba(255, 0, 0, 0.3);
  border: 1px solid
}

       Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vehicula eget metus at maximus. Proin at nunc nibh. Curabitur elementum ipsum urna, ut rutrum justo consequat nec. Integer volutpat ornare nunc, ac pellentesque magna pharetra nec. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut sed turpis vitae dolor consequat elementum. Aenean in tempus nisi. Mauris varius finibus nunc, nec feugiat odio pharetra eget. Morbi maximus velit id tellus congue dignissim. Suspendisse potenti. Duis mattis ligula non purus dapibus, ac ornare urna tincidunt. Integer orci turpis, iaculis ac ornare a, dignissim sit amet libero. Cras libero risus, finibus tincidunt neque scelerisque, elementum tempus sapien.

Here a sample
https://codepen.io/anon/pen/zzvmNR?editors=1100

It's kind of easy to fix with a display flex in the .body class but I'm trying to understand why it's not working with the first attempt.

Can someone explain me what happen?

Thanks.


问:
Windows Start command handles EXE and BAT differently, the latter is flawed
Please how can I run batch file with arguments enclosed in double quotes using the Start command?

If you use EXE file, it works (calc is just an example you can test with):

```<code>start "Some Title" "calc.exe" "arg1" "arg 2" "arg  3"
</code>```

The same syntax calling batch file does not: (in the above, only the extension was replaced)

```<code>start "Some Title" "calc.bat" "arg1" "arg 2" "arg  3"
</code>```

Error:

'calc.bat"  "arg1" "arg' is not recognized as an internal or external command,
  operable program or batch file.

(The content of calc.bat file does not matter, it can even have zero length.)

How I can achieve launching calc.bat using start command (asynchronously, in separate window) with arguments arg1, arg 2 and arg  3?

Of course, if you specify arguments without quotes, it works:

```<code>start "Some Title" "calc.bat" arg1 arg2 arg3
</code>```

EDIT:

I actually need start_all.bat which starts 3 parallel processes in 3 new windows:

```<code>set user="abc"
start "Run 1" "calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "calc.bat" "%user%" "arg 7" "arg 8" "arg 9"
</code>```

but this works only with EXE, not with BAT.

calc.bat can be something simple like

```<code>@echo 1: `%1`
@echo 2: `%2`
@echo 3: `%3`
@pause
</code>```

Additional question: What if the path with the space is present?

set user="abc"
start "Run 1" "c:\batch files\calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "c:\batch files\calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "c:\batch files\calc.bat" "%user%" "arg 7" "arg 8" "arg 9"
```

答:
you can surely call the batch like this

```<code>start "Title" calc.bat "arg1" "arg 2"
</code>```

The problem is more with your batch. Let's say you are using ping.exe in the batch. Instead of doing:

```<code>ping %1 %2 %3
</code>```

You should do:

```<code>ping %~1 %~2 %~3
</code>```

this will catch the entire args even in quotes.

so if you then do:

```<code>start ping.bat "127.0.0.1" "-n 6" "-a"
</code>```

it will work

EDIT
calc.bat should then be:

```<code>@echo 1: %~1
@echo 2: %~2
@echo 3: %~3
@pause
</code>```

Which in the example of ping.bat would do exactly this:

```<code>1: 127.0.0.1
2: -n 1
3: -a
Press any key to continue . . .
</code>```

Finaly, if you take what you mentioned in a comment to launch batch 3 times, with different paramaters for each. You would then have the content of calc.bat as this

```<code>ping %~1 %~2 %~3
ping %~4 %~5 %~6
ping %~7 %~8 %~9
</code>```

then you will do call it like this.

```<code>start calc.exe "127.0.0.1% "-n 6" "-a" "192.0.1.2" "-n 2" "-a" "128.0.9.1% "-n 1" "-a"
</code>```

LAST EDIT

If you must call start with path you need to call like this:

```<code>start "title" /D "c:\batch files" calc.bat "arg1" "arg2" "arg 3"
</code>```

So after a lot of discussion and not everyone seeming to understand how start works when commands to other files, and being persistent that /D is incorrect, here is another, yet incorrect, solution.

```<code>start "Some Title" cmd /K ^""C:\Batch Files\calc.bat" "arg1" "arg 2" "arg  3"^"
</code>```

Note, can be used with /C as well or just cmd. K will purely keep the window open.

This is more or less what was referred to in the other answer, but note you are calling cmd /K. Though this will work, it is wrong, you are calling cmd with start which in fact is also by default calling cmd. This defeats the purpose of use start either way. If start was used purely to send the title, this could have been done in the batch file already and you could have just called the batch without path.

Body:
Please how can I run batch file with arguments enclosed in double quotes using the Start command?

If you use EXE file, it works (calc is just an example you can test with):

start "Some Title" "calc.exe" "arg1" "arg 2" "arg  3"

The same syntax calling batch file does not: (in the above, only the extension was replaced)

start "Some Title" "calc.bat" "arg1" "arg 2" "arg  3"

Error:

'calc.bat"  "arg1" "arg' is not recognized as an internal or external command,
  operable program or batch file.

(The content of calc.bat file does not matter, it can even have zero length.)

How I can achieve launching calc.bat using start command (asynchronously, in separate window) with arguments arg1, arg 2 and arg  3?

Of course, if you specify arguments without quotes, it works:

start "Some Title" "calc.bat" arg1 arg2 arg3

EDIT:

I actually need start_all.bat which starts 3 parallel processes in 3 new windows:

set user="abc"
start "Run 1" "calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "calc.bat" "%user%" "arg 7" "arg 8" "arg 9"

but this works only with EXE, not with BAT.

calc.bat can be something simple like

@echo 1: `%1`
@echo 2: `%2`
@echo 3: `%3`
@pause

Additional question: What if the path with the space is present?

set user="abc"
start "Run 1" "c:\batch files\calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "c:\batch files\calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "c:\batch files\calc.bat" "%user%" "arg 7" "arg 8" "arg 9"

Body:
you can surely call the batch like this

start "Title" calc.bat "arg1" "arg 2"

The problem is more with your batch. Let's say you are using ping.exe in the batch. Instead of doing:

ping %1 %2 %3

You should do:

ping %~1 %~2 %~3

this will catch the entire args even in quotes.

so if you then do:

start ping.bat "127.0.0.1" "-n 6" "-a"

it will work

EDIT
calc.bat should then be:

@echo 1: %~1
@echo 2: %~2
@echo 3: %~3
@pause

Which in the example of ping.bat would do exactly this:

1: 127.0.0.1
2: -n 1
3: -a
Press any key to continue . . .

Finaly, if you take what you mentioned in a comment to launch batch 3 times, with different paramaters for each. You would then have the content of calc.bat as this

ping %~1 %~2 %~3
ping %~4 %~5 %~6
ping %~7 %~8 %~9

then you will do call it like this.

start calc.exe "127.0.0.1% "-n 6" "-a" "192.0.1.2" "-n 2" "-a" "128.0.9.1% "-n 1" "-a"

LAST EDIT

If you must call start with path you need to call like this:

start "title" /D "c:\batch files" calc.bat "arg1" "arg2" "arg 3"

So after a lot of discussion and not everyone seeming to understand how start works when commands to other files, and being persistent that /D is incorrect, here is another, yet incorrect, solution.

start "Some Title" cmd /K ^""C:\Batch Files\calc.bat" "arg1" "arg 2" "arg  3"^"

Note, can be used with /C as well or just cmd. K will purely keep the window open.

This is more or less what was referred to in the other answer, but note you are calling cmd /K. Though this will work, it is wrong, you are calling cmd with start which in fact is also by default calling cmd. This defeats the purpose of use start either way. If start was used purely to send the title, this could have been done in the batch file already and you could have just called the batch without path.


问:
Create a pivot table
I have the below excel data(and it is my backend)

```<code>  Date      Editor  Units
7/1/2013    Amreen  158
7/2/2013    Amreen  23
7/3/2013    Amreen  1
7/6/2013    Amreen  33
7/3/2013    Amreen  77
7/3/2013    Amreen  66
7/3/2013    Anirudh 748
7/3/2013    Amreen  8
7/6/2013    Amreen  402
7/7/2013    Amreen  24
7/7/2013    Amreen  146
7/9/2013    Amreen  33
7/8/2013    Amreen  45
7/8/2013    Amreen  21
</code>```

I want to create a pivot table using JasperReports. I'm new to this technology or framework(i'm not sure of what it is to be said as), can anybody help me to get the table in the below format with explanation. I'm really confused and unable to understand how to do it.

```<code>          Amreen    Anirudh Anand   Total
7/1/2013    158                      158
7/2/2013    23                        23
7/3/2013    152      748             900
7/4/2013
7/5/2013
7/6/2013    435                      435
7/7/2013    170                      170
7/8/2013    66                        66
7/9/2013    33               33       66
Total      1037      748     33     1818
</code>```

if not the solution please give me a reference of this type of instances (Excel and JasperReports pivot).

答: You should be using Crosstab from the Palette. First create a datasource for you report which can be excel or any RDBMS. Then when you drag and drop the Crosstab from the palette a wizard will open. Just follow the wizard and your Pivot table will be done in no time. I hope this helps. For more info link</p>

Title: Create a pivot table

Body:
I have the below excel data(and it is my backend)

  Date      Editor  Units
7/1/2013    Amreen  158
7/2/2013    Amreen  23
7/3/2013    Amreen  1
7/6/2013    Amreen  33
7/3/2013    Amreen  77
7/3/2013    Amreen  66
7/3/2013    Anirudh 748
7/3/2013    Amreen  8
7/6/2013    Amreen  402
7/7/2013    Amreen  24
7/7/2013    Amreen  146
7/9/2013    Amreen  33
7/8/2013    Amreen  45
7/8/2013    Amreen  21

I want to create a pivot table using JasperReports. I'm new to this technology or framework(i'm not sure of what it is to be said as), can anybody help me to get the table in the below format with explanation. I'm really confused and unable to understand how to do it.

          Amreen    Anirudh Anand   Total
7/1/2013    158                      158
7/2/2013    23                        23
7/3/2013    152      748             900
7/4/2013
7/5/2013
7/6/2013    435                      435
7/7/2013    170                      170
7/8/2013    66                        66
7/9/2013    33               33       66
Total      1037      748     33     1818

if not the solution please give me a reference of this type of instances (Excel and JasperReports pivot).


问:
How to use MSBuild to build multiple platforms
I am using Visual Studio online build with an MSBuild task. I currently have the following MSBuild Arguments fed to my task:

```<code>/p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86|x64|ARM";AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\";UapAppxPackageBuildMode=StoreUpload
</code>```

This creates my application in x86, x64 and ARM. It creates Release version of the libraries in x86 BUT creates Debug version of my libraries in x64 and ARM.

When my .appxupload package is creates it fails Windows Certification tests because my libraries are built in debug.

How can I make MSBuild build for all 3 configurations. My guess is because I haven't provided a /platform configuration. How do I provide this configuration for 3 platforms?

I have tried platform="x86|x64|ARM" but it returned an error

答:
For a standard project file there's no way to do this in a single command. Either use multiple commands to build the project for each platform/configuration combination needed, or use a 'master' build file which does the same for you, something like:</p>

```<code><?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="FullRebuild">
  <Target>
    <ItemGroup>
      <Configurations Include="Debug;Release"/>
      <Platforms Include="x86;x64;ARM"/>
      <ConfigAndPlatform Include="@(Configurations)">
        <Platform>%(Platforms.Identity)</Platform>
      </ConfigAndPlatform>
    </ItemGroup>
    <MSBuild Projects="myproject.sln" Targets="Build"
             Properties="Configuration=%(ConfigAndPlatform.Identity);Platform=%(ConfigAndPlatform.Platform)"/>
  </Target>
</Project>
</code>```

Body:
I am using Visual Studio online build with an MSBuild task. I currently have the following MSBuild Arguments fed to my task:

/p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86|x64|ARM";AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\";UapAppxPackageBuildMode=StoreUpload

This creates my application in x86, x64 and ARM. It creates Release version of the libraries in x86 BUT creates Debug version of my libraries in x64 and ARM.

When my .appxupload package is creates it fails Windows Certification tests because my libraries are built in debug.

How can I make MSBuild build for all 3 configurations. My guess is because I haven't provided a /platform configuration. How do I provide this configuration for 3 platforms?

I have tried platform="x86|x64|ARM" but it returned an error

Body:
For a standard project file there's no way to do this in a single command. Either use multiple commands to build the project for each platform/configuration combination needed, or use a 'master' build file which does the same for you, something like:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="FullRebuild">
  <Target>
    <ItemGroup>
      <Configurations Include="Debug;Release"/>
      <Platforms Include="x86;x64;ARM"/>
      <ConfigAndPlatform Include="@(Configurations)">
        <Platform>%(Platforms.Identity)</Platform>
      </ConfigAndPlatform>
    </ItemGroup>
    <MSBuild Projects="myproject.sln" Targets="Build"
             Properties="Configuration=%(ConfigAndPlatform.Identity);Platform=%(ConfigAndPlatform.Platform)"/>
  </Target>
</Project>


问:
I'm trying to make a function (button) to upload images to my database in CodeIgniter (PHP). But I'm getting an error
I'm trying to make a function in CodeIgniter (PHP) so users can add images to my database but I'm getting an error when I try to upload an image..

I'm using phpMyAdmin

Database name: kadokado

Table name: products

Table row name where i want to put these images to: product_foto

image folder: upload

My controller file (Product.php):

```<code>    class Product extends CI_Controller {

    var $data = array();

       public function __construct()
 {
  parent::__construct();
 }

}

     public function index()
 {
  $config = array (
   'upload_path' => 'upload/',
   'allowed_types' => 'jpg|jpeg|png|bmp',
   'max_size' => 0,
   'filename' => url_title($this->input->post('file'))

   );
   $this->load->library('upload', $config);

   if ($this->upload->do_upload('file')) {
    $this->db->insert('products', array(
        'product_foto' => $this->upload->product_foto
     ));
     $this->session->set_flashdata('msg', 'Success');
   }

  $this->load->view('product_form', $this->data);
 }
</code>```

}

This is my view file (product_form.php) :

```<code><?php
echo $this->session->flashdata('msg');
echo form_open_multipart();
echo form_upload('file');
echo form_submit('upload', 'Upload');
echo form_close();
?>
</code>```

And these are the errors I'm getting:`

```<code>  A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Upload::$product_foto

Filename: controllers/Product.php

Line Number: 21

Backtrace:

File: /home/ubuntu/workspace/application/controllers/Product.php
Line: 21
Function: _error_handler

File: /home/ubuntu/workspace/index.php
Line: 315
Function: require_once

A Database Error Occurred

Error Number: 1048

Column 'product_foto' cannot be null

INSERT INTO `products` (`product_foto`) VALUES (NULL)

Filename: controllers/Product.php

Line Number: 22
</code>```

答:
```<code>$config['upload_path']      = 'uploads/size/';
                $config['allowed_types']    = 'gif|jpg|png|jpeg';
                $config['max_size']         = '1024*20';
                $config['encrypt_name']     = true;
                $this->load->library('upload', $config);
                $uploaded   = $this->upload->do_upload('photo');   if($uploaded){                                                          $image_productimage1         = $this->upload->data();
$insert_data['size_image']  = $image_productimage1['file_name'];
// insert data into the database                                                                       }
</code>```

Body:
I'm trying to make a function in CodeIgniter (PHP) so users can add images to my database but I'm getting an error when I try to upload an image..

I'm using phpMyAdmin

Database name: kadokado

Table name: products

Table row name where i want to put these images to: product_foto

image folder: upload

My controller file (Product.php):

    class Product extends CI_Controller {

    var $data = array();

       public function __construct()
 {
  parent::__construct();
 }

}

     public function index()
 {
  $config = array (
   'upload_path' => 'upload/',
   'allowed_types' => 'jpg|jpeg|png|bmp',
   'max_size' => 0,
   'filename' => url_title($this->input->post('file'))

   );
   $this->load->library('upload', $config);

   if ($this->upload->do_upload('file')) {
    $this->db->insert('products', array(
        'product_foto' => $this->upload->product_foto
     ));
     $this->session->set_flashdata('msg', 'Success');
   }

  $this->load->view('product_form', $this->data);
 }

}

This is my view file (product_form.php) :

<?php
echo $this->session->flashdata('msg');
echo form_open_multipart();
echo form_upload('file');
echo form_submit('upload', 'Upload');
echo form_close();
?>

And these are the errors I'm getting:`

  A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Upload::$product_foto

Filename: controllers/Product.php

Line Number: 21

Backtrace:

File: /home/ubuntu/workspace/application/controllers/Product.php
Line: 21
Function: _error_handler

File: /home/ubuntu/workspace/index.php
Line: 315
Function: require_once

A Database Error Occurred

Error Number: 1048

Column 'product_foto' cannot be null

INSERT INTO `products` (`product_foto`) VALUES (NULL)

Filename: controllers/Product.php

Line Number: 22


问:
How to link youtube video without captions?
Is it possible to link youtube videos in HTML code without showing it's captions (subtitles)?

Let's say I have following video: http://www.youtube.com/watch?v=kTvHIDKLFqc . It has default english subtitles. However, when linking this video, I want to load it without them. Is there a possibility to do so with some kind of parameter in video?

I found this link with description how to do it, but it doesn't seem to work. If I try to use following format of link, it shows captions anyway: http://www.youtube.com/watch?v=kTvHIDKLFqc&cc_load_policy=0. Is it not working or did I misunderstand anything?

答:
I found the documentation to be a little misleading in that setting &cc_load_policy=1 does not show the closed captions by default, but enables toggling with the cc button in the video control bar when entered as shown here -

http://www.google.com/support/youtube/bin/answer.py?hl=en&answer=140174


问:
How to share notes data with share extension in iOS 9?
My application is working fine till iOS 8 But in iOS 9 Beta I am not able to share Notes text/image so can you please suggest me what thinks I need to implement for this? </p>

答:
What to use if I am using NSPredicate for NSExtensionActivationRule?</p>

```<code><key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <string>
            SUBQUERY(
            extensionItems,
            $extensionItem,
            SUBQUERY
            (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
            ).@count == $extensionItem.attachments.@count AND $extensionItem.attachments.@count == 1
            ).@count > 0
            OR
            SUBQUERY(
            extensionItems,
            $extensionItem,
            SUBQUERY
            (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg-2000"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.tiff"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.compuserve.gif"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.bmp"
            ).@count == $extensionItem.attachments.@count AND $extensionItem.attachments.@count < 6
            ).@count > 0
</string>
</dict>
</code>```

Body:
What to use if I am using NSPredicate for NSExtensionActivationRule?

<key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <string>
            SUBQUERY(
            extensionItems,
            $extensionItem,
            SUBQUERY
            (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
            ).@count == $extensionItem.attachments.@count AND $extensionItem.attachments.@count == 1
            ).@count > 0
            OR
            SUBQUERY(
            extensionItems,
            $extensionItem,
            SUBQUERY
            (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg-2000"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.tiff"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.compuserve.gif"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.bmp"
            ).@count == $extensionItem.attachments.@count AND $extensionItem.attachments.@count &lt; 6
            ).@count > 0
</string>
</dict>


问:
How to sum value of two json object key?
```<code>"bills": [
    {
        "refNo": 17,
        "billDate": "1-apr-2016",
        "dueDate": "30-apr-2016",
        "pendingAmount": 4500,
        "overdueDays": 28
    },
    {
        "refNo": 20,
        "billDate": "15-apr-2016",
        "dueDate": "3-may-2016",
        "pendingAmount": 56550,
        "overdueDays": 15
    }
]
</code>```

I want to sum "pendingAmount" field.
It should be return like pendingAmount: 61050

答:
The reduce() method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.

var bills = [
          {
            "refNo": 17,
            "billDate": "1-apr-2016",
            "dueDate": "30-apr-2016",
            "pendingAmount": 4500,
            "overdueDays": 28
          },
          {
            "refNo": 20,
            "billDate": "15-apr-2016",
            "dueDate": "3-may-2016",
            "pendingAmount": 56550,
            "overdueDays": 15
          }
        ];

      var result = bills.reduce(function(_this, val) {
          return _this + val.pendingAmount
      }, 0);

    console.log(result)
    //61050 answer```

Body:
"bills": [
    {
        "refNo": 17,
        "billDate": "1-apr-2016",
        "dueDate": "30-apr-2016",
        "pendingAmount": 4500,
        "overdueDays": 28
    },
    {
        "refNo": 20,
        "billDate": "15-apr-2016",
        "dueDate": "3-may-2016",
        "pendingAmount": 56550,
        "overdueDays": 15
    }
]

I want to sum "pendingAmount" field.
It should be return like pendingAmount: 61050


问:
How to use MaterialSearchView On Fragment
I am trying to add MaterialSearchView with Custom Toolbar inside a fragment.

So first I created the xml layout for it.

search_view.xml

```<code>   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/toolbar_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar2"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorAccent"/>
        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>
</LinearLayout>
</code>```

Then I added the menu Item..

```<code>    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <item android:id="@+id/action_search"
            android:title="@string/app_name"
            android:icon="@drawable/ic_action_action_search"
            app:showAsAction="collapseActionView|ifRoom"
            />
    </menu>
</code>```

Then in fragment class I added the custom actionbar. And after testing it the code worked fine. But when I added the MaterialSearchView .. The application stops responding..

So here is my java code..

```<code>    public class searchView extends Fragment{

        Toolbar search;
        MaterialSearchView search_view;
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View v =  inflater.inflate(R.layout.search_view,container,false);
            LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.search_view, container, false);

           search = (Toolbar)layout.findViewById(R.id.toolbar2);
            ((AppCompatActivity) getActivity()).setSupportActionBar(search);
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Contacts");

            return v;
        }

        @Override
        public void onCreateOptionsMenu (Menu menu, MenuInflater inflater)  {

            inflater.inflate(R.menu.search,menu);
            super.onCreateOptionsMenu(menu, inflater);
            search_view = (MaterialSearchView) getView().findViewById(R.id.search_view);
            final MenuItem item = menu.findItem(R.id.action_search);
            search_view.setMenuItem(item);
        }
    }
</code>```

The complete error log is so big.. So here is some part

```<code>   01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:143)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance0!(Native method)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   - locked <0x0cb4b03a> (a java.lang.Object[])
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:143)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance0!(Native method)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   - locked <0x0cb4b03a> (a java.lang.Object[])
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:143)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance0!(Native method)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]   Summary:
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]       503 of com.miguelcatalan.materialsearchview.MaterialSearchView (503 unique instances)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         1 of java.lang.ClassNotFoundException
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         1 of java.lang.NoClassDefFoundError
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         4 of java.lang.String (4 unique instances)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         2 of java.lang.Class (2 unique instances)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         1 of java.lang.String[] (4 elements)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]
01-17 19:46:58.178 17920-17920/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 17920 (buckydroid.chat)

                                         [ 01-17 19:46:58.178   357:  357 W/         ]
                                         debuggerd: handling request: pid=17920 uid=10147 gid=10147 tid=17920
</code>```

Thank you..

答:
Had the same problem. Change

```<code> search_view = (MaterialSearchView) getView().findViewById(R.id.search_view);
</code>```

to

```<code> search_view = (MaterialSearchView) getActivity().findViewById(R.id.search_view);
</code>```

My code for example

```<code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    setHasOptionsMenu(true);
    view = inflater.inflate(R.layout.fragment_stock, container, false);
    return view;
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.menu_main, menu);
        MaterialSearchView searchView = (MaterialSearchView) getActivity().findViewById(R.id.search_view);
        final MenuItem item = menu.findItem(R.id.action_search);
        searchView.setMenuItem(item);}
}
</code>```

Body:
I am trying to add MaterialSearchView with Custom Toolbar inside a fragment.

So first I created the xml layout for it.

search_view.xml

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/toolbar_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar2"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorAccent"/>
        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>
</LinearLayout>

Then I added the menu Item..

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <item android:id="@+id/action_search"
            android:title="@string/app_name"
            android:icon="@drawable/ic_action_action_search"
            app:showAsAction="collapseActionView|ifRoom"
            />
    </menu>

Then in fragment class I added the custom actionbar. And after testing it the code worked fine. But when I added the MaterialSearchView .. The application stops responding..

So here is my java code..

    public class searchView extends Fragment{

        Toolbar search;
        MaterialSearchView search_view;
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View v =  inflater.inflate(R.layout.search_view,container,false);
            LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.search_view, container, false);

           search = (Toolbar)layout.findViewById(R.id.toolbar2);
            ((AppCompatActivity) getActivity()).setSupportActionBar(search);
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Contacts");

            return v;
        }

        @Override
        public void onCreateOptionsMenu (Menu menu, MenuInflater inflater)  {

            inflater.inflate(R.menu.search,menu);
            super.onCreateOptionsMenu(menu, inflater);
            search_view = (MaterialSearchView) getView().findViewById(R.id.search_view);
            final MenuItem item = menu.findItem(R.id.action_search);
            search_view.setMenuItem(item);
        }
    }

The complete error log is so big.. So here is some part

   01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:143)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance0!(Native method)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   - locked <0x0cb4b03a> (a java.lang.Object[])
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:143)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance0!(Native method)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
    01-17 19:46:57.968 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   - locked <0x0cb4b03a> (a java.lang.Object[])
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:143)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance0!(Native method)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    01-17 19:46:57.969 17920-17920/? A/art: art/runtime/runtime.cc:422]   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]   Summary:
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]       503 of com.miguelcatalan.materialsearchview.MaterialSearchView (503 unique instances)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         1 of java.lang.ClassNotFoundException
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         1 of java.lang.NoClassDefFoundError
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         4 of java.lang.String (4 unique instances)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         2 of java.lang.Class (2 unique instances)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]         1 of java.lang.String[] (4 elements)
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]
01-17 19:46:58.178 17920-17920/? A/art: art/runtime/runtime.cc:427]
01-17 19:46:58.178 17920-17920/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 17920 (buckydroid.chat)

                                         [ 01-17 19:46:58.178   357:  357 W/         ]
                                         debuggerd: handling request: pid=17920 uid=10147 gid=10147 tid=17920

Thank you..

Body:
Had the same problem. Change

 search_view = (MaterialSearchView) getView().findViewById(R.id.search_view);

to

 search_view = (MaterialSearchView) getActivity().findViewById(R.id.search_view);

My code for example

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    setHasOptionsMenu(true);
    view = inflater.inflate(R.layout.fragment_stock, container, false);
    return view;
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.menu_main, menu);
        MaterialSearchView searchView = (MaterialSearchView) getActivity().findViewById(R.id.search_view);
        final MenuItem item = menu.findItem(R.id.action_search);
        searchView.setMenuItem(item);}
}


问:
Firebase check if user's displayname/username is unique
I would like to ensure that before attempting to sign up a displayName is unique. I have a user table like this:

```<code>$uid: {
  ..data..
  displayName: 'noob839',
}
</code>```

I have done an ".indexOn": ["displayName"] to optimise this, now I need to (from the client) check every user to see if displayName value is already taken.

It is very important that the current user can only read that field of another user.

Is this a recommended approach? How would I go about iterating over every user to see if the display name is unique? Thanks in advance.

P.S. Since we cannot attach data to users we must make a seperate user object which complicates app design since it adds another point of failure for sign ups, and data retrieval (a two step process). That's a shame!

答:
Query on that name so you are not looping through the users:

This is in Angular2 but can converted to the appropriate language (what I had already)

```<code>/*
    Available username
*/
public availUsername(displayName: string): Observable<any[]> {
    this.users = this.AF.database.list("users", {
        query: {
            orderByChild: 'displayName',
            equalTo: displayName
        }
    }).first();
    return this.users;
}

this.availUsername("theblindprophet").
   subscribe(response => {
       if(response.length == 0) {
           // No one has this displayName
       } else {
           // someone has it
       }
   });
</code>```

If there are no results (array length of 0) then no one has that name.

Assumed you have users stored under users.

Body:
I would like to ensure that before attempting to sign up a displayName is unique. I have a user table like this:

$uid: {
  ..data..
  displayName: 'noob839',
}

I have done an ".indexOn": ["displayName"] to optimise this, now I need to (from the client) check every user to see if displayName value is already taken.

It is very important that the current user can only read that field of another user.

Is this a recommended approach? How would I go about iterating over every user to see if the display name is unique? Thanks in advance.

P.S. Since we cannot attach data to users we must make a seperate user object which complicates app design since it adds another point of failure for sign ups, and data retrieval (a two step process). That's a shame!

Body:
Query on that name so you are not looping through the users:

This is in Angular2 but can converted to the appropriate language (what I had already)

/*
    Available username
*/
public availUsername(displayName: string): Observable<any[]> {
    this.users = this.AF.database.list("users", {
        query: {
            orderByChild: 'displayName',
            equalTo: displayName
        }
    }).first();
    return this.users;
}

this.availUsername("theblindprophet").
   subscribe(response => {
       if(response.length == 0) {
           // No one has this displayName
       } else {
           // someone has it
       }
   });

If there are no results (array length of 0) then no one has that name.

Assumed you have users stored under users.


问:
I am getting the below error while trying to execute spark submit using oozie on emr
I am running on cluster mode. The apacheds-kerberos-codec-2.0.0-M15.jar is present in multiple places in oozie/share/lib/lib*/spark and oozie/share/lib/lib*/oozie. Is this an environmental issue ?</p>

```<code>ava.lang.IllegalArgumentException: Attempt to add (hdfs://ip-172-20-10-53.ec2.internal:8020/user/oozie/share/lib/lib_20170208121307/oozie/apacheds-kerberos-codec-2.0.0-M15.jar) multiple times to the distributed cache.
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11$$anonfun$apply$8.apply(Client.scala:608)
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11$$anonfun$apply$8.apply(Client.scala:599)
    at scala.collection.mutable.ArraySeq.foreach(ArraySeq.scala:74)
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11.apply(Client.scala:599)
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11.apply(Client.scala:598)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at org.apache.spark.deploy.yarn.Client.prepareLocalResources(Client.scala:598)
    at org.apache.spark.deploy.yarn.Client.createContainerLaunchContext(Client.scala:868)
    at org.apache.spark.deploy.yarn.Client.submitApplication(Client.scala:170)
    at org.apache.spark.deploy.yarn.Client.run(Client.scala:1154)
    at org.apache.spark.deploy.yarn.Client$.main(Client.scala:1213)
    at org.apache.spark.deploy.yarn.Client.main(Client.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
    at org.apache.oozie.action.hadoop.SparkMain.runSpark(SparkMain.java:338)
    at org.apache.oozie.action.hadoop.SparkMain.run(SparkMain.java:257)
    at org.apache.oozie.action.hadoop.LauncherMain.run(LauncherMain.java:60)
    at org.apache.oozie.action.hadoop.SparkMain.main(SparkMain.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.oozie.action.hadoop.LauncherMapper.map(LauncherMapper.java:232)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:455)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:344)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler.runSubtask(LocalContainerLauncher.java:380)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler.runTask(LocalContainerLauncher.java:301)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler.access$200(LocalContainerLauncher.java:187)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler$1.run(LocalContainerLauncher.java:230)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
</code>```

答: I have an oozie job that starts a spark job, running in Amazon EMR. I got the same error when the EMR Hadoop setup has one instance for the master and one instance for the slaves. When I increased the amount of instances for the slaves to two, everything worked as expected.</p>

Body:
I am running on cluster mode. The apacheds-kerberos-codec-2.0.0-M15.jar is present in multiple places in oozie/share/lib/lib*/spark and oozie/share/lib/lib*/oozie. Is this an environmental issue ?

ava.lang.IllegalArgumentException: Attempt to add (hdfs://ip-172-20-10-53.ec2.internal:8020/user/oozie/share/lib/lib_20170208121307/oozie/apacheds-kerberos-codec-2.0.0-M15.jar) multiple times to the distributed cache.
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11$$anonfun$apply$8.apply(Client.scala:608)
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11$$anonfun$apply$8.apply(Client.scala:599)
    at scala.collection.mutable.ArraySeq.foreach(ArraySeq.scala:74)
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11.apply(Client.scala:599)
    at org.apache.spark.deploy.yarn.Client$$anonfun$prepareLocalResources$11.apply(Client.scala:598)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at org.apache.spark.deploy.yarn.Client.prepareLocalResources(Client.scala:598)
    at org.apache.spark.deploy.yarn.Client.createContainerLaunchContext(Client.scala:868)
    at org.apache.spark.deploy.yarn.Client.submitApplication(Client.scala:170)
    at org.apache.spark.deploy.yarn.Client.run(Client.scala:1154)
    at org.apache.spark.deploy.yarn.Client$.main(Client.scala:1213)
    at org.apache.spark.deploy.yarn.Client.main(Client.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
    at org.apache.oozie.action.hadoop.SparkMain.runSpark(SparkMain.java:338)
    at org.apache.oozie.action.hadoop.SparkMain.run(SparkMain.java:257)
    at org.apache.oozie.action.hadoop.LauncherMain.run(LauncherMain.java:60)
    at org.apache.oozie.action.hadoop.SparkMain.main(SparkMain.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.oozie.action.hadoop.LauncherMapper.map(LauncherMapper.java:232)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:455)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:344)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler.runSubtask(LocalContainerLauncher.java:380)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler.runTask(LocalContainerLauncher.java:301)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler.access$200(LocalContainerLauncher.java:187)
    at org.apache.hadoop.mapred.LocalContainerLauncher$EventHandler$1.run(LocalContainerLauncher.java:230)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)


问:
ICAL Wrong date in outlook (windows and android) but good in Google Calendar and Iphone ical
Hi There im busy with an i cal calendar.
But he display wrong date:

```<code>BEGIN:VEVENT
SUMMARY:TEST EVENT!
UID:140
STATUS:CONFIRMED
DTSTAMP;TZID=Europe/Amsterdam:20170610T220000Z
DTSTART;TZID=Europe/Amsterdam:20170610T220000Z
DTEND;TZID=Europe/Amsterdam:20170610T220000Z
LAST-MODIFIED:20170608T064314Z
LOCATION:STREET 1 1111 AA CITY
END:VEVENT
END:VCALENDAR
</code>```

This sould be date: 11/06/2017 22:00 (Day time Amsterdam)
In Outlook is the date: 11/06/2017 00:00 (Day time Amsterdam)

This is the rest of my code:

```<code>BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//2017/TEST CALENDAR//EN
BEGIN:VTIMEZONE
TZID:Europe/Amsterdam
BEGIN:STANDARD
DTSTART:20151025T020000
RDATE:20160327T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:Europe/Amsterdam CET
END:STANDARD
BEGIN:STANDARD
DTSTART:20161030T020000
RDATE:20170326T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:Europe/Amsterdam CET
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20150601T073000
RDATE:20151025T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:Europe/Amsterdam CEST
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20160327T030000
RDATE:20161030T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:Europe/Amsterdam CEST
END:DAYLIGHT
</code>```

I hope someone can help me out!
Thanks alot!

My php code which generate the Ical is below:

```<code><?php
date_default_timezone_set('Europe/Amsterdam');
$querystr ="
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND ( $wpdb->posts.post_status = 'confirmed'
OR $wpdb->posts.post_status = 'pending'
)
ORDER BY $wpdb->posts.post_date DESC";
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
<?php
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=TESTAGENDA.ics");
// the iCal date format. Note the Z on the end indicates a UTC timestamp.
define('DATE_ICAL', 'Ymd\THis\Z');
// max line length is 75 chars. New line is \\n
$output = "BEGIN:VCALENDAR\r\n";
$output .= "METHOD:PUBLISH\r\n";
$output .= "VERSION:2.0\r\n";
$output .= "PRODID:-//2017/TEST AGENDA//EN\r\n";

$output .= "BEGIN:VTIMEZONE\r\n";
$output .= "TZID:Europe/Amsterdam\r\n";
$output .= "BEGIN:STANDARD\r\n";
$output .= "DTSTART:20151025T020000\r\n";
$output .= "RDATE:20160327T030000\r\n";
$output .= "TZOFFSETFROM:+0200\r\n";
$output .= "TZOFFSETTO:+0100\r\n";
$output .= "TZNAME:Europe/Amsterdam CET\r\n";
$output .= "END:STANDARD\r\n";
$output .= "BEGIN:STANDARD\r\n";
$output .= "DTSTART:20161030T020000\r\n";
$output .= "RDATE:20170326T030000\r\n";
$output .= "TZOFFSETFROM:+0200\r\n";
$output .= "TZOFFSETTO:+0100\r\n";
$output .= "TZNAME:Europe/Amsterdam CET\r\n";
$output .= "END:STANDARD\r\n";
$output .= "BEGIN:DAYLIGHT\r\n";
$output .= "DTSTART:20150601T073000\r\n";
$output .= "RDATE:20151025T020000\r\n";
$output .= "TZOFFSETFROM:+0100\r\n";
$output .= "TZOFFSETTO:+0200\r\n";
$output .= "TZNAME:Europe/Amsterdam CEST\r\n";
$output .= "END:DAYLIGHT\r\n";
$output .= "BEGIN:DAYLIGHT\r\n";
$output .= "DTSTART:20160327T030000\r\n";
$output .= "RDATE:20161030T020000\r\n";
$output .= "TZOFFSETFROM:+0100\r\n";
$output .= "TZOFFSETTO:+0200\r\n";
$output .= "TZNAME:Europe/Amsterdam CEST\r\n";
$output .= "END:DAYLIGHT\r\n";
$output .= "END:VTIMEZONE\r\n";
?>
<?php if ($pageposts){ ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post): ?>
<?php $postmeta_reservering = get_post_meta( get_the_ID(), 'rtb', true );
if ( ! empty( $postmeta_reservering ) ) {
    $aantalpersonen = $postmeta_reservering['party'];
    $emailadres = $postmeta_reservering['email'];
    $telefoonnr = $postmeta_reservering['phone'];
    $ipadres = $postmeta_reservering['ip'];
}
?>
<?php setup_postdata($post); ?>
<?php if($post->post_status == 'confirmed'){$poststatus = 'CONFIRMED';}else{$poststatus = 'IN-PROCESS';}
$output .= "BEGIN:VEVENT\r\n";
$output .= "SUMMARY:".$post->post_title." Tel.:".$telefoonnr." (".$aantalpersonen." pers.)\r\n";
$output .= "UID:".$post->ID."\r\n";
$output .= "STATUS:".$poststatus."\r\n";
$output .= "DTSTAMP;TZID=Europe/Amsterdam:".date(DATE_ICAL, strtotime($post->post_date))."\r\n";
$output .= "DTSTART;TZID=Europe/Amsterdam:".date(DATE_ICAL, strtotime($post->post_date))."\r\n";
$output .= "DTEND;TZID=Europe/Amsterdam:".date(DATE_ICAL, strtotime($post->post_date))."\r\n";
$output .= "LAST-MODIFIED:".date(DATE_ICAL, strtotime($post->post_modified))."\r\n";
$output .= "LOCATION:STREET 01 1111 AA CITY\r\n";
$output .= "END:VEVENT\r\n";?>
<?php endforeach; ?>
<?php
// close calendar
$output .= "END:VCALENDAR";
// loop over events
echo $output;
?>
<?php }else{ ?>
    <span>No event!</span>
<?php } ?>
</code>```

答:
You are using a datetime format with timezone but in the meantime, you are suffixing those with a Z which indicates zulu/UTC time. So different clients will pick up a different interpretation.

Just remove the final Z from DTSTART and DTEND fields. DTSTAMP is expressed in zulu time only. Finally, your DTEND is equal to your DTSTART which is not legal (must be later in time, see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.2.2 )

```<code>DTSTAMP:20170610T220000Z
DTSTART;TZID=Europe/Amsterdam:20170610T220000
DTEND;TZID=Europe/Amsterdam:20170610T230000
</code>```

Body:
Hi There im busy with an i cal calendar.
But he display wrong date:

BEGIN:VEVENT
SUMMARY:TEST EVENT!
UID:140
STATUS:CONFIRMED
DTSTAMP;TZID=Europe/Amsterdam:20170610T220000Z
DTSTART;TZID=Europe/Amsterdam:20170610T220000Z
DTEND;TZID=Europe/Amsterdam:20170610T220000Z
LAST-MODIFIED:20170608T064314Z
LOCATION:STREET 1 1111 AA CITY
END:VEVENT
END:VCALENDAR

This sould be date: 11/06/2017 22:00 (Day time Amsterdam)
In Outlook is the date: 11/06/2017 00:00 (Day time Amsterdam)

This is the rest of my code:

BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//2017/TEST CALENDAR//EN
BEGIN:VTIMEZONE
TZID:Europe/Amsterdam
BEGIN:STANDARD
DTSTART:20151025T020000
RDATE:20160327T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:Europe/Amsterdam CET
END:STANDARD
BEGIN:STANDARD
DTSTART:20161030T020000
RDATE:20170326T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:Europe/Amsterdam CET
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20150601T073000
RDATE:20151025T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:Europe/Amsterdam CEST
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20160327T030000
RDATE:20161030T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:Europe/Amsterdam CEST
END:DAYLIGHT

I hope someone can help me out!
Thanks alot!

My php code which generate the Ical is below:

<?php
date_default_timezone_set('Europe/Amsterdam');
$querystr ="
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND ( $wpdb->posts.post_status = 'confirmed'
OR $wpdb->posts.post_status = 'pending'
)
ORDER BY $wpdb->posts.post_date DESC";
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
<?php
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=TESTAGENDA.ics");
// the iCal date format. Note the Z on the end indicates a UTC timestamp.
define('DATE_ICAL', 'Ymd\THis\Z');
// max line length is 75 chars. New line is \\n
$output = "BEGIN:VCALENDAR\r\n";
$output .= "METHOD:PUBLISH\r\n";
$output .= "VERSION:2.0\r\n";
$output .= "PRODID:-//2017/TEST AGENDA//EN\r\n";

$output .= "BEGIN:VTIMEZONE\r\n";
$output .= "TZID:Europe/Amsterdam\r\n";
$output .= "BEGIN:STANDARD\r\n";
$output .= "DTSTART:20151025T020000\r\n";
$output .= "RDATE:20160327T030000\r\n";
$output .= "TZOFFSETFROM:+0200\r\n";
$output .= "TZOFFSETTO:+0100\r\n";
$output .= "TZNAME:Europe/Amsterdam CET\r\n";
$output .= "END:STANDARD\r\n";
$output .= "BEGIN:STANDARD\r\n";
$output .= "DTSTART:20161030T020000\r\n";
$output .= "RDATE:20170326T030000\r\n";
$output .= "TZOFFSETFROM:+0200\r\n";
$output .= "TZOFFSETTO:+0100\r\n";
$output .= "TZNAME:Europe/Amsterdam CET\r\n";
$output .= "END:STANDARD\r\n";
$output .= "BEGIN:DAYLIGHT\r\n";
$output .= "DTSTART:20150601T073000\r\n";
$output .= "RDATE:20151025T020000\r\n";
$output .= "TZOFFSETFROM:+0100\r\n";
$output .= "TZOFFSETTO:+0200\r\n";
$output .= "TZNAME:Europe/Amsterdam CEST\r\n";
$output .= "END:DAYLIGHT\r\n";
$output .= "BEGIN:DAYLIGHT\r\n";
$output .= "DTSTART:20160327T030000\r\n";
$output .= "RDATE:20161030T020000\r\n";
$output .= "TZOFFSETFROM:+0100\r\n";
$output .= "TZOFFSETTO:+0200\r\n";
$output .= "TZNAME:Europe/Amsterdam CEST\r\n";
$output .= "END:DAYLIGHT\r\n";
$output .= "END:VTIMEZONE\r\n";
?>
<?php if ($pageposts){ ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post): ?>
<?php $postmeta_reservering = get_post_meta( get_the_ID(), 'rtb', true );
if ( ! empty( $postmeta_reservering ) ) {
    $aantalpersonen = $postmeta_reservering['party'];
    $emailadres = $postmeta_reservering['email'];
    $telefoonnr = $postmeta_reservering['phone'];
    $ipadres = $postmeta_reservering['ip'];
}
?>
<?php setup_postdata($post); ?>
<?php if($post->post_status == 'confirmed'){$poststatus = 'CONFIRMED';}else{$poststatus = 'IN-PROCESS';}
$output .= "BEGIN:VEVENT\r\n";
$output .= "SUMMARY:".$post->post_title." Tel.:".$telefoonnr." (".$aantalpersonen." pers.)\r\n";
$output .= "UID:".$post->ID."\r\n";
$output .= "STATUS:".$poststatus."\r\n";
$output .= "DTSTAMP;TZID=Europe/Amsterdam:".date(DATE_ICAL, strtotime($post->post_date))."\r\n";
$output .= "DTSTART;TZID=Europe/Amsterdam:".date(DATE_ICAL, strtotime($post->post_date))."\r\n";
$output .= "DTEND;TZID=Europe/Amsterdam:".date(DATE_ICAL, strtotime($post->post_date))."\r\n";
$output .= "LAST-MODIFIED:".date(DATE_ICAL, strtotime($post->post_modified))."\r\n";
$output .= "LOCATION:STREET 01 1111 AA CITY\r\n";
$output .= "END:VEVENT\r\n";?>
<?php endforeach; ?>
<?php
// close calendar
$output .= "END:VCALENDAR";
// loop over events
echo $output;
?>
<?php }else{ ?>
    No event!
<?php } ?>

Body:
You are using a datetime format with timezone but in the meantime, you are suffixing those with a Z which indicates zulu/UTC time. So different clients will pick up a different interpretation.

Just remove the final Z from DTSTART and DTEND fields. DTSTAMP is expressed in zulu time only. Finally, your DTEND is equal to your DTSTART which is not legal (must be later in time, see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.2.2 )

DTSTAMP:20170610T220000Z
DTSTART;TZID=Europe/Amsterdam:20170610T220000
DTEND;TZID=Europe/Amsterdam:20170610T230000