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 |
|---|---|---|---|---|---|
70,992,183 | I currently have a dataframe of customers, contracts, and contract dates like this ex
```
Cust Contract Start End
A 123 10/1/2021 11/3/2021
B 987 7/4/2022 8/12/2022
```
For each row, I want to generate a variable that tells me if it was active during a set range ex: 10/1/2021-12/31/2021.
When I import from the excel file, the 'Start' and 'End' Columns come in as datetime64[ns]
Code I have tried so far is this:
```
df.loc[df['Start'].dt.strftime('%Y-%m-%d')<='2021-10-31' & df['End'].dt.strftime('%Y-%m-%d')<='2021-10-1', 'Active Flag'] = 'Yes'
```
When I run this I get the following error
```
Cannot perform 'rand_' with a dtyped [object] array and scalar of type [bool]
```
I'm not really sure if I am even on the correct track for solving this, or if there is an easier way. Any help would be appreciated as Python's date time operations are very odd to me. | 2022/02/04 | [
"https://Stackoverflow.com/questions/70992183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17996183/"
] | This assignment
```
if(a[1]==' '){s[0]=a[1];
```
invokes undefined behavior because the string `s` is empty and you may not use the subscript operator for an empty string to assign a value.
Instead you could write for example
```
if(a[1]==' '){s += a[1];
```
Pay attention to that in this case the string s will contain the space character. To make it visible you could write for example
```
#include <iostream>
#include <iomanip>
#include <string>
//...
std::cout<< std::quoted( s ) << '\n';
```
or
```
std::cout << '\'' << s << "\'\n";
``` | Thats because "s" is empty string with size 0.
It means there is no element at index [0] in it.
When you ask "s" for [0] element it leads to UB.
If you want to add a[1] to "s", you can use:
```
s.push_back(a[1]);
```
Or:
```
s += a[1];
```
Or:
```
s.insert(s.begin(), a[1]); // That's bad way, dont use it.
``` |
70,992,183 | I currently have a dataframe of customers, contracts, and contract dates like this ex
```
Cust Contract Start End
A 123 10/1/2021 11/3/2021
B 987 7/4/2022 8/12/2022
```
For each row, I want to generate a variable that tells me if it was active during a set range ex: 10/1/2021-12/31/2021.
When I import from the excel file, the 'Start' and 'End' Columns come in as datetime64[ns]
Code I have tried so far is this:
```
df.loc[df['Start'].dt.strftime('%Y-%m-%d')<='2021-10-31' & df['End'].dt.strftime('%Y-%m-%d')<='2021-10-1', 'Active Flag'] = 'Yes'
```
When I run this I get the following error
```
Cannot perform 'rand_' with a dtyped [object] array and scalar of type [bool]
```
I'm not really sure if I am even on the correct track for solving this, or if there is an easier way. Any help would be appreciated as Python's date time operations are very odd to me. | 2022/02/04 | [
"https://Stackoverflow.com/questions/70992183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17996183/"
] | You are not allocating any character memory for `s` to refer to, so `s.size()` is 0 and thus `[0]` is out of bounds, and writing anything to it is [**undefined behavior**](https://en.cppreference.com/w/cpp/language/ub) 1.
1: in C++11 and later, you can safely write `'\0'` to `s[s.size()]`, but you are not doing that here.
Try this instead:
```
#include <string>
#include <iostream>
using namespace std;
int main()
{
string a = "1 23";
string s = "";
if (a[1] == ' ') {
s += a[1];
// alternatively:
s = a[1];
// alternatively:
s.resize(1);
s[0] = a[1];
cout << s;
}
return 0;
}
```
Just note that `a[1]` is the whitespace character `' '`, so while you can assign that character to `s`, and it will print to the console, you just won't (easily) see it visually in your console. Any of the other characters from `a` would be more visible. | My guess is that this is a naive attempt to parse the string. Is this what you are looking for?
```
#include <string>
#include <iostream>
using namespace std;
int main()
{
string a = "1 23";
string s;
if (a[1] == ' ') {
s = a.substr(2);
cout << s;
}
return 0;
}
``` |
70,992,183 | I currently have a dataframe of customers, contracts, and contract dates like this ex
```
Cust Contract Start End
A 123 10/1/2021 11/3/2021
B 987 7/4/2022 8/12/2022
```
For each row, I want to generate a variable that tells me if it was active during a set range ex: 10/1/2021-12/31/2021.
When I import from the excel file, the 'Start' and 'End' Columns come in as datetime64[ns]
Code I have tried so far is this:
```
df.loc[df['Start'].dt.strftime('%Y-%m-%d')<='2021-10-31' & df['End'].dt.strftime('%Y-%m-%d')<='2021-10-1', 'Active Flag'] = 'Yes'
```
When I run this I get the following error
```
Cannot perform 'rand_' with a dtyped [object] array and scalar of type [bool]
```
I'm not really sure if I am even on the correct track for solving this, or if there is an easier way. Any help would be appreciated as Python's date time operations are very odd to me. | 2022/02/04 | [
"https://Stackoverflow.com/questions/70992183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17996183/"
] | You are not allocating any character memory for `s` to refer to, so `s.size()` is 0 and thus `[0]` is out of bounds, and writing anything to it is [**undefined behavior**](https://en.cppreference.com/w/cpp/language/ub) 1.
1: in C++11 and later, you can safely write `'\0'` to `s[s.size()]`, but you are not doing that here.
Try this instead:
```
#include <string>
#include <iostream>
using namespace std;
int main()
{
string a = "1 23";
string s = "";
if (a[1] == ' ') {
s += a[1];
// alternatively:
s = a[1];
// alternatively:
s.resize(1);
s[0] = a[1];
cout << s;
}
return 0;
}
```
Just note that `a[1]` is the whitespace character `' '`, so while you can assign that character to `s`, and it will print to the console, you just won't (easily) see it visually in your console. Any of the other characters from `a` would be more visible. | Thats because "s" is empty string with size 0.
It means there is no element at index [0] in it.
When you ask "s" for [0] element it leads to UB.
If you want to add a[1] to "s", you can use:
```
s.push_back(a[1]);
```
Or:
```
s += a[1];
```
Or:
```
s.insert(s.begin(), a[1]); // That's bad way, dont use it.
``` |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | ```
Table: Album
ID/PK (your choice of primary key philosophy)
AlbumName
Table: Track
ID/PK (optional, could make AlbumFK, TrackNumber the primary key)
AlbumFK REFERENCES (Album.PK)
TrackNumber
TrackName
TrackURL
``` | Conventional approach would be to have one table with a row for each track (with any meta data). Have another table for each Album, and a third table that records the association for which tracks are on which album(s) and in which order. |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | It's entirely possible, you could store the field as comma-separated or XML data for example.
Whether it's *sensible* is another question - if you ever want to query how many albums have more than 10 tracks for example you aren't going to be able to write an SQL query for that and you'll have to resort to pulling the data back into your application and dissecting it there which is not ideal.
Another option is to store the data in a separate "tracks" table (i.e. normalised), but also provide a view on those tables that gives the data as a single field in a denormalised manner. Then you get the benefit of properly structured data and the ability to query the data as a single field from the view. | Conventional approach would be to have one table with a row for each track (with any meta data). Have another table for each Album, and a third table that records the association for which tracks are on which album(s) and in which order. |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | Conventional approach would be to have one table with a row for each track (with any meta data). Have another table for each Album, and a third table that records the association for which tracks are on which album(s) and in which order. | The Wikipedia article on [Database Normalization](http://en.wikipedia.org/wiki/Normal_forms) makes a reasonable effort to explain the purpose of normalization ... and the sorts of anomalies that the normalization rules are intended to prevent. |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | ```
Table: Album
ID/PK (your choice of primary key philosophy)
AlbumName
Table: Track
ID/PK (optional, could make AlbumFK, TrackNumber the primary key)
AlbumFK REFERENCES (Album.PK)
TrackNumber
TrackName
TrackURL
``` | Use two tables, one for albums, and one for tracks.
```
Album
-----
Id
Name
Artist
etc...
Track
-----
Id
AlbumId(Foreign Key to Album Table)
Name
URL
```
You could also augment this with a third table that joined the trackId and AlbumId fields (so don't have the AlbumId in the Track table). The advantage of this second approach would be that it would allow you to reuse a recording when it appeared on many albums (such as compilations). |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | It's entirely possible, you could store the field as comma-separated or XML data for example.
Whether it's *sensible* is another question - if you ever want to query how many albums have more than 10 tracks for example you aren't going to be able to write an SQL query for that and you'll have to resort to pulling the data back into your application and dissecting it there which is not ideal.
Another option is to store the data in a separate "tracks" table (i.e. normalised), but also provide a view on those tables that gives the data as a single field in a denormalised manner. Then you get the benefit of properly structured data and the ability to query the data as a single field from the view. | Use two tables, one for albums, and one for tracks.
```
Album
-----
Id
Name
Artist
etc...
Track
-----
Id
AlbumId(Foreign Key to Album Table)
Name
URL
```
You could also augment this with a third table that joined the trackId and AlbumId fields (so don't have the AlbumId in the Track table). The advantage of this second approach would be that it would allow you to reuse a recording when it appeared on many albums (such as compilations). |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | Use two tables, one for albums, and one for tracks.
```
Album
-----
Id
Name
Artist
etc...
Track
-----
Id
AlbumId(Foreign Key to Album Table)
Name
URL
```
You could also augment this with a third table that joined the trackId and AlbumId fields (so don't have the AlbumId in the Track table). The advantage of this second approach would be that it would allow you to reuse a recording when it appeared on many albums (such as compilations). | The Wikipedia article on [Database Normalization](http://en.wikipedia.org/wiki/Normal_forms) makes a reasonable effort to explain the purpose of normalization ... and the sorts of anomalies that the normalization rules are intended to prevent. |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | ```
Table: Album
ID/PK (your choice of primary key philosophy)
AlbumName
Table: Track
ID/PK (optional, could make AlbumFK, TrackNumber the primary key)
AlbumFK REFERENCES (Album.PK)
TrackNumber
TrackName
TrackURL
``` | The Wikipedia article on [Database Normalization](http://en.wikipedia.org/wiki/Normal_forms) makes a reasonable effort to explain the purpose of normalization ... and the sorts of anomalies that the normalization rules are intended to prevent. |
2,961,536 | * I would like to store album's
track names in a single field in a
database.
* The number of tracks are arbitrary
for each album.
* Each album is one record in the table.
* Each track must be linked to a specific URL which also should be stored in the database somewhere.
Is it possible to do this by storing them in a single field, or is a relational table for the track names/urls the only way to go? | 2010/06/02 | [
"https://Stackoverflow.com/questions/2961536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | It's entirely possible, you could store the field as comma-separated or XML data for example.
Whether it's *sensible* is another question - if you ever want to query how many albums have more than 10 tracks for example you aren't going to be able to write an SQL query for that and you'll have to resort to pulling the data back into your application and dissecting it there which is not ideal.
Another option is to store the data in a separate "tracks" table (i.e. normalised), but also provide a view on those tables that gives the data as a single field in a denormalised manner. Then you get the benefit of properly structured data and the ability to query the data as a single field from the view. | The Wikipedia article on [Database Normalization](http://en.wikipedia.org/wiki/Normal_forms) makes a reasonable effort to explain the purpose of normalization ... and the sorts of anomalies that the normalization rules are intended to prevent. |
39,542,132 | My php script from PuTTY on a synology sever returns this:
>
> PHP Fatal error: Call to undefined function mysqli\_connect()`.
>
>
>
Mysqli is installed on the server and has been used many times before in scripts via a browser. I don't understand why `mysqli_connect()` is supposedly undefined. How can I resolve this? | 2016/09/17 | [
"https://Stackoverflow.com/questions/39542132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | create a php file and have code <?php phpinfo(); ?> check whether mysqli section is displayed or not. It should display the following string in HTML Table format.
mysqli
MysqlI Support enabled
if mysqli is not available, then you need to enable it in php.ini / while configuring with apachee. | Web version and CLI version are using different php.ini files.
you can find out which ini file is used by the following command
```
php -i | grep php.ini
```
then configure this php.ini to make it support mysqli. |
39,542,132 | My php script from PuTTY on a synology sever returns this:
>
> PHP Fatal error: Call to undefined function mysqli\_connect()`.
>
>
>
Mysqli is installed on the server and has been used many times before in scripts via a browser. I don't understand why `mysqli_connect()` is supposedly undefined. How can I resolve this? | 2016/09/17 | [
"https://Stackoverflow.com/questions/39542132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | By running this from CLI (from Putty):
`php70 --ini`
i printed list of ini files used by PHP.
I found, that web server is using
`/usr/syno/etc/packages/WebStation/php70/conf.d/user_settings.ini`
while CLI doesn't use that file. It only using
`/usr/local/etc/php70/php.ini`
So, I had to add few lines to that file:
`sudo vi /usr/local/etc/php70/php.ini`
Here are the lines to add:
```
extension = mysqli.so
extension = pdo_mysql.so
``` | create a php file and have code <?php phpinfo(); ?> check whether mysqli section is displayed or not. It should display the following string in HTML Table format.
mysqli
MysqlI Support enabled
if mysqli is not available, then you need to enable it in php.ini / while configuring with apachee. |
39,542,132 | My php script from PuTTY on a synology sever returns this:
>
> PHP Fatal error: Call to undefined function mysqli\_connect()`.
>
>
>
Mysqli is installed on the server and has been used many times before in scripts via a browser. I don't understand why `mysqli_connect()` is supposedly undefined. How can I resolve this? | 2016/09/17 | [
"https://Stackoverflow.com/questions/39542132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | By running this from CLI (from Putty):
`php70 --ini`
i printed list of ini files used by PHP.
I found, that web server is using
`/usr/syno/etc/packages/WebStation/php70/conf.d/user_settings.ini`
while CLI doesn't use that file. It only using
`/usr/local/etc/php70/php.ini`
So, I had to add few lines to that file:
`sudo vi /usr/local/etc/php70/php.ini`
Here are the lines to add:
```
extension = mysqli.so
extension = pdo_mysql.so
``` | Web version and CLI version are using different php.ini files.
you can find out which ini file is used by the following command
```
php -i | grep php.ini
```
then configure this php.ini to make it support mysqli. |
10,316,702 | I have a program that is reading from plain text files. the amount of these files can be more that 5 Million!
When I'm reading them I found them by name! the names are basically save as x and y of a matrix for example 440x300.txt
Now I want to put all of them in one big file and index them
I mean I want to now exactly for example 440x300.txt is saved in the file from which byte and end in which byte!
My first Idea was to create a separate file and save this info in that like each line contains 440 x 300 150883 173553
but finding this info will also a lot of time!
I want to know if the is a better way to find out where do they start and end!
Somehow index the files
Please help
By the way I'm programming in Java.
Thanks in advance for your time. | 2012/04/25 | [
"https://Stackoverflow.com/questions/10316702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1029483/"
] | The only thing that worked for me was using
```
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
```
in my ViewController and presenting it with ***presentModalViewController***.
This forces the View to stay in landscape. | You can manually set the transform of the view to rotate it. For example, to rotate 90 degrees:
```
view.transform = CGAffineTransformMakeRotation( M_PI / 2 );
``` |
10,316,702 | I have a program that is reading from plain text files. the amount of these files can be more that 5 Million!
When I'm reading them I found them by name! the names are basically save as x and y of a matrix for example 440x300.txt
Now I want to put all of them in one big file and index them
I mean I want to now exactly for example 440x300.txt is saved in the file from which byte and end in which byte!
My first Idea was to create a separate file and save this info in that like each line contains 440 x 300 150883 173553
but finding this info will also a lot of time!
I want to know if the is a better way to find out where do they start and end!
Somehow index the files
Please help
By the way I'm programming in Java.
Thanks in advance for your time. | 2012/04/25 | [
"https://Stackoverflow.com/questions/10316702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1029483/"
] | You can manually set the transform of the view to rotate it. For example, to rotate 90 degrees:
```
view.transform = CGAffineTransformMakeRotation( M_PI / 2 );
``` | ```
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
```
Write in your Event. |
10,316,702 | I have a program that is reading from plain text files. the amount of these files can be more that 5 Million!
When I'm reading them I found them by name! the names are basically save as x and y of a matrix for example 440x300.txt
Now I want to put all of them in one big file and index them
I mean I want to now exactly for example 440x300.txt is saved in the file from which byte and end in which byte!
My first Idea was to create a separate file and save this info in that like each line contains 440 x 300 150883 173553
but finding this info will also a lot of time!
I want to know if the is a better way to find out where do they start and end!
Somehow index the files
Please help
By the way I'm programming in Java.
Thanks in advance for your time. | 2012/04/25 | [
"https://Stackoverflow.com/questions/10316702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1029483/"
] | The only thing that worked for me was using
```
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
```
in my ViewController and presenting it with ***presentModalViewController***.
This forces the View to stay in landscape. | ```
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
```
Write in your Event. |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | This would have major impacts across society. First, pornography and prostitution, gone. However, any concept of father hood? Also gone. Since sex is so common, without any DNA testing it would be impossible to tell who the father is. Over time, that would lead to a system of female inheritance. Since you don't know who your father is, all family ties would be through females and so property would follow that line.
Additionally, there would only be single mothers. Perhaps the government would set up a program where all men pay a child tax, to help care for and support the children in the clan, but women would basically be on there own as far as kids go.
Too keep society functioning, I would imagine getting rid of weekends for females and just have all females off while in heat so everyone else could continue working. There would also be major thoughts about the change in society. Some would embrace it and set up areas to go to while in heat. Others could try to keep up marriage and isolate themselves from anyone else of the opposite sex to stay faithful.
Depending on how predictable the schedule is, humans could either continue working together and have females in heat remove themselves, or be forced to split into two separate groups to keep men from being in constant conflict with each other over the latest women.
While most ancient societies valued children highly, it would likely be even harder to practice any sort of birth control or controlled population growth.
If our world suddenly had the same issue, the most amusing change would be advertising. Since sex isn't constantly appealing, an advertisers main hook would be gone for most of the month.
Everything else would be chaos. Any type of coed organization from schools to sports would collapse. Family ties would break down as men and women felt betrayed. Births would skyrocket as women want to be pregnant. | My initial response is to think of something along the lines of a conservative Arabic family structure, though with women even more tightly controlled as a burka won't be enough. This only lasts for a week per month, so perhaps it would only be strict isolation for that week, but otherwise a fully integrated member of society.
Romance is not just sex, so traditional family structures could still persist. Pair bonding would still develop, all the benefits of 'traditional' families would remain intact, just with women being isolated at home for a week when not pregnant. Then considering the implication of being in rut, boys would need to be turned out of the home by the time they hit puberty else they may mate with their mothers or sisters, and daughters would need to be married off before puberty as well.
Either women are isolated for a week each month (which is a considerable amount of time), or they will cause massive disruption as all males in the vicinity go into rut (cue lots of violence between fighting males and rape of nearby females). In the interest of safety, culture will likely dictate isolated imprisonment of women nearing their estrus to reduce the constant risk of all the nearby men being put into rut, not to mention issues of uncertain parentage and inbreeding.
The lack of interest in sex outside of being in rut may be taken advantage of - women could be sent to a kind of convent during their estrus. Men would simply stay away from it, and thus remain uninterested in sex. Women not in estrus could guard the facility and keep the other women imprisoned within it, and likely run by post-menopausal women.
Perhaps men would live in a barracks until they can establish a household of their own, and women would live in a convent until a man claims her. This would probably result in wealthier older men forming a household and developing a harem. Sons be sent to the barracks as soon as they might hit puberty, while daughters are either married off before puberty or sent to the convent.
Women who have recently given birth would be a serious risk as there is no means of determining when exactly they will become fertile again. Breastfeeding delays the return to fertility, but by a wildly uncertain duration, so they could unintentionally cause a serious disruption as they send all the men into rut. This may require mothers to remain isolated until their cycle returns to predictability. This may result in women being isolated for most of their lives - only be outside when prepubescent, when pregnant, or postmenopausal. Unmarried or non-breeding women would only be confined one week per cycle, but will there be any significant numbers of these?
One interesting prospect would be to abandon the idea of family groups and go with something akin to medieval monasteries - women would have a large collective residence around which much farming and industry will go on. Women not in estrus can tend the grounds and interact with men who tend them as well, while women nearing estrus or recent mothers at risk of returning to fertility would be confined to interior labors (where no men are allowed). Male children would be sent out to join some kind of fraternity, and these fraternities would fund the convents (much like generous patrons funded the medieval monasteries). In order to keep birth rates up, the champions of the sponsoring fraternities could be invited inside for a time to father some children.
Men would probably do most of the primary labor (collecting raw materials and farming/fishing/hunting), as well as trading expeditions or conducting warfare, while women would take over much of the more sedentary labors in workshops (not being allowed to roam about the countryside for much of the time).
There is a potential problem there - with men having no interest in sex without being in rut, and not having a good handle on who exactly their children are or providing an inheritance specifically for them, it may be difficult to convince men to not be selfish. Why reduce their own standard of living to support potentially unrelated women and children? This is why the older rich men with their own strictly controlled harems seems more plausible to me, but it may be possible for a large fraternal organization to keep their own stable of women (could be more or less egalitarian - though the potential for women in estrus to be used as a weapon/decoy to allow the other women to escape captivity would probably keep relations amicable). |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | I think your initial presumption should be clarified a bit. Human sexuality is not naturally private, nocturnal, or selective. Those attributes of sexuality are socially constructed and did not exist for the majority of human evolution. Privacy in any respect was really only created during the Industrial Revolution. Prior to that, families slept, and screwed, in common rooms. Only the tiny upper class had private bedrooms.
Agriculture brought about selectivity and provided motivation for monogamy that didn't exist in nomadic tribes. All pre-historic tribes which have survived to modern times share one idea - shared fatherhood. They believed that multiple men contributed to the formation of children. Most believed that women required a constant supply of semen in order for their child to develop properly. Children were thus raised by the tribe in common, and it was not resource-expensive for someone to care for children which were not their own. Once we settled down into agricultural societies, resource scarcity became much more common, famines killed off many with regularity (about every 5 years there would be a massive famine due to soil nutrient depletion), and it became extremely expensive for someone to raise a child which was not their own. This motivated men to control the sexuality of women and created the situation we've preserved to modern times of women bargaining sexual liberty for material security.
Sex was radically important to human survival. Prior to the development of language and reasoning, human survival (as a species) was pretty dicey. Compared to other animals, we are weak, slow, have no venom or fangs or natural armor, etc. We have great endurance and this allowed us to chase game to exhaustion, but that's not terribly useful for individuals. Humanity survived because of strong group cohesion. And people stuck together because of sex. Sex bonded them together and provided motivation for everyone in the tribe to stick with the tribe, to protect the tribe, and to share that game they hunted down with the tribe. This extreme necessity to be accepted by the tribe both for survival and to maintain access to sex partners led to brain development. Dealing with social situations can be very complex (especially without language) and those with the brainpower to manage it had a distinct survival advantage.
You lump all chimpanzees together in your question, and this is wrong. Bonobo chimpanzees, for instance, use sex primarily as a means of social bonding and for conflict resolution. They have mostly hidden estrus, and estrus has no influence on how actively they seek sexual interaction with others. Bonobos are our closest genetic relatives, and the primates most similar to humans in terms of sexual morphology (things like genital size, ejaculate density, sperm competition, limited sexual dimorphism, etc).
If the humans were without language, I think they would certainly go extinct were their sexuality to change as you describe. With language and technology, however, the effects would be muted and probably not lethal. Most animals have a sexuality like you describe. Those animals are also much better prepared for survival. They're strong, fast, have fangs or venom, etc. They don't rely as much upon group cohesion to survive and many don't join together in groups at all. Humanity with language, reason, and technology would, I think, be equivalent to those species with that sort of sexuality and other survival traits. Humans would have little to no reason to join together in societies, and unless economic concerns forced them to stay together, they would probably dissolve given enough time. Lack of strong selective pressure for positive sociability traits might lead to the sort of things seen in most animals where sex is for reproduction instead of pleasure, like men taking women by force and abandoning them.
I have a bit of a problem with you indicating that a lack of motivation to seek sexual pleasure would result in people being more logical. Rational thinking is inextricably bound up with emotion. In the book 'Neurological Origins of Individuality', the author describes a man who, due to an accident, loses the capacity to experience emotion. An unexpected side effect is that he becomes incapable of making decisions. At all. He could list the 'pros' and 'cons' of two choices, and no matter how lopsided the lists were, he was not capable of performing the act of actually making the choice. Emotion is necessary to carry out even the most logical thinking. To presume that sex (and the complex emotional relationships that come along with it) detracts from peoples ability to reason is inaccurate.
Also, one thing which you didn't address but I was sort of just assuming... I assume that along with these other changes, people would also be "freed" from the negative consequences of abstinence? Sex is on the same level of Maslow's Hierarchy of Needs as breathing, sweating, sleeping, eating, etc for a reason. Abstinence is not healthy. It increases risk of heart disease, several types of cancer, death (a study of a town in Ireland over decades showed men with lower sexual activity had an increased risk of death from any cause), depression, anxiety, it reduces the effectiveness of the immune system and even sense of smell. If the physiological changes which alter their sexuality don't change that aspect, you might want to consider a significant increase in mortality due to heart disease, cancer, suicide, etc.
Some sources if the topic interests you: 'Sex At Dawn', 'Sex At Dusk', 'Good Sex Illustrated', 'Sex And God: How Religion Distorts Sexuality', the 'Sociology of Sex' course from The Teaching Company (if you can find it), 'History of Sexuality' by Michel Foucalt | The most obvious result would be that there would be no concept of a family. Now the concept of a family influences a lot of things; for one, the concept of inheriting goods might not develop; without that, also the concept of property would be less strong. A lack of sexual/compassionate bindings would probably give a very individualistic society. It would also affect religion, since the concept of a father-like god in the sense we understand it would probably not develop. It also might decrease the likelihood of a single leader person also in other contexts like politics. |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | Well, extrapolating from chimpanzees and dolphins, the results might be rather grim.
Males and females have contradictory goals in species where multiple mates are an option. The reproductive expenditure in males is minimal compared to the huge expenditure of females. Therefore they follow contradictory strategies. Males use a quantity over quality strategy while females use quality over quantity. Males will knock up any female but females will be selective.
Males can fertilize many females but they can't ever be sure which females carry their young unless they control access to the females during estrous and usually always. But the females don't necessarily view any particular mate as the optimum mate so they try to escape mating restriction. The males respond by forming alliance with other males to control the females, especially in their narrow reproductive windows.
Since the only reason for males to join an alliance is to improve their chances of passing on their genes, males have little to no incentive to form alliance with any other than close blood kin. That way, regardless of who succeeds in impregnating females, some of their genes get passed on.
The base social unit chimpanzees and dolphins is a group of males who are father, sons, brothers, nephews, cousins to each other. They spend most of their time capturing females, corralling them and fighting other male groups to steal their females. In general, they kill any non-related male they come across especially infants and juveniles.
Human societies eerily follow genetically optimal paths even though they have no concept of genetics or evolutionary theory. For example, in many small scale cultures, sexual fidelity of women in marriage is not strictly enforced and marriages are usually temporary. That means that no man can ever know child of his wife of the moment is his or not. In every known instance of such societies, men concentrate their paternal attention on their nephews and nieces born of their sisters. That way, at least some of their effort is guaranteed to go towards their own gene line.
Therefore, it's likely that human society with chimpanzee like mating conditions would adopt a chimpanzee like social structure. The base social unit would be a group of related men.
It's important to note that just because men could only mate episodically does not mean that their reproductive goals would not dominate their lives. Species devote time to reproduction based on the payoff off of reproductive success not how often they actually mate.
Men would attempt to control as large a group of women as possible at all times. With human technology, men could much more easily physically control women compared to chimpanzees or dolphins having to control females with just the males own bodies. Women would likely be treated as chattel.
Close personal relationships between men and women would be rare. Men would tend to view all women of reproductive age as interchangeable. Women would attempt to be more selective but the men would not allow them to do so. Since selectivity and romance might lead to jealousy and lethal conflict, the Men's moral culture might actively view selectivity, romance and even love as immoral and dangerous perversions.
"Marriages" would likely be one group of men sending their daughters out to close but not to closely related group of men for the purposes of forming military and economic alliances. New family groups of males would arise from multiple births to traded daughters from the same male group. Males would always stay with their families but women would get sent out although possibly in batches.
Close inbreeding would be a constant problem. Overall genetic diversity would be low. Entire male family groups could be wiped out by single disease.
When women came into estrous, they would be especially isolated or controlled not only to control access but to prevent violent quarrels among men. A detached woman with no controlling male group would be regarded as source of violent conflict and therefore very dangerous. A detached woman in estrous might be killed on sight just to prevent open war.
Since their sexuality only turned on episodically, men and women would emotionally bond with members of their own sex and would like socialize only within their own sex. Each sex would have it's own distinctive subculture.
The male society would likely be structured and hierarchical with great emphasis on ritual, respect and likely dueling. Males would mostly fight or train to do so. They would shun productive labor and see warrior as the ideal male. For the higher status males, they would rather starve than get their hands dirty.
Women's culture would likely be less hierarchical, would be based on status linked to age and number of sons. Since men would view women as interchangeable, women would not have status based on their mates rank or favoritism from males. Instead, status would likely depend on skill of assisting in child birth and general raising of children.
Boys would have to be raised by women at least to weaning age. In a bronze age culture that would be around 4. In known cultures where boys and girls are separated, the usual age is 7. Women will try to favor their own offspring so women will nurse and raise their own sons as much as possible. Therefore, a man's mother might be the only women he views as special and with affection. He might visit her and care for her specially.
A women's ultimate status therefore will be linked to the status of her sons. A women who gives births to only sons will have a high status while a woman who gives birth only to daughters will have none.
If men fought constantly, then women would likely perform most productive labor. That is the pattern in all low-tech militaristic extant cultures. However, that might conflict with containment.
Architecture would be based on walled compounds with the women/children's quarters in the center and the men's quarters surrounding. Men would likely sleep in barrack like arrangements.
It's likely that art and literary themes would be vastly different. Sexual beauty would not be an important theme. Romance would likely be unknown. Most literature and art would concern masculine power struggles and conflicts over status and loyalty to elders.
As the society grew more large scale (assuming it could given it's fractious nature) the most dominate male groups would have the most females. In groups with a lot of females, there might be enough females for each male to start corralling his own set away from the other males. At first, this might seem like a good way to use abundance to avoid conflict but eventually each male would stop looking at his relations as allies and start seeing them as competitors. Aristocratic male groups might be treacherous and prone to blow apart while lower class groups would be more mutually supportive and bonding.
As technology advances, there might be a subtle power shift if women did most of the work. As society became less violent, productive work would increasingly provide economic power and most of the work would still be done by women. The condition might be like the early industrial era with aristocrats still strutting around while the emerging productive class quietly took over. Men might still value fighting but fight little. They would likely just laze about. Superficially they would order women about and still control them sexually, but in all other matters women would maneuver men to do what the women wanted. Since men would consider all non-military matters as beneath them, this would be easy.
An obvious story potential would lay in some humans being born in each generation immune to the altering-effect and having the natural human mating pattern of always interested. Such individuals might be regarded as dangerous and be hunted.
A woman that was always sexually receptive would likely get raped to death if she couldn't disguise her availability. On the other hand, the magic wand pheromones simply might not ever manifest and no man would ever show any interest in her.
A male with sex always on his mind would likely be regarded as insane and prone to unnecessary violence. Out of frustration he might try to have intercourse with non-receptive females resulting in injury. (This happens in some over-bred domestic species of birds when the males lose the ability to distinguish when females are in season.)
If the reversions were relatively common, say 2% of the population, they might create a special caste for them and isolate the "afflicted' men and women together. They might develope some special task or function which only the reversions could effectively carry out.
If women went into estrous in sync with women near by, then all the women in a male group might activate at once. This could cause the male group to be vulnerable to attack. Male groups might divide into mating and guarding groups, likely based on lot or strict rotation. The mating groups would sequester themselves in the women's quarters for the duration and the guards would stay away for the duration.
Contrariwise, women in estrous could be used as weapons. If men lost control in their presence, then sending a few receptive women into a group of enemy males would make them helpless, if another male group could attack from outside of the range of female hormones.
That's about all I think of for now. | I think your initial presumption should be clarified a bit. Human sexuality is not naturally private, nocturnal, or selective. Those attributes of sexuality are socially constructed and did not exist for the majority of human evolution. Privacy in any respect was really only created during the Industrial Revolution. Prior to that, families slept, and screwed, in common rooms. Only the tiny upper class had private bedrooms.
Agriculture brought about selectivity and provided motivation for monogamy that didn't exist in nomadic tribes. All pre-historic tribes which have survived to modern times share one idea - shared fatherhood. They believed that multiple men contributed to the formation of children. Most believed that women required a constant supply of semen in order for their child to develop properly. Children were thus raised by the tribe in common, and it was not resource-expensive for someone to care for children which were not their own. Once we settled down into agricultural societies, resource scarcity became much more common, famines killed off many with regularity (about every 5 years there would be a massive famine due to soil nutrient depletion), and it became extremely expensive for someone to raise a child which was not their own. This motivated men to control the sexuality of women and created the situation we've preserved to modern times of women bargaining sexual liberty for material security.
Sex was radically important to human survival. Prior to the development of language and reasoning, human survival (as a species) was pretty dicey. Compared to other animals, we are weak, slow, have no venom or fangs or natural armor, etc. We have great endurance and this allowed us to chase game to exhaustion, but that's not terribly useful for individuals. Humanity survived because of strong group cohesion. And people stuck together because of sex. Sex bonded them together and provided motivation for everyone in the tribe to stick with the tribe, to protect the tribe, and to share that game they hunted down with the tribe. This extreme necessity to be accepted by the tribe both for survival and to maintain access to sex partners led to brain development. Dealing with social situations can be very complex (especially without language) and those with the brainpower to manage it had a distinct survival advantage.
You lump all chimpanzees together in your question, and this is wrong. Bonobo chimpanzees, for instance, use sex primarily as a means of social bonding and for conflict resolution. They have mostly hidden estrus, and estrus has no influence on how actively they seek sexual interaction with others. Bonobos are our closest genetic relatives, and the primates most similar to humans in terms of sexual morphology (things like genital size, ejaculate density, sperm competition, limited sexual dimorphism, etc).
If the humans were without language, I think they would certainly go extinct were their sexuality to change as you describe. With language and technology, however, the effects would be muted and probably not lethal. Most animals have a sexuality like you describe. Those animals are also much better prepared for survival. They're strong, fast, have fangs or venom, etc. They don't rely as much upon group cohesion to survive and many don't join together in groups at all. Humanity with language, reason, and technology would, I think, be equivalent to those species with that sort of sexuality and other survival traits. Humans would have little to no reason to join together in societies, and unless economic concerns forced them to stay together, they would probably dissolve given enough time. Lack of strong selective pressure for positive sociability traits might lead to the sort of things seen in most animals where sex is for reproduction instead of pleasure, like men taking women by force and abandoning them.
I have a bit of a problem with you indicating that a lack of motivation to seek sexual pleasure would result in people being more logical. Rational thinking is inextricably bound up with emotion. In the book 'Neurological Origins of Individuality', the author describes a man who, due to an accident, loses the capacity to experience emotion. An unexpected side effect is that he becomes incapable of making decisions. At all. He could list the 'pros' and 'cons' of two choices, and no matter how lopsided the lists were, he was not capable of performing the act of actually making the choice. Emotion is necessary to carry out even the most logical thinking. To presume that sex (and the complex emotional relationships that come along with it) detracts from peoples ability to reason is inaccurate.
Also, one thing which you didn't address but I was sort of just assuming... I assume that along with these other changes, people would also be "freed" from the negative consequences of abstinence? Sex is on the same level of Maslow's Hierarchy of Needs as breathing, sweating, sleeping, eating, etc for a reason. Abstinence is not healthy. It increases risk of heart disease, several types of cancer, death (a study of a town in Ireland over decades showed men with lower sexual activity had an increased risk of death from any cause), depression, anxiety, it reduces the effectiveness of the immune system and even sense of smell. If the physiological changes which alter their sexuality don't change that aspect, you might want to consider a significant increase in mortality due to heart disease, cancer, suicide, etc.
Some sources if the topic interests you: 'Sex At Dawn', 'Sex At Dusk', 'Good Sex Illustrated', 'Sex And God: How Religion Distorts Sexuality', the 'Sociology of Sex' course from The Teaching Company (if you can find it), 'History of Sexuality' by Michel Foucalt |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | Well, extrapolating from chimpanzees and dolphins, the results might be rather grim.
Males and females have contradictory goals in species where multiple mates are an option. The reproductive expenditure in males is minimal compared to the huge expenditure of females. Therefore they follow contradictory strategies. Males use a quantity over quality strategy while females use quality over quantity. Males will knock up any female but females will be selective.
Males can fertilize many females but they can't ever be sure which females carry their young unless they control access to the females during estrous and usually always. But the females don't necessarily view any particular mate as the optimum mate so they try to escape mating restriction. The males respond by forming alliance with other males to control the females, especially in their narrow reproductive windows.
Since the only reason for males to join an alliance is to improve their chances of passing on their genes, males have little to no incentive to form alliance with any other than close blood kin. That way, regardless of who succeeds in impregnating females, some of their genes get passed on.
The base social unit chimpanzees and dolphins is a group of males who are father, sons, brothers, nephews, cousins to each other. They spend most of their time capturing females, corralling them and fighting other male groups to steal their females. In general, they kill any non-related male they come across especially infants and juveniles.
Human societies eerily follow genetically optimal paths even though they have no concept of genetics or evolutionary theory. For example, in many small scale cultures, sexual fidelity of women in marriage is not strictly enforced and marriages are usually temporary. That means that no man can ever know child of his wife of the moment is his or not. In every known instance of such societies, men concentrate their paternal attention on their nephews and nieces born of their sisters. That way, at least some of their effort is guaranteed to go towards their own gene line.
Therefore, it's likely that human society with chimpanzee like mating conditions would adopt a chimpanzee like social structure. The base social unit would be a group of related men.
It's important to note that just because men could only mate episodically does not mean that their reproductive goals would not dominate their lives. Species devote time to reproduction based on the payoff off of reproductive success not how often they actually mate.
Men would attempt to control as large a group of women as possible at all times. With human technology, men could much more easily physically control women compared to chimpanzees or dolphins having to control females with just the males own bodies. Women would likely be treated as chattel.
Close personal relationships between men and women would be rare. Men would tend to view all women of reproductive age as interchangeable. Women would attempt to be more selective but the men would not allow them to do so. Since selectivity and romance might lead to jealousy and lethal conflict, the Men's moral culture might actively view selectivity, romance and even love as immoral and dangerous perversions.
"Marriages" would likely be one group of men sending their daughters out to close but not to closely related group of men for the purposes of forming military and economic alliances. New family groups of males would arise from multiple births to traded daughters from the same male group. Males would always stay with their families but women would get sent out although possibly in batches.
Close inbreeding would be a constant problem. Overall genetic diversity would be low. Entire male family groups could be wiped out by single disease.
When women came into estrous, they would be especially isolated or controlled not only to control access but to prevent violent quarrels among men. A detached woman with no controlling male group would be regarded as source of violent conflict and therefore very dangerous. A detached woman in estrous might be killed on sight just to prevent open war.
Since their sexuality only turned on episodically, men and women would emotionally bond with members of their own sex and would like socialize only within their own sex. Each sex would have it's own distinctive subculture.
The male society would likely be structured and hierarchical with great emphasis on ritual, respect and likely dueling. Males would mostly fight or train to do so. They would shun productive labor and see warrior as the ideal male. For the higher status males, they would rather starve than get their hands dirty.
Women's culture would likely be less hierarchical, would be based on status linked to age and number of sons. Since men would view women as interchangeable, women would not have status based on their mates rank or favoritism from males. Instead, status would likely depend on skill of assisting in child birth and general raising of children.
Boys would have to be raised by women at least to weaning age. In a bronze age culture that would be around 4. In known cultures where boys and girls are separated, the usual age is 7. Women will try to favor their own offspring so women will nurse and raise their own sons as much as possible. Therefore, a man's mother might be the only women he views as special and with affection. He might visit her and care for her specially.
A women's ultimate status therefore will be linked to the status of her sons. A women who gives births to only sons will have a high status while a woman who gives birth only to daughters will have none.
If men fought constantly, then women would likely perform most productive labor. That is the pattern in all low-tech militaristic extant cultures. However, that might conflict with containment.
Architecture would be based on walled compounds with the women/children's quarters in the center and the men's quarters surrounding. Men would likely sleep in barrack like arrangements.
It's likely that art and literary themes would be vastly different. Sexual beauty would not be an important theme. Romance would likely be unknown. Most literature and art would concern masculine power struggles and conflicts over status and loyalty to elders.
As the society grew more large scale (assuming it could given it's fractious nature) the most dominate male groups would have the most females. In groups with a lot of females, there might be enough females for each male to start corralling his own set away from the other males. At first, this might seem like a good way to use abundance to avoid conflict but eventually each male would stop looking at his relations as allies and start seeing them as competitors. Aristocratic male groups might be treacherous and prone to blow apart while lower class groups would be more mutually supportive and bonding.
As technology advances, there might be a subtle power shift if women did most of the work. As society became less violent, productive work would increasingly provide economic power and most of the work would still be done by women. The condition might be like the early industrial era with aristocrats still strutting around while the emerging productive class quietly took over. Men might still value fighting but fight little. They would likely just laze about. Superficially they would order women about and still control them sexually, but in all other matters women would maneuver men to do what the women wanted. Since men would consider all non-military matters as beneath them, this would be easy.
An obvious story potential would lay in some humans being born in each generation immune to the altering-effect and having the natural human mating pattern of always interested. Such individuals might be regarded as dangerous and be hunted.
A woman that was always sexually receptive would likely get raped to death if she couldn't disguise her availability. On the other hand, the magic wand pheromones simply might not ever manifest and no man would ever show any interest in her.
A male with sex always on his mind would likely be regarded as insane and prone to unnecessary violence. Out of frustration he might try to have intercourse with non-receptive females resulting in injury. (This happens in some over-bred domestic species of birds when the males lose the ability to distinguish when females are in season.)
If the reversions were relatively common, say 2% of the population, they might create a special caste for them and isolate the "afflicted' men and women together. They might develope some special task or function which only the reversions could effectively carry out.
If women went into estrous in sync with women near by, then all the women in a male group might activate at once. This could cause the male group to be vulnerable to attack. Male groups might divide into mating and guarding groups, likely based on lot or strict rotation. The mating groups would sequester themselves in the women's quarters for the duration and the guards would stay away for the duration.
Contrariwise, women in estrous could be used as weapons. If men lost control in their presence, then sending a few receptive women into a group of enemy males would make them helpless, if another male group could attack from outside of the range of female hormones.
That's about all I think of for now. | My initial response is to think of something along the lines of a conservative Arabic family structure, though with women even more tightly controlled as a burka won't be enough. This only lasts for a week per month, so perhaps it would only be strict isolation for that week, but otherwise a fully integrated member of society.
Romance is not just sex, so traditional family structures could still persist. Pair bonding would still develop, all the benefits of 'traditional' families would remain intact, just with women being isolated at home for a week when not pregnant. Then considering the implication of being in rut, boys would need to be turned out of the home by the time they hit puberty else they may mate with their mothers or sisters, and daughters would need to be married off before puberty as well.
Either women are isolated for a week each month (which is a considerable amount of time), or they will cause massive disruption as all males in the vicinity go into rut (cue lots of violence between fighting males and rape of nearby females). In the interest of safety, culture will likely dictate isolated imprisonment of women nearing their estrus to reduce the constant risk of all the nearby men being put into rut, not to mention issues of uncertain parentage and inbreeding.
The lack of interest in sex outside of being in rut may be taken advantage of - women could be sent to a kind of convent during their estrus. Men would simply stay away from it, and thus remain uninterested in sex. Women not in estrus could guard the facility and keep the other women imprisoned within it, and likely run by post-menopausal women.
Perhaps men would live in a barracks until they can establish a household of their own, and women would live in a convent until a man claims her. This would probably result in wealthier older men forming a household and developing a harem. Sons be sent to the barracks as soon as they might hit puberty, while daughters are either married off before puberty or sent to the convent.
Women who have recently given birth would be a serious risk as there is no means of determining when exactly they will become fertile again. Breastfeeding delays the return to fertility, but by a wildly uncertain duration, so they could unintentionally cause a serious disruption as they send all the men into rut. This may require mothers to remain isolated until their cycle returns to predictability. This may result in women being isolated for most of their lives - only be outside when prepubescent, when pregnant, or postmenopausal. Unmarried or non-breeding women would only be confined one week per cycle, but will there be any significant numbers of these?
One interesting prospect would be to abandon the idea of family groups and go with something akin to medieval monasteries - women would have a large collective residence around which much farming and industry will go on. Women not in estrus can tend the grounds and interact with men who tend them as well, while women nearing estrus or recent mothers at risk of returning to fertility would be confined to interior labors (where no men are allowed). Male children would be sent out to join some kind of fraternity, and these fraternities would fund the convents (much like generous patrons funded the medieval monasteries). In order to keep birth rates up, the champions of the sponsoring fraternities could be invited inside for a time to father some children.
Men would probably do most of the primary labor (collecting raw materials and farming/fishing/hunting), as well as trading expeditions or conducting warfare, while women would take over much of the more sedentary labors in workshops (not being allowed to roam about the countryside for much of the time).
There is a potential problem there - with men having no interest in sex without being in rut, and not having a good handle on who exactly their children are or providing an inheritance specifically for them, it may be difficult to convince men to not be selfish. Why reduce their own standard of living to support potentially unrelated women and children? This is why the older rich men with their own strictly controlled harems seems more plausible to me, but it may be possible for a large fraternal organization to keep their own stable of women (could be more or less egalitarian - though the potential for women in estrus to be used as a weapon/decoy to allow the other women to escape captivity would probably keep relations amicable). |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | Well, extrapolating from chimpanzees and dolphins, the results might be rather grim.
Males and females have contradictory goals in species where multiple mates are an option. The reproductive expenditure in males is minimal compared to the huge expenditure of females. Therefore they follow contradictory strategies. Males use a quantity over quality strategy while females use quality over quantity. Males will knock up any female but females will be selective.
Males can fertilize many females but they can't ever be sure which females carry their young unless they control access to the females during estrous and usually always. But the females don't necessarily view any particular mate as the optimum mate so they try to escape mating restriction. The males respond by forming alliance with other males to control the females, especially in their narrow reproductive windows.
Since the only reason for males to join an alliance is to improve their chances of passing on their genes, males have little to no incentive to form alliance with any other than close blood kin. That way, regardless of who succeeds in impregnating females, some of their genes get passed on.
The base social unit chimpanzees and dolphins is a group of males who are father, sons, brothers, nephews, cousins to each other. They spend most of their time capturing females, corralling them and fighting other male groups to steal their females. In general, they kill any non-related male they come across especially infants and juveniles.
Human societies eerily follow genetically optimal paths even though they have no concept of genetics or evolutionary theory. For example, in many small scale cultures, sexual fidelity of women in marriage is not strictly enforced and marriages are usually temporary. That means that no man can ever know child of his wife of the moment is his or not. In every known instance of such societies, men concentrate their paternal attention on their nephews and nieces born of their sisters. That way, at least some of their effort is guaranteed to go towards their own gene line.
Therefore, it's likely that human society with chimpanzee like mating conditions would adopt a chimpanzee like social structure. The base social unit would be a group of related men.
It's important to note that just because men could only mate episodically does not mean that their reproductive goals would not dominate their lives. Species devote time to reproduction based on the payoff off of reproductive success not how often they actually mate.
Men would attempt to control as large a group of women as possible at all times. With human technology, men could much more easily physically control women compared to chimpanzees or dolphins having to control females with just the males own bodies. Women would likely be treated as chattel.
Close personal relationships between men and women would be rare. Men would tend to view all women of reproductive age as interchangeable. Women would attempt to be more selective but the men would not allow them to do so. Since selectivity and romance might lead to jealousy and lethal conflict, the Men's moral culture might actively view selectivity, romance and even love as immoral and dangerous perversions.
"Marriages" would likely be one group of men sending their daughters out to close but not to closely related group of men for the purposes of forming military and economic alliances. New family groups of males would arise from multiple births to traded daughters from the same male group. Males would always stay with their families but women would get sent out although possibly in batches.
Close inbreeding would be a constant problem. Overall genetic diversity would be low. Entire male family groups could be wiped out by single disease.
When women came into estrous, they would be especially isolated or controlled not only to control access but to prevent violent quarrels among men. A detached woman with no controlling male group would be regarded as source of violent conflict and therefore very dangerous. A detached woman in estrous might be killed on sight just to prevent open war.
Since their sexuality only turned on episodically, men and women would emotionally bond with members of their own sex and would like socialize only within their own sex. Each sex would have it's own distinctive subculture.
The male society would likely be structured and hierarchical with great emphasis on ritual, respect and likely dueling. Males would mostly fight or train to do so. They would shun productive labor and see warrior as the ideal male. For the higher status males, they would rather starve than get their hands dirty.
Women's culture would likely be less hierarchical, would be based on status linked to age and number of sons. Since men would view women as interchangeable, women would not have status based on their mates rank or favoritism from males. Instead, status would likely depend on skill of assisting in child birth and general raising of children.
Boys would have to be raised by women at least to weaning age. In a bronze age culture that would be around 4. In known cultures where boys and girls are separated, the usual age is 7. Women will try to favor their own offspring so women will nurse and raise their own sons as much as possible. Therefore, a man's mother might be the only women he views as special and with affection. He might visit her and care for her specially.
A women's ultimate status therefore will be linked to the status of her sons. A women who gives births to only sons will have a high status while a woman who gives birth only to daughters will have none.
If men fought constantly, then women would likely perform most productive labor. That is the pattern in all low-tech militaristic extant cultures. However, that might conflict with containment.
Architecture would be based on walled compounds with the women/children's quarters in the center and the men's quarters surrounding. Men would likely sleep in barrack like arrangements.
It's likely that art and literary themes would be vastly different. Sexual beauty would not be an important theme. Romance would likely be unknown. Most literature and art would concern masculine power struggles and conflicts over status and loyalty to elders.
As the society grew more large scale (assuming it could given it's fractious nature) the most dominate male groups would have the most females. In groups with a lot of females, there might be enough females for each male to start corralling his own set away from the other males. At first, this might seem like a good way to use abundance to avoid conflict but eventually each male would stop looking at his relations as allies and start seeing them as competitors. Aristocratic male groups might be treacherous and prone to blow apart while lower class groups would be more mutually supportive and bonding.
As technology advances, there might be a subtle power shift if women did most of the work. As society became less violent, productive work would increasingly provide economic power and most of the work would still be done by women. The condition might be like the early industrial era with aristocrats still strutting around while the emerging productive class quietly took over. Men might still value fighting but fight little. They would likely just laze about. Superficially they would order women about and still control them sexually, but in all other matters women would maneuver men to do what the women wanted. Since men would consider all non-military matters as beneath them, this would be easy.
An obvious story potential would lay in some humans being born in each generation immune to the altering-effect and having the natural human mating pattern of always interested. Such individuals might be regarded as dangerous and be hunted.
A woman that was always sexually receptive would likely get raped to death if she couldn't disguise her availability. On the other hand, the magic wand pheromones simply might not ever manifest and no man would ever show any interest in her.
A male with sex always on his mind would likely be regarded as insane and prone to unnecessary violence. Out of frustration he might try to have intercourse with non-receptive females resulting in injury. (This happens in some over-bred domestic species of birds when the males lose the ability to distinguish when females are in season.)
If the reversions were relatively common, say 2% of the population, they might create a special caste for them and isolate the "afflicted' men and women together. They might develope some special task or function which only the reversions could effectively carry out.
If women went into estrous in sync with women near by, then all the women in a male group might activate at once. This could cause the male group to be vulnerable to attack. Male groups might divide into mating and guarding groups, likely based on lot or strict rotation. The mating groups would sequester themselves in the women's quarters for the duration and the guards would stay away for the duration.
Contrariwise, women in estrous could be used as weapons. If men lost control in their presence, then sending a few receptive women into a group of enemy males would make them helpless, if another male group could attack from outside of the range of female hormones.
That's about all I think of for now. | The solution my early-iron-age settlers came up with is gender segregation enabled by the design of their settlements. Men live in one district, women in another, and between them is two districts, one for trade where both men and women can meet (and accept the risk that they may encounter or be a woman going into heat, who will not be able to avoid the consequences of that), and the other an area of parkland where people in heat/rut do what they have to do.
Since male-only and female only areas do not permit members of the opposite gender (unless infertile, e.g. menopausal women or male castrati), those wanting to avoid reproductive matters won't be in a position where it will be forced on them.
Women going into heat in the trade area (and any men following them) are sent to the parkland. |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | This would have major impacts across society. First, pornography and prostitution, gone. However, any concept of father hood? Also gone. Since sex is so common, without any DNA testing it would be impossible to tell who the father is. Over time, that would lead to a system of female inheritance. Since you don't know who your father is, all family ties would be through females and so property would follow that line.
Additionally, there would only be single mothers. Perhaps the government would set up a program where all men pay a child tax, to help care for and support the children in the clan, but women would basically be on there own as far as kids go.
Too keep society functioning, I would imagine getting rid of weekends for females and just have all females off while in heat so everyone else could continue working. There would also be major thoughts about the change in society. Some would embrace it and set up areas to go to while in heat. Others could try to keep up marriage and isolate themselves from anyone else of the opposite sex to stay faithful.
Depending on how predictable the schedule is, humans could either continue working together and have females in heat remove themselves, or be forced to split into two separate groups to keep men from being in constant conflict with each other over the latest women.
While most ancient societies valued children highly, it would likely be even harder to practice any sort of birth control or controlled population growth.
If our world suddenly had the same issue, the most amusing change would be advertising. Since sex isn't constantly appealing, an advertisers main hook would be gone for most of the month.
Everything else would be chaos. Any type of coed organization from schools to sports would collapse. Family ties would break down as men and women felt betrayed. Births would skyrocket as women want to be pregnant. | The most obvious result would be that there would be no concept of a family. Now the concept of a family influences a lot of things; for one, the concept of inheriting goods might not develop; without that, also the concept of property would be less strong. A lack of sexual/compassionate bindings would probably give a very individualistic society. It would also affect religion, since the concept of a father-like god in the sense we understand it would probably not develop. It also might decrease the likelihood of a single leader person also in other contexts like politics. |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | Given that humanity has evolved from what we believe were such species, I would expect that any such society would not be as successful as ours. We evolved our current forms of sexuality precisely because they were more successful.
In your description of human sexuality you miss the most important factor behind the vast majority of human sexual activity - it is an important part of human pair bonding. [Recent studies suggest that when it comes to conception women are actually programmed to seek very different partners to those they would form a relationship with](http://news.bbc.co.uk/1/hi/sci/tech/376321.stm). Even at a base, instinctual level almost the entirety of the sexual activity within this relationship is motivated by the desire to bond and form a closely knit unit, and not to conceive. Without this "recreational" sexual activity, it is unclear to what level male/female relationships would develop. Without the support of such a relationship, new and expectant mothers may face significant difficulty.
In humans, as compared with other species, the male and female are remarkably equivalent in the overwhelming majority of qualities and abilities. However, relative to other species, human pregnancy is especially restrictive - a heavily pregnant cow is not nearly as restricted in its movement as a heavily pregnant woman. Worse, excessive exercise during pregnancy is heavily associated with miscarriage - and strenuous agricultural work would be more so. This means that for a period of time a pregnant woman will contribute less and demand more. Also, human newborn are unusually helpless for an unusually long period of time - it is perhaps 4-5 years before they have any real hope of fending for themselves, and much, much longer before they have a *good* chance.
Now, it is possible that a woman will be sufficiently supported by her family or wider society, but there are difficulties here. Firstly, in an early agrarian society life expectancy is short and mortality at all stages of life, especially infancy, is high. Even in our own world, the typical response to high infant mortality is a higher birth rate. Families will most likely be very broad but lack depth. Relative to modern families there will be fewer elderly relatives per young child, less attention to go around, and less spare capacity in the system to support them. The "dreadful algebra of necessity" creates a kind of terrible paradox for children - they are both loved and unwanted, both essential and disposable. In our own world, impoverished children have had a terribly bad lot in life and most societies throughout most of history have done very little to help. It seems unlikely then that a pregnant woman or new mother, unable to depend on the father, could reliably depend on significant support from society. Furthermore, by limiting the development of pair bonding, any "family" will be restricted to female ancestors and their descendants (of both sexes). Realistically, extended families will comprise somewhere between a quarter and a half of the individuals that would have been included in a pair bonded society.
In a bronze- to iron-age society, I would expect all of this to dramatically increase the depth and duration of periods of poverty and hardship, exacerbating food shortages and severely limiting the supply of surplus labour that could be turned to technological development.
As for modern society suddenly catching the disease, I have far fewer fears. With the high levels of social security enjoyed by modern civilisation, established charitable organisations and well developed systems of state support, society would largely continue unchanged. There would probably be increased pressure on housing as people lived separately rather than together, but otherwise we know that single parents and their children are able to live very good lives. | There is plenty of material in the earlier answers to make them nearly comprehensive; so while I agree with those earlier answers, I will only expand on a devil's advocate view for the fun of it:
For women, due to both sexual dimorphism and having to bear all the burdens of pregnancy, these urges (if unchecked) will cause them to be become woefully 2nd class citizens. They would likely be pregnant somewhat continuously from the age of 14 on, but unlike their 2nd class position IRL (just a hundred years back in America, and still extant in much of the world) in this fantasy they don't even have husbands protecting them or their children. For the last three months of pregnancy and two months after (to recover and nurse infants) they are much less capable of working for a living, with no adult partner to care and provide for them. That is an economic and social disaster for women; in this non-technological society no work means no food.
But there is an out! Presuming women are not **owned** by men and are free to act independently: They aren't beholden to husbands, or sons for that matter. So women can bond *with each other* in coalitions; societies of their own.
The purpose of their bonding is not sexual but to provide for and sequester each other when one of their members is in heat, so they *never* get pregnant, because they enter a voluntary state of confinement while they wait out their periodic temporary insanity.
This is a socialist solution. non-estrus females can do the hunting, gathering, herding and provide defensive military. Production from the group ensures women in heat are fed, sheltered and protected from any males.
Not to engage in the prurient details; but I will note that if denying their sexual urges by confinement is too much for them psychologically, then no matter how primitive the society it is relatively easy for women, alone or with others, to simulate the mechanics of the male role in sex.
What are the ramifications of the women's guild?
* No children unless they say so.
* When they do allow children, controlled and supervised mating means certainty about paternity for the father, which can then include agreement for child support and raising.
* Broader social roles for women: They aren't the mother of six at the age of 20, and do not have to be a mother at all if (in their rational times) they do not wish to be.
* They have exactly as many children as they want, when they want them.
* Social cohesion and separate politics: They are bound to their sisterhood of some dozens; they have their own leaders, and such sisterhoods can form a wider regional guild; like one per village; so women can travel and have places to stay and be sequestered and protected during estrus; so they have groups to join if they choose to move elsewhere on a permanent basis.
* They can raise their children, on their own, and instill in them the moral values **the women** choose, which will include for both genders an acceptance that women are in charge and males are subordinate workers.
* As a result, most males will be raised without ever experiencing a women in heat; the women themselves will ensure that doesn't happen.
They can isolate males a year or two before the males enter puberty, and the males won't mind: Since they first learned to talk, the mothers have long explained the necessity of this isolation, and in fact it is a celebration of their impending maturity and taking on the role of support for their mothers and sisters, the role the men will believe they were *born* to do.
Perhaps if they do it well then someday, the mothers will deem them worthy, and grant them the right to father a few children of their own; and much like modern society, share the joys of their childhood and take pride in their accomplishments, even if they **are** raised and educated by the guild to be subordinate males.
In short, this scenario could easily become a pure matriarchy; only **women** decide who will be fathers, and then they raise males and females to believe this is the way society **must** be. The males only earn the right to be fathers through hunting, military service (and protection of women from rogue males), farming and other work on behalf of the women.
I will note that most societies of the past (and most today, for that matter) raise **women** in a culture that constantly reinforces the belief that they are the weaker sex, not just physically but mentally and morally, and thus are rightfully subordinate to males. The Bible says so explicitly!
In this fantasy world, a mechanism exists to reverse that dynamic, and I see no reason to think males would be any more resistant than females to being subjugated by culture in this way, if males are raised from birth to think so.
Remember that heightened rationality component: The women's guild gave them life, raised and fed them, protected them and educated them. Why shouldn't they be beholden to the guild, to their mothers and sisters, above all else? |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | This would have major impacts across society. First, pornography and prostitution, gone. However, any concept of father hood? Also gone. Since sex is so common, without any DNA testing it would be impossible to tell who the father is. Over time, that would lead to a system of female inheritance. Since you don't know who your father is, all family ties would be through females and so property would follow that line.
Additionally, there would only be single mothers. Perhaps the government would set up a program where all men pay a child tax, to help care for and support the children in the clan, but women would basically be on there own as far as kids go.
Too keep society functioning, I would imagine getting rid of weekends for females and just have all females off while in heat so everyone else could continue working. There would also be major thoughts about the change in society. Some would embrace it and set up areas to go to while in heat. Others could try to keep up marriage and isolate themselves from anyone else of the opposite sex to stay faithful.
Depending on how predictable the schedule is, humans could either continue working together and have females in heat remove themselves, or be forced to split into two separate groups to keep men from being in constant conflict with each other over the latest women.
While most ancient societies valued children highly, it would likely be even harder to practice any sort of birth control or controlled population growth.
If our world suddenly had the same issue, the most amusing change would be advertising. Since sex isn't constantly appealing, an advertisers main hook would be gone for most of the month.
Everything else would be chaos. Any type of coed organization from schools to sports would collapse. Family ties would break down as men and women felt betrayed. Births would skyrocket as women want to be pregnant. | The solution my early-iron-age settlers came up with is gender segregation enabled by the design of their settlements. Men live in one district, women in another, and between them is two districts, one for trade where both men and women can meet (and accept the risk that they may encounter or be a woman going into heat, who will not be able to avoid the consequences of that), and the other an area of parkland where people in heat/rut do what they have to do.
Since male-only and female only areas do not permit members of the opposite gender (unless infertile, e.g. menopausal women or male castrati), those wanting to avoid reproductive matters won't be in a position where it will be forced on them.
Women going into heat in the trade area (and any men following them) are sent to the parkland. |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | Given that humanity has evolved from what we believe were such species, I would expect that any such society would not be as successful as ours. We evolved our current forms of sexuality precisely because they were more successful.
In your description of human sexuality you miss the most important factor behind the vast majority of human sexual activity - it is an important part of human pair bonding. [Recent studies suggest that when it comes to conception women are actually programmed to seek very different partners to those they would form a relationship with](http://news.bbc.co.uk/1/hi/sci/tech/376321.stm). Even at a base, instinctual level almost the entirety of the sexual activity within this relationship is motivated by the desire to bond and form a closely knit unit, and not to conceive. Without this "recreational" sexual activity, it is unclear to what level male/female relationships would develop. Without the support of such a relationship, new and expectant mothers may face significant difficulty.
In humans, as compared with other species, the male and female are remarkably equivalent in the overwhelming majority of qualities and abilities. However, relative to other species, human pregnancy is especially restrictive - a heavily pregnant cow is not nearly as restricted in its movement as a heavily pregnant woman. Worse, excessive exercise during pregnancy is heavily associated with miscarriage - and strenuous agricultural work would be more so. This means that for a period of time a pregnant woman will contribute less and demand more. Also, human newborn are unusually helpless for an unusually long period of time - it is perhaps 4-5 years before they have any real hope of fending for themselves, and much, much longer before they have a *good* chance.
Now, it is possible that a woman will be sufficiently supported by her family or wider society, but there are difficulties here. Firstly, in an early agrarian society life expectancy is short and mortality at all stages of life, especially infancy, is high. Even in our own world, the typical response to high infant mortality is a higher birth rate. Families will most likely be very broad but lack depth. Relative to modern families there will be fewer elderly relatives per young child, less attention to go around, and less spare capacity in the system to support them. The "dreadful algebra of necessity" creates a kind of terrible paradox for children - they are both loved and unwanted, both essential and disposable. In our own world, impoverished children have had a terribly bad lot in life and most societies throughout most of history have done very little to help. It seems unlikely then that a pregnant woman or new mother, unable to depend on the father, could reliably depend on significant support from society. Furthermore, by limiting the development of pair bonding, any "family" will be restricted to female ancestors and their descendants (of both sexes). Realistically, extended families will comprise somewhere between a quarter and a half of the individuals that would have been included in a pair bonded society.
In a bronze- to iron-age society, I would expect all of this to dramatically increase the depth and duration of periods of poverty and hardship, exacerbating food shortages and severely limiting the supply of surplus labour that could be turned to technological development.
As for modern society suddenly catching the disease, I have far fewer fears. With the high levels of social security enjoyed by modern civilisation, established charitable organisations and well developed systems of state support, society would largely continue unchanged. There would probably be increased pressure on housing as people lived separately rather than together, but otherwise we know that single parents and their children are able to live very good lives. | The ability to think more logically when it is "not time for sex" could help the Society to be stable. Female politicians may be precluded from taking decisions on those 5 days (and also to going to work, to avoid influencing Male politicians). Same for policemen and policewomen, judges and the military, and you have a good system. Better if there are no weapons on private hands.
But the system will have a hinder in that women in heat are still there, and not hiding, so competition between them for males and between males for women in heat could cause injuries and killings. Also, a male trying to have sex with a woman in heat that (for some reason, like a sexual disease in the man) is not interested in him can cause rapes.
A society that acknowledges these changes and "rides the wave", forgetting religious prejudices in the process, may survive and prosper. But if these people come to Earth later, while we still have here rapes, murders and there are tons of wild weapons around, it might be a disaster. Moreover if you note that there is a lot of religious people in this world. |
144 | Consider a group of humans at a bronze-age to early iron-age technological level colonizing a new earthlike planet. There is just one difference - there exists on the planet *something* which changes the nature of human sexuality - and the colonists don't know what it is, nor can they stop it from having its effect.
Normal Human sexuality could be summarized as being (usually) private, nocturnal and selective, and can occur at any time due to humans' concealed and extended estrus.
The change (which occurs within a few decades of colonization as the source is revealed) changes human sexuality to (usually) public, diurnal and unselective, only occurring for 5 days each 28 or so of the human female reproductive cycle. Men are only interested in women in heat when said women are present (due to the woman's pheromones), and are very strongly driven to act upon their desires (i.e. in rut), as are the women who are in heat. Women become selective for the day of maximum fertility. Men can only stay in rut for a day or two before they become exhausted. When in heat, a woman *wants* to become pregnant. The rest of the time, women are totally disinterested in sex/pregnancy and the men they come into contact are similarly disinterested, and they are able to think even more logically than non-estrus humans. When not in heat, the limit of sexual behavior between men and women may be to ask a member of the opposite sex if they would be interested in getting together the next time the woman goes into heat.
While this is a question on human sexuality, I'm not interested in the prurient aspects
- I'm sure we could all imagine the immediate results of the changes I suggest on an interpersonal level. I'm looking for an answer that gives a broader view of the effects this change could have on the way human society structures itself and the things it makes, particularly the infrastructure of settlements. I want to find ways that humans could maintain or improve their technology under such conditions, if that is possible.
In addition, I am interested in what would happen if after a long period of isolation (say, several thousand years), a colony beginning with this change (that had managed to maintain a reasonable level of development) came into contact with an advanced society such as ours, and our whole modern society "caught" the same "disease" about month later, globally (airborne trigger).
In neither case will a cure be available within any foreseeable timeframe, certainly not within several human lifespans, by which time it will have become the norm.
**EDIT**
It has been shown in chimpanzees (who show just this behavior) that when a female becomes mate-selective at her time of greatest fertility (i.e. at ovulation), she retires with the chosen male, who usually becomes the genetic father of the offspring of the resulting pregnancy. Hence, it would be possible to determine the biological father with some degree of accuracy without needing to resort to DNA tests.
Those of us who are either women or who live with one would know that women can predict their cycles to an accuracy of a day or so.
When *not* in heat, there is nothing stopping a woman from taking birth control pills that would prevent a pregnancy despite *wanting* to get pregnant when in heat, and nothing would prevent a woman taking abortive drugs after the fact once her heat had passed.
So, to reiterate the question:
How would each society adapt to this situation in terms of its social organization and infrastructure? | 2014/09/17 | [
"https://worldbuilding.stackexchange.com/questions/144",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/75/"
] | This would have major impacts across society. First, pornography and prostitution, gone. However, any concept of father hood? Also gone. Since sex is so common, without any DNA testing it would be impossible to tell who the father is. Over time, that would lead to a system of female inheritance. Since you don't know who your father is, all family ties would be through females and so property would follow that line.
Additionally, there would only be single mothers. Perhaps the government would set up a program where all men pay a child tax, to help care for and support the children in the clan, but women would basically be on there own as far as kids go.
Too keep society functioning, I would imagine getting rid of weekends for females and just have all females off while in heat so everyone else could continue working. There would also be major thoughts about the change in society. Some would embrace it and set up areas to go to while in heat. Others could try to keep up marriage and isolate themselves from anyone else of the opposite sex to stay faithful.
Depending on how predictable the schedule is, humans could either continue working together and have females in heat remove themselves, or be forced to split into two separate groups to keep men from being in constant conflict with each other over the latest women.
While most ancient societies valued children highly, it would likely be even harder to practice any sort of birth control or controlled population growth.
If our world suddenly had the same issue, the most amusing change would be advertising. Since sex isn't constantly appealing, an advertisers main hook would be gone for most of the month.
Everything else would be chaos. Any type of coed organization from schools to sports would collapse. Family ties would break down as men and women felt betrayed. Births would skyrocket as women want to be pregnant. | I think your initial presumption should be clarified a bit. Human sexuality is not naturally private, nocturnal, or selective. Those attributes of sexuality are socially constructed and did not exist for the majority of human evolution. Privacy in any respect was really only created during the Industrial Revolution. Prior to that, families slept, and screwed, in common rooms. Only the tiny upper class had private bedrooms.
Agriculture brought about selectivity and provided motivation for monogamy that didn't exist in nomadic tribes. All pre-historic tribes which have survived to modern times share one idea - shared fatherhood. They believed that multiple men contributed to the formation of children. Most believed that women required a constant supply of semen in order for their child to develop properly. Children were thus raised by the tribe in common, and it was not resource-expensive for someone to care for children which were not their own. Once we settled down into agricultural societies, resource scarcity became much more common, famines killed off many with regularity (about every 5 years there would be a massive famine due to soil nutrient depletion), and it became extremely expensive for someone to raise a child which was not their own. This motivated men to control the sexuality of women and created the situation we've preserved to modern times of women bargaining sexual liberty for material security.
Sex was radically important to human survival. Prior to the development of language and reasoning, human survival (as a species) was pretty dicey. Compared to other animals, we are weak, slow, have no venom or fangs or natural armor, etc. We have great endurance and this allowed us to chase game to exhaustion, but that's not terribly useful for individuals. Humanity survived because of strong group cohesion. And people stuck together because of sex. Sex bonded them together and provided motivation for everyone in the tribe to stick with the tribe, to protect the tribe, and to share that game they hunted down with the tribe. This extreme necessity to be accepted by the tribe both for survival and to maintain access to sex partners led to brain development. Dealing with social situations can be very complex (especially without language) and those with the brainpower to manage it had a distinct survival advantage.
You lump all chimpanzees together in your question, and this is wrong. Bonobo chimpanzees, for instance, use sex primarily as a means of social bonding and for conflict resolution. They have mostly hidden estrus, and estrus has no influence on how actively they seek sexual interaction with others. Bonobos are our closest genetic relatives, and the primates most similar to humans in terms of sexual morphology (things like genital size, ejaculate density, sperm competition, limited sexual dimorphism, etc).
If the humans were without language, I think they would certainly go extinct were their sexuality to change as you describe. With language and technology, however, the effects would be muted and probably not lethal. Most animals have a sexuality like you describe. Those animals are also much better prepared for survival. They're strong, fast, have fangs or venom, etc. They don't rely as much upon group cohesion to survive and many don't join together in groups at all. Humanity with language, reason, and technology would, I think, be equivalent to those species with that sort of sexuality and other survival traits. Humans would have little to no reason to join together in societies, and unless economic concerns forced them to stay together, they would probably dissolve given enough time. Lack of strong selective pressure for positive sociability traits might lead to the sort of things seen in most animals where sex is for reproduction instead of pleasure, like men taking women by force and abandoning them.
I have a bit of a problem with you indicating that a lack of motivation to seek sexual pleasure would result in people being more logical. Rational thinking is inextricably bound up with emotion. In the book 'Neurological Origins of Individuality', the author describes a man who, due to an accident, loses the capacity to experience emotion. An unexpected side effect is that he becomes incapable of making decisions. At all. He could list the 'pros' and 'cons' of two choices, and no matter how lopsided the lists were, he was not capable of performing the act of actually making the choice. Emotion is necessary to carry out even the most logical thinking. To presume that sex (and the complex emotional relationships that come along with it) detracts from peoples ability to reason is inaccurate.
Also, one thing which you didn't address but I was sort of just assuming... I assume that along with these other changes, people would also be "freed" from the negative consequences of abstinence? Sex is on the same level of Maslow's Hierarchy of Needs as breathing, sweating, sleeping, eating, etc for a reason. Abstinence is not healthy. It increases risk of heart disease, several types of cancer, death (a study of a town in Ireland over decades showed men with lower sexual activity had an increased risk of death from any cause), depression, anxiety, it reduces the effectiveness of the immune system and even sense of smell. If the physiological changes which alter their sexuality don't change that aspect, you might want to consider a significant increase in mortality due to heart disease, cancer, suicide, etc.
Some sources if the topic interests you: 'Sex At Dawn', 'Sex At Dusk', 'Good Sex Illustrated', 'Sex And God: How Religion Distorts Sexuality', the 'Sociology of Sex' course from The Teaching Company (if you can find it), 'History of Sexuality' by Michel Foucalt |
946,588 | Does a limit that equals to infinity considered to exist ?? am confused !!
for Example 1/(x-2)--> when evaluating the limit at 2 the result is 1/0 which is infinity
while after looking at the graph the left hand limit equals -inf while right hand limit
equals +inf does the one sided limits exists ??
pls an expert discuss existence of limits for my question and example because am confused
thanx | 2014/09/26 | [
"https://math.stackexchange.com/questions/946588",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/177540/"
] | The limit exists if the values approach some real number. If the values are getting bigger and bigger the limit doesn't exist. There are other ways the limit could not exist. Saying the limit is infinity is being more specific about how the limit fails to exist.
Also, saying "the result is 1/0" causes many math folks pain. You could say the denominator is going to zero, so the whole thing is going to infinity. Or if you don't want to say that much, just say the limit is infinity. | If we consider the real number or complex number system then the limit does not exist. But if we include ∞ with that system, which is called extended real number or extended complex number system, then obviously we have to say that the limit exists. |
118,336 | We know Bohr said that the angular momentum of an electron is an integral multiple of $nh/(2π).$ And in de Broglie's wave equation, he said the circumference of the path of the electron traveling as a way is $n$ times the wavelength, which is equal to $2πr.$
But in Bohr's model $n$ is the principal quantum number, while the $n$ in de Broglie's equation is the number of wavelengths in the one revolution. I don't understand how they are equal. | 2019/07/22 | [
"https://chemistry.stackexchange.com/questions/118336",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/81201/"
] | **de Brogile explains why orbitals are quantised**
Strictly speaking de Brogile doesn't prove Bohr's postulates which are mostly wrong. But he did provide an explanation for the most important of Bohr's ideas: electron orbitals are *quantised*.
Bohr's whole model starts with the classical idea that electrons "orbit" a nucleus. But this has several problems not least of which is why don't they just radiate away their energy and fall into the nucleus (which is what accelerating charges should do in classical electromagnetism). Bohr made the extra assumption that the electrons around a nucleus could only "orbit" in a small number of fixed paths or orbitals which explained the actual observations. He didn't have any good reason *why* this was true.
de Brogile provided a reason. According to his postulates things like electrons are not just classical particles but have some of the characteristics of waves. and the thing about waves is that they *interfere* with each other. Electrons orbiting a nucleus can only do so if their wave-like property fits into a specific orbit (the way the vibrations in a guitar string produce only specific notes made from standing waves of integer divisions of the string length). Imagine integer numbers of electron waves around a nucleus and you are a third of the way of getting the picture (electrons orbit in 3D so the compatible vibrations are *spherical harmonics* in 3D space not the easier to picture vibrations of a 1D guitar string).
de Brogile, in short, produced a *justification* for the Bohr assumption that electron orbits had to be quantised.
Those pictures you see of electron "orbitals" are, in essence, pictures of the possible "waves" electrons can form when orbiting a nucleus.
All the above simplifies things a bit but the key ideas were from de Brogile and were more fully mathematicised by Dirac and Schroedinger giving us the modern quantum picture of how electrons behave. | Bohr's theory that angular momentum $mvr$ is an integer multiple of $\frac{h}{2π}$ has been reinterpreted by de Broglie to show that the electron is characterised by a standing wave condition. This means that a whole number of wavelengths must fit around the circumference of its orbit, and that it behaves like a wave.1
$$2 \pi r=n \lambda \cdots (1)$$
$$L=mvr=n\frac{h}{2π} \cdots (2)$$
From (1) and (2),
$$
\begin{array}{r}
m v r=n \frac{h}{2 \pi} \\
\Rightarrow 2 \pi r=\frac{n h}{m v} \\
\Rightarrow n \lambda=\frac{n h}{m v} \\
\Rightarrow \lambda=\frac{h}{m v}
\end{array}
$$
Hence, de-Broglie's theory and Bohr's theory are in agreement with each other. de-Broglie's concept supports the postulate of Bohr that the angular momentum of an electron in an orbit is quantised.
In case if the circumference of the electron orbit ($2nr$) is bigger or smaller than $nλ$, the electron wave is said to be out of phase. Then there occurs destructive interference of electron waves causing radiation of energy, such an orbit cannot exist.
[](https://upload.wikimedia.org/wikipedia/commons/7/7e/In_phase_out_phase_removebg.png)
In situation (a), we have an perfect in phase standing wave, In situation (b), we have out of phase wave.
1 <https://en.wikipedia.org/wiki/Bohr_model> |
55,581,124 | I’m currently working with spring boot and kubernetes and came across a problem.
I’ve already implemented service discovery in spring boot with spring-boot-cloud-kubernetes and it’s working fine, but (and this is something I’m not stoked about) I have to redeploy my microservices to minikube every time I want to observe the changes. Is there a way to use local service discovery (localhost) that also works within kubernetes without using Eureka, etc? | 2019/04/08 | [
"https://Stackoverflow.com/questions/55581124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7723191/"
] | You could use Consul in combination with [consul-template](https://github.com/hashicorp/consul-template) or [envconsul](https://github.com/hashicorp/envconsul) to do service discovery and config file templating, including automatic restarting of the application if required. | Use k8s services that point to respective endpoints. You can always change the service endpoints and will be reflected any time there are changes to services. |
200,507 | I'm currently hosting sites for clients using the following setup:
* Apache 2.2.16
* mod\_fastcgi 2.4.7
* php 5.3.3
Apache uses the worker MPM and serves PHP through a dynamic FastCGI config:
```
FastCgiSuexec /usr/sbin/suexec
FastCgiConfig -singleThreshold 0 -pass-header Authorization -idle-timeout 3600
SuexecUserGroup user group
Action application/x-httpd-fastphp /cgi-bin/php.fcgi
AddType application/x-httpd-fastphp .php
```
This works well but this creates a php-cgi instance for each VirtualHost (even if the cgi-bin dir is physically the same for a given account) so if a client has a few subdomains it begins to add up, starving the server and trashing it.
So this brings me to the actual question, is it possible to serve all php requests for an account through a single php-cgi instance? Preferably while maintaining the suexec bit to prevent clients from reading files outside of their directory. | 2010/11/10 | [
"https://serverfault.com/questions/200507",
"https://serverfault.com",
"https://serverfault.com/users/59871/"
] | If you have a windows server to look after these clients then I'd suggest [Windows Deployment Services](http://technet.microsoft.com/en-us/library/cc772106%28WS.10%29.aspx), which is included in Windows Server.
Failing that, I'd consider [FOG](http://www.fogproject.org/), which is a very decent open source alternative. Both can be a no cost/low cost thing to set up depending on what you already have. | if you are installing operating systems, and have the hardware to support it [PXE booting](http://en.wikipedia.org/wiki/Preboot_Execution_Environment) is the way to go, you can maintain installation images on a single server, boot from the media using pxe and away you go |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I never seem to name them anything like what you proposed (i.e. keeping one way). It just seems to be much more clear when I can find a "proper name" for the hash. It might be "person\_details" or "file\_sizes" or "album\_tracks" etc. (although the last 2 seem to have key\_value names, first one a bit less). In rare cases, it will be `key_value_map`, or `value_key_map` if it's important that it's a map.
I would never assume any naming scheme for that. Sometimes the values are what you're after, sometimes the keys. My preference is "a natural name". | I usually use <something>`map` since it's usually a map such as strings to functions, or numbers to classes, or whatnot. Unnamed dicts usually end up in a larger structure, so I don't worry about them. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | `key_to_value`, for example `surname_to_salary` may be useful when there are closely interrelated maps in code: a to b, b to a, c to b etc. | I usually use <something>`map` since it's usually a map such as strings to functions, or numbers to classes, or whatnot. Unnamed dicts usually end up in a larger structure, so I don't worry about them. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I never seem to name them anything like what you proposed (i.e. keeping one way). It just seems to be much more clear when I can find a "proper name" for the hash. It might be "person\_details" or "file\_sizes" or "album\_tracks" etc. (although the last 2 seem to have key\_value names, first one a bit less). In rare cases, it will be `key_value_map`, or `value_key_map` if it's important that it's a map.
I would never assume any naming scheme for that. Sometimes the values are what you're after, sometimes the keys. My preference is "a natural name". | I will contrast with many answers so far (including the chosen answer) and say:
I avoid adding type references like `dict` or `map` to the variable name. It feels too much like Hungarian notation to me, which feels very anti-pythonic.
To answer the question of what I DO use:
I use names of the form `values`, `values_by_key` or `values_for_key`, whichever reads most naturally. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I never seem to name them anything like what you proposed (i.e. keeping one way). It just seems to be much more clear when I can find a "proper name" for the hash. It might be "person\_details" or "file\_sizes" or "album\_tracks" etc. (although the last 2 seem to have key\_value names, first one a bit less). In rare cases, it will be `key_value_map`, or `value_key_map` if it's important that it's a map.
I would never assume any naming scheme for that. Sometimes the values are what you're after, sometimes the keys. My preference is "a natural name". | `values_by_key`
1. it is not so confusing as `value_key_map`: you can't confuse what is
value name and what is key name
2. it doesn't name the type directly -- python style naming |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I never seem to name them anything like what you proposed (i.e. keeping one way). It just seems to be much more clear when I can find a "proper name" for the hash. It might be "person\_details" or "file\_sizes" or "album\_tracks" etc. (although the last 2 seem to have key\_value names, first one a bit less). In rare cases, it will be `key_value_map`, or `value_key_map` if it's important that it's a map.
I would never assume any naming scheme for that. Sometimes the values are what you're after, sometimes the keys. My preference is "a natural name". | I think it makes sense to name the dict after the values in the dict, and drop any mention of the key. After all, you are going to be using the dict in situations like `values[key]` which makes it perfectly clear what the keys are, assuming you named `key` well. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I never seem to name them anything like what you proposed (i.e. keeping one way). It just seems to be much more clear when I can find a "proper name" for the hash. It might be "person\_details" or "file\_sizes" or "album\_tracks" etc. (although the last 2 seem to have key\_value names, first one a bit less). In rare cases, it will be `key_value_map`, or `value_key_map` if it's important that it's a map.
I would never assume any naming scheme for that. Sometimes the values are what you're after, sometimes the keys. My preference is "a natural name". | In our projects, we adopted following convention:
* `key_to_value_map` when it is a map
* `aname_dict` for larger more complex structure. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I will contrast with many answers so far (including the chosen answer) and say:
I avoid adding type references like `dict` or `map` to the variable name. It feels too much like Hungarian notation to me, which feels very anti-pythonic.
To answer the question of what I DO use:
I use names of the form `values`, `values_by_key` or `values_for_key`, whichever reads most naturally. | In our projects, we adopted following convention:
* `key_to_value_map` when it is a map
* `aname_dict` for larger more complex structure. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | `key_to_value`, for example `surname_to_salary` may be useful when there are closely interrelated maps in code: a to b, b to a, c to b etc. | I will contrast with many answers so far (including the chosen answer) and say:
I avoid adding type references like `dict` or `map` to the variable name. It feels too much like Hungarian notation to me, which feels very anti-pythonic.
To answer the question of what I DO use:
I use names of the form `values`, `values_by_key` or `values_for_key`, whichever reads most naturally. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | I will contrast with many answers so far (including the chosen answer) and say:
I avoid adding type references like `dict` or `map` to the variable name. It feels too much like Hungarian notation to me, which feels very anti-pythonic.
To answer the question of what I DO use:
I use names of the form `values`, `values_by_key` or `values_for_key`, whichever reads most naturally. | I usually use <something>`map` since it's usually a map such as strings to functions, or numbers to classes, or whatnot. Unnamed dicts usually end up in a larger structure, so I don't worry about them. |
2,405,958 | While other questions have tackled the broader category of [sequences](https://stackoverflow.com/questions/659415/python-sequence-naming-convention) and [modules](https://stackoverflow.com/questions/711884/python-naming-conventions-for-modules), I ask this very specific question:
**"What naming convention do you use for dictionaries and why?"**
Some naming convention samples I have been considering:
```
# 'value' is the data type stored in the map, while 'key' is the type of key
value_for_key={key1:value1, key2,value2}
value_key={key1:value1, key2,value2}
v_value_k_key={key1:value1, key2,value2}
```
Don't bother answering the 'why' with "because my work tells me to", not very helpful. The reason driving the choice is more important. Are there any other good considerations for a dictionary naming convention aside from readability?
**EDIT:**
**Chosen answer:** value\_key\_map
**Reason for chosen answer:** Allows a code reviewer to quickly and easily figure out the key and value for a map, and the fact that it is a map without looking anywhere else. | 2010/03/09 | [
"https://Stackoverflow.com/questions/2405958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158687/"
] | `values_by_key`
1. it is not so confusing as `value_key_map`: you can't confuse what is
value name and what is key name
2. it doesn't name the type directly -- python style naming | In our projects, we adopted following convention:
* `key_to_value_map` when it is a map
* `aname_dict` for larger more complex structure. |
58,002,042 | Hostinger offers this really cheap plan that is 1 dollar per month but it doesn't have SSH support. Do I need SSH support to host NodeJS? The plan provides shared hosting. | 2019/09/18 | [
"https://Stackoverflow.com/questions/58002042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11655959/"
] | This is false. Consider a two-state NFA with a non-accepting initial state leading to an accepting state by means of a lambda- (or epsilon-, or empty) transition. The empty string is accepted by this NFA by traversing the transition, but the initial state is non-accepting.
If the claim were about DFAs, then it would be true, since lambda- (or epsilon-, or empty) transitions wouldn't be available. | Yes, it is true. When the start state become the final state, then without reading any string you reached the final state. So the string accepted is empty.
Refer <https://www.udemy.com/course/introduction-to-theory-of-computations/> |
58,002,042 | Hostinger offers this really cheap plan that is 1 dollar per month but it doesn't have SSH support. Do I need SSH support to host NodeJS? The plan provides shared hosting. | 2019/09/18 | [
"https://Stackoverflow.com/questions/58002042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11655959/"
] | This is false. Consider a two-state NFA with a non-accepting initial state leading to an accepting state by means of a lambda- (or epsilon-, or empty) transition. The empty string is accepted by this NFA by traversing the transition, but the initial state is non-accepting.
If the claim were about DFAs, then it would be true, since lambda- (or epsilon-, or empty) transitions wouldn't be available. | Yes it is true.
By defualt NFA means NFA without Epsilon transition.
If it is an Epsilon NFA (NFA which can change state without consuming the input symbol) then the answer is false. |
58,002,042 | Hostinger offers this really cheap plan that is 1 dollar per month but it doesn't have SSH support. Do I need SSH support to host NodeJS? The plan provides shared hosting. | 2019/09/18 | [
"https://Stackoverflow.com/questions/58002042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11655959/"
] | Yes it is true.
By defualt NFA means NFA without Epsilon transition.
If it is an Epsilon NFA (NFA which can change state without consuming the input symbol) then the answer is false. | Yes, it is true. When the start state become the final state, then without reading any string you reached the final state. So the string accepted is empty.
Refer <https://www.udemy.com/course/introduction-to-theory-of-computations/> |
72,266,632 | I have a form that once certain checkboxes are checked, I need them to v-show additional form components. I can get it to work, sort of. If you only choose 1 option, it will populate the correct form, however, If multiple choices are made it doesn't show the additional forms components. Here is my code. It seems that am getting the correct values through the store, I'm just missing something. I apologize in advance if this is a duplicate question. I feel like I've read all of stackoverflow in the last few weeks :) Here is a screencast of it somewhat working <http://somup.com/c3hD0TtnJh>
I'm using Formkit, Vue3, Pinia. Thanks in advance.
### App.vue
```
<template>
<ReasonForVisit />
<Sports v-show="data.reasonForVisit == 'si' " />
<WorkComp v-show="data.reasonForVisit == 'wc' " />
<Accident v-show="data.reasonForVisit == 'aa' " />
</template>
<script>
import ReasonForVisit from './components/ReasonForVisit.vue'
import Sports from './components/Sports.vue'
import WorkComp from './components/WorkComp.vue'
import Accident from './components/Accident.vue'
import { useFormStore} from './stores/formStore.js'
const data = useFormStore()
</script>
```
### ReasonForVisit.vue
```
<template>
<FormKit
v-model="data.reasonForVisit"
type="checkbox"
label="Reason for Visit"
:options="{
we: 'Wellness Check',
aa: 'Auto Accident',
si: 'Sports Injury',
wc: 'Work Comp' }"
validation="required"
@change="data.checkedReason"
/>
<p>reason: {{ data.reasonForVisit }}</p>
</template>
```
### FormStore.js
```
import { defineStore } from 'pinia'
import { differenceInYears, parseISO } from 'date-fns'
export const useFormStore = defineStore('formStore', {
state: () => ({
reasonForVisit: [],
}),
},
}
)
``` | 2022/05/16 | [
"https://Stackoverflow.com/questions/72266632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18994237/"
] | Only create the new image once, if it hasn't been created already. On click, copy the src attribute of the clicked image to the one created inside the `playerbox` div.
See how it works by running the snippet and clicking one of the three images...
```js
// this "lazy" getter for playerImg will either return or create the img
function playerImg() {
let playerImg = document.getElementById('playerimg');
if (!playerImg) {
playerImg = document.createElement('img');
playerImg.id = 'playerimg';
document.getElementById('playerbox').appendChild(playerImg);
}
return playerImg;
}
// set the source attribute of the playerImg
function setPlayerImg(src) {
playerImg().setAttribute('src', src);
}
// get the rock, paper, scissors elements with their common class
const imgs = document.getElementsByClassName("myclass");
// for each, add a click handler that calls our src setting function
for (let i = 0; i < imgs.length; i++) {
const el = imgs[i];
el.addEventListener('click', () => setPlayerImg(el.src), false);
}
```
```html
<div class="user">
<img class="rock myclass" src="https://dummyimage.com/100x100/0f0/000" />
<img class="paper myclass" src="https://dummyimage.com/100x100/ff0/000" />
<img class="scissors myclass" src="https://dummyimage.com/100x100/0ff/000" />
</div>
<div id="playerbox"></div>
``` | HTML elements with an id are directly put into javascript variables.
It's not the case with classes (since multiple html elements can have the same class name).
So if you'd use
```
<div id="user">
<img id="select" id="rock" src="images/rock-removebg-preview.png" onclick="addImg()">
<img id="select" id="paper" src="images/paper-removebg-preview.png" >
<img id="select" id="scissors" src="images/scissors-removebg-preview.png" >
</div>
<div id="player-box"></div>
```
Your code should work.
Else, if you need to use class names, use `const rock = document.querySelector('.rock')` and `const playerBox = document.querySelector('.player-box')`.
Also, i'm not sure why you're removing the `onclick` attribute just to add the same listener again.
Also, when adding the event listener, the name of the event is 'click' and not 'onclick'. |
72,266,632 | I have a form that once certain checkboxes are checked, I need them to v-show additional form components. I can get it to work, sort of. If you only choose 1 option, it will populate the correct form, however, If multiple choices are made it doesn't show the additional forms components. Here is my code. It seems that am getting the correct values through the store, I'm just missing something. I apologize in advance if this is a duplicate question. I feel like I've read all of stackoverflow in the last few weeks :) Here is a screencast of it somewhat working <http://somup.com/c3hD0TtnJh>
I'm using Formkit, Vue3, Pinia. Thanks in advance.
### App.vue
```
<template>
<ReasonForVisit />
<Sports v-show="data.reasonForVisit == 'si' " />
<WorkComp v-show="data.reasonForVisit == 'wc' " />
<Accident v-show="data.reasonForVisit == 'aa' " />
</template>
<script>
import ReasonForVisit from './components/ReasonForVisit.vue'
import Sports from './components/Sports.vue'
import WorkComp from './components/WorkComp.vue'
import Accident from './components/Accident.vue'
import { useFormStore} from './stores/formStore.js'
const data = useFormStore()
</script>
```
### ReasonForVisit.vue
```
<template>
<FormKit
v-model="data.reasonForVisit"
type="checkbox"
label="Reason for Visit"
:options="{
we: 'Wellness Check',
aa: 'Auto Accident',
si: 'Sports Injury',
wc: 'Work Comp' }"
validation="required"
@change="data.checkedReason"
/>
<p>reason: {{ data.reasonForVisit }}</p>
</template>
```
### FormStore.js
```
import { defineStore } from 'pinia'
import { differenceInYears, parseISO } from 'date-fns'
export const useFormStore = defineStore('formStore', {
state: () => ({
reasonForVisit: [],
}),
},
}
)
``` | 2022/05/16 | [
"https://Stackoverflow.com/questions/72266632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18994237/"
] | ***Details are commented in example below***
```js
// Reference the <form>
const RPS = document.forms.RPS
// Register the click event to <form>
RPS.onclick = addIMG;
// Pass the Event Object
function addIMG(e) {
// Reference all form controls
const IO = this.elements;
// The tag that the user cklicked
const clk = e.target;
// Clean #player to make room.
IO.player.replaceChildren();
/*
** Match clicked tag #id to <img>
*/
if (clk.matches('.rps')) {
switch (clk.id) {
case 'rock':
IO.player.insertAdjacentHTML('afterbegin', `<img src='https://www.biography.com/.image/ar_16:9%2Cc_fill%2Ccs_srgb%2Cg_faces:center%2Cq_auto:good%2Cw_1920/MTc5NjIyODM0ODM2ODc0Mzc3/dwayne-the-rock-johnson-gettyimages-1061959920.webp' height='150'>`);
break;
case 'paper':
IO.player.insertAdjacentHTML(
'afterbegin',
`<img src='https://d1csarkz8obe9u.cloudfront.net/posterpreviews/notebook-paper-background-design-template-c114c2ed2104bd8b815cf7fbb2f34f44_screen.jpg?ts=1636989881' height='150'>`);
break;
case 'scissors':
IO.player.insertAdjacentHTML(
'afterbegin',
`<img src='https://smithsverdict.files.wordpress.com/2013/02/johnny-depp-as-edward-scissorhands-1990.jpeg' height='150'>`);
break;
default:
break;
}
}
}
```
```css
#objects {
display: flex;
justify-content: space-evenly;
}
object {
display: block;
margin: 0 15px;
cursor: pointer;
}
#player {
width: auto;
max-height: 150px;
text-align: center;
}
img {
object-fit: contain;
}
```
```html
<form id="RPS">
<fieldset id='objects'>
<legend>Pick One</legend>
<object id="rock" class="rps"></object>
<object id="paper" class="rps"></object>
<object id="scissors" class="rps">✂</object>
</fieldset>
<fieldset id="player">
<legend>Player</legend>
</fieldset>
<fieldset id='opponent'>
<legend>Opponent</legend>
</fieldset>
</form>
``` | HTML elements with an id are directly put into javascript variables.
It's not the case with classes (since multiple html elements can have the same class name).
So if you'd use
```
<div id="user">
<img id="select" id="rock" src="images/rock-removebg-preview.png" onclick="addImg()">
<img id="select" id="paper" src="images/paper-removebg-preview.png" >
<img id="select" id="scissors" src="images/scissors-removebg-preview.png" >
</div>
<div id="player-box"></div>
```
Your code should work.
Else, if you need to use class names, use `const rock = document.querySelector('.rock')` and `const playerBox = document.querySelector('.player-box')`.
Also, i'm not sure why you're removing the `onclick` attribute just to add the same listener again.
Also, when adding the event listener, the name of the event is 'click' and not 'onclick'. |
647,194 | I am trying to get Grub to look nice.
But, for some reason the changes do not apply. I tried background images, (custom ones and the ones from grub2-splashimages), color changing (all the options), but it does not want to apply. It does save correctly(without any errors), and as far as I know, grub is installed on the default location. Also the changes are still there when I re-launch grub-customizer.
Also I am using grub-emulator to test the result, but it is showing the exact same thing.
If you need any of grub's config files, please mention. | 2015/07/11 | [
"https://askubuntu.com/questions/647194",
"https://askubuntu.com",
"https://askubuntu.com/users/428648/"
] | To add a custom background image:
1. Save your background image to your Pictures directory as .png
2. Open terminal and paste `sudo gedit /etc/grub.d/05_debian_theme`
3. Paste the line `GRUB_BACKGROUND="/home/YOURUSERNAME/Pictures/NAME-OF-BACKGROUND.png"` on its own line in the file.
4. In terminal run `sudo update-grub`
5. Terminal should say background image found.
6. Reboot.
If this does not work, then I am not sure. The link I posted also has instructions on changing the text color and text background. If this works for you, please be sure to up vote it and mark as the correct answer. Thank you. | Grub works better with **png** images than jpg.
Have a look at this page: [Ubuntu Community - Grub2/Displays](https://help.ubuntu.com/community/Grub2/Displays)
>
> GRUB 2 can use PNG, JPG/JPEG and TGA images for the background. The
> image must meet the following specifications:
>
>
> * JPG/JPEG images must be 8-bit (256 color). Else you will get errors saying "Too many Huffman tables". Since most of the time you
> will not want to limit yourself to 256 colors (which is totally
> yesteryear) you will probably find PNG much preferable.
> * Images should be non-indexed, RGB.
>
>
> |
647,194 | I am trying to get Grub to look nice.
But, for some reason the changes do not apply. I tried background images, (custom ones and the ones from grub2-splashimages), color changing (all the options), but it does not want to apply. It does save correctly(without any errors), and as far as I know, grub is installed on the default location. Also the changes are still there when I re-launch grub-customizer.
Also I am using grub-emulator to test the result, but it is showing the exact same thing.
If you need any of grub's config files, please mention. | 2015/07/11 | [
"https://askubuntu.com/questions/647194",
"https://askubuntu.com",
"https://askubuntu.com/users/428648/"
] | To add a custom background image:
1. Save your background image to your Pictures directory as .png
2. Open terminal and paste `sudo gedit /etc/grub.d/05_debian_theme`
3. Paste the line `GRUB_BACKGROUND="/home/YOURUSERNAME/Pictures/NAME-OF-BACKGROUND.png"` on its own line in the file.
4. In terminal run `sudo update-grub`
5. Terminal should say background image found.
6. Reboot.
If this does not work, then I am not sure. The link I posted also has instructions on changing the text color and text background. If this works for you, please be sure to up vote it and mark as the correct answer. Thank you. | If you only want to change the background image you can do this:
Put the image under /boot/grub/ and run:
```
sudo update-grub
```
For some reason `grub-customizer` doesn't work you should fill a bug.
It happens to a lot of users.
This [article](https://www.thegeekstuff.com/2012/10/grub-splash-image/) for Debian should work, since Ubuntu is based on it.
>
> Now to change the colors, open “/etc/grub.d/05\_debian\_theme” and find
> the following line:
>
>
>
> ```
> if [ -z "${2}" ] && [ -z "${3}" ]; then
> echo " true"
> fi
>
> ```
>
> and, replace them with the following:
>
>
>
> ```
> if [ -z "${2}" ] && [ -z "${3}" ]; then
> # echo " true"
> echo " set color_highlight=red/green"
> echo " set color_normal=light-cyan/black"
> fi
>
> ```
>
> Don’t change the “black” present in color\_normal. If changed, the
> image will not be transparent in the area where the menu is displayed.
>
>
> After this change, execute “update-grub”, and reboot your system.
>
>
>
>
> The following colors are supported by grub:
>
>
>
```
black
blue
brown
cyan
dark-gray
green
light-cyan
light-blue
light-green
light-gray
light-magenta
light-red
magenta
red
white
yellow
```
The article explains also the paths and the requirements for the images.
You simply need to put them in some folder no need to edit the config.
Make a backup of the file that you will edit. |
647,194 | I am trying to get Grub to look nice.
But, for some reason the changes do not apply. I tried background images, (custom ones and the ones from grub2-splashimages), color changing (all the options), but it does not want to apply. It does save correctly(without any errors), and as far as I know, grub is installed on the default location. Also the changes are still there when I re-launch grub-customizer.
Also I am using grub-emulator to test the result, but it is showing the exact same thing.
If you need any of grub's config files, please mention. | 2015/07/11 | [
"https://askubuntu.com/questions/647194",
"https://askubuntu.com",
"https://askubuntu.com/users/428648/"
] | Grub works better with **png** images than jpg.
Have a look at this page: [Ubuntu Community - Grub2/Displays](https://help.ubuntu.com/community/Grub2/Displays)
>
> GRUB 2 can use PNG, JPG/JPEG and TGA images for the background. The
> image must meet the following specifications:
>
>
> * JPG/JPEG images must be 8-bit (256 color). Else you will get errors saying "Too many Huffman tables". Since most of the time you
> will not want to limit yourself to 256 colors (which is totally
> yesteryear) you will probably find PNG much preferable.
> * Images should be non-indexed, RGB.
>
>
> | If you only want to change the background image you can do this:
Put the image under /boot/grub/ and run:
```
sudo update-grub
```
For some reason `grub-customizer` doesn't work you should fill a bug.
It happens to a lot of users.
This [article](https://www.thegeekstuff.com/2012/10/grub-splash-image/) for Debian should work, since Ubuntu is based on it.
>
> Now to change the colors, open “/etc/grub.d/05\_debian\_theme” and find
> the following line:
>
>
>
> ```
> if [ -z "${2}" ] && [ -z "${3}" ]; then
> echo " true"
> fi
>
> ```
>
> and, replace them with the following:
>
>
>
> ```
> if [ -z "${2}" ] && [ -z "${3}" ]; then
> # echo " true"
> echo " set color_highlight=red/green"
> echo " set color_normal=light-cyan/black"
> fi
>
> ```
>
> Don’t change the “black” present in color\_normal. If changed, the
> image will not be transparent in the area where the menu is displayed.
>
>
> After this change, execute “update-grub”, and reboot your system.
>
>
>
>
> The following colors are supported by grub:
>
>
>
```
black
blue
brown
cyan
dark-gray
green
light-cyan
light-blue
light-green
light-gray
light-magenta
light-red
magenta
red
white
yellow
```
The article explains also the paths and the requirements for the images.
You simply need to put them in some folder no need to edit the config.
Make a backup of the file that you will edit. |
41,259,138 | I am attempting to get multiple views to use the same controller. I've tried a couple of things so far, none seem to work. By "doesnt work" I mean the controller `MapController` isnt instantiated and the views cannot see the controller
**1**
```
$stateProvider.state(PageStateNames.COMPONENTS_LIVEMAP, {
url: "/components/vehicles/:vehicle/:panel",
views: {
"": {
controller: "MapController as vm"
},
"content@app": {
templateUrl: "....html"
},
"sidenav@app": {
templateUrl: "....html"
}
}
});
```
**2**
```
$stateProvider.state(PageStateNames.COMPONENTS_LIVEMAP, {
url: "/components/vehicles/:vehicle/:panel",
controller: "MapController as vm"
views: {
"content@app": {
templateUrl: "....html"
},
"sidenav@app": {
templateUrl: "....html"
}
}
});
```
Having looked at [existing](https://stackoverflow.com/a/23283912/94278) [questions](https://stackoverflow.com/a/29708369/94278) this should work. Have I missed something? | 2016/12/21 | [
"https://Stackoverflow.com/questions/41259138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/94278/"
] | all you need to do is just use a custom drawable as **track** of **switch**
this is the code for custom drawable:
```
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape android:shape="rectangle">
<corners
android:radius="@dimen/_40sdp" />
<solid
android:color="@android:color/darker_gray" />
<padding
android:bottom="@dimen/_5dp"
android:left="@dimen/_5dp"
android:right="@dimen/_5dp"
android:top="@dimen/_5dp" />
</shape>
</item>
```
Further make these modification to your existing layout
add ***android:thumbTint="@android:color/holo\_blue\_dark"*** or any color that meets your requirement
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Available"
android:textColor="#82BCB4"
android:textSize="20sp" />
<Switch
android:id="@+id/theSwitchId"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center|center_vertical"
android:layout_marginStart="40dp"
android:minHeight="60dp"
android:switchMinWidth="90dp"
android:textOff=""
android:textOn=""
android:thumbTextPadding="5dp"
android:thumbTint="@android:color/holo_blue_dark"
android:track="@drawable/track_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:text="UnAvailable"
android:textColor="#224e6d"
android:textSize="20sp" />
```
hope this helps
click here to view the resulting screenshot
[screenshot](https://i.stack.imgur.com/7Nmi5.png) | In style.xml
```
<style name="switchCompatStyle">
<item name="colorControlActivated">@color/colorPrimary</item>
</style>
```
And code for switch is like
```
<android.support.v7.widget.SwitchCompat
android:id="@+id/switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/_10sdp"
app:theme="@style/switchCompatStyle" />
``` |
41,259,138 | I am attempting to get multiple views to use the same controller. I've tried a couple of things so far, none seem to work. By "doesnt work" I mean the controller `MapController` isnt instantiated and the views cannot see the controller
**1**
```
$stateProvider.state(PageStateNames.COMPONENTS_LIVEMAP, {
url: "/components/vehicles/:vehicle/:panel",
views: {
"": {
controller: "MapController as vm"
},
"content@app": {
templateUrl: "....html"
},
"sidenav@app": {
templateUrl: "....html"
}
}
});
```
**2**
```
$stateProvider.state(PageStateNames.COMPONENTS_LIVEMAP, {
url: "/components/vehicles/:vehicle/:panel",
controller: "MapController as vm"
views: {
"content@app": {
templateUrl: "....html"
},
"sidenav@app": {
templateUrl: "....html"
}
}
});
```
Having looked at [existing](https://stackoverflow.com/a/23283912/94278) [questions](https://stackoverflow.com/a/29708369/94278) this should work. Have I missed something? | 2016/12/21 | [
"https://Stackoverflow.com/questions/41259138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/94278/"
] | all you need to do is just use a custom drawable as **track** of **switch**
this is the code for custom drawable:
```
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape android:shape="rectangle">
<corners
android:radius="@dimen/_40sdp" />
<solid
android:color="@android:color/darker_gray" />
<padding
android:bottom="@dimen/_5dp"
android:left="@dimen/_5dp"
android:right="@dimen/_5dp"
android:top="@dimen/_5dp" />
</shape>
</item>
```
Further make these modification to your existing layout
add ***android:thumbTint="@android:color/holo\_blue\_dark"*** or any color that meets your requirement
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Available"
android:textColor="#82BCB4"
android:textSize="20sp" />
<Switch
android:id="@+id/theSwitchId"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center|center_vertical"
android:layout_marginStart="40dp"
android:minHeight="60dp"
android:switchMinWidth="90dp"
android:textOff=""
android:textOn=""
android:thumbTextPadding="5dp"
android:thumbTint="@android:color/holo_blue_dark"
android:track="@drawable/track_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:text="UnAvailable"
android:textColor="#224e6d"
android:textSize="20sp" />
```
hope this helps
click here to view the resulting screenshot
[screenshot](https://i.stack.imgur.com/7Nmi5.png) | You create Thumb in drawable xml:
thumb.xml
```
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/ic_thumbselecter"/>
<item android:drawable="@drawable/ic_thumbselecter"/>
</selector>
```
And put into switch (in my case I was using that):
```
<Switch
app:kswThumbDrawable="@drawable/thumb"/>
``` |
41,259,138 | I am attempting to get multiple views to use the same controller. I've tried a couple of things so far, none seem to work. By "doesnt work" I mean the controller `MapController` isnt instantiated and the views cannot see the controller
**1**
```
$stateProvider.state(PageStateNames.COMPONENTS_LIVEMAP, {
url: "/components/vehicles/:vehicle/:panel",
views: {
"": {
controller: "MapController as vm"
},
"content@app": {
templateUrl: "....html"
},
"sidenav@app": {
templateUrl: "....html"
}
}
});
```
**2**
```
$stateProvider.state(PageStateNames.COMPONENTS_LIVEMAP, {
url: "/components/vehicles/:vehicle/:panel",
controller: "MapController as vm"
views: {
"content@app": {
templateUrl: "....html"
},
"sidenav@app": {
templateUrl: "....html"
}
}
});
```
Having looked at [existing](https://stackoverflow.com/a/23283912/94278) [questions](https://stackoverflow.com/a/29708369/94278) this should work. Have I missed something? | 2016/12/21 | [
"https://Stackoverflow.com/questions/41259138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/94278/"
] | all you need to do is just use a custom drawable as **track** of **switch**
this is the code for custom drawable:
```
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape android:shape="rectangle">
<corners
android:radius="@dimen/_40sdp" />
<solid
android:color="@android:color/darker_gray" />
<padding
android:bottom="@dimen/_5dp"
android:left="@dimen/_5dp"
android:right="@dimen/_5dp"
android:top="@dimen/_5dp" />
</shape>
</item>
```
Further make these modification to your existing layout
add ***android:thumbTint="@android:color/holo\_blue\_dark"*** or any color that meets your requirement
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Available"
android:textColor="#82BCB4"
android:textSize="20sp" />
<Switch
android:id="@+id/theSwitchId"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center|center_vertical"
android:layout_marginStart="40dp"
android:minHeight="60dp"
android:switchMinWidth="90dp"
android:textOff=""
android:textOn=""
android:thumbTextPadding="5dp"
android:thumbTint="@android:color/holo_blue_dark"
android:track="@drawable/track_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:text="UnAvailable"
android:textColor="#224e6d"
android:textSize="20sp" />
```
hope this helps
click here to view the resulting screenshot
[screenshot](https://i.stack.imgur.com/7Nmi5.png) | Change the thumb (circle on the switch) color by using:
```
android:thumbTint="@color/thumbColor"
```
On your colors.xml:
```
<color name="thumbColor">#FFFFFF</color>
``` |
55,318,985 | I am defining a function, standard\_deviation that consumes a list of numbers and returns a float representing their standard deviation. I need to use the len function to return None if the list has fewer than 2 elements.
This is what I have written:
```
SURVEY_RESULTS = [0, 1, 2, 0, 2, 3, 1, 1, 1, 2]
def standard_deviation():
if len(SURVEY_RESULTS) < 2:
return None
elif len(SURVEY_RESULTS) > 2:
stdev = (((sum(square(SURVEY_RESULTS))) - (summate * summate)/(count))/(count - 1)) ** .5
rounded_stdev = (round(stdev, 2))
print(rounded_stdev)
```
Nothing prints when I run the code. I have run the code for standard deviation separately so I know that works fine and that my issue lies in my if statement. | 2019/03/23 | [
"https://Stackoverflow.com/questions/55318985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11140950/"
] | `sp_send_dbmail` only queues up the mail. Does not attempt to deliver, does not validate the email profile, cannot raise any of the errors you complain are missing.
Read here how to check the status of emails queued: [Check the Status of E-Mail Messages Sent With Database Mail](https://learn.microsoft.com/en-us/sql/relational-databases/database-mail/check-the-status-of-e-mail-messages-sent-with-database-mail?view=sql-server-2017):
```
USE msdb ;
GO
-- Show the subject, the time that the mail item row was last
-- modified, and the log information.
-- Join sysmail_faileditems to sysmail_event_log
-- on the mailitem_id column.
-- In the WHERE clause list items where danw was in the recipients,
-- copy_recipients, or blind_copy_recipients.
-- These are the items that would have been sent
-- to danw.
SELECT items.subject,
items.last_mod_date
,l.description FROM dbo.sysmail_faileditems as items
INNER JOIN dbo.sysmail_event_log AS l
ON items.mailitem_id = l.mailitem_id
WHERE items.recipients LIKE '%danw%'
OR items.copy_recipients LIKE '%danw%'
OR items.blind_copy_recipients LIKE '%danw%'
GO
```
More articles on the topic:
* [Troubleshooting Database Mail Failures](https://www.sqlshack.com/troubleshooting-database-mail-failures/)
* [Complete Troubleshooting Guide for SQL Server Database Mail](http://www.midnightdba.com/DBARant/complete-troubleshooting-guide-for-sql-server-databasemail-dbmail/) | Your error is pretty clear in what is required. First off, create a profile and note down all the values that you will input on the wizard. [This](https://learn.microsoft.com/en-us/sql/relational-databases/database-mail/create-a-database-mail-profile?view=sql-server-2017) guide will help you create the profile correctly.
Once you have verified that the dbmail profile has been setup, its time to put it to test. If you cant send out email through the stored proc, I would want to talk to the AD admin or the person responsible for setting up the email server. This is to make sure that you can anonymously send emails and to take care of any potential relay server issues. Hope this helps. |
60,213,218 | I've been searching through many forums and articles and did not find any successful way to define an interface for a function component in React that has required properties which are defined in defaultProps without throwing a "property is missing" Typescript error.
I've tried to set a default value directly in props but it doesn't work either. Is there any way or it's unresolved issue in React and Typescript?
To see this problem in action, I've provided CodeSandbox project.
[](https://codesandbox.io/s/misty-pine-rtdl8?fontsize=14&hidenavigation=1&theme=dark)
```
type ButtonProps = {
color: "white" | "green";
};
const Button: FunctionComponent<ButtonProps> = ({
// First way to define default value
color = "green",
children
}) => <ButtonContainer>{children}</ButtonContainer>;
// Second way to define default value
Button.defaultProps = {
color: "white"
} as Partial<ButtonProps>;
const ButtonContainer = styled.button<ButtonProps>`
background-color: ${(props: ButtonProps) => props.color};
`;
const App: FunctionComponent = () => (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
{/* Here is an error */}
<Button>hello world</Button>
</div>
);
``` | 2020/02/13 | [
"https://Stackoverflow.com/questions/60213218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5334773/"
] | Since `color` is the only property on the `ButtonProps` type, you can use [Partial](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialt), which will set the properties of the type as optional:
```
const Button: FunctionComponent<Partial<ButtonProps>> = ({
// First way to define default value
color = "green",
children
}) => <ButtonContainer>{children}</ButtonContainer>;
```
Here is a working [demo](https://codesandbox.io/s/compassionate-shannon-n46fp).
**Edit**:
Following up on your comment, this is what I would recommend. We can remove the `defaultProps`, and use `ButtonProps` to define the typings for `ButtonContainer`. On the `Button` component, you may simply spread the remaining props into the child `ButtonContainer`.
```
type ButtonProps = {
color: "white" | "green";
fontSize: string;
};
const Button: FunctionComponent<Partial<ButtonProps>> = ({
// First way to define default value
children,
...styleProps
}) => <ButtonContainer {...styleProps}>{children}</ButtonContainer>;
const ButtonContainer = styled.button<ButtonProps>`
background-color: ${(props: ButtonProps) => props.color};
font-size: ${(props: ButtonProps) => props.fontSize};
`;
const App: FunctionComponent = () => (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<Button color='green'>hello world</Button>
</div>
);
```
Here is the updated [demo](https://codesandbox.io/s/black-rain-m7qd9). | Change your ButtonProps like this
```js
type ButtonProps = {
color?: "white" | "green";
};
```
Making the color props optional. And then you can initialize it with a default value, just like you are doing.
```js
const Button: FunctionComponent<ButtonProps> = ({
// First way to define default value
color = "green",
children
}) => <ButtonContainer>{children}</ButtonContainer>;
```
Hope it helps! |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | This worked for me, modify your web.config file
Section 1.
```
<system.webServer>
<handlers>
<add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
</system.webServer>
```
Section 2.
```
<system.web>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
</system.web>
``` | I had the same issue, I am using asp.net 5.0 vs2013
i changed my web.config as follows
```
<system.web>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha"/>
</httpHandlers>
<system.webServer>
<handlers>
<add name="CAPTCHAHandler" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
```
three changes to my web.config and a dll change
updated the .dll from 1.0 to 4.0
Added handlers to the system.webserver
Added
```
</system.webServer>
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
```
changed C to c at MSCaptcha.\*\*c\*\*aptchaImageHandler
it is working for me on my dev box and local. |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | Got it...
Web.config is Case Sensitive.. So change the Capital "C" to small "c" in captchaImageHandler
Change: type="MSCaptcha.\**C*\*aptchaImageHandler, MSCaptcha"
To: type="MSCaptcha.\**c*\*aptchaImageHandler, MSCaptcha"
Hope this will work for you..
happy coding...:) | This path should be like this: `path="/CaptchaImage.axd"` in `system.webServer`.
```
<system.webServer>
<handlers>
<add name = " MSCaptcha" verb = "GET" path = "/CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler,MSCaptcha"/>
</handlers>
</system.webServer>
``` |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | Got it...
Web.config is Case Sensitive.. So change the Capital "C" to small "c" in captchaImageHandler
Change: type="MSCaptcha.\**C*\*aptchaImageHandler, MSCaptcha"
To: type="MSCaptcha.\**c*\*aptchaImageHandler, MSCaptcha"
Hope this will work for you..
happy coding...:) | If you're using Forms Authentication then it's probably a permissions issue, so try this:
<http://www.aspsnippets.com/post/2009/04/03/How-to-implement-Captcha-in-ASPNet.aspx#id_9f698584-ecb7-4fa1-99f5-797ee1a8f593> |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | This path should be like this: `path="/CaptchaImage.axd"` in `system.webServer`.
```
<system.webServer>
<handlers>
<add name = " MSCaptcha" verb = "GET" path = "/CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler,MSCaptcha"/>
</handlers>
</system.webServer>
``` | I had the same issue, I am using asp.net 5.0 vs2013
i changed my web.config as follows
```
<system.web>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha"/>
</httpHandlers>
<system.webServer>
<handlers>
<add name="CAPTCHAHandler" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
```
three changes to my web.config and a dll change
updated the .dll from 1.0 to 4.0
Added handlers to the system.webserver
Added
```
</system.webServer>
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
```
changed C to c at MSCaptcha.\*\*c\*\*aptchaImageHandler
it is working for me on my dev box and local. |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | This worked for me, modify your web.config file
Section 1.
```
<system.webServer>
<handlers>
<add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
</system.webServer>
```
Section 2.
```
<system.web>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
</system.web>
``` | I have solved my issue. As Web.config is case sensitive so be careful when you edit it. Here is the code of 2 sections.
```
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
```
And make sure that you put **forward slash(/)** for the **path** value
```
<system.webServer>
<handlers>
<add name="MSCaptcha" verb="GET" path="/CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
</system.webServer>
``` |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | This worked for me, modify your web.config file
Section 1.
```
<system.webServer>
<handlers>
<add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
</system.webServer>
```
Section 2.
```
<system.web>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
</system.web>
``` | If you use form authentication then you may not be able to see the image. To resolve this add ,
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="\*" />
</authorization>
</system.web>
</location>
this section in the web.config |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | If you use form authentication then you may not be able to see the image. To resolve this add ,
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="\*" />
</authorization>
</system.web>
</location>
this section in the web.config | If you're using Forms Authentication then it's probably a permissions issue, so try this:
<http://www.aspsnippets.com/post/2009/04/03/How-to-implement-Captcha-in-ASPNet.aspx#id_9f698584-ecb7-4fa1-99f5-797ee1a8f593> |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | This path should be like this: `path="/CaptchaImage.axd"` in `system.webServer`.
```
<system.webServer>
<handlers>
<add name = " MSCaptcha" verb = "GET" path = "/CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler,MSCaptcha"/>
</handlers>
</system.webServer>
``` | If you're using Forms Authentication then it's probably a permissions issue, so try this:
<http://www.aspsnippets.com/post/2009/04/03/How-to-implement-Captcha-in-ASPNet.aspx#id_9f698584-ecb7-4fa1-99f5-797ee1a8f593> |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | This worked for me, modify your web.config file
Section 1.
```
<system.webServer>
<handlers>
<add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
</system.webServer>
```
Section 2.
```
<system.web>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
</system.web>
``` | This path should be like this: `path="/CaptchaImage.axd"` in `system.webServer`.
```
<system.webServer>
<handlers>
<add name = " MSCaptcha" verb = "GET" path = "/CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler,MSCaptcha"/>
</handlers>
</system.webServer>
``` |
1,548,153 | Mondor's MSCaptcha control runs and displays on the local dev machine but doesn't display its genrated image when deployed to the shared server hosting service.
// what my web.config says:
```
<handlers>
<add name="MSCaptchaImage"
path="CaptchaImage.axd"
verb="GET"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha"
preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>
```
Yes, I FTP the .dll(s) to the bin directory on the host server and my local code running from IIS7 on Vista runs as expected. Anything else you might need to assit please ask but I need to figure this one out as I'm stumped and note I have no control of the server at the host provider
note: I've observed somebody else has this problem as responded to at asp.net [1] lucky for me all of my Passport and Windows DeadOnArrival credentials are totally FUBAR and asp.net won't even send me a forgotten password as it doesn't know me anymore either so I can't get involed in the asp.net forums.
[1] <http://forums.asp.net/p/1468509/3395243.aspx> | 2009/10/10 | [
"https://Stackoverflow.com/questions/1548153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450681/"
] | If you use form authentication then you may not be able to see the image. To resolve this add ,
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="\*" />
</authorization>
</system.web>
</location>
this section in the web.config | I have solved my issue. As Web.config is case sensitive so be careful when you edit it. Here is the code of 2 sections.
```
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
```
And make sure that you put **forward slash(/)** for the **path** value
```
<system.webServer>
<handlers>
<add name="MSCaptcha" verb="GET" path="/CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
</system.webServer>
``` |
16,780,053 | I have a method that takes an array as an argument, and returns true or false depending on the presence of a particular value.
In this scenario how many test cases should be written?
I think 3:
1. If the value is present
2. If the value is not present
3. If the array is empty (could be covered by 2 though?? ) | 2013/05/27 | [
"https://Stackoverflow.com/questions/16780053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189880/"
] | I can think of 3 test cases:
1. If the array is not empty (or not null)
2. If the value is valid or not (I can pass an object where it expects a string :) )
3. If the value is present in array | It is the code of the function you want to test, so you cannot tell how many test cases are useful. Think again what your code does, how will the value be found?
An example: If your code tries to find a value with a certain name, and you make a string comparison, then think of the problems that can arise with string comparisons -> should the key be found case (in)sensitive, is null equal to an empty string, how does it handle duplicates and are other types converted correctly to strings (type juggling)? |
35,926,509 | I'm using MVC Razor's @Html.DropDownList to generate dropdown list.
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name
});
ViewBag.cSfRR = cSfRR;
```
This TABLE has one more field which determines activity of each item in the table.
If I use following code I get that activity field included after c.Name
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + " - " + c.Activity
});
ViewBag.cSfRR = cSfRR;
```
My problem is that that field has only one character which determines it's activity. A - Active, N - Not active.
I would like to show custom text "Not Active" for those items in SelectListItem that have value "N". Something like...
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + " - " + IF C.ACTIVITY IS "N", THEN PRINT "NOT ACTIVE"
});
ViewBag.cSfRR = cSfRR;
```
I hope someone can help me achieve something like this
DROPDOWN LIST ITEM 1
DROPDOWN LIST ITEM 2
DROPDOWN LIST ITEM 3
DROPDOWN LIST ITEM 4
DROPDOWN LIST ITEM 5 - NOT ACTIVE
DROPDOWN LIST ITEM 6 - NOT ACTIVE
DROPDOWN LIST ITEM 7 - NOT ACTIVE | 2016/03/10 | [
"https://Stackoverflow.com/questions/35926509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803051/"
] | I don't promote the use of `ViewBag`, but this should work:
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + (c.ACTIVITY == "N" ? " - NOT ACTIVE" : string.empty)
});
ViewBag.cSfRR = cSfRR;
``` | You could try something like this:
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + (c.Activity == "N") ? " - Not Active " : "";
});
ViewBag.cSfRR = cSfRR;
``` |
35,926,509 | I'm using MVC Razor's @Html.DropDownList to generate dropdown list.
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name
});
ViewBag.cSfRR = cSfRR;
```
This TABLE has one more field which determines activity of each item in the table.
If I use following code I get that activity field included after c.Name
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + " - " + c.Activity
});
ViewBag.cSfRR = cSfRR;
```
My problem is that that field has only one character which determines it's activity. A - Active, N - Not active.
I would like to show custom text "Not Active" for those items in SelectListItem that have value "N". Something like...
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + " - " + IF C.ACTIVITY IS "N", THEN PRINT "NOT ACTIVE"
});
ViewBag.cSfRR = cSfRR;
```
I hope someone can help me achieve something like this
DROPDOWN LIST ITEM 1
DROPDOWN LIST ITEM 2
DROPDOWN LIST ITEM 3
DROPDOWN LIST ITEM 4
DROPDOWN LIST ITEM 5 - NOT ACTIVE
DROPDOWN LIST ITEM 6 - NOT ACTIVE
DROPDOWN LIST ITEM 7 - NOT ACTIVE | 2016/03/10 | [
"https://Stackoverflow.com/questions/35926509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803051/"
] | You can use [conditional operator - ?: Operator](https://msdn.microsoft.com/en-us/library/ty67wk28.aspx)
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + (c.Activity == "N" ? " - NOT ACTIVE" : "")
});
ViewBag.cSfRR = cSfRR;
``` | You could try something like this:
```
IEnumerable<SelectListItem> cSfRR = db.TABLE.Where(m => m.cRoleName == dbrole)
.Select(c => new SelectListItem
{
Value = c.ID,
Text = c.Name + (c.Activity == "N") ? " - Not Active " : "";
});
ViewBag.cSfRR = cSfRR;
``` |
4,639,166 | Consider the matrix given as $$A=\begin{bmatrix}a\_0 & a\_2 & a\_1\\ a\_1 & a\_0 & a\_2\\ a\_2 & a\_1 & a\_0\end{bmatrix}$$
Write down a formual for $A^n$ for $n\in\mathbb{N}$.
$$$$
**My attempt:** The first that comes to mind is to diagonalize it and hence find the formual for $A^n$, but that is very messy, so I tried to do something else it goes as:
bserve that $$A=\begin{bmatrix}a\_0 & a\_2 & a\_1\\ a\_1 & a\_0 & a\_2\\ a\_2 & a\_1 & a\_0\end{bmatrix}=a\_0\begin{bmatrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{bmatrix}+a\_1\begin{bmatrix}0 & 0 & 1\\1 & 0 & 0\\0 & 1 & 0\end{bmatrix}+a\_2\begin{bmatrix}0 & 1 & 0\\0 & 0 & 1\\1 & 0 & 0\end{bmatrix}$$
Let $U=\begin{bmatrix}0 & 0 & 1\\1 & 0 & 0\\0 & 1 & 0\end{bmatrix}$ then we will have that
$$\begin{matrix}U^2=\begin{bmatrix}0 & 1 & 0\\0 & 0 & 1\\1 & 0 & 0\end{bmatrix} & \text{ and } & U^3=\begin{bmatrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{bmatrix}\end{matrix}$$
Hence we have $A=a\_0I+a\_1U+a\_2U^2 = a\_0U^3+a\_1U+a\_2U^2=(a\_0U^2+a\_1I+a\_2U)U$
This got me thinking that there might be an easy way to solve the above problem but, I was not able to make any further progress.
Please Help and thanks in advance. | 2023/02/14 | [
"https://math.stackexchange.com/questions/4639166",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/872144/"
] | $A$ is a so-called circulant matrix, which can be denoted as ${\rm circ}(a\_0,a\_1,a\_2)$. Let $\alpha = \exp{2\pi i/3}$; $\alpha$ is a 3rd root of unity, and satisfies $\alpha^3 = 1$ and $1 + \alpha + \alpha^2 = 0$ (as does its conjugate). By the general theory of circulants, we can diagonalize $A$ as follows:
$$ A = U \,{\rm diag}(d\_0,d\_1,d\_2)\, U^\*,$$ where
$U$ is the unitary matrix:
$$ U = \frac{1}{\sqrt{3}}\,\pmatrix{1 &1 & 1 \\ 1 &\alpha &\alpha^2 \\ 1 &\alpha^2 &\alpha^4},$$ and $d = \sqrt{3}\,U^\* a$. We recover $a$ from the inverse transformation: $a = \frac{1}{\sqrt{3}} U d.$
We can now calculate
\begin{align}
A^n &= (U D U^\*)^n \\
&= U D^n U^\* \\
&= U\, {\rm diag}(d\_0^n, d\_1^n, d\_2^n)\, U^\*\\
&= {\rm circ}(a^{(n)}\_0, a^{(n)}\_1, a^{(n)}\_2),
\end{align}
where $a^{(n)} = \frac{1}{\sqrt{3}} U\cdot (d^n\_0,d^n\_1,d^n\_2)^T.$ | I think you've reached a decent result and by just using the multinomial theorem you can obtain a generalized solution.
$A=a\_0I+ a\_1U + a\_2 U^2 \\
A^n = (a\_0I+ a\_1U + a\_2 U^2)^n\\$
Then the coeffecients of $U^3$, $U^2$ and $U^1$ are determined using the multinomial theorem and just plugged back into the result matrix.
$$
\begin{matrix}
\sum\_{a+b+c=n,\\ b+2c =3k} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+2} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+1} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c \\
\sum\_{a+b+c=n,\\ b+2c =3k+1} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+2} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c \\
\sum\_{a+b+c=n,\\ b+2c =3k+2} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+1} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c \\
\end{matrix}
$$
The answer may seem obvious but unfortunately the multinomial expansion can't be simplified further (as per my knowledge). Even if it could it would just be a huge mess. |
4,639,166 | Consider the matrix given as $$A=\begin{bmatrix}a\_0 & a\_2 & a\_1\\ a\_1 & a\_0 & a\_2\\ a\_2 & a\_1 & a\_0\end{bmatrix}$$
Write down a formual for $A^n$ for $n\in\mathbb{N}$.
$$$$
**My attempt:** The first that comes to mind is to diagonalize it and hence find the formual for $A^n$, but that is very messy, so I tried to do something else it goes as:
bserve that $$A=\begin{bmatrix}a\_0 & a\_2 & a\_1\\ a\_1 & a\_0 & a\_2\\ a\_2 & a\_1 & a\_0\end{bmatrix}=a\_0\begin{bmatrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{bmatrix}+a\_1\begin{bmatrix}0 & 0 & 1\\1 & 0 & 0\\0 & 1 & 0\end{bmatrix}+a\_2\begin{bmatrix}0 & 1 & 0\\0 & 0 & 1\\1 & 0 & 0\end{bmatrix}$$
Let $U=\begin{bmatrix}0 & 0 & 1\\1 & 0 & 0\\0 & 1 & 0\end{bmatrix}$ then we will have that
$$\begin{matrix}U^2=\begin{bmatrix}0 & 1 & 0\\0 & 0 & 1\\1 & 0 & 0\end{bmatrix} & \text{ and } & U^3=\begin{bmatrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{bmatrix}\end{matrix}$$
Hence we have $A=a\_0I+a\_1U+a\_2U^2 = a\_0U^3+a\_1U+a\_2U^2=(a\_0U^2+a\_1I+a\_2U)U$
This got me thinking that there might be an easy way to solve the above problem but, I was not able to make any further progress.
Please Help and thanks in advance. | 2023/02/14 | [
"https://math.stackexchange.com/questions/4639166",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/872144/"
] | Circulant matrices are related to Fourier transform.
Consider the DFT matrix of length $N=3$
$$
\mathbf{W}
=
\begin{pmatrix}
1 & 1 & 1 \\
1 & \Omega & \Omega^2 \\
1 & \Omega^2 & \Omega^4
\end{pmatrix}
$$
where
$\Omega
= e^{-2\pi i/N}$.
Consider now the DFT of the signal
$$
\mathbf{y}=
\mathbf{W}
\begin{pmatrix}
a\_0 \\ a\_1 \\ a\_2
\end{pmatrix}
$$
From here, you can observe that
$$
\mathbf{WA}=
\mathbf{W}
\begin{pmatrix}
a\_0 & a\_2 & a\_1 \\ a\_1 & a\_0 & a\_2 \\ a\_2 & a\_1 & a\_0
\end{pmatrix}
=
\mathrm{Diag}(\mathbf{y})
\mathbf{W}
$$
and thus
$$
\mathbf{A}
=
\mathbf{W}^{-1}
\mathrm{Diag}(\mathbf{y})
\mathbf{W}
=
\frac{1}{N} \mathbf{W}^{H}
\mathbf{D}
\mathbf{W}
$$
with $\mathbf{D}=\mathrm{Diag}(\mathbf{y})$.
Finally the $k$th power of $\mathbf{A}$ is
$$
\mathbf{A}^k
=
\frac{1}{N}
\mathbf{W}^{H} \mathbf{D}^k \mathbf{W}
$$ | I think you've reached a decent result and by just using the multinomial theorem you can obtain a generalized solution.
$A=a\_0I+ a\_1U + a\_2 U^2 \\
A^n = (a\_0I+ a\_1U + a\_2 U^2)^n\\$
Then the coeffecients of $U^3$, $U^2$ and $U^1$ are determined using the multinomial theorem and just plugged back into the result matrix.
$$
\begin{matrix}
\sum\_{a+b+c=n,\\ b+2c =3k} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+2} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+1} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c \\
\sum\_{a+b+c=n,\\ b+2c =3k+1} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+2} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c \\
\sum\_{a+b+c=n,\\ b+2c =3k+2} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k+1} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c & \sum\_{a+b+c=n,\\ b+2c =3k} \frac{n!}{a!b!c!}(a\_0)^ a(a\_1)^b(a\_2)^c \\
\end{matrix}
$$
The answer may seem obvious but unfortunately the multinomial expansion can't be simplified further (as per my knowledge). Even if it could it would just be a huge mess. |
17,958,173 | Omniture/SiteCatalyst's code is integrated onto the webpage to collect the analytics in our firm.
Current process: SiteCatalyst id deployed by pasting HTML code onto each page of the website. This HTML code contains variables and other identifiers that facilitate the data collection process. These variables may be dynamically populated with server or application variables. The code snippet also calls the JavaScript library file, which contains SiteCatalyst-specific JavaScript functions used during metrics collection.
We use Add-on's like Charlie, HTTP Post, DigitalPulse Debugger to Test if the code inserted has accurate values corresponding to it. This process is time consuming and tedious.
How to Automate this process? Any help would be appreciated!
Example 1:
```
<a href="javascript:void(s.t());">Click here to send a page view</a>
s.pageName="New Page"
s.prop1="some value"
void(s.t());
```
Example 2:
```
s=s_gi('myreportsuiteid');
s.linkTrackVars="prop1,eVar1,events"; s.linkTrackEvents="event1";
s.prop1="some value"; s.eVar1="another value"; s.events="event1";
s.tl(this,'o','My Link Name');
``` | 2013/07/30 | [
"https://Stackoverflow.com/questions/17958173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2631288/"
] | There are a few different ways to automate testing. I've been looking into it lately myself. So far I'm looking into Selenium, Zombiejs and Phantomjs. You can search for "headless testing" which basically let's run code as a browser and test conditions on the page you visit.
Here's a good place to start <https://github.com/ariya/phantomjs/wiki/Headless-Testing>
Using these platforms, you could easily set pages to automatically validate if the SiteCatalyst code is firing, page names are correct, click events happen etc.
Selenium is an enterprise product whereas the JS frameworks would be more of a development effort. | we usually do this using a more customizable proxy application called Fiddler which we use to capture all the traffic sent from our brower.
Fiddler has an internal scripting language that let you make any type of check on the data passing in the Adobe Analytics call and highlight in the interface any bad call. |
86,303 | I clipped a concrete block at dead slow speed. It bent my rear bumper.
This is the view of the full bumper now. You can see the "knee" I put in it.
[](https://i.stack.imgur.com/sFeOA.jpg)
The bumper itself has a piece of angle iron running through the center to give it support. It is about 1/2" - 3/4" on each leg,as you can see here:
[](https://i.stack.imgur.com/dvvqi.jpg)
As you can see in this photo, there is no gap between the angle iron and the fiberglass.
TIA | 2021/12/13 | [
"https://mechanics.stackexchange.com/questions/86303",
"https://mechanics.stackexchange.com",
"https://mechanics.stackexchange.com/users/61103/"
] | I think it is very unlikely that you can straighten the steel.
I would carefully cut the steel out from the back, get some new steel, weld the brackets back on if necessary, then fibreglass it back in place.
That is what I would do if a second hand replacement is not readily available. It would be a lot easier to repaint a second hand one than repair the one you have. | You shouldn't attempt to repair a bumper. You will not be able to restore the original performance correctly - remember that its job is to *absorb impact* in order to protect the vehicle (including occupants) and environment (including other road users).
If you make it too stiff or too soft, you have compromised the safety of the vehicle.
The only reasonable choice is to replace with a new or reputably salvaged one. |
25,105,541 | I'm writing a program that will read a text file containing 5,163 names. (text file can be seen [here](http://pastebin.com/BAKTJKy6))
Then I want to store the names into a list called 'names', afterwards, I sort the list based on how many letters the name contains, shorter names are at the start of the list and the longer ones are at the end.
I used quicksort to sort the list, but when I run it, it shows this error:
```
C:\Python27\python.exe C:/Users/Lenovo/Desktop/Anagrams/Main.py
Traceback (most recent call last):
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 25, in <module>
names = quicksort(names)
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 8, in quicksort
greater = quicksort([x for x in list[1:] if not lessThan(x, pivot)])
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 7, in quicksort
lesser = quicksort([x for x in list[1:] if lessThan(x, pivot)])
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 8, in quicksort
greater = quicksort([x for x in list[1:] if not lessThan(x, pivot)])
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 7, in quicksort
lesser = quicksort([x for x in list[1:] if lessThan(x, pivot)])
# [.... many lines elided ...]
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 8, in quicksort
greater = quicksort([x for x in list[1:] if not lessThan(x, pivot)])
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 8, in quicksort
greater = quicksort([x for x in list[1:] if not lessThan(x, pivot)])
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 7, in quicksort
lesser = quicksort([x for x in list[1:] if lessThan(x, pivot)])
File "C:/Users/Lenovo/Desktop/Anagrams/Main.py", line 3, in quicksort
if list == []:
RuntimeError: maximum recursion depth exceeded in cmp
```
The full traceback is available [as a pastie](http://pastebin.com/cC671BTd).
I've tested the quicksort function and it works for ordinary lists (ex: list = ['Alice','Bob,'Carl','Derp']), but it doesn't work if I try to sort 'names'
Here's my code
```
def quicksort(list):
"""Quicksort using list comprehensions"""
if list == []:
return []
else:
pivot = list[0]
lesser = quicksort([x for x in list[1:] if lessThan(x, pivot)])
greater = quicksort([x for x in list[1:] if not lessThan(x, pivot)])
return lesser + [pivot] + greater
def lessThan(a, b):
return len(a) < len(b)
#'''
input = open('Names.txt', 'r')
output = open('Names Arranged By Length.txt', 'w')
names = []
for line in input:
line = line.translate(None, '\n')
names.append(line)
names = quicksort(names)
for i in names:
print i
output.write(i)
output.write('\n')
print 'Count: ', len(names)
input.close()
output.close()
#'''
```
What's wrong with my code and how do I fix it? | 2014/08/03 | [
"https://Stackoverflow.com/questions/25105541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2412444/"
] | You have simply hit the recursion limits. Your list of names is too large for Python's limited recursion capabilities. Your Quicksort works just fine otherwise.
You *could* raise the recursion limit by setting the limit higher with [`sys.setrecursionlimit()`](https://docs.python.org/2/library/sys.html#sys.setrecursionlimit). You can set it a fair amount higher, but you do so at your own risk.
A better option is to use the built-in Python sort; the [TimSort algorithm](http://en.wikipedia.org/wiki/Timsort) is far superior and won't hit a recursion limit:
```
names = sorted(names, key=len)
```
This sorts the names by their length, shortest names first. | You exceed python default recursion size. The default recursion limit is 1000. You can increase recursion limit but it is not recommended. Here is how to do
```
import sys
sys.setrecursionlimit(1500)
```
**Suggestion**
My suggestion is use [numpy.argsort()](http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.sort.html) method which is already prepared for many sorting algorithms. [Here is simple examle](https://stackoverflow.com/a/36592205/4104008) for how to do quicksort algorith by using numpy library. |
22,524,403 | I am new to RubyOnRails and SoundCloud.
I want to integrate SoundCloud API in my ruby on rails application.
For this I have registered on [SoundCloud](http://developers.soundcloud.com/) And I got the ClientID and ClientSecret. Also I have [downloaded the SDK](https://github.com/soundcloud/soundcloud-ruby).
Now I have copied the files and folders from **lib** and **spec** directory to my applications lib and spec directory. Also I have added **gem 'soundcloud'** in the Gemfile.
After this I made simple code (copied from doc) in My Interactor:
```
# register a client with YOUR_CLIENT_ID as client_id_
client = SoundCloud.new(:client_id => YOUR_CLIENT_ID)
# get 10 hottest tracks
tracks = client.get('/tracks', :limit => 10, :order => 'hotness')
# print each link
tracks.each do |track|
puts track.permalink_url
end
```
But here I'm getting the error -
```
uninitialized constant MyApp::Interactors::MyInteractor::MyAction::SoundCloud
```
I followed the steps from [APIDoc](https://github.com/soundcloud/soundcloud-ruby). Is there any step by step example for integrating SoundCloud in Ruby on Rails so that I can follow?
How can I resolve this error?
MyInteracor.rb
```
module MyApp
module Interactors
module MyInteractor
class MyAction < Struct.new(:user, :params)
def run
# SoundCloud
# register a client with YOUR_CLIENT_ID as client_id_
client = SoundCloud.new(:client_id => 'my-client-id')
# get 10 hottest tracks
tracks = client.get('/tracks', :limit => 10, :order => 'hotness')
# print each link
tracks.each do |track|
puts track.permalink_url
end
end
end
end
end
end
``` | 2014/03/20 | [
"https://Stackoverflow.com/questions/22524403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1147080/"
] | There's a typo in the soundcloud github page change the line:
```
client = SoundCloud.new(:client_id => 'my-client-id')
```
to
```
client = Soundcloud.new(:client_id => 'my-client-id')
```
[notice the lowercase c in Soundcloud] | Also you are going to need your client secret for SoundCloud's API to verify you.
Perhaps put client method and in it have client = SoundCloud.new(your-client-id,your-secret-key-your-redirect-uri) in a controller or helper with your client\_id, client\_secret, and redirect uri values protected in a .env file.
I think by leaving out your redirect\_uri and client secret you might be getting this error in MyInteractor.rb
Hope this helps |
17,208,227 | I'm trying to export a gridview to pdf with package iTextSharp.
I'm doing it in my .aspx files :
```
<form id="formOptions" runat="server">
[...]
<asp:GridView ID="gvReportingStockComp" runat="server" AutoGenerateColumns="false" Visible="true">
<Columns>
<asp:BoundField DataField="cod_wo" HeaderText="N° OF" />
<asp:BoundField DataField="composant" HeaderText="Composant" />
<asp:BoundField DataField="BESOIN" HeaderText="Besoin/OF" />
<asp:BoundField DataField="BESOIN_T" HeaderText="Besoin total" />
<asp:BoundField DataField="stock_dispo" HeaderText="Stock dispo" />
<asp:BoundField DataField="QTE_RESTANTE" HeaderText="Qte restante" />
</Columns>
</asp:GridView>
</form>
```
And in my code behind, I fill the gridview :
```
OracleConnection oConnexion = new OracleConnection();
oConnexion.ConnectionString = "X";
oConnexion.Open();
string reqStockCompTotal = "intitulé de ma requete"
OracleCommand cmdReqStockComp = new OracleCommand(reqStockCompTotal);
cmdReqStockComp.Connection = oConnexion;
OracleDataReader readerReqStockComp = cmdReqStockComp.ExecuteReader();
gvReportingStockComp.DataSource = readerReqStockComp;
gvReportingStockComp.DataBind();
oConnexion.Close();
oConnexion.Dispose();
```
It work buit if I add the next code in order to make the export :
```
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestMES.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvReportingStockComp.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
```
In a first hand it block with :
```
gvReportingStockComp.RenderControl(hw);
```
and visual studio says : "GridView must be declared in with runat=server"
Or it block to :
```
pdfDoc.Close();
```
and he says : pdfDoc is empty...
Somebody has an idea please ? | 2013/06/20 | [
"https://Stackoverflow.com/questions/17208227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2265252/"
] | Add below code to avoid runat="server" error.
```
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
```
You may want to disable paging so that it exports all rows of Gridview to PDF.
Add below code before gridview's rendercontrol method.
```
gvReportingStockComp.AllowPaging = false;
gvReportingStockComp.DataBind();
```
Incase you've any doubt, refer below article.
<http://www.aspsnippets.com/Articles/Export-GridView-To-Word-Excel-PDF-CSV-Formats-in-ASP.Net.aspx> | Add the `Rendering` Function after your PDF code
```
public override void VerifyRenderingInServerForm(Control control)
{
// verifies the control is rendered here
}
``` |
6,359,654 | I need to use 4 dimensional matrix as an accumulator for voting 4 parameters. every parameters vary in the range of 1~300. for that, I define Acc = zeros(300,300,300,300) in MATLAB. and somewhere for example, I used:
```
Acc(4,10,120,78)=Acc(4,10,120,78)+1
```
however, MATLAB says some error happened because of memory limitation.
```
??? Error using ==> zeros
Out of memory. Type HELP MEMORY for your options.
```
---
in the below, you can see a part of my code:
```
I = imread('image.bmp'); %I is logical 300x300 image.
Acc = zeros(100,100,100,100);
for i = 1:300
for j = 1:300
if I(i,j)==1
for x0 = 3:3:300
for y0 = 3:3:300
for a = 3:3:300
b = abs(j-y0)/sqrt(1-((i-x0)^2) / (a^2));
b1=floor(b/3);
if b1==0
b1=1;
end
a1=ceil(a/3);
Acc(x0/3,y0/3,a1,b1) = Acc(x0/3,y0/3,a1,b1)+1;
end
end
end
end
end
end
``` | 2011/06/15 | [
"https://Stackoverflow.com/questions/6359654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/787978/"
] | As @Rasman mentioned, you probably want to use a sparse representation of the matrix Acc.
Unfortunately, the `sparse` function is geared toward 2D matrices, not arbitrary n-D.
But that's ok, because we can take advantage of `sub2ind` and *linear indexing* to go back and forth to 4D.
```
Dims = [300, 300, 300, 300]; % it will be a 300 by 300 by 300 by 300 matrix
Acc = sparse([], [], [], prod(Dims), 1, ExpectedNumElts);
```
Here `ExpectedNumElts` should be some number like 30 or 9000 or however many non-zero elements you expect for the matrix `Acc` to have. We notionally think of `Acc` as a matrix, but actually it will be a vector. But that's okay, we can use `sub2ind` to convert 4D coordinates into linear indices into the vector:
```
ind = sub2ind(Dims, 4, 10, 120, 78);
Acc(ind) = Acc(ind) + 1;
```
You may also find the functions `find`, `nnz`, `spy`, and `spfun` helpful. | See [Avoiding 'Out of Memory' Errors](http://www.mathworks.com/support/tech-notes/1100/1107.html)
Your statement would require more than 4 GB of RAM (Around 16 Gigs, to be specific).
>
> Solutions to 'Out of Memory' problems
> fall into two main categories:
>
>
> * Maximizing the memory available to
> MATLAB (i.e., removing or increasing
> limits) on your system via operating
> system selection and system
> configuration. These usually have the
> greatest overall applicability but are
> potentially the most disruptive (e.g.
> using a different operating system).
> These techniques are covered in the
> first two sections of this document.
> * Minimizing the memory used by MATLAB
> by making your code more memory
> efficient. These are all algorithm
> and application specific and therefore
> are less broadly applicable. These
> techniques are covered in later
> sections of this document.
>
>
>
In your case later seems to be the solution - try reducing the amount of memory used / required. |
6,359,654 | I need to use 4 dimensional matrix as an accumulator for voting 4 parameters. every parameters vary in the range of 1~300. for that, I define Acc = zeros(300,300,300,300) in MATLAB. and somewhere for example, I used:
```
Acc(4,10,120,78)=Acc(4,10,120,78)+1
```
however, MATLAB says some error happened because of memory limitation.
```
??? Error using ==> zeros
Out of memory. Type HELP MEMORY for your options.
```
---
in the below, you can see a part of my code:
```
I = imread('image.bmp'); %I is logical 300x300 image.
Acc = zeros(100,100,100,100);
for i = 1:300
for j = 1:300
if I(i,j)==1
for x0 = 3:3:300
for y0 = 3:3:300
for a = 3:3:300
b = abs(j-y0)/sqrt(1-((i-x0)^2) / (a^2));
b1=floor(b/3);
if b1==0
b1=1;
end
a1=ceil(a/3);
Acc(x0/3,y0/3,a1,b1) = Acc(x0/3,y0/3,a1,b1)+1;
end
end
end
end
end
end
``` | 2011/06/15 | [
"https://Stackoverflow.com/questions/6359654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/787978/"
] | edit: see lambdageek for the exact same answer with a bit more elegance.
The other answers are helping to guide you to use a sparse mat instead of your current dense solution. This is made a little more difficult since current matlab doesn't support N-dimensional sparse arrays. One implementation to do this is
replace
```
zeros(100,100,100,100)
```
with
```
sparse(100*100*100*100,1)
```
this will store all your counts in a sparse array, as long as most remain zero, you will be ok for memory.
then to access this data, instead of:
```
Acc(h,i,j,k)=Acc(h,i,j,k)+1
```
use:
```
index = h+100*i+100*100*j+100*100*100*k
Acc(index,1)=Acc(index,1)+1
``` | See [Avoiding 'Out of Memory' Errors](http://www.mathworks.com/support/tech-notes/1100/1107.html)
Your statement would require more than 4 GB of RAM (Around 16 Gigs, to be specific).
>
> Solutions to 'Out of Memory' problems
> fall into two main categories:
>
>
> * Maximizing the memory available to
> MATLAB (i.e., removing or increasing
> limits) on your system via operating
> system selection and system
> configuration. These usually have the
> greatest overall applicability but are
> potentially the most disruptive (e.g.
> using a different operating system).
> These techniques are covered in the
> first two sections of this document.
> * Minimizing the memory used by MATLAB
> by making your code more memory
> efficient. These are all algorithm
> and application specific and therefore
> are less broadly applicable. These
> techniques are covered in later
> sections of this document.
>
>
>
In your case later seems to be the solution - try reducing the amount of memory used / required. |
631,108 | Prove by induction that for $q\neq1$, we have $1+q+...+q^{n-1}=\dfrac{q^{n}-1}{q-1}, \forall n\in \mathbb N $
-------------------------------------------------------------------------------------------------------------
Let $P(n)$ be the proposition we want to prove.
For $P(1)$ we have:
$q^0=\dfrac{q^1-1}{q-1}\implies1=1$, so $P(1)$ is true
For $P(2)$ we have:
$q^0+q^1=\dfrac{q^2-1}{q-1}\implies1+q=1+q$, so $P(2)$ is true
**Inductive Hypothesis:** Let $n=k$ and we assume that $P(k):1+q+...+q^{k-1}=\frac{q^{k}-1}{q-1}$ is true .
We have to prove that $P(k+1):1+q+...+q^{k-1}+q^{k}=\dfrac{q^{k+1}-1}{q-1}$ is true.
**Inductive step:** $1+q+...+q^{k-1}+q^{k}=\dfrac{q^{k}-1}{q-1}+q^{k}$,
And I get stuck at this part. | 2014/01/08 | [
"https://math.stackexchange.com/questions/631108",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/116309/"
] | $$
\frac{q^k-1}{q-1}+q^k=\frac{q^{k+1}-1}{q-1}
$$ | Assume it for $k$ and we show the formula for $k+1$:
$1+q+...+q^{k}+q^{k+1}=\frac{q^{k+1}-1}{q-1}+q^{k+1}=\frac{q^{k+1}-1+q^{k+1}(q-1)}{q-1}=\frac{q^{k+1}-1+q^{k+2}-q^{k+1}}{q-1}=\frac{q^{k+1}-1}{q-1}$ |
631,108 | Prove by induction that for $q\neq1$, we have $1+q+...+q^{n-1}=\dfrac{q^{n}-1}{q-1}, \forall n\in \mathbb N $
-------------------------------------------------------------------------------------------------------------
Let $P(n)$ be the proposition we want to prove.
For $P(1)$ we have:
$q^0=\dfrac{q^1-1}{q-1}\implies1=1$, so $P(1)$ is true
For $P(2)$ we have:
$q^0+q^1=\dfrac{q^2-1}{q-1}\implies1+q=1+q$, so $P(2)$ is true
**Inductive Hypothesis:** Let $n=k$ and we assume that $P(k):1+q+...+q^{k-1}=\frac{q^{k}-1}{q-1}$ is true .
We have to prove that $P(k+1):1+q+...+q^{k-1}+q^{k}=\dfrac{q^{k+1}-1}{q-1}$ is true.
**Inductive step:** $1+q+...+q^{k-1}+q^{k}=\dfrac{q^{k}-1}{q-1}+q^{k}$,
And I get stuck at this part. | 2014/01/08 | [
"https://math.stackexchange.com/questions/631108",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/116309/"
] | $$
\frac{q^k-1}{q-1}+q^k=\frac{q^{k+1}-1}{q-1}
$$ | Note that $\frac{q^k-1}{q-1} + q^k = \frac{q^k-1 + (q-1)q^k}{q-1} = \frac{q^{k+1} + q^k - q^k - 1}{q-1} = \frac{q^{k+1}-1}{q-1}$ |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | Of course! You can use the same keystore file as many times you want. It's always better to use the same keystore file for all the applications you develop. That will help if you want to update or modify the application. At that time you need to sign your application with the same key. | **Recent Update**
If you want to enrol in **App signing by google** you have to use new different key to sign your apk or bundle otherwise after uploading google console will give you error message saying
>
> You uploaded an APK or Android App Bundle that is signed with a key
> that is also used to sign APKs that are delivered to users. Because
> you are enrolled in App Signing by Google Play, you should sign your
> APK or Android App Bundle with a new key before you upload it
>
>
> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | The official documentation tells us:
>
> In general, the recommended strategy for all developers is to sign all of your applications with the same certificate, throughout the expected lifespan of your applications. There are several reasons why you should do so ...
>
>
>
<https://developer.android.com/studio/publish/app-signing.html#considerations>
So yes, try to sign all of your applications with the same certificate. | I want to add some clarification here, because this question and the answers provided lead to confusion for me. It is crucial to understand what a keystore actually is.
A keystore is just a means to securely store the public/private key pair which is used to sign your Android apks. So yes, you can use the same *keystore* to sign multiple apks, without a problem. You can also use the same alias (each alias is a certificate) to sign multiple apks, and it will work. It has security implications, however. If your single alias is compromised, then all of your apps will have been compromised.
However, if you intend to sell the rights to your apps one day, then using the same alias for all of your apps may not be a good idea. However, using the same keystore, provided you use a different alias for each apk, may not necessarily be a bad option. I'm sure there is a way that you can move a certificate from one keystore to another, so that you can securely give the necessary keys for only that certificate to your buyer.
To make it very clear, a keystore is just that, a storage medium for keys. It plays no actual part in the process of signing an apk, but only serves to store the keys which are actually used to sign the apk.
References:
[Understanding keystore, certificates and alias](https://stackoverflow.com/questions/5724631/understanding-keystore-certificates-and-alias)
<https://www.digitalocean.com/community/tutorials/java-keytool-essentials-working-with-java-keystores> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | I'll make a counter argument to the consensus answer so far.
I agree that for most app authors most of the time, sharing the same keystore/certificate/password between your apps will work fine. The critical thing is to use "[the same certificate throughout the expected lifespan of your applications](http://developer.android.com/tools/publishing/app-signing.html#considerations)" so the app can upgrade itself.
But I can think of one very good reason to have separate keystores for separate apps or families of apps. If you think you might ever want to sell an app to someone else for them to publish as an upgrade to the original, you'll have to share your one-and-only keystore and password with them to do so. Probably not a huge issue but a bit of worry to you and, perhaps, a due diligence issue to a big-enough buyer.
Also, I really don't read the same line in the documentation the same way as @ol\_v\_er does. I think the current line:
>
> You should sign all of your apps with the same certificate throughout the expected lifespan of your applications.
>
>
>
(note the lack of a comma in the current version) is simply emphasizing that the 'lifetime' recommendation applies to all apps, not actually directing you to use the same certificate for all of your apps. | I do sign all my apps using the same certificate (keystore). This gives an advantage if i change my mind and want my apps to share their data.
As you might know Android identifies each app with an UID. If all your apps are signed by the same certificate you can request android to assign same user id more than one app and inturn make them run in a single process and share the data.
From android doc [android:sharedUserId](https://developer.android.com/guide/topics/manifest/manifest-element.html#uid)
>
> android:sharedUserId
>
>
> The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process
>
>
> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | I want to add some clarification here, because this question and the answers provided lead to confusion for me. It is crucial to understand what a keystore actually is.
A keystore is just a means to securely store the public/private key pair which is used to sign your Android apks. So yes, you can use the same *keystore* to sign multiple apks, without a problem. You can also use the same alias (each alias is a certificate) to sign multiple apks, and it will work. It has security implications, however. If your single alias is compromised, then all of your apps will have been compromised.
However, if you intend to sell the rights to your apps one day, then using the same alias for all of your apps may not be a good idea. However, using the same keystore, provided you use a different alias for each apk, may not necessarily be a bad option. I'm sure there is a way that you can move a certificate from one keystore to another, so that you can securely give the necessary keys for only that certificate to your buyer.
To make it very clear, a keystore is just that, a storage medium for keys. It plays no actual part in the process of signing an apk, but only serves to store the keys which are actually used to sign the apk.
References:
[Understanding keystore, certificates and alias](https://stackoverflow.com/questions/5724631/understanding-keystore-certificates-and-alias)
<https://www.digitalocean.com/community/tutorials/java-keytool-essentials-working-with-java-keystores> | I do sign all my apps using the same certificate (keystore). This gives an advantage if i change my mind and want my apps to share their data.
As you might know Android identifies each app with an UID. If all your apps are signed by the same certificate you can request android to assign same user id more than one app and inturn make them run in a single process and share the data.
From android doc [android:sharedUserId](https://developer.android.com/guide/topics/manifest/manifest-element.html#uid)
>
> android:sharedUserId
>
>
> The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process
>
>
> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | I'll make a counter argument to the consensus answer so far.
I agree that for most app authors most of the time, sharing the same keystore/certificate/password between your apps will work fine. The critical thing is to use "[the same certificate throughout the expected lifespan of your applications](http://developer.android.com/tools/publishing/app-signing.html#considerations)" so the app can upgrade itself.
But I can think of one very good reason to have separate keystores for separate apps or families of apps. If you think you might ever want to sell an app to someone else for them to publish as an upgrade to the original, you'll have to share your one-and-only keystore and password with them to do so. Probably not a huge issue but a bit of worry to you and, perhaps, a due diligence issue to a big-enough buyer.
Also, I really don't read the same line in the documentation the same way as @ol\_v\_er does. I think the current line:
>
> You should sign all of your apps with the same certificate throughout the expected lifespan of your applications.
>
>
>
(note the lack of a comma in the current version) is simply emphasizing that the 'lifetime' recommendation applies to all apps, not actually directing you to use the same certificate for all of your apps. | **Recent Update**
If you want to enrol in **App signing by google** you have to use new different key to sign your apk or bundle otherwise after uploading google console will give you error message saying
>
> You uploaded an APK or Android App Bundle that is signed with a key
> that is also used to sign APKs that are delivered to users. Because
> you are enrolled in App Signing by Google Play, you should sign your
> APK or Android App Bundle with a new key before you upload it
>
>
> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | You can use that `keystore` for any number of applications.
No need to generate a new keystore. | I want to add some clarification here, because this question and the answers provided lead to confusion for me. It is crucial to understand what a keystore actually is.
A keystore is just a means to securely store the public/private key pair which is used to sign your Android apks. So yes, you can use the same *keystore* to sign multiple apks, without a problem. You can also use the same alias (each alias is a certificate) to sign multiple apks, and it will work. It has security implications, however. If your single alias is compromised, then all of your apps will have been compromised.
However, if you intend to sell the rights to your apps one day, then using the same alias for all of your apps may not be a good idea. However, using the same keystore, provided you use a different alias for each apk, may not necessarily be a bad option. I'm sure there is a way that you can move a certificate from one keystore to another, so that you can securely give the necessary keys for only that certificate to your buyer.
To make it very clear, a keystore is just that, a storage medium for keys. It plays no actual part in the process of signing an apk, but only serves to store the keys which are actually used to sign the apk.
References:
[Understanding keystore, certificates and alias](https://stackoverflow.com/questions/5724631/understanding-keystore-certificates-and-alias)
<https://www.digitalocean.com/community/tutorials/java-keytool-essentials-working-with-java-keystores> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | The official documentation tells us:
>
> In general, the recommended strategy for all developers is to sign all of your applications with the same certificate, throughout the expected lifespan of your applications. There are several reasons why you should do so ...
>
>
>
<https://developer.android.com/studio/publish/app-signing.html#considerations>
So yes, try to sign all of your applications with the same certificate. | **Recent Update**
If you want to enrol in **App signing by google** you have to use new different key to sign your apk or bundle otherwise after uploading google console will give you error message saying
>
> You uploaded an APK or Android App Bundle that is signed with a key
> that is also used to sign APKs that are delivered to users. Because
> you are enrolled in App Signing by Google Play, you should sign your
> APK or Android App Bundle with a new key before you upload it
>
>
> |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | You can use that `keystore` for any number of applications.
No need to generate a new keystore. | I'll make a counter argument to the consensus answer so far.
I agree that for most app authors most of the time, sharing the same keystore/certificate/password between your apps will work fine. The critical thing is to use "[the same certificate throughout the expected lifespan of your applications](http://developer.android.com/tools/publishing/app-signing.html#considerations)" so the app can upgrade itself.
But I can think of one very good reason to have separate keystores for separate apps or families of apps. If you think you might ever want to sell an app to someone else for them to publish as an upgrade to the original, you'll have to share your one-and-only keystore and password with them to do so. Probably not a huge issue but a bit of worry to you and, perhaps, a due diligence issue to a big-enough buyer.
Also, I really don't read the same line in the documentation the same way as @ol\_v\_er does. I think the current line:
>
> You should sign all of your apps with the same certificate throughout the expected lifespan of your applications.
>
>
>
(note the lack of a comma in the current version) is simply emphasizing that the 'lifetime' recommendation applies to all apps, not actually directing you to use the same certificate for all of your apps. |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | You can use that `keystore` for any number of applications.
No need to generate a new keystore. | The official documentation tells us:
>
> In general, the recommended strategy for all developers is to sign all of your applications with the same certificate, throughout the expected lifespan of your applications. There are several reasons why you should do so ...
>
>
>
<https://developer.android.com/studio/publish/app-signing.html#considerations>
So yes, try to sign all of your applications with the same certificate. |
7,685,458 | I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same? | 2011/10/07 | [
"https://Stackoverflow.com/questions/7685458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806972/"
] | You can use that `keystore` for any number of applications.
No need to generate a new keystore. | Of course! You can use the same keystore file as many times you want. It's always better to use the same keystore file for all the applications you develop. That will help if you want to update or modify the application. At that time you need to sign your application with the same key. |
38,265,987 | i am facing problem (i really frustrated), while i connecting the io.on function. i am using express,ioredis and socket.io. redis working properly but socket.io is not working. it is'nt working.please help.
```
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var Redis = require('ioredis');
var redis = new Redis();
//port connection
server.listen(3000);
console.log('server listening 3000');
//redis sub (working fine)
redis.subscribe('test-channel', function () {
console.log('Redis: test-channel subscribed');
});
//this code is not working (stop execution)
io.on('connection', function(socket){
console.log("new client connected");
});
io.on('connection', function (socket) {
console.log("new client connected");
redis.subscribe('message');
console.log("redis start");
//send message to frontend
redis.on("message", function(channel, message) {
console.log("mew message in queue "+ message + "channel");
socket.emit(channel, message);
});
//close socket
socket.on('disconnect', function() {
redis.quit();
console.log('redis disconnected!');
});
});
```
Client side
```
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script>
<script>
var socket = io.connect('http://localhost:3000');
socket.on('message', function (data) {
$(".progress-bar").css('width',+data+'%');
alert('connection established');
$("#messages").append( "<p>"+data+"</p>" );
});
</script>
``` | 2016/07/08 | [
"https://Stackoverflow.com/questions/38265987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6502612/"
] | Server side
```
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server); // it was require('socket.io')(server);
server.listen(3000);
```
Client side
```
io.sockets.on('connection', function(socket){
console.log("new client connected");
});
``` | const { Server } = require("socket.io")
const io = new Server(server) |
17,481,866 | I must be missing something really obvious here I think, but what I am trying to do is use MySQL 5.6 and return values through memcache
So I have set up MYSQL to use the memcache plugin, set up the details in the innodb\_memcache.containers table
I now have two items in that table, the default ones entered by MySQL and my own settings, both of them have table names.
To get the data via php I use:
```
$memcache->get($key);
```
Where $key is the data in the db column
However this returns nothing, I suspect the reason is that, according to the MySQL Docs if no table name is specified, it choose the first one in the list, which is not the one I want, what I don't understand is how I specify the correct table name in the key, so it knows which table to look for the key in.
Additional Information:
```
table design:
table: codes
id INT PK
code VARCHAR UNIQUE
codeval VARCHAR
innodb_memcache.containers :
name: mycode
db_schema: databaseName
db_table: codes
key_columns: code
value_columns: codeval
flags: id
cas_column: null
expire_time_column: null
unique_idx_name_on_key: code
```
Code:
```
$table = "mycode";
$key = "123456";
$memcache = new Memcache;
$memcache->connect($this->CONNECTURL, $this->CONNECTPORT) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$key = "@@" . $table . "." . $key . "." . $table;
$get_result = $memcache->get($key);
print_r($get_result);
```
The above code returns the server version without issue, so the connection is working.
print\_r($get\_result) returns blank, when it should be returning a value
It does throw a notice: Trying to get property of non-object
So if someone could let me know how I specify with the $key which table I am using to query through memcache, I would be much appreciated! | 2013/07/05 | [
"https://Stackoverflow.com/questions/17481866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585958/"
] | From: <http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-intro.html>
>
> Namespaces: memcached is like a single giant directory, where to keep files from conflicting with each other you might give them elaborate names with prefixes and suffixes. The integrated InnoDB / memcached server lets you use these same naming conventions for keys, with one addition. Key names of the format **@@table\_id.key.table\_id** are decoded to reference a specific a table, using mapping data from the **innodb\_memcache.containers** table. The key is looked up in or written to the specified table.
>
>
> The @@ notation only works for individual calls to the get, add, and set functions, not the others such as incr or delete. To designate the default table for all subsequent memcached operations within a session, perform a get request using the @@ notation and a table ID, but without the key portion. For example:
>
>
> **get @@table\_x**
>
>
> Subsequent get, set, incr, delete and other operations use the table designated by table\_x in the **innodb\_memcache.containers.name** column.
>
>
> | ```
<?php
$memc = new Memcache;
$memc->addServer('localhost','11211');
if(empty($_POST['film'])) {
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Memcache Lookup</title>
</head>
<body>
<form method="post">
<p><b>Film</b>: <input type="text" size="20" name="film"></p>
<input type="submit">
</form>
<hr/>
<?php
} else {
echo "Loading data...\n";
$film = htmlspecialchars($_POST['film'], ENT_QUOTES, 'UTF-8');
$mfilms = $memc->get($film);
if ($mfilms) {
printf("<p>Film data for %s loaded from memcache</p>", $mfilms['title']);
foreach (array_keys($mfilms) as $key) {
printf("<p><b>%s</b>: %s</p>", $key, $mfilms[$key]);
}
} else {
$mysqli = mysqli('localhost','sakila','password','sakila');
if (mysqli_connect_error()) {
sprintf("Database error: (%d) %s", mysqli_connect_errno(), mysqli_connect_error());
exit;
}
$sql = sprintf('SELECT * FROM film WHERE title="%s"', $mysqli->real_escape_string($film));
$result = $mysqli->query($sql);
if (!$result) {
sprintf("Database error: (%d) %s", $mysqli->errno, $mysqli->error);
exit;
}
$row = $result->fetch_assoc();
$memc->set($row['title'], $row);
printf("<p>Loaded (%s) from MySQL</p>", htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8');
}
}
?>
</body>
</html>
```
With PHP, the connections to the memcached instances are kept open as long as the PHP and associated Apache instance remain running. When adding or removing servers from the list in a running instance (for example, when starting another script that mentions additional servers), the connections are shared, but the script only selects among the instances explicitly configured within the script. |
17,481,866 | I must be missing something really obvious here I think, but what I am trying to do is use MySQL 5.6 and return values through memcache
So I have set up MYSQL to use the memcache plugin, set up the details in the innodb\_memcache.containers table
I now have two items in that table, the default ones entered by MySQL and my own settings, both of them have table names.
To get the data via php I use:
```
$memcache->get($key);
```
Where $key is the data in the db column
However this returns nothing, I suspect the reason is that, according to the MySQL Docs if no table name is specified, it choose the first one in the list, which is not the one I want, what I don't understand is how I specify the correct table name in the key, so it knows which table to look for the key in.
Additional Information:
```
table design:
table: codes
id INT PK
code VARCHAR UNIQUE
codeval VARCHAR
innodb_memcache.containers :
name: mycode
db_schema: databaseName
db_table: codes
key_columns: code
value_columns: codeval
flags: id
cas_column: null
expire_time_column: null
unique_idx_name_on_key: code
```
Code:
```
$table = "mycode";
$key = "123456";
$memcache = new Memcache;
$memcache->connect($this->CONNECTURL, $this->CONNECTPORT) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$key = "@@" . $table . "." . $key . "." . $table;
$get_result = $memcache->get($key);
print_r($get_result);
```
The above code returns the server version without issue, so the connection is working.
print\_r($get\_result) returns blank, when it should be returning a value
It does throw a notice: Trying to get property of non-object
So if someone could let me know how I specify with the $key which table I am using to query through memcache, I would be much appreciated! | 2013/07/05 | [
"https://Stackoverflow.com/questions/17481866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585958/"
] | The table name (`table_id` in `@@table_id`) must be the value from your mappings (`innodb_memcache.containers`), not the actual table name, if that varies.
And if you table name in mappings is `mycode`, then the resulting query through *memcache* should look like this:
```
$table = 'mycode';
$key = '123456';
$memcache->get( '@@' . $table . '.' . $key );
```
There is no extra `'.' . $table` at the end.
Some details are available from [InnoDB memcached Plugin](http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-internals.html) documentation page.
To name a few of importance here:
1. Use `select * from innodb_memcache.containers;` to get defined mappings;
2. Note the queries organization:
>
> For example, @@t1.some\_key and @@t2.some\_key have the same key value,
> but are stored in different tables and so do not conflict.
>
>
> | ```
<?php
$memc = new Memcache;
$memc->addServer('localhost','11211');
if(empty($_POST['film'])) {
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Memcache Lookup</title>
</head>
<body>
<form method="post">
<p><b>Film</b>: <input type="text" size="20" name="film"></p>
<input type="submit">
</form>
<hr/>
<?php
} else {
echo "Loading data...\n";
$film = htmlspecialchars($_POST['film'], ENT_QUOTES, 'UTF-8');
$mfilms = $memc->get($film);
if ($mfilms) {
printf("<p>Film data for %s loaded from memcache</p>", $mfilms['title']);
foreach (array_keys($mfilms) as $key) {
printf("<p><b>%s</b>: %s</p>", $key, $mfilms[$key]);
}
} else {
$mysqli = mysqli('localhost','sakila','password','sakila');
if (mysqli_connect_error()) {
sprintf("Database error: (%d) %s", mysqli_connect_errno(), mysqli_connect_error());
exit;
}
$sql = sprintf('SELECT * FROM film WHERE title="%s"', $mysqli->real_escape_string($film));
$result = $mysqli->query($sql);
if (!$result) {
sprintf("Database error: (%d) %s", $mysqli->errno, $mysqli->error);
exit;
}
$row = $result->fetch_assoc();
$memc->set($row['title'], $row);
printf("<p>Loaded (%s) from MySQL</p>", htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8');
}
}
?>
</body>
</html>
```
With PHP, the connections to the memcached instances are kept open as long as the PHP and associated Apache instance remain running. When adding or removing servers from the list in a running instance (for example, when starting another script that mentions additional servers), the connections are shared, but the script only selects among the instances explicitly configured within the script. |
17,481,866 | I must be missing something really obvious here I think, but what I am trying to do is use MySQL 5.6 and return values through memcache
So I have set up MYSQL to use the memcache plugin, set up the details in the innodb\_memcache.containers table
I now have two items in that table, the default ones entered by MySQL and my own settings, both of them have table names.
To get the data via php I use:
```
$memcache->get($key);
```
Where $key is the data in the db column
However this returns nothing, I suspect the reason is that, according to the MySQL Docs if no table name is specified, it choose the first one in the list, which is not the one I want, what I don't understand is how I specify the correct table name in the key, so it knows which table to look for the key in.
Additional Information:
```
table design:
table: codes
id INT PK
code VARCHAR UNIQUE
codeval VARCHAR
innodb_memcache.containers :
name: mycode
db_schema: databaseName
db_table: codes
key_columns: code
value_columns: codeval
flags: id
cas_column: null
expire_time_column: null
unique_idx_name_on_key: code
```
Code:
```
$table = "mycode";
$key = "123456";
$memcache = new Memcache;
$memcache->connect($this->CONNECTURL, $this->CONNECTPORT) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$key = "@@" . $table . "." . $key . "." . $table;
$get_result = $memcache->get($key);
print_r($get_result);
```
The above code returns the server version without issue, so the connection is working.
print\_r($get\_result) returns blank, when it should be returning a value
It does throw a notice: Trying to get property of non-object
So if someone could let me know how I specify with the $key which table I am using to query through memcache, I would be much appreciated! | 2013/07/05 | [
"https://Stackoverflow.com/questions/17481866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585958/"
] | If you still have the default tables, you can try using telnet.
Note: This was used on an AWS RDS instance with memcached, it *should* be the same for any MySQL implementation using memcached, but I'm not sure.
```
telnet localhost 11211
stats
#=> should return a long list of stats including pid, uptime, etc
get AA
#=> should return
VALUE AA 8 12
HELLO, HELLO
END
quit #exit telnet session
```
I know this doesn't answer your question, but it might help in troubleshooting. | ```
<?php
$memc = new Memcache;
$memc->addServer('localhost','11211');
if(empty($_POST['film'])) {
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Memcache Lookup</title>
</head>
<body>
<form method="post">
<p><b>Film</b>: <input type="text" size="20" name="film"></p>
<input type="submit">
</form>
<hr/>
<?php
} else {
echo "Loading data...\n";
$film = htmlspecialchars($_POST['film'], ENT_QUOTES, 'UTF-8');
$mfilms = $memc->get($film);
if ($mfilms) {
printf("<p>Film data for %s loaded from memcache</p>", $mfilms['title']);
foreach (array_keys($mfilms) as $key) {
printf("<p><b>%s</b>: %s</p>", $key, $mfilms[$key]);
}
} else {
$mysqli = mysqli('localhost','sakila','password','sakila');
if (mysqli_connect_error()) {
sprintf("Database error: (%d) %s", mysqli_connect_errno(), mysqli_connect_error());
exit;
}
$sql = sprintf('SELECT * FROM film WHERE title="%s"', $mysqli->real_escape_string($film));
$result = $mysqli->query($sql);
if (!$result) {
sprintf("Database error: (%d) %s", $mysqli->errno, $mysqli->error);
exit;
}
$row = $result->fetch_assoc();
$memc->set($row['title'], $row);
printf("<p>Loaded (%s) from MySQL</p>", htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8');
}
}
?>
</body>
</html>
```
With PHP, the connections to the memcached instances are kept open as long as the PHP and associated Apache instance remain running. When adding or removing servers from the list in a running instance (for example, when starting another script that mentions additional servers), the connections are shared, but the script only selects among the instances explicitly configured within the script. |
17,481,866 | I must be missing something really obvious here I think, but what I am trying to do is use MySQL 5.6 and return values through memcache
So I have set up MYSQL to use the memcache plugin, set up the details in the innodb\_memcache.containers table
I now have two items in that table, the default ones entered by MySQL and my own settings, both of them have table names.
To get the data via php I use:
```
$memcache->get($key);
```
Where $key is the data in the db column
However this returns nothing, I suspect the reason is that, according to the MySQL Docs if no table name is specified, it choose the first one in the list, which is not the one I want, what I don't understand is how I specify the correct table name in the key, so it knows which table to look for the key in.
Additional Information:
```
table design:
table: codes
id INT PK
code VARCHAR UNIQUE
codeval VARCHAR
innodb_memcache.containers :
name: mycode
db_schema: databaseName
db_table: codes
key_columns: code
value_columns: codeval
flags: id
cas_column: null
expire_time_column: null
unique_idx_name_on_key: code
```
Code:
```
$table = "mycode";
$key = "123456";
$memcache = new Memcache;
$memcache->connect($this->CONNECTURL, $this->CONNECTPORT) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$key = "@@" . $table . "." . $key . "." . $table;
$get_result = $memcache->get($key);
print_r($get_result);
```
The above code returns the server version without issue, so the connection is working.
print\_r($get\_result) returns blank, when it should be returning a value
It does throw a notice: Trying to get property of non-object
So if someone could let me know how I specify with the $key which table I am using to query through memcache, I would be much appreciated! | 2013/07/05 | [
"https://Stackoverflow.com/questions/17481866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585958/"
] | The table name (`table_id` in `@@table_id`) must be the value from your mappings (`innodb_memcache.containers`), not the actual table name, if that varies.
And if you table name in mappings is `mycode`, then the resulting query through *memcache* should look like this:
```
$table = 'mycode';
$key = '123456';
$memcache->get( '@@' . $table . '.' . $key );
```
There is no extra `'.' . $table` at the end.
Some details are available from [InnoDB memcached Plugin](http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-internals.html) documentation page.
To name a few of importance here:
1. Use `select * from innodb_memcache.containers;` to get defined mappings;
2. Note the queries organization:
>
> For example, @@t1.some\_key and @@t2.some\_key have the same key value,
> but are stored in different tables and so do not conflict.
>
>
> | From: <http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-intro.html>
>
> Namespaces: memcached is like a single giant directory, where to keep files from conflicting with each other you might give them elaborate names with prefixes and suffixes. The integrated InnoDB / memcached server lets you use these same naming conventions for keys, with one addition. Key names of the format **@@table\_id.key.table\_id** are decoded to reference a specific a table, using mapping data from the **innodb\_memcache.containers** table. The key is looked up in or written to the specified table.
>
>
> The @@ notation only works for individual calls to the get, add, and set functions, not the others such as incr or delete. To designate the default table for all subsequent memcached operations within a session, perform a get request using the @@ notation and a table ID, but without the key portion. For example:
>
>
> **get @@table\_x**
>
>
> Subsequent get, set, incr, delete and other operations use the table designated by table\_x in the **innodb\_memcache.containers.name** column.
>
>
> |
17,481,866 | I must be missing something really obvious here I think, but what I am trying to do is use MySQL 5.6 and return values through memcache
So I have set up MYSQL to use the memcache plugin, set up the details in the innodb\_memcache.containers table
I now have two items in that table, the default ones entered by MySQL and my own settings, both of them have table names.
To get the data via php I use:
```
$memcache->get($key);
```
Where $key is the data in the db column
However this returns nothing, I suspect the reason is that, according to the MySQL Docs if no table name is specified, it choose the first one in the list, which is not the one I want, what I don't understand is how I specify the correct table name in the key, so it knows which table to look for the key in.
Additional Information:
```
table design:
table: codes
id INT PK
code VARCHAR UNIQUE
codeval VARCHAR
innodb_memcache.containers :
name: mycode
db_schema: databaseName
db_table: codes
key_columns: code
value_columns: codeval
flags: id
cas_column: null
expire_time_column: null
unique_idx_name_on_key: code
```
Code:
```
$table = "mycode";
$key = "123456";
$memcache = new Memcache;
$memcache->connect($this->CONNECTURL, $this->CONNECTPORT) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$key = "@@" . $table . "." . $key . "." . $table;
$get_result = $memcache->get($key);
print_r($get_result);
```
The above code returns the server version without issue, so the connection is working.
print\_r($get\_result) returns blank, when it should be returning a value
It does throw a notice: Trying to get property of non-object
So if someone could let me know how I specify with the $key which table I am using to query through memcache, I would be much appreciated! | 2013/07/05 | [
"https://Stackoverflow.com/questions/17481866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585958/"
] | From: <http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-intro.html>
>
> Namespaces: memcached is like a single giant directory, where to keep files from conflicting with each other you might give them elaborate names with prefixes and suffixes. The integrated InnoDB / memcached server lets you use these same naming conventions for keys, with one addition. Key names of the format **@@table\_id.key.table\_id** are decoded to reference a specific a table, using mapping data from the **innodb\_memcache.containers** table. The key is looked up in or written to the specified table.
>
>
> The @@ notation only works for individual calls to the get, add, and set functions, not the others such as incr or delete. To designate the default table for all subsequent memcached operations within a session, perform a get request using the @@ notation and a table ID, but without the key portion. For example:
>
>
> **get @@table\_x**
>
>
> Subsequent get, set, incr, delete and other operations use the table designated by table\_x in the **innodb\_memcache.containers.name** column.
>
>
> | If you still have the default tables, you can try using telnet.
Note: This was used on an AWS RDS instance with memcached, it *should* be the same for any MySQL implementation using memcached, but I'm not sure.
```
telnet localhost 11211
stats
#=> should return a long list of stats including pid, uptime, etc
get AA
#=> should return
VALUE AA 8 12
HELLO, HELLO
END
quit #exit telnet session
```
I know this doesn't answer your question, but it might help in troubleshooting. |
17,481,866 | I must be missing something really obvious here I think, but what I am trying to do is use MySQL 5.6 and return values through memcache
So I have set up MYSQL to use the memcache plugin, set up the details in the innodb\_memcache.containers table
I now have two items in that table, the default ones entered by MySQL and my own settings, both of them have table names.
To get the data via php I use:
```
$memcache->get($key);
```
Where $key is the data in the db column
However this returns nothing, I suspect the reason is that, according to the MySQL Docs if no table name is specified, it choose the first one in the list, which is not the one I want, what I don't understand is how I specify the correct table name in the key, so it knows which table to look for the key in.
Additional Information:
```
table design:
table: codes
id INT PK
code VARCHAR UNIQUE
codeval VARCHAR
innodb_memcache.containers :
name: mycode
db_schema: databaseName
db_table: codes
key_columns: code
value_columns: codeval
flags: id
cas_column: null
expire_time_column: null
unique_idx_name_on_key: code
```
Code:
```
$table = "mycode";
$key = "123456";
$memcache = new Memcache;
$memcache->connect($this->CONNECTURL, $this->CONNECTPORT) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$key = "@@" . $table . "." . $key . "." . $table;
$get_result = $memcache->get($key);
print_r($get_result);
```
The above code returns the server version without issue, so the connection is working.
print\_r($get\_result) returns blank, when it should be returning a value
It does throw a notice: Trying to get property of non-object
So if someone could let me know how I specify with the $key which table I am using to query through memcache, I would be much appreciated! | 2013/07/05 | [
"https://Stackoverflow.com/questions/17481866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585958/"
] | The table name (`table_id` in `@@table_id`) must be the value from your mappings (`innodb_memcache.containers`), not the actual table name, if that varies.
And if you table name in mappings is `mycode`, then the resulting query through *memcache* should look like this:
```
$table = 'mycode';
$key = '123456';
$memcache->get( '@@' . $table . '.' . $key );
```
There is no extra `'.' . $table` at the end.
Some details are available from [InnoDB memcached Plugin](http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-internals.html) documentation page.
To name a few of importance here:
1. Use `select * from innodb_memcache.containers;` to get defined mappings;
2. Note the queries organization:
>
> For example, @@t1.some\_key and @@t2.some\_key have the same key value,
> but are stored in different tables and so do not conflict.
>
>
> | If you still have the default tables, you can try using telnet.
Note: This was used on an AWS RDS instance with memcached, it *should* be the same for any MySQL implementation using memcached, but I'm not sure.
```
telnet localhost 11211
stats
#=> should return a long list of stats including pid, uptime, etc
get AA
#=> should return
VALUE AA 8 12
HELLO, HELLO
END
quit #exit telnet session
```
I know this doesn't answer your question, but it might help in troubleshooting. |
3,499,351 | I have four dice: three red, one blue. I roll all four.
1) How do I find the formula to establish the probability of the blue one getting the highest result (ties included: if all four rolled 6, then the blue one still got the highest result)?
2) How do I generalize the formula above for a group of four dice, each one with a different number of faces? (ie: one red 6-sided die, two red 8-sided dice, and a black 10-sided die)?
I apologize if anything is unclear, English isn't my first language. | 2020/01/06 | [
"https://math.stackexchange.com/questions/3499351",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/457310/"
] | For 1), you didn't specify the numbers of faces, but I take it from $2)$ that you intended them all to have the same number of faces in $1)$. Let $n$ denote this number of faces. Then the probability for the other three dice to show at most the value shown by the blue die is
$$
\frac1n\sum\_{k=1}^n\frac{k^3}{n^3}=\frac1{n^4}\left(\frac{n(n+1)}2\right)^2=\frac14\left(1+\frac1n\right)^2\;.
$$
The factor $\frac1n$ is the probability for the blue die to show one of the $n$ faces, and $\frac{k^3}{n^3}$ is the probability for the other three dice not to show more. As one might expect, the probability goes to $\frac14$ for $n\to\infty$.
For $2)$, you basically do the same thing but with a bit more casework. For instance, in the example you gave, the probability for the black die to show at least as much as all the others would be
$$
\frac1{10}\left(\sum\_{k=1}^6\frac{k^3}{6\cdot8\cdot8}+\sum\_{k=7}^8\frac{k^2}{8^2}+\sum\_{k=9}^{10}1\right)=\frac1{10}\left(\frac14\cdot\frac{6^2(6+1)^2}{6\cdot8\cdot8}+\frac{7^2}{8^2}+\frac{8^2}{8^2}+2\right)=\frac{629}{1280}\;.
$$
*P.S.:* As requested in a comment, here's the probability for one $8$-sided blue die to show not less than one $6$-sided and two $10$-sided red dice:
$$
\frac18\left(\sum\_{k=1}^6\frac{k^3}{6\cdot10\cdot10}+\sum\_{k=7}^8\frac{k^2}{10^2}\right)=\frac18\left(\frac14\cdot\frac{6^2(6+1)^2}{6\cdot10\cdot10}+\frac{7^2}{10^2}+\frac{8^2}{10^2}\right)=\frac{373}{1600}\;.
$$ | For (1): Treat the dice as being distinguishable (including the three red dice).
Then count favorable outcomes conditioning on the value of the blue die:
If the blue die is $1$, there is one favorable outcome: Each of the red dice is $1$.
If the blue die is $2$ there are eight favorable outcomes. Each of the red dice is $1$ or $2$
If the blue die is $3$ there are $27$ favorable outcomes... etc.
So the total number of favorable outcomes is $1+8+27+64+125+216$ out of $1296$ possible outcomes.
Problem (2) can be handled similarly. |
22,573,953 | I have a specific requirement to find a pattern and replace the value of matching group(2) in the original string by retaining the pattern(delimiter), I am using the pattern
```
:(\w+)[:\|]+(.*)
```
With this pattern it parse the values correctly but i am not able to replace the value of group(2). For example i have a multi-line input string
```
:20:9405601140
:2D::11298666
:28C:20/1
```
I want to replace the value(9405601140) of tag 20 with new value(1234) so the output i am expecting is
```
:20:1234
:2D::11298666
:28C:20/1
```
Thanks | 2014/03/22 | [
"https://Stackoverflow.com/questions/22573953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3448704/"
] | Use this one:
```
input = input.replaceAll("(:20):(\\d+)(?!\\d)", "$1:1234");
```
Here `(\\d+)(?!\\d)` is checking whether the digits `after the :20:` are not followed by a digit or not.
However, if you want to replace only the `:20:9405601140` there here it is much simple:
```
input = input.replaceAll(":20:9405601140(?!\\d)", ":20:1234");
``` | How about doing it the other way around.
Create a pattern like this `(:(\w+)[:\|]+)(.*)` then for each row output the first group and your replacement (instead of group 2).
Here is an working example <http://ideone.com/9TkGx6> |
22,573,953 | I have a specific requirement to find a pattern and replace the value of matching group(2) in the original string by retaining the pattern(delimiter), I am using the pattern
```
:(\w+)[:\|]+(.*)
```
With this pattern it parse the values correctly but i am not able to replace the value of group(2). For example i have a multi-line input string
```
:20:9405601140
:2D::11298666
:28C:20/1
```
I want to replace the value(9405601140) of tag 20 with new value(1234) so the output i am expecting is
```
:20:1234
:2D::11298666
:28C:20/1
```
Thanks | 2014/03/22 | [
"https://Stackoverflow.com/questions/22573953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3448704/"
] | Use this one:
```
input = input.replaceAll("(:20):(\\d+)(?!\\d)", "$1:1234");
```
Here `(\\d+)(?!\\d)` is checking whether the digits `after the :20:` are not followed by a digit or not.
However, if you want to replace only the `:20:9405601140` there here it is much simple:
```
input = input.replaceAll(":20:9405601140(?!\\d)", ":20:1234");
``` | You can do this by capturing what you want to keep, instead of what you want to replace, and then using a backreference (`$1`, for the first capturing group) in the replacement string to include it in the final result.
Something like:
```
string.replaceAll("(:\\w+[:\\|]+).*", "$11234")
```
To perform the replacement on all the given lines, or just:
```
string.replaceAll("(:20[:\\|]+).*", "$11234")
```
To perform the replacement only on the line beginning with ":20". |
22,573,953 | I have a specific requirement to find a pattern and replace the value of matching group(2) in the original string by retaining the pattern(delimiter), I am using the pattern
```
:(\w+)[:\|]+(.*)
```
With this pattern it parse the values correctly but i am not able to replace the value of group(2). For example i have a multi-line input string
```
:20:9405601140
:2D::11298666
:28C:20/1
```
I want to replace the value(9405601140) of tag 20 with new value(1234) so the output i am expecting is
```
:20:1234
:2D::11298666
:28C:20/1
```
Thanks | 2014/03/22 | [
"https://Stackoverflow.com/questions/22573953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3448704/"
] | Use this one:
```
input = input.replaceAll("(:20):(\\d+)(?!\\d)", "$1:1234");
```
Here `(\\d+)(?!\\d)` is checking whether the digits `after the :20:` are not followed by a digit or not.
However, if you want to replace only the `:20:9405601140` there here it is much simple:
```
input = input.replaceAll(":20:9405601140(?!\\d)", ":20:1234");
``` | try this
```
s = s.replaceAll("\\A(?::[:\\|])\\w+", "1234");
``` |
14,171 | * What [blessing](http://www.jewishvirtuallibrary.org/jsource/Judaism/Brachot.html) would one make on leaves from [woody] trees that are routinely eaten? Is it ha'eitz, because they came from a tree? Is it ha-adama, because they're not "fruit" but are vegetative? Is it shehakol, for some other reason?
* Are there any examples of leaves from [woody] trees that are routinely eaten? If so, do any halachic sources discuss what to make on them? | 2012/02/12 | [
"https://judaism.stackexchange.com/questions/14171",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/2/"
] | The [Shulchan Aruch OC 202:6](http://hebrewbooks.org/pdfpager.aspx?req=49624&st=&pgnum=208) discusses the bracha on a [caper bush](http://en.wikipedia.org/wiki/Caper)[1]. The caper has multiple edible parts including leaves and berries. The Shulchan Aruch says the berries get a HaEtz because they are the main fruit ("Ikkar HaPeri") and the leaves get a HaAdamah. The Shaar HaTziyun sk 41 says the reason the leaves still get a HaAdamah is because the capers were planted for their leaves as well. He says that when people do not plant the capers for the leaves at all but solely for the fruit than the leaves revert to SheHaKol.
So in short, if the leaves are the main fruit of the tree they get a HaEtz. If they are not the main fruit but still an intended benfit of planting the tree, they get a HaAdamah. If they are completely unintended, they get a SheHaKol.
---
[1] Capers are a common plant in parts of Israel and were often cultivated for their fruits. One famous caper-farmer is the Tanna [Elazar HaKappar](http://en.wikipedia.org/wiki/Eleazar_ha-kappar). (see:[here](http://www.tapuz.co.il/blog/net/print.aspx?EntryId=1968965)) | According to the shulchan aruch harav capers are hoadomo too, being that they are planted for their leaves too. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.