问:
table rows and cells are broken
I have the following styling and HTML, but when it displays, the table appears broken (all the table rows and cells are broken). I'm not sure why; how can I fix it?

the tbody need have this size: height: calc(100vh - 130px);

the red line defines the size of the table.

edit: my tbody need have scroll and the thead need be fixed.

jsfiddle: https://jsfiddle.net/zuxq2gr0/11/

.col-lg-12 {
  border: 1px solid red;
}

tbody {
  display: block;
  overflow-y: scroll;
  height: calc(100vh - 130px);
}

tbody > tr {
  display: table;
  width: 100%;
}```

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

          test
          test
          test
          test
          test

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          <compose view="./-box.html"></compose>

```

答:
I think what you are wanting is the tbody to still be scrollable. You were on the right track with making it Block, but to maintain the width of the Row you'll need to make your thead block as well

```<code>tbody,thead {
    display:block;
}

tbody{
    overflow-y: auto;
    height: calc(100vh - 130px);

}
</code>```

Fiddle

You'll notice the Thead columns are not in line, the only way I know to fix this is via JS or styling each column width with CSS.

Here a link to another stack article:

HTML table with 100% width, with vertical scroll inside tbody

Title: table rows and cells are broken

Body:
I have the following styling and HTML, but when it displays, the table appears broken (all the table rows and cells are broken). I'm not sure why; how can I fix it?

the tbody need have this size: height: calc(100vh - 130px);

the red line defines the size of the table.

edit: my tbody need have scroll and the thead need be fixed.

jsfiddle: https://jsfiddle.net/zuxq2gr0/11/

.col-lg-12 {
  border: 1px solid red;
}

tbody {
  display: block;
  overflow-y: scroll;
  height: calc(100vh - 130px);
}

tbody > tr {
  display: table;
  width: 100%;
}

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

          test
          test
          test
          test
          test

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          test
          test
          test

              <select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
                <option value="" selected=""></option>
                <option value="-action"> Action</option>
              </select>

          <compose view="./-box.html"></compose>

Body:
I think what you are wanting is the tbody to still be scrollable. You were on the right track with making it Block, but to maintain the width of the Row you'll need to make your thead block as well

tbody,thead {
    display:block;
}

tbody{
    overflow-y: auto;
    height: calc(100vh - 130px);

}

Fiddle

You'll notice the Thead columns are not in line, the only way I know to fix this is via JS or styling each column width with CSS.

Here a link to another stack article:

HTML table with 100% width, with vertical scroll inside tbody


来源: stackexchange

问:
PHP searching array
I am creating a contact form, which needs to change the sendto address based on an entered postal code.

I have an array of postal codes which I can search trough, so that I know if the postal code entered is actually in the array.

Here's how I search trough the array:

```<code>$districts = json_decode('{
 "district" : [
 { "name": "District A", "email": "abc@example.com", "url": "district-a", "postalcodes": ["3311AA","3311AB"] },
 { "name": "District B", "email": "xyz@example.com", "url": "district-b", "postalcodes": ["3317EA","3317EB","3317EC"] },
 ]
}',true);

$results = array_filter($districts['district'], function($district) {
    $key = array_search('3311AB', $district['postalcodes']);
  return $key;
});

var_dump($results);
</code>```

Now I need to return the email address, based on in which District the postal code is found.

How would I search for, for example, postal code 3311AB and return the email adress of the district to which it belongs?

答:
Instead of returning key of postal code, you need to return $district['email']

```<code>$emails = [];

foreach ($districts['district'] as $district) {
    if (in_array('3311AB', $district['postalcodes'])) {
        $emails[] = $district['email'];
    }
}

var_dump($emails);
</code>```

Example

ContentLicense: CC BY-SA 3.0

Title: PHP searching array

Body:
I am creating a contact form, which needs to change the sendto address based on an entered postal code.

I have an array of postal codes which I can search trough, so that I know if the postal code entered is actually in the array.

Here's how I search trough the array:

$districts = json_decode('{
 "district" : [
 { "name": "District A", "email": "abc@example.com", "url": "district-a", "postalcodes": ["3311AA","3311AB"] },
 { "name": "District B", "email": "xyz@example.com", "url": "district-b", "postalcodes": ["3317EA","3317EB","3317EC"] },
 ]
}',true);

$results = array_filter($districts['district'], function($district) {
    $key = array_search('3311AB', $district['postalcodes']);
  return $key;
});

var_dump($results);

Now I need to return the email address, based on in which District the postal code is found.

How would I search for, for example, postal code 3311AB and return the email adress of the district to which it belongs?

Body:
Instead of returning key of postal code, you need to return $district['email']

$emails = [];

foreach ($districts['district'] as $district) {
    if (in_array('3311AB', $district['postalcodes'])) {
        $emails[] = $district['email'];
    }
}

var_dump($emails);

Example


问:
Downloading folders from Google Cloud Storage Bucket
I'm new to Google Cloud Platform.I have trained my model on datalab and saved the model folder on cloud storage in my bucket. I'm able to download the existing files in the bucket to my local machine by doing right-click on the file --> save as link. But when I try to download the folder by the same procedure as above, I'm not getting the folder but its image. Is there anyway I can download the whole folder and its contents as it is? Is there any gsutil command to copy folders from cloud storage to local directory?</p>

答:
You can find docs on the gsutil tool here and for your question more specifically here.

The command you want to use is:

```<code>gsutil cp -r gs://bucket/folder .
</code>```

Body:
You can find docs on the gsutil tool here and for your question more specifically here.

The command you want to use is:

gsutil cp -r gs://bucket/folder .


问:
Facebook sdk for python cannot limit page feed query with 'since'
I'm trying to fetch all posts on specific page after certain time. I'm using this facebook-sdk for python. Last post on the page has been posted 30th may 2017. The problem with my query is that even if I try to limit the query with since='2017-06-06T09:00:00+00:00', it always returns my posts from the page.

My timestamp is in exact same format as I get it if I query it from the facebook.

Here's the code

```<code>facebook_api = facebook.GraphAPI(access_token='FACEBOOK_PAGE_ACCESS_TOKEN')
facebook_feed = facebook_api.get_object(
            id=FACEBOOK_PAGE_ID,
            fields='feed',
            since='2017-06-06T09:00:00+0000'
)
</code>```

I don't have a clue what kind of api query url facebook-sdk for python creates with this code and I don't know how to check that.

I also tried converting timestamp to unix timestamp with online tool, but it didn't work either.

答:
get_object() will query the root node directly, not the non-root nodes. Use get_connections() instead.

Read more here about objects: https://developers.facebook.com/docs/graph-api/reference/

Try below code, it works for me.

```<code>import facebook

facebook_api = facebook.GraphAPI(access_token='YOUR_ACCESS_TOKEN')
facebook_feed = facebook_api.get_connections('YOUR_PAGE_ID', 'feed', since=1496707200)

print facebook_feed['data']
</code>```

Body:
I'm trying to fetch all posts on specific page after certain time. I'm using this facebook-sdk for python. Last post on the page has been posted 30th may 2017. The problem with my query is that even if I try to limit the query with since='2017-06-06T09:00:00+00:00', it always returns my posts from the page.

My timestamp is in exact same format as I get it if I query it from the facebook.

Here's the code

facebook_api = facebook.GraphAPI(access_token='FACEBOOK_PAGE_ACCESS_TOKEN')
facebook_feed = facebook_api.get_object(
            id=FACEBOOK_PAGE_ID,
            fields='feed',
            since='2017-06-06T09:00:00+0000'
)

I don't have a clue what kind of api query url facebook-sdk for python creates with this code and I don't know how to check that.

I also tried converting timestamp to unix timestamp with online tool, but it didn't work either.

Body:
get_object() will query the root node directly, not the non-root nodes. Use get_connections() instead.

Read more here about objects: https://developers.facebook.com/docs/graph-api/reference/

Try below code, it works for me.

import facebook

facebook_api = facebook.GraphAPI(access_token='YOUR_ACCESS_TOKEN')
facebook_feed = facebook_api.get_connections('YOUR_PAGE_ID', 'feed', since=1496707200)

print facebook_feed['data']


问:
How can I make my icon
s show up next to each other, rather than underneath each other?
I have this

```<code><a href="#"><div class="iconFriends"></div></a>
<a href="#"><div class="iconFavorite"></div></a>
<a href="#"><div class="iconPM"></div></a>
<a href="#"><div class="iconShield"></div></a>
</code>```

and the css for the icons class looks all similiar to this:

```<code>.iconFriends{
background: url(../images/icons/friends_16x16.png) no-repeat;
width: 16px;
height: 16px;
border: none;
}
</code>```

Now the results is that there is like a
 when I do this. But if i remove the div and make a normal  It shows fine. How can i fix this?

答:
set your divs to have display:inline-block or better yet remove the divs and apply the styling to the a tags directly (again with display:inline-block)

html

```<code><a href="#" class="iconFriends"></a>
<a href="#" class="iconFavorite"></a>
<a href="#" class="iconPM"></a>
<a href="#" class="iconShield"></a>
</code>```

css

```<code>.iconFriends{
   background: url(../images/icons/friends_16x16.png) no-repeat;
   width: 16px;
   height: 16px;
   border: none;

   display:inline-block;
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: How can I make my icon <div>s show up next to each other, rather than underneath each other?

Body:
I have this

and the css for the icons class looks all similiar to this:

.iconFriends{
background: url(../images/icons/friends_16x16.png) no-repeat;
width: 16px;
height: 16px;
border: none;
}

Now the results is that there is like a
 when I do this. But if i remove the div and make a normal  It shows fine. How can i fix this?

Body:
set your divs to have display:inline-block or better yet remove the divs and apply the styling to the a tags directly (again with display:inline-block)

html

<a href="#" class="iconFriends"></a>
<a href="#" class="iconFavorite"></a>
<a href="#" class="iconPM"></a>
<a href="#" class="iconShield"></a>

css

.iconFriends{
   background: url(../images/icons/friends_16x16.png) no-repeat;
   width: 16px;
   height: 16px;
   border: none;

   display:inline-block;
}


问:
Computed column, or update column by trigger to keep statistics
For every user, our application calculates some statistics, like how many times they logged in or how many answers they got wrong in the quiz, ... it can be all sorts of things. The app runs on SQL Server and .NET Entity Framework 6.1

Right now, the statistics are calculated on demand but as the user base grows, this makes the reporting part of the application ever slower.

We were wondering about either using computed columns (either persisted or not persisted) or use a trigger to store these values with the user.

How would you go about doing this? It seems to me that computed columns may be easier to implement, but they would get recalculated every time I read the User from the table, which may not be very much faster than what we're doing now. Since we would fit an entire SQL query into the computed column, persisting the column does not seem a right fit either (how will SQL Server deduce that it should update the calculation?).
A trigger on certain actions seems to be a more logical fit for me.

For the sake of the argument, suppose all the calculated statistics are count(*) and sum(*) of values in other tables and nothing more interesting than that.

答:
For the sake of the argument, suppose all the calculated statistics are count() and sum() of values and nothing more interesting than that.

Since your operations for reporting are simple enough, I'd recommend a reporting table/audit log table for these statistics.

Basic premise is that all reports can be obtained as a variation of a simple query like

```<code>SELECT COUNT(*) FROM tblUserLog (NO LOCK) WHERE UserID=34
</code>```

or in a slightly complex query like

```<code>SELECT
  COUNT(*) OVER(PARTITION BY colA ORDER BY colB) as Metric1,
  SUM(*) OVER (PARTITION BY colD ORDER BY colC) as Metric2
FROM tblUserLog (NO LOCK) WHERE UserID =34
</code>```

Main problem is now how to populate this table tblUserLog and what should be the composition.

Composition:

The schema of of the tables should be generic and must satisfy all your reporting needs like columns to count on or sum on. Say something on the lines of

```<code>LogID (PK, auto increment)
LogDateTimestamp
LogType
UserID
MetricToSum1
MetricToSum2
....
</code>```

This is rather de-normalized table; and I would not recommend normalizing it.

How to populate:

This should definitely not be done via triggers. Looking at the best possible alternatives, and assuming that your web application has a well tiered architecture; you should have a log method in place which can insert into the DB table necessary details asynchronously. So basically writing on the table happens asynchronously along with the main user table CRUD and reading on demand
whenever report are needed.

For a very simple operations I would suggest you to simply implement a view over the main entity table like User. An example of this sort be a view which returns say the count of active users for admin reporting.

Body:
For the sake of the argument, suppose all the calculated statistics are count() and sum() of values and nothing more interesting than that.

Since your operations for reporting are simple enough, I'd recommend a reporting table/audit log table for these statistics.

Basic premise is that all reports can be obtained as a variation of a simple query like

SELECT COUNT(*) FROM tblUserLog (NO LOCK) WHERE UserID=34

or in a slightly complex query like

SELECT
  COUNT(*) OVER(PARTITION BY colA ORDER BY colB) as Metric1,
  SUM(*) OVER (PARTITION BY colD ORDER BY colC) as Metric2
FROM tblUserLog (NO LOCK) WHERE UserID =34

Main problem is now how to populate this table tblUserLog and what should be the composition.

Composition:

The schema of of the tables should be generic and must satisfy all your reporting needs like columns to count on or sum on. Say something on the lines of

LogID (PK, auto increment)
LogDateTimestamp
LogType
UserID
MetricToSum1
MetricToSum2
....

This is rather de-normalized table; and I would not recommend normalizing it.

How to populate:

This should definitely not be done via triggers. Looking at the best possible alternatives, and assuming that your web application has a well tiered architecture; you should have a log method in place which can insert into the DB table necessary details asynchronously. So basically writing on the table happens asynchronously along with the main user table CRUD and reading on demand
whenever report are needed.

For a very simple operations I would suggest you to simply implement a view over the main entity table like User. An example of this sort be a view which returns say the count of active users for admin reporting.


问:
Run Gulp script with forever?
Is it possible to run Gulp script with forever?

I have Gulp script that would like to run as a daemon, so I could start / stop / list it.

答:
Try this:

forever start -c "gulp" serve

The -c option allows you to use any command.

Title: Run Gulp script with forever?


问:
Listing 'rake routes' for a mountable Rails 3.1 engine
I'm working on a mountable engine for use with Rails 3.1, and I want to list the engine's routes.

I created the engine using:

```<code>$ rails plugin new rails_blog_engine --mountable
</code>```

And edited the 'test/dummy/config/routes' file to read:

```<code>Rails.application.routes.draw do
  mount RailsBlogEngine::Engine => "/blog"
end
</code>```

...and 'config/routes' to read:

```<code>RailsBlogEngine::Engine.routes.draw do
  resources :posts
end
</code>```

I want to list the routes generated for ':posts', but it's not clear how I can do this. When I run 'rake app:routes', I get only the "/blog" route:

```<code>$ rake app:routes
rails_blog_engine    /blog    {:to=>RailsBlogEngine::Engine}
</code>```

When I run 'rake routes', I get an error:

```<code>$ rake routes
rake aborted!
Don't know how to build task 'routes'
</code>```

How can I see the routes for ':posts'? Can I do this without rewriting the relevant rake tasks?

答:
in Rails 5, I could get the routes of the engine using the following command:</p>

```<code>bundle exec rake app:routes
</code>```

Body:
I'm working on a mountable engine for use with Rails 3.1, and I want to list the engine's routes.

I created the engine using:

$ rails plugin new rails_blog_engine --mountable

And edited the 'test/dummy/config/routes' file to read:

Rails.application.routes.draw do
  mount RailsBlogEngine::Engine => "/blog"
end

...and 'config/routes' to read:

RailsBlogEngine::Engine.routes.draw do
  resources :posts
end

I want to list the routes generated for ':posts', but it's not clear how I can do this. When I run 'rake app:routes', I get only the "/blog" route:

$ rake app:routes
rails_blog_engine    /blog    {:to=>RailsBlogEngine::Engine}

When I run 'rake routes', I get an error:

$ rake routes
rake aborted!
Don't know how to build task 'routes'

How can I see the routes for ':posts'? Can I do this without rewriting the relevant rake tasks?

Body:
in Rails 5, I could get the routes of the engine using the following command:

bundle exec rake app:routes


问:
How to parse rss-feeds / xml in a shell script
I'd like to parse rss feeds and download podcasts on my ReadyNas which is running 24/7 anyway.

So I'm thinking about having a shell script checking periodically the feeds and spawning wget to download the files.

What is the best way to do the parsing?

Thanks!

答: You can use xsltproc from libxml2 and write a simple xsl stylesheet that parses the rss and outputs a list of links.</p>

OwnerDisplayName: Oli

ContentLicense: CC BY-SA 4.0

OwnerDisplayName: rjack


问:
When Developing the database then compolsury to define the primary key or forign key in each tables of the database?
When Developing the database then compolsury to  define the primary key or forign key in each tables of the databse if any tables that do not contain any unique field that time how can we connect the table with other table.
Suppose i have three tabe.

table1 Personel Detail

```<code>Emai_Address (PK)
Name
City
ContactNo
Land_Line_No
D_O_B
Gender
Marital_Status
Language_Known
</code>```

Table2 Professiona_Detail

```<code>Total_Experiance
Annual_Salary
Functional_Area
Current_Industry
Key_Skill
Resume_HeadLine
</code>```

Table3 WorkPreference

```<code>Specify Your Preference
Start Working
Prefered Location
Job Type
</code>```

The Obove Table1 contain the PK but Table2 or Table 3 does not contain any Pk Or FK then  how can connect this three table.

答:
There is nothing that will enforce primary/foreign keys apart from you as a developer.

They are not compulsary, but are best practice and should be created.

OwnerDisplayName: harikrishna

Body:
When Developing the database then compolsury to  define the primary key or forign key in each tables of the databse if any tables that do not contain any unique field that time how can we connect the table with other table.
Suppose i have three tabe.

table1 Personel Detail

Emai_Address (PK)
Name
City
ContactNo
Land_Line_No
D_O_B
Gender
Marital_Status
Language_Known

Table2 Professiona_Detail

Total_Experiance
Annual_Salary
Functional_Area
Current_Industry
Key_Skill
Resume_HeadLine

Table3 WorkPreference

Specify Your Preference
Start Working
Prefered Location
Job Type

The Obove Table1 contain the PK but Table2 or Table 3 does not contain any Pk Or FK then  how can connect this three table.


问:
Using getAttribute to get the class name of a webelement in Native context
Went through the java docs of getAttribute. Couldn't understand the point mentioned as :

Finally, the following commonly mis-capitalized attribute/property
  names are evaluated as expected: "class" "readonly"

Could someone confirm if webElement.getAttribute("class") shall return the class name of the element or not?

Edit : On trying this myself

```<code>System.out.println("element " + webElement.getAttribute("class"));
</code>```

I am getting

org.openqa.selenium.NoSuchElementException

Note : The element does exist on the screen as I can perform actions successfully on the element :

```<code>webElement.click(); //runs successfully
</code>```

Code:

```<code>WebElement webElement = <findElement using some locator strategy>;
System.out.println("element " + webElement.getAttribute("class"));
</code>```

答:
```<code>public String getStringAttribute(final String attr)
  throws UiObjectNotFoundException, NoAttributeFoundException {
String res;
if (attr.equals("name")) {
  res = getContentDesc();
  if (res.equals("")) {
    res = getText();
  }
} else if (attr.equals("contentDescription")) {
  res = getContentDesc();
} else if (attr.equals("text")) {
  res = getText();
} else if (attr.equals("className")) {
  res = getClassName();
} else if (attr.equals("resourceId")) {
  res = getResourceId();
} else {
  throw new NoAttributeFoundException(attr);
}
return res;
</code>```

<p>}</p>

Body:
Went through the java docs of getAttribute. Couldn't understand the point mentioned as :

Finally, the following commonly mis-capitalized attribute/property
  names are evaluated as expected: "class" "readonly"

Could someone confirm if webElement.getAttribute("class") shall return the class name of the element or not?

Edit : On trying this myself

System.out.println("element " + webElement.getAttribute("class"));

I am getting

org.openqa.selenium.NoSuchElementException

Note : The element does exist on the screen as I can perform actions successfully on the element :

webElement.click(); //runs successfully

Code:

WebElement webElement = <findElement using some locator strategy>;
System.out.println("element " + webElement.getAttribute("class"));

Body:
public String getStringAttribute(final String attr)
  throws UiObjectNotFoundException, NoAttributeFoundException {
String res;
if (attr.equals("name")) {
  res = getContentDesc();
  if (res.equals("")) {
    res = getText();
  }
} else if (attr.equals("contentDescription")) {
  res = getContentDesc();
} else if (attr.equals("text")) {
  res = getText();
} else if (attr.equals("className")) {
  res = getClassName();
} else if (attr.equals("resourceId")) {
  res = getResourceId();
} else {
  throw new NoAttributeFoundException(attr);
}
return res;

}


问:
Track the launch of a third-party application
Is it possible to track the launch of a third-party application on the device? Maybe the android sends a broadcast when the applications are launched.

UPDATE

```<code>public class ServiceAppControl extends IntentService {

private boolean serviceStarted = true;

public ServiceAppControl() {
    super("ServiceAppControl");
}

@Override
protected void onHandleIntent(@Nullable Intent intent) {
    while (serviceStarted){
        String appIsForeground = isAppOnForeground(getBaseContext());
        Log.d(AppGlobal.LOG_TAG, "Запущено приложение " + appIsForeground);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

private String isAppOnForeground(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
    String appIsForeground = "";
    if (appProcesses == null) {
        return appIsForeground;
    }
    final String packageName = context.getPackageName();
    for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
            appIsForeground = appProcess.processName;
            return appIsForeground;
        }
    }
    return appIsForeground;
}
</code>```

}

答: There is no broadcast as such to inform about launch of an application to which others can listen because that can be a security threat. People can use it for malicious purpose. Otherwise from the logs you can get to know about currently launched application.</p>

Body:
Is it possible to track the launch of a third-party application on the device? Maybe the android sends a broadcast when the applications are launched.

UPDATE

public class ServiceAppControl extends IntentService {

private boolean serviceStarted = true;

public ServiceAppControl() {
    super("ServiceAppControl");
}

@Override
protected void onHandleIntent(@Nullable Intent intent) {
    while (serviceStarted){
        String appIsForeground = isAppOnForeground(getBaseContext());
        Log.d(AppGlobal.LOG_TAG, "Запущено приложение " + appIsForeground);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

private String isAppOnForeground(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
    String appIsForeground = "";
    if (appProcesses == null) {
        return appIsForeground;
    }
    final String packageName = context.getPackageName();
    for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
        if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
            appIsForeground = appProcess.processName;
            return appIsForeground;
        }
    }
    return appIsForeground;
}

}


问:
Cannot find module 'angular2/angular2'
I am developing an node app with angular2 and gulp. I have written a component file login.ts as follows:

```<code>import {Component, View} from 'angular2/angular2';
import {FormBuilder,  formDirectives } from 'angular2/forms';
@Component({
  selector: 'login',
  injectables: [FormBuilder]
})
@View({
  templateUrl: '/scripts/src/components/login/login.html',
  directives: [formDirectives]
})

export class login {

}
</code>```

And my bootstrap.ts file is:

```<code>import {bootstrap} from 'angular2/angular2';

import {login} from './components/login/login';

bootstrap(login);
</code>```

but when I compile these files it gives me the following errors:

```<code>client\bootstrap.ts(1,25): error TS2307: Cannot find module 'angular2/angular2'.
client\components\login\login.ts(1,31): error TS2307: Cannot find module 'angular2/angular2
client\components\login\login.ts(2,45): error TS2307: Cannot find module 'angular2/forms'.
</code>```

Here is my tsconfig.json:

```<code>{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "watch": true,
        "removeComments": true,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
    }
}
</code>```

I have installed the typing for angular2 using:

```<code>tsd install angular2 --save
</code>```

Please help to fix the error.

答:
The best way to kick of angular2 project is using Angular CLI.

The Angular CLI makes it easy to create an application that already works, right out of the box. It already follows our best practices!

please check this for more details.

Title: Cannot find module 'angular2/angular2'

Body:
I am developing an node app with angular2 and gulp. I have written a component file login.ts as follows:

import {Component, View} from 'angular2/angular2';
import {FormBuilder,  formDirectives } from 'angular2/forms';
@Component({
  selector: 'login',
  injectables: [FormBuilder]
})
@View({
  templateUrl: '/scripts/src/components/login/login.html',
  directives: [formDirectives]
})

export class login {

}

And my bootstrap.ts file is:

import {bootstrap} from 'angular2/angular2';

import {login} from './components/login/login';

bootstrap(login);

but when I compile these files it gives me the following errors:

client\bootstrap.ts(1,25): error TS2307: Cannot find module 'angular2/angular2'.
client\components\login\login.ts(1,31): error TS2307: Cannot find module 'angular2/angular2
client\components\login\login.ts(2,45): error TS2307: Cannot find module 'angular2/forms'.

Here is my tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "watch": true,
        "removeComments": true,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
    }
}

I have installed the typing for angular2 using:

tsd install angular2 --save

Please help to fix the error.


问:
get the result of SELECT 1 query in DataTable and get the value in ASP.NET
I've a query which checks for username and password in database. I have used as SELECT 1 query and set it in DataTable. Now how can I retrieve the value from DataTable since it doesnot have column name in DataTable.

```<code>protected void login_Click(object sender, EventArgs e)
{
    try
    {
            DataTable dt = new DataTable();
            string strQuery = "SELECT 1 FROM login WHERE USERNAME = @USERNAME AND PASSWORD = @PASSWORD";
            SqlCommand cmd = new SqlCommand(strQuery);

            cmd.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = user_login.Value.Trim();
            cmd.Parameters.Add("@PASSWORD", SqlDbType.VarChar).Value = user_pass.Value.Trim();

            DBConnection conn_ = new DBConnection();

            dt = conn_.SelectData(cmd);

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                // how can I get the value

            }
    }
    catch (Exception ex)
    {

    }
}
</code>```

答:
You are selecting the number 1, so why you want to read it? You know if the entered password for the user was valid by checking if (dt.Rows.Count > 0).

If you want to read the 1(for whatever reason) you can use the position of the column:

```<code>DataRow row = dt.Rows[0];
int number1 = row.Field<int>(0); // first column
</code>```

Body:
I've a query which checks for username and password in database. I have used as SELECT 1 query and set it in DataTable. Now how can I retrieve the value from DataTable since it doesnot have column name in DataTable.

protected void login_Click(object sender, EventArgs e)
{
    try
    {
            DataTable dt = new DataTable();
            string strQuery = "SELECT 1 FROM login WHERE USERNAME = @USERNAME AND PASSWORD = @PASSWORD";
            SqlCommand cmd = new SqlCommand(strQuery);

            cmd.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = user_login.Value.Trim();
            cmd.Parameters.Add("@PASSWORD", SqlDbType.VarChar).Value = user_pass.Value.Trim();

            DBConnection conn_ = new DBConnection();

            dt = conn_.SelectData(cmd);

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                // how can I get the value

            }
    }
    catch (Exception ex)
    {

    }
}

Body:
You are selecting the number 1, so why you want to read it? You know if the entered password for the user was valid by checking if (dt.Rows.Count > 0).

If you want to read the 1(for whatever reason) you can use the position of the column:

DataRow row = dt.Rows[0];
int number1 = row.Field<int>(0); // first column


问:
Fragment cannot be spread here as objects of type "X" can never be of type "Y"
In this case, type "X" is Application and type "Y" is type "Node" - I can see why this is happening, but my understanding of Relay isn't enough to understand how to fix it. The query generated by Relay is

```<code>query {
    node(id: $some_id) {
        ...F0
    }
}

fragment F0 on Application {
    ...
}
</code>```

I have a schema that looks like

```<code>query {
    application {
        /* kind of a generic endpoint for fetching lists, etc */
        invites(token: $token) {
            name
        }
    }
    viewer { /* the current user */ }
}
</code>```

I'm trying to fetch a specific invite from outside a session (viewer is null).

I've tried

```<code>const application = Relay.QL`query { application }`
...
<Route ... queries={{ application }}/>
...
Relay.createContainer(Component, {
    initialValues: { token: null },
    fragments: {
        application: () => {
            fragment on Application {
                invites(token: $token) {
                    ...
                }
            }
        }
    }
})
</code>```

which gives me the error

fragment "F0" cannot be spread here as objects of type "Node" can never be of type "Application" - or something to that effect.

I'm a little confused, because if I were to write a raw query and run it through GraphQL directly

```<code>query {
    application {
        invites(token: "asdasdasd") {
            edges {
                node {
                    name
                }
            }
        }
    }
}
</code>```

it gives me what I'm looking for...

In the backend, my graph is defined like

```<code>export const Application = new GraphQLObjectType({
  name: 'Application',
  fields: () => ({
    id: {
      type: GraphQLString,
      resolve: () => 'APPLICATION_ID'
    },
    invites: {
        type: InviteConnectionType,
        args: connectionArgs,
        resolve: (application, args) => {
            ...
        }
    }
  })
})

export default new GraphQLSchema({
  query: new GraphQLObjectType({
  name: 'query',
  fields: {
    node: nodeField,
    application: {
      type: Application,
      resolve: (root, args, ctx) => {
        return Promise.resolve({})
      }
    }
  }
})
</code>```

I've been looking at questions like this and some issues on the Relay github, but it's not clear to me how I should implement nodeInterface.

edit: the short-long of the current nodeInterface code is

```<code>export const {
  nodeInterface,
  nodeField
} = nodeDefinitions(
  (globalId) => {
    const { type, id } = fromGlobalId(globalId)
    return db[type].findById(id)
  },
  (obj) => {
    const name = obj.$modelOptions.name.singular
    return types[name]
  }
)
</code>```

Application is not a db model, however, just a generic interface to fetch data through. I've tried checking to see if type === 'Application', and returning null (although I see why that doesn't work), returning Application (the GraphQLObject), but that doesn't work... not really sure where to go from there.

答:
You need to automatically generate an unique global id for a GraphQL
type that you want to refetch.

In nodeInterface you tell GraphQL
how to map the id to the corresponding GraphQL object.

By the given server-side object nodeInterface identifies the GraphQL type.

Below is simplified example how it may look like with Application:

```<code>// nodeInterface.
var {nodeInterface, nodeField} = nodeDefinitions(
  (globalId) => {
    var {type, id} = fromGlobalId(globalId);

    // The mapping from globalId to actual object id and type.
    console.log('globalId:', id);
    console.log('type:', type);

    if (type === 'Application') {
      // getApplication is your db method to retrieve Application object.
      // With id you could also retrieve a specific db object.
      return getApplication();
    } else {
      return null;
    }
  },
  (obj) => {
    // Note that instanceof does an identity check on the prototype object, so it can be easily fooled.
    if (obj instanceof Application) {
      return ApplicationType;
    } else {
      return null;
    }
  },
);

// Application.
export const ApplicationType = new GraphQLObjectType({
  name: 'Application',
  fields: () => ({
    // Auto-generated, globally defined id.
    id: globalIdField('Application'),
    _id: {
      type: GraphQLString,
      resolve: () => 'APPLICATION_ID'
    },
    invites: {
        type: InviteConnectionType,
        args: connectionArgs,
        resolve: (application, args) => {
            ...
        }
    }
  }),
  // Declaring nodeInterface.
  interfaces: [nodeInterface]
});
</code>```

Note that during the initial fetch nodeInterface is not even executed, so if nodeInterface is returning nothing there won’t be errors at the initial fetch. If that doesn’t make sense or you’re still struggling you can post a link to the repo, I’ll look into it.

Body:
In this case, type "X" is Application and type "Y" is type "Node" - I can see why this is happening, but my understanding of Relay isn't enough to understand how to fix it. The query generated by Relay is

query {
    node(id: $some_id) {
        ...F0
    }
}

fragment F0 on Application {
    ...
}

I have a schema that looks like

query {
    application {
        /* kind of a generic endpoint for fetching lists, etc */
        invites(token: $token) {
            name
        }
    }
    viewer { /* the current user */ }
}

I'm trying to fetch a specific invite from outside a session (viewer is null).

I've tried

const application = Relay.QL`query { application }`
...
<Route ... queries={{ application }}/>
...
Relay.createContainer(Component, {
    initialValues: { token: null },
    fragments: {
        application: () => {
            fragment on Application {
                invites(token: $token) {
                    ...
                }
            }
        }
    }
})

which gives me the error

fragment "F0" cannot be spread here as objects of type "Node" can never be of type "Application" - or something to that effect.

I'm a little confused, because if I were to write a raw query and run it through GraphQL directly

query {
    application {
        invites(token: "asdasdasd") {
            edges {
                node {
                    name
                }
            }
        }
    }
}

it gives me what I'm looking for...

In the backend, my graph is defined like

export const Application = new GraphQLObjectType({
  name: 'Application',
  fields: () => ({
    id: {
      type: GraphQLString,
      resolve: () => 'APPLICATION_ID'
    },
    invites: {
        type: InviteConnectionType,
        args: connectionArgs,
        resolve: (application, args) => {
            ...
        }
    }
  })
})

export default new GraphQLSchema({
  query: new GraphQLObjectType({
  name: 'query',
  fields: {
    node: nodeField,
    application: {
      type: Application,
      resolve: (root, args, ctx) => {
        return Promise.resolve({})
      }
    }
  }
})

I've been looking at questions like this and some issues on the Relay github, but it's not clear to me how I should implement nodeInterface.

edit: the short-long of the current nodeInterface code is

export const {
  nodeInterface,
  nodeField
} = nodeDefinitions(
  (globalId) => {
    const { type, id } = fromGlobalId(globalId)
    return db[type].findById(id)
  },
  (obj) => {
    const name = obj.$modelOptions.name.singular
    return types[name]
  }
)

Application is not a db model, however, just a generic interface to fetch data through. I've tried checking to see if type === 'Application', and returning null (although I see why that doesn't work), returning Application (the GraphQLObject), but that doesn't work... not really sure where to go from there.

Body:
You need to automatically generate an unique global id for a GraphQL
type that you want to refetch.

In nodeInterface you tell GraphQL
how to map the id to the corresponding GraphQL object.

By the given server-side object nodeInterface identifies the GraphQL type.

Below is simplified example how it may look like with Application:

// nodeInterface.
var {nodeInterface, nodeField} = nodeDefinitions(
  (globalId) => {
    var {type, id} = fromGlobalId(globalId);

    // The mapping from globalId to actual object id and type.
    console.log('globalId:', id);
    console.log('type:', type);

    if (type === 'Application') {
      // getApplication is your db method to retrieve Application object.
      // With id you could also retrieve a specific db object.
      return getApplication();
    } else {
      return null;
    }
  },
  (obj) => {
    // Note that instanceof does an identity check on the prototype object, so it can be easily fooled.
    if (obj instanceof Application) {
      return ApplicationType;
    } else {
      return null;
    }
  },
);

// Application.
export const ApplicationType = new GraphQLObjectType({
  name: 'Application',
  fields: () => ({
    // Auto-generated, globally defined id.
    id: globalIdField('Application'),
    _id: {
      type: GraphQLString,
      resolve: () => 'APPLICATION_ID'
    },
    invites: {
        type: InviteConnectionType,
        args: connectionArgs,
        resolve: (application, args) => {
            ...
        }
    }
  }),
  // Declaring nodeInterface.
  interfaces: [nodeInterface]
});

Note that during the initial fetch nodeInterface is not even executed, so if nodeInterface is returning nothing there won’t be errors at the initial fetch. If that doesn’t make sense or you’re still struggling you can post a link to the repo, I’ll look into it.


问:
Both vertically and horizontally center of Bootsrap ui Modal
I'm trying to make a Bootstrap ui Modal that is both vertically and horizontally center align .

I tried this solution , that indeed vertically centered the modal , but when I tried it with my own template (with 800px) it lost its horizontally center:

i.e - http://plnkr.co/edit/vp3IWIcrpGG6ehH8JKVe?p=preview

How could I achieve this modal with vertically and horizontally center with my own template ?

Note - The width and height of the template is dynamic so the solution should be appropriate for any width and and height .

答:
the reason the modal lost its center is due to this css rule:

```<code>@media (min-width: 768px) {
    .modal-dialog {
      width: 600px;
      margin: 30px auto;
    }
}
</code>```

since your template has a 800px width, it overflows its container (the .modal-dialog div)

if you set .modal-dialog to width: auto it'll be fixed.

example: http://plnkr.co/edit/cYoYOgN1iMUzPKJuBw9H?p=preview

Body:
the reason the modal lost its center is due to this css rule:

@media (min-width: 768px) {
    .modal-dialog {
      width: 600px;
      margin: 30px auto;
    }
}

since your template has a 800px width, it overflows its container (the .modal-dialog div)

if you set .modal-dialog to width: auto it'll be fixed.

example: http://plnkr.co/edit/cYoYOgN1iMUzPKJuBw9H?p=preview


问:
How to run bash commands in gulp?
I want to add some bash commands at the end of gulp.watch function to accelerate my development speed. So, I am wondering if it is possible. Thanks!

答:
The simplest solution is as easy as:

```<code>var child = require('child_process');
var gulp   = require('gulp');

gulp.task('launch-ls',function(done) {
   child.spawn('ls', [ '-la'], { stdio: 'inherit' });
});
</code>```

It doesn't use node streams and gulp pipes but it will do the work.

Title: How to run bash commands in gulp?

Body:
The simplest solution is as easy as:

var child = require('child_process');
var gulp   = require('gulp');

gulp.task('launch-ls',function(done) {
   child.spawn('ls', [ '-la'], { stdio: 'inherit' });
});

It doesn't use node streams and gulp pipes but it will do the work.


问:
How to store response data as variable in typescript/ angular2
I am new to typescript. I have got an id generated after post function. Now by using that _id generated in post,using that i must call PUT function for play pause, when play pause button is called response must go to server. I am here by sharing my code of both ts and API service,

API code for PUT:

```<code>    edit(updateId) {
  console.log(updateId);
  let authToken = JSON.parse(localStorage.getItem('authToken'));
  var company_id = JSON.parse(localStorage.getItem('company_id'));
  var queries = "?authToken=" + authToken + "&&_id="+ company_id +"&&view_id=2";
 return this.http.put(urlBase + '/timerEntry/' + updateId ,options)
                  .map(this.extractData)
                  .catch(this.handleError);
}
</code>```

TS code:
This is for POST function

```<code>this.ApiService
 .addtimerEntries(new_task)
              .subscribe(
                entry  => {
                 console.log(entry)
                  this.todays.today.push(entry.data[0]);
                  this.updateId = entry.data[0]._id;
                 console.log(this.updateId);
              this.toasterService.pop('success', 'Entry added
               successfully');
              this.newTask.hide();
            },
          error => {
          this.toasterService.pop('error', 'Something went wrong!');
        });
</code>```

This is for PUT function:

```<code> playTimer() {
     this.timerService.playTimer();
      this.playDiv = true;
      console.log(this.updateId);
      if (this.updateId){
    this.ApiService
           .edit( this.updateId)
           .subscribe(
             user => {
               console.log(user);
               this.ApiService
                          .getEntries(this.workEmail)
                          .subscribe(
                            entries  => {
                              console.log(entries);
                              this.entries = entries;
                      this.toasterService.pop('success', 'updated successfully');},
                    error => {
                      //console.log(error);
                    });
             },
             error => {
                this.toasterService.pop('error', 'Something went wrong!');
             });
    }
    }
    pauseTimer() {
     this.timerService.pauseTimer();
      this.playDiv = false;
    }
</code>```

Consoled Output:

```<code>data:Array(1)
0:Object
category_id:1
client_id:15
company_id:4
department_id:26
entry_type:"checkin_entry"
project_id:7
subcategories:Array(1)
times:Array(1)
workEmail:"test3@test.com"
_id:"59362522325a5a0786f661b3"
</code>```

答:
According to your code, you called different baseUrl for post and put. so it is giving 404 error

So, in  PUT change

return this.http.put(urlBase + '/timerEntry/' + updateId ,options)

to

return this.http.put(timerUrlBase + '/timerEntry/' + updateId ,options)

So, your service code will be,

```<code>edit(updateId) {
    console.log(updateId);
    let authToken = JSON.parse(localStorage.getItem('authToken'));
    var company_id = JSON.parse(localStorage.getItem('company_id'));
    var queries = "?authToken=" + authToken + "&&_id="+ company_id +"&&view_id=2";
    return this.http.put(timerUrlBase + '/timerEntry/' + updateId ,options)
    .map(this.extractData)
    .catch(this.handleError);
}
</code>```

Body:
I am new to typescript. I have got an id generated after post function. Now by using that _id generated in post,using that i must call PUT function for play pause, when play pause button is called response must go to server. I am here by sharing my code of both ts and API service,

API code for PUT:

    edit(updateId) {
  console.log(updateId);
  let authToken = JSON.parse(localStorage.getItem('authToken'));
  var company_id = JSON.parse(localStorage.getItem('company_id'));
  var queries = "?authToken=" + authToken + "&&_id="+ company_id +"&&view_id=2";
 return this.http.put(urlBase + '/timerEntry/' + updateId ,options)
                  .map(this.extractData)
                  .catch(this.handleError);
}

TS code:
This is for POST function

this.ApiService
 .addtimerEntries(new_task)
              .subscribe(
                entry  => {
                 console.log(entry)
                  this.todays.today.push(entry.data[0]);
                  this.updateId = entry.data[0]._id;
                 console.log(this.updateId);
              this.toasterService.pop('success', 'Entry added
               successfully');
              this.newTask.hide();
            },
          error => {
          this.toasterService.pop('error', 'Something went wrong!');
        });

This is for PUT function:

 playTimer() {
     this.timerService.playTimer();
      this.playDiv = true;
      console.log(this.updateId);
      if (this.updateId){
    this.ApiService
           .edit( this.updateId)
           .subscribe(
             user => {
               console.log(user);
               this.ApiService
                          .getEntries(this.workEmail)
                          .subscribe(
                            entries  => {
                              console.log(entries);
                              this.entries = entries;
                      this.toasterService.pop('success', 'updated successfully');},
                    error => {
                      //console.log(error);
                    });
             },
             error => {
                this.toasterService.pop('error', 'Something went wrong!');
             });
    }
    }
    pauseTimer() {
     this.timerService.pauseTimer();
      this.playDiv = false;
    }

Consoled Output:

data:Array(1)
0:Object
category_id:1
client_id:15
company_id:4
department_id:26
entry_type:"checkin_entry"
project_id:7
subcategories:Array(1)
times:Array(1)
workEmail:"test3@test.com"
_id:"59362522325a5a0786f661b3"

Body:
According to your code, you called different baseUrl for post and put. so it is giving 404 error

So, in  PUT change

return this.http.put(urlBase + '/timerEntry/' + updateId ,options)

to

return this.http.put(timerUrlBase + '/timerEntry/' + updateId ,options)

So, your service code will be,

edit(updateId) {
    console.log(updateId);
    let authToken = JSON.parse(localStorage.getItem('authToken'));
    var company_id = JSON.parse(localStorage.getItem('company_id'));
    var queries = "?authToken=" + authToken + "&&_id="+ company_id +"&&view_id=2";
    return this.http.put(timerUrlBase + '/timerEntry/' + updateId ,options)
    .map(this.extractData)
    .catch(this.handleError);
}


问:
How to change 'selection criterion' in Lotus notes Views
I have  Lotus Notes Client and some Views created already. How can I see the 'Selection Creterion' for views, and I need to change 'Selection Creterion' also.

Thanks in advance.

答:
You can use the 'Design Synopis' tool to produce a report of the design settings of most design elements, including view selection formulas.

Select the application/database, then, from the main menu, goto: File, Application, Design Synopsis and select 'Define contact, Views' and select which features you want. Choose 'selection formuals' and produce the report.

If you want to change selection formulas, either use the Domino Designer (as mentioned elewhere here) or create an agent that change the selection formula for you. Check the Desinger Help for details of how to do this programmatically.


问:
Detect if the mouse is clicked outside GroupBox
I am looking for an event if the mouse is clicked outside of the groupBox in Qt. I tried FocusOutEvent but was not able to get the event:

```<code>ui.groupBox->installEventFilter(this);

void myClass::focusOutEvent(QFocusEvent *event) { ui.groupBox->hide(); }
</code>```

Any kind of help would be greatly appreciated!

答:
The problem is that the events of the monitored object are not forwarded to the native event handlers of the filter object such as focusOutEvent, but to a special virtual event function, i.e. eventFilter(QObject *obj, QEvent *event) as documented in installEventFilter. So, your event handler should look like this:

```<code>bool myClass::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == ui.groupBox && event->type () == QEvent::FocusOut)
        ui.groupBox->hide();
    return false;
}
</code>```

Body:
I am looking for an event if the mouse is clicked outside of the groupBox in Qt. I tried FocusOutEvent but was not able to get the event:

ui.groupBox->installEventFilter(this);

void myClass::focusOutEvent(QFocusEvent *event) { ui.groupBox->hide(); }

Any kind of help would be greatly appreciated!

Body:
The problem is that the events of the monitored object are not forwarded to the native event handlers of the filter object such as focusOutEvent, but to a special virtual event function, i.e. eventFilter(QObject *obj, QEvent *event) as documented in installEventFilter. So, your event handler should look like this:

bool myClass::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == ui.groupBox && event->type () == QEvent::FocusOut)
        ui.groupBox->hide();
    return false;
}


问:
How to not open an activity which has been finished through recent apps
From Activity A, I open Activity B which starts a sticky Service. Then I press the home button which puts the app in background. I open recent apps and close my app, Sticky Service keeps running.

Clicking the app icon brings me back to the Launcher Activity A. But if I instead click the sticky Service Notification I'm brought back to Activity B which is correct. If I at this moment stop Activity B and the Sticky Service which also finishes the app, then if I go to recent apps and open my app I'm brought back to Activity B which is wrong, it should take me back to Activity A. But only if I have killed the Sticky Service.

How can this be achieved?

Is there an intent flag for this? Or do I have to use some extras with the intent to tell the app where it's started from?

答: using excludeFromRecents for Activity B could serve your purpose, without changing anything else</p>


问:
Eclipse: Virgo tooling plugin installation using P2 directory
I am trying to install Virgo tooling Eclipse plugin using the P2 installation directory, since I want to install directly from command line and not from GUI. I am getting the below error and seems like some dependencies issues are there. I tried resolving the dependencies but I am still facing the same issue. I also searched on the web and was not able to find a good solution for the issue.

```<code>Cannot complete the install because one or more required items could not be found.
 Software being installed: Eclipse Virgo Tools 1.5.0.R01-RELEASE (org.eclipse.virgo.ide.feature.feature.group 1.5.0.R01-RELEASE)
 Missing requirement: Eclipse Virgo IDE (Server Core) 1.5.0.R01-RELEASE (org.eclipse.virgo.ide.runtime.core 1.5.0.R01-RELEASE) requires 'bundle org.json 0.0.0' but it could not be found
 Cannot satisfy dependency:
  From: Eclipse Virgo Tools 1.5.0.R01-RELEASE (org.eclipse.virgo.ide.feature.feature.group 1.5.0.R01-RELEASE)
  To: org.eclipse.virgo.ide.runtime.core [1.5.0.R01-RELEASE]
</code>```

Please note that the plugin installation works from the Eclipse GUI. I also installed other plugins from command line and that worked, only facing issue with Virgo tooling plugin.

答:
The Virgo Tools depend on the Virgo server and several other Eclipse projects. When installing from the command line using p2 director you have to specify the comma separated list of features to install and the list of p2 repositories containing such features (and dependencies).

The following is an example for creating an Eclipse + Virgo Tools starting from the Neon RCP runtime distribution and adding JDT, egit, Web Tools etc. etc.

I created it from a working script I have, removing some very specific plug-ins I use. You may want to have a look at it as an example, I do not guarantee it works after the modification.

If instead of starting from Neon RCP you start from Neon for JavaEE developers you can remove most of the features and repositories.

```<code>#!/bin/sh

./eclipse -nosplash -debug -consolelog -application org.eclipse.equinox.p2.director\
 -i \
org.eclipse.recommenders.rcp.feature.feature.group,\
org.eclipse.recommenders.mylyn.rcp.feature.feature.group,\
org.eclipse.egit.feature.group,\
org.eclipse.egit.gitflow.feature.feature.group,\
org.eclipse.egit.mylyn.feature.group,\
org.eclipse.mylyn.github.feature.feature.group,\
org.eclipse.jdt.feature.group,\
org.eclipse.jst.enterprise_ui.feature.feature.group,\
org.eclipse.jst.web_ui.feature.feature.group,\
org.eclipse.virgo.ide.feature.feature.group,\
org.eclipse.wst.web_ui.feature.feature.group,\
org.eclipse.wst.xml_ui.feature.feature.group,\
org.eclipse.wst.xsl.feature.feature.group,\
org.eclipse.emf.sdk.feature.group,\
org.eclipse.wst.jsdt.feature.feature.group,\
org.eclipse.m2e.feature.feature.group,\
org.eclipse.epp.mpc.feature.group,\
org.eclipse.mylyn.hudson.feature.group,\
org.eclipse.mylyn.ide_feature.feature.group,\
org.eclipse.mylyn.java_feature.feature.group,\
org.eclipse.mylyn.pde_feature.feature.group,\
org.eclipse.mylyn.team_feature.feature.group,\
org.eclipse.mylyn.gerrit.feature.feature.group,\
org.eclipse.mylyn.gerrit.dashboard.feature.feature.group,\
org.eclipse.mylyn_feature.feature.group,\
org.eclipse.mylyn.context_feature.feature.group,\
org.eclipse.mylyn.bugzilla_feature.feature.group,\
org.eclipse.mylyn.git.feature.group,\
org.eclipse.mylyn.wikitext_feature.feature.group,\
org.eclipse.tm.terminal.feature.feature.group,\
org.sonatype.tycho.m2e.feature.feature.group,\
org.sonatype.m2e.egit.feature.feature.group,\
org.jboss.tools.m2e.jdt.feature.feature.group,\
org.sonatype.m2e.sisu.feature.feature.group,\
 -r \
http://download.eclipse.org/releases/neon,\
http://download.eclipse.org/virgo/release/tooling,\
http://download.eclipse.org/recommenders/updates/stable/,\
http://download.eclipse.org/technology/m2e/releases/,\
http://download.eclipse.org/tools/orbit/downloads/drops/R20160520211859/repository/,\
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-egit/0.14.0/N/LATEST/,\
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.8.0/N/LATEST/,\
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-sisu/0.15.0/N/LATEST/,\
http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-jdt-compiler/1.0.1-2012-09-20_05-03-18-H2/,\
http://download.eclipse.org/eclipse/updates/4.2/
</code>```

Comments:

the above is a *unix shell script (runs fine on MacOs).

the \ character at the end of each line is required because this is a shell command that continues for multiple lines

-i is the p2 parameter for specifying a comma separated list of features to be installed

-r is the p2 parameter for specifying a comma separated list of repositories to be used for locating features and dependencies

Disclaimer: I am an Eclipse Virgo committer.

Body:
I am trying to install Virgo tooling Eclipse plugin using the P2 installation directory, since I want to install directly from command line and not from GUI. I am getting the below error and seems like some dependencies issues are there. I tried resolving the dependencies but I am still facing the same issue. I also searched on the web and was not able to find a good solution for the issue.

Cannot complete the install because one or more required items could not be found.
 Software being installed: Eclipse Virgo Tools 1.5.0.R01-RELEASE (org.eclipse.virgo.ide.feature.feature.group 1.5.0.R01-RELEASE)
 Missing requirement: Eclipse Virgo IDE (Server Core) 1.5.0.R01-RELEASE (org.eclipse.virgo.ide.runtime.core 1.5.0.R01-RELEASE) requires 'bundle org.json 0.0.0' but it could not be found
 Cannot satisfy dependency:
  From: Eclipse Virgo Tools 1.5.0.R01-RELEASE (org.eclipse.virgo.ide.feature.feature.group 1.5.0.R01-RELEASE)
  To: org.eclipse.virgo.ide.runtime.core [1.5.0.R01-RELEASE]

Please note that the plugin installation works from the Eclipse GUI. I also installed other plugins from command line and that worked, only facing issue with Virgo tooling plugin.

Body:
The Virgo Tools depend on the Virgo server and several other Eclipse projects. When installing from the command line using p2 director you have to specify the comma separated list of features to install and the list of p2 repositories containing such features (and dependencies).

The following is an example for creating an Eclipse + Virgo Tools starting from the Neon RCP runtime distribution and adding JDT, egit, Web Tools etc. etc.

I created it from a working script I have, removing some very specific plug-ins I use. You may want to have a look at it as an example, I do not guarantee it works after the modification.

If instead of starting from Neon RCP you start from Neon for JavaEE developers you can remove most of the features and repositories.

#!/bin/sh

./eclipse -nosplash -debug -consolelog -application org.eclipse.equinox.p2.director\
 -i \
org.eclipse.recommenders.rcp.feature.feature.group,\
org.eclipse.recommenders.mylyn.rcp.feature.feature.group,\
org.eclipse.egit.feature.group,\
org.eclipse.egit.gitflow.feature.feature.group,\
org.eclipse.egit.mylyn.feature.group,\
org.eclipse.mylyn.github.feature.feature.group,\
org.eclipse.jdt.feature.group,\
org.eclipse.jst.enterprise_ui.feature.feature.group,\
org.eclipse.jst.web_ui.feature.feature.group,\
org.eclipse.virgo.ide.feature.feature.group,\
org.eclipse.wst.web_ui.feature.feature.group,\
org.eclipse.wst.xml_ui.feature.feature.group,\
org.eclipse.wst.xsl.feature.feature.group,\
org.eclipse.emf.sdk.feature.group,\
org.eclipse.wst.jsdt.feature.feature.group,\
org.eclipse.m2e.feature.feature.group,\
org.eclipse.epp.mpc.feature.group,\
org.eclipse.mylyn.hudson.feature.group,\
org.eclipse.mylyn.ide_feature.feature.group,\
org.eclipse.mylyn.java_feature.feature.group,\
org.eclipse.mylyn.pde_feature.feature.group,\
org.eclipse.mylyn.team_feature.feature.group,\
org.eclipse.mylyn.gerrit.feature.feature.group,\
org.eclipse.mylyn.gerrit.dashboard.feature.feature.group,\
org.eclipse.mylyn_feature.feature.group,\
org.eclipse.mylyn.context_feature.feature.group,\
org.eclipse.mylyn.bugzilla_feature.feature.group,\
org.eclipse.mylyn.git.feature.group,\
org.eclipse.mylyn.wikitext_feature.feature.group,\
org.eclipse.tm.terminal.feature.feature.group,\
org.sonatype.tycho.m2e.feature.feature.group,\
org.sonatype.m2e.egit.feature.feature.group,\
org.jboss.tools.m2e.jdt.feature.feature.group,\
org.sonatype.m2e.sisu.feature.feature.group,\
 -r \
http://download.eclipse.org/releases/neon,\
http://download.eclipse.org/virgo/release/tooling,\
http://download.eclipse.org/recommenders/updates/stable/,\
http://download.eclipse.org/technology/m2e/releases/,\
http://download.eclipse.org/tools/orbit/downloads/drops/R20160520211859/repository/,\
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-egit/0.14.0/N/LATEST/,\
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.8.0/N/LATEST/,\
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-sisu/0.15.0/N/LATEST/,\
http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-jdt-compiler/1.0.1-2012-09-20_05-03-18-H2/,\
http://download.eclipse.org/eclipse/updates/4.2/

Comments:

the above is a *unix shell script (runs fine on MacOs).

the \ character at the end of each line is required because this is a shell command that continues for multiple lines

-i is the p2 parameter for specifying a comma separated list of features to be installed

-r is the p2 parameter for specifying a comma separated list of repositories to be used for locating features and dependencies

Disclaimer: I am an Eclipse Virgo committer.


问:
Create a DataManger together with Firebase
I'm all new to Firebase and using it together with Swift. I'm trying to get an understanding on how to use the Firebase Database.

Usually when working with data in Swift I create a DataManager that handles all work with data/database/api so that code is isolated and not cluttered all over the app.

In a TableViewController to load the data I can later just do something like

```<code>self.items = DataManager.shared.getItems()
</code>```

When following the different Firebase tutorials I've found that in all examples all data handling are made in the ViewControllers itself. For example this tutorial In a TableViewController they would have something like:

```<code>let ref = FIRDatabase.database().reference(withPath: "items")

override func viewDidLoad() {
    ref.observe(.value, with: { snapshot in
        var newItems: [Item] = []

        for item in snapshot.children {
            let newItem = Item(snapshot: item as! FIRDataSnapshot)
            newItems.append(newItem)
        }
        self.items = newItems
        self.tableView.reloadData()
    })
}
</code>```

Probably they are doing it this way because this is just an example and it's easier to explain. But I think this way makes the app cluttered and I rather move that stuff into a DataManager.

I've been trying to get an understanding for how to do it in a good way but I can't figure it out. How making sure the observers gets removed etc? How would you do it? Is there a good example on creating this structure? Or is this not the way Firebase works?

答:
You should add completion handlers to your functions in data manager.

Like this:

```<code>override func viewDidLoad() {
    super.viewDidLoad()

    DataManager.getItems() { items in
        // this part will be called, when data is loaded in DataManager
        self.items = items
        self.tableView.reloadData()
    })
}
</code>```

DataManager func:

```<code>static func getItems(completion: @escaping (_items: [Item]) -> Void) {
     ref.observe(.value, with: { snapshot in
         var newItems: [Item] = []

         for item in snapshot.children {
             let newItem = Item(snapshot: item as! FIRDataSnapshot)
             newItems.append(newItem)
         }

         completions(newItems)
    })
}
</code>```

Hope it helps

Body:
I'm all new to Firebase and using it together with Swift. I'm trying to get an understanding on how to use the Firebase Database.

Usually when working with data in Swift I create a DataManager that handles all work with data/database/api so that code is isolated and not cluttered all over the app.

In a TableViewController to load the data I can later just do something like

self.items = DataManager.shared.getItems()

When following the different Firebase tutorials I've found that in all examples all data handling are made in the ViewControllers itself. For example this tutorial In a TableViewController they would have something like:

let ref = FIRDatabase.database().reference(withPath: "items")

override func viewDidLoad() {
    ref.observe(.value, with: { snapshot in
        var newItems: [Item] = []

        for item in snapshot.children {
            let newItem = Item(snapshot: item as! FIRDataSnapshot)
            newItems.append(newItem)
        }
        self.items = newItems
        self.tableView.reloadData()
    })
}

Probably they are doing it this way because this is just an example and it's easier to explain. But I think this way makes the app cluttered and I rather move that stuff into a DataManager.

I've been trying to get an understanding for how to do it in a good way but I can't figure it out. How making sure the observers gets removed etc? How would you do it? Is there a good example on creating this structure? Or is this not the way Firebase works?

Body:
You should add completion handlers to your functions in data manager.

Like this:

override func viewDidLoad() {
    super.viewDidLoad()

    DataManager.getItems() { items in
        // this part will be called, when data is loaded in DataManager
        self.items = items
        self.tableView.reloadData()
    })
}

DataManager func:

static func getItems(completion: @escaping (_items: [Item]) -> Void) {
     ref.observe(.value, with: { snapshot in
         var newItems: [Item] = []

         for item in snapshot.children {
             let newItem = Item(snapshot: item as! FIRDataSnapshot)
             newItems.append(newItem)
         }

         completions(newItems)
    })
}

Hope it helps


问:
IIS 7 NT Authencation fail Redirect
On IIS 7 i have NT auth for the site. In AD I have users and they belong to groups. In ASP.NET applicaiton i neeed to allows only certain groups not every one AD. Is there any way at IIS level i can restrict the access to certain groups for the site? Or each page I have to check that user is valid or not?

Also i need to redirect to differnt page if the user is not part of any group? or on AD? How do is do that in IIS 7

答:
Hi @user171523 A couple questions for you but I have some answers too. Have you seen this book? It can walk you through the material for what you're wanting to do.

http://www.amazon.com/ASP-NET-2-0-Unleashed-Stephen-Walther/dp/0672328232

What resources have you seen already? Will MSDN be able to help you, or do you need some walkthroughs? Will you be configuring this by hand or automagically? Will you be using the ASP.NET tool included via VS or will you need to code something by hand?

Title: IIS 7 NT Authencation fail Redirect


问:
jQuery set as active next or previous submenu
I'm working with this jSFiddle: https://jsfiddle.net/vkuz8ra3/

And i need function which active next or previous link after click to div prev or div next.

I tried something like this but it does not work

```<code>$('.prev').click(function() {
  $('#links').children().prev().addClass('active');
    var index = $('#links').children().index('#links');
    $('#linksobsah').children().hide(500).eq(index).show(500);
    $('#links').children().removeClass('active');
    $('#links').addClass('active');
});
</code>```

How can i do that?

答:
I would suggest you to maintain a global variable and use that to show or hide the sub menu

Suppose you have lis with class link1, link2..

And menus with class 'menu menu1 active,menu menu2` ...(notice that first is active)

Maintain a global counter as

```<code>var counter = 0;
</code>```

Your function should be

```<code>$('.prev').click(function(){
    $('menu.active').removeClass('active');
    counter--;
    $('.menu' + counter % $('menu').length).addClass('active');
});
</code>```

Similarly for next

```<code>$('.next').click(function(){
    $('menu.active').removeClass('active');
    counter++;
    $('.menu' + counter % $('menu').length).addClass('active');
});
</code>```

Body:
I'm working with this jSFiddle: https://jsfiddle.net/vkuz8ra3/

And i need function which active next or previous link after click to div prev or div next.

I tried something like this but it does not work

$('.prev').click(function() {
  $('#links').children().prev().addClass('active');
    var index = $('#links').children().index('#links');
    $('#linksobsah').children().hide(500).eq(index).show(500);
    $('#links').children().removeClass('active');
    $('#links').addClass('active');
});

How can i do that?

Body:
I would suggest you to maintain a global variable and use that to show or hide the sub menu

Suppose you have lis with class link1, link2..

And menus with class 'menu menu1 active,menu menu2` ...(notice that first is active)

Maintain a global counter as

var counter = 0;

Your function should be

$('.prev').click(function(){
    $('menu.active').removeClass('active');
    counter--;
    $('.menu' + counter % $('menu').length).addClass('active');
});

Similarly for next

$('.next').click(function(){
    $('menu.active').removeClass('active');
    counter++;
    $('.menu' + counter % $('menu').length).addClass('active');
});


问:
Do chrome and firefox support pointer event (pressure, tilt, touch, etc.) any soon?
I am writing web app on canvas that suppose to support tablet and touch pressure. However, if I am not mistaken,  I believe only IE10 support these pointer events. I would want to know if chrome and firefox are going to support it any soon?</p>

答: I just tested this on the Surface Studio with the pen in Chrome 58 (Windows 10).  It generates the pointer events but the pressure is always 0.5.  It doesn't register any variance.  IE correctly returns varying values for pressure.