qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
35,915,229
I want to sort an array containing numerical values. I know the original logic but it is not working for me. However I want to stop sorting for the similar numerical values in an array.
2016/03/10
[ "https://Stackoverflow.com/questions/35915229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3824193/" ]
``` var numbers = [40, 100, 1, 5, 25, 10]; numbers.sort(function(a, b){return a-b}); ```
By default the sort method sorts elements alphabetically. but for sort numerically just add a new method which handles numeric sorts **sortNumber**, (shown below) ``` function sortNumber(a,b) { return a - b; } var numArray = [140000, 104, 99]; numArray.sort(sortNumber); alert(numArray.joi...
35,915,229
I want to sort an array containing numerical values. I know the original logic but it is not working for me. However I want to stop sorting for the similar numerical values in an array.
2016/03/10
[ "https://Stackoverflow.com/questions/35915229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3824193/" ]
By default, JavaScript will convert the numbers in the array to strings and sort by their unicode code points so a comparison function needs to be supplied with consecutive array elements as the arguments: For more clarity your comparison function should work as follows: ``` function descending(a, b) { if ( a.avg...
``` var numbers = [40, 100, 1, 5, 25, 10]; numbers.sort(function(a, b){return a-b}); ```
35,915,229
I want to sort an array containing numerical values. I know the original logic but it is not working for me. However I want to stop sorting for the similar numerical values in an array.
2016/03/10
[ "https://Stackoverflow.com/questions/35915229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3824193/" ]
By default, JavaScript will convert the numbers in the array to strings and sort by their unicode code points so a comparison function needs to be supplied with consecutive array elements as the arguments: For more clarity your comparison function should work as follows: ``` function descending(a, b) { if ( a.avg...
By default the sort method sorts elements alphabetically. but for sort numerically just add a new method which handles numeric sorts **sortNumber**, (shown below) ``` function sortNumber(a,b) { return a - b; } var numArray = [140000, 104, 99]; numArray.sort(sortNumber); alert(numArray.joi...
11,900,982
Why is it that two synchronized blocks can't be executed simultaneously by two different threads in Java. **EDIT** ``` public class JavaApplication4 { public static void main(String[] args) { new JavaApplication4(); } public JavaApplication4() { Thread t1 = new Thread() { @O...
2012/08/10
[ "https://Stackoverflow.com/questions/11900982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075213/" ]
Your statement is false. Any number of synchronized blocks can execute in parallel as long as they don't contend for the same lock. But if your question is about blocks contending for the same lock, then it is wrong to ask "why is it so" because that is the purpose of the whole concept. Programmers **need** a mutual e...
Two Threads can execute synchronized blocks simultaneously till the point they are not locking the same object. In case the blocks are synchronized on different object... they can execute simultaneously. ``` synchronized(object1){ ... } synchronized(object2){ ... } ``` **EDIT:** `Please reason the output f...
11,900,982
Why is it that two synchronized blocks can't be executed simultaneously by two different threads in Java. **EDIT** ``` public class JavaApplication4 { public static void main(String[] args) { new JavaApplication4(); } public JavaApplication4() { Thread t1 = new Thread() { @O...
2012/08/10
[ "https://Stackoverflow.com/questions/11900982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075213/" ]
Your statement is false. Any number of synchronized blocks can execute in parallel as long as they don't contend for the same lock. But if your question is about blocks contending for the same lock, then it is wrong to ask "why is it so" because that is the purpose of the whole concept. Programmers **need** a mutual e...
That is the whole concept of synchronization, if you are taking a lock on an object (or a class), none of the other threads can access any synchronized blocks. Example ``` Class A{ public void method1() { synchronized(this)//Block 1 taking lock on Object { //do something } } public void method2() { synchroni...
11,900,982
Why is it that two synchronized blocks can't be executed simultaneously by two different threads in Java. **EDIT** ``` public class JavaApplication4 { public static void main(String[] args) { new JavaApplication4(); } public JavaApplication4() { Thread t1 = new Thread() { @O...
2012/08/10
[ "https://Stackoverflow.com/questions/11900982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075213/" ]
Your statement is false. Any number of synchronized blocks can execute in parallel as long as they don't contend for the same lock. But if your question is about blocks contending for the same lock, then it is wrong to ask "why is it so" because that is the purpose of the whole concept. Programmers **need** a mutual e...
This is not absolutely true. If you are dealing with locks on different objects then multiple threads can execute those blocks. ``` synchronized(obj1){ //your code here } synchronized(obj2){ //your code here } ``` In above case one thread can execute first and second can execute second blo...
11,900,982
Why is it that two synchronized blocks can't be executed simultaneously by two different threads in Java. **EDIT** ``` public class JavaApplication4 { public static void main(String[] args) { new JavaApplication4(); } public JavaApplication4() { Thread t1 = new Thread() { @O...
2012/08/10
[ "https://Stackoverflow.com/questions/11900982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075213/" ]
That is the whole concept of synchronization, if you are taking a lock on an object (or a class), none of the other threads can access any synchronized blocks. Example ``` Class A{ public void method1() { synchronized(this)//Block 1 taking lock on Object { //do something } } public void method2() { synchroni...
Two Threads can execute synchronized blocks simultaneously till the point they are not locking the same object. In case the blocks are synchronized on different object... they can execute simultaneously. ``` synchronized(object1){ ... } synchronized(object2){ ... } ``` **EDIT:** `Please reason the output f...
11,900,982
Why is it that two synchronized blocks can't be executed simultaneously by two different threads in Java. **EDIT** ``` public class JavaApplication4 { public static void main(String[] args) { new JavaApplication4(); } public JavaApplication4() { Thread t1 = new Thread() { @O...
2012/08/10
[ "https://Stackoverflow.com/questions/11900982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075213/" ]
That is the whole concept of synchronization, if you are taking a lock on an object (or a class), none of the other threads can access any synchronized blocks. Example ``` Class A{ public void method1() { synchronized(this)//Block 1 taking lock on Object { //do something } } public void method2() { synchroni...
This is not absolutely true. If you are dealing with locks on different objects then multiple threads can execute those blocks. ``` synchronized(obj1){ //your code here } synchronized(obj2){ //your code here } ``` In above case one thread can execute first and second can execute second blo...
5,361
More specifically, is nicotine in the concentrations that smokers receive when smoking cigarettes toxic? I know that in great enough concentrations it can be toxic (but then, so can just about anything else, including oxygen) and I know that in plants it is used as a defense against insects and can even be used as an i...
2012/11/27
[ "https://biology.stackexchange.com/questions/5361", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/1306/" ]
I think its useful to say that nicotine is not very toxic to humans - cells don't die or get sick for typical smoking habits. Secondary health effects are possible, but here is a toxicological profiles. Nicotine is a toxin in large enough quantities and nicotine has an LD50 (lethal dose for 50% of individuals) of [0....
Nicotine acts as a ligand for nicotinic acetycholine receptors (nAChRs), which are ligand-gated ion channels normally activated by acetylcholine. This family of receptors is expressed in every mammalian cell ([Schuller, 2009](http://dx.doi.org/10.1038/nrc2590)). *A priori*, at least to me, I'd suggest that it's a bad i...
5,361
More specifically, is nicotine in the concentrations that smokers receive when smoking cigarettes toxic? I know that in great enough concentrations it can be toxic (but then, so can just about anything else, including oxygen) and I know that in plants it is used as a defense against insects and can even be used as an i...
2012/11/27
[ "https://biology.stackexchange.com/questions/5361", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/1306/" ]
Nicotine acts as a ligand for nicotinic acetycholine receptors (nAChRs), which are ligand-gated ion channels normally activated by acetylcholine. This family of receptors is expressed in every mammalian cell ([Schuller, 2009](http://dx.doi.org/10.1038/nrc2590)). *A priori*, at least to me, I'd suggest that it's a bad i...
When exploring whether nicotine is toxic to humans, the discussion isn't complete without the inclusion of non-adult humans / humans-in-development. Nicotine is toxic to humans beginning at conception. Nicotine has adverse effects on sperm, making them malformed, less likely to fertilize eggs, and making the embryos th...
5,361
More specifically, is nicotine in the concentrations that smokers receive when smoking cigarettes toxic? I know that in great enough concentrations it can be toxic (but then, so can just about anything else, including oxygen) and I know that in plants it is used as a defense against insects and can even be used as an i...
2012/11/27
[ "https://biology.stackexchange.com/questions/5361", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/1306/" ]
Nicotine acts as a ligand for nicotinic acetycholine receptors (nAChRs), which are ligand-gated ion channels normally activated by acetylcholine. This family of receptors is expressed in every mammalian cell ([Schuller, 2009](http://dx.doi.org/10.1038/nrc2590)). *A priori*, at least to me, I'd suggest that it's a bad i...
<https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3880486/> Suggesting that the LD50 is an oral LD50 of 6.5–13 mg/kg.
5,361
More specifically, is nicotine in the concentrations that smokers receive when smoking cigarettes toxic? I know that in great enough concentrations it can be toxic (but then, so can just about anything else, including oxygen) and I know that in plants it is used as a defense against insects and can even be used as an i...
2012/11/27
[ "https://biology.stackexchange.com/questions/5361", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/1306/" ]
I think its useful to say that nicotine is not very toxic to humans - cells don't die or get sick for typical smoking habits. Secondary health effects are possible, but here is a toxicological profiles. Nicotine is a toxin in large enough quantities and nicotine has an LD50 (lethal dose for 50% of individuals) of [0....
When exploring whether nicotine is toxic to humans, the discussion isn't complete without the inclusion of non-adult humans / humans-in-development. Nicotine is toxic to humans beginning at conception. Nicotine has adverse effects on sperm, making them malformed, less likely to fertilize eggs, and making the embryos th...
5,361
More specifically, is nicotine in the concentrations that smokers receive when smoking cigarettes toxic? I know that in great enough concentrations it can be toxic (but then, so can just about anything else, including oxygen) and I know that in plants it is used as a defense against insects and can even be used as an i...
2012/11/27
[ "https://biology.stackexchange.com/questions/5361", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/1306/" ]
I think its useful to say that nicotine is not very toxic to humans - cells don't die or get sick for typical smoking habits. Secondary health effects are possible, but here is a toxicological profiles. Nicotine is a toxin in large enough quantities and nicotine has an LD50 (lethal dose for 50% of individuals) of [0....
<https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3880486/> Suggesting that the LD50 is an oral LD50 of 6.5–13 mg/kg.
5,361
More specifically, is nicotine in the concentrations that smokers receive when smoking cigarettes toxic? I know that in great enough concentrations it can be toxic (but then, so can just about anything else, including oxygen) and I know that in plants it is used as a defense against insects and can even be used as an i...
2012/11/27
[ "https://biology.stackexchange.com/questions/5361", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/1306/" ]
When exploring whether nicotine is toxic to humans, the discussion isn't complete without the inclusion of non-adult humans / humans-in-development. Nicotine is toxic to humans beginning at conception. Nicotine has adverse effects on sperm, making them malformed, less likely to fertilize eggs, and making the embryos th...
<https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3880486/> Suggesting that the LD50 is an oral LD50 of 6.5–13 mg/kg.
18,340,890
I have a table in an html form containing a table that a row is added to every time a button is clicked. When each row is added, I want the name and id of each field in the new row (there are four) to be updated from "Id.0" in the first row to "Id.1" in the second row and then "Id.2" in the third, etc. I can accomplish...
2013/08/20
[ "https://Stackoverflow.com/questions/18340890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554841/" ]
There is no `name` property on an HTML element. Instead you'll need to access it as an attribute: ``` this.setAttribute('name', this.getAttribute('name').replace(/\d+$/, "")+counter); ``` **[Working Demo](http://jsfiddle.net/fQDLg/)**
Try this ``` $(element).find("[name]").add(element).each(function() { this.attr("name",this.attr('name').replace(/\d+$/, "")+counter) ; }); ```
18,340,890
I have a table in an html form containing a table that a row is added to every time a button is clicked. When each row is added, I want the name and id of each field in the new row (there are four) to be updated from "Id.0" in the first row to "Id.1" in the second row and then "Id.2" in the third, etc. I can accomplish...
2013/08/20
[ "https://Stackoverflow.com/questions/18340890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554841/" ]
The issue comes from this part of your statement: `add(element)` See, `element` refers to the complete row, and rows don't have a name attribute. You just want to act upon the inputs inside the row that have the name attribute so you should remove that part from your code: ``` $(element).find("[name]").each(function(...
There is no `name` property on an HTML element. Instead you'll need to access it as an attribute: ``` this.setAttribute('name', this.getAttribute('name').replace(/\d+$/, "")+counter); ``` **[Working Demo](http://jsfiddle.net/fQDLg/)**
18,340,890
I have a table in an html form containing a table that a row is added to every time a button is clicked. When each row is added, I want the name and id of each field in the new row (there are four) to be updated from "Id.0" in the first row to "Id.1" in the second row and then "Id.2" in the third, etc. I can accomplish...
2013/08/20
[ "https://Stackoverflow.com/questions/18340890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554841/" ]
use `$(this).attr('name');` to get and set the name attribute. The full line: ``` $(this).attr('name',$( this).attr('name').replace(/\d+$/, "")+counter); ```
Try this ``` $(element).find("[name]").add(element).each(function() { this.attr("name",this.attr('name').replace(/\d+$/, "")+counter) ; }); ```
18,340,890
I have a table in an html form containing a table that a row is added to every time a button is clicked. When each row is added, I want the name and id of each field in the new row (there are four) to be updated from "Id.0" in the first row to "Id.1" in the second row and then "Id.2" in the third, etc. I can accomplish...
2013/08/20
[ "https://Stackoverflow.com/questions/18340890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554841/" ]
The issue comes from this part of your statement: `add(element)` See, `element` refers to the complete row, and rows don't have a name attribute. You just want to act upon the inputs inside the row that have the name attribute so you should remove that part from your code: ``` $(element).find("[name]").each(function(...
use `$(this).attr('name');` to get and set the name attribute. The full line: ``` $(this).attr('name',$( this).attr('name').replace(/\d+$/, "")+counter); ```
18,340,890
I have a table in an html form containing a table that a row is added to every time a button is clicked. When each row is added, I want the name and id of each field in the new row (there are four) to be updated from "Id.0" in the first row to "Id.1" in the second row and then "Id.2" in the third, etc. I can accomplish...
2013/08/20
[ "https://Stackoverflow.com/questions/18340890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554841/" ]
The issue comes from this part of your statement: `add(element)` See, `element` refers to the complete row, and rows don't have a name attribute. You just want to act upon the inputs inside the row that have the name attribute so you should remove that part from your code: ``` $(element).find("[name]").each(function(...
Try this ``` $(element).find("[name]").add(element).each(function() { this.attr("name",this.attr('name').replace(/\d+$/, "")+counter) ; }); ```
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
Personally I have no problem with using a test suite as a todo list like this as long as you eventually get around to writing the test *before* you implement the code to pass. Having said that, I used to use this approach myself, although now I'm finding that doing so leads me down a path of writing too many tests up...
Beware `Assert.Fail` and its corrupting influence to make developers write silly or broken tests. For example: ``` [TestMethod] public void TestWork() { try { Work(); } catch { Assert.Fail(); } } ``` This is silly, because the try-catch is redundant. A test fails if it throws an excep...
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
Beware `Assert.Fail` and its corrupting influence to make developers write silly or broken tests. For example: ``` [TestMethod] public void TestWork() { try { Work(); } catch { Assert.Fail(); } } ``` This is silly, because the try-catch is redundant. A test fails if it throws an excep...
Why would you use `Assert.Fail` for saying that an exception should be thrown? That is unnecessary. Why not just use the `ExpectedException` attribute?
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
This is the pattern that I use when writting a test for code that I want to throw an exception by design: ``` [TestMethod] public void TestForException() { Exception _Exception = null; try { //Code that I expect to throw the exception. MyClass _MyClass = null; _MyClass.SomeMethod()...
Why would you use `Assert.Fail` for saying that an exception should be thrown? That is unnecessary. Why not just use the `ExpectedException` attribute?
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
It was deliberately left out. This is Brad Wilson's reply as to why is there no Assert.Fail(): > > We didn't overlook this, actually. I > find Assert.Fail is a crutch which > implies that there is probably an > assertion missing. Sometimes it's just > the way the test is structured, and > sometimes it's because ...
Wild guess: withholding Assert.Fail is intended to stop you thinking that a good way to write test code is as a huge heap of spaghetti leading to an Assert.Fail in the bad cases. [Edit to add: other people's answers broadly confirm this, but with quotations] Since that's not what you're doing, it's possible that xUnit...
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
It was deliberately left out. This is Brad Wilson's reply as to why is there no Assert.Fail(): > > We didn't overlook this, actually. I > find Assert.Fail is a crutch which > implies that there is probably an > assertion missing. Sometimes it's just > the way the test is structured, and > sometimes it's because ...
This is the pattern that I use when writting a test for code that I want to throw an exception by design: ``` [TestMethod] public void TestForException() { Exception _Exception = null; try { //Code that I expect to throw the exception. MyClass _MyClass = null; _MyClass.SomeMethod()...
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
It was deliberately left out. This is Brad Wilson's reply as to why is there no Assert.Fail(): > > We didn't overlook this, actually. I > find Assert.Fail is a crutch which > implies that there is probably an > assertion missing. Sometimes it's just > the way the test is structured, and > sometimes it's because ...
Why would you use `Assert.Fail` for saying that an exception should be thrown? That is unnecessary. Why not just use the `ExpectedException` attribute?
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
This is the pattern that I use when writting a test for code that I want to throw an exception by design: ``` [TestMethod] public void TestForException() { Exception _Exception = null; try { //Code that I expect to throw the exception. MyClass _MyClass = null; _MyClass.SomeMethod()...
This is our use case for **Assert.Fail()**. One important goal for our Unit tests is that they *don't touch the database*. Sometimes mocking doesn't happen properly, or application code is modified and a database call is inadvertently made. This can be quite deep in the call stack. The exception may be caught so i...
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
For this scenario, rather than calling Assert.Fail, I do the following (in C# / NUnit) ``` [Test] public void MyClassDoesSomething() { throw new NotImplementedException(); } ``` It is more explicit than an Assert.Fail. There seems to be general agreement that it is preferable to use more explicit assertions tha...
Personally I have no problem with using a test suite as a todo list like this as long as you eventually get around to writing the test *before* you implement the code to pass. Having said that, I used to use this approach myself, although now I'm finding that doing so leads me down a path of writing too many tests up...
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
I've always used Assert.Fail() for handling cases where you've detected that a test should fail through logic beyond simple value comparison. As an example: ``` try { // Some code that should throw ExceptionX Assert.Fail("ExceptionX should be thrown") } catch ( ExceptionX ex ) { // test passed } ``` Thus th...
With the good code I usually do: ``` void goodCode() { // TODO void goodCode() throw new NotSupportedOperationException("void goodCode()"); } ``` With the test code I usually do: ``` @Test void testSomething() { // TODO void test Something Assert.assert("Some descriptive text about what to test"...
120,648
I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the...
2008/09/23
[ "https://Stackoverflow.com/questions/120648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3320/" ]
I've always used Assert.Fail() for handling cases where you've detected that a test should fail through logic beyond simple value comparison. As an example: ``` try { // Some code that should throw ExceptionX Assert.Fail("ExceptionX should be thrown") } catch ( ExceptionX ex ) { // test passed } ``` Thus th...
This is the pattern that I use when writting a test for code that I want to throw an exception by design: ``` [TestMethod] public void TestForException() { Exception _Exception = null; try { //Code that I expect to throw the exception. MyClass _MyClass = null; _MyClass.SomeMethod()...
1,880,262
Is there a way to ensure that a goroutine will run only in a specific OS thread? For example, when GUI operations must run in the GUI thread, but there might be multiple goroutines running GUI code. `GOMAXPROCS(1)` does the job technically, but that defeats the purpose of multithreading. `LockOSThread()` works too, b...
2009/12/10
[ "https://Stackoverflow.com/questions/1880262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/127007/" ]
To the best of my knowledge, not currently. I think the 'go-like' way to do this would be to write a Goroutine that runs in the GUI thread and services requests from other goroutines sent in over a channel. For example, you could have it read from a channel that accepts function pointers, and execute those functions.
Why do you want to do this? I believe `runtime.LockOSThread()` is necessary if you are creating a library binding from C code which uses thread-local storage. Otherwise, just let the scheduler multiplex the goroutines for you. And note that `runtime.LockOSThread()` only prevents other goroutines from running in that t...
6,137,304
getting following error: > > SMTP -> ERROR: Failed to connect to server: php\_network\_getaddresses: getaddrinfo failed: No such host is known. (0) > SMTP Error: Could not connect to SMTP host. There was a problem sending this mail! > > > This is my config file setting as I have followed this [PHPMailer tutoria...
2011/05/26
[ "https://Stackoverflow.com/questions/6137304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685713/" ]
Is SMTP set up on ? And if so is it configured to listen to smtp..com on port 587? If the server is not set up by yourself it's not uncommon that they listen to mail..com instead. Also, try to connect to port 25 to see if it might be configured to listen to the default smtp port. The error messages is in any case very...
Hopefully this helps someone else out there because I was fighting this same error. First I was getting. I was getting an error that said it couldn't connect(). Then I turned on the debugging and got the error you mentioned. The solution that worked for me was to change the smtp..com to the ip address. ``` $mail->Host...
6,137,304
getting following error: > > SMTP -> ERROR: Failed to connect to server: php\_network\_getaddresses: getaddrinfo failed: No such host is known. (0) > SMTP Error: Could not connect to SMTP host. There was a problem sending this mail! > > > This is my config file setting as I have followed this [PHPMailer tutoria...
2011/05/26
[ "https://Stackoverflow.com/questions/6137304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685713/" ]
Is SMTP set up on ? And if so is it configured to listen to smtp..com on port 587? If the server is not set up by yourself it's not uncommon that they listen to mail..com instead. Also, try to connect to port 25 to see if it might be configured to listen to the default smtp port. The error messages is in any case very...
I had this problem a while ago, everything checked out just fine but the problem persisted. A reboot of httpd.service solved it.
6,137,304
getting following error: > > SMTP -> ERROR: Failed to connect to server: php\_network\_getaddresses: getaddrinfo failed: No such host is known. (0) > SMTP Error: Could not connect to SMTP host. There was a problem sending this mail! > > > This is my config file setting as I have followed this [PHPMailer tutoria...
2011/05/26
[ "https://Stackoverflow.com/questions/6137304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685713/" ]
Is SMTP set up on ? And if so is it configured to listen to smtp..com on port 587? If the server is not set up by yourself it's not uncommon that they listen to mail..com instead. Also, try to connect to port 25 to see if it might be configured to listen to the default smtp port. The error messages is in any case very...
Had this issue after restart of computer where docker container with apache webserver was running. Apache server hosted php code which stopped sending emails after computer restart. Restarting apache docker container solved the issue.
6,137,304
getting following error: > > SMTP -> ERROR: Failed to connect to server: php\_network\_getaddresses: getaddrinfo failed: No such host is known. (0) > SMTP Error: Could not connect to SMTP host. There was a problem sending this mail! > > > This is my config file setting as I have followed this [PHPMailer tutoria...
2011/05/26
[ "https://Stackoverflow.com/questions/6137304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685713/" ]
Hopefully this helps someone else out there because I was fighting this same error. First I was getting. I was getting an error that said it couldn't connect(). Then I turned on the debugging and got the error you mentioned. The solution that worked for me was to change the smtp..com to the ip address. ``` $mail->Host...
Had this issue after restart of computer where docker container with apache webserver was running. Apache server hosted php code which stopped sending emails after computer restart. Restarting apache docker container solved the issue.
6,137,304
getting following error: > > SMTP -> ERROR: Failed to connect to server: php\_network\_getaddresses: getaddrinfo failed: No such host is known. (0) > SMTP Error: Could not connect to SMTP host. There was a problem sending this mail! > > > This is my config file setting as I have followed this [PHPMailer tutoria...
2011/05/26
[ "https://Stackoverflow.com/questions/6137304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685713/" ]
I had this problem a while ago, everything checked out just fine but the problem persisted. A reboot of httpd.service solved it.
Had this issue after restart of computer where docker container with apache webserver was running. Apache server hosted php code which stopped sending emails after computer restart. Restarting apache docker container solved the issue.
26,909,389
I am reading a string from a file in ruby. This string has escape sequences in them that I would like turned into the appropriate characters. For example I might have a string like this: ``` "this is a string\n" ``` With the actual characters `\` and `n` in the file, not the newline character. Is there a built in ...
2014/11/13
[ "https://Stackoverflow.com/questions/26909389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
If this is just a plain text file (e.g. not JSON, YAML, or another data format that has specific escape sequences) then those character sequences have no special meaning. Therefore, if you want to give them one in the context of your application you'll have to write the code to do that yourself. For newlines specifical...
You can use `%q{}` %q{"this is a string\n"} => "\"this is a string\n\"" This way it will escape the string characters. From the [documentation](https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-perl/): > > There’s a general delimited string and regex quoting syntax similar to > P...
26,909,389
I am reading a string from a file in ruby. This string has escape sequences in them that I would like turned into the appropriate characters. For example I might have a string like this: ``` "this is a string\n" ``` With the actual characters `\` and `n` in the file, not the newline character. Is there a built in ...
2014/11/13
[ "https://Stackoverflow.com/questions/26909389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
If you are satisfied with the escape sequences supported by the JSON format, you can do something like this: ``` require 'json' def unescape(str) JSON.parse("[\"#{str}\"]")[0] end p unescape("\\nline\\u0040") # "\nline@" ``` Please note that the ruby JSON parser does not accept naked values, so the stri...
You can use `%q{}` %q{"this is a string\n"} => "\"this is a string\n\"" This way it will escape the string characters. From the [documentation](https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-perl/): > > There’s a general delimited string and regex quoting syntax similar to > P...
26,909,389
I am reading a string from a file in ruby. This string has escape sequences in them that I would like turned into the appropriate characters. For example I might have a string like this: ``` "this is a string\n" ``` With the actual characters `\` and `n` in the file, not the newline character. Is there a built in ...
2014/11/13
[ "https://Stackoverflow.com/questions/26909389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
If this is just a plain text file (e.g. not JSON, YAML, or another data format that has specific escape sequences) then those character sequences have no special meaning. Therefore, if you want to give them one in the context of your application you'll have to write the code to do that yourself. For newlines specifical...
I hope there's a better option, but it's good to know that you can achieve this with [`Kernel#eval`](http://www.ruby-doc.org/core-2.1.4/Kernel.html#method-i-eval): ``` literal_from_file = '"this is a string\n"' puts literal_from_file # print the literal first puts eval(literal_from_file) # and then print the in...
26,909,389
I am reading a string from a file in ruby. This string has escape sequences in them that I would like turned into the appropriate characters. For example I might have a string like this: ``` "this is a string\n" ``` With the actual characters `\` and `n` in the file, not the newline character. Is there a built in ...
2014/11/13
[ "https://Stackoverflow.com/questions/26909389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
If you are satisfied with the escape sequences supported by the JSON format, you can do something like this: ``` require 'json' def unescape(str) JSON.parse("[\"#{str}\"]")[0] end p unescape("\\nline\\u0040") # "\nline@" ``` Please note that the ruby JSON parser does not accept naked values, so the stri...
I hope there's a better option, but it's good to know that you can achieve this with [`Kernel#eval`](http://www.ruby-doc.org/core-2.1.4/Kernel.html#method-i-eval): ``` literal_from_file = '"this is a string\n"' puts literal_from_file # print the literal first puts eval(literal_from_file) # and then print the in...
26,909,389
I am reading a string from a file in ruby. This string has escape sequences in them that I would like turned into the appropriate characters. For example I might have a string like this: ``` "this is a string\n" ``` With the actual characters `\` and `n` in the file, not the newline character. Is there a built in ...
2014/11/13
[ "https://Stackoverflow.com/questions/26909389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
If you are satisfied with the escape sequences supported by the JSON format, you can do something like this: ``` require 'json' def unescape(str) JSON.parse("[\"#{str}\"]")[0] end p unescape("\\nline\\u0040") # "\nline@" ``` Please note that the ruby JSON parser does not accept naked values, so the stri...
If this is just a plain text file (e.g. not JSON, YAML, or another data format that has specific escape sequences) then those character sequences have no special meaning. Therefore, if you want to give them one in the context of your application you'll have to write the code to do that yourself. For newlines specifical...
14,058,371
I am trying to write a query that will give me the `max date` form `Table_A` based on the following condition. If the given date (input parameter) falls **between 01 April and 30 Sept** of that year then return `MAX(date)` prior to April 1. OR If the given date (input parameter) falls **between 01 Oct and 31 March**...
2012/12/27
[ "https://Stackoverflow.com/questions/14058371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822984/" ]
try this: ``` select max(case when trunc(the_date) between to_date('01-apr-'||the_year, 'dd-mon-yyyy') and to_date('30-sep-'||the_year, 'dd-mon-yyyy') and dte < to_date('01-apr-'||the_year, 'dd-mon-yyyy') then dte when ...
The end date in my example is Dec-31-2012, you can extend it to 2013+. I'm building table on the fly-the max\_date is printed for every row. Also, I hardcode max dates. You do not need to do any of this, this is just for example. Replace &1 and &2 with values w/out quotes...: ``` SELECT date_table --, start_date, end_...
70,525,104
I have `struct` that conforms to protocol `Codable`. Some properties are decoded from JSON fields so I use the `CodingKeys` enum for that. But there are few properties that are not in my JSON and I need to calculate them from decoded JSON properties. For example, if you get a `Zip code` from JSON, I want to calculate `...
2021/12/29
[ "https://Stackoverflow.com/questions/70525104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2173628/" ]
> > I would prefer to let default init decoder does it job, and then add my code to calculate City > > > Unfortunately you can't. It is currently all or nothing; you cannot treat the synthesized init as some sort of inheritance from super (as in your imagined `Call default init`). > > I was also thinking about c...
You can use a computed property that relies on the zip to return a city. So you'd have to figure out the logic of how to map zip back to city with some method but here's a simple example I cooked up: ``` struct Rectangle : Codable{ var width : Float var height : Float var area : Float{ ...
70,525,104
I have `struct` that conforms to protocol `Codable`. Some properties are decoded from JSON fields so I use the `CodingKeys` enum for that. But there are few properties that are not in my JSON and I need to calculate them from decoded JSON properties. For example, if you get a `Zip code` from JSON, I want to calculate `...
2021/12/29
[ "https://Stackoverflow.com/questions/70525104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2173628/" ]
I have found a solution but it needs to use `class` instead of `struct`. I store decoded properties in a parent class. Then I extend this class and add calculated properties in it. As it is not possible to extend `struct`, I had to use `class`. Maybe it is a first step to a better solution and it can help anyone find...
You can use a computed property that relies on the zip to return a city. So you'd have to figure out the logic of how to map zip back to city with some method but here's a simple example I cooked up: ``` struct Rectangle : Codable{ var width : Float var height : Float var area : Float{ ...
70,525,104
I have `struct` that conforms to protocol `Codable`. Some properties are decoded from JSON fields so I use the `CodingKeys` enum for that. But there are few properties that are not in my JSON and I need to calculate them from decoded JSON properties. For example, if you get a `Zip code` from JSON, I want to calculate `...
2021/12/29
[ "https://Stackoverflow.com/questions/70525104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2173628/" ]
> > I would prefer to let default init decoder does it job, and then add my code to calculate City > > > Unfortunately you can't. It is currently all or nothing; you cannot treat the synthesized init as some sort of inheritance from super (as in your imagined `Call default init`). > > I was also thinking about c...
Ok misread at first. Here's something I think could help: use willSet or didSet on zip to then compute the city perhaps? Not sure if that gets you around not having a default value but this code will only run if the zipcode changes ``` struct Place: Codable { var name: String var zipcode: String{ didSet...
70,525,104
I have `struct` that conforms to protocol `Codable`. Some properties are decoded from JSON fields so I use the `CodingKeys` enum for that. But there are few properties that are not in my JSON and I need to calculate them from decoded JSON properties. For example, if you get a `Zip code` from JSON, I want to calculate `...
2021/12/29
[ "https://Stackoverflow.com/questions/70525104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2173628/" ]
> > I would prefer to let default init decoder does it job, and then add my code to calculate City > > > Unfortunately you can't. It is currently all or nothing; you cannot treat the synthesized init as some sort of inheritance from super (as in your imagined `Call default init`). > > I was also thinking about c...
I have found a solution but it needs to use `class` instead of `struct`. I store decoded properties in a parent class. Then I extend this class and add calculated properties in it. As it is not possible to extend `struct`, I had to use `class`. Maybe it is a first step to a better solution and it can help anyone find...
70,525,104
I have `struct` that conforms to protocol `Codable`. Some properties are decoded from JSON fields so I use the `CodingKeys` enum for that. But there are few properties that are not in my JSON and I need to calculate them from decoded JSON properties. For example, if you get a `Zip code` from JSON, I want to calculate `...
2021/12/29
[ "https://Stackoverflow.com/questions/70525104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2173628/" ]
I have found a solution but it needs to use `class` instead of `struct`. I store decoded properties in a parent class. Then I extend this class and add calculated properties in it. As it is not possible to extend `struct`, I had to use `class`. Maybe it is a first step to a better solution and it can help anyone find...
Ok misread at first. Here's something I think could help: use willSet or didSet on zip to then compute the city perhaps? Not sure if that gets you around not having a default value but this code will only run if the zipcode changes ``` struct Place: Codable { var name: String var zipcode: String{ didSet...
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
On a more elementary side, the are these probabilistic paradoxes, such as: <https://en.wikipedia.org/wiki/Monty_Hall_problem>, <https://en.wikipedia.org/wiki/Two_envelopes_problem>, <https://en.wikipedia.org/wiki/Boy_or_Girl_paradox>, <https://en.wikipedia.org/wiki/Sleeping_Beauty_problem>, etc. Also, this one is fun:...
The book "The Drunkard's Walk: How Randomness Rules Our Lives" by Leonard Mlodinow is *probably* close to what you are looking for.
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
On a more elementary side, the are these probabilistic paradoxes, such as: <https://en.wikipedia.org/wiki/Monty_Hall_problem>, <https://en.wikipedia.org/wiki/Two_envelopes_problem>, <https://en.wikipedia.org/wiki/Boy_or_Girl_paradox>, <https://en.wikipedia.org/wiki/Sleeping_Beauty_problem>, etc. Also, this one is fun:...
1. A proof using the coupling method, say the coupling proof of the convergence theorem of finite-state Markov chains. See [Lindvall's beautiful book](http://books.google.com/books/about/Lectures_on_the_Coupling_Method.html?id=GUwyU1ypd1wC) for other examples. 2. The proof of existence of phase transition for the perco...
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
Random walk! That is a fascinating topic which can be treated with combinatorial methods. Associated is the ruin problem. Treat the facts that simple random walk is recurrent in dimension two but not in dimension three.
I think the proof that the normal PDF is a PDF (i.e. integrates to 1) is beautiful and deserves to be in a probability course. Obviously, it's mostly calculus, so perhaps not elementary enough for what you have in mind, but it's really beautiful.
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
Random walk! That is a fascinating topic which can be treated with combinatorial methods. Associated is the ruin problem. Treat the facts that simple random walk is recurrent in dimension two but not in dimension three.
The Central Limit Theorem and how it even works for something as discrete as counting coin flips.
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
On a more elementary side, the are these probabilistic paradoxes, such as: <https://en.wikipedia.org/wiki/Monty_Hall_problem>, <https://en.wikipedia.org/wiki/Two_envelopes_problem>, <https://en.wikipedia.org/wiki/Boy_or_Girl_paradox>, <https://en.wikipedia.org/wiki/Sleeping_Beauty_problem>, etc. Also, this one is fun:...
The Central Limit Theorem and how it even works for something as discrete as counting coin flips.
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
Random walk! That is a fascinating topic which can be treated with combinatorial methods. Associated is the ruin problem. Treat the facts that simple random walk is recurrent in dimension two but not in dimension three.
A quincunx (balls dropping through what is typically a triangle of nails, creating a roughly binomial distribution) is fun to watch. Real ones are extremely sensitive to errors in the locations of the nails; there are simulations on the internet, somewhere.
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
On a more elementary side, the are these probabilistic paradoxes, such as: <https://en.wikipedia.org/wiki/Monty_Hall_problem>, <https://en.wikipedia.org/wiki/Two_envelopes_problem>, <https://en.wikipedia.org/wiki/Boy_or_Girl_paradox>, <https://en.wikipedia.org/wiki/Sleeping_Beauty_problem>, etc. Also, this one is fun:...
The connection between random walks and electrical networks, e.g. as laid out by Doyle and Snell: <http://arxiv.org/abs/math/0001057>. This gives really slick proofs of many classical results about random walks (e.g. Polya's Theorem regarding recurrence vs. transience on lattices $\mathbb{Z}^n$, cover time, hitting tim...
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
I nominate the **Overlapping Words Paradox**. E.g., see pages 42-44 in a [book excerpt](https://stepic.org/media/attachments/lessons/1/excerpt_1st_printing.pdf), a [research paper](http://www.worldscientific.com/doi/abs/10.1142/9789814503655_0006), or an [elementary exposition](http://kvant.mccme.ru/1987/05/luchshee_pa...
A quincunx (balls dropping through what is typically a triangle of nails, creating a roughly binomial distribution) is fun to watch. Real ones are extremely sensitive to errors in the locations of the nails; there are simulations on the internet, somewhere.
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
Random walk! That is a fascinating topic which can be treated with combinatorial methods. Associated is the ruin problem. Treat the facts that simple random walk is recurrent in dimension two but not in dimension three.
The obvious application of probability is to gambling. Not only is this the major historical motivation to study probability, coin flips and rolling dice are still the easiest examples for students to understand while containing very meaty problems (e.g. if a friend flips a coin 20 times and 15 are heads, is the coin b...
231,045
I have to read several lectures on probability or applications of probability for high school students (of high level). There is no necessary part I must lecture, that is, my aim is just advertisement. What are possible subjects? There are many nice examples in Alon-Spencer book, with applications to combinatorics an...
2016/02/13
[ "https://mathoverflow.net/questions/231045", "https://mathoverflow.net", "https://mathoverflow.net/users/4312/" ]
On a more elementary side, the are these probabilistic paradoxes, such as: <https://en.wikipedia.org/wiki/Monty_Hall_problem>, <https://en.wikipedia.org/wiki/Two_envelopes_problem>, <https://en.wikipedia.org/wiki/Boy_or_Girl_paradox>, <https://en.wikipedia.org/wiki/Sleeping_Beauty_problem>, etc. Also, this one is fun:...
A quincunx (balls dropping through what is typically a triangle of nails, creating a roughly binomial distribution) is fun to watch. Real ones are extremely sensitive to errors in the locations of the nails; there are simulations on the internet, somewhere.
42,655
I wonder if someone knows any C# script that will provide me all Site Features in a site collection as well as all Site collection features in a site collection. I only required Activated features (GUID).
2012/08/06
[ "https://sharepoint.stackexchange.com/questions/42655", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/6183/" ]
I think that when you use the Feature property in a SPSite or SpWeb you only get the active features on the "site collection"/site. So the code under will give you the active features on a site collection and all the sites in that site collection (write it to a file so you do not miss any because of the cmd buffer). `...
This should get you started : <http://www.c-sharpcorner.com/blogs/7698/get-the-list-of-activated-features-in-the-site-collection-an.aspx> However, it only shows the guid and not the feature name. Alternatively you use these scripts:- Features are activated for an SPSite: ``` Get-SPFeature -Site http://sitecollectio...
39,392,070
for my input in the feed forward neural network that I have implemented in Keras, I just wanted to check that my understanding is correct. ``` [[ 25.26000023 26.37000084 24.67000008 23.30999947] [ 26.37000084 24.67000008 23.30999947 21.36000061] [ 24.67000008 23.30999947 21.36000061 19.77000046]...] ``` So...
2016/09/08
[ "https://Stackoverflow.com/questions/39392070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4704934/" ]
You can store it as String. The issue you are facing - I assume - is when you want to return that JSON as structure within the Solr JSON response. By default Solr does not know that you want to **embed** the content rather than **present** it. To tell it otherwise, try using a [**[json]** document transformer](https:/...
`String` type stores a word/sentence as an exact string without performing tokenization etc. Commonly useful for storing exact matches, e.g, for facetting. `Text` typically performs `tokenization`, and secondary processing (such as lower-casing etc.). More of use when you want to match a word which is part of that a s...
43,350
When a client edits a featured image, they notice that they have the ability to set its "Alignment". If they were working with standard images embedded via the Editor, then this wouldn't be a problem. But since it is a featured image, WordPress doesn't pass in the appropriate class. Is there a way to know which alignm...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43350", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1766/" ]
Short answer: **you don't**. The alignment settings only apply to images that the user *adds to the Post Content*. The Featured Image is *incorporated into the template* and is *not added by the user* to the Post Content. The Featured Image is directly integrated into the template, usually as a "post thumbnail" disp...
I am sort of confused with your question but I hope that this link will help. <http://codex.wordpress.org/CSS#WordPress_Generated_Classes>
43,350
When a client edits a featured image, they notice that they have the ability to set its "Alignment". If they were working with standard images embedded via the Editor, then this wouldn't be a problem. But since it is a featured image, WordPress doesn't pass in the appropriate class. Is there a way to know which alignm...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43350", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1766/" ]
Short answer: **you don't**. The alignment settings only apply to images that the user *adds to the Post Content*. The Featured Image is *incorporated into the template* and is *not added by the user* to the Post Content. The Featured Image is directly integrated into the template, usually as a "post thumbnail" disp...
As a tag-along to Chip's answer (which is correct), here's a sample of the meta that's stored for image attachments via `wp_get_attachment_meta($attachment_id)`: ``` array ( 'width' => '228', 'height' => '147', 'hwstring_small' => 'height='82' width='128'', 'file' => '2009/06/1.jpg', 'sizes' => array ( ...
61,817,193
`If the input is more than a single charecter then the program should ask the user if he wants to try again.But my code fails and the input line keeps popping up. ``` def is_vowel(char): vowels = ('a', 'e', 'i', 'o', 'u') if char not in vowels: return False return True def main(): again="y" ...
2020/05/15
[ "https://Stackoverflow.com/questions/61817193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13430940/" ]
The problem is you're cancelling your interval timer when there aren't any images, so if the user doesn't create an image within a second (and within a second after that, etc.), the timer will get cancelled and no further images will be removed. I wouldn't use an interval timer for this, I'd use a single timer (`setTi...
You can add a load event listener to a added image and within the handler remove it with a timeout. Generic snippet, maybe it's useful for your code: ```js const addImage = (i = 1) => { let img = document.createElement("img"); img.src = "https://img.icons8.com/metro/2x/like.png"; img.addEventListener("load", ...
61,817,193
`If the input is more than a single charecter then the program should ask the user if he wants to try again.But my code fails and the input line keeps popping up. ``` def is_vowel(char): vowels = ('a', 'e', 'i', 'o', 'u') if char not in vowels: return False return True def main(): again="y" ...
2020/05/15
[ "https://Stackoverflow.com/questions/61817193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13430940/" ]
The problem is you're cancelling your interval timer when there aren't any images, so if the user doesn't create an image within a second (and within a second after that, etc.), the timer will get cancelled and no further images will be removed. I wouldn't use an interval timer for this, I'd use a single timer (`setTi...
If the intent is to remove the images 1 second after each other you should set the `timer` inside the "click" callback. This way you can add the interval if it is not yet set. If the intent is to display each image a maximum of 1 second this is not the answer you're looking for. ```js let imgList = []; let timer; d...
114,561
Windows 7 Home Premium has **local users and groups** mmc console snap-in disabled: ![W7Home - snapin disabled](https://img6.imageshack.us/img6/3594/ss20100219114724.png) Is there any custom utility I can use to manage my accounts? I need no more than adding users and email addresses to have some test accounts for my ...
2010/02/19
[ "https://serverfault.com/questions/114561", "https://serverfault.com", "https://serverfault.com/users/8965/" ]
The MMC is disabled since Home Premium does not support active diretory users and the net effect is that it does not support the Users and Groups MMC snap-in. After some research it is revealed that the only way to do this is using the command-line or PowerShell scripting. There is currently no third party tools simpl...
While you can't use the MMC, there should be a control panel applet allowing local user administration. There's always been a limited applet since XP Home. 'nusermgr.cpl' and 'control userpasswords2' should still work I believe. If you're looking for a scriptable means to do this you can use 'net user' to add/modify...
114,561
Windows 7 Home Premium has **local users and groups** mmc console snap-in disabled: ![W7Home - snapin disabled](https://img6.imageshack.us/img6/3594/ss20100219114724.png) Is there any custom utility I can use to manage my accounts? I need no more than adding users and email addresses to have some test accounts for my ...
2010/02/19
[ "https://serverfault.com/questions/114561", "https://serverfault.com", "https://serverfault.com/users/8965/" ]
The MMC is disabled since Home Premium does not support active diretory users and the net effect is that it does not support the Users and Groups MMC snap-in. After some research it is revealed that the only way to do this is using the command-line or PowerShell scripting. There is currently no third party tools simpl...
Now it is, I missed this functionality too so I created clone, you can download it here: <http://primocode.blogspot.com/2015/06/prils-local-users-and-groups-for.html>. It is not quite finished yet but basic functionalities work ok.
114,561
Windows 7 Home Premium has **local users and groups** mmc console snap-in disabled: ![W7Home - snapin disabled](https://img6.imageshack.us/img6/3594/ss20100219114724.png) Is there any custom utility I can use to manage my accounts? I need no more than adding users and email addresses to have some test accounts for my ...
2010/02/19
[ "https://serverfault.com/questions/114561", "https://serverfault.com", "https://serverfault.com/users/8965/" ]
While you can't use the MMC, there should be a control panel applet allowing local user administration. There's always been a limited applet since XP Home. 'nusermgr.cpl' and 'control userpasswords2' should still work I believe. If you're looking for a scriptable means to do this you can use 'net user' to add/modify...
Now it is, I missed this functionality too so I created clone, you can download it here: <http://primocode.blogspot.com/2015/06/prils-local-users-and-groups-for.html>. It is not quite finished yet but basic functionalities work ok.
194,799
On old computers (using BIOS) we had to create 2 partitions, one to mount `/` and second for swap. But on new systems with UEFI we need to create third partition `EFI System` in addition to those two partitions. What is the purpose of this partition? Update: does this partition is shared between a Linux distributio...
2015/04/07
[ "https://unix.stackexchange.com/questions/194799", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/52733/" ]
Beside the meaning of the [ESP](http://en.wikipedia.org/wiki/EFI_System_partition)(EFI System Partition), is really just any partition formatted with one of the UEFI spec-defined variants of FAT and given a specific GPT partition type to help the firmware find it. This way, all EFI executables will be stored at one pla...
Via [Wikipedia](http://en.wikipedia.org/wiki/EFI_System_partition): > > ESP (EFI System Partition) contains the boot loader programs for all > installed operating systems (which are contained in other partitions > on the same or other storage device), device driver files for devices > present in a computer that ar...
65,771,662
One of my controller's action returns huge collection in JSON response and when I make a request toward this controller WebAPI don't return a response. So I have tested this action using breakpoint and collection is filled normally. At the end I am sure that this is a problem of WebApi since I have tested this controll...
2021/01/18
[ "https://Stackoverflow.com/questions/65771662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10304482/" ]
I came here looking for a solution to the same problem, but for me it was not resolved by changing the MaxResponseBufferSize. As it turned out, it seems that Postman also returns this same error, as the maximum size can be configured, and the default is 50Mb. In the Postman application, you can go to settings, and co...
According to documentation. Deafult Response buffer size is 64KB. Take a look [here](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserverlimits.maxresponsebuffersize?view=aspnetcore-5.0) You can change it like: ``` public static IWebHostBuilder CreateWebHostBuilder(s...
1,184,024
What I need is to clearly differentiate between the attachments (this is an approval, this is an offer, this is a PO, etc). Is this possible, or it is working only in bulk (attach all files together)? Thanks,
2009/07/26
[ "https://Stackoverflow.com/questions/1184024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/168650/" ]
SharePoint does not support attachment metadata. I would suggest storing the attachments in a document library (probably with Content Types for Approval, Offer, PO, etc) with a lookup column to the associated item in your list.
You could create separate lists for each item requiring an attachment, then link those lists in a master table.
1,184,024
What I need is to clearly differentiate between the attachments (this is an approval, this is an offer, this is a PO, etc). Is this possible, or it is working only in bulk (attach all files together)? Thanks,
2009/07/26
[ "https://Stackoverflow.com/questions/1184024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/168650/" ]
You could create separate lists for each item requiring an attachment, then link those lists in a master table.
There are two option. 1. Add as many attachment you want to attachment column with the list. but you cannot associate metadata with that. 2. Create document library and use lookup in the list to view name of the document. so in a way it is storing the common document in library and just refer which one you are suppose...
1,184,024
What I need is to clearly differentiate between the attachments (this is an approval, this is an offer, this is a PO, etc). Is this possible, or it is working only in bulk (attach all files together)? Thanks,
2009/07/26
[ "https://Stackoverflow.com/questions/1184024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/168650/" ]
SharePoint does not support attachment metadata. I would suggest storing the attachments in a document library (probably with Content Types for Approval, Offer, PO, etc) with a lookup column to the associated item in your list.
There are two option. 1. Add as many attachment you want to attachment column with the list. but you cannot associate metadata with that. 2. Create document library and use lookup in the list to view name of the document. so in a way it is storing the common document in library and just refer which one you are suppose...
67,770,320
I'm having a hard time calculating the sum of a specific set of children with the same name. I did it like this, but it does not work. Please help. ``` driverRef.orderByChild("earnings") .once() .then((DataSnapshot dataSnapShot) { print("PPPP" + dataSnapShot.value.toString()); ...
2021/05/31
[ "https://Stackoverflow.com/questions/67770320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4243978/" ]
Instead of doing `model.build_vocab(sentences=shuffle_corpus(tokenized_sentences), update=True)` Replace the **sentence** param name with **corpus\_iterable** so if your iterable is working fine, you should be able to generate easily as: `model.build_vocab(shuffle_corpus(tokenized_sentences), update=True)` or `mode...
In recent versions of Gensim, the name `sentences` has been replaced. (It often misled people into thinking each text had to be a proper sentence, as opposed to just a list-of-tokens.) You should either specify your corpus as a `corpus_iterable` (if it's something like a Python `list`, or sequence that is re-iterable)...
2,002,509
Right now, I have a console application I'm working on, which is supposed to display and update information to the console at a given interval. The problem I'm having is that with a carriage return, I can only update one line of text at a time. If I use a newline, the old line can no longer be updated using a carriage ...
2010/01/04
[ "https://Stackoverflow.com/questions/2002509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136846/" ]
You might be able to find a [curses library](http://en.wikipedia.org/wiki/Curses_(programming_library)) variant that works on your platform.
This is a really ugly solution, but in a pinch you could always just clear the console entirely and then reprint everything. This strategy looks a bit ugly in some cases; it may make things look blinky.
2,002,509
Right now, I have a console application I'm working on, which is supposed to display and update information to the console at a given interval. The problem I'm having is that with a carriage return, I can only update one line of text at a time. If I use a newline, the old line can no longer be updated using a carriage ...
2010/01/04
[ "https://Stackoverflow.com/questions/2002509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136846/" ]
You might be able to find a [curses library](http://en.wikipedia.org/wiki/Curses_(programming_library)) variant that works on your platform.
The correct answer is to use the curses library as mentioned by Mark. But if you're on Unix-like systems and can't be bothered with curses then the quick and dirty solution is to directly print out vt100 escape sequences: <http://ascii-table.com/ansi-escape-sequences-vt-100.php> I often do this especially in scriptin...
2,002,509
Right now, I have a console application I'm working on, which is supposed to display and update information to the console at a given interval. The problem I'm having is that with a carriage return, I can only update one line of text at a time. If I use a newline, the old line can no longer be updated using a carriage ...
2010/01/04
[ "https://Stackoverflow.com/questions/2002509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136846/" ]
The correct answer is to use the curses library as mentioned by Mark. But if you're on Unix-like systems and can't be bothered with curses then the quick and dirty solution is to directly print out vt100 escape sequences: <http://ascii-table.com/ansi-escape-sequences-vt-100.php> I often do this especially in scriptin...
This is a really ugly solution, but in a pinch you could always just clear the console entirely and then reprint everything. This strategy looks a bit ugly in some cases; it may make things look blinky.
7,145,501
I have a table in MYSQL on which I need to perform a select and then order it by a fairly complex logic. Here is an example of my logic: ``` if(column_a is not null && column_a > 0){ var_a = column_a else var_a = 1; if(column_a is not null){ var_b = column_b else var_b = 0 if(column_c is not null){ va...
2011/08/22
[ "https://Stackoverflow.com/questions/7145501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856906/" ]
a complex case/where structure is really what you need, so the mess is in the syntax. if you want to make the query more elegant, check out the [Adding New Functions to MySQL](http://dev.mysql.com/doc/refman/5.1/en/adding-functions.html) section of the reference manual. then you'll have something like this: ``` SELECT...
One way to tidy things up: ``` SELECT my_table.*, IF( foo > bar, a, b ) AS var_a, IF( some_value IS NOT NULL AND is_numeric( some_value ), some_value, other_value ) AS var_b, IFNULL( yet_another_value, 0 ) AS var_c FROM my_table ORDER BY var_b - (column_baz + var_a)/(var_c + var_a) ``` There will be 3 ...
7,145,501
I have a table in MYSQL on which I need to perform a select and then order it by a fairly complex logic. Here is an example of my logic: ``` if(column_a is not null && column_a > 0){ var_a = column_a else var_a = 1; if(column_a is not null){ var_b = column_b else var_b = 0 if(column_c is not null){ va...
2011/08/22
[ "https://Stackoverflow.com/questions/7145501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856906/" ]
For a down and dirty way, you can use functions in an `order by` clause. In specific, you can use the `if` and `ifnull` functions. Therefore, you should be able to do something like this: ``` SELECT ... ORDER BY IF(some_value IS NOT NULL AND some_value RLIKE '^[[:digit:]]+$', some_value, other_value) - (column_...
One way to tidy things up: ``` SELECT my_table.*, IF( foo > bar, a, b ) AS var_a, IF( some_value IS NOT NULL AND is_numeric( some_value ), some_value, other_value ) AS var_b, IFNULL( yet_another_value, 0 ) AS var_c FROM my_table ORDER BY var_b - (column_baz + var_a)/(var_c + var_a) ``` There will be 3 ...
7,145,501
I have a table in MYSQL on which I need to perform a select and then order it by a fairly complex logic. Here is an example of my logic: ``` if(column_a is not null && column_a > 0){ var_a = column_a else var_a = 1; if(column_a is not null){ var_b = column_b else var_b = 0 if(column_c is not null){ va...
2011/08/22
[ "https://Stackoverflow.com/questions/7145501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856906/" ]
For a down and dirty way, you can use functions in an `order by` clause. In specific, you can use the `if` and `ifnull` functions. Therefore, you should be able to do something like this: ``` SELECT ... ORDER BY IF(some_value IS NOT NULL AND some_value RLIKE '^[[:digit:]]+$', some_value, other_value) - (column_...
a complex case/where structure is really what you need, so the mess is in the syntax. if you want to make the query more elegant, check out the [Adding New Functions to MySQL](http://dev.mysql.com/doc/refman/5.1/en/adding-functions.html) section of the reference manual. then you'll have something like this: ``` SELECT...
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
``` a_file = open("file1.txt", "r") number_of_lines = 2 with open("file2.txt", "w") as new_file: for i in range(number_of_lines): line = a_file.readline() new_file.write(line) a_file.close() ``` I'm sure there is a neater solution out there somewhere but this will work! Hope it helps you :)
For 2 lines: ``` with open("file1.txt", "r") as r: with open("file2.txt", "w") as w: w.write(r.readline() + r.readline()) ``` Each time `r.readline()` is called, it goes to the next line. So if you wanted to read `n` lines; use: Note that `.readline() + r.readline()` is only 2 seperate lines if there is...
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
``` a_file = open("file1.txt", "r") number_of_lines = 2 with open("file2.txt", "w") as new_file: for i in range(number_of_lines): line = a_file.readline() new_file.write(line) a_file.close() ``` I'm sure there is a neater solution out there somewhere but this will work! Hope it helps you :)
``` f1=open("file1.txt","r") f2=open("file2.txt","w") fcontent=f1.readline() f2.write(fcontent) fcontent=f1.readline() f2.write(fcontent) f1.close() f2.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
``` a_file = open("file1.txt", "r") number_of_lines = 2 with open("file2.txt", "w") as new_file: for i in range(number_of_lines): line = a_file.readline() new_file.write(line) a_file.close() ``` I'm sure there is a neater solution out there somewhere but this will work! Hope it helps you :)
``` f1 = open("file1.txt","r") f2 = open("file2.txt","w") str = f1.readline() f2.write(str) str = f1.readline() f2.write(str) f1.close() f2.close() f3 = open("file2.txt") print(f3.read()) f3.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
``` a_file = open("file1.txt", "r") number_of_lines = 2 with open("file2.txt", "w") as new_file: for i in range(number_of_lines): line = a_file.readline() new_file.write(line) a_file.close() ``` I'm sure there is a neater solution out there somewhere but this will work! Hope it helps you :)
``` fhandle1 = open("file1.txt") fhandle2 = open("file2.txt","w") fcontents = fhandle1.readline() fhandle2.write(fcontents) fcontents = fhandle1.readline() fhandle2.write(fcontents) fhandle1.close() fhandle2.close() fhandle3 = open("file2.txt") print(fhandle3.read()) fhandle3.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
``` a_file = open("file1.txt", "r") number_of_lines = 2 with open("file2.txt", "w") as new_file: for i in range(number_of_lines): line = a_file.readline() new_file.write(line) a_file.close() ``` I'm sure there is a neater solution out there somewhere but this will work! Hope it helps you :)
``` fhandle1 = open("file1.txt","r") l1 = fhandle1.readline() l2 = fhandle1.readline() fhandle2 = open("file2.txt","w") fhandle2.write(l1) fhandle2.write(l2) fhandle2 = open("file2.txt") print(fhandle2.read()) fhandle2.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
Write a Python program to 1. Read the first two lines from a text file named "file1.txt" 2. Write the two lines read from "file1.txt" to a new file called "file2.txt" 3. Read "file2.txt" and Print the contents ```py fhandle1 = open("file1.txt","r") fhandle2 = open("file2.txt","w") str = fhandle1.readline() fhandle2....
For 2 lines: ``` with open("file1.txt", "r") as r: with open("file2.txt", "w") as w: w.write(r.readline() + r.readline()) ``` Each time `r.readline()` is called, it goes to the next line. So if you wanted to read `n` lines; use: Note that `.readline() + r.readline()` is only 2 seperate lines if there is...
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
Write a Python program to 1. Read the first two lines from a text file named "file1.txt" 2. Write the two lines read from "file1.txt" to a new file called "file2.txt" 3. Read "file2.txt" and Print the contents ```py fhandle1 = open("file1.txt","r") fhandle2 = open("file2.txt","w") str = fhandle1.readline() fhandle2....
``` f1=open("file1.txt","r") f2=open("file2.txt","w") fcontent=f1.readline() f2.write(fcontent) fcontent=f1.readline() f2.write(fcontent) f1.close() f2.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
Write a Python program to 1. Read the first two lines from a text file named "file1.txt" 2. Write the two lines read from "file1.txt" to a new file called "file2.txt" 3. Read "file2.txt" and Print the contents ```py fhandle1 = open("file1.txt","r") fhandle2 = open("file2.txt","w") str = fhandle1.readline() fhandle2....
``` f1 = open("file1.txt","r") f2 = open("file2.txt","w") str = f1.readline() f2.write(str) str = f1.readline() f2.write(str) f1.close() f2.close() f3 = open("file2.txt") print(f3.read()) f3.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
Write a Python program to 1. Read the first two lines from a text file named "file1.txt" 2. Write the two lines read from "file1.txt" to a new file called "file2.txt" 3. Read "file2.txt" and Print the contents ```py fhandle1 = open("file1.txt","r") fhandle2 = open("file2.txt","w") str = fhandle1.readline() fhandle2....
``` fhandle1 = open("file1.txt") fhandle2 = open("file2.txt","w") fcontents = fhandle1.readline() fhandle2.write(fcontents) fcontents = fhandle1.readline() fhandle2.write(fcontents) fhandle1.close() fhandle2.close() fhandle3 = open("file2.txt") print(fhandle3.read()) fhandle3.close() ```
72,008,526
I have an `input` file where first column values are same and other column values are different. i want to sum the values of `third` column only(first row to first row...) and want to keep the added values just beside of common first column values. input ``` > > > > 1.000 3 0.002 2.010 4 -0.001 3.020 5 -0.001 > > > >...
2022/04/26
[ "https://Stackoverflow.com/questions/72008526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6532890/" ]
Write a Python program to 1. Read the first two lines from a text file named "file1.txt" 2. Write the two lines read from "file1.txt" to a new file called "file2.txt" 3. Read "file2.txt" and Print the contents ```py fhandle1 = open("file1.txt","r") fhandle2 = open("file2.txt","w") str = fhandle1.readline() fhandle2....
``` fhandle1 = open("file1.txt","r") l1 = fhandle1.readline() l2 = fhandle1.readline() fhandle2 = open("file2.txt","w") fhandle2.write(l1) fhandle2.write(l2) fhandle2 = open("file2.txt") print(fhandle2.read()) fhandle2.close() ```
36,617,248
I'm new to c++ and have a simple program as below ``` #include <iostream> #include <map> #include <vector> using namespace std; int main() { std::map<std::string, double*> testMap; std::vector<std::string> v = {"A", "B", "C"}; for(size_t i=0;i<v.size();++i) { std::string sym = v[i]; double* d = testMap[sym...
2016/04/14
[ "https://Stackoverflow.com/questions/36617248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599840/" ]
This is the expected behavior of [`std::map::operator[]`](http://en.cppreference.com/w/cpp/container/map/operator_at): > > Returns a reference to the value that is mapped to a key equivalent to > key, performing an insertion if such key does not already exist. > > > If an insertion is performed, the mapped value ...
When you write `testMap[sym]` a check is done whether `sym` exists in map, and if it does then reference to it is returned. If it does not then new entry value initialized is inserted into map with key `sym`, in your case it is a null pointer. So if you dont want to have null vaules, then check if key exists with [std...
36,617,248
I'm new to c++ and have a simple program as below ``` #include <iostream> #include <map> #include <vector> using namespace std; int main() { std::map<std::string, double*> testMap; std::vector<std::string> v = {"A", "B", "C"}; for(size_t i=0;i<v.size();++i) { std::string sym = v[i]; double* d = testMap[sym...
2016/04/14
[ "https://Stackoverflow.com/questions/36617248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599840/" ]
This is the expected behavior of [`std::map::operator[]`](http://en.cppreference.com/w/cpp/container/map/operator_at): > > Returns a reference to the value that is mapped to a key equivalent to > key, performing an insertion if such key does not already exist. > > > If an insertion is performed, the mapped value ...
That is the way maps works. The map must be check if the key is all raedy containt. Use find(key) for that. In your excample testMap[sym]; creates a new entry. ``` std::map<std::string,double*>::iterator it; it = testMap.find("A"); if ( it == testMap.end() ) { // create a new entry testMap["A"] = new double(1.0); }...
36,617,248
I'm new to c++ and have a simple program as below ``` #include <iostream> #include <map> #include <vector> using namespace std; int main() { std::map<std::string, double*> testMap; std::vector<std::string> v = {"A", "B", "C"}; for(size_t i=0;i<v.size();++i) { std::string sym = v[i]; double* d = testMap[sym...
2016/04/14
[ "https://Stackoverflow.com/questions/36617248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599840/" ]
When you write `testMap[sym]` a check is done whether `sym` exists in map, and if it does then reference to it is returned. If it does not then new entry value initialized is inserted into map with key `sym`, in your case it is a null pointer. So if you dont want to have null vaules, then check if key exists with [std...
That is the way maps works. The map must be check if the key is all raedy containt. Use find(key) for that. In your excample testMap[sym]; creates a new entry. ``` std::map<std::string,double*>::iterator it; it = testMap.find("A"); if ( it == testMap.end() ) { // create a new entry testMap["A"] = new double(1.0); }...
63,551,804
I want to split my string based on elements of a list but I am not sure how to do it. ``` string = "IwenttotheParkToday" my_list = ["went", "the", "today"] Desired Output: [I, went, to, the, park, today] ```
2020/08/23
[ "https://Stackoverflow.com/questions/63551804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8684461/" ]
In your Store function you have used this `$abouts = new about;` Are you doing the same in update functions? then it will be a new instance. Adding Validations may help you know the reason why it's not getting updated. `\Log::debug('message');` can also be useful if you still don't get the issue after putting validat...
The best solution is to test it first if you are getting data in the request or not using `dd()` method. OR you can try this: ``` public function update(Request $request) { if($request->isMethod('PUT')){ //in this section all code are same as like as my store controller $abouts->update(); ...
39,749
When Jon Snow is captured by the Wildlings in S02E08 of Game of Thrones, the Lord of Bones says > > Why would we need a dead man's bastard? > > > How did they know that Ned Stark was dead? It seems unlikely that a crow carrying the message would be north of The Wall.
2013/08/22
[ "https://scifi.stackexchange.com/questions/39749", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/16133/" ]
We don't know exactly how they know this, but it isn't impossible. Wildlings trade with the Night's Watch at Eastwatch-by-the-Sea. So it could be that they heard about it from the Night's Watch. Remember that Ned was warden of the North. Besides the Night's Watch, Ned would be the main force preventing the Wildling in...
Mance Rayder, himself, had been to Winterfell, incognito as a traveling minstrel (when King Robert visits at the very beginning of the saga), so the ability to for people and information to move from one side of the Wall to the other is pretty well established. Plus, as a former member of the Night's Watch, he apparent...
24,080,680
Can someone tell me how to add 3 buttons under the txtArea in the TextLine class present in this link : <https://stackoverflow.com/a/18780743/3649438> I am new to GUI programming and I have problems in adding them. I tried to add JButtons to pane1 or contentPane, but it seems that the code automatically resizes the wi...
2014/06/06
[ "https://Stackoverflow.com/questions/24080680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3649438/" ]
Read Layout Manager from [here](http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) Run this code. It will solve your problem. But first read the basic tutorials of Swing. ``` import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax....
``` public test() { super("Title"); JPanel panel = new JPanel(); add(panel); JButton mybutton = new JButton("TEST BUTTON"); getContentPane().add(mybutton); } ```
16,302,273
I have installed Python and configured in apache. I created a Python web file and open this in browser, I get an error. But the same code working in command-line. I hope the problem is from my apache configuration. This is the error message. ``` MOD_PYTHON ERROR ProcessId: 6368 Interpreter: 'localhost' Ser...
2013/04/30
[ "https://Stackoverflow.com/questions/16302273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816211/" ]
There appears to be a typo in your httpd.conf `AddHandler mod_python .py` Because of the space it is looking for two modules `mod_python` and `py`
you wrote : ``` AddHandler mod_python .py ``` Try to remove the blank before the `.py` **EDIT :** Ok, so try something like that : ``` SetHandler python-program PythonHandler mod_python.py PythonDebug On ``` or the following : ``` AddHandler mod_python py PythonHandler mod_python.py PythonDebug On ```
16,302,273
I have installed Python and configured in apache. I created a Python web file and open this in browser, I get an error. But the same code working in command-line. I hope the problem is from my apache configuration. This is the error message. ``` MOD_PYTHON ERROR ProcessId: 6368 Interpreter: 'localhost' Ser...
2013/04/30
[ "https://Stackoverflow.com/questions/16302273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816211/" ]
[AddHandler](http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler) requires additional parameters and you basically provide it with the python extension `.py`. Then you provide the name of the Python file to the [PythonHandler](http://www.modpython.org/live/current/doc-html/dir-handlers-ph.html) without the ex...
you wrote : ``` AddHandler mod_python .py ``` Try to remove the blank before the `.py` **EDIT :** Ok, so try something like that : ``` SetHandler python-program PythonHandler mod_python.py PythonDebug On ``` or the following : ``` AddHandler mod_python py PythonHandler mod_python.py PythonDebug On ```
16,302,273
I have installed Python and configured in apache. I created a Python web file and open this in browser, I get an error. But the same code working in command-line. I hope the problem is from my apache configuration. This is the error message. ``` MOD_PYTHON ERROR ProcessId: 6368 Interpreter: 'localhost' Ser...
2013/04/30
[ "https://Stackoverflow.com/questions/16302273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816211/" ]
[AddHandler](http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler) requires additional parameters and you basically provide it with the python extension `.py`. Then you provide the name of the Python file to the [PythonHandler](http://www.modpython.org/live/current/doc-html/dir-handlers-ph.html) without the ex...
There appears to be a typo in your httpd.conf `AddHandler mod_python .py` Because of the space it is looking for two modules `mod_python` and `py`
39,975
> > How do you like your coffee? > > > Can I use the above sentence either on an offering situation that I ask if they like it black or with sugar, or during having situation that I ask if the coffee tastes good? When the latter is possible, can next both answers be possible? 1. I like it a lot. 2. It's good.
2014/11/20
[ "https://ell.stackexchange.com/questions/39975", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/504/" ]
Good question -- in addition to the answers concerned with the various contexts in which this is asked: The ambiguity is as much a question of contrastive focus: * **How** do you like your coffee? * How **do** you like your coffee? * How do **you** like your coffee? * How do you **like** your coffee? * How do you lik...
It's easier to see the meaning if you expand the two sentences to avoid the ambiguity: > > How do you like your coffee [to be]? > > > And the second definition: > > How do you like your coffee [in front of you]? > > > --- The latter is usually instead said without the "how" (in fact, I have a feeling inclu...
39,975
> > How do you like your coffee? > > > Can I use the above sentence either on an offering situation that I ask if they like it black or with sugar, or during having situation that I ask if the coffee tastes good? When the latter is possible, can next both answers be possible? 1. I like it a lot. 2. It's good.
2014/11/20
[ "https://ell.stackexchange.com/questions/39975", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/504/" ]
This phrase does have two meanings in US English, as agreed by other posters. For the sake of completeness, I feel compelled to add that in British English, this is a phrase that would only be used when offering coffee. Using it as a question to affirm how much someone was enjoying their coffee would probably be under...
Good question -- in addition to the answers concerned with the various contexts in which this is asked: The ambiguity is as much a question of contrastive focus: * **How** do you like your coffee? * How **do** you like your coffee? * How do **you** like your coffee? * How do you **like** your coffee? * How do you lik...
39,975
> > How do you like your coffee? > > > Can I use the above sentence either on an offering situation that I ask if they like it black or with sugar, or during having situation that I ask if the coffee tastes good? When the latter is possible, can next both answers be possible? 1. I like it a lot. 2. It's good.
2014/11/20
[ "https://ell.stackexchange.com/questions/39975", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/504/" ]
Context depends greatly on whether I ask: **before I give it to you**, where it's equivalent to *"Would you like milk/sugar/etc.?"* **after I give it to you**, where I'm asking *"Do you like it?"/"Is that coffee ok?"*
One other possible interpretation is if it's being said by someone who doesn't like coffee, in an incredulous manner: > > *How* do you like your coffee?? I hate it! > > > (This is me. :))
39,975
> > How do you like your coffee? > > > Can I use the above sentence either on an offering situation that I ask if they like it black or with sugar, or during having situation that I ask if the coffee tastes good? When the latter is possible, can next both answers be possible? 1. I like it a lot. 2. It's good.
2014/11/20
[ "https://ell.stackexchange.com/questions/39975", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/504/" ]
As the other answers suggest, `"How do you like your coffee?"` can indeed have either meaning, depending on context. If you're looking for unambiguous versions, you could instead ask: > > How do you take your coffee? `Meaning: Milk? Sugar?` > > > Or > > How is your coffee? `Meaning: Do you like the coffee you...
One other possible interpretation is if it's being said by someone who doesn't like coffee, in an incredulous manner: > > *How* do you like your coffee?? I hate it! > > > (This is me. :))