qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | Firstly, the recommended shebang line is:
```
#!/usr/bin/env python
```
This will make sure the python interpreter that is invoked when you `./foo.py` is the same interpreter that is invoked when you invoke python from the command line.
From your description, I suspect that if you did:
```
which python
```
It wo... | Try `which python`. I will tell you which python interpreter is used in your environment.
If it is not `/usr/bin/python` like in the script, then your suspicion is confirmed. |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | Firstly, the recommended shebang line is:
```
#!/usr/bin/env python
```
This will make sure the python interpreter that is invoked when you `./foo.py` is the same interpreter that is invoked when you invoke python from the command line.
From your description, I suspect that if you did:
```
which python
```
It wo... | It may be a bit odd providing a Perl script to answer a Python question, but it works for Python just as well as it does for Perl. This is a script called '`fixin`', meaning 'fix interpreter'. It changes the shebang line to the correct string for your current PATH.
```
#!/Users/jleffler/perl/v5.10.0/bin/perl
#
# @(#... |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | According to the first line of the script, `#!/usr/bin/python`, you are calling the Python interpreter at `/usr/bin/python` (which is most likely the one that ships with Mac OS X). You have to change that path to the path where you installed your Python 3 interpreter (likely `/usr/local/bin/python` or `/opt/local/bin/p... | run 'which python' - if this gives a different answer than /usr/bin/python, change #!/usr/bin/python to have that path instead. |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | run 'which python' - if this gives a different answer than /usr/bin/python, change #!/usr/bin/python to have that path instead. | It may be a bit odd providing a Perl script to answer a Python question, but it works for Python just as well as it does for Perl. This is a script called '`fixin`', meaning 'fix interpreter'. It changes the shebang line to the correct string for your current PATH.
```
#!/Users/jleffler/perl/v5.10.0/bin/perl
#
# @(#... |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | According to the first line of the script, `#!/usr/bin/python`, you are calling the Python interpreter at `/usr/bin/python` (which is most likely the one that ships with Mac OS X). You have to change that path to the path where you installed your Python 3 interpreter (likely `/usr/local/bin/python` or `/opt/local/bin/p... | It may be a bit odd providing a Perl script to answer a Python question, but it works for Python just as well as it does for Perl. This is a script called '`fixin`', meaning 'fix interpreter'. It changes the shebang line to the correct string for your current PATH.
```
#!/Users/jleffler/perl/v5.10.0/bin/perl
#
# @(#... |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | Firstly, the recommended shebang line is:
```
#!/usr/bin/env python
```
This will make sure the python interpreter that is invoked when you `./foo.py` is the same interpreter that is invoked when you invoke python from the command line.
From your description, I suspect that if you did:
```
which python
```
It wo... | It's very possibly what you suspect, that the shebang line is calling the older version. Two things you might want to check:
1) what version is the interpreter at /usr/bin/python:
```
/usr/bin/python -V
```
2) where is the python 3 interpreter you installed:
```
which python
```
If you get the correct one from t... |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | According to the first line of the script, `#!/usr/bin/python`, you are calling the Python interpreter at `/usr/bin/python` (which is most likely the one that ships with Mac OS X). You have to change that path to the path where you installed your Python 3 interpreter (likely `/usr/local/bin/python` or `/opt/local/bin/p... | It's very possibly what you suspect, that the shebang line is calling the older version. Two things you might want to check:
1) what version is the interpreter at /usr/bin/python:
```
/usr/bin/python -V
```
2) where is the python 3 interpreter you installed:
```
which python
```
If you get the correct one from t... |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | According to the first line of the script, `#!/usr/bin/python`, you are calling the Python interpreter at `/usr/bin/python` (which is most likely the one that ships with Mac OS X). You have to change that path to the path where you installed your Python 3 interpreter (likely `/usr/local/bin/python` or `/opt/local/bin/p... | Try `which python`. I will tell you which python interpreter is used in your environment.
If it is not `/usr/bin/python` like in the script, then your suspicion is confirmed. |
904,170 | I updated my python interpreter, but I think the old one is still called. When I check for the version I get:
```
$ python -V
Python 3.0.1
```
But I believe the old interpreter is still being called. When I run the command:
```
python myProg.py
```
The script runs properly. But when I invoke it with the command
... | 2009/05/24 | [
"https://Stackoverflow.com/questions/904170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74660/"
] | According to the first line of the script, `#!/usr/bin/python`, you are calling the Python interpreter at `/usr/bin/python` (which is most likely the one that ships with Mac OS X). You have to change that path to the path where you installed your Python 3 interpreter (likely `/usr/local/bin/python` or `/opt/local/bin/p... | Firstly, the recommended shebang line is:
```
#!/usr/bin/env python
```
This will make sure the python interpreter that is invoked when you `./foo.py` is the same interpreter that is invoked when you invoke python from the command line.
From your description, I suspect that if you did:
```
which python
```
It wo... |
32,852,267 | I'm using:
```
<ul class="ont-bd-phone">[\s\S]+<li>[\s\S]+T: ([^$]+?)[\s\S]+<\/li>[\s\S]+<\/ul>
```
to pick up `020 3514 0019` from:
```
<ul class="ont-bd-phone">
<li>
T: 020 3514 0019
</li>
</ul>
```
But the only match group being returned is '0' instead of ... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32852267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4459644/"
] | Definitely use something that can read HTML/XML before you start throwing regexes around. It's trivial to find the content in those list items using something like Nokogiri. After that, the regex (if you even really need it) is easy.
To get that text, something like this will work:
```
require 'nokogiri'
page = # ho... | remove the `?` from the group `([^$]+)` or just write `(.*)`
```
<ul class="ont-bd-phone">[\s\S]+<li>[\s\S]+T: (.*)[\s\S]+<\/li>[\s\S]+<\/ul>
``` |
37,474,379 | How to properly create a custom configuration key in zend expressive
I tried to create a file custom-config.php in the config/autoload directory but the key is not read by the container
my custom-config.php looks like this
```
<?php
[
'customkey' => [
'value1' => '1',
'value2' => '2',
],
];
``` | 2016/05/27 | [
"https://Stackoverflow.com/questions/37474379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4616154/"
] | I think you a missing a `return` statement.
Try with
```
<?php
return [
'customkey' => [
'value1' => '1',
'value2' => '2',
],
];
``` | Besides missing `return` statement, as *marcosh* pointed out, I think additional problem is the filename itself.
It should be something like `custom-config.local.php` or `custom-config.global.php`. |
37,474,379 | How to properly create a custom configuration key in zend expressive
I tried to create a file custom-config.php in the config/autoload directory but the key is not read by the container
my custom-config.php looks like this
```
<?php
[
'customkey' => [
'value1' => '1',
'value2' => '2',
],
];
``` | 2016/05/27 | [
"https://Stackoverflow.com/questions/37474379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4616154/"
] | I think you a missing a `return` statement.
Try with
```
<?php
return [
'customkey' => [
'value1' => '1',
'value2' => '2',
],
];
``` | Configuration files are loaded in a specific order. First `global.php`, then `*.global.php`, `local.php` and finally `*.local.php`. This way local settings overwrite global settings.
Settings shared between servers go into `*.global.php`, sensitive data and local settings in `*.local.php`. Local config files are ignor... |
500,472 | I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).
Those are different local sites, with domains which are set in my `/etc/hosts`:
```
127.0.0.1 localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14
#... | 2014/07/21 | [
"https://askubuntu.com/questions/500472",
"https://askubuntu.com",
"https://askubuntu.com/users/240339/"
] | It looks like your resolv.conf settings are causing your hosts file to ignored.
Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.
General resolvconf documentation
<http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.... | You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section. |
500,472 | I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).
Those are different local sites, with domains which are set in my `/etc/hosts`:
```
127.0.0.1 localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14
#... | 2014/07/21 | [
"https://askubuntu.com/questions/500472",
"https://askubuntu.com",
"https://askubuntu.com/users/240339/"
] | There is another thing to look at - `/etc/nsswitch.conf`. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:
```
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
```
This is how to interpret it:
The hosts: line specifies the order in which various na... | You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section. |
500,472 | I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).
Those are different local sites, with domains which are set in my `/etc/hosts`:
```
127.0.0.1 localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14
#... | 2014/07/21 | [
"https://askubuntu.com/questions/500472",
"https://askubuntu.com",
"https://askubuntu.com/users/240339/"
] | It looks like your resolv.conf settings are causing your hosts file to ignored.
Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.
General resolvconf documentation
<http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.... | Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.
But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called... |
500,472 | I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).
Those are different local sites, with domains which are set in my `/etc/hosts`:
```
127.0.0.1 localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14
#... | 2014/07/21 | [
"https://askubuntu.com/questions/500472",
"https://askubuntu.com",
"https://askubuntu.com/users/240339/"
] | There is another thing to look at - `/etc/nsswitch.conf`. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:
```
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
```
This is how to interpret it:
The hosts: line specifies the order in which various na... | Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.
But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called... |
35,826,083 | I m defining a Shape class with constructors, get and set methods, toString methods etc... And in toString method, I have to print **" is Filled "** or **" is not Filled "** according to a **given boolean value.**
I also wrote a getter method for boolean type such as:
```
...
...
private boolean filled;
... | 2016/03/06 | [
"https://Stackoverflow.com/questions/35826083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6025059/"
] | You need to close the message, if you forgot to do so you need to type this:
`CTRL + C`
[](https://i.stack.imgur.com/z9MpG.png)
---
Another option is to use `CTRL + D` but this will display error message.
[ and press Enter, and then to overwrite the commit message by running:
```
git commit --amend -m "<message>"
```
Where `<message>` is the correct message you want to insert |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken juices contain a soupy mix of proteins including haemoglobin (which gives blood its red colour when mixed with oxygen), and some myoglobin (which gives red meat its red colour when mixed with oxygen). Up to about 140F, they are unchanged, but heat them to between 140F and 160F and they lose their ability to bin... | What if you overcook it and there are no juices? You'd have to leave it in the oven until it caught fire.
While this is, indeed, how my grandmother cooked poultry, I prefer a thermometer if anyone but me is eating it. (If it's just me, I actually test for doneness by pushing on the breast with my fingers. Don't recomm... |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken juices contain a soupy mix of proteins including haemoglobin (which gives blood its red colour when mixed with oxygen), and some myoglobin (which gives red meat its red colour when mixed with oxygen). Up to about 140F, they are unchanged, but heat them to between 140F and 160F and they lose their ability to bin... | Chicken is cooked when it reaches the temperature necessary to denature (break down) most proteins, which kills any salmonella or other disease-causing agents and changes the texture of the meat.
The juices that come out of meat as it cooks should be fat or water, both of which are colorless, but they could pick up co... |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken juices contain a soupy mix of proteins including haemoglobin (which gives blood its red colour when mixed with oxygen), and some myoglobin (which gives red meat its red colour when mixed with oxygen). Up to about 140F, they are unchanged, but heat them to between 140F and 160F and they lose their ability to bin... | [Hemoglobin](http://en.wikipedia.org/wiki/Hemoglobin) is concentrated inside red blood cells and gives them the red colour. If the heat is high enough red and other cells, including bacteria, are destroyed. The red juices contain intact red blood cells and turn clear as the haemoglobin spills out of the destroyed cells... |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken juices contain a soupy mix of proteins including haemoglobin (which gives blood its red colour when mixed with oxygen), and some myoglobin (which gives red meat its red colour when mixed with oxygen). Up to about 140F, they are unchanged, but heat them to between 140F and 160F and they lose their ability to bin... | Hemoglobin is concentrated inside red blood cells and gives them the red colour. If the heat is high enough red and other cells, including bacteria, are destroyed. The red juices contain intact red blood cells and turn clear as the haemoglobin spills out of the destroyed cells and is diluted by the other juices. If you... |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken is cooked when it reaches the temperature necessary to denature (break down) most proteins, which kills any salmonella or other disease-causing agents and changes the texture of the meat.
The juices that come out of meat as it cooks should be fat or water, both of which are colorless, but they could pick up co... | What if you overcook it and there are no juices? You'd have to leave it in the oven until it caught fire.
While this is, indeed, how my grandmother cooked poultry, I prefer a thermometer if anyone but me is eating it. (If it's just me, I actually test for doneness by pushing on the breast with my fingers. Don't recomm... |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken is cooked when it reaches the temperature necessary to denature (break down) most proteins, which kills any salmonella or other disease-causing agents and changes the texture of the meat.
The juices that come out of meat as it cooks should be fat or water, both of which are colorless, but they could pick up co... | [Hemoglobin](http://en.wikipedia.org/wiki/Hemoglobin) is concentrated inside red blood cells and gives them the red colour. If the heat is high enough red and other cells, including bacteria, are destroyed. The red juices contain intact red blood cells and turn clear as the haemoglobin spills out of the destroyed cells... |
11,526 | I've come across this particular recommendation many times in [various recipes](http://www.bbc.co.uk/food/recipes/roastturkeywithbread_87596) and cookbooks and probably even given it out myself once or twice. Poultry is sufficiently cooked when the juices run clear, not red or pink.
In recent months and years, as I've... | 2011/01/27 | [
"https://cooking.stackexchange.com/questions/11526",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/41/"
] | Chicken is cooked when it reaches the temperature necessary to denature (break down) most proteins, which kills any salmonella or other disease-causing agents and changes the texture of the meat.
The juices that come out of meat as it cooks should be fat or water, both of which are colorless, but they could pick up co... | Hemoglobin is concentrated inside red blood cells and gives them the red colour. If the heat is high enough red and other cells, including bacteria, are destroyed. The red juices contain intact red blood cells and turn clear as the haemoglobin spills out of the destroyed cells and is diluted by the other juices. If you... |
25,926,481 | I want to hide the parent `li` if child `li` is empty. Here is the [jsfiddle link](http://jsfiddle.net/nepfw2qf/6/) where I want to hide the parent `li` label TWO.
```
<ul id='ListNav'>
<li ng-repeat='mainList in lists.list' ng-hide='subList.length<0' >
<a>{{mainList.label}}</a>
<ul>
<l... | 2014/09/19 | [
"https://Stackoverflow.com/questions/25926481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4012758/"
] | You may use the carriage return escape sequence, or `\r`. This will return the cursor to the start of the line.
```
while (1)
{
std::cout << "\rTest.";
}
``` | Try this...
```
while(1)
{
printf("this id infinite loop\n");
sleep(1);
system("clear");
}
``` |
25,926,481 | I want to hide the parent `li` if child `li` is empty. Here is the [jsfiddle link](http://jsfiddle.net/nepfw2qf/6/) where I want to hide the parent `li` label TWO.
```
<ul id='ListNav'>
<li ng-repeat='mainList in lists.list' ng-hide='subList.length<0' >
<a>{{mainList.label}}</a>
<ul>
<l... | 2014/09/19 | [
"https://Stackoverflow.com/questions/25926481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4012758/"
] | You only need carriage return, not line feed hence you need to use only "\r"
Carriage return means bringing the cursor back to the beginning of the line.
Line feed means feeding a new line to the terminal.
In c :
```
while(1)
{
printf("\r This is an infinite loop.");
}
```
Since the printf is buffered, therefore... | Try this...
```
while(1)
{
printf("this id infinite loop\n");
sleep(1);
system("clear");
}
``` |
25,926,481 | I want to hide the parent `li` if child `li` is empty. Here is the [jsfiddle link](http://jsfiddle.net/nepfw2qf/6/) where I want to hide the parent `li` label TWO.
```
<ul id='ListNav'>
<li ng-repeat='mainList in lists.list' ng-hide='subList.length<0' >
<a>{{mainList.label}}</a>
<ul>
<l... | 2014/09/19 | [
"https://Stackoverflow.com/questions/25926481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4012758/"
] | You only need carriage return, not line feed hence you need to use only "\r"
Carriage return means bringing the cursor back to the beginning of the line.
Line feed means feeding a new line to the terminal.
In c :
```
while(1)
{
printf("\r This is an infinite loop.");
}
```
Since the printf is buffered, therefore... | You may use the carriage return escape sequence, or `\r`. This will return the cursor to the start of the line.
```
while (1)
{
std::cout << "\rTest.";
}
``` |
56,176,858 | I need to send a PDF file to Google Vision to extract and return text. From documentation I understood that DPF file must be located on Google Storage, so I am putting the file to my Google Storage bucket like this:
```
require '../vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageC... | 2019/05/16 | [
"https://Stackoverflow.com/questions/56176858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434218/"
] | I realize how frustrating it could be when documentation is somewhat lacking organization, content or good examples. Here's what I ended-up doing myself, that finally allowed my script to work. Hope it'll help someone too:
```
require '../vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\... | The error indicates authentication issues. To resolve the issue, see and follow [Using a service account](https://cloud.google.com/vision/docs/auth#using_a_service_account) for instructions on authenticating with a service account.
"The account used for authentication must have access to the Cloud Storage bucket that ... |
46,456,895 | I'm new to powershell and I need some help with a script.
I have a simple code which loops while the user doesn't type a name :
```
do {$name = Read-Host "Choose a name "}
while (!$name) {}
```
I try to use it for the GUI version but the loop doesn't stop :
```
[void] [System.Reflection.Assembly]::LoadWithPart... | 2017/09/27 | [
"https://Stackoverflow.com/questions/46456895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8685417/"
] | You cannot pass a closure of type `(Error) -> Error` to `mapError`
because [a protocol does not conform to itself](https://stackoverflow.com/q/33112559/1187415), i.e. `Error` is not
a valid `T` for the constraint `<T: Error>`.
Making `mapError` non-generic
```
public func mapError(_ transform: (Error) -> Error) -> Re... | >
> What is this `_` return type [in the error]?
>
>
>
This means the compiler cannot determine a type, which might give a further clue as to what's going on... |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [R](https://www.r-project.org/), 86 bytes
=========================================
```r
function(a,b,d=a*(1-a))runif(1)<="if"(d,"if"(d>999e-6,a,1-round(a)),"if"(b,.9-.8*a,a))
```
[Try it online!](https://tio.run/##hY/RCoMwDEXf9xXiUyJpacc2VtD9S9QWCluVYr@/6/R5NS8Xcm4OJGbX9KLJLoVp80sAppHmgTvQghFjCt6Bxn5ovWthpiNexhgrHs... | [Perl 5](https://www.perl.org/) `-pl`, 61 bytes
===============================================
```perl
$_=(!$_?<>?.9:0:$_==1?<>?.1:1:$_<=.001||($_<.999&&$_))>rand<>
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZDUSXe3sbOXs/SysAKyLc1BPMMrQyBPBtbPQMDw5oaDSBTz9LSUk1NJV5T064oMS/Fxu7/f0Muw3/5BSWZ@XnF/3ULcgA "Per... |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [R](https://www.r-project.org/), 86 bytes
=========================================
```r
function(a,b,d=a*(1-a))runif(1)<="if"(d,"if"(d>999e-6,a,1-round(a)),"if"(b,.9-.8*a,a))
```
[Try it online!](https://tio.run/##hY/RCoMwDEXf9xXiUyJpacc2VtD9S9QWCluVYr@/6/R5NS8Xcm4OJGbX9KLJLoVp80sAppHmgTvQghFjCt6Bxn5ovWthpiNexhgrHs... | Python 3, 118 bytes
===================
```
from random import *
def f(p,c):
if c:
if p==1:p=.9
if p==0:p=.1
if p<1e-3:p=1
if p>.999:p=0
return random()<p
```
Inputs: p is initial probability, c is climax |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [C (gcc)](https://gcc.gnu.org/), 82 bytes
=========================================
Zero bytes of source code. Use the preprocessor directive:
```c
-Df(p,c)=rand()<~(1<<31)*(c&p==0?.9:p==1&c?.1:(p<=1e-3|p>=.999)&p!=1&p!=0?p<.1:p)
```
[Try it online!](https://tio.run/##jZBdS8MwFIav119xNkmbU9qSUHbRmlgQb7zRMbwUpKTNCKw... | [Perl 5](https://www.perl.org/) `-pl`, 61 bytes
===============================================
```perl
$_=(!$_?<>?.9:0:$_==1?<>?.1:1:$_<=.001||($_<.999&&$_))>rand<>
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZDUSXe3sbOXs/SysAKyLc1BPMMrQyBPBtbPQMDw5oaDSBTz9LSUk1NJV5T064oMS/Fxu7/f0Muw3/5BSWZ@XnF/3ULcgA "Per... |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [C (gcc)](https://gcc.gnu.org/), 82 bytes
=========================================
Zero bytes of source code. Use the preprocessor directive:
```c
-Df(p,c)=rand()<~(1<<31)*(c&p==0?.9:p==1&c?.1:(p<=1e-3|p>=.999)&p!=1&p!=0?p<.1:p)
```
[Try it online!](https://tio.run/##jZBdS8MwFIav119xNkmbU9qSUHbRmlgQb7zRMbwUpKTNCKw... | Python 3, 118 bytes
===================
```
from random import *
def f(p,c):
if c:
if p==1:p=.9
if p==0:p=.1
if p<1e-3:p=1
if p>.999:p=0
return random()<p
```
Inputs: p is initial probability, c is climax |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | Java 8, 65 bytes
================
```java
P->C->Math.random()<(P==0?C?.9:0:P>.001?P<.999?P:P==1?C?.1:1:0:1)
```
[Try it online.](https://tio.run/##fZPNasJAEMfveYpBaMlqXHcFkaiJ0JTeCgserYdVY42NiZiNIMVrH6CP2Bexkw814mpOm/n/ZmbnY1dyJ5ur@ddxFsokgXcZRN8GQKKkCmawQpWmKgjpIo1mKogj@lYeBq9xOg196yHzEsehLyMLyoPrwgKco2i6XtN9l2pJtz... | [Perl 5](https://www.perl.org/) `-pl`, 61 bytes
===============================================
```perl
$_=(!$_?<>?.9:0:$_==1?<>?.1:1:$_<=.001||($_<.999&&$_))>rand<>
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZDUSXe3sbOXs/SysAKyLc1BPMMrQyBPBtbPQMDw5oaDSBTz9LSUk1NJV5T064oMS/Fxu7/f0Muw3/5BSWZ@XnF/3ULcgA "Per... |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | Java 8, 65 bytes
================
```java
P->C->Math.random()<(P==0?C?.9:0:P>.001?P<.999?P:P==1?C?.1:1:0:1)
```
[Try it online.](https://tio.run/##fZPNasJAEMfveYpBaMlqXHcFkaiJ0JTeCgserYdVY42NiZiNIMVrH6CP2Bexkw814mpOm/n/ZmbnY1dyJ5ur@ddxFsokgXcZRN8GQKKkCmawQpWmKgjpIo1mKogj@lYeBq9xOg196yHzEsehLyMLyoPrwgKco2i6XtN9l2pJtz... | Python 3, 118 bytes
===================
```
from random import *
def f(p,c):
if c:
if p==1:p=.9
if p==0:p=.1
if p<1e-3:p=1
if p>.999:p=0
return random()<p
```
Inputs: p is initial probability, c is climax |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [Perl 6](https://github.com/nxadm/rakudo-pkg), 54 bytes
=======================================================
```perl6
{(($/=1-$^p min$p)??.001>=$/||$/!!$^c*.9)>rand^^$p>.5}
```
[Try it online!](https://tio.run/##LYzLCsIwFET3/YpbuEgiMQ8hYpAkf5JS1IBga4irYv32mLZu5gyHYdI9P09lmGAXwZYPISisOmBIMDxGTNR7LqVyFsU8o2hbDNc9N9... | [Perl 5](https://www.perl.org/) `-pl`, 61 bytes
===============================================
```perl
$_=(!$_?<>?.9:0:$_==1?<>?.1:1:$_<=.001||($_<.999&&$_))>rand<>
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZDUSXe3sbOXs/SysAKyLc1BPMMrQyBPBtbPQMDw5oaDSBTz9LSUk1NJV5T064oMS/Fxu7/f0Muw3/5BSWZ@XnF/3ULcgA "Per... |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~44~~ 42 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
===================================================================================================================================
[Crossed out 44 is no longer 44 :)](https:/... | [Perl 5](https://www.perl.org/) `-pl`, 61 bytes
===============================================
```perl
$_=(!$_?<>?.9:0:$_==1?<>?.1:1:$_<=.001||($_<.999&&$_))>rand<>
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZDUSXe3sbOXs/SysAKyLc1BPMMrQyBPBtbPQMDw5oaDSBTz9LSUk1NJV5T064oMS/Fxu7/f0Muw3/5BSWZ@XnF/3ULcgA "Per... |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [Perl 6](https://github.com/nxadm/rakudo-pkg), 54 bytes
=======================================================
```perl6
{(($/=1-$^p min$p)??.001>=$/||$/!!$^c*.9)>rand^^$p>.5}
```
[Try it online!](https://tio.run/##LYzLCsIwFET3/YpbuEgiMQ8hYpAkf5JS1IBga4irYv32mLZu5gyHYdI9P09lmGAXwZYPISisOmBIMDxGTNR7LqVyFsU8o2hbDNc9N9... | Python 3, 118 bytes
===================
```
from random import *
def f(p,c):
if c:
if p==1:p=.9
if p==0:p=.1
if p<1e-3:p=1
if p>.999:p=0
return random()<p
```
Inputs: p is initial probability, c is climax |
174,705 | The premise of this is simple: [A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!](http://www.giantitp.com/comics/oots0584.html)
So, write code that implements the following "dramatic" probability rules:
* Take in a floating point *P* from 0 to 1 representing the unmo... | 2018/10/25 | [
"https://codegolf.stackexchange.com/questions/174705",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/62402/"
] | [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~44~~ 42 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
===================================================================================================================================
[Crossed out 44 is no longer 44 :)](https:/... | Python 3, 118 bytes
===================
```
from random import *
def f(p,c):
if c:
if p==1:p=.9
if p==0:p=.1
if p<1e-3:p=1
if p>.999:p=0
return random()<p
```
Inputs: p is initial probability, c is climax |
61,024,277 | There are two ways to validate a file format when uploading to php.
```
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) { ........
```
and use mime type ...
```
if(($_FILES["file"][... | 2020/04/04 | [
"https://Stackoverflow.com/questions/61024277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13120460/"
] | PHP has a set of imagecreatefromXXX() functions. I would use these based on the $\_FILES['xxx']['type'] and see if you get a valid image resource. If the output from the imagecreatefromXXX() is FALSE, discard the file. See example here:
<https://www.php.net/manual/en/function.imagecreatefrompng>
It's also good to kno... | @unclexo
I wrote the code as follows. Do you think it is safe?
```
$file = $_FILES["file"]["name"];
$Forfi = basename($file);
$FilTy = strtolower(pathinfo($Forfi,PATHINFO_EXTENSION));
if( $FilTy == "gif" || $FilTy == "jpg" || $FilTy == "jpeg" .............. Step 1
if(($_FILES["file"]["type"] == "image/gif") || ($_FI... |
28,743,443 | In my app I need to perform location updates in background. For this purpose I registered my location tracking object as observer like this:
```
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(start)
... | 2015/02/26 | [
"https://Stackoverflow.com/questions/28743443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/994107/"
] | When your application goes in to background it has finite time to finish tasks. After that time the tasks will be suspended.
Try to put your `UpdateLocation` into a background task, like here:
<http://hayageek.com/ios-long-running-background-task/>
This example also uses location updates while going into background.... | You need to enable project **Background Modes** capabilities.
Go to project properties >> Capabilities section.
Select **Background Modes** and click switch to turn ON.

In background mode check **Location updates** true.
This will enable location... |
59,349 | I'm using this code to get word Chapter in TOC before each chapter.
```
\documentclass[a4paper]{book}
\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{Chapter }
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}
\begin{document}
\tableofcontents
\include{Intro}
\cleardoublepage
\b... | 2012/06/10 | [
"https://tex.stackexchange.com/questions/59349",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/4821/"
] | You have to do the changes while reading the `.toc` file: this is an example of how to do it. The double `\unexpanded` is because the `toc` entry is first written in the `.aux` file and then in the `.toc`, so we have to protect it twice. One could add several `\protect`, but this is surely easier to write.
```
\docume... | Add this line after `\begin{appendices}`:
```
\addtocontents{toc}{\def\protect\cftchappresnum{\appendixname{} }}
```
It adds a line to the TOC file that changes the title of the chapters (you ought to run twice).
You might as well want to change the label width, so put `Appendix` instead of `Chapter` in the `\AtBegi... |
59,349 | I'm using this code to get word Chapter in TOC before each chapter.
```
\documentclass[a4paper]{book}
\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{Chapter }
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}
\begin{document}
\tableofcontents
\include{Intro}
\cleardoublepage
\b... | 2012/06/10 | [
"https://tex.stackexchange.com/questions/59349",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/4821/"
] | Add this line after `\begin{appendices}`:
```
\addtocontents{toc}{\def\protect\cftchappresnum{\appendixname{} }}
```
It adds a line to the TOC file that changes the title of the chapters (you ought to run twice).
You might as well want to change the label width, so put `Appendix` instead of `Chapter` in the `\AtBegi... | The answers using `tocloft` works fine if you are not using the `\include` command. The problem is the delayed write mechanism used inside the `\addtocontents` to put stuff in the toc usualy ends up after the include contents. Solutions that works under all conditions are:
(1) It is the default behaviour of the `amsbo... |
59,349 | I'm using this code to get word Chapter in TOC before each chapter.
```
\documentclass[a4paper]{book}
\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{Chapter }
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}
\begin{document}
\tableofcontents
\include{Intro}
\cleardoublepage
\b... | 2012/06/10 | [
"https://tex.stackexchange.com/questions/59349",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/4821/"
] | You have to do the changes while reading the `.toc` file: this is an example of how to do it. The double `\unexpanded` is because the `toc` entry is first written in the `.aux` file and then in the `.toc`, so we have to protect it twice. One could add several `\protect`, but this is surely easier to write.
```
\docume... | The answers using `tocloft` works fine if you are not using the `\include` command. The problem is the delayed write mechanism used inside the `\addtocontents` to put stuff in the toc usualy ends up after the include contents. Solutions that works under all conditions are:
(1) It is the default behaviour of the `amsbo... |
27,141,610 | I have the following code...
```
public interface GithubService {
@GET("/repos/{owner}/{repo}/contributors")
public List<Contributor> contributors(@Path("owner") String owner, @Path("repo") String repo);
}
```
RepositoresBusinessController.class
```
RestAdapter restAdapter = new RestAdapter.Builder().setEnd... | 2014/11/26 | [
"https://Stackoverflow.com/questions/27141610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4068310/"
] | Retrofit has a mechanism for async callbacks without having to use `AsyncTask` or a service. Change your interface to use a callback instead of a return type --
```
public interface GithubService {
@GET("/repos/{owner}/{repo}/contributors")
public void contributors(@Path("owner") String owner, @Path("repo") S... | When I have executed your code considering the correct params passed to method `contributors(...)` here is the complete logcat
```
Caused by: retrofit.RetrofitError
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at $P... |
1,505,359 | I have a question and a possible solution. Please let me know if I'm wrong:
>
> Let $A,B$ be a complex matrices $n \times n$. Prove that if there is some polynomial $q(t)$ such that $q(A)=0$ and $q(B)\ne0$, than $A$ and $B$ are not similar matrices.
>
>
>
**Possible Solution**
From the Cayley Hamilton theorem we... | 2015/10/30 | [
"https://math.stackexchange.com/questions/1505359",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/88027/"
] | That's because if $A$ and $B$ are similar then $B = P^{-1}AP$ which means that $B^n = P^{-1}A^nP$ for natural numbers $n$ (even if $n=0$) this in turn means that $q(B) = P^{-1}q(A)P$. So if $q(A)=0$ then so is $q(B)$. | Let the polynomial such that $q(A) = 0$ and $q(B) = \lambda \neq 0$ be represented by
$q(t) = \sum\_{k = 0}^n a\_k t^k$
Now since $A$ and $B$ are similar there exists a matrix $P$ such that $A = P^{-1}BP$.
Now take
$0 = q(A) = q(P^{-1}BP) = \sum\_{k = 0}^n a\_k (P^{-1}BP)^k = P^{-1}\left ( \sum\_{k = 0}^n a\_k B^k... |
1,505,359 | I have a question and a possible solution. Please let me know if I'm wrong:
>
> Let $A,B$ be a complex matrices $n \times n$. Prove that if there is some polynomial $q(t)$ such that $q(A)=0$ and $q(B)\ne0$, than $A$ and $B$ are not similar matrices.
>
>
>
**Possible Solution**
From the Cayley Hamilton theorem we... | 2015/10/30 | [
"https://math.stackexchange.com/questions/1505359",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/88027/"
] | That's because if $A$ and $B$ are similar then $B = P^{-1}AP$ which means that $B^n = P^{-1}A^nP$ for natural numbers $n$ (even if $n=0$) this in turn means that $q(B) = P^{-1}q(A)P$. So if $q(A)=0$ then so is $q(B)$. | The *fundamental* definition of a minimal polynomial (in the context of linear algebra) is for a linear operator on a finite dimensional vector space, not for a matrix. In other words it does not require any basis to be chosen (in order to describe the operator$~\phi$ by a matrix), it is just the minimal degree monic p... |
31,692,130 | I'm using python 3.x and I don't know how to make my script randomly choose directories in the same PC to copy files.
I want it to copy the files in the random directories. What should I do to make it happen?
```
from sys import argv
import os
import random
script=argv
name=str(script[0])
count = 0
i = 10
while... | 2015/07/29 | [
"https://Stackoverflow.com/questions/31692130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5088212/"
] | As already stated, there is no way in Java to find objects that are referring to an object in question if there is no explicit reference held in a field.
If you have such a requirement, the easiest way is really to add a `parent` field to your class `StatusMessage`. But make sure to deal with it correctly:
1. Remove ... | No, you cannot find out which objects refer to a particular object.
You probably just want to add a `parent` field (and make sure to set it correctly). |
21,860,754 | Why doesn't my collection of strings (`lst`) appear in the console? Visual Studio does not show any obvious errors. Please point out my mistake.
```
public partial class Home : Page {
public Home() {
InitializeComponent();
}
// ...
private void Button_Click(object sender, EventArgs e) {
... | 2014/02/18 | [
"https://Stackoverflow.com/questions/21860754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3214034/"
] | As mentioned above, you are not using a console application and as such you cannot write to the console.
Create a RichTextBox and use
```
foreach(var line in lst)
{
RichTextBoxName.AppendText(line)
}
foreach(var line in lst)
{
RichTextBoxName.AppendText(line + "\n") //adds a new line after each strin... | You cannot use a console window in a standard Winforms application. It is launched with Application.Run and shows the default dialog, rather than the console.
In order to display a console window AS WELL as a winforms dialog, you have to use Win32 API to manually create the console window.
See here:
[How do I show a... |
21,860,754 | Why doesn't my collection of strings (`lst`) appear in the console? Visual Studio does not show any obvious errors. Please point out my mistake.
```
public partial class Home : Page {
public Home() {
InitializeComponent();
}
// ...
private void Button_Click(object sender, EventArgs e) {
... | 2014/02/18 | [
"https://Stackoverflow.com/questions/21860754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3214034/"
] | As mentioned above, you are not using a console application and as such you cannot write to the console.
Create a RichTextBox and use
```
foreach(var line in lst)
{
RichTextBoxName.AppendText(line)
}
foreach(var line in lst)
{
RichTextBoxName.AppendText(line + "\n") //adds a new line after each strin... | The console stream output isn't set to a visible console window, so Console.Write accepts the text, but doesn't display anything anywhere.
Try using [Debug.WriteLine](http://msdn.microsoft.com/en-us/library/system.diagnostics.debug.writeline%28v=vs.110%29.aspx) instead. |
9,735,578 | I am at the start of building a Facebook style notification system for our page (social gaming type) and I'm now researching what would be the best way to design such system. I'm not interested in how to push notifications to the user or anything like that (for now even). I am researching how to build the system on the... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9735578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185527/"
] | A notification is about something (object = event, friendship..) being changed (verb = added, requested..) by someone (actor) and reported to the user (subject). Here is a normalized data structure (though I've used MongoDB). You need to notify certain users about changes. So it's per-user notifications.. meaning that ... | This is really an abstract question, so I guess we are just going to have to discuss it instead of pointing out what you should or shouldn't do.
Here's what I think about your concerns:
* Yes, a notification system is complex, but not as hell though. You can have many different approaches on modeling and implementing... |
9,735,578 | I am at the start of building a Facebook style notification system for our page (social gaming type) and I'm now researching what would be the best way to design such system. I'm not interested in how to push notifications to the user or anything like that (for now even). I am researching how to build the system on the... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9735578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185527/"
] | This is really an abstract question, so I guess we are just going to have to discuss it instead of pointing out what you should or shouldn't do.
Here's what I think about your concerns:
* Yes, a notification system is complex, but not as hell though. You can have many different approaches on modeling and implementing... | ```
╔════════════════════╗
║notification ║
╟────────────────────╢
║Username ║
║Object ║
║verb ║
║actor ║
║isRead ║
╚════════════════════╝
```
This looks a good answer rather than having 2 collections. You can query by username, object and isRead... |
9,735,578 | I am at the start of building a Facebook style notification system for our page (social gaming type) and I'm now researching what would be the best way to design such system. I'm not interested in how to push notifications to the user or anything like that (for now even). I am researching how to build the system on the... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9735578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185527/"
] | This is really an abstract question, so I guess we are just going to have to discuss it instead of pointing out what you should or shouldn't do.
Here's what I think about your concerns:
* Yes, a notification system is complex, but not as hell though. You can have many different approaches on modeling and implementing... | I personally don't understand very well the diagram for the accepted answer, So I'm going to attach a database diagram base on what I could learn from the accepted answer and other pages.
[](https://i.stack.imgur.com/gSrVL.png)
Improvements are well ... |
9,735,578 | I am at the start of building a Facebook style notification system for our page (social gaming type) and I'm now researching what would be the best way to design such system. I'm not interested in how to push notifications to the user or anything like that (for now even). I am researching how to build the system on the... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9735578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185527/"
] | A notification is about something (object = event, friendship..) being changed (verb = added, requested..) by someone (actor) and reported to the user (subject). Here is a normalized data structure (though I've used MongoDB). You need to notify certain users about changes. So it's per-user notifications.. meaning that ... | ```
╔════════════════════╗
║notification ║
╟────────────────────╢
║Username ║
║Object ║
║verb ║
║actor ║
║isRead ║
╚════════════════════╝
```
This looks a good answer rather than having 2 collections. You can query by username, object and isRead... |
9,735,578 | I am at the start of building a Facebook style notification system for our page (social gaming type) and I'm now researching what would be the best way to design such system. I'm not interested in how to push notifications to the user or anything like that (for now even). I am researching how to build the system on the... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9735578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185527/"
] | A notification is about something (object = event, friendship..) being changed (verb = added, requested..) by someone (actor) and reported to the user (subject). Here is a normalized data structure (though I've used MongoDB). You need to notify certain users about changes. So it's per-user notifications.. meaning that ... | I personally don't understand very well the diagram for the accepted answer, So I'm going to attach a database diagram base on what I could learn from the accepted answer and other pages.
[](https://i.stack.imgur.com/gSrVL.png)
Improvements are well ... |
9,735,578 | I am at the start of building a Facebook style notification system for our page (social gaming type) and I'm now researching what would be the best way to design such system. I'm not interested in how to push notifications to the user or anything like that (for now even). I am researching how to build the system on the... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9735578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185527/"
] | ```
╔════════════════════╗
║notification ║
╟────────────────────╢
║Username ║
║Object ║
║verb ║
║actor ║
║isRead ║
╚════════════════════╝
```
This looks a good answer rather than having 2 collections. You can query by username, object and isRead... | I personally don't understand very well the diagram for the accepted answer, So I'm going to attach a database diagram base on what I could learn from the accepted answer and other pages.
[](https://i.stack.imgur.com/gSrVL.png)
Improvements are well ... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | For black-box testing (you dont have access to the source code), you can't prove it is uniformly distributed (UD). You can, however, perform statistical tests to find the likelihood of it being UD. Run the generator many times (say, N\*X times) and each number between 0 and N should have appeared around X times.
This... | Just *one* number from the generator, or as many as you want? If just one, you can't say anything about uniformity. So long as 0 ≤ number < N, it's OK.
Assuming the interviewer meant "[the uniformity of] a large number of results", you need to look at both the resulting distribution, and for patterns in the results. T... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | To **prove** it, you need to know the algorithm being used and show in graph terms that the set of all states constitutes a cycle, that there are no subcycles, and that the cardinality of the state space modulo N is zero so that there is no set of states that occur more/less frequently than others. This is how we know ... | For black-box testing (you dont have access to the source code), you can't prove it is uniformly distributed (UD). You can, however, perform statistical tests to find the likelihood of it being UD. Run the generator many times (say, N\*X times) and each number between 0 and N should have appeared around X times.
This... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | To **prove** it, you need to know the algorithm being used and show in graph terms that the set of all states constitutes a cycle, that there are no subcycles, and that the cardinality of the state space modulo N is zero so that there is no set of states that occur more/less frequently than others. This is how we know ... | Just *one* number from the generator, or as many as you want? If just one, you can't say anything about uniformity. So long as 0 ≤ number < N, it's OK.
Assuming the interviewer meant "[the uniformity of] a large number of results", you need to look at both the resulting distribution, and for patterns in the results. T... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | Since this is an interview, the real problem is not to prove uniform distribution, the real problem is to get selected for the job. I'd suggest an approach where you quickly decide whether the interviewer is looking for an interesting discussion on advanced mathematics or is testing for your practical thinking. My gues... | I'd start by asking how soon they would want an answer, and how good an answer they would want once you had the generator.
Yes, running a comprehensive set of statistical tests is nice if you want to be thorough. But that may take days or weeks. In some situations, the question may be asked in a meeting with a bunch o... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | To **prove** it, you need to know the algorithm being used and show in graph terms that the set of all states constitutes a cycle, that there are no subcycles, and that the cardinality of the state space modulo N is zero so that there is no set of states that occur more/less frequently than others. This is how we know ... | I'd start by asking how soon they would want an answer, and how good an answer they would want once you had the generator.
Yes, running a comprehensive set of statistical tests is nice if you want to be thorough. But that may take days or weeks. In some situations, the question may be asked in a meeting with a bunch o... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | Just *one* number from the generator, or as many as you want? If just one, you can't say anything about uniformity. So long as 0 ≤ number < N, it's OK.
Assuming the interviewer meant "[the uniformity of] a large number of results", you need to look at both the resulting distribution, and for patterns in the results. T... | There's an accessible discussion of this in the [Princeton Companion to Mathematics](http://books.google.co.uk/books?id=ZOfUsvemJDMC&lpg=PA116&dq=%22when%20should%20we%20regard%20such%20a%20sequence%20as%20random%3F%22&pg=PA116#v=onepage&q=%22when%20should%20we%20regard%20such%20a%20sequence%20as%20random?%22&f=false)
... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | To **prove** it, you need to know the algorithm being used and show in graph terms that the set of all states constitutes a cycle, that there are no subcycles, and that the cardinality of the state space modulo N is zero so that there is no set of states that occur more/less frequently than others. This is how we know ... | Since this is an interview, the real problem is not to prove uniform distribution, the real problem is to get selected for the job. I'd suggest an approach where you quickly decide whether the interviewer is looking for an interesting discussion on advanced mathematics or is testing for your practical thinking. My gues... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | Since this is an interview, the real problem is not to prove uniform distribution, the real problem is to get selected for the job. I'd suggest an approach where you quickly decide whether the interviewer is looking for an interesting discussion on advanced mathematics or is testing for your practical thinking. My gues... | There's an accessible discussion of this in the [Princeton Companion to Mathematics](http://books.google.co.uk/books?id=ZOfUsvemJDMC&lpg=PA116&dq=%22when%20should%20we%20regard%20such%20a%20sequence%20as%20random%3F%22&pg=PA116#v=onepage&q=%22when%20should%20we%20regard%20such%20a%20sequence%20as%20random?%22&f=false)
... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | For black-box testing (you dont have access to the source code), you can't prove it is uniformly distributed (UD). You can, however, perform statistical tests to find the likelihood of it being UD. Run the generator many times (say, N\*X times) and each number between 0 and N should have appeared around X times.
This... | This is a bit of a cruel question for an interview (unless this was a research position), but a fun one for a forum. 20 years ago after finishing my maths degree, I would have gaily presented a random generator written by myself with the mathematical proof that it was random. Looking at that code now, I find it hard to... |
24,409,639 | I was asked this question in an interview.
>
> Given a random number generator to generate a number between [0,N), how
> to prove this number is uniform distributed.
>
>
>
I am not sure how to approach this problem, any suggestion? | 2014/06/25 | [
"https://Stackoverflow.com/questions/24409639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35829/"
] | Just *one* number from the generator, or as many as you want? If just one, you can't say anything about uniformity. So long as 0 ≤ number < N, it's OK.
Assuming the interviewer meant "[the uniformity of] a large number of results", you need to look at both the resulting distribution, and for patterns in the results. T... | This is a bit of a cruel question for an interview (unless this was a research position), but a fun one for a forum. 20 years ago after finishing my maths degree, I would have gaily presented a random generator written by myself with the mathematical proof that it was random. Looking at that code now, I find it hard to... |
3,693,372 | This is supposed to be solved using high school methods, I've been thinking about Bezout, but I don't know whether that'll work, or even how to use it in this scenario.
Edit: It was supposed to be $20^m$ and $9^n$, I mistyped. | 2020/05/27 | [
"https://math.stackexchange.com/questions/3693372",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Certainly $20^m-9^n=11$ has a solution.
Now suppose $20^m-9^n=t$ with $|t|<11$.
If we're allowed to use zero as an exponent, then we have $20^0-9^0=0$, so we'll assume zero is banned.
Then $t$ can't be divisible by $2$ or $5$, since $20^m$ is but $9^n$ isn't; similarly, $t$ can't be a multiple of $3$, since $9^n$... | An absolute value cannot be less than $0$. Can you make the expression equal $0$? If so, show how and you are done. |
35,443,591 | So in a GridControl, the user selects which session he wants to view and then press on a "See Gallery" which will take the application to a "next" View - Gallery, then another GridControl to select which Image in that gallery and press "See Images" to go and so on.
I am trying to get rid of all "Buttons" and let the ... | 2016/02/16 | [
"https://Stackoverflow.com/questions/35443591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5890227/"
] | Instead of using hidden inputs, have you tried applying a class to each column and then toggling as follows?:
```
$(document).ready( function () {
var table = $('#example').DataTable( {
columns: [
{ className: "group1" },
{ className: "group2" },
{ className: "group1" },
{ className: "group2" },
... | Try this code:
```
var table = $('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{
extend: 'columnToggle',
text: 'Toggle Group1',
columns: $('#example thead th input[value="group1"]').closest('th')
}
]
});
```
See [updated example](http://live.datatables.net/novikubo/5/ed... |
37,592,787 | Update: The list are filled with strings I edited the list to show this
I have 3 different list such as
```
Section = [('1', '1.1', '1.2'), ('1', '2', '2.2', '3'), ('1', '1.2', '3.2', '3.5')]
Page = [('1', '1', '3'), ('1', '2', '2', '2'), ('1', '2', '3', '5')]
Titles = [('General', 'Info', 'Titles'), ('More', 'Info'... | 2016/06/02 | [
"https://Stackoverflow.com/questions/37592787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4673518/"
] | Try this,
```
Section = [('1', '1.1', '1.2'), ('1', '2', '2.2', '3'), ('1', '1.2', '3.2', '3.5')]
Page = [('1', '1', '3'), ('1', '2', '2', '2'), ('1', '2', '3', '5')]
Titles = [('General', 'Info', 'Titles'), ('More', 'Info', 'Section', 'Here'), ('Another', 'List', 'Of', 'Strings')]
# Flat a list of tuples into a lis... | You can do:
```
from itertools import chain
tuples = zip(map(float, list(chain(*Section))),
list(chain(*Page)),
list(chain(*Title)))
zip(*sorted(tuples, key=lambda x: x[0]))
Out[232]:
[(1.0, 1.0, 1.0, 1.1, 1.2, 1.2, 2.0, 2.2, 3.0, 3.2, 3.5),
('1', '1', '1', '1', '3', '2', '2', '2', '2',... |
37,592,787 | Update: The list are filled with strings I edited the list to show this
I have 3 different list such as
```
Section = [('1', '1.1', '1.2'), ('1', '2', '2.2', '3'), ('1', '1.2', '3.2', '3.5')]
Page = [('1', '1', '3'), ('1', '2', '2', '2'), ('1', '2', '3', '5')]
Titles = [('General', 'Info', 'Titles'), ('More', 'Info'... | 2016/06/02 | [
"https://Stackoverflow.com/questions/37592787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4673518/"
] | You can do:
```
from itertools import chain
tuples = zip(map(float, list(chain(*Section))),
list(chain(*Page)),
list(chain(*Title)))
zip(*sorted(tuples, key=lambda x: x[0]))
Out[232]:
[(1.0, 1.0, 1.0, 1.1, 1.2, 1.2, 2.0, 2.2, 3.0, 3.2, 3.5),
('1', '1', '1', '1', '3', '2', '2', '2', '2',... | My approach. List comprehension and no need to import modules. I think its fast, and its very simple.
EDIT: I've added an unsorted approach and a sorted approach.
```
#Unsorted
newList =[
[item for sublist in Section for item in sublist],
[item for sublist in Page for item in sublist],
[item for sublist i... |
37,592,787 | Update: The list are filled with strings I edited the list to show this
I have 3 different list such as
```
Section = [('1', '1.1', '1.2'), ('1', '2', '2.2', '3'), ('1', '1.2', '3.2', '3.5')]
Page = [('1', '1', '3'), ('1', '2', '2', '2'), ('1', '2', '3', '5')]
Titles = [('General', 'Info', 'Titles'), ('More', 'Info'... | 2016/06/02 | [
"https://Stackoverflow.com/questions/37592787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4673518/"
] | Try this,
```
Section = [('1', '1.1', '1.2'), ('1', '2', '2.2', '3'), ('1', '1.2', '3.2', '3.5')]
Page = [('1', '1', '3'), ('1', '2', '2', '2'), ('1', '2', '3', '5')]
Titles = [('General', 'Info', 'Titles'), ('More', 'Info', 'Section', 'Here'), ('Another', 'List', 'Of', 'Strings')]
# Flat a list of tuples into a lis... | My approach. List comprehension and no need to import modules. I think its fast, and its very simple.
EDIT: I've added an unsorted approach and a sorted approach.
```
#Unsorted
newList =[
[item for sublist in Section for item in sublist],
[item for sublist in Page for item in sublist],
[item for sublist i... |
42,431,368 | When I post value from angular2 using services from my ng server, <http://localhost:4200> to my localhost XAMPP server <http://localhost/test/catch_angular_post.php> and tring to catch value using $\_POST OR $\_REQUEST but It's showing Empty Array,
Here is My services Code :
```
const contactData =
{
full_name:f... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42431368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4701975/"
] | ```
ion-segment {
display: block;
white-space: nowrap;
font-size: 0;
overflow: auto;
&::-webkit-scrollbar {
width: 0;
height: 0;
display: none;
}
ion-segment-button.segment-button {
display: inline-block;
min-width: 100px;
width: auto;
}
... | this solution is for Ionic2, so the solution was working only for Ionic2
```
ion-segment {
justify-content: space-between;
overflow: auto;
&::-webkit-scrollbar {
width: 0;
height: 0;
display: none;
}
ion-segment-button.segment-button {
flex: 1 0 100px;
}
}
```... |
23,949,721 | How can I delete a resource created with the scaffold command in Ruby on Rails? If I try to overwrite it, I have problems to migrate because the table already exists! | 2014/05/30 | [
"https://Stackoverflow.com/questions/23949721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3671840/"
] | You need to add the attribute below to your password input.
```
autocomplete="off"
```
Please note though that latest versions of major browsers are not supporting this attribute any more. | First, I guess it would be better if you put your code.
Secondly, if the password is already filled maybe the value attribute in your input is not empty! Check it out :)
Example:
```
<input type="password" name="password" value="someValue">
``` |
23,949,721 | How can I delete a resource created with the scaffold command in Ruby on Rails? If I try to overwrite it, I have problems to migrate because the table already exists! | 2014/05/30 | [
"https://Stackoverflow.com/questions/23949721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3671840/"
] | You need to add the attribute below to your password input.
```
autocomplete="off"
```
Please note though that latest versions of major browsers are not supporting this attribute any more. | I know this is an old question, but for those still looking for an answer, you can use the attribute `autofill='new-password'`.
Complete example;
```
<input type="password" autocomplete="new-password">
``` |
8,516,857 | I am trying to use AVFoundation framework to capture a 'series' of still images from AVCaptureStillImageOutput QUICKLY, like the burst mode in some cameras. I want to use the completion handler,
```
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection
... | 2011/12/15 | [
"https://Stackoverflow.com/questions/8516857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155683/"
] | "IMPORTANT: Clients of CMSampleBuffer must explicitly manage the retain count by calling CFRetain and CFRelease, even in processes using garbage collection."
SOURCE: CoreMedia.Framework CMSampleBuffer.h | I've been doing a lot of work with CMSampleBuffer objects recently and I've learned that most of the media buffers sourced by the OS during real-time operations are allocated from pools. If AVFoundation (or CoreVideo/CoreMedia) runs out of buffers in a pool (ie. you CFRetain a buffer for a 'long' time), the real time a... |
1,465,638 | I have been tasked with encrypting a string using S/Mime encryption. Eons ago, the firm I work for bought a component for this (from IPWorks) but we have had untold bundles of grief getting their component to play nicely on our servers. Not a functionality issue, more licensing.
So in short, I must do it myself. I hav... | 2009/09/23 | [
"https://Stackoverflow.com/questions/1465638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63627/"
] | This line is the problem:
```
var av = new AlternateView(ms, "application/pkcs7-mime; smime-type=enveloped-data;name=smime.p7m; content-transfer-encoding=Base64; content-disposition=attachment; fileName=smime.p7m;");
```
You are dumping the values of multiple headers into the Content-Type header.
Instead, what you ... | I think the default encoder/decoder for StreamReader is UTF-8. What happens if you change it to ASCII in the constructor (last line)? |
19,360,324 | I have a text file that has about 5,000 lines with each line being about 200 characters long. Each line actually contains 6 different pieces of data that I've been using `substr()` to break apart. For example, on each line, characters 0 - 10 contain the Client#, characters 10-20 contain the Matter#, etc. This is all we... | 2013/10/14 | [
"https://Stackoverflow.com/questions/19360324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1077670/"
] | I can't see why that would be so much slower, but you could take a look at [unpack](http://php.net/unpack) which could extract your fixed width record in one hit:
```
$fields = unpack('A10client/A10matter/A60name ...etc... ',$tempLine_matters);
```
I did a quick benchmark using a similar record pattern to your exam... | It's not a very optimized process. You should maybe think about it a little bit more.
But if it's working right now it's the most important...
Maybe if you get your value with two process it will be faster. For example :
```
$clientID_bis = trim(substr($tempLine_matters, 0, 10));
$clientID = trim(substr($clientID_bi... |
20,834,664 | I want to use 2 clauses in SQL Server like so:
```
SELECT ROW_NUMBER() OVER (ORDER BY date_time ASC) AS RowNumber,
<column_name1>,
<column_name2>,
<column_name3>,
date_time
from <table name>
where <column name1> = 'assdf'
or RowNumber between 1 and 10
```
But this produces an error... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20834664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3145444/"
] | Use jQuery remove() functionality , In your case as
```
$('td').removeClass('ui-widget-content');
```
basics [here](http://w3schools.com/jquery/jquery_css_classes.asp) | If you have a lot of these, and don't want to delete them directly from the file, you can use jQuery. This single line will remove them.
```
$('*').removeClass('ui-widget-content');
```
However, if you want them to be removed from the css file.. I'd think just to open the css file in any text editor, and use the fin... |
20,834,664 | I want to use 2 clauses in SQL Server like so:
```
SELECT ROW_NUMBER() OVER (ORDER BY date_time ASC) AS RowNumber,
<column_name1>,
<column_name2>,
<column_name3>,
date_time
from <table name>
where <column name1> = 'assdf'
or RowNumber between 1 and 10
```
But this produces an error... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20834664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3145444/"
] | Use jQuery remove() functionality , In your case as
```
$('td').removeClass('ui-widget-content');
```
basics [here](http://w3schools.com/jquery/jquery_css_classes.asp) | using jquery
```
$(document).ready(function() {
$("div td").removeClass("ui-widget-content");
});
``` |
20,834,664 | I want to use 2 clauses in SQL Server like so:
```
SELECT ROW_NUMBER() OVER (ORDER BY date_time ASC) AS RowNumber,
<column_name1>,
<column_name2>,
<column_name3>,
date_time
from <table name>
where <column name1> = 'assdf'
or RowNumber between 1 and 10
```
But this produces an error... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20834664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3145444/"
] | Use jQuery remove() functionality , In your case as
```
$('td').removeClass('ui-widget-content');
```
basics [here](http://w3schools.com/jquery/jquery_css_classes.asp) | If you are okay with using jquery ,
Use the following :
`$( "td" ).removeClass( "ui-widget-content" );` |
37,341,683 | I have a problem , my android-sdk-manager is suddenly stopped showing all packages, it is only showing the installed packages only. Can you guys help me out how to solve this issue?
[](https://i.stack.imgur.com/SD9TX.png) | 2016/05/20 | [
"https://Stackoverflow.com/questions/37341683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3115186/"
] | Navigate through File --> setting --> Android SDK --> SDK update site tab, in that check **force https://... sources to be fetched using http://...**
[](https://i.stack.imgur.com/zcC3h.jpg) | Firstly, just try toggling "`Updates/New`", there might be a glitch on the SDK manager itself.
Secondly you can go to "`Tools -> Manage Add On sites...`"
[](https://i.stack.imgur.com/tArXJ.png)
Ensure they are all clicked
Third, try Reloading. i.e "`Packages -> Re... |
46,843 | Someone has been harassing me on kik all week by continually adding me group chats that I did not ask to be part of. The person is blocked, but they are still able to add me to group chats against my will - I don't have the option of accepting or not, it just happens.
If I have to abandon the platform and find another... | 2013/06/07 | [
"https://android.stackexchange.com/questions/46843",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/12303/"
] | The answer is: you cannot. Either wait out the harassment, don't open the app for a while, or switch discussion platforms with the people you care to talk to. All unsatisfying solutions, but... they are the only ones. | If you want them to stop why don't you make a new kik? I have done the same blocked and it still happens I don't understand why but just make a new one or simply email kik messenger and report that person. |
9,893,267 | In a php-script i have a form, method is post, action-attribute is empty, which is working so far. but when i add a value into the action-atribute, like so:
```
action="index.php?id=9&get-id=5"
```
the whole post-array is empty after submitting.
Someone has any idea what this could be about?
Thanx in advance, Jay... | 2012/03/27 | [
"https://Stackoverflow.com/questions/9893267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075320/"
] | You should not use both GET and POST in a request.
You must only use post, therefore the two variables 'id' and 'get-id' should be in the form (use hidden fields)
edit:
try changing your code to:
```
<form name="form1" method="post" enctype="multipart/form-data"
action="index.php?id=9&get-id=5">
<input type=... | If you're trying to access id or get-id from your script: Those were appended to the url, even if you submit that form via post. Therefore you will find their values in $\_GET, as usual. Only the values of `<input>` fields (and textarea etc., simply: all form elements) are in $\_POST. |
9,893,267 | In a php-script i have a form, method is post, action-attribute is empty, which is working so far. but when i add a value into the action-atribute, like so:
```
action="index.php?id=9&get-id=5"
```
the whole post-array is empty after submitting.
Someone has any idea what this could be about?
Thanx in advance, Jay... | 2012/03/27 | [
"https://Stackoverflow.com/questions/9893267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075320/"
] | try to use `$_REQUEST`
which is collection of $\_GET and $\_POST | If you're trying to access id or get-id from your script: Those were appended to the url, even if you submit that form via post. Therefore you will find their values in $\_GET, as usual. Only the values of `<input>` fields (and textarea etc., simply: all form elements) are in $\_POST. |
9,893,267 | In a php-script i have a form, method is post, action-attribute is empty, which is working so far. but when i add a value into the action-atribute, like so:
```
action="index.php?id=9&get-id=5"
```
the whole post-array is empty after submitting.
Someone has any idea what this could be about?
Thanx in advance, Jay... | 2012/03/27 | [
"https://Stackoverflow.com/questions/9893267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075320/"
] | try to use `$_REQUEST`
which is collection of $\_GET and $\_POST | You should not use both GET and POST in a request.
You must only use post, therefore the two variables 'id' and 'get-id' should be in the form (use hidden fields)
edit:
try changing your code to:
```
<form name="form1" method="post" enctype="multipart/form-data"
action="index.php?id=9&get-id=5">
<input type=... |
61,271,065 | I know this is a very documented subject but after hours and hours of research I'm now stuck.
I'm making a quiz, and when a choice is made I would like to update the corresponding parameter on the URL.
<https://deusbot-trading.com/quiz/age=&exp=&asset=>
This is my URL, generated with :
```
let refresh = window.loca... | 2020/04/17 | [
"https://Stackoverflow.com/questions/61271065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12527136/"
] | No, it's not possible. [`erase()`](https://en.cppreference.com/w/cpp/container/vector/erase) is a method of the container, and you can't reach the container from an iterator. | In general you cannot modify size of container which content passed to you by pair of iterators. If it would be possible it would be quite strange though. What if only part of container is passed to you as a range? What if 2 pointers to content of embedded array is passed to you? How are you going to resize an embedded... |
30,484,716 | I've got an existing codebase that I'm attempting to upgrade from Rails 3.2 to Rails 4.0
I have controller called assets\_controller with a 'create' method and I have a an entry in my routes file:
```
resources :assets
```
Using jQuery for ajax on the front end, if I send a post request to '/assets' from a browser,... | 2015/05/27 | [
"https://Stackoverflow.com/questions/30484716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2539548/"
] | This isn't just about the word `assets`. Rails does not like when a route path and the asset directory are in the same subdirectory.
When making a post request, you will get `method not allowed`. The problem is there can be no overlap with paths and the asset directory. The problem is specifically with `POST` requests... | It turns out the problem was with the name 'assets' I can't find any documentation to confirm this, but renaming the asset model and controller to something else fixed the problem. |
30,484,716 | I've got an existing codebase that I'm attempting to upgrade from Rails 3.2 to Rails 4.0
I have controller called assets\_controller with a 'create' method and I have a an entry in my routes file:
```
resources :assets
```
Using jQuery for ajax on the front end, if I send a post request to '/assets' from a browser,... | 2015/05/27 | [
"https://Stackoverflow.com/questions/30484716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2539548/"
] | It turns out the problem was with the name 'assets' I can't find any documentation to confirm this, but renaming the asset model and controller to something else fixed the problem. | The issue is that your `asset` controller routes are conflicting with the rails default `/assets` path.
The simplest solution is to modify your `config/routes.rb` file line to read as follows (or any other path of your choosing that is not `assets`):
`resources :assets, path: 'site_assets'` |
30,484,716 | I've got an existing codebase that I'm attempting to upgrade from Rails 3.2 to Rails 4.0
I have controller called assets\_controller with a 'create' method and I have a an entry in my routes file:
```
resources :assets
```
Using jQuery for ajax on the front end, if I send a post request to '/assets' from a browser,... | 2015/05/27 | [
"https://Stackoverflow.com/questions/30484716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2539548/"
] | This isn't just about the word `assets`. Rails does not like when a route path and the asset directory are in the same subdirectory.
When making a post request, you will get `method not allowed`. The problem is there can be no overlap with paths and the asset directory. The problem is specifically with `POST` requests... | The issue is that your `asset` controller routes are conflicting with the rails default `/assets` path.
The simplest solution is to modify your `config/routes.rb` file line to read as follows (or any other path of your choosing that is not `assets`):
`resources :assets, path: 'site_assets'` |
14,950,273 | I have a div which should be a draggable.
Below is the code,
```
$( "#SpeedDraggable" ). draggable
({
axis: "y",
containment:'parent',
drag: function(event, ui)
{
var Startpos = $(this).position();
$("#SpeedText").text(184-Startpos.top).css('color','#DDDDDD'); ... | 2013/02/19 | [
"https://Stackoverflow.com/questions/14950273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2010420/"
] | ```
$( "#SpeedDraggable" ). draggable
({
axis: "y",
containment:'parent',
drag: function(event, ui)
{
if($("#imgManualSetting_Pressed").is(":visible"))
{
var Startpos = $(this).position();
$("#SpeedText").text(184-Startpos.top).css('color','#DDDDDD');
... | ```
if($("#imgManualSetting_Pressed").is(":visible")) {
// set to draggable widget
$( "#SpeedDraggable" ).draggable({
axis: "y",
containment:'parent',
drag: function(event, ui)
{
var Startpos = $(this).position();
$("#SpeedText").text(184-Sta... |
2,231,315 | So, I received this question to solve a while ago, and frankly, I'm a bit confused, since it's been a while since I've done linear algebra. Since the two questions depend on each other, I would like a detailed solution for both, please. The question is listed below:
Let $A$ be an n x n nonsingular matrix and $I\_n$ ... | 2017/04/12 | [
"https://math.stackexchange.com/questions/2231315",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/405500/"
] | ***True for the edited version.***
One can assume that $\mu$ is a unitary measure since one can divide by $\mu(\Omega)$ and obtain a new measure where all norms will be multiplied by $\dfrac{1}{\mu(\Omega)}.$ So, I shall assume $\mu$ is unitary.
In this case, a direct application of Holder inequality allows concludin... | ***False for original version.***
Consider $\displaystyle g\_n = \sum\_{k = 0}^n \dfrac{1}{k} \left( \mathbf{1}\_{[k, k + \frac{1}{2})} - \mathbf{1}\_{[k + \frac{1}{2}, k + 1)} \right).$ Then, $g\_n$ has integral zero, converges in $\mathscr{L}^2$ sense to $\displaystyle g = \sum\_{k = 0}^\infty \dfrac{1}{k} \left( \m... |
38,179,366 | Hi I've got follow code:
```js
angular.module("myApp", []).controller("myController", function($scope) {
$scope.fieldSize = "cInputLarge"; //Change for the effect to -> cInputMedium, cInputLarge
});
```
```css
.cDefault {
width: 50px;
}
.cInputMedium {
width: 100px;
}
.cInputLarge {
width: 200px;
}
... | 2016/07/04 | [
"https://Stackoverflow.com/questions/38179366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5466074/"
] | Just use the name of the variable, it should be sufficient:
```js
angular.module("myApp", []).controller("myController", function($scope) {
$scope.fieldSize = "cInputLarge"; //Change for the effect to -> cInputMedium, cInputLarge
});
```
```css
.cDefault {
width: 50px;
}
.cInputMedium {
width: 100px;
}
... | Yes its correct .
You can bind to a scope variable |
38,179,366 | Hi I've got follow code:
```js
angular.module("myApp", []).controller("myController", function($scope) {
$scope.fieldSize = "cInputLarge"; //Change for the effect to -> cInputMedium, cInputLarge
});
```
```css
.cDefault {
width: 50px;
}
.cInputMedium {
width: 100px;
}
.cInputLarge {
width: 200px;
}
... | 2016/07/04 | [
"https://Stackoverflow.com/questions/38179366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5466074/"
] | Just use the name of the variable, it should be sufficient:
```js
angular.module("myApp", []).controller("myController", function($scope) {
$scope.fieldSize = "cInputLarge"; //Change for the effect to -> cInputMedium, cInputLarge
});
```
```css
.cDefault {
width: 50px;
}
.cInputMedium {
width: 100px;
}
... | Or try this
```
<input class="cDefault" ng-class="{{'fieldSize'}}">
``` |
994,450 | I have followed [the following guide](http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/) to setup Rsync with SSH between my local machine and a remote server:
I performed the below as root:
1. `rsync -avz -e ssh /home/user/dir root@192.168.200.10::Backup/dir` -> prompts for password
2. `ssh-keygen`... | 2015/10/31 | [
"https://superuser.com/questions/994450",
"https://superuser.com",
"https://superuser.com/users/516320/"
] | You are mixing two separate connection modes: with a remote shell (`-e ssh`) and without a remote shell, thru a `rsync daemon` (identified by the double colon).
[The manual](http://linuxcommand.org/man_pages/rsync1.html) states:
>
> **CONNECTING TO AN RSYNC SERVER**
>
>
> It is also possible to use rsync without ... | Your username on your local account is probably not `root`, which is the username you use with Rsync.
```
ssh remotehost
```
…is effectively the same as:
```
ssh localUserName@remotehost
```
---
Sorry, I didn't notice that you already said you’re running as root.
I also didn’t notice that you are using the mod... |
994,450 | I have followed [the following guide](http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/) to setup Rsync with SSH between my local machine and a remote server:
I performed the below as root:
1. `rsync -avz -e ssh /home/user/dir root@192.168.200.10::Backup/dir` -> prompts for password
2. `ssh-keygen`... | 2015/10/31 | [
"https://superuser.com/questions/994450",
"https://superuser.com",
"https://superuser.com/users/516320/"
] | Your username on your local account is probably not `root`, which is the username you use with Rsync.
```
ssh remotehost
```
…is effectively the same as:
```
ssh localUserName@remotehost
```
---
Sorry, I didn't notice that you already said you’re running as root.
I also didn’t notice that you are using the mod... | I had this problem too - I hope this helps. For me, the problem was the syntax required for alternate port ssh. Here are two working examples:
Execute this from the target backup machine, which pulls from source to target backup:
`rsync -av --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' user@10.9.9.3:/home/user... |
994,450 | I have followed [the following guide](http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/) to setup Rsync with SSH between my local machine and a remote server:
I performed the below as root:
1. `rsync -avz -e ssh /home/user/dir root@192.168.200.10::Backup/dir` -> prompts for password
2. `ssh-keygen`... | 2015/10/31 | [
"https://superuser.com/questions/994450",
"https://superuser.com",
"https://superuser.com/users/516320/"
] | You are mixing two separate connection modes: with a remote shell (`-e ssh`) and without a remote shell, thru a `rsync daemon` (identified by the double colon).
[The manual](http://linuxcommand.org/man_pages/rsync1.html) states:
>
> **CONNECTING TO AN RSYNC SERVER**
>
>
> It is also possible to use rsync without ... | I had this problem too - I hope this helps. For me, the problem was the syntax required for alternate port ssh. Here are two working examples:
Execute this from the target backup machine, which pulls from source to target backup:
`rsync -av --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' user@10.9.9.3:/home/user... |
71,200,752 | I can't add elements correctly to a `Dictionary<string, List<string>>` with a `List<string>` like value. Every time I enter a new key with a List as value, the values of the previous keys are overwritten with the last List entered.
```
Dictionary<string, List<string>> videosBloqueDict = new Dictionary<string, List<s... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71200752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8766065/"
] | Lists are reference types, so `videosResult` is a reference to a single list. Every turn of the loop, you clear the same list, and then add another reference to that same list to the dictionary. That's why you end up with identical results for each entry in the dictionary: it's the same list repeated multiple times.
Y... | ```
Dictionary<string, List<string>> videosBloqueDict = new Dictionary<string, List<string>>();
string[] bloques = Directory.GetDirectories(path).Select(Path.GetFileName).ToArray();
foreach(var bloque in bloques)
{
List<string> videosResult = new List<string>();
... |
26,522,650 | I need to input multiple data, as in 50000 different sets of data into a database with a txt file.
The data is inputed as shown.
chr 166999824 67210768 NM\_032291
They are separated with a tab.
Is there any way to help input the numerous different data without slowly inputting it in one by one? We are currently us... | 2014/10/23 | [
"https://Stackoverflow.com/questions/26522650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172833/"
] | traverse from last index (a.length - 1) to 0
return the index when you first encountered the key. | One possible approach would be to start at the end of the array and work your way backwards, returning the index of the first element you encounter....
```
int[] array = new int[]{2, 8, 8, 3, 4, 4, 4, 7}; //im suppose to find the index of the last 4.
int find = 4; //4 or 5(return -1 when element is not found)
int las... |
42,246,281 | I don't understand why the type system lets me do this?
In other words **I would expect this to crash when foo is passed to the function**.
```
var foo:String!
func someFunction(_ bar:String?) {
print("-- \(bar) --")
}
someFunction(foo)
=> writes "-- nil --"
``` | 2017/02/15 | [
"https://Stackoverflow.com/questions/42246281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/308189/"
] | Inside your `someFunction` you are printing the optional not String. that's why it is not crashing. if you want to print bar as `String` you have to unwrap the value. | ```
// This line will create variable named foo and type of it will be String! and value of it will be nil.
// It mean i can access this variable is force-wraped so it may dangerous but uses of this variable without type checking compiler will not give any warning(ignore by compiler).
var foo:String!
// This function... |
42,246,281 | I don't understand why the type system lets me do this?
In other words **I would expect this to crash when foo is passed to the function**.
```
var foo:String!
func someFunction(_ bar:String?) {
print("-- \(bar) --")
}
someFunction(foo)
=> writes "-- nil --"
``` | 2017/02/15 | [
"https://Stackoverflow.com/questions/42246281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/308189/"
] | As @Hamish so correctly points out here:
<https://stackoverflow.com/a/39537558/308189>
>
> If the expression can be explicitly type checked with a strong optional type, it will be. However, the type checker will fall back to forcing the optional if necessary.
>
>
>
And the comment on the answer explains why this ... | Inside your `someFunction` you are printing the optional not String. that's why it is not crashing. if you want to print bar as `String` you have to unwrap the value. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.