问:
How do I "shake" an Android device within the Android emulator to bring up the dev menu to debug my React Native app
I am working on a cross-platform React Native mobile app. I am writing console.log statements as I develop. I want to see these logging statements in Chrome while I'm running the Android app in the default Android emulator. According to Facebook's docs I just need to "shake the device". How do I do this in the Android emulator?

To access the in-app developer menu:

On iOS shake the device or press control + ⌘ + z in the simulator.
  On Android shake the device or press hardware menu button (available on older >devices and in most of the emulators, e.g. in genymotion you can press ⌘ + m to >simulate hardware menu button click)

答:
As while developing react native apps, we play with the terminal so much

so I added a script in the scripts in the package.json file

"menu": "adb shell input keyevent 82"

and I hit $ yarn menu

for the menu to appear on the emulator
it will forward the keycode 82 to the emulator via ADB
not the optimal way but I like it and felt to share it.


来源: stackexchange

问:
cp --parents option on mac
On Linux, I have a --parents option available for the cp command so I can do

```<code>cp --parents test/withintest/go.rb test2
</code>```

http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html

On Mac, I do not have this option available. Is there a way to do this on Mac? Why is this option not available?

PS. The purpose of --parents is the following:

‘--parents’ Form the name of each destination file by appending to the
  target directory a slash and the specified name of the source file.

The last argument given to cp must be the name of an existing
  directory.

For example, the command:

```<code>      cp --parents a/b/c existing_dir
</code>```

copies the file a/b/c to existing_dir/a/b/c, creating any missing intermediate directories.

答:
The Homebrew way:

Install coreutils

brew install coreutils
```

<p>Use the <code>GNU</code> g- prefixed command</p>

```gcp --parents test/withintest/go.rb test2
```

ContentLicense: CC BY-SA 3.0

Title: cp --parents option on mac

Body:
On Linux, I have a --parents option available for the cp command so I can do

cp --parents test/withintest/go.rb test2

http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html

On Mac, I do not have this option available. Is there a way to do this on Mac? Why is this option not available?

PS. The purpose of --parents is the following:

‘--parents’ Form the name of each destination file by appending to the
  target directory a slash and the specified name of the source file.

The last argument given to cp must be the name of an existing
  directory.

For example, the command:

      cp --parents a/b/c existing_dir

copies the file a/b/c to existing_dir/a/b/c, creating any missing intermediate directories.

Body:
The Homebrew way:

Install coreutils

brew install coreutils

Use the GNU g- prefixed command

gcp --parents test/withintest/go.rb test2

ContentLicense: CC BY-SA 4.0


问:
Query for state attributes
If I have a state with an attribute, e.g.:

```<code>class Test(val timestamp: Double, val linearId = UniqueIdentifier()): LinearState
</code>```

I can execute a vault query based on the linearId with LinearStateQueryCriteria. Is there a way to define query criteria for the attributes of a State? For example, get every state where the timestamp attribute is equal to x or even in a range between y and z?

答:
This would work if your State is a QueryableState. You could use a VaultCustomQueryCriteria to get the desired result as shown below:

```<code>QueryCriteria generalCriteria = new VaultQueryCriteria(Vault.StateStatus.ALL);

FieldInfo attributeCurrency = getField("currency", CashSchemaV1.PersistentCashState.class);
FieldInfo attributeQuantity = getField("pennies", CashSchemaV1.PersistentCashState.class);

CriteriaExpression currencyIndex = Builder.equal(attributeCurrency, "USD");
CriteriaExpression quantityIndex = Builder.greaterThanOrEqual(attributeQuantity, 10L);

QueryCriteria customCriteria2 = new VaultCustomQueryCriteria(quantityIndex);
QueryCriteria customCriteria1 = new VaultCustomQueryCriteria(currencyIndex);

QueryCriteria criteria = generalCriteria.and(customCriteria1).and(customCriteria2);
Vault.Page<ContractState> results = vaultService.queryBy(Cash.State.class, criteria);
</code>```

Refer here for more details: https://docs.corda.net/api-vault-query.html

Refer here if you want to learn about QueryableState:
https://medium.com/corda/persisting-corda-states-in-custom-database-tables-using-queryablestate-dedaa18b7050

Title: Query for state attributes

Body:
If I have a state with an attribute, e.g.:

class Test(val timestamp: Double, val linearId = UniqueIdentifier()): LinearState

I can execute a vault query based on the linearId with LinearStateQueryCriteria. Is there a way to define query criteria for the attributes of a State? For example, get every state where the timestamp attribute is equal to x or even in a range between y and z?

Body:
This would work if your State is a QueryableState. You could use a VaultCustomQueryCriteria to get the desired result as shown below:

QueryCriteria generalCriteria = new VaultQueryCriteria(Vault.StateStatus.ALL);

FieldInfo attributeCurrency = getField("currency", CashSchemaV1.PersistentCashState.class);
FieldInfo attributeQuantity = getField("pennies", CashSchemaV1.PersistentCashState.class);

CriteriaExpression currencyIndex = Builder.equal(attributeCurrency, "USD");
CriteriaExpression quantityIndex = Builder.greaterThanOrEqual(attributeQuantity, 10L);

QueryCriteria customCriteria2 = new VaultCustomQueryCriteria(quantityIndex);
QueryCriteria customCriteria1 = new VaultCustomQueryCriteria(currencyIndex);

QueryCriteria criteria = generalCriteria.and(customCriteria1).and(customCriteria2);
Vault.Page<ContractState> results = vaultService.queryBy(Cash.State.class, criteria);

Refer here for more details: https://docs.corda.net/api-vault-query.html

Refer here if you want to learn about QueryableState:
https://medium.com/corda/persisting-corda-states-in-custom-database-tables-using-queryablestate-dedaa18b7050


问:
Extract Content of firts Index[0] in each array If I have one array and has several array in it
If I have one Array that has three array in side it and want to extract content of index[1] in each array

```<code>Array(4) [Array(3), Array(3), Array(1), Array(1)]
length:4
[
0:Array(3) ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"]  // Extract content of Index[0]
1:Array(3) ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"]  // Extract content of Index[0]
2:Array(1) ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]  // Extract content of Index[0]
3:Array(1) ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]  // Extract content of Index[0]
]
</code>```

in each line I want extract just first variable,This is my result :

```<code>let result = [
                ["cfdb9868-0f69-5781-b1e4-793301280788"],["cfdb9868-0f69-5781-b1e4-793301280788"],
                ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
             ]
</code>```

I used slice and split for have just first one but give me error function

答:
Very simple solution using Array.prototype.map property

const input = [
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
]

const output = input.map(([firstElement])=>[firstElement])

console.log(output)```
</div>
</div>
</p>

<p>a little more complicated for storing nth variable</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const input = [
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
]

const output = (n) => input.map((element)=> element[n] ? [element[n]] : [])

console.log("0", JSON.stringify(output(0)))
console.log("1", JSON.stringify(output(1)))
console.log("2", JSON.stringify(output(2)))</code>```

Assuming that you may not want to leave empty arrays if no element with given index exists you could modify the code above like so:

const input = [
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
]

const output = (n) => input.reduce((list, element)=> element[n] ? [...list, element[n]] : list, [])

console.log("0", JSON.stringify(output(0)))
console.log("1", JSON.stringify(output(1)))
console.log("2", JSON.stringify(output(2)))```

Body:
If I have one Array that has three array in side it and want to extract content of index[1] in each array

Array(4) [Array(3), Array(3), Array(1), Array(1)]
length:4
[
0:Array(3) ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"]  // Extract content of Index[0]
1:Array(3) ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"]  // Extract content of Index[0]
2:Array(1) ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]  // Extract content of Index[0]
3:Array(1) ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]  // Extract content of Index[0]
]

in each line I want extract just first variable,This is my result :

let result = [
                ["cfdb9868-0f69-5781-b1e4-793301280788"],["cfdb9868-0f69-5781-b1e4-793301280788"],
                ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
             ]

I used slice and split for have just first one but give me error function

Body:
Very simple solution using Array.prototype.map property

const input = [
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
]

const output = input.map(([firstElement])=>[firstElement])

console.log(output)

a little more complicated for storing nth variable

const input = [
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
]

const output = (n) => input.map((element)=> element[n] ? [element[n]] : [])

console.log("0", JSON.stringify(output(0)))
console.log("1", JSON.stringify(output(1)))
console.log("2", JSON.stringify(output(2)))

Assuming that you may not want to leave empty arrays if no element with given index exists you could modify the code above like so:

const input = [
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["cfdb9868-0f69-5781-b1e4-793301280788", "127.0.0.1", "9146"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"],
  ["b32f4c08-8d53-5fed-8034-4bfb144dfe10"]
]

const output = (n) => input.reduce((list, element)=> element[n] ? [...list, element[n]] : list, [])

console.log("0", JSON.stringify(output(0)))
console.log("1", JSON.stringify(output(1)))
console.log("2", JSON.stringify(output(2)))


问:
Updating WordPress publish posts dates using cron-job
I was looking for help in a particular topic in WordPress in which I haven't worked before. I'm unable to get how to work

with cron-job and its settings.

There are Three posts in WordPress, now these three posts are event posts which is showing event name, event day, event date and event time.

I need to work only with "event date". After doing a bit research stuffs I found that I need to setup a cron job in the

three posts for updating the "event date" fields.

In these three posts following are their respective datas from which I only need to work with "event date" which is the

only section which is important for me at the present moment.

Event 1 Name :- HEALING NIGHT
Event 1 Date :- February 21, 2020
Event 1 Day :- Friday
Event 1 Time :- 7:30 pm

Event 2 Name :- SUNDAY CHURCH SERVICE
Event 2 Date :- February 23, 2020
Event 2 Day :- Sunday
Event 2 Time :- 10:00 am

Event 2 Name :- PRAYING TOGETHER
Event 2 Date :- February 25, 2020
Event 2 Day :- Tuesday
Event 2 Time :- 7:30 pm

Now for these three events there are 3 posts as I mentioned earlier. I am explaining by taking an event for example and then explaining all 3 events alongside.

In the first event the "Event 1 Date" is "February 21, 2020". I need to setup a cron-job (as per my thinking) for automatically updating the "Event 1 Date" as NEXT SEVENTH DAY just after 12:00 AM (midnight of February 21, 2020) i'e it AUTOMATICALLY GETS UPDATED to the "Event 1 Date :- February 28, 2020" and then automatically to "Event 1 Date :- March 6, 2020" and so on. This process will run with respect to all the three posts accordingly.

Like for example for the second event the next "event date" will be "Event 2 Date :- March 1, 2020" and then "Event 2 Date :- March 8, 2020" and so on.

Like for example for the third event the next "event date" will be "Event 2 Date :- March 3, 2020" and then "Event 3 Date :- March 10, 2020" and so on.

All these dates and day will be with respect to Australian Standard time Zone.

Any help is appreciated.

答:
First, this code will look up the 3 posts by name - this is ugly. It would be prettier to create a category (e.g., Events) and add only these 3 posts to the category. This way they could be looked up by category rather than by name.

The code will do the following:

in a daily cron, look up those post's IDs

fetch their post date and see if they are older than today

if older, add 7 days to the date until date is after today

update the post date with the new date

```<code>function mycron_event_dates()
{
  $post_names = array('HEALING NIGHT', 'SUNDAY CHURCH SERVICE', 'PRAYING TOGETHER');
  foreach ($post_names as $post_name) {
    $post_id = post_exists($post_name);
    if ($post_id) {
      $post = get_post($post_id);
      $post_datetime = $post->post_date;
      $post_date = date('Y-m-d', strtotime($post_datetime)); // without time
      $date_now = date('Y-m-d', strtotime(current_time('mysql'))); // right now
      $date_changed = false;
      while ($post_date < $date_now) {
        $post_new_date = strtotime("+7 day", strtotime($post_datetime));
        $post_date = date('Y-m-d', $post_new_date);
        $post_datetime = date('Y-m-d H:i:s', $post_new_date);
        $date_changed = true;
      }
      if ($date_changed) {
        update_post(array(
          'ID' => $post_id,
          'post_date' => $post_datetime,
        )); // modify the post date
      }
    } else {
      error_log("Event schedule: post '$post_name' not found");
    }
  }
}

add_action( 'init', 'mycron_setup_cron');

function mycron_setup_cron()
{
  if ( ! wp_next_scheduled( 'mycron_event_dates' ) ) {
    wp_schedule_event( strtotime(date('Y-m-d')), 'daily', 'mycron_event_dates' );
  }
}

</code>```

You will have to try around with this and see if it actually finds the $post_names (otherwise, it will output an error in the debug log. They have to precisely match the real post names. If this doesn't work, you can try replacing this with an array of post IDs and do a

```<code>$post_ids = array(1111, 2222, 3333); // replace by real post IDs of the events
foreach ($post_ids as $post_id) {
</code>```

loop instead. To test this, you can just add a direct call to mycron_event_dates() into the mycron_setup_cron function so it gets called on every page load for debugging purposes. As soon as it works, you can remove it and leave it to the cron job.

Body:
First, this code will look up the 3 posts by name - this is ugly. It would be prettier to create a category (e.g., Events) and add only these 3 posts to the category. This way they could be looked up by category rather than by name.

The code will do the following:

in a daily cron, look up those post's IDs

fetch their post date and see if they are older than today

if older, add 7 days to the date until date is after today

update the post date with the new date

function mycron_event_dates()
{
  $post_names = array('HEALING NIGHT', 'SUNDAY CHURCH SERVICE', 'PRAYING TOGETHER');
  foreach ($post_names as $post_name) {
    $post_id = post_exists($post_name);
    if ($post_id) {
      $post = get_post($post_id);
      $post_datetime = $post->post_date;
      $post_date = date('Y-m-d', strtotime($post_datetime)); // without time
      $date_now = date('Y-m-d', strtotime(current_time('mysql'))); // right now
      $date_changed = false;
      while ($post_date < $date_now) {
        $post_new_date = strtotime("+7 day", strtotime($post_datetime));
        $post_date = date('Y-m-d', $post_new_date);
        $post_datetime = date('Y-m-d H:i:s', $post_new_date);
        $date_changed = true;
      }
      if ($date_changed) {
        update_post(array(
          'ID' => $post_id,
          'post_date' => $post_datetime,
        )); // modify the post date
      }
    } else {
      error_log("Event schedule: post '$post_name' not found");
    }
  }
}

add_action( 'init', 'mycron_setup_cron');

function mycron_setup_cron()
{
  if ( ! wp_next_scheduled( 'mycron_event_dates' ) ) {
    wp_schedule_event( strtotime(date('Y-m-d')), 'daily', 'mycron_event_dates' );
  }
}

You will have to try around with this and see if it actually finds the $post_names (otherwise, it will output an error in the debug log. They have to precisely match the real post names. If this doesn't work, you can try replacing this with an array of post IDs and do a

$post_ids = array(1111, 2222, 3333); // replace by real post IDs of the events
foreach ($post_ids as $post_id) {

loop instead. To test this, you can just add a direct call to mycron_event_dates() into the mycron_setup_cron function so it gets called on every page load for debugging purposes. As soon as it works, you can remove it and leave it to the cron job.


问:
Is there way to expand all folders in Eclipse project view and search results?
I'm spending a lot of time manually expanding deeply-nested folders in tree views like the Project Explorer and the File Search result tree. Is there a keyboard shortcut or menu command to expand all folders? </p>

答:
buttons to expand all

 Shift and  (+)

buttons to minimize all

 Shift and (-)

ContentLicense: CC BY-SA 2.5


问:
Can JDBC + MySQL be convinced to ignore timezones?
I've got a Java web application in which the client sends timestamped data to the server to be stored in a MySQL database and retrieved later. These timestamps should always be treated as local time and never adjusted for timezone: If a client in one timezone inputs a time of 18:00:00, it should display for a client in another timezone as 18:00:00.

The database column holding this value is of type DATETIME, as I was under the impression that it does no timezone-adjusting. The java application receives timestamps as java.util.Date objects, and converts them to java.sql.Timestamp objects before inserting them in PreparedStatements. Somewhere along the way however, the time values are getting offset when the client and server are in different time zones.

To give you an idea of what I'm looking for, I could store all my timestamps as strings and that would be exactly the effect I want, but it doesn't make sense to me to have to format and parse strings as dates when they need to be operated on.

What is the usual way to handle such applications when timestamp values should always be treated as local time?

答:
This is a really old thread, but I've found that if you insert and/or get the Date using the Timezone of the database, it will work everywhere:

```<code>final Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+2"));
pst.setDate(0, new java.sql.Date(myDate.getTime()), cal);
(...)
resultSet.getDate("COLUMN_NAME", cal).getTime());
</code>```

Hope this helps.

Body:
This is a really old thread, but I've found that if you insert and/or get the Date using the Timezone of the database, it will work everywhere:

final Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+2"));
pst.setDate(0, new java.sql.Date(myDate.getTime()), cal);
(...)
resultSet.getDate("COLUMN_NAME", cal).getTime());

Hope this helps.


问:
Code snippet not working after recent update to wordpress
Hi all I am a bit stumped it seems after the latest update to wordpress this function has stopped working. Any ideas would be gratefully received . . .

First snippet gets the parameter "we" and should then auto fill the form field id #input_2_4 after making some calculations.

```<code>`<script>
$.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
                  .exec(window.location.href);
return results[1] || 0;
}
var we = parseInt( $.urlParam('we') );
$('#input_2_4').val( '£' + (we * 0.1450).toFixed(2));
</script>`
</code>```

Everything seems present in the url string including &we=1685 value but field #input_3_4 is now blank.

Link

答:
I'd try it like below to remove any $ issues. Console.log should let you know if the issue is in getting the URL parameters. You may need to look at enqueueing the script as well to make sure it's getting loaded in the proper order. </p>

```<code>jQuery.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
                  .exec(window.location.href);
  console.log(window.location.href)
  console.log(results[1] || 0);
return results[1] || 0;
}
var we = parseInt( jQuery.urlParam('we') );
jQuery('#input_2_4').val( '£' + (we * 0.1450).toFixed(2));
</code>```

Body:
Hi all I am a bit stumped it seems after the latest update to wordpress this function has stopped working. Any ideas would be gratefully received . . .

First snippet gets the parameter "we" and should then auto fill the form field id #input_2_4 after making some calculations.

``

Everything seems present in the url string including &we=1685 value but field #input_3_4 is now blank.

Link

Body:
I'd try it like below to remove any $ issues. Console.log should let you know if the issue is in getting the URL parameters. You may need to look at enqueueing the script as well to make sure it's getting loaded in the proper order.

jQuery.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
                  .exec(window.location.href);
  console.log(window.location.href)
  console.log(results[1] || 0);
return results[1] || 0;
}
var we = parseInt( jQuery.urlParam('we') );
jQuery('#input_2_4').val( '£' + (we * 0.1450).toFixed(2));


问:
Python's `struct` byte size calcualtion
Unfortunately I don't understand the byte size calculation of the struct python module.
I use this documentation when encoding my values.

```<code>import struct

struct.calcsize('H') # == 2
struct.calcsize('d') # == 8
</code>```

but

```<code>struct.calcsize('Hd') # == 16 != 8+2
</code>```

using the encoding together requires 16 bytes instead of 10

What could be/is the reason for this? Thanks!

答:
Maybe this can help; Python struct giving incorrect length</p>

```<code>struct.calcsize('=Hd')
</code>```

Title: Python's `struct` byte size calcualtion

Body:
Unfortunately I don't understand the byte size calculation of the struct python module.
I use this documentation when encoding my values.

import struct

struct.calcsize('H') # == 2
struct.calcsize('d') # == 8

but

struct.calcsize('Hd') # == 16 != 8+2

using the encoding together requires 16 bytes instead of 10

What could be/is the reason for this? Thanks!

Body:
Maybe this can help; Python struct giving incorrect length

struct.calcsize('=Hd')


问:
Remove gap between widget
I want to close the gap between the lists but its just not working. the only option i have is to increase the gap : Sizedbox,spacer,divider

screenshot of my problem

code:

body: Container(
        child: Column(
          children: <Widget>[
            _mainList(Icon(Icons.cached), "Erste", "21:13 pm"),
            _mainList(Icon(Icons.cached), "Zweite", "21:13 pm"),
            _mainList(Icon(Icons.cached), "Dritte", "21:13 pm"),
            _mainList(Icon(Icons.cached), "Vierte", "21:13 pm"),
          ]
        )
  )```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>  Widget _mainList(Icon symbol, String name, String time){
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 30),
      child: ListTile(
        leading: symbol,
        title: Text(name, textScaleFactor: 1.2),
        trailing: Text(time, textScaleFactor: 1.3),
      ),
    );
  }</code>```

答:
That's because ListTile has it's own Padding. You can try changing the Padding of the ListTile. And if it's still not enough you should create your own Widget without vertical padding

You can always go to the source code of ListTile and copy and customize it.

Title: Remove gap between widget

Body:
I want to close the gap between the lists but its just not working. the only option i have is to increase the gap : Sizedbox,spacer,divider

screenshot of my problem

code:

body: Container(
        child: Column(
          children: <Widget>[
            _mainList(Icon(Icons.cached), "Erste", "21:13 pm"),
            _mainList(Icon(Icons.cached), "Zweite", "21:13 pm"),
            _mainList(Icon(Icons.cached), "Dritte", "21:13 pm"),
            _mainList(Icon(Icons.cached), "Vierte", "21:13 pm"),
          ]
        )
  )

  Widget _mainList(Icon symbol, String name, String time){
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 30),
      child: ListTile(
        leading: symbol,
        title: Text(name, textScaleFactor: 1.2),
        trailing: Text(time, textScaleFactor: 1.3),
      ),
    );
  }


问:
adding && \ to each line on a text file except last line
I'm trying to add && \ on end of each line on a text file except the last line.

Sample input:

```<code>ps
mkdir repo
cd repo/
touch file1.txt
</code>```

Expected output:

```<code>ps && \
mkdir repo && \
cd repo/ && \
touch file1.txt
</code>```

First attempt

I tried this, but it outputs && \ on each line including the final line:

```<code>awk '{print $0"&& \\"}' RS="\r*\n\r*"
</code>```

Second attempt

I tried using sed:

```<code>sed '1s/^//;$!s/$/"&&" \\/;$s/$//'
</code>```

This seems to add extra newlines:

```<code> ps
 && \
mkdir repo
 && \
cd repo/
 && \
touch file1.txt
</code>```

答:
You could use sed for something that simple:

```<code>printf "line 1\nLine 2\nLine 3\n" | sed '$ ! s/$/ \&\& \\ /'
</code>```

Output

```<code>line 1 && \
Line 2 && \
Line 3
</code>```

Body:
I'm trying to add && \ on end of each line on a text file except the last line.

Sample input:

ps
mkdir repo
cd repo/
touch file1.txt

Expected output:

ps && \
mkdir repo && \
cd repo/ && \
touch file1.txt

First attempt

I tried this, but it outputs && \ on each line including the final line:

awk '{print $0"&& \\"}' RS="\r*\n\r*"

Second attempt

I tried using sed:

sed '1s/^//;$!s/$/"&&" \\/;$s/$//'

This seems to add extra newlines:

 ps
 && \
mkdir repo
 && \
cd repo/
 && \
touch file1.txt

Body:
You could use sed for something that simple:

printf "line 1\nLine 2\nLine 3\n" | sed '$ ! s/$/ \&\& \\ /'

Output

line 1 && \
Line 2 && \
Line 3


问:
How to convert string with a specific date format like 'mm/dd/yy' to date object in hibernate query
One of the columns my_column in my table is of type varchar where i store value of date in string. The format is 'MM/DD/YY'. I want to use cast function of hibernate to convert this column value to date. But it appears that the cast function accepts string of 'yy-mm-dd' format to convert. Is it possible to use cast for string with specific date format for conversion. Something like this: cast(am.my_column as date format 'mm/dd/yy')

cast function in hibernate is used this way: cast(am.my_column as date).
My use case is basically converting the column value from string to date and making a date comparison.  cast(am.my_column as date format 'mm/dd/yy') > '12/30/2017'

答: Instead of casting a column value inside the query, you may consider to give '12/30/2017' as parameter (with type of Java Date). So that you can directly write am.my_column > :parameterDate


问:
How to replicate Who bot people search criteria?
Need help in implementing people/user search in the entire organization with a fuzzy search

Microsoft Graph API
People Search
https://graph.microsoft.com/v1.0/me/people/?$search="Mary"
Perform a fuzzy search but this is done only on people collection of the signed-in user
Which doesn't give a result based on the entire organization

Users Search

```<code>Doesn't support following ODATA Parameters
1.$Search https://graph.microsoft.com/v1.0/users?$search="Mary" is not supported
2.$filter doesn't support $filter=substring(displayName, 1) eq 'abc, xyz'
3.contains is also not supported $filter=contains(CompanyName,'Alfreds')
</code>```

答:
Seems your are trying to search user among your organization. But the way you tried is not supported.

If you want to search organization user you could try in following way

```<code>https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Kiron')
</code>```

It will show all the name start with given value. See the screen shot

Please refer to this official docs

Body:
Need help in implementing people/user search in the entire organization with a fuzzy search

Microsoft Graph API
People Search
https://graph.microsoft.com/v1.0/me/people/?$search="Mary"
Perform a fuzzy search but this is done only on people collection of the signed-in user
Which doesn't give a result based on the entire organization

Users Search

Doesn't support following ODATA Parameters
1.$Search https://graph.microsoft.com/v1.0/users?$search="Mary" is not supported
2.$filter doesn't support $filter=substring(displayName, 1) eq 'abc, xyz'
3.contains is also not supported $filter=contains(CompanyName,'Alfreds')

Body:
Seems your are trying to search user among your organization. But the way you tried is not supported.

If you want to search organization user you could try in following way

https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Kiron')

It will show all the name start with given value. See the screen shot

Please refer to this official docs


问:
JMeter - list of installed plugins
I am using JMeter 5.2, only via Command Line Mode.

For debugging purposes I need to get a list of all currently installed plugins for the JMeter version.

How I could achieve that?

答:
You can use plugin manager using CLI:

command-line is simple:

```<code>PluginsManagerCMD <command> [<params>]
</code>```

In your case execute status

```<code>PluginsManagerCMD status
</code>```

Title: JMeter - list of installed plugins

Body:
You can use plugin manager using CLI:

command-line is simple:

PluginsManagerCMD <command> [<params>]

In your case execute status

PluginsManagerCMD status


问:
Exception reading Wifi/3G State
Hi I have the following code that reads Network/Wifi state:

```<code>public String getMacAddress() {
    WifiManager wm = (WifiManager) context
            .getSystemService(Context.WIFI_SERVICE);
    return wm.getConnectionInfo().getMacAddress();
}
</code>```

This throws

```<code>Caused by: java.lang.SecurityException: WifiService: Neither user 10032 nor current process has android.permission.ACCESS_WIFI_STATE
</code>```

And

```<code>public boolean is3G() {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    return !(connectivityManager.getNetworkInfo(
            ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connectivityManager
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED);
}
</code>```

This throws

```<code>Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10032 nor current process has android.permission.ACCESS_NETWORK_STATE.
</code>```

Before someone tell me about the permissions, that is my Manifest (the relevant part):

```<code><manifest>
   <!-- usual tags for activitys... etc.. -->

    <uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
    <uses-permission android:name="android.permission.READ_OWNER_DATA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <user-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <user-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>
</code>```

答:
You've mispelled the latest 2 permissions:

useR-permission instead of useS-permission

Title: Exception reading Wifi/3G State

Body:
Hi I have the following code that reads Network/Wifi state:

public String getMacAddress() {
    WifiManager wm = (WifiManager) context
            .getSystemService(Context.WIFI_SERVICE);
    return wm.getConnectionInfo().getMacAddress();
}

This throws

Caused by: java.lang.SecurityException: WifiService: Neither user 10032 nor current process has android.permission.ACCESS_WIFI_STATE

And

public boolean is3G() {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    return !(connectivityManager.getNetworkInfo(
            ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connectivityManager
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED);
}

This throws

Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10032 nor current process has android.permission.ACCESS_NETWORK_STATE.

Before someone tell me about the permissions, that is my Manifest (the relevant part):

<manifest>

    <uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
    <uses-permission android:name="android.permission.READ_OWNER_DATA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <user-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <user-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>


问:
How to replace Sphinx cover page when making a PDF
I need to change the cover page of a Sphinx-generated latexpdf from RST.

How can I do that without modifying the Sphinx package itself?

I've noticed latex_preamble in the conf file but that only seems to append things. If that is the way an example would be helpful. Right now whatever I do only seems to add to rather than remove the cover page.

答:
Found the answer and posting it here for anyone else who is interested.

In the conf.py file add the following entry:

```<code>"maketitle": "\\input{your_cover.tex}"
</code>```

where your_cover.tex is your LaTeX file you want to be the cover.

Body:
Found the answer and posting it here for anyone else who is interested.

In the conf.py file add the following entry:

"maketitle": "\\input{your_cover.tex}"

where your_cover.tex is your LaTeX file you want to be the cover.


问:
How to get CSV data (as obtained from GoogleSheets - Google Python API) into a table-format (dataframe)?
I have written a piece of code that gets data from a Google-Sheets doc through a path defined by IFTTT, DialogFlow and Hiroku, this happens through this snippet:

```<code># Finding a workbook by name and opening the first sheet
sheet = client.open("IFTTT_Webhooks").sheet1

# Extract and print all of the values
list_of_answers = sheet.get_all_records()

#put the values from the list_of_answers into a csv and store locallyy.
with open('user_answers.csv', 'w') as myfile:
    wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
    wr.writerow(list_of_answers)
</code>```

If I open 'user_answers.csv' the csv looks as such:

[{'Date/Time': 'February 19, 2020 at 09:49PM', 'Intent':
  'poll_completed', 'Statement 1': 'yes', 'Statement 2': 'Sometimes',
  'Statement 3': 'sometimes', 'Statement 4': 'yes'}, {'Date/Time':
  'February 19, 2020 at 09:50PM', 'Intent': 'poll_completed', 'Statement
  1': 'yes', 'Statement 2': 'never', 'Statement 3': 'never', 'Statement
  4': 'no'}, {'Date/Time': 'February 19, 2020 at 10:48PM', 'Intent':
  'poll_completed', 'Statement 1': 'yes', 'Statement 2': 'often',
  'Statement 3': 'sometimes', 'Statement 4': 'yes'}, {'Date/Time':
  'February 20, 2020 at 12:14AM', 'Intent': 'poll_completed', 'Statement
  1': 'now', 'Statement 2': 'often', 'Statement 3': 'sometimes',
  'Statement 4': 'yes'}]

How can I get this data in a table-format with the columns as such and their respective values:

```<code>Date/time,                    Statement 1, Statement 2, Statement 3, Statement 4
February 19, 2020 at 09:49PM.  yes         Sometimes    Sometimes.   no
</code>```

It's ok if the csv format stays as is. But I want to be able to work with data more effectively in another file. So I want to create I guess a dataframe that considers this new (requested) table-format. Any help is appreciated.

答:
list of answers is a list of dictionaries. That means that you should better use a DictWriter here.

```<code>...
#put the values from the list_of_answers into a csv and store locallyy.
with open('user_answers.csv', 'w', newline='') as myfile:
    wr = csv.DictWriter(myfile, quoting=csv.QUOTE_ALL, fieldnames =
                        ['Date/time', 'Statement 1', 'Statement 2', 'Statement 3', 'Statement 4'])
    wr.writeheader()
    wr.writerow(list_of_answers)
</code>```

Body:
I have written a piece of code that gets data from a Google-Sheets doc through a path defined by IFTTT, DialogFlow and Hiroku, this happens through this snippet:

# Finding a workbook by name and opening the first sheet
sheet = client.open("IFTTT_Webhooks").sheet1

# Extract and print all of the values
list_of_answers = sheet.get_all_records()

#put the values from the list_of_answers into a csv and store locallyy.
with open('user_answers.csv', 'w') as myfile:
    wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
    wr.writerow(list_of_answers)

If I open 'user_answers.csv' the csv looks as such:

[{'Date/Time': 'February 19, 2020 at 09:49PM', 'Intent':
  'poll_completed', 'Statement 1': 'yes', 'Statement 2': 'Sometimes',
  'Statement 3': 'sometimes', 'Statement 4': 'yes'}, {'Date/Time':
  'February 19, 2020 at 09:50PM', 'Intent': 'poll_completed', 'Statement
  1': 'yes', 'Statement 2': 'never', 'Statement 3': 'never', 'Statement
  4': 'no'}, {'Date/Time': 'February 19, 2020 at 10:48PM', 'Intent':
  'poll_completed', 'Statement 1': 'yes', 'Statement 2': 'often',
  'Statement 3': 'sometimes', 'Statement 4': 'yes'}, {'Date/Time':
  'February 20, 2020 at 12:14AM', 'Intent': 'poll_completed', 'Statement
  1': 'now', 'Statement 2': 'often', 'Statement 3': 'sometimes',
  'Statement 4': 'yes'}]

How can I get this data in a table-format with the columns as such and their respective values:

Date/time,                    Statement 1, Statement 2, Statement 3, Statement 4
February 19, 2020 at 09:49PM.  yes         Sometimes    Sometimes.   no

It's ok if the csv format stays as is. But I want to be able to work with data more effectively in another file. So I want to create I guess a dataframe that considers this new (requested) table-format. Any help is appreciated.

Body:
list of answers is a list of dictionaries. That means that you should better use a DictWriter here.

...
#put the values from the list_of_answers into a csv and store locallyy.
with open('user_answers.csv', 'w', newline='') as myfile:
    wr = csv.DictWriter(myfile, quoting=csv.QUOTE_ALL, fieldnames =
                        ['Date/time', 'Statement 1', 'Statement 2', 'Statement 3', 'Statement 4'])
    wr.writeheader()
    wr.writerow(list_of_answers)


问:
Python: What exceptions should I handle in this pieces of code?
Not sure how or what exceptions should I take into account.

I have the following piece of code that handles default files to pass to the program if not specified.

```<code>if len(sys.argv)==1:
    fileName = "file1.txt"
else:
    fileName = sys.argv[1]
</code>```

The other part of code is when opening the file:

```<code>with open(fileName) as file:
    for line in file:
        words = line.split(';')
               ....
               ....
               ....
</code>```

答:
You should use FileNotFoundError.

Example below taking user input:

```<code>yourPath = input('Enter your path')
try:
    with open(yourPath) as fl:
        for i in fl:
            print(i)
except FileNotFoundError:
    print('Please enter correct path')
</code>```

OR you can use IOError:

```<code>yourPath = input('Enter your path')
    try:
        with open(yourPath) as fl:
            for i in fl:
                print(i)
    except IOError:
        print('Please enter correct path')
</code>```

OR if you are not sure about just use except:

```<code>yourPath = input('Enter your path')
        try:
            with open(yourPath) as fl:
                for i in fl:
                    print(i)
        except:
            print('Please enter correct path')
</code>```

Body:
Not sure how or what exceptions should I take into account.

I have the following piece of code that handles default files to pass to the program if not specified.

if len(sys.argv)==1:
    fileName = "file1.txt"
else:
    fileName = sys.argv[1]

The other part of code is when opening the file:

with open(fileName) as file:
    for line in file:
        words = line.split(';')
               ....
               ....
               ....

Body:
You should use FileNotFoundError.

Example below taking user input:

yourPath = input('Enter your path')
try:
    with open(yourPath) as fl:
        for i in fl:
            print(i)
except FileNotFoundError:
    print('Please enter correct path')

OR you can use IOError:

yourPath = input('Enter your path')
    try:
        with open(yourPath) as fl:
            for i in fl:
                print(i)
    except IOError:
        print('Please enter correct path')

OR if you are not sure about just use except:

yourPath = input('Enter your path')
        try:
            with open(yourPath) as fl:
                for i in fl:
                    print(i)
        except:
            print('Please enter correct path')


问:
check if image exists with fetch (function does not return response)
I have the following function to check if an image (avatar) exists on the server. If so, the avatar is displayed. If not, a default avatar is displayed.

```<code>export const Avatar = props => {

    const userId = props.userId

    const size = props.size ? props.size : 25

    fetch(URL.Avatar + '/' + userId + '_avatar.jpg').then(res => {
        if (res.status === 404) {
            return (
                <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        } else {
            return (
                <Image source={{uri: URL.Avatar + '/' + userId + '_avatar.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        }
    }).catch(err => {
        return (
            <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                width: size,
                height: size,
                borderRadius: size / 2
            }} />
        )
    })

}
</code>```

However, this function does not work. I get the error "nothing was returned from render", because the function thinks a return-statement (at the end) is missing. However, when I put some console.logs in it, the fetch itself is working. The URLs are correct, because when I put a return at the end with an Image-component, it works.

Anyone knows what the problem could be? Has it anything to do with async?

答:
Fetch is async and will return later than you're expecting it to, because the code will continue to run while fetch is waiting for the response.

You can solve this by awaiting the fetch and making the function async

```<code>export const Avatar = async props => {

    const userId = props.userId

    const size = props.size ? props.size : 25

    return await fetch(URL.Avatar + '/' + userId + '_avatar.jpg').then(res => {
        if (res.status === 404) {
            return (
                <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        } else {
            return (
                <Image source={{uri: URL.Avatar + '/' + userId + '_avatar.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        }
    }).catch(err => {
        return (
            <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                width: size,
                height: size,
                borderRadius: size / 2
            }} />
        )
    })

}
</code>```

Body:
I have the following function to check if an image (avatar) exists on the server. If so, the avatar is displayed. If not, a default avatar is displayed.

export const Avatar = props => {

    const userId = props.userId

    const size = props.size ? props.size : 25

    fetch(URL.Avatar + '/' + userId + '_avatar.jpg').then(res => {
        if (res.status === 404) {
            return (
                <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        } else {
            return (
                <Image source={{uri: URL.Avatar + '/' + userId + '_avatar.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        }
    }).catch(err => {
        return (
            <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                width: size,
                height: size,
                borderRadius: size / 2
            }} />
        )
    })

}

However, this function does not work. I get the error "nothing was returned from render", because the function thinks a return-statement (at the end) is missing. However, when I put some console.logs in it, the fetch itself is working. The URLs are correct, because when I put a return at the end with an Image-component, it works.

Anyone knows what the problem could be? Has it anything to do with async?

Body:
Fetch is async and will return later than you're expecting it to, because the code will continue to run while fetch is waiting for the response.

You can solve this by awaiting the fetch and making the function async

export const Avatar = async props => {

    const userId = props.userId

    const size = props.size ? props.size : 25

    return await fetch(URL.Avatar + '/' + userId + '_avatar.jpg').then(res => {
        if (res.status === 404) {
            return (
                <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        } else {
            return (
                <Image source={{uri: URL.Avatar + '/' + userId + '_avatar.jpg' }} style={{
                    width: size,
                    height: size,
                    borderRadius: size / 2
                }} />
            )
        }
    }).catch(err => {
        return (
            <Image source={{uri: URL.Avatar + '/default.jpg' }} style={{
                width: size,
                height: size,
                borderRadius: size / 2
            }} />
        )
    })

}


问:
forge viewer - how to show object tree / components tree along with viewer?
How we can show object tree / components tree along with viewer? So that user can click on the tree node and then he can see the object/dbid selected in viewer?

Any thoughts on this?

答:
So, you wanted to build a similar model tree aside by Forge Viewer. The demo you shared is using JStree library to list the files in BIM 360. I believe you are familiar with JsTree.

To dump the model tree nodes of Forge Viewer, the code below could be a reference. It enumerates the hierarchy and gets the nodes name and dbId one by one.

```<code>function getAllLeafComponents(viewer, callback) {
    var cbCount = 0;
    var tree;
    var jsData = []

function getLeafComponentsRec(current,parent) {
    cbCount++;
    if (tree.getChildCount(current) != 0) {
        tree.enumNodeChildren(current, function (children) {
            getLeafComponentsRec(children,current);
        }, false);
    }
    var nodeName = viewer.model.getInstanceTree().getNodeName(current)
    jsData.push({id:current,parent:parent,text:nodeName})

    if (--cbCount == 0) callback(jsData);
}
viewer.getObjectTree(function (objectTree) {
    tree = objectTree;
    var rootId = tree.getRootId()
    var nodeName = viewer.model.getInstanceTree().getNodeName(rootId)
    jsData.push({id:rootId,parent:'#',text:nodeName})
    var allLeafComponents = getLeafComponentsRec(rootId,'#');

 });
}
</code>```

To use the function,

```<code>getAllLeafComponents(viewer, function (jsonData) {
   console.log(jsonData);
</code>```

})

It dumps the tree, which can be used with JSTree. Since the data tells DbId, when the JStree node is clicked, get out dbId, and call

```<code>viewer.fitToView([dbId])
</code>```

It will zoom to the object.

Body:
So, you wanted to build a similar model tree aside by Forge Viewer. The demo you shared is using JStree library to list the files in BIM 360. I believe you are familiar with JsTree.

To dump the model tree nodes of Forge Viewer, the code below could be a reference. It enumerates the hierarchy and gets the nodes name and dbId one by one.

function getAllLeafComponents(viewer, callback) {
    var cbCount = 0;
    var tree;
    var jsData = []

function getLeafComponentsRec(current,parent) {
    cbCount++;
    if (tree.getChildCount(current) != 0) {
        tree.enumNodeChildren(current, function (children) {
            getLeafComponentsRec(children,current);
        }, false);
    }
    var nodeName = viewer.model.getInstanceTree().getNodeName(current)
    jsData.push({id:current,parent:parent,text:nodeName})

    if (--cbCount == 0) callback(jsData);
}
viewer.getObjectTree(function (objectTree) {
    tree = objectTree;
    var rootId = tree.getRootId()
    var nodeName = viewer.model.getInstanceTree().getNodeName(rootId)
    jsData.push({id:rootId,parent:'#',text:nodeName})
    var allLeafComponents = getLeafComponentsRec(rootId,'#');

 });
}

To use the function,

getAllLeafComponents(viewer, function (jsonData) {
   console.log(jsonData);

})

It dumps the tree, which can be used with JSTree. Since the data tells DbId, when the JStree node is clicked, get out dbId, and call

viewer.fitToView([dbId])

It will zoom to the object.


问:
Is there any C# framework or code to parse *blg Perfomance Counter log files?
The task is not to gather Performance counters data in my .NET app, but open already prepared binary log files (*.blg)?

I know that MS SQL Profiler (.NET app) can parse binary logs.

答:
Microsoft has opened PowerShell source code, so now we can also find how to implement our own readers on top pdh.dll.

https://github.com/PowerShell/PowerShell/tree/master/src/Microsoft.PowerShell.Commands.Diagnostics


答:
Ive not pulled from google but maybe change the code to something like this so it pulls directly into a dataframe?</p>

```<code>import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pandas as pd

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name(
         'ForMedium-8f02213e02aa.json', scope) # Your json file here

gc = gspread.authorize(credentials)

wks = gc.open("NYC subway data").sheet1

data = wks.get_all_values()
headers = data.pop(0)

df = pd.DataFrame(data, columns=headers)
</code>```

Title: How to get CSV data (as obtained from GoogleSheets - Google Python API) into a table-format (dataframe)?

Body:
Ive not pulled from google but maybe change the code to something like this so it pulls directly into a dataframe?

import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pandas as pd

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name(
         'ForMedium-8f02213e02aa.json', scope) # Your json file here

gc = gspread.authorize(credentials)

wks = gc.open("NYC subway data").sheet1

data = wks.get_all_values()
headers = data.pop(0)

df = pd.DataFrame(data, columns=headers)


问:
Finding anchor text when there are tags there
I want to find the text between a pair of  tags that link to a given site

Here's the re string that I'm using to find the content:

```<code>r'''(<a([^<>]*)href=("|')(http://)?(www\.)?%s([^'"]*)("|')([^<>]*)>([^<]*))</a>''' % our_url
</code>```

The result will be something like this:

```<code>r'''(<a([^<>]*)href=("|')(http://)?(www\.)?stackoverflow.com([^'"]*)("|')([^<>]*)>([^<]*))</a>'''
</code>```

This is great for most links but it errors with a link with tags within it. I tried changing the final part of the regex from:

```<code>([^<]*))</a>'''
</code>```

to:

```<code>(.*))</a>'''
</code>```

But that just got everything on the page after the link, which I don't want. Are there any suggestions on what I can do to solve this?

答: I would not use a regex - use an HTML parser like Beautiful Soup.</p>

OwnerDisplayName: Teifion

Body:
I want to find the text between a pair of  tags that link to a given site

Here's the re string that I'm using to find the content:

r'''(<a([^<>]*)href=("|')(http://)?(www\.)?%s([^'"]*)("|')([^<>]*)>([^<]*))''' % our_url

The result will be something like this:

r'''(<a([^<>]*)href=("|')(http://)?(www\.)?stackoverflow.com([^'"]*)("|')([^<>]*)>([^<]*))'''

This is great for most links but it errors with a link with tags within it. I tried changing the final part of the regex from:

([^<]*))'''

to:

(.*))'''

But that just got everything on the page after the link, which I don't want. Are there any suggestions on what I can do to solve this?

OwnerDisplayName: Andrew Hare


问:
tiny exe to launch a java application
Some questions are like: How can I package my java app into an exe ?
This is not what I am going to ask.

I can launch my application by doing the following:

```<code>java -jar myApp.jar
</code>```

That works perfectly (Assuming the machine has java 1.5.0 or >)

Now what I was thinking of having is a myApp.exe file.

What it would do is the following:

check if java is installed on the machine and its version.
if java is not there it would prompt a dialog to say:
"you need to install java to run myApp"
exactly like eclipse.exe does if it does not find java.
it would then terminate.

if java is there, then effectively run the command
javaw -jar app.jar and spawn the process.

any idea ?

答:
I left this question unanswered for a very long time.
I think it's fair to say that there is no such easy way to do so.
JSmooth looks like a good tool, but it's pretty limited.
Eclipse has written its own solution and so many other solutions written in java deployed as exe.</p>

Title: tiny exe to launch a java application

Body:
Some questions are like: How can I package my java app into an exe ?
This is not what I am going to ask.

I can launch my application by doing the following:

java -jar myApp.jar

That works perfectly (Assuming the machine has java 1.5.0 or >)

Now what I was thinking of having is a myApp.exe file.

What it would do is the following:

check if java is installed on the machine and its version.
if java is not there it would prompt a dialog to say:
"you need to install java to run myApp"
exactly like eclipse.exe does if it does not find java.
it would then terminate.

if java is there, then effectively run the command
javaw -jar app.jar and spawn the process.

any idea ?


问:
clang-cl PCH missing header include error
We generate our PCH as a preprocess step before compile time and then force include the PCH into every file in the project.  This works fine for us with MSVC cl but clang-cl is checking to see if the PCH is included in the sources (excluded by design).

I get the following error:

```<code>fatal error: #include of 'pch.hxx' not seen while attempting to use precompiled header
</code>```

Shouldn't clang-cl detect the /FI (or /clang:-include) as a header within the source?

答: clang-cl should (and does) treat /FI arguments as include lines. Can you paste the compile command that's failing? Maybe you're passing slightly different paths to /Yu and /Fi?

Body:
We generate our PCH as a preprocess step before compile time and then force include the PCH into every file in the project.  This works fine for us with MSVC cl but clang-cl is checking to see if the PCH is included in the sources (excluded by design).

I get the following error:

fatal error: #include of 'pch.hxx' not seen while attempting to use precompiled header

Shouldn't clang-cl detect the /FI (or /clang:-include) as a header within the source?


问:
speed up modelling of subgroups in large data frame
I need to perform an analysis with glmer on many different subgroups of a large dataset and only extract the estimate and z-value of each model. This works perfectly fine if I only use a small subset of my data (or some dummy data, as attached below), but when I try to include the whole data set, it takes forever. Currently I am using this bit of code:

```<code>slope_range <- df %>%
  group_by(region, year, species) %>%
  summarise(slope = coef(summary(glmer(presence ~ transect + (1 | road), family = "binomial")))[2],
            p_val = coef(summary(glmer(presence ~ transect + (1 | road), family = "binomial")))[6])

</code>```

As I said, this works fine, but very slow on a large data set. I'm aware that I could also just write multiple loops, but I assume this would take even longer. Does anyone have a better solution of what could be done to make it faster? Thanks!

Dummy data:

```<code>> dput(df)
structure(list(region = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("ARG", "CHE"), class = "factor"),
    transect = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L,
    6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
    10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L,
    4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
    8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L,
    6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
    10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L,
    4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
    8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), presence = c(1L, 1L,
    1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L,
    0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L,
    0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L,
    1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L,
    1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L,
    1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L,
    0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L,
    0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L,
    0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L), year = c(2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L), species = structure(c(1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("a", "b"), class = "factor"),
    road = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
    ), .Label = c("FG", "MK", "PL", "XY"), class = "factor")), class = "data.frame", row.names = c(NA,
-160L))
</code>```

答:
You are calling coef(summary(glmer(...))) twice for each group, so you can cut the execution time roughly in half by fitting the model and extracting the coefficients once for each group. The following code will extract all the coefficients and their Z and p-values, not just the two values you specified, which I think is preferable if you might end up needing them later. Of course it can be easily modified to discard the other coefficients and keep only the two you specified.

code

```<code>library(tidyverse)
library(lme4)

df %>%
  group_by(region, year, species) %>%
  group_modify(~ data.frame(variable = c('Intercept', 'transect'),
                            coef(summary(glmer(presence ~ transect + (1 | road), family = "binomial", data = .)))))
</code>```

output

```<code># A tibble: 16 x 8
# Groups:   region, year, species [8]
   region  year species variable  Estimate Std..Error z.value Pr...z..
   <fct>  <int> <fct>   <fct>        <dbl>      <dbl>   <dbl>    <dbl>
 1 ARG     2007 a       Intercept    6.11       2.81     2.17   0.0300
 2 ARG     2007 a       transect    -0.743      0.361   -2.06   0.0398
 3 ARG     2007 b       Intercept    1.91       1.22     1.57   0.116
 4 ARG     2007 b       transect    -0.396      0.208   -1.90   0.0570
 5 ARG     2017 a       Intercept    3.95       1.73     2.28   0.0223
 6 ARG     2017 a       transect    -0.654      0.275   -2.38   0.0174
 7 ARG     2017 b       Intercept    2.44       1.33     1.83   0.0668
 8 ARG     2017 b       transect    -0.396      0.208   -1.90   0.0570
 9 CHE     2007 a       Intercept    3.95       1.73     2.28   0.0223
10 CHE     2007 a       transect    -0.654      0.275   -2.38   0.0174
11 CHE     2007 b       Intercept    2.44       1.33     1.83   0.0668
12 CHE     2007 b       transect    -0.396      0.208   -1.90   0.0570
13 CHE     2017 a       Intercept    6.11       2.81     2.17   0.0300
14 CHE     2017 a       transect    -0.743      0.361   -2.06   0.0398
15 CHE     2017 b       Intercept    1.91       1.22     1.57   0.116
16 CHE     2017 b       transect    -0.396      0.208   -1.90   0.0570
</code>```

Body:
I need to perform an analysis with glmer on many different subgroups of a large dataset and only extract the estimate and z-value of each model. This works perfectly fine if I only use a small subset of my data (or some dummy data, as attached below), but when I try to include the whole data set, it takes forever. Currently I am using this bit of code:

slope_range <- df %>%
  group_by(region, year, species) %>%
  summarise(slope = coef(summary(glmer(presence ~ transect + (1 | road), family = "binomial")))[2],
            p_val = coef(summary(glmer(presence ~ transect + (1 | road), family = "binomial")))[6])

As I said, this works fine, but very slow on a large data set. I'm aware that I could also just write multiple loops, but I assume this would take even longer. Does anyone have a better solution of what could be done to make it faster? Thanks!

Dummy data:

> dput(df)
structure(list(region = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("ARG", "CHE"), class = "factor"),
    transect = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L,
    6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
    10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L,
    4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
    8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L,
    6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
    10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L,
    4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
    8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), presence = c(1L, 1L,
    1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L,
    0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L,
    0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L,
    1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L,
    1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L,
    1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L,
    0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L,
    0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L,
    0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L), year = c(2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
    2007L, 2007L, 2007L, 2007L, 2007L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L,
    2017L, 2017L, 2017L, 2017L), species = structure(c(1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("a", "b"), class = "factor"),
    road = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
    ), .Label = c("FG", "MK", "PL", "XY"), class = "factor")), class = "data.frame", row.names = c(NA,
-160L))

Body:
You are calling coef(summary(glmer(...))) twice for each group, so you can cut the execution time roughly in half by fitting the model and extracting the coefficients once for each group. The following code will extract all the coefficients and their Z and p-values, not just the two values you specified, which I think is preferable if you might end up needing them later. Of course it can be easily modified to discard the other coefficients and keep only the two you specified.

code

library(tidyverse)
library(lme4)

df %>%
  group_by(region, year, species) %>%
  group_modify(~ data.frame(variable = c('Intercept', 'transect'),
                            coef(summary(glmer(presence ~ transect + (1 | road), family = "binomial", data = .)))))

output

# A tibble: 16 x 8
# Groups:   region, year, species [8]
   region  year species variable  Estimate Std..Error z.value Pr...z..
   <fct>  <int> <fct>   <fct>        <dbl>      <dbl>   <dbl>    <dbl>
 1 ARG     2007 a       Intercept    6.11       2.81     2.17   0.0300
 2 ARG     2007 a       transect    -0.743      0.361   -2.06   0.0398
 3 ARG     2007 b       Intercept    1.91       1.22     1.57   0.116
 4 ARG     2007 b       transect    -0.396      0.208   -1.90   0.0570
 5 ARG     2017 a       Intercept    3.95       1.73     2.28   0.0223
 6 ARG     2017 a       transect    -0.654      0.275   -2.38   0.0174
 7 ARG     2017 b       Intercept    2.44       1.33     1.83   0.0668
 8 ARG     2017 b       transect    -0.396      0.208   -1.90   0.0570
 9 CHE     2007 a       Intercept    3.95       1.73     2.28   0.0223
10 CHE     2007 a       transect    -0.654      0.275   -2.38   0.0174
11 CHE     2007 b       Intercept    2.44       1.33     1.83   0.0668
12 CHE     2007 b       transect    -0.396      0.208   -1.90   0.0570
13 CHE     2017 a       Intercept    6.11       2.81     2.17   0.0300
14 CHE     2017 a       transect    -0.743      0.361   -2.06   0.0398
15 CHE     2017 b       Intercept    1.91       1.22     1.57   0.116
16 CHE     2017 b       transect    -0.396      0.208   -1.90   0.0570


问:
Searching for files with the same name and 3 letter extensions
So for my task i have to find all files on my C: partition that start with the word 'printer'and they have to have an extension that contains exactly 3 letters i also have to do the same for the .dll extension only</p>

答:
That is a lot of work for PowerShell (my old opinion). :)

If you do it in the native operating system it is:

```<code>dir printer*.??? /s /A-D
</code>```

or

```<code>dir printer*.* /s /A-D
</code>```

(In both cases from the root as /s denotes subfolders. You could add some other stuff for hidden files or folders but /? will give that to you. /A-D removes directories.)

You can pull that in to PowerShell with: cmd /r dir printer*.??? /s /A-D

Now if you do want to use PowerShell Natively you can read up but it'll be like this:

```<code>Get-ChildItem -Path C:\ -Include printer*.??? -File -Recurse -ErrorAction SilentlyContinue
</code>```

You can swap out *.??? for *.dll in the code to get the results you want.

Body:
That is a lot of work for PowerShell (my old opinion). :)

If you do it in the native operating system it is:

dir printer*.??? /s /A-D

or

dir printer*.* /s /A-D

(In both cases from the root as /s denotes subfolders. You could add some other stuff for hidden files or folders but /? will give that to you. /A-D removes directories.)

You can pull that in to PowerShell with: cmd /r dir printer*.??? /s /A-D

Now if you do want to use PowerShell Natively you can read up but it'll be like this:

Get-ChildItem -Path C:\ -Include printer*.??? -File -Recurse -ErrorAction SilentlyContinue

You can swap out *.??? for *.dll in the code to get the results you want.


问:
Is it normal that the value predicted by the model is similar to the trained value?
I wonder if the time series data has been properly learned and predicted.

is this right get the following(next) value?

I want to get the next value like model.predict or etc...

I have x_test and x_test[-1] == t So, the meaning of the next value is t+1, t+2, .... t+n,

in this example I want to get t+1, t+2 ... t+n

I tried

```<code>inputs = total_data[len(total_data) - forecast - look_back:]
inputs = scaler.transform(inputs)
X_test = []
for i in range(look_back, inputs.shape[0]):
    X_test.append(inputs[i - look_back:i])
X_test = np.array(X_test)
predicted = model.predict(X_test)
</code>```

but the result is like below

The results from X_test[-20:] and the following 20 predictions looks like same.

I'm wondering if it's the correct train and predicted value.

and I'm wondering if it was a right training and predict.

答:
Building your test set purely out of your data will show you how good your model predicts one value in the future. Say you predict the temperature based on values of temperature of the last week. Your approach will test how good you can predict the temperature for tomorrow, but not several days into the future. So if you want to test how good your model can predict several values into the future, you'd need to build your test set starting with values from your total_data and then adding your predictions:

```<code>X1 = [X_11, X_12, ..., X_1n-1, X_1n]
Y1 = model.predict(X1)
X2 = [X_12, X_13, ..., X_1n, Y1]
Y2 = model.predict(X2)
X3 = [X_13, X_14, ..., Y1, Y2]
Y3 = model.predict(X3)
</code>```

and so on.

Body:
I wonder if the time series data has been properly learned and predicted.

is this right get the following(next) value?

I want to get the next value like model.predict or etc...

I have x_test and x_test[-1] == t So, the meaning of the next value is t+1, t+2, .... t+n,

in this example I want to get t+1, t+2 ... t+n

I tried

inputs = total_data[len(total_data) - forecast - look_back:]
inputs = scaler.transform(inputs)
X_test = []
for i in range(look_back, inputs.shape[0]):
    X_test.append(inputs[i - look_back:i])
X_test = np.array(X_test)
predicted = model.predict(X_test)

but the result is like below

The results from X_test[-20:] and the following 20 predictions looks like same.

I'm wondering if it's the correct train and predicted value.

and I'm wondering if it was a right training and predict.

Body:
Building your test set purely out of your data will show you how good your model predicts one value in the future. Say you predict the temperature based on values of temperature of the last week. Your approach will test how good you can predict the temperature for tomorrow, but not several days into the future. So if you want to test how good your model can predict several values into the future, you'd need to build your test set starting with values from your total_data and then adding your predictions:

X1 = [X_11, X_12, ..., X_1n-1, X_1n]
Y1 = model.predict(X1)
X2 = [X_12, X_13, ..., X_1n, Y1]
Y2 = model.predict(X2)
X3 = [X_13, X_14, ..., Y1, Y2]
Y3 = model.predict(X3)

and so on.


问:
Insert multiple images randomly into different table cells using Javascript
I'm pretty new in Javascript/Jquery, currently still learning and so here I am seeking help. I would like to insert different images randomly (the location changes everytime i refresh the page) into table cells using Javascript/Jquery and not touching HTML/CSS.

I have tried using append to insert the images, however every image appears in all table cells which weren't what I wanted. I have also tried backgroundrepeat: no repeat but it doesn't work. It would be good if there's some simple coding that would work, so it will be easier for me to understand.

I can't use getElementById cause my separated js file can't detect the ID from the HTML file

HTML:

```<code><table id="Image">
<tr>
<td><div class="ImageHere" value=1></div></td>
<td><div class="ImageHere" value=2></div></td>
<td><div class="ImageHere" value=3></div></td>
<td><div class="ImageHere" value=4></div></td>
<td><div class="ImageHere" value=5></div></td>
</tr>
<tr>
<td><div class="ImageHere" value=6></div></td>
<td><div class="ImageHere" value=7></div></td>
<td><div class="ImageHere" value=8></div></td>
<td><div class="ImageHere" value=9></div></td>
<td><div class="ImageHere" value=10></div></td>
</tr>
</table>
</code>```

my jQuery best try:

```<code>$(document).ready(function(){
    $(".ImageHere").append("<img src='images/card.jpg' width='100%' height='100%' />" ) });
});
</code>```

答:
```<code>document.querySelectorAll('.ImageHere').item(n)
</code>```

or

```<code>$('.ImageHere').eq(n)
</code>```

where n is the index of a random number.

Body:
I'm pretty new in Javascript/Jquery, currently still learning and so here I am seeking help. I would like to insert different images randomly (the location changes everytime i refresh the page) into table cells using Javascript/Jquery and not touching HTML/CSS.

I have tried using append to insert the images, however every image appears in all table cells which weren't what I wanted. I have also tried backgroundrepeat: no repeat but it doesn't work. It would be good if there's some simple coding that would work, so it will be easier for me to understand.

I can't use getElementById cause my separated js file can't detect the ID from the HTML file

HTML:

my jQuery best try:

$(document).ready(function(){
    $(".ImageHere").append("" ) });
});

Body:
document.querySelectorAll('.ImageHere').item(n)

or

$('.ImageHere').eq(n)

where n is the index of a random number.


问:
CSS Sprite Generator: I have the bundled image
I have an image which I want to use as a sprite. Let's say the image has r x c rectangles of the same size which are to be used as backgrounds. Given the dimensions in the following image, how could we generate css for containers with classes R1C1 through to RnCm? The symbols used are defined below the image.

OH = Outer Height, OW = Outer Width,

IH = Inner Height, IW = Inner Width,

VG = Vertical Gutter, HG = Horizontal Gutter

P.S. I am not sure if I have used VG and HG correctly or they should be swapped in the image, please ignore this if the latter is the case.

答: Maybe you can try a CSS sprite generator. I haven't tried this one myself but it should accept any ammount of images and output the right sprite and CSS code.</p>


问:
Plot time series with different timestamps and datetime.time format that goes over one day
I have two datasets that contain temperature and light sensor readings. The measurements were done from 22:35:41 - 04:49:41.

The problem with this datasets is to plot the measurements with respect to the datetime.date format when the measurements are taken from one day to another (22:35:41 - 04:49:41). The plot-function automatically starts from 00:00 and puts the data that was measured before 00:00 to the end of the plot.

```<code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

Temperature = pd.read_excel("/kaggle/input/Temperature_measurement.xlsx")
Light = pd.read_excel("/kaggle/input/Light_measurement.xlsx")

sns.lineplot(x="Time",y="Light", data = Light)
sns.lineplot(y="Temperature", x="Time", data = Temperature)
plt.show()
</code>```

This is a link to the dataset

Here is a link to the Jupyter Notebook

答:
First you need to convert your times to a Pandas Timestamp. Pandas Timestamps don't really support a time on its own, they will attach a date to them, but that's fine since we'll hide that part later.

We also need to detect day changes, which we can do by looking at where the time wraps, which we can find by looking at a time that's smaller than its predecessor.

We can count the cumulative wraps and add that number of dates to our timestamps.

Let's define a function to take the datetime.time objects, convert them to native Pandas Timestamps (using an arbitrary date of 1900-01-01, which is the default for Pandas) and adjusting the day according to the wraps (so we end up with our final times on 1900-01-02):

```<code>def normalize_time(series):
    series = pd.to_datetime(series, format="%H:%M:%S")
    series += pd.to_timedelta(series.lt(series.shift()).cumsum(), unit="D")
    return series
</code>```

Let's now apply it to our DataFrames:

```<code>Light["Time"] = normalize_time(Light["Time"])
Temperature["Time"] = normalize_time(Temperature["Time"])
</code>```

Plotting the data now will look correct, with the times being continuous. Except that the labels of the X ticks will try to display the dates, which are not really what we care about, so let's fix that part now.

We can use Matplotlib's set_major_formatter together with a DateFormatter to include times only:

```<code>import matplotlib.dates

ax = plt.subplot()

sns.lineplot(x="Time", y="Light", data=Light)
sns.lineplot(x="Time", y="Temperature", data=Temperature)

ax.xaxis.set_major_formatter(
    matplotlib.dates.DateFormatter("%H:%M")
)

plt.show()
</code>```

This produces X ticks every hour, which seem to be a great fit for this data set.

Body:
I have two datasets that contain temperature and light sensor readings. The measurements were done from 22:35:41 - 04:49:41.

The problem with this datasets is to plot the measurements with respect to the datetime.date format when the measurements are taken from one day to another (22:35:41 - 04:49:41). The plot-function automatically starts from 00:00 and puts the data that was measured before 00:00 to the end of the plot.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

Temperature = pd.read_excel("/kaggle/input/Temperature_measurement.xlsx")
Light = pd.read_excel("/kaggle/input/Light_measurement.xlsx")

sns.lineplot(x="Time",y="Light", data = Light)
sns.lineplot(y="Temperature", x="Time", data = Temperature)
plt.show()

This is a link to the dataset

Here is a link to the Jupyter Notebook

Body:
First you need to convert your times to a Pandas Timestamp. Pandas Timestamps don't really support a time on its own, they will attach a date to them, but that's fine since we'll hide that part later.

We also need to detect day changes, which we can do by looking at where the time wraps, which we can find by looking at a time that's smaller than its predecessor.

We can count the cumulative wraps and add that number of dates to our timestamps.

Let's define a function to take the datetime.time objects, convert them to native Pandas Timestamps (using an arbitrary date of 1900-01-01, which is the default for Pandas) and adjusting the day according to the wraps (so we end up with our final times on 1900-01-02):

def normalize_time(series):
    series = pd.to_datetime(series, format="%H:%M:%S")
    series += pd.to_timedelta(series.lt(series.shift()).cumsum(), unit="D")
    return series

Let's now apply it to our DataFrames:

Light["Time"] = normalize_time(Light["Time"])
Temperature["Time"] = normalize_time(Temperature["Time"])

Plotting the data now will look correct, with the times being continuous. Except that the labels of the X ticks will try to display the dates, which are not really what we care about, so let's fix that part now.

We can use Matplotlib's set_major_formatter together with a DateFormatter to include times only:

import matplotlib.dates

ax = plt.subplot()

sns.lineplot(x="Time", y="Light", data=Light)
sns.lineplot(x="Time", y="Temperature", data=Temperature)

ax.xaxis.set_major_formatter(
    matplotlib.dates.DateFormatter("%H:%M")
)

plt.show()

This produces X ticks every hour, which seem to be a great fit for this data set.


问:
NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle
In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error comes?

```<code>  NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle
  /Users/XXXXXXXXXXXX/Library/Application Support/iPhone simulator/6.0/Applications/
  B7A7D461-1CFE-4B05-AF32-00B65FCFFF49/XXXXXXXXXX.app> (loaded)'with name
 'RootViewController''

  *** First throw call stack:
  (0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418 0x380648 0x380882 0
  x380b2a  0x397ef5 0x397fdb x398286 0x398381 0x398eab 0x398fc9 0x399055 0x49e3ab
  0x2ef92d 0x136b6b0 0x1f12fc0 0x1f0733c 0x1f12eaf 0x38e8cd 0x2d71a6 0x2d5cbf
  0x2d5bd9 0x2d4e34 0x2d4c6e 0x2d5a29 0x2d8922 0x382fec 0x2cfbc4 0x2cfdbf
  0x2cff55 0x2d8f67 0x2b30 0x29c7b7 0x29cda7 0x29dfab 0x2af315 0x2b024b 0x2a1cf8
  0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da
  0x29f65c 0x269d 0x25c5)
  ibc++abi.dylib: terminate called throwing an exception
  (lldb)
</code>```

This is the code in AppDelegate.h

```<code>  #import <UIKit/UIKit.h>

  @class RootViewController;

  @interface AppDelegate : UIResponder <UIApplicationDelegate>{

       UINavigationController *navigationController;
   }

  @property (strong, nonatomic) UIWindow *window;

  @property (strong, nonatomic) RootViewController *viewController;
  @property (strong, nonatomic) UINavigationController * navigationController;

  @end
</code>```

This is the code of AppDelegate.m

```<code>  #import "AppDelegate.h"

  #import "RootViewController.h"

  @implementation AppDelegate

  @synthesize navigationController;
  @synthesize viewController;
  @synthesize window;

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
 {
         self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.

         if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
               self.viewController = [[RootViewController alloc]      initWithNibName:@"RootViewController_iPhone.xib" bundle:nil];
   } else {
    self.viewController = [[RootViewController alloc] initWithNibName:@"RootViewController_iPad.xib" bundle:nil];
   }

    RootViewController *rootMenu=[[RootViewController alloc]initWithNibName:@"RootViewController" bundle:nil];

    self.navigationController =[[UINavigationController alloc]initWithRootViewController:rootMenu];

    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}
</code>```

答:
In Identity inspector change class name with the corresponding identifier and also
In Attributes inspector modify Indentifier then it should work as expected.

Body:
In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error comes?

  NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle
  /Users/XXXXXXXXXXXX/Library/Application Support/iPhone simulator/6.0/Applications/
  B7A7D461-1CFE-4B05-AF32-00B65FCFFF49/XXXXXXXXXX.app> (loaded)'with name
 'RootViewController''

  *** First throw call stack:
  (0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418 0x380648 0x380882 0
  x380b2a  0x397ef5 0x397fdb x398286 0x398381 0x398eab 0x398fc9 0x399055 0x49e3ab
  0x2ef92d 0x136b6b0 0x1f12fc0 0x1f0733c 0x1f12eaf 0x38e8cd 0x2d71a6 0x2d5cbf
  0x2d5bd9 0x2d4e34 0x2d4c6e 0x2d5a29 0x2d8922 0x382fec 0x2cfbc4 0x2cfdbf
  0x2cff55 0x2d8f67 0x2b30 0x29c7b7 0x29cda7 0x29dfab 0x2af315 0x2b024b 0x2a1cf8
  0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da
  0x29f65c 0x269d 0x25c5)
  ibc++abi.dylib: terminate called throwing an exception
  (lldb)

This is the code in AppDelegate.h

  #import <UIKit/UIKit.h>

  @class RootViewController;

  @interface AppDelegate : UIResponder <UIApplicationDelegate>{

       UINavigationController *navigationController;
   }

  @property (strong, nonatomic) UIWindow *window;

  @property (strong, nonatomic) RootViewController *viewController;
  @property (strong, nonatomic) UINavigationController * navigationController;

  @end

This is the code of AppDelegate.m

  #import "AppDelegate.h"

  #import "RootViewController.h"

  @implementation AppDelegate

  @synthesize navigationController;
  @synthesize viewController;
  @synthesize window;

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
 {
         self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.

         if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
               self.viewController = [[RootViewController alloc]      initWithNibName:@"RootViewController_iPhone.xib" bundle:nil];
   } else {
    self.viewController = [[RootViewController alloc] initWithNibName:@"RootViewController_iPad.xib" bundle:nil];
   }

    RootViewController *rootMenu=[[RootViewController alloc]initWithNibName:@"RootViewController" bundle:nil];

    self.navigationController =[[UINavigationController alloc]initWithRootViewController:rootMenu];

    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}


问:
How to manage Azure App Service Certificate
I have purchased an app service wildcard certificate and would like to import this cert into Azure Key vault for other purposes.  Once I export/import the cert into Azure key vault and use for other custom domains (for example: APIM) will the auto renew ability continue to work as expected (automatically) or will I be forced to manage the cert differently now stored in key vault? </p>

答:
Key Vault Certificates support automatic renewal with selected issuers - Key Vault partner X509 certificate providers / certificate authorities.

Non-partnered providers/authorities are also allowed but, will not support the auto renewal feature.

So, the cert imported into key vault will auto renew the cert instead of manually renewing it.


问:
Creating and filling a dataframe per row from the script (i.e. without using separate vectors for the columns)
I'm trying to create a data frame from a list of "records", i.e. per row (compare to loading a CSV file, but now from within the R script file), but all the examples I can find create the data frame from vectors containing the individual columns.

The closest thing I found was starting with an empty data frame and then add the rows using rbind and list's, but then the original column names get lost and all columns have class character.

```<code>> generations <- data.frame(launch_date=as.Date(integer(), origin="1970-01-01"), generation=character(), stringsAsFactors=FALSE)
> generations
[1] launch_date generation
<0 rows> (or 0-length row.names)
</code>```

All fine here. And now:

```<code>> generations <- rbind(generations,list("2010-09-01", "Generation 1"), stringsAsFactors=FALSE)
> generations
  X.2010.09.01. X.Generation.1.
1    2010-09-01    Generation 1
> str(generations)
'data.frame':   1 obs. of  2 variables:
 $ X.2010.09.01.  : chr "2010-09-01"
 $ X.Generation.1.: chr "Generation 1"
</code>```

Original column names and classes gone :(

The reason to want something like this is that maintaining the data in separate vectors is cumbersome and invites making mistakes. So the idea here was to use an rbind with a bunch of list's where dates and names can be maintained together (i.e. pairwise, per "record"/row).

How to go about this one?

答:
I found an easier way to accomplish this, starting from a matrix, and then convert it into a data frame:

```<code>generations_matrix <- matrix(data=c(
    "2014-04-01", "Generation 1",
    "2016-06-01", "Generation 2",
    "2018-01-01", "Generation 3"
    ), ncol = 2, dimnames=list(NULL,c("launch_date", "generation")), byrow=TRUE)
generations <- data.frame(
    launch_date=as.Date(generations_matrix[,1]), generation=generations_matrix[,2],
    stringsAsFactors=FALSE)
</code>```

results in this:

```<code>> generations
  launch_date   generation
1  2014-04-01 Generation 1
2  2016-06-01 Generation 2
3  2018-01-01 Generation 3
> str(generations)
'data.frame':   3 obs. of  2 variables:
 $ launch_date: Date, format: "2014-04-01" "2016-06-01" ...
 $ generation : chr  "Generation 1" "Generation 2" "Generation 3"
</code>```

Which is exactly what I was looking for: a way to define and maintain a data frame in line per row.

Body:
I'm trying to create a data frame from a list of "records", i.e. per row (compare to loading a CSV file, but now from within the R script file), but all the examples I can find create the data frame from vectors containing the individual columns.

The closest thing I found was starting with an empty data frame and then add the rows using rbind and list's, but then the original column names get lost and all columns have class character.

> generations <- data.frame(launch_date=as.Date(integer(), origin="1970-01-01"), generation=character(), stringsAsFactors=FALSE)
> generations
[1] launch_date generation
<0 rows> (or 0-length row.names)

All fine here. And now:

> generations <- rbind(generations,list("2010-09-01", "Generation 1"), stringsAsFactors=FALSE)
> generations
  X.2010.09.01. X.Generation.1.
1    2010-09-01    Generation 1
> str(generations)
'data.frame':   1 obs. of  2 variables:
 $ X.2010.09.01.  : chr "2010-09-01"
 $ X.Generation.1.: chr "Generation 1"

Original column names and classes gone :(

The reason to want something like this is that maintaining the data in separate vectors is cumbersome and invites making mistakes. So the idea here was to use an rbind with a bunch of list's where dates and names can be maintained together (i.e. pairwise, per "record"/row).

How to go about this one?

Body:
I found an easier way to accomplish this, starting from a matrix, and then convert it into a data frame:

generations_matrix <- matrix(data=c(
    "2014-04-01", "Generation 1",
    "2016-06-01", "Generation 2",
    "2018-01-01", "Generation 3"
    ), ncol = 2, dimnames=list(NULL,c("launch_date", "generation")), byrow=TRUE)
generations <- data.frame(
    launch_date=as.Date(generations_matrix[,1]), generation=generations_matrix[,2],
    stringsAsFactors=FALSE)

results in this:

> generations
  launch_date   generation
1  2014-04-01 Generation 1
2  2016-06-01 Generation 2
3  2018-01-01 Generation 3
> str(generations)
'data.frame':   3 obs. of  2 variables:
 $ launch_date: Date, format: "2014-04-01" "2016-06-01" ...
 $ generation : chr  "Generation 1" "Generation 2" "Generation 3"

Which is exactly what I was looking for: a way to define and maintain a data frame in line per row.