问:
Defining command in base View model
We would like define some button be visible in every page for a set of users. We defined button as control template for view and called out it in the pages that require them to be displayed.

```<code><Button ImageSource="home_footer.png" BackgroundColor="Transparent" HorizontalOptions="FillAndExpand"
        Command="{TemplateBinding BindingContext.HomeCommand}"/>
</code>```

Here command is selected according to the binding context, i.e corresponding view model. Command need to written multiple times. I thought of including the command in base view model so that it needs to written only once. Is there any option for implementing this option.
Thanks in advance.

答:
In your BaseViewModel add a command

```<code>    public ICommand HomeCommand { get; set; }
</code>```

In your base ContentPage add a bindable property that supplies you this command:

```<code>   public ICommand Command
    {
        get => (ICommand)GetValue(CommandProperty);
        set => SetValue(CommandProperty, value);
    }

    public object CommandParameter
    {
        get => GetValue(CommandParameterProperty);
        set => SetValue(CommandParameterProperty, value);
    }

    public static readonly BindableProperty CommandProperty = BindableProperty.Create(
        nameof(Command),
        typeof(ICommand),
        typeof(ClassName),
        null
        );

    public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(
        nameof(CommandParameter),
        typeof(object),
        typeof(ClassName),
        null
        );
</code>```

Supply a command to this property from the ContentPage

```<code><base:CustomContentPage ....
Command="{Binding HomeCommand}">
</code>```

Set it to your Button something like:

You can give it a better name to explain the behaviour,

Goodluck!

Feel free to get back if you have queries!

Title: Defining command in base View model

Body:
We would like define some button be visible in every page for a set of users. We defined button as control template for view and called out it in the pages that require them to be displayed.

<Button ImageSource="home_footer.png" BackgroundColor="Transparent" HorizontalOptions="FillAndExpand"
        Command="{TemplateBinding BindingContext.HomeCommand}"/>

Here command is selected according to the binding context, i.e corresponding view model. Command need to written multiple times. I thought of including the command in base view model so that it needs to written only once. Is there any option for implementing this option.
Thanks in advance.

Body:
In your BaseViewModel add a command

    public ICommand HomeCommand { get; set; }

In your base ContentPage add a bindable property that supplies you this command:

   public ICommand Command
    {
        get => (ICommand)GetValue(CommandProperty);
        set => SetValue(CommandProperty, value);
    }

    public object CommandParameter
    {
        get => GetValue(CommandParameterProperty);
        set => SetValue(CommandParameterProperty, value);
    }

    public static readonly BindableProperty CommandProperty = BindableProperty.Create(
        nameof(Command),
        typeof(ICommand),
        typeof(ClassName),
        null
        );

    public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(
        nameof(CommandParameter),
        typeof(object),
        typeof(ClassName),
        null
        );

Supply a command to this property from the ContentPage

<base:CustomContentPage ....
Command="{Binding HomeCommand}">

Set it to your Button something like:

You can give it a better name to explain the behaviour,

Goodluck!

Feel free to get back if you have queries!


来源: stackexchange

问:
How does <ENTER> work on a webpage?
I have a webpage with a Master.  The master contains

search1Button with PostBackUrl="~/Search.aspx"

The child page contains

search2Button with onclick="btnSearch_Click"

When a user hits <enter> search1Button will execute.  When nothing is active I can see how search1Button can be viewed as the default.  But, when the active textbox is say

search2TextBox

Things can be a little confusing when suddenly search1Button executes instead of search2Button.

A. How does the page decide what executes?

B. Does this have anything to do with Forms?  If yes, does having only 1 Form limit my ability to control the situation (I cannot add more forms due to major problems experienced by me and discussed on SO with nested forms)?

答: You can use the DefaultButton attribute of the form.

ContentLicense: CC BY-SA 3.0

Title: How does <ENTER> work on a webpage?


问:
Author Element not display with RDFa
sorry for my English...

I have a Website and I'll eBooks to offer, I build my RDFa for a eBook this,

```<code><main vocab="http://schema.org/EBook" >
<h1>Title...</h1>
 <h1>Introduction to Linux </h1>
 <h2>A Hands on Guide</h2>
 <p><b>Author: </b> name_author</p>
 <meta typeof="Book" resource="http://en.tldp.org/LDP/intro-linux/html/index.html">
 <meta property="name" content="Introduction to Linux - A Hands on Guide"/>
 <meta property="author" typeof="Person" content="Machtelt Garrels"/>
 <meta propety="inLanguage" content="en"/>
</code>```

When test with search.google.com/structured-data it to say,

and

I do try to give the Author name, but can't.

Can Please someone help me, Thanks!

答:
People help me with the solution..., how to build my RDFa for Books.</p>

```<code><h2 property="name">
  <span class="title">Introduction to Linux</span>
  <span hidden="">–</span>
  <span class="subtitle">A Hands on Guide</span>
 </h2>
 <p property="author" typeof="Person">
<b>Author:</b>
 <span property="name">Machtelt Garrels</span>
</p>
<meta property="inLanguage" content="en"/>
</code>```

ContentLicense: CC BY-SA 4.0

Title: Author Element not display with RDFa

Body:
sorry for my English...

I have a Website and I'll eBooks to offer, I build my RDFa for a eBook this,

Title...

Introduction to Linux

A Hands on Guide

Author:  name_author

 <meta typeof="Book" resource="http://en.tldp.org/LDP/intro-linux/html/index.html">
 <meta property="name" content="Introduction to Linux - A Hands on Guide"/>
 <meta property="author" typeof="Person" content="Machtelt Garrels"/>
 <meta propety="inLanguage" content="en"/>

When test with search.google.com/structured-data it to say,

and

I do try to give the Author name, but can't.

Can Please someone help me, Thanks!

Body:
People help me with the solution..., how to build my RDFa for Books.

<h2 property="name">
  <span class="title">Introduction to Linux</span>
  <span hidden="">–</span>
  <span class="subtitle">A Hands on Guide</span>
 </h2>
 <p property="author" typeof="Person">
<b>Author:</b>
 <span property="name">Machtelt Garrels</span>
</p>
<meta property="inLanguage" content="en"/>


问:
Preselect checkboxes in a Vuetify list item group from an array of objects
I am trying to preselect checkboxes in a v-list-item-group , but can't for the life of me figure out what true-value should be set to in order for it to check the checkbox.

I have also tried changing the value of true-value to column.value, to no avail.

As opposed to most examples I have found, the model for this v-list-item-group is an array of objects, as opposed to primitives that seem to be the norm.

In the code snippet example provided (sorry, couldn't manage to make it run in the sandbox), "Column 2" should be preselected.

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    defaultColumns: [{
        value: 'column1',
        text: 'Column 1',
      },
      {
        value: 'column2',
        text: 'Column 2',
      },
      {
        value: 'column3',
        text: 'Column 3'
      },
    ],
    selectedColumns: [{
      value: 'column2',
      text: 'Column 2',
    }],
  }),
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.2.13/vuetify.js"></script>
<div id="app">
  <v-app>
    <v-list>
      <v-subheader>
        Select columns
      </v-subheader>

      <v-list-item-group v-model="selectedColumns" multiple>
        <v-list-item v-for="column in defaultColumns" :key="column.value" :value="column">
          <template v-slot:default="{ active, toggle }">
            <v-list-item-action>
              <v-checkbox
                :input-value="active"
                :true-value="column"
                color="primary"
                @click="toggle"
              />
            </v-list-item-action>

            <v-list-item-title>
              {{ column.text }}
            </v-list-item-title>
          </template>
        </v-list-item>
      </v-list-item-group>
    </v-list>
  </v-app>
</div></code>```

答:
Use v-model into v-checkbox instead of toggle or click, assign a boolean value to v-model and the checkbox will be automatically selected/unselected, as per vuetify docs :

```<code><v-checkbox
      v-model="checkbox"
      :label="`Checkbox 1: ${checkbox.toString()}`"
    ></v-checkbox>
.
..
...
<script>
  export default {
    data () {
      return {
        checkbox: true,
        radioGroup: 1,
        switch1: true,
      }
    },
  }
</script>
</code>```

To advise you to find a solution i did this example:

https://codepen.io/emkeythekeyem/pen/XWbjzav

HTML :

```<code><div id="app">
  <v-app>
    <v-list>
      <v-subheader>
        Select columns
      </v-subheader>

      <v-list-item-group v-model="selectedColumns" multiple>
        <v-list-item v-for="column in defaultColumns" :key="column.value" :value="column">
          <template v-slot:default="{ active, toggle }">
            <v-list-item-action>
              <v-checkbox
                :input-value="active"
                color="primary"
                v-model="selectedColumns.filter(e => e.value === column.value).length > 0"
              />
            </v-list-item-action>

            <v-list-item-title>
              {{ column.text }}
            </v-list-item-title>
          </template>
        </v-list-item>
      </v-list-item-group>
    </v-list>
  </v-app>
</div>
</code>```

Vue

```<code>new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    defaultColumns: [{
        value: 'column1',
        text: 'Column 1',
      },
      {
        value: 'column2',
        text: 'Column 2',
      },
      {
        value: 'column3',
        text: 'Column 3'
      },
    ],
    selectedColumns: [{
      value: 'column2',
      text: 'Column 2',
    }],
  }),
})
</code>```

Body:
I am trying to preselect checkboxes in a v-list-item-group , but can't for the life of me figure out what true-value should be set to in order for it to check the checkbox.

I have also tried changing the value of true-value to column.value, to no avail.

As opposed to most examples I have found, the model for this v-list-item-group is an array of objects, as opposed to primitives that seem to be the norm.

In the code snippet example provided (sorry, couldn't manage to make it run in the sandbox), "Column 2" should be preselected.

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    defaultColumns: [{
        value: 'column1',
        text: 'Column 1',
      },
      {
        value: 'column2',
        text: 'Column 2',
      },
      {
        value: 'column3',
        text: 'Column 3'
      },
    ],
    selectedColumns: [{
      value: 'column2',
      text: 'Column 2',
    }],
  }),
});

  <v-app>
    <v-list>
      <v-subheader>
        Select columns
      </v-subheader>

      <v-list-item-group v-model="selectedColumns" multiple>
        <v-list-item v-for="column in defaultColumns" :key="column.value" :value="column">
          <template v-slot:default="{ active, toggle }">
            <v-list-item-action>
              <v-checkbox
                :input-value="active"
                :true-value="column"
                color="primary"
                @click="toggle"
              />
            </v-list-item-action>

            <v-list-item-title>
              {{ column.text }}
            </v-list-item-title>
          </template>
        </v-list-item>
      </v-list-item-group>
    </v-list>
  </v-app>

Body:
Use v-model into v-checkbox instead of toggle or click, assign a boolean value to v-model and the checkbox will be automatically selected/unselected, as per vuetify docs :

<v-checkbox
      v-model="checkbox"
      :label="`Checkbox 1: ${checkbox.toString()}`"
    ></v-checkbox>
.
..
...
<script>
  export default {
    data () {
      return {
        checkbox: true,
        radioGroup: 1,
        switch1: true,
      }
    },
  }
</script>

To advise you to find a solution i did this example:

https://codepen.io/emkeythekeyem/pen/XWbjzav

HTML :

<div id="app">
  <v-app>
    <v-list>
      <v-subheader>
        Select columns
      </v-subheader>

      <v-list-item-group v-model="selectedColumns" multiple>
        <v-list-item v-for="column in defaultColumns" :key="column.value" :value="column">
          <template v-slot:default="{ active, toggle }">
            <v-list-item-action>
              <v-checkbox
                :input-value="active"
                color="primary"
                v-model="selectedColumns.filter(e => e.value === column.value).length > 0"
              />
            </v-list-item-action>

            <v-list-item-title>
              {{ column.text }}
            </v-list-item-title>
          </template>
        </v-list-item>
      </v-list-item-group>
    </v-list>
  </v-app>
</div>

Vue

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    defaultColumns: [{
        value: 'column1',
        text: 'Column 1',
      },
      {
        value: 'column2',
        text: 'Column 2',
      },
      {
        value: 'column3',
        text: 'Column 3'
      },
    ],
    selectedColumns: [{
      value: 'column2',
      text: 'Column 2',
    }],
  }),
})


问:
Load fancybox content inside div?
I am trying to change the fancybox 2 functionality by placing the content inside a div(instead of floating it on the center of the screen) which at first will be hidden, and will expand to fit it's content. When the close button is hit then the div will shrink and hide again.

I am using iframe fancybox type for this and the content that will be loaded is html.
I tried to use appendTo but had no success, any ideas on how to pull this out?

fancybox js file:

```<code>overlay:f('<div class="fancybox-overlay"></div>').appendTo(b.parent||"body")
</code>```

if appendTo myDiv nothing changes(content still loads but in the middle of the body):

```<code>overlay:f('<div class="fancybox-overlay"></div>').appendTo("#myDiv")
</code>```

答:
You can add an option parentEl to the fancybox options,

Just like parentEl: '.myDivClass'

Title: Load fancybox content inside div?

Body:
I am trying to change the fancybox 2 functionality by placing the content inside a div(instead of floating it on the center of the screen) which at first will be hidden, and will expand to fit it's content. When the close button is hit then the div will shrink and hide again.

I am using iframe fancybox type for this and the content that will be loaded is html.
I tried to use appendTo but had no success, any ideas on how to pull this out?

fancybox js file:

overlay:f('

').appendTo(b.parent||"body")

if appendTo myDiv nothing changes(content still loads but in the middle of the body):

overlay:f('

').appendTo("#myDiv")


问:
How is the process done by detecting all the data on the page using jQuery?
I want to make a progress bar that counts forward with the specified start date and end date line. I can perform the operation I want with the code I wrote. But since there is a lot of code, there is confusion.

I want to follow a more logical way. My current codes are listed below.

MY HTML:

```<code><div id="div1"></div>
<div id="div2"></div>
</code>```

MY jQuery + PHP:

```<code>progressBar(<?php echo strtotime("2020-02-20 10:00:00"); ?>, <?php echo strtotime("2020-02-20 15:00:00"); ?>, <?php echo time(); ?>, '#div1');
progressBar(<?php echo strtotime("2020-02-20 04:00:00"); ?>, <?php echo strtotime("2020-02-20 09:00:00"); ?>, <?php echo time(); ?>, '#div2');

/** Start Time, Stop Time, Now Time, Element Id **/
function progressBar(start, stop, now, element) {
    now++
    var timepast = now - start;
    var duration = stop - start;
    var percent  = ( 100 - ( timepast / duration ) *100 ).toFixed(2);

    $(element).text(percent);

    var timer = setTimeout(function(){
        progressBar(start, stop, now);
    }, 1000);

    if( percent < 0){
        clearInterval(timer);
    }
}
</code>```

Desired Method/Result:

I want it to automatically detect and count in real time all the elements that are set as follows.

I need jQuery (Javascript) codes to detect these HTML codes.

```<code><div id="div1" data-start="2020-02-20 10:00:00" data-stop="2020-02-20 15:00:00"></div>
<div id="div2" data-start="2020-02-20 04:00:00" data-stop="2020-02-20 09:00:00"></div>
</code>```

答:
With the code below, you only have to create your div's and the script automatically detect them and shows the progressbar.

function progressBar(start, stop, element) {

    var now = (new Date().getTime() / 1000);
    var timepast = now - start;
    var duration = stop - start;
    var percent  = ( 100 - ( timepast / duration ) *100 ).toFixed(2);

    $(element).text(percent);

    var timer = setTimeout(function(){
        progressBar(start, stop, element);
    }, 1000);

    if( percent < 0){
        clearInterval(timer);
    }
}

$('div[data-start][data-stop]').each( function( index, element ) {
  var start = $(element).attr( 'data-start' );
  var stop = $(element).attr( 'data-stop' );
  progressBar( start, stop, element );
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="div1" data-start="<?php echo strtotime("2020-02-20 10:00:00"); ?>" data-stop="<?php echo strtotime("2020-02-20 04:00:00"); ?>"></div>
<div id="div2" data-start="<?php echo strtotime("2020-02-20 04:00:00"); ?>" data-stop="<?php echo strtotime("2020-02-20 09:00:00"); ?>"></div></code>```

Body:
I want to make a progress bar that counts forward with the specified start date and end date line. I can perform the operation I want with the code I wrote. But since there is a lot of code, there is confusion.

I want to follow a more logical way. My current codes are listed below.

MY HTML:

MY jQuery + PHP:

progressBar(<?php echo strtotime("2020-02-20 10:00:00"); ?>, <?php echo strtotime("2020-02-20 15:00:00"); ?>, <?php echo time(); ?>, '#div1');
progressBar(<?php echo strtotime("2020-02-20 04:00:00"); ?>, <?php echo strtotime("2020-02-20 09:00:00"); ?>, <?php echo time(); ?>, '#div2');

/** Start Time, Stop Time, Now Time, Element Id **/
function progressBar(start, stop, now, element) {
    now++
    var timepast = now - start;
    var duration = stop - start;
    var percent  = ( 100 - ( timepast / duration ) *100 ).toFixed(2);

    $(element).text(percent);

    var timer = setTimeout(function(){
        progressBar(start, stop, now);
    }, 1000);

    if( percent < 0){
        clearInterval(timer);
    }
}

Desired Method/Result:

I want it to automatically detect and count in real time all the elements that are set as follows.

I need jQuery (Javascript) codes to detect these HTML codes.

Body:
With the code below, you only have to create your div's and the script automatically detect them and shows the progressbar.

function progressBar(start, stop, element) {

    var now = (new Date().getTime() / 1000);
    var timepast = now - start;
    var duration = stop - start;
    var percent  = ( 100 - ( timepast / duration ) *100 ).toFixed(2);

    $(element).text(percent);

    var timer = setTimeout(function(){
        progressBar(start, stop, element);
    }, 1000);

    if( percent < 0){
        clearInterval(timer);
    }
}

$('div[data-start][data-stop]').each( function( index, element ) {
  var start = $(element).attr( 'data-start' );
  var stop = $(element).attr( 'data-stop' );
  progressBar( start, stop, element );
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="div1" data-start="<?php echo strtotime("2020-02-20 10:00:00"); ?>" data-stop="<?php echo strtotime("2020-02-20 04:00:00"); ?>"></div>
<div id="div2" data-start="<?php echo strtotime("2020-02-20 04:00:00"); ?>" data-stop="<?php echo strtotime("2020-02-20 09:00:00"); ?>"></div>


问:
Servlet Compiling error
I developed simple servlet using Apache Tomcat 6.

Firstly I write simple Hello World print servlet. Then set CLASSPATH for servlet-api.jar and compile and copy webapps/login/WEB-INF/classes/test/HelloServlet.class. That's working fine.

After I write simple JDBC connection in the servlet. I downloaded MySQL J-Connector and set CLASSPATH like this:

```<code>C:\Program Files\apache-tomcat-6.0.32\lib\servlet-api.jar;C:\Program Files\apache-tomcat-6.0.32\lib\mysql-connector-java-5.1.16-bin.jar
</code>```

then try to compile; it then shows the following message:

```<code>"Unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown"
</code>```

How should I solve that?

答:
java.lang.ClassNotFoundException is a checked exception. That means that you are required to deal with it, either by putting the call that may throw this exception inside a try { ... } catch (ClassNotFoundException e) { ... } block or by adding a throws clause to the method declaration of the method in which you make the call to the method that may throw this exception.

Read more about dealing with checked exceptions in The Catch or Specify Requirement in Oracle's Java Tutorials.

Title: Servlet Compiling error

Body:
I developed simple servlet using Apache Tomcat 6.

Firstly I write simple Hello World print servlet. Then set CLASSPATH for servlet-api.jar and compile and copy webapps/login/WEB-INF/classes/test/HelloServlet.class. That's working fine.

After I write simple JDBC connection in the servlet. I downloaded MySQL J-Connector and set CLASSPATH like this:

C:\Program Files\apache-tomcat-6.0.32\lib\servlet-api.jar;C:\Program Files\apache-tomcat-6.0.32\lib\mysql-connector-java-5.1.16-bin.jar

then try to compile; it then shows the following message:

"Unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown"

How should I solve that?


问:
Can pm2 run an 'npm start' script
Is there a way for pm2 to run an npm start script or do you just have to run pm2 start app.js

So in development

```<code>npm start
</code>```

Then in production with pm2 you would run something like

```<code>pm2 start 'npm start'
</code>```

There is an equivalent way to do this in forever:

```<code>forever start -c "npm start" ./
</code>```

答:
you need to provide app name here like myapp

```<code>pm2 start npm --name {appName} -- run {script name}
</code>```

you can check it by

```<code>pm2 list
</code>```

you can also add time

```<code>pm2 restart "id" --log-date-format 'DD-MM HH:mm:ss.SSS'
</code>```

or

```<code>pm2 restart "id" --time
</code>```

you can check logs by

```<code>pm2 log "id"
</code>```

or

```<code>pm2 log "appName"
</code>```

to get logs for all app

```<code>pm2 logs
</code>```

Title: Can pm2 run an 'npm start' script

Body:
Is there a way for pm2 to run an npm start script or do you just have to run pm2 start app.js

So in development

npm start

Then in production with pm2 you would run something like

pm2 start 'npm start'

There is an equivalent way to do this in forever:

forever start -c "npm start" ./

Body:
you need to provide app name here like myapp

pm2 start npm --name {appName} -- run {script name}

you can check it by

pm2 list

you can also add time

pm2 restart "id" --log-date-format 'DD-MM HH:mm:ss.SSS'

or

pm2 restart "id" --time

you can check logs by

pm2 log "id"

or

pm2 log "appName"

to get logs for all app

pm2 logs


问:
jest+supertest e2e testing of API endpoints that issue HTTP requests to other endpoints
I am e2e testing my API endpoints using jest and supertest. The api endpoints are implemented in express with typescript. The problem I am dealing with is that my app is setup as microservices where some of my endpoints issue HTTP requests to other endpoints. All of those microservices are mounted in the same app for the purpose of these tests.

So I am using

```<code>const res = await request(app)
      .get(endpoint)
      .set('Authorization', authorization);
    expect(res.status).toEqual(200);
</code>```

to fetch my endpoint. But this returns with statusCode 500 and the error Error: connect ECONNREFUSED 127.0.0.1:8999. The endpoint indeed issues an HTTP request to another endpoint on the same host. I guess supertest isn't actually starting the whole app, and therefore the other api endpoints aren't available? Is there a way to solve this? I don't want to mock the other endpoint, since this should be an end-to-end test. Unittests are available too, but right now I am writing e2e snapshot tests.

答: The problem was the port number, which is defined in config, but Supertest uses a random port number to run the app on. But you can also pass a running (listening) app to supertest's request so you can just use request(app.listen(portnum)).get(endpoint).

Body:
I am e2e testing my API endpoints using jest and supertest. The api endpoints are implemented in express with typescript. The problem I am dealing with is that my app is setup as microservices where some of my endpoints issue HTTP requests to other endpoints. All of those microservices are mounted in the same app for the purpose of these tests.

So I am using

const res = await request(app)
      .get(endpoint)
      .set('Authorization', authorization);
    expect(res.status).toEqual(200);

to fetch my endpoint. But this returns with statusCode 500 and the error Error: connect ECONNREFUSED 127.0.0.1:8999. The endpoint indeed issues an HTTP request to another endpoint on the same host. I guess supertest isn't actually starting the whole app, and therefore the other api endpoints aren't available? Is there a way to solve this? I don't want to mock the other endpoint, since this should be an end-to-end test. Unittests are available too, but right now I am writing e2e snapshot tests.


问:
powermail should update a `pages`-field
I want to use powermail (7.4.0) to give special page visitors the option to modify a field in the current pages record.

my setting so far:

```<code>plugin.tx_powermail.settings.setup {
    dbEntry {
        1 {
            _enable = TEXT
            _enable.value = 1

            _table = TEXT
            _table.value = pages

            uid = TEXT
            uid.data = TSFE:id

            description = TEXT
            description.field = abnahmestatus
        }
    }
    prefill {
        abnahmestatus = TEXT
        abnahmestatus.data = TSFE:description
    }
}
</code>```

How can I get powermail to update the record (instead of inserting)?

How can I prefill the input field with the current value from the pages field?

答:
Answer 1: update instead of insert:

I missed the line

```<code>_ifUnique.uid = update
</code>```

from the manual example.

Answer 2:

I inserted {abnahemstatus} which was not helpfull as it overwrote the typoscript prefill. so:

no value in prefill_value of the field definition

the correct definition is abnahmestatus.data = page:description (TSFE is obsolete)

Title: powermail should update a `pages`-field

Body:
I want to use powermail (7.4.0) to give special page visitors the option to modify a field in the current pages record.

my setting so far:

plugin.tx_powermail.settings.setup {
    dbEntry {
        1 {
            _enable = TEXT
            _enable.value = 1

            _table = TEXT
            _table.value = pages

            uid = TEXT
            uid.data = TSFE:id

            description = TEXT
            description.field = abnahmestatus
        }
    }
    prefill {
        abnahmestatus = TEXT
        abnahmestatus.data = TSFE:description
    }
}

How can I get powermail to update the record (instead of inserting)?

How can I prefill the input field with the current value from the pages field?

Body:
Answer 1: update instead of insert:

I missed the line

_ifUnique.uid = update

from the manual example.

Answer 2:

I inserted {abnahemstatus} which was not helpfull as it overwrote the typoscript prefill. so:

no value in prefill_value of the field definition

the correct definition is abnahmestatus.data = page:description (TSFE is obsolete)


问:
Best practice to record large amount of hits into MySQL database
Well, this is the thing. Let's say that my future PHP CMS need to drive 500k visitors daily and I need to record them all in MySQL database (referrer, ip address, time etc.). This way I need to insert 300-500 rows per minute and update 50 more. The main problem is that script would call database every time I want to insert new row, which is every time someone hits a page.

My question, is there any way to locally cache incoming hits first (and what is the best solution for that apc, csv...?) and periodically send them to database every 10 minutes for example? Is this good solution and what is the best practice for this situation?

答:
500k daily it's just 5-7 queries per second. If each request will be served for 0.2 sec, then you will have almost 0 simultaneous queries, so there is nothing to worry about.

Even if you will have 5 times more users - all should work fine.

You can just use INSERT DELAYED and tune your mysql.

About tuning: http://www.day32.com/MySQL/ - there is very useful script (will change nothing, just show you the tips how to optimize settings).

You can use memcache or APC to write log there first, but with using INSERT DELAYED MySQL will do almost same work, and will do it better :)

Do not use files for this. DB will serve locks much better, than PHP. It's not so trivial to write effective mutexes, so let DB (or memcache, APC) do this work.


问:
Spring beans are not initializing in Spring REST
My Spring beans are not getting initialized in Spring Java Config which I am using to create a sample Spring REST Application(As No Web.xml is required I have deleted it) . And also getting 404 while calling the REST endpoint /dest/types.

Can anyone please help. Project Structure

Pom.xml :

<project xmlns="http://maven.apache.org/POM/4.0.0"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-
    instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.travel</groupId>
    <artifactId>patcyyRestApp</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>patcyyRestApp Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <springframework.version>5.0.9.RELEASE</springframework.version>
        <jackson.library>2.9.6</jackson.library>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <hibernate.core.version>5.3.6.Final</hibernate.core.version>
        <javax.servlet.api.version>3.1.0</javax.servlet.api.version>
        <lombok.version>1.18.12</lombok.version>
        <apache.commons.version>3.9</apache.commons.version>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${javax.servlet.api.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.library}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.core.version}</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${apache.commons.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>patcyyRestApp</finalName>
    </build>
</project>
```

<p>Dispatch Initializer : </p>

<pre class="lang-java prettyprint-override"><code>package com.patcyy.rest.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class PatcyyDispatcherServletInitializer  extends
    AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        System.out.println("Inside getServletConfigClasses");
        return new Class[] { PatcyyConfig.class };
    }

    @Override
    protected String[] getServletMappings() {
        System.out.println("Inside mapping");

        return new String[] { "/patcyy" };
    }

}
</code>```

Config :

package com.patcyy.rest.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@EnableWebMvc
@ComponentScan("com.patcyy.rest")
public class PatcyyConfig {

}
```

<p>Controller : </p>

<pre class="lang-java prettyprint-override"><code>package com.patcyy.rest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.patcyy.rest.response.DestinationTypes;
import com.patcyy.rest.service.IDestinationService;

@RestController
@RequestMapping(path = "/dest", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces =
     MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DestinationController extends BaseController {

    private final IDestinationService iDestinationService;

    /**
     * @param iDestinationService
     */
    public DestinationController(@Autowired IDestinationService iDestinationService) {
        super();
        this.iDestinationService = iDestinationService;
    }

    @GetMapping("/types")
    public ResponseEntity<List<DestinationTypes>> getDestinationTypes() {
        List<DestinationTypes> destTypes = iDestinationService.getDestinationTypes();
        return new ResponseEntity<List<DestinationTypes>>(destTypes, HttpStatus.OK);
    }

}
</code>```

答:
Please share console log for further investigation. As per my understanding after seeing above code , you can replace

"/patcyy" with only "/"
  in getServletMappings() method.

your requested resource url will be like:

http://{hostname:port}/patcyyRestApp/dest/types

It's occurring due to invalid url servlet mapping.

Body:
My Spring beans are not getting initialized in Spring Java Config which I am using to create a sample Spring REST Application(As No Web.xml is required I have deleted it) . And also getting 404 while calling the REST endpoint /dest/types.

Can anyone please help. Project Structure

Pom.xml :

<project xmlns="http://maven.apache.org/POM/4.0.0"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-
    instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.travel</groupId>
    <artifactId>patcyyRestApp</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>patcyyRestApp Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <springframework.version>5.0.9.RELEASE</springframework.version>
        <jackson.library>2.9.6</jackson.library>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <hibernate.core.version>5.3.6.Final</hibernate.core.version>
        <javax.servlet.api.version>3.1.0</javax.servlet.api.version>
        <lombok.version>1.18.12</lombok.version>
        <apache.commons.version>3.9</apache.commons.version>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${javax.servlet.api.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.library}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.core.version}</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${apache.commons.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>patcyyRestApp</finalName>
    </build>
</project>

Dispatch Initializer :

package com.patcyy.rest.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class PatcyyDispatcherServletInitializer  extends
    AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        System.out.println("Inside getServletConfigClasses");
        return new Class[] { PatcyyConfig.class };
    }

    @Override
    protected String[] getServletMappings() {
        System.out.println("Inside mapping");

        return new String[] { "/patcyy" };
    }

}

Config :

package com.patcyy.rest.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@EnableWebMvc
@ComponentScan("com.patcyy.rest")
public class PatcyyConfig {

}

Controller :

package com.patcyy.rest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.patcyy.rest.response.DestinationTypes;
import com.patcyy.rest.service.IDestinationService;

@RestController
@RequestMapping(path = "/dest", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces =
     MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DestinationController extends BaseController {

    private final IDestinationService iDestinationService;

    /**
     * @param iDestinationService
     */
    public DestinationController(@Autowired IDestinationService iDestinationService) {
        super();
        this.iDestinationService = iDestinationService;
    }

    @GetMapping("/types")
    public ResponseEntity<List<DestinationTypes>> getDestinationTypes() {
        List<DestinationTypes> destTypes = iDestinationService.getDestinationTypes();
        return new ResponseEntity<List<DestinationTypes>>(destTypes, HttpStatus.OK);
    }

}


问:
Why (keydown.enter) and (keydown) dont work for list?
I have list of elements:

```<code><div class="List">
<div class=" SearchListItem" [ngClass]="{ active: i == activeIndexResultItem }"
          *ngFor="let item of searchShortResultItems; let i = index"
          (mouseenter)="mouseEnterItem($event, i)" (keydown.enter)="searchByEnter($event, item)"
          (click)="selectSearchResult(item)"> {{ item.text }}
        </div>
</div>
</code>```

Why (keydown.enter) does not work?

```<code>searchByEnter(e, item) {
   console.log(e); // no invoke
}
</code>```

Also I have tried to change to:

```<code>(keydown)="searchByEnter($event, item)"
</code>```

The same result

Also I havea set focus on: <divclass="List"#searchList>:

```<code> if (this.searchList) {
      setTimeout(() => this.searchList.nativeElement.focus(), 50);
}
</code>```

答:
Keyboard events are only dispatched on focused elements. You can add tabindex="0" to make your DIV focusable.

If your parent element is focused and you just keep track of current element from the list — add (keydown.enter) to parent element and pass your active item to that handler.

Body:
I have list of elements:

 {{ item.text }}

Why (keydown.enter) does not work?

searchByEnter(e, item) {
   console.log(e); // no invoke
}

Also I have tried to change to:

(keydown)="searchByEnter($event, item)"

The same result

Also I havea set focus on: <divclass="List"#searchList>:

 if (this.searchList) {
      setTimeout(() => this.searchList.nativeElement.focus(), 50);
}


问:
Gradle Sync Issue when I try to build and run code from a GitHub repository
What I want to do

I would like to execute a circle slider on Android app.

This is the reference of the circle slider which I would like to implement.

HoloCircleSeekBar

Problem

I have cloned the repository and tried to execute and see the code.

However, I can not build the files on my Android Studio.

Please give me advices to start emulator and see the function.

Error Message

Gradle Sync Issues:

```<code>ERROR: Could not find com.android.tools.build:gradle:2.2.0-alpha2.
Searched in the following locations:
   https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha2/gradle-2.2.0-alpha2.pom
   https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha2/gradle-2.2.0-alpha2.jar
Required by:
   :HoloCircleSeekBar-master:unspecified
Add Google Maven repository and sync project
Open File

</code>```

Development Environment

Android Studio 3.5.3

答: someone updated this code but owner has not accept it. https://github.com/JesusM/HoloCircleSeekBar/pull/21/commits/5429211edaeabc68704999cecfe22974d336b85a you can check this commit and update for yourself.</p>

Body:
What I want to do

I would like to execute a circle slider on Android app.

This is the reference of the circle slider which I would like to implement.

HoloCircleSeekBar

Problem

I have cloned the repository and tried to execute and see the code.

However, I can not build the files on my Android Studio.

Please give me advices to start emulator and see the function.

Error Message

Gradle Sync Issues:

ERROR: Could not find com.android.tools.build:gradle:2.2.0-alpha2.
Searched in the following locations:
   https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha2/gradle-2.2.0-alpha2.pom
   https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha2/gradle-2.2.0-alpha2.jar
Required by:
   :HoloCircleSeekBar-master:unspecified
Add Google Maven repository and sync project
Open File

Development Environment

Android Studio 3.5.3


问:
Makefile: pass variable from function to a make target
I have the following folder structure in my project:

```<code>my-app:
    apps:
        app1:
            file1
        app2:
            file2
    Makefile
</code>```

and want in my Makefile to loop through all the folders under apps and do some stuff while also providing the folder name to the command. However, I can't seem to be able to pass the folder name as a variable down to the make target.

This is what I have so far:

```<code>.PHONY: clean sandbox build

APPS=apps

define make_all
    for file in $(wildcard ${APPS}/*); do \
        make APP_NAME=$(file) $(1) || exit 1; \
    done
endef

clean:
    rm -rf node_modules
    $(call make_all,clean_one)

clean_one:
    rm -rf build
    echo ${APP_NAME}

</code>```

The output I get when doing make clean is the following:

```<code>rm -rf node_modules
for file in apps/app1 apps/app2; do make APP_NAME= clean_one || exit 1; done
make[1]: Entering directory 'my-app'
rm -rf build
echo

make[1]: Entering directory 'my-app'
</code>```

Is what I need to do somehow possible?

答:
In this case, file is a variable of for loop called from Makefile - not a Makefile's variable itself. This is why you have to escape $ by using $$.

```<code>VAR_LIST = aaa bbb ccc ddd

all: b a

a:
        for var in ${VAR_LIST} ; do echo ${var}; done

b:
        for var in ${VAR_LIST} ; do echo $${var}; done
</code>```

Target a will fail because there is no variable var inside Makefile.

Target b will work fine, because we will use ${var} that is defined inside for loop.

Body:
I have the following folder structure in my project:

my-app:
    apps:
        app1:
            file1
        app2:
            file2
    Makefile

and want in my Makefile to loop through all the folders under apps and do some stuff while also providing the folder name to the command. However, I can't seem to be able to pass the folder name as a variable down to the make target.

This is what I have so far:

.PHONY: clean sandbox build

APPS=apps

define make_all
    for file in $(wildcard ${APPS}/*); do \
        make APP_NAME=$(file) $(1) || exit 1; \
    done
endef

clean:
    rm -rf node_modules
    $(call make_all,clean_one)

clean_one:
    rm -rf build
    echo ${APP_NAME}

The output I get when doing make clean is the following:

rm -rf node_modules
for file in apps/app1 apps/app2; do make APP_NAME= clean_one || exit 1; done
make[1]: Entering directory 'my-app'
rm -rf build
echo

make[1]: Entering directory 'my-app'

Is what I need to do somehow possible?

Body:
In this case, file is a variable of for loop called from Makefile - not a Makefile's variable itself. This is why you have to escape $ by using $$.

VAR_LIST = aaa bbb ccc ddd

all: b a

a:
        for var in ${VAR_LIST} ; do echo ${var}; done

b:
        for var in ${VAR_LIST} ; do echo $${var}; done

Target a will fail because there is no variable var inside Makefile.

Target b will work fine, because we will use ${var} that is defined inside for loop.


问:
How to reload or refresh only child component in Angular 8
I have two components, One parent and Other Child.

HTML Part

```<code><div>
  <div class="row col-md-12">
    <div class="col-md-4">
       <!-- Some HTML Code of Parent component over here -->
    </div>
    <div class="col-md-8">
      <child-component></child-component>
    </div>
 </div>
 <button class="button" (click)="reloadOnlyChild($event)">Reload Child</button>
</div>
</code>```

Now, On click of this button, I want the only child to get reload, or refresh.

TS Part

```<code>reloadOnlyChild(event){
  // I want to reload the child from here.
}
</code>```

I searched on the Internet, I am getting for Vue or React, But not for Angular.

答:
We can also use *ngIf and setTimeout to reset the child component from parent without making any change in child component.

.template:

.ts:

```<code>show:boolean = true

resetChildForm(){
   this.show = false;

   setTimeout(() => {
      this.show = true
    }, 100);
}
</code>```

This is particularly helpful when we have no control over child component, like a 3rd party library component.

Body:
I have two components, One parent and Other Child.

HTML Part

      <child-component></child-component>

 <button class="button" (click)="reloadOnlyChild($event)">Reload Child</button>

Now, On click of this button, I want the only child to get reload, or refresh.

TS Part

reloadOnlyChild(event){
  // I want to reload the child from here.
}

I searched on the Internet, I am getting for Vue or React, But not for Angular.

Body:
We can also use *ngIf and setTimeout to reset the child component from parent without making any change in child component.

.template:

.ts:

show:boolean = true

resetChildForm(){
   this.show = false;

   setTimeout(() => {
      this.show = true
    }, 100);
}

This is particularly helpful when we have no control over child component, like a 3rd party library component.


问:
Error in summary.manova(model, test = "Pillai") : residuals have rank 1 < 2
I want to get mancova for two level group and I have two variables but after I enter data and variable I get an error and I don't know how to fix it.

library(jmv)
Data=read.csv(file.choose())
  Data
  attach(Data)
  names(Data)
y1 = mancova(
    data = Data,
    deps = vars(postTotalcorrecttrial, postmemoryspan),
    covs = vars(preTotalcorrecttrail, preMemoryspan),
    factors = group,
    multivar ="wilks")
```

<blockquote>
  <p>Error in summary.manova(model, test = "Pillai") :
    residuals have rank 1 < 2</p>
</blockquote>

```> Data4=read.csv(file.choose())
>   Data4
   group ` preTotalcorrecttrail` preMemoryspan `postTotalcorrecttrial `postmemoryspan
1      2                    7           4.5                    12            7.0
2      2                    5           3.5                     6            4.0
3      2                    4           3.0                     7            4.5
4      2                   10           6.0                     9            5.5
5      2                    4           3.0                     6            4.0
6      2                    5           3.5                     8            5.0
7      2                    8           5.0                     7            4.5
8      2                    5           3.5                     6            4.0
9      2                    5           3.5                     6            4.0
10     2                    3           2.5                     5            3.5
11     2                    7           4.5                     6            4.0
12     2                    4           3.0                     6            4.0
13     2                    3           2.5                     5            3.5
14     2                    4           3.0                     5            3.5
15     3                    4           3.0                     5            3.5
16     3                    3           2.5                     4            3.0
17     3                    5           3.5                     6            4.0
18     3                    8           5.0                     8            5.0
19     3                    9           5.5                     7            4.5
20     3                    5           3.5                     4            3.0
21     3                    6           4.0                     5            3.5
22     3                    4           3.0                     5            3.5
23     3                    4           3.0                     4            3.0
24     3                    6           4.0                     6            4.0
25     3                    3           2.5                     5            3.5
26     3                    4           3.0                     5            3.5
27     3                    4           3.0                     5            3.5
```

答:
You get that error because your variables are perfectly correlated.

Your data which I got from the example:

```<code>structure(list(group = structure(c(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), .Label = c("2", "3"), class = "factor"), preTotalcorrecttrail = c(7L,
5L, 4L, 10L, 4L, 5L, 8L, 5L, 5L, 3L, 7L, 4L, 3L, 4L, 4L, 3L,
5L, 8L, 9L, 5L, 6L, 4L, 4L, 6L, 3L, 4L, 4L), preMemoryspan = c(4.5,
3.5, 3, 6, 3, 3.5, 5, 3.5, 3.5, 2.5, 4.5, 3, 2.5, 3, 3, 2.5,
3.5, 5, 5.5, 3.5, 4, 3, 3, 4, 2.5, 3, 3), postTotalcorrecttrial = c(12L,
6L, 7L, 9L, 6L, 8L, 7L, 6L, 6L, 5L, 6L, 6L, 5L, 5L, 5L, 4L, 6L,
8L, 7L, 4L, 5L, 5L, 4L, 6L, 5L, 5L, 5L), postmemoryspan = c(7,
4, 4.5, 5.5, 4, 5, 4.5, 4, 4, 3.5, 4, 4, 3.5, 3.5, 3.5, 3, 4,
5, 4.5, 3, 3.5, 3.5, 3, 4, 3.5, 3.5, 3.5)), row.names = c(NA,
-27L), class = "data.frame")
</code>```

We check the correlation:

```<code>cor(Data[,-1])
                      preTotalcorrecttrail preMemoryspan
preTotalcorrecttrail             1.0000000     1.0000000
preMemoryspan                    1.0000000     1.0000000
postTotalcorrecttrial            0.6469337     0.6469337
postmemoryspan                   0.6469337     0.6469337
                      postTotalcorrecttrial postmemoryspan
preTotalcorrecttrail              0.6469337      0.6469337
preMemoryspan                     0.6469337      0.6469337
postTotalcorrecttrial             1.0000000      1.0000000
postmemoryspan                    1.0000000      1.0000000
</code>```

From what I can see, postmemoryspan = 1 + 0.5*postTotalcorrecttrial . There's no point in doing a mancova. You just do a linear regression.

Body:
I want to get mancova for two level group and I have two variables but after I enter data and variable I get an error and I don't know how to fix it.

library(jmv)
Data=read.csv(file.choose())
  Data
  attach(Data)
  names(Data)
y1 = mancova(
    data = Data,
    deps = vars(postTotalcorrecttrial, postmemoryspan),
    covs = vars(preTotalcorrecttrail, preMemoryspan),
    factors = group,
    multivar ="wilks")

Error in summary.manova(model, test = "Pillai") :
    residuals have rank 1 < 2

> Data4=read.csv(file.choose())
>   Data4
   group ` preTotalcorrecttrail` preMemoryspan `postTotalcorrecttrial `postmemoryspan
1      2                    7           4.5                    12            7.0
2      2                    5           3.5                     6            4.0
3      2                    4           3.0                     7            4.5
4      2                   10           6.0                     9            5.5
5      2                    4           3.0                     6            4.0
6      2                    5           3.5                     8            5.0
7      2                    8           5.0                     7            4.5
8      2                    5           3.5                     6            4.0
9      2                    5           3.5                     6            4.0
10     2                    3           2.5                     5            3.5
11     2                    7           4.5                     6            4.0
12     2                    4           3.0                     6            4.0
13     2                    3           2.5                     5            3.5
14     2                    4           3.0                     5            3.5
15     3                    4           3.0                     5            3.5
16     3                    3           2.5                     4            3.0
17     3                    5           3.5                     6            4.0
18     3                    8           5.0                     8            5.0
19     3                    9           5.5                     7            4.5
20     3                    5           3.5                     4            3.0
21     3                    6           4.0                     5            3.5
22     3                    4           3.0                     5            3.5
23     3                    4           3.0                     4            3.0
24     3                    6           4.0                     6            4.0
25     3                    3           2.5                     5            3.5
26     3                    4           3.0                     5            3.5
27     3                    4           3.0                     5            3.5

Body:
You get that error because your variables are perfectly correlated.

Your data which I got from the example:

structure(list(group = structure(c(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), .Label = c("2", "3"), class = "factor"), preTotalcorrecttrail = c(7L,
5L, 4L, 10L, 4L, 5L, 8L, 5L, 5L, 3L, 7L, 4L, 3L, 4L, 4L, 3L,
5L, 8L, 9L, 5L, 6L, 4L, 4L, 6L, 3L, 4L, 4L), preMemoryspan = c(4.5,
3.5, 3, 6, 3, 3.5, 5, 3.5, 3.5, 2.5, 4.5, 3, 2.5, 3, 3, 2.5,
3.5, 5, 5.5, 3.5, 4, 3, 3, 4, 2.5, 3, 3), postTotalcorrecttrial = c(12L,
6L, 7L, 9L, 6L, 8L, 7L, 6L, 6L, 5L, 6L, 6L, 5L, 5L, 5L, 4L, 6L,
8L, 7L, 4L, 5L, 5L, 4L, 6L, 5L, 5L, 5L), postmemoryspan = c(7,
4, 4.5, 5.5, 4, 5, 4.5, 4, 4, 3.5, 4, 4, 3.5, 3.5, 3.5, 3, 4,
5, 4.5, 3, 3.5, 3.5, 3, 4, 3.5, 3.5, 3.5)), row.names = c(NA,
-27L), class = "data.frame")

We check the correlation:

cor(Data[,-1])
                      preTotalcorrecttrail preMemoryspan
preTotalcorrecttrail             1.0000000     1.0000000
preMemoryspan                    1.0000000     1.0000000
postTotalcorrecttrial            0.6469337     0.6469337
postmemoryspan                   0.6469337     0.6469337
                      postTotalcorrecttrial postmemoryspan
preTotalcorrecttrail              0.6469337      0.6469337
preMemoryspan                     0.6469337      0.6469337
postTotalcorrecttrial             1.0000000      1.0000000
postmemoryspan                    1.0000000      1.0000000

From what I can see, postmemoryspan = 1 + 0.5*postTotalcorrecttrial . There's no point in doing a mancova. You just do a linear regression.


答:
You can convert column time to datetimes by to_datetime with unit parameter and for custom format use Series.dt.strftime:

```<code>df = pd.DataFrame(a)
d = pd.to_datetime(df['time'], unit='s')
df['time'] = d.dt.strftime('%Y-%m-%d')
g = d.dt.strftime('%Y-%m')

d1 = {k: v.to_dict('r') for k, v in df.groupby(g)}
</code>```

Title: pandas group by day or week or month for timestamp

Body:
I'm a pandas beginner.

I have the following data:

a = [{"content": '1', "time": 1577870427},
     {"content": '4', "time": 1577870427},
     {"content": '2', "time": 1577956827},
     {"content": '3', "time": 1580548827},
     {"content": '4', "time": 1580635227},
     {"content": '5', "time": 1583054427},
     {"content": '6', "time": 1583140827}]

And I want:

2020-01: [
     {"content": '1', "time": '2020-01-01'},
     {"content": '4', "time": '2020-01-01'},
     {"content": '2', "time": '2020-01-02'},
    ]

    2020-02: [
     {"content": '3', "time": '2020-02-01'},
     {"content": '4', "time": '2020-02-02'},
    ]

    2020-03: [
     {"content": '5', "time": '2020-03-01'},
     {"content": '6', "time": '2020-03-02'}
    ]

Body:
You can convert column time to datetimes by to_datetime with unit parameter and for custom format use Series.dt.strftime:

df = pd.DataFrame(a)
d = pd.to_datetime(df['time'], unit='s')
df['time'] = d.dt.strftime('%Y-%m-%d')
g = d.dt.strftime('%Y-%m')

d1 = {k: v.to_dict('r') for k, v in df.groupby(g)}


问:
How to make the link inside Button change color on hover without hovering over link
My link changes color on hovering over it directly but does not change color when I hover over the button and not the link directly

```<code>btn:hover{
color: black;
}
</code>```

This does not work.

```<code>a:hover{
color:black
}
</code>```

This is working currently but does not do the job as needed.

How do I make the button change the color of the link when I hover over it?
As seen in the first image.

答:
just try this

a{
text-decoration:none;
color:white;
}
.btn{
background-color:black;}
.btn:hover {background: gray;}
.btn:hover > a {color:black}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><button class="btn">Home</button></code>```

Body:
My link changes color on hovering over it directly but does not change color when I hover over the button and not the link directly

btn:hover{
color: black;
}

This does not work.

a:hover{
color:black
}

This is working currently but does not do the job as needed.

How do I make the button change the color of the link when I hover over it?
As seen in the first image.

Body:
just try this

a{
text-decoration:none;
color:white;
}
.btn{
background-color:black;}
.btn:hover {background: gray;}
.btn:hover > a {color:black}

<button class="btn"><a href="#">Home</a></button>


问:
Is it possible to load new Javascript files with AJAX?
I'm building a new AJAX powered website with distinct sections.  Each section requires a new set of Javascript functions to run.  I'd rather not load every script at the start, as there might be quite a few.

Is there a way to load new scripts using AJAX and remove old ones (so as to make sure there are no compatibility issues with similar variable names or function signatures).

Thanks

Edit - JQuery is fine, it doesn't have to be old school Javascript

答: Script elements are also a part of the DOM tree, you can attach and remove as you like.</p>


问:
Angular 8: unable to send Authorization with service
I want to send the following "Authorization" through service.

```<code>Authorization :: Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==
</code>```

In the service I wrote the following code:

```<code>constructor(
        private http: HttpClient
    ) {
        this.header_auth = {
          headers: new HttpHeaders()
            .set('Authorization',  "Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==")
        }
    }

getToken() {
        return this.http.post(this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXXXX&username=XX@XXX.com&grant_type=password", this.header_auth);
    }
</code>```

I also used this code:
 public basic: any = 'Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==';

```<code>getToken() {

        const request = {
             headers: {
               'Authorization': this.basic,
             }
        };

        return this.http.post<any>(
            this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXXXX&username=XX@XXX.com&grant_type=password",
            { headers: request.headers }
        );
}
</code>```

When I called the service in my component, it shows me "error: "Unauthorized" But the same API URL is working well in "Postman".

xxx.component.ts:

```<code>this.commService.getToken().subscribe((data: any) => {
  console.log(data);
});
</code>```

In console I see the following error:

POST http://10.X.X.XXX:8089/XXXX/oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXX&username=XX@XXX.com&grant_type=password 401

See postman screen:

答:
This is the correct way to pass it: </p>

```<code>const httpOptions = {
      headers: new HttpHeaders({ 'Authorization': 'Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==' })
    };

return this.httpClient.post(this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXXXX&username=XX@XXX.com&grant_type=password", httpOptions)
</code>```

Body:
I want to send the following "Authorization" through service.

Authorization :: Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==

In the service I wrote the following code:

constructor(
        private http: HttpClient
    ) {
        this.header_auth = {
          headers: new HttpHeaders()
            .set('Authorization',  "Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==")
        }
    }

getToken() {
        return this.http.post(this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXXXX&username=XX@XXX.com&grant_type=password", this.header_auth);
    }

I also used this code:
 public basic: any = 'Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==';

getToken() {

        const request = {
             headers: {
               'Authorization': this.basic,
             }
        };

        return this.http.post<any>(
            this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXXXX&username=XX@XXX.com&grant_type=password",
            { headers: request.headers }
        );
}

When I called the service in my component, it shows me "error: "Unauthorized" But the same API URL is working well in "Postman".

xxx.component.ts:

this.commService.getToken().subscribe((data: any) => {
  console.log(data);
});

In console I see the following error:

POST http://10.X.X.XXX:8089/XXXX/oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXX&username=XX@XXX.com&grant_type=password 401

See postman screen:

Body:
This is the correct way to pass it:

const httpOptions = {
      headers: new HttpHeaders({ 'Authorization': 'Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==' })
    };

return this.httpClient.post(this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=XXXXX&username=XX@XXX.com&grant_type=password", httpOptions)


问:
Scroll NAV bar left to right one by one not all at once width issue
The problem is that I am unable to find the correct width to scroll left or right. Because of it I the nav tabs not correctly scroll one by one.
Each time I hit the scroll right button it added more than the required width. nav bars are not correctly scrolled one by one because of this.

Thanks in advance.

var scrollBarWidths = 40;
var widthOfList = function(){
  var itemsWidth = 0;
  $('.list a').each(function(){
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
  });
  return itemsWidth;
};
var innerwidth = 0;
var widthofEachNav = function(){
var itemsWidth = 0;
var count = 0;
  $('.list a').each(function(){
    innerwidth = $(this).innerWidth();
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
 count++
  });
  console.log(itemsWidth+"  "+count+"     width"+(itemsWidth/count ))
  return (itemsWidth/count);
}
var widthNav = widthofEachNav();
var getLeftPosi = function(){
  return $('.list').position().left;
};
var widthOfHidden = function(){
  return (($('.wrapper').outerWidth())-widthOfList()-getLeftPosi());
};
var hidvith = widthOfHidden();

$('.scroller-right').click(function() {
  $('.scroller-left').fadeIn('slow');
if(widthOfHidden()<0 && getLeftPosi()<=0){
 $('.list').animate({left:"-="+widthNav+"px"},'slow',function(){  });
}

});

$('.scroller-left').click(function() {
 $('.scroller-right').fadeIn('slow');
  if(getLeftPosi()<0 ){
 $('.list').animate({left:"+="+widthNav+"px"},'slow',function(){   });
  }

});
$(window).on('resize',function(e){
   reAdjust();
});
var reAdjust = function(){
  if (($('.wrapper').outerWidth()) < widthOfList()) {
    $('.scroller-right').show().css('display', 'flex');
  }
  else {
    $('.scroller-right').hide();
  }

  if (getLeftPosi()<0) {
    $('.scroller-left').show().css('display', 'flex');
  }
  else {
    $('.item').animate({left:"-="+getLeftPosi()+"px"},'slow');
   $('.scroller-left').hide();

  }

  $('.scroller-right').show();
}

reAdjust();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.closeBtn:focus {
  outline: none;
}
.w-100.p-3 {
    max-width: 50%;
}

    .close{
        color: gray;
      }

.wrapper {
    position:relative;
    margin:0 auto;
    overflow:hidden;
 padding:5px;
   height:50px;
}

.list {
    position:absolute;
    left:0px;
    top:0px;
   min-width:3500px;

    margin-top:0px;
}

.list li{
 display:table-cell;
    position:relative;
    text-align:center;
    cursor:grab;
    cursor:-webkit-grab;
    color:#efefef;
    vertical-align:middle;
}

.scroller {
  text-align:center;
  cursor:pointer;
  display:none;
  padding:7px;
  padding-top:11px;
  white-space:no-wrap;
  vertical-align:middle;
  background-color:#fff;
}

.scroller-right{
  float:right;
}

.scroller-left {
  float:left;
}
.xyzzz {
    max-width: 27% !important;
    min-width: 20% !important;
}</code>```

<link rel="stylesheet" href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

<

>

  Tab1
  Tab 2
    Tab 3
      Tab 4
        Tab 5
          Tab 6
           Tab 7
            Tab 8
             Tab 9
              Tab 10
               Tab 11
               Tab 12
               Tab 13
               Tab 14
               Tab 15
               Tab 16

           Tab 1

Tab 2

Tab 3

Tab 4

Tab 5

Tab 6

Tab 7

Tab 8

Tab 9

Tab 10

Tab 11

Tab 12

Tab 13

Tab 14

Tab 15

Tab 16

```

答:
Please refer below code. I have overridden few existing classes in css. Which you can see at the bottom of CSS.

var scrollBarWidths = 40;
var widthOfList = function(){
  var itemsWidth = 0;
  $('.list a').each(function(){
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
  });
  return itemsWidth;
};
var innerwidth = 0;
var widthofEachNav = function(){
var itemsWidth = 0;
var count = 0;
  $('.list a').each(function(){
    innerwidth = $(this).innerWidth();
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
 count++
  });
  console.log(itemsWidth+"  "+count+"     width"+(itemsWidth/count ))
  return (itemsWidth/count);
}
var widthNav = widthofEachNav();
var getLeftPosi = function(){
  return $('.list').position().left;
};
var widthOfHidden = function(){
  return (($('.wrapper').outerWidth())-widthOfList()-getLeftPosi());
};
var hidvith = widthOfHidden();

$('.scroller-right').click(function() {
  $('.scroller-left').fadeIn('slow');
if(widthOfHidden()<0 && getLeftPosi()<=0){
 $('.list').animate({left:"-="+widthNav+"px"},'slow',function(){  });
}

});

$('.scroller-left').click(function() {
 $('.scroller-right').fadeIn('slow');
  if(getLeftPosi()<0 ){
 $('.list').animate({left:"+="+widthNav+"px"},'slow',function(){   });
  }

});
$(window).on('resize',function(e){
   reAdjust();
});
var reAdjust = function(){
  if (($('.wrapper').outerWidth()) < widthOfList()) {
    $('.scroller-right').show().css('display', 'flex');
  }
  else {
    $('.scroller-right').hide();
  }

  if (getLeftPosi()<0) {
    $('.scroller-left').show().css('display', 'flex');
  }
  else {
    $('.item').animate({left:"-="+getLeftPosi()+"px"},'slow');
   $('.scroller-left').hide();

  }

  $('.scroller-right').show();
}

reAdjust();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.closeBtn:focus {
  outline: none;
}
.w-100.p-3 {
    max-width: 50%;
}

    .close{
        color: gray;
      }

.wrapper {
    position:relative;
    margin:0 auto;
    overflow:hidden;
 padding:5px;
   height:50px;
}

.list {
    position:absolute;
    left:0px;
    top:0px;
   min-width:3500px;

    margin-top:0px;
}

.list li{
 display:table-cell;
    position:relative;
    text-align:center;
    cursor:grab;
    cursor:-webkit-grab;
    color:#efefef;
    vertical-align:middle;
}

.scroller {
  text-align:center;
  cursor:pointer;
  display:none;
  padding:7px;
  padding-top:11px;
  white-space:no-wrap;
  vertical-align:middle;
  background-color:#fff;
}

.scroller-right{
  float:right;
}

.scroller-left {
  float:left;
}
.xyzzz {
    max-width: 27% !important;
    min-width: 20% !important;
}

.w-100.p-3 {
    max-width: 55% !important;
}
nav#myTab {
    margin-left: -5px !important;
}

.scroller.scroller-right.mt-2 {
    margin-right: -30px !important;
}</code>```

<link rel="stylesheet" href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

<

>

  Tab 1
  Tab 2
    Tab 3
      Tab 4
        Tab 5
          Tab 6
           Tab 7
            Tab 8
             Tab 9
              Tab 10
               Tab 11
               Tab 12
               Tab 13
               Tab 14
               Tab 15
               Tab 16

           Tab 1

Tab 2

Tab 3

Tab 4

Tab 5

Tab 6

Tab 7

Tab 8

Tab 9

Tab 10

Tab 11

Tab 12

Tab 13

Tab 14

Tab 15

Tab 16

```

Body:
The problem is that I am unable to find the correct width to scroll left or right. Because of it I the nav tabs not correctly scroll one by one.
Each time I hit the scroll right button it added more than the required width. nav bars are not correctly scrolled one by one because of this.

Thanks in advance.

var scrollBarWidths = 40;
var widthOfList = function(){
  var itemsWidth = 0;
  $('.list a').each(function(){
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
  });
  return itemsWidth;
};
var innerwidth = 0;
var widthofEachNav = function(){
var itemsWidth = 0;
var count = 0;
  $('.list a').each(function(){
    innerwidth = $(this).innerWidth();
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
 count++
  });
  console.log(itemsWidth+"  "+count+"     width"+(itemsWidth/count ))
  return (itemsWidth/count);
}
var widthNav = widthofEachNav();
var getLeftPosi = function(){
  return $('.list').position().left;
};
var widthOfHidden = function(){
  return (($('.wrapper').outerWidth())-widthOfList()-getLeftPosi());
};
var hidvith = widthOfHidden();

$('.scroller-right').click(function() {
  $('.scroller-left').fadeIn('slow');
if(widthOfHidden()<0 && getLeftPosi()<=0){
 $('.list').animate({left:"-="+widthNav+"px"},'slow',function(){  });
}

});

$('.scroller-left').click(function() {
 $('.scroller-right').fadeIn('slow');
  if(getLeftPosi()<0 ){
 $('.list').animate({left:"+="+widthNav+"px"},'slow',function(){   });
  }

});
$(window).on('resize',function(e){
   reAdjust();
});
var reAdjust = function(){
  if (($('.wrapper').outerWidth()) < widthOfList()) {
    $('.scroller-right').show().css('display', 'flex');
  }
  else {
    $('.scroller-right').hide();
  }

  if (getLeftPosi()<0) {
    $('.scroller-left').show().css('display', 'flex');
  }
  else {
    $('.item').animate({left:"-="+getLeftPosi()+"px"},'slow');
   $('.scroller-left').hide();

  }

  $('.scroller-right').show();
}

reAdjust();

.closeBtn:focus {
  outline: none;
}
.w-100.p-3 {
    max-width: 50%;
}

    .close{
        color: gray;
      }

.wrapper {
    position:relative;
    margin:0 auto;
    overflow:hidden;
 padding:5px;
   height:50px;
}

.list {
    position:absolute;
    left:0px;
    top:0px;
   min-width:3500px;

    margin-top:0px;
}

.list li{
 display:table-cell;
    position:relative;
    text-align:center;
    cursor:grab;
    cursor:-webkit-grab;
    color:#efefef;
    vertical-align:middle;
}

.scroller {
  text-align:center;
  cursor:pointer;
  display:none;
  padding:7px;
  padding-top:11px;
  white-space:no-wrap;
  vertical-align:middle;
  background-color:#fff;
}

.scroller-right{
  float:right;
}

.scroller-left {
  float:left;
}
.xyzzz {
    max-width: 27% !important;
    min-width: 20% !important;
}

<link rel="stylesheet" href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

<

>

  Tab1
  Tab 2
    Tab 3
      Tab 4
        Tab 5
          Tab 6
           Tab 7
            Tab 8
             Tab 9
              Tab 10
               Tab 11
               Tab 12
               Tab 13
               Tab 14
               Tab 15
               Tab 16

           Tab 1

Tab 2

Tab 3

Tab 4

Tab 5

Tab 6

Tab 7

Tab 8

Tab 9

Tab 10

Tab 11

Tab 12

Tab 13

Tab 14

Tab 15

Tab 16

Body:
Please refer below code. I have overridden few existing classes in css. Which you can see at the bottom of CSS.

var scrollBarWidths = 40;
var widthOfList = function(){
  var itemsWidth = 0;
  $('.list a').each(function(){
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
  });
  return itemsWidth;
};
var innerwidth = 0;
var widthofEachNav = function(){
var itemsWidth = 0;
var count = 0;
  $('.list a').each(function(){
    innerwidth = $(this).innerWidth();
    var itemWidth = $(this).outerWidth();
    itemsWidth+=itemWidth;
 count++
  });
  console.log(itemsWidth+"  "+count+"     width"+(itemsWidth/count ))
  return (itemsWidth/count);
}
var widthNav = widthofEachNav();
var getLeftPosi = function(){
  return $('.list').position().left;
};
var widthOfHidden = function(){
  return (($('.wrapper').outerWidth())-widthOfList()-getLeftPosi());
};
var hidvith = widthOfHidden();

$('.scroller-right').click(function() {
  $('.scroller-left').fadeIn('slow');
if(widthOfHidden()<0 && getLeftPosi()<=0){
 $('.list').animate({left:"-="+widthNav+"px"},'slow',function(){  });
}

});

$('.scroller-left').click(function() {
 $('.scroller-right').fadeIn('slow');
  if(getLeftPosi()<0 ){
 $('.list').animate({left:"+="+widthNav+"px"},'slow',function(){   });
  }

});
$(window).on('resize',function(e){
   reAdjust();
});
var reAdjust = function(){
  if (($('.wrapper').outerWidth()) < widthOfList()) {
    $('.scroller-right').show().css('display', 'flex');
  }
  else {
    $('.scroller-right').hide();
  }

  if (getLeftPosi()<0) {
    $('.scroller-left').show().css('display', 'flex');
  }
  else {
    $('.item').animate({left:"-="+getLeftPosi()+"px"},'slow');
   $('.scroller-left').hide();

  }

  $('.scroller-right').show();
}

reAdjust();

.closeBtn:focus {
  outline: none;
}
.w-100.p-3 {
    max-width: 50%;
}

    .close{
        color: gray;
      }

.wrapper {
    position:relative;
    margin:0 auto;
    overflow:hidden;
 padding:5px;
   height:50px;
}

.list {
    position:absolute;
    left:0px;
    top:0px;
   min-width:3500px;

    margin-top:0px;
}

.list li{
 display:table-cell;
    position:relative;
    text-align:center;
    cursor:grab;
    cursor:-webkit-grab;
    color:#efefef;
    vertical-align:middle;
}

.scroller {
  text-align:center;
  cursor:pointer;
  display:none;
  padding:7px;
  padding-top:11px;
  white-space:no-wrap;
  vertical-align:middle;
  background-color:#fff;
}

.scroller-right{
  float:right;
}

.scroller-left {
  float:left;
}
.xyzzz {
    max-width: 27% !important;
    min-width: 20% !important;
}

.w-100.p-3 {
    max-width: 55% !important;
}
nav#myTab {
    margin-left: -5px !important;
}

.scroller.scroller-right.mt-2 {
    margin-right: -30px !important;
}

<script src="http://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<!-- <script src="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"></script> -->
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<div class="w-100 p-3">

  <div class="scroller scroller-left mt-2"><i class="fa fa-chevron-left"><</i></div>
  <div class="scroller scroller-right mt-2"><i class="fa fa-chevron-right"></i>></div>
  <div class="wrapper">
   <nav class="nav nav-tabs list mt-2" id="myTab" role="tablist">
  <a class="nav-item nav-link active" data-toggle="tab" href="#tab1" style="margin-left: 21px" role="tab" aria-controls="public" aria-expanded="true">Tab 1</a>
  <a class="nav-item nav-link" href="#tab2" role="tab" data-toggle="tab">Tab 2</a>
    <a class="nav-item nav-link" href="#tab3" role="tab" data-toggle="tab">Tab 3</a>
      <a class="nav-item nav-link" href="#tab4" role="tab" data-toggle="tab">Tab 4</a>
        <a class="nav-item nav-link" href="#tab5" role="tab" data-toggle="tab" style="margin-left: 7px;">Tab 5</a>
          <a class="nav-item nav-link" href="#tab6" role="tab" data-toggle="tab">Tab 6</a>
           <a class="nav-item nav-link" href="#tab7" role="tab" data-toggle="tab">Tab 7</a>
            <a class="nav-item nav-link" href="#tab8" role="tab" data-toggle="tab">Tab 8</a>
             <a class="nav-item nav-link" href="#tab9" role="tab" data-toggle="tab">Tab 9</a>
              <a class="nav-item nav-link" href="#tab10" role="tab" data-toggle="tab">Tab 10</a>
               <a class="nav-item nav-link" href="#tab11" role="tab" data-toggle="tab">Tab 11</a>
               <a class="nav-item nav-link" href="#tab12" role="tab" data-toggle="tab">Tab 12</a>
               <a class="nav-item nav-link" href="#tab13" role="tab" data-toggle="tab">Tab 13</a>
               <a class="nav-item nav-link" href="#tab14" role="tab" data-toggle="tab">Tab 14</a>
               <a class="nav-item nav-link" href="#tab15" role="tab" data-toggle="tab">Tab 15</a>
               <a class="nav-item nav-link" href="#tab16" role="tab" data-toggle="tab" style="margin-left: -6px;">Tab 16</a>

</nav>
  </div>
    <div class="tab-content" id="myTabContent">
        <div role="tabpanel" class="tab-pane fade active show mt-2" id="tab1" aria-labelledby="public-tab" aria-expanded="true">
           Tab 1
        </div>
        <div class="tab-pane fade mt-2" id="tab2" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 2</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab3" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 3</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab4" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 4</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab5" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 5</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab6" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 6</p>
        </div>
         <div class="tab-pane fade mt-2" id="tab7" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 7</p>
        </div>
         <div class="tab-pane fade mt-2" id="tab8" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 8</p>
        </div>
         <div class="tab-pane fade mt-2" id="tab9" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 9</p>
        </div>
         <div class="tab-pane fade mt-2" id="tab10" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 10</p>
        </div>
         <div class="tab-pane fade mt-2" id="tab11" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 11</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab12" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 12</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab13" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 13</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab14" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 14</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab15" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 15</p>
        </div>
        <div class="tab-pane fade mt-2" id="tab16" role="tabpanel" aria-labelledby="group-dropdown2-tab" aria-expanded="false">
            <p class="">Tab 16</p>
        </div>

    </div>
</div>


问:
Python : datetime.strptime error when I used wx
I found a curious bug.
When I used the library wx, my function strptime, which comes of datetime library, doesn't work.

Example :

```<code>from datetime import datetime
myDate2= datetime.strptime('Wed Feb 19 14:57:58 2020', '%a %b %d %H:%M:%S %Y')
</code>```

When I execute the previous code and wx.app() I have the following error:

```<code>myDate2= datetime.strptime('Wed Feb 19 14:57:58 2020', '%a %b %d %H:%M:%S %Y')
Traceback (most recent call last):

File "<ipython-input-108-b41842200da1>", line 1, in <module>
myDate2= datetime.strptime('Wed Feb 19 14:57:58 2020', '%a %b %d %H:%M:%S %Y')

File "C:\Simu\WinPython_3741\python-3.7.4.amd64\Lib\_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)

File "C:\Simu\WinPython_3741\python-3.7.4.amd64\Lib\_strptime.py", line 359, in _strptime
(data_string, format))

ValueError: time data 'Wed Feb 19 14:57:58 2020' does not match format '%a %b %d %H:%M:%S %Y'
</code>```

What is the link between the datetime and wx ?
And how to fix this bug ?

答:
Resolved !

This bug comes from localtime. I don't know why but when I execute wx.app(), my localtime change.

I discovered this thanks to the following command :

from time import strftime,localtime
 print(strftime("%H:%M, %d %B %Y",localtime()))
 10:44, 20 février 2020

To change the localtime, here is the code :

```<code>import locale
locale.setlocale(locale.LC_ALL, 'en_US')
</code>```

Body:
I found a curious bug.
When I used the library wx, my function strptime, which comes of datetime library, doesn't work.

Example :

from datetime import datetime
myDate2= datetime.strptime('Wed Feb 19 14:57:58 2020', '%a %b %d %H:%M:%S %Y')

When I execute the previous code and wx.app() I have the following error:

myDate2= datetime.strptime('Wed Feb 19 14:57:58 2020', '%a %b %d %H:%M:%S %Y')
Traceback (most recent call last):

File "<ipython-input-108-b41842200da1>", line 1, in <module>
myDate2= datetime.strptime('Wed Feb 19 14:57:58 2020', '%a %b %d %H:%M:%S %Y')

File "C:\Simu\WinPython_3741\python-3.7.4.amd64\Lib\_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)

File "C:\Simu\WinPython_3741\python-3.7.4.amd64\Lib\_strptime.py", line 359, in _strptime
(data_string, format))

ValueError: time data 'Wed Feb 19 14:57:58 2020' does not match format '%a %b %d %H:%M:%S %Y'

What is the link between the datetime and wx ?
And how to fix this bug ?

Body:
Resolved !

This bug comes from localtime. I don't know why but when I execute wx.app(), my localtime change.

I discovered this thanks to the following command :

from time import strftime,localtime
 print(strftime("%H:%M, %d %B %Y",localtime()))
 10:44, 20 février 2020

To change the localtime, here is the code :

import locale
locale.setlocale(locale.LC_ALL, 'en_US')


问:
After partitioning a table, how can we see data in each partition
```<code>ALTER TABLE  Laptop
PARTITION BY LIST(Id) ( PARTITION pNorth VALUES IN (0,1),
                        PARTITION pEast VALUES IN (2,3),
                        PARTITION pWest VALUES IN (4,5),
                        PARTITION pCentral VALUES IN (6,7) );
</code>```

schema-Electronics table-Laptop

Tried this

```<code>SELECT *
FROM information_schema.partitions
WHERE TABLE_SCHEMA='Electronics'
  AND TABLE_NAME = 'Laptop'
  AND PARTITION_NAME IS NOT NULL
</code>```

but this gives information about the partitions, but i want to check the data inside each partition.  Is it possible or not if yes please tell me how can i find

答:
"we can get the data from each partition using that partition name"

SELECT * FROM table_name PARTITION (your partition name);

Body:
ALTER TABLE  Laptop
PARTITION BY LIST(Id) ( PARTITION pNorth VALUES IN (0,1),
                        PARTITION pEast VALUES IN (2,3),
                        PARTITION pWest VALUES IN (4,5),
                        PARTITION pCentral VALUES IN (6,7) );

schema-Electronics table-Laptop

Tried this

SELECT *
FROM information_schema.partitions
WHERE TABLE_SCHEMA='Electronics'
  AND TABLE_NAME = 'Laptop'
  AND PARTITION_NAME IS NOT NULL

but this gives information about the partitions, but i want to check the data inside each partition.  Is it possible or not if yes please tell me how can i find


问:
Having trouble installing PyQt5 using conda on Mac OS
I think its telling me it wants to use Python 3.7 but the message is confusing so I made 3.7 the default for the terminal shell, but I still get the following:</p>

```<code>dzimmerman@QA-Bonjour-OSX ~ % python --version
Python 3.7.2
dzimmerman@QA-Bonjour-OSX ~ % conda install -c dsdale24 pyqt5
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - pyqt5 -> python=2.7

Your python: python=3.7

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
</code>```

答:
The pyqt5 package in the channel you are trying to use is compiled only for python 2.7.

You should use the version from conda-forge which also provides pyqt5 and has versions for pyhton 3.7 on OsX:

```<code>conda install -c conda-forge pyqt
</code>```

Body:
I think its telling me it wants to use Python 3.7 but the message is confusing so I made 3.7 the default for the terminal shell, but I still get the following:

dzimmerman@QA-Bonjour-OSX ~ % python --version
Python 3.7.2
dzimmerman@QA-Bonjour-OSX ~ % conda install -c dsdale24 pyqt5
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - pyqt5 -> python=2.7

Your python: python=3.7

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

Body:
The pyqt5 package in the channel you are trying to use is compiled only for python 2.7.

You should use the version from conda-forge which also provides pyqt5 and has versions for pyhton 3.7 on OsX:

conda install -c conda-forge pyqt


问:
Color Changing for Dash Daq Thermometer/gauge/LED display
I want to make an interactive dashboard with gauge/thermometer/led in it.

How can I make the color changes in them according to their updated values rather than everything in one color?

```<code>daq.Thermometer(
       id ='temperature', label="Temperature",
       value=27, max=50, min=0, showCurrentValue=True, units="C",
       color='red',
    ),
</code>```

答:
You can use a callback taking the Thermometer value as an input and the Thermometer colour as an output.

Example below:

```<code>@app.callback(
    Output('temperature', 'color'),
    [Input('temperature', 'value')]
)
def update_therm_col(val):
    if val >= 20:
        return 'red'
    elif val < 20:
        return 'blue'
</code>```

If you wanted to jazz it up a bit more you could make the colour a function of the value - the color parameter can take hexadecimal values as well.

Hope this helps,

Ollie

Body:
I want to make an interactive dashboard with gauge/thermometer/led in it.

How can I make the color changes in them according to their updated values rather than everything in one color?

daq.Thermometer(
       id ='temperature', label="Temperature",
       value=27, max=50, min=0, showCurrentValue=True, units="C",
       color='red',
    ),

Body:
You can use a callback taking the Thermometer value as an input and the Thermometer colour as an output.

Example below:

@app.callback(
    Output('temperature', 'color'),
    [Input('temperature', 'value')]
)
def update_therm_col(val):
    if val >= 20:
        return 'red'
    elif val < 20:
        return 'blue'

If you wanted to jazz it up a bit more you could make the colour a function of the value - the color parameter can take hexadecimal values as well.

Hope this helps,

Ollie


问:
Pass jenkins credentials from pipline to ansible playbook
I try to pass credentials from jenkins pipline to ansible playbook into docker as enviromental variable.

jenkins pipline:

```<code>steps {
  withCredentials([usernamePassword(credentialsId: 'creds', passwordVariable: 'pass', usernameVariable: 'usr')]) {
    ansiblePlaybook(
      playbook: 'AnsiblePlaybook.yml',
      inventory: 'AnsibleInventory.ini',
      installation: 'ansible-latest',
      disableHostKeyChecking: true,
      become: 'yes',
      extras: '-vvv',
      extraVars: [
        usr: ${usr},
        pass: ${pass}
      ]
    )
  }
}
</code>```

AnsiblePlaybook.yml:

```<code>docker_container:
  name: mysql
  image: mysql:5.6
  state: started
  env:
    MYSQL_USER: "{{ usr }}"
    MYSQL_PASSWORD: "{{ pass }}"
    MYSQL_RANDOM_ROOT_PASSWORD: "yes"
</code>```

I got error:

java.lang.NoSuchMethodError: No such DSL method '$' found among steps

答:
I had same issue.

You had used wrong syntax.
You forgot "
Here is right example:

```<code>steps {
  withCredentials([usernamePassword(credentialsId: 'creds', passwordVariable: 'pass', usernameVariable: 'usr')]) {
    ansiblePlaybook(
      playbook: 'AnsiblePlaybook.yml',
      inventory: 'AnsibleInventory.ini',
      installation: 'ansible-latest',
      disableHostKeyChecking: true,
      become: 'yes',
      extras: '-vvv',
      extraVars: [
        usr: "${usr}",  // <================ Here you need extra "
        pass: "${pass}" // <================ Here you need extra "
      ]
    )
  }
}

</code>```

Body:
I try to pass credentials from jenkins pipline to ansible playbook into docker as enviromental variable.

jenkins pipline:

steps {
  withCredentials([usernamePassword(credentialsId: 'creds', passwordVariable: 'pass', usernameVariable: 'usr')]) {
    ansiblePlaybook(
      playbook: 'AnsiblePlaybook.yml',
      inventory: 'AnsibleInventory.ini',
      installation: 'ansible-latest',
      disableHostKeyChecking: true,
      become: 'yes',
      extras: '-vvv',
      extraVars: [
        usr: ${usr},
        pass: ${pass}
      ]
    )
  }
}

AnsiblePlaybook.yml:

docker_container:
  name: mysql
  image: mysql:5.6
  state: started
  env:
    MYSQL_USER: "{{ usr }}"
    MYSQL_PASSWORD: "{{ pass }}"
    MYSQL_RANDOM_ROOT_PASSWORD: "yes"

I got error:

java.lang.NoSuchMethodError: No such DSL method '$' found among steps

Body:
I had same issue.

You had used wrong syntax.
You forgot "
Here is right example:

steps {
  withCredentials([usernamePassword(credentialsId: 'creds', passwordVariable: 'pass', usernameVariable: 'usr')]) {
    ansiblePlaybook(
      playbook: 'AnsiblePlaybook.yml',
      inventory: 'AnsibleInventory.ini',
      installation: 'ansible-latest',
      disableHostKeyChecking: true,
      become: 'yes',
      extras: '-vvv',
      extraVars: [
        usr: "${usr}",  // <================ Here you need extra "
        pass: "${pass}" // <================ Here you need extra "
      ]
    )
  }
}


问:
How can I animate coordinate data in gnuplot?
I have 4 sets of coordinate data (2D, let's say it represents a square at different positions). How can I animate their positions in gnuplot (please recommend if other programs are easier to achieve this) so that it looks like it is rotating counter-clockwise?

Position 1:

1 1
3 1
3 3
1 3

Position 2:

-1 1
-3 1
-3 3
-1 3

Position 3:

-1 -1
-3 -1
-3 -3
-1 -3

Position 4:

1 -1
3 -1
3 -3
1 -3

答:
You don't write whether you want a filled square or lines or animated gif or something else.
You can start with something like this. Make sure that the data is separated by two empty lines, such that gnuplot will recognize the blocks which you can address via index i.
Also check help gif.

Code:

```<code>### animation of square
reset session
set size square

$Data <<EOD
# Position 1:
1 1
3 1
3 3
1 3

# Position 2:
-1 1
-3 1
-3 3
-1 3

# Position 3:
-1 -1
-3 -1
-3 -3
-1 -3

# Position 4:
1 -1
3 -1
3 -3
1 -3
EOD

set xrange [-4:4]
set yrange [-4:4]

set term gif animate delay 100 optimize
set output "tbAnimationSquare.gif"
do for [i=0:3] {
    plot $Data u 1:2 index i w filledcurves lc rgb "red" not
}
set output
### end of code
</code>```

Result:

Body:
You don't write whether you want a filled square or lines or animated gif or something else.
You can start with something like this. Make sure that the data is separated by two empty lines, such that gnuplot will recognize the blocks which you can address via index i.
Also check help gif.

Code:

### animation of square
reset session
set size square

$Data <<EOD
# Position 1:
1 1
3 1
3 3
1 3

# Position 2:
-1 1
-3 1
-3 3
-1 3

# Position 3:
-1 -1
-3 -1
-3 -3
-1 -3

# Position 4:
1 -1
3 -1
3 -3
1 -3
EOD

set xrange [-4:4]
set yrange [-4:4]

set term gif animate delay 100 optimize
set output "tbAnimationSquare.gif"
do for [i=0:3] {
    plot $Data u 1:2 index i w filledcurves lc rgb "red" not
}
set output
### end of code

Result: