qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
3,063,930 | I have a simple string which is delimited by some character, let's say a comma. I should be able to create a TStringList and set it's delimiter to a comma then set the DelimitedText to the text I want to parse and it should be automaticlly parsed.
The problem is when I look at the output it also includes spaces as del... | 2010/06/17 | [
"https://Stackoverflow.com/questions/3063930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/332617/"
] | There's a StrictDelimiter property on the TStringList. Set it to True and it will only parse on the delimiter, not the spaces. | You can have a look on the function "ExtractStrings" , if you are using d7 |
4,412,979 | Our connectivity to EMS code was initially ill-designed and created one TopicConnection object per topic that we listened to. So, in effect, whenever we subscribed to a topic, we create a new connection, a new session and, lastly, a new listener.
We would like to switch to a single connection model. Although I am able... | 2010/12/10 | [
"https://Stackoverflow.com/questions/4412979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7583/"
] | The .NET EMS API is based on [JMS](http://dlc.sun.com/pdf/816-5904-10/816-5904-10.pdf). In JMS, the Connection and Session objects are specified to be thread-safe and can be reused within the program. You are quite correct in that the Connection object simply represent a network pipe to the EMS server. The EMS User's G... | I think yes as long as sharing is within the same application (exe, binary).
We have shared same connection object, and used it as a singleton in our code. |
4,412,979 | Our connectivity to EMS code was initially ill-designed and created one TopicConnection object per topic that we listened to. So, in effect, whenever we subscribed to a topic, we create a new connection, a new session and, lastly, a new listener.
We would like to switch to a single connection model. Although I am able... | 2010/12/10 | [
"https://Stackoverflow.com/questions/4412979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7583/"
] | The .NET EMS API is based on [JMS](http://dlc.sun.com/pdf/816-5904-10/816-5904-10.pdf). In JMS, the Connection and Session objects are specified to be thread-safe and can be reused within the program. You are quite correct in that the Connection object simply represent a network pipe to the EMS server. The EMS User's G... | Agree with an earlier answer: the JMS Session must not be shared between threads, but the Connection can/should be. So one connection per application is ok (make sure you start/close it only once - best before/after the individual threads creation).
And then create and use one Session per thread. Remember that when yo... |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | ```
void CallFunction ()
{ // <----- At this point the compiler knows
// nothing about the members of B.
B b;
b.bFunction();
}
```
This happens for the same reason that functions in C cannot call each other without at least one of them being declared as a function prototyp... | in A you have used a definition of B which is not given until then , that's why the compiler is giving error . |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | ```
void CallFunction ()
{ // <----- At this point the compiler knows
// nothing about the members of B.
B b;
b.bFunction();
}
```
This happens for the same reason that functions in C cannot call each other without at least one of them being declared as a function prototyp... | What you should do, is put `CallFunction` into \*.cpp file, where you include B.h.
After edit, files will look like:
B.h:
====
```
#pragma once //or other specific to compiler...
using namespace std;
class A
{
public:
void CallFunction ();
};
class B: public A
{
public:
virtual void bFunction()
{
... |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | What you should do, is put `CallFunction` into \*.cpp file, where you include B.h.
After edit, files will look like:
B.h:
====
```
#pragma once //or other specific to compiler...
using namespace std;
class A
{
public:
void CallFunction ();
};
class B: public A
{
public:
virtual void bFunction()
{
... | Forward declare `class B` and swap order of `A` and `B` definitions: 1st `B` and 2nd `A`. You can not call methods of forward declared `B` class. |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | ```
void CallFunction ()
{ // <----- At this point the compiler knows
// nothing about the members of B.
B b;
b.bFunction();
}
```
This happens for the same reason that functions in C cannot call each other without at least one of them being declared as a function prototyp... | class B is only **declared** but not **defined** at the beginning, which is what the compiler complains about. The root cause is that in class A's Call Function, you are referencing instance b of type `B`, which is incomplete and undefined. You can modify source like this without introducing new file(just for sake of s... |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | What you should do, is put `CallFunction` into \*.cpp file, where you include B.h.
After edit, files will look like:
B.h:
====
```
#pragma once //or other specific to compiler...
using namespace std;
class A
{
public:
void CallFunction ();
};
class B: public A
{
public:
virtual void bFunction()
{
... | Here's my solution to the issue. Tried to keep it straight and simple.
```
#include <iostream>
using namespace std;
class Game{
public:
void init(){
cout << "Hi" << endl;
}
}g;
class b : Game{ //class b uses/imports class Game
public:
void h(){
init(); //Use function from class Game
}
}A;
int main(... |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | ```
void CallFunction ()
{ // <----- At this point the compiler knows
// nothing about the members of B.
B b;
b.bFunction();
}
```
This happens for the same reason that functions in C cannot call each other without at least one of them being declared as a function prototyp... | Forward declare `class B` and swap order of `A` and `B` definitions: 1st `B` and 2nd `A`. You can not call methods of forward declared `B` class. |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | class B is only **declared** but not **defined** at the beginning, which is what the compiler complains about. The root cause is that in class A's Call Function, you are referencing instance b of type `B`, which is incomplete and undefined. You can modify source like this without introducing new file(just for sake of s... | in A you have used a definition of B which is not given until then , that's why the compiler is giving error . |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | ```
void CallFunction ()
{ // <----- At this point the compiler knows
// nothing about the members of B.
B b;
b.bFunction();
}
```
This happens for the same reason that functions in C cannot call each other without at least one of them being declared as a function prototyp... | You can also have a look at the [curiously recurring template pattern](https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) and solve your problem similar to this:
```cpp
template<typename B_TYPE>
struct A
{
int callFctn()
{
B_TYPE b;
return b.bFctn();
}
};
struct B : A<B>
{... |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | What you should do, is put `CallFunction` into \*.cpp file, where you include B.h.
After edit, files will look like:
B.h:
====
```
#pragma once //or other specific to compiler...
using namespace std;
class A
{
public:
void CallFunction ();
};
class B: public A
{
public:
virtual void bFunction()
{
... | in A you have used a definition of B which is not given until then , that's why the compiler is giving error . |
14,173,217 | Very new to c++ having trouble calling a function from another class.
Class B inherits from Class A, and I want class A to be able to call a function created in class B.
```
using namespace std;
class B;
class A
{
public:
void CallFunction ()
{
B b;
b.bFunction();
}
};
class B: publ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14173217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1451008/"
] | class B is only **declared** but not **defined** at the beginning, which is what the compiler complains about. The root cause is that in class A's Call Function, you are referencing instance b of type `B`, which is incomplete and undefined. You can modify source like this without introducing new file(just for sake of s... | Here's my solution to the issue. Tried to keep it straight and simple.
```
#include <iostream>
using namespace std;
class Game{
public:
void init(){
cout << "Hi" << endl;
}
}g;
class b : Game{ //class b uses/imports class Game
public:
void h(){
init(); //Use function from class Game
}
}A;
int main(... |
57,323,333 | I have a data frame,in which, two of the columns are Age and Income. I have clustered the data Using Kmeans. Now I want to plot between Age and Income distinguishing the data points based on Clusters (By Colours)
df
```
Age Income Cluster
20 10000 1
30 20000 2
40 25000 1
50 20000... | 2019/08/02 | [
"https://Stackoverflow.com/questions/57323333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11758952/"
] | You could use `ggplot()` for this:
```
ggplot() +
geom_point(mapping = aes(x = Age, y = Income, color = Cluster))
```
Here it is creating the aesthetics based on the values in the data (x position of the point is based on age, y position on the income, and colour of the point on the variable "cluster").
You could... | I found one Using plot function
df
Age Income
20 10000
30 20000
40 25000
50 20000
60 10000
70 15000
clust <- kmeans(df,centers = 3) *# df without the last "Cluster" Column as in the Question*
plot(df,col=clust$cluster, color=TRUE,las=1,xlab ="Age",ylab="Income") *# df containing only Columns Age an... |
57,323,333 | I have a data frame,in which, two of the columns are Age and Income. I have clustered the data Using Kmeans. Now I want to plot between Age and Income distinguishing the data points based on Clusters (By Colours)
df
```
Age Income Cluster
20 10000 1
30 20000 2
40 25000 1
50 20000... | 2019/08/02 | [
"https://Stackoverflow.com/questions/57323333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11758952/"
] | try something like this :
```
library(ggplot2)
ggplot() + geom_point(data = df, aes(x = Age, y = Income, group = Cluster, color = Cluster))
``` | I found one Using plot function
df
Age Income
20 10000
30 20000
40 25000
50 20000
60 10000
70 15000
clust <- kmeans(df,centers = 3) *# df without the last "Cluster" Column as in the Question*
plot(df,col=clust$cluster, color=TRUE,las=1,xlab ="Age",ylab="Income") *# df containing only Columns Age an... |
20,156,057 | I have a simple working example:
```
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<toolkit:ListPicker>
<toolkit:ListPickerItem Content="FIRST" />
<toolkit:ListPickerItem Content="SECOND" />
<toolkit:L... | 2013/11/22 | [
"https://Stackoverflow.com/questions/20156057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/218826/"
] | You can't create a `LinkedList<int>` because the generic types cannot be primitives, but having said that, it's easy to add Integers to a LinkedList and no need to "convert" them to String.
i.e., use a `LinkedList<Integer>`.
Otherwise if this doesn't answer your question, then please tell us more about the actual pr... | You can do it using iteration.
Then use `Integer.toString` method to convert each element from Integer to String.
```
LinkedList<String> strings = new LinkedList<String>();
for(LinkedList<Integer> item : integers ){
strings.add(Integer.toString(item));
}
```
This will work for you. |
16,631,423 | When using the Grep command to find a search string in a set of files, how do I dump the results to a text file?
Also is there a switch for the Grep command that provides cleaner results for better readability, such as a line feed between each entry or a way to justify file names and search results?
For instance, a a... | 2013/05/19 | [
"https://Stackoverflow.com/questions/16631423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2398188/"
] | ```
grep -n "YOUR SEARCH STRING" * > output-file
```
The `-n` will print the line number and the `>` will redirect grep-results to the output-file.
If you want to "clean" the results you can filter them using pipe `|` for example:
`grep -n "test" * | grep -v "mytest" > output-file`
will match all the lines that h... | Redirection of program output is performed by the shell.
```
grep ... > output.txt
```
`grep` has no mechanism for adding blank lines between each match, but does provide options such as context around the matched line and colorization of the match itself. See the `grep(1)` man page for details, specifically the `-C... |
16,631,423 | When using the Grep command to find a search string in a set of files, how do I dump the results to a text file?
Also is there a switch for the Grep command that provides cleaner results for better readability, such as a line feed between each entry or a way to justify file names and search results?
For instance, a a... | 2013/05/19 | [
"https://Stackoverflow.com/questions/16631423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2398188/"
] | Redirection of program output is performed by the shell.
```
grep ... > output.txt
```
`grep` has no mechanism for adding blank lines between each match, but does provide options such as context around the matched line and colorization of the match itself. See the `grep(1)` man page for details, specifically the `-C... | To add a blank line between lines of text in `grep` output to make it easier to read, pipe (`|`) it through `sed`:
```
grep text-to-search-for file-to-grep | sed G
``` |
16,631,423 | When using the Grep command to find a search string in a set of files, how do I dump the results to a text file?
Also is there a switch for the Grep command that provides cleaner results for better readability, such as a line feed between each entry or a way to justify file names and search results?
For instance, a a... | 2013/05/19 | [
"https://Stackoverflow.com/questions/16631423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2398188/"
] | ```
grep -n "YOUR SEARCH STRING" * > output-file
```
The `-n` will print the line number and the `>` will redirect grep-results to the output-file.
If you want to "clean" the results you can filter them using pipe `|` for example:
`grep -n "test" * | grep -v "mytest" > output-file`
will match all the lines that h... | To add a blank line between lines of text in `grep` output to make it easier to read, pipe (`|`) it through `sed`:
```
grep text-to-search-for file-to-grep | sed G
``` |
3,852,134 | I have a curious problem that I hope is something stupid I overlooked.
I am getting an error that usually occurs when there is a missing column in a mysql table, or a misspelled php variable: "Unknown column 'Bob' in 'field list'"...
Except 'Bob' is not the name of a column, its the VALUE I am trying to assign to the... | 2010/10/04 | [
"https://Stackoverflow.com/questions/3852134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/346466/"
] | Enclose the string in single quotes i.e. 'Bob' before trying to insert the string values | Yes, try to enclose in sigle quotes like this :
```
VALUES ('".$fname."','".$lname etc
```
But better yet you should never insert stuff in the database that way, it open the risk of SQL injection and other bad stuff
unless you are using some draconian php version you can use PDO and use statement. Like in this exam... |
57,581,840 | I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.
The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using. | 2019/08/20 | [
"https://Stackoverflow.com/questions/57581840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640586/"
] | That information is not stored anywhere in Kubernetes. You typically can get the 'current' CPU utilization from a metrics endpoint.
You will have to use another system/database to store that information through time. The most common one to use is the open-source time series DB [Prometheus](https://prometheus.io/). You... | From docker, you can query a container with `docker stats`. To show the instantaneous stats, including CPU, memory, and network usage, of all containers:
```
docker stats --no-stream
```
For gathering the metrics over time, cAdvisor, Prometheus, and Grafana together are a common open source metrics gathering, storag... |
57,581,840 | I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.
The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using. | 2019/08/20 | [
"https://Stackoverflow.com/questions/57581840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640586/"
] | That information is not stored anywhere in Kubernetes. You typically can get the 'current' CPU utilization from a metrics endpoint.
You will have to use another system/database to store that information through time. The most common one to use is the open-source time series DB [Prometheus](https://prometheus.io/). You... | I may be reading too much into how the question is worded: (quote) "how much CPU a pod is actually using"...even though the question also mentions (quote) "to optimize...based on previous runs". So:
For usage history - see Rico's answer.
For current usage, see [`kubectl top`](https://kubernetes.io/docs/reference/gene... |
57,581,840 | I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.
The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using. | 2019/08/20 | [
"https://Stackoverflow.com/questions/57581840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640586/"
] | That information is not stored anywhere in Kubernetes. You typically can get the 'current' CPU utilization from a metrics endpoint.
You will have to use another system/database to store that information through time. The most common one to use is the open-source time series DB [Prometheus](https://prometheus.io/). You... | consider github.com/dpetzold/kube-resource-explorer
```
# /opt/go/bin/kube-resource-explorer -namespace kube-system -reverse -sort MemReq
Namespace Name CpuReq CpuReq% CpuLimit CpuLimit% ... |
57,581,840 | I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.
The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using. | 2019/08/20 | [
"https://Stackoverflow.com/questions/57581840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640586/"
] | I may be reading too much into how the question is worded: (quote) "how much CPU a pod is actually using"...even though the question also mentions (quote) "to optimize...based on previous runs". So:
For usage history - see Rico's answer.
For current usage, see [`kubectl top`](https://kubernetes.io/docs/reference/gene... | From docker, you can query a container with `docker stats`. To show the instantaneous stats, including CPU, memory, and network usage, of all containers:
```
docker stats --no-stream
```
For gathering the metrics over time, cAdvisor, Prometheus, and Grafana together are a common open source metrics gathering, storag... |
57,581,840 | I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.
The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using. | 2019/08/20 | [
"https://Stackoverflow.com/questions/57581840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640586/"
] | consider github.com/dpetzold/kube-resource-explorer
```
# /opt/go/bin/kube-resource-explorer -namespace kube-system -reverse -sort MemReq
Namespace Name CpuReq CpuReq% CpuLimit CpuLimit% ... | From docker, you can query a container with `docker stats`. To show the instantaneous stats, including CPU, memory, and network usage, of all containers:
```
docker stats --no-stream
```
For gathering the metrics over time, cAdvisor, Prometheus, and Grafana together are a common open source metrics gathering, storag... |
57,581,840 | I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.
The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using. | 2019/08/20 | [
"https://Stackoverflow.com/questions/57581840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640586/"
] | I may be reading too much into how the question is worded: (quote) "how much CPU a pod is actually using"...even though the question also mentions (quote) "to optimize...based on previous runs". So:
For usage history - see Rico's answer.
For current usage, see [`kubectl top`](https://kubernetes.io/docs/reference/gene... | consider github.com/dpetzold/kube-resource-explorer
```
# /opt/go/bin/kube-resource-explorer -namespace kube-system -reverse -sort MemReq
Namespace Name CpuReq CpuReq% CpuLimit CpuLimit% ... |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | Theoretically you could get 1 in both situations. This is one of the situations when the compiler may or may not optimize the copy constructor away.
You can find more detailed information on the subject by googling for **"Return value optimization"** and **"Named return value optimization"**, in your case the latter.
... | There will be a copy as you return by value. Optimizing settings can (should) never change the visible behaviour of a program. |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | That a compiler may miss some cases an optimization is possible even if it does it in other cases. AFAIK -- and I've checked now the place which allows the copy constructor elisions -- there is no constraint that the variable must be int the top scope in the function, it must just be an automatic variable. | There will be a copy as you return by value. Optimizing settings can (should) never change the visible behaviour of a program. |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | With which compiler? Both results are legal, so formally, you can't
complain. Practically, I can't see why introducing the scope should
change anything; as a quality of implementation issue, I think you
could complain. | There will be a copy as you return by value. Optimizing settings can (should) never change the visible behaviour of a program. |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | I don't see any reason other than that the compiler is not being smart enough to see that the dummy scope (introduced by extra brackets) makes no difference at all, at least for this particular code. The compiler is being fooled by the extra brackets; it *probably* made the wild assumptions about the rest of the functi... | There will be a copy as you return by value. Optimizing settings can (should) never change the visible behaviour of a program. |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | Theoretically you could get 1 in both situations. This is one of the situations when the compiler may or may not optimize the copy constructor away.
You can find more detailed information on the subject by googling for **"Return value optimization"** and **"Named return value optimization"**, in your case the latter.
... | That a compiler may miss some cases an optimization is possible even if it does it in other cases. AFAIK -- and I've checked now the place which allows the copy constructor elisions -- there is no constraint that the variable must be int the top scope in the function, it must just be an automatic variable. |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | With which compiler? Both results are legal, so formally, you can't
complain. Practically, I can't see why introducing the scope should
change anything; as a quality of implementation issue, I think you
could complain. | That a compiler may miss some cases an optimization is possible even if it does it in other cases. AFAIK -- and I've checked now the place which allows the copy constructor elisions -- there is no constraint that the variable must be int the top scope in the function, it must just be an automatic variable. |
8,522,526 | Original code
```
#include <iostream>
int global;
struct A
{
A(){}
A(const A&x){
++global;
}
~A(){}
};
A foo()
{
A a;
return a;
}
int main()
{
A x = foo();
std::cout << global;
}
```
Output would be `0` on an optimized compiler supporting Named Return Value Optimization.
When ... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8522526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165520/"
] | I don't see any reason other than that the compiler is not being smart enough to see that the dummy scope (introduced by extra brackets) makes no difference at all, at least for this particular code. The compiler is being fooled by the extra brackets; it *probably* made the wild assumptions about the rest of the functi... | That a compiler may miss some cases an optimization is possible even if it does it in other cases. AFAIK -- and I've checked now the place which allows the copy constructor elisions -- there is no constraint that the variable must be int the top scope in the function, it must just be an automatic variable. |
54,386,131 | I am getting this error
I have installed keras and other required libraries but don't know why this error is coming
```
from keras.applications import MobileNet
```
>
> ImportError: cannot import name 'MobileNet'.
>
>
> | 2019/01/27 | [
"https://Stackoverflow.com/questions/54386131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8046623/"
] | You should import it as `from keras.applications.mobilenet import MobileNet`. | I found the answer,If we are using Keras 2.2.0 version, then we will not find the applications module inside keras installed directory. Keras has externalized the applications module to a separate directory called keras\_applications from where all the pre-trained models will now get imported. |
54,386,131 | I am getting this error
I have installed keras and other required libraries but don't know why this error is coming
```
from keras.applications import MobileNet
```
>
> ImportError: cannot import name 'MobileNet'.
>
>
> | 2019/01/27 | [
"https://Stackoverflow.com/questions/54386131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8046623/"
] | You should import it as `from keras.applications.mobilenet import MobileNet`. | The problem can be solved by upgrading Keras,Keras-Application version.Check [this answer](https://stackoverflow.com/a/61547033/7355075) for help. |
52,467,936 | All the examples that I see for using spacy just read in a single text file (that is small in size).
How does one load a corpus of text files into spacy?
I can do this with textacy by pickling all the text in the corpus:
```
docs = textacy.io.spacy.read_spacy_docs('E:/spacy/DICKENS/dick.pkl', lang='en')
for doc in ... | 2018/09/23 | [
"https://Stackoverflow.com/questions/52467936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7155242/"
] | So I finally got this working, and it shall be preserved here for posterity.
Start with a generator, here named `iterator` because I'm currently too afraid to change anything for fear of it breaking again:
```
def path_iterator(paths):
for p in paths:
print("yielding")
yield p.open("r").read(25)
... | If you can convert your corpus into a data-frame in a way that each row corresponds to a document, you can basically write a function to do what you want to do and then:
```
df['new_column'] = df['document'].apply(lambda x: your_function(x))
```
Or, I am not sure if this is what you want, but you can try something l... |
52,467,936 | All the examples that I see for using spacy just read in a single text file (that is small in size).
How does one load a corpus of text files into spacy?
I can do this with textacy by pickling all the text in the corpus:
```
docs = textacy.io.spacy.read_spacy_docs('E:/spacy/DICKENS/dick.pkl', lang='en')
for doc in ... | 2018/09/23 | [
"https://Stackoverflow.com/questions/52467936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7155242/"
] | You would just read the files in one at a time. This is what I usually do with my corpora files:
```
import glob
import spacy
nlp = spacy.load("en_core_web_sm")
path = 'your path here\\*.txt'
for file in glob.glob(path):
with open(file, encoding='utf-8', errors='ignore') as file_in:
text = file_in.read()
... | If you can convert your corpus into a data-frame in a way that each row corresponds to a document, you can basically write a function to do what you want to do and then:
```
df['new_column'] = df['document'].apply(lambda x: your_function(x))
```
Or, I am not sure if this is what you want, but you can try something l... |
52,467,936 | All the examples that I see for using spacy just read in a single text file (that is small in size).
How does one load a corpus of text files into spacy?
I can do this with textacy by pickling all the text in the corpus:
```
docs = textacy.io.spacy.read_spacy_docs('E:/spacy/DICKENS/dick.pkl', lang='en')
for doc in ... | 2018/09/23 | [
"https://Stackoverflow.com/questions/52467936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7155242/"
] | So I finally got this working, and it shall be preserved here for posterity.
Start with a generator, here named `iterator` because I'm currently too afraid to change anything for fear of it breaking again:
```
def path_iterator(paths):
for p in paths:
print("yielding")
yield p.open("r").read(25)
... | You would just read the files in one at a time. This is what I usually do with my corpora files:
```
import glob
import spacy
nlp = spacy.load("en_core_web_sm")
path = 'your path here\\*.txt'
for file in glob.glob(path):
with open(file, encoding='utf-8', errors='ignore') as file_in:
text = file_in.read()
... |
164,138 | I'm working on an FPS game. I want to make a little bit of difference in shooting direction, only on the horizontal axis.
To do this, I wrote this code:
```
Temp_Shake_Horizontal.x = Random.Range(-0.1f, 0.1f);
if (Physics.Raycast(the_camera.position, the_camera.forward + Temp_Shake_Horizontal, out BulletDecal_Hit, M... | 2018/09/29 | [
"https://gamedev.stackexchange.com/questions/164138",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/120778/"
] | ```
Temp_Shake_Horizontal.x = Random.Range(-0.1f, 0.1f);
```
This shake is always applied along the world x-axis. That means, if you're aiming along the world x-axis, the shake is being applied forward & backward along your direction of fire (ie. not changing the direction).
To apply the shake relative to your curre... | Actually my problem solved by this way :
```
Temp_Shake_Horizontal = Random.Range(-0.1f, 0.1f) * the_camera.right;
```
without + |
57,169,881 | So I just started working with PyQt5. Right now I only programmed 1 button that's supposed to take text from a line edit, store it in a global variable and put it in a text browser. Now it does this... but with issues.
The text browser does NOT update until I click another program/window and then click my app again
Whe... | 2019/07/23 | [
"https://Stackoverflow.com/questions/57169881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9864490/"
] | I found the same problem as yours and I use MacOS Mojave 10.14.6. This problem maybe due to OS, but I downgraded pyqt5 from the latest 5.14.1 to a stable version 5.9.2, the problem was solved. | 1. `The text browser does NOT update until I click another program/window and then click my app again` - this issue can be related with your OS. I have got incorrect PyQT5 behavior on Ubuntu 16.04 while on Ubuntu 18.04 everything was working fine. Can you share more info?
Note: I tested your script on Ubuntu 18.04, I ... |
57,169,881 | So I just started working with PyQt5. Right now I only programmed 1 button that's supposed to take text from a line edit, store it in a global variable and put it in a text browser. Now it does this... but with issues.
The text browser does NOT update until I click another program/window and then click my app again
Whe... | 2019/07/23 | [
"https://Stackoverflow.com/questions/57169881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9864490/"
] | This problem also happens with macos 10.15.6 + pyqt 5.15.0.
I created a small example with qtdesigner (with 1 lineEdit box, 1 label box, 1 button), and then created python file with pyuic5 as well as with pyside2-uic.
Both the generated python files have the same problem - when "click" is pressed I have to move out of... | 1. `The text browser does NOT update until I click another program/window and then click my app again` - this issue can be related with your OS. I have got incorrect PyQT5 behavior on Ubuntu 16.04 while on Ubuntu 18.04 everything was working fine. Can you share more info?
Note: I tested your script on Ubuntu 18.04, I ... |
57,169,881 | So I just started working with PyQt5. Right now I only programmed 1 button that's supposed to take text from a line edit, store it in a global variable and put it in a text browser. Now it does this... but with issues.
The text browser does NOT update until I click another program/window and then click my app again
Whe... | 2019/07/23 | [
"https://Stackoverflow.com/questions/57169881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9864490/"
] | I found the same problem as yours and I use MacOS Mojave 10.14.6. This problem maybe due to OS, but I downgraded pyqt5 from the latest 5.14.1 to a stable version 5.9.2, the problem was solved. | Here is a cleaner more class-ified (more pythonic pyqt) version of your program I have left commented out stuff in for you to see where it would have been but I removed your coordinate system and replaced it with the more standard Layout style of creating a GUI.
I tested this using python 3.7 pyqt5 on win10 so if ther... |
57,169,881 | So I just started working with PyQt5. Right now I only programmed 1 button that's supposed to take text from a line edit, store it in a global variable and put it in a text browser. Now it does this... but with issues.
The text browser does NOT update until I click another program/window and then click my app again
Whe... | 2019/07/23 | [
"https://Stackoverflow.com/questions/57169881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9864490/"
] | This problem also happens with macos 10.15.6 + pyqt 5.15.0.
I created a small example with qtdesigner (with 1 lineEdit box, 1 label box, 1 button), and then created python file with pyuic5 as well as with pyside2-uic.
Both the generated python files have the same problem - when "click" is pressed I have to move out of... | Here is a cleaner more class-ified (more pythonic pyqt) version of your program I have left commented out stuff in for you to see where it would have been but I removed your coordinate system and replaced it with the more standard Layout style of creating a GUI.
I tested this using python 3.7 pyqt5 on win10 so if ther... |
57,169,881 | So I just started working with PyQt5. Right now I only programmed 1 button that's supposed to take text from a line edit, store it in a global variable and put it in a text browser. Now it does this... but with issues.
The text browser does NOT update until I click another program/window and then click my app again
Whe... | 2019/07/23 | [
"https://Stackoverflow.com/questions/57169881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9864490/"
] | I found the same problem as yours and I use MacOS Mojave 10.14.6. This problem maybe due to OS, but I downgraded pyqt5 from the latest 5.14.1 to a stable version 5.9.2, the problem was solved. | This problem also happens with macos 10.15.6 + pyqt 5.15.0.
I created a small example with qtdesigner (with 1 lineEdit box, 1 label box, 1 button), and then created python file with pyuic5 as well as with pyside2-uic.
Both the generated python files have the same problem - when "click" is pressed I have to move out of... |
29,156,146 | I would like to have an `assert` or `fail` task in my Ansible play that validates that the right code build was deployed. The deployment comes with a `version.properties` file which has the build info I care about.
The 'correct' code version comes from a vars file and is called `desired_build_id`.
How can I validate ... | 2015/03/19 | [
"https://Stackoverflow.com/questions/29156146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/693772/"
] | A much simpler python expression would also do:
```
- name: Read version.properties file
shell: cat /path/to/version.properties
register: version_prop_content
- debug: msg="desired build installed"
when: "'{{desired_build_id}}' in '{{version_prop_content.stdout}}'"
```
Or as I always recommend, avoid using `a... | Figured it out!
The way to do the substring comparison is with `version_prop_content.stdout.find(desired_build_id) > 0` which is true if the substring is present
The `find` command returns index of the substring and -1 if it is not present.
I also changed it to an assert tasks to make it look a bit prettier (`fail`... |
57,686 | I would like to import my File Geodatabase from ArcGIS 10.1 into MS SQL Server 2012.
I have never done it before, so I expect to do the import the same way as import data from excel table.
Problem is when I open MS SQL Server Import wizard and as a data source I choose Esri geodatabse OLE DB provider - an error occu... | 2013/04/10 | [
"https://gis.stackexchange.com/questions/57686",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/9486/"
] | [ArcSDE](http://en.wikipedia.org/wiki/ArcSDE) is the best option to Import and Manage your Geodatabase in Database servers ( SQL server,Oracle ,...) . You can't import File Geodatabase or Personal Geodatabase directly in SQL server . you should use ArcSDE software . The Geodatabase type of ArcSDE is SDE Geodatabase not... | You could also go via shape file (not the most elegant but gets the job done):
FileGeodatabase -> Export to ShapeFile - then use [Shape2SQL](http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx) tool to import shape into Sql Server. |
57,686 | I would like to import my File Geodatabase from ArcGIS 10.1 into MS SQL Server 2012.
I have never done it before, so I expect to do the import the same way as import data from excel table.
Problem is when I open MS SQL Server Import wizard and as a data source I choose Esri geodatabse OLE DB provider - an error occu... | 2013/04/10 | [
"https://gis.stackexchange.com/questions/57686",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/9486/"
] | [ArcSDE](http://en.wikipedia.org/wiki/ArcSDE) is the best option to Import and Manage your Geodatabase in Database servers ( SQL server,Oracle ,...) . You can't import File Geodatabase or Personal Geodatabase directly in SQL server . you should use ArcSDE software . The Geodatabase type of ArcSDE is SDE Geodatabase not... | If you do have access to ArcSDE, then all of your conversion can be done within the ArcGIS Desktop/Arcpy kit of tools. For example, in ArcCatalog you simply right-click the feature class in your file GDB and select Export/Geodatabase (single or multiple items).
If you are not afraid of scripting, I would recommend [py... |
57,686 | I would like to import my File Geodatabase from ArcGIS 10.1 into MS SQL Server 2012.
I have never done it before, so I expect to do the import the same way as import data from excel table.
Problem is when I open MS SQL Server Import wizard and as a data source I choose Esri geodatabse OLE DB provider - an error occu... | 2013/04/10 | [
"https://gis.stackexchange.com/questions/57686",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/9486/"
] | If you do have access to ArcSDE, then all of your conversion can be done within the ArcGIS Desktop/Arcpy kit of tools. For example, in ArcCatalog you simply right-click the feature class in your file GDB and select Export/Geodatabase (single or multiple items).
If you are not afraid of scripting, I would recommend [py... | You could also go via shape file (not the most elegant but gets the job done):
FileGeodatabase -> Export to ShapeFile - then use [Shape2SQL](http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx) tool to import shape into Sql Server. |
58,915,168 | So, I'm trying to create a sketch pad and I'm at the stage where I created the squares, I linked to functions of colouring the squares with DOM and linked a function that creates as many squares as user wants but when I resize the page(mobile, less than normal full screen), the DIV or full square just spreads verticall... | 2019/11/18 | [
"https://Stackoverflow.com/questions/58915168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12143300/"
] | Please consider the following points:
1. `MyClass` does not need to extend `ArrayList`.
2. Use Generics to instantiate the concrete classes e.g. `List<MyClass> numberSeries = new ArrayList<MyClass>();`
3. Override the `toString()` method in `MyClass` so that it becomes easier for you to print it.
Given below is the c... | I don't see why you extend `ArrayList`. I think you are overthinking it, if you just want to build a list of `MyClass` it does not need to extend `ArrayList`
* Remove the extend,
* make a sensible `toString` method on your `MyClass` object so you can see the values in your arrays
```
class MyClass {
public int[]... |
71,098,756 | I have a kiosk application where the kiosk software wraps a registration website where the user pays at the end of the process.
As with many of these types of applications, there is a need after a certain period of inactivity, to redirect to the starting page and/or clear user data.
Since stripe.js "elements" payment... | 2022/02/13 | [
"https://Stackoverflow.com/questions/71098756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2336839/"
] | You can use `Object.entries()` to get hold of both key and value at same time.
From [MDN docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries):
>
> The Object.entries() method returns an array of a given object's own enumerable string-keyed property [key, value] pairs... | With `Object.keys()`, you can work as below:
```js
let input = {
item1: "this is string field value",
item2: "FF FF A2 C4h"
};
let result: {id: string, value: string}[] = [];
Object.keys(input).forEach(function(k) {
let key = k as keyof typeof input;
result.push({
id: k,
value: input[... |
30,847,330 | I have a satis.json file specified like so:
```
{
"name": "My organizations Satis Server",
"homepage": "http://satis.mydomain.org",
"repositories": [
{
"type": "vcs",
"url": "git@git.mydomain.org:/home/git/packages/MyPackage",
"options": {
"ssh2":... | 2015/06/15 | [
"https://Stackoverflow.com/questions/30847330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1385833/"
] | As a workaround, I have managed to get by with setting the `$HOME/.ssh/config` file ([Nixcraft reference](http://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/)) for all of the hosts in the satis.json file like so:
```
Host git.mydomain.org
HostName git.mydomain.org
User git
Port 22
Id... | When building static repository use **-n** switch to use public ssh keys available for your current user in $HOME/.ssh folder. |
53,420,144 | I have such a menu page, on which php generates a list that I get from the database. Here is what it looks like [this](https://i.stack.imgur.com/xvtGZ.jpg)
I just can’t find a simple list style that would fit here, and I also can’t figure out how to make me show only the title, but when I click on it, then the rest of... | 2018/11/21 | [
"https://Stackoverflow.com/questions/53420144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10687905/"
] | First of all, you could change the input's attribute `type` to `"button"` but if you wish to keep it as a `submit` button you'll need to stop the forms submit event to prevent the page navigating away/refreshing.
You do this by using the first argument of the event's function. The first argument holds the event that w... | Change your button type from `submit` to just `button` so the form doesn't actually submit.
```
<input type="button" value="Next" onclick="answerNext();">
```
You'll also want to fix the typo (`documet`) and implement a radio group to prevent both from being selected. Finally, wrap your radio buttons and their text ... |
11,567,086 | I have two files, one with text and another with key / hash values. I want to replace occurrences of the key with the hash values. The following code does this, what I want to know is if there is a better way than the foreach loop I am using.
Thanks all
*Edit: I know it is a bit strange using*
```
s/\n//;
s/\r//;
`... | 2012/07/19 | [
"https://Stackoverflow.com/questions/11567086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1535915/"
] | If your application is using a window and can read the message loop you can simply subscribe to [Microsoft.Win32.SystemEvents.PowerModeChanged](http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.powermodechanged.aspx) like:
```
AddHandler Microsoft.Win32.SystemEvents.PowerModeChanged, AddressOf Syste... | try below:
To restart the pc
```
System.Diagnostics.Process.Start("Shutdown", " -r -t 00")
```
To shutdown the pc
```
System.Diagnostics.Process.Start("Shutdown", " -s -t 00")
``` |
930,625 | how do I draw a ERD with cardinality? I am still in school and I am not sure how to go about it. I just need a sample idea Thanks | 2009/05/30 | [
"https://Stackoverflow.com/questions/930625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Depends on the notation you're using. I find that putting something like "0..\*" or "m" or "1" at one end of the relationship link, near the table it applies to, to denote "zero or more" or "m" or "exactly 1 required" communicates my intent pretty well. | Generally I like to use MS Visio(if you're a student you should be able to get it for free at [Dreamspark](https://www.dreamspark.com/).
Be sure to think about INSTANCE in ERD's instead of classes (I.E. an entity would be called Student, NOT Students).
Avoid many-to-many relationships as they don't make logical sense... |
892,936 | If I want to setup a few Windows 7 or 8 PCs to only permit logins using domain accounts, must I fork out the cash to purchase a Windows Server for this? Or a LDAP server such as the Apache DS or even the LDAP server built in my QNAP NAS would do?
If I further want to apply policies on the PCs such as disabling users f... | 2015/03/23 | [
"https://superuser.com/questions/892936",
"https://superuser.com",
"https://superuser.com/users/430734/"
] | You can set up Linux to act as a domain controller using the SAMBA software. So no, you do not need to buy licenses for Windows Server simply for domain logins.
An ordinary LDAP server however, is not enough.
AFIK, you can even apply group policies using free software, SAMBA v4 certainly supports group policies thoug... | A Samba 4 Domain Controller should provide all the functions you described. In particular it supports group policies and authentication you mentioned out of the box as long as you stick to a single server. Setup isn't too hard as long as you stick to the documentation.
As was already mentioned a standard LDAP server h... |
42,140,262 | When I install Stormpath for .NET Core through the package console I have these errors:
```
Unable to resolve 'Stormpath.Owin.Views.Precompiled (>= 0.4.4)' for '.NETFramework,Version=v4.5.2'.
Unable to resolve 'Stormpath.Owin.Abstractions (>= 1.7.2)' for '.NETFramework,Version=v4.5.2'.
Unable to resolve 'Stormpath.S... | 2017/02/09 | [
"https://Stackoverflow.com/questions/42140262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7541035/"
] | The string value of an element is all of the text that is within it (including inside child elements.
If you want to get the value of every non-empty text node:
```
XDocument xml = XDocument.Load("D:\\test.xml");
foreach (var node in xml.DescendantNodes().OfType<XText>())
{
var value = node.Value.Trim();
if... | Try `foreach(XElement node in xdoc.Nodes())` instead. |
42,140,262 | When I install Stormpath for .NET Core through the package console I have these errors:
```
Unable to resolve 'Stormpath.Owin.Views.Precompiled (>= 0.4.4)' for '.NETFramework,Version=v4.5.2'.
Unable to resolve 'Stormpath.Owin.Abstractions (>= 1.7.2)' for '.NETFramework,Version=v4.5.2'.
Unable to resolve 'Stormpath.S... | 2017/02/09 | [
"https://Stackoverflow.com/questions/42140262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7541035/"
] | I got needed result by the code:
```
XDocument xml = XDocument.Load("D:\\test.xml");
foreach (var node in xml.DescendantNodes())
{
if (node is XText)
{
MessageBox.Show(((XText)node).Value);
//some code...
}
if (node is XElement)
{
//some code for XElement...
}
}
```
T... | Try `foreach(XElement node in xdoc.Nodes())` instead. |
42,140,262 | When I install Stormpath for .NET Core through the package console I have these errors:
```
Unable to resolve 'Stormpath.Owin.Views.Precompiled (>= 0.4.4)' for '.NETFramework,Version=v4.5.2'.
Unable to resolve 'Stormpath.Owin.Abstractions (>= 1.7.2)' for '.NETFramework,Version=v4.5.2'.
Unable to resolve 'Stormpath.S... | 2017/02/09 | [
"https://Stackoverflow.com/questions/42140262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7541035/"
] | I got needed result by the code:
```
XDocument xml = XDocument.Load("D:\\test.xml");
foreach (var node in xml.DescendantNodes())
{
if (node is XText)
{
MessageBox.Show(((XText)node).Value);
//some code...
}
if (node is XElement)
{
//some code for XElement...
}
}
```
T... | The string value of an element is all of the text that is within it (including inside child elements.
If you want to get the value of every non-empty text node:
```
XDocument xml = XDocument.Load("D:\\test.xml");
foreach (var node in xml.DescendantNodes().OfType<XText>())
{
var value = node.Value.Trim();
if... |
5,450,370 | I need to get the first ~50 words from a text for suplying exerpt to the users of my application.
I did the following:
```
use strict;use warnings;use utf8;
binmode(STDOUT, ':utf8');
my $text = <<TXT;
Регулярните изрази ни позволяват да търсим шаблони в данните си.
Повечето букви и символи просто ще съвпадат със сами... | 2011/03/27 | [
"https://Stackoverflow.com/questions/5450370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92795/"
] | Try:
```
#!/usr/bin/env perl
use strict;
use warnings;
my $text = <<TXT;
Регулярните изрази ни позволяват да търсим шаблони в данните си.
Повечето букви и символи просто ще съвпадат със самите себе си.
Например, регулярният израз "test" просто и точно ще съвпада със
символния низ "test". Можете да включите режим,... | If you define a "word" as "\S", you could do something like this:
```
$words = $1 if $text=~/^\s*((?:\S+(?:\s+|$)){0,50})/;
``` |
5,450,370 | I need to get the first ~50 words from a text for suplying exerpt to the users of my application.
I did the following:
```
use strict;use warnings;use utf8;
binmode(STDOUT, ':utf8');
my $text = <<TXT;
Регулярните изрази ни позволяват да търсим шаблони в данните си.
Повечето букви и символи просто ще съвпадат със сами... | 2011/03/27 | [
"https://Stackoverflow.com/questions/5450370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92795/"
] | Try:
```
#!/usr/bin/env perl
use strict;
use warnings;
my $text = <<TXT;
Регулярните изрази ни позволяват да търсим шаблони в данните си.
Повечето букви и символи просто ще съвпадат със самите себе си.
Например, регулярният израз "test" просто и точно ще съвпада със
символния низ "test". Можете да включите режим,... | You could get all the words then remove the excess as in shawnhcorey's solution, or you could stop when you have enough.
```
my @words;
push @words, $1 while @words < 50 && $text =~ /\s*(\S+)/g;
```
**Update**: Removed bad solution. |
52,180,762 | After reading the article [Removing Babel's Stage Presets](https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets) by `babel`, I still not fully understand how to add a proposal from, for example, `stage-3` ([flatMap](https://github.com/tc39/proposal-flatMap)) to `.babelrc`.
As far as I understand, because `... | 2018/09/05 | [
"https://Stackoverflow.com/questions/52180762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806963/"
] | flatMap was removed from @babel/polyfill for babel 7. You need to include it directly from core-js, like
```
import "core-js/fn/array/flat-map";
```
Or if you want all of the polyfills that babel 6 used to include:
```
import "core-js/shim";
```
See: <https://github.com/babel/babel/pull/8440> (or more directly, ... | With core.js 3.x use the following import:
```
import "core-js/features/array/flat-map";
``` |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | The best tab situation and common situations is:
* input: **email**
* input: **password**
* checkbox: keep me **logged** in *(sometimes this is omitted)*
* button: **submit** (note how you can use the spacebar, faster than enter in some situations)
Proofs:
* Google (unified login)
* Yahoo (unified login, includes Fl... | It is irrelevant to respond "I don't use this pattern". Whether or not the pattern is THE dominant one (and your sample-size-one doesn't show this), if it's a significant pattern then it should be respected. Maybe only 10% of users press a tab before enter, but you don't want to piss off 10% of your users for something... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Just think about your own experiences - when you log in to a site, what do you expect to do? Me, I expect to do exactly what Dan said - Username TAB Password TAB enter. I've even seen placed that have "Remember me" functionality maintain this basic concept - On chase.com, to tab to the "remember my username" checkbox, ... | It is irrelevant to respond "I don't use this pattern". Whether or not the pattern is THE dominant one (and your sample-size-one doesn't show this), if it's a significant pattern then it should be respected. Maybe only 10% of users press a tab before enter, but you don't want to piss off 10% of your users for something... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Just think about your own experiences - when you log in to a site, what do you expect to do? Me, I expect to do exactly what Dan said - Username TAB Password TAB enter. I've even seen placed that have "Remember me" functionality maintain this basic concept - On chase.com, to tab to the "remember my username" checkbox, ... | I agree with John. I think that most people press Enter while in the password field (I do), or will click/tap on the Enter button.
However, for the few Windows users that press Tab and then Enter, Dan is right: there shouldn't be anything between the password's edit field and the Enter button.
I singled out Windows u... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Just think about your own experiences - when you log in to a site, what do you expect to do? Me, I expect to do exactly what Dan said - Username TAB Password TAB enter. I've even seen placed that have "Remember me" functionality maintain this basic concept - On chase.com, to tab to the "remember my username" checkbox, ... | I don't believe the dominant UX pattern is Username TAB Password TAB Enter. Why the extra TAB+Enter after typing in the password? Save yourself a keystroke and hit Enter after entering the password to submit the form. As Chase mentions, for login forms: Username TAB Password Enter.
I consider forms having false submi... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Egregious breaks in this pattern are when helpful form designers put the Forgot Password link on the tab stop after password and before the submit button. This inevitably results in the page refreshing, a new form loading. Then, when going back, as per good security practices, the password field (which I typed in the f... | It is irrelevant to respond "I don't use this pattern". Whether or not the pattern is THE dominant one (and your sample-size-one doesn't show this), if it's a significant pattern then it should be respected. Maybe only 10% of users press a tab before enter, but you don't want to piss off 10% of your users for something... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Egregious breaks in this pattern are when helpful form designers put the Forgot Password link on the tab stop after password and before the submit button. This inevitably results in the page refreshing, a new form loading. Then, when going back, as per good security practices, the password field (which I typed in the f... | I don't believe the dominant UX pattern is Username TAB Password TAB Enter. Why the extra TAB+Enter after typing in the password? Save yourself a keystroke and hit Enter after entering the password to submit the form. As Chase mentions, for login forms: Username TAB Password Enter.
I consider forms having false submi... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | The best tab situation and common situations is:
* input: **email**
* input: **password**
* checkbox: keep me **logged** in *(sometimes this is omitted)*
* button: **submit** (note how you can use the spacebar, faster than enter in some situations)
Proofs:
* Google (unified login)
* Yahoo (unified login, includes Fl... | For login forms if the design requires something between password and submit, you can still change the tab order so that it skips the bad experience elements when tabbing. See <https://www.bankofamerica.com/> which is somewhat similar. Tabbing goes user/area/submit, continue tabbing to get the link for the checkbox and... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Egregious breaks in this pattern are when helpful form designers put the Forgot Password link on the tab stop after password and before the submit button. This inevitably results in the page refreshing, a new form loading. Then, when going back, as per good security practices, the password field (which I typed in the f... | I agree with John. I think that most people press Enter while in the password field (I do), or will click/tap on the Enter button.
However, for the few Windows users that press Tab and then Enter, Dan is right: there shouldn't be anything between the password's edit field and the Enter button.
I singled out Windows u... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | Just think about your own experiences - when you log in to a site, what do you expect to do? Me, I expect to do exactly what Dan said - Username TAB Password TAB enter. I've even seen placed that have "Remember me" functionality maintain this basic concept - On chase.com, to tab to the "remember my username" checkbox, ... | For login forms if the design requires something between password and submit, you can still change the tab order so that it skips the bad experience elements when tabbing. See <https://www.bankofamerica.com/> which is somewhat similar. Tabbing goes user/area/submit, continue tabbing to get the link for the checkbox and... |
1,627 | I was intrigued by this statement by [@DanWilson](http://twitter.com/DanWIlson) on Twitter:
>
> All Web Developers: Never Ever Ever
> put anything after the password box
> and before submit button on a form.
> Tab MUST go directly to submit.
>
>
>
When I asked for clarification, he added:
>
> because the UI ... | 2010/09/23 | [
"https://ux.stackexchange.com/questions/1627",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/61/"
] | The best tab situation and common situations is:
* input: **email**
* input: **password**
* checkbox: keep me **logged** in *(sometimes this is omitted)*
* button: **submit** (note how you can use the spacebar, faster than enter in some situations)
Proofs:
* Google (unified login)
* Yahoo (unified login, includes Fl... | I agree with John. I think that most people press Enter while in the password field (I do), or will click/tap on the Enter button.
However, for the few Windows users that press Tab and then Enter, Dan is right: there shouldn't be anything between the password's edit field and the Enter button.
I singled out Windows u... |
70,387,164 | ```js
interface ApiResponse{
data: Student[];
}
interface Student {
name: string;
}
```
Given an example I'm 100% sure I will get **data** but in case data is an empty array this will generate a runtime error.
```js
const response = await fetch(...);
response.data[0].name
Uncaught TypeError: Cannot read proper... | 2021/12/17 | [
"https://Stackoverflow.com/questions/70387164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9416254/"
] | Traditional relational databases won't use an index on a column unless the leading part of the column is specified in the condition, ie:
```
... where my_column like 'FOO%' -- will (usually) use index
... where my_column like '%FOO%' -- will (usually) not use index
```
To efficiently search for terms within content ... | If I create a trigram index on the right columns, it will support this directly.
Much to my surprise, it was actually pretty efficient as well. That is not always a given, some regexp cannot be decomposed to an efficient set of trigrams.
```
create extension pg_trgm;
create index on people using gin (title gin_trgm_o... |
68,049,226 | I have a class called *Category* that takes a variadic constructor. The arguments are strings.
```
class Category
{
string[] definedSets; // Sets supplied to the constructor
public Category(params string[] specifiedSets)
{
definedSets = specifiedSets;
}
etc.
```
A call to the constructor m... | 2021/06/19 | [
"https://Stackoverflow.com/questions/68049226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4157812/"
] | The general problem here is that an array has a fixed size, known at compile-time, but the number of items in an iterator is not known at compile-time — even if it is an `ExactSizeIterator`, there's no const parameter for the size. Therefore, there are no *infallible* conversions from an iterator to an array.
However,... | ### As of Rust 1.63
Use [from\_fn](https://doc.rust-lang.org/std/array/fn.from_fn.html):
```rust
let array: [usize; 5] = core::array::from_fn(|i| i + 1);
assert_eq!(array, [1, 2, 3, 4, 5]);
``` |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | This is already mentioned in the question:
Open:
-----
>
> Separate $EXP^{NP}$ from $AC^0\_2[6]$ ($AC^0[6]$ circuits of depth 2). (see the update below)
>
>
> [Nov. 11, 2010] Separate $EXP$ from $AC^0\_2[6]$.
> Separate $EXP^{NP}$ from $TC^0$.
>
>
>
Known:
------
1. [Alexander Razborov 1987 - Roman Smolens... | What is the largest possible gap between deterministic and (2-sided bounded-error) quantum [query complexities](http://en.wikipedia.org/wiki/Decision_tree_model) for total functions?
Open:
-----
>
> Does there exist a total function whose quantum query complexity is T, and deterministic query complexity is ω(T2)?
> ... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | Let CNF-SAT be the problem of determining whether a given CNF formula is satisfiable (no restrictions on the width of clauses).
>
> Is CNF-SAT on $n$ variables and $m$ clauses solvable in $2^{\delta n} poly(m)$ time, for some $\delta < 1$?
>
>
>
This is a well-known open problem in the area of "faster algorithms ... | Open:
-----
>
> Show an oracle separation between QIP(2) and AM. That is, show a problem in QIP(2)A that is not in AMA.
>
>
>
The big open problem is to show an oracle separation between BQP and PH. But we don't even have a separation between BQP and AM (since AM is in PH, this should be easier). Even worse, make... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | This is already mentioned in the question:
Open:
-----
>
> Separate $EXP^{NP}$ from $AC^0\_2[6]$ ($AC^0[6]$ circuits of depth 2). (see the update below)
>
>
> [Nov. 11, 2010] Separate $EXP$ from $AC^0\_2[6]$.
> Separate $EXP^{NP}$ from $TC^0$.
>
>
>
Known:
------
1. [Alexander Razborov 1987 - Roman Smolens... | A *$(q,\delta,\epsilon)$-locally decodable code (LDC)* is a map $C: \mathbb{F}^m \to \mathbb{F}^n$ such that there is an algorithm $A$, called the local decoder, which, given as input an integer $i \in [m]$ and a received word $y \in \mathbb{F}^n$ that differs from $C(x)$ for some $x \in \mathbb{F}^m$ on at most $\delt... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | Here are three in shortest paths research:
$1$. Is there a linear time algorithm for single source shortest paths in directed graphs with nonnegative weights, at least in the word-RAM model of computation? Note that a linear time algorithm exists for undirected graphs (see Thorup's paper). Based on that, Hagerup has a... | What is the largest possible gap between deterministic and (2-sided bounded-error) quantum [query complexities](http://en.wikipedia.org/wiki/Decision_tree_model) for total functions?
Open:
-----
>
> Does there exist a total function whose quantum query complexity is T, and deterministic query complexity is ω(T2)?
> ... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | OPEN:
Show a lower bound in the cell probe model for an explicit static data-structures problem, that proves that under some "reasonable" space restriction (e.g. that the space is polynomial in the size of the input), then the query time must be at least T, where T is larger than log|Q|, where Q is the set of queries.... | Open:
-----
>
> Show an oracle separation between QIP(2) and AM. That is, show a problem in QIP(2)A that is not in AMA.
>
>
>
The big open problem is to show an oracle separation between BQP and PH. But we don't even have a separation between BQP and AM (since AM is in PH, this should be easier). Even worse, make... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | This is already mentioned in the question:
Open:
-----
>
> Separate $EXP^{NP}$ from $AC^0\_2[6]$ ($AC^0[6]$ circuits of depth 2). (see the update below)
>
>
> [Nov. 11, 2010] Separate $EXP$ from $AC^0\_2[6]$.
> Separate $EXP^{NP}$ from $TC^0$.
>
>
>
Known:
------
1. [Alexander Razborov 1987 - Roman Smolens... | The question of whether decision trees are PAC learnable seems to be at the frontier of computational learning theory.
**OPEN**
>
> Are decision trees (DTs) PAC learnable under
> the uniform distribution on examples (or in general)?
>
>
>
**KNOWN**
>
> * DTs are not learnable under the uniform distribution wit... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | This is already mentioned in the question:
Open:
-----
>
> Separate $EXP^{NP}$ from $AC^0\_2[6]$ ($AC^0[6]$ circuits of depth 2). (see the update below)
>
>
> [Nov. 11, 2010] Separate $EXP$ from $AC^0\_2[6]$.
> Separate $EXP^{NP}$ from $TC^0$.
>
>
>
Known:
------
1. [Alexander Razborov 1987 - Roman Smolens... | I'm not sure if this belongs to the class of *frontier* open problems or *major* open problems, so comments are welcomed.
Open:
-----
>
> Show that whether $\mathsf{NP} = \mathsf{UP}$ implies $\mathsf{PH}$ collapses or not.
>
>
>
$\mathsf{UP}$ (the *unambiguous* polynomial time) is a class defined as decision pr... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | Here are three in shortest paths research:
$1$. Is there a linear time algorithm for single source shortest paths in directed graphs with nonnegative weights, at least in the word-RAM model of computation? Note that a linear time algorithm exists for undirected graphs (see Thorup's paper). Based on that, Hagerup has a... | Let CNF-SAT be the problem of determining whether a given CNF formula is satisfiable (no restrictions on the width of clauses).
>
> Is CNF-SAT on $n$ variables and $m$ clauses solvable in $2^{\delta n} poly(m)$ time, for some $\delta < 1$?
>
>
>
This is a well-known open problem in the area of "faster algorithms ... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | Some PCP open problems:
* **The Sliding Scale Conjecture.** In PCP we want the error of the verifier to be as small as possible. [BGLR](http://portal.acm.org/citation.cfm?id=195467) conjectured that the error can go all the way to $2^{-\Theta(r)}$ where $r$ is the randomness (there is clearly a $2^{-r}$ lower bound). ... | Open:
-----
>
> Show an oracle separation between QIP(2) and AM. That is, show a problem in QIP(2)A that is not in AMA.
>
>
>
The big open problem is to show an oracle separation between BQP and PH. But we don't even have a separation between BQP and AM (since AM is in PH, this should be easier). Even worse, make... |
1,015 | In the thread [Major unsolved problems in theoretical computer science?](https://cstheory.stackexchange.com/questions/174/major-unsolved-problems-in-theoretical-computer-science), Iddo Tzameret made the following excellent comment:
>
> I think we should distinguish between major open problems that are viewed as funda... | 2010/09/06 | [
"https://cstheory.stackexchange.com/questions/1015",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/206/"
] | Here are three in shortest paths research:
$1$. Is there a linear time algorithm for single source shortest paths in directed graphs with nonnegative weights, at least in the word-RAM model of computation? Note that a linear time algorithm exists for undirected graphs (see Thorup's paper). Based on that, Hagerup has a... | Prove that for every $c > 0$, there is a language in $E^{NP}$ that doesn't have (non-uniform) circuits with $c n$ wires. Recall that $E = \bigcup\_{k \geq 1} TIME[2^{k n}]$. That is, prove superlinear circuit lower bounds for exponential time with access to an $NP$ oracle. |
225 | This question might arise from a misunderstanding from my part, but here I am to solve it once and for all.
From my russian courses, I remember my classmates answering "ничего" to questions meaning "Nothing" or something similar.
Now, given that this is a genitive, where the nominative is ничто, what should I answer ... | 2012/06/18 | [
"https://russian.stackexchange.com/questions/225",
"https://russian.stackexchange.com",
"https://russian.stackexchange.com/users/71/"
] | >
> Now, given that this is a genitive, where the nominative is ничто, what should I answer to a question like "что ты делаешь?"?
>
>
>
Normally you would put an object into accusative rather than nominative in this sentence:
*Что ты делаешь? **Свою работу** / What are you doing? My job.*
Ничто is a negative ina... | You may use it as a closed response to an answer suggesting broader reply whenever a) you wish to emphasise that you do not wish to continue a conversation and b) the question has been asked with a reference to a subject denoting a non-existential topic - both logically and grammatically. That is, ничто is used like a ... |
56,623,402 | Doing this exercise from ThinkPython and wanting to do a little extra, trying to modify the exercise function (avoid) to prompt the user repeatedly and perform the calculation to find how many words in a text file (fin) contain the user inputted letters (avoidprompt). It works the first time but after it prompts the us... | 2019/06/16 | [
"https://Stackoverflow.com/questions/56623402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11656419/"
] | When you open a file and do `for line in file`, you've consumed the entire file.
There are two easy solutions:
1) Go back to the start of the file in each iteration of your `while(True)` loop, by doing `fin.seek(0)`
2) Just store the file contents in a list, by replacing the first line of your script with `fin = ope... | I believe you need to do something along these lines:
```
def avoidprompt():
while(True):
n = 0
fin.seek(0)
forbidden = input('gimmie some letters n Ill tell u how many words have em. \n')
for line in fin:
if avoid(line, forbidden) == False:
n = n+1
... |
145,689 | I am a high school student and I am very confused in salt hydrolysis
My confusion is that: when we talk of hydrolysis of salt of weak base and weak acid, we internally assume the degree of hydrolysis of both cation and anion of the salt is assumed to be same but I think it is a very wrong assumption, why don't we simp... | 2021/01/30 | [
"https://chemistry.stackexchange.com/questions/145689",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/98419/"
] | The general approach to solve acido-basic equilibrium problems is:
* respecting charge balance and charge conservation
* respecting mass conservation
* respecting dissociation equilibrium constants for acids, bases and water itself.
Generally, it leads to a set of nonlinear equations for a set of independent variable... | Regarding your degree of hydrolysis expression in the textbook, we have to keep **charge balance** in mind. It is not an assumption, it is a charge balance fundamental requirement because a solution can never have a uncharged specie without its counter ion. A solution is always electrically neutral. For example, $\ce{N... |
145,689 | I am a high school student and I am very confused in salt hydrolysis
My confusion is that: when we talk of hydrolysis of salt of weak base and weak acid, we internally assume the degree of hydrolysis of both cation and anion of the salt is assumed to be same but I think it is a very wrong assumption, why don't we simp... | 2021/01/30 | [
"https://chemistry.stackexchange.com/questions/145689",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/98419/"
] | The general approach to solve acido-basic equilibrium problems is:
* respecting charge balance and charge conservation
* respecting mass conservation
* respecting dissociation equilibrium constants for acids, bases and water itself.
Generally, it leads to a set of nonlinear equations for a set of independent variable... | LOL - I spent so much time trying to decipher your handwriting I missed what you question was.
You actually asked a very pertinent question. It is very very wise to wonder about the boundary conditions of some derived formula.
First let me point out that chemistry problems aren't like pure math problems. In math pi h... |
500,458 | I need to do a voltage conversion to control a servomotor.
I need to convert a pwm signal that ranges from 0V to + 3.3V into an amplified signal that ranges from -10V to + 10V.
I thought about doing this with the use of an operational amplifier (as in the circuit below).
However, I can't get the correct Vout signal,... | 2020/05/18 | [
"https://electronics.stackexchange.com/questions/500458",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/160807/"
] | To address both parts of your question:
1. What's wrong with the current circuit:
So remember that a MOSFET is not actually a symmetric device. It can't turn-off current going in both directions, only in one direction. Your schematic has current flowing from source to drain on the MOSFET, but that is the direction of... | If you just want to generate signals that can be monitored by a 4 - 20 mA analog input then try this.

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f5H38d.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/)
*Fi... |
308,198 | The file size is huge and I have to extract only the lines that match a certain location code which is of variable ( varying from 2 bytes to 8 bytes) length.
I cannot use normal grep since that may give undesirable results. When I search for loc cd mas, if I give `grep mas`, it matches with name thomas...
Since thi... | 2016/09/06 | [
"https://unix.stackexchange.com/questions/308198",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/188503/"
] | `sed` is a good fit for this
```
sed -n '620,628 { /mas/p }'
```
Now it's also possible to have `sed` terminate (so run quicker) after you've read up to the last line you care about; eg
```
sed -n -e '620,628 { /mas/p }' -e '629q'
```
For complete word matches you can change the expression by surrounding it with ... | I would try
```
awk '/mas/ && NR >= 620 && NR <= 628' file
```
where
* `NR` (number of record) is line number
* `/mas/` is searched pattern
* default action is to print the line |
308,198 | The file size is huge and I have to extract only the lines that match a certain location code which is of variable ( varying from 2 bytes to 8 bytes) length.
I cannot use normal grep since that may give undesirable results. When I search for loc cd mas, if I give `grep mas`, it matches with name thomas...
Since thi... | 2016/09/06 | [
"https://unix.stackexchange.com/questions/308198",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/188503/"
] | `sed` is a good fit for this
```
sed -n '620,628 { /mas/p }'
```
Now it's also possible to have `sed` terminate (so run quicker) after you've read up to the last line you care about; eg
```
sed -n -e '620,628 { /mas/p }' -e '629q'
```
For complete word matches you can change the expression by surrounding it with ... | I would try
```
grep -P '^.{620}mas' file
```
If your pattern is changing, you can use variables
```
PAT='mas\b'
grep -nP "^.{620}$PAT" file
``` |
27,980,879 | I'm generating dropdown inputs with php simple html dom. I have some values from database and according them i will add 'selected' value into my select->option dom elements.
```
<select name="myDropDown" id="someID">
<option value="someValue1">Value1Value</option>
<option value="someValue2">Value2Value</option>
... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27980879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154480/"
] | My solution was:
* Set up a variable as `newtComponent answer`
* After destroy the form call this function `answer = newtFormGetCurrent(form);`
* and check if answer was my b1 button `if( answer == b1 )`. | You have to see a guide that explain about callback
```
typedef void (*newtCallback)(newtComponent, void *);
void newtComponentAddCallback(newtComponent co, newtCallback f, void * data);
void newtComponentTakesFocus(newtComponent co, int val);
```
Example of a callback
```
static void b1Callback(newtComponent co, ... |
27,980,879 | I'm generating dropdown inputs with php simple html dom. I have some values from database and according them i will add 'selected' value into my select->option dom elements.
```
<select name="myDropDown" id="someID">
<option value="someValue1">Value1Value</option>
<option value="someValue2">Value2Value</option>
... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27980879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154480/"
] | You have to see a guide that explain about callback
```
typedef void (*newtCallback)(newtComponent, void *);
void newtComponentAddCallback(newtComponent co, newtCallback f, void * data);
void newtComponentTakesFocus(newtComponent co, int val);
```
Example of a callback
```
static void b1Callback(newtComponent co, ... | You are using a deprecated function **newtRunForm()**. Use **newtFormRun()**. The second parameter in **newtFormRun()** is the struct with results, which returns everything you need to know what happened during form execution. Use it like this:
```
newtComponent form,b1,b2;
struct newtExitStruct exit_status;
newtFor... |
27,980,879 | I'm generating dropdown inputs with php simple html dom. I have some values from database and according them i will add 'selected' value into my select->option dom elements.
```
<select name="myDropDown" id="someID">
<option value="someValue1">Value1Value</option>
<option value="someValue2">Value2Value</option>
... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27980879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154480/"
] | My solution was:
* Set up a variable as `newtComponent answer`
* After destroy the form call this function `answer = newtFormGetCurrent(form);`
* and check if answer was my b1 button `if( answer == b1 )`. | You are using a deprecated function **newtRunForm()**. Use **newtFormRun()**. The second parameter in **newtFormRun()** is the struct with results, which returns everything you need to know what happened during form execution. Use it like this:
```
newtComponent form,b1,b2;
struct newtExitStruct exit_status;
newtFor... |
469,702 | [](https://i.stack.imgur.com/qe9JA.png)
I know when it is centered at 0, Vpeak/sqrt(2) gives the RMS.
When I do FFT on LTspice, it gives a peak at -17dB which is equal to 0.141254
[... | 2019/11/30 | [
"https://electronics.stackexchange.com/questions/469702",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/225442/"
] | You want to know the rms of a waveform \$ f(t) \$.
There are two approaches here direct application of the formula:
$$RMS = \sqrt{\dfrac{1}{T} \cdot \int\_0^T (f(t))^2 \text{d}t}$$
Where T is the period of the signal. However there is another useful function:
$$RMS = \sqrt{RMS\_1^2 + RMS\_2^2}$$
Where \$RMS\_1\$ a... | The RMS value you are seeing is a combination of the DC and AC components. Your signal is the sum of those two components and the RMS value is taken **of the sum**.
If you want only the RMS value of the AC portion, i.e., the sinusoidal portion, then using the SPICE controls to subtract the DC component and then take t... |
469,702 | [](https://i.stack.imgur.com/qe9JA.png)
I know when it is centered at 0, Vpeak/sqrt(2) gives the RMS.
When I do FFT on LTspice, it gives a peak at -17dB which is equal to 0.141254
[... | 2019/11/30 | [
"https://electronics.stackexchange.com/questions/469702",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/225442/"
] | As the signal is not totally recognizable in the first figure, I'll assume your sine wave equation to be \$ f(t) = 0.25 + 0.25\,sin(5000\,\pi\,t)\$ and \$f(t)\$ has Watt unit.
Thus, the RMS value is given by \$\sqrt{\dfrac{1}{T}\int\_{t\_0}^{t\_0+T} f(t)^2dt}\$ being T the period of the function, which I have assumed ... | The RMS value you are seeing is a combination of the DC and AC components. Your signal is the sum of those two components and the RMS value is taken **of the sum**.
If you want only the RMS value of the AC portion, i.e., the sinusoidal portion, then using the SPICE controls to subtract the DC component and then take t... |
469,702 | [](https://i.stack.imgur.com/qe9JA.png)
I know when it is centered at 0, Vpeak/sqrt(2) gives the RMS.
When I do FFT on LTspice, it gives a peak at -17dB which is equal to 0.141254
[... | 2019/11/30 | [
"https://electronics.stackexchange.com/questions/469702",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/225442/"
] | You want to know the rms of a waveform \$ f(t) \$.
There are two approaches here direct application of the formula:
$$RMS = \sqrt{\dfrac{1}{T} \cdot \int\_0^T (f(t))^2 \text{d}t}$$
Where T is the period of the signal. However there is another useful function:
$$RMS = \sqrt{RMS\_1^2 + RMS\_2^2}$$
Where \$RMS\_1\$ a... | As the signal is not totally recognizable in the first figure, I'll assume your sine wave equation to be \$ f(t) = 0.25 + 0.25\,sin(5000\,\pi\,t)\$ and \$f(t)\$ has Watt unit.
Thus, the RMS value is given by \$\sqrt{\dfrac{1}{T}\int\_{t\_0}^{t\_0+T} f(t)^2dt}\$ being T the period of the function, which I have assumed ... |
469,702 | [](https://i.stack.imgur.com/qe9JA.png)
I know when it is centered at 0, Vpeak/sqrt(2) gives the RMS.
When I do FFT on LTspice, it gives a peak at -17dB which is equal to 0.141254
[... | 2019/11/30 | [
"https://electronics.stackexchange.com/questions/469702",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/225442/"
] | You want to know the rms of a waveform \$ f(t) \$.
There are two approaches here direct application of the formula:
$$RMS = \sqrt{\dfrac{1}{T} \cdot \int\_0^T (f(t))^2 \text{d}t}$$
Where T is the period of the signal. However there is another useful function:
$$RMS = \sqrt{RMS\_1^2 + RMS\_2^2}$$
Where \$RMS\_1\$ a... | I am assuming the waveform has a peak value of 500mW and an average of 250mW.
The rms value of dc portion is 250mW, same as the average value.
For the 1kHz ac part, rms is:
$$ \frac{500-250}{\sqrt{2}} = 177mW
$$
So the net rms will be:
$$ \sqrt{DC rms^{2} + AC rms^{2}} = 306mW
$$
To get rms value from LTSpice, CTRL + ... |
469,702 | [](https://i.stack.imgur.com/qe9JA.png)
I know when it is centered at 0, Vpeak/sqrt(2) gives the RMS.
When I do FFT on LTspice, it gives a peak at -17dB which is equal to 0.141254
[... | 2019/11/30 | [
"https://electronics.stackexchange.com/questions/469702",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/225442/"
] | As the signal is not totally recognizable in the first figure, I'll assume your sine wave equation to be \$ f(t) = 0.25 + 0.25\,sin(5000\,\pi\,t)\$ and \$f(t)\$ has Watt unit.
Thus, the RMS value is given by \$\sqrt{\dfrac{1}{T}\int\_{t\_0}^{t\_0+T} f(t)^2dt}\$ being T the period of the function, which I have assumed ... | I am assuming the waveform has a peak value of 500mW and an average of 250mW.
The rms value of dc portion is 250mW, same as the average value.
For the 1kHz ac part, rms is:
$$ \frac{500-250}{\sqrt{2}} = 177mW
$$
So the net rms will be:
$$ \sqrt{DC rms^{2} + AC rms^{2}} = 306mW
$$
To get rms value from LTSpice, CTRL + ... |
610,792 | I have a full and balanced bridge circuit with four through-hole \$ 350 \,\Omega \$ resistors and an instrumentation amplifier [AD8293G80](https://www.analog.com/en/products/ad8293g80.html) that has a gain of 80. Both the bridge and the amplifier are powered by an \$ 2.8 \,V \$ LDO with the amplifier referenced at \$ 1... | 2022/03/04 | [
"https://electronics.stackexchange.com/questions/610792",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/7393/"
] | This [AD8293G80](https://www.analog.com/media/en/technical-documentation/data-sheets/AD8293G80_160.pdf) InAmp is unsuitable for applications where the input voltage is typically greater than 1.1 volts on a 2.8 volt supply. You are generating about 1.4 volts on each half of the bridge and this is beyond the device's cap... | What you're trying to do is fairly expensive. I don't see a point of using an LDO specifically for the bridge. Bridge circuits with A/D conversion almost always are ratiometric. That is: the A/D reference voltage is a scaled version of the excitation voltage. For typical 3.3V microcontrollers, the excitation and A/D re... |
225,143 | I want to filter search results by multiple filters at once. Is it possible to reduce the number of if statements?
My code:
```
public IEnumerable<Article> Search(ArticleFiltersModel filters, ArticleSortOptions? options)
{
var result = Mapper.Map<IQueryable<Article>>(_unitOfWork.Articles.AsQueryable())... | 2019/07/29 | [
"https://codereview.stackexchange.com/questions/225143",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/205644/"
] | I read it as one long `AND` operation where the result is the articles that satisfy all the valid predicates. You could therefore build an enumerable of valid predicates in an extension method:
```
public static class ArticleFilterExtensions
{
public static IEnumerable<Predicate<Article>> GetValidPredicates(th... | Given an extension method:
```
public static IQueryable<T> NullWhere<T>(this IQueryable<T> source, Expression<Func<T, bool?>> expression, bool? compare) => compare.HasValue
? source.Where(Expression.Lambda<Func<T, bool>>(Expression.Equal(expression.Body, Expression.Constant((bool)compare)), expression.Parameters))... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.