qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
22,262,270 | I have no problems with running the TCP Server and I like the fact that it's in blocking to avoid useless loops and sleeping code and useless cpu cycles.
The problem happens when shutting it down in Linux environment, it stays on, until the connected user sends something, then it turns off.
I figured it's because it'... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22262270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/414521/"
] | Have a look here, I made some notes on the issues.
<http://ossh.com.au/design-and-technology/software-development/sample-library-style-ios-core-data-app-with-icloud-integration/sample-apps-explanations/>
Also take a look at the sample apps that handle iCloud account transitions, I think you can choose a merge option ... | There are two ways to do that:
1. Deep copy entities from one store to another;
2. Migrate store from local to iCloud or vice versa.
The second way is much easier due to less code. |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | Why don't you just use `head` for that? | ```
my ($first_five) = $s =~ /\A((?:.*\n){5})/;
my ($last_five) = $s =~ /((?:.*\n){5})\z/;
``` |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | Why don't you just use `head` for that? | People are missing some key flags:
```
/(?m)((?:^.*\n?){1,5})/
```
Without the multi-line flag, it's only going to look at the first line. Also by making the `\n` optional, we can take the first five *lines*, regardless of a newline at the end of the fifth. |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | People are missing some key flags:
```
/(?m)((?:^.*\n?){1,5})/
```
Without the multi-line flag, it's only going to look at the first line. Also by making the `\n` optional, we can take the first five *lines*, regardless of a newline at the end of the fifth. | ```
use strict;
my $line; #Store line currently being read
my $count=$ARGV[1]; # How many lines to read as passed from command line
my @last; #Array to store last count lines
my $index; #Index of the line being stored
#Open the file to read as supplied from command line
open (FILE,$ARGV[0]);
while ($line=<FILE>)
{
... |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | You don't need a regex. Just open a filehandle on a reference to the scalar then do the same things that you would for any other sort of filehandle:
```
my $scalar = ...;
open my($fh), "<", \ $scalar or die "Could not open filehandle: $!";
foreach ( 1 .. 5 )
{
push @lines, scalar <$fh>;
}
close $fh;
$sca... | People are missing some key flags:
```
/(?m)((?:^.*\n?){1,5})/
```
Without the multi-line flag, it's only going to look at the first line. Also by making the `\n` optional, we can take the first five *lines*, regardless of a newline at the end of the fifth. |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | Odd request, but this should do it:
```
#!/usr/bin/perl
use strict;
use warnings;
my $s = join '', map { "$_\n" } 1 .. 9;
my ($first) = $s =~ /^((?:.*\n){0,5})/;
my ($last) = $s =~ /((?:.*\n){0,5})$/;
print "first:\n${first}last:\n$last";
```
A more common solution would be something like this:
```
#!/usr/bn/pe... | Why don't you just use `head` for that? |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | As Brian says, you can use `head` or `tail` pretty easily for either problem (first 5 lines or last 5 lines).
But now I'm wondering if I even understand your question correctly. When you say "for any kind of scalar", do you mean that (for whatever reason) the file is already in a scalar?
If not, I think that the be... | ```
use strict;
my $line; #Store line currently being read
my $count=$ARGV[1]; # How many lines to read as passed from command line
my @last; #Array to store last count lines
my $index; #Index of the line being stored
#Open the file to read as supplied from command line
open (FILE,$ARGV[0]);
while ($line=<FILE>)
{
... |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | As Brian says, you can use `head` or `tail` pretty easily for either problem (first 5 lines or last 5 lines).
But now I'm wondering if I even understand your question correctly. When you say "for any kind of scalar", do you mean that (for whatever reason) the file is already in a scalar?
If not, I think that the be... | People are missing some key flags:
```
/(?m)((?:^.*\n?){1,5})/
```
Without the multi-line flag, it's only going to look at the first line. Also by making the `\n` optional, we can take the first five *lines*, regardless of a newline at the end of the fifth. |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | ```
my ($first_five) = $s =~ /\A((?:.*\n){5})/;
my ($last_five) = $s =~ /((?:.*\n){5})\z/;
``` | People are missing some key flags:
```
/(?m)((?:^.*\n?){1,5})/
```
Without the multi-line flag, it's only going to look at the first line. Also by making the `\n` optional, we can take the first five *lines*, regardless of a newline at the end of the fifth. |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | Odd request, but this should do it:
```
#!/usr/bin/perl
use strict;
use warnings;
my $s = join '', map { "$_\n" } 1 .. 9;
my ($first) = $s =~ /^((?:.*\n){0,5})/;
my ($last) = $s =~ /((?:.*\n){0,5})$/;
print "first:\n${first}last:\n$last";
```
A more common solution would be something like this:
```
#!/usr/bn/pe... | People are missing some key flags:
```
/(?m)((?:^.*\n?){1,5})/
```
Without the multi-line flag, it's only going to look at the first line. Also by making the `\n` optional, we can take the first five *lines*, regardless of a newline at the end of the fifth. |
776,554 | I have two sets of data which I need to join, but there is an added problem because the data quality is not great.
The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call\_id and comm\_id respectively. The communication records also have call\_ids to... | 2009/04/22 | [
"https://Stackoverflow.com/questions/776554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74706/"
] | Odd request, but this should do it:
```
#!/usr/bin/perl
use strict;
use warnings;
my $s = join '', map { "$_\n" } 1 .. 9;
my ($first) = $s =~ /^((?:.*\n){0,5})/;
my ($last) = $s =~ /((?:.*\n){0,5})$/;
print "first:\n${first}last:\n$last";
```
A more common solution would be something like this:
```
#!/usr/bn/pe... | As Brian says, you can use `head` or `tail` pretty easily for either problem (first 5 lines or last 5 lines).
But now I'm wondering if I even understand your question correctly. When you say "for any kind of scalar", do you mean that (for whatever reason) the file is already in a scalar?
If not, I think that the be... |
14,307,086 | I have an alias: `alias gco='git checkout'`
How can I add tab completion as if I had typed `git checkout`?
For my `alias g='git'` I use `compdef g='git'`.
I've been trying to use `compdef` but I've not had any success. | 2013/01/13 | [
"https://Stackoverflow.com/questions/14307086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/958409/"
] | You don’t need to do anything, especially `compdef g='git'`, it should work without any configuration. You would need something only if you used function in place of an alias. | Disable this option and you're also good...
```
# don't expand aliases _before_ completion has finished
# like: git comm-[tab]
# setopt complete_aliases
``` |
14,307,086 | I have an alias: `alias gco='git checkout'`
How can I add tab completion as if I had typed `git checkout`?
For my `alias g='git'` I use `compdef g='git'`.
I've been trying to use `compdef` but I've not had any success. | 2013/01/13 | [
"https://Stackoverflow.com/questions/14307086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/958409/"
] | You don’t need to do anything, especially `compdef g='git'`, it should work without any configuration. You would need something only if you used function in place of an alias. | For me adding both of `complete_aliases` and `compdef` is necessary to get below snippet work:
```
alias docker-compose-dev='docker-compose -f docker-compose.yml -f docker-compose-dev.yml'
compdef docker-compose-dev='docker-compose'
setopt complete_aliases
``` |
14,307,086 | I have an alias: `alias gco='git checkout'`
How can I add tab completion as if I had typed `git checkout`?
For my `alias g='git'` I use `compdef g='git'`.
I've been trying to use `compdef` but I've not had any success. | 2013/01/13 | [
"https://Stackoverflow.com/questions/14307086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/958409/"
] | Disable this option and you're also good...
```
# don't expand aliases _before_ completion has finished
# like: git comm-[tab]
# setopt complete_aliases
``` | For me adding both of `complete_aliases` and `compdef` is necessary to get below snippet work:
```
alias docker-compose-dev='docker-compose -f docker-compose.yml -f docker-compose-dev.yml'
compdef docker-compose-dev='docker-compose'
setopt complete_aliases
``` |
5,024,369 | I need an array to store some geometrical data. I would like to simply inherit from the Array object and than extend it with a few new functions like "height" and "width" (sum of all children's heights/widths), but also with a few convenience methods like "insertAt" or "remove".
What is the best way to do it **without... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5024369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39409/"
] | You can always mixin your changes directly into Array, but that might not be the best choice given that it's not something every array should have. So let's inherit from Array:
```
// create a constructor for the class
function GeometricArray() {
this.width = 0;
this.height = 0;
}
// create a new instance for t... | You could use prototyping to put those functions in Array.
To add the height function for example do this:
```
Array.prototype.height = function() {
//implementation of height
}
``` |
5,024,369 | I need an array to store some geometrical data. I would like to simply inherit from the Array object and than extend it with a few new functions like "height" and "width" (sum of all children's heights/widths), but also with a few convenience methods like "insertAt" or "remove".
What is the best way to do it **without... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5024369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39409/"
] | Are you (maybe) applying Java concepts to Javascript?
You don't need to inherit from classes in Javascript, you just ***enrich*** objects.
So the best way in my world (a world full of people *head-butting* methods into objects) is:
```
function GeometricArray()
{
var obj=[]
obj.height=function() {
// wibbly... | You could use prototyping to put those functions in Array.
To add the height function for example do this:
```
Array.prototype.height = function() {
//implementation of height
}
``` |
5,024,369 | I need an array to store some geometrical data. I would like to simply inherit from the Array object and than extend it with a few new functions like "height" and "width" (sum of all children's heights/widths), but also with a few convenience methods like "insertAt" or "remove".
What is the best way to do it **without... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5024369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39409/"
] | You can always mixin your changes directly into Array, but that might not be the best choice given that it's not something every array should have. So let's inherit from Array:
```
// create a constructor for the class
function GeometricArray() {
this.width = 0;
this.height = 0;
}
// create a new instance for t... | Are you (maybe) applying Java concepts to Javascript?
You don't need to inherit from classes in Javascript, you just ***enrich*** objects.
So the best way in my world (a world full of people *head-butting* methods into objects) is:
```
function GeometricArray()
{
var obj=[]
obj.height=function() {
// wibbly... |
7,605,097 | Consider this HTML source code:
```
<form id="foo1" name="x"> Form 1 </form>
<form id="foo2"> Form 2 </form>
```
As you can see, we define two FORM elements.
In Chrome, Safari and Firefox, both `document.foo1` and `document.foo2` return `undefined`.
However, in IE and Opera, `document.foo1` returns a reference to... | 2011/09/30 | [
"https://Stackoverflow.com/questions/7605097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425275/"
] | What looks to be happening is you're navigating outside the scope of jQM, but 1.html is in location.hash.
>
> Hash changes that occur independently of a click, such as when a user
> clicks the back button, are handled through the hashchange event,
> which is bound to the window object using Ben Alman's hashchange
... | If you want jQuery mobile to handle the history and back button you need to use $.mobile.changePage to change the page (as opposed to window.location=..).
More info here: <http://jquerymobile.com/demos/1.0rc1/docs/api/methods.html> |
7,605,097 | Consider this HTML source code:
```
<form id="foo1" name="x"> Form 1 </form>
<form id="foo2"> Form 2 </form>
```
As you can see, we define two FORM elements.
In Chrome, Safari and Firefox, both `document.foo1` and `document.foo2` return `undefined`.
However, in IE and Opera, `document.foo1` returns a reference to... | 2011/09/30 | [
"https://Stackoverflow.com/questions/7605097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425275/"
] | What looks to be happening is you're navigating outside the scope of jQM, but 1.html is in location.hash.
>
> Hash changes that occur independently of a click, such as when a user
> clicks the back button, are handled through the hashchange event,
> which is bound to the window object using Ben Alman's hashchange
... | Have you tried to specifically set data-ajax="false" on your links? Or rel="external", although this is supposed to only be used if you want to change to another domain.
If you don't set either one, I'm afraid JQM hijacks.
Try if it works with data-ajax="false".
Actually I have a similar issue with regular JQM-Ajax... |
7,605,097 | Consider this HTML source code:
```
<form id="foo1" name="x"> Form 1 </form>
<form id="foo2"> Form 2 </form>
```
As you can see, we define two FORM elements.
In Chrome, Safari and Firefox, both `document.foo1` and `document.foo2` return `undefined`.
However, in IE and Opera, `document.foo1` returns a reference to... | 2011/09/30 | [
"https://Stackoverflow.com/questions/7605097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425275/"
] | What looks to be happening is you're navigating outside the scope of jQM, but 1.html is in location.hash.
>
> Hash changes that occur independently of a click, such as when a user
> clicks the back button, are handled through the hashchange event,
> which is bound to the window object using Ben Alman's hashchange
... | a wild guess. you didn't hardcode css class ui-page-active into the .ui-page element right? becuase that would cause both page to appear. |
49,006,773 | I´m using Mac OS el capitán and I am trying to follow the [quick start tutorial for OpenNMT pytorch](http://opennmt.net/OpenNMT-py/quickstart) version. In the training step I get the following warning message:
```
OpenNMT-py/onmt/modules/GlobalAttention.py:177: UserWarning: Implicit dimension choice for softmax has be... | 2018/02/27 | [
"https://Stackoverflow.com/questions/49006773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1791939/"
] | It is almost always you will need the last dimension when you compute the cross-entropy so your line may look like:
```
torch.nn.functional.log_softmax(x, -1)
``` | From the warning it's pretty clear that you have to explicitly mention the dimension since implicit dimension choice for softmax has been deprecated.
In my case, I'm using `log_softmax`and I've changed below line of code to include dimension.
```
torch.nn.functional.log_softmax(x) # This throws warning.
```
is cha... |
46,718,463 | Say I have two beans (where `BeanA` properties are immutable, requiring constructor injection):
```
<bean id="beanA1" class="BeanA">
<constructor-arg type="ServiceA" ref="serviceA" />
<constructor-arg type="ServiceB" ref="serviceB" />
<constructor-arg type="ServiceC" ref="serviceC" />
<constructor-arg type="bo... | 2017/10/12 | [
"https://Stackoverflow.com/questions/46718463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3821009/"
] | You can't do what you are trying to achieve with the Constructor Dependency Injection because in the case of the `beanA2` you are calling a constructor with a single boolean parameter.
However, you can achieve what you want if you change the injection from a constructor-based to a setter-based DI:
```
<bean id="beanA... | Current exception telling you that there is no constructor with only one `boolean` value. It is not clear why you need constructor injection, you could try just to set needed property by it name to `false`. |
17,706,577 | The following script should validate only certain input fields depending on the selection a user makes in a drop-down box (var problem).
The trouble I'm having is when the if statement runs for problem == 4 (below) and the user has filled in the corresponding cityid field, the alert (Alert#3) for the next if statement... | 2013/07/17 | [
"https://Stackoverflow.com/questions/17706577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2170703/"
] | You're not returning from the function when you discover that the problem is #4. Thus, because it **is** 4, then it's not 5, and so the "else" part of that branch is taken.
*edit* — OK, let's look at the code:
```
if (problem.selectedIndex == 4) {
cityid.focus();
}
else if (cityid.value == "") {
alert("Alert#... | You should restructure each IF like so:
```
if (problem.selectedIndex == 4 || cityid.value == "")
{
cityid.focus();
return false;
}
if (problem.selectedIndex == 5 || model.value == "")
//and so on
```
so it returns either way and does not hit the next `if` statement |
35,814,755 | When a user opens the page there is a count variable which increments by one. The count variable as well as the data are written in a file.
The problem concerns the session variable which is not incrementing. Every time the page loads there should be a increment in the session which should be put into the file.
```
... | 2016/03/05 | [
"https://Stackoverflow.com/questions/35814755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6022326/"
] | You should change the last line:
```
#!/bin/sh
# run: $ ./normalize x y input_file output_file
X=$1
Y=$2
INPUT=$3
OUTPUT=$4
BIGGEST_FIRST_COLUMN=$(sort -nrk1 $INPUT | head -n1 | cut -d ' ' -f 1)
BIGGEST_SECOND_COLUMN=$(sort -nrk2 $INPUT | head -n1 | cut -d ' ' -f 2)
PERL_CMD="'s!([\d.]+)\s([\d.]+)!(\$1/$BIGGEST_FIR... | Here's a Perl one-liner that will do as you ask without needing the shell to preprocess the data
```none
perl -MList::Util=max -E'@d=map[split],<>;for $i(0,1){$m=max map $$_[$i],@d; $$_[$i]*=10/$m for @d} say qq{@$_} for @d' data.txt
```
### output
```
10 5
7.5 10
``` |
65,221,853 | ```
df = pd.DataFrame({'col1':['A','A','B'], 'col2':[1,2,1]})
```
I'd like to group the results into tuples inside a list:
```
[ ('A', [1,2]), ('B',[1]) ]
```
I thought `list(df.groupby(by='col1')['col2'])` would be sufficient but the second element of the tuple is a Series.
`df.groupby(by='col1')['col2'].apply(l... | 2020/12/09 | [
"https://Stackoverflow.com/questions/65221853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635863/"
] | You can use [`GroupBy.agg`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.agg.html) to list, then use [`df.to_records`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_records.html) and convert it to list.
```
df.groupby('col1').agg(list).to_recor... | You could add the `agg` function with `list` and then `zip` the final result :
```
result = df.groupby(by="col1")["col2"].agg(list)
list(zip(result.index, result))
[('A', [1, 2]), ('B', [1])]
``` |
65,221,853 | ```
df = pd.DataFrame({'col1':['A','A','B'], 'col2':[1,2,1]})
```
I'd like to group the results into tuples inside a list:
```
[ ('A', [1,2]), ('B',[1]) ]
```
I thought `list(df.groupby(by='col1')['col2'])` would be sufficient but the second element of the tuple is a Series.
`df.groupby(by='col1')['col2'].apply(l... | 2020/12/09 | [
"https://Stackoverflow.com/questions/65221853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635863/"
] | You can use [`GroupBy.agg`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.agg.html) to list, then use [`df.to_records`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_records.html) and convert it to list.
```
df.groupby('col1').agg(list).to_recor... | Make a list zip according to your `groupby` value index
```
import pandas as pd
df = pd.DataFrame({'col1':['A','A','B'], 'col2':[1,2,1]})
dff= df.groupby(by='col1')['col2'].apply(lambda x: x.values.tolist())
df_f= list(zip(dff.index, dff))
df_f
``` |
48,364,575 | I was trying to order a data frame in R according to a column named 'credit card usage'. The name of the data frame is mydata. The following command without a comma gives an error
>
> newdata = mydata[order('credit card usage')]
>
>
>
But the following command with a comma works absolutely fine
>
> newdata = ... | 2018/01/21 | [
"https://Stackoverflow.com/questions/48364575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3643544/"
] | Why `mydata[order('credit card usage'),]` returns only `first row` is a tricky one.
The name of the column when used after `,` in `[` refers to value of column otherwise it is just a `string`.
`order('credit card usage')` call considers just a `string` is passed to it and it sorts it out and pass the index(which is ... | MKR's answer explains why the OP obtained the results described in the post. Here, we'll explain how to deal with the column named `credit card usage` to correctly sort the entire data frame.
Generally speaking, it's not advisable to use column names containing spaces in R because it often leads to unexpected results... |
50,775,205 | My home page used to be www.example.com/index.html, because I was on the Weebly platform. I then switched to Wordpress, where the home page should simply be www.example.com/home.
However, I realized if I visit the URL on a browser where cache hasn't been cleared for the past 24 hours, the website automatically redirec... | 2018/06/09 | [
"https://Stackoverflow.com/questions/50775205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9918434/"
] | You're creating the adapter after receiving the response on `ValueEventListener`:
```
CustomListAdapter adapter = new CustomListAdapter(ViewDatabase.this , R.layout.custom_list , mList);
ListView mListView= findViewById(R.id.listview);
mListView.setAdapter(adapter);
```
Instead of that, set the adapter o... | You are modifying the view only when it hasn't been created before, which won't be the case the next time around, that's it, when the data is available. So, based on your code (should consider including a holder btw):
```
public View getView(int position, View v, ViewGroup parent) {
View mView = v;
if (mView =... |
25,601,349 | I am developing MVC application.
I want to get entire object with its child collection when I click on submit button on the form.
Please check below View Model.
I have below view model.
```
public class AdviceCreateVM
{
[Key]
public int Id { get; set; }
publ... | 2014/09/01 | [
"https://Stackoverflow.com/questions/25601349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1650894/"
] | When rendering your view, be sure to render out any fields you wish to keep during form submit as a hidden field using something like `Html.HiddenFor()`, if they aren't already represented on the form as an `input`, `select`, `textarea`, etc.
Also when you come to render your repeating element (your invoice), do this ... | You can create single ViewModel and add these two classes to that model as its fields
```
public class YourViewModel
{
public YourViewModel()
{
this.adviceCreateVM = new AdviceCreateVM ();
this.invoiceVM = new InvoiceVM();
}
public AdviceCreateVM adviceCreateVM { get; s... |
25,601,349 | I am developing MVC application.
I want to get entire object with its child collection when I click on submit button on the form.
Please check below View Model.
I have below view model.
```
public class AdviceCreateVM
{
[Key]
public int Id { get; set; }
publ... | 2014/09/01 | [
"https://Stackoverflow.com/questions/25601349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1650894/"
] | You can use:
```
Parent.FindControl("control_name") as Control_Type
```
For example:
```
HiddenField hdn = Parent.FindControl("hdn") as HiddenField;
``` | You can create single ViewModel and add these two classes to that model as its fields
```
public class YourViewModel
{
public YourViewModel()
{
this.adviceCreateVM = new AdviceCreateVM ();
this.invoiceVM = new InvoiceVM();
}
public AdviceCreateVM adviceCreateVM { get; s... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | In Java 8 you can proceed as below :
```
String s1 = "T,V,E";
String s2 = "T,W,E";
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.j... | you can use the split() function as the following
```
String a="A, B, C, D";
String b="B, C, D";
String[] a_chars =a.split(", "); //returns array with A B C D
String[] b_chars =b.split(", "); //returns array with B C D
```
this whay you have 2 arrays of strings now you can compare them using ... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | The appropriate data structure is Set.
```
Set<String> m3 = new TreeSet<>();
Collections.addAll(m3, "T", "V", "E");
Collections.addAll(m3, "T, V, E".split(",\\s*")); // Alternatively.
Set<String> m2 = new HashSet<>();
Collections.addAll(m2, "T", "W", "E");
Set<String> m5 = new TreeSet<>(m2);
... | If all your `String` follows this pattern : `..., ..., ....` , you could split them and filter only each String that is contained in the two arrays.
You can then collect them into a `List` and join them with `,` :
```
List<String> commonStrings = Arrays.stream(m2.split(",\\s"))
.flatMap(s-> Arrays.stream(m3.s... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | The appropriate data structure is Set.
```
Set<String> m3 = new TreeSet<>();
Collections.addAll(m3, "T", "V", "E");
Collections.addAll(m3, "T, V, E".split(",\\s*")); // Alternatively.
Set<String> m2 = new HashSet<>();
Collections.addAll(m2, "T", "W", "E");
Set<String> m5 = new TreeSet<>(m2);
... | you can use the split() function as the following
```
String a="A, B, C, D";
String b="B, C, D";
String[] a_chars =a.split(", "); //returns array with A B C D
String[] b_chars =b.split(", "); //returns array with B C D
```
this whay you have 2 arrays of strings now you can compare them using ... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | In Java 8 you can proceed as below :
```
String s1 = "T,V,E";
String s2 = "T,W,E";
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.j... | You can achieve this in many ways. One of the ways is using **Set**.
First, split **m1** the characters by (comma) and add it to **HashSet**. Then split the **m2** characters and add it to **ArrayList**. Now by the for loop try to add the **ArrayList** characters to **HashSet**. You will get false from the add method ... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | In Java 8 you can proceed as below :
```
String s1 = "T,V,E";
String s2 = "T,W,E";
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.j... | The appropriate data structure is Set.
```
Set<String> m3 = new TreeSet<>();
Collections.addAll(m3, "T", "V", "E");
Collections.addAll(m3, "T, V, E".split(",\\s*")); // Alternatively.
Set<String> m2 = new HashSet<>();
Collections.addAll(m2, "T", "W", "E");
Set<String> m5 = new TreeSet<>(m2);
... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | In Java 8 you can proceed as below :
```
String s1 = "T,V,E";
String s2 = "T,W,E";
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.j... | String s1 = "T,V,E";
String s2 = "T,W,E";
```
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.join(",", result));
```
result = T&E
This is good answer I wi... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | In Java 8 you can proceed as below :
```
String s1 = "T,V,E";
String s2 = "T,W,E";
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.j... | If all your `String` follows this pattern : `..., ..., ....` , you could split them and filter only each String that is contained in the two arrays.
You can then collect them into a `List` and join them with `,` :
```
List<String> commonStrings = Arrays.stream(m2.split(",\\s"))
.flatMap(s-> Arrays.stream(m3.s... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | You can achieve this in many ways. One of the ways is using **Set**.
First, split **m1** the characters by (comma) and add it to **HashSet**. Then split the **m2** characters and add it to **ArrayList**. Now by the for loop try to add the **ArrayList** characters to **HashSet**. You will get false from the add method ... | you can use the split() function as the following
```
String a="A, B, C, D";
String b="B, C, D";
String[] a_chars =a.split(", "); //returns array with A B C D
String[] b_chars =b.split(", "); //returns array with B C D
```
this whay you have 2 arrays of strings now you can compare them using ... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | You can achieve this in many ways. One of the ways is using **Set**.
First, split **m1** the characters by (comma) and add it to **HashSet**. Then split the **m2** characters and add it to **ArrayList**. Now by the for loop try to add the **ArrayList** characters to **HashSet**. You will get false from the add method ... | String s1 = "T,V,E";
String s2 = "T,W,E";
```
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.join(",", result));
```
result = T&E
This is good answer I wi... |
46,111,002 | I have some strings defined in my Java application, like so:
```
m3 = "T, V, E";
m2 = "T, W, E";
```
as an example.
Now I need to check, which parts of the strings match. So in this case, I would want a string `m4`, containing `T, E`, as a result.
In that case for example:
```
m1 = "A, S";
m3 = "T, V, E";
```
... | 2017/09/08 | [
"https://Stackoverflow.com/questions/46111002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3375021/"
] | The appropriate data structure is Set.
```
Set<String> m3 = new TreeSet<>();
Collections.addAll(m3, "T", "V", "E");
Collections.addAll(m3, "T, V, E".split(",\\s*")); // Alternatively.
Set<String> m2 = new HashSet<>();
Collections.addAll(m2, "T", "W", "E");
Set<String> m5 = new TreeSet<>(m2);
... | String s1 = "T,V,E";
String s2 = "T,W,E";
```
List<String> l1 = Arrays.asList(s1.split(","));
List<String> l2 = Arrays.asList(s2.split(","));
List<String> result = l1.stream().filter(l2::contains).collect(Collectors.toList());
System.out.println(String.join(",", result));
```
result = T&E
This is good answer I wi... |
460,101 | Running a clean install of ubuntustudio 14.04 the suspend and resume works when using the power button or selecting it from the user menu but is not available in the xfce4-power-manager-settings. Only "Lock Screen" or "Nothing" is available for lid close action.
<http://docs.xfce.org/xfce/xfce4-power-manager/faq>
Sug... | 2014/05/03 | [
"https://askubuntu.com/questions/460101",
"https://askubuntu.com",
"https://askubuntu.com/users/61005/"
] | 1. Install `pm-utils`
```
sudo apt-get install pm-utils
```
2. Reboot
Reference: [[Solved] Issues with xfce4-power-manager-1.2.0](https://forum.xfce.org/viewtopic.php?id=7250)
Discussion resume that: `upower` is relying on `pm-utils` to check for suspend/hibernate capability.
The broken link in the reference page ... | The same symptoms and output of `xfce4-power-manager` can be observed with `pm-utils` installed. In that case, it is possible at least to restore the suspend when lid is closed using the information on [Xfce4 FAQ page](http://docs.xfce.org/xfce/xfce4-power-manager/faq), section "How can I make logind handle button even... |
460,101 | Running a clean install of ubuntustudio 14.04 the suspend and resume works when using the power button or selecting it from the user menu but is not available in the xfce4-power-manager-settings. Only "Lock Screen" or "Nothing" is available for lid close action.
<http://docs.xfce.org/xfce/xfce4-power-manager/faq>
Sug... | 2014/05/03 | [
"https://askubuntu.com/questions/460101",
"https://askubuntu.com",
"https://askubuntu.com/users/61005/"
] | 1. Install `pm-utils`
```
sudo apt-get install pm-utils
```
2. Reboot
Reference: [[Solved] Issues with xfce4-power-manager-1.2.0](https://forum.xfce.org/viewtopic.php?id=7250)
Discussion resume that: `upower` is relying on `pm-utils` to check for suspend/hibernate capability.
The broken link in the reference page ... | Another solution is to use the power management GUI xfce provides:
<https://docs.xfce.org/xfce/xfce4-power-manager/preferences> |
460,101 | Running a clean install of ubuntustudio 14.04 the suspend and resume works when using the power button or selecting it from the user menu but is not available in the xfce4-power-manager-settings. Only "Lock Screen" or "Nothing" is available for lid close action.
<http://docs.xfce.org/xfce/xfce4-power-manager/faq>
Sug... | 2014/05/03 | [
"https://askubuntu.com/questions/460101",
"https://askubuntu.com",
"https://askubuntu.com/users/61005/"
] | The same symptoms and output of `xfce4-power-manager` can be observed with `pm-utils` installed. In that case, it is possible at least to restore the suspend when lid is closed using the information on [Xfce4 FAQ page](http://docs.xfce.org/xfce/xfce4-power-manager/faq), section "How can I make logind handle button even... | Another solution is to use the power management GUI xfce provides:
<https://docs.xfce.org/xfce/xfce4-power-manager/preferences> |
52,105,980 | I have a panda dataframe in Python at which I am applying a groupby. And then I want to apply a new groupby + sum on the previous result. To be more specific, first I am doing:
```
check_df = data_df.groupby(['hotel_code', 'dp_id', 'market', 'number_of_rooms'])
[['market', 'number_of_rooms']]
```
And then I want t... | 2018/08/30 | [
"https://Stackoverflow.com/questions/52105980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443917/"
] | IIUC, instead of:
```
check_df = data_df.groupby(['hotel_code', 'dp_id', 'market', 'number_of_rooms'])
[['market', 'number_of_rooms']]
```
You should simply do:
```
check_df = data_df.drop_duplicates(subset=['hotel_code', 'dp_id', 'market', 'number_of_rooms'])\
.loc[:, ['market', 'number_of_rooms'... | ```
df = pd.DataFrame({'Market': [1,1,1,2,2,2,3,3], 'Rooms':range(8), 'C':np.random.rand(8)})
Market Rooms C
0 1 0 0.187793
1 1 1 0.325284
2 1 2 0.095147
3 2 3 0.296781
4 2 4 0.022262
5 2 5 0.201078
6 3 6 0.160082
7 ... |
52,105,980 | I have a panda dataframe in Python at which I am applying a groupby. And then I want to apply a new groupby + sum on the previous result. To be more specific, first I am doing:
```
check_df = data_df.groupby(['hotel_code', 'dp_id', 'market', 'number_of_rooms'])
[['market', 'number_of_rooms']]
```
And then I want t... | 2018/08/30 | [
"https://Stackoverflow.com/questions/52105980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443917/"
] | IIUC, instead of:
```
check_df = data_df.groupby(['hotel_code', 'dp_id', 'market', 'number_of_rooms'])
[['market', 'number_of_rooms']]
```
You should simply do:
```
check_df = data_df.drop_duplicates(subset=['hotel_code', 'dp_id', 'market', 'number_of_rooms'])\
.loc[:, ['market', 'number_of_rooms'... | If I understand your question correctly, You could simply do -
```
data_df.groupby('Market').agg({'Rooms': np.sum}) OR
data_df.groupby(['market'], as_index=False).agg({'Rooms': np.sum})
data_df = pd.DataFrame({'Market' : ['A','B','C','B'],
'Hotel' : ['H1','H2','H4','H5'],
'... |
60,397 | I'm having a bit of trouble understanding the connection between measurable maps and continuous functions. Namely, I know the following: Assume $f:(\Omega\_{1}, \mathcal{B}\_{1}) \rightarrow (\Omega\_{2}, \mathcal{B}\_{2})$
1. $E \subset \Omega\_{2} \quad \mbox{open} \Rightarrow f^{-1}(E) \quad \mbox{open} $ by conti... | 2011/08/28 | [
"https://math.stackexchange.com/questions/60397",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/10994/"
] | If $\Omega\_1$ and $\Omega\_2$ are topological spaces and $\mathcal{B}\_1$ and $\mathcal{B}\_2$ are their Borel sigma-algebras, then every continuous function is measurable (but, in general, not every measurable function is continuous).
Proof. Let $u:\Omega\_1\to\Omega\_2$ be a continuous function. That $u$ is $\mathc... | *(While the answer is not* very *useful to the OP, I am not deleting it since I do believe that someone will find it useful, and perhaps even the OP someday may find it useful.)*
[This answer is using some amount of choice, in particular a countable union of countable sets is countable assumed in here]
The Borel meas... |
6,427,850 | Given the following - how can I replace **trailing spaces** with 0's in SQL Server?
```
CREATE TABLE TestTable
(
TestField CHAR(8)
)
INSERT INTO TestTable
SELECT ' 1 1 1 '
INSERT INTO TestTable
SELECT ' 1 1 1 1'
SELECT
TestField,
LEN(TestField) AS LenTestField,
REPLACE(TestField, ' ', '0') AS Test... | 2011/06/21 | [
"https://Stackoverflow.com/questions/6427850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185783/"
] | You can leverage the difference in LEN and DATALENGTH. LEN removes trailing spaces,DATALENGTH doesn't. And REPLICATE will take a zero length parameter
```
SELECT
RTRIM(TestField) + REPLICATE('0', DATALENGTH(TestField)-LEN(TestField))
FROM
TestTable
``` | how about this:
```
DECLARE @test TABLE
(num nvarchar(30) )
INSERT INTO @test (num) VALUES ('1 1 1 ')
SELECT LEFT(num, LEN(num)) + REPLICATE('0', LEN(REPLACE(num, ' ', '*')) - LEN(num)) FROM @test
``` |
44,109,014 | Hi I have date\_time column as "Factor" type which is having mixed date\_time as below. How to change these informats to R datetime format
```
date_time R_date_time
01-Apr-2017 12:00:00 2017-04-01 12:00:00
02/04/2017 03:00:00 2017-04-02 03:00:00
30/05/2017 06:15:00 2017-05-30 06:... | 2017/05/22 | [
"https://Stackoverflow.com/questions/44109014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5860640/"
] | I have gotten the same error accessing a web service from a Java agent. In FP8+ another grant seems to be required in the `java.policy` or `java.pol` file:
```
permission java.io.FilePermission "${java.home}/lib/-", "read";
```
The `jaxws-tubes-default.xml` file is located in the `resources.jar` file in the lib... | Check the java.policy or java.pol file on the working FP7 server. Upgrades regularly overwrite java.policy and, on occasion, have been known to remove that file. If it's security-related, the server's Java policy must be different. |
44,109,014 | Hi I have date\_time column as "Factor" type which is having mixed date\_time as below. How to change these informats to R datetime format
```
date_time R_date_time
01-Apr-2017 12:00:00 2017-04-01 12:00:00
02/04/2017 03:00:00 2017-04-02 03:00:00
30/05/2017 06:15:00 2017-05-30 06:... | 2017/05/22 | [
"https://Stackoverflow.com/questions/44109014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5860640/"
] | I have gotten the same error accessing a web service from a Java agent. In FP8+ another grant seems to be required in the `java.policy` or `java.pol` file:
```
permission java.io.FilePermission "${java.home}/lib/-", "read";
```
The `jaxws-tubes-default.xml` file is located in the `resources.jar` file in the lib... | I ran into another Java security related issue issue yesterday that might also be causing your problem. I'm using GSON to do JSON parsing, but after an upgrade to FP8 it stopped working and threw a security error:
```
Agent Manager: Agent error: java.security.AccessControlException:
Access denied ("java.lang.Runti... |
735,791 | Given a set of integers, is there an algorithm that returns the sum of all the subsets? For example if $s = \{6, 3, -2\}$ then the algorithm returns $28$. I.e:
$$(-2) + (3) + (3-2) + 6 + (6-2) + (6+3) + (6+3-2) = 28$$
The runtime of this is $\mathcal{O}(2^n)$ though I believe: is there a quicker way to do this?
Than... | 2014/04/01 | [
"https://math.stackexchange.com/questions/735791",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/138240/"
] | Every element of the set occurs in half of the subsets of $s$, so in $2^{\lvert s\rvert-1}$ subsets (taking the complement gives a bijection between the subsets of $s$ containing $x$ and those not containing it). Therefore,
$$\sum\_{M \in \mathcal{P}(s)}\left(\sum\_{x\in M} x\right) = 2^{\lvert s\rvert-1}\cdot\sum\_{x... | You are generating the [Power set](http://en.wikipedia.org/wiki/Power_set) of some set $S$ with $n$ elements (denoted $\mathcal{P}(S)$) and then summing over all of the elements, so it would be impossible to have a runtime better than $\mathcal{O}(2^{n})$ because you need to generate and iterate over all of the $2^{n}$... |
735,791 | Given a set of integers, is there an algorithm that returns the sum of all the subsets? For example if $s = \{6, 3, -2\}$ then the algorithm returns $28$. I.e:
$$(-2) + (3) + (3-2) + 6 + (6-2) + (6+3) + (6+3-2) = 28$$
The runtime of this is $\mathcal{O}(2^n)$ though I believe: is there a quicker way to do this?
Than... | 2014/04/01 | [
"https://math.stackexchange.com/questions/735791",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/138240/"
] | Every element of the set occurs in half of the subsets of $s$, so in $2^{\lvert s\rvert-1}$ subsets (taking the complement gives a bijection between the subsets of $s$ containing $x$ and those not containing it). Therefore,
$$\sum\_{M \in \mathcal{P}(s)}\left(\sum\_{x\in M} x\right) = 2^{\lvert s\rvert-1}\cdot\sum\_{x... | This can also be solved using a basic generating function technique. The ordinary generating function $f(z)$ where $[z^q] f(z)$ represents the number of times the sum $q$ occured among the subsets is given by $$f(z) = \prod\_{x\in S} (1+z^x).$$
We want to turn $[z^q] f(z)$ into $q$, so we differentiate and set $z=1$ to... |
38,216,033 | Is there any difference between:
```
cBase* object = new cDerived();
```
and
```
cDerived* object = new cDerived();
```
If so, in which cases do I choose one over the other? | 2016/07/06 | [
"https://Stackoverflow.com/questions/38216033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061193/"
] | The difference is that they declare `object` as having different types, which can have lots of consequences. For example:
* If `cDerived` declares any new members (beyond what it inherits from `cBase`), then only the version with `cDerived* object` makes those available (unless you explicitly downcast back to `cDerive... | The static type of `object` differs in your two examples. Let's take an example:
```
struct A {};
struct B : A
{
void method() {}
};
int main() {
A* a = new B;
B* b = new B;
a->method(); // compile error, A has no member named method.
b->method(); // fine. b's static type is B*, and B has a membe... |
27,384,630 | I tried many times to make the vertical `Scroll Bar` of `Textrea` to be always active instead of being visible only when focus on the `Textarea` but I couldn't do that ! ..
any help please | 2014/12/09 | [
"https://Stackoverflow.com/questions/27384630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427913/"
] | I know that a lot of time has passed since this question was asked but I still want to give the answer for those who need it. To make the ScrollBar visible you just need to access to it from the TextArea class while passing through the Scrollpane :
```
.text-area > .scroll-pane{
-fx-vbar-policy:always; /* Control the... | If you wand declare that within the code you can use lookup:
```
for (Node node : textArea.lookupAll(".scroll-pane"))
{
if (node instanceof ScrollPane)
{
((ScrollPane) node).setVbarPolicy(ScrollBarPolicy.ALWAYS);
}
}
}
``` |
52,865,000 | In Unity I have GameObjectName which has script 1 and script 2 attached to it. Script1 is an IEnumerator like this.
```
public IEnumerator Sunglasses()
{
// Do stuff
}
```
Script2 looks like this.
```
public void Start()
{
Function1();
String blah = "Things";
Function2();
StartCoroutine(Routine2... | 2018/10/17 | [
"https://Stackoverflow.com/questions/52865000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10521183/"
] | Try this, just using JavaScript to set the value attribute on the element.
This may not be the approach you are looking for, if it is replace the time.sleep with a better approach (wait for the element to be available).
I have hardcoded the date 20/10/2018
```
from selenium.webdriver import Chrome
driver = Chrome()... | The field you have referenced does not allow you to click on it and type numbers so you will need to take another approach.
Check out this guide here: <https://www.guru99.com/handling-date-time-picker-using-selenium.html>
The provided code is Java but the Selenium API should be similar as well as the approach you nee... |
59,901,959 | I have an animated sequence for all the `div` with the class `loaded`.
The goal is to add the class `visible` to these `div` (it's a css opacity animation) and then remove the class `loaded` once the animation is completed/finished.
```
$('.loaded').each(function(index) {
(function(that, i) {
var t = setTimeo... | 2020/01/24 | [
"https://Stackoverflow.com/questions/59901959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5479680/"
] | You can use the listener 'transitionend' or 'animationend',
>
> When using the css transition use transitionend, and when using
> @keyframes/animation, use animationend.
>
>
>
according to [animationend event not firing](https://stackoverflow.com/questions/41530263/animationend-event-not-firing)
```
$('.loaded... | You can attach an event listener for the [`transitionend`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/transitionend_event) or [`animationend`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/animationend_event) events with jQuery [`.on()`](https://api.jquery.com/on/), and then remove the ... |
66,755 | [From the BBC](https://www.bbc.co.uk/news/stories-50211901), WRT instructions by the police for people on the streets to move on:
>
> the legal niceties don't always matter: "The police will often just insist on people 'moving on' because they have been asked by the local authority to clear the street, but without qu... | 2021/06/14 | [
"https://law.stackexchange.com/questions/66755",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/24401/"
] | **Is asking police to justify their orders illegal?**
**NO** but the manner in which the "asking" is done may be. | Asking is not illegal
---------------------
**In fact, the police must tell you the reason for the direction to be valid.**
[new-south-wales](/questions/tagged/new-south-wales "show questions tagged 'new-south-wales'")
[s197](http://www5.austlii.edu.au/au/legis/nsw/consol_act/leara2002451/s197.html) of the *Law Enfo... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | With React hooks. It will wait `5s` and then render this component.
```
import React from 'react'
const DeleayComponent = () => {
const [show, setShow] = React.useState(false)
React.useEffect(() => {
const timeout = setTimeout(() => {
setShow(true)
}, 5000)
return () => clearTimeout(timeout)
... | One way to use hook with setTimeout is to set a property after the interval.
```
import { useState, useEffect } from "react";
const BotResponse = () => {
......
const [botMessage, setBotMessage] = useState('');
// function called from some user interaction
const botResponse = (msg) => {
setTimeout(function() {
... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | Not sure why you would want to do this, but something like this?
The component's constructor:
```
constructor(props) {
super(props);
this.state = {
render: false //Set render state to false
}
}
```
On component mount:
```
componentDidMount() {
setTimeout(function() { //Start the timer
t... | With React hooks. It will wait `5s` and then render this component.
```
import React from 'react'
const DeleayComponent = () => {
const [show, setShow] = React.useState(false)
React.useEffect(() => {
const timeout = setTimeout(() => {
setShow(true)
}, 5000)
return () => clearTimeout(timeout)
... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | The easiest way to display a component after a time is conditional rendering like this :
```
constructor(props) {
super(props);
this.state = {
render: false
}
}
```
```
handleRender = () => {
setTimeout(() => {
this.setState({ render : !this.state.render })
}, 1000);
}
render () {
r... | One way to use hook with setTimeout is to set a property after the interval.
```
import { useState, useEffect } from "react";
const BotResponse = () => {
......
const [botMessage, setBotMessage] = useState('');
// function called from some user interaction
const botResponse = (msg) => {
setTimeout(function() {
... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | **Pure typescript Solution**
You would be able to create delay function with `async`:
```
function timeout(delay: number) {
return new Promise( res => setTimeout(res, delay) );
}
```
And then call the function:
```
await timeout(1000); //for 1 sec delay
``` | If you like Ronit's solution but want pure javascript
```
function timeout(delay) {
return new Promise( res => setTimeout(res, delay) );
}
await timeout(1000);
``` |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | The easiest way to display a component after a time is conditional rendering like this :
```
constructor(props) {
super(props);
this.state = {
render: false
}
}
```
```
handleRender = () => {
setTimeout(() => {
this.setState({ render : !this.state.render })
}, 1000);
}
render () {
r... | If you like Ronit's solution but want pure javascript
```
function timeout(delay) {
return new Promise( res => setTimeout(res, delay) );
}
await timeout(1000);
``` |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | **Pure typescript Solution**
You would be able to create delay function with `async`:
```
function timeout(delay: number) {
return new Promise( res => setTimeout(res, delay) );
}
```
And then call the function:
```
await timeout(1000); //for 1 sec delay
``` | With React hooks. It will wait `5s` and then render this component.
```
import React from 'react'
const DeleayComponent = () => {
const [show, setShow] = React.useState(false)
React.useEffect(() => {
const timeout = setTimeout(() => {
setShow(true)
}, 5000)
return () => clearTimeout(timeout)
... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | Not sure why you would want to do this, but something like this?
The component's constructor:
```
constructor(props) {
super(props);
this.state = {
render: false //Set render state to false
}
}
```
On component mount:
```
componentDidMount() {
setTimeout(function() { //Start the timer
t... | The easiest way to display a component after a time is conditional rendering like this :
```
constructor(props) {
super(props);
this.state = {
render: false
}
}
```
```
handleRender = () => {
setTimeout(() => {
this.setState({ render : !this.state.render })
}, 1000);
}
render () {
r... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | **Pure typescript Solution**
You would be able to create delay function with `async`:
```
function timeout(delay: number) {
return new Promise( res => setTimeout(res, delay) );
}
```
And then call the function:
```
await timeout(1000); //for 1 sec delay
``` | The easiest way to display a component after a time is conditional rendering like this :
```
constructor(props) {
super(props);
this.state = {
render: false
}
}
```
```
handleRender = () => {
setTimeout(() => {
this.setState({ render : !this.state.render })
}, 1000);
}
render () {
r... |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | Not sure why you would want to do this, but something like this?
The component's constructor:
```
constructor(props) {
super(props);
this.state = {
render: false //Set render state to false
}
}
```
On component mount:
```
componentDidMount() {
setTimeout(function() { //Start the timer
t... | If you like Ronit's solution but want pure javascript
```
function timeout(delay) {
return new Promise( res => setTimeout(res, delay) );
}
await timeout(1000);
``` |
42,089,548 | I am new to React.js. I am not sure how to add `delay` to render in React.js. What is the best way to add delay.
I am adding the following code in render but its not working.
```
setTimeout(function() {
}, 1000);
``` | 2017/02/07 | [
"https://Stackoverflow.com/questions/42089548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7302405/"
] | Not sure why you would want to do this, but something like this?
The component's constructor:
```
constructor(props) {
super(props);
this.state = {
render: false //Set render state to false
}
}
```
On component mount:
```
componentDidMount() {
setTimeout(function() { //Start the timer
t... | One way to use hook with setTimeout is to set a property after the interval.
```
import { useState, useEffect } from "react";
const BotResponse = () => {
......
const [botMessage, setBotMessage] = useState('');
// function called from some user interaction
const botResponse = (msg) => {
setTimeout(function() {
... |
3,733,298 | is there off screen drawing possible in android like a imageContext in objective C. if it is kindly tell me the link or some kind of hint.
thanks a lot. | 2010/09/17 | [
"https://Stackoverflow.com/questions/3733298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/397901/"
] | I believe you are looking for the [Canvas](http://developer.android.com/reference/android/graphics/Canvas.html) object. This doesn't have to be on the screen when you draw on it (lines, shapes, bitmaps, etc.).
You'll first want to [create a Bitmap](http://developer.android.com/reference/android/graphics/Bitmap.html#cr... | Check out the `FingerPaint` application in `ApiDemos/Graphics` |
3,733,298 | is there off screen drawing possible in android like a imageContext in objective C. if it is kindly tell me the link or some kind of hint.
thanks a lot. | 2010/09/17 | [
"https://Stackoverflow.com/questions/3733298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/397901/"
] | I believe you are looking for the [Canvas](http://developer.android.com/reference/android/graphics/Canvas.html) object. This doesn't have to be on the screen when you draw on it (lines, shapes, bitmaps, etc.).
You'll first want to [create a Bitmap](http://developer.android.com/reference/android/graphics/Bitmap.html#cr... | Ii is possible to draw off screen by creating a canvas, assign it to a mutable bitmap and doing all drawing with canvas method, like this:
```
Canvas c = new Canvas();
Bitmap bmp = BitmapFactory.decodeResource(this, R.drawable.mybasebmp); // this is NOT MUTABLE!!
Bitmap bmpm = bmp.copy(bmp.getConfig(), true); // creat... |
66,448,947 | [](https://i.stack.imgur.com/tVxUX.png)
I'm using ggplot and I get those weird horizontal lines out of geom\_bar. I cannot provide a minimal working example: the same code works with few observations and it relies on data I am importing and transformi... | 2021/03/03 | [
"https://Stackoverflow.com/questions/66448947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8589444/"
] | I'm guessing the lines are due to a plotting bug between observations that go into each bar. (That could be related to the OS, the graphics device, and/or how ggplot2 interacts with them...)
I expect it'd go away if you summarized before ggplot2, e.g.:
```
library(dplyr);
data %>%
count(Horizon, Groups, wt = Impo... | Mine went away when changing the size of the graphs in rmarkdown. |
66,448,947 | [](https://i.stack.imgur.com/tVxUX.png)
I'm using ggplot and I get those weird horizontal lines out of geom\_bar. I cannot provide a minimal working example: the same code works with few observations and it relies on data I am importing and transformi... | 2021/03/03 | [
"https://Stackoverflow.com/questions/66448947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8589444/"
] | You can fix it by adding the *fill* as *color*. Like this:
```
geom_bar(aes(x=Horizon, y=Importance, fill=Groups, color=Groups),
position='fill', stat='identity')
```
This was suggested [here](https://community.rstudio.com/t/lines-on-bars-in-graph-when-publishing-shiny/46580/3). | Mine went away when changing the size of the graphs in rmarkdown. |
236,136 | I have a remote win xp machine to which I connect via RDP. When I open a Cisco VPN connection (4.8 client) on that machine, the RDP connection drops because all traffic is routed over the VPN connection now.
Is there a way to make this work?
me => rdp => winXp => vpn => target | 2011/02/16 | [
"https://serverfault.com/questions/236136",
"https://serverfault.com",
"https://serverfault.com/users/101758/"
] | Typically the SC is on a 'proper' routable network to allow for management, if you want the SC to deal with the VMs in any way (and it's a **very** bad idea by the way) you need to put the VMs on the same network as the SC or one that is routable from the SC. | I don't think you can access the OS directly from an ESX host, and until you network those machines you aren't going to be able to run commands on them through SSH. Since you are switching IP tables off, I am assuming that you don't have a security policy in place that requires IP tables (or any firewall) is switched o... |
236,136 | I have a remote win xp machine to which I connect via RDP. When I open a Cisco VPN connection (4.8 client) on that machine, the RDP connection drops because all traffic is routed over the VPN connection now.
Is there a way to make this work?
me => rdp => winXp => vpn => target | 2011/02/16 | [
"https://serverfault.com/questions/236136",
"https://serverfault.com",
"https://serverfault.com/users/101758/"
] | Typically the SC is on a 'proper' routable network to allow for management, if you want the SC to deal with the VMs in any way (and it's a **very** bad idea by the way) you need to put the VMs on the same network as the SC or one that is routable from the SC. | Nope, not from the ESX console. Just because these are VMs, doesn't mean you can do batched actions within them from the ESX side of things. You'll probably have to do this the same way you would do it with 32 physical machines - pssh, puppet, etc.
---
/edit - missed the fact that there's no network enabled in your V... |
21,721,429 | I need to make pattern for asterisk sip calling like this way.
1. Pattern consist only "\*","#" and 0-9 digits
2. pattern's first arguments is optional for "+" symbols.
like it matches
```
*1203#023212232
+*1203#122
12345555
```
but reject these cases
```
3434+23443
*2334%2323
```
I prepared pattern like this w... | 2014/02/12 | [
"https://Stackoverflow.com/questions/21721429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2703166/"
] | I use Rajawali which is an overlay for OpenGL.
<http://www.rozengain.com/blog/2011/08/23/announcing-rajawali-an-opengl-es-2-0-based-3d-framework-for-android/>
I would strongly recommend you use it too as it takes a lot of the pain of OpenGL away. Anyway, what I've put below does involve some Rajawali code but the pri... | You can do it like this in your `onCreate()` method. Remember to `setFormat(PixelFormat.TRANSLUCENT)` in MyGLSurfaceView constructor:
```
mGLView = new MyGLSurfaceView(this);
setContentView(mGLView);
mOpenCvCameraView = (CameraBridgeViewBase) new JavaCameraView(this, -1);
mOpenCvCameraView.setCvCamera... |
154,453 | I'm running Windows Vista Home Premium on a Sony Vaio laptop. I think somehow my Windows Explorer has become corrupted. I don't recall any certain inciting incident like installing an unreputable 3rd party app or hardware failure but just recently my system won't wake after it's been left idle longer that 20 minutes an... | 2010/06/19 | [
"https://superuser.com/questions/154453",
"https://superuser.com",
"https://superuser.com/users/36108/"
] | Download the latest AV files here
Paid versions
<http://www.avg.com/us-en/download-update>
AVG Free
<http://free.avg.com/us-en/download-update>
. | Have you tried using "Sync Center"? If I am right, you should be able to share your -
C:\ProgramData\avg10\update folder with your second computer. I have yet to test this
option, but it looks like it should do the trick for you. |
21,633,388 | I am new here, I have generated 5 images from an array. Now I want to select those images as we select using checkbox (means i can select 1 image or 2 image or more as per choice). After selecting I want to display their name as an alert that you have selected these images. Please guide me because i am new in javascrip... | 2014/02/07 | [
"https://Stackoverflow.com/questions/21633388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3284778/"
] | You can specify the specific users & SSH keys to use for an instance by setting the instance level [`sshKeys` metadata key](https://developers.google.com/compute/docs/instances?hl=en#sshkeys). You can also do this from the command line using gcutil's `--authorized_ssh_keys` option:
```
$ gcutil addinstance --authorize... | Google adds these ssh keys to the project ssh-keys automatically. So you need to block project-wide SSH keys: <https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#block-project-keys>
You can do it via meta-data:
`"block-project-ssh-keys": "true"` |
5,308,260 | I have 3 different activity namely, category,sub\_category and list of items. In sub\_category i created back button using intent Activity. Back button in list\_of items should be focus to sub\_category. i dont know how to do this.. pls guide me.. | 2011/03/15 | [
"https://Stackoverflow.com/questions/5308260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/599841/"
] | from category activity
call
```
Intent it=new Intent(category.this,sub_category.class)
startActivityForResult(it);
```
similarly
```
Intent it=new Intent(sub_category.this,list_item.class)
startActivityForResult(it);
```
and in onClickListener of back button simply finish your activity like
```
list_item.this.fi... | for going back to previous screen u can call finish() in your current activity. It will remove the current activity from activity Stack and take you to the previous one. |
22,817,095 | I have a dgrid which only has one column of data *(name)* however i am attempting to preform an update on this column and it keeps inserting a new record. I understand it will treat the information entered as a new record since the *idProperty* in the dgrid is = *name*. How can i over come this issue and be able to upd... | 2014/04/02 | [
"https://Stackoverflow.com/questions/22817095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/586731/"
] | Add an `id` field to your data and remove the `idProperty` from your Memory store or set it to "id". When you want to update a row, use the id from the selected row and set `name` to the new value.
```
nameStore.put({id:selectedRowId, name: userEnteredName});
```
Life is better when you generate primary keys rather ... | Its worth (if you are using a [Memory store](http://dojotoolkit.org/api/?qs=1.9/dojo/store/Memory) to back your dgrid data) checking the put directives being used when you perform an update on an existing row, check the [Dojo PutDirectives API](http://dojotoolkit.org/api/?qs=1.9/dojo/store/api/Store.PutDirectives) for ... |
73,922,767 | I have been looking around to get what I want but I couldn't find anything hence my question (hopefully not a duplicate!)
I am looking to get a microsecond resolution epoch time (to be converted to a Date string) of the clock perhaps using `chrono`.
Following is what works for me for `seconds` resolution:
```
auto s... | 2022/10/02 | [
"https://Stackoverflow.com/questions/73922767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12497236/"
] | The referenced column in a foreign key needs to be indexed, so you need to add an index on the `idEtape` column in `etapexprojet`:
```
--Etape X Projet
CREATE TABLE IF NOT EXISTS jegere.EtapexProjet_ (
idEtape INT NOT NULL,
idProjet INT NOT NULL,
dateDebut DATE NOT NULL ,
dateFin DATE,
PRIMARY KEY(... | Your last table etape references only the column idetape, but all referenced columns need an index , primary key or UNIQUE constraint.
so add a KEY to your EtapexProjet\_ for the column idetape, and you can run the code
```
CREATE TABLE IF NOT EXISTS EtapexProjet_ (
idEtape INT NOT NULL,
idProjet INT NOT NULL... |
50,298,168 | I've an imageview with an icon on background, instead of generating all diferent sizes of icons for diferent sizes of screen i'm using only a big one and resizing it to fit the size I want.
If I set the layout\_height to any value android automatically resize the width to keep aspect ratio (what is good) but the place... | 2018/05/11 | [
"https://Stackoverflow.com/questions/50298168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5679560/"
] | You are using a so-called *dependent subquery.* These can sometime be very inefficient.
You can use this subquery to retrieve the max timestamp for each stock\_id value.
```
SELECT MAX(timestamp) timestamp, stock_id
FROM market
GROUP BY stock_id
```
Your c... | You are using a so-called *dependent subquery.* These can sometimes be very inefficient, because the query planner repeats them for every value from the outer query (`m1.stock_id` in your case).
You can use this subquery to retrieve the max timestamp for each stock\_id value.
```
SELECT MAX(timesta... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | According to [Herb Sutter](https://stackoverflow.com/users/297582/herb-sutter), `register` is "[exactly as meaningful as whitespace](http://www.drdobbs.com/184403859)" and has no effect on the semantics of a C++ program. | With today's compilers, probably nothing. Is was orginally a hint to place a variable in a register for faster access, but most compilers today ignore that hint and decide for themselves. |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | With today's compilers, probably nothing. Is was orginally a hint to place a variable in a register for faster access, but most compilers today ignore that hint and decide for themselves. | As of gcc 9.3, [compiling using `-std=c++2a`,](https://godbolt.org/z/QJqome) `register` produces a compiler warning, but it still has the desired effect and behaves identically to C's `register` when compiling without -O1–-Ofast optimisation flags in the respect of [this](https://stackoverflow.com/a/61141973/7194773) a... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `register` is deprecated in C++11. It is unused and reserved in C++17.
Source: <http://en.cppreference.com/w/cpp/keyword/register> | The `register` keyword was useful for:
* Inline assembly.
* Expert C/C++ programming.
* Cacheable variables declaration.
An example of a productive system, where the `register` keyword was required:
```
typedef unsigned long long Out;
volatile Out out,tmp;
Out register rax asm("rax");
asm volatile("rdtsc":"=A"(rax))... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `register` is a hint to the compiler, advising it to store that variable in a processor register instead of memory (for example, instead of the stack).
The compiler may or may not follow that hint.
According to Herb Sutter in ["Keywords That Aren't (or, Comments by Another Name)"](http://www.drdobbs.com/184403859):
... | According to [Herb Sutter](https://stackoverflow.com/users/297582/herb-sutter), `register` is "[exactly as meaningful as whitespace](http://www.drdobbs.com/184403859)" and has no effect on the semantics of a C++ program. |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In C++ as it existed in 2010, any program which is valid that uses the keywords "auto" or "register" will be semantically identical to one with those keywords removed (unless they appear in stringized macros or other similar contexts). In that sense the keywords are useless for properly-compiling programs. On the other... | The `register` keyword was useful for:
* Inline assembly.
* Expert C/C++ programming.
* Cacheable variables declaration.
An example of a productive system, where the `register` keyword was required:
```
typedef unsigned long long Out;
volatile Out out,tmp;
Out register rax asm("rax");
asm volatile("rdtsc":"=A"(rax))... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Almost certainly nothing.
`register` is a hint to the compiler that you plan on using `x` a lot, and that you think it should be placed in a register.
However, compilers are now far better at determining what values should be placed in registers than the average (or even expert) programmer is, so compilers just ignor... | Consider a case when compiler's optimizer has two variables and is forced to spill one onto stack. It so happened that both variables have the same weight to the compiler. Given there is no difference, the compiler will arbitrarily spill one of the variables. On the other hand, the `register` keyword gives compiler a h... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | As of gcc 9.3, [compiling using `-std=c++2a`,](https://godbolt.org/z/QJqome) `register` produces a compiler warning, but it still has the desired effect and behaves identically to C's `register` when compiling without -O1–-Ofast optimisation flags in the respect of [this](https://stackoverflow.com/a/61141973/7194773) a... | Consider a case when compiler's optimizer has two variables and is forced to spill one onto stack. It so happened that both variables have the same weight to the compiler. Given there is no difference, the compiler will arbitrarily spill one of the variables. On the other hand, the `register` keyword gives compiler a h... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `register` is a hint to the compiler, advising it to store that variable in a processor register instead of memory (for example, instead of the stack).
The compiler may or may not follow that hint.
According to Herb Sutter in ["Keywords That Aren't (or, Comments by Another Name)"](http://www.drdobbs.com/184403859):
... | With today's compilers, probably nothing. Is was orginally a hint to place a variable in a register for faster access, but most compilers today ignore that hint and decide for themselves. |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | According to [Herb Sutter](https://stackoverflow.com/users/297582/herb-sutter), `register` is "[exactly as meaningful as whitespace](http://www.drdobbs.com/184403859)" and has no effect on the semantics of a C++ program. | Almost certainly nothing.
`register` is a hint to the compiler that you plan on using `x` a lot, and that you think it should be placed in a register.
However, compilers are now far better at determining what values should be placed in registers than the average (or even expert) programmer is, so compilers just ignor... |
3,207,018 | What is difference between
```
int x=7;
```
and
```
register int x=7;
```
?
I am using C++. | 2010/07/08 | [
"https://Stackoverflow.com/questions/3207018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `register` is deprecated in C++11. It is unused and reserved in C++17.
Source: <http://en.cppreference.com/w/cpp/keyword/register> | Almost certainly nothing.
`register` is a hint to the compiler that you plan on using `x` a lot, and that you think it should be placed in a register.
However, compilers are now far better at determining what values should be placed in registers than the average (or even expert) programmer is, so compilers just ignor... |
45,973 | We have quite a few [questions on tipping in the USA](https://travel.stackexchange.com/questions/tagged/tipping+usa), but looking through I can't seem to spot one that covers this.
When in the USA, if you are somewhere where drinks are free but served to you, is it expected to tip the person pouring / bringing the dri... | 2015/04/11 | [
"https://travel.stackexchange.com/questions/45973",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/26/"
] | In general, if you're in a place that also *sells* drinks and you're using vouchers, etc then tip as you would if you'd paid. So a dollar or two per drink depending on price and place. Same goes for discounts and other freebies like a 2 for 1 deal -- although you could choose to tip more up front. Obviously if the staf... | "It depends."
Typically, the rule is that whoever gets the bill does the tipping. For example, at a catered event, you wouldn't try to tip the people bringing you your food or drinks because you're not paying the bill. I think any time you aren't paying a bill, you're safe to err on the side of "no tipping".
I have b... |
45,973 | We have quite a few [questions on tipping in the USA](https://travel.stackexchange.com/questions/tagged/tipping+usa), but looking through I can't seem to spot one that covers this.
When in the USA, if you are somewhere where drinks are free but served to you, is it expected to tip the person pouring / bringing the dri... | 2015/04/11 | [
"https://travel.stackexchange.com/questions/45973",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/26/"
] | In general, if you're in a place that also *sells* drinks and you're using vouchers, etc then tip as you would if you'd paid. So a dollar or two per drink depending on price and place. Same goes for discounts and other freebies like a 2 for 1 deal -- although you could choose to tip more up front. Obviously if the staf... | Tipping in North America has become such a hot button issue. It is customary to tip and is usually a percentage of the cost of your food/drinks (or what the cost would have been). But there have been so much writing happening on this topic like:
1. Why is the tip calculated on post tax amount and it should be pre tax ... |
45,973 | We have quite a few [questions on tipping in the USA](https://travel.stackexchange.com/questions/tagged/tipping+usa), but looking through I can't seem to spot one that covers this.
When in the USA, if you are somewhere where drinks are free but served to you, is it expected to tip the person pouring / bringing the dri... | 2015/04/11 | [
"https://travel.stackexchange.com/questions/45973",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/26/"
] | "It depends."
Typically, the rule is that whoever gets the bill does the tipping. For example, at a catered event, you wouldn't try to tip the people bringing you your food or drinks because you're not paying the bill. I think any time you aren't paying a bill, you're safe to err on the side of "no tipping".
I have b... | Tipping in North America has become such a hot button issue. It is customary to tip and is usually a percentage of the cost of your food/drinks (or what the cost would have been). But there have been so much writing happening on this topic like:
1. Why is the tip calculated on post tax amount and it should be pre tax ... |
39,980 | Until just a few weeks ago I always used to set up my home-servers one service at a time (e.g. httpd, ProFTPD, etc.). I have now begun using XAMPP instead and was wondering if there is any reason why I **shouldn't** be using it.
I have heard that using a server package such as XAMPP can present a security risk. How is... | 2009/09/12 | [
"https://superuser.com/questions/39980",
"https://superuser.com",
"https://superuser.com/users/1951/"
] | The biggest problem is that out of the box its not locked down very tight.
From [Wikipedia](http://en.wikipedia.org/wiki/XAMPP):
>
> Officially, XAMPP's designers intended
> it for use only as a development tool,
> to allow website designers and
> programmers to test their work on
> their own computers without ... | FTP isn't the greatest protocol to use for security reasons plain text passwords is one. Unless you update the software yourself you are stuck on their upgrade schedule which can lead to exploits and other security holes. The other packages they include just add to your problems if they aren't patched on a regular basi... |
4,271,008 | I need a database of interests for a coming project.
By saying "interests" I mean like:
Sports - Football, Basketball and so on...
Is somebody know something like this?
I just don't want start writing thousands (or even millions) of interests. | 2010/11/24 | [
"https://Stackoverflow.com/questions/4271008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/519322/"
] | Try to google on "interests list" or "hobbies list" and the write simple parcer to extract all (based on neko-html for example). Examples of useful links:
<http://www.notsoboringlife.com/list-of-hobbies/>
<http://www.buzzle.com/articles/list-types-of-hobbies/>
Also it is possible to ask admins of any dating sites t... | There is an API from google called Freebase. I allows you suggest to the user what input he should give the same way google search suggests you what to look for.
[Freebase](https://developers.google.com/freebase/v1/suggest) |
56,906 | I'm in the process of doing some usability testing this week for one our iOS apps. We're having them attempt a few targeted tasks to test goals like
* New users should be able to signup with their email in under 15 seconds
* Users should use all their 'votes' inside a challenge
* Users should be able to located 'John ... | 2014/05/07 | [
"https://ux.stackexchange.com/questions/56906",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/47798/"
] | The 'flat design' aesthetic tends to favor large blocks of solid colors. If all of your colors are 'highlighter-esque' then you just end up with an incredibly busy UI where nothing stands out as they are all competing equally for your attention.
Intense vibrant colors--in UI design, at least--are there to draw attenti... | The answer doesn't depend on wether its flat or 3D because bright "highlighteresque" colors are harsh to the eyes, hard to read, and don't comply with usability guidelines for people with color blindness et. al. As an accent color they are fine but large swaths wouldn't be advisable nor would it be advised to place tex... |
56,906 | I'm in the process of doing some usability testing this week for one our iOS apps. We're having them attempt a few targeted tasks to test goals like
* New users should be able to signup with their email in under 15 seconds
* Users should use all their 'votes' inside a challenge
* Users should be able to located 'John ... | 2014/05/07 | [
"https://ux.stackexchange.com/questions/56906",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/47798/"
] | The 'flat design' aesthetic tends to favor large blocks of solid colors. If all of your colors are 'highlighter-esque' then you just end up with an incredibly busy UI where nothing stands out as they are all competing equally for your attention.
Intense vibrant colors--in UI design, at least--are there to draw attenti... | Harsh colors are one of those things that break through the unconscious into conscious awareness as an annoyance when in an interface. In other words, some UI choices, like counterintuitive navigation, fatigue users and they might not know the culprit. However, people usually speak up, knowing exactly why they don't en... |
71,321,052 | quoting AWS:
>
> AWS has the concept of a Region, which is a physical location around the world where we cluster data centers. We call each group **of logical data centers an Availability Zone**. Each AWS Region consists of **multiple, isolated, and physically separate AZs within a geographic area**.
>
>
>
I'm co... | 2022/03/02 | [
"https://Stackoverflow.com/questions/71321052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7948270/"
] | AWS availability zone logical or physical?
>
> When they say logical datacenter it's like saying a logical model
> which describes the physical datacenter without regarding to how they
> are physically implemented, but giving you a clear perspective how
> they operate.
>
>
>
In contrast, a physical datacenter is ... | An Availability Zone (AZ) is one or more discrete data centers with redundant power, networking, and connectivity in an AWS Region.
Ref: <https://aws.amazon.com/about-aws/global-infrastructure/regions_az/> |
12,865,803 | I have a general question that is Java related.
I am writing an application that has a GUI menu. I am trying to change one part of the GUI menu based on the selection of a Radio button.
Do I need to:
1. Redraw the whole window or just update that part with:
```
setVisible(true)?
```
2. If I just use the statement ... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12865803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/537126/"
] | Swing components have a repaint(), revalidate(), and doLayout() method. One of those should probably be able to redraw whichever pieces you want. However, doLayout is not something that you should be taking responsibility for, that's the layout engines responsibility.
You may also want to check out [this post](https:/... | Call `revalidate()` on the top level component. |
12,865,803 | I have a general question that is Java related.
I am writing an application that has a GUI menu. I am trying to change one part of the GUI menu based on the selection of a Radio button.
Do I need to:
1. Redraw the whole window or just update that part with:
```
setVisible(true)?
```
2. If I just use the statement ... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12865803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/537126/"
] | Swing components have a repaint(), revalidate(), and doLayout() method. One of those should probably be able to redraw whichever pieces you want. However, doLayout is not something that you should be taking responsibility for, that's the layout engines responsibility.
You may also want to check out [this post](https:/... | >
> ..in my application the user select which device platform type they want top test (that choice is a set of two radio buttons on the left). When the user selects either Android or iOS, the center grouping of check boxes changes to reflect a group of android devices they can test or a group of iOS devices that they ... |
48,358,686 | This is my code :
```python
#Choose Report
def chooseReport():
print "Choose a report."
while True:
choice = raw_input("Enter A or B: ")
if choice == 'a' or choice == 'A':
reportA()
break
elif choice == 'b' or choice == 'B':
reportB()
brea... | 2018/01/20 | [
"https://Stackoverflow.com/questions/48358686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9244343/"
] | ```
def chooseReport():
print "Choose a report."
t=True # t starts at true
while t:
choice = raw_input("Enter A or B: ")
if choice == 'a' or choice == 'A':
reportA()
t=False # t turns false to break out of loop
... | Code is fine. I think you call your chooseReport() function in a loop or your input has extra characters and if conditions didn't satisfied. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.