问:
Formatting URLs in list to all have a trailing slash in python
There's some similar questions to this on stackoverflow but none do exactly what I want and my various attempts seem to fail.

I have a list of urls, some have trailing slash, others not... I want to check them and add a slash to those that don't.

```<code>url_list = ['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

for url in url_list:
    if url[len(url)-1] != "/":
        url = url + "/"
    else:
        url = url

print url_list
</code>```

returns the same list (last two urls still don't have a trailing slash)

```<code>['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']
</code>```

why isn't it working? any ideas?

thanks :)

答:
You are not changing url_list. To keep the initial structure of your code, you could try this:

```<code>url_list = ['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

new_urls = []
for url in url_list:
    if url[len(url)-1] != "/":
        new_urls.append(url + "/")
    else:
        new_urls.append(url)
url_list = new_urls

print url_list
</code>```

You could also use .endswith() as suggested in another answer:

```<code>url_list = ['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

new_urls = []
for url in url_list:
    if url.endswith('/'):
        new_urls.append(url)
    else:
        new_urls.append(url + "/")
url_list = new_urls

print url_list
</code>```

Body:
There's some similar questions to this on stackoverflow but none do exactly what I want and my various attempts seem to fail.

I have a list of urls, some have trailing slash, others not... I want to check them and add a slash to those that don't.

url_list = ['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

for url in url_list:
    if url[len(url)-1] != "/":
        url = url + "/"
    else:
        url = url

print url_list

returns the same list (last two urls still don't have a trailing slash)

['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

why isn't it working? any ideas?

thanks :)

Body:
You are not changing url_list. To keep the initial structure of your code, you could try this:

url_list = ['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

new_urls = []
for url in url_list:
    if url[len(url)-1] != "/":
        new_urls.append(url + "/")
    else:
        new_urls.append(url)
url_list = new_urls

print url_list

You could also use .endswith() as suggested in another answer:

url_list = ['http://google.com/somedirectory/', 'http://google.com/someotherdirectory/', 'http://google.com/anotherdirectory', 'http://google.com/yetanotherdirectory']

new_urls = []
for url in url_list:
    if url.endswith('/'):
        new_urls.append(url)
    else:
        new_urls.append(url + "/")
url_list = new_urls

print url_list


来源: stackexchange

问:
Explode array data into rows in spark
I have a dataset in the following way:

```<code>FieldA    FieldB    ArrayField
1         A         {1,2,3}
2         B         {3,5}
</code>```

I would like to explode the data on ArrayField so the output will look in the following way:

```<code>FieldA    FieldB    ExplodedField
1         A         1
1         A         2
1         A         3
2         B         3
2         B         5
</code>```

I mean I want to generate an output line for each item in the array the in ArrayField while keeping the values of the other fields.

How would you implement it in Spark.
Notice that the input dataset is very large.

答:
explode does exactly what you want.  Docs:

http://spark.apache.org/docs/latest/api/python/pyspark.sql.html#pyspark.sql.functions.explode

Also, here is an example from a different question using it:

https://stackoverflow.com/a/44418598/1461187

ContentLicense: CC BY-SA 3.0

Title: Explode array data into rows in spark

Body:
I have a dataset in the following way:

FieldA    FieldB    ArrayField
1         A         {1,2,3}
2         B         {3,5}

I would like to explode the data on ArrayField so the output will look in the following way:

FieldA    FieldB    ExplodedField
1         A         1
1         A         2
1         A         3
2         B         3
2         B         5

I mean I want to generate an output line for each item in the array the in ArrayField while keeping the values of the other fields.

How would you implement it in Spark.
Notice that the input dataset is very large.


问:
Best way to find the correct load time of a webpage with Jmeter
I am doing performance testing of a website.

I see two options, but I'm confused about which one is right:

Simply hit website Url and under HTTP Request Defaults check Retrieve all Embedded resources.

Use Jmeter Http recorder, and under Url patterns to exclude, check Add suggested excludes.

Any suggestions would be helpful.

答:
I would recommend the following:

Start with your option 1

Tick Parallel downloads

Put 6 in the number of threads for parallel downloading

Filter out all external resources via URLs must match section. If your application makes outside calls to images, banners, etc. you need to filter out them so your load test would focus solely on your application domain(s), example exclusions look like:

```<code>^((?!google|facebook|pinterest|twimg|doubleclick|whatever).)*$
</code>```

amend the line according to your needs

Add HTTP Cache Manager to mimic browser cache. Real browsers download these "embedded resources" but do it only once, on subsequent requests the resources are being returned from memory or disk cache and no actual requests to the server are being made

Don't forget HTTP Cookie Manager and HTTP Header Manager to represent browser cookies and headers

If your application uses AJAX requests you need to simulate them as well as JMeter is not a browser and it doesn't execute client-side JavaScript

More information: How To Make JMeter Behave More Like A Real Browser

Body:
I would recommend the following:

Start with your option 1

Tick Parallel downloads

Put 6 in the number of threads for parallel downloading

Filter out all external resources via URLs must match section. If your application makes outside calls to images, banners, etc. you need to filter out them so your load test would focus solely on your application domain(s), example exclusions look like:

^((?!google|facebook|pinterest|twimg|doubleclick|whatever).)*$

amend the line according to your needs

Add HTTP Cache Manager to mimic browser cache. Real browsers download these "embedded resources" but do it only once, on subsequent requests the resources are being returned from memory or disk cache and no actual requests to the server are being made

Don't forget HTTP Cookie Manager and HTTP Header Manager to represent browser cookies and headers

If your application uses AJAX requests you need to simulate them as well as JMeter is not a browser and it doesn't execute client-side JavaScript

More information: How To Make JMeter Behave More Like A Real Browser


问:
Android achartengine doughnut chart
Hi all I am trying to reduce the inner radius of doughnut chart in Android development by using achartengine. I declared my chart layout as such:

```<code><LinearLayout
      android:id="@+id/doughtnut_chart"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal">
</LinearLayout>
</code>```

Then, I customized the renderer by using this:

```<code>renderer.setScale((float)1.4);
</code>```

However, the radius of the circle is not reducing. I can't find any solution online either.

Any ideas? Thanks in advance.

答:
The renderer.setScale() is the correct API to use for reducing the size, the parameter should probably be something smaller than 1.

Once done this, just call mChartView.repaint() in order to do the visual refresh, in case you are modifying the size during runtime.

Title: Android achartengine doughnut chart

Body:
Hi all I am trying to reduce the inner radius of doughnut chart in Android development by using achartengine. I declared my chart layout as such:

<LinearLayout
      android:id="@+id/doughtnut_chart"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal">
</LinearLayout>

Then, I customized the renderer by using this:

renderer.setScale((float)1.4);

However, the radius of the circle is not reducing. I can't find any solution online either.

Any ideas? Thanks in advance.


问:
Change date format for ui datepicker (jHipster)
I've generated a Spring Boot + Angular 1 based project in jHipster. I'm kind of newbie the Angular world. Everything works fine, but when I input the date using the provided UI datepicker (https://angular-ui.github.io/bootstrap), its format is yyyy-MM-dd, even if I've defined spanish to be my only language package (I would prefer it to be dd/MM/yyyy). That's the code snippet for the input:

regulation-version-dialog.html

```<code><div class="form-group">
    <label class="control-label"
        data-translate="selfprotectionApp.regulationVersion.versionDate"
        for="field_versionDate">Version Date</label>
    <div class="input-group">
        <input id="field_versionDate" type="text" class="form-control"
            name="versionDate" uib-datepicker-popup="{{dateformat}}"
            ng-model="vm.regulationVersion.versionDate"
            is-open="vm.datePickerOpenStatus.versionDate" /> <span
            class="input-group-btn">
            <button type="button" class="btn btn-default"
                ng-click="vm.openCalendar('versionDate')">
                <i class="glyphicon glyphicon-calendar"></i>
            </button>
        </span>
    </div>
</div>
</code>```

Here there's the {{dateformat}} binding, but I don't know where jHipster picks it from. The only matches are in the date-util.service.js file, but changing the format here doesn't seem to affect.

date-util.service.js

```<code>(function() {
    'use strict';

    angular
        .module('selfprotectionApp')
        .factory('DateUtils', DateUtils);

    DateUtils.$inject = ['$filter'];

    function DateUtils($filter) {

        var service = {
            convertDateTimeFromServer: convertDateTimeFromServer,
            convertLocalDateFromServer: convertLocalDateFromServer,
            convertLocalDateToServer: convertLocalDateToServer,
            dateformat: dateformat
        };

        return service;

        function convertDateTimeFromServer(date) {
            if (date) {
                return new Date(date);
            } else {
                return null;
            }
        }

        function convertLocalDateFromServer(date) {
            if (date) {
                var dateString = date.split('-');
                return new Date(dateString[0], dateString[1] - 1, dateString[2]);
            }
            return null;
        }

        function convertLocalDateToServer(date) {
            if (date) {
                return $filter('date')(date, 'yyyy-MM-dd');
            } else {
                return null;
            }
        }

        function dateformat() {
            return 'yyyy-MM-dd';
        }
    }

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

Of course, I could replace the {{dateformat}} expression by some date format in HTML, but I would like to do it for the whole project.

答:
There is no default way in angular JS to set up dateformat from a provider for example for the complete project.

What you could do; is define a filter with your format to be used like that : {{dateformat | date:'MM/dd/yyyy'}}
OR define a global filter for that requirement to make it more easy to type (source https://stackoverflow.com/a/18402623/3687474 )

```<code>.filter('myDate', function($filter) {
    var angularDateFilter = $filter('date');
    return function(theDate) {
       return angularDateFilter(theDate, 'dd MMMM @ HH:mm:ss');
    }
});
</code>```

and used it like that : {{dateformat | myDate }}

The ultimate solution is to used a very robust library to manage your dates such as moment.js and it angularjs diretives
this is my favorite solution; as it is more scalable for many uses and date manipulation.
However; adding libraries to your project has always a performance cost ;)

Body:
I've generated a Spring Boot + Angular 1 based project in jHipster. I'm kind of newbie the Angular world. Everything works fine, but when I input the date using the provided UI datepicker (https://angular-ui.github.io/bootstrap), its format is yyyy-MM-dd, even if I've defined spanish to be my only language package (I would prefer it to be dd/MM/yyyy). That's the code snippet for the input:

regulation-version-dialog.html

    Version Date

        <input id="field_versionDate" type="text" class="form-control"
            name="versionDate" uib-datepicker-popup="{{dateformat}}"
            ng-model="vm.regulationVersion.versionDate"
            is-open="vm.datePickerOpenStatus.versionDate" />
            <button type="button" class="btn btn-default"
                ng-click="vm.openCalendar('versionDate')">

            </button>

Here there's the {{dateformat}} binding, but I don't know where jHipster picks it from. The only matches are in the date-util.service.js file, but changing the format here doesn't seem to affect.

date-util.service.js

(function() {
    'use strict';

    angular
        .module('selfprotectionApp')
        .factory('DateUtils', DateUtils);

    DateUtils.$inject = ['$filter'];

    function DateUtils($filter) {

        var service = {
            convertDateTimeFromServer: convertDateTimeFromServer,
            convertLocalDateFromServer: convertLocalDateFromServer,
            convertLocalDateToServer: convertLocalDateToServer,
            dateformat: dateformat
        };

        return service;

        function convertDateTimeFromServer(date) {
            if (date) {
                return new Date(date);
            } else {
                return null;
            }
        }

        function convertLocalDateFromServer(date) {
            if (date) {
                var dateString = date.split('-');
                return new Date(dateString[0], dateString[1] - 1, dateString[2]);
            }
            return null;
        }

        function convertLocalDateToServer(date) {
            if (date) {
                return $filter('date')(date, 'yyyy-MM-dd');
            } else {
                return null;
            }
        }

        function dateformat() {
            return 'yyyy-MM-dd';
        }
    }

})();

Of course, I could replace the {{dateformat}} expression by some date format in HTML, but I would like to do it for the whole project.

Body:
There is no default way in angular JS to set up dateformat from a provider for example for the complete project.

What you could do; is define a filter with your format to be used like that : {{dateformat | date:'MM/dd/yyyy'}}
OR define a global filter for that requirement to make it more easy to type (source https://stackoverflow.com/a/18402623/3687474 )

.filter('myDate', function($filter) {
    var angularDateFilter = $filter('date');
    return function(theDate) {
       return angularDateFilter(theDate, 'dd MMMM @ HH:mm:ss');
    }
});

and used it like that : {{dateformat | myDate }}

The ultimate solution is to used a very robust library to manage your dates such as moment.js and it angularjs diretives
this is my favorite solution; as it is more scalable for many uses and date manipulation.
However; adding libraries to your project has always a performance cost ;)


问:
Using conditional operators in v-model?
I have a vue component that shows a form populated with items from a selected item to edit. Now I don't want to have to use a second form for creating a new item. At the moment I auto populate and update the item with v-model which obviously updates the object. Am I not able to use conditional operators in this like so?</p>

```<code><form @submit.prevent>
  <div class="field">
    <label class="label">Job Title</label>

    <p class="control">
      <input type="text" class="input" placeholder="Job title" v-model="experiences[editIndex].title ? experiences[editIndex].title : ''" />
    </p>
  </div>
</form>
</code>```

答:
You can use conditional operators with v-model, but you can't give v-model a string like you're attempting in your example.

I wouldn't use the same form for editing and creating (might be preference). I would make the form its own component and then make two additional form components for editing and creating.

However, if you really want to handle the logic in each input's v-model directive, you would need to give it a variable in the last part of the ternary operator. Something like this:

```<code>v-model="experiences[i].title ? experiences[i].title : newExperience.title"
</code>```

Title: Using conditional operators in v-model?

Body:
I have a vue component that shows a form populated with items from a selected item to edit. Now I don't want to have to use a second form for creating a new item. At the moment I auto populate and update the item with v-model which obviously updates the object. Am I not able to use conditional operators in this like so?

<form @submit.prevent>

    Job Title

      <input type="text" class="input" placeholder="Job title" v-model="experiences[editIndex].title ? experiences[editIndex].title : ''" />

</form>

Body:
You can use conditional operators with v-model, but you can't give v-model a string like you're attempting in your example.

I wouldn't use the same form for editing and creating (might be preference). I would make the form its own component and then make two additional form components for editing and creating.

However, if you really want to handle the logic in each input's v-model directive, you would need to give it a variable in the last part of the ternary operator. Something like this:

v-model="experiences[i].title ? experiences[i].title : newExperience.title"


问:
Can't get radio button styling to work in plunker
I'm trying to get the skewed radio button style found here (https://codepen.io/anon/pen/yXNopJ) to work in my project. Visually it looks right but doesn't do anything on click. So to debug I thought I'd place this in plunker and play around with it in an isolated area. However when I copy and paste the html and css into Plunker the visuals don't work. Can anyone see why the visuals don't work in plunker but do in codepen?

http://plnkr.co/edit/IPiDZdLS51UzAwUcQZHp?p=preview

HTML

```<code><h2>Toggle 'em</h2>
<ul class="tg-list">
  <li class="tg-list-item">
    <h4>Light</h4>
    <input class="tgl tgl-light" id="cb1" type="checkbox"/>
    <label class="tgl-btn" for="cb1"></label>
  </li>
  <li class="tg-list-item">
    <h4>iOS</h4>
    <input class="tgl tgl-ios" id="cb2" type="checkbox"/>
    <label class="tgl-btn" for="cb2"></label>
  </li>
  <li class="tg-list-item">
    <h4>Skewed</h4>
    <input class="tgl tgl-skewed" id="cb3" type="checkbox"/>
    <label class="tgl-btn" data-tg-off="OFF" data-tg-on="ON" for="cb3"></label>
  </li>
  <li class="tg-list-item">
    <h4>Flat</h4>
    <input class="tgl tgl-flat" id="cb4" type="checkbox"/>
    <label class="tgl-btn" for="cb4"></label>
  </li>
  <li class="tg-list-item">
    <h4>Flip</h4>
    <input class="tgl tgl-flip" id="cb5" type="checkbox"/>
    <label class="tgl-btn" data-tg-off="Nope" data-tg-on="Yeah!" for="cb5"></label>
  </li>
</ul>
</code>```

CSS

```<code>html, body {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  min-height: 100%;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  font-family: sans-serif;
}

ul, li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tg-list {
  text-align: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}

.tg-list-item {
  margin: 0 2em;
}

h2 {
  color: #777;
}

h4 {
  color: #999;
}

.tgl {
  display: none;
}
.tgl, .tgl:after, .tgl:before, .tgl *, .tgl *:after, .tgl *:before, .tgl + .tgl-btn {
  box-sizing: border-box;
}
.tgl::-moz-selection, .tgl:after::-moz-selection, .tgl:before::-moz-selection, .tgl *::-moz-selection, .tgl *:after::-moz-selection, .tgl *:before::-moz-selection, .tgl + .tgl-btn::-moz-selection {
  background: none;
}
.tgl::selection, .tgl:after::selection, .tgl:before::selection, .tgl *::selection, .tgl *:after::selection, .tgl *:before::selection, .tgl + .tgl-btn::selection {
  background: none;
}
.tgl + .tgl-btn {
  outline: 0;
  display: block;
  width: 4em;
  height: 2em;
  position: relative;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}
.tgl + .tgl-btn:after, .tgl + .tgl-btn:before {
  position: relative;
  display: block;
  content: "";
  width: 50%;
  height: 100%;
}
.tgl + .tgl-btn:after {
  left: 0;
}
.tgl + .tgl-btn:before {
  display: none;
}
.tgl:checked + .tgl-btn:after {
  left: 50%;
}

.tgl-light + .tgl-btn {
  background: #f0f0f0;
  border-radius: 2em;
  padding: 2px;
  -webkit-transition: all .4s ease;
  transition: all .4s ease;
}
.tgl-light + .tgl-btn:after {
  border-radius: 50%;
  background: #fff;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
}
.tgl-light:checked + .tgl-btn {
  background: #9FD6AE;
}

.tgl-ios + .tgl-btn {
  background: #fbfbfb;
  border-radius: 2em;
  padding: 2px;
  -webkit-transition: all .4s ease;
  transition: all .4s ease;
  border: 1px solid #e8eae9;
}
.tgl-ios + .tgl-btn:after {
  border-radius: 2em;
  background: #fbfbfb;
  -webkit-transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;
  transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 0 rgba(0, 0, 0, 0.08);
}
.tgl-ios + .tgl-btn:hover:after {
  will-change: padding;
}
.tgl-ios + .tgl-btn:active {
  box-shadow: inset 0 0 0 2em #e8eae9;
}
.tgl-ios + .tgl-btn:active:after {
  padding-right: .8em;
}
.tgl-ios:checked + .tgl-btn {
  background: #86d993;
}
.tgl-ios:checked + .tgl-btn:active {
  box-shadow: none;
}
.tgl-ios:checked + .tgl-btn:active:after {
  margin-left: -.8em;
}

.tgl-skewed + .tgl-btn {
  overflow: hidden;
  -webkit-transform: skew(-10deg);
          transform: skew(-10deg);
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  font-family: sans-serif;
  background: #888;
}
.tgl-skewed + .tgl-btn:after, .tgl-skewed + .tgl-btn:before {
  -webkit-transform: skew(10deg);
          transform: skew(10deg);
  display: inline-block;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  width: 100%;
  text-align: center;
  position: absolute;
  line-height: 2em;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.tgl-skewed + .tgl-btn:after {
  left: 100%;
  content: attr(data-tg-on);
}
.tgl-skewed + .tgl-btn:before {
  left: 0;
  content: attr(data-tg-off);
}
.tgl-skewed + .tgl-btn:active {
  background: #888;
}
.tgl-skewed + .tgl-btn:active:before {
  left: -10%;
}
.tgl-skewed:checked + .tgl-btn {
  background: #86d993;
}
.tgl-skewed:checked + .tgl-btn:before {
  left: -100%;
}
.tgl-skewed:checked + .tgl-btn:after {
  left: 0;
}
.tgl-skewed:checked + .tgl-btn:active:after {
  left: 10%;
}

.tgl-flat + .tgl-btn {
  padding: 2px;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  background: #fff;
  border: 4px solid #f2f2f2;
  border-radius: 2em;
}
.tgl-flat + .tgl-btn:after {
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  background: #f2f2f2;
  content: "";
  border-radius: 1em;
}
.tgl-flat:checked + .tgl-btn {
  border: 4px solid #7FC6A6;
}
.tgl-flat:checked + .tgl-btn:after {
  left: 50%;
  background: #7FC6A6;
}

.tgl-flip + .tgl-btn {
  padding: 2px;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  font-family: sans-serif;
  -webkit-perspective: 100px;
          perspective: 100px;
}
.tgl-flip + .tgl-btn:after, .tgl-flip + .tgl-btn:before {
  display: inline-block;
  -webkit-transition: all .4s ease;
  transition: all .4s ease;
  width: 100%;
  text-align: center;
  position: absolute;
  line-height: 2em;
  font-weight: bold;
  color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  border-radius: 4px;
}
.tgl-flip + .tgl-btn:after {
  content: attr(data-tg-on);
  background: #02C66F;
  -webkit-transform: rotateY(-180deg);
          transform: rotateY(-180deg);
}
.tgl-flip + .tgl-btn:before {
  background: #FF3A19;
  content: attr(data-tg-off);
}
.tgl-flip + .tgl-btn:active:before {
  -webkit-transform: rotateY(-20deg);
          transform: rotateY(-20deg);
}
.tgl-flip:checked + .tgl-btn:before {
  -webkit-transform: rotateY(180deg);
          transform: rotateY(180deg);
}
.tgl-flip:checked + .tgl-btn:after {
  -webkit-transform: rotateY(0);
          transform: rotateY(0);
  left: 0;
  background: #7FC6A6;
}
.tgl-flip:checked + .tgl-btn:active:after {
  -webkit-transform: rotateY(20deg);
          transform: rotateY(20deg);
}
</code>```

答:
Apparently in plnkr you need to link to the css file.

Like:

```<code><!doctype html>
<html>
<head>
  <link href="style.css" rel="stylesheet"/>
</head>
</code>```

Body:
I'm trying to get the skewed radio button style found here (https://codepen.io/anon/pen/yXNopJ) to work in my project. Visually it looks right but doesn't do anything on click. So to debug I thought I'd place this in plunker and play around with it in an isolated area. However when I copy and paste the html and css into Plunker the visuals don't work. Can anyone see why the visuals don't work in plunker but do in codepen?

http://plnkr.co/edit/IPiDZdLS51UzAwUcQZHp?p=preview

HTML

Toggle 'em

Light

    <input class="tgl tgl-light" id="cb1" type="checkbox"/>

iOS

    <input class="tgl tgl-ios" id="cb2" type="checkbox"/>

Skewed

    <input class="tgl tgl-skewed" id="cb3" type="checkbox"/>

Flat

    <input class="tgl tgl-flat" id="cb4" type="checkbox"/>

Flip

    <input class="tgl tgl-flip" id="cb5" type="checkbox"/>

CSS

html, body {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  min-height: 100%;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  font-family: sans-serif;
}

ul, li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tg-list {
  text-align: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}

.tg-list-item {
  margin: 0 2em;
}

h2 {
  color: #777;
}

h4 {
  color: #999;
}

.tgl {
  display: none;
}
.tgl, .tgl:after, .tgl:before, .tgl *, .tgl *:after, .tgl *:before, .tgl + .tgl-btn {
  box-sizing: border-box;
}
.tgl::-moz-selection, .tgl:after::-moz-selection, .tgl:before::-moz-selection, .tgl *::-moz-selection, .tgl *:after::-moz-selection, .tgl *:before::-moz-selection, .tgl + .tgl-btn::-moz-selection {
  background: none;
}
.tgl::selection, .tgl:after::selection, .tgl:before::selection, .tgl *::selection, .tgl *:after::selection, .tgl *:before::selection, .tgl + .tgl-btn::selection {
  background: none;
}
.tgl + .tgl-btn {
  outline: 0;
  display: block;
  width: 4em;
  height: 2em;
  position: relative;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}
.tgl + .tgl-btn:after, .tgl + .tgl-btn:before {
  position: relative;
  display: block;
  content: "";
  width: 50%;
  height: 100%;
}
.tgl + .tgl-btn:after {
  left: 0;
}
.tgl + .tgl-btn:before {
  display: none;
}
.tgl:checked + .tgl-btn:after {
  left: 50%;
}

.tgl-light + .tgl-btn {
  background: #f0f0f0;
  border-radius: 2em;
  padding: 2px;
  -webkit-transition: all .4s ease;
  transition: all .4s ease;
}
.tgl-light + .tgl-btn:after {
  border-radius: 50%;
  background: #fff;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
}
.tgl-light:checked + .tgl-btn {
  background: #9FD6AE;
}

.tgl-ios + .tgl-btn {
  background: #fbfbfb;
  border-radius: 2em;
  padding: 2px;
  -webkit-transition: all .4s ease;
  transition: all .4s ease;
  border: 1px solid #e8eae9;
}
.tgl-ios + .tgl-btn:after {
  border-radius: 2em;
  background: #fbfbfb;
  -webkit-transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;
  transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 0 rgba(0, 0, 0, 0.08);
}
.tgl-ios + .tgl-btn:hover:after {
  will-change: padding;
}
.tgl-ios + .tgl-btn:active {
  box-shadow: inset 0 0 0 2em #e8eae9;
}
.tgl-ios + .tgl-btn:active:after {
  padding-right: .8em;
}
.tgl-ios:checked + .tgl-btn {
  background: #86d993;
}
.tgl-ios:checked + .tgl-btn:active {
  box-shadow: none;
}
.tgl-ios:checked + .tgl-btn:active:after {
  margin-left: -.8em;
}

.tgl-skewed + .tgl-btn {
  overflow: hidden;
  -webkit-transform: skew(-10deg);
          transform: skew(-10deg);
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  font-family: sans-serif;
  background: #888;
}
.tgl-skewed + .tgl-btn:after, .tgl-skewed + .tgl-btn:before {
  -webkit-transform: skew(10deg);
          transform: skew(10deg);
  display: inline-block;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  width: 100%;
  text-align: center;
  position: absolute;
  line-height: 2em;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.tgl-skewed + .tgl-btn:after {
  left: 100%;
  content: attr(data-tg-on);
}
.tgl-skewed + .tgl-btn:before {
  left: 0;
  content: attr(data-tg-off);
}
.tgl-skewed + .tgl-btn:active {
  background: #888;
}
.tgl-skewed + .tgl-btn:active:before {
  left: -10%;
}
.tgl-skewed:checked + .tgl-btn {
  background: #86d993;
}
.tgl-skewed:checked + .tgl-btn:before {
  left: -100%;
}
.tgl-skewed:checked + .tgl-btn:after {
  left: 0;
}
.tgl-skewed:checked + .tgl-btn:active:after {
  left: 10%;
}

.tgl-flat + .tgl-btn {
  padding: 2px;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  background: #fff;
  border: 4px solid #f2f2f2;
  border-radius: 2em;
}
.tgl-flat + .tgl-btn:after {
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  background: #f2f2f2;
  content: "";
  border-radius: 1em;
}
.tgl-flat:checked + .tgl-btn {
  border: 4px solid #7FC6A6;
}
.tgl-flat:checked + .tgl-btn:after {
  left: 50%;
  background: #7FC6A6;
}

.tgl-flip + .tgl-btn {
  padding: 2px;
  -webkit-transition: all .2s ease;
  transition: all .2s ease;
  font-family: sans-serif;
  -webkit-perspective: 100px;
          perspective: 100px;
}
.tgl-flip + .tgl-btn:after, .tgl-flip + .tgl-btn:before {
  display: inline-block;
  -webkit-transition: all .4s ease;
  transition: all .4s ease;
  width: 100%;
  text-align: center;
  position: absolute;
  line-height: 2em;
  font-weight: bold;
  color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  border-radius: 4px;
}
.tgl-flip + .tgl-btn:after {
  content: attr(data-tg-on);
  background: #02C66F;
  -webkit-transform: rotateY(-180deg);
          transform: rotateY(-180deg);
}
.tgl-flip + .tgl-btn:before {
  background: #FF3A19;
  content: attr(data-tg-off);
}
.tgl-flip + .tgl-btn:active:before {
  -webkit-transform: rotateY(-20deg);
          transform: rotateY(-20deg);
}
.tgl-flip:checked + .tgl-btn:before {
  -webkit-transform: rotateY(180deg);
          transform: rotateY(180deg);
}
.tgl-flip:checked + .tgl-btn:after {
  -webkit-transform: rotateY(0);
          transform: rotateY(0);
  left: 0;
  background: #7FC6A6;
}
.tgl-flip:checked + .tgl-btn:active:after {
  -webkit-transform: rotateY(20deg);
          transform: rotateY(20deg);
}

Body:
Apparently in plnkr you need to link to the css file.

Like:

<!doctype html>
<html>
<head>
  <link href="style.css" rel="stylesheet"/>
</head>


问:
Are there any tools to optimize the number of consumer and producer threads on a JMS queue?
I'm working on an application that is distributed over two JBoss instances and that produces/consumes JMS messages on several JMS queues.

When we configured the application we had to determine which threading model we would use, in particular the number of producing and consuming threads per queue. We have done this in a rather ad-hoc fashion but after reading the most recent columns by Herb Sutter in Dr Dobbs (in particular this one) I would like to size our threads in a more rigorous manner.

Are there any methods/tools to measure the throughput of JMS queues (in particular JBoss Messaging queues) as a function of the number of producing/consuming threads?

答:
I've got the perfect thing for you: IBM provide a free command line tool called perfharness.

It's aimed at benchmarking JMS providers, i.e. measuring the throughput of queues (single or multiple) given different numbers of producing or consuming threads.

Some features:

Send and consume messages at a fixed rate (msg/s) or at maximum rate possible on the queue

Use a specific number of threads

Use either JMS or native MQ

Can use data either generated randomly or taken from a file

Generates statistics telling you exactly how fast your queue is performing

The only down side is that it's not super intuitive, given the number of operations it supports. And IBM haven't open sourced it, which is a shame. However it sounds perfect for your purposes.

OwnerDisplayName: lindelof

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Air


问:
Is there a workaround for Firefox not calling onunload when a window is closed?
As some of you know Firefox does not call onunload in if the window or tab is closed.  Do you know of any sort of work around?

Basically, I need to know that user is done with the window, so I can free a lock.  Do you all have any suggestions?

I have heard robust code should not use onunload.  Is there some obvious alternative?

答: If your lock is on the server, make the lock time out after (say) 30 seconds and have a function on the window automatically renew the lock every 25 seconds.  Call the function from a setInterval.  When the window is closed, the interval is canceled and the lock will timeout 15 seconds later (on average).  Crude but effective.</p>

ContentLicense: CC BY-SA 4.0


问:
Why there is NoClassDefFoundError with a class that exists?
I experience a weird NoClassDefFoundError, because the "NoClassDefFound's class" exists:

```<code>Fatal Exception: java.lang.NoClassDefFoundError: cn.dreamtobe.babyguard.b.a$e
       at cn.dreamtobe.babyguard.data.BabyGuardDatabase.repealLastAction(BabyGuardDatabase.kt:109)
       at cn.dreamtobe.babyguard.data.BabyGuardDatabase$show$1.onClick(BabyGuardDatabase.kt:192)
       at android.support.design.widget.Snackbar$1.onClick(Snackbar.java:255)
       at android.view.View.performClick(View.java:5207)
       at android.view.View.onKeyUp(View.java:9893)
       at android.widget.TextView.onKeyUp(TextView.java:6201)
       at android.view.KeyEvent.dispatch(KeyEvent.java:2667)
       at android.view.View.dispatchKeyEvent(View.java:9245)
</code>```

But the class cn.dreamtobe.babyguard.b.a$e is exists:

Stack point:

Proguard one

Source one

答: java.util.ArrayList#removeIf method was added to ArrayList in Java 8, along with functional interfaces (e. g. Predicate). You can use filterNot from Kotlin instead.

Body:
I experience a weird NoClassDefFoundError, because the "NoClassDefFound's class" exists:

Fatal Exception: java.lang.NoClassDefFoundError: cn.dreamtobe.babyguard.b.a$e
       at cn.dreamtobe.babyguard.data.BabyGuardDatabase.repealLastAction(BabyGuardDatabase.kt:109)
       at cn.dreamtobe.babyguard.data.BabyGuardDatabase$show$1.onClick(BabyGuardDatabase.kt:192)
       at android.support.design.widget.Snackbar$1.onClick(Snackbar.java:255)
       at android.view.View.performClick(View.java:5207)
       at android.view.View.onKeyUp(View.java:9893)
       at android.widget.TextView.onKeyUp(TextView.java:6201)
       at android.view.KeyEvent.dispatch(KeyEvent.java:2667)
       at android.view.View.dispatchKeyEvent(View.java:9245)

But the class cn.dreamtobe.babyguard.b.a$e is exists:

Stack point:

Proguard one

Source one


问:
Add particles on button click in unity
I am new to unity 3d, I have to do some enhancement in exiting project.. if user choose correct option then I have to show some particles around the button at runtime.
My code for adding particles is below ..not working:

```<code>ParticleSystem ps = GetComponent<ParticleSystem>();
ps.Play ();
</code>```

I have also added particles component from unity editor..

Thanks in advance

Edit :

as @kardux suggested:

declaration :

```<code>[SerializeField] private ParticleSystem ps;
</code>```

on method :

```<code>ps.Play()
</code>```

Screenshot from inspector:

Error:

```<code>I/Unity   (23313): NullReferenceException
I/Unity   (23313):   at UnityEngine.ParticleSystem.<Play>m__0 (UnityEngine.ParticleSystem ps) [0x00001] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3666
I/Unity   (23313):   at UnityEngine.ParticleSystem.IterateParticleSystems (Boolean recurse, UnityEngine.IteratorDelegate func) [0x00003] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3780
I/Unity   (23313):   at UnityEngine.ParticleSystem.Play (Boolean withChildren) [0x00020] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3666
I/Unity   (23313):   at UnityEngine.ParticleSystem.Play () [0x00005] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3661
</code>```

答:
First of all if you're using particles inside Unity UI I highly advise you looking to UIParticleSystem.cs script from Unity UI Extension repository: this is a community gathering of many useful UI tools :)

(simply don't forget to add the UI/Particles/Hidden shader that you can find here)

You can change the sprite you want to use here:

Also keep in mind when using this script that you will have to scale your particles according to your screen (particles are initialized at a size of 1 because that's 1 meter in Unity 3D world: but now you will probably be in canvas space which will be something like 1920x1080px so 1px will be very small). You can find some base settings below:

Now coming to your scrip I suspect you simply have to call Stop() before Play() like this (note I used a burst emission type in my particle system settings):

```<code>ParticleSystem ps = GetComponent<ParticleSystem>();
ps.Stop ();
ps.Play ();
</code>```

P.-S. Please note that if you use UIParticleSystem script you will have to consider your particles system as an UI item (will be rendered on top of other items based on hierarchy order)

Hope this helps,

EDIT:

You have two ways of setting up your GameObjects:

you have all component on the same GameObject (ParticleSystem, UIParticleSystem and YOUR_SCRIPT): this way you can get the ParticleSystem reference by calling GetComponent<ParticleSystem>() inside your script

you have one particle GameObject (with ParticleSystem and UIParticleSystem) and YOUR_SCRIPT is on another GameObject: you can't call GetComponent<ParticleSystem>() in your script since it will search on the components of this GameObject so you declare a ParticleSystem ps; variable (either public or [SerializeField] private) that you assign through the Inspector by dragging your particle GameObject to it.

Note that implicitly, GetComponent<ParticleSystem>() equals this.gameObject.GetComponent<ParticleSystem>(): that's why it will search components from the current GameObject.

EDIT 2:

Not sure why your script throw this NullReference exception: I just tried with a very short script and it works perfectly...

```<code>public class TestScript: MonoBehaviour
{
    [SerializeField]
    private ParticleSystem ps;

    void Start()
    {
        // This one is not even needed
        ps.Stop();
    }

    public void PlayParticles()
    {
        ps.Stop();
        ps.Play();
    }
}
</code>```

Title: Add particles on button click in unity

Body:
I am new to unity 3d, I have to do some enhancement in exiting project.. if user choose correct option then I have to show some particles around the button at runtime.
My code for adding particles is below ..not working:

ParticleSystem ps = GetComponent<ParticleSystem>();
ps.Play ();

I have also added particles component from unity editor..

Thanks in advance

Edit :

as @kardux suggested:

declaration :

[SerializeField] private ParticleSystem ps;

on method :

ps.Play()

Screenshot from inspector:

Error:

I/Unity   (23313): NullReferenceException
I/Unity   (23313):   at UnityEngine.ParticleSystem.<Play>m__0 (UnityEngine.ParticleSystem ps) [0x00001] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3666
I/Unity   (23313):   at UnityEngine.ParticleSystem.IterateParticleSystems (Boolean recurse, UnityEngine.IteratorDelegate func) [0x00003] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3780
I/Unity   (23313):   at UnityEngine.ParticleSystem.Play (Boolean withChildren) [0x00020] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3666
I/Unity   (23313):   at UnityEngine.ParticleSystem.Play () [0x00005] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/ParticleSystem/ParticleSystemBindings.gen.cs:3661

Body:
First of all if you're using particles inside Unity UI I highly advise you looking to UIParticleSystem.cs script from Unity UI Extension repository: this is a community gathering of many useful UI tools :)

(simply don't forget to add the UI/Particles/Hidden shader that you can find here)

You can change the sprite you want to use here:

Also keep in mind when using this script that you will have to scale your particles according to your screen (particles are initialized at a size of 1 because that's 1 meter in Unity 3D world: but now you will probably be in canvas space which will be something like 1920x1080px so 1px will be very small). You can find some base settings below:

Now coming to your scrip I suspect you simply have to call Stop() before Play() like this (note I used a burst emission type in my particle system settings):

ParticleSystem ps = GetComponent<ParticleSystem>();
ps.Stop ();
ps.Play ();

P.-S. Please note that if you use UIParticleSystem script you will have to consider your particles system as an UI item (will be rendered on top of other items based on hierarchy order)

Hope this helps,

EDIT:

You have two ways of setting up your GameObjects:

you have all component on the same GameObject (ParticleSystem, UIParticleSystem and YOUR_SCRIPT): this way you can get the ParticleSystem reference by calling GetComponent<ParticleSystem>() inside your script

you have one particle GameObject (with ParticleSystem and UIParticleSystem) and YOUR_SCRIPT is on another GameObject: you can't call GetComponent<ParticleSystem>() in your script since it will search on the components of this GameObject so you declare a ParticleSystem ps; variable (either public or [SerializeField] private) that you assign through the Inspector by dragging your particle GameObject to it.

Note that implicitly, GetComponent<ParticleSystem>() equals this.gameObject.GetComponent<ParticleSystem>(): that's why it will search components from the current GameObject.

EDIT 2:

Not sure why your script throw this NullReference exception: I just tried with a very short script and it works perfectly...

public class TestScript: MonoBehaviour
{
    [SerializeField]
    private ParticleSystem ps;

    void Start()
    {
        // This one is not even needed
        ps.Stop();
    }

    public void PlayParticles()
    {
        ps.Stop();
        ps.Play();
    }
}


问:
Howto change from proportional to tabulated digits in menu items?
I want to change from proportional to tabulated digits in menu items? It's possible?

Menu without tabulated digits

答:
You need to use the monospaced font like this:

```<code>label.font = UIFont.monospacedDigitSystemFont(ofSize: 17, weight: UIFontWeightRegular)
</code>```

Obviously you can specify whatever font size and weight you want (or get them from the current font descriptor).

Body:
You need to use the monospaced font like this:

label.font = UIFont.monospacedDigitSystemFont(ofSize: 17, weight: UIFontWeightRegular)

Obviously you can specify whatever font size and weight you want (or get them from the current font descriptor).


问:
get the most two recent dates for each customer
basically, I need to retrieve the last two dates for customers who purchased in at least two different dates, implying there are some customer who had purchased only in one date, the data has the following form

```<code>client_id  date
1          2016-07-02
1          2016-07-02
1          2016-06-01
2          2015-06-01
</code>```

and I would like to get it in the following form

```<code>client_id      previous_date     last_date
1              2016-06-01        2016-07-02
</code>```

remarques:

a client can have multiple entries for the same date

a client can have entries only for one date, such customer should be discarded

答:
UNTESTED:

We use a common table expression to assign a row number based on the date in descending order and then only include those records having a row number <=2 and then ensure that those having 1 row are excluded by the having.

```<code>WITH CTE AS (
  SELECT Distinct Client_ID
       , Date
       , row_number() over (partition by clientID order by date desc) rn
  FROM Table)

SELECT  Client_ID, min(date) previous_date, max(date) last_date)
FROM CTE
WHERE RN <=2
GROUP BY Client_ID
HAVING max(RN) > 1
</code>```

Body:
basically, I need to retrieve the last two dates for customers who purchased in at least two different dates, implying there are some customer who had purchased only in one date, the data has the following form

client_id  date
1          2016-07-02
1          2016-07-02
1          2016-06-01
2          2015-06-01

and I would like to get it in the following form

client_id      previous_date     last_date
1              2016-06-01        2016-07-02

remarques:

a client can have multiple entries for the same date

a client can have entries only for one date, such customer should be discarded

Body:
UNTESTED:

We use a common table expression to assign a row number based on the date in descending order and then only include those records having a row number <=2 and then ensure that those having 1 row are excluded by the having.

WITH CTE AS (
  SELECT Distinct Client_ID
       , Date
       , row_number() over (partition by clientID order by date desc) rn
  FROM Table)

SELECT  Client_ID, min(date) previous_date, max(date) last_date)
FROM CTE
WHERE RN <=2
GROUP BY Client_ID
HAVING max(RN) > 1


问:
Windows Start command handles EXE and BAT differently, the latter is flawed
Please how can I run batch file with arguments enclosed in double quotes using the Start command?

If you use EXE file, it works (calc is just an example you can test with):

```<code>start "Some Title" "calc.exe" "arg1" "arg 2" "arg  3"
</code>```

The same syntax calling batch file does not: (in the above, only the extension was replaced)

```<code>start "Some Title" "calc.bat" "arg1" "arg 2" "arg  3"
</code>```

Error:

'calc.bat"  "arg1" "arg' is not recognized as an internal or external command,
  operable program or batch file.

(The content of calc.bat file does not matter, it can even have zero length.)

How I can achieve launching calc.bat using start command (asynchronously, in separate window) with arguments arg1, arg 2 and arg  3?

Of course, if you specify arguments without quotes, it works:

```<code>start "Some Title" "calc.bat" arg1 arg2 arg3
</code>```

EDIT:

I actually need start_all.bat which starts 3 parallel processes in 3 new windows:

```<code>set user="abc"
start "Run 1" "calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "calc.bat" "%user%" "arg 7" "arg 8" "arg 9"
</code>```

but this works only with EXE, not with BAT.

calc.bat can be something simple like

```<code>@echo 1: `%1`
@echo 2: `%2`
@echo 3: `%3`
@pause
</code>```

Additional question: What if the path with the space is present?

set user="abc"
start "Run 1" "c:\batch files\calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "c:\batch files\calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "c:\batch files\calc.bat" "%user%" "arg 7" "arg 8" "arg 9"
```

答:
When using start to call a batch file, it actually invokes cmd /K implicitly to run the batch file:

start "Some Title" cmd /K "calc.bat" "arg1" "arg 2" "arg  3"
```

<p>The <code>cmd /K</code> part consumes the leading and trailing quotation marks, leaving the invalid command line:</p>

<pre class="lang-cmd prettyprint-override"><code>calc.bat" "arg1" "arg 2" "arg  3
</code>```

To compensate for that, provide an additional surrounding pair of quotes; escape them to let the arguments appear quoted to the hosting cmd instance too.

start "Some Title" ^""calc.bat" "arg1" "arg 2" "arg  3"^"
```

<p>However, these nested quotation marks most probably confuses the <code>start</code> command, so it does no longer recognise the (path to the) batch file that you are trying to call. To avoid that, you must explicitly specify the <code>cmd /K</code> part:</p>

<pre class="lang-cmd prettyprint-override"><code>start "Some Title" cmd /K ^""calc.bat" "arg1" "arg 2" "arg  3"^"
</code>```

Or, with the full path to the batch file provided:

start "Some Title" cmd /K ^""C:\Batch Files\calc.bat" "arg1" "arg 2" "arg  3"^"
```

Body:
Please how can I run batch file with arguments enclosed in double quotes using the Start command?

If you use EXE file, it works (calc is just an example you can test with):

start "Some Title" "calc.exe" "arg1" "arg 2" "arg  3"

The same syntax calling batch file does not: (in the above, only the extension was replaced)

start "Some Title" "calc.bat" "arg1" "arg 2" "arg  3"

Error:

'calc.bat"  "arg1" "arg' is not recognized as an internal or external command,
  operable program or batch file.

(The content of calc.bat file does not matter, it can even have zero length.)

How I can achieve launching calc.bat using start command (asynchronously, in separate window) with arguments arg1, arg 2 and arg  3?

Of course, if you specify arguments without quotes, it works:

start "Some Title" "calc.bat" arg1 arg2 arg3

EDIT:

I actually need start_all.bat which starts 3 parallel processes in 3 new windows:

set user="abc"
start "Run 1" "calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "calc.bat" "%user%" "arg 7" "arg 8" "arg 9"

but this works only with EXE, not with BAT.

calc.bat can be something simple like

@echo 1: `%1`
@echo 2: `%2`
@echo 3: `%3`
@pause

Additional question: What if the path with the space is present?

set user="abc"
start "Run 1" "c:\batch files\calc.bat" "%user%" "arg 1" "arg 2" "arg 3"
start "Run 2" "c:\batch files\calc.bat" "%user%" "arg 4" "arg 5" "arg 6"
start "Run 3" "c:\batch files\calc.bat" "%user%" "arg 7" "arg 8" "arg 9"

Body:
When using start to call a batch file, it actually invokes cmd /K implicitly to run the batch file:

start "Some Title" cmd /K "calc.bat" "arg1" "arg 2" "arg  3"

The cmd /K part consumes the leading and trailing quotation marks, leaving the invalid command line:

calc.bat" "arg1" "arg 2" "arg  3

To compensate for that, provide an additional surrounding pair of quotes; escape them to let the arguments appear quoted to the hosting cmd instance too.

start "Some Title" ^""calc.bat" "arg1" "arg 2" "arg  3"^"

However, these nested quotation marks most probably confuses the start command, so it does no longer recognise the (path to the) batch file that you are trying to call. To avoid that, you must explicitly specify the cmd /K part:

start "Some Title" cmd /K ^""calc.bat" "arg1" "arg 2" "arg  3"^"

Or, with the full path to the batch file provided:

start "Some Title" cmd /K ^""C:\Batch Files\calc.bat" "arg1" "arg 2" "arg  3"^"


问:
Copying 15 million records to a new table/server
Good day. I need to move 15 Million Records from one MySQL table to a new table on other schemas. This is a live system and time is a problem. The table I need to move is a history table and isn't important for day to day business. I can't leave the table as it is part of a bigger upgrade I am doing.

I tried just moving the data with basic sql in a test environment but this doesn't work; the server kicks me out after 20min.

What would be the best way of moving the data?

I am a C# programmer  if someone has a coding solution

答: take a look to Bulk Import/Export... i think it's the fastest way.</p>


问:
DataTables: Cannot read property style of undefined
I am getting this error with the following:

```<code>jquery.dataTables.js:4089 Uncaught TypeError: Cannot read property 'style' of undefined(…)
_fnCalculateColumnWidths @ jquery.dataTables.js:4089
_fnInitialise @ jquery.dataTables.js:3216
(anonymous function) @ jquery.dataTables.js:6457
each @ jquery-2.0.2.min.js:4
each @ jquery-2.0.2.min.js:4
DataTable @ jquery.dataTables.js:5993
$.fn.DataTable @ jquery.dataTables.js:14595
(anonymous function) @ VM3329:1
(anonymous function) @ VM3156:180
l @ jquery-2.0.2.min.js:4
fireWith @ jquery-2.0.2.min.js:4
k @ jquery-2.0.2.min.js:6
(anonymous function) @ jquery-2.0.2.min.js:6
</code>```

The line above referring to     (anonymous function) @ VM3156:180 is:

```<code>                TASKLISTGRID = $("#TASK_LIST_GRID").DataTable({
                    data : response,
                    columns : columns.AdoptionTaskInfo.columns,
                    paging: true
                });
</code>```

So I am guessing this is where it is failing.

The HTML ID element exist:

```<code>  <table id="TASK_LIST_GRID" class="table table-striped table-bordered table-hover dataTable no-footer" width="100%" role="grid" aria-describedby="TASK_LIST_GRID_info">
  <thead>
    <tr role="row">
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Solution</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Status</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Category</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Type</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Due Date</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Create Date</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Owner</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Comments</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Mnemonic</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Domain</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Approve</th>
      <th class="sorting" tabindex="0" aria-controls="TASK_LIST_GRID" rowspan="1" colspan="1">Dismiss</th>
    </tr>
  </thead>
  <tbody></tbody>
</table>
</code>```

Also, the columns.AdoptionTaskInfo.columns & response object arrays exist. Not sure how to debug what's wrong.. Any suggestions will be helpful..

答:
I had this issue when i set colspan in table header. So my table was:

```<code>        <thead>
            <tr>
                <th colspan="2">Expenses</th>

                <th colspan="2">Income</th>

                <th>Profit/Loss</th>
            </tr>
        </thead>
</code>```

Then once i change it to:

```<code>        <thead>
            <tr>
                <th>Expenses</th>
                <th></th>
                <th>Income</th>
                <th></th>
                <th>Profit/Loss</th>
            </tr>
        </thead>
</code>```

Everything worked just fine.

Body:
I am getting this error with the following:

jquery.dataTables.js:4089 Uncaught TypeError: Cannot read property 'style' of undefined(…)
_fnCalculateColumnWidths @ jquery.dataTables.js:4089
_fnInitialise @ jquery.dataTables.js:3216
(anonymous function) @ jquery.dataTables.js:6457
each @ jquery-2.0.2.min.js:4
each @ jquery-2.0.2.min.js:4
DataTable @ jquery.dataTables.js:5993
$.fn.DataTable @ jquery.dataTables.js:14595
(anonymous function) @ VM3329:1
(anonymous function) @ VM3156:180
l @ jquery-2.0.2.min.js:4
fireWith @ jquery-2.0.2.min.js:4
k @ jquery-2.0.2.min.js:6
(anonymous function) @ jquery-2.0.2.min.js:6

The line above referring to     (anonymous function) @ VM3156:180 is:

                TASKLISTGRID = $("#TASK_LIST_GRID").DataTable({
                    data : response,
                    columns : columns.AdoptionTaskInfo.columns,
                    paging: true
                });

So I am guessing this is where it is failing.

The HTML ID element exist:

      Solution
      Status
      Category
      Type
      Due Date
      Create Date
      Owner
      Comments
      Mnemonic
      Domain
      Approve
      Dismiss

Also, the columns.AdoptionTaskInfo.columns & response object arrays exist. Not sure how to debug what's wrong.. Any suggestions will be helpful..

Body:
I had this issue when i set colspan in table header. So my table was:

        <thead>
            <tr>
                <th colspan="2">Expenses</th>

                <th colspan="2">Income</th>

                <th>Profit/Loss</th>
            </tr>
        </thead>

Then once i change it to:

        <thead>
            <tr>
                <th>Expenses</th>
                <th></th>
                <th>Income</th>
                <th></th>
                <th>Profit/Loss</th>
            </tr>
        </thead>

Everything worked just fine.


问:
Increment page value when passing through URL
I need to pass the value of page by increasing one. This is my pure code

```<code><?php echo "<li><a href='pro.php?page=$page'><span class='ico-next'></span></a></li>" ?>
</code>```

this is I tried one

```<code><?php echo "<li><a href='pro.php?page=.$page++.'><span class='ico-next'></span></a></li>" ?>
</code>```

But its not working,how can I pass the value by increasing it by one

答:
You first need to increment the variable before you print it to the page.</p>

```<code><?php echo "<li><a href='pro.php?page=".trim(++$page)."'><span class='ico-next'></span></a></li>" ?>
</code>```

Body:
I need to pass the value of page by increasing one. This is my pure code

<?php echo "

" ?>

this is I tried one

<?php echo "

" ?>

But its not working,how can I pass the value by increasing it by one

Body:
You first need to increment the variable before you print it to the page.

<?php echo "<li><a href='pro.php?page=".trim(++$page)."'><span class='ico-next'></span></a></li>" ?>


问:
SAS - Custom Date Format - YYYYMMDDhhmmss
I need to add a current date to the output I am exporting from SAS in the following format: filename_YYYYMMDDhhmmss.csv

I am creating a macro variable the following way:

```<code>%let date_human = %sysfunc(today(), YYYYMMDDn8.);
</code>```

Does anybody know how to create a custom format for the date I have got? datetime20. gives an incorrect one.

Thank you.

答:
Use picture in proc format:

```<code>proc format;
    *custom format for the datetime values;
   picture cust_dt other = '%0Y%0m%0d%0H%0M%0S' (datatype=datetime);
run;

** put into macro **;
data test;
    dt = datetime();
    call symputx("dt",strip(put(dt,cust_dt.)));
run;

%put &dt.;

** use macro for filename **;
data file_&dt.; set sashelp.class;
run;
</code>```

Body:
I need to add a current date to the output I am exporting from SAS in the following format: filename_YYYYMMDDhhmmss.csv

I am creating a macro variable the following way:

%let date_human = %sysfunc(today(), YYYYMMDDn8.);

Does anybody know how to create a custom format for the date I have got? datetime20. gives an incorrect one.

Thank you.

Body:
Use picture in proc format:

proc format;
    *custom format for the datetime values;
   picture cust_dt other = '%0Y%0m%0d%0H%0M%0S' (datatype=datetime);
run;

** put into macro **;
data test;
    dt = datetime();
    call symputx("dt",strip(put(dt,cust_dt.)));
run;

%put &dt.;

** use macro for filename **;
data file_&dt.; set sashelp.class;
run;


问:
variables mixing when loading one of them
im trying to write simple program in MASM and im noticed that my program is mixing varaibles while loading one of them.

Here's simple example example:

```<code>.386
.model FLAT, STDCALL
option casemap:none
include \masm32\include\masm32rt.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
buffer2     db "34"
buffer1     db "60"

.data?
number1 dd  ?
number2 dd  ?

.code
start:

invoke  atodw, offset buffer1
mov    number1, eax;             ;Here eax=60 so it's ok

invoke  atodw, offset buffer2
mov    number2, eax              ;but here eax=3460

invoke  ExitProcess, 0
end start
</code>```

What more interesting i can change those valuses simple by switching variable order in .data section and then i will see (1)eax=6034 and (2)eax=34

So my question is: What Im doing wrong and how to fix it?

答:
A "string" means in the MASM32 SDK always a null-terminated string. The assembler does not recognize a string in quotes as a string with null-termination, it's just a sequence of characters for it.

Whatever I removed was not needed - masm32rt.inc does it all:

```<code>include \masm32\include\masm32rt.inc

.data
buffer2     db "34",0
buffer1     db "60",0

.data?
number1 dd  ?
number2 dd  ?

.code
start:

invoke  atodw, offset buffer1
mov    number1, eax;             ;Here eax=60 so it's ok

printf ("number1: %d\n",[number1])

invoke  atodw, offset buffer2
mov    number2, eax              ;but here eax=3460

printf ("number2: %d\n",[number2])

invoke  ExitProcess, 0
end start
</code>```

I'm sorry, I didn't understand the second question.

Body:
im trying to write simple program in MASM and im noticed that my program is mixing varaibles while loading one of them.

Here's simple example example:

.386
.model FLAT, STDCALL
option casemap:none
include \masm32\include\masm32rt.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
buffer2     db "34"
buffer1     db "60"

.data?
number1 dd  ?
number2 dd  ?

.code
start:

invoke  atodw, offset buffer1
mov    number1, eax;             ;Here eax=60 so it's ok

invoke  atodw, offset buffer2
mov    number2, eax              ;but here eax=3460

invoke  ExitProcess, 0
end start

What more interesting i can change those valuses simple by switching variable order in .data section and then i will see (1)eax=6034 and (2)eax=34

So my question is: What Im doing wrong and how to fix it?

Body:
A "string" means in the MASM32 SDK always a null-terminated string. The assembler does not recognize a string in quotes as a string with null-termination, it's just a sequence of characters for it.

Whatever I removed was not needed - masm32rt.inc does it all:

include \masm32\include\masm32rt.inc

.data
buffer2     db "34",0
buffer1     db "60",0

.data?
number1 dd  ?
number2 dd  ?

.code
start:

invoke  atodw, offset buffer1
mov    number1, eax;             ;Here eax=60 so it's ok

printf ("number1: %d\n",[number1])

invoke  atodw, offset buffer2
mov    number2, eax              ;but here eax=3460

printf ("number2: %d\n",[number2])

invoke  ExitProcess, 0
end start

I'm sorry, I didn't understand the second question.


问:
npm init doesn't create package.json
I am new to ReactJS, I was following one of the tutorials in "TutorialsPoint".

In Step 2: After the folder is created we need to open it and create empty package.json file inside by running npm init from the command prompt and follow the instructions.

```<code>C:\Users\username\Desktop\reactApp>npm init
</code>```

By running the above command I am unable to create and package.json
Only this thing is coming up after running init.

In Step 4: it asks to add dependencies and plugins

In Step 5: it asks to open the package.json and delete "test": "echo \"Error: no test specified\" && exit 1" inside "scripts" object.

Now how can I open package.json, if I was not been created from the beginning?

答:
I am new on npm. I got confused just like you when i was trying to follow the npm tutorial.
You just need to press the 'Enter' key on your keyboard after your step2.
When you press 'Enter', you give default value to it. So it's gonna generate the json file based on its default information... hope it helps.</p>

Title: npm init doesn't create package.json

Body:
I am new to ReactJS, I was following one of the tutorials in "TutorialsPoint".

In Step 2: After the folder is created we need to open it and create empty package.json file inside by running npm init from the command prompt and follow the instructions.

C:\Users\username\Desktop\reactApp>npm init

By running the above command I am unable to create and package.json
Only this thing is coming up after running init.

In Step 4: it asks to add dependencies and plugins

In Step 5: it asks to open the package.json and delete "test": "echo \"Error: no test specified\" && exit 1" inside "scripts" object.

Now how can I open package.json, if I was not been created from the beginning?


问:
@JmsListener issue with durable subscription
I am using Spring's @JmsListener (spring-jms-4.3.4.RELEASE.jar)  for receiving messages from ActiveMQ using the below code:

```<code>@Component
public class TopicSubscriber {
    @JmsListener(destination="xyz.topic1", subscription="xyz_topic_durable_subscription")
    public void send(Product product) {
        System.out.println(" reveived message ***"+product);
    }
}
</code>```

As per the Spring API's documentation (link given below), the above code should create a durable subscription with subscription name as xyz_topic_durable_subscription:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/annotation/JmsListener.html#subscription--

But, the issue is that the above code creates only Non-Durable subscription which I could find by monitoring the ActiveMQ using admin console (added screenshot below, look for 'xyz.topic1' Destination under 'Active Non-Durable Topic Subscribers' section).

Are there any changes to be made in the code to make the durable subscription ?

答:
In the answer marked as correct above, the code:

```<code>factory.setPubSubDomain(true);
factory.setSubscriptionDurable(true);
factory.setClientId("jmsDemo");
</code>```

must come after

```<code>configurer.configure(factory, connectionFactory);
</code>```

or you will lose those settings.

Body:
I am using Spring's @JmsListener (spring-jms-4.3.4.RELEASE.jar)  for receiving messages from ActiveMQ using the below code:

@Component
public class TopicSubscriber {
    @JmsListener(destination="xyz.topic1", subscription="xyz_topic_durable_subscription")
    public void send(Product product) {
        System.out.println(" reveived message ***"+product);
    }
}

As per the Spring API's documentation (link given below), the above code should create a durable subscription with subscription name as xyz_topic_durable_subscription:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/annotation/JmsListener.html#subscription--

But, the issue is that the above code creates only Non-Durable subscription which I could find by monitoring the ActiveMQ using admin console (added screenshot below, look for 'xyz.topic1' Destination under 'Active Non-Durable Topic Subscribers' section).

Are there any changes to be made in the code to make the durable subscription ?

Body:
In the answer marked as correct above, the code:

factory.setPubSubDomain(true);
factory.setSubscriptionDurable(true);
factory.setClientId("jmsDemo");

must come after

configurer.configure(factory, connectionFactory);

or you will lose those settings.


问:
Cannot get XML structure right
I am working with XML and php. I am trying to get an array of PHP result to this XML format with two <customer> customers, I can get 1 but dont know how to do it for 2 customers in an array.

```<code><?xml version="1.0"?>
<NewSLSCase>
  <Identification CientNo="4xxx" CLientBatchNo="1" IJBatchNo="1" HubNo="201048" ClientEmailAddress1="etunimi.sukunimi@yritys.fi" ClientEmailAddress2="etunimi.sukunimi@yritys.fi"/>
  <LedgerSet>
    <Ledger ProductionUnit="04" LedgerNo="4xxxxx">
      <CustomerSet>
        <Customer No="123456" Name="Farhana" Address1="Myhouse" ZipCode="40100" City="Vantaa" LanguageCode="FIN" CountryCode="FI" VatNo="01011-111A" TypeCode="C"/>
        <Customer No="123457" Name="Asiakas Anna" Address1="Asiakastie 2" ZipCode="00100" City=" Helsinki" LanguageCode="FIN" CountryCode="FI" VATNo="010111-111A" TypeCode="C"/>
      </CustomerSet>
      <InvoiceSet>
        <Invoice InvoiceNo="123456"/>
        <InvoiceHeader InvoiceHeaderType="L" InvoiceCustomerNo="123456" InvoiceCurrency="EUR" InvoiceDate="2011-04-08" InvoiceDueDate="2011-05-15" InvoiceAmount="57.00" ClientOCRReference="908000101800031186" InvoiceReferenceText3="150,00" InvoiceReferenceText4="Laskuille tulostuva" InvoiceReferenceText5="IBAN" InvoiceReferenceText6="BIC"/>
      </InvoiceSet>
    </Ledger>
  </LedgerSet>
</NewSLSCase>
</code>```

I wrote the codes for just getting one ` but adding another one is something I am truly not sure off.

Here is the array, did not copy the whole thing since its big, but I am using a small part of it for testing.

```<code>array(2) (
  [0] => stdClass object {
    ID => (string) 177835
    currency => (string) Asiakas Anna
    type => (string) Asiakastie 2
  }
  [1] => stdClass object {
    ID => (string) 177840
    Name=> (string) Farhana
    Address=> (string) Myhouse
   .....
</code>```

Here is the whole XML format

```<code>$result = $this->invoice_page->getInvoiceByID('20241'); //this is the array

        $xml = new DomDocument('1.0');
        $xml->formatOutput = true;
        $NewSLSCase = $xml->createElement("NewSLSCase");
        $xml->appendChild($NewSLSCase);

        $Identification = $xml->createElement("Identification");
        $Identification->setAttribute("CientNo","4xxx");
        $Identification->setAttribute("CLientBatchNo", "1");
        $Identification->setAttribute("CLientBatchNo", "1");
        $Identification->setAttribute("IJBatchNo", "1");
        $Identification->setAttribute("HubNo", "201048");
        $Identification->setAttribute("ClientEmailAddress1", "etunimi.sukunimi@yritys.fi");
        $Identification->setAttribute("ClientEmailAddress2", "etunimi.sukunimi@yritys.fi");
        $NewSLSCase->appendChild($Identification);

        $LedgerSet = $xml->createElement("LedgerSet");
        $NewSLSCase->appendChild($LedgerSet);

        $Ledger = $xml->createElement("Ledger");
        $Ledger->setAttribute("ProductionUnit","04");
        $Ledger->setAttribute("LedgerNo", "4xxxxx");
        $LedgerSet->appendChild($Ledger);

        $CustomerSet = $xml->createElement("CustomerSet");
        $Ledger->appendChild($CustomerSet);

        $Customer = $xml->createElement("Customer");
        $Customer->setAttribute("No","123456");
        $Customer->setAttribute("Name", $result['Fullname']);
        $Customer->setAttribute("Address1", $result['Address_street']);
        $Customer->setAttribute("ZipCode", $result['Address_zip']);
        $Customer->setAttribute("City",$result['Address_city']);
        $Customer->setAttribute("LanguageCode", "FIN");
        $Customer->setAttribute("CountryCode","FI");
        $Customer->setAttribute("VatNo", "01011-111A");
        $Customer->setAttribute("TypeCode","C");
        $CustomerSet->appendChild($Customer);

        $InvoiceSet = $xml->createElement("InvoiceSet");
        $Ledger->appendChild($InvoiceSet);

        $Invoice = $xml->createElement("Invoice");
        $Invoice->setAttribute("InvoiceNo","123456");
        $InvoiceSet->appendChild($Invoice);

        $InvoiceHeader = $xml->createElement("InvoiceHeader");
        $InvoiceHeader->setAttribute("InvoiceHeaderType", "L");
        $InvoiceHeader->setAttribute("InvoiceCustomerNo","123456");
        $InvoiceHeader->setAttribute("InvoiceCurrency", "EUR");
        $InvoiceHeader->setAttribute("InvoiceDate","2011-04-08");
        $InvoiceHeader->setAttribute("InvoiceDueDate", "2011-05-15");
        $InvoiceHeader->setAttribute("InvoiceAmount","57.00");
        $InvoiceHeader->setAttribute("ClientOCRReference", "908000101800031186");
        $InvoiceHeader->setAttribute("InvoiceReferenceText3","150,00");
        $InvoiceHeader->setAttribute("InvoiceReferenceText4","Laskuille tulostuva");
        $InvoiceHeader->setAttribute("InvoiceReferenceText5",$result['IBAN']);
        $InvoiceHeader->setAttribute("InvoiceReferenceText6",$result['BIC']);
        $InvoiceSet->appendChild($InvoiceHeader);

        echo "<xmp>".$xml->saveXML()."</xmp>";
</code>```

What the above code, gives me is this

```<code><?xml version="1.0"?>
<NewSLSCase>
  <Identification CientNo="4xxx" CLientBatchNo="1" IJBatchNo="1" HubNo="201048" ClientEmailAddress1="etunimi.sukunimi@yritys.fi" ClientEmailAddress2="etunimi.sukunimi@yritys.fi"/>
  <LedgerSet>
    <Ledger ProductionUnit="04" LedgerNo="4xxxxx">
      <CustomerSet>
        <Customer No="123456" Name="Farhana" Address1="Myhouse" ZipCode="40100" City="Vantaa" LanguageCode="FIN" CountryCode="FI" VatNo="01011-111A" TypeCode="C"/>
      </CustomerSet>
      <InvoiceSet>
        <Invoice InvoiceNo="123456"/>
        <InvoiceHeader InvoiceHeaderType="L" InvoiceCustomerNo="123456" InvoiceCurrency="EUR" InvoiceDate="2011-04-08" InvoiceDueDate="2011-05-15" InvoiceAmount="57.00" ClientOCRReference="908000101800031186" InvoiceReferenceText3="150,00" InvoiceReferenceText4="Laskuille tulostuva" InvoiceReferenceText5="IBAN" InvoiceReferenceText6="BIC"/>
      </InvoiceSet>
    </Ledger>
  </LedgerSet>
</NewSLSCase>
</code>```

I have no clue how to add a foreach to get two customers information.

答:
Use foreach loop through customers:</p>

```<code>foreach ($customersArray as $customerData) {
    $Customer = $xml->createElement("Customer");
    $Customer->setAttribute("No",$customerData->ID);
    //set all attributes like that
    $CustomerSet->appendChild($Customer);
}
</code>```

Title: Cannot get XML structure right

Body:
I am working with XML and php. I am trying to get an array of PHP result to this XML format with two <customer> customers, I can get 1 but dont know how to do it for 2 customers in an array.

<?xml version="1.0"?>
<NewSLSCase>
  <Identification CientNo="4xxx" CLientBatchNo="1" IJBatchNo="1" HubNo="201048" ClientEmailAddress1="etunimi.sukunimi@yritys.fi" ClientEmailAddress2="etunimi.sukunimi@yritys.fi"/>
  <LedgerSet>
    <Ledger ProductionUnit="04" LedgerNo="4xxxxx">
      <CustomerSet>
        <Customer No="123456" Name="Farhana" Address1="Myhouse" ZipCode="40100" City="Vantaa" LanguageCode="FIN" CountryCode="FI" VatNo="01011-111A" TypeCode="C"/>
        <Customer No="123457" Name="Asiakas Anna" Address1="Asiakastie 2" ZipCode="00100" City=" Helsinki" LanguageCode="FIN" CountryCode="FI" VATNo="010111-111A" TypeCode="C"/>
      </CustomerSet>
      <InvoiceSet>
        <Invoice InvoiceNo="123456"/>
        <InvoiceHeader InvoiceHeaderType="L" InvoiceCustomerNo="123456" InvoiceCurrency="EUR" InvoiceDate="2011-04-08" InvoiceDueDate="2011-05-15" InvoiceAmount="57.00" ClientOCRReference="908000101800031186" InvoiceReferenceText3="150,00" InvoiceReferenceText4="Laskuille tulostuva" InvoiceReferenceText5="IBAN" InvoiceReferenceText6="BIC"/>
      </InvoiceSet>
    </Ledger>
  </LedgerSet>
</NewSLSCase>

I wrote the codes for just getting one ` but adding another one is something I am truly not sure off.

Here is the array, did not copy the whole thing since its big, but I am using a small part of it for testing.

array(2) (
  [0] => stdClass object {
    ID => (string) 177835
    currency => (string) Asiakas Anna
    type => (string) Asiakastie 2
  }
  [1] => stdClass object {
    ID => (string) 177840
    Name=> (string) Farhana
    Address=> (string) Myhouse
   .....

Here is the whole XML format

$result = $this->invoice_page->getInvoiceByID('20241'); //this is the array

        $xml = new DomDocument('1.0');
        $xml->formatOutput = true;
        $NewSLSCase = $xml->createElement("NewSLSCase");
        $xml->appendChild($NewSLSCase);

        $Identification = $xml->createElement("Identification");
        $Identification->setAttribute("CientNo","4xxx");
        $Identification->setAttribute("CLientBatchNo", "1");
        $Identification->setAttribute("CLientBatchNo", "1");
        $Identification->setAttribute("IJBatchNo", "1");
        $Identification->setAttribute("HubNo", "201048");
        $Identification->setAttribute("ClientEmailAddress1", "etunimi.sukunimi@yritys.fi");
        $Identification->setAttribute("ClientEmailAddress2", "etunimi.sukunimi@yritys.fi");
        $NewSLSCase->appendChild($Identification);

        $LedgerSet = $xml->createElement("LedgerSet");
        $NewSLSCase->appendChild($LedgerSet);

        $Ledger = $xml->createElement("Ledger");
        $Ledger->setAttribute("ProductionUnit","04");
        $Ledger->setAttribute("LedgerNo", "4xxxxx");
        $LedgerSet->appendChild($Ledger);

        $CustomerSet = $xml->createElement("CustomerSet");
        $Ledger->appendChild($CustomerSet);

        $Customer = $xml->createElement("Customer");
        $Customer->setAttribute("No","123456");
        $Customer->setAttribute("Name", $result['Fullname']);
        $Customer->setAttribute("Address1", $result['Address_street']);
        $Customer->setAttribute("ZipCode", $result['Address_zip']);
        $Customer->setAttribute("City",$result['Address_city']);
        $Customer->setAttribute("LanguageCode", "FIN");
        $Customer->setAttribute("CountryCode","FI");
        $Customer->setAttribute("VatNo", "01011-111A");
        $Customer->setAttribute("TypeCode","C");
        $CustomerSet->appendChild($Customer);

        $InvoiceSet = $xml->createElement("InvoiceSet");
        $Ledger->appendChild($InvoiceSet);

        $Invoice = $xml->createElement("Invoice");
        $Invoice->setAttribute("InvoiceNo","123456");
        $InvoiceSet->appendChild($Invoice);

        $InvoiceHeader = $xml->createElement("InvoiceHeader");
        $InvoiceHeader->setAttribute("InvoiceHeaderType", "L");
        $InvoiceHeader->setAttribute("InvoiceCustomerNo","123456");
        $InvoiceHeader->setAttribute("InvoiceCurrency", "EUR");
        $InvoiceHeader->setAttribute("InvoiceDate","2011-04-08");
        $InvoiceHeader->setAttribute("InvoiceDueDate", "2011-05-15");
        $InvoiceHeader->setAttribute("InvoiceAmount","57.00");
        $InvoiceHeader->setAttribute("ClientOCRReference", "908000101800031186");
        $InvoiceHeader->setAttribute("InvoiceReferenceText3","150,00");
        $InvoiceHeader->setAttribute("InvoiceReferenceText4","Laskuille tulostuva");
        $InvoiceHeader->setAttribute("InvoiceReferenceText5",$result['IBAN']);
        $InvoiceHeader->setAttribute("InvoiceReferenceText6",$result['BIC']);
        $InvoiceSet->appendChild($InvoiceHeader);

        echo "<xmp>".$xml->saveXML()."</xmp>";

What the above code, gives me is this

<?xml version="1.0"?>
<NewSLSCase>
  <Identification CientNo="4xxx" CLientBatchNo="1" IJBatchNo="1" HubNo="201048" ClientEmailAddress1="etunimi.sukunimi@yritys.fi" ClientEmailAddress2="etunimi.sukunimi@yritys.fi"/>
  <LedgerSet>
    <Ledger ProductionUnit="04" LedgerNo="4xxxxx">
      <CustomerSet>
        <Customer No="123456" Name="Farhana" Address1="Myhouse" ZipCode="40100" City="Vantaa" LanguageCode="FIN" CountryCode="FI" VatNo="01011-111A" TypeCode="C"/>
      </CustomerSet>
      <InvoiceSet>
        <Invoice InvoiceNo="123456"/>
        <InvoiceHeader InvoiceHeaderType="L" InvoiceCustomerNo="123456" InvoiceCurrency="EUR" InvoiceDate="2011-04-08" InvoiceDueDate="2011-05-15" InvoiceAmount="57.00" ClientOCRReference="908000101800031186" InvoiceReferenceText3="150,00" InvoiceReferenceText4="Laskuille tulostuva" InvoiceReferenceText5="IBAN" InvoiceReferenceText6="BIC"/>
      </InvoiceSet>
    </Ledger>
  </LedgerSet>
</NewSLSCase>

I have no clue how to add a foreach to get two customers information.

Body:
Use foreach loop through customers:

foreach ($customersArray as $customerData) {
    $Customer = $xml->createElement("Customer");
    $Customer->setAttribute("No",$customerData->ID);
    //set all attributes like that
    $CustomerSet->appendChild($Customer);
}


问:
Calling command from Perl, need to see output
I need to call some shell commands from perl. Those commands take quite some time to finish so I'd like to see their output while waiting for completion.

The system function does not give me any output until it is completed.

The exec function gives output; however, it exits the perl script from that point, which is not what I wanted.

I am on Windows. Is there a way to accomplish this?

答:
Backticks, or the qx command, run a command in a separate process and returns the output:

```<code>print `$command`;
print qx($command);
</code>```

If you wish to see intermediate output, use open to create a handle to the command's output stream and read from it.

```<code>open my $cmd_fh, "$command |";   # <---  | at end means to make command
                                 #         output available to the handle
while (<$cmd_fh>) {
    print "A line of output from the command is: $_";
}
close $cmd_fh;
</code>```

Body:
Backticks, or the qx command, run a command in a separate process and returns the output:

print `$command`;
print qx($command);

If you wish to see intermediate output, use open to create a handle to the command's output stream and read from it.

open my $cmd_fh, "$command |";   # <---  | at end means to make command
                                 #         output available to the handle
while (<$cmd_fh>) {
    print "A line of output from the command is: $_";
}
close $cmd_fh;


问:
What is the difference between these fuctions?
What is the difference between these two way of defining a method?

```<code> var Todo = {};
    Todo.abc = function(){
    }
</code>```

and

```<code>function abc(){
}
</code>```

答:
First is a Todo property, second is a global function.
In fact, in order to call the first one you have to write

```<code>Todo.abc();
</code>```

Note that Todo.abc = 'Hello' will overwrite instance property.

Body:
What is the difference between these two way of defining a method?

 var Todo = {};
    Todo.abc = function(){
    }

and

function abc(){
}

Body:
First is a Todo property, second is a global function.
In fact, in order to call the first one you have to write

Todo.abc();

Note that Todo.abc = 'Hello' will overwrite instance property.


问:
How to change button color when radio input is selected, but input is wrapped in div before label?
I am trying to make our dinky radio buttons into lovely toggle buttons on our donation page. The HTML cannot be modified, and as it stands the inputs are wrapped in divs, then followed by the labels. I have zero knowledge of JS/jQuery and I imagine this task requires some.

Here is my fiddle: https://jsfiddle.net/cgz63qhd/

body {
  padding: 10px;
  font-family: sans-serif;
}

div.donation-levels {
  margin: 3px 0;
}

.donation-level-container {
  display: inline-block;
}

.donation-level-container input {
  visibility: hidden;
}

.donation-level-amount-container {
  text-align: center;
  margin: 5px 2px;
  padding: 0.7em 2em;
  color: #ffffff;
  background-color: #1a92b4;
  border-radius: 5px;
  display: inline-block;
  cursor: pointer;
  font-size: 22px;
}

.donation-level-amount-container:hover {
  background: #e8525f;
  color: #ffffff;
}

.donation-level-label-input-container input:checked~label {
  background: #e8525f;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="donation-level-container">
  <div class="form-content">

    <div class="donation-level-input-container form-input">

      <div class="donation-level-label-input-container">
        <input name="level_flexibleexpanded" id="level_flexibleexpanded5942" value="5942" onclick="evalMatchingGift('$35.00');" type="radio">
      </div>

      <label for="level_flexibleexpanded5942" onclick="">

    <div class="donation-level-amount-container">
    $35.00
    </div>

    </label>

    </div>

    <input name="level_flexibleexpandedsubmit" id="level_flexible_5942expandedsubmit" value="true" type="hidden">
  </div>
</div>
<div class="donation-level-container">
  <div class="form-content">

    <div class="donation-level-input-container form-input">

      <div class="donation-level-label-input-container">
        <input name="level_flexibleexpanded" id="level_flexibleexpanded5943" value="5943" onclick="evalMatchingGift('$60.00');" type="radio">
      </div>

      <label for="level_flexibleexpanded5943" onclick="">

    <div class="donation-level-amount-container">
    $60.00
    </div>

    </label>

    </div>

    <input name="level_flexibleexpandedsubmit" id="level_flexible_5943expandedsubmit" value="true" type="hidden">
  </div>
</div>
<div class="donation-level-container">
  <div class="form-content">

    <div class="donation-level-input-container form-input">

      <div class="donation-level-label-input-container">
        <input name="level_flexibleexpanded" id="level_flexibleexpanded5944" value="5944" onclick="evalMatchingGift('$120.00');" type="radio">
      </div>

      <label for="level_flexibleexpanded5944" onclick="">

    <div class="donation-level-amount-container">
    $120.00
    </div>

    </label>

    </div>

    <input name="level_flexibleexpandedsubmit" id="level_flexible_5944expandedsubmit" value="true" type="hidden">
  </div>
</div></code>```

Here is my inspiration donate page: https://action.audubon.org/donate/now

Alas, their labels are set up better so I think they were able to make the buttons with pure CSS (?).

My buttons currently are looking decent, are sized fine and colored nicely, but they just won't stay that coral color when clicked! Can someone help me out?

I've seen a lot of questions here on this topic but I can't seem to get anything to work.

I'm sure there are other issues in the code, please point them out if you see them!

答:
You need this piece of jQuery:

```<code>$(function() {
  $(document).on('click','.donation-level-amount-container',function(){
    $('.donation-level-amount-container').removeClass('active');
    $(this).addClass('active');
  });
});
</code>```

Update also to this CSS:

```<code>.donation-level-amount-container:hover, .donation-level-amount-container.active {
    background:#e8525f;
    color:#ffffff;
}
</code>```

Here is the updated jsfiddle.

Body:
I am trying to make our dinky radio buttons into lovely toggle buttons on our donation page. The HTML cannot be modified, and as it stands the inputs are wrapped in divs, then followed by the labels. I have zero knowledge of JS/jQuery and I imagine this task requires some.

Here is my fiddle: https://jsfiddle.net/cgz63qhd/

body {
  padding: 10px;
  font-family: sans-serif;
}

div.donation-levels {
  margin: 3px 0;
}

.donation-level-container {
  display: inline-block;
}

.donation-level-container input {
  visibility: hidden;
}

.donation-level-amount-container {
  text-align: center;
  margin: 5px 2px;
  padding: 0.7em 2em;
  color: #ffffff;
  background-color: #1a92b4;
  border-radius: 5px;
  display: inline-block;
  cursor: pointer;
  font-size: 22px;
}

.donation-level-amount-container:hover {
  background: #e8525f;
  color: #ffffff;
}

.donation-level-label-input-container input:checked~label {
  background: #e8525f;
}

        <input name="level_flexibleexpanded" id="level_flexibleexpanded5942" value="5942" onclick="evalMatchingGift('$35.00');" type="radio">

    $35.00

    <input name="level_flexibleexpandedsubmit" id="level_flexible_5942expandedsubmit" value="true" type="hidden">

        <input name="level_flexibleexpanded" id="level_flexibleexpanded5943" value="5943" onclick="evalMatchingGift('$60.00');" type="radio">

    $60.00

    <input name="level_flexibleexpandedsubmit" id="level_flexible_5943expandedsubmit" value="true" type="hidden">

        <input name="level_flexibleexpanded" id="level_flexibleexpanded5944" value="5944" onclick="evalMatchingGift('$120.00');" type="radio">

    $120.00

    <input name="level_flexibleexpandedsubmit" id="level_flexible_5944expandedsubmit" value="true" type="hidden">

Here is my inspiration donate page: https://action.audubon.org/donate/now

Alas, their labels are set up better so I think they were able to make the buttons with pure CSS (?).

My buttons currently are looking decent, are sized fine and colored nicely, but they just won't stay that coral color when clicked! Can someone help me out?

I've seen a lot of questions here on this topic but I can't seem to get anything to work.

I'm sure there are other issues in the code, please point them out if you see them!

Body:
You need this piece of jQuery:

$(function() {
  $(document).on('click','.donation-level-amount-container',function(){
    $('.donation-level-amount-container').removeClass('active');
    $(this).addClass('active');
  });
});

Update also to this CSS:

.donation-level-amount-container:hover, .donation-level-amount-container.active {
    background:#e8525f;
    color:#ffffff;
}

Here is the updated jsfiddle.


问:
how to add elements of a list
I have a list(Y) which contains numpy arrays of different length.The list contain more than 50 element(I just took five for testing).The shape of the list is 5 and I can print the shape of each element as shown below and the outputs are in the comments

```<code>print(Y.shape) #(5,)
print(Y[0].shape) #(600, 2)
print(Y[1].shape) #(250, 2)
print(Y[2].shape) #(300, 2)
print(Y[3].shape) #(200, 2)
print(Y[4].shape) #(100, 2)
</code>```

each element of the list has different length(600,250,300,200,100) but all have [1 0] or [0 1] dimension.I want to add these elements and get output as

(1450,2)

I have tried

Y=np.sum(Y, axis=0)

it gives a broadcast error,ValueError: operands could not be broadcast together with shapes (600,2) (250,2)  and I know this wants (600,2) (600,2) or (250,2) (250,2) but I want to add the 600 and 250.

The same function works with a three dimension array like [80,20,30] and [40,20,30] I get output as [120,20,30]

how can I add/sum these elements?

答:
Use np.concatenate:

```<code>np.concatenate(Y, axis=0)
</code>```

For example:

```<code>import numpy as np

Y1 = np.ones((100, 2))
Y2 = np.ones((200, 2))
Y3 = np.ones((300, 2))

np.concatenate([Y1, Y2, Y3], axis=0).shape   # (600, 2)
</code>```

Title: how to add elements of a list

Body:
I have a list(Y) which contains numpy arrays of different length.The list contain more than 50 element(I just took five for testing).The shape of the list is 5 and I can print the shape of each element as shown below and the outputs are in the comments

print(Y.shape) #(5,)
print(Y[0].shape) #(600, 2)
print(Y[1].shape) #(250, 2)
print(Y[2].shape) #(300, 2)
print(Y[3].shape) #(200, 2)
print(Y[4].shape) #(100, 2)

each element of the list has different length(600,250,300,200,100) but all have [1 0] or [0 1] dimension.I want to add these elements and get output as

(1450,2)

I have tried

Y=np.sum(Y, axis=0)

it gives a broadcast error,ValueError: operands could not be broadcast together with shapes (600,2) (250,2)  and I know this wants (600,2) (600,2) or (250,2) (250,2) but I want to add the 600 and 250.

The same function works with a three dimension array like [80,20,30] and [40,20,30] I get output as [120,20,30]

how can I add/sum these elements?

Body:
Use np.concatenate:

np.concatenate(Y, axis=0)

For example:

import numpy as np

Y1 = np.ones((100, 2))
Y2 = np.ones((200, 2))
Y3 = np.ones((300, 2))

np.concatenate([Y1, Y2, Y3], axis=0).shape   # (600, 2)