问:
How to partially check object with Jasmine
is there a way how to partially match object with array property? Let's suppose that I'd like to test this object

```

    {
       "groups": [
          {
             "id": 1,
             "name": "Group 1",
             "people": [
                {
                   "firstName": "John",
                   "age": 23
                },
                {
                   "firstName": "Ethan",
                   "age": 18
                }
             ]
          },
          {
             "id": 2,
             "name": "Group 2",
             "people": [
                {
                   "firstName": "Peter",
                   "age": 47
                },
                {
                   "firstName": "Henry",
                   "age": 55
                }
             ]
          }
       ]
    }

```

and ensure that it contains group with name Group 1 that contains John and Ethan.
I'm aware of jasmine.objectContaining but I don't know how to apply to this particular case.
Thank for any advice.

答:
You can achieve the desired result by using jasmine.arrayContaining and jasmine.objectContaining like below.

Please note: 'foo' is variable in which your test data resides as you wrote above.

```<code>describe("Array comparison", function () {

  it("matches objects with the expect key/value pairs", function() {

    expect(foo).toEqual(jasmine.objectContaining({

      groups: jasmine.arrayContaining([
        jasmine.objectContaining({name: "Group 2"}),
        jasmine.objectContaining({
            people: jasmine.arrayContaining([
              jasmine.objectContaining({firstName: "Peter"}),
              jasmine.objectContaining({firstName: "Henry"})
          ])
        })
       ])
    }));
</code>```

Here is a jsFiddle for above working code.

Body:
is there a way how to partially match object with array property? Let's suppose that I'd like to test this object

    {
       "groups": [
          {
             "id": 1,
             "name": "Group 1",
             "people": [
                {
                   "firstName": "John",
                   "age": 23
                },
                {
                   "firstName": "Ethan",
                   "age": 18
                }
             ]
          },
          {
             "id": 2,
             "name": "Group 2",
             "people": [
                {
                   "firstName": "Peter",
                   "age": 47
                },
                {
                   "firstName": "Henry",
                   "age": 55
                }
             ]
          }
       ]
    }

and ensure that it contains group with name Group 1 that contains John and Ethan.
I'm aware of jasmine.objectContaining but I don't know how to apply to this particular case.
Thank for any advice.

Body:
You can achieve the desired result by using jasmine.arrayContaining and jasmine.objectContaining like below.

Please note: 'foo' is variable in which your test data resides as you wrote above.

describe("Array comparison", function () {

  it("matches objects with the expect key/value pairs", function() {

    expect(foo).toEqual(jasmine.objectContaining({

      groups: jasmine.arrayContaining([
        jasmine.objectContaining({name: "Group 2"}),
        jasmine.objectContaining({
            people: jasmine.arrayContaining([
              jasmine.objectContaining({firstName: "Peter"}),
              jasmine.objectContaining({firstName: "Henry"})
          ])
        })
       ])
    }));

Here is a jsFiddle for above working code.


来源: stackexchange

问:
Encrypt database connection .env in laravel
When we put laravel project to localhost. Anyone can view our project .env file and they can view our database password DB_USERNAME= DB_PASSWORD= how can we encrypt it??

答:
You can access environment variables using $_SERVER , $_ENV (PHP super global variables) and env helper and after this encrypt your environment variables value and decrypt when assign value to a variable . For more information laravel docs

If you have not enough time than you also find this package to make it easy to add encrypted environment variables BaglerIT package

ContentLicense: CC BY-SA 3.0


问:
Detecting Page Changes in pdf using WebView in iOS Swift
I'm displaying a pdf stored in a Document directory in a WebView, i want to detect the changes of the pages within the pdf. I searched about it and got to know about the methods goBack() and goForward() but it didn't work for me, i think they are for switching between the files in webView but i want to detect the page switching within a current loaded pdf file. i didn't have a code for this to show as i'm still trying to figure it out. any sample code with an explanation will be really helpful. Thanks.

答:
For this you have to scrollView to navigate particular position of page, like below.

```<code>let selectedPage: CGFloat = 2; // i.e. Go to page 5

let pageHeight: CGFloat = 1000.0; // i.e. Height of PDF page = 1000 px;

let y: CGFloat = pageHeight * selectedPage;

let pageOffset = CGPoint(x: 0, y: y)
self.webView.scrollView.setContentOffset(pageOffset, animated: true)
</code>```

Body:
For this you have to scrollView to navigate particular position of page, like below.

let selectedPage: CGFloat = 2; // i.e. Go to page 5

let pageHeight: CGFloat = 1000.0; // i.e. Height of PDF page = 1000 px;

let y: CGFloat = pageHeight * selectedPage;

let pageOffset = CGPoint(x: 0, y: y)
self.webView.scrollView.setContentOffset(pageOffset, animated: true)


问:
How to stop elements resizing when I change the zoom on page
I'm a newbie to HTML and CSS, facing a problem where when I resize my page, the elements go berserk. I've tried everything from creating a main wrapper and adding max widths and heights, but all to no avail. Here is my code in CSS so that you can take a look.</p>

```<code>body {
  background-image: url(3eMAHaa.jpg)
}

div.header {
  border: 1px solid black;
  border-radius: 50px;
  padding-top: 26%;
  padding-bottom: 26%;
  padding-left: 10%;
  padding-right: 10%
}

h1 {
  ;
  position: absolute;
  top: 30%;
  left: 40%;
  color: #FF2B24;
  font-family: helvetica
}

.someimage {
  position: absolute;
  top: 43%;
  left: 32%
}

div.navbox {
  border: 1px solid black;
  border-radius: 50px;
  padding-top: 70px;
  padding-bottom: 70px;
  padding-left: 500px;
  padding-right: 500px;
  position: absolute;
  top: 1%;
  right: 2%
}

img.about {
  border: 1px solid gray;
  position: absolute;
  right: 80%;
  top: 35%
}

}
img.location {
  border: 1px solid gray;
  position: absolute
}
img.contact {
  border: 1px solid gray;
  position: absolute;
  right: 15%;
  top: 35%
}
</code>```

答: Remove your all padding code then it will not be resized</p>

Body:
I'm a newbie to HTML and CSS, facing a problem where when I resize my page, the elements go berserk. I've tried everything from creating a main wrapper and adding max widths and heights, but all to no avail. Here is my code in CSS so that you can take a look.

body {
  background-image: url(3eMAHaa.jpg)
}

div.header {
  border: 1px solid black;
  border-radius: 50px;
  padding-top: 26%;
  padding-bottom: 26%;
  padding-left: 10%;
  padding-right: 10%
}

h1 {
  ;
  position: absolute;
  top: 30%;
  left: 40%;
  color: #FF2B24;
  font-family: helvetica
}

.someimage {
  position: absolute;
  top: 43%;
  left: 32%
}

div.navbox {
  border: 1px solid black;
  border-radius: 50px;
  padding-top: 70px;
  padding-bottom: 70px;
  padding-left: 500px;
  padding-right: 500px;
  position: absolute;
  top: 1%;
  right: 2%
}

img.about {
  border: 1px solid gray;
  position: absolute;
  right: 80%;
  top: 35%
}

}
img.location {
  border: 1px solid gray;
  position: absolute
}
img.contact {
  border: 1px solid gray;
  position: absolute;
  right: 15%;
  top: 35%
}


问:
Cloudant Query choosing the wrong index
I'm using the following end-point to see which index is being chosen by cloudant to fetch my results:

```<code>https://mydb.cloudant.com/mlslistings-temp/_explain
</code>```

and here's an example query for which wrong index is being chosen:

```<code>{
 "sort": ["ListPrice"],
 "limit":20,
 "selector":{
     "Street#":"1031",
     "MLSStatus":{"$or":[{"$eq":"Active"}]},
     "ListPrice":{"$gte":0},
     "ParcelSizeAcres":{"$gte":0,"$lte":50}}
}
</code>```

All the fields you see in the query are json based indexes.
I have two questions regarding index selection:

Whichever field I put as the sort field automatically gets selected as the chosen index. It would've been fine but mostly my query is going to be "ListPrice":{"$gte":0} which ends-up doing full table scan since almost all properties have greater than 0 price.

If I take out all the fields in the query and just leave Street# and ParcelSizeAcres in the query, ParcelSizeAcres is selected as the index but that's wrong. Because when I run the query with Street# a total of 53 documents are returned whereas ParcelSizeAcres returns hundreds.

These index selections seem to be going against Cloudant's Explain Plans

答: All your indexes hold a single field. So as far as Cloudant's concerned they have the same weight, and as per the documentation you refer to, the choice is then the first available index in lexicographical sort order, so in the first case, ListPrice and in the second case, ParcelSizeAcres. It seems consistent with the documented behaviour.

Title: Cloudant Query choosing the wrong index

Body:
I'm using the following end-point to see which index is being chosen by cloudant to fetch my results:

https://mydb.cloudant.com/mlslistings-temp/_explain

and here's an example query for which wrong index is being chosen:

{
 "sort": ["ListPrice"],
 "limit":20,
 "selector":{
     "Street#":"1031",
     "MLSStatus":{"$or":[{"$eq":"Active"}]},
     "ListPrice":{"$gte":0},
     "ParcelSizeAcres":{"$gte":0,"$lte":50}}
}

All the fields you see in the query are json based indexes.
I have two questions regarding index selection:

Whichever field I put as the sort field automatically gets selected as the chosen index. It would've been fine but mostly my query is going to be "ListPrice":{"$gte":0} which ends-up doing full table scan since almost all properties have greater than 0 price.

If I take out all the fields in the query and just leave Street# and ParcelSizeAcres in the query, ParcelSizeAcres is selected as the index but that's wrong. Because when I run the query with Street# a total of 53 documents are returned whereas ParcelSizeAcres returns hundreds.

These index selections seem to be going against Cloudant's Explain Plans


问:
Make section on top of all div
I am trying to make the Country list from drop down to be on top of the page. It going behnid the content.

I did changed the section itself with home page.

It working now.

答:
In your code you have given overflow: hidden to .header-inner because of which the list is getting hidden. Once you remove it the image will overflow. So following is the solution for both issues:

HTML:

```<code><div class="overlay bg-opacity-5">
  <img src="images/header-img_howitworks.jpg" alt="" class="img-responsive-1">
</div>
</code>```

You need to move the image inside the overlay div.

CSS:

```<code>.header-inner {
    position: relative;
    width: 100%;
    height: 300px !important;
    padding: 0px;
    margin: 0px;
    float: left;
    z-index: 0;
    /* overflow: hidden; */
}
.header-inner.two .overlay {
    height: 300px;
    overflow: hidden;
}
</code>```

In CSS, remove overflow hidden from .header-inner and add it to the overlay.

Title: Make section on top of all div

Body:
In your code you have given overflow: hidden to .header-inner because of which the list is getting hidden. Once you remove it the image will overflow. So following is the solution for both issues:

HTML:

<div class="overlay bg-opacity-5">
  <img src="images/header-img_howitworks.jpg" alt="" class="img-responsive-1">
</div>

You need to move the image inside the overlay div.

CSS:

.header-inner {
    position: relative;
    width: 100%;
    height: 300px !important;
    padding: 0px;
    margin: 0px;
    float: left;
    z-index: 0;
    /* overflow: hidden; */
}
.header-inner.two .overlay {
    height: 300px;
    overflow: hidden;
}

In CSS, remove overflow hidden from .header-inner and add it to the overlay.


问:
Amazon EC2 latency
What's the expected latency for a simple connection between a pair of Amazon EC2 instances in the same region?

Thanks!

答: The latency should be similar to the latency of two computers in the same LAN. Just make sure that you are using the private IPs when connecting the two images and not their public ones.</p>

ContentLicense: CC BY-SA 2.5

Title: Amazon EC2 latency


问:
Schedule U-SQL jobs in Azure Data Factory
I've got a following issue. I'd like to schedule three U-SQL jobs in following timing: 02:00UTC, 03:00UTC and 04:00UTC everyday. I know that by default, jobs in the pipeline are executed at 12:00AM UTC hence all my jobs run at the same time which is not what I want.

I red the documentation and it is written that I should consider offset parameter in dataset template. However when I try to set this the following error occurs: .

I do not knot how to set different than 12:00AM runtime of U-SQL job. Can You provide me some info on how to do that properly? In addition I attach my template of a dataset and a pipeline:

Dataset

```<code>{
"name": "TransformedData2",
"properties": {
    "published": false,
    "type": "AzureDataLakeStore",
    "linkedServiceName": "ADLstore_linkedService_scrapper",
    "typeProperties": {
        "fileName": "TestOutput2.csv",
        "folderPath": "transformedData/",
        "format": {
            "type": "TextFormat",
            "rowDelimiter": "\n",
            "columnDelimiter": ","
        }
    },
    "availability": {
        "frequency": "Day",
        "interval": 1,
        "style": "StartOfInterval"
    }
}
</code>```

}

Pipeline

```<code>{
"name": "filtering",
"properties": {
    "activities": [
        {
            "type": "DataLakeAnalyticsU-SQL",
            "typeProperties": {
                "scriptPath": "usqljobs\\cleanStatements.txt",
                "scriptLinkedService": "AzureStorageLinkedService",
                "degreeOfParallelism": 5,
                "priority": 100,
                "parameters": {}
            },
            "outputs": [
                {
                    "name": "TransformedData2"
                }
            ],
            "scheduler": {
                "frequency": "Day",
                "interval": 1,
                "style": "StartOfInterval"
            },
            "name": "Brajan filtering",
            "linkedServiceName": "AzureDataLakeAnalyticsLinkedService"
        }
    ],
    "start": "2017-07-02T09:50:00Z",
    "end": "2018-06-30T03:00:00Z",
    "isPaused": false,
    "hubName": "datafactoryfin_hub",
    "pipelineMode": "Scheduled"
}
</code>```

}

Thanks

答:
Using the Offset attribute can get a little messy as you'll need to re-provision time slices at the dataset level.

As an alternative I would suggest using the Delay attribute at for the activity. This gives more control and does not require time slices to be re-provisioned.

So in your JSON...

```<code>{
"name": "filtering",
"properties": {
    "activities": [
        {
            "type": "DataLakeAnalyticsU-SQL",
            "typeProperties": {
                "scriptPath": "usqljobs\\cleanStatements.txt",
                "scriptLinkedService": "AzureStorageLinkedService",
                "degreeOfParallelism": 5,
                "priority": 100,
                "parameters": {}
            },
            "outputs": [
                {
                    "name": "TransformedData2"
                }
            ],
            "policy": {
              "delay": "02:00:00" // <<<<< 2:00am start
            },
            "scheduler": {
                "frequency": "Day",
                "interval": 1,
                "style": "StartOfInterval"
            },
            "name": "Brajan filtering",
            "linkedServiceName": "AzureDataLakeAnalyticsLinkedService"
        }
    ],
    "start": "2017-07-02T09:50:00Z",
    "end": "2018-06-30T03:00:00Z",
    "isPaused": false,
    "hubName": "datafactoryfin_hub",
    "pipelineMode": "Scheduled"
}
</code>```

Then you'll of course need additional activities for the 3:00am and 4:00am versions.

Check out this link for more info:

https://learn.microsoft.com/en-us/azure/data-factory/data-factory-scheduling-and-execution

Delay is mentioned about a quarter of the way down the page.

Hope this helps

Body:
I've got a following issue. I'd like to schedule three U-SQL jobs in following timing: 02:00UTC, 03:00UTC and 04:00UTC everyday. I know that by default, jobs in the pipeline are executed at 12:00AM UTC hence all my jobs run at the same time which is not what I want.

I red the documentation and it is written that I should consider offset parameter in dataset template. However when I try to set this the following error occurs: .

I do not knot how to set different than 12:00AM runtime of U-SQL job. Can You provide me some info on how to do that properly? In addition I attach my template of a dataset and a pipeline:

Dataset

{
"name": "TransformedData2",
"properties": {
    "published": false,
    "type": "AzureDataLakeStore",
    "linkedServiceName": "ADLstore_linkedService_scrapper",
    "typeProperties": {
        "fileName": "TestOutput2.csv",
        "folderPath": "transformedData/",
        "format": {
            "type": "TextFormat",
            "rowDelimiter": "\n",
            "columnDelimiter": ","
        }
    },
    "availability": {
        "frequency": "Day",
        "interval": 1,
        "style": "StartOfInterval"
    }
}

}

Pipeline

{
"name": "filtering",
"properties": {
    "activities": [
        {
            "type": "DataLakeAnalyticsU-SQL",
            "typeProperties": {
                "scriptPath": "usqljobs\\cleanStatements.txt",
                "scriptLinkedService": "AzureStorageLinkedService",
                "degreeOfParallelism": 5,
                "priority": 100,
                "parameters": {}
            },
            "outputs": [
                {
                    "name": "TransformedData2"
                }
            ],
            "scheduler": {
                "frequency": "Day",
                "interval": 1,
                "style": "StartOfInterval"
            },
            "name": "Brajan filtering",
            "linkedServiceName": "AzureDataLakeAnalyticsLinkedService"
        }
    ],
    "start": "2017-07-02T09:50:00Z",
    "end": "2018-06-30T03:00:00Z",
    "isPaused": false,
    "hubName": "datafactoryfin_hub",
    "pipelineMode": "Scheduled"
}

}

Thanks

Body:
Using the Offset attribute can get a little messy as you'll need to re-provision time slices at the dataset level.

As an alternative I would suggest using the Delay attribute at for the activity. This gives more control and does not require time slices to be re-provisioned.

So in your JSON...

{
"name": "filtering",
"properties": {
    "activities": [
        {
            "type": "DataLakeAnalyticsU-SQL",
            "typeProperties": {
                "scriptPath": "usqljobs\\cleanStatements.txt",
                "scriptLinkedService": "AzureStorageLinkedService",
                "degreeOfParallelism": 5,
                "priority": 100,
                "parameters": {}
            },
            "outputs": [
                {
                    "name": "TransformedData2"
                }
            ],
            "policy": {
              "delay": "02:00:00" // <<<<< 2:00am start
            },
            "scheduler": {
                "frequency": "Day",
                "interval": 1,
                "style": "StartOfInterval"
            },
            "name": "Brajan filtering",
            "linkedServiceName": "AzureDataLakeAnalyticsLinkedService"
        }
    ],
    "start": "2017-07-02T09:50:00Z",
    "end": "2018-06-30T03:00:00Z",
    "isPaused": false,
    "hubName": "datafactoryfin_hub",
    "pipelineMode": "Scheduled"
}

Then you'll of course need additional activities for the 3:00am and 4:00am versions.

Check out this link for more info:

https://learn.microsoft.com/en-us/azure/data-factory/data-factory-scheduling-and-execution

Delay is mentioned about a quarter of the way down the page.

Hope this helps


问:
printing a texture2D to file or as image for debugging purposes
I am trying to figure out how an image is processed (what it looks like, etc...) at several stages of Image Processing operations, so I have written the following co-routine to capture a screenshot, but I am not sure how to print out the taken shots at different stages (for example as png images)

```<code>public void CaptureFrame(RectTransform rect)
{
    StartCoroutine( Co_Capture(rect) );
}

private IEnumerator Co_Capture(RectTransform rect)
{
    yield return new WaitForEndOfFrame();

    _texture = new Texture2D( (int)rect.sizeDelta.x, (int)rect.sizeDelta.y );
    _texture.ReadPixels( new Rect( rect.anchoredPosition.x - (rect.sizeDelta.x * 0.5f), rect.anchoredPosition.y - (rect.sizeDelta.y * 0.5f), rect.sizeDelta.x, rect.sizeDelta.y ), 0, 0 );
    _texture.Apply();

    OnImageCaptured( new ScreenShotEventArgs(_texture) );
}
</code>```

Given that I build the app to an Android device, ideally I would like to have the images saved both in a folder somewhere (through Unity3D Editor) as well as on the device in its data folder, for example. Something akin to Debug.Log messages that you print out at different stages to see which parts of your code are reached, etc...

What options do I have? What is the code/command/method for saving an image/picture through Unity3D and also on an Android tablet, so that the developer can see the images at various stages or processing?

答:
This will save the texture as Img1.png at a valid, public location on all devices.</p>

```<code>File.WriteAllBytes(Path.Combine(Application.persistentDataPath + "Img1.png"), _texture.EncodeToPng());
</code>```

Body:
I am trying to figure out how an image is processed (what it looks like, etc...) at several stages of Image Processing operations, so I have written the following co-routine to capture a screenshot, but I am not sure how to print out the taken shots at different stages (for example as png images)

public void CaptureFrame(RectTransform rect)
{
    StartCoroutine( Co_Capture(rect) );
}

private IEnumerator Co_Capture(RectTransform rect)
{
    yield return new WaitForEndOfFrame();

    _texture = new Texture2D( (int)rect.sizeDelta.x, (int)rect.sizeDelta.y );
    _texture.ReadPixels( new Rect( rect.anchoredPosition.x - (rect.sizeDelta.x * 0.5f), rect.anchoredPosition.y - (rect.sizeDelta.y * 0.5f), rect.sizeDelta.x, rect.sizeDelta.y ), 0, 0 );
    _texture.Apply();

    OnImageCaptured( new ScreenShotEventArgs(_texture) );
}

Given that I build the app to an Android device, ideally I would like to have the images saved both in a folder somewhere (through Unity3D Editor) as well as on the device in its data folder, for example. Something akin to Debug.Log messages that you print out at different stages to see which parts of your code are reached, etc...

What options do I have? What is the code/command/method for saving an image/picture through Unity3D and also on an Android tablet, so that the developer can see the images at various stages or processing?

Body:
This will save the texture as Img1.png at a valid, public location on all devices.

File.WriteAllBytes(Path.Combine(Application.persistentDataPath + "Img1.png"), _texture.EncodeToPng());


问:
angular.js TypeError: $(...).owlCarousel is not a function
I am using angular js and data-ng-repeat to get data.
Below is my HTML.

```<code>      <div id="newsslide" class="owl-carousel owl-theme">
          <div class="item darkCyan" data-ng-repeat="items in NewsList">
                        Hello
          </div>
      </div>
</code>```

Here is my JS

```<code>    $scope.getNewsList = function (Id) {
    var getData = HomeService.getNewsList(Id);
    getData.then(function (_result) {
        $scope.getMediaList(Id);
        if (_result.data.length > 0) {
            $scope.NewsList = _result.data;
            $scope.NewsNoRecords = false;
            $timeout(function () {
                $("#newsslide").owlCarousel({
                    items: 3,
                    nav: false,
                    dots: true,
                    rtl:true,
                    // autoPlay: 3000,
                    navText: [
                    "<i class='fa fa-angle-left'></i>",
                    "<i class='fa fa-angle-right'></i>"
                    ]
                });
            }, 1000);
        }
        else {
            $scope.NewsNoRecords = true;
        }
    }, function (errorMsg) {
        $scope.loadingDataEntryList = false;
        console.log('Error in getting records - ' + JSON.stringify(errorMsg))
    });
}
</code>```

Data is binding Fine. But it shows

TypeError: $(...).owlCarousel is not a function.

I also tried to run  $("#newsslide").owlCarousel({}); through pasting in chrome developer console. I got error

Uncaught TypeError: $(...).owlCarousel is not a function
      at Anonymous:1:18.

Below is library sequence i added, [jQuery library was in head tag before this image. and thats why it cause problem]
[]1

I have searched a lot. Please help. Thanks

答: Using jquery near and above of all libraries resolved the issue. Before this, The jquery was in head tag. Thanks ...</p>

Body:
I am using angular js and data-ng-repeat to get data.
Below is my HTML.

                        Hello

Here is my JS

    $scope.getNewsList = function (Id) {
    var getData = HomeService.getNewsList(Id);
    getData.then(function (_result) {
        $scope.getMediaList(Id);
        if (_result.data.length > 0) {
            $scope.NewsList = _result.data;
            $scope.NewsNoRecords = false;
            $timeout(function () {
                $("#newsslide").owlCarousel({
                    items: 3,
                    nav: false,
                    dots: true,
                    rtl:true,
                    // autoPlay: 3000,
                    navText: [
                    "",
                    ""
                    ]
                });
            }, 1000);
        }
        else {
            $scope.NewsNoRecords = true;
        }
    }, function (errorMsg) {
        $scope.loadingDataEntryList = false;
        console.log('Error in getting records - ' + JSON.stringify(errorMsg))
    });
}

Data is binding Fine. But it shows

TypeError: $(...).owlCarousel is not a function.

I also tried to run  $("#newsslide").owlCarousel({}); through pasting in chrome developer console. I got error

Uncaught TypeError: $(...).owlCarousel is not a function
      at Anonymous:1:18.

Below is library sequence i added, [jQuery library was in head tag before this image. and thats why it cause problem]
[]1

I have searched a lot. Please help. Thanks


问:
Custom Radio Buttons: How to uncheck? (Checkbox Hack)
I created some custom checkboxes which work great:

https://codepen.io/anon/pen/jwxXar

I tried to do the same with radio buttons. But if one radio button is active and I click another one, the unchecking does not work:

➤ https://codepen.io/anon/pen/YQLdxd

Custom Radio Buttons CSS Code

```<code>.radio  {
    position: relative;
    margin-bottom: 10px;
}

.radio input[type="radio"] {
    cursor: pointer;
    height: 100%;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
}

.radio label {margin-left: 32px;}

.radio label:before,
.radio label:after {
    content: "";
    display: block;
    position: absolute;
}

.radio label:before {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    height: 20px;
    left: 0;
    top: 4px;
    width: 20px;
}

.radio label:after {
    background: red;
    border-radius: 50%;
    height: 12px;
    left: 5px;
    opacity: 0;
    pointer-events: none;
    top: 9px;
    width: 12px;
}

.radio input:checked ~ label:after {opacity: 1;}

input[type="radio"]:checked + label:before {
    border: 1px solid red;
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 0 #fff, inset 0 0 0 16px #fff;
    color: #fff;
}
</code>```

Custom Radio Buttons HTMLCode

```<code><div class="radio">
    <input value="" type="radio">
    <label>Radio Button 1</label>
</div>
<div class="radio">
    <input value="" type="radio">
    <label>Radio Button 2</label>
</div>
<div class="radio">
    <input value="" type="radio">
    <label>Radio Button 3</label>
</div>
<div class="radio">
    <input value="" type="radio">
    <label>Radio Button 4</label>
</div>
</code>```

Does anyone of the CSS Super Heros have an idea, why the radio buttons are not working?

答:
you have to specify the name of the radios : name="radios", the same name for all the radio of the group

.radio  {
    position: relative;
    margin-bottom: 10px;
}

.radio input[type="radio"] {
    cursor: pointer;
    height: 100%;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
}

.radio label {margin-left: 32px;}

.radio label:before,
.radio label:after {
    content: "";
    display: block;
    position: absolute;
}

.radio label:before {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    height: 20px;
    left: 0;
    top: 4px;
    width: 20px;
}

.radio label:after {
    background: red;
    border-radius: 50%;
    height: 12px;
    left: 5px;
    opacity: 0;
    pointer-events: none;
    top: 9px;
    width: 12px;
}

.radio input:checked ~ label:after {opacity: 1;}

input[type="radio"]:checked + label:before {
    border: 1px solid red;
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 0 #fff, inset 0 0 0 16px #fff;
    color: #fff;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 1</label>
</div>
<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 2</label>
</div>
<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 3</label>
</div>
<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 4</label>
</div></code>```

Body:
I created some custom checkboxes which work great:

https://codepen.io/anon/pen/jwxXar

I tried to do the same with radio buttons. But if one radio button is active and I click another one, the unchecking does not work:

➤ https://codepen.io/anon/pen/YQLdxd

Custom Radio Buttons CSS Code

.radio  {
    position: relative;
    margin-bottom: 10px;
}

.radio input[type="radio"] {
    cursor: pointer;
    height: 100%;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
}

.radio label {margin-left: 32px;}

.radio label:before,
.radio label:after {
    content: "";
    display: block;
    position: absolute;
}

.radio label:before {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    height: 20px;
    left: 0;
    top: 4px;
    width: 20px;
}

.radio label:after {
    background: red;
    border-radius: 50%;
    height: 12px;
    left: 5px;
    opacity: 0;
    pointer-events: none;
    top: 9px;
    width: 12px;
}

.radio input:checked ~ label:after {opacity: 1;}

input[type="radio"]:checked + label:before {
    border: 1px solid red;
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 0 #fff, inset 0 0 0 16px #fff;
    color: #fff;
}

Custom Radio Buttons HTMLCode

    <input value="" type="radio">
    Radio Button 1

    <input value="" type="radio">
    Radio Button 2

    <input value="" type="radio">
    Radio Button 3

    <input value="" type="radio">
    Radio Button 4

Does anyone of the CSS Super Heros have an idea, why the radio buttons are not working?

Body:
you have to specify the name of the radios : name="radios", the same name for all the radio of the group

.radio  {
    position: relative;
    margin-bottom: 10px;
}

.radio input[type="radio"] {
    cursor: pointer;
    height: 100%;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
}

.radio label {margin-left: 32px;}

.radio label:before,
.radio label:after {
    content: "";
    display: block;
    position: absolute;
}

.radio label:before {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    height: 20px;
    left: 0;
    top: 4px;
    width: 20px;
}

.radio label:after {
    background: red;
    border-radius: 50%;
    height: 12px;
    left: 5px;
    opacity: 0;
    pointer-events: none;
    top: 9px;
    width: 12px;
}

.radio input:checked ~ label:after {opacity: 1;}

input[type="radio"]:checked + label:before {
    border: 1px solid red;
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 0 #fff, inset 0 0 0 16px #fff;
    color: #fff;
}

<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 1</label>
</div>
<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 2</label>
</div>
<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 3</label>
</div>
<div class="radio">
    <input value="" type="radio" name="radios">
    <label>Radio Button 4</label>
</div>


答:
First of all, it is not the thing with SVG itself, but general behaviour of clickable ("tapable") elements on your page. Regardless if it is a link or just an element that changes when active, it will get the highlight to show it is usable.

To remove it (or alter it if you wish so) I generally use this solution from CSS Tricks and recommend it:

```<code>-webkit-tap-highlight-color: rgba(0,0,0,0);
</code>```

Here is the link on CSS Tricks

It is not a standard solution tho: MDN

Beware that cursor: pointer might prevent that from working!

I would look into :active and :focus adjusting to maybe find some fallback if you need wider and more secure support.

Title: SVG Icon highlighting issue in mobile devices on click

Body:
I have used SVG icons in my web page. When i click on it from a mobile browser, the browser show highlighting on the icon.
Can i disable that highlight appear?

Example:
highlight

Code:

<svg fill="#262626" height="72" viewBox="0 0 24 24" width="72" xmlns="http://www.w3.org/2000/svg">
    <path d="M0 0h24v24H0z" fill="none"></path>
    <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"></path>
</svg>

Body:
First of all, it is not the thing with SVG itself, but general behaviour of clickable ("tapable") elements on your page. Regardless if it is a link or just an element that changes when active, it will get the highlight to show it is usable.

To remove it (or alter it if you wish so) I generally use this solution from CSS Tricks and recommend it:

-webkit-tap-highlight-color: rgba(0,0,0,0);

Here is the link on CSS Tricks

It is not a standard solution tho: MDN

Beware that cursor: pointer might prevent that from working!

I would look into :active and :focus adjusting to maybe find some fallback if you need wider and more secure support.


问:
Seperate GC log file for each Java VM on a Oracle Application Server
We have an Oracle AS 10.1.3.4 running 1 application on multiple JVMs. We have set up garbage collection logging using the -Xloggc parameter.

However, the gc logging of both JVMs is sent to the same log file. We'd like to get this logging in different log files. Anyone got an idea how to do this?

答: Do you have control over the JVM arguments of each JVM? I guess the -Xloggc which you have set is getting applied for both the JVM's hence the situation. Do you have an admin console where you can view each JVM of your cluster? If yes, you can change the JVM properties for each JVM to log the GC activity to a separate file.

ContentLicense: CC BY-SA 4.0


问:
Angularjs:radio button is not aligning in one line using the ng-repeat,tr,td
I have written simple angularjs code which will have the multiple radio buttons.I have implemented it using the ng-repeat,tr,td.
Below is the code,

```<code><html ng-app="plunker">
   <head>
      <script data-require="angular.js@1.2.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js" data-semver="1.2.16"></script>
   </head>
   <body ng-controller="MainCtrl">
      <table>
         <tr ng-repeat="subscription in entities">
            <td>
               <input type="radio" ng-model="subscription.checked" ng-value="true" ng-click="updateSelection($index, entities)" />{{subscription.name}}
            </td>
         </tr>
      </table>
   </body>
   <script>
      var app = angular.module('plunker', []);

      app.controller('MainCtrl', function($scope, $http, $location, $window) {
          $scope.entities = [{
                  name: 'Last Week',
                  id: 1,
                  checked: false
              }, {
                  name: 'Last Month',
                  id: 2,
                  checked: false
              }, {
                  name: 'Last year',
                  id: 3,
                  checked: false
              },
              {
                  name: 'Last 3 months',
                  id: 4,
                  checked: false
              },
              {
                  name: 'Last 6 months',
                  id: 5,
                  checked: false
              },
              {
                  name: 'Last 9 months',
                  id: 6,
                  checked: false
              }
          ]
          $scope.updateSelection = function(position, entities) {
              angular.forEach(entities, function(subscription, index) {
                  if (position != index)
                      subscription.checked = false;
                  else {
                      console.log(subscription.id);
                      $window.location.href = "/view_report/?q=" + subscription.id;
                  }
              });
          };

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

The code should display the all the buttons in to the single horizontal line because td is inside tr.However all the buttons are displayed in new row/line.
Please help.

答:
Just move your ng-repeat to TD tag. Since you have in TR tag, it will keep repeating the TR also.

```<code><html ng-app="plunker">
   <head>
      <script data-require="angular.js@1.2.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js" data-semver="1.2.16"></script>
   </head>
   <body ng-controller="MainCtrl">
      <table>
         <tr>
            <td ng-repeat="subscription in entities">
               <input type="radio" ng-model="subscription.checked" ng-value="true" ng-click="updateSelection($index, entities)" />{{subscription.name}}
            </td>
         </tr>
      </table>
   </body>
   <script>
      var app = angular.module('plunker', []);

      app.controller('MainCtrl', function($scope, $http, $location, $window) {
          $scope.entities = [{
                  name: 'Last Week',
                  id: 1,
                  checked: false
              }, {
                  name: 'Last Month',
                  id: 2,
                  checked: false
              }, {
                  name: 'Last year',
                  id: 3,
                  checked: false
              },
              {
                  name: 'Last 3 months',
                  id: 4,
                  checked: false
              },
              {
                  name: 'Last 6 months',
                  id: 5,
                  checked: false
              },
              {
                  name: 'Last 9 months',
                  id: 6,
                  checked: false
              }
          ]
          $scope.updateSelection = function(position, entities) {
              angular.forEach(entities, function(subscription, index) {
                  if (position != index)
                      subscription.checked = false;
                  else {
                      console.log(subscription.id);
                      $window.location.href = "/view_report/?q=" + subscription.id;
                  }
              });
          };

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

Also, find the plunker link for your code:

https://plnkr.co/edit/tiLFg8r8Xk8aR65aNcG9?p=preview

Body:
I have written simple angularjs code which will have the multiple radio buttons.I have implemented it using the ng-repeat,tr,td.
Below is the code,

               <input type="radio" ng-model="subscription.checked" ng-value="true" ng-click="updateSelection($index, entities)" />{{subscription.name}}

The code should display the all the buttons in to the single horizontal line because td is inside tr.However all the buttons are displayed in new row/line.
Please help.

Body:
Just move your ng-repeat to TD tag. Since you have in TR tag, it will keep repeating the TR also.

<html ng-app="plunker">
   <head>
      <script data-require="angular.js@1.2.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js" data-semver="1.2.16"></script>
   </head>
   <body ng-controller="MainCtrl">
      <table>
         <tr>
            <td ng-repeat="subscription in entities">
               <input type="radio" ng-model="subscription.checked" ng-value="true" ng-click="updateSelection($index, entities)" />{{subscription.name}}
            </td>
         </tr>
      </table>
   </body>
   <script>
      var app = angular.module('plunker', []);

      app.controller('MainCtrl', function($scope, $http, $location, $window) {
          $scope.entities = [{
                  name: 'Last Week',
                  id: 1,
                  checked: false
              }, {
                  name: 'Last Month',
                  id: 2,
                  checked: false
              }, {
                  name: 'Last year',
                  id: 3,
                  checked: false
              },
              {
                  name: 'Last 3 months',
                  id: 4,
                  checked: false
              },
              {
                  name: 'Last 6 months',
                  id: 5,
                  checked: false
              },
              {
                  name: 'Last 9 months',
                  id: 6,
                  checked: false
              }
          ]
          $scope.updateSelection = function(position, entities) {
              angular.forEach(entities, function(subscription, index) {
                  if (position != index)
                      subscription.checked = false;
                  else {
                      console.log(subscription.id);
                      $window.location.href = "/view_report/?q=" + subscription.id;
                  }
              });
          };

      });
   </script>

Also, find the plunker link for your code:

https://plnkr.co/edit/tiLFg8r8Xk8aR65aNcG9?p=preview


问:
Error: <Route> elements are for router configuration only and should not be rendered in react-router v4
Tried to upgrade react-router from 2 to 4 and broke it and now cant render my app.

getting various errors (the most recent is: <Route> elements are for router configuration only and should not be rendered)

I have also had the error where my ./ route renders fine but every other route blows up when I refresh and says Cannot GET /randomRoute

I am creating a react app and my main index.js file (where I include ReactDOM.render) also includes the routes and looks like so:

```<code>import React from 'react';
import ReactDOM from 'react-dom';
import { Route } from 'react-router';
import { BrowserRouter as Router, Match, HashRouter } from 'react-router-dom'
import Header from './components/header';

import './index.scss';

class App extends React.Component {

  render() {
    return (
      <Router  history={HashRouter}>
        <div>
          <Route path={"/"} component={Header} />
        </div>
      </Router>
    );
  }
}

ReactDOM.render(<App />,
    document.getElementById('content'));
</code>```

why would I be getting that current error and can anyone give me a simple start to the basics I need to include just to get routing working? it worked in version 2 but I wanted to upgrade and now cant get it working again

答:
The problem is that you are specifying history object as a Router type.

From the Documentation

A <Router> that uses the hash portion of the URL (i.e.
  window.location.hash) to keep your UI in sync with the URL.

This is similar to what you would do when you specify history as
hashHistory in Router v2.

Also, history object has been seprated into a seprate package from v4 onwards.

You can either make use of BrowserRouter or HashRouter to render your Routes.

Change your Route Configuration to below if you want to use BrowserRouter which is <Router> that uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL.This is similar to what you would do when you specify history as browserHistory in Router v2.

Also you need to import Route from 'react-router-dom'.

```<code>import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Match, Route} from 'react-router-dom'
import Header from './components/header';

import './index.scss';

class App extends React.Component {

  render() {
    return (
      <Router >
        <div>
          <Route path={"/"} component={Header} />
        </div>
      </Router>
    );
  }
}
</code>```

Body:
Tried to upgrade react-router from 2 to 4 and broke it and now cant render my app.

getting various errors (the most recent is: <Route> elements are for router configuration only and should not be rendered)

I have also had the error where my ./ route renders fine but every other route blows up when I refresh and says Cannot GET /randomRoute

I am creating a react app and my main index.js file (where I include ReactDOM.render) also includes the routes and looks like so:

import React from 'react';
import ReactDOM from 'react-dom';
import { Route } from 'react-router';
import { BrowserRouter as Router, Match, HashRouter } from 'react-router-dom'
import Header from './components/header';

import './index.scss';

class App extends React.Component {

  render() {
    return (
      <Router  history={HashRouter}>

          <Route path={"/"} component={Header} />

      </Router>
    );
  }
}

ReactDOM.render(<App />,
    document.getElementById('content'));

why would I be getting that current error and can anyone give me a simple start to the basics I need to include just to get routing working? it worked in version 2 but I wanted to upgrade and now cant get it working again

Body:
The problem is that you are specifying history object as a Router type.

From the Documentation

A <Router> that uses the hash portion of the URL (i.e.
  window.location.hash) to keep your UI in sync with the URL.

This is similar to what you would do when you specify history as
hashHistory in Router v2.

Also, history object has been seprated into a seprate package from v4 onwards.

You can either make use of BrowserRouter or HashRouter to render your Routes.

Change your Route Configuration to below if you want to use BrowserRouter which is <Router> that uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL.This is similar to what you would do when you specify history as browserHistory in Router v2.

Also you need to import Route from 'react-router-dom'.

import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Match, Route} from 'react-router-dom'
import Header from './components/header';

import './index.scss';

class App extends React.Component {

  render() {
    return (
      <Router >
        <div>
          <Route path={"/"} component={Header} />
        </div>
      </Router>
    );
  }
}


问:
How to share model classes between applications in CakePHP?
I have two applications in CakePHP, App A an App B. I want that App B have access to the models in App A. I found that this is possible with the $modelPaths variable in the bootstrap.php file, but I have some models with the same name in both applications. Is this a problem? If this is a problem, how can I select only some models from the App A to be used by App B? If this is not a problem, how can I know what model is from App A and what is from App B? Thanks</p>

答:
Bit outdated. But on Linux machines you can use symlink (https://en.wikipedia.org/wiki/Symbolic_link) to specify just models you need to share between these 2 applications.

Possible issues:

1) Not solution for same model names

2) Different datasources - in case you want to use also tables of App A from App B

3) Creating symlink for all related Behaviors, Classes


问:
Links displays in blue in gmail
When I add following code to MailChimp editor it display me correct version, but after sending  test email all links become blue.

```<code>    <span><a href="mailto:info@mysite.com" target="_top" style="text-decoration:none;">info@mysite.com</a></span>
        <span style="margin-left: 15px; margin-right: 15px">|</span>
        <span><a href="*|UNSUB|*" style="text-decoration:none;">Unsubscribe</a></span>
    </span>
</code>```

What is interesting that gmail show links blue, but google inbox show correct version.

Any ideas how to solve this issue?

答:
Make anchor tag css as follows

```<code><style>
  a {
    color: #000000!important; // Black
  }
</style>
</code>```

Change the anchor tag color to whatever you want.

Title: Links displays in blue in gmail

Body:
When I add following code to MailChimp editor it display me correct version, but after sending  test email all links become blue.

    info@mysite.com
        |
        Unsubscribe

What is interesting that gmail show links blue, but google inbox show correct version.

Any ideas how to solve this issue?

Body:
Make anchor tag css as follows

<style>
  a {
    color: #000000!important; // Black
  }
</style>

Change the anchor tag color to whatever you want.


问:
populate dropdown list from a list of objects
In an attempt of building a 3-tier architecture c# asp.net application, I've started building a class that is database which is used for the connecting to the database, another class that is City which has a method for each column in the table cities, and a Cities class in which I have the GetCities method that creates a list of City objects and then use the DataSource wizard to set the control to use the data from GetCities().
All I get is blanks in the dropdown list. Any idea why?

```<code>        public List<City> GetCities()
    {
        List<City> cities = new List<City>();
        Database db = new Database();
        SqlConnection conn = db.GetConnection();
        String sql = "SELECT * FROM CITIES";
        SqlCommand cmd = new SqlCommand(sql, conn);
        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            City c = new City(reader.GetInt32(0), reader.GetString(1).ToString());
            cities.Add(c);
        }

        db.CloseConnection();
        return cities;
    }
</code>```

thanks

答: Have you called DataBind() method on the object you want to be populated ?</p>

Body:
In an attempt of building a 3-tier architecture c# asp.net application, I've started building a class that is database which is used for the connecting to the database, another class that is City which has a method for each column in the table cities, and a Cities class in which I have the GetCities method that creates a list of City objects and then use the DataSource wizard to set the control to use the data from GetCities().
All I get is blanks in the dropdown list. Any idea why?

        public List<City> GetCities()
    {
        List<City> cities = new List<City>();
        Database db = new Database();
        SqlConnection conn = db.GetConnection();
        String sql = "SELECT * FROM CITIES";
        SqlCommand cmd = new SqlCommand(sql, conn);
        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            City c = new City(reader.GetInt32(0), reader.GetString(1).ToString());
            cities.Add(c);
        }

        db.CloseConnection();
        return cities;
    }

thanks


问:
How to use java mapping in mule?
i get payload in below java format:

```<code>[
      {emai:'xyz@gmail.com',id:a1},
      {emai:'xyz@gmail.com',id:a2},
      {emai:'abc@gmail.com',id:a3},
      ....
]
</code>```

the above input i is sent to java component which which need to give output in below format

```<code>[
      {emai:'xyz@gmail.com',id:[a1,a2]},
      {emai:'abc@gmail.com',id:a3},
      ....
]
</code>```

i.e i need to combine all the id of a email into single array.

can anybody share the link to write java code? or any sample code?

Thanks..,

答:
Nothing to do with Mule probably. Assuming you have a class Input and Output representing your corresponding List elements you can write:

```<code>public static class Output {
    private String email;
    private List<String> id;

    public Output(String email, List<String> id) {
        this.email = email;
        this.id = id;
    }
    // .. getters
}

public static class Input {
    private String email;
    private String id;

    public Input(String email, String id) {
        this.email = email;
        this.id = id;
    }
    // .. getters
}

@Test
public void test() {
    List<Input> inputs = Arrays.asList(
            new Input("xyz@gmail.com", "a1"),
            new Input("xyz@gmail.com", "a2"),
            new Input("abc@gmail.com", "a3")
    );

    List<Output> results = inputs.stream()
            .collect(Collectors.groupingBy(Input::getEmail))
            .entrySet().stream().map(e->
                    new Output(e.getKey(),
                            e.getValue().stream().map(Input::getId).collect(Collectors.toList())
                    )
            ).collect(Collectors.toList());

    System.out.println(results);
}
</code>```

And your input list will be converted to the desired format. I assume you can figure out how to transform whatever format you're sending and receiving to POJOs in Mule.

Title: How to use java mapping in mule?

Body:
i get payload in below java format:

[
      {emai:'xyz@gmail.com',id:a1},
      {emai:'xyz@gmail.com',id:a2},
      {emai:'abc@gmail.com',id:a3},
      ....
]

the above input i is sent to java component which which need to give output in below format

[
      {emai:'xyz@gmail.com',id:[a1,a2]},
      {emai:'abc@gmail.com',id:a3},
      ....
]

i.e i need to combine all the id of a email into single array.

can anybody share the link to write java code? or any sample code?

Thanks..,

Body:
Nothing to do with Mule probably. Assuming you have a class Input and Output representing your corresponding List elements you can write:

public static class Output {
    private String email;
    private List<String> id;

    public Output(String email, List<String> id) {
        this.email = email;
        this.id = id;
    }
    // .. getters
}

public static class Input {
    private String email;
    private String id;

    public Input(String email, String id) {
        this.email = email;
        this.id = id;
    }
    // .. getters
}

@Test
public void test() {
    List<Input> inputs = Arrays.asList(
            new Input("xyz@gmail.com", "a1"),
            new Input("xyz@gmail.com", "a2"),
            new Input("abc@gmail.com", "a3")
    );

    List<Output> results = inputs.stream()
            .collect(Collectors.groupingBy(Input::getEmail))
            .entrySet().stream().map(e->
                    new Output(e.getKey(),
                            e.getValue().stream().map(Input::getId).collect(Collectors.toList())
                    )
            ).collect(Collectors.toList());

    System.out.println(results);
}

And your input list will be converted to the desired format. I assume you can figure out how to transform whatever format you're sending and receiving to POJOs in Mule.


问:
JavaScript classList not working while clicking a button
I am currently creating a dropdown menu so I want the menu to be displayed when clicked by adding class via Javascript but classList is not working at all. I tried lots of time but couldn't. Also if i add style.display = "block", then it works! I am unable to figure out! Please Help me!

document.getElementById('dbtn').addEventListener('click', function() {
  document.getElementById('d-content').classList.toggle('show');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#wrapper {
  position: relative;
  display: inline-block;
}

#dbtn {
  background-color: #F44336;
  font-size: 27px;
  font-family: 'Droid Sans', sans-serif;
  border: none;
  padding: 0.3em 0.6em;
  color: #FFFFFF;
  cursor: pointer;
  outline: none;
}

#d-content {
  position: absolute;
  display: none;
  background-color: #F44336;
  font-family: 'Droid Sans', sans-serif;
  font-size: 22px;
  border-top: 2px solid #FFFFFF;
  z-index: 1;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

#d-content a {
  color: #FFFFFF;
  text-decoration: none;
  display: block;
  padding: 0.3em 5em 0.3em 0.3em;
}

#d-content a:hover {
  background-color: darkorchid;
}

.show {
  display: block;
}</code>```

<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Dropdown Menu</title>

    <input type="button" id="dbtn" value="Select..." />

      USA
      Canada
      Europe

```

答:
The problem is you are using the wrong approach (Don't worry it happens, and it's okay). it would be easier if you just toggle the display property it will save lot of your time. you can toggle the display property using following snippest:</p>

```<code>document.getElementById('dbtn').addEventListener('click', function () {
        var dContent = document.getElementById('d-content');
        dContent.style.display = dContent.style.display === 'none' ? 'block' : 'none';

    });
</code>```

Body:
I am currently creating a dropdown menu so I want the menu to be displayed when clicked by adding class via Javascript but classList is not working at all. I tried lots of time but couldn't. Also if i add style.display = "block", then it works! I am unable to figure out! Please Help me!

document.getElementById('dbtn').addEventListener('click', function() {
  document.getElementById('d-content').classList.toggle('show');
});

#wrapper {
  position: relative;
  display: inline-block;
}

#dbtn {
  background-color: #F44336;
  font-size: 27px;
  font-family: 'Droid Sans', sans-serif;
  border: none;
  padding: 0.3em 0.6em;
  color: #FFFFFF;
  cursor: pointer;
  outline: none;
}

#d-content {
  position: absolute;
  display: none;
  background-color: #F44336;
  font-family: 'Droid Sans', sans-serif;
  font-size: 22px;
  border-top: 2px solid #FFFFFF;
  z-index: 1;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

#d-content a {
  color: #FFFFFF;
  text-decoration: none;
  display: block;
  padding: 0.3em 5em 0.3em 0.3em;
}

#d-content a:hover {
  background-color: darkorchid;
}

.show {
  display: block;
}

<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Dropdown Menu</title>

    <input type="button" id="dbtn" value="Select..." />

      USA
      Canada
      Europe

Body:
The problem is you are using the wrong approach (Don't worry it happens, and it's okay). it would be easier if you just toggle the display property it will save lot of your time. you can toggle the display property using following snippest:

document.getElementById('dbtn').addEventListener('click', function () {
        var dContent = document.getElementById('d-content');
        dContent.style.display = dContent.style.display === 'none' ? 'block' : 'none';

    });


问:
Barcode Scanner in ionic 2
I am try to scan barcode using barcode scanner in android mobile using ionic2. I am a new learner of ionic. I tried some code,

home.ts

```<code>  import { Component } from '@angular/core';

  import { NavController } from 'ionic-angular';
  declare var cordova:any;
  @Component({
  selector: 'page-home',
  templateUrl: 'home.html'
  })
  export class HomePage {

  constructor(public navCtrl: NavController) {

  }

  scan() {
  var me = this;
  if (cordova.plugins.barcodeScanner) {
    cordova.plugins.barcodeScanner.scan((imageData) => {
        alert(imageData.text);

    }, (error) => {
        alert("An error happened -> " + error);
    });
  }

  }
  }
</code>```

home.html

```<code>  <ion-navbar *navbar>
  <ion-title>
    Home
  </ion-title>
  </ion-navbar>

 <ion-content class="home">
 <button primary (click)="scan()">Scan</button>
 </ion-content>
</code>```

But I got an error is 'Cannot find variable: Cordova'.

I used this plugin -

https://ionicframework.com/docs/v2/native/barcode-scanner/

for barcode scanner in ionic2

Thank you for the answer.

答:
1.

$ cordova plugin add phonegap-plugin-barcodescanner

$ npm install --save @ionic-native/barcode-scanner

2.

app.module.ts

```<code>import { BarcodeScanner } from '@ionic-native/barcode-scanner';
   @NgModule({

   ......

   providers: [
     BarcodeScanner,
     {provide: ErrorHandler, useClass: IonicErrorHandler}
   ]
 })
 export class AppModule {}
</code>```

scanner.ts

```<code> import { Component } from '@angular/core';
 import { NavParams, NavController } from 'ionic-angular';
 import { BarcodeScanner } from '@ionic-native/barcode-scanner';

 @Component({
    selector: 'page-contact',
    templateUrl: 'contact.html'
 })
export class ContactPage {
    constructor( public nacCtrl: NavController,
    public NavParams: NavParams,
    private barcodeScanner: BarcodeScanner) { }

  takeScan(){
      this.barcodeScanner.scan().then((barcodeData) => {
      // Success! Barcode data is here
      alert(barcodeData.text);
      console.log("Barcode Format -> " + barcodeData.format);
      console.log("Cancelled -> " + barcodeData.cancelled);

   }, (err) => {
      // An error occurred
     console.log("An error happened -> " + err);
   });
 }

}
</code>```

Title: Barcode Scanner in ionic 2

Body:
I am try to scan barcode using barcode scanner in android mobile using ionic2. I am a new learner of ionic. I tried some code,

home.ts

  import { Component } from '@angular/core';

  import { NavController } from 'ionic-angular';
  declare var cordova:any;
  @Component({
  selector: 'page-home',
  templateUrl: 'home.html'
  })
  export class HomePage {

  constructor(public navCtrl: NavController) {

  }

  scan() {
  var me = this;
  if (cordova.plugins.barcodeScanner) {
    cordova.plugins.barcodeScanner.scan((imageData) => {
        alert(imageData.text);

    }, (error) => {
        alert("An error happened -> " + error);
    });
  }

  }
  }

home.html

  <ion-navbar *navbar>
  <ion-title>
    Home
  </ion-title>
  </ion-navbar>

 <ion-content class="home">
 <button primary (click)="scan()">Scan</button>
 </ion-content>

But I got an error is 'Cannot find variable: Cordova'.

I used this plugin -

https://ionicframework.com/docs/v2/native/barcode-scanner/

for barcode scanner in ionic2

Thank you for the answer.

Body:
1.

$ cordova plugin add phonegap-plugin-barcodescanner

$ npm install --save @ionic-native/barcode-scanner

2.

app.module.ts

import { BarcodeScanner } from '@ionic-native/barcode-scanner';
   @NgModule({

   ......

   providers: [
     BarcodeScanner,
     {provide: ErrorHandler, useClass: IonicErrorHandler}
   ]
 })
 export class AppModule {}

scanner.ts

 import { Component } from '@angular/core';
 import { NavParams, NavController } from 'ionic-angular';
 import { BarcodeScanner } from '@ionic-native/barcode-scanner';

 @Component({
    selector: 'page-contact',
    templateUrl: 'contact.html'
 })
export class ContactPage {
    constructor( public nacCtrl: NavController,
    public NavParams: NavParams,
    private barcodeScanner: BarcodeScanner) { }

  takeScan(){
      this.barcodeScanner.scan().then((barcodeData) => {
      // Success! Barcode data is here
      alert(barcodeData.text);
      console.log("Barcode Format -> " + barcodeData.format);
      console.log("Cancelled -> " + barcodeData.cancelled);

   }, (err) => {
      // An error occurred
     console.log("An error happened -> " + err);
   });
 }

}


问:
How can I find repeated dates in this VBA code?
How can I find repeated dates in the array DataInicio in this code? I need to find ALL repeated dates and how many times. It is not useful for me to know it is just repeated.

Thanks!

I have been trying to figure out but nothing is working.

```<code>Sub EscalaDinâmicaHTA()

Dim NumHelis As Integer
Dim DataInicio(1 To 15) As Date
Dim DataFim As Date
Dim ContData As Double
Dim LinHeliInicial As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim a As Integer
Dim b As Integer

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

a = 1

Do While LinHeliInicial <= LinTotal

i = 2
j = 3
k = 4

Do While i <= 14 And j <= 15 And k <= 16      '26,27,28

DataInicio(a) = Worksheets(1).Cells(LinHeliInicial, i).Value
ContData = DateValue(DataInicio(a))
ContData = Val(ContData)

DataFim = Worksheets(1).Cells(LinHeliInicial, j).Value
DataFim = DateValue(DataFim)

Duracao = DataFim - DateValue(DataInicio(a))
Worksheets(1).Cells(LinHeliInicial, k).Value = Duracao + 1
Duracao = ContData + Duracao
Duracao = Val(Duracao)

ContData = ContData - 43072         '43072 é a descontar as colunas A,B,C,D,etc até ao começo do calendário
Duracao = Duracao - 43072

Do While ContData <= Duracao
Cells(LinHeliInicial, ContData).Interior.ColorIndex = 4
ContData = ContData + 1
Loop

k = k + 3
j = j + 3
i = i + 3

a = a + 1

Loop

LinHeliInicial = LinHeliInicial + 1

Loop

End Sub
</code>```

答:
This outputs number of duplicates in an array. Note that it will output the same element multiple times, if it occurs multiple times. This can be easily fixed by keeping track of checked elements in another array, and only check them if not checked before (i.e. making an array with unique entries for checking).

```<code>Dim counter As Integer
Dim varElement1 As Variant
Dim varElement2 As Variant

'get element within array
For Each varElement1 In array
    'reset counter
    counter = 0
    For Each varElement2 In array
        'compare varElement1 with each element of array
        If varElement2 = varElement1 Then
            'increase counter if match was found (1 will alway be found -> the element itself)
            counter = counter + 1
        End If
    Next varElement2
    'output number if more than 1 (more than itself) was found
    If counter > 1 Then
        Debug.Print varElement1 & " occured " & counter " times"
    End If
Next varElement1
</code>```

Edit: simplified code, added comments

Body:
How can I find repeated dates in the array DataInicio in this code? I need to find ALL repeated dates and how many times. It is not useful for me to know it is just repeated.

Thanks!

I have been trying to figure out but nothing is working.

Sub EscalaDinâmicaHTA()

Dim NumHelis As Integer
Dim DataInicio(1 To 15) As Date
Dim DataFim As Date
Dim ContData As Double
Dim LinHeliInicial As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim a As Integer
Dim b As Integer

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

a = 1

Do While LinHeliInicial <= LinTotal

i = 2
j = 3
k = 4

Do While i <= 14 And j <= 15 And k <= 16      '26,27,28

DataInicio(a) = Worksheets(1).Cells(LinHeliInicial, i).Value
ContData = DateValue(DataInicio(a))
ContData = Val(ContData)

DataFim = Worksheets(1).Cells(LinHeliInicial, j).Value
DataFim = DateValue(DataFim)

Duracao = DataFim - DateValue(DataInicio(a))
Worksheets(1).Cells(LinHeliInicial, k).Value = Duracao + 1
Duracao = ContData + Duracao
Duracao = Val(Duracao)

ContData = ContData - 43072         '43072 é a descontar as colunas A,B,C,D,etc até ao começo do calendário
Duracao = Duracao - 43072

Do While ContData <= Duracao
Cells(LinHeliInicial, ContData).Interior.ColorIndex = 4
ContData = ContData + 1
Loop

k = k + 3
j = j + 3
i = i + 3

a = a + 1

Loop

LinHeliInicial = LinHeliInicial + 1

Loop

End Sub

Body:
This outputs number of duplicates in an array. Note that it will output the same element multiple times, if it occurs multiple times. This can be easily fixed by keeping track of checked elements in another array, and only check them if not checked before (i.e. making an array with unique entries for checking).

Dim counter As Integer
Dim varElement1 As Variant
Dim varElement2 As Variant

'get element within array
For Each varElement1 In array
    'reset counter
    counter = 0
    For Each varElement2 In array
        'compare varElement1 with each element of array
        If varElement2 = varElement1 Then
            'increase counter if match was found (1 will alway be found -> the element itself)
            counter = counter + 1
        End If
    Next varElement2
    'output number if more than 1 (more than itself) was found
    If counter > 1 Then
        Debug.Print varElement1 & " occured " & counter " times"
    End If
Next varElement1

Edit: simplified code, added comments


问:
Load CSV files to Azure SQL Warehouse via curl
Can anyone provide an example using curl (I'm writing a bash shell script) to upload a CSV to Azure SQL Warehouse? I'm frequently generating CSV exports on Ubuntu virtual instances and need a method to upload to Azure SQL Warehouse via HTTPS rather than other means that require custom network configurations to allow the outbound traffic.</p>

答: I think you would have to create a custom API in azure to call and insert the data. An easier solution may be Microsoft Flow if you have an O365 account or Zapier if not. You could export the csv to a cloud storage account (Onedrive, dropbox etc) the use one of those tools to import it to azure.</p>


问:
How to get the template path in the view django
So I'm trying to get the template path in my view. Is there a dynamic way of doing this because at the moment I am hard-coding the path.

```<code>html = 'C:/Users/user/Desktop/project/src/templates/project.html'
</code>```

Templates Path

```<code>TEMPLATES = [
   'DIRS': [os.path.join(BASE_DIR, "templates")],
]
</code>```

View

```<code>html = 'C:/Users/user/Desktop/project/src/templates/project.html'
open_html = open(html, 'r')
soup =  BeautifulSoup(open_html, "html5lib")
image = soup.find('img', {'name':'image_url'})
img_url = image.get('src')
open_html.close()
</code>```

答:
Try this. get template location from your project setting file.   </p>

```<code>from your_project_name.settings import BASE_DIR

path = os.path.join(BASE_DIR+'templates/', 'project.html')
open_html = open(path, 'r')
soup =  BeautifulSoup(open_html, "html5lib")
image = soup.find('img', {'name':'image_url'})
img_url = image.get('src')
open_html.close()
</code>```

Body:
So I'm trying to get the template path in my view. Is there a dynamic way of doing this because at the moment I am hard-coding the path.

html = 'C:/Users/user/Desktop/project/src/templates/project.html'

Templates Path

TEMPLATES = [
   'DIRS': [os.path.join(BASE_DIR, "templates")],
]

View

html = 'C:/Users/user/Desktop/project/src/templates/project.html'
open_html = open(html, 'r')
soup =  BeautifulSoup(open_html, "html5lib")
image = soup.find('img', {'name':'image_url'})
img_url = image.get('src')
open_html.close()

Body:
Try this. get template location from your project setting file.

from your_project_name.settings import BASE_DIR

path = os.path.join(BASE_DIR+'templates/', 'project.html')
open_html = open(path, 'r')
soup =  BeautifulSoup(open_html, "html5lib")
image = soup.find('img', {'name':'image_url'})
img_url = image.get('src')
open_html.close()


问:
Qtp uft count the links number on a webpage:Count function is not recognized
I'm trying to count the number of links in a web page, using QTP UFT version 14 build 1775, but the count function is not recognized, maybe it has been deprecated. If someone has an idea about the issue, i'll be thankful for your help.

The is the code that I used

```<code>Set desc=description.Create()
desc("micclass").value="Link"

Set objLink =Browser("creationtime:=0").Page("title:=.*").childobjects(desc)

msgbox bjLink.count
</code>```

答:
You have a typo in your code.  You're setting the objLink reference then trying to get the Count property from bjLink.  Change that to objLink.Count and it will work as expected

```<code>Set desc=description.Create()
desc("micclass").value="Link"

Set objLink =Browser("creationtime:=0").Page("title:=.*").childobjects(desc)

msgbox objLink.count
</code>```

Body:
I'm trying to count the number of links in a web page, using QTP UFT version 14 build 1775, but the count function is not recognized, maybe it has been deprecated. If someone has an idea about the issue, i'll be thankful for your help.

The is the code that I used

Set desc=description.Create()
desc("micclass").value="Link"

Set objLink =Browser("creationtime:=0").Page("title:=.*").childobjects(desc)

msgbox bjLink.count

Body:
You have a typo in your code.  You're setting the objLink reference then trying to get the Count property from bjLink.  Change that to objLink.Count and it will work as expected

Set desc=description.Create()
desc("micclass").value="Link"

Set objLink =Browser("creationtime:=0").Page("title:=.*").childobjects(desc)

msgbox objLink.count


答:
```<code>import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.parser.ParseException;
import org.json.simple.parser.JSONParser;

private final static String s = "[{emai:'xyz@gmail.com',id:a1},{emai:'xyz@gmail.com',id:a2},{emai:'abc@gmail.com',id:a3},....]";

public static void main(final String[] argv) throws JSONException {
Object obj = parser.parse(s);
JSONArray array = (JSONArray)obj;
//Turn the payload into a JSONArray
JSONArray new_arry=new JSONArray();
int payload_length = array.length();
ArrayList<String> emails = new ArrayList();
for(int i=0;i<payload_length;i++){
//For every email, use combine to add ids into a JSONArray and attach it to
//a single email
String email = array.getJSONObject(i).get("email").toString();
//If email has been already considered, skip the check for it
if(array.contains(email))
continue;
else{
emails.add(email);
JSONArray combine = new JSONArray();
for(j=i;j<payload_length;j++){
if(array.get(j).get("email").toString()==email)
combine.put(array.get(j).get("id").toString();
    }
new_array.put(new JSONObject().(email,combine);
   }
}
</code>```

Title: How to use java mapping in mule?


问:
Popup window is displayed with a space/gap on immersive mode, on Marshmallow only
Specifically on Marshmallow (tested on Nexus 5X and 6P) when I open a PopupWindow (which has match_parent width and height) over a screen in immersive mode, the content of the popup doesn't expand to full screen, there's a gap where the navigation buttons used to be. The effect is as if invisible navigation buttons were still there, adding a space/gap/margin.

This is how I create the popup:

```<code>PopupWindow popup = new PopupWindow(popupView, FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT, false);

popup.showAtLocation(activity.findViewById(R.id.full_screen_root_view), Gravity.CENTER, 0, 0);
</code>```

This is the beginning of the popup layout:

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/popup"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:background="#AA000000">
</code>```

This is the full screen view where the popup is displayed:

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/full_screen_root_view"
    android:background="@android:color/black">
</code>```

Do you know if anything changed with Marshmallow that would cause this bug specifically? All works well in a Nexus 5, with version 5.0.1 and other older phones/versions I tested. Thank you in advance! :)

答:
I resolved with Gravity.FILL_VERTICAL</p>

```<code>popup.showAtLocation(activity.findViewById(R.id.full_screen_root_view), Gravity.FILL_VERTICAL, 0, 0);
</code>```

Body:
Specifically on Marshmallow (tested on Nexus 5X and 6P) when I open a PopupWindow (which has match_parent width and height) over a screen in immersive mode, the content of the popup doesn't expand to full screen, there's a gap where the navigation buttons used to be. The effect is as if invisible navigation buttons were still there, adding a space/gap/margin.

This is how I create the popup:

PopupWindow popup = new PopupWindow(popupView, FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT, false);

popup.showAtLocation(activity.findViewById(R.id.full_screen_root_view), Gravity.CENTER, 0, 0);

This is the beginning of the popup layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/popup"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:background="#AA000000">

This is the full screen view where the popup is displayed:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/full_screen_root_view"
    android:background="@android:color/black">

Do you know if anything changed with Marshmallow that would cause this bug specifically? All works well in a Nexus 5, with version 5.0.1 and other older phones/versions I tested. Thank you in advance! :)

Body:
I resolved with Gravity.FILL_VERTICAL

popup.showAtLocation(activity.findViewById(R.id.full_screen_root_view), Gravity.FILL_VERTICAL, 0, 0);