qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
sequence | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | NodeJS provides a setup script that must run before you install it with yum
```
curl -sL https://rpm.nodesource.com/setup | bash -
```
Then the yum command should work
```
yum install -y nodejs
```
<https://github.com/joyent/node/wiki/installing-node.js-via-package-manager#enterprise-linux-and-fedora> | It worked for me. Run both commands as super user.
```
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
sudo yum install -y nodejs
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | Just as per <https://nodejs.org/en/download/package-manager/> you have to launch:
```
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
```
or
```
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
```
depending on NodeJS version you need. Then simply run
```
yum -y install nodejs
``` | I recommend using `dnf` to install the version of NodeJS you need because `yum` will likely pull the wrong version. As seen [Here](https://linuxconfig.org/how-to-install-node-js-on-redhat-8-linux)
List the available versions;
```
sudo dnf module list nodejs
```
Install the one you want:
```
sudo dnf module install nodejs:14
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | Just as per <https://nodejs.org/en/download/package-manager/> you have to launch:
```
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
```
or
```
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
```
depending on NodeJS version you need. Then simply run
```
yum -y install nodejs
``` | It worked for me. Run both commands as super user.
```
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
sudo yum install -y nodejs
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | I don't have the rep to comment on jfredys' answer, but wanted to add an addendum. His answer is correct for certain environments I assume, but it failed for me as I was running into the error:
**Your distribution, identified as "redhat-release-server-6Server-6.6.0.2.el6.x86\_64", is not currently supported, please contact NodeSource at <https://github.com/nodesource/distributions/issues> if you think this is incorrect or would like your distribution to be considered for support**
I had run into weirdness trying to install meteor packages on another server recently and it turned out to be a proxy/firewall issue with curl trying to hit SSL sites. I had to alter all curl commands to use -k to bypass false SSL warnings. First I copied the install script locally:
```
curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
```
While I was at it I removed the s (silent) option to give some insight into any problems (fortunately there were none). In the script I changed all the curl commands to use -k (also removed the silent option just in case). I set it executable and this ran cleanly (under sudo), I was then finally able to install npm with
```
sudo yum install -y nodejs
```
And all was happy:
```
$npm -version
1.4.28
``` | It worked for me. Run both commands as super user.
```
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
sudo yum install -y nodejs
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | NodeJS provides a setup script that must run before you install it with yum
```
curl -sL https://rpm.nodesource.com/setup | bash -
```
Then the yum command should work
```
yum install -y nodejs
```
<https://github.com/joyent/node/wiki/installing-node.js-via-package-manager#enterprise-linux-and-fedora> | Just as per <https://nodejs.org/en/download/package-manager/> you have to launch:
```
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
```
or
```
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
```
depending on NodeJS version you need. Then simply run
```
yum -y install nodejs
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | if this command is not working then visit ...
<https://rpm.nodesource.com/setup>
in your browser
It gives instructions on how to use wget instead.
```
wget -qO- https://rpm.nodesource.com/setup | bash -
```
maybe that will help someone! | I recommend using `dnf` to install the version of NodeJS you need because `yum` will likely pull the wrong version. As seen [Here](https://linuxconfig.org/how-to-install-node-js-on-redhat-8-linux)
List the available versions;
```
sudo dnf module list nodejs
```
Install the one you want:
```
sudo dnf module install nodejs:14
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | IMO the answer by @Eric Soyke should be marked as the correct one. One thing to change in case you want node v4, is to replace 'setup' with 'setup\_4.x'.
The sequence of commands (at least for a root user) is this:
```
curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
# or for v4 / v6:
# curl -kL https://rpm.nodesource.com/setup_4.x > ~/nodeInstall.sh
# curl -kL https://rpm.nodesource.com/setup_6.x > ~/nodeInstall.sh
sed -i -e 's_curl _curl -k _g' nodeInstall.sh
chmod u+x nodeInstall.sh
./nodeInstall.sh
yum -y install nodejs
rm nodeInstall.sh
``` | I recommend using `dnf` to install the version of NodeJS you need because `yum` will likely pull the wrong version. As seen [Here](https://linuxconfig.org/how-to-install-node-js-on-redhat-8-linux)
List the available versions;
```
sudo dnf module list nodejs
```
Install the one you want:
```
sudo dnf module install nodejs:14
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | I don't have the rep to comment on jfredys' answer, but wanted to add an addendum. His answer is correct for certain environments I assume, but it failed for me as I was running into the error:
**Your distribution, identified as "redhat-release-server-6Server-6.6.0.2.el6.x86\_64", is not currently supported, please contact NodeSource at <https://github.com/nodesource/distributions/issues> if you think this is incorrect or would like your distribution to be considered for support**
I had run into weirdness trying to install meteor packages on another server recently and it turned out to be a proxy/firewall issue with curl trying to hit SSL sites. I had to alter all curl commands to use -k to bypass false SSL warnings. First I copied the install script locally:
```
curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
```
While I was at it I removed the s (silent) option to give some insight into any problems (fortunately there were none). In the script I changed all the curl commands to use -k (also removed the silent option just in case). I set it executable and this ran cleanly (under sudo), I was then finally able to install npm with
```
sudo yum install -y nodejs
```
And all was happy:
```
$npm -version
1.4.28
``` | IMO the answer by @Eric Soyke should be marked as the correct one. One thing to change in case you want node v4, is to replace 'setup' with 'setup\_4.x'.
The sequence of commands (at least for a root user) is this:
```
curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
# or for v4 / v6:
# curl -kL https://rpm.nodesource.com/setup_4.x > ~/nodeInstall.sh
# curl -kL https://rpm.nodesource.com/setup_6.x > ~/nodeInstall.sh
sed -i -e 's_curl _curl -k _g' nodeInstall.sh
chmod u+x nodeInstall.sh
./nodeInstall.sh
yum -y install nodejs
rm nodeInstall.sh
``` |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | NodeJS provides a setup script that must run before you install it with yum
```
curl -sL https://rpm.nodesource.com/setup | bash -
```
Then the yum command should work
```
yum install -y nodejs
```
<https://github.com/joyent/node/wiki/installing-node.js-via-package-manager#enterprise-linux-and-fedora> | if this command is not working then visit ...
<https://rpm.nodesource.com/setup>
in your browser
It gives instructions on how to use wget instead.
```
wget -qO- https://rpm.nodesource.com/setup | bash -
```
maybe that will help someone! |
27,778,593 | I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
```
sudo yum install nodejs npm
```
I got the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
```
I tried the following command as well:
```
sudo yum install -y nodejs
```
I am getting the following error:
```
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
```
How should I install it? I want to install the latest version. | 2015/01/05 | [
"https://Stackoverflow.com/questions/27778593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4088696/"
] | I don't have the rep to comment on jfredys' answer, but wanted to add an addendum. His answer is correct for certain environments I assume, but it failed for me as I was running into the error:
**Your distribution, identified as "redhat-release-server-6Server-6.6.0.2.el6.x86\_64", is not currently supported, please contact NodeSource at <https://github.com/nodesource/distributions/issues> if you think this is incorrect or would like your distribution to be considered for support**
I had run into weirdness trying to install meteor packages on another server recently and it turned out to be a proxy/firewall issue with curl trying to hit SSL sites. I had to alter all curl commands to use -k to bypass false SSL warnings. First I copied the install script locally:
```
curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
```
While I was at it I removed the s (silent) option to give some insight into any problems (fortunately there were none). In the script I changed all the curl commands to use -k (also removed the silent option just in case). I set it executable and this ran cleanly (under sudo), I was then finally able to install npm with
```
sudo yum install -y nodejs
```
And all was happy:
```
$npm -version
1.4.28
``` | if this command is not working then visit ...
<https://rpm.nodesource.com/setup>
in your browser
It gives instructions on how to use wget instead.
```
wget -qO- https://rpm.nodesource.com/setup | bash -
```
maybe that will help someone! |
1,521,394 | How can I send mail to Gmail using Perl? Here's what I'm trying:
```
my $mailer = Email::Send->new(
{
mailer => 'SMTP::TLS',
mailer_args => [
Host => 'smtp.gmail.com',
Port => 587,
User => 'xxx',
Password => 'xxx',
]
}
);
use Email::Simple::Creator; # or other Email::
use File::Slurp;
@arrIrc = read_file("$ircFile");
my $email = Email::Simple->create(
header => [
From => 'xxx',
To => "$configList{email}",
Subject => "The summary of logfile $channelName",
],
body => "@arrIrc",
);
``` | 2009/10/05 | [
"https://Stackoverflow.com/questions/1521394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184311/"
] | Use [Net::SMTP::SSL](http://search.cpan.org/perldoc/Net::SMTP::SSL) to talk to GMail.
See [MIME::Lite inline images](http://www.perlmonks.org/?node_id=784574) on [Perlmonks](http://www.perlmonks.org) for an example. | You can use [MIME::Lite](http://search.cpan.org/perldoc?MIME::Lite) to compose a message, which you then send to your local sendmail process. However, in order to talk to gmail's servers you need to [have SSL certificates set up](http://download.gna.org/hpr/fetchmail/FAQ/gmail-pop-howto.html). There's probably more detailed instructions for that on [superuser](http://superuser.com). |
1,521,394 | How can I send mail to Gmail using Perl? Here's what I'm trying:
```
my $mailer = Email::Send->new(
{
mailer => 'SMTP::TLS',
mailer_args => [
Host => 'smtp.gmail.com',
Port => 587,
User => 'xxx',
Password => 'xxx',
]
}
);
use Email::Simple::Creator; # or other Email::
use File::Slurp;
@arrIrc = read_file("$ircFile");
my $email = Email::Simple->create(
header => [
From => 'xxx',
To => "$configList{email}",
Subject => "The summary of logfile $channelName",
],
body => "@arrIrc",
);
``` | 2009/10/05 | [
"https://Stackoverflow.com/questions/1521394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184311/"
] | Use [Net::SMTP::SSL](http://search.cpan.org/perldoc/Net::SMTP::SSL) to talk to GMail.
See [MIME::Lite inline images](http://www.perlmonks.org/?node_id=784574) on [Perlmonks](http://www.perlmonks.org) for an example. | If you want to send mail to Gmail, you do the same thing you would do to send mail anywhere. If you want to send mail through Gmail, there is the [Email::Send::Gmail](http://search.cpan.org/dist/Email-Send-Gmail/) module. Merely typing your question in Google led me to [Sending Mail Through Gmail with Perl](http://www.nixtutor.com/linux/sending-mail-through-gmail-with-perl/) by Mark Sanborn. |
26,897,502 | I have to segregate the even and odd numbers in a 2D array in java in two different rows (even in row 1 and odd in row two). I have included the output of my code bellow here is what I have:
```
class TwoDimensionArrays {
public static void main(String[] args) {
int sum = 0;
int row = 2;
int column = 10;
int[][] iArrays = new int[row][column];
for(int rowCount = 0; rowCount < iArrays.length /*&& rowCount % 2 == 0*/; rowCount++) {
for(int columnCount = 0; columnCount < iArrays[0].length /*&& columnCount % 2 != 0*/; columnCount++) {
if(columnCount % 2 != 0 /*&& rowCount % 2 == 0*/) {
iArrays[rowCount][columnCount] = columnCount + 1;
}
}
}
System.out.println("The array has " + iArrays.length + " rows");
System.out.println("The array has " + iArrays[0].length + " columns");
for(int rowCount = 0; rowCount < iArrays.length; rowCount++) {
for(int columnCount = 0; columnCount < iArrays[0].length; columnCount++) {
System.out.print(iArrays[rowCount][columnCount] + " ");
sum += iArrays[rowCount][columnCount];
}
System.out.println();
}
System.out.println("The sum is: " +sum);
}
}
//OUTPUT//
/*The array has 2 rows
The array has 10 columns
0 2 0 4 0 6 0 8 0 10
0 2 0 4 0 6 0 8 0 10
The sum is: 60*/
```
Can anyone lend a hand?
Thank you in advance. | 2014/11/12 | [
"https://Stackoverflow.com/questions/26897502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4092147/"
] | Instead of passing over the list twice try this:
```
for(int v = 0; v < 20; v++) {
iArrays[v % 2][(int)v/2] = v;
}
```
This will set `iArrays` to:
```
[[0,2,4,6,8,10,12,14,16,18],
[1,3,5,7,9,11,13,15,17,19]]
```
What is happening is the `row` is being set to the remainder of `v % 2` (`0` if `v` is even, `1` if `v` is odd) and the `col` is being set to the corresponding index (with the cast to `int` to drop any fraction). You can even generalize it like this:
```
public static int[][] group(int groups, int size){
int[][] output = new int[groups][size];
for(int value = 0; value < (groups*size); value++) {
output[value % groups][(int)value/groups] = value;
}
return output;
}
```
Then a call to `group(2, 10)` will return:
```
[[0, 2, 4, 6, 8, 10, 12, 14, 16, 18], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]
``` | If I understand your question, one solution is to iterate the array from `0` to `COLUMN` and set each successive slot to two plus the previous slots value (starting with 0 for even and 1 for odd). Like,
```
public static void main(String arg[]) {
final int ROW = 2;
final int COLUMN = 10;
int[][] iArrays = new int[ROW][COLUMN];
for (int i = 0; i < COLUMN; i++) {
iArrays[0][i] = (i > 0) ? iArrays[0][i - 1] + 2 : 0; // 0,2,4,6...
iArrays[1][i] = (i > 0) ? iArrays[1][i - 1] + 2 : 1; // 1,3,5,7...
}
System.out.println(Arrays.deepToString(iArrays));
}
```
Output is
```
[[0, 2, 4, 6, 8, 10, 12, 14, 16, 18], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]
``` |
54,241,950 | This is my first question in Stackoverflow and I am not a professional developer, so be kind guys :) If any additional information is needed, just let me know.
So, I am trying to create a flatlist for a delivery man showing his daily itinerary. In this example he has 4 address to go to. When he arrives at the first place, in this case "METAL", he should press the yellow button. Pressing the yellow button should disable it and chage its background color, but just for the first place "METAL".
Right now, when i press the yellow button it disables and changes the background color for all buttons in the flatlist, I am not sure how to target just the one button that was clicked.
I attached some pictures to show whats going on. The last picture is just an example of what I want.
<https://imgur.com/a/G1S0ap4>
This's what the code first loads
[](https://i.stack.imgur.com/o0mUS.jpg)
This is what happens when i press the yellow button. All buttons have been disabled
[](https://i.stack.imgur.com/pfRWg.jpg)
This is what i wanted it to do, disable just the button that i actually clicked on
[](https://i.stack.imgur.com/Hm7eZ.jpg)
```
this.state = {disablearrived: false,
disablesuccess: false,
disablenotdelivered: false,
showView: true,
fadeAnim: new Animated.Value(0),
colorarrived: '#E5C454',
colorsuccess: '#52D273',
colornotdelivered: '#E94F64',
data: [
{ id: "1", custid: "1111111111111", name: "METAL", nf: "166951" },
{ id: "2", custid: "222222222222", name: "BRUNO", nf: "166952" },
{ id: "3", custid: "8248632473", name: "Doc Hudson" },
{ id: "4", custid: "8577673", name: "Cruz Ramirez" },
],
};
onPressButtonarrived(item) {
// Alert.alert('Chegada às: '+new Date().toLocaleTimeString('pt-BR', {timeZone: 'America/Sao_Paulo'}))
this.setState({ disablearrived: true })
this.setState({ colorarrived: '#D6D6D6' })
}
render() {
return (
<View style={{ backgroundColor: '#252525'}}>
<View>
<Text style={styles.normalblue}>Bem vindo, Victor</Text>
<Text style={styles.normalblue}>Estas são suas entregas de dia</Text>
</View>
<FlatList
data={this.state.data}
extraData={this.state}
keyExtractor={item => item.id}
renderItem={({ item }) => {
return (
<View style={{backgroundColor: '#484848', borderBottomColor: '#252525', borderBottomWidth: 20}}>
<Text style={styles.bigyellow}>{item.name}</Text>
<Text style={styles.smallblue}>{item.add}, {item.addnumber}</Text>
<Text style={styles.normalyellow}>NF {item.nf}</Text>
<View style={styles.containercontent}>
<View style={{backgroundColor: this.state.colorarrived, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonarrived(item)}} disabled={this.state.disablearrived}>
<View style={styles.btnIcon}>
<Icon name="location" size={30} />
<Text>Chegada</Text>
</View>
</TouchableHighlight>
</View>
<View style={{backgroundColor: this.state.colorsuccess, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonsuccess(item)}} disabled={this.state.disablesuccess}>
<View style={styles.btnIcon}>
<Icon name="check" size={30} />
<Text>Entregue</Text>
</View>
</TouchableHighlight>
</View>
{this.state.showView && (
<View style={{backgroundColor: this.state.colornotdelivered, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonnotdelivered(item)}} disabled={this.state.disablenotdelivered}>
<View style={styles.btnIcon}>
<Icon name="block" size={30} />
<Text>Não Entregue</Text>
</View>
</TouchableHighlight>
</View>
)}
</View>
</View>
);
}}
/>
</View>
);
}
``` | 2019/01/17 | [
"https://Stackoverflow.com/questions/54241950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075757/"
] | You can also try with one another approach as shown below.
```
Create Table Result(Id int, Title Varchar(10), Category Varchar(10), SubCategory Varchar(10), Value Int)
Insert Into Result Values(1, 'Part-1','CatX', 'A', 100),
(2 ,'Part-1','CatX', 'B', 0),
(3 ,'Part-1','CatX', 'C', 50),
(4 ,'Part-1','CatY', 'A', 100),
(5 ,'Part-1','CatY', 'B', 0),
(6 ,'Part-1','CatY', 'C', 100),
(7 ,'Part-2','CatM', 'A', 30),
(8 ,'Part-2','CatM', 'B', 10),
(9 ,'Part-2','CatM', 'C', 100),
(10 ,'Part-2','CatN', 'A', 50),
(11 ,'Part-2','CatN', 'B', 10),
(12 ,'Part-2','CatN', 'C', 80)
Select Title, SubCategory, AVG(Value) as Average from Result
Group By Title, SubCategory
Select Title, SubCategory, SUM(Value) / COUNT(*) as Average
From Result Group By Title, SubCategory
```
The output in both case is as shown below which are same.
[](https://i.stack.imgur.com/aOeCG.png)
You can find the live demo [**Live Demo Here**](https://rextester.com/SHC11303) | Use `avg()` aggregate function
```
select Title,SubCategory ,avg(Value)
from table_name
group by Title,SubCategory
``` |
54,241,950 | This is my first question in Stackoverflow and I am not a professional developer, so be kind guys :) If any additional information is needed, just let me know.
So, I am trying to create a flatlist for a delivery man showing his daily itinerary. In this example he has 4 address to go to. When he arrives at the first place, in this case "METAL", he should press the yellow button. Pressing the yellow button should disable it and chage its background color, but just for the first place "METAL".
Right now, when i press the yellow button it disables and changes the background color for all buttons in the flatlist, I am not sure how to target just the one button that was clicked.
I attached some pictures to show whats going on. The last picture is just an example of what I want.
<https://imgur.com/a/G1S0ap4>
This's what the code first loads
[](https://i.stack.imgur.com/o0mUS.jpg)
This is what happens when i press the yellow button. All buttons have been disabled
[](https://i.stack.imgur.com/pfRWg.jpg)
This is what i wanted it to do, disable just the button that i actually clicked on
[](https://i.stack.imgur.com/Hm7eZ.jpg)
```
this.state = {disablearrived: false,
disablesuccess: false,
disablenotdelivered: false,
showView: true,
fadeAnim: new Animated.Value(0),
colorarrived: '#E5C454',
colorsuccess: '#52D273',
colornotdelivered: '#E94F64',
data: [
{ id: "1", custid: "1111111111111", name: "METAL", nf: "166951" },
{ id: "2", custid: "222222222222", name: "BRUNO", nf: "166952" },
{ id: "3", custid: "8248632473", name: "Doc Hudson" },
{ id: "4", custid: "8577673", name: "Cruz Ramirez" },
],
};
onPressButtonarrived(item) {
// Alert.alert('Chegada às: '+new Date().toLocaleTimeString('pt-BR', {timeZone: 'America/Sao_Paulo'}))
this.setState({ disablearrived: true })
this.setState({ colorarrived: '#D6D6D6' })
}
render() {
return (
<View style={{ backgroundColor: '#252525'}}>
<View>
<Text style={styles.normalblue}>Bem vindo, Victor</Text>
<Text style={styles.normalblue}>Estas são suas entregas de dia</Text>
</View>
<FlatList
data={this.state.data}
extraData={this.state}
keyExtractor={item => item.id}
renderItem={({ item }) => {
return (
<View style={{backgroundColor: '#484848', borderBottomColor: '#252525', borderBottomWidth: 20}}>
<Text style={styles.bigyellow}>{item.name}</Text>
<Text style={styles.smallblue}>{item.add}, {item.addnumber}</Text>
<Text style={styles.normalyellow}>NF {item.nf}</Text>
<View style={styles.containercontent}>
<View style={{backgroundColor: this.state.colorarrived, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonarrived(item)}} disabled={this.state.disablearrived}>
<View style={styles.btnIcon}>
<Icon name="location" size={30} />
<Text>Chegada</Text>
</View>
</TouchableHighlight>
</View>
<View style={{backgroundColor: this.state.colorsuccess, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonsuccess(item)}} disabled={this.state.disablesuccess}>
<View style={styles.btnIcon}>
<Icon name="check" size={30} />
<Text>Entregue</Text>
</View>
</TouchableHighlight>
</View>
{this.state.showView && (
<View style={{backgroundColor: this.state.colornotdelivered, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonnotdelivered(item)}} disabled={this.state.disablenotdelivered}>
<View style={styles.btnIcon}>
<Icon name="block" size={30} />
<Text>Não Entregue</Text>
</View>
</TouchableHighlight>
</View>
)}
</View>
</View>
);
}}
/>
</View>
);
}
``` | 2019/01/17 | [
"https://Stackoverflow.com/questions/54241950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075757/"
] | You can also try with one another approach as shown below.
```
Create Table Result(Id int, Title Varchar(10), Category Varchar(10), SubCategory Varchar(10), Value Int)
Insert Into Result Values(1, 'Part-1','CatX', 'A', 100),
(2 ,'Part-1','CatX', 'B', 0),
(3 ,'Part-1','CatX', 'C', 50),
(4 ,'Part-1','CatY', 'A', 100),
(5 ,'Part-1','CatY', 'B', 0),
(6 ,'Part-1','CatY', 'C', 100),
(7 ,'Part-2','CatM', 'A', 30),
(8 ,'Part-2','CatM', 'B', 10),
(9 ,'Part-2','CatM', 'C', 100),
(10 ,'Part-2','CatN', 'A', 50),
(11 ,'Part-2','CatN', 'B', 10),
(12 ,'Part-2','CatN', 'C', 80)
Select Title, SubCategory, AVG(Value) as Average from Result
Group By Title, SubCategory
Select Title, SubCategory, SUM(Value) / COUNT(*) as Average
From Result Group By Title, SubCategory
```
The output in both case is as shown below which are same.
[](https://i.stack.imgur.com/aOeCG.png)
You can find the live demo [**Live Demo Here**](https://rextester.com/SHC11303) | This would work
```
select Title, SubCategory, AVG(Value)
from Table1
group by Title, subcategory
``` |
54,241,950 | This is my first question in Stackoverflow and I am not a professional developer, so be kind guys :) If any additional information is needed, just let me know.
So, I am trying to create a flatlist for a delivery man showing his daily itinerary. In this example he has 4 address to go to. When he arrives at the first place, in this case "METAL", he should press the yellow button. Pressing the yellow button should disable it and chage its background color, but just for the first place "METAL".
Right now, when i press the yellow button it disables and changes the background color for all buttons in the flatlist, I am not sure how to target just the one button that was clicked.
I attached some pictures to show whats going on. The last picture is just an example of what I want.
<https://imgur.com/a/G1S0ap4>
This's what the code first loads
[](https://i.stack.imgur.com/o0mUS.jpg)
This is what happens when i press the yellow button. All buttons have been disabled
[](https://i.stack.imgur.com/pfRWg.jpg)
This is what i wanted it to do, disable just the button that i actually clicked on
[](https://i.stack.imgur.com/Hm7eZ.jpg)
```
this.state = {disablearrived: false,
disablesuccess: false,
disablenotdelivered: false,
showView: true,
fadeAnim: new Animated.Value(0),
colorarrived: '#E5C454',
colorsuccess: '#52D273',
colornotdelivered: '#E94F64',
data: [
{ id: "1", custid: "1111111111111", name: "METAL", nf: "166951" },
{ id: "2", custid: "222222222222", name: "BRUNO", nf: "166952" },
{ id: "3", custid: "8248632473", name: "Doc Hudson" },
{ id: "4", custid: "8577673", name: "Cruz Ramirez" },
],
};
onPressButtonarrived(item) {
// Alert.alert('Chegada às: '+new Date().toLocaleTimeString('pt-BR', {timeZone: 'America/Sao_Paulo'}))
this.setState({ disablearrived: true })
this.setState({ colorarrived: '#D6D6D6' })
}
render() {
return (
<View style={{ backgroundColor: '#252525'}}>
<View>
<Text style={styles.normalblue}>Bem vindo, Victor</Text>
<Text style={styles.normalblue}>Estas são suas entregas de dia</Text>
</View>
<FlatList
data={this.state.data}
extraData={this.state}
keyExtractor={item => item.id}
renderItem={({ item }) => {
return (
<View style={{backgroundColor: '#484848', borderBottomColor: '#252525', borderBottomWidth: 20}}>
<Text style={styles.bigyellow}>{item.name}</Text>
<Text style={styles.smallblue}>{item.add}, {item.addnumber}</Text>
<Text style={styles.normalyellow}>NF {item.nf}</Text>
<View style={styles.containercontent}>
<View style={{backgroundColor: this.state.colorarrived, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonarrived(item)}} disabled={this.state.disablearrived}>
<View style={styles.btnIcon}>
<Icon name="location" size={30} />
<Text>Chegada</Text>
</View>
</TouchableHighlight>
</View>
<View style={{backgroundColor: this.state.colorsuccess, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonsuccess(item)}} disabled={this.state.disablesuccess}>
<View style={styles.btnIcon}>
<Icon name="check" size={30} />
<Text>Entregue</Text>
</View>
</TouchableHighlight>
</View>
{this.state.showView && (
<View style={{backgroundColor: this.state.colornotdelivered, justifyContent: 'center', flex: 1}}>
<TouchableHighlight style={styles.buttonview}
onPress={() => {this.onPressButtonnotdelivered(item)}} disabled={this.state.disablenotdelivered}>
<View style={styles.btnIcon}>
<Icon name="block" size={30} />
<Text>Não Entregue</Text>
</View>
</TouchableHighlight>
</View>
)}
</View>
</View>
);
}}
/>
</View>
);
}
``` | 2019/01/17 | [
"https://Stackoverflow.com/questions/54241950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075757/"
] | You can also try with one another approach as shown below.
```
Create Table Result(Id int, Title Varchar(10), Category Varchar(10), SubCategory Varchar(10), Value Int)
Insert Into Result Values(1, 'Part-1','CatX', 'A', 100),
(2 ,'Part-1','CatX', 'B', 0),
(3 ,'Part-1','CatX', 'C', 50),
(4 ,'Part-1','CatY', 'A', 100),
(5 ,'Part-1','CatY', 'B', 0),
(6 ,'Part-1','CatY', 'C', 100),
(7 ,'Part-2','CatM', 'A', 30),
(8 ,'Part-2','CatM', 'B', 10),
(9 ,'Part-2','CatM', 'C', 100),
(10 ,'Part-2','CatN', 'A', 50),
(11 ,'Part-2','CatN', 'B', 10),
(12 ,'Part-2','CatN', 'C', 80)
Select Title, SubCategory, AVG(Value) as Average from Result
Group By Title, SubCategory
Select Title, SubCategory, SUM(Value) / COUNT(*) as Average
From Result Group By Title, SubCategory
```
The output in both case is as shown below which are same.
[](https://i.stack.imgur.com/aOeCG.png)
You can find the live demo [**Live Demo Here**](https://rextester.com/SHC11303) | Here is solution :
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace ConsoleApplication97
{
class Program
{
static void Main(string[] args)
{
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Title", typeof(string));
dt.Columns.Add("Category", typeof(string));
dt.Columns.Add("SubCategory", typeof(string));
dt.Columns.Add("Value", typeof(int));
dt.Rows.Add(new object[] {1, "Part-1", "CatX", "A", 100});
dt.Rows.Add(new object[] {2, "Part-1", "CatX", "B", 0});
dt.Rows.Add(new object[] {3, "Part-1", "CatX", "C", 50});
dt.Rows.Add(new object[] {4, "Part-1", "CatY", "A", 100});
dt.Rows.Add(new object[] {5, "Part-1", "CatY", "B", 0});
dt.Rows.Add(new object[] {6, "Part-1", "CatY", "C", 100});
dt.Rows.Add(new object[] {7, "Part-2", "CatM", "A", 30});
dt.Rows.Add(new object[] {8, "Part-2", "CatM", "B", 10});
dt.Rows.Add(new object[] {9, "Part-2", "CatM", "C", 100});
dt.Rows.Add(new object[] {10, "Part-2", "CatN", "A", 50});
dt.Rows.Add(new object[] {11, "Part-2", "CatN", "B", 10});
dt.Rows.Add(new object[] {12, "Part-2", "CatN", "C", 80});
var groups = dt.AsEnumerable().GroupBy(x => new { title = x.Field<string>("Title"), subcategory = x.Field<string>("SubCategory") }).ToList();
var totals = groups.Select(x => new {title = x.Key.title, subCategory = x.Key.subcategory, average = x.Average(y => y.Field<int>("Value"))}).ToList();
}
}
}
``` |
35,079,608 | I have an unordered dynamic list with same class list items. and I want to group the same class list items into one ul in the main ul.
How can I group same class list items?
I want to convert the below dynamic list
```
<ul>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a2">Some Content</li>
<li class="a2">Some Content</li>
<li class="a3">Some Content</li>
</ul>
```
into this
```
<ul>
<li>A1
<ul>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
</ul>
</li>
<li>A2
<ul>
<li class="a2">Some Content</li>
<li class="a2">Some Content</li>
</ul>
</li>
<li>A3
<ul>
<li class="a3">Some Content</li>
</ul>
</li>
</ul>
``` | 2016/01/29 | [
"https://Stackoverflow.com/questions/35079608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5740672/"
] | Here a solution for you:
HTML:
```
<ul id="BaseNode">
<li class="a1">A</li>
<li class="a1">B</li>
<li class="a1">C</li>
<li class="a1">D</li>
<li class="a2">E</li>
<li class="a2">F</li>
<li class="a3">G</li>
</ul>
```
---
jQuery:
```
$(document).ready(function(){
var lis = $("#BaseNode > LI");
var as = { };
$.each(lis, function(i, el){
var c = $(el).attr("class");
if(as[c] == null) {
as[c] = new Array();
}
as[c].push(el);
});
$("#BaseNode").empty();
$.each(as, function(i, el) {
var li = $("<li>" + i.toUpperCase() + "</li>");
var ul = $("<ul></ul>");
$(ul).append(el);
$(li).append(ul);
$("#BaseNode").append(li);
});
});
```
I created also a [jsFiddle](https://jsfiddle.net/3hm6yczh/1/) where you can see the result. I added an `ID` to first `UL` only for convenience. | Try this,
```js
var classes = {};
$('ul li').each(function() {
classes[$(this).attr('class')] = $(this).attr('class');
});
$.each(classes,function(entry) {
$("."+entry).wrapAll("<li>"+entry.toUpperCase()+"<ul></ul></li>");
});
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<ul>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a1">Some Content</li>
<li class="a2">Some Content</li>
<li class="a2">Some Content</li>
<li class="a3">Some Content</li>
</ul>
``` |
11,324,750 | I have table `types` and i want to build `selectbox` with all values from this table
In my controller i wrote this code
```
$allRegistrationTypes = RegistrationType::model()->findAll();
$this->render('index', array('allRegistrationTypes' => $allRegistrationTypes))
```
How build selectbox in view file ? | 2012/07/04 | [
"https://Stackoverflow.com/questions/11324750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221313/"
] | Well then its pretty simple all you need to do is first create List Data like
```
CHtml::ListData(allRegistrationTypes,'value you want to pass when item is selected','value you have to display');
```
for ex
```
typeList = CHtml::ListData(allRegistrationTypes,'id','type');
```
now remember both ***id and type are fields in table***
now all you have to do is if you are using form then
```
<?php echo $form->dropDownList($model, 'type_id', $typeList, array('empty'=>'Select a tyoe')); ?>
```
and if you need multiple you can pass `multiple => multiple` in the array as htmlOptions | You would use [`CHtml::dropDownList`](http://www.yiiframework.com/doc/api/1.1/CHtml#dropDownList-detail), or [`activeDropDownList`](http://www.yiiframework.com/doc/api/1.1/CHtml#activeDropDownList-detail) if there is a "parent" model and you want to leverage its validation rules.
If you want to make the `<select>` element multiple-selection-capable, pass in `'multiple' => 'multiple'` and `'size' => X` as part of the `$htmlOptions` parameter. |
11,324,750 | I have table `types` and i want to build `selectbox` with all values from this table
In my controller i wrote this code
```
$allRegistrationTypes = RegistrationType::model()->findAll();
$this->render('index', array('allRegistrationTypes' => $allRegistrationTypes))
```
How build selectbox in view file ? | 2012/07/04 | [
"https://Stackoverflow.com/questions/11324750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221313/"
] | You would use [`CHtml::dropDownList`](http://www.yiiframework.com/doc/api/1.1/CHtml#dropDownList-detail), or [`activeDropDownList`](http://www.yiiframework.com/doc/api/1.1/CHtml#activeDropDownList-detail) if there is a "parent" model and you want to leverage its validation rules.
If you want to make the `<select>` element multiple-selection-capable, pass in `'multiple' => 'multiple'` and `'size' => X` as part of the `$htmlOptions` parameter. | Simplest Method to get "Select Box" in YII Framework:
```
<div class="row">
<?php
echo $form->labelEx($model,'county');
$data = CHtml::listData(County::model()->findAll(), 'id', 'county');
$htmlOptions = array('size' => '1', 'prompt'=>'-- select county --', );
echo $form->listBox($model,'county', $data, $htmlOptions);
echo $form->error($model,'county');
?>
</div>
```
Good Luck.. |
11,324,750 | I have table `types` and i want to build `selectbox` with all values from this table
In my controller i wrote this code
```
$allRegistrationTypes = RegistrationType::model()->findAll();
$this->render('index', array('allRegistrationTypes' => $allRegistrationTypes))
```
How build selectbox in view file ? | 2012/07/04 | [
"https://Stackoverflow.com/questions/11324750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221313/"
] | Well then its pretty simple all you need to do is first create List Data like
```
CHtml::ListData(allRegistrationTypes,'value you want to pass when item is selected','value you have to display');
```
for ex
```
typeList = CHtml::ListData(allRegistrationTypes,'id','type');
```
now remember both ***id and type are fields in table***
now all you have to do is if you are using form then
```
<?php echo $form->dropDownList($model, 'type_id', $typeList, array('empty'=>'Select a tyoe')); ?>
```
and if you need multiple you can pass `multiple => multiple` in the array as htmlOptions | Simplest Method to get "Select Box" in YII Framework:
```
<div class="row">
<?php
echo $form->labelEx($model,'county');
$data = CHtml::listData(County::model()->findAll(), 'id', 'county');
$htmlOptions = array('size' => '1', 'prompt'=>'-- select county --', );
echo $form->listBox($model,'county', $data, $htmlOptions);
echo $form->error($model,'county');
?>
</div>
```
Good Luck.. |
42,164,949 | Hello I am new at c# and I am doing a small game that I need to play mp3 files.
I've been searching about this and using wmp to do it, like this:
```
WindowsMediaPlayer myplayer = new WindowsMediaPlayer();
myplayer.URL = @"c:\somefolder\project\music.mp3";
myplayer.controls.play();
```
I am able to play the file successfully with the full path of the mp3 file. The problem is that I can't find a way to use the file directly from the project folder, I mean, if I copy the project to another computer the path of the mp3 file will be invalid and no sound will be played. I feel that I am at a dead end now, so if someone can help me I would appreciate it! Thanks in advance | 2017/02/10 | [
"https://Stackoverflow.com/questions/42164949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7547069/"
] | I think that your problem is the way you use `getResource()` :
```
Paths.get(getClass().getResource(filepath).toURI());
```
You use a relative classpath (that is relative to the the current class location) to retrieve the `"extrapack-renew.sql"` file.
It means that this resource has to be located inside this path in your jar to be retrieved.
If the resource is not located inside the current class path, the path used to retrieve the resource should start with a `"/"` character in order to specify an absolute name of the resource:
```
Paths.get(getClass().getResource("/"+filepath).toURI());
```
Of course if you use maven, `extrapack-renew.sql` should be in
the `src/main/resources/secure` folder of the source project so that `"/secure/extrapack-renew.sql"` be a resource in the classpath. | My solution was to have the properties files NOT in the jar archive, contrary to what was asked in the original title of the question.
I got it working, with a properties file sitting in the project home directory.
```
$ ll
total 52K
-rw-rw-r-- 1 stephane 10 févr. 13 10:49 application.properties
-rw-r--r-- 1 stephane 6,1K févr. 10 17:22 pom.xml
```
I can open this file and load its properties with:
```
properties.load(new FileInputStream(new File(DB_AUTOSELF_PROPERTIES_FILENAME)));
```
Then I can move the `.jar` archive and the properties file to another directory, and run the application:
```
$ pwd
/home/stephane/trash
$ cp ~/dev/java/projects/AS/target/script-jar-with-dependencies.jar .
$ cp ~/dev/java/projects/AS/application.properties .
$ vi application.properties
-rw-rw-r-- 1 stephane 10 févr. 13 10:53 application.properties
java -jar script-jar-with-dependencies.jar 1 2016-12-01 2017-02-12 all
```
My `pom.xml` file contains the plugins to copy the resources and create a fat `jar` archive:
```
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.fatec.migration.script.utils.Script</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
``` |
26,433,429 | I have an app that has a textbox, validation control and a button. The problem is that if someone copies text from a word document inside the textbox, some of the special characters won't be allowed because of the validation control. But if I delete those special characters and we typed them, the validation control works. Is there a way to convert that text to plain text or rich text inside the textbox? | 2014/10/17 | [
"https://Stackoverflow.com/questions/26433429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3896029/"
] | Copy the text into a `visibility: hidden` div with font styles equal to the textarea and a `max-width` that won't let it go beyond your number of columns. If the height of the hidden copy of the text exceeds your limit, remove the text that was added.
The following is *close* to what you need. Unfortunately, it doesn't nix the 5th row (after hitting enter on the 4th row) until you type something on it, and it can leave a couple characters on the 5th row (if you wrap to the 5th row from the 4th row). I'm uncertain how to refine the technique further.
```js
var $measure = $('#measure');
var $input = $('#input');
var $output = $('#measurement');
var existingText = '';
$input.on('keyup', function(event) {
$measure.html($input.val());
$output.val($measure.width() + 'x' + $measure.height() + 'px');
if ($measure.height() > 60) {
$input.val(existingText.trim());
$measure.html(existingText.trim());
}
existingText = $input.val();
});
```
```css
#measure
{
position: absolute;
visibility: hidden;
height: auto;
width: auto;
white-space: pre-wrap;
/* set font style equal to style of textarea */
font-family: monospace;
font-size: 13px;
letter-spacing: normal;
line-height: normal;
word-spacing: 0;
word-wrap: break-word;
max-width: 221px;
border: 1x solid black;
margin: 2px;
padding: 2px;
}
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="input" cols="30" rows="4"></textarea>
<div id="measure"></div>
<br>
<input type="text" disabled="disabled" id="measurement"/>
``` | Set maxlength attr to 120
Example link is here
<http://www.w3schools.com/tags/att_textarea_maxlength.asp> |
26,433,429 | I have an app that has a textbox, validation control and a button. The problem is that if someone copies text from a word document inside the textbox, some of the special characters won't be allowed because of the validation control. But if I delete those special characters and we typed them, the validation control works. Is there a way to convert that text to plain text or rich text inside the textbox? | 2014/10/17 | [
"https://Stackoverflow.com/questions/26433429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3896029/"
] | This solution is quite simple and works for me:
1. Style your textarea with '**overflow:hidden**' and '**resize:none**'. This will hide the scroll
bar and stop the user from resizing the textarea themselves.
2. Set the desired dimensions of your textarea. (i.e. rows="4" cols="50")
3. Use an **input** event handler to compare the height of your text area with the height of the scroll. While the scroll is taller than your textarea remove one character from the end of your input. This loop will continue until the scroll no longer exceeds the height of the textarea (i.e there is no scrollbar and the textarea remains it's desired size).
```js
const textarea = document.querySelector('textarea');
textarea.addEventListener('input', function() {
while (textarea.clientHeight < textarea.scrollHeight) {
textarea.value = textarea.value.substr(0, textarea.value.length - 1);
}
});
```
```css
textarea {
overflow: hidden;
resize: none;
}
```
```html
<textarea rows="2" cols="20"> </textarea>
``` | Set maxlength attr to 120
Example link is here
<http://www.w3schools.com/tags/att_textarea_maxlength.asp> |
27,477,558 | Here is the code for back button. I want to kill other activities by back button but its not working in one activity, but I have other activities and without one activity its working fine. Please help me out.
```
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
SomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
``` | 2014/12/15 | [
"https://Stackoverflow.com/questions/27477558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4294246/"
] | Might be this code will help you:
```
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), SomeActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();
}
``` | You have to set Flags according to API level :
```
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
if(Build.VERSION.SDK_INT >= 11)
{
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
else
{
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(intent);
```
Hope it helps ツ |
27,477,558 | Here is the code for back button. I want to kill other activities by back button but its not working in one activity, but I have other activities and without one activity its working fine. Please help me out.
```
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
SomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
``` | 2014/12/15 | [
"https://Stackoverflow.com/questions/27477558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4294246/"
] | Might be this code will help you:
```
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), SomeActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();
}
``` | You can set `android:noHistory="true"` in activities tag in `AndroidManifest.xml` which you don't want to save in stack. |
27,477,558 | Here is the code for back button. I want to kill other activities by back button but its not working in one activity, but I have other activities and without one activity its working fine. Please help me out.
```
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
SomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
``` | 2014/12/15 | [
"https://Stackoverflow.com/questions/27477558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4294246/"
] | Might be this code will help you:
```
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), SomeActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();
}
``` | Try to define one local broadcast receiver on top most parent activity or base activity :
```
private final class KillReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
finish();
}
}
```
Intialize and register broadcast receiver in onCreate() and unregister in onDestroy() on top most parent activity or base activity :
private KillReceiver clearActivityStack;
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
clearActivityStack = new KillReceiver();
registerReceiver(clearActivityStack, IntentFilter.create("clearStackActivity", "text/plain"));
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(clearActivityStack);
}
```
Now call broadcast receiver when wan to clear all previous activity :
```
public void onClick(View v) {
Intent clearIntent = new Intent("clearStackActivity");
clearIntent.setType("text/plain");
sendBroadcast(clearIntent);
Intent intent = new Intent(getApplicationContext(),SomeActivity.class);
startActivity(intent);
}
``` |
5,474,767 | I'm trying to solve [this problem.](https://stackoverflow.com/questions/5461191/creating-screens-and-underlying-data-access-layer-dynamically-on-android) I was wondering if it's possible to use ORMLite (or modify it) to support this use case ?
Thanks. | 2011/03/29 | [
"https://Stackoverflow.com/questions/5474767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/306346/"
] | Just use [db4o](http://www.db4o.com/android/) and forget all the sql and mappings hassle. Model your objects and persist them directly. | Now, you could create a table of screens which could then have a field table with the name of the screen-id, field name, and other information. You could have a user-id in the screen table so each user could have an entry which corresponds to a list of fields.
```
public class Screen {
String user;
...
}
public class Field {
Screen screen;
String fieldName;
int fieldPosition;
...
}
```
But unless you actually need SQL functionality, you may want to consider a different persistence strategy like @mgv mentioned. |
35,161,201 | I have gone through almost all posts for this error. But i was unable for figure out the issue.
I have tried to change build.gradle repositories to mavenCentral() and have also tried make changes in app.gradle. I just though of adding volley into my app, from then the sync is getting failed.
I have also tried file->Invalidate caches/Restart.
I feel there is some problem with getDefaultProgaurdFile. as I can see it is underlined.
Please help me on this.
Thanks
```
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.six30labs.cms"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
```
<http://postimg.org/image/4kv7qh7cr/>
<http://postimg.org/image/azlbyum2b/> | 2016/02/02 | [
"https://Stackoverflow.com/questions/35161201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4994472/"
] | ```
insert into table_a (f1, f2, f3, f4, f5, f6)
select f1, f2, f3, f4, f5, f6
from (
(
select $1, $2, $3, f4, f5, f2, 1
from table_a
where <conditionals>
order by <ordering>
limit 1
) s
union all
select $1, $2, $3, '', '', null, 2
) s (f1, f2, f3, f4, f5, f6, o)
order by o
limit 1
``` | Just another way if you want to use default value from table DDL instead of hardcoded in the query:
```
WITH t AS (
INSERT INTO table_a (f1, f2, f3, f4, f5, f6)
SELECT $1, $2, $3, f4, f5, f2
FROM table_a
WHERE <conditionals>
ORDER BY <ordering>
LIMIT 1
RETURNING *) -- This query will return inserted values
INSERT INTO table_a (f1, f2, f3)
SELECT $1, $2, $3 WHERE (SELECT count(*) FROM t) = 0; -- Insert if no insertion was happened at WITH clause
``` |
48,862,529 | I understand [why control characters are illegal in XML 1.0](https://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0), but still I need to store them somehow in XML payload and I cannot find any recommendations about escaping them. I cannot upgrade to XML 1.1.
How should I escape e.g. [SOH character](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#SOH) (`\u0001` - standard separator for FIX messages)?
The following doesn't work:
```
<data></data>
``` | 2018/02/19 | [
"https://Stackoverflow.com/questions/48862529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4647853/"
] | One way is to use processing instructions: `<?hex 01?>`. But that only works in element content, not in attributes. And of course the processing instruction needs to be understood by the receiving application.
You could also use elements: `<hex value="01"/>` but elements are visible in an XSD schema or DTD, while processing instructions are hidden.
Another approach is that if a piece of payload can contain such characters, then put the whole payload in Base64 encoding. | It's quite common in logging/printing of FIX messages to substitute SOH with another character like '|'. Could you do the same here? |
48,862,529 | I understand [why control characters are illegal in XML 1.0](https://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0), but still I need to store them somehow in XML payload and I cannot find any recommendations about escaping them. I cannot upgrade to XML 1.1.
How should I escape e.g. [SOH character](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#SOH) (`\u0001` - standard separator for FIX messages)?
The following doesn't work:
```
<data></data>
``` | 2018/02/19 | [
"https://Stackoverflow.com/questions/48862529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4647853/"
] | One way is to use processing instructions: `<?hex 01?>`. But that only works in element content, not in attributes. And of course the processing instruction needs to be understood by the receiving application.
You could also use elements: `<hex value="01"/>` but elements are visible in an XSD schema or DTD, while processing instructions are hidden.
Another approach is that if a piece of payload can contain such characters, then put the whole payload in Base64 encoding. | My company ended up adding our own markup before XML: {1}.
You also have to escape the { and } braces as {123} and {125}.
The when reading the XML you have to do your own parse of the embedded codes. |
49,160,125 | I have and Application which has a **singleton** that stores information across the whole app. However, this is creating some data race issues when using the singleton from different threads.
Here there is a very dummy and simplistic version of the problem:
**Singleton**
```
class Singleton {
static var shared = Singleton()
var foo: String = "foo"
}
```
**Use of the singleton** (from the AppDelegate for simplicity)
```
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
DispatchQueue.global().async {
var foo = Singleton.shared.foo // Causes data race
}
DispatchQueue.global().async {
Singleton.shared.foo = "bar" // Causes data race
}
return true
}
}
```
Is there any way to ensure that a singleton is thread safe, so it can be used from anywhere in the app without having to worry about which thread you are in?
This question is **not** a duplicate of [Using a dispatch\_once singleton model in Swift](https://stackoverflow.com/questions/24024549/using-a-dispatch-once-singleton-model-in-swift) since (if I understood it correctly) in there they are addressing the problem of accessing to the singleton object itself, but not ensuring that the reading and writing of its properties is done thread safely. | 2018/03/07 | [
"https://Stackoverflow.com/questions/49160125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5761878/"
] | Thanks to @rmaddy comments which pointed me in the right direction I was able to solve the problem.
In order to make the property `foo` of the `Singleton` thread safe, it need to be modified as follows:
```
class Singleton {
static let shared = Singleton()
private init(){}
private let internalQueue = DispatchQueue(label: "com.singletioninternal.queue",
qos: .default,
attributes: .concurrent)
private var _foo: String = "aaa"
var foo: String {
get {
return internalQueue.sync {
_foo
}
}
set (newState) {
internalQueue.async(flags: .barrier) {
self._foo = newState
}
}
}
func setup(string: String) {
foo = string
}
}
```
Thread safety is accomplished by having a computed property `foo` which uses an `internalQueue` to access the "real" `_foo` property.
Also, in order to have better performance `internalQueue` is created as concurrent. And it means that it is needed to add the `barrier` flag when writing to the property.
What the `barrier` flag does is to ensure that the work item will be executed when all previously scheduled work items on the queue have finished. | **Swift Thread safe Singleton**
[[GCD]](https://stackoverflow.com/a/61102990/4770877)
[[Swift barrier flag for thread safe]](https://stackoverflow.com/questions/46732016/main-async-vs-main-sync-vs-global-async-in-swift3-gcd/61102990#61102990)
You are able to implement Swift's Singleton pattern for concurrent envirompment using `GCD` and 3 main things:
1. Custom **concurrent queue** - local queue for better performance where multiple reads can be happened at the same time
2. `sync` - `customQueue.sync` for **reading** a shared resource - to have clear API without callbacks
3. `barrier flag` - `customQueue.async(flags: .barrier)` for **writing** operation: wait when running operations are done -> execute write task -> proceed executing task
```
public class MySingleton {
public static let shared = Singleton()
//1. custom queue
private let customQueue = DispatchQueue(label: "com.mysingleton.queue", qos: .default, attributes: .concurrent)
//shared resource
private var sharedResource: String = "Hello World"
//computed property can be replaced getters/setters
var computedProperty: String {
get {
//2. sync read
return customQueue.sync {
sharedResource
}
}
set {
//3. async write
customQueue.async(flags: .barrier) {
sharedResource = newValue
}
}
}
private init() {
}
}
``` |
21,563,414 | I am using aptana studio v 3.4.2.201308081805 on windows 7, I know that v 3.5 is available because I was prompted to update to 3.5 on a different computer.
I have not received the update prompt on my macbook air or on my work computer. Does anyone know how to force aptana to update to v 3.5? | 2014/02/04 | [
"https://Stackoverflow.com/questions/21563414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1922932/"
] | Aptana has removed version 3.5 due to several bugs.
Current stable version is 3.4.2
You can check here [Aptana download](http://www.aptana.com/products/studio3/download) | Check out the other Stack Overflow question from [here](https://stackoverflow.com/questions/11182618/how-to-update-aptana-studio-to-the-latest). It's also about updating Aptana Studio. Basically, in your case, Aptana may not have the update sites list configured yet. You'll need to import the XML file containing these addresses (many people have had to deal with this, as show in the support thread [on Aptana Studio's support site](http://aptanastudio.tenderapp.com/discussions/problems/2791-available-software-sites-list-is-empty-on-aptana3) about adding update sites to Aptana. Also, check out [this](https://wiki.appcelerator.org/display/tis/Errors+While+Updating) page on the Appcelerator wiki about common issues with updating. |
62,315 | After watching the thirteen films in the *Marvel Cinematic Universe*, I've been wondering if there is a longer running series of films that maps out a continuous storyline.
[I've found this article on Wikipedia](https://en.wikipedia.org/wiki/List_of_film_series_with_more_than_twenty_entries), but I am unsure if any of these film series have reboots, or even if they follow a continuous plotline/timeline.
The *James Bond* series of films features a reboot, but even before *Casino Royale* there didn't seem to be much of a continual plotline across the entire series of films (despite the recurring characters, organisations and themes).
To explain what I mean by continuous plotline, I am going by the following criteria:
* Films set in the same "universe" or setting
* A continuous timeline of events depicted by the films (although not necessarily in sequence)
* Each film should intentionally reference at least one of the other films that preceded it
* Preferably at least one of the characters should be shared across more than one of the films in the series
* Reboots or remakes break the continuous plotline, so these cannot be included (but they can be ignored if subsequent films continue the original plotline)
The important part here is the continuous timeline of events. If a film can be placed somewhere in the timeline of a series without causing issues (eg. characters being revived without explanation, previously destroyed places suddenly restored without explanation, massive jumps in time for the setting and yet the characters don't age without explanation), then it is part of the continuous timeline. Otherwise that film breaks the timeline and cannot be included.
I am more than happy to accept parts of a film series. For example if twenty of the thirty or more *Godzilla* films all follow these criteria, then I would accept those twenty films as a continuous plotline.
I can think of several film series that fit these criteria, the *Star Wars* and *Harry Potter* film series are two examples. But I am looking for the longest series of films that fits my criteria of a continuous plotline or timeline of events.
Films don't have to be direct sequels/prequels to fit into my criteria - films in the same setting but chronologically spread out, and therefore with different characters would fit the bill so long as they kept to a continuous timeline of events. Also, I would accept foreign language films and films that are TV movies or straight to DVD films. | 2016/10/24 | [
"https://movies.stackexchange.com/questions/62315",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/30280/"
] | According to [Wikipedia's entry for *Blondie* (the comic strip)](https://en.wikipedia.org/wiki/Blondie_(comic_strip)), of the 28 movies made based on the strip, at least the first 14 were a continuous series meeting your definition:
>
> Blondie was adapted into a long-running series of 28 low-budget theatrical B-features, produced by Columbia Pictures. *[...]*
>
>
> Columbia was careful to maintain continuity, so each picture progressed from where the last one left off. Thus the Bumstead children grew from toddlers to young adults onscreen. *[...]*
>
>
> In 1943 Columbia felt the series was slipping, and ended the string with It's a Great Life and Footlight Glamour, deliberately omitting "Blondie" from the titles to attract unwary moviegoers. After 14 Blondies, stars Singleton and Lake moved on to other productions. During their absence from the screen, Columbia heard from many exhibitors and fans who wanted the Blondies back. The studio reactivated the series, which ran another 14 films until discontinued permanently in 1950.
>
>
>
So this is definitely 14, and most likely all 28; I note that the entry for Larry Sims (the child actor who plays Dagwood & Blondie's son Alexander) is listed as appearing in all 28 films along with the two main stars, Penny Singleton and Arthur Lake. | **New Answer**:
It is [The Land Before Time](https://en.wikipedia.org/wiki/The_Land_Before_Time_(franchise)#Films). There have been 14 movies in the series, but the 13th one is reboot. So, if we don't count it, there are still 12.
>
> The Land Before Time is a franchise of Universal Studios animated films centered on dinosaurs. The series began in 1988 with The Land Before Time, directed and produced by Don Bluth and executive produced by George Lucas and Steven Spielberg.
>
>
>
[Source](https://movies.stackexchange.com/q/6855/27264)
**Old Answer** (after pointed out in comment)
This can be [Carry On](https://en.wikipedia.org/wiki/Carry_On_(franchise)) (1958-1992).
>
> The Carry On franchise primarily consists of a sequence of **31 low-budget British comedy motion pictures (1958–92)**, four Christmas specials, a television series of thirteen episodes, and three West End and provincial stage plays. The films' humour was in the British comic tradition of the music hall and bawdy seaside postcards. Producer Peter Rogers and director Gerald Thomas drew on a regular group of actors, the Carry On team, that included Sidney James, Kenneth Williams, Charles Hawtrey, Joan Sims, Kenneth Connor, Peter Butterworth, Hattie Jacques, Terry Scott, Bernard Bresslaw, Barbara Windsor, Jack Douglas and Jim Dale.
>
>
>
**NOTE: There may be many other series in other languages, but one can only say confirm if he/she has watched it.** |
62,315 | After watching the thirteen films in the *Marvel Cinematic Universe*, I've been wondering if there is a longer running series of films that maps out a continuous storyline.
[I've found this article on Wikipedia](https://en.wikipedia.org/wiki/List_of_film_series_with_more_than_twenty_entries), but I am unsure if any of these film series have reboots, or even if they follow a continuous plotline/timeline.
The *James Bond* series of films features a reboot, but even before *Casino Royale* there didn't seem to be much of a continual plotline across the entire series of films (despite the recurring characters, organisations and themes).
To explain what I mean by continuous plotline, I am going by the following criteria:
* Films set in the same "universe" or setting
* A continuous timeline of events depicted by the films (although not necessarily in sequence)
* Each film should intentionally reference at least one of the other films that preceded it
* Preferably at least one of the characters should be shared across more than one of the films in the series
* Reboots or remakes break the continuous plotline, so these cannot be included (but they can be ignored if subsequent films continue the original plotline)
The important part here is the continuous timeline of events. If a film can be placed somewhere in the timeline of a series without causing issues (eg. characters being revived without explanation, previously destroyed places suddenly restored without explanation, massive jumps in time for the setting and yet the characters don't age without explanation), then it is part of the continuous timeline. Otherwise that film breaks the timeline and cannot be included.
I am more than happy to accept parts of a film series. For example if twenty of the thirty or more *Godzilla* films all follow these criteria, then I would accept those twenty films as a continuous plotline.
I can think of several film series that fit these criteria, the *Star Wars* and *Harry Potter* film series are two examples. But I am looking for the longest series of films that fits my criteria of a continuous plotline or timeline of events.
Films don't have to be direct sequels/prequels to fit into my criteria - films in the same setting but chronologically spread out, and therefore with different characters would fit the bill so long as they kept to a continuous timeline of events. Also, I would accept foreign language films and films that are TV movies or straight to DVD films. | 2016/10/24 | [
"https://movies.stackexchange.com/questions/62315",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/30280/"
] | Beating the 14 movie streak of the Blondie movies, we now have **23** movies in the Marvel Cinematic Universe:
1. [Iron Man](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Iron_Man_(2008))
2. [The Incredible Hulk](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#The_Incredible_Hulk_(2008))
3. [Iron Man 2](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Iron_Man_2_(2010))
4. [Thor](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Thor_(2011))
5. [Captain America: The First Avenger](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_America:_The_First_Avenger_(2011))
6. [Marvel's The Avengers](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Marvel's_The_Avengers_(2012))
7. [Iron Man 3](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Iron_Man_3_(2013))
8. [Thor: The Dark World](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Thor:_The_Dark_World_(2013))
9. [Captain America: The Winter Soldier](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_America:_The_Winter_Soldier_(2014))
10. [Guardians of the Galaxy](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Guardians_of_the_Galaxy_(2014))
11. [Avengers: Age of Ultron](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Avengers:_Age_of_Ultron_(2015))
12. [Ant-Man](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Ant-Man_(2015))
13. [Captain America: Civil War](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_America:_Civil_War_(2016))
14. [Doctor Strange](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Doctor_Strange_(2016))
15. [Guardians of the Galaxy Vol. 2](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Guardians_of_the_Galaxy_Vol._2_(2017))
16. [Spider-Man: Homecoming](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Spider-Man:_Homecoming_(2017))
17. [Thor: Ragnarok](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Thor:_Ragnarok_(2017))
18. [Black Panther](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Black_Panther_(2018))
19. [Avengers: Infinity War](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Avengers:_Infinity_War_(2018))
20. [Ant-Man and the Wasp](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Ant-Man_and_the_Wasp_(2018))
21. [Captain Marvel](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_Marvel_(2019))
22. [Avengers: Endgame](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Avengers:_Endgame_(2019))
23. [Spider-Man: Far From Home](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Spider-Man:_Far_From_Home_(2019))
The next MCU film (as of February 2020) will be [Black Widow](https://en.wikipedia.org/wiki/Marvel_Cinematic_Universe:_Phase_Four#Black_Widow_(2020)) on May 1, 2020 with five additional films listed as part of "[Phase Four](https://en.wikipedia.org/wiki/Marvel_Cinematic_Universe:_Phase_Four)". | **New Answer**:
It is [The Land Before Time](https://en.wikipedia.org/wiki/The_Land_Before_Time_(franchise)#Films). There have been 14 movies in the series, but the 13th one is reboot. So, if we don't count it, there are still 12.
>
> The Land Before Time is a franchise of Universal Studios animated films centered on dinosaurs. The series began in 1988 with The Land Before Time, directed and produced by Don Bluth and executive produced by George Lucas and Steven Spielberg.
>
>
>
[Source](https://movies.stackexchange.com/q/6855/27264)
**Old Answer** (after pointed out in comment)
This can be [Carry On](https://en.wikipedia.org/wiki/Carry_On_(franchise)) (1958-1992).
>
> The Carry On franchise primarily consists of a sequence of **31 low-budget British comedy motion pictures (1958–92)**, four Christmas specials, a television series of thirteen episodes, and three West End and provincial stage plays. The films' humour was in the British comic tradition of the music hall and bawdy seaside postcards. Producer Peter Rogers and director Gerald Thomas drew on a regular group of actors, the Carry On team, that included Sidney James, Kenneth Williams, Charles Hawtrey, Joan Sims, Kenneth Connor, Peter Butterworth, Hattie Jacques, Terry Scott, Bernard Bresslaw, Barbara Windsor, Jack Douglas and Jim Dale.
>
>
>
**NOTE: There may be many other series in other languages, but one can only say confirm if he/she has watched it.** |
62,315 | After watching the thirteen films in the *Marvel Cinematic Universe*, I've been wondering if there is a longer running series of films that maps out a continuous storyline.
[I've found this article on Wikipedia](https://en.wikipedia.org/wiki/List_of_film_series_with_more_than_twenty_entries), but I am unsure if any of these film series have reboots, or even if they follow a continuous plotline/timeline.
The *James Bond* series of films features a reboot, but even before *Casino Royale* there didn't seem to be much of a continual plotline across the entire series of films (despite the recurring characters, organisations and themes).
To explain what I mean by continuous plotline, I am going by the following criteria:
* Films set in the same "universe" or setting
* A continuous timeline of events depicted by the films (although not necessarily in sequence)
* Each film should intentionally reference at least one of the other films that preceded it
* Preferably at least one of the characters should be shared across more than one of the films in the series
* Reboots or remakes break the continuous plotline, so these cannot be included (but they can be ignored if subsequent films continue the original plotline)
The important part here is the continuous timeline of events. If a film can be placed somewhere in the timeline of a series without causing issues (eg. characters being revived without explanation, previously destroyed places suddenly restored without explanation, massive jumps in time for the setting and yet the characters don't age without explanation), then it is part of the continuous timeline. Otherwise that film breaks the timeline and cannot be included.
I am more than happy to accept parts of a film series. For example if twenty of the thirty or more *Godzilla* films all follow these criteria, then I would accept those twenty films as a continuous plotline.
I can think of several film series that fit these criteria, the *Star Wars* and *Harry Potter* film series are two examples. But I am looking for the longest series of films that fits my criteria of a continuous plotline or timeline of events.
Films don't have to be direct sequels/prequels to fit into my criteria - films in the same setting but chronologically spread out, and therefore with different characters would fit the bill so long as they kept to a continuous timeline of events. Also, I would accept foreign language films and films that are TV movies or straight to DVD films. | 2016/10/24 | [
"https://movies.stackexchange.com/questions/62315",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/30280/"
] | According to [Wikipedia's entry for *Blondie* (the comic strip)](https://en.wikipedia.org/wiki/Blondie_(comic_strip)), of the 28 movies made based on the strip, at least the first 14 were a continuous series meeting your definition:
>
> Blondie was adapted into a long-running series of 28 low-budget theatrical B-features, produced by Columbia Pictures. *[...]*
>
>
> Columbia was careful to maintain continuity, so each picture progressed from where the last one left off. Thus the Bumstead children grew from toddlers to young adults onscreen. *[...]*
>
>
> In 1943 Columbia felt the series was slipping, and ended the string with It's a Great Life and Footlight Glamour, deliberately omitting "Blondie" from the titles to attract unwary moviegoers. After 14 Blondies, stars Singleton and Lake moved on to other productions. During their absence from the screen, Columbia heard from many exhibitors and fans who wanted the Blondies back. The studio reactivated the series, which ran another 14 films until discontinued permanently in 1950.
>
>
>
So this is definitely 14, and most likely all 28; I note that the entry for Larry Sims (the child actor who plays Dagwood & Blondie's son Alexander) is listed as appearing in all 28 films along with the two main stars, Penny Singleton and Arthur Lake. | [The *Up* documentary series](https://en.wikipedia.org/wiki/Up_Series) currently consists of nine films spanning 55 years. The original film, [*Seven Up!*](https://www.imdb.com/title/tt0058578/), was released in 1964 and featured interviews with several 7-year-old British children from a variety of backgrounds.
Since then, the original filmmakers have produced [new](https://www.imdb.com/title/tt0066356/) [documentaries](https://www.imdb.com/title/tt0075610/) [revisiting](https://www.imdb.com/title/tt0088650/) [the](https://www.imdb.com/title/tt0101254/) [subjects](https://www.imdb.com/title/tt0164312/) [every](https://www.imdb.com/title/tt0473434/) [seven](https://www.imdb.com/title/tt2147134/) [years](https://www.imdb.com/title/tt8929142/). The most recent film in the series is [*63 Up*](https://www.imdb.com/title/tt8929142/) released in 2019, and there's every reason to believe that the series will continue on schedule. |
62,315 | After watching the thirteen films in the *Marvel Cinematic Universe*, I've been wondering if there is a longer running series of films that maps out a continuous storyline.
[I've found this article on Wikipedia](https://en.wikipedia.org/wiki/List_of_film_series_with_more_than_twenty_entries), but I am unsure if any of these film series have reboots, or even if they follow a continuous plotline/timeline.
The *James Bond* series of films features a reboot, but even before *Casino Royale* there didn't seem to be much of a continual plotline across the entire series of films (despite the recurring characters, organisations and themes).
To explain what I mean by continuous plotline, I am going by the following criteria:
* Films set in the same "universe" or setting
* A continuous timeline of events depicted by the films (although not necessarily in sequence)
* Each film should intentionally reference at least one of the other films that preceded it
* Preferably at least one of the characters should be shared across more than one of the films in the series
* Reboots or remakes break the continuous plotline, so these cannot be included (but they can be ignored if subsequent films continue the original plotline)
The important part here is the continuous timeline of events. If a film can be placed somewhere in the timeline of a series without causing issues (eg. characters being revived without explanation, previously destroyed places suddenly restored without explanation, massive jumps in time for the setting and yet the characters don't age without explanation), then it is part of the continuous timeline. Otherwise that film breaks the timeline and cannot be included.
I am more than happy to accept parts of a film series. For example if twenty of the thirty or more *Godzilla* films all follow these criteria, then I would accept those twenty films as a continuous plotline.
I can think of several film series that fit these criteria, the *Star Wars* and *Harry Potter* film series are two examples. But I am looking for the longest series of films that fits my criteria of a continuous plotline or timeline of events.
Films don't have to be direct sequels/prequels to fit into my criteria - films in the same setting but chronologically spread out, and therefore with different characters would fit the bill so long as they kept to a continuous timeline of events. Also, I would accept foreign language films and films that are TV movies or straight to DVD films. | 2016/10/24 | [
"https://movies.stackexchange.com/questions/62315",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/30280/"
] | Beating the 14 movie streak of the Blondie movies, we now have **23** movies in the Marvel Cinematic Universe:
1. [Iron Man](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Iron_Man_(2008))
2. [The Incredible Hulk](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#The_Incredible_Hulk_(2008))
3. [Iron Man 2](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Iron_Man_2_(2010))
4. [Thor](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Thor_(2011))
5. [Captain America: The First Avenger](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_America:_The_First_Avenger_(2011))
6. [Marvel's The Avengers](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Marvel's_The_Avengers_(2012))
7. [Iron Man 3](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Iron_Man_3_(2013))
8. [Thor: The Dark World](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Thor:_The_Dark_World_(2013))
9. [Captain America: The Winter Soldier](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_America:_The_Winter_Soldier_(2014))
10. [Guardians of the Galaxy](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Guardians_of_the_Galaxy_(2014))
11. [Avengers: Age of Ultron](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Avengers:_Age_of_Ultron_(2015))
12. [Ant-Man](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Ant-Man_(2015))
13. [Captain America: Civil War](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_America:_Civil_War_(2016))
14. [Doctor Strange](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Doctor_Strange_(2016))
15. [Guardians of the Galaxy Vol. 2](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Guardians_of_the_Galaxy_Vol._2_(2017))
16. [Spider-Man: Homecoming](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Spider-Man:_Homecoming_(2017))
17. [Thor: Ragnarok](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Thor:_Ragnarok_(2017))
18. [Black Panther](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Black_Panther_(2018))
19. [Avengers: Infinity War](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Avengers:_Infinity_War_(2018))
20. [Ant-Man and the Wasp](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Ant-Man_and_the_Wasp_(2018))
21. [Captain Marvel](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Captain_Marvel_(2019))
22. [Avengers: Endgame](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Avengers:_Endgame_(2019))
23. [Spider-Man: Far From Home](https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_films#Spider-Man:_Far_From_Home_(2019))
The next MCU film (as of February 2020) will be [Black Widow](https://en.wikipedia.org/wiki/Marvel_Cinematic_Universe:_Phase_Four#Black_Widow_(2020)) on May 1, 2020 with five additional films listed as part of "[Phase Four](https://en.wikipedia.org/wiki/Marvel_Cinematic_Universe:_Phase_Four)". | [The *Up* documentary series](https://en.wikipedia.org/wiki/Up_Series) currently consists of nine films spanning 55 years. The original film, [*Seven Up!*](https://www.imdb.com/title/tt0058578/), was released in 1964 and featured interviews with several 7-year-old British children from a variety of backgrounds.
Since then, the original filmmakers have produced [new](https://www.imdb.com/title/tt0066356/) [documentaries](https://www.imdb.com/title/tt0075610/) [revisiting](https://www.imdb.com/title/tt0088650/) [the](https://www.imdb.com/title/tt0101254/) [subjects](https://www.imdb.com/title/tt0164312/) [every](https://www.imdb.com/title/tt0473434/) [seven](https://www.imdb.com/title/tt2147134/) [years](https://www.imdb.com/title/tt8929142/). The most recent film in the series is [*63 Up*](https://www.imdb.com/title/tt8929142/) released in 2019, and there's every reason to believe that the series will continue on schedule. |
29,774,038 | Why is this query returning an error. I am trying to load the code for table as a constant string, the flag for data again a constant string, the time of insertion and the counts for a table. I thought, let me try and run the secelct before writing the inserts.
But for some reason, it fails listing column names from tables from where I am trying to get a count. All i need is two constant values, one date and one count. Tried by removing the groupby as well, throws another error.
**hive -e "select "WEB" as src\_cd, "1Hr" as Load\_Flag, from\_unixtime((unix\_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(\*)
from weblog
where year=2015 and month=04 and day=17
group by src\_cd, load\_flag, time
;**
"
OK
Time taken: 1.446 seconds
FAILED: SemanticException [Error 10004]: Line 4:9 Invalid table alias or column reference 'src\_cd': (possible column names are: clientip, authuser, sysdate, clfrequest.........(and so on) year, month, day) | 2015/04/21 | [
"https://Stackoverflow.com/questions/29774038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1725647/"
] | The double quotes on the literals is a problem. Here is a simpler version that I tested successfully:
```
hive -e "select 'WEB' , '1Hr' , from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(*) from weblog where year=2015 and month=04 and day=17 group by 1,2 , from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') ; "
``` | Just leave out the constants in the `group by`. It isn't doing anything:
```
select "WEB" as src_cd, "1Hr" as Load_Flag,
from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(*)
from weblog
where year = 2015 and month = 04 and day = 17
group by from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy')
```
I don't think Hive allows column aliases in the `group by`, so you need to put in the entire expression or use a subquery/CTE. |
29,774,038 | Why is this query returning an error. I am trying to load the code for table as a constant string, the flag for data again a constant string, the time of insertion and the counts for a table. I thought, let me try and run the secelct before writing the inserts.
But for some reason, it fails listing column names from tables from where I am trying to get a count. All i need is two constant values, one date and one count. Tried by removing the groupby as well, throws another error.
**hive -e "select "WEB" as src\_cd, "1Hr" as Load\_Flag, from\_unixtime((unix\_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(\*)
from weblog
where year=2015 and month=04 and day=17
group by src\_cd, load\_flag, time
;**
"
OK
Time taken: 1.446 seconds
FAILED: SemanticException [Error 10004]: Line 4:9 Invalid table alias or column reference 'src\_cd': (possible column names are: clientip, authuser, sysdate, clfrequest.........(and so on) year, month, day) | 2015/04/21 | [
"https://Stackoverflow.com/questions/29774038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1725647/"
] | Just leave out the constants in the `group by`. It isn't doing anything:
```
select "WEB" as src_cd, "1Hr" as Load_Flag,
from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(*)
from weblog
where year = 2015 and month = 04 and day = 17
group by from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy')
```
I don't think Hive allows column aliases in the `group by`, so you need to put in the entire expression or use a subquery/CTE. | There are two things.
1. Hive does not parse double quote or single quote in that way. So instead use back quote(`).
2. In group by clause either use the columnar position specifier or the direct functional translation. |
29,774,038 | Why is this query returning an error. I am trying to load the code for table as a constant string, the flag for data again a constant string, the time of insertion and the counts for a table. I thought, let me try and run the secelct before writing the inserts.
But for some reason, it fails listing column names from tables from where I am trying to get a count. All i need is two constant values, one date and one count. Tried by removing the groupby as well, throws another error.
**hive -e "select "WEB" as src\_cd, "1Hr" as Load\_Flag, from\_unixtime((unix\_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(\*)
from weblog
where year=2015 and month=04 and day=17
group by src\_cd, load\_flag, time
;**
"
OK
Time taken: 1.446 seconds
FAILED: SemanticException [Error 10004]: Line 4:9 Invalid table alias or column reference 'src\_cd': (possible column names are: clientip, authuser, sysdate, clfrequest.........(and so on) year, month, day) | 2015/04/21 | [
"https://Stackoverflow.com/questions/29774038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1725647/"
] | The double quotes on the literals is a problem. Here is a simpler version that I tested successfully:
```
hive -e "select 'WEB' , '1Hr' , from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(*) from weblog where year=2015 and month=04 and day=17 group by 1,2 , from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') ; "
``` | There are two things.
1. Hive does not parse double quote or single quote in that way. So instead use back quote(`).
2. In group by clause either use the columnar position specifier or the direct functional translation. |
43,123 | I'm getting aversion when someone do things that I don't like. This happens when a person do and not on natural things like rain. But It is hard to recorgnise it as aversion because that aversion is not towards a person. I just don't like certain actions that affect me (Only the things that affects me in someway). I don't want to hit someone or to hurt someone. So I always try to avoid such situations. But It is not always possible and that avoiding proccess makes suffering, makes doubts. So, How can I stop avoiding things ? How can I practise more acceptance ? How can I face anything without getting aversion? | 2020/11/03 | [
"https://buddhism.stackexchange.com/questions/43123",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/17744/"
] | Very good question, focused on real and useful problem.
Mind generates aversion when things go contrary to what it believes is "right". This belief is called "attachment". For example you believe that only certain weather is good and that it should be that same weather most of the time.
So the first technique is to remember this as soon as you feel aversion (basically, as soon as you feel emotionally disturbed): "what is my attachment in this case?". Once you identify the attachment you should think: "this attachment is a cause of suffering and an obstacle to Enlightenment, I shall let it go". And then you should make effort to let go of that attachment. "I shall not be attached to what I think is good weather. I should enjoy all weather as it is."
The second technique is to turn problems into blessings by changing your perspective. Here's how. Every time you have some unpleasant experience, tell to yourself: "this is actually a blessing because it gives me chance to practice Dharma and reach Enlightenment." Thinking like this will immediately turn a negative experience into a positive, happy event. Instead of experiencing suffering your mind will be elated.
Initially, you may tend to keep forgetting these instructions. If that happens you will react automatically as you always did. That's okay, keep practicing, keep trying to remember. (This is called mindfulness.)
Eventually you will reach a point when the problems themselves will serve as automatic reminders. At which point the game is won: what was previously triggering aversion will now trigger recollection of Dharma. | Not sure whether it is a Buddhist perspective, i would like to share few things which may be of some sense to you. Please excuse my immature writing skills.
There are two streams of thoughts/ideas/concepts/feelings we are put up with in any life situation. In present case, first stream is the feeling/idea of aversion. Please don't assume i am denouncing that there is nothing called aversion.
And the second stream is the idea of avoiding it.
If you can look at both of these streams and try to see how we play this never ending game of duality like, "this is how things are !! and this is how things should be", not just intellectually, even with a minute bit of intuitiveness if you can see yourself how the game is played, you are at the shore of great ocean called freedom.
Along with the instructions from Andrei try to see what i struggled to convey !!!.
All the best in your journey!!!. |
43,123 | I'm getting aversion when someone do things that I don't like. This happens when a person do and not on natural things like rain. But It is hard to recorgnise it as aversion because that aversion is not towards a person. I just don't like certain actions that affect me (Only the things that affects me in someway). I don't want to hit someone or to hurt someone. So I always try to avoid such situations. But It is not always possible and that avoiding proccess makes suffering, makes doubts. So, How can I stop avoiding things ? How can I practise more acceptance ? How can I face anything without getting aversion? | 2020/11/03 | [
"https://buddhism.stackexchange.com/questions/43123",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/17744/"
] | Very good question, focused on real and useful problem.
Mind generates aversion when things go contrary to what it believes is "right". This belief is called "attachment". For example you believe that only certain weather is good and that it should be that same weather most of the time.
So the first technique is to remember this as soon as you feel aversion (basically, as soon as you feel emotionally disturbed): "what is my attachment in this case?". Once you identify the attachment you should think: "this attachment is a cause of suffering and an obstacle to Enlightenment, I shall let it go". And then you should make effort to let go of that attachment. "I shall not be attached to what I think is good weather. I should enjoy all weather as it is."
The second technique is to turn problems into blessings by changing your perspective. Here's how. Every time you have some unpleasant experience, tell to yourself: "this is actually a blessing because it gives me chance to practice Dharma and reach Enlightenment." Thinking like this will immediately turn a negative experience into a positive, happy event. Instead of experiencing suffering your mind will be elated.
Initially, you may tend to keep forgetting these instructions. If that happens you will react automatically as you always did. That's okay, keep practicing, keep trying to remember. (This is called mindfulness.)
Eventually you will reach a point when the problems themselves will serve as automatic reminders. At which point the game is won: what was previously triggering aversion will now trigger recollection of Dharma. | You reflect aversion is harmful to yourself & others; it causes stress to yourself & can even lead to physical disease, such as cancer. If you get angry at the other person in the wrong way or place, you can lose your job, etc, or get suspended by politically correct authorities.
You also reflect the Buddha taught the foundational element of the world is "ignorance". People do bad things due to ignorance. The Buddha said only a relative few people in the world are free from ignorance or blindness.
If the bad action is closely related to your life, family, work, etc, you should learn to calmly talk to the other person about their behavior. |
43,123 | I'm getting aversion when someone do things that I don't like. This happens when a person do and not on natural things like rain. But It is hard to recorgnise it as aversion because that aversion is not towards a person. I just don't like certain actions that affect me (Only the things that affects me in someway). I don't want to hit someone or to hurt someone. So I always try to avoid such situations. But It is not always possible and that avoiding proccess makes suffering, makes doubts. So, How can I stop avoiding things ? How can I practise more acceptance ? How can I face anything without getting aversion? | 2020/11/03 | [
"https://buddhism.stackexchange.com/questions/43123",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/17744/"
] | Very good question, focused on real and useful problem.
Mind generates aversion when things go contrary to what it believes is "right". This belief is called "attachment". For example you believe that only certain weather is good and that it should be that same weather most of the time.
So the first technique is to remember this as soon as you feel aversion (basically, as soon as you feel emotionally disturbed): "what is my attachment in this case?". Once you identify the attachment you should think: "this attachment is a cause of suffering and an obstacle to Enlightenment, I shall let it go". And then you should make effort to let go of that attachment. "I shall not be attached to what I think is good weather. I should enjoy all weather as it is."
The second technique is to turn problems into blessings by changing your perspective. Here's how. Every time you have some unpleasant experience, tell to yourself: "this is actually a blessing because it gives me chance to practice Dharma and reach Enlightenment." Thinking like this will immediately turn a negative experience into a positive, happy event. Instead of experiencing suffering your mind will be elated.
Initially, you may tend to keep forgetting these instructions. If that happens you will react automatically as you always did. That's okay, keep practicing, keep trying to remember. (This is called mindfulness.)
Eventually you will reach a point when the problems themselves will serve as automatic reminders. At which point the game is won: what was previously triggering aversion will now trigger recollection of Dharma. | The rain is cold. With too much rain we can die of exposure. Knowing a body is cold, we can shield it or take it to a dry place. The thought "I am cold" or "I am averse to cold" can be replaced with the simple thought, "there is wet. there is cold." Further thoughts can address the situation with "this is bearable" or "this should be remedied to avoid cruelty."
Aversion is unskillful in its reactiveness. The escape from aversion is skillful consideration:
>
> [SN7.2:3.1](https://suttacentral.net/sn7.2/en/sujato#sn7.2:3.1): Someone who, when abused, harassed, and attacked, abuses, harasses, and attacks in return is said to eat the food and have a reaction to it.
>
>
> [SN7.2:3.2](https://suttacentral.net/sn7.2/en/sujato#sn7.2:3.2): But we neither eat your food nor do we have a reaction to it.
>
>
> |
43,123 | I'm getting aversion when someone do things that I don't like. This happens when a person do and not on natural things like rain. But It is hard to recorgnise it as aversion because that aversion is not towards a person. I just don't like certain actions that affect me (Only the things that affects me in someway). I don't want to hit someone or to hurt someone. So I always try to avoid such situations. But It is not always possible and that avoiding proccess makes suffering, makes doubts. So, How can I stop avoiding things ? How can I practise more acceptance ? How can I face anything without getting aversion? | 2020/11/03 | [
"https://buddhism.stackexchange.com/questions/43123",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/17744/"
] | Very good question, focused on real and useful problem.
Mind generates aversion when things go contrary to what it believes is "right". This belief is called "attachment". For example you believe that only certain weather is good and that it should be that same weather most of the time.
So the first technique is to remember this as soon as you feel aversion (basically, as soon as you feel emotionally disturbed): "what is my attachment in this case?". Once you identify the attachment you should think: "this attachment is a cause of suffering and an obstacle to Enlightenment, I shall let it go". And then you should make effort to let go of that attachment. "I shall not be attached to what I think is good weather. I should enjoy all weather as it is."
The second technique is to turn problems into blessings by changing your perspective. Here's how. Every time you have some unpleasant experience, tell to yourself: "this is actually a blessing because it gives me chance to practice Dharma and reach Enlightenment." Thinking like this will immediately turn a negative experience into a positive, happy event. Instead of experiencing suffering your mind will be elated.
Initially, you may tend to keep forgetting these instructions. If that happens you will react automatically as you always did. That's okay, keep practicing, keep trying to remember. (This is called mindfulness.)
Eventually you will reach a point when the problems themselves will serve as automatic reminders. At which point the game is won: what was previously triggering aversion will now trigger recollection of Dharma. | "Come, bite your botty" sometimes help quick if telling angy children, or to "force" them looking, or need to look, into a mirror. Try it, when ever aversion arises. |
31,532,828 | ```
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
public class LocationService extends Service {
private LocationDatabaseHelper mLocationDatabaseHelper;
private LocationModel mLocationModel;
private Date mDate;
private Handler mHandler = new Handler();
private Timer mTimer = null;
private int mCount = 0;
public static final long NOTIFY_INTERVAL = 30 * 1000;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
// cancel if already existed
if (mTimer != null) {
mTimer.cancel();
} else {
// recreate new
mTimer = new Timer();
}
mLocationModel = LocationModel.getInstance();
// schedule task
mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
}
@Override
public void onDestroy() {
mTimer.cancel();
}
private class TimeDisplayTimerTask extends TimerTask implements LocationListener {
@Override
public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
//I send message to draw map here
sendMessage();
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
TimeDisplayTimerTask.this);
}
});
}
@Override
public void onLocationChanged(Location location) {
// I get location and do work here
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
}
private void sendMessage() {
Intent intent = new Intent("my-event");
intent.putExtra("message", "data");
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
```
What I want is to get user location after every 30 seconds but this code does not work as I expected. It gets location very fast (I think every second).
I tried to get location this way because it can get my current location immediately after I start my app.I have tried getLastKnowLocation before, but it give me the last known location which is very far from where I am.
Please show me how fix this.Thank you! | 2015/07/21 | [
"https://Stackoverflow.com/questions/31532828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4209039/"
] | in requestLocationUpdates method second parameter is minimum time interval between location updates, in milliseconds, So you just need to do this:
```
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 0, TimeDisplayTimerTask.this);
``` | try using
```
TimerTask scanTask;
final Handler handler = new Handler();
mTimer = new Timer();
public void sendSMS(){
scanTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
//your method here which you want to call every 30 sec
}
});
}};
mTimer.schedule(scanTask, 30000, 30000);
}
``` |
31,532,828 | ```
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
public class LocationService extends Service {
private LocationDatabaseHelper mLocationDatabaseHelper;
private LocationModel mLocationModel;
private Date mDate;
private Handler mHandler = new Handler();
private Timer mTimer = null;
private int mCount = 0;
public static final long NOTIFY_INTERVAL = 30 * 1000;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
// cancel if already existed
if (mTimer != null) {
mTimer.cancel();
} else {
// recreate new
mTimer = new Timer();
}
mLocationModel = LocationModel.getInstance();
// schedule task
mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
}
@Override
public void onDestroy() {
mTimer.cancel();
}
private class TimeDisplayTimerTask extends TimerTask implements LocationListener {
@Override
public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
//I send message to draw map here
sendMessage();
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
TimeDisplayTimerTask.this);
}
});
}
@Override
public void onLocationChanged(Location location) {
// I get location and do work here
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
}
private void sendMessage() {
Intent intent = new Intent("my-event");
intent.putExtra("message", "data");
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
```
What I want is to get user location after every 30 seconds but this code does not work as I expected. It gets location very fast (I think every second).
I tried to get location this way because it can get my current location immediately after I start my app.I have tried getLastKnowLocation before, but it give me the last known location which is very far from where I am.
Please show me how fix this.Thank you! | 2015/07/21 | [
"https://Stackoverflow.com/questions/31532828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4209039/"
] | According to Android Developer Reference Documentation
[http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener)](http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String,%20long,%20float,%20android.location.LocationListener) "LocationManager")
```
public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener)
```
When registering for location updates the `LocationManager` is invoking `LocationListener` `onLocationChanged(Location)` method with latest `Location` object.
And the second parameter of `requestLocationUpdates` method is
`minTime` The minimum time interval between location updates, in milliseconds
This does not mean that you will get location updates every 30 seconds constantly, because if the location cannot be obtained you will not get updates also, if the location is not being changed you will again not get any updates.
Anyway, if you would like to get location updates every 30 seconds constantly, you can keep latest location and send it using your scheduler, while updating it when the `onLocationChanged` method is called. | try using
```
TimerTask scanTask;
final Handler handler = new Handler();
mTimer = new Timer();
public void sendSMS(){
scanTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
//your method here which you want to call every 30 sec
}
});
}};
mTimer.schedule(scanTask, 30000, 30000);
}
``` |
31,532,828 | ```
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
public class LocationService extends Service {
private LocationDatabaseHelper mLocationDatabaseHelper;
private LocationModel mLocationModel;
private Date mDate;
private Handler mHandler = new Handler();
private Timer mTimer = null;
private int mCount = 0;
public static final long NOTIFY_INTERVAL = 30 * 1000;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
// cancel if already existed
if (mTimer != null) {
mTimer.cancel();
} else {
// recreate new
mTimer = new Timer();
}
mLocationModel = LocationModel.getInstance();
// schedule task
mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
}
@Override
public void onDestroy() {
mTimer.cancel();
}
private class TimeDisplayTimerTask extends TimerTask implements LocationListener {
@Override
public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
//I send message to draw map here
sendMessage();
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
TimeDisplayTimerTask.this);
}
});
}
@Override
public void onLocationChanged(Location location) {
// I get location and do work here
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
}
private void sendMessage() {
Intent intent = new Intent("my-event");
intent.putExtra("message", "data");
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
```
What I want is to get user location after every 30 seconds but this code does not work as I expected. It gets location very fast (I think every second).
I tried to get location this way because it can get my current location immediately after I start my app.I have tried getLastKnowLocation before, but it give me the last known location which is very far from where I am.
Please show me how fix this.Thank you! | 2015/07/21 | [
"https://Stackoverflow.com/questions/31532828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4209039/"
] | in requestLocationUpdates method second parameter is minimum time interval between location updates, in milliseconds, So you just need to do this:
```
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 0, TimeDisplayTimerTask.this);
``` | According to Android Developer Reference Documentation
[http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener)](http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String,%20long,%20float,%20android.location.LocationListener) "LocationManager")
```
public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener)
```
When registering for location updates the `LocationManager` is invoking `LocationListener` `onLocationChanged(Location)` method with latest `Location` object.
And the second parameter of `requestLocationUpdates` method is
`minTime` The minimum time interval between location updates, in milliseconds
This does not mean that you will get location updates every 30 seconds constantly, because if the location cannot be obtained you will not get updates also, if the location is not being changed you will again not get any updates.
Anyway, if you would like to get location updates every 30 seconds constantly, you can keep latest location and send it using your scheduler, while updating it when the `onLocationChanged` method is called. |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | >
> What do her parents do?
>
>
>
Here the subject of the sentence is *her parents*. Because *her parents* is plural the auxiliary verb *DO* must agree with the plural noun phrase, so we need *do* and not *does*. The auxiliary verb *DO* is the first verb in the sentence. This is the verb that moves in front of the subject. It has no meaning, it just helps to make the sentence a question.
The verb after auxiliary *Do* is ***ALWAYS*** an infinitive. It can never be "Xing", "Xs", "Xed" or "to X".:
* Does he ~~eats~~?
* Did they ~~went~~?
* We don't ~~liking~~...
* They didn't ~~to come~~.
It should be:
* Does he eat?
* Did they go?
* We don't like ...
* They didn't come.
We can only have one auxiliary verb *DO* in a sentence.
However, the second *DO* in the Original Poster's example is the main verb. It's the lexical verb *DO*. It isn't an auxiliary. Because it comes after the auxiliary *DO*, it must be in the infinitive. The verb after *auxiliary* *DO* is ***ALWAYS*** an infinitive. Therefore the sentence must be like this:
* What do her parents do?
Hope this is helpful! | The correct question is, "What do her parents do?"
Since the word 'parents' is plural you would use 'do.'
Of course if you had the word 'parent' instead of 'parents'you would use does.
"What do her parents do?"
"What does her parent do?" |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | >
> What do her parents do?
>
>
>
Here the subject of the sentence is *her parents*. Because *her parents* is plural the auxiliary verb *DO* must agree with the plural noun phrase, so we need *do* and not *does*. The auxiliary verb *DO* is the first verb in the sentence. This is the verb that moves in front of the subject. It has no meaning, it just helps to make the sentence a question.
The verb after auxiliary *Do* is ***ALWAYS*** an infinitive. It can never be "Xing", "Xs", "Xed" or "to X".:
* Does he ~~eats~~?
* Did they ~~went~~?
* We don't ~~liking~~...
* They didn't ~~to come~~.
It should be:
* Does he eat?
* Did they go?
* We don't like ...
* They didn't come.
We can only have one auxiliary verb *DO* in a sentence.
However, the second *DO* in the Original Poster's example is the main verb. It's the lexical verb *DO*. It isn't an auxiliary. Because it comes after the auxiliary *DO*, it must be in the infinitive. The verb after *auxiliary* *DO* is ***ALWAYS*** an infinitive. Therefore the sentence must be like this:
* What do her parents do?
Hope this is helpful! | I saw you're struggling between "parent" and parents.
Let's start from your question. First, we need to see the subject here which is "parents", mean both of our mother and father, which means that this is a plural subject. For plural subject, you must use the root word. So,....
What does her parents do? (Wrong)
What do her parents do? (Right)
I saw that you ask Ste about the word "parent". The word "parent" here means one of the parent(father or mother), which is a singular subject. For singular subject, we must add -s, -es, -ies and more. So,.....
What do her parent do? (Wrong)
What does her parent do? (Right)
In conclusion, we must pay attention on the subject to see which is suitable for the sentence. |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | Araucaria answered the part about which is correct. Yes, it's "do", because the subject is "her parents", which is plural, and so requires a plural verb.
As to whether you can use the word "do" twice in a sentence: Sure you can. Maybe you're thinking of the common advice to avoid using the same word twice in a sentence, but this is a matter of style and not an absolute rule. I wouldn't write, "I bought a car from the car salesman at Friendly Car Lot" because the repeated use of the word "car" sounds awkward. But short, common words like "the" and "do" are used repeatedly all the time and no one really notices.
Note the two "do"s are serving different functions in the sentence. The first is part of the conventional way of phrasing a question about an action: "What do ..." The second is the specific action being asked about. Many other verbs would fit in its place. "What do her parents read?" "What do her parents eat?" etc. | The correct question is, "What do her parents do?"
Since the word 'parents' is plural you would use 'do.'
Of course if you had the word 'parent' instead of 'parents'you would use does.
"What do her parents do?"
"What does her parent do?" |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | To answer your specific question, *Can you have **does** and **do** in the same sentence like the first one?*, Yes, you can. You can have *do* twice, but not *does* twice. This is not a very helpful rule, however. The role that each word plays is very different in each case.
The first use of *do*/*does* is just a way to construct a question in English. It has nothing to do with the second use, which is what the question is really about. Try with a different verb in the question:
*What **do**/**does** her parents **cook**?*
Clearly, the word *cook* is irrelevant to whether we should use *do* or *does*. In reply to your hypothetical question, you could preserve the *do* to give a more assertive tone.
*Her parents **do** cook.*
*Her parents **do** do.*
Or in singular form:
*Her father **does** cook.*
*Her father **does** do.*
So there's nothing wrong with a sentence with multiple uses of *do*. | The correct question is, "What do her parents do?"
Since the word 'parents' is plural you would use 'do.'
Of course if you had the word 'parent' instead of 'parents'you would use does.
"What do her parents do?"
"What does her parent do?" |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | Araucaria answered the part about which is correct. Yes, it's "do", because the subject is "her parents", which is plural, and so requires a plural verb.
As to whether you can use the word "do" twice in a sentence: Sure you can. Maybe you're thinking of the common advice to avoid using the same word twice in a sentence, but this is a matter of style and not an absolute rule. I wouldn't write, "I bought a car from the car salesman at Friendly Car Lot" because the repeated use of the word "car" sounds awkward. But short, common words like "the" and "do" are used repeatedly all the time and no one really notices.
Note the two "do"s are serving different functions in the sentence. The first is part of the conventional way of phrasing a question about an action: "What do ..." The second is the specific action being asked about. Many other verbs would fit in its place. "What do her parents read?" "What do her parents eat?" etc. | I saw you're struggling between "parent" and parents.
Let's start from your question. First, we need to see the subject here which is "parents", mean both of our mother and father, which means that this is a plural subject. For plural subject, you must use the root word. So,....
What does her parents do? (Wrong)
What do her parents do? (Right)
I saw that you ask Ste about the word "parent". The word "parent" here means one of the parent(father or mother), which is a singular subject. For singular subject, we must add -s, -es, -ies and more. So,.....
What do her parent do? (Wrong)
What does her parent do? (Right)
In conclusion, we must pay attention on the subject to see which is suitable for the sentence. |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | To answer your specific question, *Can you have **does** and **do** in the same sentence like the first one?*, Yes, you can. You can have *do* twice, but not *does* twice. This is not a very helpful rule, however. The role that each word plays is very different in each case.
The first use of *do*/*does* is just a way to construct a question in English. It has nothing to do with the second use, which is what the question is really about. Try with a different verb in the question:
*What **do**/**does** her parents **cook**?*
Clearly, the word *cook* is irrelevant to whether we should use *do* or *does*. In reply to your hypothetical question, you could preserve the *do* to give a more assertive tone.
*Her parents **do** cook.*
*Her parents **do** do.*
Or in singular form:
*Her father **does** cook.*
*Her father **does** do.*
So there's nothing wrong with a sentence with multiple uses of *do*. | I saw you're struggling between "parent" and parents.
Let's start from your question. First, we need to see the subject here which is "parents", mean both of our mother and father, which means that this is a plural subject. For plural subject, you must use the root word. So,....
What does her parents do? (Wrong)
What do her parents do? (Right)
I saw that you ask Ste about the word "parent". The word "parent" here means one of the parent(father or mother), which is a singular subject. For singular subject, we must add -s, -es, -ies and more. So,.....
What do her parent do? (Wrong)
What does her parent do? (Right)
In conclusion, we must pay attention on the subject to see which is suitable for the sentence. |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | It's "do".
Think about the answer to the questions. "Her parents *does*" is incorrect, whereas
>
> Her parents do a mean chicken casserole.
>
>
>
Is natural sounding and correct. | The correct question is, "What do her parents do?"
Since the word 'parents' is plural you would use 'do.'
Of course if you had the word 'parent' instead of 'parents'you would use does.
"What do her parents do?"
"What does her parent do?" |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | To answer your specific question, *Can you have **does** and **do** in the same sentence like the first one?*, Yes, you can. You can have *do* twice, but not *does* twice. This is not a very helpful rule, however. The role that each word plays is very different in each case.
The first use of *do*/*does* is just a way to construct a question in English. It has nothing to do with the second use, which is what the question is really about. Try with a different verb in the question:
*What **do**/**does** her parents **cook**?*
Clearly, the word *cook* is irrelevant to whether we should use *do* or *does*. In reply to your hypothetical question, you could preserve the *do* to give a more assertive tone.
*Her parents **do** cook.*
*Her parents **do** do.*
Or in singular form:
*Her father **does** cook.*
*Her father **does** do.*
So there's nothing wrong with a sentence with multiple uses of *do*. | Araucaria answered the part about which is correct. Yes, it's "do", because the subject is "her parents", which is plural, and so requires a plural verb.
As to whether you can use the word "do" twice in a sentence: Sure you can. Maybe you're thinking of the common advice to avoid using the same word twice in a sentence, but this is a matter of style and not an absolute rule. I wouldn't write, "I bought a car from the car salesman at Friendly Car Lot" because the repeated use of the word "car" sounds awkward. But short, common words like "the" and "do" are used repeatedly all the time and no one really notices.
Note the two "do"s are serving different functions in the sentence. The first is part of the conventional way of phrasing a question about an action: "What do ..." The second is the specific action being asked about. Many other verbs would fit in its place. "What do her parents read?" "What do her parents eat?" etc. |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | It's "do".
Think about the answer to the questions. "Her parents *does*" is incorrect, whereas
>
> Her parents do a mean chicken casserole.
>
>
>
Is natural sounding and correct. | I saw you're struggling between "parent" and parents.
Let's start from your question. First, we need to see the subject here which is "parents", mean both of our mother and father, which means that this is a plural subject. For plural subject, you must use the root word. So,....
What does her parents do? (Wrong)
What do her parents do? (Right)
I saw that you ask Ste about the word "parent". The word "parent" here means one of the parent(father or mother), which is a singular subject. For singular subject, we must add -s, -es, -ies and more. So,.....
What do her parent do? (Wrong)
What does her parent do? (Right)
In conclusion, we must pay attention on the subject to see which is suitable for the sentence. |
41,614 | >
> * What does her parents do?
> * What do her parents do?
>
>
>
Which one is correct? Can you have *does* and *do* in the same sentence like the first one? Would it be incorrect because parents is plural so *do* must be used throughout? | 2014/12/10 | [
"https://ell.stackexchange.com/questions/41614",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | >
> What do her parents do?
>
>
>
Here the subject of the sentence is *her parents*. Because *her parents* is plural the auxiliary verb *DO* must agree with the plural noun phrase, so we need *do* and not *does*. The auxiliary verb *DO* is the first verb in the sentence. This is the verb that moves in front of the subject. It has no meaning, it just helps to make the sentence a question.
The verb after auxiliary *Do* is ***ALWAYS*** an infinitive. It can never be "Xing", "Xs", "Xed" or "to X".:
* Does he ~~eats~~?
* Did they ~~went~~?
* We don't ~~liking~~...
* They didn't ~~to come~~.
It should be:
* Does he eat?
* Did they go?
* We don't like ...
* They didn't come.
We can only have one auxiliary verb *DO* in a sentence.
However, the second *DO* in the Original Poster's example is the main verb. It's the lexical verb *DO*. It isn't an auxiliary. Because it comes after the auxiliary *DO*, it must be in the infinitive. The verb after *auxiliary* *DO* is ***ALWAYS*** an infinitive. Therefore the sentence must be like this:
* What do her parents do?
Hope this is helpful! | It's "do".
Think about the answer to the questions. "Her parents *does*" is incorrect, whereas
>
> Her parents do a mean chicken casserole.
>
>
>
Is natural sounding and correct. |
65,811,090 | My code worked fine but I changed some things and now it doesn't...
When I type `!ping` in the any channel it doesn't work.
* the bot is on the server and an admin.
* I changed the token down there
* here's the code: Does anyone see something??
```js
const Discord = require(`discord.js`),
client = new Discord.Client(),
prefix = `!`,
NO = `801418578069815297`
YES = `801418578300764180`
client.login(`bruh`)
client.once(`ready`, () => {
console.log(`online.`)
client.user.setPresence({
status: `online`,
game: {
name: `You`,
type: `WATCHING`
}
})
})
client.on(`message`, message =>{
if(!message.content.startsWith(prefix) || message.author.client) return
const args = message.content.slice(prefix.length).trim().split(` `)
const arg = args.toString().split(sep)
const command = args.shift().toLowerCase()
if(command === `ping`){
message.channel.send(`pong!`)
}
}
)
```
EDIT:
I put some log outputs in:
```js
const Discord = require("discord.js");
let client = new Discord.Client();
let prefix = "!";
console.log("discord, client, prefix defined.")
client.login("bruh");
console.log("logged in.")
client.once("ready", () => {
console.log("online.");
client.user.setPresence({
status: "online",
game: {
name: "You",
type: "WATCHING"
}
});
});
client.on("message", message =>{
console.log("message recieved")
if(!message.content.startsWith(prefix) || message.author.client) return;
console.log("it's a command.")
const args = message.content.slice(prefix.length).trim().split(" ");
console.log("splitted.")
const arg = args.toString().split(sep);
console.log("args defined.")
const command = args.shift().toLowerCase();
console.log("command defined.")
if(command === "ping") {
console.log("command identified:"+command)
message.channel.send("pong!");
console.log("message sent.")
}
});
```
The output is:
```
logged in.
online.
message recieved
```
I looked at that closely but still didn't find anything... | 2021/01/20 | [
"https://Stackoverflow.com/questions/65811090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14081166/"
] | The problem is, you're using commas where you should be using semicolons, so JS will be interepreting this strangely which will give you undefined behaviour. You should also preferably prefix your variables with `let`, `var` or `const` otherwise this could also lead to undefined behaviour. It is recommended to use `let` over `var`.
Try the code below to fix your problem:
```js
const Discord = require(`discord.js`);
let client = new Discord.Client();
let prefix = '!';
let NO = "801418578069815297";
let YES = "801418578300764180";
client.login(`bruh`);
client.once(`ready`, () => {
console.log(`online.`);
client.user.setPresence({
status: `online`,
game: {
name: `You`,
type: `WATCHING`
}
});
});
client.on(`message`, message =>{
if(!message.content.startsWith(prefix) || message.author.client) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if(command === `ping`) {
message.channel.send(`pong!`);
}
});
``` | I've had problems in the past with using wrong quotation marks, that might be the case for you here as well
Try to replace all your ` with ' or " |
65,811,090 | My code worked fine but I changed some things and now it doesn't...
When I type `!ping` in the any channel it doesn't work.
* the bot is on the server and an admin.
* I changed the token down there
* here's the code: Does anyone see something??
```js
const Discord = require(`discord.js`),
client = new Discord.Client(),
prefix = `!`,
NO = `801418578069815297`
YES = `801418578300764180`
client.login(`bruh`)
client.once(`ready`, () => {
console.log(`online.`)
client.user.setPresence({
status: `online`,
game: {
name: `You`,
type: `WATCHING`
}
})
})
client.on(`message`, message =>{
if(!message.content.startsWith(prefix) || message.author.client) return
const args = message.content.slice(prefix.length).trim().split(` `)
const arg = args.toString().split(sep)
const command = args.shift().toLowerCase()
if(command === `ping`){
message.channel.send(`pong!`)
}
}
)
```
EDIT:
I put some log outputs in:
```js
const Discord = require("discord.js");
let client = new Discord.Client();
let prefix = "!";
console.log("discord, client, prefix defined.")
client.login("bruh");
console.log("logged in.")
client.once("ready", () => {
console.log("online.");
client.user.setPresence({
status: "online",
game: {
name: "You",
type: "WATCHING"
}
});
});
client.on("message", message =>{
console.log("message recieved")
if(!message.content.startsWith(prefix) || message.author.client) return;
console.log("it's a command.")
const args = message.content.slice(prefix.length).trim().split(" ");
console.log("splitted.")
const arg = args.toString().split(sep);
console.log("args defined.")
const command = args.shift().toLowerCase();
console.log("command defined.")
if(command === "ping") {
console.log("command identified:"+command)
message.channel.send("pong!");
console.log("message sent.")
}
});
```
The output is:
```
logged in.
online.
message recieved
```
I looked at that closely but still didn't find anything... | 2021/01/20 | [
"https://Stackoverflow.com/questions/65811090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14081166/"
] | I've had problems in the past with using wrong quotation marks, that might be the case for you here as well
Try to replace all your ` with ' or " | I found a way to make it work. contact me on discord Moderpo#0172 if you wanna know the answer I'll have to find out what I did because I forgot lol |
65,811,090 | My code worked fine but I changed some things and now it doesn't...
When I type `!ping` in the any channel it doesn't work.
* the bot is on the server and an admin.
* I changed the token down there
* here's the code: Does anyone see something??
```js
const Discord = require(`discord.js`),
client = new Discord.Client(),
prefix = `!`,
NO = `801418578069815297`
YES = `801418578300764180`
client.login(`bruh`)
client.once(`ready`, () => {
console.log(`online.`)
client.user.setPresence({
status: `online`,
game: {
name: `You`,
type: `WATCHING`
}
})
})
client.on(`message`, message =>{
if(!message.content.startsWith(prefix) || message.author.client) return
const args = message.content.slice(prefix.length).trim().split(` `)
const arg = args.toString().split(sep)
const command = args.shift().toLowerCase()
if(command === `ping`){
message.channel.send(`pong!`)
}
}
)
```
EDIT:
I put some log outputs in:
```js
const Discord = require("discord.js");
let client = new Discord.Client();
let prefix = "!";
console.log("discord, client, prefix defined.")
client.login("bruh");
console.log("logged in.")
client.once("ready", () => {
console.log("online.");
client.user.setPresence({
status: "online",
game: {
name: "You",
type: "WATCHING"
}
});
});
client.on("message", message =>{
console.log("message recieved")
if(!message.content.startsWith(prefix) || message.author.client) return;
console.log("it's a command.")
const args = message.content.slice(prefix.length).trim().split(" ");
console.log("splitted.")
const arg = args.toString().split(sep);
console.log("args defined.")
const command = args.shift().toLowerCase();
console.log("command defined.")
if(command === "ping") {
console.log("command identified:"+command)
message.channel.send("pong!");
console.log("message sent.")
}
});
```
The output is:
```
logged in.
online.
message recieved
```
I looked at that closely but still didn't find anything... | 2021/01/20 | [
"https://Stackoverflow.com/questions/65811090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14081166/"
] | The problem is, you're using commas where you should be using semicolons, so JS will be interepreting this strangely which will give you undefined behaviour. You should also preferably prefix your variables with `let`, `var` or `const` otherwise this could also lead to undefined behaviour. It is recommended to use `let` over `var`.
Try the code below to fix your problem:
```js
const Discord = require(`discord.js`);
let client = new Discord.Client();
let prefix = '!';
let NO = "801418578069815297";
let YES = "801418578300764180";
client.login(`bruh`);
client.once(`ready`, () => {
console.log(`online.`);
client.user.setPresence({
status: `online`,
game: {
name: `You`,
type: `WATCHING`
}
});
});
client.on(`message`, message =>{
if(!message.content.startsWith(prefix) || message.author.client) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if(command === `ping`) {
message.channel.send(`pong!`);
}
});
``` | I found a way to make it work. contact me on discord Moderpo#0172 if you wanna know the answer I'll have to find out what I did because I forgot lol |
45,749,458 | I am trying to identify lines in a file that have either 4 integer or 2 double values. My regular expression is as below:
```
var match = new Regex(@"^(?<Values>(((\d+\s*){4})|(\d+\.\d+\s*){2}))$");
```
Sample of lines in the file getting parsed:
```
element 1 2
8 24 2 1 1
0 1 129
2 2 0 0
30.200001 1000.0000
208 0 0 0 0 0 0 0
.....
.....
```
Here, my regular expression matches correctly for above lines no 4 & 5. That's ok. But, it's also matching line no 3 (0 1 129). That's the problem for me. **Kindly suggest:**
1. Why my regular expression is matching line no 3.
2. Correct regular expression that matches exactly either 4 no. of integers or 2 no. of double values in a line. | 2017/08/18 | [
"https://Stackoverflow.com/questions/45749458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1762551/"
] | you directly store result into array. so your code should be like
```
$reader= \Excel::load(Input::file('import_file'))->toArray();
return redirect()->back()->with('reader', $reader);
``` | You can try this:
```
Excel::load(Input::file('import_file'), function ($reader) {
//Read and get excel rows...
var $arrExcelData = array();
$arrExcelData = $reader->toArray();
return redirect()->back()->with('arrExcelData', $arrExcelData);
});
```
**Render data:**
```
@if(!empty(Session::get('arrExcelData')))
@foreach(session()->get('arrExcelData') as $key=>$row)
print_r($row);
@endforeach
@endif
``` |
5,706,194 | I have inherited a .NET 4 VS2010 solution consisting of a WinForms app and a web service. I don't have access to a server that's running a copy of the web service but I have to run, debug, upgrade and test the project that accesses the web service as well as the web service code.
Later, I also want to quickly switch between a deployed web service and the code in my local project
What's the best strategy for changing the projects so I can make changes to both projects, test locally, deploy the web service then test against that? If I find issues, I want to switch back to "local" mode to debug.
Thanks team! | 2011/04/18 | [
"https://Stackoverflow.com/questions/5706194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686433/"
] | The easiest is to host the service locally in visual studio and change the service url to switch between the production service and the local one. You can automatically switch between the services by checking for Debug and Release modes using `#if` and `#else` directives.
You can also use the interface to provide a stub of the service. This will also make unit testing easier. | * Host your web service in IIS or using a local development web server (cassini)
* Use *app.config* to store the address of the web server
* Get the code to use the build the endpoint of the web service based on the app.config
* Change web server address in the web.config to switch between servers. |
62,653,757 | I integrated React Froala Editor to my website.
It's a simple project and I want to show paragraph select drop down.
But it doesn't work.
Is it related to version?
```
this.state = {
model: ``,
tags: [],
config: {
theme: 'foobar',
heightMax: 800,
height: 800,
toolbarButtons: ['bold', 'italic', 'underline', 'strikeThrough', 'fontFamily', 'fontSize', '|', 'paragraphStyle', 'paragraphFormat', 'align', 'undo', 'redo', 'html']
}
}
<FroalaEditorComponent
model={this.state.model}
onModelChange={this.onChange}
config={this.state.config}
/>
```
[](https://i.stack.imgur.com/rvJ1H.png) | 2020/06/30 | [
"https://Stackoverflow.com/questions/62653757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12067813/"
] | It seems that plugins are missing. Try to import plugins in your component:
```
import 'froala-editor/js/plugins.pkgd.min.js';
``` | The issue might be with the froala version you are using.
Please update Froala version using
>
> npm update froala-editor
>
>
>
All the options are available in the trail version too.
The same options worked for me with v3.1.0, check it below.
[Froala editor](https://i.stack.imgur.com/m9Elj.png) |
3,197,523 | I have a question about camera calibration. I've followed approach shown in a book Learning OpenCV for camera calibration process. But the calibrated(undistorted) image is worse than the original one.
Is it possible that my camera don't need calibration anymore?(means that the calibration is done by some driver or something like that)?
In fact it seems that the original image is not distorted at all. I know that it's not only about distortion, but what would you recommend me to do?
Thanks for every reply | 2010/07/07 | [
"https://Stackoverflow.com/questions/3197523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385826/"
] | The calibration cannot be done by the driver. If you're planning 3D reconstruction, then you cannot do without a calibration matrix. | Several things to check:
1. Have you verified the corner finder is working correctly (draw them on the calibration images and see if there are any outliers)?
2. Taken good calibration images? Visual inspection for blur, drastic perspective changes, etc.
3. Have good coverage of the image area with your calibration images? The calibration is done using a nonlinear optimizer which depends heavily on inputs. I usually will take one that has target taking up entire image, four with target taking up each quadrant, then another four with target taking up ~1/9 the area in each of the four corners. Note: bias to corners is often useful since lens distortion is usually bad at the corners and minimal in the middle.
Also, have you checked the other solved intrinsics such as focal length and thought about whether it makes sense? You can compare it to what the lens says. You can also estimate it manually by estimating FOV with placing known objects at the edge of FOV and looking at their configuration relative to the camera. |
3,198,494 | I am try in to get the ClientID of one of my server controls to appear in a Javascript in my aspx page.
Obviously I am going about it the wrong way, but my intent should be made clear in the following:
```
doSomethingFirst();
var hid = "<% Response.Write(HidingField.ClientID) %>";
doSomethingElse(hid);
```
Any advice?
Thanks. | 2010/07/07 | [
"https://Stackoverflow.com/questions/3198494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/316862/"
] | I'm doing a bit of guessing about your intent, so forgive me if I've guessed wrong, but I think this is what you're looking for:
```
doSomethingFirst();
var hid = document.getElementById('<%= HidingField.ClientID %>');
doSomethingElse(hid);
```
I assuming your intent is to get a reference to the DOM element represented by the client id so that you can then do some sort of javascript operation on that element. | Have you tried:
```
var hid = "<%= HidingField.ClientID %>";
```
making sure that "HidingField" is the ID of the server control? |
3,198,494 | I am try in to get the ClientID of one of my server controls to appear in a Javascript in my aspx page.
Obviously I am going about it the wrong way, but my intent should be made clear in the following:
```
doSomethingFirst();
var hid = "<% Response.Write(HidingField.ClientID) %>";
doSomethingElse(hid);
```
Any advice?
Thanks. | 2010/07/07 | [
"https://Stackoverflow.com/questions/3198494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/316862/"
] | I'm doing a bit of guessing about your intent, so forgive me if I've guessed wrong, but I think this is what you're looking for:
```
doSomethingFirst();
var hid = document.getElementById('<%= HidingField.ClientID %>');
doSomethingElse(hid);
```
I assuming your intent is to get a reference to the DOM element represented by the client id so that you can then do some sort of javascript operation on that element. | It was the stupid missing semicolon.
I apologized for wasting everyone's time. |
28,592,077 | >
> HTTP/1.1 has served the Web well for more than fifteen years, but its
> age is starting to show.
>
>
>
Can anybody explain what is the **main difference** between HTTP 1.1 and 2.0?
Is there any change in the transport protocol? | 2015/02/18 | [
"https://Stackoverflow.com/questions/28592077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | HTTP/2 supports queries multiplexing, headers compression, priority and more intelligent packet streaming management. This results in reduced latency and accelerates content download on modern web pages.
[More details here.](https://daniel.haxx.se/http2/) | HTTP 2.0 is a **binary** protocol that multiplexes numerous streams going over a single (normally TLS-encrypted) TCP connection.
The contents of each stream are HTTP 1.1 requests and responses, just encoded and packed up differently. HTTP2 adds a number of features to manage the streams, but leaves old semantics untouched. |
33,910,676 | Problem
=======
On one Form I have a Multilist where each item has a "name" and an "ID number". I'd like my app to do the following:
After I select an item, it will go to the "profile" screen and then it will display all the information about that person, based on the "ID number" that I will get from the Storage.
Question
========
How can I get the information from the Multilist item I just clicked?
And then, how can I save that info so I can use it in the "before show (Profile screen)" so I can retrieve the info from Storage.
Thnaks | 2015/11/25 | [
"https://Stackoverflow.com/questions/33910676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602982/"
] | I will suggest you use a MultiButton instead of Multilist, then you can add actionEvent to individual element.
You can save individual element into static variables in the actionEvent and use it in the before show of your profile form. For example:
Declare this globally:
```
private static String UserName = "";
```
And initialize it as follows:
```
Container content = new Container(new BoxLayout(BoxLayout.Y_AXIS));
content.setScrollableY(true);
for (int i = 0; i < YourItemsLength; i++) {
final MultiButton mb = new MultiButton("Blablabla");
mb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
UserName = mb.getTextLine1(); // or anything you want it to be
//show the profile form here
}
});
content.addComponent(mb);
}
content.revalidate();
```
In the beforeShow() of profile, call UserName and you should be able to use the value. Do the same for all the values you need. | I totally agree with Diamonds answer and I think that's the best/simplest way to create a list of items. However, if you do still want to use `MultiList` you need to implement a `ListModel` or use `DefaultListModel`.
From your question I assume you just used the `MultiList` and filled out the values?
In that case when there is an action event on the list you can just get the instance of the list the invoke `Map m = (Map)myList.getSelectedItem();`
The map should return key/value pairs containing your data. You can have hidden keys within that data simple by naming them differently from rendererd list elements so you can have something like "id" as the key. |
50,314 | I wanna set 4 different wallpapers in my 4 workspaces by setting in CCMS (wallpaper plugin).
It just only work if show\_desktop (gconf-editor->apps/nautilus/preference) is unchecked.
But after that I can not right-click on my desktop anymore.
Is it possible to make wallpaper-plugin work without "disable" my desktop? | 2011/06/24 | [
"https://askubuntu.com/questions/50314",
"https://askubuntu.com",
"https://askubuntu.com/users/20503/"
] | No.
And to make it possible to save my answer ("no" is a bit short) this a possible workaround that changes your actions to open a file on the desktop from 1 move with the mouse and 1 click on an icon to 2 clicks on icons and 1 mouse move:
You need to use places>desktop to get to your desktop icons.
So you can add in an option to show desktop from the launcher. Rightclick desktop (w/o compiz wallpaper active ;) ) and choose 'add launcher'. See image...

(command `nautilus "/home/your_username/Desktop"`)
Add in an icon, move this launcher from desktop to `~/.local/share/applications` and pin this to the launcher.
 | i don't know if this helps or not, but i wanted to do the same thing. i have 3 different monitors (running via xinerama), and i want a different background on each one. i also want it to rotate every once in a while.
the problem is that a lot of the software out there needs randr to run. but we can get around that. i could never get anything to work properly as far as wallpapers go.
so i wrote a simple bash script that handles all of this for me. basically, i have a folder of images that i want to use for each background. then i use imagemagick to stitch 3 pics together from that directory, and then i can display that new single pic as a spanned pic on the desktop. so it is really one actual png file, but it appears as each desktop has its own background. the imagemagick portion doesn't hit your system hard. but for some reason, the call to gsettings will slow your box down for 10 seconds or so.
beware that this script could really be beefed up. it doesn't check to make sure that files are proper images (jpgs, pngs...), and makes a lot of assumptions.
here is the script i use:
```
#this is the directory that holds all of the pics you want to show
PIC_DIR=/home/myuser/Pictures/desktop
# We want indexes 1 and over
FLOOR=0
#We don't want to exceed the number of pics we have (upper bound)
RANGE=$(ls $PIC_DIR | wc -l)
#Initialize this
file_number=0
#Function to generate a random number using our bounds
function generate_random_number()
{
file_number=0
while [ "$file_number" -le $FLOOR ]
do
file_number=$RANDOM
let "file_number %= $RANGE"
done
}
# so we get a number that will represent the picture we want to use.
# We get the size of the directory, and generate a random number
# between 0 and that size. Then, we get the file that
# corresponds to that number.
generate_random_number
# We have to add a 'p' to the file number to get it to
# work with sed, so we add it here
file_number=${file_number}"p"
#get the file name based upon the file number
FILENAME1=$(ls $PIC_DIR | sed -n "$file_number")
#Do it all over again for the second pic
generate_random_number
file_number=${file_number}"p"
FILENAME2=$(ls $PIC_DIR | sed -n "$file_number")
#Do it all over again for the third pic
generate_random_number
file_number=${file_number}"p"
FILENAME3=$(ls $PIC_DIR | sed -n "$file_number")
# Here is where we will stitch the pics together.
# My monitors are turned vertically, so their resolution is
# 1050x1680. We will always reuse the same name for the
# output file, so that we aren't creating hundreds of files.
${montage -geometry 1050x1680+0+0 ${PIC_DIR}/${FILENAME1} ${PIC_DIR}/${FILENAME2} ${PIC_DIR}/${FILENAME3} ${PIC_DIR}/out.png
# Set the wallpaper.
$(/usr/bin/gsettings set set org.gnome.desktop.background picture-uri file:///${PIC_DIR}/out.png >> /dev/null)
# Set the image to span
$(/usr/bin/gsettings set org.gnome.desktop.background picture-options "spanned" >> /dev/null)
```
so you can call this just via the command line, or you can set it up to be called via cron. in that case, use "crontab -e" to open your cron. this must be called in a special way though. say you want your background to change once an hour, you need to do this:
```
0 * * * * DISPLAY=:0.0 /home/myuser/path/to/my/script >> /dev/null
```
the key is to make sure to include the DISPLAY remark.
the beauty of this is that it runs in gnome2 or compiz, and is really easy to do. i don't know why the xorg process takes such a hit when you call the gsettings command, but it does, and it will lag your system for about 10 seconds. but this can be used on pretty much any gnome-based system. |
6,375,516 | Ignore the .bat extensions, just a habit from the old dos batch file days.
I have 2 simple shell scripts. I want to pass a filename with spaces (some file with spaces.ext) from little.bat to big.bat, as you can see below. It won't let me put the filename in single or double quotes.
First one called little.bat:
```
./big.bat some file with spaces.ext
```
Second one called big.bat:
>
> cat template.iss | sed
> "s/replace123/$1/g" | sed
> "s/replace456/$1/g" > $1.iss
>
>
> | 2011/06/16 | [
"https://Stackoverflow.com/questions/6375516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/710624/"
] | Escape spaces with another sed command.
you can fine details about the idea here:
[Escape a string for a sed replace pattern](https://stackoverflow.com/questions/407523/bash-escape-a-string-for-sed-search-pattern) | You can escape each space with a backslash:
```
some\ file\ with\ spaces.ext
```
That way, each space is passed on *quoted*, and the shell won't parse the space to mean "this is the end of one argument and the start of another". |
75,925 | I implemented an application run on Raspberry Pi 3 using Android Things. This application will be able to play `rtsp` video and output to screen via HDMI port. But the audio is not working with jack 3.5mm. Below is my code:
```
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = findViewById(R.id.video_view);
videoView.setVideoPath("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");
videoView.start();
}
}
```
**How can I fix it?** | 2017/12/01 | [
"https://raspberrypi.stackexchange.com/questions/75925",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/77116/"
] | The problem is that if you connect the hdmi first, it will use the hdmi as the audio output.
Try connecting the audio jack first. This solved it for me. | If you cannot get the 3.5" jack working, Android Things also supports USB audio as well. A viable solution might be to just get a $7 USB audio card that has 3.5mm jacks on it, something like this:
[](https://i.stack.imgur.com/6Z7hn.jpg)
I found a good question/answer related to this in [another post HERE](https://raspberrypi.stackexchange.com/questions/66815/how-can-i-get-audio-ultrasonic-nearby-api-working-with-android-things).
Good Luck, and please write back here to let us know what you found! |
75,925 | I implemented an application run on Raspberry Pi 3 using Android Things. This application will be able to play `rtsp` video and output to screen via HDMI port. But the audio is not working with jack 3.5mm. Below is my code:
```
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = findViewById(R.id.video_view);
videoView.setVideoPath("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");
videoView.start();
}
}
```
**How can I fix it?** | 2017/12/01 | [
"https://raspberrypi.stackexchange.com/questions/75925",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/77116/"
] | The problem is that if you connect the hdmi first, it will use the hdmi as the audio output.
Try connecting the audio jack first. This solved it for me. | Add this line in `config.txt` file:
```
hdmi_ignore_edid_audio=1
``` |
60,336,447 | I have custom hash function for unordered\_set of vectors< int >:
```
struct VectorHash {
int operator()(const vector<int> &V) const {
int hsh=V[0] + V[1];
return hash<int>()(hsh);
}};
```
And for two such vectors I have the same hash equal 3:
```
vector<int> v1{2,1};
vector<int> v2{1,2};
```
But when I try to insert first vector v1 in unordered\_set, and then check if I have the same vector by hash as v2 in my unordered\_set I get false:
```
std::unordered_set<std::vector<int>, VectorHash> mySet;
mySet.insert(v1);
if(mySet.find(v2) == mySet.end())
cout << "didn't find" << endl;
Output: "didn't find"
```
I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, `find` method should return true, when I try to find v2. But it is not the case.
Could anyone explain me what is wrong in my reasoning? | 2020/02/21 | [
"https://Stackoverflow.com/questions/60336447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12937832/"
] | Hash isn't everything, what you're seeing here, is a collision.
Both `std::vector<int>` have the same hash value here, but after hash is calculated, `std::unordered_map` will actually actually check for equality of elements using `operator==` to check for equality of elements, which fails in this case, and fails to find the element.
Collisions are a normal thing in HashMaps, not much you can do here without providing custom `operator==`. | >
> I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, find method should return true, when I try to find v2.
>
>
>
That assumption is incorrect, same hash doesn't mean objects are equal.
[`unordered_map`](https://en.cppreference.com/w/cpp/container/unordered_map) uses the equality predicate to determine key equality (by default `std::equal_to`). |
60,336,447 | I have custom hash function for unordered\_set of vectors< int >:
```
struct VectorHash {
int operator()(const vector<int> &V) const {
int hsh=V[0] + V[1];
return hash<int>()(hsh);
}};
```
And for two such vectors I have the same hash equal 3:
```
vector<int> v1{2,1};
vector<int> v2{1,2};
```
But when I try to insert first vector v1 in unordered\_set, and then check if I have the same vector by hash as v2 in my unordered\_set I get false:
```
std::unordered_set<std::vector<int>, VectorHash> mySet;
mySet.insert(v1);
if(mySet.find(v2) == mySet.end())
cout << "didn't find" << endl;
Output: "didn't find"
```
I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, `find` method should return true, when I try to find v2. But it is not the case.
Could anyone explain me what is wrong in my reasoning? | 2020/02/21 | [
"https://Stackoverflow.com/questions/60336447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12937832/"
] | >
> I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, find method should return true, when I try to find v2.
>
>
>
That assumption is incorrect, same hash doesn't mean objects are equal.
[`unordered_map`](https://en.cppreference.com/w/cpp/container/unordered_map) uses the equality predicate to determine key equality (by default `std::equal_to`). | If you happen to want unique identifiers but not automatically compare values, you could use an `(unordered_)map<int, vector<int>>` and use that VectorHash function to generate the int key:
```
unordered_map<int, vector<int>> map;
int key=V[0] + V[1]
map[key] = V;
``` |
60,336,447 | I have custom hash function for unordered\_set of vectors< int >:
```
struct VectorHash {
int operator()(const vector<int> &V) const {
int hsh=V[0] + V[1];
return hash<int>()(hsh);
}};
```
And for two such vectors I have the same hash equal 3:
```
vector<int> v1{2,1};
vector<int> v2{1,2};
```
But when I try to insert first vector v1 in unordered\_set, and then check if I have the same vector by hash as v2 in my unordered\_set I get false:
```
std::unordered_set<std::vector<int>, VectorHash> mySet;
mySet.insert(v1);
if(mySet.find(v2) == mySet.end())
cout << "didn't find" << endl;
Output: "didn't find"
```
I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, `find` method should return true, when I try to find v2. But it is not the case.
Could anyone explain me what is wrong in my reasoning? | 2020/02/21 | [
"https://Stackoverflow.com/questions/60336447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12937832/"
] | >
> I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, find method should return true, when I try to find v2.
>
>
>
That assumption is incorrect, same hash doesn't mean objects are equal.
[`unordered_map`](https://en.cppreference.com/w/cpp/container/unordered_map) uses the equality predicate to determine key equality (by default `std::equal_to`). | you need to provide a comparator to the `unordered_set` as well if you want the two elements to match, you can do something along the lines of this:
```
struct VectorComparator {
bool operator()(const std::vector<int> & obj1, const std::vector<int> & obj2) const
{
if ((obj1[0] + obj1[1]) == (obj2[0] + obj2[1]))
return true;
return false;
}
};
```
and create your `unordered_set` like this
`std::unordered_set<std::vector<int>, VectorHash, VectorComparator> mySet;`
Then you should get the result you are expecting |
60,336,447 | I have custom hash function for unordered\_set of vectors< int >:
```
struct VectorHash {
int operator()(const vector<int> &V) const {
int hsh=V[0] + V[1];
return hash<int>()(hsh);
}};
```
And for two such vectors I have the same hash equal 3:
```
vector<int> v1{2,1};
vector<int> v2{1,2};
```
But when I try to insert first vector v1 in unordered\_set, and then check if I have the same vector by hash as v2 in my unordered\_set I get false:
```
std::unordered_set<std::vector<int>, VectorHash> mySet;
mySet.insert(v1);
if(mySet.find(v2) == mySet.end())
cout << "didn't find" << endl;
Output: "didn't find"
```
I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, `find` method should return true, when I try to find v2. But it is not the case.
Could anyone explain me what is wrong in my reasoning? | 2020/02/21 | [
"https://Stackoverflow.com/questions/60336447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12937832/"
] | Hash isn't everything, what you're seeing here, is a collision.
Both `std::vector<int>` have the same hash value here, but after hash is calculated, `std::unordered_map` will actually actually check for equality of elements using `operator==` to check for equality of elements, which fails in this case, and fails to find the element.
Collisions are a normal thing in HashMaps, not much you can do here without providing custom `operator==`. | If you happen to want unique identifiers but not automatically compare values, you could use an `(unordered_)map<int, vector<int>>` and use that VectorHash function to generate the int key:
```
unordered_map<int, vector<int>> map;
int key=V[0] + V[1]
map[key] = V;
``` |
60,336,447 | I have custom hash function for unordered\_set of vectors< int >:
```
struct VectorHash {
int operator()(const vector<int> &V) const {
int hsh=V[0] + V[1];
return hash<int>()(hsh);
}};
```
And for two such vectors I have the same hash equal 3:
```
vector<int> v1{2,1};
vector<int> v2{1,2};
```
But when I try to insert first vector v1 in unordered\_set, and then check if I have the same vector by hash as v2 in my unordered\_set I get false:
```
std::unordered_set<std::vector<int>, VectorHash> mySet;
mySet.insert(v1);
if(mySet.find(v2) == mySet.end())
cout << "didn't find" << endl;
Output: "didn't find"
```
I assume that if two elements in unordered\_set have the same hash then if I have v1 in my unordered\_set, `find` method should return true, when I try to find v2. But it is not the case.
Could anyone explain me what is wrong in my reasoning? | 2020/02/21 | [
"https://Stackoverflow.com/questions/60336447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12937832/"
] | Hash isn't everything, what you're seeing here, is a collision.
Both `std::vector<int>` have the same hash value here, but after hash is calculated, `std::unordered_map` will actually actually check for equality of elements using `operator==` to check for equality of elements, which fails in this case, and fails to find the element.
Collisions are a normal thing in HashMaps, not much you can do here without providing custom `operator==`. | you need to provide a comparator to the `unordered_set` as well if you want the two elements to match, you can do something along the lines of this:
```
struct VectorComparator {
bool operator()(const std::vector<int> & obj1, const std::vector<int> & obj2) const
{
if ((obj1[0] + obj1[1]) == (obj2[0] + obj2[1]))
return true;
return false;
}
};
```
and create your `unordered_set` like this
`std::unordered_set<std::vector<int>, VectorHash, VectorComparator> mySet;`
Then you should get the result you are expecting |
38,990,345 | I hava a javaagent Jar `simpleAgent.jar`. I used it to redifine classes in it and I cached some classes to avoid redifine
```
public class Premain {
private static Instrumentation instrumentation;
private static final Map<String, Class> allLoadClassesMap = new ConcurrentHashMap<>();
public static void premain(String agentArgs, Instrumentation inst) {
instrumentation = inst;
cacheAllLoadedClasses("com.example");
}
public static void cacheAllLoadedClasses(String prfixName) {
try {
Class[] allLoadClasses = instrumentation.getAllLoadedClasses();
for (Class loadedClass : allLoadClasses) {
if (loadedClass.getName().startsWith(prfixName)) {
allLoadClassesMap.put(loadedClass.getName(), loadedClass);
}
}
logger.warn("Loaded Class Count " + allLoadClassesMap.size());
} catch (Exception e) {
logger.error("", e);
}
}
}
```
I have three different application `app1.jar`, `app2.jar`, `app3.jar`, so when I start the three application can I use the same agent jar? Eg.:
```
java -javaagent:simpleAgent.jar -jar app1.jar
java -javaagent:simpleAgent.jar -jar app2.jar
java -javaagent:simpleAgent.jar -jar app3.jar
```
I don't know the javaagent's implementation, so I was scared that using the same javaagent can trigger in app1 or app2 or app3 crash. | 2016/08/17 | [
"https://Stackoverflow.com/questions/38990345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6704318/"
] | Each JVM instance is separate and does not "know" about other JVMs unless you do something in application level. So, generally the answer is "yes, you can use the same jar either javaagent or not for as many JVM instances as you want." | A Javaaget is treated by the VM similarly to jar files on the class path. Those files are read only, all state is contained in the running VM such that they are safely shared among multiple processes. |
71,906,448 | I need to hide or to make some field completely hidden in some field in the item class. i have tried using jquery, javascript and html but the result is not too good.
```
<div class="item">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number:</label>: <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label for="id_idplan">Idplan:</label>: <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label for="id_user">User:</label>:
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
Am trying to make some fields invisible or completely hidden with html but the result only hide only the input field or text property while the name of the html element still shows on the form.
I want those field or element mark hidden to be completely hidden or completely invisible.
users should not be able to know that there was supposed to be an item there.
```
check my code
```
i tried using javascript and only the input field is hidden while the form name and size and other still display
<script type="text/javascript">
var net = document.getElementById('id_idnetwork');
net.style.display = 'hidden';
</script>
```
I tried using html but only the input is hidden while the name and other property shows
am using html id to get this field.
```
#id_user {
position: absolute;
display: none
}
#id_idplan {
position: absolute;
display: none
}
``` | 2022/04/18 | [
"https://Stackoverflow.com/questions/71906448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18375924/"
] | You can hide siblings:
```css
[for="id_user"],
[for="id_user"] ~ * /* hide siblings */
{
position: absolute;
display: none
}
[for="id_idplan"],
[for="id_idplan"] ~ * /* hide siblings */
{
position: absolute;
display: none
}
```
```html
<div class="item">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number:</label> <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label for="id_idplan">Idplan:</label> <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label for="id_user">User:</label>
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
```
Or much better way is to add additional classes to the `.item` elements, so you can control it instead:
```css
.item4 {
position: absolute;
display: none;
}
.item3 {
position: absolute;
display: none;
}
```
```html
<div class="item item1">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item item2">
<label for="id_ported_number">Ported number:</label>: <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item item3">
<label for="id_idplan">Idplan:</label>: <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item item4">
<label for="id_user">User:</label>:
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
``` | Since the release of [HTML5](https://html.spec.whatwg.org/multipage/) one can now simply do:
```html
<div hidden>This div is hidden</div>
```
Note: This is not [supported](https://caniuse.com/hidden) by some old browsers, most notably IE < 11.
Hidden Attribute Documentation ([MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden),[W3C](https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute)) |
71,906,448 | I need to hide or to make some field completely hidden in some field in the item class. i have tried using jquery, javascript and html but the result is not too good.
```
<div class="item">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number:</label>: <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label for="id_idplan">Idplan:</label>: <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label for="id_user">User:</label>:
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
Am trying to make some fields invisible or completely hidden with html but the result only hide only the input field or text property while the name of the html element still shows on the form.
I want those field or element mark hidden to be completely hidden or completely invisible.
users should not be able to know that there was supposed to be an item there.
```
check my code
```
i tried using javascript and only the input field is hidden while the form name and size and other still display
<script type="text/javascript">
var net = document.getElementById('id_idnetwork');
net.style.display = 'hidden';
</script>
```
I tried using html but only the input is hidden while the name and other property shows
am using html id to get this field.
```
#id_user {
position: absolute;
display: none
}
#id_idplan {
position: absolute;
display: none
}
``` | 2022/04/18 | [
"https://Stackoverflow.com/questions/71906448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18375924/"
] | Maybe like this??
```css
#id_user {
position: absolute;
display: none
}
#id_idplan {
position: absolute;
display: none
}
label#hide_user {display:none;}
select#hide_user {display:none;}
```
```html
<div class="item">
<label for="id_mobile_number">Mobile number::</label> <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number::</label> <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label id="hide_user" for="id_idplan">Idplan::</label> <select id="hide_user" name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label id="hide_user" for="id_user">User:: </label>
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
``` | Since the release of [HTML5](https://html.spec.whatwg.org/multipage/) one can now simply do:
```html
<div hidden>This div is hidden</div>
```
Note: This is not [supported](https://caniuse.com/hidden) by some old browsers, most notably IE < 11.
Hidden Attribute Documentation ([MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden),[W3C](https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute)) |
71,906,448 | I need to hide or to make some field completely hidden in some field in the item class. i have tried using jquery, javascript and html but the result is not too good.
```
<div class="item">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number:</label>: <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label for="id_idplan">Idplan:</label>: <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label for="id_user">User:</label>:
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
Am trying to make some fields invisible or completely hidden with html but the result only hide only the input field or text property while the name of the html element still shows on the form.
I want those field or element mark hidden to be completely hidden or completely invisible.
users should not be able to know that there was supposed to be an item there.
```
check my code
```
i tried using javascript and only the input field is hidden while the form name and size and other still display
<script type="text/javascript">
var net = document.getElementById('id_idnetwork');
net.style.display = 'hidden';
</script>
```
I tried using html but only the input is hidden while the name and other property shows
am using html id to get this field.
```
#id_user {
position: absolute;
display: none
}
#id_idplan {
position: absolute;
display: none
}
``` | 2022/04/18 | [
"https://Stackoverflow.com/questions/71906448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18375924/"
] | You can hide siblings:
```css
[for="id_user"],
[for="id_user"] ~ * /* hide siblings */
{
position: absolute;
display: none
}
[for="id_idplan"],
[for="id_idplan"] ~ * /* hide siblings */
{
position: absolute;
display: none
}
```
```html
<div class="item">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number:</label> <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label for="id_idplan">Idplan:</label> <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label for="id_user">User:</label>
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
```
Or much better way is to add additional classes to the `.item` elements, so you can control it instead:
```css
.item4 {
position: absolute;
display: none;
}
.item3 {
position: absolute;
display: none;
}
```
```html
<div class="item item1">
<label for="id_mobile_number">Mobile number:</label>: <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item item2">
<label for="id_ported_number">Ported number:</label>: <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item item3">
<label for="id_idplan">Idplan:</label>: <select name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item item4">
<label for="id_user">User:</label>:
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
``` | Maybe like this??
```css
#id_user {
position: absolute;
display: none
}
#id_idplan {
position: absolute;
display: none
}
label#hide_user {display:none;}
select#hide_user {display:none;}
```
```html
<div class="item">
<label for="id_mobile_number">Mobile number::</label> <input type="text" name="mobile_number"
maxlength="12" required id="id_mobile_number">
</div>
<div class="item">
<label for="id_ported_number">Ported number::</label> <input type="text" name="ported_number"
value="true" maxlength="100" id="id_ported_number">
</div>
<div class="item">
<label id="hide_user" for="id_idplan">Idplan::</label> <select id="hide_user" name="idplan" required id="id_idplan">
<option value="" selected>---------</option>
<option value="1">500 at 150 for 1month</option>
</select>
</div>
<div class="item">
<label id="hide_user" for="id_user">User:: </label>
<select name="user" id="id_user">
<option value="">---------</option>
<option value="2">[email protected]</option>
<option value="3">[email protected]</option>
</select>
</div>
``` |
31,451,935 | While writing interface in java 8 i noticed behavior that i was able to define method in interface without any compile time error.
```
public interface AdvanceMediaPlayer {
public static void playVlc(String fileName) {
System.out.println("play VLC");
}
public abstract void playMp4(String fileName);
}
```
Please explain why is this happening. As far as I am aware we cant implement methods inside interfaces. | 2015/07/16 | [
"https://Stackoverflow.com/questions/31451935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2828006/"
] | Java8 provides the ability to create default method implementations:
<https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html> | >
> `Java 8` introduces `“Default Method”`new feature, which allows
> developer to add new methods to the interfaces without breaking the
> existing implementation of these interface. It provides flexibility to
> allow interface define implementation which will use as default in the
> situation where a concrete class fails to provide an implementation
> for that method.
>
>
>
Refer [this](https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html) for more. |
31,451,935 | While writing interface in java 8 i noticed behavior that i was able to define method in interface without any compile time error.
```
public interface AdvanceMediaPlayer {
public static void playVlc(String fileName) {
System.out.println("play VLC");
}
public abstract void playMp4(String fileName);
}
```
Please explain why is this happening. As far as I am aware we cant implement methods inside interfaces. | 2015/07/16 | [
"https://Stackoverflow.com/questions/31451935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2828006/"
] | Java8 provides the ability to create default method implementations:
<https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html> | Java 8 makes you able to declare static and default methods in interfaces.
A static interface method can not be overridden by the implementing class. It can only be called like this:
```
AdvanceMediaPlayer.playVlc(fileName);
```
A default method can be overridden by the implementing class. It is declared with the `default` keyword. |
308,829 | I have often heard developers mention that Java can't "*do [Real Time](https://en.wikipedia.org/wiki/Real-time_computing)*", meaning a Java app running on Linux cannot meet the requirements of a deterministic real-time system, such as something running on RIOT-OS, etc.
I am trying to understand *why*. My [SWAG](https://en.wikipedia.org/wiki/Scientific_Wild-Ass_Guess) tells me that this is probably largely due to Java's Garbage Collector, which can run at any time and totally pause the system. And although there are so-called "pauseless GCs" out there, I don't necessarily believe their advertising, and also don't have $80K-per-JVM-instance to fork over for a hobby project!
I was also reading [this article about running drone software on Linux](http://owenson.me/build-your-own-quadcopter-autopilot/). In that article, the author describes a scenario where Linux almost caused his drone to crash into his car:
>
> I learnt a hard lesson after choosing to do the low level control loop (PIDs) on the Pi - trying to be clever I decided to put a log write in the middle of the loop for debugging - the quad initially flied fine but then Linux decided to take 2seconds to write one log entry and the quad almost crashed into my car!
>
>
>
Now although that author wrote his drone software in C++, I would imagine a Java app running on Linux could very well suffer the same fate.
According to Wikipedia:
>
> A system is said to be real-time if the total correctness of an operation depends not only upon its logical correctness, but also upon the time in which it is performed.
>
>
>
So to me, this means "*You don't have real-time if total correctness requires logical correctness and timeliness.*"
Let's pretend I've written a Java app to be super performant, and that I've "squeezed the lemon" so to speak, and it couldn't reasonably be written (in Java) to be any faster.
All in all, my question is: I'm looking for someone to explain to me all/most of the reasons for why a Java app running n Linux would fail to be a "real time app". **Meaning, what are all the categories of things on a Java/Linux stack that prevent it from "being timely", and therefore, from being "*totally correct*"?** As mentioned, it looks like GC and Linux log-flushing can pause execution, but I'm sure there are more things outside the Java app itself that would cause bad timing/performance, and cause it to meet hard deadline constraints. **What are they?** | 2016/01/30 | [
"https://softwareengineering.stackexchange.com/questions/308829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/154753/"
] | A software is real time not when it is as fast as possible, but when it is guaranteed that a process completes within some determined time slot. In a soft real time system, it is good but not absolutely necessary that this is guaranteed. E.g. in a game, the calculations necessary for a frame should complete within the period of a frame, or the framerate will drop. This degrades the quality of the gameplay, but does not make it incorrect. E.g. Minecraft is enjoyable even though the game occasionally stutters.
In a hard real time system, we don't have such liberties. A flight control software must react within some deadline, or the vehicle could crash. And the hardware, OS, and software must work together to support real time.
For example, the OS has a scheduler to decide when which thread is run. For a real-time program, the scheduler has to guarantee big enough, frequent enough time slots. Any other process that wants to execute in such a slot must be interrupted in favour of the real-time process. This requires a scheduler with explicit real-time support.
Also, a user-space program will do system calls into the kernel. In a real-time OS, these too must be real-time. E.g. writing to a file handle would have to be guaranteed to take no more that *x* time units, which would solve the log problem. This impacts how such a system call can be implemented, e.g. how buffers can be used. It also means that a call must fail if it can't complete within the required time, and that the user-space program must be prepared to deal with these cases. In the case of Java, the JVM and the standard library are also kernel-like and would need explicit real-time support.
For anything that is real-time, your programming style will change. If you don't have endless time, you have to restrict yourself to small problems. All your loops must be bounded by some constant. All memory can be allocated statically, since you have an upper bound on size. Unrestricted recursion is forbidden. This goes against a lot of best practices, but they don't apply for real-time systems. E.g. a logging system might use a statically allocated ring buffer to store log messages when they are written. Once the start is reached, old logs would be discarded, or this condition might be an error. | From [wikipedia](https://en.wikipedia.org/wiki/Real-time_operating_system):
>
> A key characteristic of an RTOS is the level of its consistency concerning the amount of time it takes to accept and complete an application's task; the variability is jitter.
>
>
>
The important thing is that jitter is quantified for the system to be considered *real time*. The article goes on to say that if the jitter is *usually* bounded, the system is *soft real-time*. If the jitter is *always* bounded, the system is *hard real-time*.
Unless the versions of Java and Linux you use are quantified in terms of jitter, they're *not* real-time. Garbage collection and log-writing are certainly sources of jitter, but even autonomous processing of (e.g.) network packets counts if it introduces jitter into *your* processes. |
308,829 | I have often heard developers mention that Java can't "*do [Real Time](https://en.wikipedia.org/wiki/Real-time_computing)*", meaning a Java app running on Linux cannot meet the requirements of a deterministic real-time system, such as something running on RIOT-OS, etc.
I am trying to understand *why*. My [SWAG](https://en.wikipedia.org/wiki/Scientific_Wild-Ass_Guess) tells me that this is probably largely due to Java's Garbage Collector, which can run at any time and totally pause the system. And although there are so-called "pauseless GCs" out there, I don't necessarily believe their advertising, and also don't have $80K-per-JVM-instance to fork over for a hobby project!
I was also reading [this article about running drone software on Linux](http://owenson.me/build-your-own-quadcopter-autopilot/). In that article, the author describes a scenario where Linux almost caused his drone to crash into his car:
>
> I learnt a hard lesson after choosing to do the low level control loop (PIDs) on the Pi - trying to be clever I decided to put a log write in the middle of the loop for debugging - the quad initially flied fine but then Linux decided to take 2seconds to write one log entry and the quad almost crashed into my car!
>
>
>
Now although that author wrote his drone software in C++, I would imagine a Java app running on Linux could very well suffer the same fate.
According to Wikipedia:
>
> A system is said to be real-time if the total correctness of an operation depends not only upon its logical correctness, but also upon the time in which it is performed.
>
>
>
So to me, this means "*You don't have real-time if total correctness requires logical correctness and timeliness.*"
Let's pretend I've written a Java app to be super performant, and that I've "squeezed the lemon" so to speak, and it couldn't reasonably be written (in Java) to be any faster.
All in all, my question is: I'm looking for someone to explain to me all/most of the reasons for why a Java app running n Linux would fail to be a "real time app". **Meaning, what are all the categories of things on a Java/Linux stack that prevent it from "being timely", and therefore, from being "*totally correct*"?** As mentioned, it looks like GC and Linux log-flushing can pause execution, but I'm sure there are more things outside the Java app itself that would cause bad timing/performance, and cause it to meet hard deadline constraints. **What are they?** | 2016/01/30 | [
"https://softwareengineering.stackexchange.com/questions/308829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/154753/"
] | From [wikipedia](https://en.wikipedia.org/wiki/Real-time_operating_system):
>
> A key characteristic of an RTOS is the level of its consistency concerning the amount of time it takes to accept and complete an application's task; the variability is jitter.
>
>
>
The important thing is that jitter is quantified for the system to be considered *real time*. The article goes on to say that if the jitter is *usually* bounded, the system is *soft real-time*. If the jitter is *always* bounded, the system is *hard real-time*.
Unless the versions of Java and Linux you use are quantified in terms of jitter, they're *not* real-time. Garbage collection and log-writing are certainly sources of jitter, but even autonomous processing of (e.g.) network packets counts if it introduces jitter into *your* processes. | For starter, the vanilla Linux itself can't do real time. That's why [RTLinux](https://en.wikipedia.org/wiki/RTLinux) was developed.
Lets say you run a few java processes on RTLinux, they would still be considered real time as all those processes are scheduled by the kernel, i.e. if one process is late, other processes still can have their slice of cpu time, guaranteed.
Now, if the java processes run [Green threads](https://en.wikipedia.org/wiki/Green_threads), then the execution of these threads won't be real time anymore since the JVM doesn't do real time scheduling. |
308,829 | I have often heard developers mention that Java can't "*do [Real Time](https://en.wikipedia.org/wiki/Real-time_computing)*", meaning a Java app running on Linux cannot meet the requirements of a deterministic real-time system, such as something running on RIOT-OS, etc.
I am trying to understand *why*. My [SWAG](https://en.wikipedia.org/wiki/Scientific_Wild-Ass_Guess) tells me that this is probably largely due to Java's Garbage Collector, which can run at any time and totally pause the system. And although there are so-called "pauseless GCs" out there, I don't necessarily believe their advertising, and also don't have $80K-per-JVM-instance to fork over for a hobby project!
I was also reading [this article about running drone software on Linux](http://owenson.me/build-your-own-quadcopter-autopilot/). In that article, the author describes a scenario where Linux almost caused his drone to crash into his car:
>
> I learnt a hard lesson after choosing to do the low level control loop (PIDs) on the Pi - trying to be clever I decided to put a log write in the middle of the loop for debugging - the quad initially flied fine but then Linux decided to take 2seconds to write one log entry and the quad almost crashed into my car!
>
>
>
Now although that author wrote his drone software in C++, I would imagine a Java app running on Linux could very well suffer the same fate.
According to Wikipedia:
>
> A system is said to be real-time if the total correctness of an operation depends not only upon its logical correctness, but also upon the time in which it is performed.
>
>
>
So to me, this means "*You don't have real-time if total correctness requires logical correctness and timeliness.*"
Let's pretend I've written a Java app to be super performant, and that I've "squeezed the lemon" so to speak, and it couldn't reasonably be written (in Java) to be any faster.
All in all, my question is: I'm looking for someone to explain to me all/most of the reasons for why a Java app running n Linux would fail to be a "real time app". **Meaning, what are all the categories of things on a Java/Linux stack that prevent it from "being timely", and therefore, from being "*totally correct*"?** As mentioned, it looks like GC and Linux log-flushing can pause execution, but I'm sure there are more things outside the Java app itself that would cause bad timing/performance, and cause it to meet hard deadline constraints. **What are they?** | 2016/01/30 | [
"https://softwareengineering.stackexchange.com/questions/308829",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/154753/"
] | A software is real time not when it is as fast as possible, but when it is guaranteed that a process completes within some determined time slot. In a soft real time system, it is good but not absolutely necessary that this is guaranteed. E.g. in a game, the calculations necessary for a frame should complete within the period of a frame, or the framerate will drop. This degrades the quality of the gameplay, but does not make it incorrect. E.g. Minecraft is enjoyable even though the game occasionally stutters.
In a hard real time system, we don't have such liberties. A flight control software must react within some deadline, or the vehicle could crash. And the hardware, OS, and software must work together to support real time.
For example, the OS has a scheduler to decide when which thread is run. For a real-time program, the scheduler has to guarantee big enough, frequent enough time slots. Any other process that wants to execute in such a slot must be interrupted in favour of the real-time process. This requires a scheduler with explicit real-time support.
Also, a user-space program will do system calls into the kernel. In a real-time OS, these too must be real-time. E.g. writing to a file handle would have to be guaranteed to take no more that *x* time units, which would solve the log problem. This impacts how such a system call can be implemented, e.g. how buffers can be used. It also means that a call must fail if it can't complete within the required time, and that the user-space program must be prepared to deal with these cases. In the case of Java, the JVM and the standard library are also kernel-like and would need explicit real-time support.
For anything that is real-time, your programming style will change. If you don't have endless time, you have to restrict yourself to small problems. All your loops must be bounded by some constant. All memory can be allocated statically, since you have an upper bound on size. Unrestricted recursion is forbidden. This goes against a lot of best practices, but they don't apply for real-time systems. E.g. a logging system might use a statically allocated ring buffer to store log messages when they are written. Once the start is reached, old logs would be discarded, or this condition might be an error. | For starter, the vanilla Linux itself can't do real time. That's why [RTLinux](https://en.wikipedia.org/wiki/RTLinux) was developed.
Lets say you run a few java processes on RTLinux, they would still be considered real time as all those processes are scheduled by the kernel, i.e. if one process is late, other processes still can have their slice of cpu time, guaranteed.
Now, if the java processes run [Green threads](https://en.wikipedia.org/wiki/Green_threads), then the execution of these threads won't be real time anymore since the JVM doesn't do real time scheduling. |
25,937,168 | I use a `entity` form type to provide a list of `Position` entities in a form. I use it often enough (each with the same "setup" code to customize it) that I've decided to make a custom form type from it for better re-use.
Here's the current form type:
```
class PositionType extends AbstractType
{
private $om;
public function __construct(ObjectManager $om, $mode)
{
$this->om = $om;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
// I need to pass "mode" as an option when building the form.
$mode = ???
$query_builder = function (EntityRepository $em) use ($mode) {
// Limit the positions returned based on the editing mode
return $em
->createQueryBuilder('Position')
->orderBy('Position.name')
->leftJoin('Position.type', 'Type')
->andWhere('Type.id IN (:ids)')
->setParameter('ids', Type::typesForMode($mode))
;
};
$resolver
->setRequired(array('mode'))
->setDefaults(array(
'label' => 'Position',
'class' => 'AcmeBundle:Position',
'property' => 'name',
'query_builder' => $query_builder,
'empty_value' => '',
'empty_data' => null,
'constraints' => array(
new NotBlank(),
),
))
;
}
public function getParent()
{
return 'entity';
}
public function getName()
{
return 'position';
}
}
```
Don't worry about the specifics in the query builder, that doesn't matter. The part that does matter is I'm trying to use a form type option in the query builder.
How can I do this? The problem is I can't use `$mode` (the option I want to pass to alter the query builder) in `setDefaultOptions`.
I was beginning to look for a way to set the query builder from inside `buildForm` but I'm not sure I can do that. | 2014/09/19 | [
"https://Stackoverflow.com/questions/25937168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/899199/"
] | This is fairly easy to achieve. You can build an option that depends on another option.
[OptionResolver Component - Default Values that Depend on another Option](http://symfony.com/doc/current/components/options_resolver.html#default-values-that-depend-on-another-option)
Basically you will do:
```
$resolver
->setRequired(array('mode', 'em')) // "em" for EntityManager as well
->setDefaults(array(
'label' => 'Position',
'class' => 'AcmeBundle:Position',
'property' => 'name',
#####################################################
'query_builder' => function(Options $options){
// Obviously you will need to pass the EntityManager
$em = $options['em'];
// Limit the positions returned based on the editing mode
return $em
->createQueryBuilder('Position')
->orderBy('Position.name')
->leftJoin('Position.type', 'Type')
->andWhere('Type.id IN (:ids)')
->setParameter('ids', Type::typesForMode($options['mode'])) //
;
},
####################################
'empty_value' => '',
'empty_data' => null,
'constraints' => array(
new NotBlank(),
),
))
;
```
This is just a rough representation of what `OptionsResolver` can do. Hope it helps :) | You could make use of the form options to pass a variable into the form builder.
For example in controller;
```
public function createAction()
{
$form = $this->formFactory->create('client', $client, array('name' => 'create'));
return $this->template->renderResponse('bundle:add.html.twig', array('form' => $form->createView()));
}
```
And in your form type;
```
class PositionType extends AbstractType
{
private $mode;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$this->mode = $options['name'];
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
// I need to pass "mode" as an option when building the form.
$mode = ???
$query_builder = function (EntityRepository $em) use ($this->mode) {
// Limit the positions returned based on the editing mode
return $em
->createQueryBuilder('Position')
->orderBy('Position.name')
->leftJoin('Position.type', 'Type')
->andWhere('Type.id IN (:ids)')
->setParameter('ids', Type::typesForMode($mode))
;
};
$resolver
->setRequired(array('mode'))
->setDefaults(array(
'label' => 'Position',
'class' => 'AcmeBundle:Position',
'property' => 'name',
'query_builder' => $query_builder,
'empty_value' => '',
'empty_data' => null,
'constraints' => array(
new NotBlank(),
),
))
;
}
}
``` |
29,456,031 | I am running a simple client-server program written in python, on my android phone using QPython and QPython3. I need to pass some commandline parameters. How do I do that? | 2015/04/05 | [
"https://Stackoverflow.com/questions/29456031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3211321/"
] | I found a couple of way of running a script that I imported from my Linux laptop.
If I put `frets.py` in the `script3` directory, and create this script in the same directory:
```
import sys, os
dir = '/storage/emulated/0/com.hipipal.qpyplus/scripts3/'
os.chdir(dir)
def callfrets(val):
os.system(sys.executable+" frets.py " + val)
while True:
val = input('$:')
if val:
callfrets(val)
else:
break
```
I can run the program with the same commandline inputs that I used in Linux, getting output on the console. Just invoke this script from the editor or the `programs` menu.
I also found (after getting some `argparse` errors) that I can get to a usable Linux shell by quiting the Python console with `sys.exit(1)`:
```
import sys
sys.exit(1)
```
drops me into the shell with the `/` directory. Changing directory
```
cd /storage/emulated/0/Download # or to the scripts3 directory
```
lets me run that original script directly
```
python frets.py -a ...
```
This shell has the necessary permisions and `$PATH` (`/data/data/com.hipipal.qpy3/files/bin`).
(I had problems getting this working on my phone, but updating Qpython3 took care of that.) | Just write a wrapper script which get the parameters and pass to the real script using some function like execfile, and put the script into /sdcard/com.hipipal.qpyplus/scripts or /sdcard/com.hipipal.qpyplus/scripts3 (for qpython3).
Then you can see the script in scripts when clicking the start button. |
627,158 | $$\nabla \times A = B$$
$A$ is vector magnetic potential, $\mathrm{Wb/m}$
$B$ is magnetic field intensity, $\mathrm{Wb/m^2}$
**Where does one more m come from for $B$?** *Is that from the gradient operator so it is in meter or something?* | 2021/04/05 | [
"https://physics.stackexchange.com/questions/627158",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/271720/"
] | It's kind of a funny misconception that the sun is yellow. I mean, astronomically speaking it is indeed a *yellow star*, more precisely [G-type main sequence / yellow dwarf](https://en.wikipedia.org/wiki/G-type_main-sequence_star)... but don't be fooled by the terminology: astronomically speaking, you'll also find that the Earth consists completely of [metal](https://en.wikipedia.org/wiki/Metallicity)!
Actually you should consider **the sun as white**.
The main reason, strangely enough, why we think the sun is yellow is that **we never look at it**. That is, directly enough to judge its colour. When the sun is high in a cloudless sky, it's just too bright to see its colour (and evolution has trained us to not even try, because it would damage the eyes). Only near sunrise or sunset do we actually get to look at the sun, but then it's not so much the colour of the sun but the colour of the *atmosphere* we're noticing – and the atmosphere is, again counter to perception, yellow-orange-red in colour. Well, not quite – the point is that the atmosphere lets red / yellow light through in a straight line whereas bluer frequencies are more [Rayleigh scattered](https://en.wikipedia.org/wiki/Rayleigh_scattering). That's the reason why *the sky* is blue, and also adds to the perception of the sun being yellow: it's yellow-ish in comparison with the surrounding sky colour.
When you see the sun through clouds, you get to see its actual colour more faithfully than usual, both because (as [Mark Bell wrote](https://physics.stackexchange.com/a/627151/3540)) Mie scattering doesn't have the colour-separating effect that Rayleigh scattering does, and because you then see it against a grey / white backdrop instead of against the blue sky. | Sunlight is "white". Blue sky is due to Rayleigh scattering, where the intensity of scattered light depends on the fourth power of the frequency, then this is why the sky is blue, since blue is in the upper bound of the visible spectrum in frequency. This is because the molecules in atmosphere have a size much smaller than the wavelength of light.
The clouds contain droplets of water that are bigger (1-100 $\mu m$) than the particles mentioned before. Since here the size of droplets is bigger than the wavelength of light, we have to use Mie scattering. And in Mie scattering we have that the wavelengths are equally scattered in all directions and that determines the white color. |
19,249,756 | I have the regular wordpress code to display category description:
```
<?php echo category_description( $category_id ); ?>
```
But how can i display Woocommerce category description?
@@
After one of the comment suggestion i added:
```
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description;
} // end while
} // end if
?>
```
Still, not work. | 2013/10/08 | [
"https://Stackoverflow.com/questions/19249756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713576/"
] | ```
$args = array( 'taxonomy' => 'product_cat' );
$terms = get_terms('product_cat', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo $term->description;
}
}
```
Edit for Last answer:
```
<?php
global $post;
$args = array(
'taxonomy' => 'product_cat'
);
$terms = wp_get_post_terms($post->ID, 'product_cat', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo '<div style="direction:rtl;">';
echo $term->description;
echo '</div>';
}
}
``` | You can display the product **category description** -
use this code -
```
<?php global $post, $product;
$categ = $product->get_categories();
$term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' );
echo $term->description; ?>
``` |
19,249,756 | I have the regular wordpress code to display category description:
```
<?php echo category_description( $category_id ); ?>
```
But how can i display Woocommerce category description?
@@
After one of the comment suggestion i added:
```
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description;
} // end while
} // end if
?>
```
Still, not work. | 2013/10/08 | [
"https://Stackoverflow.com/questions/19249756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713576/"
] | ```
$args = array( 'taxonomy' => 'product_cat' );
$terms = get_terms('product_cat', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo $term->description;
}
}
```
Edit for Last answer:
```
<?php
global $post;
$args = array(
'taxonomy' => 'product_cat'
);
$terms = wp_get_post_terms($post->ID, 'product_cat', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo '<div style="direction:rtl;">';
echo $term->description;
echo '</div>';
}
}
``` | The main answer for some reason displayed more than one description for me.
The answer below solved this for anyone with the same issue:
<https://stackoverflow.com/a/19266706/2703913> |
19,249,756 | I have the regular wordpress code to display category description:
```
<?php echo category_description( $category_id ); ?>
```
But how can i display Woocommerce category description?
@@
After one of the comment suggestion i added:
```
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description;
} // end while
} // end if
?>
```
Still, not work. | 2013/10/08 | [
"https://Stackoverflow.com/questions/19249756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713576/"
] | ```
$args = array( 'taxonomy' => 'product_cat' );
$terms = get_terms('product_cat', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo $term->description;
}
}
```
Edit for Last answer:
```
<?php
global $post;
$args = array(
'taxonomy' => 'product_cat'
);
$terms = wp_get_post_terms($post->ID, 'product_cat', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo '<div style="direction:rtl;">';
echo $term->description;
echo '</div>';
}
}
``` | [`the_archive_description()`](https://developer.wordpress.org/reference/functions/the_archive_description/) worked for my purposes when other (more complicated) solutions would not.
Optional before and after string parameters can be added if needed. |
19,249,756 | I have the regular wordpress code to display category description:
```
<?php echo category_description( $category_id ); ?>
```
But how can i display Woocommerce category description?
@@
After one of the comment suggestion i added:
```
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description;
} // end while
} // end if
?>
```
Still, not work. | 2013/10/08 | [
"https://Stackoverflow.com/questions/19249756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713576/"
] | You can display the product **category description** -
use this code -
```
<?php global $post, $product;
$categ = $product->get_categories();
$term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' );
echo $term->description; ?>
``` | The main answer for some reason displayed more than one description for me.
The answer below solved this for anyone with the same issue:
<https://stackoverflow.com/a/19266706/2703913> |
19,249,756 | I have the regular wordpress code to display category description:
```
<?php echo category_description( $category_id ); ?>
```
But how can i display Woocommerce category description?
@@
After one of the comment suggestion i added:
```
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description;
} // end while
} // end if
?>
```
Still, not work. | 2013/10/08 | [
"https://Stackoverflow.com/questions/19249756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713576/"
] | [`the_archive_description()`](https://developer.wordpress.org/reference/functions/the_archive_description/) worked for my purposes when other (more complicated) solutions would not.
Optional before and after string parameters can be added if needed. | The main answer for some reason displayed more than one description for me.
The answer below solved this for anyone with the same issue:
<https://stackoverflow.com/a/19266706/2703913> |
73,573,550 | The react docs boldly state that hooks shall only be called inside **"React functions"**:
<https://reactjs.org/docs/hooks-rules.html#only-call-hooks-from-react-functions>
"Don’t call Hooks from **regular JavaScript** functions."
That raises the question what *precisely* distinguishes a React function from a regular js function. Is it the return of a JSX Element? How about those functions:
```
function F1() { return <div>hello</div> } // certainly can use hooks
function F2() { return F1() } // can use hooks? is a react function? is a regular js function?
function F2() { return <F1 /> } // makes no difference, right?
function F3(s) { return <div>{s}</div> } // is a react function because uses jsx?
function F4() { return F3("bugs bunny") }
function F5({s}) { return <div>{s}</div> }
```
They all return a JSX Element. But I am not sure that f2 or f4 really are React functions and participate in the hook attachment. The way we pass arguments should only not matter. So the question: What exactly makes the difference?
(I know how JSX, hyperscript work, no need to explain those basics. I just did not look into the internals of the hook system.) | 2022/09/01 | [
"https://Stackoverflow.com/questions/73573550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857848/"
] | Whether the function is a component or not comes down to how you will use the function. Do you plan to render it as a JSX element, eg: `<f1 />`? If so, it's a react component and it can use hooks (though you will need to rename it to uppercase, as in `<F1 />`). During the render process, react will call your function, but only after it has set up the appropriate internal state so that the hooks can work correctly.
On the other hand, if you plan to call it directly (eg, `f1()`), you can't set up react's internal state for it, and react won't know you're calling the function so it can't do the setup for you. Thus, the only way you can get away with calling hooks in this kind of function is if you exclusively call this function while another component is rendering. This is called a "custom hook". They're a very useful tool for reusing code, but you should use the naming convention of starting with `use`, so that the programmer and the lint tools know to enforce the rules of hooks. | **You get to decide whether a function is a React function, a custom function, or a regular function, which defines who can call it from where.** If F1 is a React function (functional component) you can call it as `<F1 />` but should not call it as `F1()`; if F1 is a regular function you can call it as `F1()` but should not call it as `<F1 />`. The naming convention (F1, f1, or useF1) would help you distinguish which type of function you intend, which helps you and the linter hold to those rules; things might work if you break the rules, but they also might fail in difficult-to-debug ways.
* **React function** (functional component): Call from `createElement` or JSX. Can call hooks according to the rules and should return `createElement` or JSX expressions. Named with upper camel case (`Foo`) by convention.
* **Custom hook**: Call from functional components or other custom hooks. Can call hooks according to the rules; can return anything. Named with lower camel case starting with "use" (`useFoo`) by convention.
* **Regular function**: Call from anywhere. Shouldn't call hooks; can return anything. Named with lower camel case (`foo`) as usual.
---
In addition to Nicholas Tower's answer, you should observe that `<F1 />` and `F1()` are not identical. From the ["JSX Represents Objects" header of React's Main Concepts / Introducing JSX](https://reactjs.org/docs/introducing-jsx.html#jsx-represents-objects):
>
> Babel compiles JSX down to `React.createElement()` calls.
>
>
> These two examples are identical:
>
>
>
> ```
> const element = (
> <h1 className="greeting">
> Hello, world!
> </h1>
> );
>
> ```
>
>
> ```js
> const element = React.createElement(
> 'h1',
> {className: 'greeting'},
> 'Hello, world!'
> );
>
> ```
>
>
Specifically, this example:
```
function F1() {
return <F1>hello</F1>;
}
function F2() {
}
```
compiles to [this JS](https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=GYVwdgxgLglg9mABAMQIwAoCUiDeAoRRAJwFMoQikAeNAPgAsSAbJuKgejoG48BfPPKEiwEKAExZcfIA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2&prettier=false&targets=&version=7.18.13&externalPlugins=&assumptions=%7B%7D):
```js
"use strict";
function F1() {
return /*#__PURE__*/React.createElement(F1, null, "hello");
}
function F2() {}
```
**F1 doesn't call F2, F1 passes F2 to `React.createElement()`.** Consequently, `createElement` gets to call F2 *exactly and only* when it is ready to do so, allowing it to create a fresh internal state (i.e. history of hook calls). So when you [define F2 like this](https://reactjs.org/docs/hooks-rules.html#explanation):
```
// React function, returns JSX
function F2() {
useState('Mary') // 1. Initialize the name state variable with 'Mary'
useEffect(persistForm) // 2. Add an effect for persisting the form
useState('Poppins') // 3. Initialize the surname state variable with 'Poppins'
useEffect(updateTitle) // 4. Add an effect for updating the title
useLogin() // 5 & 6
}
// Custom hook, can call hooks according to rules, named "use" by convention
function useLogin() {
const [user, setUser] = useState(getDefaultUser());
const [domain, setDomain] = useState(getDomain());
}
// Normal function, can't call hooks
function getDefaultUser() {
return "defaultUser";
}
```
...then React can generate a new hook state for that particular component invocation, call F2 itself, and then wind up with an internal state that looks like `[useState, useEffect, useState, useEffect, useState(useLogin:user), useState(useLogin:domain)]`. Because of the rules for hooks barring conditionals and loops, if you've done it right, every invocation of F2 will wind up with exactly those six entries. If you use hooks from a "regular Javascript function" like `getDefaultUser()`, it might work by accident, but it will be harder to understand the usage and hold to the rules.
Thus, you are the one that determines which type of function a function is, all in service of keeping that state predictable. |
42,789,183 | I have and angular service that I want to test. In one of his methods I am using $http of angular service. I am simply want to mock that function (to be more specific mock $http.post function) that would return whatever I want and inject this mock to my service test.
I am tried to find solution and I found $httpBackend but I am not sure that this could help me.
MyService looks like that:
```
angular.module('app').service('MyService' , function (dependencies) {
let service = this;
service.methodToTest = function () {
$http.post('url').then(function () {
// Do something
});
}
}
```
* I am want to test methodToTest and inject the mock of $http.post()
P.S please remember that $http.post() returns promise so I think that I need to consider in that. | 2017/03/14 | [
"https://Stackoverflow.com/questions/42789183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6848513/"
] | From the docs
>
> **pluginManagement**: is an element that is seen along side plugins.
> Plugin Management contains plugin elements in much the same way,
> except that rather than configuring plugin information for this
> particular project build, it is intended to configure project builds
> that inherit from this one. However, this only configures plugins that
> are actually referenced within the plugins element in the children.
> The children have every right to override pluginManagement
> definitions.
>
>
>
Considering your Inherited POM, the `maven-checkstyle-plugin` used would be the one you've declared first(outside the pluginManagement). Instead of this, for the **inherited `pom.xml`**, to override the configuration, you must specify the same under the `plugins` and not `pluginManagement`. Try simplifying the pom's build tag as --
```
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!--Note - the version would be inherited-->
<configuration>
<configLocation>${project.parent.basedir}/${checkstyle.configLocation}</configLocation>
<suppressionsFile>${project.parent.basedir}/${checkstyle.suppressionsLocation}</suppressionsFile>
</configuration>
</plugin>
</plugins>
</build>
```
*Edit* : - From the comment, it was visible that the OP was not using the Simple [Inheritance structure](http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Example_1) hence using a *relative path* would solve the problem in such cases. | If your inherited project is in a different repo, you need another approach. Just add the parent as a dependency in the plugin. Note that you can't use this approach in `<reporting>` because it doesn't support plugin dependencies.
```
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!--version is inherited-->
<dependencies>
<dependency>
<groupId>parent.group.id</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
```
For more info, see
<https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html> |
48,275,998 | How C++ handles cout of negative value of signed char? Is the behavour defined in C++11 standard? I am using MinGW C++ 11 compiler. It looks the signed value is converted to unsigned type by adding 256 and then prints extended ASCII characters.
```
signed char a=-35;
std::cout<<a;
``` | 2018/01/16 | [
"https://Stackoverflow.com/questions/48275998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6446479/"
] | According to [this](http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2), the following overload is selected:
```
template< class Traits >
basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os,
signed char ch );
```
And since `signed char` is not `char`, `a` is first converted to a `char` using [`widen`](http://en.cppreference.com/w/cpp/io/basic_ios/widen):
```
char_type widen( char c ) const;
```
So your code is equivalent to:
```
std::cout << std::cout.widen(c);
// or:
std::cout << std::use_facet< std::ctype<char> >(getloc()).widen(c)
```
As you can see, `widen` takes a `char`, so you'll have a conversion from `signed char` to `char` prior to the actual "widening".
Even if you are widening from a `char` to a `char`, the behavior is implementation-defined — The standard makes no guarantee regarding this. | Use type casting to `int`...
```
std::cout << (int)a;
```
...or, following better C++ programming style (as Christian Hackl suggested):
```
std::cout << static_cast<int>(a);
```
This actually does not answer your questions (already been answered by Holt), but shows a solution to the problem. |
48,275,998 | How C++ handles cout of negative value of signed char? Is the behavour defined in C++11 standard? I am using MinGW C++ 11 compiler. It looks the signed value is converted to unsigned type by adding 256 and then prints extended ASCII characters.
```
signed char a=-35;
std::cout<<a;
``` | 2018/01/16 | [
"https://Stackoverflow.com/questions/48275998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6446479/"
] | According to [this](http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2), the following overload is selected:
```
template< class Traits >
basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os,
signed char ch );
```
And since `signed char` is not `char`, `a` is first converted to a `char` using [`widen`](http://en.cppreference.com/w/cpp/io/basic_ios/widen):
```
char_type widen( char c ) const;
```
So your code is equivalent to:
```
std::cout << std::cout.widen(c);
// or:
std::cout << std::use_facet< std::ctype<char> >(getloc()).widen(c)
```
As you can see, `widen` takes a `char`, so you'll have a conversion from `signed char` to `char` prior to the actual "widening".
Even if you are widening from a `char` to a `char`, the behavior is implementation-defined — The standard makes no guarantee regarding this. | Most of this is required behavior (and most of what isn't still borders on being required).
To be specific, the C++ standard says that iostreams are associated with C-style input and output streams, so `cout` is associated with `stdout` (§[narrow.stream.objects]/3):
>
> The object `cout` controls output to a stream buffer associated with the object `stdout`, declared in `<cstdio>`.
>
>
>
The C standard, in turn, defines narrow-character output as being as-if written via `fputc` (§7.19.3/12):
>
> The byte output functions write characters to the stream as if by successive calls to the `fputc` function.
>
>
>
`fputc` requires (§7.19.7.3/2):
>
> The `fputc` function writes the character specified by `c` (converted to an `unsigned char`) to the output stream pointed to by `stream`, [...]
>
>
>
So, yes, the conversion to `unsigned char` is exactly what the standards require. The C standard requires that conversion from signed to unsigned (of any integer type, including `char`) happen in the following fashion (§6.3.1.3/2):
>
> Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.
>
>
>
So yes, it is converted to unsigned by adding 256 (assuming `unsigned char` can represent values from 0 to 255, as is typical).
So that leaves us one part that the standard sort of attempts to require, without going quite all the way--the transformation that `widen` has to do (§[locale.ctype.virtuals]/10):
>
> Applies the simplest reasonable transformation from a char value or sequence of char values to the corresponding charT value or values.
>
>
>
Since it's a little difficult to decide exactly what's "reasonable", this *could* carry out some more or less arbitrary mapping on your character. In fact, it's apparently mapping input to output without modification (at least for the particular character you're writing), but it's true that other transformations could fall within "reasonable", and it would ultimately be difficult to draw a hard line saying that any particular transformation was not "reasonable".
The other part that's not really required by the C++ (or any other) standard is how something else will interpret that output. All the language standards can mandate is what gets written to the stream. The part with something else opening that stream and interpreting its content as "extended ASCII" (probably one of the ISO 8859 variants) is clearly outside the control of the language (or much of anything else in your program, of course). |
22,599,917 | I am using jQuery File Upload plugin (<http://blueimp.github.io/jQuery-File-Upload/>) for image upload for my website. I am trying to disable `UploadHandler.php` from generating thumbnail image on the server. After some searching, I found this: <https://github.com/blueimp/jQuery-File-Upload/issues/2223>
My Code:
```
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$options = array (
'upload_dir' => dirname(__FILE__) . '/uploaddir/',
'image_versions' => array()
);
$upload_handler = new UploadHandler($options);
```
When I try to upload file, it is not generating thumbnail in to the thumbnail folder. But it generate another smaller image on the `uploaddir` folder with the resolution 800 x 800.
So, how to properly disable thumbnail generation in UploadHandler.php?
Thank you. | 2014/03/24 | [
"https://Stackoverflow.com/questions/22599917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1995781/"
] | The default `index.php` file should look like following.
`error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$upload_handler = new UploadHandler();`
---
In your **`index.php`** file **before** the following function call
`$upload_handler = new UploadHandler();`
add the following code...
```
$options = array(
// This option will disable creating thumbnail images and will not create that extra folder.
// However, due to this, the images preview will not be displayed after upload
'image_versions' => array()
);
```
and then **CHANGE** the `UploadHandler()` function call to the pass the option as follows
`$upload_handler = new UploadHandler($options);`
---
**Short Explanation**
In `UploadHandler.php` file there are default options. One of which is `'image_versions'`. This option sets all relevant options to create server side thumbnail image.
With the above explained changes we are overwriting the `'image_versions'` option to be an empty array (which is same as not having this option).
This disables the server side thumbnail creation. | uncomment these lines in UploadHandler.php around line 103...
```
/*'thumbnail' => array(
// Uncomment the following to force the max
// dimensions and e.g. create square thumbnails:
//'crop' => true,
'max_width' => 80,
'max_height' => 80
) */
``` |
72,097,711 | I searched a lot and there are several questions like this however most of them do not have any answer or are not relevant to me.
I'm using TypeORM(v0.2.45) with Postgres driver and my entities/schemas are working fine with `synchronize` mode enabled.
My goal is to reverse generate migrations from the existing entities however it fails somehow.
This is what I get when trying to generate migrations
```sh
❯ npm run migration:generate Coffee
> [email protected] migration:generate
> npm run build && npm run typeorm migration:generate -- -n "Coffee"
> [email protected] prebuild
> rimraf dist
> [email protected] build
> cross-env NODE_ENV=production nest build
> [email protected] typeorm
> cross-env NODE_ENV=production ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config dist/src/common/setup/config/orm.config.js "migration:generate" "-n" "Coffee"
No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command
```
Here are my npm scripts for TypeORM
```json
{
"typeorm": "cross-env NODE_ENV=production ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config dist/src/common/setup/config/orm.config.js",
"migration:generate": "npm run build && npm run typeorm migration:generate -- -n",
"migration:run": "npm run typeorm migration:run"
}
```
orm.config.ts
```js
import { Env } from '../../env';
import { join } from 'path';
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
export default {
database: Env.isTest ? ':memory:' : process.env.DB_DATABASE || 'dri',
type: Env.isTest ? 'sqlite' : 'postgres',
port: Number(process.env.DB_PORT || 5432),
username: process.env.DB_USERNAME || 'dri-user',
password: process.env.DB_PASSWORD || 'dri-secret',
host: process.env.DB_HOST || '127.0.0.1',
...(!Env.isProd && {
synchronize: true,
synchronizeOptions: {
force: true,
},
}),
autoLoadEntities: true,
entities: [Env.isTest ? 'src/**/*.entity{.ts,.js}' : join(__dirname, './**/*.entity{.ts,.js}')],
keepConnectionAlive: true,
namingStrategy: new SnakeNamingStrategy(),
logging: Env.isDev ? 'all' : 'error',
migrations: [join(__dirname, './**/*.entity{.ts,.js}')],
cli: {
migrationsDir: 'migrations',
},
};
```
When I try to create a migration - it works but I want to generate it from the existing schema which is failing at the moment.
p.s.
I tried it with all the tables removed and also having em all in place but the result is the same - did not generate anything. | 2022/05/03 | [
"https://Stackoverflow.com/questions/72097711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8108312/"
] | Late to the party but maybe it will help someone else.
TypeOrm compares your entities schema to the database schema for any changes. If not changes between the two are found, it will not create a new migration. Because you are using `sync: true`, you DB is already up to date with your orm code so no migration is generated.
To generate migrations for each table, you will need to delete one table at a time, run the generate command and after run the migration. Repeat for all the tables. | try delete `dist` folder,
re-run `npm run migration:generate Coffee`, or you can split `npm run build` and then generate migration later |
433,009 | I can't seem to be able to type in a password so that I may acquire access to #apt-get. I'm looking to update my system via terminal, but typing out my password does no good to get me into su, as the spaces stay blank, and what I know is the password won't go through. Has anyone else had this issue? | 2014/03/12 | [
"https://askubuntu.com/questions/433009",
"https://askubuntu.com",
"https://askubuntu.com/users/257348/"
] | This answer has screenshots for Gnome-Shell (Ubuntu Gnome 13.10). I suppose it will be similar for standard Unity, but if not, please chime in.
First of all (and this is the most common problem), **to have AltGr working you need a keyboard layout which uses it**. For example, this is my keyboard layout (Settings -> Region and Language):
[](https://i.stack.imgur.com/zE3UR.png)
* English (US, international with dead keys) has AltGr.
* English (US) has NO AltGr.
* English (international AltGr dead keys) has AltGr.
(My preferred layout is the third one, really).
If the layout does not map AltGr+Key to anything, like for example the default "English (US)", AltGr **will not work** even if it's activated in the Keyboard -> Shortcuts panel.
This is normally sufficient. To change the position of the AltGr you go to Settings -> Keyboard and set the "Alternative Characters Key":
[](https://i.stack.imgur.com/QNOB1.png)
For example, my keyboard has no physical AltGr key, so I mapped it to the Right Alt key.
Now with the third layout, pressing `AltGr` and `n` **together** gives ñ.
[Compose](https://help.ubuntu.com/community/ComposeKey) (the option before) is a very different beast. If you enable it, then you will have a set of characters available with three (or more) keystrokes. For example, pressing `Compose`, `o`, `e` gives œ. That's three sequential keystrokes, not together.
Take into account that there is a [bug related to the layout switching](https://bugs.launchpad.net/ubuntu/+source/gnome-settings-daemon/+bug/1218322) in 13.10 which is being worked on, so check it if you have problems changing layout. | In order to set up the `Alt-Gr` key you must go to (setting -> keyboard -> layout settings -> keyboard settings -> then go to the typing tab -> press and hold the Alternative Keyboard Key setting -> move you mouse down to select the key you want to assign `Alt-Gr` to.



 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.