问:
Loop through JS object to return matching result of value
I have an object, full of salmon. I want to loop through and check whether salmon is fresh or frozen. If frozen, put in no pile, if fresh, put in yes pile. If ounces is less than 2 and more than 6, no pile, and if it matches 2-6, yes pile.

Then, with the yes pile, I want to loop through those keys and values to find the cheapest one, and print that out.

Here is what I have so far, but I seem to be stuck on looping through the big object in order to run the checks.

How do I do this?

```<code>function findSalmon(salmonInStore){
  var noPile,
      yesPile;
      var salmon = Object.keys(salmonInStore));
  for(var key in salmonInStore){

    if(salmonInStore.key.freshness !== 'fresh'){
      noPile.push(salmonInStore.key);
    } else {
      yesPile.push(salmonInStore.key);
    }
    if(salmonInStore.key.ounces < 2 && salmonInStore.key.ounces > 6){
      noPile.push(key);
    }else {
      yesPile.push(salmonInStore.key);
    }
  }
  return yesPile;
}

var salmonInStore = {
  salmon1 : {
    ounces: 1,
    freshness: 'frozen',
    price: 16
  },

 salmon2 : {
    ounces: 6,
    freshness: 'fresh',
    price: 10
  },

  salmon3 : {
    ounces: 2,
    freshness: 'frozen',
    price: 20
  },

  salmon4 : {
    ounces: 5,
    freshness: 'fresh',
    price: 1
  },

  salmon5 : {
    ounces: 3,
    freshness: 'frozen',
    price: 12
  }
}

findSalmon(salmonInStore);
</code>```

答:
First we can sort the salmon list by price.

```<code>const salmonList = Object.keys(salmonInStore)
  .map(key => salmonInStore[key])
  .sort((a,b) => {
    if (a.price < b.price)
      return -1;
    if (a.price > b.price)
      return 1;

    return 0;
});
</code>```

Then we can filter out the yes fish.

```<code>const yesPile = salmonList.filter((salmon) => {
 return salmon.ounces >= 2 && salmon.ounces <= 6 && salmon.freshness === 'fresh';
});

yesPile[0] // cheapest fish
</code>```

Check out the fiddle for a working example.

https://jsfiddle.net/y1jg01wy/

Body:
I have an object, full of salmon. I want to loop through and check whether salmon is fresh or frozen. If frozen, put in no pile, if fresh, put in yes pile. If ounces is less than 2 and more than 6, no pile, and if it matches 2-6, yes pile.

Then, with the yes pile, I want to loop through those keys and values to find the cheapest one, and print that out.

Here is what I have so far, but I seem to be stuck on looping through the big object in order to run the checks.

How do I do this?

function findSalmon(salmonInStore){
  var noPile,
      yesPile;
      var salmon = Object.keys(salmonInStore));
  for(var key in salmonInStore){

    if(salmonInStore.key.freshness !== 'fresh'){
      noPile.push(salmonInStore.key);
    } else {
      yesPile.push(salmonInStore.key);
    }
    if(salmonInStore.key.ounces < 2 && salmonInStore.key.ounces > 6){
      noPile.push(key);
    }else {
      yesPile.push(salmonInStore.key);
    }
  }
  return yesPile;
}

var salmonInStore = {
  salmon1 : {
    ounces: 1,
    freshness: 'frozen',
    price: 16
  },

 salmon2 : {
    ounces: 6,
    freshness: 'fresh',
    price: 10
  },

  salmon3 : {
    ounces: 2,
    freshness: 'frozen',
    price: 20
  },

  salmon4 : {
    ounces: 5,
    freshness: 'fresh',
    price: 1
  },

  salmon5 : {
    ounces: 3,
    freshness: 'frozen',
    price: 12
  }
}

findSalmon(salmonInStore);

Body:
First we can sort the salmon list by price.

const salmonList = Object.keys(salmonInStore)
  .map(key => salmonInStore[key])
  .sort((a,b) => {
    if (a.price < b.price)
      return -1;
    if (a.price > b.price)
      return 1;

    return 0;
});

Then we can filter out the yes fish.

const yesPile = salmonList.filter((salmon) => {
 return salmon.ounces >= 2 && salmon.ounces <= 6 && salmon.freshness === 'fresh';
});

yesPile[0] // cheapest fish

Check out the fiddle for a working example.

https://jsfiddle.net/y1jg01wy/


来源: stackexchange

问:
Where can I find org.jenkinsci.plugins.workflow.steps.FlowInterruptedException with gradle?
I have the following build.gradle

```<code>apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'java'
repositories {
    mavenCentral()
    maven {
        url 'https://repo.jenkins-ci.org/releases'
    }
    maven {
        url 'https://repo.jenkins-ci.org/public'
    }
}
sourceSets {
    main {
        groovy {
            srcDirs = ['src']
        }
    }
    test {
        groovy {
            srcDirs = ['test']
        }
    }
}
dependencies {
    compile group: 'org.jenkins-ci.main', name: 'jenkins-core', version: '2.76'
    compile group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.13'
    compile 'com.cloudbees:groovy-cps:1.14'
    compile 'org.connectbot.jbcrypt:jbcrypt:1.0.0'
    compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
    compile 'org.codehaus.groovy:groovy-all:2.4.12'
    testCompile 'junit:junit:4.12'
}
</code>```

When I run "gradle build" I get the following error:

```<code>> Task :compileGroovy FAILED
startup failed:
/home/user/myproject/SomeClass.groovy: 26: unable to resolve class org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
@ line 26, column 11.
        } catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException flowInterruptedException) {
            ^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
1 actionable task: 1 executed
</code>```

It's as if it does not see "org.jenkinsci.plugins.workflow.steps.FlowInterruptedException" but I added workflow-step-api and it should find it.

What am I doing wrong? How to fix?

Thank you

答:
The 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.13' dependency has a POM that has this in it (taken from here):

<packaging>hpi</packaging>
```

<p>The dependency that Gradle retrieves is the <code>hpi</code> artifact, not the <code>jar</code> one when you point at this dependency. This can be shown with a task like the following:</p>

<pre class="lang-groovy prettyprint-override"><code>tasks.create('showDependencies') {
  doFirst {
    final config = configurations.getByName(sourceSets.getByName('main').compileClasspathConfigurationName)
    config.resolvedConfiguration.resolvedArtifacts.findAll { it.moduleVersion.id.group.contains('jenkins') }.each {
      println("Resolved dependency: id=${it.id}, extension=${it.extension}, classifier=${it.classifier}")
    }
  }
}
</code>```

The output:

```<code> > Task :showDependencies
Resolved dependency: id=jenkins-core.jar (org.jenkins-ci.main:jenkins-core:2.76), extension=jar, classifier=null
Resolved dependency: id=workflow-step-api.hpi (org.jenkins-ci.plugins.workflow:workflow-step-api:2.13), extension=hpi, classifier=null
Resolved dependency: id=cli.jar (org.jenkins-ci.main:cli:2.76), extension=jar, classifier=null
Resolved dependency: id=trilead-ssh2.jar (org.jenkins-ci:trilead-ssh2:build-217-jenkins-11), extension=jar, classifier=null
Resolved dependency: id=icon-set.jar (org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5), extension=jar, classifier=null
Resolved dependency: id=remoting.jar (org.jenkins-ci.main:remoting:3.11), extension=jar, classifier=null
Resolved dependency: id=version-number.jar (org.jenkins-ci:version-number:1.4), extension=jar, classifier=null
Resolved dependency: id=crypto-util.jar (org.jenkins-ci:crypto-util:1.1), extension=jar, classifier=null
Resolved dependency: id=bytecode-compatibility-transformer.jar (org.jenkins-ci:bytecode-compatibility-transformer:1.8), extension=jar, classifier=null
Resolved dependency: id=structs.hpi (org.jenkins-ci.plugins:structs:1.5), extension=hpi, classifier=null
Resolved dependency: id=symbol-annotation.jar (org.jenkins-ci:symbol-annotation:1.5), extension=jar, classifier=null
Resolved dependency: id=annotation-indexer.jar (org.jenkins-ci:annotation-indexer:1.12), extension=jar, classifier=null
Resolved dependency: id=task-reactor.jar (org.jenkins-ci:task-reactor:1.4), extension=jar, classifier=null
Resolved dependency: id=commons-jelly.jar (org.jenkins-ci:commons-jelly:1.1-jenkins-20120928), extension=jar, classifier=null
Resolved dependency: id=commons-jexl.jar (org.jenkins-ci:commons-jexl:1.1-jenkins-20111212), extension=jar, classifier=null
Resolved dependency: id=memory-monitor.jar (org.jenkins-ci:memory-monitor:1.9), extension=jar, classifier=null
Resolved dependency: id=jmdns.jar (org.jenkins-ci:jmdns:3.4.0-jenkins-3), extension=jar, classifier=null
Resolved dependency: id=constant-pool-scanner.jar (org.jenkins-ci:constant-pool-scanner:1.2), extension=jar, classifier=null
Resolved dependency: id=dom4j.jar (org.jenkins-ci.dom4j:dom4j:1.6.1-jenkins-4), extension=jar, classifier=null
</code>```

There are several ways to use Gradle's dependency management features to better handle dependencies. One possible way to change the dependency would be to add an artifact dependency with the extension. This may not solve your exact use case depending on how you want your dependencies to end up, but can hopefully point you in a direction:

compile(group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.13') {
  artifact {
    name = 'workflow-step-api'
    type = 'jar'
  }
}
```

As a side note, in the Jenkins plugin ecosystem, the Jenkins Maven HPI Plugin and Jenkins Plugin Parent POM work together to do dependency management so you don't run into issues like this.

ContentLicense: CC BY-SA 3.0

Body:
I have the following build.gradle

apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'java'
repositories {
    mavenCentral()
    maven {
        url 'https://repo.jenkins-ci.org/releases'
    }
    maven {
        url 'https://repo.jenkins-ci.org/public'
    }
}
sourceSets {
    main {
        groovy {
            srcDirs = ['src']
        }
    }
    test {
        groovy {
            srcDirs = ['test']
        }
    }
}
dependencies {
    compile group: 'org.jenkins-ci.main', name: 'jenkins-core', version: '2.76'
    compile group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.13'
    compile 'com.cloudbees:groovy-cps:1.14'
    compile 'org.connectbot.jbcrypt:jbcrypt:1.0.0'
    compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
    compile 'org.codehaus.groovy:groovy-all:2.4.12'
    testCompile 'junit:junit:4.12'
}

When I run "gradle build" I get the following error:

> Task :compileGroovy FAILED
startup failed:
/home/user/myproject/SomeClass.groovy: 26: unable to resolve class org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
@ line 26, column 11.
        } catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException flowInterruptedException) {
            ^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
1 actionable task: 1 executed

It's as if it does not see "org.jenkinsci.plugins.workflow.steps.FlowInterruptedException" but I added workflow-step-api and it should find it.

What am I doing wrong? How to fix?

Thank you

Body:
The 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.13' dependency has a POM that has this in it (taken from here):

<packaging>hpi</packaging>

The dependency that Gradle retrieves is the hpi artifact, not the jar one when you point at this dependency. This can be shown with a task like the following:

tasks.create('showDependencies') {
  doFirst {
    final config = configurations.getByName(sourceSets.getByName('main').compileClasspathConfigurationName)
    config.resolvedConfiguration.resolvedArtifacts.findAll { it.moduleVersion.id.group.contains('jenkins') }.each {
      println("Resolved dependency: id=${it.id}, extension=${it.extension}, classifier=${it.classifier}")
    }
  }
}

The output:

 > Task :showDependencies
Resolved dependency: id=jenkins-core.jar (org.jenkins-ci.main:jenkins-core:2.76), extension=jar, classifier=null
Resolved dependency: id=workflow-step-api.hpi (org.jenkins-ci.plugins.workflow:workflow-step-api:2.13), extension=hpi, classifier=null
Resolved dependency: id=cli.jar (org.jenkins-ci.main:cli:2.76), extension=jar, classifier=null
Resolved dependency: id=trilead-ssh2.jar (org.jenkins-ci:trilead-ssh2:build-217-jenkins-11), extension=jar, classifier=null
Resolved dependency: id=icon-set.jar (org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5), extension=jar, classifier=null
Resolved dependency: id=remoting.jar (org.jenkins-ci.main:remoting:3.11), extension=jar, classifier=null
Resolved dependency: id=version-number.jar (org.jenkins-ci:version-number:1.4), extension=jar, classifier=null
Resolved dependency: id=crypto-util.jar (org.jenkins-ci:crypto-util:1.1), extension=jar, classifier=null
Resolved dependency: id=bytecode-compatibility-transformer.jar (org.jenkins-ci:bytecode-compatibility-transformer:1.8), extension=jar, classifier=null
Resolved dependency: id=structs.hpi (org.jenkins-ci.plugins:structs:1.5), extension=hpi, classifier=null
Resolved dependency: id=symbol-annotation.jar (org.jenkins-ci:symbol-annotation:1.5), extension=jar, classifier=null
Resolved dependency: id=annotation-indexer.jar (org.jenkins-ci:annotation-indexer:1.12), extension=jar, classifier=null
Resolved dependency: id=task-reactor.jar (org.jenkins-ci:task-reactor:1.4), extension=jar, classifier=null
Resolved dependency: id=commons-jelly.jar (org.jenkins-ci:commons-jelly:1.1-jenkins-20120928), extension=jar, classifier=null
Resolved dependency: id=commons-jexl.jar (org.jenkins-ci:commons-jexl:1.1-jenkins-20111212), extension=jar, classifier=null
Resolved dependency: id=memory-monitor.jar (org.jenkins-ci:memory-monitor:1.9), extension=jar, classifier=null
Resolved dependency: id=jmdns.jar (org.jenkins-ci:jmdns:3.4.0-jenkins-3), extension=jar, classifier=null
Resolved dependency: id=constant-pool-scanner.jar (org.jenkins-ci:constant-pool-scanner:1.2), extension=jar, classifier=null
Resolved dependency: id=dom4j.jar (org.jenkins-ci.dom4j:dom4j:1.6.1-jenkins-4), extension=jar, classifier=null

There are several ways to use Gradle's dependency management features to better handle dependencies. One possible way to change the dependency would be to add an artifact dependency with the extension. This may not solve your exact use case depending on how you want your dependencies to end up, but can hopefully point you in a direction:

compile(group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.13') {
  artifact {
    name = 'workflow-step-api'
    type = 'jar'
  }
}

As a side note, in the Jenkins plugin ecosystem, the Jenkins Maven HPI Plugin and Jenkins Plugin Parent POM work together to do dependency management so you don't run into issues like this.


答:
It can be done this way with Pandas' basic pivot_table functionality and aggregate functions (also need to import NumPy). See the answer in this question and Pandas pivot_table documentation with examples:

```<code>import numpy as np
df = ...
ndf = df.pivot_table(index=['value'],
                     columns='movie',
                     aggfunc=np.count_nonzero).reset_index().fillna(0).astype(int)
print(ndf)

      value id
movie        a  b  c
0         0  4  2  0
1        10  1  1  0
2        20  2  0  0
3        30  0  3  0
4        40  0  0  2
</code>```

Title: python pivot table of counts

Body:
I have a dataframe df as follows:

| id | movie | value |
|----|-------|-------|
| 1  | a     | 0     |
| 2  | a     | 0     |
| 3  | a     | 20    |
| 4  | a     | 0     |
| 5  | a     | 10    |
| 6  | a     | 0     |
| 7  | a     | 20    |
| 8  | b     | 0     |
| 9  | b     | 0     |
| 10 | b     | 30    |
| 11 | b     | 30    |
| 12 | b     | 30    |
| 13 | b     | 10    |
| 14 | c     | 40    |
| 15 | c     | 40    |

I want to create a 2X2 pivot table of counts as follows:

| Value | count(a) | count(b) | count ( C ) |
|-------|----------|----------|-------------|
| 0     | 4        | 2        | 0           |
| 10    | 1        | 1        | 0           |
| 20    | 2        | 0        | 0           |
| 30    | 0        | 3        | 0           |
| 40    | 0        | 0        | 2           |

I can do this very easily in Excel using Row and Column Labels. How can I do this using Python?

Body:
It can be done this way with Pandas' basic pivot_table functionality and aggregate functions (also need to import NumPy). See the answer in this question and Pandas pivot_table documentation with examples:

import numpy as np
df = ...
ndf = df.pivot_table(index=['value'],
                     columns='movie',
                     aggfunc=np.count_nonzero).reset_index().fillna(0).astype(int)
print(ndf)

      value id
movie        a  b  c
0         0  4  2  0
1        10  1  1  0
2        20  2  0  0
3        30  0  3  0
4        40  0  0  2


问:
Click on a button in a single browser and task should be performed in both opened browser
What I want to achieve is that I have click here button which will fetch the users name from the DB. Now, I have two browsers opened and are on the same page, so when I click the button on any one browser the data should be shown in both the browser.

Here's the code:

```<code><html>

<head>
  <script src="jquery-3.2.1.min.js"></script>
</head>

<body>
  <button id="sub">click here</button>
  <div id="detail"></div>

  <script>
    function fetch_data() {
      $.ajax({
        url: "select.php",
        method: "POST",
        success: function(data) {
          $('#detail').html(data);
        }
      });
    }
    $(document).ready(function() {
      $("#sub").click(function() {
        fetch_data();
      });

    });
  </script>
</body>

</html>
</code>```

答: You going to need a "Realtime Database" to achive what you are looking for. I suggest to use Firebase. with firebase data is synced across all clients in realtime, and even remains available when your app goes offline. Instead of typical HTTP requests, the Firebase Realtime Database uses data synchronization—every time data changes, any connected device receives that update within milliseconds. Provide collaborative and immersive experiences without thinking about networking code.</p>

Body:
What I want to achieve is that I have click here button which will fetch the users name from the DB. Now, I have two browsers opened and are on the same page, so when I click the button on any one browser the data should be shown in both the browser.

Here's the code:

  <button id="sub">click here</button>


问:
Parse string with Python and pull numbers for simple math
I am running "Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2" on Ubuntu.

I have a line as follows from serial:

```<code>line="[99]  nodeId=99    uptime=31987895     BarC=1.15     sensorVal=226 -"
</code>```

and wish to parse this. I need to extract 1.15 and 226 as numbers so I can do math with those numbers.

I have used the following python code:

```<code>pressure=line.split()[3].split("=")[1:2]
print(pressure)
</code>```

This prints this:

```<code>['1.15']
</code>```

How do I get rid of the  ' ' (apostrophes) and the  [  ]  and turn this into something I can do simple math with. A floating number will be fine.

Here is more output:

```<code>Listening at 868 Mhz...
[99]  nodeId=99    uptime=48743987     BarC=1.19     sensorVal=229 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48745052     BarC=1.19     sensorVal=229
[99]  nodeId=99    uptime=48527151     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48528216     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48529276     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48530341     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48531402     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48532467     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48533528     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48534594     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48535655     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48536720     BarC=1.20     sen**
</code>```

Body:
I am running "Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2" on Ubuntu.

I have a line as follows from serial:

line="[99]  nodeId=99    uptime=31987895     BarC=1.15     sensorVal=226 -"

and wish to parse this. I need to extract 1.15 and 226 as numbers so I can do math with those numbers.

I have used the following python code:

pressure=line.split()[3].split("=")[1:2]
print(pressure)

This prints this:

['1.15']

How do I get rid of the  ' ' (apostrophes) and the  [  ]  and turn this into something I can do simple math with. A floating number will be fine.

Here is more output:

Listening at 868 Mhz...
[99]  nodeId=99    uptime=48743987     BarC=1.19     sensorVal=229 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48745052     BarC=1.19     sensorVal=229
[99]  nodeId=99    uptime=48527151     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48528216     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48529276     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48530341     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48531402     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48532467     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48533528     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48534594     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48535655     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48536720     BarC=1.20     sen**

Body:
You can use re.findall for a broader solution:

import re
s = 'line="[99]  nodeId=99    uptime=31987895     BarC=1.15     sensorVal=226 -"'
a, b = map(float, re.findall('\d+\.*\d+', s))[-2:]
print(a, b)

Output:

(1.15, 226.0)

Edit: Assuming your output is [[227.0, 99.0] [1.17, 227.0] [228.0, 99.0] [1.17, 227.0] [228.0, 99.0]], can try this:

s = [[227.0, 99.0] [1.17, 227.0] [228.0, 99.0] [1.17, 227.0] [228.0, 99.0]]
final_data = [i[0] for i in s[:2]]


问:
How to catch all exceptions in web config from all controllers c#
We're using MVC Structure and have multiple c# controllers, is it possible to catch them all thru web.config? instead of adding a catch statement to all controller methods?

Thank you so much.

答:
You can create your own base controller and handle the exceptions in the OnException event.

```<code>public class BaseController : Controller
{
    protected override void OnException(ExceptionContext filterContext)
    {
       // to do : Log the exception (filterContext.Exception)
       // and redirect / return error view
        filterContext.ExceptionHandled = true;
        // If the exception occurred in an ajax call. Send a json response back
        // (you need to parse this and display to user as needed at client side)
        if (filterContext.HttpContext.Request.Headers["X-Requested-With"]
                                                          =="XMLHttpRequest")
        {
            filterContext.Result = new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { Error = true, Message = filterContext.Exception.Message }
            };
            filterContext.HttpContext.Response.StatusCode = 500; // Set as needed
        }
        else
        {
            filterContext.Result = new ViewResult { ViewName = "Error.cshtml" };
            //Assuming the view exists in the "~/Views/Shared" folder
        }
    }
}
</code>```

For non ajax requests, it will render the Error.cshtml to the user. If you want to do a redirect (a new GET call) to your Error action method instead of showing Error.cshtml, you can replace the ViewResult with a RedirectToRouteResult.

```<code>filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
                                               {"controller", "Home"}, {"action", "Error"}
                                              };
</code>```

Now have your other controllers inherit from this

```<code>public class HomeController : BaseController
{
   public ActionResult Die()
   {
      throw new Exception("Bad code!");
   }
}
public class ProductsController : BaseController
{
   public ActionResult Index()
   {
       var arr =new int[2];
       var thisShouldCrash = arr[10];
       return View();
   }
}
</code>```

Body:
You can create your own base controller and handle the exceptions in the OnException event.

public class BaseController : Controller
{
    protected override void OnException(ExceptionContext filterContext)
    {
       // to do : Log the exception (filterContext.Exception)
       // and redirect / return error view
        filterContext.ExceptionHandled = true;
        // If the exception occurred in an ajax call. Send a json response back
        // (you need to parse this and display to user as needed at client side)
        if (filterContext.HttpContext.Request.Headers["X-Requested-With"]
                                                          =="XMLHttpRequest")
        {
            filterContext.Result = new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { Error = true, Message = filterContext.Exception.Message }
            };
            filterContext.HttpContext.Response.StatusCode = 500; // Set as needed
        }
        else
        {
            filterContext.Result = new ViewResult { ViewName = "Error.cshtml" };
            //Assuming the view exists in the "~/Views/Shared" folder
        }
    }
}

For non ajax requests, it will render the Error.cshtml to the user. If you want to do a redirect (a new GET call) to your Error action method instead of showing Error.cshtml, you can replace the ViewResult with a RedirectToRouteResult.

filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
                                               {"controller", "Home"}, {"action", "Error"}
                                              };

Now have your other controllers inherit from this

public class HomeController : BaseController
{
   public ActionResult Die()
   {
      throw new Exception("Bad code!");
   }
}
public class ProductsController : BaseController
{
   public ActionResult Index()
   {
       var arr =new int[2];
       var thisShouldCrash = arr[10];
       return View();
   }
}


问:
VSTS Release Task - Push to Nuget
I'm trying to set up CI for my Core projects and wrappers to our vsts nuget feed.
I've followed the Zen of Package Management tutorial here.

It's a little out of date, but I believe I managed to translate the changes.

My Build seems to work fine, it builds and packages the dll's into several nuget packages.

The release seems to work also, but the Nuget Feed is not updated with the latest packages.

My Release task is only one task as shown in the image below.
The log shows that it found and downloaded the packages, but it does not show any success on the actual push to nuget.

This is the log that shows the packages being found, and successful completion.

```<code>2017-11-15T02:40:59.5675003Z ##[section]Finishing: Initialize Job
2017-11-15T02:40:59.6125167Z ##[section]Starting: Download Artifacts
2017-11-15T02:41:00.2861639Z Downloading artifact
2017-11-15T02:41:00.2961643Z Creating artifacts directory: d:\a\r1\a
...etc

2017-11-15T02:41:00.8313684Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.AzureWrapper.Domain.2.0.0.3.nupkg
2017-11-15T02:41:00.9943663Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.PaymentGateway.Interfaces.2.0.0.3.nupkg
2017-11-15T02:41:00.9998063Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.PaymentGateway.Test.2.0.0.3.nupkg
...etc

2017-11-15T02:41:01.0750176Z Download complete.
2017-11-15T02:41:01.0761342Z 16 placed file(s): 16 downloaded, 0 empty
2017-11-15T02:41:01.0830178Z 1 MB downloaded at 1491 KB/sec. Download time: 00:00:00.2761869.
2017-11-15T02:41:01.0830178Z Downloaded linked artifact Satalyst-Visual Studio-CI
2017-11-15T02:41:01.0830178Z Finished artifacts download
2017-11-15T02:41:01.0890187Z ##[section]Finishing: Download Artifacts
</code>```

... its this bit below that succeeds, but the feed does not show the new packages??

```<code>2017-11-15T02:41:01.0920188Z ##[section]Starting: NuGet Publish
2017-11-15T02:41:01.1190170Z ==============================================================================
2017-11-15T02:41:01.1190170Z Task         : NuGet
2017-11-15T02:41:01.1190170Z Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
2017-11-15T02:41:01.1190170Z Version      : 2.0.15
2017-11-15T02:41:01.1190170Z Author       : Microsoft Corporation
2017-11-15T02:41:01.1190170Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2017-11-15T02:41:01.1190170Z ==============================================================================
2017-11-15T02:41:04.1372760Z Caching tool: NuGet 4.1.0 x64
2017-11-15T02:41:04.1502760Z Found tool in cache: NuGet 4.1.0 x64
2017-11-15T02:41:04.1612765Z Resolved from tool cache: 4.1.0
2017-11-15T02:41:04.1612765Z Using version: 4.1.0
2017-11-15T02:41:04.1612765Z Found tool in cache: NuGet 4.1.0 x64
2017-11-15T02:41:05.1667858Z [command]C:\Windows\system32\chcp.com 65001
2017-11-15T02:41:05.1667858Z Active code page: 65001
2017-11-15T02:41:05.1877908Z ##[section]Finishing: NuGet Publish
2017-11-15T02:41:05.1937859Z ##[section]Finishing: Release
</code>```

Any assistance would be greatly appreciated, I've been doing a bit of trial and error to find the issue with no success.  I'm now a bit stuck with no error messages and no feedback on the outcome for the push.

答:
It's caused by the configuration of Path to NuGet package(s) to publish option for NuGet Push task in your release definition.

Please change the Path to NuGet package(s) to publish as:

```<code>$(System.DefaultWorkingDirectory)/**/packed/*.nupkg
</code>```

Then the nuget package should be published to your feed correctly.

Title: VSTS Release Task - Push to Nuget

Body:
I'm trying to set up CI for my Core projects and wrappers to our vsts nuget feed.
I've followed the Zen of Package Management tutorial here.

It's a little out of date, but I believe I managed to translate the changes.

My Build seems to work fine, it builds and packages the dll's into several nuget packages.

The release seems to work also, but the Nuget Feed is not updated with the latest packages.

My Release task is only one task as shown in the image below.
The log shows that it found and downloaded the packages, but it does not show any success on the actual push to nuget.

This is the log that shows the packages being found, and successful completion.

2017-11-15T02:40:59.5675003Z ##[section]Finishing: Initialize Job
2017-11-15T02:40:59.6125167Z ##[section]Starting: Download Artifacts
2017-11-15T02:41:00.2861639Z Downloading artifact
2017-11-15T02:41:00.2961643Z Creating artifacts directory: d:\a\r1\a
...etc

2017-11-15T02:41:00.8313684Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.AzureWrapper.Domain.2.0.0.3.nupkg
2017-11-15T02:41:00.9943663Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.PaymentGateway.Interfaces.2.0.0.3.nupkg
2017-11-15T02:41:00.9998063Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.PaymentGateway.Test.2.0.0.3.nupkg
...etc

2017-11-15T02:41:01.0750176Z Download complete.
2017-11-15T02:41:01.0761342Z 16 placed file(s): 16 downloaded, 0 empty
2017-11-15T02:41:01.0830178Z 1 MB downloaded at 1491 KB/sec. Download time: 00:00:00.2761869.
2017-11-15T02:41:01.0830178Z Downloaded linked artifact Satalyst-Visual Studio-CI
2017-11-15T02:41:01.0830178Z Finished artifacts download
2017-11-15T02:41:01.0890187Z ##[section]Finishing: Download Artifacts

... its this bit below that succeeds, but the feed does not show the new packages??

2017-11-15T02:41:01.0920188Z ##[section]Starting: NuGet Publish
2017-11-15T02:41:01.1190170Z ==============================================================================
2017-11-15T02:41:01.1190170Z Task         : NuGet
2017-11-15T02:41:01.1190170Z Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
2017-11-15T02:41:01.1190170Z Version      : 2.0.15
2017-11-15T02:41:01.1190170Z Author       : Microsoft Corporation
2017-11-15T02:41:01.1190170Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2017-11-15T02:41:01.1190170Z ==============================================================================
2017-11-15T02:41:04.1372760Z Caching tool: NuGet 4.1.0 x64
2017-11-15T02:41:04.1502760Z Found tool in cache: NuGet 4.1.0 x64
2017-11-15T02:41:04.1612765Z Resolved from tool cache: 4.1.0
2017-11-15T02:41:04.1612765Z Using version: 4.1.0
2017-11-15T02:41:04.1612765Z Found tool in cache: NuGet 4.1.0 x64
2017-11-15T02:41:05.1667858Z [command]C:\Windows\system32\chcp.com 65001
2017-11-15T02:41:05.1667858Z Active code page: 65001
2017-11-15T02:41:05.1877908Z ##[section]Finishing: NuGet Publish
2017-11-15T02:41:05.1937859Z ##[section]Finishing: Release

Any assistance would be greatly appreciated, I've been doing a bit of trial and error to find the issue with no success.  I'm now a bit stuck with no error messages and no feedback on the outcome for the push.

Body:
It's caused by the configuration of Path to NuGet package(s) to publish option for NuGet Push task in your release definition.

Please change the Path to NuGet package(s) to publish as:

$(System.DefaultWorkingDirectory)/**/packed/*.nupkg

Then the nuget package should be published to your feed correctly.


问:
For what purposes in Swift using NSObject class?
As I know in Objective-C all classes are inherit from NSObject class. What about Swift? For what purposes we need to inherit from NSObject in Swift?</p>

答:
Nothing about the Swift language inherently requires you to inherit from NSObject. There is no Swift base class. NSObject is not part of Swift. In the absence of Cocoa Foundation, NSObject doesn't even exist as far as Swift is concerned.

In practical usage — e.g., when programming iOS — the reason you might want a class to inherit from NSObject would have to do with Cocoa, not Swift; it would be because you want Objective-C to be able to work with that class in some special way that is only possible if this is an NSObject subclass.


问:
Styling Text inside Android TextView
In my app, each Target Text has a mix of numbers and strings. I want the numbers to be highlighted in Bold and string to be italicised. For e.g.

You have reached 25% of your goal. 30 more days to achieve target

Is there an easier way to do it than create 5 separate textviews for this - 3 for string and 2 for number. Managing layout of 5 textboxes for each target is becoming a nightmare in my layout. I have 9 such rows leading to potentially 45 textviews in one layout.

答:
You can use the following example,

For Kotlin

```<code>textView.text = Html.fromHtml("<b>Hello</b> <i>World</i>")
</code>```

For Java

```<code>textView.setText(Html.fromHtml("<b>Hello</b> <i>World</i>"))
</code>```

Title: Styling Text inside Android TextView

Body:
You can use the following example,

For Kotlin

textView.text = Html.fromHtml("<b>Hello</b> <i>World</i>")

For Java

textView.setText(Html.fromHtml("<b>Hello</b> <i>World</i>"))


问:
Most efficient way to find the index of the only '1' bit in a char variable (in C)
This is an interview question:

You are given a char variable named ch, when you know that it represents a number that in its binary form, only one of its eight bits will be equal to '1'. I.E. , the only possible values for ch are: 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80.

Given the variable ch, I need to write the most efficient code to get the index of that '1' bit. For example: if ch == 0x1 -> result is 0. if ch == 0x4 -> result is 2.

The obvious way is to use switch-case, but I need something more efficient.

Is there any bit manipulation you can do here for efficient implementation?

答:
A few methods, that are not going to be hyper efficient( depending on your definition of efficiency).

Loop and shift method.

```<code>int ch = 32
int i;
for ( i=1;ch >>i ; i++)
  printf("%i %i \n",i, ch>>i);
printf("Final index:%i\n",i-1);
</code>```

Calling math.h log2

```<code>int l=log2((double)ch);
printf("math log2:%i\n",l);
</code>```

More efficient: For a single lookup it is probably difficult to beat AnT's version. But for repeated lookups, a lookup table might  perform better.

```<code>int ltable[256]= { -1 };

void initTable()
{
  ltable[0x01]=0;
  ltable[0x02]=1;
  ltable[0x04]=2;
  ltable[0x08]=3;
  ltable[0x10]=4;
  ltable[0x20]=5;
  ltable[0x40]=6;
  ltable[0x80]=7;
}

int lookup(size_t ch)
{
  return  ltable[ch];
}
</code>```

Table init ASM

```<code>init():
  push rbp
  mov rbp, rsp
  mov DWORD PTR ltable[rip+4], 0
  mov DWORD PTR ltable[rip+8], 1
  mov DWORD PTR ltable[rip+16], 2
  mov DWORD PTR ltable[rip+32], 3
  mov DWORD PTR ltable[rip+64], 4
  mov DWORD PTR ltable[rip+128], 5
  mov DWORD PTR ltable[rip+256], 6
  mov DWORD PTR ltable[rip+512], 7
  nop
  pop rbp
  ret
</code>```

Table lookup ASM

```<code>lookup(unsigned long):
  push rbp
  mov rbp, rsp
  mov QWORD PTR [rbp-8], rdi
  mov rax, QWORD PTR [rbp-8]
  mov eax, DWORD PTR ltable[0+rax*4]
  pop rbp
  ret
</code>```

Outputs

```<code> 1 16
 2 8
 3 4
 4 2
 5 1
 Final index:5
 math log2:5
 Lookup[32]=>5
</code>```

Body:
A few methods, that are not going to be hyper efficient( depending on your definition of efficiency).

Loop and shift method.

int ch = 32
int i;
for ( i=1;ch >>i ; i++)
  printf("%i %i \n",i, ch>>i);
printf("Final index:%i\n",i-1);

Calling math.h log2

int l=log2((double)ch);
printf("math log2:%i\n",l);

More efficient: For a single lookup it is probably difficult to beat AnT's version. But for repeated lookups, a lookup table might  perform better.

int ltable[256]= { -1 };

void initTable()
{
  ltable[0x01]=0;
  ltable[0x02]=1;
  ltable[0x04]=2;
  ltable[0x08]=3;
  ltable[0x10]=4;
  ltable[0x20]=5;
  ltable[0x40]=6;
  ltable[0x80]=7;
}

int lookup(size_t ch)
{
  return  ltable[ch];
}

Table init ASM

init():
  push rbp
  mov rbp, rsp
  mov DWORD PTR ltable[rip+4], 0
  mov DWORD PTR ltable[rip+8], 1
  mov DWORD PTR ltable[rip+16], 2
  mov DWORD PTR ltable[rip+32], 3
  mov DWORD PTR ltable[rip+64], 4
  mov DWORD PTR ltable[rip+128], 5
  mov DWORD PTR ltable[rip+256], 6
  mov DWORD PTR ltable[rip+512], 7
  nop
  pop rbp
  ret

Table lookup ASM

lookup(unsigned long):
  push rbp
  mov rbp, rsp
  mov QWORD PTR [rbp-8], rdi
  mov rax, QWORD PTR [rbp-8]
  mov eax, DWORD PTR ltable[0+rax*4]
  pop rbp
  ret

Outputs

 1 16
 2 8
 3 4
 4 2
 5 1
 Final index:5
 math log2:5
 Lookup[32]=>5


问:
Chef/Ruby: Iterating through a Hash Array
I'm trying to iterate through a hash defined in my Chef attributes file and write it to a config template:

```<code>default['disk'] = node['block_device'].select { |i,j| j['state'] == 'running' && i != 'cdrom' }.select { |r| puts "Disk #{r}"}
</code>```

In my Chef template, I am calling the variable with <%= @disk %>, so all the work is being done in the attributes file variable.

The above attribute will show me the result I want when it is compiling the cookbook, but using the puts method will not write to the config template, and I come up with empty strings written instead (see below).

```<code>Compiling Cookbooks...
Disk sda
Disk sdb
Converging 7 resources
....
+    Disk "{}"
</code>```

If I remove the puts method (should not need it to write to config template), then I get the entire ['block_device'] structure (instead of just the device name) as a Disk value written to config template instead.

I've also tried playing around with using the puts method within the config template as well, but got no where. How can I write a new line in my template per key value in the array during a chef-client run? I would like to get it written to the config template instead of STDOUT during compile??

答:
Chef templates use Erb formatting do you would want to actually use that:</p>

```<code># recipe
template '/asdf' do
  # ...
  variables disks: node['block_device'].select { |i,j| j['state'] == 'running' && i != 'cdrom' }
end

# template
<%- @disk.each do |i, j| -%>
<%= i %>
<%- end -%>
</code>```

Body:
I'm trying to iterate through a hash defined in my Chef attributes file and write it to a config template:

default['disk'] = node['block_device'].select { |i,j| j['state'] == 'running' && i != 'cdrom' }.select { |r| puts "Disk #{r}"}

In my Chef template, I am calling the variable with <%= @disk %>, so all the work is being done in the attributes file variable.

The above attribute will show me the result I want when it is compiling the cookbook, but using the puts method will not write to the config template, and I come up with empty strings written instead (see below).

Compiling Cookbooks...
Disk sda
Disk sdb
Converging 7 resources
....
+    Disk "{}"

If I remove the puts method (should not need it to write to config template), then I get the entire ['block_device'] structure (instead of just the device name) as a Disk value written to config template instead.

I've also tried playing around with using the puts method within the config template as well, but got no where. How can I write a new line in my template per key value in the array during a chef-client run? I would like to get it written to the config template instead of STDOUT during compile??

Body:
Chef templates use Erb formatting do you would want to actually use that:

# recipe
template '/asdf' do
  # ...
  variables disks: node['block_device'].select { |i,j| j['state'] == 'running' && i != 'cdrom' }
end

# template
<%- @disk.each do |i, j| -%>
<%= i %>
<%- end -%>


问:
Remove horizontal bar from website without footer
I am using bootstrap frame to create a responsive website. I realized that there is a horizontal bar at the bottom of the page, which I could not get rid of. I looked up on similar answers on stackoverflow and most of them have problems with the footer. I checked mine and I have yet to set a footer and also I do not have any width of 100%. The CSS I used also did not modify the dimensions of the bootstrap elements. May I know what is wrong with my HTML code?

My stylesheet(I am using the stylesheet provided by bootstrap for carousel and a div id of section to modify the content at the bottom :

CSS

```<code>.carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
    width: 70%;
    margin: auto;
}

#section {
  padding-left: 5%;
}
</code>```

HTML

```<code><div id="container">
  <!--Slideshow-->
  <div class="jumbotron" style="background:transparent !important;">
    <div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
        <li data-target="#myCarousel" data-slide-to="3"></li>
        <li data-target="#myCarousel" data-slide-to="4"></li>
      </ol>

      <!-- Wrapper for slides -->
      <div class="carousel-inner" role="listbox">

        <div class="item active">
          <img src="Images/Swimming.jpg" alt="1" style="width:460px; height:345px">
          <div class="carousel-caption">
            <h3>Swimming</h3>
            <p>Event of Swimming</p>
          </div>
        </div>

        <div class="item">
          <img src="Images/Basketball.jpg" alt="2" style="width:460px; height:345px">
          <div class="carousel-caption">
            <h3>Basketball</h3>
            <p>Event of Basketball</p>
          </div>
        </div>

        <div class="item">
          <img src="Images/Tennis.jpg" alt="3" style="width:460px; height:345px">
          <div class="carousel-caption">
            <h3>Tennis</h3>
            <p>Event of Tennis</p>
          </div>
        </div>

        <div class="item">
          <img src="Images/Football.jpg" alt="4" width="460" height="345">
          <div class="carousel-caption">
            <h3>Football</h3>
            <p>Event of Football</p>
          </div>
        </div>

        <div class="item">
          <img src="Images/Baseball.jpg" alt="5" width="460" height="345">
          <div class="carousel-caption">
            <h3>Baseball</h3>
            <p>Event of Baseball</p>
          </div>
        </div>
      </div>

      <!-- Left and right controls -->
      <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
  </div>

  <br>

  <div class="row">
    <div class="col-sm-12 col-md-4" id="section">
      <h3>Registration for 2018</h3>
      <div id="registration" style="font-size: 20px;">
        <p>Click <a href="#">here</a> to Register
          <br /> Click <a href="#">here</a> to Register</p>
      </div>
    </div>
    <div class="col-sm-12 col-md-4" id="section">
      <h3>Announcements</h3>
      <p>s to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one
        of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
        et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in
        section 1.10.32.
      </p>
    </div>
    <div class="col-sm-12 col-md-4" id="section">
      <h3>Facebook Feed</h3>
      <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English
        versions from the 1914 translation by H. Rackham.
      </p>
    </div>
  </div>
</div>
</code>```

Below is the picture of my website with horizontal bar:

Hope that I can learn what is wrong with this.

答:
One typical cause of an unwanted horizontal scroll bar is setting negative left/right margins on an element to pull it to the edge of the viewport. The margins extend beyond the screen and force a scrollbar.

Bootstrap applies -15px margins to the left and right of .row, which is causing the horizontal scrollbar in your case.

Bootstrap's .row is designed to be used inside of .container, which has left and right padding to compensate for the negative margins. You have a containing div, but is has an id of "container", not a class, so Bootstrap is not styling it. Add the .container class to it:

```<code><div id="container" class="container">
</code>```

If you find .container's padding undesirable, you could instead hide its overflow with a custom CSS rule:

```<code>#container {
    overflow: hidden;
}
</code>```

Body:
I am using bootstrap frame to create a responsive website. I realized that there is a horizontal bar at the bottom of the page, which I could not get rid of. I looked up on similar answers on stackoverflow and most of them have problems with the footer. I checked mine and I have yet to set a footer and also I do not have any width of 100%. The CSS I used also did not modify the dimensions of the bootstrap elements. May I know what is wrong with my HTML code?

My stylesheet(I am using the stylesheet provided by bootstrap for carousel and a div id of section to modify the content at the bottom :

CSS

.carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
    width: 70%;
    margin: auto;
}

#section {
  padding-left: 5%;
}

HTML

Swimming

Event of Swimming

Basketball

Event of Basketball

Tennis

Event of Tennis

Football

Event of Football

Baseball

Event of Baseball

        Previous

        Next

Registration for 2018

Click here to Register

 Click here to Register

Announcements

s to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one
        of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
        et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in
        section 1.10.32.

Facebook Feed

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English
        versions from the 1914 translation by H. Rackham.

Below is the picture of my website with horizontal bar:

Hope that I can learn what is wrong with this.

Body:
One typical cause of an unwanted horizontal scroll bar is setting negative left/right margins on an element to pull it to the edge of the viewport. The margins extend beyond the screen and force a scrollbar.

Bootstrap applies -15px margins to the left and right of .row, which is causing the horizontal scrollbar in your case.

Bootstrap's .row is designed to be used inside of .container, which has left and right padding to compensate for the negative margins. You have a containing div, but is has an id of "container", not a class, so Bootstrap is not styling it. Add the .container class to it:

<div id="container" class="container">

If you find .container's padding undesirable, you could instead hide its overflow with a custom CSS rule:

#container {
    overflow: hidden;
}


问:
Why am i getting EXC_BAD_ACCESS (code=1, address=0x0)?
I am trying to write a program that, when given a certain price, will break it into 20s, 10s, 5s and 1s.

However, I am getting the following error: EXC_BAD_ACCESS (code=1, address=0x0)

The error shows up on the line: *tens=diff in the function.
I do not understand what is wrong!

Here is the code:

```<code>#include<stdio.h>
#include<stdlib.h>

void pay_month(int , int *, int *, int *, int *);

int main(){

int dollars, *twenties=0, *tens=0, *fives=0, *ones=0;

printf("enter amount to pay: ");
scanf("%d",&dollars);

pay_month(dollars, twenties, tens, fives, ones);

return 0;
}
void pay_month(int dollars, int *twenties, int *tens, int *fives, int
*ones){

int diff=0;
int odolls;

odolls=dollars;

while(dollars%20!=0){
    dollars=dollars-1;
    diff++;
}

*tens=diff;

*twenties=dollars/20;

diff=0;

while(*tens%10!=0){
    *tens=*tens-1;
    diff++;
}

*tens=*tens/10;

*fives=diff;

diff=0;

while(*fives%5!=0){
    *fives=*fives-1;
    diff++;
}

*ones=diff;

diff=0;

while(*ones%1!=0){
    *ones=*ones-1;
    diff++;
}

printf("in %d there is %d twentis %d tens %d fives and %d ones\n",odolls, *twenties, *tens, *fives, *ones);

}
</code>```

答:
You are dereferencing a NULL pointer.  That is, you are asking the computer to write into memory location 0.  You are not allowed to do that.

I think what you've done is used pointers without quite understanding how to obtain them.  Possibly just to stop the compiler from throwing errors.

This simple change should solve the problem:

```<code>int dollars, twenties=0, tens=0, fives=0, ones=0;

printf("enter amount to pay: ");
scanf("%d",&dollars);

pay_month(dollars, &twenties, &tens, &fives, &ones);
</code>```

Notice that none of the values in the calling function are pointers anymore.  They're just integers.  You prefix with & when passing them to pay_month.  That's the reference operator, which obtains a pointer to where the value is stored.

Now, when you dereference the tens pointer inside pay_month, you're actually accessing the same part of memory where the value tens is stored on the stack in main.

Body:
I am trying to write a program that, when given a certain price, will break it into 20s, 10s, 5s and 1s.

However, I am getting the following error: EXC_BAD_ACCESS (code=1, address=0x0)

The error shows up on the line: *tens=diff in the function.
I do not understand what is wrong!

Here is the code:

#include<stdio.h>
#include<stdlib.h>

void pay_month(int , int *, int *, int *, int *);

int main(){

int dollars, *twenties=0, *tens=0, *fives=0, *ones=0;

printf("enter amount to pay: ");
scanf("%d",&dollars);

pay_month(dollars, twenties, tens, fives, ones);

return 0;
}
void pay_month(int dollars, int *twenties, int *tens, int *fives, int
*ones){

int diff=0;
int odolls;

odolls=dollars;

while(dollars%20!=0){
    dollars=dollars-1;
    diff++;
}

*tens=diff;

*twenties=dollars/20;

diff=0;

while(*tens%10!=0){
    *tens=*tens-1;
    diff++;
}

*tens=*tens/10;

*fives=diff;

diff=0;

while(*fives%5!=0){
    *fives=*fives-1;
    diff++;
}

*ones=diff;

diff=0;

while(*ones%1!=0){
    *ones=*ones-1;
    diff++;
}

printf("in %d there is %d twentis %d tens %d fives and %d ones\n",odolls, *twenties, *tens, *fives, *ones);

}

Body:
You are dereferencing a NULL pointer.  That is, you are asking the computer to write into memory location 0.  You are not allowed to do that.

I think what you've done is used pointers without quite understanding how to obtain them.  Possibly just to stop the compiler from throwing errors.

This simple change should solve the problem:

int dollars, twenties=0, tens=0, fives=0, ones=0;

printf("enter amount to pay: ");
scanf("%d",&dollars);

pay_month(dollars, &twenties, &tens, &fives, &ones);

Notice that none of the values in the calling function are pointers anymore.  They're just integers.  You prefix with & when passing them to pay_month.  That's the reference operator, which obtains a pointer to where the value is stored.

Now, when you dereference the tens pointer inside pay_month, you're actually accessing the same part of memory where the value tens is stored on the stack in main.


问:
read/write /dev/ttySDIO0 like a file?
Need to read/write to a tty SDIO device in an user space program in using JNI in Android.
Is it possible to open the device (/dev/ttySDIO0) using fopen and read/write as a normal file?

From the terminal apps it is possible to do cat/echo to it. However I am looking for a approach which can be used in a program.

I don't see the .read operation defined in the SDIO UART driver.

Thank you.

EDIT: I am using Android Dev Phone 1 which has Android 1.6 (Linux Kernel Version 2.6.29).

答:
When I browsed the SDIO driver source from the latest Linux Kernel Version 2.6.34. It has added file_operations structure which has .read operation listed. I realized I need to upgrade the Android to resolve the issue.

Thank you all for your time, effort and answers.

OwnerDisplayName: TheCottonSilk

ContentLicense: CC BY-SA 2.5

Title: read/write /dev/ttySDIO0 like a file?


答:
What you need to do is to implement websockets, this will enable your site to implement real-time stuff. This used a pub/hub approach under the hood.

If you are using php as backend this may help you: Socketo

And for the frontend use something like jQuery Simple Websockets (which works with jQuery)

If you want to simplify the things, the easiest way to do it is using a service like Firebase which works for almost anything in real-time (this like chatting apps).

Title: Click on a button in a single browser and task should be performed in both opened browser


问:
Reading XML file line by line
I am new to go and trying to write a script to parse multiple soap responses.

Here is a snippet of the xml snippet of the xml I am trying to parse. Its a  full SOAP response but I have just included that tags I wish to parse

```<code>            <Results xsi:type="AccountUser">
                <Client>
                    <ID>72rere341</ID>
                </Client>
                <PartnerKey xsi:nil="true" />
                <PartnerProperties>
                    <Name>email</Name>
                    <Value>example1@test1.com</Value>
                </PartnerProperties>
                <ID>755454475</ID>
                <ObjectID xsi:nil="true" />
                <UserID>5fd0acfc-6crerfrgrfe6e9a675f65</UserID>
                <ActiveFlag>true</ActiveFlag>
                <Delete>0</Delete>
                <LastSuccessfulLogin>2014-11-07T16:00:46.747</LastSuccessfulLogin>
            </Results>
            <Results xsi:type="AccountUser">
                <Client>
                    <ID>72rere5341</ID>
                </Client>
                <PartnerKey xsi:nil="true" />
                <PartnerProperties>
                    <Name>email</Name>
                    <Value>example2@test1.com</Value>
                </PartnerProperties>
                <ID>7225483</ID>
                <ObjectID xsi:nil="true" />
                <UserID>example2@test1.com</UserID>
                <ActiveFlag>false</ActiveFlag>
                <Delete>0</Delete>
                <LastSuccessfulLogin>2015-04-29T05:01:27.85</LastSuccessfulLogin>
            </Results>
</code>```

I would like to print each result on a new line.

Here is a snippet of my code:

```<code>package main

import (

    "os"
    "fmt"
    "encoding/xml"
    "io/ioutil"

)

type AccountUser struct {

    ParentMID string `xml:"Client>ID"`
    EmailAddress string `xml:"PartnerProperties>Value"`
    BuinessUnit string `xml:"ID"`
    UserID string `xml:"UserID"`
    Active string`xml:"ActiveFlag"`
    LastSucessfulLogin string`xml:"LastSucessfulLogin"`

}

type Email struct {

    Email string `xml:"PartnerProperties>Value"`
}

type Query struct {
    Accounts AccountUser
    AccountList []Email `xml:"PartnerProperties>Value"`
}

func (a AccountUser) String() string {
    return fmt.Sprintf("%s - %s - %s", a.ParentMID, a.EmailAddress, a.UserID)
}

func main() {
    xmlFile, err := os.Open("Results.xml")
    if err != nil {
        fmt.Println("Error opening file:", err)
        return
    }
    defer xmlFile.Close()

    b, _ := ioutil.ReadAll(xmlFile)

    var q Query
    xml.Unmarshal(b, &q)

    fmt.Println(q.Accounts)
    for _, account := range q.AccountList {
        fmt.Printf("\t%s\n", account)
    }
}
</code>```

When I run this in terminal, It returns nothing
ie.

```<code>-     - //just the string in the function
</code>```

I would love pointers on how I can resolve this.

答:
There are some problems with your code  :

First is your xml file is not correct the correct xml file must contains parent xml like <Data> //Yourdata here </Data> it must be look like this :

```<code><?xml version="1.0" encoding="UTF-8" ?>
<Data>
    <Results>
        <Client>
            <ID>72rere341</ID>
        </Client>
        <PartnerKey xsi:nil="true" />
        <PartnerProperties>
            <Name>email</Name>
            <Value>example1@test1.com</Value>
        </PartnerProperties>
        <ID>755454475</ID>
        <ObjectID xsi:nil="true" />
        <UserID>5fd0acfc-6crerfrgrfe6e9a675f65</UserID>
        <ActiveFlag>true</ActiveFlag>
        <Delete>0</Delete>
        <LastSuccessfulLogin>2014-11-07T16:00:46.747</LastSuccessfulLogin>
    </Results>
    <Results>
        <Client>
            <ID>72rere5341</ID>
        </Client>
        <PartnerKey xsi:nil="true" />
        <PartnerProperties>
            <Name>email</Name>
            <Value>example2@test1.com</Value>
        </PartnerProperties>
        <ID>7225483</ID>
        <ObjectID xsi:nil="true" />
        <UserID>example2@test1.com</UserID>
        <ActiveFlag>false</ActiveFlag>
        <Delete>0</Delete>
        <LastSuccessfulLogin>2015-04-29T05:01:27.85</LastSuccessfulLogin>
    </Results>
</Data>
</code>```

Second your struct AccountUser has a method:

```<code>func (a AccountUser) String() string {
    return fmt.Sprintf("%s - %s - %s", a.ParentMID, a.EmailAddress, a.UserID)
}
</code>```

To fix your problem fix the your xml file, and make your String() method like this :

```<code>func (a *AccountUser) String() string {
    return ""
}
</code>```

And here is the working code that I have tried with the above xml file :

```<code>package main

import (
    "encoding/xml"
    "fmt"
    "io/ioutil"
    "log"
    "os"
)

type AccountUser struct {
    UserID              string
    ActiveFlag          string
    LastSuccessfulLogin string
    PartnerProperties   Partner `xml:"PartnerProperties"`
}

type Partner struct {
    Name  string
    Value string
}

type Query struct {
    ResultList []AccountUser `xml:"Results"`
}

func (a *AccountUser) String() string {
    return fmt.Sprintf("%s - %s - %s", a.PartnerProperties.Name, a.PartnerProperties.Value, a.UserID)
}

func main() {
    xmlFile, err := os.Open("read.xml")
    if err != nil {
        fmt.Println("Error opening file:", err)
        return
    }
    defer xmlFile.Close()

    b, err := ioutil.ReadAll(xmlFile)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("read result = ", string(b))

    var q Query
    err = xml.Unmarshal(b, &q)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(q.ResultList[0].String())
}
</code>```

Title: Reading XML file line by line

Body:
I am new to go and trying to write a script to parse multiple soap responses.

Here is a snippet of the xml snippet of the xml I am trying to parse. Its a  full SOAP response but I have just included that tags I wish to parse

            <Results xsi:type="AccountUser">
                <Client>
                    <ID>72rere341</ID>
                </Client>
                <PartnerKey xsi:nil="true" />
                <PartnerProperties>
                    <Name>email</Name>
                    <Value>example1@test1.com</Value>
                </PartnerProperties>
                <ID>755454475</ID>
                <ObjectID xsi:nil="true" />
                <UserID>5fd0acfc-6crerfrgrfe6e9a675f65</UserID>
                <ActiveFlag>true</ActiveFlag>
                <Delete>0</Delete>
                <LastSuccessfulLogin>2014-11-07T16:00:46.747</LastSuccessfulLogin>
            </Results>
            <Results xsi:type="AccountUser">
                <Client>
                    <ID>72rere5341</ID>
                </Client>
                <PartnerKey xsi:nil="true" />
                <PartnerProperties>
                    <Name>email</Name>
                    <Value>example2@test1.com</Value>
                </PartnerProperties>
                <ID>7225483</ID>
                <ObjectID xsi:nil="true" />
                <UserID>example2@test1.com</UserID>
                <ActiveFlag>false</ActiveFlag>
                <Delete>0</Delete>
                <LastSuccessfulLogin>2015-04-29T05:01:27.85</LastSuccessfulLogin>
            </Results>

I would like to print each result on a new line.

Here is a snippet of my code:

package main

import (

    "os"
    "fmt"
    "encoding/xml"
    "io/ioutil"

)

type AccountUser struct {

    ParentMID string `xml:"Client>ID"`
    EmailAddress string `xml:"PartnerProperties>Value"`
    BuinessUnit string `xml:"ID"`
    UserID string `xml:"UserID"`
    Active string`xml:"ActiveFlag"`
    LastSucessfulLogin string`xml:"LastSucessfulLogin"`

}

type Email struct {

    Email string `xml:"PartnerProperties>Value"`
}

type Query struct {
    Accounts AccountUser
    AccountList []Email `xml:"PartnerProperties>Value"`
}

func (a AccountUser) String() string {
    return fmt.Sprintf("%s - %s - %s", a.ParentMID, a.EmailAddress, a.UserID)
}

func main() {
    xmlFile, err := os.Open("Results.xml")
    if err != nil {
        fmt.Println("Error opening file:", err)
        return
    }
    defer xmlFile.Close()

    b, _ := ioutil.ReadAll(xmlFile)

    var q Query
    xml.Unmarshal(b, &q)

    fmt.Println(q.Accounts)
    for _, account := range q.AccountList {
        fmt.Printf("\t%s\n", account)
    }
}

When I run this in terminal, It returns nothing
ie.

-     - //just the string in the function

I would love pointers on how I can resolve this.

Body:
There are some problems with your code  :

First is your xml file is not correct the correct xml file must contains parent xml like <Data> //Yourdata here </Data> it must be look like this :

<?xml version="1.0" encoding="UTF-8" ?>
<Data>
    <Results>
        <Client>
            <ID>72rere341</ID>
        </Client>
        <PartnerKey xsi:nil="true" />
        <PartnerProperties>
            <Name>email</Name>
            <Value>example1@test1.com</Value>
        </PartnerProperties>
        <ID>755454475</ID>
        <ObjectID xsi:nil="true" />
        <UserID>5fd0acfc-6crerfrgrfe6e9a675f65</UserID>
        <ActiveFlag>true</ActiveFlag>
        <Delete>0</Delete>
        <LastSuccessfulLogin>2014-11-07T16:00:46.747</LastSuccessfulLogin>
    </Results>
    <Results>
        <Client>
            <ID>72rere5341</ID>
        </Client>
        <PartnerKey xsi:nil="true" />
        <PartnerProperties>
            <Name>email</Name>
            <Value>example2@test1.com</Value>
        </PartnerProperties>
        <ID>7225483</ID>
        <ObjectID xsi:nil="true" />
        <UserID>example2@test1.com</UserID>
        <ActiveFlag>false</ActiveFlag>
        <Delete>0</Delete>
        <LastSuccessfulLogin>2015-04-29T05:01:27.85</LastSuccessfulLogin>
    </Results>
</Data>

Second your struct AccountUser has a method:

func (a AccountUser) String() string {
    return fmt.Sprintf("%s - %s - %s", a.ParentMID, a.EmailAddress, a.UserID)
}

To fix your problem fix the your xml file, and make your String() method like this :

func (a *AccountUser) String() string {
    return ""
}

And here is the working code that I have tried with the above xml file :

package main

import (
    "encoding/xml"
    "fmt"
    "io/ioutil"
    "log"
    "os"
)

type AccountUser struct {
    UserID              string
    ActiveFlag          string
    LastSuccessfulLogin string
    PartnerProperties   Partner `xml:"PartnerProperties"`
}

type Partner struct {
    Name  string
    Value string
}

type Query struct {
    ResultList []AccountUser `xml:"Results"`
}

func (a *AccountUser) String() string {
    return fmt.Sprintf("%s - %s - %s", a.PartnerProperties.Name, a.PartnerProperties.Value, a.UserID)
}

func main() {
    xmlFile, err := os.Open("read.xml")
    if err != nil {
        fmt.Println("Error opening file:", err)
        return
    }
    defer xmlFile.Close()

    b, err := ioutil.ReadAll(xmlFile)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("read result = ", string(b))

    var q Query
    err = xml.Unmarshal(b, &q)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(q.ResultList[0].String())
}


问:
How to feed a list of unquoted column names into `lapply` (so that I can use it with a `dplyr` function)
I am trying to write a function in tidyverse/dplyr that I want to eventually use with lapply (or map). (I had been working on it to answer this question, but came upon an interesting result/dead-end. Please don't mark this as a duplicate - this question is an extension/departure from the answers that you see there.)

Is there

1) a way to get a list of quoted variables to work inside a dplyr function

(and not use the deprecated SE_ functions)  or is there

2) some way to feed a list of unquoted strings through an lapply or map

I have used the Programming in Dplyr vignette to construct what I believe is a function most in line with the current standard
for working with the NSE.

The sample data:

```<code>sample_data <-
    read.table(text = "REVENUEID AMOUNT  YEAR REPORT_CODE PAYMENT_METHOD INBOUND_CHANNEL  AMOUNT_CAT
               1 rev-24985629     30  FY18           S          Check            Mail     25,50
               2 rev-22812413      1  FY16           Q          Other      Canvassing   0.01,10
               3 rev-23508794    100  FY17           Q    Credit_card             Web   100,250
               4 rev-23506121    300  FY17           S    Credit_card            Mail   250,500
               5 rev-23550444    100  FY17           S    Credit_card             Web   100,250
               6 rev-21508672     25  FY14           J          Check            Mail     25,50
               7 rev-24981769    500  FY18           S    Credit_card             Web 500,1e+03
               8 rev-23503684     50  FY17           R          Check            Mail     50,75
               9 rev-24982087     25  FY18           R          Check            Mail     25,50
               10 rev-24979834     50  FY18           R    Credit_card             Web    50,75
                      ", header = TRUE, stringsAsFactors = FALSE)
</code>```

A report generating function

```<code>report <- function(report_cat){
    report_cat <- enquo(report_cat)
    sample_data %>%
    group_by(!!report_cat, YEAR) %>%
    summarize(num=n(),total=sum(AMOUNT)) %>%
    rename(REPORT_VALUE = !!report_cat) %>%
    mutate(REPORT_CATEGORY := as.character(quote(!!report_cat))[2])
}
</code>```

Which works fine for generating a single report:

```<code>> report(REPORT_CODE)
# A tibble: 7 x 5
# Groups:   REPORT_VALUE [4]
  REPORT_VALUE  YEAR   num total REPORT_CATEGORY
         <chr> <chr> <int> <int>           <chr>
1            J  FY14     1    25     REPORT_CODE
2            Q  FY16     1     1     REPORT_CODE
3            Q  FY17     1   100     REPORT_CODE
4            R  FY17     1    50     REPORT_CODE
5            R  FY18     2    75     REPORT_CODE
6            S  FY17     2   400     REPORT_CODE
7            S  FY18     2   530     REPORT_CODE
</code>```

It is when I try and set up a list of all 4 of the reports to generate, that everything breaks down. (Though admittedly the code required in that last line of the function - to return a string with which to then fill the column - should be clue enough that I have wandered off in the wrong direction.)

```<code>#the other reports
cat.list <- c("REPORT_CODE","PAYMENT_METHOD","INBOUND_CHANNEL","AMOUNT_CAT")

# Applying and Mapping attempts
lapply(cat.list, report)
map_df(cat.list, report)
</code>```

Which results in:

```<code>> lapply(cat.list, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated

> map_df(cat.list, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated
</code>```

I have also tried to convert the list of strings to names before handing it over to apply and map:

```<code>library(rlang)
cat.names <- lapply(cat.list, sym)
lapply(cat.names, report)
map_df(cat.names, report)
</code>```

```<code>> lapply(cat.names, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated
> map_df(cat.names, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated
</code>```

In any case, the reason I am asking this question is that I think that I have written the function to the currently documented standards, but ultimately I can then see no way to utilize a member of the apply or even of the purrr::map family with such a function. Short of rewriting the function to use names like useR has done here https://stackoverflow.com/a/47316151/5088194 is there a way to get this function to work with apply or map?

I am hoping to see this as a result:

```<code># A tibble: 27 x 5
# Groups:   REPORT_VALUE [16]
   REPORT_VALUE  YEAR   num total REPORT_CATEGORY
          <chr> <chr> <int> <int>           <chr>
 1            J  FY14     1    25     REPORT_CODE
 2            Q  FY16     1     1     REPORT_CODE
 3            Q  FY17     1   100     REPORT_CODE
 4            R  FY17     1    50     REPORT_CODE
 5            R  FY18     2    75     REPORT_CODE
 6            S  FY17     2   400     REPORT_CODE
 7            S  FY18     2   530     REPORT_CODE
 8        Check  FY14     1    25  PAYMENT_METHOD
 9        Check  FY17     1    50  PAYMENT_METHOD
10        Check  FY18     2    55  PAYMENT_METHOD
# ... with 17 more rows
</code>```

答:
Let me first point out that in your initial report function, you can use quo_name to convert the quosure into a string, which you can then use in mutate like the following:

```<code>library(dplyr)
library(rlang)

report <- function(report_cat){
  report_cat <- enquo(report_cat)

  sample_data %>%
    group_by(!!report_cat, YEAR) %>%
    summarize(num=n(),total=sum(AMOUNT)) %>%
    rename(REPORT_VALUE = !!report_cat) %>%
    mutate(REPORT_CATEGORY = quo_name(report_cat))
}

report(REPORT_CODE)
</code>```

Now, to address your question of "how to feed a list of unquoted strings through lapply or map to make it work inside dplyr functions", I propose two ways of doing it.

1. Use rlang::sym to parse your strings and unquote it when feeding into lapply or map

```<code>library(purrr)

cat.list <- c("REPORT_CODE","PAYMENT_METHOD","INBOUND_CHANNEL","AMOUNT_CAT")

map_df(cat.list, ~report(!!sym(.)))
</code>```

or with syms you can parse all elements of a vector at once:

```<code>map_df(syms(cat.list), ~report(!!.))
</code>```

Result:

```<code># A tibble: 27 x 5
# Groups:   REPORT_VALUE [16]
   REPORT_VALUE  YEAR   num total REPORT_CATEGORY
          <chr> <chr> <int> <int>           <chr>
 1            J  FY14     1    25     REPORT_CODE
 2            Q  FY16     1     1     REPORT_CODE
 3            Q  FY17     1   100     REPORT_CODE
 4            R  FY17     1    50     REPORT_CODE
 5            R  FY18     2    75     REPORT_CODE
 6            S  FY17     2   400     REPORT_CODE
 7            S  FY18     2   530     REPORT_CODE
 8        Check  FY14     1    25  PAYMENT_METHOD
 9        Check  FY17     1    50  PAYMENT_METHOD
10        Check  FY18     2    55  PAYMENT_METHOD
# ... with 17 more rows
</code>```

2. Rewrite your report function by placing lapply or map inside so that report can do NSE

```<code>report <- function(...){
  report_cat <- quos(...)

  map_df(report_cat, function(x) sample_data %>%
             group_by(!!x, YEAR) %>%
             summarize(num=n(),total=sum(AMOUNT)) %>%
             rename(REPORT_VALUE = !!x) %>%
             mutate(REPORT_CATEGORY = quo_name(x)))
}
</code>```

By placing map_df inside report, you can take advantage of quos, which converts ... to list of quosures. They are then fed into map_df and unquoted one by one using !!.

```<code>report(REPORT_CODE, PAYMENT_METHOD, INBOUND_CHANNEL, AMOUNT_CAT)
</code>```

Another advantage of writing it like this is that you can also supply a vector of string symbols and splice them using !!! like the following:

```<code>report(!!!syms(cat.list))
</code>```

Result:

```<code># A tibble: 27 x 5
# Groups:   REPORT_VALUE [16]
   REPORT_VALUE  YEAR   num total REPORT_CATEGORY
          <chr> <chr> <int> <int>           <chr>
 1            J  FY14     1    25     REPORT_CODE
 2            Q  FY16     1     1     REPORT_CODE
 3            Q  FY17     1   100     REPORT_CODE
 4            R  FY17     1    50     REPORT_CODE
 5            R  FY18     2    75     REPORT_CODE
 6            S  FY17     2   400     REPORT_CODE
 7            S  FY18     2   530     REPORT_CODE
 8        Check  FY14     1    25  PAYMENT_METHOD
 9        Check  FY17     1    50  PAYMENT_METHOD
10        Check  FY18     2    55  PAYMENT_METHOD
# ... with 17 more rows
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to write a function in tidyverse/dplyr that I want to eventually use with lapply (or map). (I had been working on it to answer this question, but came upon an interesting result/dead-end. Please don't mark this as a duplicate - this question is an extension/departure from the answers that you see there.)

Is there

1) a way to get a list of quoted variables to work inside a dplyr function

(and not use the deprecated SE_ functions)  or is there

2) some way to feed a list of unquoted strings through an lapply or map

I have used the Programming in Dplyr vignette to construct what I believe is a function most in line with the current standard
for working with the NSE.

The sample data:

sample_data <-
    read.table(text = "REVENUEID AMOUNT  YEAR REPORT_CODE PAYMENT_METHOD INBOUND_CHANNEL  AMOUNT_CAT
               1 rev-24985629     30  FY18           S          Check            Mail     25,50
               2 rev-22812413      1  FY16           Q          Other      Canvassing   0.01,10
               3 rev-23508794    100  FY17           Q    Credit_card             Web   100,250
               4 rev-23506121    300  FY17           S    Credit_card            Mail   250,500
               5 rev-23550444    100  FY17           S    Credit_card             Web   100,250
               6 rev-21508672     25  FY14           J          Check            Mail     25,50
               7 rev-24981769    500  FY18           S    Credit_card             Web 500,1e+03
               8 rev-23503684     50  FY17           R          Check            Mail     50,75
               9 rev-24982087     25  FY18           R          Check            Mail     25,50
               10 rev-24979834     50  FY18           R    Credit_card             Web    50,75
                      ", header = TRUE, stringsAsFactors = FALSE)

A report generating function

report <- function(report_cat){
    report_cat <- enquo(report_cat)
    sample_data %>%
    group_by(!!report_cat, YEAR) %>%
    summarize(num=n(),total=sum(AMOUNT)) %>%
    rename(REPORT_VALUE = !!report_cat) %>%
    mutate(REPORT_CATEGORY := as.character(quote(!!report_cat))[2])
}

Which works fine for generating a single report:

> report(REPORT_CODE)
# A tibble: 7 x 5
# Groups:   REPORT_VALUE [4]
  REPORT_VALUE  YEAR   num total REPORT_CATEGORY
         <chr> <chr> <int> <int>           <chr>
1            J  FY14     1    25     REPORT_CODE
2            Q  FY16     1     1     REPORT_CODE
3            Q  FY17     1   100     REPORT_CODE
4            R  FY17     1    50     REPORT_CODE
5            R  FY18     2    75     REPORT_CODE
6            S  FY17     2   400     REPORT_CODE
7            S  FY18     2   530     REPORT_CODE

It is when I try and set up a list of all 4 of the reports to generate, that everything breaks down. (Though admittedly the code required in that last line of the function - to return a string with which to then fill the column - should be clue enough that I have wandered off in the wrong direction.)

#the other reports
cat.list <- c("REPORT_CODE","PAYMENT_METHOD","INBOUND_CHANNEL","AMOUNT_CAT")

# Applying and Mapping attempts
lapply(cat.list, report)
map_df(cat.list, report)

Which results in:

> lapply(cat.list, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated

> map_df(cat.list, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated

I have also tried to convert the list of strings to names before handing it over to apply and map:

library(rlang)
cat.names <- lapply(cat.list, sym)
lapply(cat.names, report)
map_df(cat.names, report)

> lapply(cat.names, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated
> map_df(cat.names, report)
 Error in (function (x, strict = TRUE)  :
  the argument has already been evaluated

In any case, the reason I am asking this question is that I think that I have written the function to the currently documented standards, but ultimately I can then see no way to utilize a member of the apply or even of the purrr::map family with such a function. Short of rewriting the function to use names like useR has done here https://stackoverflow.com/a/47316151/5088194 is there a way to get this function to work with apply or map?

I am hoping to see this as a result:

# A tibble: 27 x 5
# Groups:   REPORT_VALUE [16]
   REPORT_VALUE  YEAR   num total REPORT_CATEGORY
          <chr> <chr> <int> <int>           <chr>
 1            J  FY14     1    25     REPORT_CODE
 2            Q  FY16     1     1     REPORT_CODE
 3            Q  FY17     1   100     REPORT_CODE
 4            R  FY17     1    50     REPORT_CODE
 5            R  FY18     2    75     REPORT_CODE
 6            S  FY17     2   400     REPORT_CODE
 7            S  FY18     2   530     REPORT_CODE
 8        Check  FY14     1    25  PAYMENT_METHOD
 9        Check  FY17     1    50  PAYMENT_METHOD
10        Check  FY18     2    55  PAYMENT_METHOD
# ... with 17 more rows

Body:
Let me first point out that in your initial report function, you can use quo_name to convert the quosure into a string, which you can then use in mutate like the following:

library(dplyr)
library(rlang)

report <- function(report_cat){
  report_cat <- enquo(report_cat)

  sample_data %>%
    group_by(!!report_cat, YEAR) %>%
    summarize(num=n(),total=sum(AMOUNT)) %>%
    rename(REPORT_VALUE = !!report_cat) %>%
    mutate(REPORT_CATEGORY = quo_name(report_cat))
}

report(REPORT_CODE)

Now, to address your question of "how to feed a list of unquoted strings through lapply or map to make it work inside dplyr functions", I propose two ways of doing it.

1. Use rlang::sym to parse your strings and unquote it when feeding into lapply or map

library(purrr)

cat.list <- c("REPORT_CODE","PAYMENT_METHOD","INBOUND_CHANNEL","AMOUNT_CAT")

map_df(cat.list, ~report(!!sym(.)))

or with syms you can parse all elements of a vector at once:

map_df(syms(cat.list), ~report(!!.))

Result:

# A tibble: 27 x 5
# Groups:   REPORT_VALUE [16]
   REPORT_VALUE  YEAR   num total REPORT_CATEGORY
          <chr> <chr> <int> <int>           <chr>
 1            J  FY14     1    25     REPORT_CODE
 2            Q  FY16     1     1     REPORT_CODE
 3            Q  FY17     1   100     REPORT_CODE
 4            R  FY17     1    50     REPORT_CODE
 5            R  FY18     2    75     REPORT_CODE
 6            S  FY17     2   400     REPORT_CODE
 7            S  FY18     2   530     REPORT_CODE
 8        Check  FY14     1    25  PAYMENT_METHOD
 9        Check  FY17     1    50  PAYMENT_METHOD
10        Check  FY18     2    55  PAYMENT_METHOD
# ... with 17 more rows

2. Rewrite your report function by placing lapply or map inside so that report can do NSE

report <- function(...){
  report_cat <- quos(...)

  map_df(report_cat, function(x) sample_data %>%
             group_by(!!x, YEAR) %>%
             summarize(num=n(),total=sum(AMOUNT)) %>%
             rename(REPORT_VALUE = !!x) %>%
             mutate(REPORT_CATEGORY = quo_name(x)))
}

By placing map_df inside report, you can take advantage of quos, which converts ... to list of quosures. They are then fed into map_df and unquoted one by one using !!.

report(REPORT_CODE, PAYMENT_METHOD, INBOUND_CHANNEL, AMOUNT_CAT)

Another advantage of writing it like this is that you can also supply a vector of string symbols and splice them using !!! like the following:

report(!!!syms(cat.list))

Result:

# A tibble: 27 x 5
# Groups:   REPORT_VALUE [16]
   REPORT_VALUE  YEAR   num total REPORT_CATEGORY
          <chr> <chr> <int> <int>           <chr>
 1            J  FY14     1    25     REPORT_CODE
 2            Q  FY16     1     1     REPORT_CODE
 3            Q  FY17     1   100     REPORT_CODE
 4            R  FY17     1    50     REPORT_CODE
 5            R  FY18     2    75     REPORT_CODE
 6            S  FY17     2   400     REPORT_CODE
 7            S  FY18     2   530     REPORT_CODE
 8        Check  FY14     1    25  PAYMENT_METHOD
 9        Check  FY17     1    50  PAYMENT_METHOD
10        Check  FY18     2    55  PAYMENT_METHOD
# ... with 17 more rows


问:
Is it possible to connect to mysql from the library so?
When writing one of my first plugins for an external application I encountered a large obstruction.
Plugins are loaded as DLL files (SO for linux)
Attempts to connect to the database, but it requires some other compilation.
Everywhere write that it is necessary to compile applications using a given command:

```<code>gcc exa_7.c -o exa_7 -std=c99  `mysql_config --cflags --libs'
</code>```

The command is the most correct, but I can't combine to the attributes: -c -fPIC

When I try to fire code without passing the attributes necessary for MYSQL, it causes me a lot of errors:

```<code>dllmain.c:46:5: error: unknown type name ‘MYSQL’; did you mean ‘MYSQL_XID’?
     MYSQL      *MySQLConRet;
     ^~~~~
     MYSQL_XID
dllmain.c:47:5: error: unknown type name ‘MYSQL’; did you mean ‘MYSQL_XID’?
     MYSQL      *MySQLConnection = NULL;
     ^~~~~
     MYSQL_XID
dllmain.c:74:5: error: unknown type name ‘MYSQL_RES’; did you mean ‘MYSQL_XID’?
     MYSQL_RES      *mysqlResult = NULL;
     ^~~~~~~~~
     MYSQL_XID
dllmain.c:90:6: error: unknown type name ‘MYSQL_ROW’; did you mean ‘MYSQL_XID’?
      MYSQL_ROW       mysqlRow;
      ^~~~~~~~~
      MYSQL_XID
dllmain.c:91:6: error: unknown type name ‘MYSQL_FIELD’; did you mean ‘MYSQL_XID’?
      MYSQL_FIELD    *mysqlFields;
      ^~~~~~~~~~~
      MYSQL_XID
</code>```

My list includes:

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <mysql/mysql.h>
#include <mysql/my_global.h>
#include <mysql/my_config.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "ts3_functions.h"
#include "plugin.h"
#include <pthread.h>
//(more includes, but not important)
</code>```

Do you have any idea how to solve this?

//EDIT:
delete comment for #include <mysql/mysql.h>

Now I compiled it with the command: gcc -pthread -c -fPIC -o test.o dllmain.c

The compilation runs correctly (without any errors), but when running the program gets the message:undefined symbol: mysql_init

Maybe problem is in code?:

```<code>MYSQL      *MySQLConRet;
MYSQL      *MySQLConnection = NULL;

MySQLConnection = mysql_init( NULL );
MySQLConRet = mysql_real_connect( MySQLConnection,
                                  hostName,
                                  userId,
                                  password,
                                  DB,
                                  0,
                                  NULL,
                                  0 );

if ( MySQLConRet == NULL ) {
    printf(mysql_error(MySQLConnection) );
    exit(1);
}
</code>```

答: You haven't included <mysql/mysql.h>. Uncomment that line. This file is required to use the MySQL API. <mysql/my_global.h> is an internal header used to include common system header files and define utility macros -- it is not a substitute for <mysql/mysql.h>, and should not be included directly at all.

Body:
When writing one of my first plugins for an external application I encountered a large obstruction.
Plugins are loaded as DLL files (SO for linux)
Attempts to connect to the database, but it requires some other compilation.
Everywhere write that it is necessary to compile applications using a given command:

gcc exa_7.c -o exa_7 -std=c99  `mysql_config --cflags --libs'

The command is the most correct, but I can't combine to the attributes: -c -fPIC

When I try to fire code without passing the attributes necessary for MYSQL, it causes me a lot of errors:

dllmain.c:46:5: error: unknown type name ‘MYSQL’; did you mean ‘MYSQL_XID’?
     MYSQL      *MySQLConRet;
     ^~~~~
     MYSQL_XID
dllmain.c:47:5: error: unknown type name ‘MYSQL’; did you mean ‘MYSQL_XID’?
     MYSQL      *MySQLConnection = NULL;
     ^~~~~
     MYSQL_XID
dllmain.c:74:5: error: unknown type name ‘MYSQL_RES’; did you mean ‘MYSQL_XID’?
     MYSQL_RES      *mysqlResult = NULL;
     ^~~~~~~~~
     MYSQL_XID
dllmain.c:90:6: error: unknown type name ‘MYSQL_ROW’; did you mean ‘MYSQL_XID’?
      MYSQL_ROW       mysqlRow;
      ^~~~~~~~~
      MYSQL_XID
dllmain.c:91:6: error: unknown type name ‘MYSQL_FIELD’; did you mean ‘MYSQL_XID’?
      MYSQL_FIELD    *mysqlFields;
      ^~~~~~~~~~~
      MYSQL_XID

My list includes:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <mysql/mysql.h>
#include <mysql/my_global.h>
#include <mysql/my_config.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "ts3_functions.h"
#include "plugin.h"
#include <pthread.h>
//(more includes, but not important)

Do you have any idea how to solve this?

//EDIT:
delete comment for #include <mysql/mysql.h>

Now I compiled it with the command: gcc -pthread -c -fPIC -o test.o dllmain.c

The compilation runs correctly (without any errors), but when running the program gets the message:undefined symbol: mysql_init

Maybe problem is in code?:

MYSQL      *MySQLConRet;
MYSQL      *MySQLConnection = NULL;

MySQLConnection = mysql_init( NULL );
MySQLConRet = mysql_real_connect( MySQLConnection,
                                  hostName,
                                  userId,
                                  password,
                                  DB,
                                  0,
                                  NULL,
                                  0 );

if ( MySQLConRet == NULL ) {
    printf(mysql_error(MySQLConnection) );
    exit(1);
}


答:
Here is another solution:

```<code>import re
line="[99]  nodeId=99    uptime=31987895     BarC=1.15     sensorVal=226 -"
print [float(_) for _ in (re.findall(pattern="=([\d\.]+)", string=line)[-2:])]
</code>```

output:
[1.15, 226.0]

to get values in variables:

```<code>(a, b) = (float(_) for _ in (re.findall(pattern="=([\d\.]+)", string=line)[-2:]))
print a, b
</code>```

output:
1.15 226.0

Title: Parse string with Python and pull numbers for simple math

Body:
I am running "Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2" on Ubuntu.

I have a line as follows from serial:

line="[99]  nodeId=99    uptime=31987895     BarC=1.15     sensorVal=226 -"

and wish to parse this. I need to extract 1.15 and 226 as numbers so I can do math with those numbers.

I have used the following python code:

pressure=line.split()[3].split("=")[1:2]
print(pressure)

This prints this:

['1.15']

How do I get rid of the  ' ' (apostrophes) and the  [  ]  and turn this into something I can do simple math with. A floating number will be fine.

Here is more output:

Listening at 868 Mhz...
[99]  nodeId=99    uptime=48743987     BarC=1.19     sensorVal=229 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48745052     BarC=1.19     sensorVal=229
[99]  nodeId=99    uptime=48527151     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48528216     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48529276     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48530341     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48531402     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48532467     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48533528     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48534594     BarC=1.20     sensorVal=230
[99]  nodeId=99    uptime=48535655     BarC=1.20     sensorVal=230 - ACK sent. Sending packet to node 99 - waiting for ACK...nothing...
[99]  nodeId=99    uptime=48536720     BarC=1.20     sen**

Body:
Here is another solution:

import re
line="[99]  nodeId=99    uptime=31987895     BarC=1.15     sensorVal=226 -"
print [float(_) for _ in (re.findall(pattern="=([\d\.]+)", string=line)[-2:])]

output:
[1.15, 226.0]

to get values in variables:

(a, b) = (float(_) for _ in (re.findall(pattern="=([\d\.]+)", string=line)[-2:]))
print a, b

output:
1.15 226.0


问:
Playing uploaded video with Django
I am not able to play video on my Django website. I think something is wrong in my views.py render function

videoplay.html:

```<code>{% block contents %}
  <video name='demo' controls autoplay width='50%' height='40%'>
    <source src="{{STATIC_URL}}sample1.mp4" type="video/mp4"></source>
  </video>
{% endblock %}
</code>```

Included this in  settings.py:

```<code> STATIC_URL = '/static/'
 STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
 MEDIA_URL = '/media/'
 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')`
</code>```

Views.py is:

```<code> from django.shortcuts import render, redirect
 from django.conf import settings
 from django.core.files.storage import FileSystemStorage
 from django.views.generic.base import TemplateView
 from uploads.core.models import Document
 from uploads.core.forms import DocumentForm
  def index(request):
     return render(request, "core/videoplay.html")`
</code>```

I am getting a play button and streaming line on my website

答:
The STATIC_URL is where your static files are located such as CSS, Template Images, Javascript etc. There is a special Template Tag for Static Files in Django called {% static %}.

To generate the full url to where the static files are located, you use the template tag like this:

```<code>{% load static %}
<video src="{% static "/videos/demo.mp4" %}">
</code>```

The MEDIA_URL is where your media files are located. Media files are uploaded files that change during the applications lifetime. They are not necessarily there at deployment but can be uploaded at any time by users or admins on the website.

Media files are set as fields on the model like this:

```<code>class DemoVideo(models.Model):
    video = models.FileField(upload_to="videos")
</code>```

They are accessed like this demovideo.video.url so in your template it would be src="{{demovideo.video.url}}.

Check if your file is a media or static file, and access it in the template in the correct way described above.

Title: Playing uploaded video with Django

Body:
I am not able to play video on my Django website. I think something is wrong in my views.py render function

videoplay.html:

{% block contents %}
  <video name='demo' controls autoplay width='50%' height='40%'>
    <source src="{{STATIC_URL}}sample1.mp4" type="video/mp4"></source>
  </video>
{% endblock %}

Included this in  settings.py:

 STATIC_URL = '/static/'
 STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
 MEDIA_URL = '/media/'
 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')`

Views.py is:

 from django.shortcuts import render, redirect
 from django.conf import settings
 from django.core.files.storage import FileSystemStorage
 from django.views.generic.base import TemplateView
 from uploads.core.models import Document
 from uploads.core.forms import DocumentForm
  def index(request):
     return render(request, "core/videoplay.html")`

I am getting a play button and streaming line on my website

Body:
The STATIC_URL is where your static files are located such as CSS, Template Images, Javascript etc. There is a special Template Tag for Static Files in Django called {% static %}.

To generate the full url to where the static files are located, you use the template tag like this:

{% load static %}
<video src="{% static "/videos/demo.mp4" %}">

The MEDIA_URL is where your media files are located. Media files are uploaded files that change during the applications lifetime. They are not necessarily there at deployment but can be uploaded at any time by users or admins on the website.

Media files are set as fields on the model like this:

class DemoVideo(models.Model):
    video = models.FileField(upload_to="videos")

They are accessed like this demovideo.video.url so in your template it would be src="{{demovideo.video.url}}.

Check if your file is a media or static file, and access it in the template in the correct way described above.


问:
javascript three dots syntax
I'm using Vuetify for a vue app, in this file I saw a very strange syntax which I can't find what it is

on line 38:

```<code>const data = {
    attrs: { disabled: this.disabled },
    class: this.classes,
    props: {},
    directives: [{
      name: 'ripple',
      value: this.ripple || false
    }],
    on: {
      ...(this.$listeners || {}),  // <<<---- here
      click: this.click
    }
  }
</code>```

can anyone tell what is that three dots? any articles about this would be nice

thanks

答: it's a spread operator, which is used in ES6 for both objects and arrays in Javascript. Here, the returned value of (this.$listeners || {}) is extracted. This returned value, combined with click: this.click is added into another empty object, following the "on: "</p>

Title: javascript three dots syntax

Body:
I'm using Vuetify for a vue app, in this file I saw a very strange syntax which I can't find what it is

on line 38:

const data = {
    attrs: { disabled: this.disabled },
    class: this.classes,
    props: {},
    directives: [{
      name: 'ripple',
      value: this.ripple || false
    }],
    on: {
      ...(this.$listeners || {}),  // <<<---- here
      click: this.click
    }
  }

can anyone tell what is that three dots? any articles about this would be nice

thanks