qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The inner variable declaration of x override the static one.
If you need to access the static variable you can access it with `Test.x` | When you have a local variable same as static variable, static variable of the class is shadowed by the local variable. |
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The inner variable declaration of x override the static one.
If you need to access the static variable you can access it with `Test.x` | It doesn't throw an error because Java has the concept of [**shadowing**](https://stackoverflow.com/questions/1092099/what-is-variable-shadowing-used-for-in-a-java-class). In essence, the variable with the lowest [scope](http://www.geeksforgeeks.org/variable-scope-in-java/) is used.
The static field is still accessibl... |
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The local variable hides the original static field somewhat, but it is not inaccessible:
```
Test.x
```
And for non-static fields:
```
this.x // not in this case
```
So it is allowed, and in effect one often sees:
```
public class Pt {
private final int x;
public Pt(int x) {
this.x = x;
}
}
... | The duplicate variable compilation error happens for two variables with the same name declared in the same scope : fields or method declaration scope.
In your example, each variable is declared in a distinct scope.
As a consequence, as you refer `x` in the method declaring `x`, by default it refers to the variabl... |
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The local variable hides the original static field somewhat, but it is not inaccessible:
```
Test.x
```
And for non-static fields:
```
this.x // not in this case
```
So it is allowed, and in effect one often sees:
```
public class Pt {
private final int x;
public Pt(int x) {
this.x = x;
}
}
... | When you have a local variable same as static variable, static variable of the class is shadowed by the local variable. |
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The local variable hides the original static field somewhat, but it is not inaccessible:
```
Test.x
```
And for non-static fields:
```
this.x // not in this case
```
So it is allowed, and in effect one often sees:
```
public class Pt {
private final int x;
public Pt(int x) {
this.x = x;
}
}
... | It doesn't throw an error because Java has the concept of [**shadowing**](https://stackoverflow.com/questions/1092099/what-is-variable-shadowing-used-for-in-a-java-class). In essence, the variable with the lowest [scope](http://www.geeksforgeeks.org/variable-scope-in-java/) is used.
The static field is still accessibl... |
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The duplicate variable compilation error happens for two variables with the same name declared in the same scope : fields or method declaration scope.
In your example, each variable is declared in a distinct scope.
As a consequence, as you refer `x` in the method declaring `x`, by default it refers to the variabl... | When you have a local variable same as static variable, static variable of the class is shadowed by the local variable. |
47,136,705 | I am new in Java and came across one OCJA-1.8 sample question where I am having some doubt. I need clarification on this behavior of JVM.
```
public class Test{
static int x=1;//**This is static class level variable**
public static void main(String[] args){
int[] nums={1,2,3,4,5};
for(int x:nums){ // Loc... | 2017/11/06 | [
"https://Stackoverflow.com/questions/47136705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8893859/"
] | The duplicate variable compilation error happens for two variables with the same name declared in the same scope : fields or method declaration scope.
In your example, each variable is declared in a distinct scope.
As a consequence, as you refer `x` in the method declaring `x`, by default it refers to the variabl... | It doesn't throw an error because Java has the concept of [**shadowing**](https://stackoverflow.com/questions/1092099/what-is-variable-shadowing-used-for-in-a-java-class). In essence, the variable with the lowest [scope](http://www.geeksforgeeks.org/variable-scope-in-java/) is used.
The static field is still accessibl... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | Your problem is most easily solved by simply POSTing to the same URL that your form is shown at, and simply redirecting the user away from the page when the POST is successful. That way until the form is successfully submitted you do not change URLs.
If you're just dying to POST to a different URL, then you need to sa... | A clean way is using the "overload" provided by pyramid for different request types, por example, you can decorate your methods this way:
```
@action(request_method='GET',
renderer='mypackage:/templates/save.mako',
name='save')
def save(request):
''' Fill the template with default values or leave i... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | The Pyramid documentation has a particularly on-point [section](http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/views.html#using-a-view-callable-to-do-an-http-redirect) with the following example:
```
from pyramid.httpexceptions import HTTPFound
def myview(request):
return HTTPFound(location='http:/... | Assuming your homepage is the default view of your pyramid web app, you can do:
```
def _get_link_form(post_data):
""" Returns the initialised form object """
return LinkForm(post_data)
def home_page(request):
form = _get_link_form(request.POST)
return {'form' : form}
def save_post(request):
... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | Your problem is most easily solved by simply POSTing to the same URL that your form is shown at, and simply redirecting the user away from the page when the POST is successful. That way until the form is successfully submitted you do not change URLs.
If you're just dying to POST to a different URL, then you need to sa... | I do this like so:
```
from pyramid.httpexceptions import HTTPCreated
response = HTTPCreated()
response.location = self.request.resource_url( newResource )
return response
```
This sends the HTTP Created code , 201 |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | The Pyramid documentation has content about ***Redirect***, you can see more information in below link :
[Pyramid documentation](http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/pylons/exceptions.html)
```
import pyramid.httpexceptions as exc
raise exc.HTTPFound(request.route_url("section1")) # Red... | Assuming your homepage is the default view of your pyramid web app, you can do:
```
def _get_link_form(post_data):
""" Returns the initialised form object """
return LinkForm(post_data)
def home_page(request):
form = _get_link_form(request.POST)
return {'form' : form}
def save_post(request):
... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | The Pyramid documentation has content about ***Redirect***, you can see more information in below link :
[Pyramid documentation](http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/pylons/exceptions.html)
```
import pyramid.httpexceptions as exc
raise exc.HTTPFound(request.route_url("section1")) # Red... | A clean way is using the "overload" provided by pyramid for different request types, por example, you can decorate your methods this way:
```
@action(request_method='GET',
renderer='mypackage:/templates/save.mako',
name='save')
def save(request):
''' Fill the template with default values or leave i... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | The Pyramid documentation has a particularly on-point [section](http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/views.html#using-a-view-callable-to-do-an-http-redirect) with the following example:
```
from pyramid.httpexceptions import HTTPFound
def myview(request):
return HTTPFound(location='http:/... | I do this like so:
```
from pyramid.httpexceptions import HTTPCreated
response = HTTPCreated()
response.location = self.request.resource_url( newResource )
return response
```
This sends the HTTP Created code , 201 |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | Your problem is most easily solved by simply POSTing to the same URL that your form is shown at, and simply redirecting the user away from the page when the POST is successful. That way until the form is successfully submitted you do not change URLs.
If you're just dying to POST to a different URL, then you need to sa... | Assuming your homepage is the default view of your pyramid web app, you can do:
```
def _get_link_form(post_data):
""" Returns the initialised form object """
return LinkForm(post_data)
def home_page(request):
form = _get_link_form(request.POST)
return {'form' : form}
def save_post(request):
... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | The Pyramid documentation has a particularly on-point [section](http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/views.html#using-a-view-callable-to-do-an-http-redirect) with the following example:
```
from pyramid.httpexceptions import HTTPFound
def myview(request):
return HTTPFound(location='http:/... | A clean way is using the "overload" provided by pyramid for different request types, por example, you can decorate your methods this way:
```
@action(request_method='GET',
renderer='mypackage:/templates/save.mako',
name='save')
def save(request):
''' Fill the template with default values or leave i... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | Your problem is most easily solved by simply POSTing to the same URL that your form is shown at, and simply redirecting the user away from the page when the POST is successful. That way until the form is successfully submitted you do not change URLs.
If you're just dying to POST to a different URL, then you need to sa... | The Pyramid documentation has a particularly on-point [section](http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/views.html#using-a-view-callable-to-do-an-http-redirect) with the following example:
```
from pyramid.httpexceptions import HTTPFound
def myview(request):
return HTTPFound(location='http:/... |
5,610,087 | I'm trying to have my form submit to a route which will validate the data then redirect back to the original route.
For example:
* User loads the page website.com/post
* Form POSTs the data to website.com/post-save
* User gets redirected back to website.com/post
Pyramid is giving me some troubles doing this.
Here's... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5610087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | I do this like so:
```
from pyramid.httpexceptions import HTTPCreated
response = HTTPCreated()
response.location = self.request.resource_url( newResource )
return response
```
This sends the HTTP Created code , 201 | A clean way is using the "overload" provided by pyramid for different request types, por example, you can decorate your methods this way:
```
@action(request_method='GET',
renderer='mypackage:/templates/save.mako',
name='save')
def save(request):
''' Fill the template with default values or leave i... |
18,560,073 | ```
var primes=[2,3,5,7]
primes.sync = function(){this[0]=23;}
primes // => [2, 3, 5, 7]
primes.sync()
primes // => [23, 3, 5, 7]
```
This seems to work perfectly in Chrome.
Are there any reasons to not use this syntax/"feature"? Also, can I count on `primes` to be behave as a normal array (e.g. when passing it ... | 2013/09/01 | [
"https://Stackoverflow.com/questions/18560073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/667178/"
] | The only trouble you'll likely have will be if you (incorrectly) try to use `for-in` to iterate the Array. As long as you use a `for` statement or one of the Array iterator methods to constrain the enumeration to numeric indices, there shouldn't be any trouble.
The Array will continue to behave like a typical Array. | What you would want to do is to add a function to Array.prototype, rather than adding it to an array instance. See below.
```
Array.prototype.sync = function(){this[0]=23;};
```
This way, all array instances, including those that have been initialized before adding the function, will automatically be able to use the... |
59,469,316 | I'm relative new in this area and I'm following a YouTube tutorial for a basic calculator app.
But I noticed, that `style = "@styles/button_calculator"` is not working at all. It is applied to buttons and after compile I get this error: `Missing attribute: layout_height` (For every button), but it actually is in the st... | 2019/12/24 | [
"https://Stackoverflow.com/questions/59469316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11653071/"
] | The proper solution would be to indeed start `ExUnit`, compile all the files and examine the outcome.
```
mix run -e 'ExUnit.start(); exit({:shutdown, (if match?({:ok, _, _}, Kernel.ParallelCompiler.compile(Path.wildcard("test/**/*.exs"))), do: 0, else: 1)})'
```
That way you might also explicitly specify the error ... | I've found an answer.
Just run tests with some tag that doesn't exist. This will compile all tests but none of them will be actually run
```
mix test --only whatever
```
**UPDATE**: this only works for umbrella apps. For a regular app, nonexistent tag leads to an error code `1` (see comments to this question).
It'... |
28,461,821 | I have developed a speech to text program where the user can speak a short sentence and then inserts that into a text box.
How do I extract the first letters of each word and then insert that into the text field?
For example if the user says: "Hello World". I want to insert HW into the text box. | 2015/02/11 | [
"https://Stackoverflow.com/questions/28461821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551922/"
] | If you have a string, you could just split it using
```
input.split(" ") //splitting by space
//maybe you want to replace dots, etc with nothing).
```
The iterate over the array:
```
for(String s : input.split(" "))
```
And then get the first letter of every string in a list/array/etc or appen... | Use [split](http://developer.android.com/reference/java/lang/String.html#split(java.lang.String)) to get an array separated words, then you can get first N characters with [substring](http://developer.android.com/reference/java/lang/String.html#substring(int,%20int))(0, N). |
28,461,821 | I have developed a speech to text program where the user can speak a short sentence and then inserts that into a text box.
How do I extract the first letters of each word and then insert that into the text field?
For example if the user says: "Hello World". I want to insert HW into the text box. | 2015/02/11 | [
"https://Stackoverflow.com/questions/28461821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551922/"
] | If you have a string, you could just split it using
```
input.split(" ") //splitting by space
//maybe you want to replace dots, etc with nothing).
```
The iterate over the array:
```
for(String s : input.split(" "))
```
And then get the first letter of every string in a list/array/etc or appen... | You would want to extract the string, put it all into a list, and loop through
```
String[] old = myTextView.getText().split(" ");
String add="";
for(String s:old)
add+=""+s.charAt(0);
myTextView.setText(add);
``` |
28,461,821 | I have developed a speech to text program where the user can speak a short sentence and then inserts that into a text box.
How do I extract the first letters of each word and then insert that into the text field?
For example if the user says: "Hello World". I want to insert HW into the text box. | 2015/02/11 | [
"https://Stackoverflow.com/questions/28461821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551922/"
] | If you have a string, you could just split it using
```
input.split(" ") //splitting by space
//maybe you want to replace dots, etc with nothing).
```
The iterate over the array:
```
for(String s : input.split(" "))
```
And then get the first letter of every string in a list/array/etc or appen... | Assuming the sentence only contain `a-z and A-Z and " " to separate the words` , If you want an efficient way to do it, I suggest the below method.
```
public String getResult(String input){
StringBuilder sb = new StringBuilder();
for(String s : input.split(" ")){
sb.append(s.charAt(0));
}... |
39,927,514 | I want to format data in 2 columns in the same pattern. Each data column has its length based on upper boundary of result array. I initially formatted them both separately and it was working as intended, but I want to keep the code as lean as possible.
I tried the code below, but it created a range from 1st range to t... | 2016/10/08 | [
"https://Stackoverflow.com/questions/39927514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6097926/"
] | something like this:
```
With statsWS.Range("b2:c" & (UBound(vGoals) + 1) & ",e2:f" & (UBound(vAssists) + 1)).Borders
.LineStyle = xlContinuous
.Color = rgbGrey
End With
``` | you can also use the `Range("Address1,Address2")` method to get the union of different ranges
```
With statsWS
With .Range(.Range("b2:c" & UBound(vGoals) + 1).Address & "," & .Range("e2:f" & UBound(vAssists) + 1).Address).Borders
.LineStyle = xlContinuous
.Color = rgbGrey
End With
End With
``` |
39,927,514 | I want to format data in 2 columns in the same pattern. Each data column has its length based on upper boundary of result array. I initially formatted them both separately and it was working as intended, but I want to keep the code as lean as possible.
I tried the code below, but it created a range from 1st range to t... | 2016/10/08 | [
"https://Stackoverflow.com/questions/39927514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6097926/"
] | You could use Chris Neilsen's suggestion:
```
With statsWS
With Union(.Range("B2:C" & UBound(vGoals) + 1), .Range("E2:F" & UBound(vAssists) + 1))
With .Borders
.LineStyle = xlContinuous
.Color = rgbGrey
End With
End With
End With
```
But if you want to keep your code l... | you can also use the `Range("Address1,Address2")` method to get the union of different ranges
```
With statsWS
With .Range(.Range("b2:c" & UBound(vGoals) + 1).Address & "," & .Range("e2:f" & UBound(vAssists) + 1).Address).Borders
.LineStyle = xlContinuous
.Color = rgbGrey
End With
End With
``` |
1,845,705 | I have two objects that reference each other. From a purely schema perspective, object one could have many instances of object two that reference it, but the business logic specifies that each instance of object 2 will reference a unique instance of object one and vice versa.
Example:
```
public class Object1 {
p... | 2009/12/04 | [
"https://Stackoverflow.com/questions/1845705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34942/"
] | This is what you are looking for:
```
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate; // called on finger up if user dragged. decelerate is true if it will continue moving afterwards
```
* From Apple's Documentation. | Try and play with decelerationRate. |
82,779 | I have been told that a GFCI *receptacle* is a "circuit breaker" in the sense that it will trip under overload. Everything I know, have been told, and have read from experts to manufacturers says this is not the case.
So the question stands: Is a GFCI receptacle device a circuit breaker? | 2016/01/22 | [
"https://diy.stackexchange.com/questions/82779",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/19875/"
] | No.
Each type of device serves a distinctly separate protective purpose.
Breaker
-------
A circuit breaker detects overcurrent faults, it does not detect ground faults. A circuit breaker will stop your house catching fire when the wiring in the walls overheats from prolonged overcurrent, it wont stop you and your fa... | I don't think the argument was that a GFCI was *designed* to be a circuit breaker, but that something in their construction caused them to trip due to an overload.
I can say with 100% certainty that GFCI devices are not designed, nor intended to take the place of circuit breakers. However, without actually seeing the ... |
82,779 | I have been told that a GFCI *receptacle* is a "circuit breaker" in the sense that it will trip under overload. Everything I know, have been told, and have read from experts to manufacturers says this is not the case.
So the question stands: Is a GFCI receptacle device a circuit breaker? | 2016/01/22 | [
"https://diy.stackexchange.com/questions/82779",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/19875/"
] | No.
Each type of device serves a distinctly separate protective purpose.
Breaker
-------
A circuit breaker detects overcurrent faults, it does not detect ground faults. A circuit breaker will stop your house catching fire when the wiring in the walls overheats from prolonged overcurrent, it wont stop you and your fa... | In the vernacular: **no**, a GFCI device is not a circuit breaker unless it says it's a combination GFCI/breaker.
Technically speaking: a GFCI contains circuit breaker switching guts, but replaces the normal thermal-magnetic trip with a differential trip, or adds the differential trip in the case of a combo device.
L... |
991,592 | I am looking to prove this function is always prime for all integers $n$: $$n^{2}-n+17$$
I have tested it for the first $10$ integers and it seems to work but I am not sure how to prove it form all $n$. Any ideas? | 2014/10/26 | [
"https://math.stackexchange.com/questions/991592",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/184015/"
] | $n^2-n+17=n(n-1)+17$. Taking $n=17$, you will get $17\times16+17$, a proper multiple of $17$. Taking $n-1=17$, you will get $18\times17+17$, another one.
More generally, a polynomial expression $P(n)$ with integer coefficients will fail for $n=P(0)$ and multiples. | Let $f(x)=a\_0+a\_1x+...+a\_nx^n \in \mathbb Z[X]$ be a polynomial. Now note that
$$f(a\_0)=a\_0+a\_1a\_0+...+a\_na\_0^n=a\_0(1+a\_1+...+a\_na\_0^{n-1})$$
In other words, $a\_0$ divides $f(a\_0)$. Therefore, if $1<a\_0<f(a\_0)$ like in your case, $f(a\_0)$ is not prime. |
991,592 | I am looking to prove this function is always prime for all integers $n$: $$n^{2}-n+17$$
I have tested it for the first $10$ integers and it seems to work but I am not sure how to prove it form all $n$. Any ideas? | 2014/10/26 | [
"https://math.stackexchange.com/questions/991592",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/184015/"
] | $n^2-n+17=n(n-1)+17$. Taking $n=17$, you will get $17\times16+17$, a proper multiple of $17$. Taking $n-1=17$, you will get $18\times17+17$, another one.
More generally, a polynomial expression $P(n)$ with integer coefficients will fail for $n=P(0)$ and multiples. | The formula $\quad n^2-n+C\quad $ is composite for many values where $n>C$ and always composite for $n=C^p, p\in\mathbb{N}.$ |
991,592 | I am looking to prove this function is always prime for all integers $n$: $$n^{2}-n+17$$
I have tested it for the first $10$ integers and it seems to work but I am not sure how to prove it form all $n$. Any ideas? | 2014/10/26 | [
"https://math.stackexchange.com/questions/991592",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/184015/"
] | Let $f(x)=a\_0+a\_1x+...+a\_nx^n \in \mathbb Z[X]$ be a polynomial. Now note that
$$f(a\_0)=a\_0+a\_1a\_0+...+a\_na\_0^n=a\_0(1+a\_1+...+a\_na\_0^{n-1})$$
In other words, $a\_0$ divides $f(a\_0)$. Therefore, if $1<a\_0<f(a\_0)$ like in your case, $f(a\_0)$ is not prime. | The formula $\quad n^2-n+C\quad $ is composite for many values where $n>C$ and always composite for $n=C^p, p\in\mathbb{N}.$ |
12,864,314 | When I click the `Installation Details` in eclipse,

I got this tab for `Installed software`

and a tab for `Features`
Contributes to 1 or more extension points(Means it can increase his property by just connecting it to any extension point)
2.)Small set of prog which generally require JRE and add some small feature to your Eclipse SDK..
While... | Yep, software may consists of multiple plugins. "Installed" not only means that you have installed them via update site, but also this software were included in that package of eclipse. |
12,864,314 | When I click the `Installation Details` in eclipse,

I got this tab for `Installed software`

and a tab for `Features`

I got this tab for `Installed software`

and a tab for `Features`
Contributes to 1 or more extension points(Means it can increase his property by just connecting it to any extension point)
2.)Small set of prog which generally require JRE and add some small feature to your Eclipse SDK..
While... |
21,465,639 | I wrote a rack app ([here](https://github.com/chaddjohnson/trading_websocket_service/blob/master/config.ru)) which locks up about once or twice per day, and I need to debug the app.
So, I tried following this: <http://robots.thoughtbot.com/using-gdb-to-inspect-a-running-ruby-process>. I tried debugging against a simpl... | 2014/01/30 | [
"https://Stackoverflow.com/questions/21465639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83897/"
] | [Amazon IAM](http://aws.amazon.com/iam/) policies are *Deny by default*, which is not identical to *Explicit Deny*, see [The Difference Between Denying by Default and Explicit Deny](http://docs.aws.amazon.com/IAM/latest/UserGuide/AccessPolicyLanguage_EvaluationLogic.html#AccessPolicyLanguage_Interplay) for details.
Ac... | For user3086014, create a policy similar to the one below:
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect":"Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:RebootInstances"
]... |
55,400,703 | I want to enable the Comment Box in Youtube for which I need to scroll down.
Here is what I am doing right now:-
```
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/watch?v=l5LfjYmNEJs&t=160s")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
... | 2019/03/28 | [
"https://Stackoverflow.com/questions/55400703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11088461/"
] | I have found one solution.See if this helps.`time.sleep` is required to slowdown while loop.
```
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/watch?v=l5LfjYmNEJs&t=160s")
while(True):
height = driver.exec... | [KunduK](https://stackoverflow.com/a/55402078/5046652)'s answer is awesome! but did not better for me in **Firefox** to get all videos of a channel. So I modified the **JavaScript** part
```py
height = driver.execute_script("return document.documentElement.scrollHeight(window.innerHeight + window.scrollY);")
``` |
55,400,703 | I want to enable the Comment Box in Youtube for which I need to scroll down.
Here is what I am doing right now:-
```
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/watch?v=l5LfjYmNEJs&t=160s")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
... | 2019/03/28 | [
"https://Stackoverflow.com/questions/55400703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11088461/"
] | I have found one solution.See if this helps.`time.sleep` is required to slowdown while loop.
```
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/watch?v=l5LfjYmNEJs&t=160s")
while(True):
height = driver.exec... | unforunately answer didn't work for me. But this worked.
```
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/c/klikklak/videos")
while True:
scroll_height = 2000
document_height_before = driver.execute_script("return
document.documentElement.scr... |
55,400,703 | I want to enable the Comment Box in Youtube for which I need to scroll down.
Here is what I am doing right now:-
```
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/watch?v=l5LfjYmNEJs&t=160s")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
... | 2019/03/28 | [
"https://Stackoverflow.com/questions/55400703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11088461/"
] | unforunately answer didn't work for me. But this worked.
```
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/c/klikklak/videos")
while True:
scroll_height = 2000
document_height_before = driver.execute_script("return
document.documentElement.scr... | [KunduK](https://stackoverflow.com/a/55402078/5046652)'s answer is awesome! but did not better for me in **Firefox** to get all videos of a channel. So I modified the **JavaScript** part
```py
height = driver.execute_script("return document.documentElement.scrollHeight(window.innerHeight + window.scrollY);")
``` |
46,109,739 | I am trying to build a psychological experiment for my PhD thesis. I am pretty new to python. What I am looking for is that I need to select a *number* from a list of numbers and then again select a *number* which should in *one case* higher than the previous one and *in another case* lower than the previous one.
The... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46109739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8578223/"
] | ```
let htmlString:String = webView.stringByEvaluatingJavaScript(from: "document.getElementById('link').innerHTML")!
``` | use **`NSDataDetector`** class can match dates, addresses, links, phone numbers and transit information. *[Reference](https://developer.apple.com/documentation/foundation/nsdatadetector)*.
```
let htmlString = "<p><a href=\"https://www.youtube.com/watch?v=i2yscjyIBsk\">https://www.youtube.com/watch?v=i2yscjyIBsk</a></... |
16,030,173 | I'm currently writing this program that I require to read info from a text file and to then compare the info read to a user input and output a message saying if it was a match or not.
Currently have this. The program is sucessfully reading the data specified but I can't seem to compare the strings correctly at the end... | 2013/04/16 | [
"https://Stackoverflow.com/questions/16030173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2285167/"
] | You should try reading the input from a textField in an user interface(visible window) where the user puts the country and getting that as raw input shortens the code.(Only if you have a visible window on screen)
I don't have that good experience with scanners, because they tend to crash my applications when I use t... | I am guessing that your comparison is failing due to case-sensitivity.
Should your string comparison not be CASE-INSENSITIVE? |
16,030,173 | I'm currently writing this program that I require to read info from a text file and to then compare the info read to a user input and output a message saying if it was a match or not.
Currently have this. The program is sucessfully reading the data specified but I can't seem to compare the strings correctly at the end... | 2013/04/16 | [
"https://Stackoverflow.com/questions/16030173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2285167/"
] | You should try reading the input from a textField in an user interface(visible window) where the user puts the country and getting that as raw input shortens the code.(Only if you have a visible window on screen)
I don't have that good experience with scanners, because they tend to crash my applications when I use t... | There are a few possible issues here. First, you're converting the `searchString` to lower case. Are the data in the CSV also lower case? If not, try using `equalsIgnoreCase` instead. Also, it seems to me like you should be able to match parts of the country name. In that case, `equals` (or `equalsIgnoreCase`) would on... |
2,124,227 | I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.
My git knowledge is pretty rudimentary though so here's what I did.
I downloaded the portable git (I'm on PC so msysgit).
I placed a copy into c:\root\git and a copy into c:\root\git c:\client... | 2010/01/23 | [
"https://Stackoverflow.com/questions/2124227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | Check into <http://sparkleshare.org/>
Sparkleshare gives you a user experience similar to Dropbox, except that it's underlying sync engine is git. It's not the most stable thing, but you can watch it's log output to see what git commands it's going to achieve seamless syncing. Once you learn those, you can simply make... | Git *can* be a good tool for synchronizing source between development and production, for one reason: It makes it easy to "hot fix" in production and check the fix back into the tree. Of course you should always reproduce the bug in a development or test environment and fix it there, but sometimes you can't.
Instead o... |
2,124,227 | I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.
My git knowledge is pretty rudimentary though so here's what I did.
I downloaded the portable git (I'm on PC so msysgit).
I placed a copy into c:\root\git and a copy into c:\root\git c:\client... | 2010/01/23 | [
"https://Stackoverflow.com/questions/2124227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | [git-annex](http://git-annex.branchable.com/) could be another tool to consider. | Git *can* be a good tool for synchronizing source between development and production, for one reason: It makes it easy to "hot fix" in production and check the fix back into the tree. Of course you should always reproduce the bug in a development or test environment and fix it there, but sometimes you can't.
Instead o... |
2,124,227 | I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.
My git knowledge is pretty rudimentary though so here's what I did.
I downloaded the portable git (I'm on PC so msysgit).
I placed a copy into c:\root\git and a copy into c:\root\git c:\client... | 2010/01/23 | [
"https://Stackoverflow.com/questions/2124227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | Check into <http://sparkleshare.org/>
Sparkleshare gives you a user experience similar to Dropbox, except that it's underlying sync engine is git. It's not the most stable thing, but you can watch it's log output to see what git commands it's going to achieve seamless syncing. Once you learn those, you can simply make... | I just tried to reproduce your steps.
`git commit -f` didn't do anything with the 1.6.5.1 version I just installed. But it should give you a long error message.
```
mkdir repo1 repo2
cd repo1
git init
( create files )
git add *
git commit -m "initial commit"
cd ..\repo2
git clone ..\repo1 .
```
and the files I crea... |
2,124,227 | I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.
My git knowledge is pretty rudimentary though so here's what I did.
I downloaded the portable git (I'm on PC so msysgit).
I placed a copy into c:\root\git and a copy into c:\root\git c:\client... | 2010/01/23 | [
"https://Stackoverflow.com/questions/2124227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | [git-annex](http://git-annex.branchable.com/) could be another tool to consider. | I just tried to reproduce your steps.
`git commit -f` didn't do anything with the 1.6.5.1 version I just installed. But it should give you a long error message.
```
mkdir repo1 repo2
cd repo1
git init
( create files )
git add *
git commit -m "initial commit"
cd ..\repo2
git clone ..\repo1 .
```
and the files I crea... |
2,124,227 | I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.
My git knowledge is pretty rudimentary though so here's what I did.
I downloaded the portable git (I'm on PC so msysgit).
I placed a copy into c:\root\git and a copy into c:\root\git c:\client... | 2010/01/23 | [
"https://Stackoverflow.com/questions/2124227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | Check into <http://sparkleshare.org/>
Sparkleshare gives you a user experience similar to Dropbox, except that it's underlying sync engine is git. It's not the most stable thing, but you can watch it's log output to see what git commands it's going to achieve seamless syncing. Once you learn those, you can simply make... | As davr suggested in the comments, you might try [Unison](http://www.cis.upenn.edu/~bcpierce/unison/). By [having all your hosts sync with a central hub](http://www.cis.upenn.edu/~bcpierce/unison/download/releases/beta/unison-manual.html#usingmultiple), you can have n-way synchronization. Unison doesn't preserve histor... |
2,124,227 | I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.
My git knowledge is pretty rudimentary though so here's what I did.
I downloaded the portable git (I'm on PC so msysgit).
I placed a copy into c:\root\git and a copy into c:\root\git c:\client... | 2010/01/23 | [
"https://Stackoverflow.com/questions/2124227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | [git-annex](http://git-annex.branchable.com/) could be another tool to consider. | As davr suggested in the comments, you might try [Unison](http://www.cis.upenn.edu/~bcpierce/unison/). By [having all your hosts sync with a central hub](http://www.cis.upenn.edu/~bcpierce/unison/download/releases/beta/unison-manual.html#usingmultiple), you can have n-way synchronization. Unison doesn't preserve histor... |
10,081,640 | **Why is all the input that is submit blank?** (see below). I believe this is due to an error in my JS file.
HTML Form that is getting submitted:
```
<form method="post" id="FanDetail">
<textarea id="bio" name="fan_bio" cols="27" rows="3"></textarea><br />
... | 2012/04/10 | [
"https://Stackoverflow.com/questions/10081640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975947/"
] | You need to set the input's `name` to the same value you use in your PHP code when accessing `$_POST`.
For example:
In `<textarea id="bio" name="fan_bio" cols="27" rows="3"></textarea>` change the attribute `name` to `bio` to get it's value as `$_POST["bio"]`.
When you submit a HTML form, the form element's `name`-a... | You are using the wrong array keys to `$_POST`. Instead of the HTML form element id attributes, you need to be using the `name` attributes.
```
$fanBio=$_POST['fan_bio'];
$fanDob=$_POST['fan_dob'];
$zipval=$_POST['term'];
$occupval=$_POST['occup'];
$facebookurl=$_POST['fan_fbk'];
$twitterurl=$_POST['fan_twit'];
$phone... |
30,770,725 | I'm trying to create a simple spring boot app with spring boot that "produce" messages to a rabbitmq exchange/queue and another sample spring boot app that "consume" these messages.
So I have two apps (or microservices if you wish).
1) "producer" microservice
2) "consumer" microservice
The "producer" has 2 domain obje... | 2015/06/11 | [
"https://Stackoverflow.com/questions/30770725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4701806/"
] | Ok, I finally got this working.
Spring uses a **PayloadArgumentResolver** to extract, convert and set the converted message to the method parameter annotated with **@RabbitListener**. Somehow we need to set the **mappingJackson2MessageConverter** into this object.
So, in the CONSUMER app, we need to implement **Rabbi... | Have not done this myself but it seems like you need to register the appropriate conversions by setting up a RabbitTemplate. Take a look at section 3.1.8 in [this Spring documentation](https://docs.spring.io/spring-amqp/reference/html/#message-converters). I know it is configured using the AMQP classes but if the messa... |
69,575,508 | Let's say I have a string:
```
L1045 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ They do not!
```
And I need to extract the name - BIANCA and the text that is at the end into two variables.
I tried to do somthen like this:
```
dialogue = "L1045 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ They do not!"
name : str ... | 2021/10/14 | [
"https://Stackoverflow.com/questions/69575508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16929755/"
] | Yes, you can just use template specialization:
```
#include <string>
template<typename T, typename Label = std::string>
class foo {};
template <class T, typename Label = std::string>
class bar;
template <template<class...> class C, typename T, typename Label>
class bar<C<T>, Label> {
C<foo<T, Label>> A;
};
```
... | The other answer's approach can be generalized as a reusable template rebinder:
```
template<typename T>
struct rebinder;
template<template<typename...> typename T, typename... Args>
struct rebinder<T<Args...>> {
template<typename... Us>
using rebind = T<Us...>;
};
template<typename T, typename... Us>
using rebo... |
24,124,312 | Guys I am trying to display all records from a table with the exception of top 3 latest records. I have tried WHERE NOT EXISTS but I can't seem to get it to work. Help will be appreciated.
`EDITED` :
Query :
```
SELECT [Subject],
IssueDate,
(SELECT d.DepartName
FROM dbo.Department d
... | 2014/06/09 | [
"https://Stackoverflow.com/questions/24124312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3331470/"
] | Your syntax error is the the order by clause has to come after the where clause. I also think you are takeing the wrong approach. I would try something like this:
```
select myfields
from mytables
where SomeIdField not in
(select top 3 SomeIdField
from mytables
where whatver
order by someField desc)
and other conditi... | It seems you just need to skip the first 3 rows.
```
SELECT [Subject],
IssueDate,
(SELECT d.DepartName
FROM dbo.Department d
WHERE d.DepartmentID = n.DepartmentID) AS 'Department',
Body,
NoticeImage,
Icon
FROM dbo.Notice n
ORDER BY IssueDate DESC
OFFSET 3... |
24,586,970 | I am trying to make a custom select just like [this](https://lcdsantos.github.io/jQuery-Selectric/demo.html), but without jquery (I just dont want to import a whole new library for one single thing). I made it until [this](http://bit.ly/1lHofKH), but I dont know how I can make the selection with regular JS. How can I s... | 2014/07/05 | [
"https://Stackoverflow.com/questions/24586970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3770924/"
] | If you just want to show the selected item in the dropdown,
You need to wrap the text to be displayed inside a `<span>` as follows
```
<div class="label"><span>Select Element</span><b class="button">▾</b>
</div>
```
Then you can change it's `innterHTML` to display the selected item using the following js:
```
var... | You need to define an onclick handler of your `li` elements. Either in HTML, or in JS by looping through children of `div` container with `li` elements <http://jsfiddle.net/rWU5t/2/>
If you want fancy item highlights on mouse hover, you also need to define `onmouseover` and `onmouseout` handlers. |
24,586,970 | I am trying to make a custom select just like [this](https://lcdsantos.github.io/jQuery-Selectric/demo.html), but without jquery (I just dont want to import a whole new library for one single thing). I made it until [this](http://bit.ly/1lHofKH), but I dont know how I can make the selection with regular JS. How can I s... | 2014/07/05 | [
"https://Stackoverflow.com/questions/24586970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3770924/"
] | Listen to clicks on your `div#options`. [Demo](http://jsfiddle.net/tarabyte/rWU5t/4/)
```
function choose(ev, el) {
var options = el, target = ev.target,
value = ev.target.innerHTML;
options.setAttribute('class', 'hidden');
options.parentElement.querySelector('.label').innerHTML = value;
}
<div i... | You need to define an onclick handler of your `li` elements. Either in HTML, or in JS by looping through children of `div` container with `li` elements <http://jsfiddle.net/rWU5t/2/>
If you want fancy item highlights on mouse hover, you also need to define `onmouseover` and `onmouseout` handlers. |
27,781,881 | I would like to load a video file's frames into a numpy array. I want the frames to be properly upright, which means I need to read the orientation metadata in the video file, and rotate the loaded frames accordingly.
I have a means of loading the frames (opencv's python bindings), so all I need is a way to read the v... | 2015/01/05 | [
"https://Stackoverflow.com/questions/27781881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/399397/"
] | Assuming the types implement the same interface or base type, you can do the following:
```
public void InsertIntoBaseElemList<TElem>(ref List<TElem> List, TElem Element) where TElem : IElem {
for (int index = 0; index < List.Count; index++) {
if (List[index].Position < Element.Position && index + 1 == Lis... | Assuming that XElem is a user-created class, you can first create an interface called IElem, which holds the common properties of XElem and YElem (such as Position). Then make XElem and YElem implement the interface that you created, and on the signature of the method, use the interface instead of the concrete class. E... |
27,781,881 | I would like to load a video file's frames into a numpy array. I want the frames to be properly upright, which means I need to read the orientation metadata in the video file, and rotate the loaded frames accordingly.
I have a means of loading the frames (opencv's python bindings), so all I need is a way to read the v... | 2015/01/05 | [
"https://Stackoverflow.com/questions/27781881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/399397/"
] | try this:
```
public void InsertIntoBaseElemList<T>(ref List<T> List, T Element)
where T : BaseElem
```
assuming XElem and YElem inherits from BaseElem | Assuming that XElem is a user-created class, you can first create an interface called IElem, which holds the common properties of XElem and YElem (such as Position). Then make XElem and YElem implement the interface that you created, and on the signature of the method, use the interface instead of the concrete class. E... |
27,781,881 | I would like to load a video file's frames into a numpy array. I want the frames to be properly upright, which means I need to read the orientation metadata in the video file, and rotate the loaded frames accordingly.
I have a means of loading the frames (opencv's python bindings), so all I need is a way to read the v... | 2015/01/05 | [
"https://Stackoverflow.com/questions/27781881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/399397/"
] | You want something like the following:
```
public void InsertIntoBaseElemList<T>(List<T> List, T Element) where T : IElem
{
for (int index = 0; index < List.Count; index++)
{
if (List[index].Position < Element.Position && index + 1 == List.Count)
List.Add(Element);
else if (List[ind... | Assuming that XElem is a user-created class, you can first create an interface called IElem, which holds the common properties of XElem and YElem (such as Position). Then make XElem and YElem implement the interface that you created, and on the signature of the method, use the interface instead of the concrete class. E... |
34,709,872 | I'm having a problem of using variables between functions. As you can see down below User.username is available and good at the sign up page, but when you go to the login page I told it to first alert the value of User.username, and it alerts undefined? I'm confused here. I'm pretty sure I'm missing a concept here. Any... | 2016/01/10 | [
"https://Stackoverflow.com/questions/34709872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5768335/"
] | ```
permission denied, rmdir '/usr/local/lib/node_modules/npm'
```
try the command again with `sudo`:
```
sudo npm update -g npm
```
reinstall npm :
First uninstall node and remove node\_modules. then install it again by homebrew
```
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --wit... | Try it with Sudo permissions or better try remove it and install a updated one. |
53,167,578 | So, the question I have is:
>
> Due to various values entered by users for the status of the facility, this leads
> to confusion. The database owner would like to limit the following values
> “Open”, “Closed”, “Reserved”, and “Maintenance” to be used for the status of
> facility.
>
>
>
My table FACILITY has th... | 2018/11/06 | [
"https://Stackoverflow.com/questions/53167578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10083655/"
] | Strange, for me it is working as expected:
```
CREATE TABLE FACILITY (
FACILITYNAME VARCHAR2(100),
RATE INTEGER,
STATUS VARCHAR2(20));
Table created.
INSERT INTO FACILITY VALUES ('f1', 1, 'Open');
1 row created.
ALTER TABLE FACILITY ADD CONSTRAINT STATUS_CHECK CHECK (STATUS IN ('Open','Closed','Reserved'... | As @KaushikNayak suggested try adding check constraint:
```
ALTER TABLE FACILITY ADD CONSTRAINT check_status CHECK (FACILITY_STATUS IN ('Open','Closed','Reserved','Maintenance'));
```
Otherwise, [Column level constraint](https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj13590.html) must use another column:
>
> ... |
23,753,078 | I have a Schedule page that is nested under events and I would like a link so that users can go back to the event show page but I get an error.
### Error
```
syntax error, unexpected '(', expecting ')'
```
### Routes
```
resources :events do
resources :sessions, path: "schedule", only: [:index]
end
```
### Vie... | 2014/05/20 | [
"https://Stackoverflow.com/questions/23753078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1365764/"
] | It should be:
```
<%= link_to "Back to Event", event_path(@event) %>
```
(`event_path` is a method)
or simply:
```
<%= link_to "Back to Event", @event %>
``` | `Marek is` correct -
---
Something more to note is that if you ever want to send to a `nested` resource (I.E you want to show the `session`), you'd need to use the likes of:
```
session_path(@session, @event) #-> notice the two objects, not a single one
```
Currently, you'd just need to pass the single object, bu... |
15,196,170 | I am working on joomla 2.5 and when I load my site in Internet Explorer the document mode for IE changes to Quirks. The sites first load changes to Quirks mode and when I change the mode again it works fine.
I checked my document type in `template.xml` file.
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html ... | 2013/03/04 | [
"https://Stackoverflow.com/questions/15196170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017316/"
] | Filters don't work on individual items in the array, they transform the entire array into another array.
```
userApp.filter('matchAccessLevel', function() {
return function( items, userAccessLevel) {
var filtered = [];
angular.forEach(items, function(item) {
if(userAccessLevel >= item.minAccess) {
... | For CoffeeScript lovers:
```
userApp.filter 'matchAccessLevel', ->
(items, userAccessLevel) ->
item for item in items when userAccessLevel >= item.minAccess
``` |
15,196,170 | I am working on joomla 2.5 and when I load my site in Internet Explorer the document mode for IE changes to Quirks. The sites first load changes to Quirks mode and when I change the mode again it works fine.
I checked my document type in `template.xml` file.
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html ... | 2013/03/04 | [
"https://Stackoverflow.com/questions/15196170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017316/"
] | Filters don't work on individual items in the array, they transform the entire array into another array.
```
userApp.filter('matchAccessLevel', function() {
return function( items, userAccessLevel) {
var filtered = [];
angular.forEach(items, function(item) {
if(userAccessLevel >= item.minAccess) {
... | You can use Array.filter for a more concise solution:
```
app.filter('matchAccessLevel', function() {
return function( items, userAccessLevel ) {
return items.filter(function(element){
return userAccessLevel >= element.minAccess;
});
}
});
```
[Check on Plunker](http://plnkr.co/edit/8sjtM... |
15,196,170 | I am working on joomla 2.5 and when I load my site in Internet Explorer the document mode for IE changes to Quirks. The sites first load changes to Quirks mode and when I change the mode again it works fine.
I checked my document type in `template.xml` file.
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html ... | 2013/03/04 | [
"https://Stackoverflow.com/questions/15196170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017316/"
] | You can use Array.filter for a more concise solution:
```
app.filter('matchAccessLevel', function() {
return function( items, userAccessLevel ) {
return items.filter(function(element){
return userAccessLevel >= element.minAccess;
});
}
});
```
[Check on Plunker](http://plnkr.co/edit/8sjtM... | For CoffeeScript lovers:
```
userApp.filter 'matchAccessLevel', ->
(items, userAccessLevel) ->
item for item in items when userAccessLevel >= item.minAccess
``` |
5,481,114 | Can anyone deny/confirm this?? | 2011/03/30 | [
"https://Stackoverflow.com/questions/5481114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | It can't be, at least not entirely -- the C grammar doesn't fit LALR(1). | Yes, GCC is LALR.
"The Gcc parser is a LALR grammar file for Bison, which is a LALR parser
generator.
Therefore, if you want to say that, gcc is LALR." |
5,481,114 | Can anyone deny/confirm this?? | 2011/03/30 | [
"https://Stackoverflow.com/questions/5481114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | It can't be, at least not entirely -- the C grammar doesn't fit LALR(1). | [This discussion](http://gcc.gnu.org/ml/gcc-help/2004-08/msg00077.html) (though old) says gcc is LALR while for C++ it is a hand-written recursive descent one. |
5,481,114 | Can anyone deny/confirm this?? | 2011/03/30 | [
"https://Stackoverflow.com/questions/5481114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | It can't be, at least not entirely -- the C grammar doesn't fit LALR(1). | The quote above is out of date. All parser of GCC is hand written now. And I am pretty sure cpp is a lalr(k) parser. |
5,481,114 | Can anyone deny/confirm this?? | 2011/03/30 | [
"https://Stackoverflow.com/questions/5481114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | <http://gcc.gnu.org/ml/gcc-help/2004-08/msg00099.html>
>
> The Gcc parser is a LALR grammar file for Bison, which is a LALR parser
> generator.
> Therefore, if you want to say that, gcc is LALR.
>
>
> | Yes, GCC is LALR.
"The Gcc parser is a LALR grammar file for Bison, which is a LALR parser
generator.
Therefore, if you want to say that, gcc is LALR." |
5,481,114 | Can anyone deny/confirm this?? | 2011/03/30 | [
"https://Stackoverflow.com/questions/5481114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | <http://gcc.gnu.org/ml/gcc-help/2004-08/msg00099.html>
>
> The Gcc parser is a LALR grammar file for Bison, which is a LALR parser
> generator.
> Therefore, if you want to say that, gcc is LALR.
>
>
> | [This discussion](http://gcc.gnu.org/ml/gcc-help/2004-08/msg00077.html) (though old) says gcc is LALR while for C++ it is a hand-written recursive descent one. |
5,481,114 | Can anyone deny/confirm this?? | 2011/03/30 | [
"https://Stackoverflow.com/questions/5481114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | <http://gcc.gnu.org/ml/gcc-help/2004-08/msg00099.html>
>
> The Gcc parser is a LALR grammar file for Bison, which is a LALR parser
> generator.
> Therefore, if you want to say that, gcc is LALR.
>
>
> | The quote above is out of date. All parser of GCC is hand written now. And I am pretty sure cpp is a lalr(k) parser. |
37,102,774 | Cans someone explain the results in a typical dt function? The help page says that I should receive the density function. However, in my code below, what does the first value ".2067" represent?The second value?
```
x<-seq(1,10)
dt(x, df=3)
[1] 0.2067483358 0.0675096607 0.0229720373 0.0091633611 0.0042193538 0.002174... | 2016/05/08 | [
"https://Stackoverflow.com/questions/37102774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191014/"
] | You need to add user\_id column to rates table | Hard to say without seeing the migration files themselves, but you can use the `add_reference` function in your migrations to add a reference to a table:
```
class AddUserIdToRate < ActiveRecord::Migration
def change
unless column_exists? :rates, :user_id
add_reference :rates, :user, index: true
end
... |
11,783,658 | What is the regular expression for `c if statement`
Following is what I am trying but does not match
`if ( $line !~ /^if \(.\) \{/) {`
I expect it to match with `if ( a ==b ) {` | 2012/08/02 | [
"https://Stackoverflow.com/questions/11783658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92568/"
] | try to exchange . for .\* , it will acept more than 1 character inside "()" | ```
if ($line =~ /^if\s*\([^\)]+\)\s*\{/)
``` |
2,423,128 | I want to design a `JPanel` which should have the color coding as shown in the following diagram:
[](https://i.stack.imgur.com/YGVFM.gif)
(source: [compendiumblog.com](http://local.content.compendiumblog.com/uploads/user/b8bbc9ab-67b1-4a8e-ac5c-5811daa967bd/ec324f27-588d-454b... | 2010/03/11 | [
"https://Stackoverflow.com/questions/2423128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157027/"
] | Try using a JTable and then alternating the colors of the row. This way you can write a generic JComponent (AlternatingColorTable) and use it just like a regular JTable in those 4 panels.
Something like this maybe:
```
public class AlternatingColorTable extends JTable {
public AlternatingColorTable () {
super();... | Just make each of the colored bars themselves panels with a different background color. Don't forget to make the panels explicitly opaque with setOpaque(true) - panels are transparent by default transparent in most look and feels.
A note on aesthetics; I would start with the first line in each group shaded differently... |
33,206,400 | I'm using Angular and trying to create nested ng-repeats. I've referred to the ng-repeat examples on the Angular site here [here](https://docs.angularjs.org/api/ng/directive/ngRepeat). But when I use the code below, the `<ul>` tag repeats but the `<li>` tag is blank. Any suggestions on how to do this correctly?
(EDIT:... | 2015/10/19 | [
"https://Stackoverflow.com/questions/33206400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/640508/"
] | You want to do something like (in your inner `ng-repeat`):
```
name in project.people
```
Instead of
```
name in vm.projects.people.name track by projects.$id
```
(If you post a valid JSON sample I can give you the exact thing to put.) | ```
you can use like this
<ul>
<li ng-repeat="c in countries">
<label>
<input type="checkbox" ng-model="CountryName" />
{{c.CountryName}}
</label>
<ul ng-repeat="s in cities" ng-if="c.CountryId==s.CountryId">
... |
33,206,400 | I'm using Angular and trying to create nested ng-repeats. I've referred to the ng-repeat examples on the Angular site here [here](https://docs.angularjs.org/api/ng/directive/ngRepeat). But when I use the code below, the `<ul>` tag repeats but the `<li>` tag is blank. Any suggestions on how to do this correctly?
(EDIT:... | 2015/10/19 | [
"https://Stackoverflow.com/questions/33206400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/640508/"
] | You want to do something like (in your inner `ng-repeat`):
```
name in project.people
```
Instead of
```
name in vm.projects.people.name track by projects.$id
```
(If you post a valid JSON sample I can give you the exact thing to put.) | First it's important to point out that there were some significant syntax issues in your JSON which was breaking your ng-repeats.
You must refer to the object inside your first ng-repeat (the one you declare in the ul tag) to make sure the scope is mapped properly for the li tag scopes. In my example "someKey" refers... |
33,206,400 | I'm using Angular and trying to create nested ng-repeats. I've referred to the ng-repeat examples on the Angular site here [here](https://docs.angularjs.org/api/ng/directive/ngRepeat). But when I use the code below, the `<ul>` tag repeats but the `<li>` tag is blank. Any suggestions on how to do this correctly?
(EDIT:... | 2015/10/19 | [
"https://Stackoverflow.com/questions/33206400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/640508/"
] | You can use parent ul project object in li like below:
```
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example85-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.1/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/... | You want to do something like (in your inner `ng-repeat`):
```
name in project.people
```
Instead of
```
name in vm.projects.people.name track by projects.$id
```
(If you post a valid JSON sample I can give you the exact thing to put.) |
33,206,400 | I'm using Angular and trying to create nested ng-repeats. I've referred to the ng-repeat examples on the Angular site here [here](https://docs.angularjs.org/api/ng/directive/ngRepeat). But when I use the code below, the `<ul>` tag repeats but the `<li>` tag is blank. Any suggestions on how to do this correctly?
(EDIT:... | 2015/10/19 | [
"https://Stackoverflow.com/questions/33206400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/640508/"
] | You can use parent ul project object in li like below:
```
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example85-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.1/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/... | ```
you can use like this
<ul>
<li ng-repeat="c in countries">
<label>
<input type="checkbox" ng-model="CountryName" />
{{c.CountryName}}
</label>
<ul ng-repeat="s in cities" ng-if="c.CountryId==s.CountryId">
... |
33,206,400 | I'm using Angular and trying to create nested ng-repeats. I've referred to the ng-repeat examples on the Angular site here [here](https://docs.angularjs.org/api/ng/directive/ngRepeat). But when I use the code below, the `<ul>` tag repeats but the `<li>` tag is blank. Any suggestions on how to do this correctly?
(EDIT:... | 2015/10/19 | [
"https://Stackoverflow.com/questions/33206400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/640508/"
] | You can use parent ul project object in li like below:
```
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example85-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.1/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/... | First it's important to point out that there were some significant syntax issues in your JSON which was breaking your ng-repeats.
You must refer to the object inside your first ng-repeat (the one you declare in the ul tag) to make sure the scope is mapped properly for the li tag scopes. In my example "someKey" refers... |
21,060,344 | The problem here is to find the length of **longest subsequence** from the input array such that all the elements are in sorted order.
**Example: input** => `[10,22,9,33,21,50,41,60,80]`
**Example: Output** => `[10,22,33,50,60,80]` is **6**
My attempt:
```
def longest_sequence(input):
obj = []
for x in sor... | 2014/01/11 | [
"https://Stackoverflow.com/questions/21060344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1112163/"
] | ```
import bisect
def lis(xs):
ret = []
for x in xs:
i = bisect.bisect_left(ret, x)
ret[i:i+1] = x,
return len(ret)
```
Example:
```
>>> lis([10, 1, 2, 3])
3
>>> lis([10,22,9,33,21,50,41,60,80])
6
```
**NOTE** In the above code,`ret` does not contains valid subsequence. But the length ... | ```
data = [100,1,2,3]
conformed = []
for i in range (0, len(data)):
if i == 0:
if data[1]<data[0]:
conformed.append(data[1])
else:
conformed.append(data[0])
else:
if data[i] > data[i-1]:
conformed.append(data[i])
print conformed, len(conformed)
``` |
65,464,206 | I have an app with a settings page where the settings of each user are stored in a MySQL database. I was wondering what is the best way to update the database for every setting the user changes while sending the minimal number of requests as I'm worried that it will crash if it sends too many( it has happened before).
... | 2020/12/27 | [
"https://Stackoverflow.com/questions/65464206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8050929/"
] | You need to make some logic functions in your app, so i will try make an pseudo codes below. Hope it will give you an idea. I don`t know the MySQL details but i am trying to explain native Swift way.
First of all you should fetch data partly, I mean if you try to fetch all data at the same time your app can work very ... | Assuming that the Database (MySQL) is on a server
You can try using [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager) for this requirement.
1. When the user changes their settings, save them locally (which you are already doing)
2. `enqueue` a Unique Periodic Work Request using `... |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | I don’t know if Wordpress has some function for that. But you could do this:
```
$_SERVER['REQUEST_URI_PATH'] = preg_replace('/\\?.*/', '', $_SERVER['REQUEST_URI']);
```
`$_SERVER['REQUEST_URI']` contains the URI path plus the query and the code above will just get the URI path. Then you can compare it to your strin... | You can use build-in web server variables for this. Here are some example:
* `$_SERVER['HTTP_HOST']` - host name for current request
* `$_SERVER['REQUEST_URI']` - requested url with get parameters
You can also see full list by `print_r($_SERVER);`. |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | I don’t know if Wordpress has some function for that. But you could do this:
```
$_SERVER['REQUEST_URI_PATH'] = preg_replace('/\\?.*/', '', $_SERVER['REQUEST_URI']);
```
`$_SERVER['REQUEST_URI']` contains the URI path plus the query and the code above will just get the URI path. Then you can compare it to your strin... | ```
$paths = explode ('/', $_SERVER['PHP_SELF']);
```
This will give you an array of paths for the given script. You can perform logic based on the resulting array. |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | I don’t know if Wordpress has some function for that. But you could do this:
```
$_SERVER['REQUEST_URI_PATH'] = preg_replace('/\\?.*/', '', $_SERVER['REQUEST_URI']);
```
`$_SERVER['REQUEST_URI']` contains the URI path plus the query and the code above will just get the URI path. Then you can compare it to your strin... | And you run phpinfo() in a simple script, you will see EVERYTHING you might want to get your hands on from pure PHP. (and a lot of other stuff too, just scroll to the bottom of the output for PHP variables.) |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | I don’t know if Wordpress has some function for that. But you could do this:
```
$_SERVER['REQUEST_URI_PATH'] = preg_replace('/\\?.*/', '', $_SERVER['REQUEST_URI']);
```
`$_SERVER['REQUEST_URI']` contains the URI path plus the query and the code above will just get the URI path. Then you can compare it to your strin... | ```
current( explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) ) )
```
will return the first part of the url
```
explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) )
```
will create an array of the url parts |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | I don’t know if Wordpress has some function for that. But you could do this:
```
$_SERVER['REQUEST_URI_PATH'] = preg_replace('/\\?.*/', '', $_SERVER['REQUEST_URI']);
```
`$_SERVER['REQUEST_URI']` contains the URI path plus the query and the code above will just get the URI path. Then you can compare it to your strin... | With the following line of PHP code you will get the URL of the HTTP Request of the current page:
$url = ((preg\_match("/(^\z|^off\z)/i", $\_SERVER['HTTPS'])) ? 'http://' : 'https://') . $\_SERVER['HTTP\_HOST'] . $\_SERVER['REQUEST\_URI'];
Then you may want to parse this URL to get a reliable result array like this:
... |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | And you run phpinfo() in a simple script, you will see EVERYTHING you might want to get your hands on from pure PHP. (and a lot of other stuff too, just scroll to the bottom of the output for PHP variables.) | You can use build-in web server variables for this. Here are some example:
* `$_SERVER['HTTP_HOST']` - host name for current request
* `$_SERVER['REQUEST_URI']` - requested url with get parameters
You can also see full list by `print_r($_SERVER);`. |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | And you run phpinfo() in a simple script, you will see EVERYTHING you might want to get your hands on from pure PHP. (and a lot of other stuff too, just scroll to the bottom of the output for PHP variables.) | ```
$paths = explode ('/', $_SERVER['PHP_SELF']);
```
This will give you an array of paths for the given script. You can perform logic based on the resulting array. |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | And you run phpinfo() in a simple script, you will see EVERYTHING you might want to get your hands on from pure PHP. (and a lot of other stuff too, just scroll to the bottom of the output for PHP variables.) | ```
current( explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) ) )
```
will return the first part of the url
```
explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) )
```
will create an array of the url parts |
1,772,823 | This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the */sitemap/* directory.
So for example, if the site is *example.com*, and if the request is *example.com/sitemap/*.
Then I want to execute conditional code in that case. I'm using wo... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1772823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209102/"
] | And you run phpinfo() in a simple script, you will see EVERYTHING you might want to get your hands on from pure PHP. (and a lot of other stuff too, just scroll to the bottom of the output for PHP variables.) | With the following line of PHP code you will get the URL of the HTTP Request of the current page:
$url = ((preg\_match("/(^\z|^off\z)/i", $\_SERVER['HTTPS'])) ? 'http://' : 'https://') . $\_SERVER['HTTP\_HOST'] . $\_SERVER['REQUEST\_URI'];
Then you may want to parse this URL to get a reliable result array like this:
... |
19,288,498 | When trying to create a new Contact group, I found that the new group cannot be seen in the mobile, unless I set `ContactsContract.Groups.ACCOUNT_NAME and ACCOUNT_TYPE`:
```
ArrayList<ContentProviderOperation> o = new ArrayList<ContentProviderOperation>();
o.add(ContentProviderOperation.newInsert(Groups.CONTENT_URI)
... | 2013/10/10 | [
"https://Stackoverflow.com/questions/19288498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/558892/"
] | Looks like there are possibly multiple accounts for contacts in Android, it is possible that the system's Contact application is only showing interested accounts. So, one proper way is to get default account name and type.
Here is a function to get default account name and type:
```
private String[] getDefaultAccount... | The accounts are allways of a certain type. For what kind of accounts do you want to create a group? Are these Google Contacts or other contact types?
Account type can be "com.google" for example when it is a Google account. But you can also use your own custom account type. Then you need an account-authenticator see:... |
172,277 | I have code snippet of Kafka Consumer which i have developed with the help of [this](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/examples/Consumer/Program.cs) and here it is:
```
static void Main(string[] args)
{
string bootstrapServers = "localhost:9092";
string ... | 2019/05/25 | [
"https://gamedev.stackexchange.com/questions/172277",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/70315/"
] | >
> Wrap the code inside coroutine, so it simultanously run with main unity thread
>
>
>
You have fundamentally misunderstood how coroutines work. [Consulting the Unity documentation](https://docs.unity3d.com/Manual/Coroutines.html):
>
> A coroutine is like a function that has the ability to **pause execution an... | Use the timeout alternative, with a zero second timeout, and wait for it to return non-null:
Turn this
```
var consumeResult = consumer.Consume();
yield return consumeResult;
```
Into this
```
ConsumeResult<string, GenericRecord> consumeResult;
do {
consumeResult = consumer.Consume(TimeSpan.Zero);
yield return... |
29,775,093 | I use the following algorithm to calculate the distance between two points but it's producing unreasonable results. Where am I wrong?
```
private static double distFrom(double latA, double lngA, double latB, double lngB) {
double pk = 180/3.14169;
double a1 = latA / pk;
double a2 = lngA / pk;
double b... | 2015/04/21 | [
"https://Stackoverflow.com/questions/29775093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1165493/"
] | Replacing 3.14169 with Math.PI will improve a little since the first digits of PI are 3.141**5**9
Also, there is alot of algorithm out there. try <http://www.geodatasource.com/developers/java> that will give you an answer in miles, kilometers and nautic miles. | Better use standard letters - L for longitude, B for latitude. The formula for <http://en.wikipedia.org/wiki/Great-circle_distance> method you have used is strange. According to wiki it will be:
```
double B1 = latA / pk;
double B2 = latB / pk;
double dL = (lngA-lngB) / pk;
double t1 = Math.cos(B1)*Ma... |
29,775,093 | I use the following algorithm to calculate the distance between two points but it's producing unreasonable results. Where am I wrong?
```
private static double distFrom(double latA, double lngA, double latB, double lngB) {
double pk = 180/3.14169;
double a1 = latA / pk;
double a2 = lngA / pk;
double b... | 2015/04/21 | [
"https://Stackoverflow.com/questions/29775093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1165493/"
] | Replacing 3.14169 with Math.PI will improve a little since the first digits of PI are 3.141**5**9
Also, there is alot of algorithm out there. try <http://www.geodatasource.com/developers/java> that will give you an answer in miles, kilometers and nautic miles. | Here's an implementation of the atan version from <http://en.wikipedia.org/wiki/Great-circle_distance> ("special case of the Vincenty formula") which is "accurate for all distances":
```
/**
* Mean earth radius in Kilometers (KM) as defined in WGS84
*/
public static final double EARTH_RADIUS_KM = 6371.0087714;
/**
... |
29,775,093 | I use the following algorithm to calculate the distance between two points but it's producing unreasonable results. Where am I wrong?
```
private static double distFrom(double latA, double lngA, double latB, double lngB) {
double pk = 180/3.14169;
double a1 = latA / pk;
double a2 = lngA / pk;
double b... | 2015/04/21 | [
"https://Stackoverflow.com/questions/29775093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1165493/"
] | Better use standard letters - L for longitude, B for latitude. The formula for <http://en.wikipedia.org/wiki/Great-circle_distance> method you have used is strange. According to wiki it will be:
```
double B1 = latA / pk;
double B2 = latB / pk;
double dL = (lngA-lngB) / pk;
double t1 = Math.cos(B1)*Ma... | Here's an implementation of the atan version from <http://en.wikipedia.org/wiki/Great-circle_distance> ("special case of the Vincenty formula") which is "accurate for all distances":
```
/**
* Mean earth radius in Kilometers (KM) as defined in WGS84
*/
public static final double EARTH_RADIUS_KM = 6371.0087714;
/**
... |
64,350,948 | Please check the images i used stack and positioned widget but the result is not responsive..
attached images are from two d/f emulators. please help.
Please check the images i used stack and positioned widget but the result is not responsive..
attached images are from two d/f emulators. please help
[enter image desc... | 2020/10/14 | [
"https://Stackoverflow.com/questions/64350948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5665367/"
] | This is intended behavior since Spring Boot 2.3 as explained [here](https://stackoverflow.com/questions/62459836/exception-message-not-included-in-response-when-throwing-responsestatusexception/62467065#62467065)
Setting `server.error.include-message=always` in the application.properties resolves this issue. | The response can be configured by injecting a custom ErrorController, like for example this one:
```
@Controller
class ExampleErrorController(private val errorAttributes: ErrorAttributes) : ErrorController {
private val mapper = ObjectMapper()
@RequestMapping("/error")
@ResponseBody
fun handleError(r... |
109,658 | Beyond the general UX rules, what is the best for a company/ a product, to focus on the existing type of users or on the users they target? | 2017/07/05 | [
"https://ux.stackexchange.com/questions/109658",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/72956/"
] | The business goals need to be clearly defined first: UX works in the service (in an ethical manner) of the business goals and the users/customers.
--------------------------------------------------------------------------------------------------------------------------------------------------
Without definition of the... | If the existing users are much different from then target users, then the company must re-evaluate their goals and business model. This may be a sign that they have to pivot ([see relevant book](http://www.pivotmethod.com/)), and change the target users to match existing.
But if they have already done this, and they h... |
45,356,962 | I have custom service class:
```
@Injectable()
export class CustomService {
constructor(num: number) {
}
}
```
This class is injected in constructor of component like this:
```
constructor(private cs: CustomService) {
}
```
But how to pass parameter `num` to service in constructor described above?
Something ... | 2017/07/27 | [
"https://Stackoverflow.com/questions/45356962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7647670/"
] | If `CustomService` instances should not be injector singletons, it is:
```
providers: [{ provide: CustomService, useValue: CustomService }]
...
private cs;
constructor(@Inject(CustomService) private CustomService: typeof CustomService) {
this.cs = new CustomService(1);
}
```
If `CustomService` is supposed be me... | A service can hold data. You could define a public property in your service and set that data.
Here is an example:
```
import { Injectable } from '@angular/core';
@Injectable()
export class DataService {
serviceData: string;
}
```
But if you are configuring the service, Jon's comment to your question may be a ... |
61,579,886 | I have created a function fadeIn defining some basic properties of animation view. I am trying to pass these values into my AnimatedView but getting an error:
The function I wrote for fadeIn is :
```
import {Animated} from 'react-native';
const fadeIn = ({delay = 0, duration = 500}) => {
const initialStyle = new... | 2020/05/03 | [
"https://Stackoverflow.com/questions/61579886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9413110/"
] | You get this error because you are trying to destruct an object which is `undefined`.
Your `fadeIn` function takes an object as argument. But when you are calling the function you do not provide any value as parameter, which will yield `undefined`. So basically what is happening is the following:
```
const {delay = ... | possible to handle this is to construct function with define parameters.
```
const fadeIn = (delay = 0, duration = 500) => { ... }
```
than you can call it as fallow
```
fadeIn()
```
or overwrite the parametr as
```
fadeIn(50, 1000)
``` |
18,775,571 | I have a collection of objects that bind to a `System.Web.UI.WebControls.ListControl`:
```
foreach (var answer in SomeCollection)
{
System.Web.UI.WebControls.ListItem listItem = new System.Web.UI.WebControls.ListItem();
listItem.Value = answer.ID.ToString();
listItem.Text = answer.AnswerText;
listContr... | 2013/09/12 | [
"https://Stackoverflow.com/questions/18775571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1038940/"
] | This is not a problem of missing headers or libraries but of a bug somewhere. If you are not using GTK+/Glib directly, it must be a wxWidgets bug, but I have no idea how could this happen, so some more information would be needed to understand what's going on: either a small, simple example reproducing the problem or a... | Came across this problem and this stackoverflow post - not when using wxWidgets, but when creating a custom composite GTK widget and instantiating it in a test program.
Looking at the source for gtype.c
```
124 #define g_return_val_if_type_system_uninitialized(return_value) G_STMT_START{ \
125 if (G_UNLIKELY (... |
3,925,503 | Hi I am looking to set the timezone for San Antonio, Texas.Can some please tell me how do i set the same in my Java code.
I want it in the format somewhat similar to America/New York
Currently I am using this code
```
TimeZone.getTimeZone("America/Denver");
```
But "America/Denver" doesn't seem to be the right ti... | 2010/10/13 | [
"https://Stackoverflow.com/questions/3925503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241755/"
] | related topic:
[How to handle calendar TimeZones using Java?](https://stackoverflow.com/questions/230126/how-to-handle-calendar-timezones-using-java)
timezone for San Antonio:
Standard time zone: UTC/GMT -6 hours
Daylight saving time: +1 hour
Current time zone offset: UTC/GMT -5 hours
Time zone abbreviat... | I totally googled your question and got this:
<http://www.few.vu.nl/~eliens/documents/java/jdk1.2-docs/docs/api/java/util/TimeZone.html>
You can also get a TimeZone using getTimeZone along with a time zone ID. For instance, the time zone ID for the Pacific Standard Time zone is "PST". So, you can get a PST TimeZone ob... |
3,925,503 | Hi I am looking to set the timezone for San Antonio, Texas.Can some please tell me how do i set the same in my Java code.
I want it in the format somewhat similar to America/New York
Currently I am using this code
```
TimeZone.getTimeZone("America/Denver");
```
But "America/Denver" doesn't seem to be the right ti... | 2010/10/13 | [
"https://Stackoverflow.com/questions/3925503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241755/"
] | For San Antonio, you should use `TimeZone.getTimeZone("US/Central")`
If you really need to use `"America/<City>"` format, the closest to San Antonio us city is `"America/Chicago"`.
You can use this to get a list of all available specific IDs for US/Central:
```
String[] values = TimeZone.getAvailableIDs(TimeZone.get... | I totally googled your question and got this:
<http://www.few.vu.nl/~eliens/documents/java/jdk1.2-docs/docs/api/java/util/TimeZone.html>
You can also get a TimeZone using getTimeZone along with a time zone ID. For instance, the time zone ID for the Pacific Standard Time zone is "PST". So, you can get a PST TimeZone ob... |
3,925,503 | Hi I am looking to set the timezone for San Antonio, Texas.Can some please tell me how do i set the same in my Java code.
I want it in the format somewhat similar to America/New York
Currently I am using this code
```
TimeZone.getTimeZone("America/Denver");
```
But "America/Denver" doesn't seem to be the right ti... | 2010/10/13 | [
"https://Stackoverflow.com/questions/3925503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241755/"
] | San Antonio → `America/Chicago`
===============================
The IANA time zone identifier for San Antonio is `America/Chicago`, as [shown on Time.is](http://time.is/San_Antonio).
Using java.time
===============
The modern way to handle date-time is with the java.time classes.
The [`Instant`](http://docs.oracle.... | I totally googled your question and got this:
<http://www.few.vu.nl/~eliens/documents/java/jdk1.2-docs/docs/api/java/util/TimeZone.html>
You can also get a TimeZone using getTimeZone along with a time zone ID. For instance, the time zone ID for the Pacific Standard Time zone is "PST". So, you can get a PST TimeZone ob... |
3,925,503 | Hi I am looking to set the timezone for San Antonio, Texas.Can some please tell me how do i set the same in my Java code.
I want it in the format somewhat similar to America/New York
Currently I am using this code
```
TimeZone.getTimeZone("America/Denver");
```
But "America/Denver" doesn't seem to be the right ti... | 2010/10/13 | [
"https://Stackoverflow.com/questions/3925503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241755/"
] | For San Antonio, you should use `TimeZone.getTimeZone("US/Central")`
If you really need to use `"America/<City>"` format, the closest to San Antonio us city is `"America/Chicago"`.
You can use this to get a list of all available specific IDs for US/Central:
```
String[] values = TimeZone.getAvailableIDs(TimeZone.get... | related topic:
[How to handle calendar TimeZones using Java?](https://stackoverflow.com/questions/230126/how-to-handle-calendar-timezones-using-java)
timezone for San Antonio:
Standard time zone: UTC/GMT -6 hours
Daylight saving time: +1 hour
Current time zone offset: UTC/GMT -5 hours
Time zone abbreviat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.