qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
3,339,591
I cannot make difference between conditional statement and biconditional statement I make difference between them when they are used in Natural language but I don't know which one to pick if its not clear. One example is this in first I think that was not biconditional statement but it turns on that is it. Example: “p: If you finish your meal, then q: you can have dessert.” in my head you can finish the meal without eating the desert, is not like "must". But the The Result says "You can have dessert if and only if you finish your meal." But without showing the answer I would never thought that the answer was p ↔ q.
2019/08/30
[ "https://math.stackexchange.com/questions/3339591", "https://math.stackexchange.com", "https://math.stackexchange.com/users/694966/" ]
This is an English question, not a math one. In English, if ... then often means if and only if. In math it is clear that an implication is true if the antecedent is false. You have to look at the context. In this case, there is a clear English implication that if you don't finish your meal you cannot have dessert, which makes it biconditional. The "you can have dessert" is permissive, so having dessert is not required even if the meal is finished.
> > Example: “p: If you finish your meal, then q: you can have dessert.” in my head you can finish the meal without eating the desert, is not like "must". > > > A simple test: Negate both the antecedent and consequent. If the statement is still true, then you have a biconditional relationship. Applying this test to your example: Is it true that, if you **DO NOT** finish your meal, then you **CANNOT** have dessert? If so, you have a biconditional relationship. The principle is the same whether it is stated in natural language or symbolic logic. $$(P \implies Q) \land (\neg P \implies \neg Q) \space \space \equiv \space \space P \iff Q$$
23,812,996
Let's consider this Java class : ``` public class A { int att1; UnknownDataType att2; } ``` And let's consider these implications : * **IF** att1 is equal to 1 **THEN** att2 should be of type DataType1. * **IF** att1 is equal to 2 **THEN** att2 should be of type DataType2. I honestly cannot yet imagine how to design this, because an attribute value is influencing another intribute class. Should simply make the class **A** as abstract class, and make **DataType1** and **DataType2** inherit from **A**? Have you guys had a similar situation? Thank you a lot.
2014/05/22
[ "https://Stackoverflow.com/questions/23812996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2766382/" ]
This is not a good design. You want to use generics ... ``` public class A<UnknownDataType> { UnknownDataType type; } A<String> aString = new A<String>(); A<Integer> aInteger = new A<Integer>(); ```
I usually use one of 3 approaches here: 1. Quick'n'dirty: If att2 is not exposed directly then just set its type to Object and cast when necessary using att1. 2. If the types are used in a similar way - there is room to create a common interface. In that case this becomes simple and allows to only use att1 when you need some non-trivial involvement. 3. Generics or subclassing. This fixes what att2 type is, but does not restrain you. Not easy to do if the type of att2 can change during the life cycle of the object though (unless you also implement variant 2)
23,812,996
Let's consider this Java class : ``` public class A { int att1; UnknownDataType att2; } ``` And let's consider these implications : * **IF** att1 is equal to 1 **THEN** att2 should be of type DataType1. * **IF** att1 is equal to 2 **THEN** att2 should be of type DataType2. I honestly cannot yet imagine how to design this, because an attribute value is influencing another intribute class. Should simply make the class **A** as abstract class, and make **DataType1** and **DataType2** inherit from **A**? Have you guys had a similar situation? Thank you a lot.
2014/05/22
[ "https://Stackoverflow.com/questions/23812996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2766382/" ]
This is not a good design. You want to use generics ... ``` public class A<UnknownDataType> { UnknownDataType type; } A<String> aString = new A<String>(); A<Integer> aInteger = new A<Integer>(); ```
This is a little tough with out knowing the exact goal of your software. There could be a few ways to approach this. Let's list a few potential scenarios Is there anything in common between the UnknownDataType that you need to store? Maybe that data type should be an interface and you store the interface instead of the data type. Is there something in common between how you perform action on the data? For example if UnknownDataType is used in a calculation maybe you want to replace it with a command interface and store a command to perform an action on that data. [Wiki Link](http://en.wikipedia.org/wiki/Command_pattern) If it takes two different data types is it possible that the object is not related? Maybe you are interested in a factory to generate your class depending on att1 and Class A is really just an interface or an abstract class. Maybe you know the value in advance and all you want to do is use generic parameters to initialize your class ``` public class a<T> ``` If either of these don't match your scenario feel free to describe it a bit more for the best practice.
23,812,996
Let's consider this Java class : ``` public class A { int att1; UnknownDataType att2; } ``` And let's consider these implications : * **IF** att1 is equal to 1 **THEN** att2 should be of type DataType1. * **IF** att1 is equal to 2 **THEN** att2 should be of type DataType2. I honestly cannot yet imagine how to design this, because an attribute value is influencing another intribute class. Should simply make the class **A** as abstract class, and make **DataType1** and **DataType2** inherit from **A**? Have you guys had a similar situation? Thank you a lot.
2014/05/22
[ "https://Stackoverflow.com/questions/23812996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2766382/" ]
I usually use one of 3 approaches here: 1. Quick'n'dirty: If att2 is not exposed directly then just set its type to Object and cast when necessary using att1. 2. If the types are used in a similar way - there is room to create a common interface. In that case this becomes simple and allows to only use att1 when you need some non-trivial involvement. 3. Generics or subclassing. This fixes what att2 type is, but does not restrain you. Not easy to do if the type of att2 can change during the life cycle of the object though (unless you also implement variant 2)
This is a little tough with out knowing the exact goal of your software. There could be a few ways to approach this. Let's list a few potential scenarios Is there anything in common between the UnknownDataType that you need to store? Maybe that data type should be an interface and you store the interface instead of the data type. Is there something in common between how you perform action on the data? For example if UnknownDataType is used in a calculation maybe you want to replace it with a command interface and store a command to perform an action on that data. [Wiki Link](http://en.wikipedia.org/wiki/Command_pattern) If it takes two different data types is it possible that the object is not related? Maybe you are interested in a factory to generate your class depending on att1 and Class A is really just an interface or an abstract class. Maybe you know the value in advance and all you want to do is use generic parameters to initialize your class ``` public class a<T> ``` If either of these don't match your scenario feel free to describe it a bit more for the best practice.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
According Leonard McCoy's memory beta wiki page, the novel Encounter at Farpoint explains how he got there and why he wasn't at the ship's launch: > > In 2363, McCoy suffered an injury after tripping over one of his > great-great-grandchildrens' toys which necessitated a stay at Bethesda > Starfleet Hospital, preventing him from attending the launch of the > USS Enterprise-D. In "revenge", McCoy connived the USS Hood to take > him to Farpoint Station, where they would be transferring crew to the > new Enterprise. McCoy inspected the ship's medical facilities of the > new ship, and was escorted back to the Hood, via shuttlecraft, by > Lieutenant Commander Data. McCoy told the young android the ship was > new but had the right name, and that if she was treated well she'd > always bring the crew home. (TNG novelization: Encounter at Farpoint) > > > References: [Encounter at Farpoint (Star Trek: The Next Generation)](http://rads.stackoverflow.com/amzn/click/0671652419) [Leonard McCoy @ Memory Beta](http://memory-beta.wikia.com/wiki/Leonard_McCoy) I haven't actually read the book, but if someone has a copy hopefully they can provide a more detailed answer.
According to the book McCoy simply wanted to see the new Enterprise. As was stated above, he missed his opportunity to tour the ship before the actual launch with other dignitaries because he was laid up in the hospital. By the time he was discharged the Enterprise had left spacedock for its shakedown cruise. So as the book said, he did something he rarely did; he politicked. He called in old favors and used his celebraty status as a legendary Federation hero to gain access to the ship. Think of what might happen today if Colin Powell wanted to tour a new naval vessel.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
According to the book McCoy simply wanted to see the new Enterprise. As was stated above, he missed his opportunity to tour the ship before the actual launch with other dignitaries because he was laid up in the hospital. By the time he was discharged the Enterprise had left spacedock for its shakedown cruise. So as the book said, he did something he rarely did; he politicked. He called in old favors and used his celebraty status as a legendary Federation hero to gain access to the ship. Think of what might happen today if Colin Powell wanted to tour a new naval vessel.
Heart. Just for the heart factor. Plus very few ships in Starfleet bear multiple alpha-numeric designations, with ships like the Enterprise, Yamato and the London being exceptions to the rule. So he has an emotional attachment to the namesake. With good reason, given the rich history of the various Enterprises in fleet service, including the one he personally served on. Plus he's an Admiral and certainly has the leeway to inspect at his discretion when it comes to the maiden voyages of space-bound medical facilities he oversees.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
You're overthinking it. This kind of thing happens all the time in the real world. Short answer: "because he's an Admiral and wanted to". Obviously TNG wanted to create a better connection with TOS, so they brought him on. However, in world, it makes perfect sense. If you were old and had been on a previous one, wouldn't you want to see the future versions? If you were an Admiral, you could make it happen without a "real" reason... Second part, even if Memnoch's info isn't canon, Admirals are often quite busy. While he can make sure he gets to it, he may not have been able to do it *exactly* at the time he originally wanted to.
Heart. Just for the heart factor. Plus very few ships in Starfleet bear multiple alpha-numeric designations, with ships like the Enterprise, Yamato and the London being exceptions to the rule. So he has an emotional attachment to the namesake. With good reason, given the rich history of the various Enterprises in fleet service, including the one he personally served on. Plus he's an Admiral and certainly has the leeway to inspect at his discretion when it comes to the maiden voyages of space-bound medical facilities he oversees.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
According Leonard McCoy's memory beta wiki page, the novel Encounter at Farpoint explains how he got there and why he wasn't at the ship's launch: > > In 2363, McCoy suffered an injury after tripping over one of his > great-great-grandchildrens' toys which necessitated a stay at Bethesda > Starfleet Hospital, preventing him from attending the launch of the > USS Enterprise-D. In "revenge", McCoy connived the USS Hood to take > him to Farpoint Station, where they would be transferring crew to the > new Enterprise. McCoy inspected the ship's medical facilities of the > new ship, and was escorted back to the Hood, via shuttlecraft, by > Lieutenant Commander Data. McCoy told the young android the ship was > new but had the right name, and that if she was treated well she'd > always bring the crew home. (TNG novelization: Encounter at Farpoint) > > > References: [Encounter at Farpoint (Star Trek: The Next Generation)](http://rads.stackoverflow.com/amzn/click/0671652419) [Leonard McCoy @ Memory Beta](http://memory-beta.wikia.com/wiki/Leonard_McCoy) I haven't actually read the book, but if someone has a copy hopefully they can provide a more detailed answer.
Heart. Just for the heart factor. Plus very few ships in Starfleet bear multiple alpha-numeric designations, with ships like the Enterprise, Yamato and the London being exceptions to the rule. So he has an emotional attachment to the namesake. With good reason, given the rich history of the various Enterprises in fleet service, including the one he personally served on. Plus he's an Admiral and certainly has the leeway to inspect at his discretion when it comes to the maiden voyages of space-bound medical facilities he oversees.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
He just wanted to see the ship one more time, I think. Also, Chekov is still alive in the 24th Century as the head of Starfleet Intelligence (I think) & so is Uhura, who became an Admiral (in the novels) which makes sense as they were both relatively young during TOS (Chekov was fresh out of the Academy back then).
Heart. Just for the heart factor. Plus very few ships in Starfleet bear multiple alpha-numeric designations, with ships like the Enterprise, Yamato and the London being exceptions to the rule. So he has an emotional attachment to the namesake. With good reason, given the rich history of the various Enterprises in fleet service, including the one he personally served on. Plus he's an Admiral and certainly has the leeway to inspect at his discretion when it comes to the maiden voyages of space-bound medical facilities he oversees.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
Upon further digging, I think the answer is right in the episode script, and my initial guess was wrong - he was inspecting Enterprise-D specifically in his capacity as Dr and ex-CMO. > > WORF: Commander Data is on a special assignment, sir. He's using our shuttlecraft to transfer an admiral over to the Hood. > > RIKER: An admiral? > > WORF: He's been aboard all day, sir, **checking over medical layout.** > > >
He just wanted to see the ship one more time, I think. Also, Chekov is still alive in the 24th Century as the head of Starfleet Intelligence (I think) & so is Uhura, who became an Admiral (in the novels) which makes sense as they were both relatively young during TOS (Chekov was fresh out of the Academy back then).
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
Dr. McCoy, as the Branch Admiral of Starfleet Medical, is most likely the Surgeon General of Starfleet. He's the man responsible for the whole of Starfleet's medical personnel, and as such, has the right to inspect, in person or by proxy, any and/or all medical staff and facilities in Starfleet. Likewise, the Fleet or Sector Medical Admiral could do so as well. It's extremely common in militaries for specialists to have dual chains of command. In the real world, most officer specialty branches have a dual chain. Engineers, Medical, Personnel, and Chaplain all answer to dual chains, and in all cases, can¹ override the Captain if a standing order from Branch would be breached by the Captain's orders. The Enterprise is not attached to a particular sector; it's apparently attached to a specific fleet of rovers. Given this, there's a Fleet Surgeon, probably a low seniority admiral, who is her direct medical supervisor. This person answers to the Starfleet Medical Command, including her commanding admiral and vice commander. All three of whom can inspect on a whim, in person or by proxy. It's really not uncommon for a major command to have a flag officer conduct their own inspections as an excuse to get away from the desk, provided other duties permit. Dr. McCoy could have opted to do the inspection as a matter of escaping his desk-duty, essentially, a "working vacation." His comments to Data imply this kind of task - filling in a required inspection early, and doing it in person because he wanted to. --- *Footnotes* ¹: Can, but not Must. If, however, things go bad, "just following the Captain's Orders" will NOT protect the senior watchstander when they came through. He and the Skipper will face charges side by side.
According to the book McCoy simply wanted to see the new Enterprise. As was stated above, he missed his opportunity to tour the ship before the actual launch with other dignitaries because he was laid up in the hospital. By the time he was discharged the Enterprise had left spacedock for its shakedown cruise. So as the book said, he did something he rarely did; he politicked. He called in old favors and used his celebraty status as a legendary Federation hero to gain access to the ship. Think of what might happen today if Colin Powell wanted to tour a new naval vessel.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
According Leonard McCoy's memory beta wiki page, the novel Encounter at Farpoint explains how he got there and why he wasn't at the ship's launch: > > In 2363, McCoy suffered an injury after tripping over one of his > great-great-grandchildrens' toys which necessitated a stay at Bethesda > Starfleet Hospital, preventing him from attending the launch of the > USS Enterprise-D. In "revenge", McCoy connived the USS Hood to take > him to Farpoint Station, where they would be transferring crew to the > new Enterprise. McCoy inspected the ship's medical facilities of the > new ship, and was escorted back to the Hood, via shuttlecraft, by > Lieutenant Commander Data. McCoy told the young android the ship was > new but had the right name, and that if she was treated well she'd > always bring the crew home. (TNG novelization: Encounter at Farpoint) > > > References: [Encounter at Farpoint (Star Trek: The Next Generation)](http://rads.stackoverflow.com/amzn/click/0671652419) [Leonard McCoy @ Memory Beta](http://memory-beta.wikia.com/wiki/Leonard_McCoy) I haven't actually read the book, but if someone has a copy hopefully they can provide a more detailed answer.
Dr. McCoy, as the Branch Admiral of Starfleet Medical, is most likely the Surgeon General of Starfleet. He's the man responsible for the whole of Starfleet's medical personnel, and as such, has the right to inspect, in person or by proxy, any and/or all medical staff and facilities in Starfleet. Likewise, the Fleet or Sector Medical Admiral could do so as well. It's extremely common in militaries for specialists to have dual chains of command. In the real world, most officer specialty branches have a dual chain. Engineers, Medical, Personnel, and Chaplain all answer to dual chains, and in all cases, can¹ override the Captain if a standing order from Branch would be breached by the Captain's orders. The Enterprise is not attached to a particular sector; it's apparently attached to a specific fleet of rovers. Given this, there's a Fleet Surgeon, probably a low seniority admiral, who is her direct medical supervisor. This person answers to the Starfleet Medical Command, including her commanding admiral and vice commander. All three of whom can inspect on a whim, in person or by proxy. It's really not uncommon for a major command to have a flag officer conduct their own inspections as an excuse to get away from the desk, provided other duties permit. Dr. McCoy could have opted to do the inspection as a matter of escaping his desk-duty, essentially, a "working vacation." His comments to Data imply this kind of task - filling in a required inspection early, and doing it in person because he wanted to. --- *Footnotes* ¹: Can, but not Must. If, however, things go bad, "just following the Captain's Orders" will NOT protect the senior watchstander when they came through. He and the Skipper will face charges side by side.
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
Dr. McCoy, as the Branch Admiral of Starfleet Medical, is most likely the Surgeon General of Starfleet. He's the man responsible for the whole of Starfleet's medical personnel, and as such, has the right to inspect, in person or by proxy, any and/or all medical staff and facilities in Starfleet. Likewise, the Fleet or Sector Medical Admiral could do so as well. It's extremely common in militaries for specialists to have dual chains of command. In the real world, most officer specialty branches have a dual chain. Engineers, Medical, Personnel, and Chaplain all answer to dual chains, and in all cases, can¹ override the Captain if a standing order from Branch would be breached by the Captain's orders. The Enterprise is not attached to a particular sector; it's apparently attached to a specific fleet of rovers. Given this, there's a Fleet Surgeon, probably a low seniority admiral, who is her direct medical supervisor. This person answers to the Starfleet Medical Command, including her commanding admiral and vice commander. All three of whom can inspect on a whim, in person or by proxy. It's really not uncommon for a major command to have a flag officer conduct their own inspections as an excuse to get away from the desk, provided other duties permit. Dr. McCoy could have opted to do the inspection as a matter of escaping his desk-duty, essentially, a "working vacation." His comments to Data imply this kind of task - filling in a required inspection early, and doing it in person because he wanted to. --- *Footnotes* ¹: Can, but not Must. If, however, things go bad, "just following the Captain's Orders" will NOT protect the senior watchstander when they came through. He and the Skipper will face charges side by side.
He just wanted to see the ship one more time, I think. Also, Chekov is still alive in the 24th Century as the head of Starfleet Intelligence (I think) & so is Uhura, who became an Admiral (in the novels) which makes sense as they were both relatively young during TOS (Chekov was fresh out of the Academy back then).
9,827
From [McCoy Memory Alpha](http://en.memory-alpha.org/wiki/Leonard_McCoy) > > On stardate 41153.7, the 137-year old Admiral Leonard McCoy inspected the USS Enterprise-D during its first mission. He commented on the great significance of the ship's name to Lieutenant Commander Data, telling Data "You treat her like a lady... and she'll always bring you home." (TNG: "Encounter at Farpoint") > > > ![enter image description here](https://i.stack.imgur.com/v6Pr6.jpg) **Why exactly would a medical doctor go inspect a new ship?** He wasn't a line officer (his "admiralty" was a special rank of "branch admiral". or an engineer, and Enterprise-D wasn't some marvel of medical technology. **Why would Dr. McCoy travel all the way to Deneb IV to do this?** I would prefer canon explanation (I don't have a better theory than "it may have been due to being the only surviving senior officer of NCC-1701/NCC-1701-A Enterprises", and as per comments, that theory is wrong).
2012/01/27
[ "https://scifi.stackexchange.com/questions/9827", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/976/" ]
According Leonard McCoy's memory beta wiki page, the novel Encounter at Farpoint explains how he got there and why he wasn't at the ship's launch: > > In 2363, McCoy suffered an injury after tripping over one of his > great-great-grandchildrens' toys which necessitated a stay at Bethesda > Starfleet Hospital, preventing him from attending the launch of the > USS Enterprise-D. In "revenge", McCoy connived the USS Hood to take > him to Farpoint Station, where they would be transferring crew to the > new Enterprise. McCoy inspected the ship's medical facilities of the > new ship, and was escorted back to the Hood, via shuttlecraft, by > Lieutenant Commander Data. McCoy told the young android the ship was > new but had the right name, and that if she was treated well she'd > always bring the crew home. (TNG novelization: Encounter at Farpoint) > > > References: [Encounter at Farpoint (Star Trek: The Next Generation)](http://rads.stackoverflow.com/amzn/click/0671652419) [Leonard McCoy @ Memory Beta](http://memory-beta.wikia.com/wiki/Leonard_McCoy) I haven't actually read the book, but if someone has a copy hopefully they can provide a more detailed answer.
He just wanted to see the ship one more time, I think. Also, Chekov is still alive in the 24th Century as the head of Starfleet Intelligence (I think) & so is Uhura, who became an Admiral (in the novels) which makes sense as they were both relatively young during TOS (Chekov was fresh out of the Academy back then).
2,257
I have been trying to develop solutions with ArcPad 10 Studio for a while now and finding it restrictive. I would like to use the Visual Studio environment to develop ArcPad 10 solutions (form development and coding). Does anyone know if this is possible?
2010/09/29
[ "https://gis.stackexchange.com/questions/2257", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/655/" ]
No, as far as I know you have to use the ArcPad Studio and are forced to deveop with VBScript or JScript.
It is possible to interact with ArcPad via a .NET application. Take a look at this developer sample from ESRI. I believe this is targeting ArcPad 8 but I would imagine the functionality still exists in ArcPad 10. <http://resources.arcgis.com/gallery/file/arcpad/details?entryID=03F8487A-1422-2418-342C-99098367450F> You can also find a .NET integration sample under the ArcPad install directory.
2,257
I have been trying to develop solutions with ArcPad 10 Studio for a while now and finding it restrictive. I would like to use the Visual Studio environment to develop ArcPad 10 solutions (form development and coding). Does anyone know if this is possible?
2010/09/29
[ "https://gis.stackexchange.com/questions/2257", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/655/" ]
I like to think of ArcPad customizers and ArcPad developers as two types of people with different workflows in ArcPad. ArcPad customizers are GIS integrators. They use ArcPad as an out of the box product and use the provided Quick Forms and ArcPad Studio to perform customization such as control placement of forms and perform rudimentary business rules such as input validation. At this level, customization is available by manipulating the layer form definition (i.e. APL / APX files) and encapsulating the business rules in your scripting language of choice (VBScript / JScript). The environment is rich so a lot of GIS projects can be delivered at this level of customization alone. ArcPad developers are developers who like to leverage their skills to extend ArcPad out of the box functionality. The development options fall into broad categories: * Developing ArcPad Extensions * Developing ActiveX / COM objects To build an ArcPad Extension, the developer is required to build a DLL with some expected entry points and placed them in a specific folder. How, where and why is covered in the documentation. Doing this will allow you to extend ArcPad's out of the box capabilities to make it support your prioprietory file format, GPS, Laser Range Finder, Projection method, Datum Transformation algorithm or leverage capabilities of your device's hardware or operating system. Traditionally, one would expect to do such customizations in native code C++ and you have the added benefit of leveraging from some UI elements from ArcPad in your extension such as ArcPad's Font Chooser and Symbology Chooser. Alternative, one can consider building an ActiveX / COM object. There are well known techniques on this. i.e. you can develop them in C++ using the ATL Project template, or you can develop them in .NET (can be C#, VB, ...) using the ComVisible setting. Either way, once registered, you can access these objects from ArcPad scripting in VBScript / JScript. This approach is quite a common approach in other scripting disciplines so it's not exclusive to ArcPad. i.e. you'll be able to use the same ActiveX / COM objects in other solutions, such as HTML, ASP, Windows Script Host, VBA and other ActiveX technologies. Both developing ArcPad Extensions or ActiveX / COM object allows developers to utilized their skills in their own environments for ArcPad. I'd say this approach is atypical for target ArcPad customizer end user. ArcPad Developers are more like consultants or 3rd party integrators who build such things either as a product of their core business or to support their core business.
It is possible to interact with ArcPad via a .NET application. Take a look at this developer sample from ESRI. I believe this is targeting ArcPad 8 but I would imagine the functionality still exists in ArcPad 10. <http://resources.arcgis.com/gallery/file/arcpad/details?entryID=03F8487A-1422-2418-342C-99098367450F> You can also find a .NET integration sample under the ArcPad install directory.
2,257
I have been trying to develop solutions with ArcPad 10 Studio for a while now and finding it restrictive. I would like to use the Visual Studio environment to develop ArcPad 10 solutions (form development and coding). Does anyone know if this is possible?
2010/09/29
[ "https://gis.stackexchange.com/questions/2257", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/655/" ]
No, as far as I know you have to use the ArcPad Studio and are forced to deveop with VBScript or JScript.
I like to think of ArcPad customizers and ArcPad developers as two types of people with different workflows in ArcPad. ArcPad customizers are GIS integrators. They use ArcPad as an out of the box product and use the provided Quick Forms and ArcPad Studio to perform customization such as control placement of forms and perform rudimentary business rules such as input validation. At this level, customization is available by manipulating the layer form definition (i.e. APL / APX files) and encapsulating the business rules in your scripting language of choice (VBScript / JScript). The environment is rich so a lot of GIS projects can be delivered at this level of customization alone. ArcPad developers are developers who like to leverage their skills to extend ArcPad out of the box functionality. The development options fall into broad categories: * Developing ArcPad Extensions * Developing ActiveX / COM objects To build an ArcPad Extension, the developer is required to build a DLL with some expected entry points and placed them in a specific folder. How, where and why is covered in the documentation. Doing this will allow you to extend ArcPad's out of the box capabilities to make it support your prioprietory file format, GPS, Laser Range Finder, Projection method, Datum Transformation algorithm or leverage capabilities of your device's hardware or operating system. Traditionally, one would expect to do such customizations in native code C++ and you have the added benefit of leveraging from some UI elements from ArcPad in your extension such as ArcPad's Font Chooser and Symbology Chooser. Alternative, one can consider building an ActiveX / COM object. There are well known techniques on this. i.e. you can develop them in C++ using the ATL Project template, or you can develop them in .NET (can be C#, VB, ...) using the ComVisible setting. Either way, once registered, you can access these objects from ArcPad scripting in VBScript / JScript. This approach is quite a common approach in other scripting disciplines so it's not exclusive to ArcPad. i.e. you'll be able to use the same ActiveX / COM objects in other solutions, such as HTML, ASP, Windows Script Host, VBA and other ActiveX technologies. Both developing ArcPad Extensions or ActiveX / COM object allows developers to utilized their skills in their own environments for ArcPad. I'd say this approach is atypical for target ArcPad customizer end user. ArcPad Developers are more like consultants or 3rd party integrators who build such things either as a product of their core business or to support their core business.
55,440,503
I am trying to make Selenium click upvote buttons on a reddit-like website. The site has entries from different users and each entry has a upvote and downvote button below it. What i want to do is to make Selenium click on the first upvote button ( which belongs to the entry at the top ) on the page. I tried to use "Copy XPath" function in Chrome, but all of the upvote buttons on the page return the same XPath: ``` //*[@id="eksico-chevron-up-thick"]/path ``` And this is how the website looks like if needed : [![enter image description here](https://i.stack.imgur.com/1HqbF.png)](https://i.stack.imgur.com/1HqbF.png) So, is there any way for finding the XPath of the first upvote button? I was thinking of something like: ``` //*[@id="eksico-chevron-up-thick"]/[1] ``` etc. Thanks in advance. Edit: The HTML Code of one of the upvote elements: [![enter image description here](https://i.stack.imgur.com/p1iRw.png)](https://i.stack.imgur.com/p1iRw.png)
2019/03/31
[ "https://Stackoverflow.com/questions/55440503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8125224/" ]
The element that you are trying to click is under `shadow dom` as mentioned in the html structure and currently selenium does not support operation on the elements under the shadow dom. Reference: <https://medium.com/rate-engineering/a-guide-to-working-with-shadow-dom-using-selenium-b124992559f> So, if you want to click on the element, you can use `JavaScriptExecutor` like: ``` WebElement element = driver.findElement(By.id("eksico-chevron-up-thick")); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", element); ``` By default, it will click on the first element itself and if you want to click on a specific nth element then you can take the elements in a list and then send the index of that element inside the method to get that element clicked.
If you want to click on the first one you could use `Driver.find_elements_by_xpath(//*[@id="eksico-chevron-up-thick"]/path)[1].click()`
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
In daily usage, people refer to someone as being "small" or "petty" to express the idea behind the "kleine" person you mention. In terms of the "große," I don't think there's a single word that encompasses all that you describe. I think instead, speakers normally apply something specific, or simply say "he/she is a leader." Sometimes you do hear someone say "That was big of you" when someone goes out of their way to do the right thing, but "he is a big person" only communicates something about his physical size. The term "great" is used so often that it becomes bland in most contexts. Occasionally, the term "the Great" is used to refer to people, but these are almost always famous people ("Alexander the Great").
A quick translation of "große Persönlichkeit" via translate.google.com yielded "Great Personality". From your description of what you are trying to convey, I believe that other terms could be "Uplifting Personality" or "Positive Influence".
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
What comes to my mind is "a person of great character" or "of noble character", where "[character](http://www.merriam-webster.com/dictionary/character)" has the meaning > > moral excellence and firmness > > > [This site](http://www.artofmanliness.com/2013/06/25/what-is-character-its-3-true-qualities-and-how-to-develop-it/) has some interesting reading on this meaning of the word: > > During the 1800s, “character was a key word in the vocabulary of > Englishmen and Americans,” and men were spoken of as having strong or > weak character, good or bad character, a great deal of character or no > character at all. Young people were admonished to cultivate real > character, high character, and noble character and told that character > was the most priceless thing they could ever attain. Starting at the > beginning of the 20th century, however, Susman found that the ideal of > character began to be replaced by that of personality. > > > "A person of [integrity](http://www.merriam-webster.com/dictionary/integrity)" would also work well, but personally I feel that something with "character" is better, as there is a sense that character is cultivated, and from a desire to generally be a good, noble, etc, person, whereas "integrity" can be an affectation.
In daily usage, people refer to someone as being "small" or "petty" to express the idea behind the "kleine" person you mention. In terms of the "große," I don't think there's a single word that encompasses all that you describe. I think instead, speakers normally apply something specific, or simply say "he/she is a leader." Sometimes you do hear someone say "That was big of you" when someone goes out of their way to do the right thing, but "he is a big person" only communicates something about his physical size. The term "great" is used so often that it becomes bland in most contexts. Occasionally, the term "the Great" is used to refer to people, but these are almost always famous people ("Alexander the Great").
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
You could also do *magnanimous* which is the older English adjective taken from Aristotle's account of the virtuous person. The new adjective in more recent translations is "great-hearted" man. Among the virtues Aristotle includes as requirements are social graces and forms of generosity that seem coterminable with what you are describing.
In daily usage, people refer to someone as being "small" or "petty" to express the idea behind the "kleine" person you mention. In terms of the "große," I don't think there's a single word that encompasses all that you describe. I think instead, speakers normally apply something specific, or simply say "he/she is a leader." Sometimes you do hear someone say "That was big of you" when someone goes out of their way to do the right thing, but "he is a big person" only communicates something about his physical size. The term "great" is used so often that it becomes bland in most contexts. Occasionally, the term "the Great" is used to refer to people, but these are almost always famous people ("Alexander the Great").
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
You might try to translate "große Persönlichket" as "gracious" person. You could possibly call them "grand" (but not *grandiose*). You might also call them "generous", though you would have to add context to clarify that you don't necessarily mean with money, but rather emotionally. When contrasting this behaviour with "petty" behaviour (typical of a *kleine Persönlichkeit*), you can say of someone with a *große Persönlichkeit* that they are "bigger" than that, or that they are a "bigger person" than that.
A quick translation of "große Persönlichkeit" via translate.google.com yielded "Great Personality". From your description of what you are trying to convey, I believe that other terms could be "Uplifting Personality" or "Positive Influence".
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
What comes to my mind is "a person of great character" or "of noble character", where "[character](http://www.merriam-webster.com/dictionary/character)" has the meaning > > moral excellence and firmness > > > [This site](http://www.artofmanliness.com/2013/06/25/what-is-character-its-3-true-qualities-and-how-to-develop-it/) has some interesting reading on this meaning of the word: > > During the 1800s, “character was a key word in the vocabulary of > Englishmen and Americans,” and men were spoken of as having strong or > weak character, good or bad character, a great deal of character or no > character at all. Young people were admonished to cultivate real > character, high character, and noble character and told that character > was the most priceless thing they could ever attain. Starting at the > beginning of the 20th century, however, Susman found that the ideal of > character began to be replaced by that of personality. > > > "A person of [integrity](http://www.merriam-webster.com/dictionary/integrity)" would also work well, but personally I feel that something with "character" is better, as there is a sense that character is cultivated, and from a desire to generally be a good, noble, etc, person, whereas "integrity" can be an affectation.
A quick translation of "große Persönlichkeit" via translate.google.com yielded "Great Personality". From your description of what you are trying to convey, I believe that other terms could be "Uplifting Personality" or "Positive Influence".
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
You could also do *magnanimous* which is the older English adjective taken from Aristotle's account of the virtuous person. The new adjective in more recent translations is "great-hearted" man. Among the virtues Aristotle includes as requirements are social graces and forms of generosity that seem coterminable with what you are describing.
A quick translation of "große Persönlichkeit" via translate.google.com yielded "Great Personality". From your description of what you are trying to convey, I believe that other terms could be "Uplifting Personality" or "Positive Influence".
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
What comes to my mind is "a person of great character" or "of noble character", where "[character](http://www.merriam-webster.com/dictionary/character)" has the meaning > > moral excellence and firmness > > > [This site](http://www.artofmanliness.com/2013/06/25/what-is-character-its-3-true-qualities-and-how-to-develop-it/) has some interesting reading on this meaning of the word: > > During the 1800s, “character was a key word in the vocabulary of > Englishmen and Americans,” and men were spoken of as having strong or > weak character, good or bad character, a great deal of character or no > character at all. Young people were admonished to cultivate real > character, high character, and noble character and told that character > was the most priceless thing they could ever attain. Starting at the > beginning of the 20th century, however, Susman found that the ideal of > character began to be replaced by that of personality. > > > "A person of [integrity](http://www.merriam-webster.com/dictionary/integrity)" would also work well, but personally I feel that something with "character" is better, as there is a sense that character is cultivated, and from a desire to generally be a good, noble, etc, person, whereas "integrity" can be an affectation.
You might try to translate "große Persönlichket" as "gracious" person. You could possibly call them "grand" (but not *grandiose*). You might also call them "generous", though you would have to add context to clarify that you don't necessarily mean with money, but rather emotionally. When contrasting this behaviour with "petty" behaviour (typical of a *kleine Persönlichkeit*), you can say of someone with a *große Persönlichkeit* that they are "bigger" than that, or that they are a "bigger person" than that.
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
You could also do *magnanimous* which is the older English adjective taken from Aristotle's account of the virtuous person. The new adjective in more recent translations is "great-hearted" man. Among the virtues Aristotle includes as requirements are social graces and forms of generosity that seem coterminable with what you are describing.
You might try to translate "große Persönlichket" as "gracious" person. You could possibly call them "grand" (but not *grandiose*). You might also call them "generous", though you would have to add context to clarify that you don't necessarily mean with money, but rather emotionally. When contrasting this behaviour with "petty" behaviour (typical of a *kleine Persönlichkeit*), you can say of someone with a *große Persönlichkeit* that they are "bigger" than that, or that they are a "bigger person" than that.
149,889
I'm looking for the appropriate English term for what I'd call a "große Persönlichkeit" in German. * This is *not* about someone who is famous, * neither about someone who tries to appear superior than others by making them small * but means someone who is wise, reflected, (possibly brave), emotionally stable and independent (in the positive sense), superior (in a way that doesn't oppress but rather the opposite) and has a good influence on other people, also by being a good example * This rough translation of a more or less idiomatic rule of thumb may also help to explain: A "große Persönlichket" will help other people to grow, while a "kleine Persönlichkeit" (small? personality?) will keep people down/small(?)/oppress people in order to seem larger (?) Actually the last point is the context I want to explain in English. I'm really unsure which of the "groß" (great/large/big/?) terms is appropriate and whether to use personality or character or something else.
2014/02/04
[ "https://english.stackexchange.com/questions/149889", "https://english.stackexchange.com", "https://english.stackexchange.com/users/27352/" ]
What comes to my mind is "a person of great character" or "of noble character", where "[character](http://www.merriam-webster.com/dictionary/character)" has the meaning > > moral excellence and firmness > > > [This site](http://www.artofmanliness.com/2013/06/25/what-is-character-its-3-true-qualities-and-how-to-develop-it/) has some interesting reading on this meaning of the word: > > During the 1800s, “character was a key word in the vocabulary of > Englishmen and Americans,” and men were spoken of as having strong or > weak character, good or bad character, a great deal of character or no > character at all. Young people were admonished to cultivate real > character, high character, and noble character and told that character > was the most priceless thing they could ever attain. Starting at the > beginning of the 20th century, however, Susman found that the ideal of > character began to be replaced by that of personality. > > > "A person of [integrity](http://www.merriam-webster.com/dictionary/integrity)" would also work well, but personally I feel that something with "character" is better, as there is a sense that character is cultivated, and from a desire to generally be a good, noble, etc, person, whereas "integrity" can be an affectation.
You could also do *magnanimous* which is the older English adjective taken from Aristotle's account of the virtuous person. The new adjective in more recent translations is "great-hearted" man. Among the virtues Aristotle includes as requirements are social graces and forms of generosity that seem coterminable with what you are describing.
11,010,591
I have many many files in a folder, and I want to process them one after another, I need to have a global dictionary to record the user identifier and the flowcount, but if my code is like this, when the second or third file is processed, the user\_dict for last file will lose. Because if an user id in the second file is as same as in the first file, then if should be assigned the same flowcount instead of a new one, how can I make one dictionary keep growing when open files one by one? ``` for line in fd.readlines(): obj = json.loads(line) user = obj["host_dst"]["addr"] + '_' + str(obj["host_dst"]["port"]) if user not in user_dict: user_dict[user] = [] user_dict[user].append(obj["params"]["flowcount"]) ``` Since the size of each file is very big, I merged them all into one file, then ran the script to process, the computer will kill the process after a while, I have to process them one by one instead
2012/06/13
[ "https://Stackoverflow.com/questions/11010591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/504283/" ]
You can open multiple files in your python script, and use your for loop to take care each of them ``` for filename in os.listdir(folderpath): filepath = os.path.join(folderpath, filename) fd = open(filepath, 'r') # here is your code for line in fd.readlines(): .... ```
You can always declare ``` global user_dict ``` in your code... But is this the best approach? Maybe you should use a class: ``` class FileProcessor(object): def __init__(self): self.user_dict = dict() def process_file(file_name): .... self.user_dict[]... ``` and then: ``` processor = FileProcessor() for file in files: processor.process_file(file) ```
7,268,772
``` class base {}; class der : public base{}; der d1; der d2(d1); ``` This statement invokes default constructor of class base then copy constructor of claas der. My question is why C++ has not provided the feature of calling copy constructor of base class while creating object of derive class by copying another object of derive class
2011/09/01
[ "https://Stackoverflow.com/questions/7268772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/923236/" ]
Short version ------------- > > This statement invokes default constructor of class base then copy constructor of claas der. > > > No, it doesn't. > > My question is why C++ has not provided the feature of calling copy constructor of base class while creating object of derive class by copying another object of derive class > > > It does. --- Long(er) version ---------------- I don't know how you came to the conclusion that the base default constructor is invoked during the construction of `d2`, but it is not. The synthesised base copy constructor *is* invoked, as you expect. This is [really easy to test](http://codepad.org/tuFLFZDe): ``` struct base { base() { cout << "*B"; } base(base const& b) { cout << "!B"; } ~base() { cout << "~B"; } }; struct der : base {}; int main() { der d1; der d2(d1); } // Output: *B!B~B~B ```
> > This statement invokes default constructor of class base then copy constructor of claas der. > > > No it does not. The first line invokes the default construct of class `der`, which invokes the default constructor of class `base`. The second line invokes the copy constructor of class `der`, because you're copying one `der` instance to another.
7,268,772
``` class base {}; class der : public base{}; der d1; der d2(d1); ``` This statement invokes default constructor of class base then copy constructor of claas der. My question is why C++ has not provided the feature of calling copy constructor of base class while creating object of derive class by copying another object of derive class
2011/09/01
[ "https://Stackoverflow.com/questions/7268772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/923236/" ]
Short version ------------- > > This statement invokes default constructor of class base then copy constructor of claas der. > > > No, it doesn't. > > My question is why C++ has not provided the feature of calling copy constructor of base class while creating object of derive class by copying another object of derive class > > > It does. --- Long(er) version ---------------- I don't know how you came to the conclusion that the base default constructor is invoked during the construction of `d2`, but it is not. The synthesised base copy constructor *is* invoked, as you expect. This is [really easy to test](http://codepad.org/tuFLFZDe): ``` struct base { base() { cout << "*B"; } base(base const& b) { cout << "!B"; } ~base() { cout << "~B"; } }; struct der : base {}; int main() { der d1; der d2(d1); } // Output: *B!B~B~B ```
The compiler-generated copy-constructor will invoke the copy constructor of the base class. You have probably added a user-defined copy constructor for `der`. In such a case you must explicitly invoke the copy constructor of the base class. ``` der::der(const der& other): base(other), ... {} ```
7,268,772
``` class base {}; class der : public base{}; der d1; der d2(d1); ``` This statement invokes default constructor of class base then copy constructor of claas der. My question is why C++ has not provided the feature of calling copy constructor of base class while creating object of derive class by copying another object of derive class
2011/09/01
[ "https://Stackoverflow.com/questions/7268772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/923236/" ]
Short version ------------- > > This statement invokes default constructor of class base then copy constructor of claas der. > > > No, it doesn't. > > My question is why C++ has not provided the feature of calling copy constructor of base class while creating object of derive class by copying another object of derive class > > > It does. --- Long(er) version ---------------- I don't know how you came to the conclusion that the base default constructor is invoked during the construction of `d2`, but it is not. The synthesised base copy constructor *is* invoked, as you expect. This is [really easy to test](http://codepad.org/tuFLFZDe): ``` struct base { base() { cout << "*B"; } base(base const& b) { cout << "!B"; } ~base() { cout << "~B"; } }; struct der : base {}; int main() { der d1; der d2(d1); } // Output: *B!B~B~B ```
Copy constructor of the derived class call the default constructor of the base class. Below sample programs demonstrates the same. ``` #include <iostream> using namespace std; class Base { public: Base(){ cout<<"Base"<<endl; } Base(int i){ cout<<"Base int "<<endl; } Base(const Base& obj){ cout<<"Base CC"<<endl; } }; class Derv : public Base { public: Derv(){ cout<<"Derv"<<endl; } Derv(int i){ cout<<"Derv int "<<endl; } Derv(const Derv& obj){ cout<<"Derv CC"<<endl; } }; int main() { Derv d1 = 2; Derv d2 = d1; // Calls the copy constructor return 0; } ```
64,398,870
[![enter image description here](https://i.stack.imgur.com/MhlLM.png)](https://i.stack.imgur.com/MhlLM.png) I bought a complete app but when I install it in my own environment then it gets back this error.
2020/10/17
[ "https://Stackoverflow.com/questions/64398870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11856004/" ]
> > Try upgrading from expo sdk 37 to expo sdk 38 by running expo upgrade > > > Looks like there is an open issue on Github. Try this: [Invariant Violation: Native module cannot be null](https://github.com/react-native-push-notification-ios/push-notification-ios/issues/43)
(I already solved this problem to move my file into a new project). But now I'm fetching a new error. I already replace all ListView component with FlatList, and also I have no Icon or Spinner that's I import from react-native or native-base. But it's getting back this error. [![enter image description here](https://i.stack.imgur.com/Qb7kM.png)](https://i.stack.imgur.com/Qb7kM.png)
43,223,483
I'm trying to change the background colour of a main activity when an item from a pop up menu in a sub-activity is selected. However, when I run the app and choose said item, the app crashes. This is the sub-activity code: ``` public class Modify extends AppCompatActivity { Button button, submit; EditText edit; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.modify); button = (Button) findViewById(R.id.button); submit = (Button) findViewById(R.id.submit); edit = (EditText) findViewById(R.id.editText); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu pop = new PopupMenu(Modify.this, button); pop.getMenuInflater().inflate(R.menu.menu,pop.getMenu()); pop.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){ @Override public boolean onMenuItemClick(MenuItem item){ Intent i = new Intent(Modify.this, MainActivity.class); switch (item.getItemId()){ case R.id.red: i.putExtra("color","red"); break; //TODO add more colours default: return false; } return true; } }); pop.show(); } }); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String message = edit.getText().toString(); Intent intent = new Intent(); intent.putExtra("MESSAGE", message); setResult(2, intent); finish(); } }); } } ``` I'm not really sure if the intents I declare on each case are actually getting back to the changeBackground method in the Main Activity: ``` public class MainActivity extends AppCompatActivity { //GLOBALS TextView txt; Button btn; RelativeLayout rel; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txt = (TextView) findViewById(R.id.Text); btn = (Button) findViewById(R.id.Btn); rel = (RelativeLayout) findViewById(R.id.activity_main); Intent intent = getIntent(); String color = intent.getStringExtra("color"); changeBackground(color); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //ON CLICK SETS INTENT Intent intent = new Intent(MainActivity.this, Modify.class); //INTENT STARTS ACTIVITY 2 startActivityForResult(intent, 2); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 2) { //SET TEXT WHEN RESULT IS ACCEPTED String message = data.getStringExtra("MESSAGE"); txt.setText(message); } } public void changeBackground(String color) { if (color.equals("red")) { rel.setBackgroundColor(Color.RED); } else if (color.equals("green")) { rel.setBackgroundColor(Color.GREEN); } else if (color.equals("blue")) { rel.setBackgroundColor(Color.BLUE); } } } ```
2017/04/05
[ "https://Stackoverflow.com/questions/43223483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1790030/" ]
babel is a transpiler, webpack is a bundler and yarn (or npm) is a package manager. These tools are for different purposes. And usually we use *all* of them together. React has a very handy tool called [Create React App](https://github.com/facebookincubator/create-react-app). With this tool you don't need to configure babel and webpack by yourself so you can start to learn React easily.
This is best place to start up with ReactJS > > In older versions you need to setup react with babel and webpack but now on current latest version you can directly start with [Create React App](https://github.com/facebookincubator/create-react-app) > > > [ReactJS Installation and startup guide](https://reactjs.org/docs/try-react.html) Just follows steps on this page, then run HelloWorld example which is best programs to start with any new programming language.
43,223,483
I'm trying to change the background colour of a main activity when an item from a pop up menu in a sub-activity is selected. However, when I run the app and choose said item, the app crashes. This is the sub-activity code: ``` public class Modify extends AppCompatActivity { Button button, submit; EditText edit; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.modify); button = (Button) findViewById(R.id.button); submit = (Button) findViewById(R.id.submit); edit = (EditText) findViewById(R.id.editText); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu pop = new PopupMenu(Modify.this, button); pop.getMenuInflater().inflate(R.menu.menu,pop.getMenu()); pop.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){ @Override public boolean onMenuItemClick(MenuItem item){ Intent i = new Intent(Modify.this, MainActivity.class); switch (item.getItemId()){ case R.id.red: i.putExtra("color","red"); break; //TODO add more colours default: return false; } return true; } }); pop.show(); } }); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String message = edit.getText().toString(); Intent intent = new Intent(); intent.putExtra("MESSAGE", message); setResult(2, intent); finish(); } }); } } ``` I'm not really sure if the intents I declare on each case are actually getting back to the changeBackground method in the Main Activity: ``` public class MainActivity extends AppCompatActivity { //GLOBALS TextView txt; Button btn; RelativeLayout rel; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txt = (TextView) findViewById(R.id.Text); btn = (Button) findViewById(R.id.Btn); rel = (RelativeLayout) findViewById(R.id.activity_main); Intent intent = getIntent(); String color = intent.getStringExtra("color"); changeBackground(color); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //ON CLICK SETS INTENT Intent intent = new Intent(MainActivity.this, Modify.class); //INTENT STARTS ACTIVITY 2 startActivityForResult(intent, 2); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 2) { //SET TEXT WHEN RESULT IS ACCEPTED String message = data.getStringExtra("MESSAGE"); txt.setText(message); } } public void changeBackground(String color) { if (color.equals("red")) { rel.setBackgroundColor(Color.RED); } else if (color.equals("green")) { rel.setBackgroundColor(Color.GREEN); } else if (color.equals("blue")) { rel.setBackgroundColor(Color.BLUE); } } } ```
2017/04/05
[ "https://Stackoverflow.com/questions/43223483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1790030/" ]
babel is a transpiler, webpack is a bundler and yarn (or npm) is a package manager. These tools are for different purposes. And usually we use *all* of them together. React has a very handy tool called [Create React App](https://github.com/facebookincubator/create-react-app). With this tool you don't need to configure babel and webpack by yourself so you can start to learn React easily.
You can start working with react using [create react app](https://github.com/facebookincubator/create-react-app)(along with official [react documentation](https://facebook.github.io/react/)) which will provide you app structure with no build configuration. So there is no need to worry about babel, webpack. you will get all configured with proper documentation. It's up to you to use yarn or npm as package manager.
65,484,212
It looks like if I place a `FlatButton.icon` under the `body` of a `Scaffold`, then its `onPressed` almost never gets called? Are there any bugs associated with `FlatButton.icon`'s `onPressed` call? Following is my **code:** ``` // My main.dart import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), routes: { '/': (context) => Loading(), '/home': (context) => Home(), }, ); } } class Loading extends StatefulWidget { @override _LoadingState createState() => _LoadingState(); } class _LoadingState extends State<Loading> { @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { Navigator.of(context).pushReplacementNamed('/home'); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Loading screen'), ), ); } } class Home extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Home'), ), body: Center( child: FlatButton.icon( icon: Icon(Icons.arrow_right, size: 60.0), label: Text('press', style: TextStyle(fontSize: 40.0)), onPressed: () { // This almost never gets called. I have to press a lot many times to get the below print statement to execute. print('Button pressed to go to location widget'); Navigator.pushReplacementNamed(context, '/'); }, ), ), ); } } ``` **Question:** The issue is that `FlatButton`'s `onPressed` ***almost never gets called in above code***. It does get called if I press the button many times. Very strange! What am I dong wrong above? Is there something I am doing which is discouraged in Flutter? **Environment:** * macOS Big Sur. * Output of running `flutter --version` is: > > Flutter 1.26.0-1.0.pre • channel dev • > <https://github.com/flutter/flutter.git> Framework • revision 63062a6443 > (2 weeks ago) • 2020-12-13 23:19:13 +0800 Engine • revision 4797b06652 > Tools • Dart 2.12.0 (build 2.12.0-141.0.dev) > > > **EDIT:** @Alwin Brauns suggested below that `FlatButton` is obsolete and to use a `TextButton` instead. This is good information but using a `TextButton` also ends up with the same problem.
2020/12/28
[ "https://Stackoverflow.com/questions/65484212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6626554/" ]
Try changing the method in `DrawingPanel` from `painting` to `paint`, which will get called when run. `paint` is a method inherited from `JPanel`. Edit: As mentioned by [NomadMaker](https://stackoverflow.com/users/9732672/nomadmaker), use `paintComponent()` not `paint()` here. Read [this](https://stackoverflow.com/questions/15103553/difference-between-paint-and-paintcomponent) for more information.
You should override paintComponent like so: ``` ... @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D pen = (Graphics2D) g; ... } ``` Also some suggestions: * You can extending `JComponent` instead of `JPanel` (It should work both ways) * You can use `setSize` or `setPreferredSize` for your `panel` to fit it with your frame size. * You can only use `setVisisble(true);` only once after all of the configurations of your frame. * And add it to the center of the frame like so: ``` ... JFrame frame = new JFrame(); frame.setSize(350, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("My Empty Window"); DrawingPanel panel = new DrawingPanel(); panel.setPreferredSize(new Dimensions(350, 300)); frame.add(panel, BorderLayout.CENTER); frame.setVisible(true); ... ``` On a side note: Adding a layout manager may not be necessary and you can also replace `setPreferredSize` with `setBounds` like so: ``` panel.setBounds(0, 0, 350, 300); frame.add(panel); ``` Where 0s are x and y coordinates respectively.
65,484,212
It looks like if I place a `FlatButton.icon` under the `body` of a `Scaffold`, then its `onPressed` almost never gets called? Are there any bugs associated with `FlatButton.icon`'s `onPressed` call? Following is my **code:** ``` // My main.dart import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), routes: { '/': (context) => Loading(), '/home': (context) => Home(), }, ); } } class Loading extends StatefulWidget { @override _LoadingState createState() => _LoadingState(); } class _LoadingState extends State<Loading> { @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { Navigator.of(context).pushReplacementNamed('/home'); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Loading screen'), ), ); } } class Home extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Home'), ), body: Center( child: FlatButton.icon( icon: Icon(Icons.arrow_right, size: 60.0), label: Text('press', style: TextStyle(fontSize: 40.0)), onPressed: () { // This almost never gets called. I have to press a lot many times to get the below print statement to execute. print('Button pressed to go to location widget'); Navigator.pushReplacementNamed(context, '/'); }, ), ), ); } } ``` **Question:** The issue is that `FlatButton`'s `onPressed` ***almost never gets called in above code***. It does get called if I press the button many times. Very strange! What am I dong wrong above? Is there something I am doing which is discouraged in Flutter? **Environment:** * macOS Big Sur. * Output of running `flutter --version` is: > > Flutter 1.26.0-1.0.pre • channel dev • > <https://github.com/flutter/flutter.git> Framework • revision 63062a6443 > (2 weeks ago) • 2020-12-13 23:19:13 +0800 Engine • revision 4797b06652 > Tools • Dart 2.12.0 (build 2.12.0-141.0.dev) > > > **EDIT:** @Alwin Brauns suggested below that `FlatButton` is obsolete and to use a `TextButton` instead. This is good information but using a `TextButton` also ends up with the same problem.
2020/12/28
[ "https://Stackoverflow.com/questions/65484212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6626554/" ]
Here's what I get after making your code runnable, fixing your `JFrame` method calls and fixing your drawing `JPanel`. [![Image GUI](https://i.stack.imgur.com/BHkI0.png)](https://i.stack.imgur.com/BHkI0.png) Swing applications should always start with a call to the `SwingUtilities` `invokeLater` method. This method ensures that the Swing components are created and executed on the [Event Dispatch Thread](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html). You pack a `JFrame`. You set the preferred size of your drawing `JPanel`. This way, you know how big your drawing `JPanel` is, without worrying about the `JFrame` decorations. Here's the complete runnable code. ``` import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class DrawingPanelExample implements Runnable { public static void main(String[] args) { SwingUtilities.invokeLater(new DrawingPanelExample()); } @Override public void run() { JFrame frame = new JFrame("My Empty Window"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DrawingPanel panel = new DrawingPanel(); frame.add(panel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); } public class DrawingPanel extends JPanel { private static final long serialVersionUID = 1L; public DrawingPanel() { this.setPreferredSize(new Dimension(350, 300)); } @Override protected void paintComponent(Graphics pen) { super.paintComponent(pen); pen.drawRect(50, 50, 20, 20); pen.drawRect(100, 50, 40, 20); pen.drawOval(200, 50, 20, 20); pen.drawOval(250, 50, 40, 20); pen.drawString("Square", 50, 90); pen.drawString("Rectangle", 100, 90); pen.drawString("Cirlce", 200, 90); pen.drawString("Oval", 250, 90); pen.fillRect(50, 100, 20, 20); pen.fillRect(100, 100, 40, 20); pen.fillOval(250, 100, 20, 20); pen.fillOval(250, 100, 40, 20); pen.drawLine(50, 150, 300, 150); pen.drawArc(50, 150, 200, 100, 0, 180); pen.fillArc(100, 175, 200, 75, 90, 45); } } } ```
You should override paintComponent like so: ``` ... @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D pen = (Graphics2D) g; ... } ``` Also some suggestions: * You can extending `JComponent` instead of `JPanel` (It should work both ways) * You can use `setSize` or `setPreferredSize` for your `panel` to fit it with your frame size. * You can only use `setVisisble(true);` only once after all of the configurations of your frame. * And add it to the center of the frame like so: ``` ... JFrame frame = new JFrame(); frame.setSize(350, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("My Empty Window"); DrawingPanel panel = new DrawingPanel(); panel.setPreferredSize(new Dimensions(350, 300)); frame.add(panel, BorderLayout.CENTER); frame.setVisible(true); ... ``` On a side note: Adding a layout manager may not be necessary and you can also replace `setPreferredSize` with `setBounds` like so: ``` panel.setBounds(0, 0, 350, 300); frame.add(panel); ``` Where 0s are x and y coordinates respectively.
14,714,416
I need to make a request to a page on a different domain when a user clicks a link in order to keep the session alive on that domain. I don't care about the response data (except *maybe* the status code so I can make sure the page hasn't gone down). I tried issuing a request via `$.ajax` but the same-origin policy is disallowing it. What's the best way to make request go through? Should I write an iframe to my page? A script tag? Is there an option in `$.ajax` that will make it work? **Edit:** I also need to know when the request gone through so that I can do some stuff afterwards (i.e., I'd like a callback). --- Adding `dataType: 'jsonp'` sort of makes it work, except that I don't want it to execute whatever the site returns, which it seems to do. The page I'm requesting is a regular old HTML page, but it triggers some stuff on their server that keeps the session alive.
2013/02/05
[ "https://Stackoverflow.com/questions/14714416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65387/" ]
You can send request using Image "class": ``` var img = new Image(); img.onerror = img.onload = function() { console.log('Sended') } img.src = "http://google.com?hey=google&rnd=" + Math.random() // random is used to prevent caching ``` But unless response isn't a picture, you'll not get any information about resource availability. Also, I'm not sure if this solution is cross-browser. It seems to work in recent Opera and Chrome, but I haven't tested it in any other browser. BTW, this image approach seems to be the only one that is safe. If you include scripts or load iframes, they could do something evil with your page, while simple image stays harmless.
This seems to work: ``` $('#myelement').on('click',function() { $('<iframe>', {src:'http://otherdomain.com/page'}).hide().load(function() { $(this).remove(); //clean up the DOM // do stuff }).appendTo('body'); }); ```
67,091,717
Similar: [writing a data.frame using cat](https://stackoverflow.com/questions/25511282/writing-a-data-frame-using-cat) however this is about appending to a file, I want to write a new file. I have a header, and a dataframe which I want to write to a file using cat(): ``` header <- "This is the top row,\n where the values are:" df <- data.frame(val1= runif(3), val2 = runif(3)) # Write to file cat(header, df, file = "path/to/file.txt", sep = "\n") ``` Gives an error: ``` Error in cat(header, df, file = "path/to/file.txt", sep = "\n") : argument 2 (type 'list') cannot be handled by 'cat' ``` It says list, but class(df) shows that it is a dataframe, and I have made this dataframe basically the same way as above. How would I print it so it would look something like this (df separated by any sort of whitespace): file.txt: ``` This is the top row where the values are: 0.63138 0.70402 0.50136 0.61327 0.10447 0.26874 ... ``` The full file can go up to a dataframe of 101 lines.
2021/04/14
[ "https://Stackoverflow.com/questions/67091717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7919144/" ]
You can use `cat` with `write.table`. ``` header <- "This is the top row,\n where the header info is.\n" cat(header, file = 'file.txt') write.table(df, 'file.txt', append = TRUE, row.names = FALSE, col.names = FALSE) ```
Give this a crack: ``` cat( paste0( header, paste0( trimws( gsub( "^\\d+", "", capture.output( print( df ) ) ), "left"), collapse = "\n") ), file = "path/to/file.txt", sep = "\n") ``` Data: ``` header <- "This is the top row, \n where the header info is.\n\n" df <- data.frame(val1= runif(3), val2 = runif(3)) ```
67,091,717
Similar: [writing a data.frame using cat](https://stackoverflow.com/questions/25511282/writing-a-data-frame-using-cat) however this is about appending to a file, I want to write a new file. I have a header, and a dataframe which I want to write to a file using cat(): ``` header <- "This is the top row,\n where the values are:" df <- data.frame(val1= runif(3), val2 = runif(3)) # Write to file cat(header, df, file = "path/to/file.txt", sep = "\n") ``` Gives an error: ``` Error in cat(header, df, file = "path/to/file.txt", sep = "\n") : argument 2 (type 'list') cannot be handled by 'cat' ``` It says list, but class(df) shows that it is a dataframe, and I have made this dataframe basically the same way as above. How would I print it so it would look something like this (df separated by any sort of whitespace): file.txt: ``` This is the top row where the values are: 0.63138 0.70402 0.50136 0.61327 0.10447 0.26874 ... ``` The full file can go up to a dataframe of 101 lines.
2021/04/14
[ "https://Stackoverflow.com/questions/67091717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7919144/" ]
Give this a crack: ``` cat( paste0( header, paste0( trimws( gsub( "^\\d+", "", capture.output( print( df ) ) ), "left"), collapse = "\n") ), file = "path/to/file.txt", sep = "\n") ``` Data: ``` header <- "This is the top row, \n where the header info is.\n\n" df <- data.frame(val1= runif(3), val2 = runif(3)) ```
`kable` can format the data frame and return a vector that `cat` can write to a file. It can also do the desired rounding and alignment. ``` library(knitr) # store the header text as a vector for better spacing header <- c("This is the top row", "where the header info is.") df <- data.frame(val1= runif(3), val2 = runif(3)) # convert the data frame into a simple markdown text table text <- kable(df, digits = 5, format = "simple", col.names = NULL) # remove the extra markdown formatting text <- text[!grepl("---", text)] # write to your file cat(header, text, sep = "\n", file = "path/to/file.txt") ``` The result will contain ``` This is the top row, where the header info is. 0.23796 0.20287 0.67260 0.41703 0.53092 0.26330 ```
67,091,717
Similar: [writing a data.frame using cat](https://stackoverflow.com/questions/25511282/writing-a-data-frame-using-cat) however this is about appending to a file, I want to write a new file. I have a header, and a dataframe which I want to write to a file using cat(): ``` header <- "This is the top row,\n where the values are:" df <- data.frame(val1= runif(3), val2 = runif(3)) # Write to file cat(header, df, file = "path/to/file.txt", sep = "\n") ``` Gives an error: ``` Error in cat(header, df, file = "path/to/file.txt", sep = "\n") : argument 2 (type 'list') cannot be handled by 'cat' ``` It says list, but class(df) shows that it is a dataframe, and I have made this dataframe basically the same way as above. How would I print it so it would look something like this (df separated by any sort of whitespace): file.txt: ``` This is the top row where the values are: 0.63138 0.70402 0.50136 0.61327 0.10447 0.26874 ... ``` The full file can go up to a dataframe of 101 lines.
2021/04/14
[ "https://Stackoverflow.com/questions/67091717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7919144/" ]
You can use `cat` with `write.table`. ``` header <- "This is the top row,\n where the header info is.\n" cat(header, file = 'file.txt') write.table(df, 'file.txt', append = TRUE, row.names = FALSE, col.names = FALSE) ```
`kable` can format the data frame and return a vector that `cat` can write to a file. It can also do the desired rounding and alignment. ``` library(knitr) # store the header text as a vector for better spacing header <- c("This is the top row", "where the header info is.") df <- data.frame(val1= runif(3), val2 = runif(3)) # convert the data frame into a simple markdown text table text <- kable(df, digits = 5, format = "simple", col.names = NULL) # remove the extra markdown formatting text <- text[!grepl("---", text)] # write to your file cat(header, text, sep = "\n", file = "path/to/file.txt") ``` The result will contain ``` This is the top row, where the header info is. 0.23796 0.20287 0.67260 0.41703 0.53092 0.26330 ```
1,181,664
I installed Ubuntu 19.04 on an HP Spectre x360 with 4k Oled Display. Many issues I've encountered with the screen (such as not being able to tweak its screen brightness the usual way and instead needing to set it via command line) but now I see that I'm not able to adjust the screen brightness while keeping Night Light turned ON. What I do: 1. Turn on Night Light via GUI and it works. 2. Lower the screen brightness by running: ``` xrandr --output eDP1 --brightness 0.8 ``` 3. The brightness gets lowered and the color of the screen resets to default, even though Night Light still shows to be turned ON. 4. Get back to Night Light preferences, move the Color Temperature slider and Night Light gets back in command of my screen, changing its color hue but resetting its brightness to 100%. I work really long hours with this machine, so I really need to be able to have both things working at the same time since this is taking a toll on my sight. I hope someone can help me with this!
2019/10/17
[ "https://askubuntu.com/questions/1181664", "https://askubuntu.com", "https://askubuntu.com/users/918140/" ]
I control this using the Gnome Extension Adjust Brightness Icon [![enter image description here](https://i.stack.imgur.com/2oP7o.png)](https://i.stack.imgur.com/2oP7o.png) This places a lightbulb icon on the top bar which, when you click on it adjusts the screen brightness in steps. The cycle is 4 steps; the 4th step returning the screen to it's native state. If you are not certain about installing Gnome Extensions Navigate your Firefox browser to <https://extensions.gnome.org/> and simply search for Adjust Brightness Icon extension. Flip the ON switch to install the extension. Complete the installation of the extension by clicking on the ON switch then click Install to confirm.
Eyesome ======= If you can't solve the problem, I wrote a bash script called [eyesome](https://askubuntu.com/questions/829814/set-initial-startup-background-brightness-depending-on-daytime/887249#887249) that lets you control brightness and color temperature (gamma) at the same time. Additional benefits: * Define three monitors with different settings * Override two monitors (blank on inactivity) when watching movie on a third TV * Gradually increase in unnoticeable steps at dusk and dawn * In use longer than Gnome Night Light (granted not as many users) Sample screen ============= [![eyesome monitor 3.png](https://i.stack.imgur.com/ebHpy.png)](https://i.stack.imgur.com/ebHpy.png)
1,181,664
I installed Ubuntu 19.04 on an HP Spectre x360 with 4k Oled Display. Many issues I've encountered with the screen (such as not being able to tweak its screen brightness the usual way and instead needing to set it via command line) but now I see that I'm not able to adjust the screen brightness while keeping Night Light turned ON. What I do: 1. Turn on Night Light via GUI and it works. 2. Lower the screen brightness by running: ``` xrandr --output eDP1 --brightness 0.8 ``` 3. The brightness gets lowered and the color of the screen resets to default, even though Night Light still shows to be turned ON. 4. Get back to Night Light preferences, move the Color Temperature slider and Night Light gets back in command of my screen, changing its color hue but resetting its brightness to 100%. I work really long hours with this machine, so I really need to be able to have both things working at the same time since this is taking a toll on my sight. I hope someone can help me with this!
2019/10/17
[ "https://askubuntu.com/questions/1181664", "https://askubuntu.com", "https://askubuntu.com/users/918140/" ]
I control this using the Gnome Extension Adjust Brightness Icon [![enter image description here](https://i.stack.imgur.com/2oP7o.png)](https://i.stack.imgur.com/2oP7o.png) This places a lightbulb icon on the top bar which, when you click on it adjusts the screen brightness in steps. The cycle is 4 steps; the 4th step returning the screen to it's native state. If you are not certain about installing Gnome Extensions Navigate your Firefox browser to <https://extensions.gnome.org/> and simply search for Adjust Brightness Icon extension. Flip the ON switch to install the extension. Complete the installation of the extension by clicking on the ON switch then click Install to confirm.
if you look in the app store you will find OLED Dimmer. It works with dell xps 15 7590 and Ubuntu 19.10. I would imagine it would work with your system too but cannot say for sure,
1,181,664
I installed Ubuntu 19.04 on an HP Spectre x360 with 4k Oled Display. Many issues I've encountered with the screen (such as not being able to tweak its screen brightness the usual way and instead needing to set it via command line) but now I see that I'm not able to adjust the screen brightness while keeping Night Light turned ON. What I do: 1. Turn on Night Light via GUI and it works. 2. Lower the screen brightness by running: ``` xrandr --output eDP1 --brightness 0.8 ``` 3. The brightness gets lowered and the color of the screen resets to default, even though Night Light still shows to be turned ON. 4. Get back to Night Light preferences, move the Color Temperature slider and Night Light gets back in command of my screen, changing its color hue but resetting its brightness to 100%. I work really long hours with this machine, so I really need to be able to have both things working at the same time since this is taking a toll on my sight. I hope someone can help me with this!
2019/10/17
[ "https://askubuntu.com/questions/1181664", "https://askubuntu.com", "https://askubuntu.com/users/918140/" ]
Eyesome ======= If you can't solve the problem, I wrote a bash script called [eyesome](https://askubuntu.com/questions/829814/set-initial-startup-background-brightness-depending-on-daytime/887249#887249) that lets you control brightness and color temperature (gamma) at the same time. Additional benefits: * Define three monitors with different settings * Override two monitors (blank on inactivity) when watching movie on a third TV * Gradually increase in unnoticeable steps at dusk and dawn * In use longer than Gnome Night Light (granted not as many users) Sample screen ============= [![eyesome monitor 3.png](https://i.stack.imgur.com/ebHpy.png)](https://i.stack.imgur.com/ebHpy.png)
if you look in the app store you will find OLED Dimmer. It works with dell xps 15 7590 and Ubuntu 19.10. I would imagine it would work with your system too but cannot say for sure,
33,766,296
EDIT 2: I got the solution. Anytime someone wants the code I'd be happy to provide. Peace. Topic: I'm trying an experiment of echoing strings that I receive in my arduino. So this is the code so far: ``` byte byteRead = 0; bool readable = LOW; char fullString[50]; int index = 0; void setup() { Serial.begin(9600); } void loop() { // State 1 if (Serial.available()) { readable = HIGH; // flag to enter in the next state when there's nothing else to read byteRead = Serial.read(); fullString[index] = (char)byteRead; index++; } // State 2 if (readable == HIGH && !Serial.available()){ fullString[index] = '\0'; // '\0' to terminate the string Serial.println(fullString); // resets variables index = 0; readable = LOW; } /** * Somehow a delay prevents characters of the string from having * a line printed between them. * Anyways, when the string is too long, a line is printed between * the first and second characters */ delay(5); } ``` Somehow this delay in the end prevents the characters of the string from having a line printed between them, like this: H e l l o Nonetheless, when the string is too long, a line is printed between the first and second characters. Do you know a better way of doing this? EDIT: Next time I'd appreciate answers from someone who actually KNOWS programming. Not just condescending idiots.
2015/11/17
[ "https://Stackoverflow.com/questions/33766296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5419703/" ]
that's my String Echo ``` #define MAX_BUFFER_SIZE 0xFF char buffer[MAX_BUFFER_SIZE]; void setup() { Serial.begin(115200); buffer[0] = '\0'; } void loop() { while (Serial.available() > 0) { char incomingByte; size_t i = 0; do { incomingByte = Serial.read(); buffer[i++] = incomingByte; } while (incomingByte != '\0' && i < MAX_BUFFER_SIZE); if(i > 0){ delay(1000); /// delay for the echo Serial.write(buffer, i); } } } ```
You want to echo the string read, so just echo the input. ``` void setup() { Serial.begin(9600); } void loop() { int c = Serial.read(); if (c >= 0) Serial.write(c); } ```
74,300
In [Have any prominent politicians in the West called for Ukraine to surrender territory to Russia?](https://politics.stackexchange.com/questions/74257/have-any-prominent-politicians-in-the-west-called-for-ukraine-to-surrender-terri) user @o.m. states that: > > He is a member of the German parliament for the AfD, a nazi party. (Some comments questioned the characterization. So did leading AfD members, who sued for defamation and failed.) Also a prominent member of the opposition. > > > In comments the [following lawsuit](https://www.reuters.com/article/us-germany-afd-nazi/afd-leader-loses-case-versus-german-tv-show-that-calls-her-nazi-bitch-idUSKCN18D29T) is quoted as the basis of this claim: > > A German court on Wednesday rejected a request by a leader of the > nationalist Alternative for Germany (AfD) party for an interim > injunction against the re-airing of a television program in which the > moderator called her a “Nazi b\*\*\*h.” > > > The Hamburg District Court ruled that satire was secured by the right > to freedom of expression, and as a public figure, senior AfD member > Alice Weidel must “put up with exaggerated criticism”, the court said > in a statement. > > > The broadcaster NDR’s “extra 3” satire program on April 27 aired a > section of Weidel’s speech to her party congress a week earlier in > which she had railed against political correctness. > > > However its not clear if the court actually believes AfD to be a "Nazi party" or if it merely allowed that particular phrase to be used in a satirical context. Have there been other lawsuits in Germany which affirmed that AfD is indeed a "Nazi party"? As a corollary, have there been lawsuits where *other parties* were called *Nazi* and the courts ruled that using such words against them is unacceptable?
2022/07/18
[ "https://politics.stackexchange.com/questions/74300", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/7434/" ]
There is no official term "Nazi party" in Germany. A right-wing party can be a "subject of extended investigation to verify a suspicion" if it has far-right tendencies. The AfD is such a case [1]: > > **1. The claim filed by AfD to stop BfV from classifying it as a ‘Verdachtsfall’ (subject of extended investigation to verify a suspicion) and investigating it based on that definition as well as from publicising a classification to that effect or the fact that it is being investigated (13 K 326/21) was dismissed.** > > The court found in its oral statement of the reasons for the judgement that there were sufficient indications of anti-constitutional endeavours within the party. This had been documented by BfV, according to the court, in pertinent reports and the related collections of material by “contextualising the statements considered relevant”. As stated by the court, BfV’s assessment was based on an overall view that was not objected to. The party was in the middle of an internal dispute about its future course, in which the anti-constitutional forces might prevail in the end. BfV will also be allowed to publicise AfD’s classification as a ‘Verdachtsfall’ in order to make a political discussion possible. > > > A right-wing party can also be called a "(subject with) extremist endeavour as corroborated by hard evidence". If that's the case, then the party has anti-constitutional, extremist endeavours and basically poses a threat to the German democracy. The AfD as a whole is not such a case (yet) [1]: > > **3. The claim filed by AfD to stop BfV from classifying the AfD faction known as ‘Der Flügel’ as a ‘Verdachtsfall’ (subject of extended investigation to verify a suspicion) and/or a ‘gesichert extremistische Bestrebung’ (extremist endeavour as corroborated by hard evidence) and investigating it based on that definition as well as from publicising a classification to that effect or the fact that it is being investigated (13 K 207/20) was admitted in part.** > > The court has ruled that BfV was allowed to classify the AfD faction referred to as ‘Der Flügel’ as a ‘Verdachtsfall’. Its classification as a ‘gesichert extremistische Bestrebung’ is today, after its formal dissolution, not permissible, as found by the court. > > > If a right-wing party is evidently a "Nazi party", then it can get banned, thus not be a party, in Germany. One of the most prominent parties in that direction is the NPD, which, however, is not banned as it has not enough political power to pose a threat to the German democracy according to a German court in 2017 [2]. Calling someone a "Nazi" or "Nazi bitch" or whatever is – depending on the case – secured by the freedom of speech, but you can also get sued if it is seen as an insult or defamation. Calling a party as a whole a "Nazi party" can be prohibited. [1] [Bundesamt für Verfassungsschutz wins lawsuit before the Administrative Court in Cologne against AfD](https://www.verfassungsschutz.de/SharedDocs/pressemitteilungen/EN/2022/press-release-2022-1-afd-1.html) [2] [Debatten um NPD-Verbot und Parteienfinanzierung](https://www.bpb.de/themen/rechtsextremismus/dossier-rechtsextremismus/41462/debatten-um-npd-verbot-und-parteienfinanzierung/)
This seems to be a complicated question, there is no oficial confirmation and deniel as well acording to [this article](https://correctiv.org/faktencheck/2018/04/24/sind-afd-mitglieder-nach-gerichtsbeschluss-alle-nazis/): > > **Are AfD members "all Nazis" according to court order?** > > > The Offenburg district court refused to carry out criminal proceedings > against a Green politician who had called an AfD colleague a “Nazi” > during the election campaign. "Journalistenwatch" now writes that > according to the court, AfD members are "all Nazis". > > > The various court justifications show that the individual case decides > when the term "Nazi" may be used against a person and when not. > > > On December 23, 2017, "Journalistenwatch" published an article > entitled: "Court confirms: AfD members are now officially "all" > Nazis!". The text is currently being shared again on Facebook. > > > "Journalistenwatch" commented on an article by "Focus" according to > which the Offenburg district court had refused to conduct criminal > proceedings for insult against a member of the "Bündnis 90/Die Grünen" > (Greens) party. The Greens politician is said to have described a > member of the Alternative for Germany (AfD) as a "Nazi" at a campaign > event for the state elections in Baden-Württemberg. > > > The article from "Journalistenwatch" is marked as "opinion" - the > statement in the title is a clear exaggeration of the reasoning of the > Offenburg district court not to initiate specific criminal > proceedings. Based on the press release from the district court, > CORRECTIV explains the reasons for this decision. > > > The Offenburg case was also not the first in which an AfD politician > had filed a complaint after being labeled a "Nazi". In two cases there > were court proceedings - CORRECTIV has made itself aware of the > reasons for the judgement. Designation covered by freedom of speech > > > According to the Offenburg district court, a conviction of the Greens > member for insult is not to be expected - therefore no criminal > proceedings would be initiated. The reason: Although the designation > as "Nazi" would be a disregard for the AfD member, which would > constitute an insult - this is covered by freedom of expression. > > > There would also not be a case of "abusive criticism" - especially > since the term "Nazi" would also be used in everyday language as a > mere, albeit harsh, designation for a politically right-wing attitude. > Criticism of party, not of individual > > > There would be a lot to suggest that the designation as "Nazi" was an > "objective, albeit harsh criticism" of the AfD party, less a > disparagement of the individual AfD member. According to his own > statement, the Greens politician wanted to differentiate himself from > the AfD party with this statement - among other things because of the > toleration of right-wing extremist party members while at the same > time claiming the middle-class. > > > This would be supported by the fact that the statements were made in > the context of the public state election campaign and the parties > involved had previously been completely unknown. Lawsuit by AfD top > candidate Weidel dismissed > > > Similar cases were brought before the district court of Hamburg and > the district court of Potsdam. > > > For example, AfD top candidate Alice Weidel sued the NDR satirical > magazine "extra3" because of the term "Nazi bitch". The district court > of Hamburg also dismissed the lawsuit. This emerges from a press > release. > > > The reason: The controversial statement was made "in a clearly > recognizable satirical manner", which is covered in the context of > freedom of expression. In the specific case, the viewer understands > the term "Nazi" as a gross exaggeration, but does not therefore assume > that the applicant is a supporter of Nazi ideology. Fine for "Nazi" > insults against AfD politicians > > > A judgment by the Potsdam district court was different. According to > an article in the "Potsdamer Latest News", AfD member of parliament > Steffen Königer was called a "Nazi" by a 31-year-old at his polling > station. The judge convicted the accused of insult and imposed a fine. > > > On request, the Potsdam district court pointed out that "the accused > only had an argument with Mr. Königer and that the insulting > statements only referred to Mr. Königer". > > >
74,300
In [Have any prominent politicians in the West called for Ukraine to surrender territory to Russia?](https://politics.stackexchange.com/questions/74257/have-any-prominent-politicians-in-the-west-called-for-ukraine-to-surrender-terri) user @o.m. states that: > > He is a member of the German parliament for the AfD, a nazi party. (Some comments questioned the characterization. So did leading AfD members, who sued for defamation and failed.) Also a prominent member of the opposition. > > > In comments the [following lawsuit](https://www.reuters.com/article/us-germany-afd-nazi/afd-leader-loses-case-versus-german-tv-show-that-calls-her-nazi-bitch-idUSKCN18D29T) is quoted as the basis of this claim: > > A German court on Wednesday rejected a request by a leader of the > nationalist Alternative for Germany (AfD) party for an interim > injunction against the re-airing of a television program in which the > moderator called her a “Nazi b\*\*\*h.” > > > The Hamburg District Court ruled that satire was secured by the right > to freedom of expression, and as a public figure, senior AfD member > Alice Weidel must “put up with exaggerated criticism”, the court said > in a statement. > > > The broadcaster NDR’s “extra 3” satire program on April 27 aired a > section of Weidel’s speech to her party congress a week earlier in > which she had railed against political correctness. > > > However its not clear if the court actually believes AfD to be a "Nazi party" or if it merely allowed that particular phrase to be used in a satirical context. Have there been other lawsuits in Germany which affirmed that AfD is indeed a "Nazi party"? As a corollary, have there been lawsuits where *other parties* were called *Nazi* and the courts ruled that using such words against them is unacceptable?
2022/07/18
[ "https://politics.stackexchange.com/questions/74300", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/7434/" ]
This was about a specific case. A public television program had called Alice Weidel a "Nazi-Schlampe" (which is here translated as Nazi bitch). The court explicitly referred to the context at hand - Weidel had clamoured for an end to "political correctness", and the TV host had replied with the most political uncorrect phrase he could come up with. Alice Weidel had previously been called a "Nazi pig" on Facebook and sued successfully for libel, and has been called (literally) a "Nazi bitch" by German rapper Farid Bang, who retracted and apologized after she threatened him with legal measures. This should already show that this was about a specific case. This is related to the AFD only insofar as the judge said it would be understandable to the audience that she is called a "Nazi" due to her AfD membership. That does not mean that the judge said the AfD was a Nazi party - they said that "Nazi party" would be understandable as satirical exaggeration of "extreme right wing party" (AfD is considered at least borderline extremist, but it seems the judge said that it would be [evident to the viewer that Weidel is not literally a supporter of Nazi ideology](https://www.tagesspiegel.de/gesellschaft/medien/alice-weidel-verliert-gegen-extra3-vor-gericht-nazi-schlampe-ist-okay-weil-satire/19816018.html)). > > its not clear if the court actually believes AfD to be a "Nazi party" > > > Any legal procedure negotiating the word "Nazi party" would always be about free speech/artistic expression (since the possible crime that this colloquially refers to is not called "being a Nazi party"). A relatively low district court would probably not try to determine if a party is actively engaged in overthrowing the constitutional order of the Federal Republic of Germany (also any German judge would be offended if you suggested he based his rulings on "beliefs"). > > if it merely allowed that particular phrase to be used in a satirical context. > > > Yes. Since German law is not based on precedent, a court always adjudicates a specific case (unless there is a decision by a higher court), so the court just ruled that in this specific instance the phrase was not grounds for an injunction. Finally, this was not even a ruling in a lawsuit. Alice Weidel wanted to ban the phrase via an preliminary injunction. Since the judge rejected this, the actual lawsuit did not happen.
This seems to be a complicated question, there is no oficial confirmation and deniel as well acording to [this article](https://correctiv.org/faktencheck/2018/04/24/sind-afd-mitglieder-nach-gerichtsbeschluss-alle-nazis/): > > **Are AfD members "all Nazis" according to court order?** > > > The Offenburg district court refused to carry out criminal proceedings > against a Green politician who had called an AfD colleague a “Nazi” > during the election campaign. "Journalistenwatch" now writes that > according to the court, AfD members are "all Nazis". > > > The various court justifications show that the individual case decides > when the term "Nazi" may be used against a person and when not. > > > On December 23, 2017, "Journalistenwatch" published an article > entitled: "Court confirms: AfD members are now officially "all" > Nazis!". The text is currently being shared again on Facebook. > > > "Journalistenwatch" commented on an article by "Focus" according to > which the Offenburg district court had refused to conduct criminal > proceedings for insult against a member of the "Bündnis 90/Die Grünen" > (Greens) party. The Greens politician is said to have described a > member of the Alternative for Germany (AfD) as a "Nazi" at a campaign > event for the state elections in Baden-Württemberg. > > > The article from "Journalistenwatch" is marked as "opinion" - the > statement in the title is a clear exaggeration of the reasoning of the > Offenburg district court not to initiate specific criminal > proceedings. Based on the press release from the district court, > CORRECTIV explains the reasons for this decision. > > > The Offenburg case was also not the first in which an AfD politician > had filed a complaint after being labeled a "Nazi". In two cases there > were court proceedings - CORRECTIV has made itself aware of the > reasons for the judgement. Designation covered by freedom of speech > > > According to the Offenburg district court, a conviction of the Greens > member for insult is not to be expected - therefore no criminal > proceedings would be initiated. The reason: Although the designation > as "Nazi" would be a disregard for the AfD member, which would > constitute an insult - this is covered by freedom of expression. > > > There would also not be a case of "abusive criticism" - especially > since the term "Nazi" would also be used in everyday language as a > mere, albeit harsh, designation for a politically right-wing attitude. > Criticism of party, not of individual > > > There would be a lot to suggest that the designation as "Nazi" was an > "objective, albeit harsh criticism" of the AfD party, less a > disparagement of the individual AfD member. According to his own > statement, the Greens politician wanted to differentiate himself from > the AfD party with this statement - among other things because of the > toleration of right-wing extremist party members while at the same > time claiming the middle-class. > > > This would be supported by the fact that the statements were made in > the context of the public state election campaign and the parties > involved had previously been completely unknown. Lawsuit by AfD top > candidate Weidel dismissed > > > Similar cases were brought before the district court of Hamburg and > the district court of Potsdam. > > > For example, AfD top candidate Alice Weidel sued the NDR satirical > magazine "extra3" because of the term "Nazi bitch". The district court > of Hamburg also dismissed the lawsuit. This emerges from a press > release. > > > The reason: The controversial statement was made "in a clearly > recognizable satirical manner", which is covered in the context of > freedom of expression. In the specific case, the viewer understands > the term "Nazi" as a gross exaggeration, but does not therefore assume > that the applicant is a supporter of Nazi ideology. Fine for "Nazi" > insults against AfD politicians > > > A judgment by the Potsdam district court was different. According to > an article in the "Potsdamer Latest News", AfD member of parliament > Steffen Königer was called a "Nazi" by a 31-year-old at his polling > station. The judge convicted the accused of insult and imposed a fine. > > > On request, the Potsdam district court pointed out that "the accused > only had an argument with Mr. Königer and that the insulting > statements only referred to Mr. Königer". > > >
74,300
In [Have any prominent politicians in the West called for Ukraine to surrender territory to Russia?](https://politics.stackexchange.com/questions/74257/have-any-prominent-politicians-in-the-west-called-for-ukraine-to-surrender-terri) user @o.m. states that: > > He is a member of the German parliament for the AfD, a nazi party. (Some comments questioned the characterization. So did leading AfD members, who sued for defamation and failed.) Also a prominent member of the opposition. > > > In comments the [following lawsuit](https://www.reuters.com/article/us-germany-afd-nazi/afd-leader-loses-case-versus-german-tv-show-that-calls-her-nazi-bitch-idUSKCN18D29T) is quoted as the basis of this claim: > > A German court on Wednesday rejected a request by a leader of the > nationalist Alternative for Germany (AfD) party for an interim > injunction against the re-airing of a television program in which the > moderator called her a “Nazi b\*\*\*h.” > > > The Hamburg District Court ruled that satire was secured by the right > to freedom of expression, and as a public figure, senior AfD member > Alice Weidel must “put up with exaggerated criticism”, the court said > in a statement. > > > The broadcaster NDR’s “extra 3” satire program on April 27 aired a > section of Weidel’s speech to her party congress a week earlier in > which she had railed against political correctness. > > > However its not clear if the court actually believes AfD to be a "Nazi party" or if it merely allowed that particular phrase to be used in a satirical context. Have there been other lawsuits in Germany which affirmed that AfD is indeed a "Nazi party"? As a corollary, have there been lawsuits where *other parties* were called *Nazi* and the courts ruled that using such words against them is unacceptable?
2022/07/18
[ "https://politics.stackexchange.com/questions/74300", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/7434/" ]
This was about a specific case. A public television program had called Alice Weidel a "Nazi-Schlampe" (which is here translated as Nazi bitch). The court explicitly referred to the context at hand - Weidel had clamoured for an end to "political correctness", and the TV host had replied with the most political uncorrect phrase he could come up with. Alice Weidel had previously been called a "Nazi pig" on Facebook and sued successfully for libel, and has been called (literally) a "Nazi bitch" by German rapper Farid Bang, who retracted and apologized after she threatened him with legal measures. This should already show that this was about a specific case. This is related to the AFD only insofar as the judge said it would be understandable to the audience that she is called a "Nazi" due to her AfD membership. That does not mean that the judge said the AfD was a Nazi party - they said that "Nazi party" would be understandable as satirical exaggeration of "extreme right wing party" (AfD is considered at least borderline extremist, but it seems the judge said that it would be [evident to the viewer that Weidel is not literally a supporter of Nazi ideology](https://www.tagesspiegel.de/gesellschaft/medien/alice-weidel-verliert-gegen-extra3-vor-gericht-nazi-schlampe-ist-okay-weil-satire/19816018.html)). > > its not clear if the court actually believes AfD to be a "Nazi party" > > > Any legal procedure negotiating the word "Nazi party" would always be about free speech/artistic expression (since the possible crime that this colloquially refers to is not called "being a Nazi party"). A relatively low district court would probably not try to determine if a party is actively engaged in overthrowing the constitutional order of the Federal Republic of Germany (also any German judge would be offended if you suggested he based his rulings on "beliefs"). > > if it merely allowed that particular phrase to be used in a satirical context. > > > Yes. Since German law is not based on precedent, a court always adjudicates a specific case (unless there is a decision by a higher court), so the court just ruled that in this specific instance the phrase was not grounds for an injunction. Finally, this was not even a ruling in a lawsuit. Alice Weidel wanted to ban the phrase via an preliminary injunction. Since the judge rejected this, the actual lawsuit did not happen.
There is no official term "Nazi party" in Germany. A right-wing party can be a "subject of extended investigation to verify a suspicion" if it has far-right tendencies. The AfD is such a case [1]: > > **1. The claim filed by AfD to stop BfV from classifying it as a ‘Verdachtsfall’ (subject of extended investigation to verify a suspicion) and investigating it based on that definition as well as from publicising a classification to that effect or the fact that it is being investigated (13 K 326/21) was dismissed.** > > The court found in its oral statement of the reasons for the judgement that there were sufficient indications of anti-constitutional endeavours within the party. This had been documented by BfV, according to the court, in pertinent reports and the related collections of material by “contextualising the statements considered relevant”. As stated by the court, BfV’s assessment was based on an overall view that was not objected to. The party was in the middle of an internal dispute about its future course, in which the anti-constitutional forces might prevail in the end. BfV will also be allowed to publicise AfD’s classification as a ‘Verdachtsfall’ in order to make a political discussion possible. > > > A right-wing party can also be called a "(subject with) extremist endeavour as corroborated by hard evidence". If that's the case, then the party has anti-constitutional, extremist endeavours and basically poses a threat to the German democracy. The AfD as a whole is not such a case (yet) [1]: > > **3. The claim filed by AfD to stop BfV from classifying the AfD faction known as ‘Der Flügel’ as a ‘Verdachtsfall’ (subject of extended investigation to verify a suspicion) and/or a ‘gesichert extremistische Bestrebung’ (extremist endeavour as corroborated by hard evidence) and investigating it based on that definition as well as from publicising a classification to that effect or the fact that it is being investigated (13 K 207/20) was admitted in part.** > > The court has ruled that BfV was allowed to classify the AfD faction referred to as ‘Der Flügel’ as a ‘Verdachtsfall’. Its classification as a ‘gesichert extremistische Bestrebung’ is today, after its formal dissolution, not permissible, as found by the court. > > > If a right-wing party is evidently a "Nazi party", then it can get banned, thus not be a party, in Germany. One of the most prominent parties in that direction is the NPD, which, however, is not banned as it has not enough political power to pose a threat to the German democracy according to a German court in 2017 [2]. Calling someone a "Nazi" or "Nazi bitch" or whatever is – depending on the case – secured by the freedom of speech, but you can also get sued if it is seen as an insult or defamation. Calling a party as a whole a "Nazi party" can be prohibited. [1] [Bundesamt für Verfassungsschutz wins lawsuit before the Administrative Court in Cologne against AfD](https://www.verfassungsschutz.de/SharedDocs/pressemitteilungen/EN/2022/press-release-2022-1-afd-1.html) [2] [Debatten um NPD-Verbot und Parteienfinanzierung](https://www.bpb.de/themen/rechtsextremismus/dossier-rechtsextremismus/41462/debatten-um-npd-verbot-und-parteienfinanzierung/)
47,191,412
I have windows 7 64 bit and Python 3.6 I literally dig entire web for solving this - and nothing works sadly. ``` AttributeError Traceback (most recent call last) <ipython-input-150-80ee8bd5f0f2> in <module>() ----> serial.Serial() AttributeError: module 'serial' has no attribute 'Serial' ``` I tried solve this by: - checking if my file is named serial.py - reinstalling module - at first, entire module didn't work, now only it's functions. - I can't use any of its features, checking ports don't work, nothing works literally. - I checked my pip - everything is fine, module is in folder site-pacages. - If I execute some code inside pySerial files - it works. But there is no serial.Serial or connecting with COM ports (which I try to do.)
2017/11/08
[ "https://Stackoverflow.com/questions/47191412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7666246/" ]
I had the same problem with Python3 3.6.3.1 installed under Cygwin. I replaced 3.6.3.1 with 3.4.5.1 and the script worked again. OK, but not a good long term solution. Better solution: I reinstalled Python3 3.6.3.1, and then did **"pip install pyserial"**, and then I was able to run my script. No additional modules show up when I do help("modules"), but something extra must have been added to serial.
There's another python module called 'serial', that you might have on your system. I was using a program that imports the 'serial' module, and on my Linux machine it worked when executed by one user, and failed when executed as another user. When running the program as user2, I got the following traceback: ``` Traceback (most recent call last): File "./grabserial", line 957, in <module> restart_requested = grab(sys.argv[1:]) File "./grabserial", line 365, in grab sd = serial.Serial() AttributeError: 'module' object has no attribute 'Serial' ``` I figured out that I had the pyserial 'serial' module in /home/user1/.local/lib/python2.7/site-packages/serial/**init**.pyc, but that the other user was getting the serial module from /usr/local/lib/python2.7/dist-packages/serial. There are two different python packages that present a module called 'serial' to the sytem. One module is called 'serial' by pip (this one is a serialization library), and the other is called 'pyserial' (this one is a serial port handling library). The simple fix, if what you want to do is use the serial port handling module, is to uninstall the serialization module with pip, and make sure you have the 'pyserial' installed. In my case, I was using a program that used python 2.7 on my machine, so I did: ``` $ pip2 uninstall serial $ pip2 install pyserial ``` I did this as 'root', so that the pyserial module would be installed globally (for all users). Apparently, user1 had run pip to install pyserial as a local package for their account (so it worked for that account), but in order for other users to to use the module, the module needed to be installed globally. Also, the conflict with the 'serial' module had to be resolved.
47,191,412
I have windows 7 64 bit and Python 3.6 I literally dig entire web for solving this - and nothing works sadly. ``` AttributeError Traceback (most recent call last) <ipython-input-150-80ee8bd5f0f2> in <module>() ----> serial.Serial() AttributeError: module 'serial' has no attribute 'Serial' ``` I tried solve this by: - checking if my file is named serial.py - reinstalling module - at first, entire module didn't work, now only it's functions. - I can't use any of its features, checking ports don't work, nothing works literally. - I checked my pip - everything is fine, module is in folder site-pacages. - If I execute some code inside pySerial files - it works. But there is no serial.Serial or connecting with COM ports (which I try to do.)
2017/11/08
[ "https://Stackoverflow.com/questions/47191412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7666246/" ]
I had the same problem with Python3 3.6.3.1 installed under Cygwin. I replaced 3.6.3.1 with 3.4.5.1 and the script worked again. OK, but not a good long term solution. Better solution: I reinstalled Python3 3.6.3.1, and then did **"pip install pyserial"**, and then I was able to run my script. No additional modules show up when I do help("modules"), but something extra must have been added to serial.
If you are on a Windows machine using the Windows Subsystem for Linux (WSL), instead of a virtual machine, you will get this error. To fix it, go into `powershell` and enter the command: ``` wsl --shutdown ``` Restarting `powershell`, and running the `pyautogui` script again, worked.
47,191,412
I have windows 7 64 bit and Python 3.6 I literally dig entire web for solving this - and nothing works sadly. ``` AttributeError Traceback (most recent call last) <ipython-input-150-80ee8bd5f0f2> in <module>() ----> serial.Serial() AttributeError: module 'serial' has no attribute 'Serial' ``` I tried solve this by: - checking if my file is named serial.py - reinstalling module - at first, entire module didn't work, now only it's functions. - I can't use any of its features, checking ports don't work, nothing works literally. - I checked my pip - everything is fine, module is in folder site-pacages. - If I execute some code inside pySerial files - it works. But there is no serial.Serial or connecting with COM ports (which I try to do.)
2017/11/08
[ "https://Stackoverflow.com/questions/47191412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7666246/" ]
If you are on a Windows machine using the Windows Subsystem for Linux (WSL), instead of a virtual machine, you will get this error. To fix it, go into `powershell` and enter the command: ``` wsl --shutdown ``` Restarting `powershell`, and running the `pyautogui` script again, worked.
There's another python module called 'serial', that you might have on your system. I was using a program that imports the 'serial' module, and on my Linux machine it worked when executed by one user, and failed when executed as another user. When running the program as user2, I got the following traceback: ``` Traceback (most recent call last): File "./grabserial", line 957, in <module> restart_requested = grab(sys.argv[1:]) File "./grabserial", line 365, in grab sd = serial.Serial() AttributeError: 'module' object has no attribute 'Serial' ``` I figured out that I had the pyserial 'serial' module in /home/user1/.local/lib/python2.7/site-packages/serial/**init**.pyc, but that the other user was getting the serial module from /usr/local/lib/python2.7/dist-packages/serial. There are two different python packages that present a module called 'serial' to the sytem. One module is called 'serial' by pip (this one is a serialization library), and the other is called 'pyserial' (this one is a serial port handling library). The simple fix, if what you want to do is use the serial port handling module, is to uninstall the serialization module with pip, and make sure you have the 'pyserial' installed. In my case, I was using a program that used python 2.7 on my machine, so I did: ``` $ pip2 uninstall serial $ pip2 install pyserial ``` I did this as 'root', so that the pyserial module would be installed globally (for all users). Apparently, user1 had run pip to install pyserial as a local package for their account (so it worked for that account), but in order for other users to to use the module, the module needed to be installed globally. Also, the conflict with the 'serial' module had to be resolved.
407,833
I'm quite sure I'm missing something obvious, but I can't seem to work out the following problem (web search indicates that it has a solution, but I didn't manage to locate one -- hence the formulation): > > Prove that there exists a surjection $2^{\aleph\_0} \to \aleph\_1$ without using the Axiom of Choice. > > > Of course, this surjection is very trivial using AC (well-order $2^{\aleph\_0}$). I have been looking around a bit, but an obvious inroad like injecting $\aleph\_1$ into $\Bbb R$ in an order-preserving way is impossible. Hints and suggestions are appreciated.
2013/05/31
[ "https://math.stackexchange.com/questions/407833", "https://math.stackexchange.com", "https://math.stackexchange.com/users/43351/" ]
In what follows, by a "real", I mean a subset of $\omega\times\omega$, that is, a binary relation on $\omega$. (You can start with a bijection $\pi:\mathbb R\to\mathcal P(\omega\times\omega)$, which can be constructed without choice, so this is fine.) If this relation happens to be a well-order of $\omega$ in order type $\omega+\alpha$, map the real to $\alpha$. Otherwise, map the real to $0$. This map is a surjection. By the way, without choice, you cannot inject $\aleph\_1$ into $\mathbb R$.
One of my favorite ways is to fix a bijection between $\Bbb N$ and $\Bbb Q$, say $q\_n$ is the $n$th rational. Now we map $A\subseteq\Bbb N$ to $\alpha$ if $\{q\_n\mid n\in A\}$ has order type $\alpha$ (ordered with the usual order of the rationals), and $0$ otherwise. Because every countable ordinal can be embedded into the rationals, for every $\alpha<\omega\_1$ we can find a subset $\{q\_i\mid i\in I\}$ which is isomorphic to $\alpha$, and therefore $I$ is mapped to $\alpha$. Thus we have a surjection onto $\omega\_1$.
69,447,700
I want to add two csv's to one dataframe. The 2 Dataframes are similar but not the same. The Date is about 10 min apart. The length can be diffrent two. I need a left joint but how can I make wehen ther is no data it should be replaced with a zero or a null? out1.csv: ``` date,speed 2021-10-03 02:00:01,5.0 2021-10-03 02:00:02,5.2 2021-10-03 02:00:03,5.1 ``` out2.csv: ``` date,curret 2021-10-03 02:00:02,32.012 2021-10-03 02:00:03,32.12 2021-10-03 02:00:04,32.5 ``` As a outpu I need a dataframe something like that: ``` date,speed,current 2021-10-03 02:00:01,5.0,null 2021-10-03 02:00:02,5.2,32.012 2021-10-03 02:00:03,5.1,32.12 2021-10-03 02:00:04,null,32.5 ```
2021/10/05
[ "https://Stackoverflow.com/questions/69447700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14378640/" ]
Formula solution would be: `=SUM(FILTERXML("<y><z>"&SUBSTITUTE(A1,"-","</z><z>")&"</z></y>","//z"))` where `A1` would contain the given text. Side note: this formula `FILTERXML` only works on Windows systems.
This seems to work fine for me. Keep out, your locale might interpret the dot differently: ``` Sub test() Dim s As String s = "0.4-2-10-0.5" a = Split(s, "-") Dim sum As Double sum = 0 For Each t In a sum = sum + CDbl(t) Next t End Sub ```
69,447,700
I want to add two csv's to one dataframe. The 2 Dataframes are similar but not the same. The Date is about 10 min apart. The length can be diffrent two. I need a left joint but how can I make wehen ther is no data it should be replaced with a zero or a null? out1.csv: ``` date,speed 2021-10-03 02:00:01,5.0 2021-10-03 02:00:02,5.2 2021-10-03 02:00:03,5.1 ``` out2.csv: ``` date,curret 2021-10-03 02:00:02,32.012 2021-10-03 02:00:03,32.12 2021-10-03 02:00:04,32.5 ``` As a outpu I need a dataframe something like that: ``` date,speed,current 2021-10-03 02:00:01,5.0,null 2021-10-03 02:00:02,5.2,32.012 2021-10-03 02:00:03,5.1,32.12 2021-10-03 02:00:04,null,32.5 ```
2021/10/05
[ "https://Stackoverflow.com/questions/69447700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14378640/" ]
Since you've tagged `Excel 2010`, P.b's `FILTERXML` set-up won't be an option for you. Try: `=SUMPRODUCT(0+TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",25)),1+25*(ROW(INDEX(A:A,1):INDEX(A:A,1+LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))-1),25)))`
This seems to work fine for me. Keep out, your locale might interpret the dot differently: ``` Sub test() Dim s As String s = "0.4-2-10-0.5" a = Split(s, "-") Dim sum As Double sum = 0 For Each t In a sum = sum + CDbl(t) Next t End Sub ```
69,447,700
I want to add two csv's to one dataframe. The 2 Dataframes are similar but not the same. The Date is about 10 min apart. The length can be diffrent two. I need a left joint but how can I make wehen ther is no data it should be replaced with a zero or a null? out1.csv: ``` date,speed 2021-10-03 02:00:01,5.0 2021-10-03 02:00:02,5.2 2021-10-03 02:00:03,5.1 ``` out2.csv: ``` date,curret 2021-10-03 02:00:02,32.012 2021-10-03 02:00:03,32.12 2021-10-03 02:00:04,32.5 ``` As a outpu I need a dataframe something like that: ``` date,speed,current 2021-10-03 02:00:01,5.0,null 2021-10-03 02:00:02,5.2,32.012 2021-10-03 02:00:03,5.1,32.12 2021-10-03 02:00:04,null,32.5 ```
2021/10/05
[ "https://Stackoverflow.com/questions/69447700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14378640/" ]
Since you've tagged `Excel 2010`, P.b's `FILTERXML` set-up won't be an option for you. Try: `=SUMPRODUCT(0+TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",25)),1+25*(ROW(INDEX(A:A,1):INDEX(A:A,1+LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))-1),25)))`
Formula solution would be: `=SUM(FILTERXML("<y><z>"&SUBSTITUTE(A1,"-","</z><z>")&"</z></y>","//z"))` where `A1` would contain the given text. Side note: this formula `FILTERXML` only works on Windows systems.
49,725,238
I need to send my data through stream, So I chose Avro for data serialization and deserialization. But the existing implementation using avro readers, doesn't support backward compatibility. Write serialized data into file and read from file support backward compatibility. How can I achieve backward compatibility, without knowing the writer's schema. I found many stackoverflow questions related to this. But I didn't find any solution for this issue. Can someone help me to solve this. Following is my serializer and deserializer methods. ``` public static byte[] serialize(String json, Schema schema) throws IOException { GenericDatumWriter<Object> writer = new GenericDatumWriter<>(schema); ByteArrayOutputStream output = new ByteArrayOutputStream(); Encoder encoder = EncoderFactory.get().binaryEncoder(output, null); DatumReader<Object> reader = new GenericDatumReader<>(schema); Decoder decoder = DecoderFactory.get().jsonDecoder(schema, json); Object datum = reader.read(null, decoder); writer.write(datum, encoder); encoder.flush(); output.flush(); return output.toByteArray(); } public static String deserialize(byte[] avro, Schema schema) throws IOException { GenericDatumReader<Object> reader = new GenericDatumReader(schema); Decoder decoder = DecoderFactory.get().binaryDecoder(avro, null); Object datum = reader.read(null, decoder); ByteArrayOutputStream output = new ByteArrayOutputStream(); JsonEncoder encoder = EncoderFactory.get().jsonEncoder(schema, output); DatumWriter<Object> writer = new GenericDatumWriter(schema); writer.write(datum, encoder); encoder.flush(); output.flush(); return new String(output.toByteArray(), "UTF-8"); } ```
2018/04/09
[ "https://Stackoverflow.com/questions/49725238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6328527/" ]
You may have to define what scope you are looking for backward compatibility. Are you expecting new attributes to be added? OR are you going to remove any attributes? To handle both of these scenarios, there are different options available. As described on the [confluent blog](https://docs.confluent.io/current/avro.html#backward-compatibility), addition of new attributes can be achieved and avro serialization/deserialization activity can be made backward compatible, you must specify `default` value for the new attribute. Something like below ``` {"name": "size", "type": "string", "default": "XL"} ``` The other option is to specify, [reader and writer schemas exclusively](https://stackoverflow.com/questions/34733604/avro-schema-doesnt-honor-backward-compatibilty). But as described in your question, it doesn't seems to be an option you are looking for. If you are planning to remove an attribute, you can continue to parse the attribute but don't use it in application. Note this has to happen for a definite period and consumers must be given enough time to make changes to their program, before you completely retire the attribute. Make sure to log a statement to indicate the attribute was found when it was not supposed to be sent (or better send a notification to client system with a warning). Besides above points, there is an excellent blog which talks about [backward/forward compatibility](http://dekarlab.de/wp/?p=489).
Backward compatibility means that you can encode data with an older schema and the data can still be decoded by a reader that knows the latest schema. [Explanation from Confluent's website](https://docs.confluent.io/current/avro.html#backward-compatibility) So in order to decode Avro data with backward compatibility, your reader needs access to the latest schema. This can be done for example using a Schema Registry.
165,491
``` $ mkdir backup && mv * backup/ mv: cannot move `backup' to a subdirectory of itself, `backup/backup' ``` Works, but issues a warning. Also exit code is 1. How to do it properly (but not [much] longer)?
2010/07/19
[ "https://superuser.com/questions/165491", "https://superuser.com", "https://superuser.com/users/27264/" ]
bash: ``` shopt -s extglob mkdir backup && mv !(backup) backup ```
Also bash, and sh (afaik): ``` $ mkdir .backup && mv * .backup/ && mv .backup backup ```
71,410,420
I am looking to make a query in SQL SERVER that will allow me to display in a grouping the string that appears in most cases. Not the amount, not the maximum, but the string that is displayed in most cases: | colA | colB | colC | | --- | --- | --- | | A | 10 | ccc | | A | 20 | aaa | | A | 35 | bbb | | A | 25 | aaa | | A | 10 | aaa | | B | 15 | ccc | | B | 15 | bbb | | B | 30 | bbb | Select sum(colB) as total, ***?????????*** as lable from table1 Group BY colA Resukt: | colA | total | lable | | --- | --- | --- | | A | 100 | aaa | | B | 60 | bbb | thanks!
2022/03/09
[ "https://Stackoverflow.com/questions/71410420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17019046/" ]
The simplest way is to calculate a `ROW_NUMBER` or a `DENSE_RANK` on the COUNT of records per ColA & ColC. A `DENSE_RANK = 1` could show more than 1 top if there's a tie. > > > ``` > SELECT > ColA > , TotalColB AS Total > , ColC AS Lable > FROM > ( > SELECT ColA, ColC > , TotalColB = SUM(SUM(ColB)) OVER (PARTITION BY ColA) > , Rnk = DENSE_RANK() OVER (PARTITION BY ColA ORDER BY COUNT(*) DESC) > FROM YourTable > GROUP BY ColA, ColC > ) q > WHERE Rnk = 1 > ORDER BY ColA; > > ``` > > > > > > > | ColA | Total | Lable | > | --- | --- | --- | > | A | 100 | aaa | > | B | 60 | bbb | > > > Test on *db<>fiddle [here](https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=1f6a927d86db0da07d1348974f73b595)*
Here is another way to do it ``` select t.ColA, sum(t.total) as ColB, max(s2.ColC) from ( select s.ColA, s.ColC, sum(ColB) as total, count(1) as numbers from strings s group by s.ColA, s.ColC ) t outer apply ( select top 1 s.ColA, s.ColC, sum(ColB) as total, count(1) as numbers from strings s where s.ColA = t.ColA group by s.ColA, s.ColC order by 4 desc ) s2 group by t.ColA ``` Try it in this [DBFiddle](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=94a28442d54c864f84344f7dea601539)
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
use this > > > ``` > [arrname replaceObjectAtIndex:1 withObject:[NSNumber numberWithInt:13]];//13 is the age you want to change > > ``` > >
Supposing your `NSMutableArray` consists of `NSMutableDictionary` objects, **try something like this :** ``` NSMutableDictionary* entry = [entries objectAtIndex:index]; [entry setValue:@"newAge" forKey:@"Age"]; ```
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
``` Person *person = (Person *)[myArray objectAtIndex:1]; person.age = 2; ``` Assuming `Person` is your custom object stored in the array
Supposing your `NSMutableArray` consists of `NSMutableDictionary` objects, **try something like this :** ``` NSMutableDictionary* entry = [entries objectAtIndex:index]; [entry setValue:@"newAge" forKey:@"Age"]; ```
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
try this ``` -insertObject:atIndex: or replaceObjectAtIndex:withObject: ```
Supposing your `NSMutableArray` consists of `NSMutableDictionary` objects, **try something like this :** ``` NSMutableDictionary* entry = [entries objectAtIndex:index]; [entry setValue:@"newAge" forKey:@"Age"]; ```
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
You should use `NSMutableDictionary` to save name,age,phone,address and add this dictionary to your array. ``` [[arry objectAtIndex:1] setObject:@"value" forKey:@"key"]; ``` Like this you can change value.
Supposing your `NSMutableArray` consists of `NSMutableDictionary` objects, **try something like this :** ``` NSMutableDictionary* entry = [entries objectAtIndex:index]; [entry setValue:@"newAge" forKey:@"Age"]; ```
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
Perhaps this will help you. ``` - (void)viewDidLoad { [super viewDidLoad]; productArray=[[NSMutableArray alloc]init]; PersonDetail *personObj = [[PersonDetail alloc] init]; personObj.firstName = @"Adeem"; personObj.lastName = @"Basraa"; personObj.phoneNumber = @"123456789"; [productArray addObject:personObj]; [personObj release]; PersonDetail *personObj = [[PersonDetail alloc] init]; personObj.firstName = @"Ijaz"; personObj.lastName = @"Ahmed"; personObj.phoneNumber = @"987654321"; [productArray addObject:personObj]; [personObj release]; PersonDetail *personObj = [[PersonDetail alloc] init]; personObj.firstName = @"Waqas"; personObj.lastName = @"Ahmad"; personObj.phoneNumber = @"45656789"; [productArray addObject:personObj]; [personObj release]; } - (void)change { for (int i=0;i<[productArray count];i++) { PersonDetail *personObj = (PersonDetail *)[[productArray objectAtIndex:i] retain]; personObj.phoneNumber = @"New"; } } ```
Supposing your `NSMutableArray` consists of `NSMutableDictionary` objects, **try something like this :** ``` NSMutableDictionary* entry = [entries objectAtIndex:index]; [entry setValue:@"newAge" forKey:@"Age"]; ```
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
``` Person *person = (Person *)[myArray objectAtIndex:1]; person.age = 2; ``` Assuming `Person` is your custom object stored in the array
use this > > > ``` > [arrname replaceObjectAtIndex:1 withObject:[NSNumber numberWithInt:13]];//13 is the age you want to change > > ``` > >
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
``` Person *person = (Person *)[myArray objectAtIndex:1]; person.age = 2; ``` Assuming `Person` is your custom object stored in the array
try this ``` -insertObject:atIndex: or replaceObjectAtIndex:withObject: ```
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
``` Person *person = (Person *)[myArray objectAtIndex:1]; person.age = 2; ``` Assuming `Person` is your custom object stored in the array
You should use `NSMutableDictionary` to save name,age,phone,address and add this dictionary to your array. ``` [[arry objectAtIndex:1] setObject:@"value" forKey:@"key"]; ``` Like this you can change value.
10,204,213
I have some html content with apostrophe inside a div, It renders correctly in all other browsers other than IE. You will get a clear idea from the screen-shot On other browsers ![enter image description here](https://i.stack.imgur.com/YimfO.png) On IE ![enter image description here](https://i.stack.imgur.com/HLWHJ.png) I have searched enough and found issues like apostrophe shown as `&apos;`. I think this is not similar to that issue. Can anyone help?
2012/04/18
[ "https://Stackoverflow.com/questions/10204213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125792/" ]
``` Person *person = (Person *)[myArray objectAtIndex:1]; person.age = 2; ``` Assuming `Person` is your custom object stored in the array
Perhaps this will help you. ``` - (void)viewDidLoad { [super viewDidLoad]; productArray=[[NSMutableArray alloc]init]; PersonDetail *personObj = [[PersonDetail alloc] init]; personObj.firstName = @"Adeem"; personObj.lastName = @"Basraa"; personObj.phoneNumber = @"123456789"; [productArray addObject:personObj]; [personObj release]; PersonDetail *personObj = [[PersonDetail alloc] init]; personObj.firstName = @"Ijaz"; personObj.lastName = @"Ahmed"; personObj.phoneNumber = @"987654321"; [productArray addObject:personObj]; [personObj release]; PersonDetail *personObj = [[PersonDetail alloc] init]; personObj.firstName = @"Waqas"; personObj.lastName = @"Ahmad"; personObj.phoneNumber = @"45656789"; [productArray addObject:personObj]; [personObj release]; } - (void)change { for (int i=0;i<[productArray count];i++) { PersonDetail *personObj = (PersonDetail *)[[productArray objectAtIndex:i] retain]; personObj.phoneNumber = @"New"; } } ```
14,042,594
I have table as below ``` create table myTable (id int, col1 varchar(20), col2 varchar(20), col3 varchar(20), col4 varchar(20), col5 varchar(20), col6 varchar(20), col7 varchar(20), col8 varchar(20), col9 varchar(20) ); ``` And have data as ``` insert into myTable values (1, 'col1','col2','col3','col4','col5','col6','col7','col8','col9'); ``` What I want is output as ``` id + AllInOne ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 + col1-col2-col3-col4-col5-col6-col7-col8-col9 ++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Any idea how to get this done with smallest query? I know I could do above with use of CONCATENATE. But I would need is some other way. Maybe some pre-defined MySQL function? [Data at sqlfiddle](http://sqlfiddle.com/#!2/7be5b/6) -----------------------------------------------------
2012/12/26
[ "https://Stackoverflow.com/questions/14042594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1066828/" ]
If you are using Castle Windsor 3.0 or newer, you can use lazy resolving. See [What's new in Windsor 3 for more details](https://github.com/castleproject/Windsor/blob/master/docs/whats-new-3.0.md). Registration process changes a bit (new component loader must be registered). After that, you are just registering components as always, but resolve dependencies as `Lazy<T>` instead of `T`. Until you won't access `.Value` property of your `Lazy<T>`, dependency will not be resolved, so you can pass few lazily evaluated objects and access only the one you will need and when you need. If you have more options to the user, maybe you should consider creating some sort of abstract factory interface. You would then register and resolve only this factory and the factory itself would create appropriate service for sending notifications (be it a mail or a sms or any other option). Implementation of the factory can be coded by hand or Castle Windsor can you with that (I think from version 3.0). Often when I do use such factory, I implement it by hand and pass container as it's dependency, so only factory implementation depends on my container.
In general, you can do that with the [Typed Factory Facility](https://github.com/castleproject/Windsor/blob/master/docs/typed-factory-facility.md). In a nutshell, when you resolve the component that uses those services, instead of giving it an email or sms service, you give it a **factory** that can create them (which is defined by you, without references to the container) The facility will take care of "implementing" your factory (from the interface you create), so there's very little to do.
14,042,594
I have table as below ``` create table myTable (id int, col1 varchar(20), col2 varchar(20), col3 varchar(20), col4 varchar(20), col5 varchar(20), col6 varchar(20), col7 varchar(20), col8 varchar(20), col9 varchar(20) ); ``` And have data as ``` insert into myTable values (1, 'col1','col2','col3','col4','col5','col6','col7','col8','col9'); ``` What I want is output as ``` id + AllInOne ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 + col1-col2-col3-col4-col5-col6-col7-col8-col9 ++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Any idea how to get this done with smallest query? I know I could do above with use of CONCATENATE. But I would need is some other way. Maybe some pre-defined MySQL function? [Data at sqlfiddle](http://sqlfiddle.com/#!2/7be5b/6) -----------------------------------------------------
2012/12/26
[ "https://Stackoverflow.com/questions/14042594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1066828/" ]
If you are using Castle Windsor 3.0 or newer, you can use lazy resolving. See [What's new in Windsor 3 for more details](https://github.com/castleproject/Windsor/blob/master/docs/whats-new-3.0.md). Registration process changes a bit (new component loader must be registered). After that, you are just registering components as always, but resolve dependencies as `Lazy<T>` instead of `T`. Until you won't access `.Value` property of your `Lazy<T>`, dependency will not be resolved, so you can pass few lazily evaluated objects and access only the one you will need and when you need. If you have more options to the user, maybe you should consider creating some sort of abstract factory interface. You would then register and resolve only this factory and the factory itself would create appropriate service for sending notifications (be it a mail or a sms or any other option). Implementation of the factory can be coded by hand or Castle Windsor can you with that (I think from version 3.0). Often when I do use such factory, I implement it by hand and pass container as it's dependency, so only factory implementation depends on my container.
Just an example to simplify (based on Marcin Deptuła answer) ``` // activate Lazy initialization feature for all Components .Register(Component.For<ILazyComponentLoader>().ImplementedBy<LazyOfTComponentLoader>()) // register rest of component(s) .Register(Component.For<IIssueRepository>().ImplementedBy<IssueRepository>()) . .... ``` resolve lazily (property injection) ``` public Lazy<IIssueRepository> IssueRepository { get; set; } IssueRepository.Value.GetLastIssue(); ``` resolve normal (property injection) ``` public IIssueRepository IssueRepository { get; set; } IssueRepository.GetLastIssue(); ```
14,042,594
I have table as below ``` create table myTable (id int, col1 varchar(20), col2 varchar(20), col3 varchar(20), col4 varchar(20), col5 varchar(20), col6 varchar(20), col7 varchar(20), col8 varchar(20), col9 varchar(20) ); ``` And have data as ``` insert into myTable values (1, 'col1','col2','col3','col4','col5','col6','col7','col8','col9'); ``` What I want is output as ``` id + AllInOne ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 + col1-col2-col3-col4-col5-col6-col7-col8-col9 ++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Any idea how to get this done with smallest query? I know I could do above with use of CONCATENATE. But I would need is some other way. Maybe some pre-defined MySQL function? [Data at sqlfiddle](http://sqlfiddle.com/#!2/7be5b/6) -----------------------------------------------------
2012/12/26
[ "https://Stackoverflow.com/questions/14042594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1066828/" ]
Just an example to simplify (based on Marcin Deptuła answer) ``` // activate Lazy initialization feature for all Components .Register(Component.For<ILazyComponentLoader>().ImplementedBy<LazyOfTComponentLoader>()) // register rest of component(s) .Register(Component.For<IIssueRepository>().ImplementedBy<IssueRepository>()) . .... ``` resolve lazily (property injection) ``` public Lazy<IIssueRepository> IssueRepository { get; set; } IssueRepository.Value.GetLastIssue(); ``` resolve normal (property injection) ``` public IIssueRepository IssueRepository { get; set; } IssueRepository.GetLastIssue(); ```
In general, you can do that with the [Typed Factory Facility](https://github.com/castleproject/Windsor/blob/master/docs/typed-factory-facility.md). In a nutshell, when you resolve the component that uses those services, instead of giving it an email or sms service, you give it a **factory** that can create them (which is defined by you, without references to the container) The facility will take care of "implementing" your factory (from the interface you create), so there's very little to do.
4,284,805
If a and b a positive real numbers find the maximum value of ax+by in terms of a and b given that $x^2+y^2 \le 1$. I started by letting $k = ax+by$ giving the line $y=\frac{-ax}{b} + \frac{k}{b}$. Now we want to find the largest value of k such that the line still intersects the unit circle. Graphically it can be seen that this occurs when the line is tangent to the circle. This results in a right triangle with $\frac{k}{b}$ as the hypotenuse and 1 as one of the side lengths. This is where I am stuck because in the solution they had the following triangle; [![Solution](https://i.stack.imgur.com/zHBjE.png)](https://i.stack.imgur.com/zHBjE.png) How do we know that the other side length of the triangle is the gradient of the line?
2021/10/23
[ "https://math.stackexchange.com/questions/4284805", "https://math.stackexchange.com", "https://math.stackexchange.com/users/981015/" ]
Applying Cauchy-Schwarz Inequality $$(ax+by)^2\leq (a^2+b^2)(x^2+y^2)\leq (a^2+b^2) \times 1 =(a^2+b^2)$$ $$ax+by \leq \sqrt{a^2+b^2}$$
I think your question is equivalent to proving the tangent of a circle always intersects the radius at a 90 degree angle. You can find the full proof here: [How to prove that the tangent to a circle is perpendicular to the radius drawn to the point of contact?](https://math.stackexchange.com/questions/158955/how-to-prove-that-the-tangent-to-a-circle-is-perpendicular-to-the-radius-drawn-t)
4,284,805
If a and b a positive real numbers find the maximum value of ax+by in terms of a and b given that $x^2+y^2 \le 1$. I started by letting $k = ax+by$ giving the line $y=\frac{-ax}{b} + \frac{k}{b}$. Now we want to find the largest value of k such that the line still intersects the unit circle. Graphically it can be seen that this occurs when the line is tangent to the circle. This results in a right triangle with $\frac{k}{b}$ as the hypotenuse and 1 as one of the side lengths. This is where I am stuck because in the solution they had the following triangle; [![Solution](https://i.stack.imgur.com/zHBjE.png)](https://i.stack.imgur.com/zHBjE.png) How do we know that the other side length of the triangle is the gradient of the line?
2021/10/23
[ "https://math.stackexchange.com/questions/4284805", "https://math.stackexchange.com", "https://math.stackexchange.com/users/981015/" ]
The right triangle you are looking at has one vertex $A$ at the origin, another vertex $B$ at the point $(0, k/b)$, and the third vertex $C$ (a right angle) at the point of tangency between the line and the circle. You've established two of the side lengths of this triangle. The third side length, call it $L$, satisfies $$\tan B = \frac 1L.$$ But there is another right triangle, formed by the line and the two coordinate axes, that shares the same angle at $B$. The side lengths of this triangle are $k/b$ (the $y$-intercept of the line) and $k/a$ (the $x$-intercept of the line). Therefore $$\tan B = \frac {k/a}{k/b}=\frac ba$$ which implies $L=\frac ab$.
I think your question is equivalent to proving the tangent of a circle always intersects the radius at a 90 degree angle. You can find the full proof here: [How to prove that the tangent to a circle is perpendicular to the radius drawn to the point of contact?](https://math.stackexchange.com/questions/158955/how-to-prove-that-the-tangent-to-a-circle-is-perpendicular-to-the-radius-drawn-t)
130,389
I'm not looking for a plug and play method like BEST in R but rather a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples.
2014/12/26
[ "https://stats.stackexchange.com/questions/130389", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/61501/" ]
With a Bayesian analysis you have more things to specify (that is actually a good thing, since it gives much more flexibility and ability to model what you believe the truth to be). Are you assuming normals for the likelihoods? Will the 2 groups have the same variance? One straight forward approach is to model the 2 means (and 1 or 2 variances/dispersions) then look at the posterior on the difference of the 2 means and/or the Credible Interval on the difference of the 2 means.
> > a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples. > > > There are several approaches to "testing" this. I'll mention a couple: * If you want an explicit *decision* you could look at decision theory. * A pretty simple thing that's sometimes done is to find an interval for the difference in the means and consider whether it includes 0 or not. That would involve starting with a model for the observations, priors on the parameters and computation of the posterior distribution of the difference in means conditional on the data. You'd need to say what your model is (e.g. normal, constant variance), and then (at least) some prior for the difference in means and a prior for the variance. You might have priors on the parameters of those priors in turn. Or you might *not* assume constant variance. Or you might assume something other than normality.
130,389
I'm not looking for a plug and play method like BEST in R but rather a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples.
2014/12/26
[ "https://stats.stackexchange.com/questions/130389", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/61501/" ]
This is a good question, that seems to pop up a lot: [link 1](https://stats.stackexchange.com/questions/15777/what-is-the-bayesian-counterpart-to-a-two-sample-t-test-with-unequal-variances/47240#47240), [link 2](https://stats.stackexchange.com/questions/104932/bayesian-alternative-or-complement-to-the-student-t-test). The paper [Bayesian Estimation Superseeds the T-Test](http://www.indiana.edu/~kruschke/BEST/BEST.pdf) that Cam.Davidson.Pilon pointed out is an excellent resource on this subject. It is also very recent, published in 2012, which I think in part is due to the current interest in the area. I will try to summarize a mathematical explanation of a Bayesian alternative to the two sample t-test. This summary is similar to the BEST paper which assess the difference in two samples by comparing the difference in their posterior distributions (explained below in R). ```r set.seed(7) #create samples sample.1 <- rnorm(8, 100, 3) sample.2 <- rnorm(10, 103, 7) #we need a pooled data set for estimating parameters in the prior. pooled <- c(sample.1, sample.2) par(mfrow=c(1, 2)) hist(sample.1) hist(sample.2) ``` ![enter image description here](https://i.stack.imgur.com/xxl3d.png) In order to compare the sample means we need to estimate what they are. The Bayesian method to do so uses Bayes' theorem: [P(A|B) = P(B|A) \* P(A)/P(B)](http://en.wikipedia.org/wiki/Bayes%27_theorem) (the syntax of P(A|B) is read as the probability of A given B) Thanks to modern numerical methods we can ignore the probability of B, P(B), and use the proportional statment: P(A|B) $\propto$ P(B|A)\*P(A) In Bayesian vernacular **the posterior is proportional to the likelihood times the prior** Applying Bayes' theory to our problem where we want to know the means of samples given some data we get $P(mean.1 | sample.1)$ $\propto$ $P(sample.1 | mean.1) \* P(mean.1)$. The first term on the right is the likelihood, $P(sample.1 | mean.1)$, which is the probability of observing the sample data given mean.1. The second term is the prior, $P(mean.1)$, which is simply the probability of mean.1. Figuring out appropriate priors is still a bit of an art and is one of the biggest critisims of Bayesian methods. Let's put it in code. Code makes everything better. ```r likelihood <- function(parameters){ mu1=parameters[1]; sig1=parameters[2]; mu2=parameters[3]; sig2=parameters[4] prod(dnorm(sample.1, mu1, sig1)) * prod(dnorm(sample.2, mu2, sig2)) } prior <- function(parameters){ mu1=parameters[1]; sig1=parameters[2]; mu2=parameters[3]; sig2=parameters[4] dnorm(mu1, mean(pooled), 1000*sd(pooled)) * dnorm(mu2, mean(pooled), 1000*sd(pooled)) * dexp(sig1, rate=0.1) * dexp(sig2, 0.1) } ``` I made some assumptions in the prior that need to be justified. To keep the priors from prejudicing the estimated mean I wanted to make them broad and uniform-ish over plausible values with the aim of letting the data produce the features of the posterior. I used recommended setting from BEST and distributed the mu's normally with mean = mean(pooled) and a broad standard deviation = 1000\*sd(pooled). The standard deviations I set to a broad exponential distribution, because I wanted a broad unbounded distribution. Now we can make the posterior ```r posterior <- function(parameters) {likelihood(parameters) * prior(parameters)} ``` We will sample the posterior distribution using a [markov chain monte carlo](http://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm) (MCMC) with Metropolis Hastings modification. Its easiest to understand with code. ```r #starting values mu1 = 100; sig1 = 10; mu2 = 100; sig2 = 10 parameters <- c(mu1, sig1, mu2, sig2) #this is the MCMC /w Metropolis method n.iter <- 10000 results <- matrix(0, nrow=n.iter, ncol=4) results[1, ] <- parameters for (iteration in 2:n.iter){ candidate <- parameters + rnorm(4, sd=0.5) ratio <- posterior(candidate)/posterior(parameters) if (runif(1) < ratio) parameters <- candidate #Metropolis modification results[iteration, ] <- parameters } ``` The results matrix is a list of samples from the posterior distribution for each parameter which we can use to answer our original question: Is sample.1 different than sample.2? But first to avoid affects from the starting values we will "burn-in" the first 500 values of the chain. ```r #burn-in results <- results[500:n.iter,] ``` Now, is sample.1 different than sample.2? ```r mu1 <- results[,1] mu2 <- results[,3] hist(mu1 - mu2) ``` ![enter image description here](https://i.stack.imgur.com/tW7g5.png) ```r mean(mu1 - mu2 < 0) [1] 0.9953689 ``` From this analysis I would conclude there is a 99.5% chance that the mean for sample.1 is less than the mean for sample.2. An advantage of the Bayesian approach, as pointed out in the BEST paper, is that it can make strong theories. E.G. what is the probability that sample.2 is 5 units bigger than sample.1. ```r mean(mu2 - mu1 > 5) [1] 0.9321124 ``` We would conclude that there is a 93% chance that the mean of sample.2 is 5 unit greater than sample.1. An observant reader would find that interesting because we know the true populations have means of 100 and 103 respectively. This is most likely due to the small sample size, and choice of using a normal distribution for the likelihood. I will end this answer with a warning: This code is for teaching purposes. For a real analysis use RJAGS and depending on your sample size fit a t-distribution for the likelihood. If there is interest I will post a t-test using RJAGS. EDIT: As requested here is a JAGS model. ```r model.str <- 'model { for (i in 1:Ntotal) { y[i] ~ dt(mu[x[i]], tau[x[i]], nu) } for (j in 1:2) { mu[j] ~ dnorm(mu_pooled, tau_pooled) tau[j] <- 1 / pow(sigma[j], 2) sigma[j] ~ dunif(sigma_low, sigma_high) } nu <- nu_minus_one + 1 nu_minus_one ~ dexp(1 / 29) }' # Indicator variable x <- c(rep(1, length(sample.1)), rep(2, length(sample.2))) cpd.model <- jags.model(textConnection(model.str), data=list(y=pooled, x=x, mu_pooled=mean(pooled), tau_pooled=1/(1000 * sd(pooled))^2, sigma_low=sd(pooled) / 1000, sigma_high=sd(pooled) * 1000, Ntotal=length(pooled))) update(cpd.model, 1000) chain <- coda.samples(model = cpd.model, n.iter = 100000, variable.names = c('mu', 'sigma')) rchain <- as.matrix(chain) hist(rchain[, 'mu[1]'] - rchain[, 'mu[2]']) mean(rchain[, 'mu[1]'] - rchain[, 'mu[2]'] < 0) mean(rchain[, 'mu[2]'] - rchain[, 'mu[1]'] > 5) ```
With a Bayesian analysis you have more things to specify (that is actually a good thing, since it gives much more flexibility and ability to model what you believe the truth to be). Are you assuming normals for the likelihoods? Will the 2 groups have the same variance? One straight forward approach is to model the 2 means (and 1 or 2 variances/dispersions) then look at the posterior on the difference of the 2 means and/or the Credible Interval on the difference of the 2 means.
130,389
I'm not looking for a plug and play method like BEST in R but rather a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples.
2014/12/26
[ "https://stats.stackexchange.com/questions/130389", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/61501/" ]
The excellent answer by user1068430 implemented in Python ```py import numpy as np from pylab import plt def dnorm(x, mu, sig): return 1/(sig * np.sqrt(2 * np.pi)) * np.exp(-(x - mu)**2 / (2 * sig**2)) def dexp(x, l): return l * np.exp(- l*x) def like(parameters): [mu1, sig1, mu2, sig2] = parameters return dnorm(sample1, mu1, sig1).prod()*dnorm(sample2, mu2, sig2).prod() def prior(parameters): [mu1, sig1, mu2, sig2] = parameters return dnorm(mu1, pooled.mean(), 1000*pooled.std()) * dnorm(mu2, pooled.mean(), 1000*pooled.std()) * dexp(sig1, 0.1) * dexp(sig2, 0.1) def posterior(parameters): [mu1, sig1, mu2, sig2] = parameters return like([mu1, sig1, mu2, sig2])*prior([mu1, sig1, mu2, sig2]) #create samples sample1 = np.random.normal(100, 3, 8) sample2 = np.random.normal(100, 7, 10) pooled= np.append(sample1, sample2) plt.figure(0) plt.hist(sample1) plt.hold(True) plt.hist(sample2) plt.show(block=False) mu1 = 100 sig1 = 10 mu2 = 100 sig2 = 10 parameters = np.array([mu1, sig1, mu2, sig2]) niter = 10000 results = np.zeros([niter, 4]) results[1,:] = parameters for iteration in np.arange(2,niter): candidate = parameters + np.random.normal(0,0.5,4) ratio = posterior(candidate)/posterior(parameters) if np.random.uniform() < ratio: parameters = candidate results[iteration,:] = parameters #burn-in results = results[499:niter-1,:] mu1 = results[:,1] mu2 = results[:,3] d = (mu1 - mu2) p_value = np.mean(d > 0) plt.figure(1) plt.hist(d,normed = 1) plt.show() ``` ```
With a Bayesian analysis you have more things to specify (that is actually a good thing, since it gives much more flexibility and ability to model what you believe the truth to be). Are you assuming normals for the likelihoods? Will the 2 groups have the same variance? One straight forward approach is to model the 2 means (and 1 or 2 variances/dispersions) then look at the posterior on the difference of the 2 means and/or the Credible Interval on the difference of the 2 means.
130,389
I'm not looking for a plug and play method like BEST in R but rather a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples.
2014/12/26
[ "https://stats.stackexchange.com/questions/130389", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/61501/" ]
This is a good question, that seems to pop up a lot: [link 1](https://stats.stackexchange.com/questions/15777/what-is-the-bayesian-counterpart-to-a-two-sample-t-test-with-unequal-variances/47240#47240), [link 2](https://stats.stackexchange.com/questions/104932/bayesian-alternative-or-complement-to-the-student-t-test). The paper [Bayesian Estimation Superseeds the T-Test](http://www.indiana.edu/~kruschke/BEST/BEST.pdf) that Cam.Davidson.Pilon pointed out is an excellent resource on this subject. It is also very recent, published in 2012, which I think in part is due to the current interest in the area. I will try to summarize a mathematical explanation of a Bayesian alternative to the two sample t-test. This summary is similar to the BEST paper which assess the difference in two samples by comparing the difference in their posterior distributions (explained below in R). ```r set.seed(7) #create samples sample.1 <- rnorm(8, 100, 3) sample.2 <- rnorm(10, 103, 7) #we need a pooled data set for estimating parameters in the prior. pooled <- c(sample.1, sample.2) par(mfrow=c(1, 2)) hist(sample.1) hist(sample.2) ``` ![enter image description here](https://i.stack.imgur.com/xxl3d.png) In order to compare the sample means we need to estimate what they are. The Bayesian method to do so uses Bayes' theorem: [P(A|B) = P(B|A) \* P(A)/P(B)](http://en.wikipedia.org/wiki/Bayes%27_theorem) (the syntax of P(A|B) is read as the probability of A given B) Thanks to modern numerical methods we can ignore the probability of B, P(B), and use the proportional statment: P(A|B) $\propto$ P(B|A)\*P(A) In Bayesian vernacular **the posterior is proportional to the likelihood times the prior** Applying Bayes' theory to our problem where we want to know the means of samples given some data we get $P(mean.1 | sample.1)$ $\propto$ $P(sample.1 | mean.1) \* P(mean.1)$. The first term on the right is the likelihood, $P(sample.1 | mean.1)$, which is the probability of observing the sample data given mean.1. The second term is the prior, $P(mean.1)$, which is simply the probability of mean.1. Figuring out appropriate priors is still a bit of an art and is one of the biggest critisims of Bayesian methods. Let's put it in code. Code makes everything better. ```r likelihood <- function(parameters){ mu1=parameters[1]; sig1=parameters[2]; mu2=parameters[3]; sig2=parameters[4] prod(dnorm(sample.1, mu1, sig1)) * prod(dnorm(sample.2, mu2, sig2)) } prior <- function(parameters){ mu1=parameters[1]; sig1=parameters[2]; mu2=parameters[3]; sig2=parameters[4] dnorm(mu1, mean(pooled), 1000*sd(pooled)) * dnorm(mu2, mean(pooled), 1000*sd(pooled)) * dexp(sig1, rate=0.1) * dexp(sig2, 0.1) } ``` I made some assumptions in the prior that need to be justified. To keep the priors from prejudicing the estimated mean I wanted to make them broad and uniform-ish over plausible values with the aim of letting the data produce the features of the posterior. I used recommended setting from BEST and distributed the mu's normally with mean = mean(pooled) and a broad standard deviation = 1000\*sd(pooled). The standard deviations I set to a broad exponential distribution, because I wanted a broad unbounded distribution. Now we can make the posterior ```r posterior <- function(parameters) {likelihood(parameters) * prior(parameters)} ``` We will sample the posterior distribution using a [markov chain monte carlo](http://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm) (MCMC) with Metropolis Hastings modification. Its easiest to understand with code. ```r #starting values mu1 = 100; sig1 = 10; mu2 = 100; sig2 = 10 parameters <- c(mu1, sig1, mu2, sig2) #this is the MCMC /w Metropolis method n.iter <- 10000 results <- matrix(0, nrow=n.iter, ncol=4) results[1, ] <- parameters for (iteration in 2:n.iter){ candidate <- parameters + rnorm(4, sd=0.5) ratio <- posterior(candidate)/posterior(parameters) if (runif(1) < ratio) parameters <- candidate #Metropolis modification results[iteration, ] <- parameters } ``` The results matrix is a list of samples from the posterior distribution for each parameter which we can use to answer our original question: Is sample.1 different than sample.2? But first to avoid affects from the starting values we will "burn-in" the first 500 values of the chain. ```r #burn-in results <- results[500:n.iter,] ``` Now, is sample.1 different than sample.2? ```r mu1 <- results[,1] mu2 <- results[,3] hist(mu1 - mu2) ``` ![enter image description here](https://i.stack.imgur.com/tW7g5.png) ```r mean(mu1 - mu2 < 0) [1] 0.9953689 ``` From this analysis I would conclude there is a 99.5% chance that the mean for sample.1 is less than the mean for sample.2. An advantage of the Bayesian approach, as pointed out in the BEST paper, is that it can make strong theories. E.G. what is the probability that sample.2 is 5 units bigger than sample.1. ```r mean(mu2 - mu1 > 5) [1] 0.9321124 ``` We would conclude that there is a 93% chance that the mean of sample.2 is 5 unit greater than sample.1. An observant reader would find that interesting because we know the true populations have means of 100 and 103 respectively. This is most likely due to the small sample size, and choice of using a normal distribution for the likelihood. I will end this answer with a warning: This code is for teaching purposes. For a real analysis use RJAGS and depending on your sample size fit a t-distribution for the likelihood. If there is interest I will post a t-test using RJAGS. EDIT: As requested here is a JAGS model. ```r model.str <- 'model { for (i in 1:Ntotal) { y[i] ~ dt(mu[x[i]], tau[x[i]], nu) } for (j in 1:2) { mu[j] ~ dnorm(mu_pooled, tau_pooled) tau[j] <- 1 / pow(sigma[j], 2) sigma[j] ~ dunif(sigma_low, sigma_high) } nu <- nu_minus_one + 1 nu_minus_one ~ dexp(1 / 29) }' # Indicator variable x <- c(rep(1, length(sample.1)), rep(2, length(sample.2))) cpd.model <- jags.model(textConnection(model.str), data=list(y=pooled, x=x, mu_pooled=mean(pooled), tau_pooled=1/(1000 * sd(pooled))^2, sigma_low=sd(pooled) / 1000, sigma_high=sd(pooled) * 1000, Ntotal=length(pooled))) update(cpd.model, 1000) chain <- coda.samples(model = cpd.model, n.iter = 100000, variable.names = c('mu', 'sigma')) rchain <- as.matrix(chain) hist(rchain[, 'mu[1]'] - rchain[, 'mu[2]']) mean(rchain[, 'mu[1]'] - rchain[, 'mu[2]'] < 0) mean(rchain[, 'mu[2]'] - rchain[, 'mu[1]'] > 5) ```
> > a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples. > > > There are several approaches to "testing" this. I'll mention a couple: * If you want an explicit *decision* you could look at decision theory. * A pretty simple thing that's sometimes done is to find an interval for the difference in the means and consider whether it includes 0 or not. That would involve starting with a model for the observations, priors on the parameters and computation of the posterior distribution of the difference in means conditional on the data. You'd need to say what your model is (e.g. normal, constant variance), and then (at least) some prior for the difference in means and a prior for the variance. You might have priors on the parameters of those priors in turn. Or you might *not* assume constant variance. Or you might assume something other than normality.
130,389
I'm not looking for a plug and play method like BEST in R but rather a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples.
2014/12/26
[ "https://stats.stackexchange.com/questions/130389", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/61501/" ]
The excellent answer by user1068430 implemented in Python ```py import numpy as np from pylab import plt def dnorm(x, mu, sig): return 1/(sig * np.sqrt(2 * np.pi)) * np.exp(-(x - mu)**2 / (2 * sig**2)) def dexp(x, l): return l * np.exp(- l*x) def like(parameters): [mu1, sig1, mu2, sig2] = parameters return dnorm(sample1, mu1, sig1).prod()*dnorm(sample2, mu2, sig2).prod() def prior(parameters): [mu1, sig1, mu2, sig2] = parameters return dnorm(mu1, pooled.mean(), 1000*pooled.std()) * dnorm(mu2, pooled.mean(), 1000*pooled.std()) * dexp(sig1, 0.1) * dexp(sig2, 0.1) def posterior(parameters): [mu1, sig1, mu2, sig2] = parameters return like([mu1, sig1, mu2, sig2])*prior([mu1, sig1, mu2, sig2]) #create samples sample1 = np.random.normal(100, 3, 8) sample2 = np.random.normal(100, 7, 10) pooled= np.append(sample1, sample2) plt.figure(0) plt.hist(sample1) plt.hold(True) plt.hist(sample2) plt.show(block=False) mu1 = 100 sig1 = 10 mu2 = 100 sig2 = 10 parameters = np.array([mu1, sig1, mu2, sig2]) niter = 10000 results = np.zeros([niter, 4]) results[1,:] = parameters for iteration in np.arange(2,niter): candidate = parameters + np.random.normal(0,0.5,4) ratio = posterior(candidate)/posterior(parameters) if np.random.uniform() < ratio: parameters = candidate results[iteration,:] = parameters #burn-in results = results[499:niter-1,:] mu1 = results[:,1] mu2 = results[:,3] d = (mu1 - mu2) p_value = np.mean(d > 0) plt.figure(1) plt.hist(d,normed = 1) plt.show() ``` ```
> > a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples. > > > There are several approaches to "testing" this. I'll mention a couple: * If you want an explicit *decision* you could look at decision theory. * A pretty simple thing that's sometimes done is to find an interval for the difference in the means and consider whether it includes 0 or not. That would involve starting with a model for the observations, priors on the parameters and computation of the posterior distribution of the difference in means conditional on the data. You'd need to say what your model is (e.g. normal, constant variance), and then (at least) some prior for the difference in means and a prior for the variance. You might have priors on the parameters of those priors in turn. Or you might *not* assume constant variance. Or you might assume something other than normality.
130,389
I'm not looking for a plug and play method like BEST in R but rather a mathematical explanation of what are some Bayesian methods I can use to test the difference between the mean of two samples.
2014/12/26
[ "https://stats.stackexchange.com/questions/130389", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/61501/" ]
This is a good question, that seems to pop up a lot: [link 1](https://stats.stackexchange.com/questions/15777/what-is-the-bayesian-counterpart-to-a-two-sample-t-test-with-unequal-variances/47240#47240), [link 2](https://stats.stackexchange.com/questions/104932/bayesian-alternative-or-complement-to-the-student-t-test). The paper [Bayesian Estimation Superseeds the T-Test](http://www.indiana.edu/~kruschke/BEST/BEST.pdf) that Cam.Davidson.Pilon pointed out is an excellent resource on this subject. It is also very recent, published in 2012, which I think in part is due to the current interest in the area. I will try to summarize a mathematical explanation of a Bayesian alternative to the two sample t-test. This summary is similar to the BEST paper which assess the difference in two samples by comparing the difference in their posterior distributions (explained below in R). ```r set.seed(7) #create samples sample.1 <- rnorm(8, 100, 3) sample.2 <- rnorm(10, 103, 7) #we need a pooled data set for estimating parameters in the prior. pooled <- c(sample.1, sample.2) par(mfrow=c(1, 2)) hist(sample.1) hist(sample.2) ``` ![enter image description here](https://i.stack.imgur.com/xxl3d.png) In order to compare the sample means we need to estimate what they are. The Bayesian method to do so uses Bayes' theorem: [P(A|B) = P(B|A) \* P(A)/P(B)](http://en.wikipedia.org/wiki/Bayes%27_theorem) (the syntax of P(A|B) is read as the probability of A given B) Thanks to modern numerical methods we can ignore the probability of B, P(B), and use the proportional statment: P(A|B) $\propto$ P(B|A)\*P(A) In Bayesian vernacular **the posterior is proportional to the likelihood times the prior** Applying Bayes' theory to our problem where we want to know the means of samples given some data we get $P(mean.1 | sample.1)$ $\propto$ $P(sample.1 | mean.1) \* P(mean.1)$. The first term on the right is the likelihood, $P(sample.1 | mean.1)$, which is the probability of observing the sample data given mean.1. The second term is the prior, $P(mean.1)$, which is simply the probability of mean.1. Figuring out appropriate priors is still a bit of an art and is one of the biggest critisims of Bayesian methods. Let's put it in code. Code makes everything better. ```r likelihood <- function(parameters){ mu1=parameters[1]; sig1=parameters[2]; mu2=parameters[3]; sig2=parameters[4] prod(dnorm(sample.1, mu1, sig1)) * prod(dnorm(sample.2, mu2, sig2)) } prior <- function(parameters){ mu1=parameters[1]; sig1=parameters[2]; mu2=parameters[3]; sig2=parameters[4] dnorm(mu1, mean(pooled), 1000*sd(pooled)) * dnorm(mu2, mean(pooled), 1000*sd(pooled)) * dexp(sig1, rate=0.1) * dexp(sig2, 0.1) } ``` I made some assumptions in the prior that need to be justified. To keep the priors from prejudicing the estimated mean I wanted to make them broad and uniform-ish over plausible values with the aim of letting the data produce the features of the posterior. I used recommended setting from BEST and distributed the mu's normally with mean = mean(pooled) and a broad standard deviation = 1000\*sd(pooled). The standard deviations I set to a broad exponential distribution, because I wanted a broad unbounded distribution. Now we can make the posterior ```r posterior <- function(parameters) {likelihood(parameters) * prior(parameters)} ``` We will sample the posterior distribution using a [markov chain monte carlo](http://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm) (MCMC) with Metropolis Hastings modification. Its easiest to understand with code. ```r #starting values mu1 = 100; sig1 = 10; mu2 = 100; sig2 = 10 parameters <- c(mu1, sig1, mu2, sig2) #this is the MCMC /w Metropolis method n.iter <- 10000 results <- matrix(0, nrow=n.iter, ncol=4) results[1, ] <- parameters for (iteration in 2:n.iter){ candidate <- parameters + rnorm(4, sd=0.5) ratio <- posterior(candidate)/posterior(parameters) if (runif(1) < ratio) parameters <- candidate #Metropolis modification results[iteration, ] <- parameters } ``` The results matrix is a list of samples from the posterior distribution for each parameter which we can use to answer our original question: Is sample.1 different than sample.2? But first to avoid affects from the starting values we will "burn-in" the first 500 values of the chain. ```r #burn-in results <- results[500:n.iter,] ``` Now, is sample.1 different than sample.2? ```r mu1 <- results[,1] mu2 <- results[,3] hist(mu1 - mu2) ``` ![enter image description here](https://i.stack.imgur.com/tW7g5.png) ```r mean(mu1 - mu2 < 0) [1] 0.9953689 ``` From this analysis I would conclude there is a 99.5% chance that the mean for sample.1 is less than the mean for sample.2. An advantage of the Bayesian approach, as pointed out in the BEST paper, is that it can make strong theories. E.G. what is the probability that sample.2 is 5 units bigger than sample.1. ```r mean(mu2 - mu1 > 5) [1] 0.9321124 ``` We would conclude that there is a 93% chance that the mean of sample.2 is 5 unit greater than sample.1. An observant reader would find that interesting because we know the true populations have means of 100 and 103 respectively. This is most likely due to the small sample size, and choice of using a normal distribution for the likelihood. I will end this answer with a warning: This code is for teaching purposes. For a real analysis use RJAGS and depending on your sample size fit a t-distribution for the likelihood. If there is interest I will post a t-test using RJAGS. EDIT: As requested here is a JAGS model. ```r model.str <- 'model { for (i in 1:Ntotal) { y[i] ~ dt(mu[x[i]], tau[x[i]], nu) } for (j in 1:2) { mu[j] ~ dnorm(mu_pooled, tau_pooled) tau[j] <- 1 / pow(sigma[j], 2) sigma[j] ~ dunif(sigma_low, sigma_high) } nu <- nu_minus_one + 1 nu_minus_one ~ dexp(1 / 29) }' # Indicator variable x <- c(rep(1, length(sample.1)), rep(2, length(sample.2))) cpd.model <- jags.model(textConnection(model.str), data=list(y=pooled, x=x, mu_pooled=mean(pooled), tau_pooled=1/(1000 * sd(pooled))^2, sigma_low=sd(pooled) / 1000, sigma_high=sd(pooled) * 1000, Ntotal=length(pooled))) update(cpd.model, 1000) chain <- coda.samples(model = cpd.model, n.iter = 100000, variable.names = c('mu', 'sigma')) rchain <- as.matrix(chain) hist(rchain[, 'mu[1]'] - rchain[, 'mu[2]']) mean(rchain[, 'mu[1]'] - rchain[, 'mu[2]'] < 0) mean(rchain[, 'mu[2]'] - rchain[, 'mu[1]'] > 5) ```
The excellent answer by user1068430 implemented in Python ```py import numpy as np from pylab import plt def dnorm(x, mu, sig): return 1/(sig * np.sqrt(2 * np.pi)) * np.exp(-(x - mu)**2 / (2 * sig**2)) def dexp(x, l): return l * np.exp(- l*x) def like(parameters): [mu1, sig1, mu2, sig2] = parameters return dnorm(sample1, mu1, sig1).prod()*dnorm(sample2, mu2, sig2).prod() def prior(parameters): [mu1, sig1, mu2, sig2] = parameters return dnorm(mu1, pooled.mean(), 1000*pooled.std()) * dnorm(mu2, pooled.mean(), 1000*pooled.std()) * dexp(sig1, 0.1) * dexp(sig2, 0.1) def posterior(parameters): [mu1, sig1, mu2, sig2] = parameters return like([mu1, sig1, mu2, sig2])*prior([mu1, sig1, mu2, sig2]) #create samples sample1 = np.random.normal(100, 3, 8) sample2 = np.random.normal(100, 7, 10) pooled= np.append(sample1, sample2) plt.figure(0) plt.hist(sample1) plt.hold(True) plt.hist(sample2) plt.show(block=False) mu1 = 100 sig1 = 10 mu2 = 100 sig2 = 10 parameters = np.array([mu1, sig1, mu2, sig2]) niter = 10000 results = np.zeros([niter, 4]) results[1,:] = parameters for iteration in np.arange(2,niter): candidate = parameters + np.random.normal(0,0.5,4) ratio = posterior(candidate)/posterior(parameters) if np.random.uniform() < ratio: parameters = candidate results[iteration,:] = parameters #burn-in results = results[499:niter-1,:] mu1 = results[:,1] mu2 = results[:,3] d = (mu1 - mu2) p_value = np.mean(d > 0) plt.figure(1) plt.hist(d,normed = 1) plt.show() ``` ```
3,127,238
How do I convert java.util.Map[String, Object] to scala.collection.immutable.Map[String, Any], so that all values in the original map (integers, booleans etc.) are converted to the right value to work well in Scala.
2010/06/27
[ "https://Stackoverflow.com/questions/3127238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/129750/" ]
As VonC says, `scala.collections.JavaConversion` supports mutable collections only, but you don't have to use a separate library. Mutable collections are derived from `TraversableOnce` which defines a `toMap` method that returns an immutable Map: ``` import scala.collection.JavaConversions._ val m = new java.util.HashMap[String, Object]() m.put("Foo", java.lang.Boolean.TRUE) m.put("Bar", java.lang.Integer.valueOf(1)) val m2: Map[String, Any] = m.toMap println(m2) ``` This will output ``` Map(Foo -> true, Bar -> 1) ```
The **[`JavaConversions`](http://www.scala-lang.org/archives/rc-api/scala/collection/JavaConversions$.html)** package of Scala2.8 deals only with mutable collections. The [**scalaj-collection**](http://github.com/scalaj/scalaj-collection) library might help here. ``` java.util.Map[A, B] #asScala: scala.collection.Map[A, B] #asScalaMutable: scala.collection.mutable.Map[A, B] #foreach(((A, B)) => Unit): Unit ```
3,127,238
How do I convert java.util.Map[String, Object] to scala.collection.immutable.Map[String, Any], so that all values in the original map (integers, booleans etc.) are converted to the right value to work well in Scala.
2010/06/27
[ "https://Stackoverflow.com/questions/3127238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/129750/" ]
As VonC says, `scala.collections.JavaConversion` supports mutable collections only, but you don't have to use a separate library. Mutable collections are derived from `TraversableOnce` which defines a `toMap` method that returns an immutable Map: ``` import scala.collection.JavaConversions._ val m = new java.util.HashMap[String, Object]() m.put("Foo", java.lang.Boolean.TRUE) m.put("Bar", java.lang.Integer.valueOf(1)) val m2: Map[String, Any] = m.toMap println(m2) ``` This will output ``` Map(Foo -> true, Bar -> 1) ```
In order to convert convert java.util.Map[String, Object] to scala.collection.immutable.Map[String,Object] , you need to simple import below statement in Scala Project and clean build. ``` import collection.JavaConversions._ ``` Refer to below code: ``` var empMap= Map[String.Object]() var emp= new Employee(empMap) // Employee is java POJO in which,passing scala map to overloaded constructor for setting default values. ```
12,357,170
For learning purposes I'm building a simple messaging program that I think can work with local storage. Another question about 2 dimensional arrays is in the comments. ``` <!DOCTYPE HTML> <html>      <head>              <title>waGwan?</title>              <meta charset="utf-8"/> <link rel=stylesheet href=comm.css></link>        </head>      <body>         <section> <p>enter or create passcode: <input type=text id=passcode></p> <input type=button id="button" value="send"> </section> <section id="log"></section> <script type="text/javascript"> //initializing my passcode. Pass is a two dimensional array that holds passcodes and arrays of corresponding message logs; how can I instantiate my passcode without nil but maintain pass as a two dimensional array, just not include pass? var pass=[mypasscode,nil]; document.getElementById("button").onclick=checkPass; function checkPass(){ for(i=0;i<pass.length;i++){ //exits if passcode exists if(document.getElementById("passcode").value==pass[i]){ break; } //if passcode doesn't equal last existing passcode the passcode and a new array (that stores the message log) is added to the pass array else if(document.getElementById("passcode").value!==pass[pass.length-1]){ pass.push(document.getElementById("passcode").value,[We can chat here.]); } } document.write("x"); } </script> </body> </html> ```
2012/09/10
[ "https://Stackoverflow.com/questions/12357170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1656125/" ]
It looks like there are hacks and workarounds that get you part way there but for what you're trying to do you need a fully working solution so it looks like **you can't** which is too bad, I love a good hack :) Edit: future readers should read the comments for a full discussion.
One idea is to save the current date at the start of the program, to a variable that is nil until it is first set. Then you have the date when the app is first run. You may also check the date of the Documents folder which is created when the App is downloaded. If you store this date as a user preference variable then it is preserved event when you update the App. Then you can compare that date to data you get from your server.
24,436,274
I am studying the implementation of `strtok` and have a question. On this line, `s [-1] = 0`, I don't understand how `tok` is limited to the first token since we had previously assigned it everything contained in `s`. ``` char *strtok(char *s, const char *delim) { static char *last; return strtok_r(s, delim, &last); } char *strtok_r(char *s, const char *delim, char **last) { char *spanp; int c, sc; char *tok; if (s == NULL && (s = *last) == NULL) return (NULL); tok = s; for (;;) { c = *s++; spanp = (char *)delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = 0; *last = s; return (tok); } } while (sc != 0); } } ```
2014/06/26
[ "https://Stackoverflow.com/questions/24436274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3780071/" ]
`tok` was not previously assigned "everything contained in `s`". It was set to point to the same address as the address in `s`. The `s[-1] = 0;` line is equivalent to `*(s - 1) = '\0';`, which sets the location just before where `s` is pointing to zero. By setting that location to zero, returning the current value of `tok` will point to a string whose data spans from `tok` to `s - 2` and is properly null-terminated at `s - 1`. Also note that before `tok` is returned, `*last` is set to the current value of `s`, which is the starting scan position for the next token. `strtok` saves this value in a static variable so it can be remembered and automatically used for the next token.
There are two ways to reach the statement `return(tok);`. One way is that at the point where `tok = s;` occurs, `s` contains none of the delimiter characters (contents of `delim`). That means `s` is a single token. The `for` loop ends when `c == 0`, that is, at the null byte at the end of `s`, and `strtok_r` returns `tok` (that is, the entire string that was in `s` at the time of `tok = s;`), as it should. The other way for that return statement to occur is when `s` contains some character that is in `delim`. In that case, at some point `*spanp == c` will be true where `*spanp` is not the terminating null of `delim`, and therefore `c == 0` is false. At this point, `s` points to the character *after* the one from which `c` was read, and `s - 1` points to the place where the delimiter was found. The statement `s[-1] = 0;` overwrites the delimiter with a null character, so now `tok` points to a string of characters that starts where `tok = s;` said to start, and ends at the first delimiter that was found in that string. In other words, `tok` now points to the first token in that string, no more and no less, and it is correctly returned by the function. The code is not very well self-documenting in my opinion, so it is understandable that it is confusing.
24,436,274
I am studying the implementation of `strtok` and have a question. On this line, `s [-1] = 0`, I don't understand how `tok` is limited to the first token since we had previously assigned it everything contained in `s`. ``` char *strtok(char *s, const char *delim) { static char *last; return strtok_r(s, delim, &last); } char *strtok_r(char *s, const char *delim, char **last) { char *spanp; int c, sc; char *tok; if (s == NULL && (s = *last) == NULL) return (NULL); tok = s; for (;;) { c = *s++; spanp = (char *)delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = 0; *last = s; return (tok); } } while (sc != 0); } } ```
2014/06/26
[ "https://Stackoverflow.com/questions/24436274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3780071/" ]
This took much more space than I anticipated when I started, but I think it offers a useful explanation along with the others. (it became more of a mission really) **NOTE:** This combination of `strtok` and `strtok_r` attempt to provide a reentrant implementation of the usual `strtok` from `string.h` by saving the address of the `last` character as a static variable in `strtok`. (whether it is reentrant was not tested) The easiest way to understand this code (at least for me) is to understand what `strtok` and `strtok_r` do with the string they are operating on. Here `strtok_r` is where the work is done. `strtok_r` basically assigns a pointer to the string provided as an argument and then **'inch-worms'** down the string, character-by-character, comparing each character to a delimiter character or null terminating character. The key is to understand that the job of `strtok_r` is to chop the string up into separate tokens, which are returned on successive calls to the function. How does it work? The string is broken up into separate tokens by replacing each delimiter character found in the original string with a null-terminating character and returning a pointer to the beginning of the token (which will either be the start of the string on first call, or the **next-character after the last delimiter** on successive calls) As with the `string.h strtok` function, the first call to `strtok` takes the original string as the first argument. For successive parsing of the same string `NULL` is used as the first argument. The original string is left littered with null-terminating characters after calls to `strtok`, so make a copy if you need it further. Below is an explanation of what goes on in `strtok_r` as you **inch-worm** down the string. Consider for example the following string and `strtok_r`: ``` 'this is a test' ``` **The outer for loop stepping through string `s`** (ignoring the assignments and the `NULL` tests, the function assigns `tok` a pointer to the beginning of the string (`tok = s`). It then enters the for loop where it will step through string `s` one character at a time. `c` is assigned the (int value of) the current character pointed to by 's', and the pointer for `s` in incremented to the next character (this is the **for loop increment of 's'**). `spanp` is assigned the pointer to the delimiter array. **The inner do loop stepping though the delimeters 'delim'** The do loop is entered and then, using the `spanp` pointer, proceeds to go through the `delim` array testing if `sc` (the `spanp` character) equals the current for loop character `c`. If and only if our character `c` matches a delimiter, we then encounter the confusing `if (c == 0)` `if-then-else` test. **The `if (c == 0)` `if-then-else` test** This test is actually simple to understand when you think about it. As we are crawling down string `s` checking each character against the `delim` array. If we match one of the delimiters or hit the end, then what? We are about to return from the function, so what must we do? Here we ask, did we reach the normal end of the string `(c == 0)`, if so we set `s = NULL`, otherwise we match a delimiter, but are not at the end of the string. **Here is where the magic happens**. We need to replace the delimiter character in the string with a null-terminating character (either `0` or `'\0'`). Why not set the pointer `s = 0` here? Answer: we can't, we incremented it assigning `c = *s++;` at the beginning of the for loop, so **`s` is now pointing to the next character in the string rather than the delimiter**. So in order to replace the delimiter in string `s` with a null-terminating character, we must do `s[-1] = 0;` This is where the string `s` gets chopped into a token. `last` is assigned the address of the current pointer `s` and `tok` (pointing to the original beginning of `s`) is returned by the function. So, in the main program, you how have the return of `strtok_r` which is a pointer pointing to the first character in the string `s` you passed to `strtok_r` which is now null-terminated at the first occurrence of the matching character in `delim` providing you with the token from the original string `s` you asked for.
There are two ways to reach the statement `return(tok);`. One way is that at the point where `tok = s;` occurs, `s` contains none of the delimiter characters (contents of `delim`). That means `s` is a single token. The `for` loop ends when `c == 0`, that is, at the null byte at the end of `s`, and `strtok_r` returns `tok` (that is, the entire string that was in `s` at the time of `tok = s;`), as it should. The other way for that return statement to occur is when `s` contains some character that is in `delim`. In that case, at some point `*spanp == c` will be true where `*spanp` is not the terminating null of `delim`, and therefore `c == 0` is false. At this point, `s` points to the character *after* the one from which `c` was read, and `s - 1` points to the place where the delimiter was found. The statement `s[-1] = 0;` overwrites the delimiter with a null character, so now `tok` points to a string of characters that starts where `tok = s;` said to start, and ends at the first delimiter that was found in that string. In other words, `tok` now points to the first token in that string, no more and no less, and it is correctly returned by the function. The code is not very well self-documenting in my opinion, so it is understandable that it is confusing.
16,351,743
How to format MySQL query date to this format? Current my variable is getting this 08/13/2013 but in my database is 2013-08-13. ``` $sql_stmt = "select * from abs where myname = 'david' and date between '$start' and '$end' order by log_id;"; ```
2013/05/03
[ "https://Stackoverflow.com/questions/16351743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2010278/" ]
Try: ``` $sql_stmt = "select * from abs where myname = 'david' and date between STR_TO_DATE('$start', '%m/%d/%Y') and STR_TO_DATE('$end', '%m/%d/%Y') order by log_id;"; ```
see the examples in the date format section [HERE](https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format) UPDATE you can format it almost anyway, check this [**SQLFIDDLE**](http://sqlfiddle.com/#!2/ac953/2)
16,351,743
How to format MySQL query date to this format? Current my variable is getting this 08/13/2013 but in my database is 2013-08-13. ``` $sql_stmt = "select * from abs where myname = 'david' and date between '$start' and '$end' order by log_id;"; ```
2013/05/03
[ "https://Stackoverflow.com/questions/16351743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2010278/" ]
Try: ``` $sql_stmt = "select * from abs where myname = 'david' and date between STR_TO_DATE('$start', '%m/%d/%Y') and STR_TO_DATE('$end', '%m/%d/%Y') order by log_id;"; ```
you can convert the output string into variable date format and then compare it. ``` $sql_stmt = "select *,DATE_FORMAT(date, '%d/%c/%Y') as date1 from abs where myname = 'david' and date1 between '$start' and '$end' order by log_id;"; ```
16,351,743
How to format MySQL query date to this format? Current my variable is getting this 08/13/2013 but in my database is 2013-08-13. ``` $sql_stmt = "select * from abs where myname = 'david' and date between '$start' and '$end' order by log_id;"; ```
2013/05/03
[ "https://Stackoverflow.com/questions/16351743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2010278/" ]
Try: ``` $sql_stmt = "select * from abs where myname = 'david' and date between STR_TO_DATE('$start', '%m/%d/%Y') and STR_TO_DATE('$end', '%m/%d/%Y') order by log_id;"; ```
We have ``` mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y'); -> 'Saturday October 1997' ``` and we can possibly adapt your solution to ``` $sql_stmt = "select * from abs where myname = 'david' and DATE_FORMAT(date, '%W %M %Y') between STR_TO_DATE('$start', '%m/%d/%Y') and STR_TO_DATE('$end', '%m/%d/%Y') order by log_id;"; ```
22,707,906
I need to export packages deployed in SSISDB by any means to make it automated; so a command line, C# or T-SQL would be fine. I don't want the manual way used by Visual Studio. Thanks
2014/03/28
[ "https://Stackoverflow.com/questions/22707906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1901545/" ]
I finally got it. Use stored procedure in SSISDB "catalog.get\_project" which will return project\_stream. Save it to a file with ".zip" extension and extract the packages from it. This is because [as per Microsoft documentation](http://download.microsoft.com/download/1/7/5/175A7833-6F75-418D-8800-86D44D1D712D/%5BMS-ISPAC%5D.pdf) the ISPAC file is based on OPC standard which is genuinely was invented by Microsoft and used for pptx, docx ... etc.
IsDeploymentWizard is a good option. You can see parameter usage by typing ``` IsDeploymentWizard -h ``` on the command line.
571,928
Because space is a delimiter when parsing macro names, I got used to ending macros in running text with `{}` like in `text \foobar{} text`, because I find the escaped space in `text \foobar\ text` disturbing. Sometimes this habit spills over into math mode. Obviously ``` \[ \sum{}^{...} \] ``` does not work as intended when really ``` \[ \sum^{...} \] ``` was meant. How are they parsed and what are the differences? Edit: I meant the `\foo\` solution, not a double space.
2020/11/22
[ "https://tex.stackexchange.com/questions/571928", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/85123/" ]
TeX creates math list which is (roughly speaking) a sequence of atoms, each atom has nucleus+subscript+superscript. Each part of the atom can be empty. The sequence of atoms are converted to the definite `\hboxes` (raised or lowered) in the second pas of scanning math mode material. First example `\sum{}^a` creates first atom with nucleus: sum character, subscript and superscript are empty. It is followed by second atom with empty nucleus, empty subscript and superscript is `a`. Second example `\sum^a` creates only one atom with sum character in nucleus and `a` in superscript. The subscript is empty. The differences in visible output is given by differences in interpreting the two atoms versus one atom in second pass over math material. The positioning of superscript depends on the size of the nucleus and on the type of the atom.
In the first version, `\sum` and `{}^{...}` are independent of each other. The second is typeset the same way, independently of `\sum`. The result of `\[ \sum{}^{a}\qquad {}^{a} \]`: [![enter image description here](https://i.stack.imgur.com/JhFWR.png)](https://i.stack.imgur.com/JhFWR.png) In the second version, the exponent is attributed to `sum` and is interpreted as upper limit. The result of `\[ \sum^{a}\qquad {}^{a} \]`: [![enter image description here](https://i.stack.imgur.com/PmDPH.png)](https://i.stack.imgur.com/PmDPH.png)
571,928
Because space is a delimiter when parsing macro names, I got used to ending macros in running text with `{}` like in `text \foobar{} text`, because I find the escaped space in `text \foobar\ text` disturbing. Sometimes this habit spills over into math mode. Obviously ``` \[ \sum{}^{...} \] ``` does not work as intended when really ``` \[ \sum^{...} \] ``` was meant. How are they parsed and what are the differences? Edit: I meant the `\foo\` solution, not a double space.
2020/11/22
[ "https://tex.stackexchange.com/questions/571928", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/85123/" ]
TeX creates math list which is (roughly speaking) a sequence of atoms, each atom has nucleus+subscript+superscript. Each part of the atom can be empty. The sequence of atoms are converted to the definite `\hboxes` (raised or lowered) in the second pas of scanning math mode material. First example `\sum{}^a` creates first atom with nucleus: sum character, subscript and superscript are empty. It is followed by second atom with empty nucleus, empty subscript and superscript is `a`. Second example `\sum^a` creates only one atom with sum character in nucleus and `a` in superscript. The subscript is empty. The differences in visible output is given by differences in interpreting the two atoms versus one atom in second pass over math material. The positioning of superscript depends on the size of the nucleus and on the type of the atom.
The technical reason is that, in math mode, `{}` is a math atom and is not something that gets discarded. It's generally not a good idea to define macros to stand for text, because this reduces readability of the code, but in some occasions some macro that's not to be followed by arguments has to be used. The typical example is the command `\LaTeX`. Anyway, if you have text commands that are not to be followed by a argument in braces, terminating it with `{}` is a good strategy for keeping a following space. In math this is disastrous, as you witnessed. Just leave a space: if you want to type the sine of *x*, do `\sin x`. ***Never*** use `{}` to terminate a command name in math mode: compare ``` \sin(x+y) \sin{}(x+y) ``` to see the reason: [![enter image description here](https://i.stack.imgur.com/VRlzt.png)](https://i.stack.imgur.com/VRlzt.png) In standard math typesetting there should be no space between “sin” and the parenthesis. The empty atom `{}` is of type “ordinary” and will trigger the space like in `\sin x`. What happens with `\sum{}_x^y`? That the subscript and superscripts are to the (empty) atom represented by `{}`: the `\sum` atom has already gone its way.
4,999,851
I'm trying to inflate an custom alertdialog and encountered something strange. ``` layout = inflater.inflate(R.layout.call_or_sms_dialog,(ViewGroup)findViewById(R.id.contacts)); ``` The inflate() method takes 2 argument, the resource to be inflated and the optional view to be the parent of the generated dialog. My problem comes at the optional view part. I can't find the id of the root view from findViewById(R.id.contacts). "contacts" is a xml file that contains the controls for this particular activity. I was able to reference some other xml file of other activities but just couldn't reference this contacts.xml. I've tried doing the "clean" build on Eclipse and regenerating the R.java but still it does not help. Is there any way to manually generate the ID of "contacts.xml" instead?
2011/02/15
[ "https://Stackoverflow.com/questions/4999851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/584187/" ]
> > > > > > "contacts" is a xml file that contains the controls for this particular activity > > > > > > > > > If it's an XML, you cannot access it by using `R.id`; but something like `R.xml` or `R.layout`. Of course, if you are using `findViewById` you must pass a valid id (something referenced by `R.id`). So... what you have to do is give an ID to the view that you want to reference; for instance: ``` <ViewGroup android:id="@+id/contacts" blah ``` Also, keep in mind that, if you are using the `findViewById` method directly, the ID must be part of the current layout (I mean the layout set in `setContentView`). If the ID does not belong to the current layout you will want to execute something like `referenceToTheViewContainingTheIDResource.findViewById()` instead.
The second argument is meant to be an existing view, not the root view of the layout you are inflating. Is this the problem? You can always just pass `null` as the second argument.
4,999,851
I'm trying to inflate an custom alertdialog and encountered something strange. ``` layout = inflater.inflate(R.layout.call_or_sms_dialog,(ViewGroup)findViewById(R.id.contacts)); ``` The inflate() method takes 2 argument, the resource to be inflated and the optional view to be the parent of the generated dialog. My problem comes at the optional view part. I can't find the id of the root view from findViewById(R.id.contacts). "contacts" is a xml file that contains the controls for this particular activity. I was able to reference some other xml file of other activities but just couldn't reference this contacts.xml. I've tried doing the "clean" build on Eclipse and regenerating the R.java but still it does not help. Is there any way to manually generate the ID of "contacts.xml" instead?
2011/02/15
[ "https://Stackoverflow.com/questions/4999851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/584187/" ]
> > > > > > "contacts" is a xml file that contains the controls for this particular activity > > > > > > > > > If it's an XML, you cannot access it by using `R.id`; but something like `R.xml` or `R.layout`. Of course, if you are using `findViewById` you must pass a valid id (something referenced by `R.id`). So... what you have to do is give an ID to the view that you want to reference; for instance: ``` <ViewGroup android:id="@+id/contacts" blah ``` Also, keep in mind that, if you are using the `findViewById` method directly, the ID must be part of the current layout (I mean the layout set in `setContentView`). If the ID does not belong to the current layout you will want to execute something like `referenceToTheViewContainingTheIDResource.findViewById()` instead.
``` Please try this code: LayoutInflater inflater = LayoutInflater.from(this); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("SET YOUR TITLE"); View view = inflater.inflate(R.layout.call_or_sms_dialog, null); v = (ViewGroup)findViewById(R.id.contacts); alertDialog.setView(view); ```
4,999,851
I'm trying to inflate an custom alertdialog and encountered something strange. ``` layout = inflater.inflate(R.layout.call_or_sms_dialog,(ViewGroup)findViewById(R.id.contacts)); ``` The inflate() method takes 2 argument, the resource to be inflated and the optional view to be the parent of the generated dialog. My problem comes at the optional view part. I can't find the id of the root view from findViewById(R.id.contacts). "contacts" is a xml file that contains the controls for this particular activity. I was able to reference some other xml file of other activities but just couldn't reference this contacts.xml. I've tried doing the "clean" build on Eclipse and regenerating the R.java but still it does not help. Is there any way to manually generate the ID of "contacts.xml" instead?
2011/02/15
[ "https://Stackoverflow.com/questions/4999851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/584187/" ]
``` Please try this code: LayoutInflater inflater = LayoutInflater.from(this); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("SET YOUR TITLE"); View view = inflater.inflate(R.layout.call_or_sms_dialog, null); v = (ViewGroup)findViewById(R.id.contacts); alertDialog.setView(view); ```
The second argument is meant to be an existing view, not the root view of the layout you are inflating. Is this the problem? You can always just pass `null` as the second argument.
256,223
A friend of mine got her iPhone stolen. When entering iCloud to activate the "Find my iPhone" feature, I see that her account has 3 phones associated with it. The 3 phones are named: * Iphone * Iphone * (Name)'s Iphone. How can I know which is her current one? Her previous models are a iPhone 4S, an iPhone 5 and an iPhone 6. I don't see any place to check each phone's model.
2016/10/06
[ "https://apple.stackexchange.com/questions/256223", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/36725/" ]
It's too late now to identify the iPhone. This must be done **prior** to losing the device, when you're able to provide a name for it. Find iPhone doesn't list the specific device. To name the device, go to `Settings -> General -> About` and in the **Name** field enter a specific device name (for example, 'PaulJ's iPhone 5s'). Then, when you need to locate the device, it will get the name you entered and it can be identified. The only thing you can do now is the process of elimination. Figure out which of the 3 devices listed is not accounted for someplace or, perhaps, not turned on.
Thanks everybody for your answers. In the end, as usual, I found the answer in the most stupid way possible: I went to the "Settings" section in iCloud.com, and in "My devices", it shows the currently backed up devices. The iPhone that shows up there is the "(name)'s iPhone" one. (It hasn't appeared yet, though :-( ).
256,223
A friend of mine got her iPhone stolen. When entering iCloud to activate the "Find my iPhone" feature, I see that her account has 3 phones associated with it. The 3 phones are named: * Iphone * Iphone * (Name)'s Iphone. How can I know which is her current one? Her previous models are a iPhone 4S, an iPhone 5 and an iPhone 6. I don't see any place to check each phone's model.
2016/10/06
[ "https://apple.stackexchange.com/questions/256223", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/36725/" ]
If you load the image of your device in "Find My iPhone" in a new tab, you are able to get the model identifier ID from the URL. As an example, here's the URL for an iPad that I lost quite a while ago: ``` https://statici.icloud.com/fmipmobile/deviceImages-9.0/iPad/iPad2,1/locked-nolocation_ipad.png ``` I wasn't sure whether this was an iPad 1 or 2, but the URL clearly shows that it's an iPad 2 (`iPad2,1`). See [this list](http://www.everymac.com/systems/by_capability/mac-specs-by-machine-model-machine-id.html) of all Mac model identifiers, and [this one](http://www.everyi.com/by-identifier/ipod-iphone-ipad-specs-by-model-identifier.html) for mobile devices.
It's too late now to identify the iPhone. This must be done **prior** to losing the device, when you're able to provide a name for it. Find iPhone doesn't list the specific device. To name the device, go to `Settings -> General -> About` and in the **Name** field enter a specific device name (for example, 'PaulJ's iPhone 5s'). Then, when you need to locate the device, it will get the name you entered and it can be identified. The only thing you can do now is the process of elimination. Figure out which of the 3 devices listed is not accounted for someplace or, perhaps, not turned on.
256,223
A friend of mine got her iPhone stolen. When entering iCloud to activate the "Find my iPhone" feature, I see that her account has 3 phones associated with it. The 3 phones are named: * Iphone * Iphone * (Name)'s Iphone. How can I know which is her current one? Her previous models are a iPhone 4S, an iPhone 5 and an iPhone 6. I don't see any place to check each phone's model.
2016/10/06
[ "https://apple.stackexchange.com/questions/256223", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/36725/" ]
Out of curiosity I logged into my account to see if there was any way of differentiating. Other than the iPad and the Mac mini, they are remarkably difficult to tell apart. This is further compounded by the name issue. That said, in the below image, the top iPhone is a 7, the next one is a 5, the next one is a 5s, the next one is a 6, the one after that is a 5s, then a 5, and the one at the very bottom is a 6s. Note if they say offline and you tap on them, you get a bigger image. (If they're not offline, you get only a slightly bigger image.) You can also try using your browser's zoom function. Remember that the 6 series moved the sleep/wake button to the right side, so that may help. [![enter image description here](https://i.stack.imgur.com/y006p.png)](https://i.stack.imgur.com/y006p.png) [![enter image description here](https://i.stack.imgur.com/cdAwr.png)](https://i.stack.imgur.com/cdAwr.png)
Thanks everybody for your answers. In the end, as usual, I found the answer in the most stupid way possible: I went to the "Settings" section in iCloud.com, and in "My devices", it shows the currently backed up devices. The iPhone that shows up there is the "(name)'s iPhone" one. (It hasn't appeared yet, though :-( ).
256,223
A friend of mine got her iPhone stolen. When entering iCloud to activate the "Find my iPhone" feature, I see that her account has 3 phones associated with it. The 3 phones are named: * Iphone * Iphone * (Name)'s Iphone. How can I know which is her current one? Her previous models are a iPhone 4S, an iPhone 5 and an iPhone 6. I don't see any place to check each phone's model.
2016/10/06
[ "https://apple.stackexchange.com/questions/256223", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/36725/" ]
If you load the image of your device in "Find My iPhone" in a new tab, you are able to get the model identifier ID from the URL. As an example, here's the URL for an iPad that I lost quite a while ago: ``` https://statici.icloud.com/fmipmobile/deviceImages-9.0/iPad/iPad2,1/locked-nolocation_ipad.png ``` I wasn't sure whether this was an iPad 1 or 2, but the URL clearly shows that it's an iPad 2 (`iPad2,1`). See [this list](http://www.everymac.com/systems/by_capability/mac-specs-by-machine-model-machine-id.html) of all Mac model identifiers, and [this one](http://www.everyi.com/by-identifier/ipod-iphone-ipad-specs-by-model-identifier.html) for mobile devices.
Out of curiosity I logged into my account to see if there was any way of differentiating. Other than the iPad and the Mac mini, they are remarkably difficult to tell apart. This is further compounded by the name issue. That said, in the below image, the top iPhone is a 7, the next one is a 5, the next one is a 5s, the next one is a 6, the one after that is a 5s, then a 5, and the one at the very bottom is a 6s. Note if they say offline and you tap on them, you get a bigger image. (If they're not offline, you get only a slightly bigger image.) You can also try using your browser's zoom function. Remember that the 6 series moved the sleep/wake button to the right side, so that may help. [![enter image description here](https://i.stack.imgur.com/y006p.png)](https://i.stack.imgur.com/y006p.png) [![enter image description here](https://i.stack.imgur.com/cdAwr.png)](https://i.stack.imgur.com/cdAwr.png)
256,223
A friend of mine got her iPhone stolen. When entering iCloud to activate the "Find my iPhone" feature, I see that her account has 3 phones associated with it. The 3 phones are named: * Iphone * Iphone * (Name)'s Iphone. How can I know which is her current one? Her previous models are a iPhone 4S, an iPhone 5 and an iPhone 6. I don't see any place to check each phone's model.
2016/10/06
[ "https://apple.stackexchange.com/questions/256223", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/36725/" ]
If you load the image of your device in "Find My iPhone" in a new tab, you are able to get the model identifier ID from the URL. As an example, here's the URL for an iPad that I lost quite a while ago: ``` https://statici.icloud.com/fmipmobile/deviceImages-9.0/iPad/iPad2,1/locked-nolocation_ipad.png ``` I wasn't sure whether this was an iPad 1 or 2, but the URL clearly shows that it's an iPad 2 (`iPad2,1`). See [this list](http://www.everymac.com/systems/by_capability/mac-specs-by-machine-model-machine-id.html) of all Mac model identifiers, and [this one](http://www.everyi.com/by-identifier/ipod-iphone-ipad-specs-by-model-identifier.html) for mobile devices.
Thanks everybody for your answers. In the end, as usual, I found the answer in the most stupid way possible: I went to the "Settings" section in iCloud.com, and in "My devices", it shows the currently backed up devices. The iPhone that shows up there is the "(name)'s iPhone" one. (It hasn't appeared yet, though :-( ).
33,230,600
I'm a nub scripter and am trying to write a really simple script to taskkill 2 programs and then uninstall 1 of them. I wrote it in Powershell and stuck it in SCCM for deployment...however every time I deploy it, it's not running the last line to uninstall the program. Here's the code: ```js # Closing Outlook instance # taskkill /IM outlook.exe /F # # Closing Linkpoint instance # taskkill /IM LinkPointAssist.exe /F # # Uninstalling Linkpoint via uninstall string if in Program Files # MsiExec.exe /X {DECDCD14-DEF6-49ED-9440-CC5E562FDC41} /qn # # Uninstalling Linkpoint via WmiObject if installed manually in AppData Get-WmiObject -class win32_product -Filter "Name like '%Linkpoint%'" | ForEach-Object { $_.Uninstall()} # Exit ``` Can someone help? SCCM says the script completes with no error and I know it's able to execute it since the taskkills work...but it's not uninstalling the program. Thanks in advance for any input.
2015/10/20
[ "https://Stackoverflow.com/questions/33230600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4310432/" ]
You may try this ``` SELECT * FROM T1, T2 WHERE REGEXP_REPLACE(T2.Name_Status, '^(.+?)_(.+?)ed$', '\1') = T1.name AND REGEXP_REPLACE(T2.Name_Status, '^(.+?)_(.+?)ed$', '\2') = T1.status ```
This would work out fine ``` SELECT name_status FROM(SELECT * FROM tbl1, tbl2 WHERE tbl2.name_status REGEXP concat(tbl1.name,"_",tbl1.status)) as temp ```
898,328
![enter image description here](https://i.stack.imgur.com/Ia731.gif) Imagine two similiar circles. We rotate one on half of the other circumference. It gives a sphere with volume of $1/2(2πr) \cdot πr^2 = π^2r^3$
2014/08/15
[ "https://math.stackexchange.com/questions/898328", "https://math.stackexchange.com", "https://math.stackexchange.com/users/122210/" ]
The problem is that the points closer to the center line of the circle don't move a distance of $2\pi r$ when the circle is rotated $2\pi$ radians. Rather a point at distance $h$ from the center line moves a distance of $2\pi h$. Now at distance $h$ the length of the rotating segment parallel to the center line is $2\sqrt{r^2 - h^2}$. Thus the volume is $$\int\_0^r 2\sqrt{r^2 - h^2} \cdot 2\pi h \, dh = \frac{4 \pi r^3}{3}.$$
It is only the top of the semicircle that travels $2\pi$, That gives a contribution to the volume of $2\pi$ times the area of the top. Other parts of the semicircle - near the diameter - travel much shorter distances, so contribute smaller multiples of their area to the volume.
898,328
![enter image description here](https://i.stack.imgur.com/Ia731.gif) Imagine two similiar circles. We rotate one on half of the other circumference. It gives a sphere with volume of $1/2(2πr) \cdot πr^2 = π^2r^3$
2014/08/15
[ "https://math.stackexchange.com/questions/898328", "https://math.stackexchange.com", "https://math.stackexchange.com/users/122210/" ]
It is only the top of the semicircle that travels $2\pi$, That gives a contribution to the volume of $2\pi$ times the area of the top. Other parts of the semicircle - near the diameter - travel much shorter distances, so contribute smaller multiples of their area to the volume.
For a more general view, any dimension, it turns out that the easy way to find the volume of higher dimensional spheres, including the one in $\mathbb R^3,$ is by adding two to the dimension and using polar coordinates. Given that the $n$-volume of the sphere of radius $R$ in $\mathbb R^n$ is $$ \omega\_n R^n, $$ the easy calculation is that the $(n+2)$-volume of the sphere of radius $R$ in $\mathbb R^{n+2}$ is $$ \frac{2 \pi \omega\_n}{n+2} R^{n+2}, $$ or $$ \omega\_{n+2} = \frac{2 \pi \omega\_n}{n+2}. $$ Your example is $\omega\_1 = 2,$ a segment of "radius" $1$ so length $2,$ so $\omega\_3 = \frac{2 \pi 2}{3} = \frac{4 \pi }{3}.$ The odd ones are $$ \omega\_1 = 2, \; \omega\_3 = \frac{4 \pi }{3}, \; \omega\_5 = \frac{8 \pi^2 }{15}, \ \omega\_7 = \frac{16 \pi^3 }{105},..., \; \omega\_{2k +1} = \frac{ 2^{k+1} \; \; \pi^k}{(2k+1)!!} $$ The even ones are $$ \omega\_2 = \pi, \; \omega\_4 = \frac{ \pi^2 }{2}, \; \omega\_6 = \frac{ \pi^3 }{6}, ..., \; \omega\_{2k} = \frac{\pi^k}{k!} $$ Compare <http://en.wikipedia.org/wiki/N-sphere#Closed_forms>
898,328
![enter image description here](https://i.stack.imgur.com/Ia731.gif) Imagine two similiar circles. We rotate one on half of the other circumference. It gives a sphere with volume of $1/2(2πr) \cdot πr^2 = π^2r^3$
2014/08/15
[ "https://math.stackexchange.com/questions/898328", "https://math.stackexchange.com", "https://math.stackexchange.com/users/122210/" ]
The problem is that the points closer to the center line of the circle don't move a distance of $2\pi r$ when the circle is rotated $2\pi$ radians. Rather a point at distance $h$ from the center line moves a distance of $2\pi h$. Now at distance $h$ the length of the rotating segment parallel to the center line is $2\sqrt{r^2 - h^2}$. Thus the volume is $$\int\_0^r 2\sqrt{r^2 - h^2} \cdot 2\pi h \, dh = \frac{4 \pi r^3}{3}.$$
For a more general view, any dimension, it turns out that the easy way to find the volume of higher dimensional spheres, including the one in $\mathbb R^3,$ is by adding two to the dimension and using polar coordinates. Given that the $n$-volume of the sphere of radius $R$ in $\mathbb R^n$ is $$ \omega\_n R^n, $$ the easy calculation is that the $(n+2)$-volume of the sphere of radius $R$ in $\mathbb R^{n+2}$ is $$ \frac{2 \pi \omega\_n}{n+2} R^{n+2}, $$ or $$ \omega\_{n+2} = \frac{2 \pi \omega\_n}{n+2}. $$ Your example is $\omega\_1 = 2,$ a segment of "radius" $1$ so length $2,$ so $\omega\_3 = \frac{2 \pi 2}{3} = \frac{4 \pi }{3}.$ The odd ones are $$ \omega\_1 = 2, \; \omega\_3 = \frac{4 \pi }{3}, \; \omega\_5 = \frac{8 \pi^2 }{15}, \ \omega\_7 = \frac{16 \pi^3 }{105},..., \; \omega\_{2k +1} = \frac{ 2^{k+1} \; \; \pi^k}{(2k+1)!!} $$ The even ones are $$ \omega\_2 = \pi, \; \omega\_4 = \frac{ \pi^2 }{2}, \; \omega\_6 = \frac{ \pi^3 }{6}, ..., \; \omega\_{2k} = \frac{\pi^k}{k!} $$ Compare <http://en.wikipedia.org/wiki/N-sphere#Closed_forms>