问:
What to use as end() iterator C++?
i made an array of pointers to some struct called element. So after i make an table** i just set every pointer in array to null pointer and then later on i add elements. Now when i iterate i can't set my end() as null pointer because then it will stop iterating at first null pointer in the array and it won't find the potential elements after that null pointer.

This is how i created and filled my array in the beginning with nullptr:

```<code>table** = new element*[max_sz+1];
for(size_t i = 0; i <= max_sz; i++) table[i] = nullptr;
</code>```

My begin iterator is first element* that is not a nullptr in the table.

So what should i set it to ? Any ideas ?

答:
table + max_sz +1 would be a suitable end iterator (in the sense that an iterator is a generalisation of the concept of a pointer) in your case.

For example;

```<code> int *begin = table;
 int *end = table + max_sz + 1;

 for (int *i = begin; i != end; ++i)
 {
       //    whatever
 }
</code>```

One rule of the language is that a pointer to one-past-the-end of an array is valid  (as long as that pointer is not dereferenced).   This is true however the array is created (e.g. as a static, of automatic storage duration, or dynamically created).

Just bear in mind that, if an array is passed to a function as an argument, it is converted to a pointer - and the length information needs to be passed separately.

You'd be better off using a standard container (e.g. std::vector<element> or, if elements need to be dynamically created, std::vector<std::unique_ptr<element> >) rather than anything involving raw pointers though.   Both for ease of obtaining an iterator, if needed, and for other reasons.

Title: What to use as end() iterator C++?

Body:
i made an array of pointers to some struct called element. So after i make an table** i just set every pointer in array to null pointer and then later on i add elements. Now when i iterate i can't set my end() as null pointer because then it will stop iterating at first null pointer in the array and it won't find the potential elements after that null pointer.

This is how i created and filled my array in the beginning with nullptr:

table** = new element*[max_sz+1];
for(size_t i = 0; i <= max_sz; i++) table[i] = nullptr;

My begin iterator is first element* that is not a nullptr in the table.

So what should i set it to ? Any ideas ?

Body:
table + max_sz +1 would be a suitable end iterator (in the sense that an iterator is a generalisation of the concept of a pointer) in your case.

For example;

 int *begin = table;
 int *end = table + max_sz + 1;

 for (int *i = begin; i != end; ++i)
 {
       //    whatever
 }

One rule of the language is that a pointer to one-past-the-end of an array is valid  (as long as that pointer is not dereferenced).   This is true however the array is created (e.g. as a static, of automatic storage duration, or dynamically created).

Just bear in mind that, if an array is passed to a function as an argument, it is converted to a pointer - and the length information needs to be passed separately.

You'd be better off using a standard container (e.g. std::vector<element> or, if elements need to be dynamically created, std::vector<std::unique_ptr<element> >) rather than anything involving raw pointers though.   Both for ease of obtaining an iterator, if needed, and for other reasons.


来源: stackexchange

问:
string split based on char \
Got a bit of a mind freeze at the moment.
I have the following syntax:-

```<code>        string[] repname = Thread.CurrentPrincipal.Identity.ToString().Split('\');
</code>```

and I get an error on the split character. Can anyone advise on how I can do the split using the \ character as the delimiter?

Cheers

答:
Use

```<code>Split('\\')
</code>```

"\" is an escape character.

ContentLicense: CC BY-SA 2.5

Title: string split based on char \

Body:
Got a bit of a mind freeze at the moment.
I have the following syntax:-

        string[] repname = Thread.CurrentPrincipal.Identity.ToString().Split('\');

and I get an error on the split character. Can anyone advise on how I can do the split using the \ character as the delimiter?

Cheers

Body:
Use

Split('\\')

"\" is an escape character.

OwnerDisplayName: Maiku Mori

LastEditorDisplayName: Maiku Mori


问:
JS gets and loops just four items
i needed a script for sliding my xml listed cars for web page. i have to show them as quads. (4 cars on 1 slide). So i wrote a code that gets data and divide them to 4.

But it gets just first 4 items for loop. my brain has stopped cant find the problem.

```<code>$(document).ready(function() {
function itemContentBuilder(array, index) {
    var items = '';
    items += '<div class="col-md-3">';
    items += '<div class="carholder">';
    items += '<div class="firstholder">';
    items += '<div class="showthecar"><img alt="" src="' + array[index].carimage + '"></div>';
    items += '<div class="innergrey"></div></div>';
    items += '<div class="carheader">';
    items += '<span class="thebox"></span>';
    items += '<h3>' + array[index].brand + ' <span>' + array[index].model + '</span></h3>';
    items += '<div class="carprice">' + array[index].price + '</div>'
    items += '<div class="car-description">' + array[index].desc + '</div>';
    items += '<div class="car-specs">'
    items += '<ul>';
    items += '<li><img alt="" src="assets/img/icon-key.png"><span>' + array[index].spec1 + '</span></li>';
    items += '<li><img alt="" src="assets/img/icon-engine.png"><span>' + array[index].spec2 + '</span></li>';
    items += '<li><img alt="" src="assets/img/icon-gear.png"><span>' + array[index].spec3 + '</span></li>';
    items += '</ul>';
    items += '</div>';
    items += '</div>';
    items += '</div>';
    items += '</div>';
    return items;
}
var array = [];
$.ajax({
    type: "GET",
    url: "assets/js/cars.xml",
    cache: false,
    dataType: "xml",
    success: function(xml) {
        $(xml).find('car').each(function() {
            array.push({
                carimage: $(this).find('carimage').text(),
                brand: $(this).find('brand').text(),
                model: $(this).find('model').text(),
                price: $(this).find('price').text(),
                desc: $(this).find('desc').text(),
                spec1: $(this).find('spec1').text(),
                spec2: $(this).find('spec2').text(),
                spec3: $(this).find('spec3').text(),
            });
        });
        var loopCount = array.length;
        var remain = ((array.length / 4.0) - Math.floor(array.length / 4));
        if (remain < 1) {
            if (remain === 0.25) {
                loopCount = loopCount + 3;
            }
            if (remain === 0.50) {
                loopCount = loopCount + 2;
            }
            if (remain === 0.75) {
                loopCount = loopCount + 1;
            }
        }

        var content = '';
        var index = 0;
        var currentIndex = 0;
        var increaseStatus = true;
        for (var i = 0; i < loopCount; i++) {
            if (currentIndex === i) {
                currentIndex = 0;
                increaseStatus = false;
            } else if (increaseStatus) {
                currentIndex = i;
            }
            if (index === 0) {
                content += '<div class="item">';
            }
            content += itemContentBuilder(array, index);
            index++;
            currentIndex++;
            if (index === 4) {
                content += '</div>';
                index = 0;
            }
        }

        $('.carousel-inner').prepend(content);
        $('.carousel-inner').find('.item').first().addClass('active');
    },
    error: function() {
        console.log('XML Data Error!');
    }

});
</code>```

});

and here is a example data of cars.xml

```<code><first>
<car>
    <carimage>assets/img/carslider/citroen.png</carimage>
    <brand>CITROEN</brand>
    <model>C-ELYSSE</model>
    <price>255 EURO + KDV</price>
    <desc>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt aliqua.</desc>
    <spec1>1.6 HDI ATTRACTION M/T - 2016</spec1>
    <spec2>92 HP</spec2>
    <spec3>MANUEL</spec3>
</car>
</code>```

答:
we solved the problem like below..i think thats gonne be a good sample for XML-HTML Data sliding</p>

```<code>    // *** XML CAR LIST NORMAL *** //
$(document).ready(function() {
    function itemContentBuilder(array, index) {
        var items = '';
        items += '<div class="col-md-3">';
        items += '<div class="carholder">';
        items += '<div class="firstholder">';
        items += '<div class="showthecar"><img alt="" src="' + array[index].carimage + '"></div>';
        items += '<div class="innergrey"></div></div>';
        items += '<div class="carheader">';
        items += '<span class="thebox"></span>';
        items += '<h3>' + array[index].brand + ' <span>' + array[index].model + '</span></h3>';
        items += '<div class="carprice">' + array[index].price + '</div>'
        items += '<div class="car-description">' + array[index].desc + '</div>';
        items += '<div class="car-specs">'
        items += '<ul>';
        items += '<li><img alt="" src="assets/img/icon-key.png"><span>' + array[index].spec1 + '</span></li>';
        items += '<li><img alt="" src="assets/img/icon-engine.png"><span>' + array[index].spec2 + '</span></li>';
        items += '<li><img alt="" src="assets/img/icon-gear.png"><span>' + array[index].spec3 + '</span></li>';
        items += '</ul>';
        items += '</div>';
        items += '</div>';
        items += '</div>';
        items += '</div>';
        return items;
    }
    var array = [];
    $.ajax({
        type: "GET",
        url: "assets/js/cars.xml",
        cache: false,
        dataType: "xml",
        success: function(xml) {
            $(xml).find('car').each(function() {
                array.push({
                    carimage: $(this).find('carimage').text(),
                    brand: $(this).find('brand').text(),
                    model: $(this).find('model').text(),
                    price: $(this).find('price').text(),
                    desc: $(this).find('desc').text(),
                    spec1: $(this).find('spec1').text(),
                    spec2: $(this).find('spec2').text(),
                    spec3: $(this).find('spec3').text(),
                });
            });

            var content = '';
            var index = 0;

            var currentIndex = 0;

            var increaseStatus = true;

            var remain = ((array.length / 4.0) - Math.floor(array.length / 4));
            if (remain < 1) {
                if (remain === 0.25) {
                    array.push(array[0]);
                    array.push(array[1]);
                    array.push(array[2]);
                }
                if (remain === 0.50) {
                    array.push(array[0]);
                    array.push(array[1]);
                }
                if (remain === 0.75) {
                    array.push(array[0]);
                }
            }

            for (var i = 0; i < array.length; i++) {

                if (currentIndex === i) {
                    currentIndex = 0;
                    increaseStatus = false;

                } else if (increaseStatus) {
                    currentIndex = i;
                }
                if (index === 0) {
                    content += '<div class="item">';
                }
                content += itemContentBuilder(array, i);
                index++;
                currentIndex++;
                if (index === 4) {
                    content += '</div>';
                    index = 0;
                }
            }

            $('.carousel-inner').prepend(content);
            $('.carousel-inner').find('.item').first().addClass('active');
        },
        error: function() {
            console.log('XML Data Hatası!');
        }
    });
});
</code>```

ContentLicense: CC BY-SA 3.0

Title: JS gets and loops just four items

Body:
i needed a script for sliding my xml listed cars for web page. i have to show them as quads. (4 cars on 1 slide). So i wrote a code that gets data and divide them to 4.

But it gets just first 4 items for loop. my brain has stopped cant find the problem.

$(document).ready(function() {
function itemContentBuilder(array, index) {
    var items = '';
    items += '
';
    items += '
';
    items += '
';
    items += '

';
    items += '

';
    items += '
';
    items += '';
    items += '
' + array[index].brand + ' ' + array[index].model + '
';
    items += '
' + array[index].price + '
'
    items += '
' + array[index].desc + '
';
    items += '
'
    items += '
';
    items += '
' + array[index].spec1 + '
';
    items += '
' + array[index].spec2 + '
';
    items += '
' + array[index].spec3 + '
';
    items += '
';
    items += '
';
    items += '
';
    items += '
';
    items += '
';
    return items;
}
var array = [];
$.ajax({
    type: "GET",
    url: "assets/js/cars.xml",
    cache: false,
    dataType: "xml",
    success: function(xml) {
        $(xml).find('car').each(function() {
            array.push({
                carimage: $(this).find('carimage').text(),
                brand: $(this).find('brand').text(),
                model: $(this).find('model').text(),
                price: $(this).find('price').text(),
                desc: $(this).find('desc').text(),
                spec1: $(this).find('spec1').text(),
                spec2: $(this).find('spec2').text(),
                spec3: $(this).find('spec3').text(),
            });
        });
        var loopCount = array.length;
        var remain = ((array.length / 4.0) - Math.floor(array.length / 4));
        if (remain < 1) {
            if (remain === 0.25) {
                loopCount = loopCount + 3;
            }
            if (remain === 0.50) {
                loopCount = loopCount + 2;
            }
            if (remain === 0.75) {
                loopCount = loopCount + 1;
            }
        }

        var content = '';
        var index = 0;
        var currentIndex = 0;
        var increaseStatus = true;
        for (var i = 0; i < loopCount; i++) {
            if (currentIndex === i) {
                currentIndex = 0;
                increaseStatus = false;
            } else if (increaseStatus) {
                currentIndex = i;
            }
            if (index === 0) {
                content += '
';
            }
            content += itemContentBuilder(array, index);
            index++;
            currentIndex++;
            if (index === 4) {
                content += '
';
                index = 0;
            }
        }

        $('.carousel-inner').prepend(content);
        $('.carousel-inner').find('.item').first().addClass('active');
    },
    error: function() {
        console.log('XML Data Error!');
    }

});

});

and here is a example data of cars.xml

<first>
<car>
    <carimage>assets/img/carslider/citroen.png</carimage>
    <brand>CITROEN</brand>
    <model>C-ELYSSE</model>
    <price>255 EURO + KDV</price>
    <desc>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt aliqua.</desc>
    <spec1>1.6 HDI ATTRACTION M/T - 2016</spec1>
    <spec2>92 HP</spec2>
    <spec3>MANUEL</spec3>
</car>

Body:
we solved the problem like below..i think thats gonne be a good sample for XML-HTML Data sliding

    // *** XML CAR LIST NORMAL *** //
$(document).ready(function() {
    function itemContentBuilder(array, index) {
        var items = '';
        items += '<div class="col-md-3">';
        items += '<div class="carholder">';
        items += '<div class="firstholder">';
        items += '<div class="showthecar"><img alt="" src="' + array[index].carimage + '"></div>';
        items += '<div class="innergrey"></div></div>';
        items += '<div class="carheader">';
        items += '<span class="thebox"></span>';
        items += '<h3>' + array[index].brand + ' <span>' + array[index].model + '</span></h3>';
        items += '<div class="carprice">' + array[index].price + '</div>'
        items += '<div class="car-description">' + array[index].desc + '</div>';
        items += '<div class="car-specs">'
        items += '<ul>';
        items += '<li><img alt="" src="assets/img/icon-key.png"><span>' + array[index].spec1 + '</span></li>';
        items += '<li><img alt="" src="assets/img/icon-engine.png"><span>' + array[index].spec2 + '</span></li>';
        items += '<li><img alt="" src="assets/img/icon-gear.png"><span>' + array[index].spec3 + '</span></li>';
        items += '</ul>';
        items += '</div>';
        items += '</div>';
        items += '</div>';
        items += '</div>';
        return items;
    }
    var array = [];
    $.ajax({
        type: "GET",
        url: "assets/js/cars.xml",
        cache: false,
        dataType: "xml",
        success: function(xml) {
            $(xml).find('car').each(function() {
                array.push({
                    carimage: $(this).find('carimage').text(),
                    brand: $(this).find('brand').text(),
                    model: $(this).find('model').text(),
                    price: $(this).find('price').text(),
                    desc: $(this).find('desc').text(),
                    spec1: $(this).find('spec1').text(),
                    spec2: $(this).find('spec2').text(),
                    spec3: $(this).find('spec3').text(),
                });
            });

            var content = '';
            var index = 0;

            var currentIndex = 0;

            var increaseStatus = true;

            var remain = ((array.length / 4.0) - Math.floor(array.length / 4));
            if (remain < 1) {
                if (remain === 0.25) {
                    array.push(array[0]);
                    array.push(array[1]);
                    array.push(array[2]);
                }
                if (remain === 0.50) {
                    array.push(array[0]);
                    array.push(array[1]);
                }
                if (remain === 0.75) {
                    array.push(array[0]);
                }
            }

            for (var i = 0; i < array.length; i++) {

                if (currentIndex === i) {
                    currentIndex = 0;
                    increaseStatus = false;

                } else if (increaseStatus) {
                    currentIndex = i;
                }
                if (index === 0) {
                    content += '<div class="item">';
                }
                content += itemContentBuilder(array, i);
                index++;
                currentIndex++;
                if (index === 4) {
                    content += '</div>';
                    index = 0;
                }
            }

            $('.carousel-inner').prepend(content);
            $('.carousel-inner').find('.item').first().addClass('active');
        },
        error: function() {
            console.log('XML Data Hatası!');
        }
    });
});


问:
Oracle SQL multiple tables
I'm still pretty fresh with SQL in general so this is probably not the best worded question. I want to get columns from different tables. They don't have any common column but there's 3rd table that has information that's able to link them together.

This is how I've tried to go about it:

```<code>SELECT
    CI_SA.ACCT_ID,
    CI_SA.EXPIRE_DT WHERE EXPIRE_DT BETWEEN '15-APR-17' AND '30-APR-17',
    CI_SP.SP_TYPE_CD WHERE SP_TYPE_CD='G-RES'
FROM CI_SA
INNER JOIN CI_SA ON CI_SA.SA_ID = CI_SA_SP.SA_ID AND CI_SP.SP_ID =
CI_SA_SP.SP_ID
</code>```

And this is the error that I receive in return:
    ORA-00923: FROM keyword not found where expected
    00923. 00000 -  "FROM keyword not found where expected"
    *Cause:

    *Action:
    Error at Line: 3 Column: 18

Anyone would be able to point me where I've got it wrong?

答:
The WHERE clause goes after the FROM and only appears once per SELECT.

Perhaps you intend:

```<code>SELECT CI_SA.ACCT_ID, CI_SA.EXPIRE_DT, CI_SP.SP_TYPE_CD
FROM CI_SA INNER JOIN
     CI_SA_SP
     ON CI_SA.SA_ID = CI_SA_SP.SA_ID AND
        CI_SP.SP_ID = CI_SA_SP.SP_ID
WHERE CI_SA.EXPIRE_DT BETWEEN DATE '2017-04-15' AND DATE '2017-04-30' AND
      CI_SP.SP_TYPE_CD = 'G-RES';
</code>```

In addition, this fixes the FROM clause so it refers to CI_SA_SP.  I assume this was a typo in your original query.  Also, I strongly recommend using ISO-standard date formats, so this uses the DATE keyword.

Title: Oracle SQL multiple tables

Body:
I'm still pretty fresh with SQL in general so this is probably not the best worded question. I want to get columns from different tables. They don't have any common column but there's 3rd table that has information that's able to link them together.

This is how I've tried to go about it:

SELECT
    CI_SA.ACCT_ID,
    CI_SA.EXPIRE_DT WHERE EXPIRE_DT BETWEEN '15-APR-17' AND '30-APR-17',
    CI_SP.SP_TYPE_CD WHERE SP_TYPE_CD='G-RES'
FROM CI_SA
INNER JOIN CI_SA ON CI_SA.SA_ID = CI_SA_SP.SA_ID AND CI_SP.SP_ID =
CI_SA_SP.SP_ID

And this is the error that I receive in return:
    ORA-00923: FROM keyword not found where expected
    00923. 00000 -  "FROM keyword not found where expected"
    *Cause:

    *Action:
    Error at Line: 3 Column: 18

Anyone would be able to point me where I've got it wrong?

Body:
The WHERE clause goes after the FROM and only appears once per SELECT.

Perhaps you intend:

SELECT CI_SA.ACCT_ID, CI_SA.EXPIRE_DT, CI_SP.SP_TYPE_CD
FROM CI_SA INNER JOIN
     CI_SA_SP
     ON CI_SA.SA_ID = CI_SA_SP.SA_ID AND
        CI_SP.SP_ID = CI_SA_SP.SP_ID
WHERE CI_SA.EXPIRE_DT BETWEEN DATE '2017-04-15' AND DATE '2017-04-30' AND
      CI_SP.SP_TYPE_CD = 'G-RES';

In addition, this fixes the FROM clause so it refers to CI_SA_SP.  I assume this was a typo in your original query.  Also, I strongly recommend using ISO-standard date formats, so this uses the DATE keyword.


问:
How to execute a single line of a python script in Terminal?
I have the current simple script saved as ex1.py in the Sublime Text 2 IDE.

```<code>print "Hello world!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print 'Yay! Printing.'
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
</code>```

I would like to execute a single line from this script in Terminal, but haven't been able to figure out how.

The script executes all seven lines. Is there a way to specify, for example, that I just want to execute line 3?

答: Why don't you check out Rodeo... I have worked in R studio and now learning python, Rodeo feels similar</p>

Body:
I have the current simple script saved as ex1.py in the Sublime Text 2 IDE.

print "Hello world!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print 'Yay! Printing.'
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'

I would like to execute a single line from this script in Terminal, but haven't been able to figure out how.

The script executes all seven lines. Is there a way to specify, for example, that I just want to execute line 3?


问:
How to join 2 tables in codeigniter PHP?
I have 2 tables guest_info and guest_profile.two columns are there g_uid and company_id.Based on company_id(I have companyID), i have to take all g_uid.
In guest_info table,

g_uid | companyID

1        5

2        5

3        6

In guest_profile table,display all values from this table(only need to display first two datas)

g_uid | fname

1         xyz

2         fds

3         fsdf

答:
```<code>$this->db->select('*');
$this->db->from('Table1 AS a');
$this->db->join('Table2 AS b', 'a.id = c.id', 'LEFT');
$this->db->join('Table3 AS c', 'a.name = c.name', 'LEFT');
$result = $this->db->get();
</code>```

hopefully you get my example.

More info : https://www.codeigniter.com/userguide3/database/query_builder.html?highlight=joins#selecting-data

Body:
$this->db->select('*');
$this->db->from('Table1 AS a');
$this->db->join('Table2 AS b', 'a.id = c.id', 'LEFT');
$this->db->join('Table3 AS c', 'a.name = c.name', 'LEFT');
$result = $this->db->get();

hopefully you get my example.

More info : https://www.codeigniter.com/userguide3/database/query_builder.html?highlight=joins#selecting-data


问:
How to convert Date into Timestamp
I want to convert date into timestamp

I have two different format of date Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time) and 2017-05-31T10:03:47.592Z. I want
to convert it into timestamp like 1379426880000.

This is my code.

```<code>var noOfDays = 5;
var targetDate = new Date();

targetDate.setDate(targetDate.getDate() - noOfDays);
console.log("targetDate date is " + targetDate); //Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time)
console.log(JSON.stringify(targetDate)); // "2017-05-31T10:03:47.592Z"
</code>```

答:
Use this code to get the timestamp.</p>

```<code>targetDate.getTime()
</code>```

Title: How to convert Date into Timestamp

Body:
I want to convert date into timestamp

I have two different format of date Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time) and 2017-05-31T10:03:47.592Z. I want
to convert it into timestamp like 1379426880000.

This is my code.

var noOfDays = 5;
var targetDate = new Date();

targetDate.setDate(targetDate.getDate() - noOfDays);
console.log("targetDate date is " + targetDate); //Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time)
console.log(JSON.stringify(targetDate)); // "2017-05-31T10:03:47.592Z"

Body:
Use this code to get the timestamp.

targetDate.getTime()


问:
Looking for best practices to test stored procedures?
We use sql server 2008 and my boss insist on testing stored procedures.

What is the best practice on testing stored procedures?
Do you use any tools ?
what is your approach?

thanks

答:
Unit testing with a framework like DbUnit and DbFit is invaluable.  Having the discipline to test means also knowing what the before and after data should be, encoding tests for edge cases when you find bugs and so on.

We keep a database available in dev that contains idealised test output data for comparing data sets with in the main dev database.  Helps to write the tests.


问:
MongoDB query array elements
I'm new to Mongodb,trying to fetch data from a collections ,firstly i need to get all the values of array "1" from the below example,without passing any value of array and secondly get data in Json format ,which will be sent to a client via cursor, toArray function works for console but not for html page.

Code:

```<code>"_id" : ObjectId("5934f65bdab27e02aa954891"),"tracker" : [
    {

        "1" : [
            "open",
            "isnot",
            "closed",
            "any"
        ],
        "2" : [
            "task",
            "user story",
            "bug",
            "support",
            "feature",
            "ui modification",
            "enhancment",
            "use case"
        ]
    }
],
"subject" : [
    {
        "1" : [
            "contains",
            "doesnot contain",
            "none",
            "any"
        ]
    }
]}
</code>```

Expected Output_1(values of array "1" ):
    "open","isnot","closed", "any"

Expected Output_2(Json format)

```<code>"tracker" : [
{
    "1" : [
        "open",
        "isnot",
        "closed",
        "any"
    ],
    "2" : [
        "task",
        "user story",
        "bug",
        "support",
        "feature",
        "ui modification",
        "enhancment",
        "use case"
    ]
}],"subject" : [
{
    "1" : [
        "contains",
        "doesnot contain",
        "none",
        "any"
    ]
}]}
</code>```

答:
```<code>db.details.aggregate(

    // Pipeline
    [
        // Stage 1
        {
            $match: {"_id" : ObjectId("5934f65bdab27e02aa954891")}
        },

        // Stage 2
        {
            $unwind: "$tracker"
        },

        // Stage 3
        {
            $project: {
                'tracker.1':1
            }
        },

    ]
);
</code>```

Above aggregate query executes following aggregation stages sequentially in pipeline

$match operator filters document to select only document where value
of _id field is equivalent to specific Object Id

$unwind operator splits an array field into separate documents for

each value of array.

$project operator limits fields returned into result.

Title: MongoDB query array elements

Body:
I'm new to Mongodb,trying to fetch data from a collections ,firstly i need to get all the values of array "1" from the below example,without passing any value of array and secondly get data in Json format ,which will be sent to a client via cursor, toArray function works for console but not for html page.

Code:

"_id" : ObjectId("5934f65bdab27e02aa954891"),"tracker" : [
    {

        "1" : [
            "open",
            "isnot",
            "closed",
            "any"
        ],
        "2" : [
            "task",
            "user story",
            "bug",
            "support",
            "feature",
            "ui modification",
            "enhancment",
            "use case"
        ]
    }
],
"subject" : [
    {
        "1" : [
            "contains",
            "doesnot contain",
            "none",
            "any"
        ]
    }
]}

Expected Output_1(values of array "1" ):
    "open","isnot","closed", "any"

Expected Output_2(Json format)

"tracker" : [
{
    "1" : [
        "open",
        "isnot",
        "closed",
        "any"
    ],
    "2" : [
        "task",
        "user story",
        "bug",
        "support",
        "feature",
        "ui modification",
        "enhancment",
        "use case"
    ]
}],"subject" : [
{
    "1" : [
        "contains",
        "doesnot contain",
        "none",
        "any"
    ]
}]}

Body:
db.details.aggregate(

    // Pipeline
    [
        // Stage 1
        {
            $match: {"_id" : ObjectId("5934f65bdab27e02aa954891")}
        },

        // Stage 2
        {
            $unwind: "$tracker"
        },

        // Stage 3
        {
            $project: {
                'tracker.1':1
            }
        },

    ]
);

Above aggregate query executes following aggregation stages sequentially in pipeline

$match operator filters document to select only document where value
of _id field is equivalent to specific Object Id

$unwind operator splits an array field into separate documents for

each value of array.

$project operator limits fields returned into result.


问:
How to convert a string to date/time stamp in PHP
I have a string which has the value '2015-06-04 00:00:00'

How can I convert this to a date/time stamp using PHP?

Many thanks,

Alec

答:
got your answer you can convert it by use this

```<code>$date = strtotime('2015-06-04 00:00:00');
echo $date;
</code>```

Body:
got your answer you can convert it by use this

$date = strtotime('2015-06-04 00:00:00');
echo $date;


问:
Wordpress woocommerce_get_price flter is not working?
i am used Events Plugin. the plugin link is Events Plugin Link.

This Plugin is integrated with the Woocommerce Tickets plugin.

not i want to filter price of the Tickets i used this hook for change price.

```<code>add_action('woocommerce_get_price','change_price_regular_member', 10, 2);
function change_price_regular_member($price, $product){
   return '$150';
}
</code>```

This is working fine.

But this filter change value in admin side and front side.

i want to cahnge price only front side not admin side.

Thank you.

答:
you can also do like this

```<code>if(!is_admin()){
   add_action('woocommerce_get_price','change_price_regular_member', 10, 2);}
</code>```

Thats it. it will work.

Body:
i am used Events Plugin. the plugin link is Events Plugin Link.

This Plugin is integrated with the Woocommerce Tickets plugin.

not i want to filter price of the Tickets i used this hook for change price.

add_action('woocommerce_get_price','change_price_regular_member', 10, 2);
function change_price_regular_member($price, $product){
   return '$150';
}

This is working fine.

But this filter change value in admin side and front side.

i want to cahnge price only front side not admin side.

Thank you.

Body:
you can also do like this

if(!is_admin()){
   add_action('woocommerce_get_price','change_price_regular_member', 10, 2);}

Thats it. it will work.


问:
how to check key existence for dictionary within a dictionary in C#
In below code, how can I check key existence for dictionary within a dictionary?

Current execution throws key existence error.

Output,
For Key "a", another key "X" with both values 1 and 2

Do we have any better collection for this?

```<code> var data = new Dictionary<string, Dictionary<string, object>>();

        foreach (var j in GetTopData())
        {
            foreach (var p in BottomData())
            {
                if (data.Keys.Contains(j.ToString()))
                {
                    data[j].Add(p.Name, p.Value);
                }
                else
                {
                    data.Add(j, new Dictionary<string, object> { { p.Name, p.Value } });
                }
            }
        }
</code>```

Here are the data classes,

```<code>private static List<TempData> BottomData()
    {
        return new List<TempData>
        {
            new TempData{ Name="X", Value=1},
            new TempData{ Name="X", Value=2}
        };
    }

    private static List<string> GetTopData()
    {
        return new List<string> { "a"};
    }

public class TempData
{
    public string Name { get; set; }
    public object Value { get; set; }
}
</code>```

答:
Your code could be simplified to:</p>

```<code>        var data = new Dictionary<string, Dictionary<string, List<object>>>();

        foreach (var j in GetTopData())
        {
            foreach (var p in BottomData())
            {
                Dictionary<string, List<object>> values;
                var existed = data.TryGetValue(j, out values);

                if (!existed)
                    values = new Dictionary<string, List<object>>();

                List<Object> list;

                var existed2 = values.TryGetValue(p.Name, out list);
                if (!existed2)
                    list = new List<object>();

                list.Add(p.Value);

                if (!existed)
                    data.Add(j, values);

                if (!existed2)
                    values.Add(p.Name, list);
            }
        }
</code>```

Body:
In below code, how can I check key existence for dictionary within a dictionary?

Current execution throws key existence error.

Output,
For Key "a", another key "X" with both values 1 and 2

Do we have any better collection for this?

 var data = new Dictionary<string, Dictionary<string, object>>();

        foreach (var j in GetTopData())
        {
            foreach (var p in BottomData())
            {
                if (data.Keys.Contains(j.ToString()))
                {
                    data[j].Add(p.Name, p.Value);
                }
                else
                {
                    data.Add(j, new Dictionary<string, object> { { p.Name, p.Value } });
                }
            }
        }

Here are the data classes,

private static List<TempData> BottomData()
    {
        return new List<TempData>
        {
            new TempData{ Name="X", Value=1},
            new TempData{ Name="X", Value=2}
        };
    }

    private static List<string> GetTopData()
    {
        return new List<string> { "a"};
    }

public class TempData
{
    public string Name { get; set; }
    public object Value { get; set; }
}

Body:
Your code could be simplified to:

        var data = new Dictionary<string, Dictionary<string, List<object>>>();

        foreach (var j in GetTopData())
        {
            foreach (var p in BottomData())
            {
                Dictionary<string, List<object>> values;
                var existed = data.TryGetValue(j, out values);

                if (!existed)
                    values = new Dictionary<string, List<object>>();

                List<Object> list;

                var existed2 = values.TryGetValue(p.Name, out list);
                if (!existed2)
                    list = new List<object>();

                list.Add(p.Value);

                if (!existed)
                    data.Add(j, values);

                if (!existed2)
                    values.Add(p.Name, list);
            }
        }


答:
You'll need to check for existing data in both of the dictionaries. Currently you are checking existence in just one dictionary:</p>

```<code>var data = new Dictionary<string, Dictionary<string, object>>();

            foreach (var j in GetTopData())
            {
                foreach (var p in BottomData())
                {
                    if(data.ContainsKey(j.ToString()))
                    {
                        var mydict = data[j.ToString()];
                        if (!mydict.ContainsKey(p.Name))
                            data[j].Add(p.Name, p.Value);
                    }
                    else
                    {
                        data.Add(j, new Dictionary<string, object> { { p.Name, p.Value } });
                    }
                }
            }
</code>```

Title: how to check key existence for dictionary within a dictionary in C#

Body:
You'll need to check for existing data in both of the dictionaries. Currently you are checking existence in just one dictionary:

var data = new Dictionary<string, Dictionary<string, object>>();

            foreach (var j in GetTopData())
            {
                foreach (var p in BottomData())
                {
                    if(data.ContainsKey(j.ToString()))
                    {
                        var mydict = data[j.ToString()];
                        if (!mydict.ContainsKey(p.Name))
                            data[j].Add(p.Name, p.Value);
                    }
                    else
                    {
                        data.Add(j, new Dictionary<string, object> { { p.Name, p.Value } });
                    }
                }
            }


问:
Qlikview - append data to Excel
I have qvw file with sql query

```<code> Data:
 LOAD  source, color, date;

 select source, color, date
 as Mytable;

 STORE Data into  [..\QV_Data\Data.qvd] (qvd);
</code>```

Then I export data to excel and save.

I need something to do that automatically instead of me

I need to run query every day and automatically send data to excel but keep old data in excel and append new value.

Can qlikview to do that?

答:
For that you need to create some crazy macro that runs after a reload task in on open-trigger. If you schedule a windows task that execute a bat file with path to qlikview.exe with the filepath as parameters and -r flag for reload(?) you can probably accomplish this... there are a lot of code of similar projects to be found on google.

I suggest adding this to the loadscript instead.

```<code>STORE Table into  [..\QV_Data\Data.csv] (txt);
</code>```

and then open that file in excel.

If you need to append data you could concatenate new data onto the previous data.. something like:

```<code>Data:
load * from Data.csv;

//add latest data
concatenate(Data)
LOAD  source, color, date from ...

STORE Data into  [..\QV_Data\Data.csv] (txt);
</code>```

Title: Qlikview - append data to Excel

Body:
I have qvw file with sql query

 Data:
 LOAD  source, color, date;

 select source, color, date
 as Mytable;

 STORE Data into  [..\QV_Data\Data.qvd] (qvd);

Then I export data to excel and save.

I need something to do that automatically instead of me

I need to run query every day and automatically send data to excel but keep old data in excel and append new value.

Can qlikview to do that?

Body:
For that you need to create some crazy macro that runs after a reload task in on open-trigger. If you schedule a windows task that execute a bat file with path to qlikview.exe with the filepath as parameters and -r flag for reload(?) you can probably accomplish this... there are a lot of code of similar projects to be found on google.

I suggest adding this to the loadscript instead.

STORE Table into  [..\QV_Data\Data.csv] (txt);

and then open that file in excel.

If you need to append data you could concatenate new data onto the previous data.. something like:

Data:
load * from Data.csv;

//add latest data
concatenate(Data)
LOAD  source, color, date from ...

STORE Data into  [..\QV_Data\Data.csv] (txt);


问:
How to change parent view property from child view in WPF?
I want to change parent view property(which binds to UI control) from the child view model.How to do it?
Any suggestions?

Thanks,
Gowtham

答:
A child view model has no knowledge about the parent by default. You could either inject the child with a reference to the parent when you create it, e.g.

```<code>public MethodInParent()
{
    var child = new ChildViewModel(this);
}
</code>```

Or you could use a messenger or an event aggregator to send messages or events between the child and the parent in a loosely coupled way. Please refer to the following link for more information about this concept: https://blog.magnusmontin.net/2014/02/28/using-the-event-aggregator-pattern-to-communicate-between-view-models/.

Body:
A child view model has no knowledge about the parent by default. You could either inject the child with a reference to the parent when you create it, e.g.

public MethodInParent()
{
    var child = new ChildViewModel(this);
}

Or you could use a messenger or an event aggregator to send messages or events between the child and the parent in a loosely coupled way. Please refer to the following link for more information about this concept: https://blog.magnusmontin.net/2014/02/28/using-the-event-aggregator-pattern-to-communicate-between-view-models/.


问:
Array base address pointer
Given the following code what is the difference between ptr and ptr2? because size of v is 20 whereas size of &v[0] is 4. Why does this even work? Why not a third pointer like ptr* = &v. All of these have the same base address but what is the difference between first... I'm confused. And it gets even worse when using 2d arrays. Thank you for your help!</p>

```<code>#include <iostream>
using namespace std;

int main(void)
{
    int v[5] = { 1, 2, 3, 4, 5 };
    int *ptr = v;
    int *ptr2 = &v[0];

    cout << sizeof(v) << endl << sizeof(&v[0]) << endl;
    cout << v << endl << &v << endl << &v[0];
    system("pause");
    return 0;
}
</code>```

答:
```<code>#include <stdio.h>
int main()
{
    printf("%zu\n", sizeof(int));
    // 4 (on a 64 bit arch)
    printf("%zu\n", sizeof(int*));
    // 8 (on a 64 bit arch)

    int v[5] = {0};

    /*Arrays are real and sizeof digs that.
      sizeof v == sizeof(int) * 5
      */
    printf("%zu\n", sizeof v);
    // 20

    /*But,
      they convert to pointers to the first element
      in pointer arithmetic expressions and in function calls
    */

    assert( v+0 == &v[0] );

    /*
       &v[0] != &v

       While they're the same numerically:

    */
    assert ( (void*)&v == (void*)&v[0] );
#if 0
    /*They have distinct types and so this doesn't compile*/

    assert ( &v == &v[0] );
#endif

    /*The difference shows in pointer arithmetic*/

    /*adding 1 to v (== &v[0]) increments the pointer by sizeof(int) (== sizeof(v[0]) ) */
    assert ( (void*) (&v[0] + 1)  == (char*)&v[0] + sizeof(v[0]) );

    /*whereas adding 1 to &v increments the pointer by sizeof v (==5 * 4)*/

    assert ( (void*) (&v + 1)  == (char*)&v[0] + sizeof(v) );

    puts("success");
    return 0;
}
</code>```

Title: Array base address pointer

Body:
Given the following code what is the difference between ptr and ptr2? because size of v is 20 whereas size of &v[0] is 4. Why does this even work? Why not a third pointer like ptr* = &v. All of these have the same base address but what is the difference between first... I'm confused. And it gets even worse when using 2d arrays. Thank you for your help!

#include <iostream>
using namespace std;

int main(void)
{
    int v[5] = { 1, 2, 3, 4, 5 };
    int *ptr = v;
    int *ptr2 = &v[0];

    cout << sizeof(v) << endl << sizeof(&v[0]) << endl;
    cout << v << endl << &v << endl << &v[0];
    system("pause");
    return 0;
}


问:
BAD signature from "Debian CD signing key <debian-cd@lists.debian.org>"
debian8 lxde iso file and signature file downloaded.

```<code>ls
debian-8.8.0-amd64-lxde-CD-1.iso    SHA1SUMS  SHA1SUMS.sign
</code>```

To check it sha1 commands.

```<code>sha1sum   debian-8.8.0-amd64-lxde-CD-1.iso
28bc1fefa093de96879be36a14b00c4991ce9cec  debian-8.8.0-amd64-lxde-CD-1.iso
grep  'lxde'  SHA1SUMS
28bc1fefa093de96879be36a14b00c4991ce9cec  debian-8.8.0-amd64-lxde-CD-1.iso
</code>```

The two sha1sum strings are same.

```<code>gpg --keyserver keyring.debian.org --recv 6294BE9B
gpg --verify  SHA1SUMS.sign  debian-8.8.0-amd64-lxde-CD-1.iso
</code>```

An error occur.

```<code>gpg: Signature made Mon 08 May 2017 02:28:21 AM CST using RSA key ID 6294BE9B
gpg: BAD signature from "Debian CD signing key <debian-cd@lists.debian.org>"
</code>```

1.Why  BAD signature from "Debian CD signing key "?

Is something wrong for the debian public key?

2.It is not a smarty way to get sha1sum with sha1sum   debian-8.8.0-amd64-lxde-CD-1.iso and grep  'lxde'  SHA1SUMS ,then to compare the two output strings by eyes.

答:
I have just crashed into the same issue when verifying debian-8.8 dvds.

The message of "BAD signature" is from the final line in the file SHA***SUMS, which is an empty line (in my case). Just deleted the empty line in my SHA***SUMS and everything went fine; tried with all SHA1, SHA256, SHA512. That's our own error when copying the content of the file from the browser that by "select all" or "ctrl A", we included the empty line.

Body:
debian8 lxde iso file and signature file downloaded.

ls
debian-8.8.0-amd64-lxde-CD-1.iso    SHA1SUMS  SHA1SUMS.sign

To check it sha1 commands.

sha1sum   debian-8.8.0-amd64-lxde-CD-1.iso
28bc1fefa093de96879be36a14b00c4991ce9cec  debian-8.8.0-amd64-lxde-CD-1.iso
grep  'lxde'  SHA1SUMS
28bc1fefa093de96879be36a14b00c4991ce9cec  debian-8.8.0-amd64-lxde-CD-1.iso

The two sha1sum strings are same.

gpg --keyserver keyring.debian.org --recv 6294BE9B
gpg --verify  SHA1SUMS.sign  debian-8.8.0-amd64-lxde-CD-1.iso

An error occur.

gpg: Signature made Mon 08 May 2017 02:28:21 AM CST using RSA key ID 6294BE9B
gpg: BAD signature from "Debian CD signing key <debian-cd@lists.debian.org>"

1.Why  BAD signature from "Debian CD signing key "?

Is something wrong for the debian public key?

2.It is not a smarty way to get sha1sum with sha1sum   debian-8.8.0-amd64-lxde-CD-1.iso and grep  'lxde'  SHA1SUMS ,then to compare the two output strings by eyes.


问:
how to break a line java script
i am setting a text of a h4 through java script what i want to do is add new line here's the code

```<code>$("#description").text("for CCAET and has received significant international scientific recognition. <br /> \n Dr. Armogan has also been responsible for many surgical firsts in retina and cataract management.");
</code>```

now i tried it with multiple solutions but still not working here's another one

```<code>$("#description").text("or CCAET and has received significant international scientific recognition.Dr. Armogan has also been responsible for many surgical firsts in retina and cataract management."+
                        "abc"+
                         "def");
</code>```

any help?

答:
Use html instead of text. This because html will render the HTML code. The text method will only insert and escape all HTML content. Ref. https://api.jquery.com/html/

$(document).ready(function() {

  var content = "This
is
modified
text";

  $('h4#one').html(content);
  $('h4#two').text(content);

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<h4 id="one">
  This is initial text
</h4>

<h4 id="two">
  This is initial text
</h4></code>```

Title: how to break a line java script

Body:
i am setting a text of a h4 through java script what i want to do is add new line here's the code

$("#description").text("for CCAET and has received significant international scientific recognition.
 \n Dr. Armogan has also been responsible for many surgical firsts in retina and cataract management.");

now i tried it with multiple solutions but still not working here's another one

$("#description").text("or CCAET and has received significant international scientific recognition.Dr. Armogan has also been responsible for many surgical firsts in retina and cataract management."+
                        "abc"+
                         "def");

any help?

Body:
Use html instead of text. This because html will render the HTML code. The text method will only insert and escape all HTML content. Ref. https://api.jquery.com/html/

$(document).ready(function() {

  var content = "This<br/>is<br/>modified<br/>text";

  $('h4#one').html(content);
  $('h4#two').text(content);

});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<h4 id="one">
  This is initial text
</h4>

<h4 id="two">
  This is initial text
</h4>


问:
glyphicons not showing with sass bootstrap integration
I used this tutorial to integrate bootstrap in my project:

https://laravel-news.com/2015/10/setup-bootstrap-sass-with-laravel-elixir/

This places an app.css file in the css folder.
However if I try to use glyphicons they don't show up.
So I tried to modify the elixir file like this:

```<code>    elixir(function(mix) {

    mix.sass('app.scss')
        .browserify('app.js')
        .copy('node_modules/bootstrap-sass/assets/fonts', 'public/css/fonts')

});
</code>```

The fonts folder is copied under public/css/fonts but yet no icon shows up. What am I missing here? Any clue?

in my app.css the path seems correct, for example:

```<code>src: url("fonts/bootstrap/glyphicons-halflings-regular.eot");
</code>```

答:
For Laravel 5.4

This answer didn't exactly solved my problem but it pointed me to the right direction. This is my solution and it covers both if you have defined url for your application (using homestead or some other VM/Vagrant/etc. or if you have set vhost and hosts file for your application), or if you're like me, and have installed lamp stack/xampp/wamp/mapm/etc and doing development from apache htdocs sbfolder.

Firstly you need to add

mix.copy('node_modules/bootstrap-sass/assets/fonts/bootstrap/', 'public/fonts/');

in your webpack.mix.js at the end of the file.

Next open up resources/assets/sass/_variable.scss and edit $icon-font-path value.

If you're not using homestead but some lamp stack where you don't have defined dev url for your application (you didn't set vhost and changed hosts file), but instead you're accessing it as a subfolder e.g. localhost/YOUR_APP/public/ then you should set icon font path like

$icon-font-path: "/YOUR_APP/public/fonts/";

If you have set url for your application, you just need to set icon font paht like

$icon-font-path: "/public/fonts/" and recompile css file. You should change to this before pushing your application to the production if it's not set at first!!!

For those who don't know how to recompile css and js files follow this steps:

1. Go to the root of your application and run bash there (git bash, cmd, etc.)

2. npm install

3. npm run-script production (you have other flags available but i perfer production as it minifies js and css)

4. Congrats you just recompiled your js and css

Body:
I used this tutorial to integrate bootstrap in my project:

https://laravel-news.com/2015/10/setup-bootstrap-sass-with-laravel-elixir/

This places an app.css file in the css folder.
However if I try to use glyphicons they don't show up.
So I tried to modify the elixir file like this:

    elixir(function(mix) {

    mix.sass('app.scss')
        .browserify('app.js')
        .copy('node_modules/bootstrap-sass/assets/fonts', 'public/css/fonts')

});

The fonts folder is copied under public/css/fonts but yet no icon shows up. What am I missing here? Any clue?

in my app.css the path seems correct, for example:

src: url("fonts/bootstrap/glyphicons-halflings-regular.eot");


问:
Talend TAC export of list of tasks
I would like to take an export of the list of jobs that are created as tasks under job conductor in TAC along with its configurations. Is this possible and if yes, please support. I am using the Enterprise edition of Talend V5.6</p>

答:
There is an API to query the TAC called MetaServletCaller. Using this API, you can send a command to get a list of the tasks deployed in Job Conductor.
The API can be called from a url in a browser, or by calling MetaServletCaller.sh (or .bat) script from your Talend installation.

The command to get this list is listTasks.

Here is a tutorial on how to do that : http://edwardost.github.io/talend/di/2015/05/28/Using-the-TAC-API/

Title: Talend TAC export of list of tasks


问:
Replace Webforms MasterPage with MVC _Layout.cshtml
I have a ASP.NET webforms project that has 100 plus web pages. All these pages have common Site.master master page.

We have started to convert our webforms project to MVC. So in MVC we have the  _Layout.cshtml as our new Master Page.  Everything from Site.master has been copied to _Layout.cshtml. Site.master is now blank.

Now I want to know how all the 100 plus web pages in my project can call this new MVC Layout.cshtml. So instead of calling Site.master, all the pages in my project should use Layout.cshtml as the new master page.

答:
You have to migrate over the whole website.

That means creating new views and controllers on the MVC site for the pages on the ASP.NET site.

Once you have a Controller with the Actions for the Views, simply add the following to the top of the View to use the Layout page:

```<code>@{
    Layout = "<path_to_layout.cshtml>";
}
</code>```

Body:
You have to migrate over the whole website.

That means creating new views and controllers on the MVC site for the pages on the ASP.NET site.

Once you have a Controller with the Actions for the Views, simply add the following to the top of the View to use the Layout page:

@{
    Layout = "<path_to_layout.cshtml>";
}


问:
Kibana: How I can find visualizations using an specific field or query?
We have tons of visualization in Kibana and I want to build a new one if does not exists.
How I can search for those visualizations showing or using an specific field?
Find them if the field is used on the query will be great as well.

UPDATE:

The search done by Kibana is only looking for matches at titleand description.

Adding visState and kibanaSavedObjectMeta.searchSourceJSON fields in the query will do the job.

Examples:

https://kibana.server.com/es_admin/.kibana/visualization/_search?pretty&q=visState:*timing.started*

https://kibana.server.com/es_admin/.kibana/visualization/_search?pretty&q=kibanaSavedObjectMeta.searchSourceJSON:*applicationName*

Thanks

答:
Finally looks there is no way so I created a PR- support it with +1-
https://github.com/elastic/kibana/pull/12164</p>


问:
passing variable value to a label angularjs
I am new to angularjs. i am stuck in an issue and couldnot find a solution.
i have a table

Table like this
and if i click on Edit button a modal popups
 modal like this

i want to assign menu name and language values from row(from which i click edit button) in table  to labels in modal. i have tried following solution but its not working.

HTML

```<code><body ng-app="VDNApp">
<div class="table-responsive" ng-controller="VDNCtrl">
    <table class="table">
        <thead>
            <tr>
                <th  style="visibility:hidden;  width:0%;">#</th>
                <th>Menu Name</th>
                <th>VDN Number</th>
                <th>VDN Name</th>
                <th>Language</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="x in responseData">
                <td style="visibility:hidden; width:0%;" >{{x.id}}</td>
                <td>{{x.NameEn}}</td>
                <td>{{x.vdnnum}}</td>
                <td>{{x.vdnname}}</td>
                <td>{{x.language}}</td>
                <td><button type="button" ng-click="editVDN(x)"  class="btn btn-info btn-lg" data-toggle="modal" data-target="#VDNModal" style="padding:5px 10px !important; font-size:14px !important;">Edit</button></td>
            </tr>
        </tbody>
    </table>
</div>
<div class="modal fade" id="VDNModal" role="dialog" ng-controller="VDNCtrl">
    <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">×</button>
                <h4 class="modal-title" style="font-weight:bold;">Edit VDN Mapping</h4>
            </div>
            <div class="modal-body">
                <div  >
                    <label class="col-sm-3 control-label" style="font-size:14px;">Menu Name: </label>
                    <label style="font-size:14px; border-color:gray;"  >{{VDNNameValue}}</label>
                </div>
                <br />
                <div  >
                    <label class="col-sm-3 control-label" style="font-size:14px;">VDN Language: </label>
                    <label style="font-size:14px;"> {{VDNlang}}</label>
                </div>
                <br />
                <div>
                    <label class="col-sm-3 control-label" style="font-size:14px;">VDN Number </label>
                    <select  ng-model="selectedOption" ng-options="option.vdnname + ' ('+option.vdnnum + ')' for option in responseData track by option.id" class="form-control selcls" style="width:300px;">
                        <option value="" disabled selected >--Select--</option>
                    </select>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>

    </div>
</div>
</code>```

AngularJS

```<code> var app = angular.module('VDNApp', []);
app.controller('VDNCtrl', function ($scope, $http) {
    $http.get("http://localhost:26413/api/MenuVDN/GetVDNMapping")
.then(function(response) {
    $scope.responseData = response.data.Table;
   // console.log($scope.responseData);
});
    $scope.VDNNameValue = "val";
    $scope.VDNlang = "lang";
    $scope.editVDN = function (obj) {
        $scope.VDNNameValue =  obj.vdnname;
        $scope.VDNlang = obj.language;
        console.log($scope.VDNNameValue, $scope.VDNlang);
}
});
</code>```

答:
You have defined 2 different scopes of VDNCtrl controller. So changing anything in first ng-controller scope won't change anything on second ng-controller scope.

Make sure to use either one controller for both(same scope in one element root) or else create a different controller and set the $scope of new controller by passing the data from first controller

var app = angular.module('VDNApp', []);
app.controller('VDNCtrl', function($scope, $http) {

  $scope.responseData = [{
    id: 1,
    NameEn: "test",
    vdnnum: "1",
    vdnname: "one",
    language: "en"
  }, {
    id: 2,
    NameEn: "test",
    vdnnum: "1",
    vdnname: "two",
    language: "en"
  }, {
    id: 3,
    NameEn: "test",
    vdnnum: "1",
    vdnname: "three",
    language: "en"
  }];

  $scope.VDNNameValue = "val";
  $scope.VDNlang = "lang";
  $scope.editVDN = function(obj) {
    $scope.VDNNameValue = obj.vdnname;
    $scope.VDNlang = obj.language;
    console.log($scope.VDNNameValue, $scope.VDNlang);
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="VDNApp">
  <div class="table-responsive" ng-controller="VDNCtrl">
    <table class="table">
      <thead>
        <tr>
          <th style="visibility:hidden;  width:0%;">#</th>
          <th>Menu Name</th>
          <th>VDN Number</th>
          <th>VDN Name</th>
          <th>Language</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="x in responseData">
          <td style="visibility:hidden; width:0%;">{{x.id}}</td>
          <td>{{x.NameEn}}</td>
          <td>{{x.vdnnum}}</td>
          <td>{{x.vdnname}}</td>
          <td>{{x.language}}</td>
          <td><button type="button" ng-click="editVDN(x)" class="btn btn-info btn-lg" data-toggle="modal" data-target="#VDNModal" style="padding:5px 10px !important; font-size:14px !important;">Edit</button></td>
        </tr>
      </tbody>
    </table>

    <div class="modal fade" id="VDNModal" role="dialog">
      <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">×</button>
            <h4 class="modal-title" style="font-weight:bold;">Edit VDN Mapping</h4>
          </div>
          <div class="modal-body">
            <div>
              <label class="col-sm-3 control-label" style="font-size:14px;">Menu Name: </label>
              <label style="font-size:14px; border-color:gray;">{{VDNNameValue}}</label>
            </div>
            <br />
            <div>
              <label class="col-sm-3 control-label" style="font-size:14px;">VDN Language: </label>
              <label style="font-size:14px;"> {{VDNlang}}</label>
            </div>
            <br />
            <div>
              <label class="col-sm-3 control-label" style="font-size:14px;">VDN Number </label>
              <select ng-model="selectedOption" ng-options="option.vdnname + ' ('+option.vdnnum + ')' for option in responseData track by option.id" class="form-control selcls" style="width:300px;">
                        <option value="" disabled selected >--Select--</option>
                    </select>

            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>
  </div></code>```

Body:
I am new to angularjs. i am stuck in an issue and couldnot find a solution.
i have a table

Table like this
and if i click on Edit button a modal popups
 modal like this

i want to assign menu name and language values from row(from which i click edit button) in table  to labels in modal. i have tried following solution but its not working.

HTML

                #
                Menu Name
                VDN Number
                VDN Name
                Language

                {{x.id}}
                {{x.NameEn}}
                {{x.vdnnum}}
                {{x.vdnname}}
                {{x.language}}
                <button type="button" ng-click="editVDN(x)"  class="btn btn-info btn-lg" data-toggle="modal" data-target="#VDNModal" style="padding:5px 10px !important; font-size:14px !important;">Edit</button>

                <button type="button" class="close" data-dismiss="modal">×</button>

Edit VDN Mapping

                    Menu Name:
                    {{VDNNameValue}}

                    VDN Language:
                     {{VDNlang}}

                    VDN Number
                    <select  ng-model="selectedOption" ng-options="option.vdnname + ' ('+option.vdnnum + ')' for option in responseData track by option.id" class="form-control selcls" style="width:300px;">
                        <option value="" disabled selected >--Select--</option>
                    </select>

                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

AngularJS

 var app = angular.module('VDNApp', []);
app.controller('VDNCtrl', function ($scope, $http) {
    $http.get("http://localhost:26413/api/MenuVDN/GetVDNMapping")
.then(function(response) {
    $scope.responseData = response.data.Table;
   // console.log($scope.responseData);
});
    $scope.VDNNameValue = "val";
    $scope.VDNlang = "lang";
    $scope.editVDN = function (obj) {
        $scope.VDNNameValue =  obj.vdnname;
        $scope.VDNlang = obj.language;
        console.log($scope.VDNNameValue, $scope.VDNlang);
}
});

Body:
You have defined 2 different scopes of VDNCtrl controller. So changing anything in first ng-controller scope won't change anything on second ng-controller scope.

Make sure to use either one controller for both(same scope in one element root) or else create a different controller and set the $scope of new controller by passing the data from first controller

var app = angular.module('VDNApp', []);
app.controller('VDNCtrl', function($scope, $http) {

  $scope.responseData = [{
    id: 1,
    NameEn: "test",
    vdnnum: "1",
    vdnname: "one",
    language: "en"
  }, {
    id: 2,
    NameEn: "test",
    vdnnum: "1",
    vdnname: "two",
    language: "en"
  }, {
    id: 3,
    NameEn: "test",
    vdnnum: "1",
    vdnname: "three",
    language: "en"
  }];

  $scope.VDNNameValue = "val";
  $scope.VDNlang = "lang";
  $scope.editVDN = function(obj) {
    $scope.VDNNameValue = obj.vdnname;
    $scope.VDNlang = obj.language;
    console.log($scope.VDNNameValue, $scope.VDNlang);
  }
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="VDNApp">
  <div class="table-responsive" ng-controller="VDNCtrl">
    <table class="table">
      <thead>
        <tr>
          <th style="visibility:hidden;  width:0%;">#</th>
          <th>Menu Name</th>
          <th>VDN Number</th>
          <th>VDN Name</th>
          <th>Language</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="x in responseData">
          <td style="visibility:hidden; width:0%;">{{x.id}}</td>
          <td>{{x.NameEn}}</td>
          <td>{{x.vdnnum}}</td>
          <td>{{x.vdnname}}</td>
          <td>{{x.language}}</td>
          <td><button type="button" ng-click="editVDN(x)" class="btn btn-info btn-lg" data-toggle="modal" data-target="#VDNModal" style="padding:5px 10px !important; font-size:14px !important;">Edit</button></td>
        </tr>
      </tbody>
    </table>

    <div class="modal fade" id="VDNModal" role="dialog">
      <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title" style="font-weight:bold;">Edit VDN Mapping</h4>
          </div>
          <div class="modal-body">
            <div>
              <label class="col-sm-3 control-label" style="font-size:14px;">Menu Name: </label>
              <label style="font-size:14px; border-color:gray;">{{VDNNameValue}}</label>
            </div>
            <br />
            <div>
              <label class="col-sm-3 control-label" style="font-size:14px;">VDN Language: </label>
              <label style="font-size:14px;"> {{VDNlang}}</label>
            </div>
            <br />
            <div>
              <label class="col-sm-3 control-label" style="font-size:14px;">VDN Number </label>
              <select ng-model="selectedOption" ng-options="option.vdnname + ' ('+option.vdnnum + ')' for option in responseData track by option.id" class="form-control selcls" style="width:300px;">
                        <option value="" disabled selected >--Select--</option>
                    </select>

            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>
  </div>


问:
Prime number in java 8
I was trying to write a simple prime number program in Java 8. Below is the program. I wanted to reduce the code in isPrime() as well. Is there something that filters the elements from 2 to n/2, and then apply filter for n%i == 0 which would make isPrime irrelevant?

```<code>import static java.util.stream.Collectors.toList;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class Stream1 {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 20);
        // Prime number
        System.out.println(numbers.stream()
                             .filter(Stream1::isPrime)
                             .collect(toList()));
    }

    public static boolean isPrime(int number) {
        for (int i = 2; i <= number / 2; i++) {
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
}
</code>```

答:
IntStream can be used to generate integer stream

```<code>public static boolean isPrime(int number) {
    return !IntStream.rangeClosed(2, number/2).anyMatch(i -> number%i == 0);
}
</code>```

or

```<code>public static boolean isPrime(int number) {
    return IntStream.rangeClosed(2, number/2).noneMatch(i -> number%i == 0);
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: Prime number in java 8

Body:
I was trying to write a simple prime number program in Java 8. Below is the program. I wanted to reduce the code in isPrime() as well. Is there something that filters the elements from 2 to n/2, and then apply filter for n%i == 0 which would make isPrime irrelevant?

import static java.util.stream.Collectors.toList;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class Stream1 {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 20);
        // Prime number
        System.out.println(numbers.stream()
                             .filter(Stream1::isPrime)
                             .collect(toList()));
    }

    public static boolean isPrime(int number) {
        for (int i = 2; i <= number / 2; i++) {
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
}

Body:
IntStream can be used to generate integer stream

public static boolean isPrime(int number) {
    return !IntStream.rangeClosed(2, number/2).anyMatch(i -> number%i == 0);
}

or

public static boolean isPrime(int number) {
    return IntStream.rangeClosed(2, number/2).noneMatch(i -> number%i == 0);
}


问:
JSON only allows one top level value?
I have the following Java Object:

```<code>public class PersonDetails {
    private Person person;
    private List<Relative> relatives;

    public PersonDetails() {};

    //getters and setters

    }
</code>```

I am trying to create Stub JSON for this so that I can parse it to a Java Object using GSON.

When I try to use the below JSON, but I get the error:

```<code>JSON only allows one top level value
</code>```

How can I alter my JSON to make it valid?

My Current JSON:

```<code>{
    "Person": {

        "id": "123",
        "name: "stubName"
    },
    [
     "Relative": {

        "name": "relative1",
        "relation: "mother"

     }

    ]
}
</code>```

答:
You should check your JSON using a validator. JsonLint is one.

This will show you that your JSON is invalid. There are a couple of problems.

Firstly you have unclosed quotes - "name: and "relation:.

Secondly, there's a more fundamental problem, which is that a JSON object can only contain a list of named fields. You have:

```<code>{
   "field1" : "Value 1",
   [
       { ... an array element ... }
   ]
}
</code>```

So you're trying to have a named field, and an unnamed array. That's not allowed.

You can fix this by giving the array field a name:

```<code>{
   "field1" : "Value 1",
   "field2" : [
       { ... an array element ... }
   ]
}
</code>```

Now the top level element contains two fields - field1 which is a string, and field2 which is an array.

Title: JSON only allows one top level value?

Body:
I have the following Java Object:

public class PersonDetails {
    private Person person;
    private List<Relative> relatives;

    public PersonDetails() {};

    //getters and setters

    }

I am trying to create Stub JSON for this so that I can parse it to a Java Object using GSON.

When I try to use the below JSON, but I get the error:

JSON only allows one top level value

How can I alter my JSON to make it valid?

My Current JSON:

{
    "Person": {

        "id": "123",
        "name: "stubName"
    },
    [
     "Relative": {

        "name": "relative1",
        "relation: "mother"

     }

    ]
}

Body:
You should check your JSON using a validator. JsonLint is one.

This will show you that your JSON is invalid. There are a couple of problems.

Firstly you have unclosed quotes - "name: and "relation:.

Secondly, there's a more fundamental problem, which is that a JSON object can only contain a list of named fields. You have:

{
   "field1" : "Value 1",
   [
       { ... an array element ... }
   ]
}

So you're trying to have a named field, and an unnamed array. That's not allowed.

You can fix this by giving the array field a name:

{
   "field1" : "Value 1",
   "field2" : [
       { ... an array element ... }
   ]
}

Now the top level element contains two fields - field1 which is a string, and field2 which is an array.


问:
can't build android project it shows error
project gradle

```<code>// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

App Gradle

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.arun4fms.efix"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE-FIREBASE.txt'
            exclude 'META-INF/NOTICE'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.google.firebase:firebase-crash:10.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.chabbal:slidingdotsplash:1.0.2'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
</code>```

Error:A problem occurred configuring root project 'webapp'.

Could not resolve all dependencies for configuration ':classpath'.
  Could not find com.android.tools.build:gradle:3.0.0-alpha3.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
           https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
           https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
       Required by:
           project :

答:
I had the same problem this morning !
As Vishal said, there is no gradle-3.0.0-alpha3..
I am sure that, since I downloaded "Android studio 3.0 Canary (Alpha3)", I was on on the same version of gradle (3.0.0 alpha3), and it worked ! (Since today).

So I've put : classpath 'com.android.tools.build:gradle:2.3.2' to compile.

EDIT : I have two versions of Android studio, When I used Android Studio 3.0, it changes gradle to gradle 3.0.0-alpha3 !

Body:
project gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.arun4fms.efix"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE-FIREBASE.txt'
            exclude 'META-INF/NOTICE'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.google.firebase:firebase-crash:10.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.chabbal:slidingdotsplash:1.0.2'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

Error:A problem occurred configuring root project 'webapp'.

Could not resolve all dependencies for configuration ':classpath'.
  Could not find com.android.tools.build:gradle:3.0.0-alpha3.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
           https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
           https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
       Required by:
           project :


问:
How to make multi level dropdown menu using select option mentod
i want to make multi level dropdown menu using select and option method</p>

```<code><select>
   <option value="" data-display-text="Select">None</option>
   <option value="oranges">SSC</option>
   <option value="oranges">GATE</option>
   <option value="bananas">BANK PO</option>
   <option value="bananas">RAILWAY</option>
 </select>
</code>```

答:
You can't make multiple levels with the select element.

In this case you would create a custom component with the capability to display something like 'hierarchic'.

Or use the trick like this:

<select>
    <option>select me</option>
    <option> me indented</option>
    <option>  even more indentation</option>
</select>```

Body:
i want to make multi level dropdown menu using select and option method

<select>
   <option value="" data-display-text="Select">None</option>
   <option value="oranges">SSC</option>
   <option value="oranges">GATE</option>
   <option value="bananas">BANK PO</option>
   <option value="bananas">RAILWAY</option>
 </select>

Body:
You can't make multiple levels with the select element.

In this case you would create a custom component with the capability to display something like 'hierarchic'.

Or use the trick like this:

<select>
    <option>select me</option>
    <option>&nbsp;me indented</option>
    <option>&nbsp;&nbsp;even more indentation</option>
</select>


问:
How to convert a string to date/time stamp in PHP
I have a string which has the value '2015-06-04 00:00:00'

How can I convert this to a date/time stamp using PHP?

Many thanks,

Alec

答:
I always prefer to pass from a DateTime class.</p>

```<code>php > $dateTime = new DateTime('2015-06-04 00:00:00');
php > echo $dateTime->format('d/m/Y');
04/06/2015
</code>```

Body:
I always prefer to pass from a DateTime class.

php > $dateTime = new DateTime('2015-06-04 00:00:00');
php > echo $dateTime->format('d/m/Y');
04/06/2015


问:
Oracle SQL multiple tables
I'm still pretty fresh with SQL in general so this is probably not the best worded question. I want to get columns from different tables. They don't have any common column but there's 3rd table that has information that's able to link them together.

This is how I've tried to go about it:

```<code>SELECT
    CI_SA.ACCT_ID,
    CI_SA.EXPIRE_DT WHERE EXPIRE_DT BETWEEN '15-APR-17' AND '30-APR-17',
    CI_SP.SP_TYPE_CD WHERE SP_TYPE_CD='G-RES'
FROM CI_SA
INNER JOIN CI_SA ON CI_SA.SA_ID = CI_SA_SP.SA_ID AND CI_SP.SP_ID =
CI_SA_SP.SP_ID
</code>```

And this is the error that I receive in return:
    ORA-00923: FROM keyword not found where expected
    00923. 00000 -  "FROM keyword not found where expected"
    *Cause:

    *Action:
    Error at Line: 3 Column: 18

Anyone would be able to point me where I've got it wrong?

答:
First 'SELECT' then, 'FROM' and the last 'WHERE'. Only one 'WHERE' clause is allowed.
Duplicated CI_SA in join. You should use aliases </p>

Title: Oracle SQL multiple tables

Body:
I'm still pretty fresh with SQL in general so this is probably not the best worded question. I want to get columns from different tables. They don't have any common column but there's 3rd table that has information that's able to link them together.

This is how I've tried to go about it:

SELECT
    CI_SA.ACCT_ID,
    CI_SA.EXPIRE_DT WHERE EXPIRE_DT BETWEEN '15-APR-17' AND '30-APR-17',
    CI_SP.SP_TYPE_CD WHERE SP_TYPE_CD='G-RES'
FROM CI_SA
INNER JOIN CI_SA ON CI_SA.SA_ID = CI_SA_SP.SA_ID AND CI_SP.SP_ID =
CI_SA_SP.SP_ID

And this is the error that I receive in return:
    ORA-00923: FROM keyword not found where expected
    00923. 00000 -  "FROM keyword not found where expected"
    *Cause:

    *Action:
    Error at Line: 3 Column: 18

Anyone would be able to point me where I've got it wrong?


问:
how to check key existence for dictionary within a dictionary in C#
In below code, how can I check key existence for dictionary within a dictionary?

Current execution throws key existence error.

Output,
For Key "a", another key "X" with both values 1 and 2

Do we have any better collection for this?

```<code> var data = new Dictionary<string, Dictionary<string, object>>();

        foreach (var j in GetTopData())
        {
            foreach (var p in BottomData())
            {
                if (data.Keys.Contains(j.ToString()))
                {
                    data[j].Add(p.Name, p.Value);
                }
                else
                {
                    data.Add(j, new Dictionary<string, object> { { p.Name, p.Value } });
                }
            }
        }
</code>```

Here are the data classes,

```<code>private static List<TempData> BottomData()
    {
        return new List<TempData>
        {
            new TempData{ Name="X", Value=1},
            new TempData{ Name="X", Value=2}
        };
    }

    private static List<string> GetTopData()
    {
        return new List<string> { "a"};
    }

public class TempData
{
    public string Name { get; set; }
    public object Value { get; set; }
}
</code>```

答:
Answer to your question how to check key existence for dictionary within a dictionary in C#:

You can check this by using Linq like this example :

```<code>bool keyExistance = data.Any(x=>x.Value.ContainsKey(keyTocheck));
</code>```

But before that you have to fix the errors in your code.

Body:
In below code, how can I check key existence for dictionary within a dictionary?

Current execution throws key existence error.

Output,
For Key "a", another key "X" with both values 1 and 2

Do we have any better collection for this?

 var data = new Dictionary<string, Dictionary<string, object>>();

        foreach (var j in GetTopData())
        {
            foreach (var p in BottomData())
            {
                if (data.Keys.Contains(j.ToString()))
                {
                    data[j].Add(p.Name, p.Value);
                }
                else
                {
                    data.Add(j, new Dictionary<string, object> { { p.Name, p.Value } });
                }
            }
        }

Here are the data classes,

private static List<TempData> BottomData()
    {
        return new List<TempData>
        {
            new TempData{ Name="X", Value=1},
            new TempData{ Name="X", Value=2}
        };
    }

    private static List<string> GetTopData()
    {
        return new List<string> { "a"};
    }

public class TempData
{
    public string Name { get; set; }
    public object Value { get; set; }
}

Body:
Answer to your question how to check key existence for dictionary within a dictionary in C#:

You can check this by using Linq like this example :

bool keyExistance = data.Any(x=>x.Value.ContainsKey(keyTocheck));

But before that you have to fix the errors in your code.


问:
Ktab command list out the principals in the keytab file more than 1 time
It might be a silly question but i want to know why its happening...

I have a keytab file for kerberos authentication. I want to list out the kvno and principal name which contained in a keytab file using ktab command.
Assume my keytab file is kumar.keytab

```<code>ktab -l -k kumar.keytab
</code>```

When execute the above command, it displays kvno and principal 5 times.

```<code>Keytab name: kumar.keytab
KVNO Principal
---- ----------------------------
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
</code>```

My question is why its displaying the same value for 5 times?

Help would be Appreciated.

Thanks,

答:
Using Java's ktab you can specify the "-e" and "-t" arguments to let it show the encryption types and the timestamps. The "-help" argument will show more info.</p>

```<code>C:\Users\test>ktab -l -e -t
Keytab name: C:\Users\test\krb5.keytab
KVNO Timestamp      Principal
---- -------------- ---------------------------------------------------
   4 25/05/17 07:56 test@TEST.COM (17:AES128 CTS mode with HMAC SHA1-96)
   4 25/05/17 07:56 test@TEST.COM (16:DES3 CBC mode with SHA1-KD)
   4 25/05/17 07:56 test@TEST.COM (23:RC4 with HMAC)
</code>```

Body:
It might be a silly question but i want to know why its happening...

I have a keytab file for kerberos authentication. I want to list out the kvno and principal name which contained in a keytab file using ktab command.
Assume my keytab file is kumar.keytab

ktab -l -k kumar.keytab

When execute the above command, it displays kvno and principal 5 times.

Keytab name: kumar.keytab
KVNO Principal
---- ----------------------------
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM
3 Kumar/hostname@KUMAR.COM

My question is why its displaying the same value for 5 times?

Help would be Appreciated.

Thanks,

Body:
Using Java's ktab you can specify the "-e" and "-t" arguments to let it show the encryption types and the timestamps. The "-help" argument will show more info.

C:\Users\test>ktab -l -e -t
Keytab name: C:\Users\test\krb5.keytab
KVNO Timestamp      Principal
---- -------------- ---------------------------------------------------
   4 25/05/17 07:56 test@TEST.COM (17:AES128 CTS mode with HMAC SHA1-96)
   4 25/05/17 07:56 test@TEST.COM (16:DES3 CBC mode with SHA1-KD)
   4 25/05/17 07:56 test@TEST.COM (23:RC4 with HMAC)


问:
RxJs Observable<string> vs Observable<string[]>
I'm having a hard time getting my head around RxJS Observables, though I've used the observable pattern in a number of different situations throughout my life. Here's some code:

```<code>    const observable: Observable<Response> = createdElswhere();
    let test1: Observable<string>;
    let test2: Observable<string[]>;

    test1 = observable.map(r => r.json());
    test2 = observable.map(r => r.json());
</code>```

Response.json() returns an array of data - usually objects that will be mapped to a typescript object, but they're just strings in this case:

```<code>[
    "test1",
    "test2",
    "test3",
    "test4"
]
</code>```

When I subscribe to the test1 or test2 properties (in an angular view template, or manually in code using .subscribe() for example), the observable generic type doesn't seem to make any difference to the framework. The items are displayed exactly the same, even though the 'data' inside the observable is different (one is an array, the other is an array of observable strings).

Can anyone explain the difference between Observable<string> and Observable<string[]>, and give me an example of how they should be used?

答:
Observable<string> is the type of observables where each emitted value is supposed to be a string.
Observable<string[]> is the type of observables where each emitted value is supposed to be an array of strings.

Whatever type you assign to an observable doesn't change what the observable will actually emit. That depends only on how the observable is constructed. If you do observable.map(r => r.json()) and r.json returns a string, the resulting observable will emit strings, if it returns an array of strings, the resulting observable will emit arrays of strings.

Said that, if r.json has a type signature like (r: Response): string[], Typescript should complain that test1's type is incompatible.

Body:
I'm having a hard time getting my head around RxJS Observables, though I've used the observable pattern in a number of different situations throughout my life. Here's some code:

    const observable: Observable<Response> = createdElswhere();
    let test1: Observable<string>;
    let test2: Observable<string[]>;

    test1 = observable.map(r => r.json());
    test2 = observable.map(r => r.json());

Response.json() returns an array of data - usually objects that will be mapped to a typescript object, but they're just strings in this case:

[
    "test1",
    "test2",
    "test3",
    "test4"
]

When I subscribe to the test1 or test2 properties (in an angular view template, or manually in code using .subscribe() for example), the observable generic type doesn't seem to make any difference to the framework. The items are displayed exactly the same, even though the 'data' inside the observable is different (one is an array, the other is an array of observable strings).

Can anyone explain the difference between Observable<string> and Observable<string[]>, and give me an example of how they should be used?


问:
Display a form in Qt
This should be very easy.

I'm using Qt Creator and I have made a Qt Gui Application (That had main.h, main.ui and main.cpp)

I just created a Qt Designer Form Class that also has a header file, ui, and a class.
I have made an action inside my main.cpp called ShowSecondForm:

```<code>void Main::ShowSecondForm()
{

}
</code>```

Everytime I execute ShowSecondForm(); I want the second form to be displayed.

What do I put inside so my form will open?

Also, is is possible to pass a string to the form while opening it? Like ShowSecondForm(const QString&)?

Some notes that may help you:

I would like to have 2 forms opened at the same time.

It will also be a class as it will compute different things.

答:
If you're opening one form from another, you might want to do something like this:

```<code>m_form = new MyForm (this);
m_form->show();
</code>```

Here you first create the form object, and then show it. Note this is passed as a parent - when a parent form is destroyed, children will be closed and destroyed automatically. That also means you don't need to bother cleaning up in destructor. If you need to open several forms, you will need an object for each of them.

```<code>m_form1 = new MyForm (this);
m_form1->show();
m_form2 = new MyForm (this);
m_form2->show();
</code>```

Finally, there are many ways to pass a string to the form. It's your form, so you may want to modify it's constructor, so that it would accept string upon creation, like m_form = new MyForm ("Some string", this); Or you may want to add a property to your form. Sometimes, you may also want to use QObject's built-in property system, take a look at QObject::setProperty() and QObject::property() functions.

Title: Display a form in Qt

Body:
This should be very easy.

I'm using Qt Creator and I have made a Qt Gui Application (That had main.h, main.ui and main.cpp)

I just created a Qt Designer Form Class that also has a header file, ui, and a class.
I have made an action inside my main.cpp called ShowSecondForm:

void Main::ShowSecondForm()
{

}

Everytime I execute ShowSecondForm(); I want the second form to be displayed.

What do I put inside so my form will open?

Also, is is possible to pass a string to the form while opening it? Like ShowSecondForm(const QString&)?

Some notes that may help you:

I would like to have 2 forms opened at the same time.

It will also be a class as it will compute different things.

Body:
If you're opening one form from another, you might want to do something like this:

m_form = new MyForm (this);
m_form->show();

Here you first create the form object, and then show it. Note this is passed as a parent - when a parent form is destroyed, children will be closed and destroyed automatically. That also means you don't need to bother cleaning up in destructor. If you need to open several forms, you will need an object for each of them.

m_form1 = new MyForm (this);
m_form1->show();
m_form2 = new MyForm (this);
m_form2->show();

Finally, there are many ways to pass a string to the form. It's your form, so you may want to modify it's constructor, so that it would accept string upon creation, like m_form = new MyForm ("Some string", this); Or you may want to add a property to your form. Sometimes, you may also want to use QObject's built-in property system, take a look at QObject::setProperty() and QObject::property() functions.


问:
WAMP requires Microsoft Visual Studio 2012 : VC 11 however that is no longer available on the microsoft website
Visual Studio 2012 : VC 11 vcredist_x64/86.exe is no longer available on the Microsoft website though I need it to run WAMP.  </p>

<p>This is the link to where the download is supposed to be:
 http://www.microsoft.com/en-us/download/details.aspx?id=30679
How can I get these files ? Is there any third party downloads ? </p>

答:
Yes, WAMPServer support have added an installer for all the MSVC Redist libraries to the Secondary repository of Wampserver files which you can find here. For some reason MS keep messing with the location of these downloads.

Secondary repository of Wampserver files

Scroll down to the botton of that page and look for Microsoft VC++ packages VC2008, 2010, 2012, 2013, 2015 zip files

You can also find the link on the WAMPServer Forum page called WAMPServer 3 All you need to know

Body:
Visual Studio 2012 : VC 11 vcredist_x64/86.exe is no longer available on the Microsoft website though I need it to run WAMP.

This is the link to where the download is supposed to be:
 http://www.microsoft.com/en-us/download/details.aspx?id=30679
How can I get these files ? Is there any third party downloads ?