问:
Combining Union results with duplicate lines
I have the below SQL Query:

```<code>SELECT qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period,
 tblPeriod_Lookup.PL_ID, Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success,
 Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM
(
 (
  ( tblFMS_Data INNER JOIN qryRef_Routes_tbl ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID )
    INNER JOIN tblRCM_II_Assets ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Number
  )
  INNER JOIN tblPeriod_Lookup ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
   AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
)
INNER JOIN qryRef_Detectable_Failure_Valid_Combo ON tblFMS_Data.FM_Component2 = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp1_ID
GROUP BY qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period, tblPeriod_Lookup.PL_ID
HAVING
(
 (
  tblPeriod_Lookup.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And
  ([Forms]![frmMainMenu]![PriorPeriodID]-12)
  )
)
UNION
SELECT qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period,
 tblPeriod_Lookup.PL_ID, Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success,
 Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM
(
 (
  ( tblFMS_Data INNER JOIN qryRef_Routes_tbl ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID)
    INNER JOIN tblRCM_II_Assets ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Pway_Number
  )
  INNER JOIN tblPeriod_Lookup ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
   AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
)
INNER JOIN qryRef_Detectable_Failure_Valid_Combo ON tblFMS_Data.FM_Component2 = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp1_ID
GROUP BY qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period, tblPeriod_Lookup.PL_ID
HAVING
(
 (
   tblPeriod_Lookup.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And [Forms]![frmMainMenu]![PriorPeriodID]-12
  )
);
</code>```

The results from this are duplicated.  I want the results of the duplicated lines to be combined.

Note the Join queries are slightly different in the 2 queries being Union'd

答:
maybe you mean combine the results of the unions on the aggregates...

```<code>SELECT sub.Ref_Route_Name
     , sub.Ref_Route_ID
     , sub.FM_FinYear
     , sub.FM_Period
     , sub.PL_ID
     , Sum(sub.Success) as Success
     , Sum(sub.CountPrevent) as countPrevent
FROM (
SELECT qryRef_Routes_tbl.Ref_Route_Name
     , qryRef_Routes_tbl.Ref_Route_ID
     , tblFMS_Data.FM_FinYear
     , tblFMS_Data.FM_Period
     , tblPeriod_Lookup.PL_ID
     , Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success
     , Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM tblFMS_Data
INNER JOIN qryRef_Routes_tbl
  ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID
INNER JOIN tblRCM_II_Assets
  ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Number
INNER JOIN tblPeriod_Lookup PL
  ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
 AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
INNER JOIN qryRef_Detectable_Failure_Valid_Combo  rdfvc
  ON tblFMS_Data.FM_Component2 = rdfvc.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = rdfvc.Ref_Fault_Comp1_ID
WHERE PL.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And[Forms]![frmMainMenu]![PriorPeriodID]-12
GROUP BY qryRef_Routes_tbl.Ref_Route_Name
    , qryRef_Routes_tbl.Ref_Route_ID
    , tblFMS_Data.FM_FinYear
    , tblFMS_Data.FM_Period, tblPeriod_Lookup.PL_ID
UNION ALL
SELECT qryRef_Routes_tbl.Ref_Route_Name
     , qryRef_Routes_tbl.Ref_Route_ID
     , tblFMS_Data.FM_FinYear
     , tblFMS_Data.FM_Period
     , tblPeriod_Lookup.PL_ID
     , Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success
     , Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM tblFMS_Data
INNER JOIN qryRef_Routes_tbl
  ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID
INNER JOIN tblRCM_II_Assets
  ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Pway_Number
INNER JOIN tblPeriod_Lookup PL
  ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
 AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
INNER JOIN qryRef_Detectable_Failure_Valid_Combo rdfvc
  ON tblFMS_Data.FM_Component2 = rdfvc.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = rdfvc.Ref_Fault_Comp1_ID
WHERE  PL.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And [Forms]![frmMainMenu]![PriorPeriodID]-12
GROUP BY qryRef_Routes_tbl.Ref_Route_Name
       , qryRef_Routes_tbl.Ref_Route_ID
       , tblFMS_Data.FM_FinYear
       , tblFMS_Data.FM_Period
       , tblPeriod_Lookup.PL_ID

) Sub
GROUP BY Sub.Ref_Route_Name
       , sub.Ref_Route_ID
       , sub.FM_FinYear
       , sub.FM_Period
       , sub.PL_ID
</code>```

Not sure if duplicates results from queries should be "Combined" or eliminated as duplicate so added a union all.

Body:
I have the below SQL Query:

SELECT qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period,
 tblPeriod_Lookup.PL_ID, Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success,
 Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM
(
 (
  ( tblFMS_Data INNER JOIN qryRef_Routes_tbl ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID )
    INNER JOIN tblRCM_II_Assets ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Number
  )
  INNER JOIN tblPeriod_Lookup ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
   AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
)
INNER JOIN qryRef_Detectable_Failure_Valid_Combo ON tblFMS_Data.FM_Component2 = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp1_ID
GROUP BY qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period, tblPeriod_Lookup.PL_ID
HAVING
(
 (
  tblPeriod_Lookup.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And
  ([Forms]![frmMainMenu]![PriorPeriodID]-12)
  )
)
UNION
SELECT qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period,
 tblPeriod_Lookup.PL_ID, Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success,
 Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM
(
 (
  ( tblFMS_Data INNER JOIN qryRef_Routes_tbl ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID)
    INNER JOIN tblRCM_II_Assets ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Pway_Number
  )
  INNER JOIN tblPeriod_Lookup ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
   AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
)
INNER JOIN qryRef_Detectable_Failure_Valid_Combo ON tblFMS_Data.FM_Component2 = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = qryRef_Detectable_Failure_Valid_Combo.Ref_Fault_Comp1_ID
GROUP BY qryRef_Routes_tbl.Ref_Route_Name, qryRef_Routes_tbl.Ref_Route_ID, tblFMS_Data.FM_FinYear, tblFMS_Data.FM_Period, tblPeriod_Lookup.PL_ID
HAVING
(
 (
   tblPeriod_Lookup.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And [Forms]![frmMainMenu]![PriorPeriodID]-12
  )
);

The results from this are duplicated.  I want the results of the duplicated lines to be combined.

Note the Join queries are slightly different in the 2 queries being Union'd

Body:
maybe you mean combine the results of the unions on the aggregates...

SELECT sub.Ref_Route_Name
     , sub.Ref_Route_ID
     , sub.FM_FinYear
     , sub.FM_Period
     , sub.PL_ID
     , Sum(sub.Success) as Success
     , Sum(sub.CountPrevent) as countPrevent
FROM (
SELECT qryRef_Routes_tbl.Ref_Route_Name
     , qryRef_Routes_tbl.Ref_Route_ID
     , tblFMS_Data.FM_FinYear
     , tblFMS_Data.FM_Period
     , tblPeriod_Lookup.PL_ID
     , Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success
     , Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM tblFMS_Data
INNER JOIN qryRef_Routes_tbl
  ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID
INNER JOIN tblRCM_II_Assets
  ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Number
INNER JOIN tblPeriod_Lookup PL
  ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
 AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
INNER JOIN qryRef_Detectable_Failure_Valid_Combo  rdfvc
  ON tblFMS_Data.FM_Component2 = rdfvc.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = rdfvc.Ref_Fault_Comp1_ID
WHERE PL.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And[Forms]![frmMainMenu]![PriorPeriodID]-12
GROUP BY qryRef_Routes_tbl.Ref_Route_Name
    , qryRef_Routes_tbl.Ref_Route_ID
    , tblFMS_Data.FM_FinYear
    , tblFMS_Data.FM_Period, tblPeriod_Lookup.PL_ID
UNION ALL
SELECT qryRef_Routes_tbl.Ref_Route_Name
     , qryRef_Routes_tbl.Ref_Route_ID
     , tblFMS_Data.FM_FinYear
     , tblFMS_Data.FM_Period
     , tblPeriod_Lookup.PL_ID
     , Sum(IIf([FM_TrustNo]=0 And [FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS Success
     , Sum(IIf([FM_Incident]=25 And [Ref_Fault_Valid_Combo]=-1,1,0)) AS CountPrevent
FROM tblFMS_Data
INNER JOIN qryRef_Routes_tbl
  ON tblFMS_Data.FM_Route = qryRef_Routes_tbl.Ref_Route_ID
INNER JOIN tblRCM_II_Assets
  ON tblFMS_Data.FM_EllipseNo = tblRCM_II_Assets.RI_Pway_Number
INNER JOIN tblPeriod_Lookup PL
  ON tblFMS_Data.FM_FinYear = tblPeriod_Lookup.PL_FinYear
 AND tblFMS_Data.FM_Period = tblPeriod_Lookup.PL_PeriodNo
INNER JOIN qryRef_Detectable_Failure_Valid_Combo rdfvc
  ON tblFMS_Data.FM_Component2 = rdfvc.Ref_Fault_Comp2_ID
 AND tblFMS_Data.FM_Component = rdfvc.Ref_Fault_Comp1_ID
WHERE  PL.PL_ID Between [Forms]![frmMainMenu]![PriorPeriodID] And [Forms]![frmMainMenu]![PriorPeriodID]-12
GROUP BY qryRef_Routes_tbl.Ref_Route_Name
       , qryRef_Routes_tbl.Ref_Route_ID
       , tblFMS_Data.FM_FinYear
       , tblFMS_Data.FM_Period
       , tblPeriod_Lookup.PL_ID

) Sub
GROUP BY Sub.Ref_Route_Name
       , sub.Ref_Route_ID
       , sub.FM_FinYear
       , sub.FM_Period
       , sub.PL_ID

Not sure if duplicates results from queries should be "Combined" or eliminated as duplicate so added a union all.


来源: stackexchange

问:
Disable client side form validation in ASP.NET Core
How can I disable client-side form validation in my ASP.NET Core 1.1 app? But I need the server-side one.</p>

答:
you just remove the javascript for jquery.unobtrusive.validation.js

In the VS project templates that is in _ValidationScriptsPartial.cshtml

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 3.0


问:
how to callback without printing to console ReactJS
So to make sure it updated you have to call back but how do i make it so that it doesn't show the callback if that callback has sensitive data for say.

my current callback code

```<code>handleChange(e) {
    var cse = this.state.Case;

    cse[e.target.name] = e.target.value;

    this.setState({
        Case: cse
    }, function () {
        console.log(this.state.Case);
    });
}
</code>```

how would i callback without using console.log??

right so by removing the console.log part it stops it from printing to the console but now i get this warning how do i stop this warning

Expected an assignment or function call and instead saw an expression  no-unused-expressions

答:
A "callback" is just a function which executes once the original one has completed - in this case once the state has been updated. However, you are never forced to use the callback. It's not a required parameter.

See setState():

setState(updater, [callback])

The [] here means the argument is optional.

So if you don't want to console.log anything, you can remove just that. If you get a warning in ESLint about an empty block statement or something, you could remove the callback altogether.

So like:

```<code>this.setState({
    Case: cse
});
</code>```

Body:
So to make sure it updated you have to call back but how do i make it so that it doesn't show the callback if that callback has sensitive data for say.

my current callback code

handleChange(e) {
    var cse = this.state.Case;

    cse[e.target.name] = e.target.value;

    this.setState({
        Case: cse
    }, function () {
        console.log(this.state.Case);
    });
}

how would i callback without using console.log??

right so by removing the console.log part it stops it from printing to the console but now i get this warning how do i stop this warning

Expected an assignment or function call and instead saw an expression  no-unused-expressions

Body:
A "callback" is just a function which executes once the original one has completed - in this case once the state has been updated. However, you are never forced to use the callback. It's not a required parameter.

See setState():

setState(updater, [callback])

The [] here means the argument is optional.

So if you don't want to console.log anything, you can remove just that. If you get a warning in ESLint about an empty block statement or something, you could remove the callback altogether.

So like:

this.setState({
    Case: cse
});


问:
Passing values to Construtor
```<code>package org.apache.wicket.examples.guestbook;

import java.util.Date;
import org.apache.wicket.IClusterable;

public class Comment implements IClusterable {
    private String text;
    private Date date = new Date();

    public Comment() {
    }

    public Comment(final Comment comment) {
        this.text = comment.text;
        this.date = comment.date;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String toString() {
        return "[Comment date = " + date + ", text = " + text + "]";
    }
}
</code>```

Why does the other construtor do here?
Why the Comment comment is declared as final?

答: Here is final keyword in java. Unless you assign a new value to final Comment comment it will not give any error

ContentLicense: CC BY-SA 2.5

Title: Passing values to Construtor

Body:
package org.apache.wicket.examples.guestbook;

import java.util.Date;
import org.apache.wicket.IClusterable;

public class Comment implements IClusterable {
    private String text;
    private Date date = new Date();

    public Comment() {
    }

    public Comment(final Comment comment) {
        this.text = comment.text;
        this.date = comment.date;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String toString() {
        return "[Comment date = " + date + ", text = " + text + "]";
    }
}

Why does the other construtor do here?
Why the Comment comment is declared as final?


问:
Bash shell expansion gives command not found
I am pretty new to bash scripting I am amazed at everything it can do. I have hit a wall, tried a number of different combinations to get this to work and cannot seem to get it.

Any ideas / tips / answers would be greatly appreciated!

The problem: I have a file that gets dropped as part of an ldapsearch script, it contains sAMAccountName and mail attributes. These are on separate lines, I would like to:
1) take a grepped file (grep -E "sAMAccountName|mail") this produces one entry per line and output this as , which i will then feed to postmap hash:/etc/postfix/canonical  (ftw).

however! my plans for world domination have been delayed because the statement where i am assigning the output of the command execution to $stuff issues command not found... grrr. Please kind internet bash gurus point out my mistakes please! note not all the code is included, just the piece that is giving me trouble:
ref1: Bash regex if statement

```<code>#############################
#!/bin/bash
while read line; do

if [[ $line =~ ^sAM ]]; then
 stuff = $( echo "$line" | cut -d\: -f2) #<-- command not found
 echo -n $stuff >> /etc/postfix/tmp-canonical

fi

if [[ $line =~ ^mail ]]; then
 stuff = $( echo "$line" | cut -d\: -f2) #<-- command not found
 echo -n "<tab>$stuff\n" >> /etc/postfix/tmp-canonical

fi

done < "$1"
#end
</code>```

答:
stuff is interpreted as a command instead of variable assignment because of the space before the equal sign. Remove the space and it should work. </p>

```<code>stuff=$( echo "$line" | cut -d\: -f2)
</code>```

Body:
I am pretty new to bash scripting I am amazed at everything it can do. I have hit a wall, tried a number of different combinations to get this to work and cannot seem to get it.

Any ideas / tips / answers would be greatly appreciated!

The problem: I have a file that gets dropped as part of an ldapsearch script, it contains sAMAccountName and mail attributes. These are on separate lines, I would like to:
1) take a grepped file (grep -E "sAMAccountName|mail") this produces one entry per line and output this as , which i will then feed to postmap hash:/etc/postfix/canonical  (ftw).

however! my plans for world domination have been delayed because the statement where i am assigning the output of the command execution to $stuff issues command not found... grrr. Please kind internet bash gurus point out my mistakes please! note not all the code is included, just the piece that is giving me trouble:
ref1: Bash regex if statement

#############################
#!/bin/bash
while read line; do

if [[ $line =~ ^sAM ]]; then
 stuff = $( echo "$line" | cut -d\: -f2) #<-- command not found
 echo -n $stuff >> /etc/postfix/tmp-canonical

fi

if [[ $line =~ ^mail ]]; then
 stuff = $( echo "$line" | cut -d\: -f2) #<-- command not found
 echo -n "<tab>$stuff\n" >> /etc/postfix/tmp-canonical

fi

done < "$1"
#end

Body:
stuff is interpreted as a command instead of variable assignment because of the space before the equal sign. Remove the space and it should work.

stuff=$( echo "$line" | cut -d\: -f2)


问:
Vuechart js not rendering on a component
I'm trying to use the vue-chartjs npm package, but my code below is not rendering the chart. I'm using VueJS 2 and have already installed the package using npm.

```<code><canvas id="chartRecord" width="100%" height="400"></canvas>

<script>
  import { Line } from 'vue-chartjs'
  export default {
    mounted () {
      Line.renderChart({
        labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        datasets: [{
          label: 'GitHub Commits',
          backgroundColor: '#f87979',
          data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
        }]
      })
    }
  }
</script>
</code>```

I'm getting this error:

[Vue warn]: Error in mounted hook: "TypeError: __WEBPACK_IMPORTED_MODULE_0_vue_chartjs__.Line.renderChart is not a function"

答:
The vue-chartjs module provides Vue components that are intended to be extended in order to customize.

The correct syntax to do what you're trying to do:

```<code>// MyChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
  mounted() {
    this.renderChart({
      labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
      datasets: [
        {
          label: 'GitHub Commits',
          backgroundColor: '#f87979',
          data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
        }
      ]
    })
  }
}
</code>```

Notice that you can simply put this in a .js file as there's no need to specify a template since it's already included in the Line component being imported, and since styling is mostly done in the options of the chart.

You can then import the extended component like any other component:

```<code>//Parent.vue
<template>
  <my-chart></my-chart>
</template>

<script>
import MyChart from './MyChart'

export default {
  components: { MyChart }
}
</script>
</code>```

See the documentation.

Body:
I'm trying to use the vue-chartjs npm package, but my code below is not rendering the chart. I'm using VueJS 2 and have already installed the package using npm.

<canvas id="chartRecord" width="100%" height="400"></canvas>

I'm getting this error:

[Vue warn]: Error in mounted hook: "TypeError: __WEBPACK_IMPORTED_MODULE_0_vue_chartjs__.Line.renderChart is not a function"

Body:
The vue-chartjs module provides Vue components that are intended to be extended in order to customize.

The correct syntax to do what you're trying to do:

// MyChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
  mounted() {
    this.renderChart({
      labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
      datasets: [
        {
          label: 'GitHub Commits',
          backgroundColor: '#f87979',
          data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
        }
      ]
    })
  }
}

Notice that you can simply put this in a .js file as there's no need to specify a template since it's already included in the Line component being imported, and since styling is mostly done in the options of the chart.

You can then import the extended component like any other component:

//Parent.vue
<template>
  <my-chart></my-chart>
</template>

<script>
import MyChart from './MyChart'

export default {
  components: { MyChart }
}
</script>

See the documentation.


问:
RVM - Error when try to install RVM in CentOS 6.8
I'm with the following problem:

I'm trying to install RVM in the CenteOS 6.8 in the company that I work. When I try to install it on my local machine, everything goes ok. However, when I try to do the same in a CenteOS 6.8 server machine to create the test environment, to the Quality Analyst to test, the curl command didn't work.

Here is how I tried to install it

```<code>$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: requesting key 39499BDB from hkp server keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: key 39499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 2  (RSA: 2)
</code>```

After that, I tried to install RVM with curl like that:

```<code>$ \curl -sSL https://get.rvm.io | bash -s stable
</code>```

After a while, I got:

```<code>$ \curl -sSL https://get.rvm.io | bash -s stable

curl: (35) SSL connect error
</code>```

I had tried tons of option that I found here in the StackOverflow and in the Google but until now, I didn't succeed

Could someone help me, please?

@widjajayd, thanks for the help. I tried to do the sequence bellow, but it stopped in the curl command again.

```<code>yum install git
git config --global user.name "your name "
git config --global user.email "your email "
cd ~/.ssh
ssh-keygen -t rsa -C “your email”
curl -L https://get.rvm.io | bash -s
</code>```

The 'cd ~/.ssh' did not work because it does not exist. So, I created it and inside of it, I run ''ssh-keygen -t rsa -C “your email”.

In the end, I executed the command curl command and I got:

```<code>$ curl -L https://get.rvm.io | bash -s
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
194   194  194   194    0     0    222      0 --:--:-- --:--:-- --:--:--  1405
curl: (35) SSL connect error
</code>```

I had used this command before I attempted this last curl command. However, the result was the same as above.

答:
probably in you local machine you already set ssl correctly but in your production you not set ssl,

below some step by step for you to double check in centos

```<code>yum install git
git config --global user.name "your name "
git config --global user.email "your email "
cd ~/.ssh
ssh-keygen -t rsa -C “your email”
curl -L https://get.rvm.io | bash -s
</code>```

To start using RVM you need to run source

```<code>source /etc/profile.d/rvm.sh
test rvm -v
</code>```

Body:
I'm with the following problem:

I'm trying to install RVM in the CenteOS 6.8 in the company that I work. When I try to install it on my local machine, everything goes ok. However, when I try to do the same in a CenteOS 6.8 server machine to create the test environment, to the Quality Analyst to test, the curl command didn't work.

Here is how I tried to install it

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: requesting key 39499BDB from hkp server keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: key 39499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 2  (RSA: 2)

After that, I tried to install RVM with curl like that:

$ \curl -sSL https://get.rvm.io | bash -s stable

After a while, I got:

$ \curl -sSL https://get.rvm.io | bash -s stable

curl: (35) SSL connect error

I had tried tons of option that I found here in the StackOverflow and in the Google but until now, I didn't succeed

Could someone help me, please?

@widjajayd, thanks for the help. I tried to do the sequence bellow, but it stopped in the curl command again.

yum install git
git config --global user.name "your name "
git config --global user.email "your email "
cd ~/.ssh
ssh-keygen -t rsa -C “your email”
curl -L https://get.rvm.io | bash -s

The 'cd ~/.ssh' did not work because it does not exist. So, I created it and inside of it, I run ''ssh-keygen -t rsa -C “your email”.

In the end, I executed the command curl command and I got:

$ curl -L https://get.rvm.io | bash -s
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
194   194  194   194    0     0    222      0 --:--:-- --:--:-- --:--:--  1405
curl: (35) SSL connect error

I had used this command before I attempted this last curl command. However, the result was the same as above.

Body:
probably in you local machine you already set ssl correctly but in your production you not set ssl,

below some step by step for you to double check in centos

yum install git
git config --global user.name "your name "
git config --global user.email "your email "
cd ~/.ssh
ssh-keygen -t rsa -C “your email”
curl -L https://get.rvm.io | bash -s

To start using RVM you need to run source

source /etc/profile.d/rvm.sh
test rvm -v


问:
Error Parsing Json using Go language
I am trying to Parse Json & Print Data and save in a CSV using GO language .

It is printing the desired 10 result per page with Println but couldn't parse JSON .

This is what I am doing

Visitor visits studentresults.com/page=1 RollNo. & Marks for 10 students are displayed and it is also saved in a CSV [key.rollno & key.marks]

Program Makes a request to studentsapimarks.com/api/rollno1,rollno2,rollno3/detail (appending all key.rollno that we got in step1)
The Json response would be like

```<code>[{"name":"James","Percentage":96.5,"Remarks":"VeryGood"},
{"name":"William","Percentage":36.0,"Remarks":"Bad"},
{"name":"Jacob","Percentage":63.0,"Remarks":"Average"},
{"name":"Wilson","Percentage":69.3,"Remarks":"Average"},
{"name":"Kurtson","Percentage":16.9,"Remarks":"VeryBad"},
{"name":"Tom","Percentage":86.3,"Remarks":"Good"}]
</code>```

Extract Name & Percentage fields & save in a csv

Here is my snippet of the code that is responsible for printing and saving the results

```<code>package main

import (
    "encoding/csv"
    "fmt"
    "net/http"
    "os"
    "strings"
    "encoding/json"

)

type Key struct {
    fname      string
    marks      int
    rollno     int
    }

type object struct {
    Percentage float64
    Name string `json:"name"`
    }

func PageRequest(w http.ResponseWriter, r *http.Request) {

    // Page header
    fmt.Fprintf(w, PageHeader, pages, previous, next)

    // Save in csv
    csvfile, err := os.OpenFile("marks.csv", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer csvfile.Close()

    writer := csv.NewWriter(csvfile)
    defer writer.Flush()

    // Defining RollNos
    var rollNos []string

    // Marks for UID
    UID, length := compute(start)
    for i := 0; i < length; i++ {
        key := UID[i]

    // Prints firstname, Marks and Rollno
        fmt.Fprintf(w, key.fname, key.marks, key.rollno)

        records := [][]string{{key.fname, key.marks, key.rollno}}

        for _, record := range records {
            err := writer.Write(record)
            if err != nil {
                fmt.Println("Error:", err)
                return
            }
        }

    // Append All key.rollno
        rollNos := append(rollNos, key.rollno)

    // Makes a request to as studentsapimarks.com/api/rollno1,rollno2,rollno3/detail
        uri := "https://studentsapimarks.com/api/" + strings.Join(rollNos, ",") + "/detail"

        res, err := http.Get(uri)
        if err != nil {
            log.Fatal(err)
        }
        defer res.Body.Close()

        var s []object
        err = json.NewDecoder(res.Body).Decode(&s)
        if err != nil {
            log.Fatal(err)
        }

    // Prints Name/ Percentage
        fmt.Println(s[0].Name)
        fmt.Println(s[0].Percentage)
    }

    // Page Footer
    fmt.Fprintf(w, PageFooter, previous, next)
}

func main() {
    http.HandleFunc("/", PageRequest)

log.Println("Listening")
log.Fatal(http.ListenAndServe(":8080", nil))

}
</code>```

fmt.Fprintf(w, key.fname, key.marks, key.rollno) is working fine and displays all 10 results per page and saves in a csv .

Problem with the code is

It is not appending all key.rollno that we got in step1 as studentsapimarks.com/api/rollno1,rollno2,rollno3/detail

Also how could i save the JSON extracted s[0].name results in a CSV ?

答:
The JSON parsing is failing because you're trying to unmarshal a JSON array into a struct. You want to unmarshal a JSON array into a slice - the outer struct is not necessary:

```<code>var s []object
err = json.NewDecoder(res.Body).Decode(&s)
</code>```

Also, it can only unmarshal exported fields (those that start with a capital letter), so to get the name, you'll need to change your struct definition. I'm guessing the percentage isn't coming through either, since in the JSON it's a single float value, but in your struct you're taking a float slice.

```<code>type object struct {
    // "Percentage": 96.4 is not a slice.
    // Also if the field name in Go and JSON are identical, you dont need the json tag.
    Percentage float64
    // The field must be capitalized, the tag can stay lowercase
    Name string `json:"name"`
}
</code>```

Then you'll access those fields accordingly:

```<code>// Prints Name/ Percentage
fmt.Println(s[0].Name)
fmt.Println(s[0].Percentage)
</code>```

Title: Error Parsing Json using Go language

Body:
I am trying to Parse Json & Print Data and save in a CSV using GO language .

It is printing the desired 10 result per page with Println but couldn't parse JSON .

This is what I am doing

Visitor visits studentresults.com/page=1 RollNo. & Marks for 10 students are displayed and it is also saved in a CSV [key.rollno & key.marks]

Program Makes a request to studentsapimarks.com/api/rollno1,rollno2,rollno3/detail (appending all key.rollno that we got in step1)
The Json response would be like

[{"name":"James","Percentage":96.5,"Remarks":"VeryGood"},
{"name":"William","Percentage":36.0,"Remarks":"Bad"},
{"name":"Jacob","Percentage":63.0,"Remarks":"Average"},
{"name":"Wilson","Percentage":69.3,"Remarks":"Average"},
{"name":"Kurtson","Percentage":16.9,"Remarks":"VeryBad"},
{"name":"Tom","Percentage":86.3,"Remarks":"Good"}]

Extract Name & Percentage fields & save in a csv

Here is my snippet of the code that is responsible for printing and saving the results

package main

import (
    "encoding/csv"
    "fmt"
    "net/http"
    "os"
    "strings"
    "encoding/json"

)

type Key struct {
    fname      string
    marks      int
    rollno     int
    }

type object struct {
    Percentage float64
    Name string `json:"name"`
    }

func PageRequest(w http.ResponseWriter, r *http.Request) {

    // Page header
    fmt.Fprintf(w, PageHeader, pages, previous, next)

    // Save in csv
    csvfile, err := os.OpenFile("marks.csv", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer csvfile.Close()

    writer := csv.NewWriter(csvfile)
    defer writer.Flush()

    // Defining RollNos
    var rollNos []string

    // Marks for UID
    UID, length := compute(start)
    for i := 0; i < length; i++ {
        key := UID[i]

    // Prints firstname, Marks and Rollno
        fmt.Fprintf(w, key.fname, key.marks, key.rollno)

        records := [][]string{{key.fname, key.marks, key.rollno}}

        for _, record := range records {
            err := writer.Write(record)
            if err != nil {
                fmt.Println("Error:", err)
                return
            }
        }

    // Append All key.rollno
        rollNos := append(rollNos, key.rollno)

    // Makes a request to as studentsapimarks.com/api/rollno1,rollno2,rollno3/detail
        uri := "https://studentsapimarks.com/api/" + strings.Join(rollNos, ",") + "/detail"

        res, err := http.Get(uri)
        if err != nil {
            log.Fatal(err)
        }
        defer res.Body.Close()

        var s []object
        err = json.NewDecoder(res.Body).Decode(&s)
        if err != nil {
            log.Fatal(err)
        }

    // Prints Name/ Percentage
        fmt.Println(s[0].Name)
        fmt.Println(s[0].Percentage)
    }

    // Page Footer
    fmt.Fprintf(w, PageFooter, previous, next)
}

func main() {
    http.HandleFunc("/", PageRequest)

log.Println("Listening")
log.Fatal(http.ListenAndServe(":8080", nil))

}

fmt.Fprintf(w, key.fname, key.marks, key.rollno) is working fine and displays all 10 results per page and saves in a csv .

Problem with the code is

It is not appending all key.rollno that we got in step1 as studentsapimarks.com/api/rollno1,rollno2,rollno3/detail

Also how could i save the JSON extracted s[0].name results in a CSV ?

Body:
The JSON parsing is failing because you're trying to unmarshal a JSON array into a struct. You want to unmarshal a JSON array into a slice - the outer struct is not necessary:

var s []object
err = json.NewDecoder(res.Body).Decode(&s)

Also, it can only unmarshal exported fields (those that start with a capital letter), so to get the name, you'll need to change your struct definition. I'm guessing the percentage isn't coming through either, since in the JSON it's a single float value, but in your struct you're taking a float slice.

type object struct {
    // "Percentage": 96.4 is not a slice.
    // Also if the field name in Go and JSON are identical, you dont need the json tag.
    Percentage float64
    // The field must be capitalized, the tag can stay lowercase
    Name string `json:"name"`
}

Then you'll access those fields accordingly:

// Prints Name/ Percentage
fmt.Println(s[0].Name)
fmt.Println(s[0].Percentage)


问:
How to trim values and send to deepEquals method ()
```<code>public static void main(String args[]){
         String [] a={"A","B"};
         String[] b ={"  B"," A"};
         Arrays.sort(a);
         Arrays.sort(b);
         System.out.println(Arrays.deepEquals(a,b));
}
</code>```

I want to compare two string arrays and should return true values but its giving a false value since String[] b values has space. How do I trim my values and send to deepEquals method .

答:
You can apply the trim function on each of the strings first.

public String trim()
    Returns a copy of the string, with leading and
    trailing whitespace omitted.

Something as the following should work:

```<code>void trimAll(String[] vec){
    for (int i = 0; i < vec.length; i++)
        vec[i] = vec[i].trim();
}

public static void main(String args[]){
         String [] a={"A","B"};
         String[] b ={"  B"," A"};
         trimAll(a);
         trimAll(b);
         Arrays.sort(a);
         Arrays.sort(b);
         System.out.println(Arrays.deepEquals(a,b));
}
</code>```

Reference here

Body:
public static void main(String args[]){
         String [] a={"A","B"};
         String[] b ={"  B"," A"};
         Arrays.sort(a);
         Arrays.sort(b);
         System.out.println(Arrays.deepEquals(a,b));
}

I want to compare two string arrays and should return true values but its giving a false value since String[] b values has space. How do I trim my values and send to deepEquals method .

Body:
You can apply the trim function on each of the strings first.

public String trim()
    Returns a copy of the string, with leading and
    trailing whitespace omitted.

Something as the following should work:

void trimAll(String[] vec){
    for (int i = 0; i < vec.length; i++)
        vec[i] = vec[i].trim();
}

public static void main(String args[]){
         String [] a={"A","B"};
         String[] b ={"  B"," A"};
         trimAll(a);
         trimAll(b);
         Arrays.sort(a);
         Arrays.sort(b);
         System.out.println(Arrays.deepEquals(a,b));
}

Reference here


答:
FOUND IT! I just hadn't tried hard enough! Okay here is how i fixed it:

code snippet (the corrected)

```<code>STUFF=$(echo "$line" | cut -d\: -f2)
</code>```

The original -

```<code>STUFF = $(echo "$line" | cut -d\: -f2)
</code>```

The space between STUFF and the "=" was being interpreted, found this article: How to set a variable to the output from a command in Bash?

Title: Bash shell expansion gives command not found

Body:
FOUND IT! I just hadn't tried hard enough! Okay here is how i fixed it:

code snippet (the corrected)

STUFF=$(echo "$line" | cut -d\: -f2)

The original -

STUFF = $(echo "$line" | cut -d\: -f2)

The space between STUFF and the "=" was being interpreted, found this article: How to set a variable to the output from a command in Bash?


答:
You can go through each element of the array and use the trim function.

```<code>String[] trimmedA = new String[a.length];
    for (int i = 0; i < a.length; i++)
        trimmedA[i] = a[i].trim();
</code>```

You can also check that the lengths of a and b are equal. If they aren't you can return false right away without sorting and trimming.

On the other hand, if you do not need to use the original strings again, you can do the trimming in place:

```<code>for (int i = 0; i < a.length; i++)
    a[i] = a[i].trim();
</code>```

Title: How to trim values and send to deepEquals method ()

Body:
You can go through each element of the array and use the trim function.

String[] trimmedA = new String[a.length];
    for (int i = 0; i < a.length; i++)
        trimmedA[i] = a[i].trim();

You can also check that the lengths of a and b are equal. If they aren't you can return false right away without sorting and trimming.

On the other hand, if you do not need to use the original strings again, you can do the trimming in place:

for (int i = 0; i < a.length; i++)
    a[i] = a[i].trim();


问:
Changing the Value of an Attribute using javascript
Getting my script down to the bare bones, I have followed the example of the w3schools.com ( https://www.w3schools.com/js/js_htmldom_html.asp ) for: document.getElementById(id).attribute = new value. Their example:

```<code><!DOCTYPE html>
<html>
<body>

    <img id="myImage" src="smiley.gif">

<script>
    document.getElementById("myImage").src = "landscape.jpg";
</script>

</body>
</html>
</code>```

Here is mine. I get no error messages on the Chrome console.

```<code><body>

    <img id = "indexPhoto" src =
        "newthaiimages/indexPhotos/indexPhoto_320.jpg"
         width="320" height="474" alt="hero sepia toned photo of Thai
         temple next to a river"/>

<script>

    document.getElementById("indexPhoto").scr =
        "newthaiimages/indexPhotos/indexPhoto_450.jpg";

</script>

</body>
</code>```

You can see the result at http://newthaimassage.com/index3.php . Here is the script not stripped down.

```<code><script>

    window.onload = function() {

       var w = window

   var x = w.innerWidth

switch(w.innerWidth){

    case x <= 320:

    break;

    case x <= 768:

        document.getElementById("indexPhoto").scr ="indexPhoto_450.jpg";

    break;

    case x <= 1024:

        document.getElementById("indexPhoto").scr ="indexPhoto_835.jpg";

    break;

    case x <= 1420:

        document.getElementById("indexPhoto").scr ="indexPhoto_1000.jpg";

    break;

    default:

        document.getElementById("indexPhoto").scr ="indexPhoto_1200.jpg";

}}

</script>
</code>```

Currently I am using CSS media queries to show images by window size, but using background images I can not use CSS animation, which is my ultimate goal here. Any help on this would be greatly appreciated.

答:
your document.getElementById("indexPhoto").scr should be :

```<code>document.getElementById("indexPhoto").src
</code>```

Body:
Getting my script down to the bare bones, I have followed the example of the w3schools.com ( https://www.w3schools.com/js/js_htmldom_html.asp ) for: document.getElementById(id).attribute = new value. Their example:

<!DOCTYPE html>

Here is mine. I get no error messages on the Chrome console.

You can see the result at http://newthaimassage.com/index3.php . Here is the script not stripped down.

Currently I am using CSS media queries to show images by window size, but using background images I can not use CSS animation, which is my ultimate goal here. Any help on this would be greatly appreciated.

Body:
your document.getElementById("indexPhoto").scr should be :

document.getElementById("indexPhoto").src


问:
Cannot run peer because cannot init crypto
I want to run the facbar-samples on windows10,reference the http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html but get the error:

```<code>$ ./startFabric.sh
orderer.example.com is up-to-date
couchdb is up-to-date
peer0.org1.example.com is up-to-date
cli is up-to-date
2017-07-05 08:17:06.550 UTC [main] main -> ERRO 001 Cannot run peer because
cannot init crypto, missing /etc/hyperledger/fabric/C:/Program
Files/Git/etc/hyperledger/msp/users/Admin@org1.example.com/msp folder
</code>```

some that I have installed:

```<code>$ npm -v
5.0.4
$ node -v
v6.11.0
$ curl -V
curl 7.54.0 (x86_64-w64-mingw32) libcurl/7.54.0 OpenSSL/1.0.2l zlib/1.2.11
libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3
pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz TLS-SRP HTTP2
HTTPS-proxy Metalink

$ docker --version
Docker version 17.06.0-ce, build 02c1d87

$ docker-compose --version
docker-compose version 1.14.0, build c7bdf9e3

$ git --version
git version 2.13.1.windows.2
</code>```

Please help ,Thanks.

答:
The problem is incorrect path to certificates  (look for windows path string between /fabric and /etc)
/etc/hyperledger/fabric/C:/ProgramFiles/Git/etc/hyperledger/msp/users/Admin@org1.example.com/msp

You can try next :

add path to certificate as environment variable to docker compose file at peer section

start network using docker-compose -f "path_to_file"

manually run instructions in startFabric.sh at peer and cli.

then you can successfully run node query.js  for testing network work

Body:
I want to run the facbar-samples on windows10,reference the http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html but get the error:

$ ./startFabric.sh
orderer.example.com is up-to-date
couchdb is up-to-date
peer0.org1.example.com is up-to-date
cli is up-to-date
2017-07-05 08:17:06.550 UTC [main] main -> ERRO 001 Cannot run peer because
cannot init crypto, missing /etc/hyperledger/fabric/C:/Program
Files/Git/etc/hyperledger/msp/users/Admin@org1.example.com/msp folder

some that I have installed:

$ npm -v
5.0.4
$ node -v
v6.11.0
$ curl -V
curl 7.54.0 (x86_64-w64-mingw32) libcurl/7.54.0 OpenSSL/1.0.2l zlib/1.2.11
libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3
pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz TLS-SRP HTTP2
HTTPS-proxy Metalink

$ docker --version
Docker version 17.06.0-ce, build 02c1d87

$ docker-compose --version
docker-compose version 1.14.0, build c7bdf9e3

$ git --version
git version 2.13.1.windows.2

Please help ,Thanks.


问:
Make new row dirty programmatically and insert a new row after it in DataGridView
I've an editable unbounded datagridview. I'm changing the value of new row programmatically.

Normally, when user types in any field of a new row, it becomes dirty and another new row is inserted below it.

But in my case, when user comes in to any field of a new row, I'm trapping the function key and changing the cell value programmatically.

myGrid.CurrentCell.Value = "xyz";

And it doesn't insert a new row below it.

Now as a work around I tried this on CellValueChanged event handler.

```<code>  if (myGrid.NewRowIndex == e.RowIndex)
  {
    myGrid.Rows.Insert(e.RowIndex + 1, 1);
  }
</code>```

But it throws error saying No row can be inserted after the uncommitted new row..

How could I tell myGrid that I've made current row (which is a new row) dirty and that there is need of a new row after it?

答:
I think (I'm not sure, though), that you're trying to insert a row after the New Row...which is not possible. Changing your code to this

```<code>myGrid.Rows.Insert(e.RowIndex - 1, 1);
</code>```

Should insert the row before the New Row, which should work.

Body:
I've an editable unbounded datagridview. I'm changing the value of new row programmatically.

Normally, when user types in any field of a new row, it becomes dirty and another new row is inserted below it.

But in my case, when user comes in to any field of a new row, I'm trapping the function key and changing the cell value programmatically.

myGrid.CurrentCell.Value = "xyz";

And it doesn't insert a new row below it.

Now as a work around I tried this on CellValueChanged event handler.

  if (myGrid.NewRowIndex == e.RowIndex)
  {
    myGrid.Rows.Insert(e.RowIndex + 1, 1);
  }

But it throws error saying No row can be inserted after the uncommitted new row..

How could I tell myGrid that I've made current row (which is a new row) dirty and that there is need of a new row after it?

Body:
I think (I'm not sure, though), that you're trying to insert a row after the New Row...which is not possible. Changing your code to this

myGrid.Rows.Insert(e.RowIndex - 1, 1);

Should insert the row before the New Row, which should work.


问:
How can I custom sort the contentful response on the frontend of my angular app
I am using Contentful in my AngularJS app... I have a content type team which holds a list of team bios. http://uat.traverusglobal.com (bottom)

I have successfully gotten data from contentful using angular-contentful... Now I need to to sort the response by name or other contentful field. So that the admin has control over the order.

How can I sort the contentful response on the frontend of my angular app? Below is my attempt.

https://jsfiddle.net/k3jmq2gm/1/

```<code>    <div class="columns teams-list" contentful-entries="'content_type=staff'" ng-controller="teamContentful">
        <div ng-repeat="item in $contentfulEntries.items | orderBy:'item.fields.name'" class="column" data-flag="{{item.fields.flag}}" data-visible="{{item.fields.visible}}" ng-class='{active:$first}' data-tab="1" data-title="{{item.fields.title}}" data-name="{{item.fields.name}}">
            <!-- <h1>{{item[0].title}}</h1> -->
            <img src="{{ item.fields.image.fields.file.url }}" title="{{item.img}}">
            <p class="hide bio">{{item.fields.bio}}</p>
        </div>
    </div>
</code>```

答: as Und3rTow pointed out. orderBy should be orderBy:'fields.name'

Body:
I am using Contentful in my AngularJS app... I have a content type team which holds a list of team bios. http://uat.traverusglobal.com (bottom)

I have successfully gotten data from contentful using angular-contentful... Now I need to to sort the response by name or other contentful field. So that the admin has control over the order.

How can I sort the contentful response on the frontend of my angular app? Below is my attempt.

https://jsfiddle.net/k3jmq2gm/1/

{{item.fields.bio}}


问:
Passing C++ double array to Python Results in a Crash
I'm running into an issue while trying to pass a double array from C++ to Python.  I run a script to create a binary file with data, then read that data back into an array and am trying to pass the array to Python.  I've followed advice here: how to return array from c function to python using ctypes among other pages I have found through google.  I can write a generic example that works fine (like a similar array to the link above), but when I try to pass the array read from a binary file (code below), the program crashes with "Unhandled exception at ADDR (ucrtbase.dll) in python.exe: An invalid parameter was passed to a function that considers invalid parameters fatal."  So, I'm wondering if anyone has any insight.

A word on methodology:

Right now, I'm just trying to learn - that's why  I'm going through the convoluted process of saving to disk, loading, and passing to Python.  Eventaully, I will use this in scientific simulations where the data read from disk needs to be generated by distributed computing/a super computer.  I would like to use Python for its ease of plotting (matplotlib) and C++ for its speed (iterative calculations, etc).

So, on to my code.  This generates the binary file:

```<code>for (int zzz = 0; zzz < arraysize; ++zzz)
{
    for (int yyy = 0; yyy < arraysize; ++yyy)
    {
        for (int xxx = 0; xxx < arraysize; ++xxx)
        {//totalBatP returns a 3 element std::vector<double> - dblArray3_t is basically that with a few overloaded operators (+,-,etc)
            dblArray3_t BatP = B.totalBatP({ -5 + xxx * stepsize, -5 + yyy * stepsize, -5 + zzz * stepsize }, 37);
            for (int bbb = 0; bbb < 3; ++bbb)
            {
                dataarray[loopind] = BatP[bbb];
                ++loopind;
                ...(end braces here)
FILE* binfile;
binfile = fopen("MBdata.bin", "wb");
fwrite(dataarray, 8, 3 * arraysize * arraysize * arraysize, binfile);
</code>```

The code that reads the file:

```<code>DLLEXPORT double* readDblBin(const std::string filename, unsigned int numOfDblsToRead)
{
    char* buffer = new char[numOfDblsToRead];
    std::ifstream binFile;
    binFile.open(filename, std::ios::in | std::ios::binary);
    binFile.read(buffer, numOfDblsToRead);
    double* dataArray = (double*)buffer;
    binFile.close();

    return dataArray;
}
</code>```

And the Python Code that receives the array:

```<code>def readBDataWrapper(filename, numDblsToRead):
    fileIO = ctypes.CDLL('./fileIO.dll')
    fileIO.readDblBin.argtypes = (ctypes.c_char_p, ctypes.c_uint)
    fileIO.readDblBin.restype = ctypes.POINTER(ctypes.c_double)

    return fileIO.readDblBin(filename, numDblsToRead)
</code>```

答:
I figured it out - at least it appears to be working.  The problem was with the binary files that were generated with the first code block.  I swapped the c-style writing with ofstream.  My assumption is perhaps I was using the code to write to disk wrong somehow.  Anyway, it appears to work now.

Replaced:

```<code>FILE* binfile;
binfile = fopen("MBdata.bin", "wb");
fwrite(dataarray, 8, 3 * arraysize * arraysize * arraysize, binfile);
</code>```

With:

```<code>std::ofstream binfile;
binfile.open("MBdata.bin", std::ios::binary | std::ios::out);
binfile.write(reinterpret_cast<const char*>(dataarray), std::streamsize(totaliter * sizeof(double)));
binfile.close();
</code>```

Body:
I'm running into an issue while trying to pass a double array from C++ to Python.  I run a script to create a binary file with data, then read that data back into an array and am trying to pass the array to Python.  I've followed advice here: how to return array from c function to python using ctypes among other pages I have found through google.  I can write a generic example that works fine (like a similar array to the link above), but when I try to pass the array read from a binary file (code below), the program crashes with "Unhandled exception at ADDR (ucrtbase.dll) in python.exe: An invalid parameter was passed to a function that considers invalid parameters fatal."  So, I'm wondering if anyone has any insight.

A word on methodology:

Right now, I'm just trying to learn - that's why  I'm going through the convoluted process of saving to disk, loading, and passing to Python.  Eventaully, I will use this in scientific simulations where the data read from disk needs to be generated by distributed computing/a super computer.  I would like to use Python for its ease of plotting (matplotlib) and C++ for its speed (iterative calculations, etc).

So, on to my code.  This generates the binary file:

for (int zzz = 0; zzz < arraysize; ++zzz)
{
    for (int yyy = 0; yyy < arraysize; ++yyy)
    {
        for (int xxx = 0; xxx < arraysize; ++xxx)
        {//totalBatP returns a 3 element std::vector<double> - dblArray3_t is basically that with a few overloaded operators (+,-,etc)
            dblArray3_t BatP = B.totalBatP({ -5 + xxx * stepsize, -5 + yyy * stepsize, -5 + zzz * stepsize }, 37);
            for (int bbb = 0; bbb < 3; ++bbb)
            {
                dataarray[loopind] = BatP[bbb];
                ++loopind;
                ...(end braces here)
FILE* binfile;
binfile = fopen("MBdata.bin", "wb");
fwrite(dataarray, 8, 3 * arraysize * arraysize * arraysize, binfile);

The code that reads the file:

DLLEXPORT double* readDblBin(const std::string filename, unsigned int numOfDblsToRead)
{
    char* buffer = new char[numOfDblsToRead];
    std::ifstream binFile;
    binFile.open(filename, std::ios::in | std::ios::binary);
    binFile.read(buffer, numOfDblsToRead);
    double* dataArray = (double*)buffer;
    binFile.close();

    return dataArray;
}

And the Python Code that receives the array:

def readBDataWrapper(filename, numDblsToRead):
    fileIO = ctypes.CDLL('./fileIO.dll')
    fileIO.readDblBin.argtypes = (ctypes.c_char_p, ctypes.c_uint)
    fileIO.readDblBin.restype = ctypes.POINTER(ctypes.c_double)

    return fileIO.readDblBin(filename, numDblsToRead)

Body:
I figured it out - at least it appears to be working.  The problem was with the binary files that were generated with the first code block.  I swapped the c-style writing with ofstream.  My assumption is perhaps I was using the code to write to disk wrong somehow.  Anyway, it appears to work now.

Replaced:

FILE* binfile;
binfile = fopen("MBdata.bin", "wb");
fwrite(dataarray, 8, 3 * arraysize * arraysize * arraysize, binfile);

With:

std::ofstream binfile;
binfile.open("MBdata.bin", std::ios::binary | std::ios::out);
binfile.write(reinterpret_cast<const char*>(dataarray), std::streamsize(totaliter * sizeof(double)));
binfile.close();


问:
SQL: If exists, limit user. If not exists show everything
I'm trying to found the best way to this requirements:

@fkStaffID INT = Current user.

If @fkStaffID got resource BLABLA only show rows of table X where is StaffID is here. If he DON'T have resource BLABLA, show everything.

SORRY I cannot paste full SQL, for employer's security policy. (I wish I show enough for help, not too much for security...)

What I do:

```<code>SELECT * FROM X
WHERE ((EXISTS
(SELECT 1 FROM STAFF WHERE pkStaff=@fkStaffID
AND STAFF.PkStaff IN (SELECT fkStaff FROM SECURITYSUBQUERY WHERE ResourceName='BLABLA')) AND X.fkStaff=@fkStaffID)
OR ((NOT EXISTS (SELECT 1 FROM STAFF WHERE pkStaff=@fkStaffID
AND STAFF.PkStaff IN (SELECT fkStaff FROM SECURITYSUBQUERY WHERE ResourceName='BLABLA')) )
</code>```

PROBLEM: It's really slow. Can I do a more efficient way? Can I do another way? Thank you for your help!

答:
I think you should be able to qrite the query thus:

```<code>SELECT * FROM x
WHERE @fkStaffID NOT IN (SELECT fkStaff FROM SecuritySubquery WHERE ResourceName= 'BLABLA')
   OR @fkStaffID = fkStaff;
</code>```

So either the @fkStaffID isn't 'BLABLA' or it matches the record's staff ID.

This NOT IN / OR still won't be very fast. Anyway, you should have the following indexes:

```<code>CREATE INDEX idx1 ON SecuritySubquery (ResourceName, fkStaff);
CREATE INDEX idx2 ON x (fkStaff);
</code>```

Body:
I'm trying to found the best way to this requirements:

@fkStaffID INT = Current user.

If @fkStaffID got resource BLABLA only show rows of table X where is StaffID is here. If he DON'T have resource BLABLA, show everything.

SORRY I cannot paste full SQL, for employer's security policy. (I wish I show enough for help, not too much for security...)

What I do:

SELECT * FROM X
WHERE ((EXISTS
(SELECT 1 FROM STAFF WHERE pkStaff=@fkStaffID
AND STAFF.PkStaff IN (SELECT fkStaff FROM SECURITYSUBQUERY WHERE ResourceName='BLABLA')) AND X.fkStaff=@fkStaffID)
OR ((NOT EXISTS (SELECT 1 FROM STAFF WHERE pkStaff=@fkStaffID
AND STAFF.PkStaff IN (SELECT fkStaff FROM SECURITYSUBQUERY WHERE ResourceName='BLABLA')) )

PROBLEM: It's really slow. Can I do a more efficient way? Can I do another way? Thank you for your help!

Body:
I think you should be able to qrite the query thus:

SELECT * FROM x
WHERE @fkStaffID NOT IN (SELECT fkStaff FROM SecuritySubquery WHERE ResourceName= 'BLABLA')
   OR @fkStaffID = fkStaff;

So either the @fkStaffID isn't 'BLABLA' or it matches the record's staff ID.

This NOT IN / OR still won't be very fast. Anyway, you should have the following indexes:

CREATE INDEX idx1 ON SecuritySubquery (ResourceName, fkStaff);
CREATE INDEX idx2 ON x (fkStaff);


问:
Is it possible to "mass replace" values in excel functions?
I have over 100 cells where I need to replace P$30 with P$57 in the formula bar. Is it possible to do this without going into each cell and changing it one by one?</p>

答: Use the command Ctrl+H.  This is the "Find and Replace" functionality built into Excel.</p>


问:
PHP Laravel manytomany eloquent distinct query
I have two tables
Projects and Categories with a many to many relationship since a project can be beneath several Categories.

In Laravel 5.4 I have setup a manytomany relationship on the two models which uses the category_project pivot table.

I would like to retrieve all the projects beneath an array of categories.

For a single category this works fine

```<code>$Projects = Category::find(1)->projects()->distinct();
</code>```

However when I pass in an array of ids to find to the find method I get an error "Method projects does not exist" which I assume is because it is returning a collection.

```<code> $Projects = Category::find([1,2])->projects()->distinct();
</code>```

Am I going about this the correct way? What do I need to do to get the projects for a list of category ids (in this example 1 and 2).

答:
If you want distinct projects that belong to either category 1 or 2 then it's easier to go at it the other way around e.g. </p>

```<code>$categories = [1,2];
$projects = Projects::whereHas(["category" => function ($query) use ($categories) {
        return $query->whereIn("category_id",$categories);
}])->get();
</code>```

<p>If you want projects that belong to both categories then you can alter your condition to </p>

```<code>$projects = Projects::whereHas(["category" => function ($query) use ($categories) {
     return $query->where(collect($categories)->map(function ($v) {
          return ["category_id",$v];
     }));
}])->get();
</code>```

Body:
I have two tables
Projects and Categories with a many to many relationship since a project can be beneath several Categories.

In Laravel 5.4 I have setup a manytomany relationship on the two models which uses the category_project pivot table.

I would like to retrieve all the projects beneath an array of categories.

For a single category this works fine

$Projects = Category::find(1)->projects()->distinct();

However when I pass in an array of ids to find to the find method I get an error "Method projects does not exist" which I assume is because it is returning a collection.

 $Projects = Category::find([1,2])->projects()->distinct();

Am I going about this the correct way? What do I need to do to get the projects for a list of category ids (in this example 1 and 2).

Body:
If you want distinct projects that belong to either category 1 or 2 then it's easier to go at it the other way around e.g.

$categories = [1,2];
$projects = Projects::whereHas(["category" => function ($query) use ($categories) {
        return $query->whereIn("category_id",$categories);
}])->get();

If you want projects that belong to both categories then you can alter your condition to

$projects = Projects::whereHas(["category" => function ($query) use ($categories) {
     return $query->where(collect($categories)->map(function ($v) {
          return ["category_id",$v];
     }));
}])->get();


问:
Is it possible to create dataframe with sub-headers in Pandas?
I have the following piece of code:

```<code>_tmp = {}
_tmp['pre'] = {
    'A2': 10,
    'B2': 15,
    'C2': 20
}
_tmp['diff'] = {
    'A1': 10,
    'B1': 15,
    'C1': 20
}
_tmp['sum'] = {
    'A': 100,
    'B': 150,
    'C': 200
}
</code>```

By performing the following commands:

```<code>_dff = pd.DataFrame(data=_tmp.values(), index=_tmp.keys())
_dff[['A', 'B', 'C', 'A1', 'B1', 'C1', 'A2', 'B2', 'C2']]
</code>```

I got a result described below:

However I am interested in knowing whether it is possible to build a structure in pandas like the following:

答:
What you're really looking at there is a three dimensional structure, which a dataframe cannot do.  (They're 2D only.)

This leaves you with a couple options:

(1) Multiple dataframes (pre/diff/sum).

```<code>dfs = {k:pd.DataFrame(v.items()) for k,v in _tmp.items()}
</code>```

(2) A pandas Panel which you can build like:

```<code>pnl = pd.Panel(dfs)
</code>```

Which is a way of grouping multiple dataframes.

(3) A 3d numpy matrix:

```<code>>>> pnl.as_matrix()
[[['A1' 10]
  ['C1' 20]
  ['B1' 15]]

 [['C2' 20]
  ['A2' 10]
  ['B2' 15]]

 [['A' 100]
  ['C' 200]
  ['B' 150]]]
</code>```

You're going to have to write a custom print function to get your exact requested output of course, but these would be the ways you can represent your data.

Body:
I have the following piece of code:

_tmp = {}
_tmp['pre'] = {
    'A2': 10,
    'B2': 15,
    'C2': 20
}
_tmp['diff'] = {
    'A1': 10,
    'B1': 15,
    'C1': 20
}
_tmp['sum'] = {
    'A': 100,
    'B': 150,
    'C': 200
}

By performing the following commands:

_dff = pd.DataFrame(data=_tmp.values(), index=_tmp.keys())
_dff[['A', 'B', 'C', 'A1', 'B1', 'C1', 'A2', 'B2', 'C2']]

I got a result described below:

However I am interested in knowing whether it is possible to build a structure in pandas like the following:

Body:
What you're really looking at there is a three dimensional structure, which a dataframe cannot do.  (They're 2D only.)

This leaves you with a couple options:

(1) Multiple dataframes (pre/diff/sum).

dfs = {k:pd.DataFrame(v.items()) for k,v in _tmp.items()}

(2) A pandas Panel which you can build like:

pnl = pd.Panel(dfs)

Which is a way of grouping multiple dataframes.

(3) A 3d numpy matrix:

>>> pnl.as_matrix()
[[['A1' 10]
  ['C1' 20]
  ['B1' 15]]

 [['C2' 20]
  ['A2' 10]
  ['B2' 15]]

 [['A' 100]
  ['C' 200]
  ['B' 150]]]

You're going to have to write a custom print function to get your exact requested output of course, but these would be the ways you can represent your data.


问:
How do I specify the directory where NuGet packages are installed?
How to do to specify the directory where I want install package? Because I need install packages in a project where others devs work and when they do download of the project they need have all packages in your pc.</p>

答:
Use -OutputDirectory.

From NuGet CLI reference.


问:
jquery selector doesn't give all elements
In the next web page I want to select all
 elements with Jquery.
I want to select all the products that are inside

https://www.walmart.com/browse/home-improvement/air-quality/1072864_133032_1231459

I have tried:

```<code>$(".search-product-result ul li")
$("ul.search-result-gridview-items li")
</code>```

Also I have tried:

```<code>$("li")
$("ul li")
$("section li")
</code>```

to select all
 and none works.
All of them give one
 and not all.

Why this happens?

答:
Because the website is not using jQuery. console.log(window.jQuery) return undefined

Most probably the $ is bind to some function

You can use vanila javascript to get all elements using

```<code>document.querySelectorAll('ul.search-result-gridview-items li')
</code>```

Body:
In the next web page I want to select all
 elements with Jquery.
I want to select all the products that are inside

https://www.walmart.com/browse/home-improvement/air-quality/1072864_133032_1231459

I have tried:

$(".search-product-result ul li")
$("ul.search-result-gridview-items li")

Also I have tried:

$("li")
$("ul li")
$("section li")

to select all
 and none works.
All of them give one
 and not all.

Why this happens?

Body:
Because the website is not using jQuery. console.log(window.jQuery) return undefined

Most probably the $ is bind to some function

You can use vanila javascript to get all elements using

document.querySelectorAll('ul.search-result-gridview-items li')


问:
How do I write a SQL query to display course_id, course_name and fee collected from each course?
The various tables and their columns are:

1)Course

```<code>course_id
course_name
duration
fee
</code>```

2)Registration

```<code>course_id
stud_id
doj
</code>```

3)Student

```<code>stud_id
first_name
last name
city
dob
</code>```

I have tried:

```<code>SELECT
    C.COURSE_ID,
    C. COURSE_NAME,
    COUNT(R.COURSE_ID) * FEES AS TOTAL_FEES
FROM
    COURSE C,
    REGISTRATION R,
WHERE
    C.COURSE_ID = R.COURSE_ID
GROUP BY
    R.COURSE_ID
</code>```

答:
You can use a select on your group by query and then join it with the course table to use the rest of its fields.

```<code>SELECT aa.course_id, aa.course_name, aa.fee * _aa.total_registrations AS total_fees
FROM course AS aa
LEFT JOIN (
    SELECT course_id, COUNT(*) as total_registrations
    FROM registration
    GROUP BY course_id
) AS _aa
ON aa.course_id = _aa.course_id
ORDER BY aa.course_name ASC
</code>```

Body:
The various tables and their columns are:

1)Course

course_id
course_name
duration
fee

2)Registration

course_id
stud_id
doj

3)Student

stud_id
first_name
last name
city
dob

I have tried:

SELECT
    C.COURSE_ID,
    C. COURSE_NAME,
    COUNT(R.COURSE_ID) * FEES AS TOTAL_FEES
FROM
    COURSE C,
    REGISTRATION R,
WHERE
    C.COURSE_ID = R.COURSE_ID
GROUP BY
    R.COURSE_ID

Body:
You can use a select on your group by query and then join it with the course table to use the rest of its fields.

SELECT aa.course_id, aa.course_name, aa.fee * _aa.total_registrations AS total_fees
FROM course AS aa
LEFT JOIN (
    SELECT course_id, COUNT(*) as total_registrations
    FROM registration
    GROUP BY course_id
) AS _aa
ON aa.course_id = _aa.course_id
ORDER BY aa.course_name ASC


问:
jQuery validation cannot work properly
I am just new to jQuery. Now I am trying to use the validation method for the form, but I found that the page will not stop there to show the error message, rather than show the message 2 seconds, then submit the data and reload the page.

My HTML code:

```<code><form class="plform" id="pricelistform" method="get" action="" enctype="multipart/form-data">
<fieldset>
    <div id="add_item" class="overlay">
        <div class="popup">
            <h2 class="div_title">Add Item</h2>
            <a class="close" href="#">×</a>
            <hr class="heading_divide">
            <div class="content">
                <div class="control-group">
                    <div class="col-xs-12 col-sm-3">
                        <div class="control-label">
                            <label id="supply_search-lbl" for="supply_search" class="hasTooltip" title="" data-original-title="<strong>Existing Supplier</strong>Please select an existing supplier<br/>">Existing Supplier</label>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-9">
                        <div class="controls">
                            <select name="supplyerid[]" id="supply_search" class="input-medium form-control">
                                <option value="-1"><?php echo JText::_('--- Select Supplier ---');?></option>
                                <?php echo JHtml::_('select.options', JFormFieldSelect::getSupplier(),'id', 'companyname', $this->escape($this->state->get('filter.supply_search')));?>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <div class="con-xs-12 col-sm-3">
                        <div class="control-label">
                            <label id="product_name-lbl" for="product_name">Product Name<span class="star"> *</span></label>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-9">
                        <div class="controls">
                            <input type='text' name='productname[]' id="product_name" class="required form-control" aria-required="true"/>
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <div class="con-xs-12 col-sm-3">
                        <div class="control-label">
                            <label id="product_code-lbl" for="product_code">Product Code</label>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-9">
                        <div class="controls">
                            <input type='text' name='productcode[]' id="product_code" class="form-control"/>
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <div class="con-xs-12 col-sm-3">
                        <div class="control-label">
                            <label id="cost_price-lbl" for="cost_price">Cost Price<span class="star"> *</span></label>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-9">
                        <div class="controls">
                            <input type='text' name='costprice[]' id="cost_price" class="form-control" />
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <div class="con-xs-12 col-sm-3">
                        <div class="control-label">
                            <label id="sell_price-lbl" for="sell_price">Sell Price<span class="star"> *</span></label>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-9">
                        <div class="controls">
                            <input type='text' name='sellprice[]' id="sell_price" class="form-control" />
                        </div>
                    </div>
                </div>
                <div class="buttons">
                    <button type="submit" class="gs-btn-2 additem" id="add_btn">Add</button>
                </div>
            </div>
        </div>
    </div>
</fieldset></form>
</code>```

jQuery:

```<code>$(document).ready(function(){

//close add item popover
    $('.close').click(function(){
        e.preventDefault();
        $('.overlay','#add_item').hide();
    });

    //click button "Add" in add item popover
    $(".additem").on('click', function(){

    var temp={
        productname: pname.val(),
        productcode: pcode.val(),
        costprice: cprice.val(),
        sellprice: sprice.val(),
        accountid: accid.val(),
        warranty: warraty.val(),
    };

    //console.log(temp);
    $.ajax({
        type:'post',
        url:'index.php?option=com_gsprlist&task=additem.addItem',
        data:{data:temp},
        success:function(re){
            //console.log(re);
            $('.overlay').hide();

            },
            error:function(re){

                alert('error saving order');
            }
        });

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

Validation scripts:

```<code>$('#pricelistform').validate({
    rules:{
        'productname[]':{
            required:true,
            minlength:2
        },
        'costprice[]':"required",
        'sellprice[]':"required",
        'indiname':"required",
        'comname':"required",
        'indiphone':"required",
        'indiemail':"required",
        'accid[]':"required",

    },
    messages:{
        'productname[]':{
            required:"Please enter your productname",
            minlength:" Your product name must consist of at least 2 characters"
        },
        'costprice[]':"Please enter your cost price",
        'sellprice[]':"Please enter your sell price",
        'accid[]':"Please enter your Account ID",
    }
});
</code>```

答:
Why use more JavaScript, .preventDefault(), to solve a problem that wouldn't be occurring if you simply employed the correct type of button element in the first place?

Change the button into a type="button", and the submit event will not be  triggered.

```<code><button type="button" class="gs-btn-2 additem" id="add_btn">Add</button>
</code>```

Title: jQuery validation cannot work properly

Body:
I am just new to jQuery. Now I am trying to use the validation method for the form, but I found that the page will not stop there to show the error message, rather than show the message 2 seconds, then submit the data and reload the page.

My HTML code:

<form class="plform" id="pricelistform" method="get" action="" enctype="multipart/form-data">
<fieldset>

Add Item

            ×

                            <label id="supply_search-lbl" for="supply_search" class="hasTooltip" title="" data-original-title="Existing SupplierPlease select an existing supplier
">Existing Supplier

                            <select name="supplyerid[]" id="supply_search" class="input-medium form-control">
                                <option value="-1"><?php echo JText::_('--- Select Supplier ---');?></option>
                                <?php echo JHtml::_('select.options', JFormFieldSelect::getSupplier(),'id', 'companyname', $this->escape($this->state->get('filter.supply_search')));?>
                            </select>

                            Product Name *

                            <input type='text' name='productname[]' id="product_name" class="required form-control" aria-required="true"/>

                            Product Code

                            <input type='text' name='productcode[]' id="product_code" class="form-control"/>

                            Cost Price *

                            <input type='text' name='costprice[]' id="cost_price" class="form-control" />

                            Sell Price *

                            <input type='text' name='sellprice[]' id="sell_price" class="form-control" />

                    <button type="submit" class="gs-btn-2 additem" id="add_btn">Add</button>

</fieldset></form>

jQuery:

$(document).ready(function(){

//close add item popover
    $('.close').click(function(){
        e.preventDefault();
        $('.overlay','#add_item').hide();
    });

    //click button "Add" in add item popover
    $(".additem").on('click', function(){

    var temp={
        productname: pname.val(),
        productcode: pcode.val(),
        costprice: cprice.val(),
        sellprice: sprice.val(),
        accountid: accid.val(),
        warranty: warraty.val(),
    };

    //console.log(temp);
    $.ajax({
        type:'post',
        url:'index.php?option=com_gsprlist&task=additem.addItem',
        data:{data:temp},
        success:function(re){
            //console.log(re);
            $('.overlay').hide();

            },
            error:function(re){

                alert('error saving order');
            }
        });

    });
})

Validation scripts:

$('#pricelistform').validate({
    rules:{
        'productname[]':{
            required:true,
            minlength:2
        },
        'costprice[]':"required",
        'sellprice[]':"required",
        'indiname':"required",
        'comname':"required",
        'indiphone':"required",
        'indiemail':"required",
        'accid[]':"required",

    },
    messages:{
        'productname[]':{
            required:"Please enter your productname",
            minlength:" Your product name must consist of at least 2 characters"
        },
        'costprice[]':"Please enter your cost price",
        'sellprice[]':"Please enter your sell price",
        'accid[]':"Please enter your Account ID",
    }
});

Body:
Why use more JavaScript, .preventDefault(), to solve a problem that wouldn't be occurring if you simply employed the correct type of button element in the first place?

Change the button into a type="button", and the submit event will not be  triggered.

<button type="button" class="gs-btn-2 additem" id="add_btn">Add</button>


问:
how to use different formats to support different languages
In this link, it says that, to support different languages in your App you should follow the following format:

```<code><resource type>-b+<language code>[+<country code>]
</code>```

While in my project, I support different languages despite not using the previous format as shown in image-1 below.

(1): please let me know how to use the previous format? and what is the difference between it and the regular format which is as follows

```<code>values-es-rES
values-es
values-en-rUS
values-fr
</code>```

(2)As shown in image-1, all my supported strings are in one folder which is 'values', and it contains several 'strings.xml' as much as the languages the App supports. Now, what is the difference
between splitting the supported language files across different 'values' files as shown in the previous point, and placing the them inside one 'values' file as shown in image-1?

image-1:

image-2

答: You are probably using the same system but you're not seeing it. Do you see that select in image-1? The one at the top left of the image with "Android" written on it. Click on it and select "Project". Now navigate to your res/values folder.</p>

Body:
In this link, it says that, to support different languages in your App you should follow the following format:

<resource type>-b+<language code>[+<country code>]

While in my project, I support different languages despite not using the previous format as shown in image-1 below.

(1): please let me know how to use the previous format? and what is the difference between it and the regular format which is as follows

values-es-rES
values-es
values-en-rUS
values-fr

(2)As shown in image-1, all my supported strings are in one folder which is 'values', and it contains several 'strings.xml' as much as the languages the App supports. Now, what is the difference
between splitting the supported language files across different 'values' files as shown in the previous point, and placing the them inside one 'values' file as shown in image-1?

image-1:

image-2


问:
Is there a way to make my background iPhone app to go foreground?
Is there a way to make my background iPhone app to go foreground?

Tnx.

答:
A UILocalNotification will bring the app to the foreground if the device is locked, a notification appears, and the user unlocks the device.

A UILocalNotification with an alertAction will display the alert while the device is unlocked, and if the user taps the View button (or whatever you set it to), your app will be brought to the front.


问:
Manipulating the iphone triple-homebutton-click programmatically in xcode
So basically I'm wondering if it would be possible to programmatically manipulate the triple-click function on the iPhone. Basically, whenever you triple-click the home button you can choose in the settings between a few set actions to occur, like inverting colours, enabling zoom etc. I'm wondering if it's possible to programmatically implement any action to occur whenever the user triple-clicks on the home button.

答: Apple does not allow direct access to the home or lock buttons on the device plain and simple.</p>


问:
Angular 2/4 animate one item inside an array instead of all items
I am trying to build some meaningful motion for a portfolio. The goal is when a user clicks on a job item, the item pop up and grow. To do that, I believe I have to change the state of the clicked element inside an array, but when I click it now, it affects all states of all elements inside the array animating all together. Can anyone explain me whats happening and how to fix?

portfolio.component.ts

```<code>import { Component } from '@angular/core';
import { trigger,style,transition,animate,keyframes,state,query,stagger } from '@angular/animations';

export class Job {
  id: number;
  title: string;
}

const JOBS: Job[] = [
  { id: 11, title: 'Item 1' },
  { id: 12, title: 'Item 2' },
  { id: 13, title: 'Item 3' },
];

@Component({
  selector: 'portfolio',
  templateUrl: './portfolio.component.html',
  styleUrls: ['./portfolio.component.css'],
  animations: [
    trigger('enlarge', [
        state('small', style({
            height: '100px',
        })),
        state('large', style({
            height: '200px',
            background: 'red',
        })),
        transition('small <=> large',
        animate('1s ease-in')),
    ]),

  ]
})

export class PortfolioComponent {
    title   = 'Portfolio';
    jobs    = JOBS;

    state: string = 'small'

    enlarge() {
        this.state = (this.state === 'small' ? 'large' : 'small');
    }
}
</code>```

portfolio.component.html

```<code><div class="list"
*ngFor='let job of jobs'
[@enlarge]='state'
(click)="enlarge()">
    <div for="#">{{job.id}} - {{job.title}}</div>
</div>
</code>```

答:
Currently you assign the same state using the same variable to all items. What you need to do is to assign different state to each item.

Set a default state for all items:

```<code>this.jobs = this.jobs.map((job) => {
  job.state = "small";
  return job;
});
</code>```

Update your template:

Set [@enlarge]='state' to [@enlarge]='job.state'

Update your enlarge() method:

```<code>enlarge(index) {
let job = this.jobs[index].state;
job = (job === 'small' ? 'large' : 'small');
     }
</code>```

Body:
I am trying to build some meaningful motion for a portfolio. The goal is when a user clicks on a job item, the item pop up and grow. To do that, I believe I have to change the state of the clicked element inside an array, but when I click it now, it affects all states of all elements inside the array animating all together. Can anyone explain me whats happening and how to fix?

portfolio.component.ts

import { Component } from '@angular/core';
import { trigger,style,transition,animate,keyframes,state,query,stagger } from '@angular/animations';

export class Job {
  id: number;
  title: string;
}

const JOBS: Job[] = [
  { id: 11, title: 'Item 1' },
  { id: 12, title: 'Item 2' },
  { id: 13, title: 'Item 3' },
];

@Component({
  selector: 'portfolio',
  templateUrl: './portfolio.component.html',
  styleUrls: ['./portfolio.component.css'],
  animations: [
    trigger('enlarge', [
        state('small', style({
            height: '100px',
        })),
        state('large', style({
            height: '200px',
            background: 'red',
        })),
        transition('small <=> large',
        animate('1s ease-in')),
    ]),

  ]
})

export class PortfolioComponent {
    title   = 'Portfolio';
    jobs    = JOBS;

    state: string = 'small'

    enlarge() {
        this.state = (this.state === 'small' ? 'large' : 'small');
    }
}

portfolio.component.html

{{job.id}} - {{job.title}}

Body:
Currently you assign the same state using the same variable to all items. What you need to do is to assign different state to each item.

Set a default state for all items:

this.jobs = this.jobs.map((job) => {
  job.state = "small";
  return job;
});

Update your template:

Set [@enlarge]='state' to [@enlarge]='job.state'

Update your enlarge() method:

enlarge(index) {
let job = this.jobs[index].state;
job = (job === 'small' ? 'large' : 'small');
     }


问:
Development and debugging in Dynamics 365
I’ve upgraded a custom model to Dynamics 365, from Ax2012.  I’ve created deploy-able package and imported into an on-prem environment.
The machine on which I developed is different from the on-prem environment (TEST-env).

There is some functionality that is not working as it should, which I need to debug, and this is where I get stuck.
I’ve been developing in Ax from version 3 to 2012.  I am struggling to get comfortable and find my way in Visual Studio.

In a broad sense I guess my question is: how do I debug something as simple as a button click event on a form?  Can I run the form from Visual Studio and debug it there, without having to open the Dynamics 365 website?
Since my development environment and the on-prem D365 website (TEST-env) are on two different machines, is there an easy way to make changes to the code and have the TEST-env updated, or do I have to create a deployment package and import it into TEST-env for each change?

答:
To debug, you just create a project with your objects, right click on a form and click "Set as Startup Object" then go put a breakpoint (F9) on whatever line of code, and press F5 to run.

You could connect your Test version to VSTS and do code moves that way via branch/merging.


问:
how to post muilti parameters on reload jqgrid in mvc
In view i have a button to search when click, I want to reload data with new parammater.
Below is my script

```<code>      function SearchClick() {
        var byer = $('#cbbSearch').val();
        var start = $('#txtDate').val();
        var end = $("#txtEndDate").val();
        var search = $("#txtFind").val();
        myJqgrid.jqGrid('setGridParam', { postData: { byer: byer, start: start, end: end, search: search } }).trigger('reloadGrid');
    }
</code>```

my url on create Grid is:

```<code>url: '/UIControl/SearchList?byer=' + byer + '&start=' + start + '&end=' + end + '&search=' + search
</code>```

But in Controller the value start, end, search always null, only byer value is true. I don't know why?
Below is my Controller

```<code>        public ActionResult SearchList(string byer = "---", string start = "", string end = "", string search = "")
    {
        List<StyleSearch> lisData = SearchStyle(byer, start, end, search);
    }
</code>```

答:
On first look your code snippet looks fine. Could be some other issue, try using browser developer console (Inspect Element) this might show you some javascript error (if any).

There is another way to post form data back to server which I have used in one of my web application and till date its working fine without any issue. Please give a try and see if this works out.

```<code>myJqgrid.jqGrid('setGridParam', {
    postData: {
            byer: function () {
                return $("#cbbSearch").val();
            },
            start: function () {
                return $("#txtDate").val();
            },
            end: function () {
                return $("#txtEndDate").val();
            },
            search: function () {
                return $("#txtFind").val();
            },
        },
}).trigger('reloadGrid');
</code>```

Note: Since jQGrid is a free version there are many forks available on web like Trirand, Gurrido and by Oleg. The one I have used if official version by Tony Tomov (Trirand).

Body:
In view i have a button to search when click, I want to reload data with new parammater.
Below is my script

      function SearchClick() {
        var byer = $('#cbbSearch').val();
        var start = $('#txtDate').val();
        var end = $("#txtEndDate").val();
        var search = $("#txtFind").val();
        myJqgrid.jqGrid('setGridParam', { postData: { byer: byer, start: start, end: end, search: search } }).trigger('reloadGrid');
    }

my url on create Grid is:

url: '/UIControl/SearchList?byer=' + byer + '&start=' + start + '&end=' + end + '&search=' + search

But in Controller the value start, end, search always null, only byer value is true. I don't know why?
Below is my Controller

        public ActionResult SearchList(string byer = "---", string start = "", string end = "", string search = "")
    {
        List

Body:
On first look your code snippet looks fine. Could be some other issue, try using browser developer console (Inspect Element) this might show you some javascript error (if any).

There is another way to post form data back to server which I have used in one of my web application and till date its working fine without any issue. Please give a try and see if this works out.

myJqgrid.jqGrid('setGridParam', {
    postData: {
            byer: function () {
                return $("#cbbSearch").val();
            },
            start: function () {
                return $("#txtDate").val();
            },
            end: function () {
                return $("#txtEndDate").val();
            },
            search: function () {
                return $("#txtFind").val();
            },
        },
}).trigger('reloadGrid');

Note: Since jQGrid is a free version there are many forks available on web like Trirand, Gurrido and by Oleg. The one I have used if official version by Tony Tomov (Trirand).


问:
I want to be able to print stack traces java style in c
Simple question, I want to be able to print stack traces java style in c. I have the signal handlers set up and I get the stack trace addresses but I want to translate the addresses to the function names. Therefore, I decided to implement reflection. Right now I have tables as follows: {"FOO", &FOO, "BAR", &BAR}. While this solution works for all platforms, it is really annoying to keep up to date. Is there another way to do this (one that wouldnt require manual upkeep?)</p>

答:
You may want to look at solutions offered here:
http://bytes.com/topic/c/answers/219429-stacktrace-code-snippet-like-gdbs-bt

or here:
http://tlug.up.ac.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV


问:
export entire excel sheet to sql table with VBA
having issue sending entire sheet to sql table. I have tried 2 different ways as shown below. both work in different ways. Ultimately I am struggling with exporting multiple rows of data to sql DB

this 1st way I can import multiple rows to sql table successfully with one click of the button, only problem is that the StartTime and FinishTime come to sql table as 00:00:00 even if I enter a normal time in excel

```<code>Sub Button1_Click()
  Dim conn As New ADODB.Connection
  Dim iRowNo As Integer
  Dim sEventDate, sID, sDeptCode, sOpCode, sStartTime, sFinishTime, sUnits  As String

  With Sheets("Sheet1")
    'Open a connection to SQL Server
    conn.Open "Provider=SQLOLEDB;Data Source=db\db1;Initial Catalog=PTW;Integrated Security=SSPI;"
    'Skip the header row
    iRowNo = 2
    'Loop until empty cell in FirstName
    Do Until .Cells(iRowNo, 1) = ""
    sEventDate = .Cells(iRowNo, 1)
    sID = .Cells(iRowNo, 2)
    sDeptCode = .Cells(iRowNo, 3)
    sOpCode = .Cells(iRowNo, 4)
    sStartTime = .Cells(iRowNo, 5).Text
    sFinishTime = .Cells(iRowNo, 6).Text
    sUnits = .Cells(iRowNo, 7)
    'Generate and execute sql statement to import the excel rows to SQL Server table
    conn.Execute "insert into dbo.TimeLog (EventDate, ID, DeptCode, Opcode, StartTime, FinishTime, Units) values ('" & sEventDate & "', '" & sID & "', '" & sDeptCode & "', '" & sOpCode & "', cast('" & dStartTime & "' as datetime), cast('" & dFinishTime & "' as datetime), '" & sUnits & "')"

    iRowNo = iRowNo + 1

    Loop

    MsgBox "Data Successfully Exported."
    conn.Close
    Set conn = Nothing
  End With
End Sub
</code>```

this 2nd way works and sends the StartTime and FinishTime exactly as it is in excel table, but it only allows me to send one row to sql table at a time

```<code>Sub Button1_Click()
  Dim conn As ADODB.Connection
  Dim cmd As ADODB.Command
  Dim strSQL As String

  strSQL = "INSERT INTO dbo.TimeLog" & _
     "(EventDate, ID, DeptCode, Opcode, StartTime, FinishTime, Units) " & _
     "VALUES (?,?,?,?,?,?,?)"

Set conn = New ADODB.Connection
  conn.Open "Provider=SQLOLEDB;Data Source=db\db1;Initial Catalog=PTW;Integrated Security=SSPI;"

iRowNo = 1

Set cmd = New ADODB.Command

  cmd.ActiveConnection = conn
  cmd.CommandType = adCmdText
  cmd.CommandText = strSQL

With Sheets("Sheet1")
  'Loop until empty cell in FirstName
   Do Until .Cells(iRowNo, 1) = ""

  cmd.Parameters.Append _
    cmd.CreateParameter("pEventDate", adVarChar, adParamInput, 8, .Cells(iRowNo, 1))
  cmd.Parameters.Append _
    cmd.CreateParameter("pID", adInteger, adParamInput, , .Cells(iRowNo, 2))
  cmd.Parameters.Append _
    cmd.CreateParameter("pDeptCode", adVarChar, adParamInput, 2, .Cells(iRowNo, 3))
  cmd.Parameters.Append _
    cmd.CreateParameter("pOpCode", adVarChar, adParamInput, 2, .Cells(iRowNo, 4))
  cmd.Parameters.Append _
    cmd.CreateParameter("pStartTime", adDBTime, adParamInput, 0, .Cells(iRowNo, 5))
  cmd.Parameters.Append _
    cmd.CreateParameter("pFinishTime", adDBTime, adParamInput, 0, .Cells(iRowNo, 6))
  cmd.Parameters.Append _
    cmd.CreateParameter("pUnits", adInteger, adParamInput, , .Cells(iRowNo, 7))

  cmd.Execute

  iRowNo = iRowNo + 1
  Loop

  MsgBox "Data Successfully Exported"

End With

  conn.Close
  Set conn = Nothing
End Sub
</code>```

答:
Adding this inside the loop of the first script was the result I was looking for...</p>

```<code>    Set cmd = New ADODB.Command
    cmd.ActiveConnection = conn
    cmd.CommandType = adCmdText
    cmd.CommandText = strSQL
</code>```

Body:
having issue sending entire sheet to sql table. I have tried 2 different ways as shown below. both work in different ways. Ultimately I am struggling with exporting multiple rows of data to sql DB

this 1st way I can import multiple rows to sql table successfully with one click of the button, only problem is that the StartTime and FinishTime come to sql table as 00:00:00 even if I enter a normal time in excel

Sub Button1_Click()
  Dim conn As New ADODB.Connection
  Dim iRowNo As Integer
  Dim sEventDate, sID, sDeptCode, sOpCode, sStartTime, sFinishTime, sUnits  As String

  With Sheets("Sheet1")
    'Open a connection to SQL Server
    conn.Open "Provider=SQLOLEDB;Data Source=db\db1;Initial Catalog=PTW;Integrated Security=SSPI;"
    'Skip the header row
    iRowNo = 2
    'Loop until empty cell in FirstName
    Do Until .Cells(iRowNo, 1) = ""
    sEventDate = .Cells(iRowNo, 1)
    sID = .Cells(iRowNo, 2)
    sDeptCode = .Cells(iRowNo, 3)
    sOpCode = .Cells(iRowNo, 4)
    sStartTime = .Cells(iRowNo, 5).Text
    sFinishTime = .Cells(iRowNo, 6).Text
    sUnits = .Cells(iRowNo, 7)
    'Generate and execute sql statement to import the excel rows to SQL Server table
    conn.Execute "insert into dbo.TimeLog (EventDate, ID, DeptCode, Opcode, StartTime, FinishTime, Units) values ('" & sEventDate & "', '" & sID & "', '" & sDeptCode & "', '" & sOpCode & "', cast('" & dStartTime & "' as datetime), cast('" & dFinishTime & "' as datetime), '" & sUnits & "')"

    iRowNo = iRowNo + 1

    Loop

    MsgBox "Data Successfully Exported."
    conn.Close
    Set conn = Nothing
  End With
End Sub

this 2nd way works and sends the StartTime and FinishTime exactly as it is in excel table, but it only allows me to send one row to sql table at a time

Sub Button1_Click()
  Dim conn As ADODB.Connection
  Dim cmd As ADODB.Command
  Dim strSQL As String

  strSQL = "INSERT INTO dbo.TimeLog" & _
     "(EventDate, ID, DeptCode, Opcode, StartTime, FinishTime, Units) " & _
     "VALUES (?,?,?,?,?,?,?)"

Set conn = New ADODB.Connection
  conn.Open "Provider=SQLOLEDB;Data Source=db\db1;Initial Catalog=PTW;Integrated Security=SSPI;"

iRowNo = 1

Set cmd = New ADODB.Command

  cmd.ActiveConnection = conn
  cmd.CommandType = adCmdText
  cmd.CommandText = strSQL

With Sheets("Sheet1")
  'Loop until empty cell in FirstName
   Do Until .Cells(iRowNo, 1) = ""

  cmd.Parameters.Append _
    cmd.CreateParameter("pEventDate", adVarChar, adParamInput, 8, .Cells(iRowNo, 1))
  cmd.Parameters.Append _
    cmd.CreateParameter("pID", adInteger, adParamInput, , .Cells(iRowNo, 2))
  cmd.Parameters.Append _
    cmd.CreateParameter("pDeptCode", adVarChar, adParamInput, 2, .Cells(iRowNo, 3))
  cmd.Parameters.Append _
    cmd.CreateParameter("pOpCode", adVarChar, adParamInput, 2, .Cells(iRowNo, 4))
  cmd.Parameters.Append _
    cmd.CreateParameter("pStartTime", adDBTime, adParamInput, 0, .Cells(iRowNo, 5))
  cmd.Parameters.Append _
    cmd.CreateParameter("pFinishTime", adDBTime, adParamInput, 0, .Cells(iRowNo, 6))
  cmd.Parameters.Append _
    cmd.CreateParameter("pUnits", adInteger, adParamInput, , .Cells(iRowNo, 7))

  cmd.Execute

  iRowNo = iRowNo + 1
  Loop

  MsgBox "Data Successfully Exported"

End With

  conn.Close
  Set conn = Nothing
End Sub

Body:
Adding this inside the loop of the first script was the result I was looking for...

    Set cmd = New ADODB.Command
    cmd.ActiveConnection = conn
    cmd.CommandType = adCmdText
    cmd.CommandText = strSQL