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 |
|---|---|---|---|---|---|
26,699,450 | I am going read codes(binary) from a text file which will have data like "000101" or "100010". Then I am concatenating 2 bits with this binary strings further. I am having trouble with leading zeros,which i cant skip. I have been trying to do it by first converting the binary string to int (using atoi()) and then to hexadecimal string. But with leading zeros if i use that function,it truncates the leading zeros. I have searched here but the solutions given are not in C language. Is there any direct method to do this or I will have to keep track of everything? thanks in advance.
Here is my function which takes int as input and then converts it to hexadecimal string
```
void toHex(int n, char str[]) /* Function to convert binary to hexadecimal. */
{
int i=0,decimal=0, rem;
char temp[2];
while (n!=0)
{
decimal += (n%10)*pow(2,i);
n/=10;
++i;
}
/* At this point, variable decimal contains binary number in decimal format. */
i=0;
while (decimal!=0)
{
rem=decimal%16;
switch(rem)
{
case 10:
str[i]='A';
break;
case 11:
str[i]='B';
break;
case 12:
str[i]='C';
break;
case 13:
str[i]='D';
break;
case 14:
str[i]='E';
break;
case 15:
str[i]='F';
break;
default:
str[i]=rem+'0';
break;
}
++i;
decimal/=16;
}
str[i]='\0';
strrev(str); // Function to reverse string.
if(strlen(str)==1)
{
temp[0] = '0';
temp[1] = str[0];
temp[2] = '\0';
strcpy(str,temp);
}
else if(strlen(str)==0)
{
temp[0] = '0';
temp[1] = '0';
temp[2] = '\0';
strcpy(str,temp);
}
}
``` | 2014/11/02 | [
"https://Stackoverflow.com/questions/26699450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3429329/"
] | 1. get the number of binary digits (before calling atoi)
```
size_t binlen = strlen(input);
```
2. get the number of hex digits to output (it's just `binlen/4` rounded up)
```
size_t hexlen = ((binlen % 4 ? binlen+4 : binlen) / 4);
```
3. print the integer as hex, with the correct number of leading zeroes
```
sprintf(str, "%0.*x", hexlen, n);
```
NB. you should really pass the length of your output buffer, and use `snprintf` instead ... | You should not start by converting the number to `int` (the loop where you construct `decimal`).
Instead, you should write a separate function that takes four characters representing a binary number, and produces a single hex character. Then you could implement your target function as a sequence of calls to this function, going four characters at a time.
The only trick to this approach is that you need to deal with situations when the length of the binary string is not divisible by 4. In this case you need to pad the initial portion of the string with zeros.
Here is how you can implement a function that converts four characters to a single hex digit:
```
char binToHexDigit(const char bin[4]) {
int digit = (bin[0] == '1' ? 8 : 0)
| (bin[1] == '1' ? 4 : 0)
| (bin[2] == '1' ? 2 : 0)
| (bin[3] == '1' ? 1 : 0);
return (digit < 10 ? '0' : ('A'-10)) + digit;
}
```
[Demo](http://ideone.com/zetfqF).
Note how this function avoids the `switch` statement by exploiting the fact that digits 0..9 and letters A..F are arranged sequentially in UNICODE, ASCII, and EBCDIC, so you can convert a number to a digit character using a simple addition. |
61,890,423 | I trying to upload a simpale text as file to oneDrive using REST API.
I Create App inportal.azure.com
And i add the follow API permissions
[](https://i.stack.imgur.com/mkIkS.jpg)
I create a token:
<https://login.microsoftonline.com/>< My tenantName>/oauth2/v2.0/token
Send the follow pramters:
* grant\_type client\_credentials
* client\_id My client id
* client\_secret My client secret
* scope <https://graph.microsoft.com/.default>
Content-Type application/x-www-form-urlencoded
Keep-Alive true
I send it as a post and get a JSON with the token.
Then I try to upload the text as file.
using the follow URL
<https://graph.microsoft.com/v1.0/drive/root:/>/test.txt:/content
* authorization Bearer {my token String}
* Content-Type text/plain
* Body "The string that needs to upload"
{
"error":
{
"code": "BadRequest",
"message": "Unable to retrieve tenant service info.",
"innerError": {
"request-id": "098f37d5-96fd-44d0-905b-c147eac223f5",
"date": "2020-05-19T11:43:03"
}
}
}
[](https://i.stack.imgur.com/3P7oi.jpg)
What I do Wrong?
Thanks in advance | 2020/05/19 | [
"https://Stackoverflow.com/questions/61890423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4112376/"
] | If you want to use Microsoft Graph to upload file to onedrive, please refer to the [document](https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http)
```
PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content
PUT /users/{user-id}/drive/items/{parent-id}:/{filename}:/content
```
For example, upload file to one user's onedrive in your tenant
1. Create Azure AD application
2. [Configure Permissions for the application](https://learn.microsoft.com/en-us/graph/auth-v2-service?context=graph%2Fapi%2F1.0&view=graph-rest-1.0#2-configure-permissions-for-microsoft-graph). (Microsoft graph -> Application Permissions -> **Files.ReadWrite.All, Sites.ReadWrite.All**)
3. Get access token
```
Post https://login.microsoftonline.com/< My tenantName>/oauth2/v2.0/token
Content-Type application/x-www-form-urlencoded
grant_type= client_credentials
&client_id= My client id
&client_secret= My client secret
&scope =https://graph.microsoft.com/.default
```
4 upload file to one user's onedrive
```
Put https://graph.microsoft.com/v1.0/users/<user object id or upn>/drive/items/root:/test.txt:/content
Authorization : Bearer <Access token>
Content-Type: text/plain
<file content>
```
[](https://i.stack.imgur.com/k9FjF.png)
Besides, please note that when we use API to upload file, the size of file cannot be larger than 4MB. If you want to upload large file, please refer to the [document](https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0) and the [document](https://dev.to/cesarcodes/uploading-large-files-to-onedrive-with-microsoft-graph-api-4lo7) | To upload file (<4MB in size) to your OneDrive in the tenant.
This command will do the job
```
foo@bar:~$ ACCESS_TOKEN=eyJ0eXAiOiJKV1QiLCJub25jZSI6IlZ0MVBN...
foo@bar:~$ curl -X PUT 'https://graph.microsoft.com/v1.0/me/drive/root:/myNewFolder/file.tgz:/content' -H 'Authorization: Bearer '"${ACCESS_TOKEN}"'' -T test.tgz
``` |
61,890,423 | I trying to upload a simpale text as file to oneDrive using REST API.
I Create App inportal.azure.com
And i add the follow API permissions
[](https://i.stack.imgur.com/mkIkS.jpg)
I create a token:
<https://login.microsoftonline.com/>< My tenantName>/oauth2/v2.0/token
Send the follow pramters:
* grant\_type client\_credentials
* client\_id My client id
* client\_secret My client secret
* scope <https://graph.microsoft.com/.default>
Content-Type application/x-www-form-urlencoded
Keep-Alive true
I send it as a post and get a JSON with the token.
Then I try to upload the text as file.
using the follow URL
<https://graph.microsoft.com/v1.0/drive/root:/>/test.txt:/content
* authorization Bearer {my token String}
* Content-Type text/plain
* Body "The string that needs to upload"
{
"error":
{
"code": "BadRequest",
"message": "Unable to retrieve tenant service info.",
"innerError": {
"request-id": "098f37d5-96fd-44d0-905b-c147eac223f5",
"date": "2020-05-19T11:43:03"
}
}
}
[](https://i.stack.imgur.com/3P7oi.jpg)
What I do Wrong?
Thanks in advance | 2020/05/19 | [
"https://Stackoverflow.com/questions/61890423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4112376/"
] | In case anyone else has a similar issue, a few days ago, I had the same problem, and I partially solve it by creating a tenant in Azure Active Directory(ADD) and switching to this new one. But with this new tenant for personal Microsoft accounts, I had the `"Tenant does not have a SPO license."` error. This happened because ADD app type was wrong, as well as my endpoints, to use with a personal Microsft account.
If you have a business account, you should use the account with office 365 business subscription and configure your tenant to use it. Like this will work as you configured.
If you have a personal Microsoft account, I shared a step-by-step how to solve this problem and the limitations for our account type [here](https://stackoverflow.com/questions/46802055/tenant-does-not-have-a-spo-license/66733599#66733599). | To upload file (<4MB in size) to your OneDrive in the tenant.
This command will do the job
```
foo@bar:~$ ACCESS_TOKEN=eyJ0eXAiOiJKV1QiLCJub25jZSI6IlZ0MVBN...
foo@bar:~$ curl -X PUT 'https://graph.microsoft.com/v1.0/me/drive/root:/myNewFolder/file.tgz:/content' -H 'Authorization: Bearer '"${ACCESS_TOKEN}"'' -T test.tgz
``` |
110,774 | We are thinking about buying an `SQL Standard Server` for implementing an `ETL via SSIS`. Since it is very expensive for us I would like to test developing SSIS Packages on a free version. Since the express version does not integrate the SSIS I want to try it on the [Evaluation 180 Expires Version](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014) of the SQL Server 2014 but cannot find anything about
```
- Is it possible
- Are there limitations.
```
Could anyone help me here? | 2015/08/12 | [
"https://dba.stackexchange.com/questions/110774",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/39065/"
] | You can use Evaluation Edition for that, yes. Beware that it has the functionality of Enterprise Edition, and you plan to have Standard Edition in production, which has less functionality. But if you are careful about what you use, you'll be fine. | SSIS does comes with SQL Server evaluation.
Additionally if you're a small company or a start up you could take advantage of the [Bizspark](https://www.microsoft.com/bizspark) program and test the full version throughout and/or develop with it for 3 years.
And to spice it up a bit this article can give you an additional input on the subject before you jump in: [The Hidden Costs of SSIS](http://devproconnections.com/sql-server/hidden-costs-ssis-how-avoid-sql-server-integration-services-gotchas) |
110,774 | We are thinking about buying an `SQL Standard Server` for implementing an `ETL via SSIS`. Since it is very expensive for us I would like to test developing SSIS Packages on a free version. Since the express version does not integrate the SSIS I want to try it on the [Evaluation 180 Expires Version](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014) of the SQL Server 2014 but cannot find anything about
```
- Is it possible
- Are there limitations.
```
Could anyone help me here? | 2015/08/12 | [
"https://dba.stackexchange.com/questions/110774",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/39065/"
] | You can use Evaluation Edition for that, yes. Beware that it has the functionality of Enterprise Edition, and you plan to have Standard Edition in production, which has less functionality. But if you are careful about what you use, you'll be fine. | Developer Edition was created for this specific reason and can be used perpetually. It was $50 USD last time I looked. Like the Eval, it has all the Enterprise Edition features. If that's not the target for deployment, take care not to use those features.
Another thought is that Amazon offers AWS instances that include SQL Server licensing built in. You can test deployment against a Standard Edition Instance and only pay the hourly usage rates. |
110,774 | We are thinking about buying an `SQL Standard Server` for implementing an `ETL via SSIS`. Since it is very expensive for us I would like to test developing SSIS Packages on a free version. Since the express version does not integrate the SSIS I want to try it on the [Evaluation 180 Expires Version](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014) of the SQL Server 2014 but cannot find anything about
```
- Is it possible
- Are there limitations.
```
Could anyone help me here? | 2015/08/12 | [
"https://dba.stackexchange.com/questions/110774",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/39065/"
] | For SQL Server 2005 and 2008 R2, the only way to get the Integration Services development environment, Business Intelligence Design Studio a.k.a. BIDS, was through the installation media aka you already bought Developer, Standard or Enterprise Edition. However, if you're looking to purchase SQL Server for the first time, it'd be insane to spend that level of money on an older version that is due to be [retired in less than four years](https://support.microsoft.com/en-us/lifecycle?c2=1044)
2012 allowed you to install the design studio, rebranded as SQL Server Data Tools-BI edition or simply SSDT-BI, *either* from the installation media or you could download it directly from MS for free. [See also](https://stackoverflow.com/a/14163142/181965)
2014 and presumably 2016, the *only* way to get the SSIS development tools is to download directly. Again, no payment required, nothing. Just download and develop awesome business intelligence items.
But you're only licensed for development. You can't do things that are supporting production as that's part of the click through license agreement no one reads.
That should get SSIS set up and running via Visual Studio/SSDT/BIDS for nothing in your environment. There's no need to install an actual database, beyond wanting to evaluate it. Honestly, for that purpose, install SQL Express. It's free, handles up to 10GB as of current version and never expires.
My two bits on the Evaluation Edition is to never install that monstrosity unless you are planning on paving over the operating system at a later date. At a client, they have a licensed 2008 install and some one had the bright idea to install 2008 R2 evaluation edition on the same physical box. Due to the shared nature of 2008 and 2008 R2 libraries, the only thing that works on that box is the database engine itself. Attempt to access any of the tooling results in an expired license error message. The uninstaller can't uninstall 2008 R2 components because they're also shared by 2008... While a bit of rant, be cautious with the expiry nature of the evaluation edition. For SSIS, it will be overkill. | You can use Evaluation Edition for that, yes. Beware that it has the functionality of Enterprise Edition, and you plan to have Standard Edition in production, which has less functionality. But if you are careful about what you use, you'll be fine. |
110,774 | We are thinking about buying an `SQL Standard Server` for implementing an `ETL via SSIS`. Since it is very expensive for us I would like to test developing SSIS Packages on a free version. Since the express version does not integrate the SSIS I want to try it on the [Evaluation 180 Expires Version](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014) of the SQL Server 2014 but cannot find anything about
```
- Is it possible
- Are there limitations.
```
Could anyone help me here? | 2015/08/12 | [
"https://dba.stackexchange.com/questions/110774",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/39065/"
] | For SQL Server 2005 and 2008 R2, the only way to get the Integration Services development environment, Business Intelligence Design Studio a.k.a. BIDS, was through the installation media aka you already bought Developer, Standard or Enterprise Edition. However, if you're looking to purchase SQL Server for the first time, it'd be insane to spend that level of money on an older version that is due to be [retired in less than four years](https://support.microsoft.com/en-us/lifecycle?c2=1044)
2012 allowed you to install the design studio, rebranded as SQL Server Data Tools-BI edition or simply SSDT-BI, *either* from the installation media or you could download it directly from MS for free. [See also](https://stackoverflow.com/a/14163142/181965)
2014 and presumably 2016, the *only* way to get the SSIS development tools is to download directly. Again, no payment required, nothing. Just download and develop awesome business intelligence items.
But you're only licensed for development. You can't do things that are supporting production as that's part of the click through license agreement no one reads.
That should get SSIS set up and running via Visual Studio/SSDT/BIDS for nothing in your environment. There's no need to install an actual database, beyond wanting to evaluate it. Honestly, for that purpose, install SQL Express. It's free, handles up to 10GB as of current version and never expires.
My two bits on the Evaluation Edition is to never install that monstrosity unless you are planning on paving over the operating system at a later date. At a client, they have a licensed 2008 install and some one had the bright idea to install 2008 R2 evaluation edition on the same physical box. Due to the shared nature of 2008 and 2008 R2 libraries, the only thing that works on that box is the database engine itself. Attempt to access any of the tooling results in an expired license error message. The uninstaller can't uninstall 2008 R2 components because they're also shared by 2008... While a bit of rant, be cautious with the expiry nature of the evaluation edition. For SSIS, it will be overkill. | SSIS does comes with SQL Server evaluation.
Additionally if you're a small company or a start up you could take advantage of the [Bizspark](https://www.microsoft.com/bizspark) program and test the full version throughout and/or develop with it for 3 years.
And to spice it up a bit this article can give you an additional input on the subject before you jump in: [The Hidden Costs of SSIS](http://devproconnections.com/sql-server/hidden-costs-ssis-how-avoid-sql-server-integration-services-gotchas) |
110,774 | We are thinking about buying an `SQL Standard Server` for implementing an `ETL via SSIS`. Since it is very expensive for us I would like to test developing SSIS Packages on a free version. Since the express version does not integrate the SSIS I want to try it on the [Evaluation 180 Expires Version](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014) of the SQL Server 2014 but cannot find anything about
```
- Is it possible
- Are there limitations.
```
Could anyone help me here? | 2015/08/12 | [
"https://dba.stackexchange.com/questions/110774",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/39065/"
] | For SQL Server 2005 and 2008 R2, the only way to get the Integration Services development environment, Business Intelligence Design Studio a.k.a. BIDS, was through the installation media aka you already bought Developer, Standard or Enterprise Edition. However, if you're looking to purchase SQL Server for the first time, it'd be insane to spend that level of money on an older version that is due to be [retired in less than four years](https://support.microsoft.com/en-us/lifecycle?c2=1044)
2012 allowed you to install the design studio, rebranded as SQL Server Data Tools-BI edition or simply SSDT-BI, *either* from the installation media or you could download it directly from MS for free. [See also](https://stackoverflow.com/a/14163142/181965)
2014 and presumably 2016, the *only* way to get the SSIS development tools is to download directly. Again, no payment required, nothing. Just download and develop awesome business intelligence items.
But you're only licensed for development. You can't do things that are supporting production as that's part of the click through license agreement no one reads.
That should get SSIS set up and running via Visual Studio/SSDT/BIDS for nothing in your environment. There's no need to install an actual database, beyond wanting to evaluate it. Honestly, for that purpose, install SQL Express. It's free, handles up to 10GB as of current version and never expires.
My two bits on the Evaluation Edition is to never install that monstrosity unless you are planning on paving over the operating system at a later date. At a client, they have a licensed 2008 install and some one had the bright idea to install 2008 R2 evaluation edition on the same physical box. Due to the shared nature of 2008 and 2008 R2 libraries, the only thing that works on that box is the database engine itself. Attempt to access any of the tooling results in an expired license error message. The uninstaller can't uninstall 2008 R2 components because they're also shared by 2008... While a bit of rant, be cautious with the expiry nature of the evaluation edition. For SSIS, it will be overkill. | Developer Edition was created for this specific reason and can be used perpetually. It was $50 USD last time I looked. Like the Eval, it has all the Enterprise Edition features. If that's not the target for deployment, take care not to use those features.
Another thought is that Amazon offers AWS instances that include SQL Server licensing built in. You can test deployment against a Standard Edition Instance and only pay the hourly usage rates. |
17,508,464 | in the past I have mostly been programming in .NET and because of that I haven't had to worry about things like pointers especially much but recently I have gotten into Objective-C and I have decided to try and fully understand the workings of memory management.
So, first I'd like to say I know you shouldn't make pointers for int's as it doesn't help efficiency but this is mostly an experiment out of curiosity.
If I create an integer pointer as such:
int \*intPointer;
How comes that it's actually the memory location that the pointer is pointing to that gets assigned when I do:
```
intPointer = 43;
```
As I have understood it, shouldn't such an action be changing the actual memory address of the pointer?
The same goes for this piece of code:
```
int *intPointer;
int integer;
integer = 43;
intPointer = integer;
```
Same result, but when I was working with CLLocationCoordinate2D and tried to make a pointer point to an CLLocationCoordinate2D variable, I actually had to do:
```
CLLocationCoordinate2D *coordinatePointer = &coordinate;
```
Which to me seems to be the correct way.
This is my first post here on stackoverflow and I hope it was good enough to be answered.
Thank you! | 2013/07/07 | [
"https://Stackoverflow.com/questions/17508464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2557273/"
] | ```
intPointer = integer;
```
This only works because of implicit conversion. Pointer is just a memory offset, which is numeric, so it can be assigned from an int (and you should get compiler warning about that).
In case of CLLocationCoordinate2D, struct cannot be converted to pointer, so compiler reports error. And when you write `&coordinate`, it gives a reference to variable `coordinate` which pointer can be assigned to. | Your initial assumption that is is working, is false:
intPointer = integer;
What actually is happening that if you store 10 in variable "integer", then it will get copied in intPointer. So when you will try to get value from intPointer using \*intPointer, it will give you the value stored at memory 10, which could be anything. But if you do this:
intPointer = &integer
Only then the memory of integer will get stored in intPointer.Then later on if you do this:
integer = 60;
then \*intPointer will also give you 60.
In other words, intPointer will have the memory address of integer, hence will be pointing to integer. |
17,508,464 | in the past I have mostly been programming in .NET and because of that I haven't had to worry about things like pointers especially much but recently I have gotten into Objective-C and I have decided to try and fully understand the workings of memory management.
So, first I'd like to say I know you shouldn't make pointers for int's as it doesn't help efficiency but this is mostly an experiment out of curiosity.
If I create an integer pointer as such:
int \*intPointer;
How comes that it's actually the memory location that the pointer is pointing to that gets assigned when I do:
```
intPointer = 43;
```
As I have understood it, shouldn't such an action be changing the actual memory address of the pointer?
The same goes for this piece of code:
```
int *intPointer;
int integer;
integer = 43;
intPointer = integer;
```
Same result, but when I was working with CLLocationCoordinate2D and tried to make a pointer point to an CLLocationCoordinate2D variable, I actually had to do:
```
CLLocationCoordinate2D *coordinatePointer = &coordinate;
```
Which to me seems to be the correct way.
This is my first post here on stackoverflow and I hope it was good enough to be answered.
Thank you! | 2013/07/07 | [
"https://Stackoverflow.com/questions/17508464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2557273/"
] | ```
intPointer = integer;
```
This only works because of implicit conversion. Pointer is just a memory offset, which is numeric, so it can be assigned from an int (and you should get compiler warning about that).
In case of CLLocationCoordinate2D, struct cannot be converted to pointer, so compiler reports error. And when you write `&coordinate`, it gives a reference to variable `coordinate` which pointer can be assigned to. | The question that you asked was all about plain C pointers. Objective-C is C with additions (there is also Objective-C++ which is C++ with additions). When you write code with Xcode, you can decide what warnings the compiler gives you and whether these warnings should be treated as errors. With lowest warnings settings, the compiler will accept code that it absolutely shouldn't accept. In your example
```
int *intPointer;
int integer;
integer = 43;
intPointer = integer;
```
the second assignment will not compile with any sane build settings for the compiler (but it may be possible to set the build settings to make it compile. Check what warnings you got). The proper way to do this would be
```
intPointer = &integer;
```
intPointer = integer, if you convince the compiler to compile it, would take the number 43 and interpret it as a pointer. Since it is highly likely that there is anything sensible stored at memory location 43, using intPointer to read or write an int is most likely to crash. intPointer = &integer takes the address of the variable "integer" and stores it in the pointer intPointer. Now the value of "intPointer" is the address of integer, and the value of \*intPointer is the contents of "integer" that is 43.
Learning about Objective-C objects is the next step. |
17,508,464 | in the past I have mostly been programming in .NET and because of that I haven't had to worry about things like pointers especially much but recently I have gotten into Objective-C and I have decided to try and fully understand the workings of memory management.
So, first I'd like to say I know you shouldn't make pointers for int's as it doesn't help efficiency but this is mostly an experiment out of curiosity.
If I create an integer pointer as such:
int \*intPointer;
How comes that it's actually the memory location that the pointer is pointing to that gets assigned when I do:
```
intPointer = 43;
```
As I have understood it, shouldn't such an action be changing the actual memory address of the pointer?
The same goes for this piece of code:
```
int *intPointer;
int integer;
integer = 43;
intPointer = integer;
```
Same result, but when I was working with CLLocationCoordinate2D and tried to make a pointer point to an CLLocationCoordinate2D variable, I actually had to do:
```
CLLocationCoordinate2D *coordinatePointer = &coordinate;
```
Which to me seems to be the correct way.
This is my first post here on stackoverflow and I hope it was good enough to be answered.
Thank you! | 2013/07/07 | [
"https://Stackoverflow.com/questions/17508464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2557273/"
] | Your initial assumption that is is working, is false:
intPointer = integer;
What actually is happening that if you store 10 in variable "integer", then it will get copied in intPointer. So when you will try to get value from intPointer using \*intPointer, it will give you the value stored at memory 10, which could be anything. But if you do this:
intPointer = &integer
Only then the memory of integer will get stored in intPointer.Then later on if you do this:
integer = 60;
then \*intPointer will also give you 60.
In other words, intPointer will have the memory address of integer, hence will be pointing to integer. | The question that you asked was all about plain C pointers. Objective-C is C with additions (there is also Objective-C++ which is C++ with additions). When you write code with Xcode, you can decide what warnings the compiler gives you and whether these warnings should be treated as errors. With lowest warnings settings, the compiler will accept code that it absolutely shouldn't accept. In your example
```
int *intPointer;
int integer;
integer = 43;
intPointer = integer;
```
the second assignment will not compile with any sane build settings for the compiler (but it may be possible to set the build settings to make it compile. Check what warnings you got). The proper way to do this would be
```
intPointer = &integer;
```
intPointer = integer, if you convince the compiler to compile it, would take the number 43 and interpret it as a pointer. Since it is highly likely that there is anything sensible stored at memory location 43, using intPointer to read or write an int is most likely to crash. intPointer = &integer takes the address of the variable "integer" and stores it in the pointer intPointer. Now the value of "intPointer" is the address of integer, and the value of \*intPointer is the contents of "integer" that is 43.
Learning about Objective-C objects is the next step. |
42,936,296 | I will present a question about 'aliasing' values from a column. I will use days of the week as an intuitive example to get my question across, but I am ***not*** asking for datetime conversions.
Suppose I have the following SQL script:
```
SELECT DaysOfWeek
FROM [databasename].[dbo].[tablename]
```
Now, the column `DaysOfWeek` will return string values of the days' names, i.e. "Monday," "Tuesday," and so forth.
What if I wanted the query to return the integer 1 for 'Monday', 2 for 'Tuesday', and so forth? I would want to assign a particular value to each of the week's days in the `SELECT` statement, but I'm not sure how to go about doing that.
I'm relatively new to SQL, so I just thought I'd ask for an intuitive method to perform such a task.
**Edited to add:** I'm only using days of the week and their respective integer representation as an easy example; my task does not involve days of the week, but rather employee code numbers and corresponding titles. | 2017/03/21 | [
"https://Stackoverflow.com/questions/42936296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856609/"
] | You can do this using `case`:
```
SELECT (CASE DaysOfWeek
WHEN 'Monday' THEN 1
WHEN 'Tuesday' THEN 2
. . .
END)
```
Under most circumstances, it is unnecessary to store the day of the week like this. You can readily use a function, `datepart()` or `datename()`, to extract the day of the week from a date/time value.
If the column is in a table, and not part of a date, then you might want to include the above logic as a computed column:
```
alter table t add DayOfWeekNumber as (case DaysOfWeek when 'Monday' then 1 . . .);
``` | If you wanted to define your own corresponding value for another value, the best way is to use a table, and join that table.
For example:
```
create table dbo.EmployeeTitle (
id int not null identity(1,1) primary key
, title varchar(32)
);
create table dbo.Employee (
id int not null identity(1,1) primary key
, name nvarchar(128)
, title_id int references dbo.EmployeeTitle(id)
);
insert into dbo.EmployeeTitle values ('Big boss');
insert into dbo.Employee values ('daOnlyBG',1);
select e.*, et.title
from dbo.Employee e
inner join dbo.EmployeeTitle et
on e.title_id = et.id
```
rextester demo: <http://rextester.com/FXIM78632>
returns:
```
+----+----------+----------+----------+
| id | name | title_id | title |
+----+----------+----------+----------+
| 1 | daOnlyBG | 1 | Big boss |
+----+----------+----------+----------+
``` |
42,936,296 | I will present a question about 'aliasing' values from a column. I will use days of the week as an intuitive example to get my question across, but I am ***not*** asking for datetime conversions.
Suppose I have the following SQL script:
```
SELECT DaysOfWeek
FROM [databasename].[dbo].[tablename]
```
Now, the column `DaysOfWeek` will return string values of the days' names, i.e. "Monday," "Tuesday," and so forth.
What if I wanted the query to return the integer 1 for 'Monday', 2 for 'Tuesday', and so forth? I would want to assign a particular value to each of the week's days in the `SELECT` statement, but I'm not sure how to go about doing that.
I'm relatively new to SQL, so I just thought I'd ask for an intuitive method to perform such a task.
**Edited to add:** I'm only using days of the week and their respective integer representation as an easy example; my task does not involve days of the week, but rather employee code numbers and corresponding titles. | 2017/03/21 | [
"https://Stackoverflow.com/questions/42936296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856609/"
] | If you wanted to define your own corresponding value for another value, the best way is to use a table, and join that table.
For example:
```
create table dbo.EmployeeTitle (
id int not null identity(1,1) primary key
, title varchar(32)
);
create table dbo.Employee (
id int not null identity(1,1) primary key
, name nvarchar(128)
, title_id int references dbo.EmployeeTitle(id)
);
insert into dbo.EmployeeTitle values ('Big boss');
insert into dbo.Employee values ('daOnlyBG',1);
select e.*, et.title
from dbo.Employee e
inner join dbo.EmployeeTitle et
on e.title_id = et.id
```
rextester demo: <http://rextester.com/FXIM78632>
returns:
```
+----+----------+----------+----------+
| id | name | title_id | title |
+----+----------+----------+----------+
| 1 | daOnlyBG | 1 | Big boss |
+----+----------+----------+----------+
``` | The easiest way I can think of is to have a table variable or CTE; create your lookup as rows and join to it. Something like this:
```
with cte as (
select 1 as emp_code, 'value1' as emp_title
union
select 2 as emp_code, 'value2' as emp_title
union
select 3 as emp_code, 'value3' as emp_title
)
select cte.emp_code, tableName.*
from tableName
inner join cte
on cte.emp_title = tableName.some_column
``` |
42,936,296 | I will present a question about 'aliasing' values from a column. I will use days of the week as an intuitive example to get my question across, but I am ***not*** asking for datetime conversions.
Suppose I have the following SQL script:
```
SELECT DaysOfWeek
FROM [databasename].[dbo].[tablename]
```
Now, the column `DaysOfWeek` will return string values of the days' names, i.e. "Monday," "Tuesday," and so forth.
What if I wanted the query to return the integer 1 for 'Monday', 2 for 'Tuesday', and so forth? I would want to assign a particular value to each of the week's days in the `SELECT` statement, but I'm not sure how to go about doing that.
I'm relatively new to SQL, so I just thought I'd ask for an intuitive method to perform such a task.
**Edited to add:** I'm only using days of the week and their respective integer representation as an easy example; my task does not involve days of the week, but rather employee code numbers and corresponding titles. | 2017/03/21 | [
"https://Stackoverflow.com/questions/42936296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856609/"
] | You can do this using `case`:
```
SELECT (CASE DaysOfWeek
WHEN 'Monday' THEN 1
WHEN 'Tuesday' THEN 2
. . .
END)
```
Under most circumstances, it is unnecessary to store the day of the week like this. You can readily use a function, `datepart()` or `datename()`, to extract the day of the week from a date/time value.
If the column is in a table, and not part of a date, then you might want to include the above logic as a computed column:
```
alter table t add DayOfWeekNumber as (case DaysOfWeek when 'Monday' then 1 . . .);
``` | Use CASE, [here](https://msdn.microsoft.com/es-ar/library/ms181765.aspx) you have the definition and one example :
```
select
CASE
WHEN(DaysOfWeek="Monday") THEN 1
WHEN(DaysOfWeek="Thusday") THEN 2
....
ELSE -1
from table
```
Hope this help! |
42,936,296 | I will present a question about 'aliasing' values from a column. I will use days of the week as an intuitive example to get my question across, but I am ***not*** asking for datetime conversions.
Suppose I have the following SQL script:
```
SELECT DaysOfWeek
FROM [databasename].[dbo].[tablename]
```
Now, the column `DaysOfWeek` will return string values of the days' names, i.e. "Monday," "Tuesday," and so forth.
What if I wanted the query to return the integer 1 for 'Monday', 2 for 'Tuesday', and so forth? I would want to assign a particular value to each of the week's days in the `SELECT` statement, but I'm not sure how to go about doing that.
I'm relatively new to SQL, so I just thought I'd ask for an intuitive method to perform such a task.
**Edited to add:** I'm only using days of the week and their respective integer representation as an easy example; my task does not involve days of the week, but rather employee code numbers and corresponding titles. | 2017/03/21 | [
"https://Stackoverflow.com/questions/42936296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856609/"
] | You can do this using `case`:
```
SELECT (CASE DaysOfWeek
WHEN 'Monday' THEN 1
WHEN 'Tuesday' THEN 2
. . .
END)
```
Under most circumstances, it is unnecessary to store the day of the week like this. You can readily use a function, `datepart()` or `datename()`, to extract the day of the week from a date/time value.
If the column is in a table, and not part of a date, then you might want to include the above logic as a computed column:
```
alter table t add DayOfWeekNumber as (case DaysOfWeek when 'Monday' then 1 . . .);
``` | The easiest way I can think of is to have a table variable or CTE; create your lookup as rows and join to it. Something like this:
```
with cte as (
select 1 as emp_code, 'value1' as emp_title
union
select 2 as emp_code, 'value2' as emp_title
union
select 3 as emp_code, 'value3' as emp_title
)
select cte.emp_code, tableName.*
from tableName
inner join cte
on cte.emp_title = tableName.some_column
``` |
42,936,296 | I will present a question about 'aliasing' values from a column. I will use days of the week as an intuitive example to get my question across, but I am ***not*** asking for datetime conversions.
Suppose I have the following SQL script:
```
SELECT DaysOfWeek
FROM [databasename].[dbo].[tablename]
```
Now, the column `DaysOfWeek` will return string values of the days' names, i.e. "Monday," "Tuesday," and so forth.
What if I wanted the query to return the integer 1 for 'Monday', 2 for 'Tuesday', and so forth? I would want to assign a particular value to each of the week's days in the `SELECT` statement, but I'm not sure how to go about doing that.
I'm relatively new to SQL, so I just thought I'd ask for an intuitive method to perform such a task.
**Edited to add:** I'm only using days of the week and their respective integer representation as an easy example; my task does not involve days of the week, but rather employee code numbers and corresponding titles. | 2017/03/21 | [
"https://Stackoverflow.com/questions/42936296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856609/"
] | Use CASE, [here](https://msdn.microsoft.com/es-ar/library/ms181765.aspx) you have the definition and one example :
```
select
CASE
WHEN(DaysOfWeek="Monday") THEN 1
WHEN(DaysOfWeek="Thusday") THEN 2
....
ELSE -1
from table
```
Hope this help! | The easiest way I can think of is to have a table variable or CTE; create your lookup as rows and join to it. Something like this:
```
with cte as (
select 1 as emp_code, 'value1' as emp_title
union
select 2 as emp_code, 'value2' as emp_title
union
select 3 as emp_code, 'value3' as emp_title
)
select cte.emp_code, tableName.*
from tableName
inner join cte
on cte.emp_title = tableName.some_column
``` |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | No, they would only make sense if you were writing a product where a "product owner" was a customer -- for example, a tool for keeping a backlog would have stories that start with "As a product owner" because *a product owner would actually be using the product you are developing*.
But normally, no. The product owner is generally not a customer/user of the product so it doesn't really make any sense. | Here some examples I pulled this template off scrumalliance.org and its worked nicely when I've adapted it
User story in front, acceptance criteria at the back
*First Example*
**As a student**
**User stories title:** Student registers
I want to register with on the website
So that I can view and apply for IT jobs
**Acceptance Criteria:**
Given that the students ID is valid in the system
When the student first enrolled at the campus
Then the student will register with email validation
*Second Example*
**\*\*User stories title:** Students edits profile\*\*
I want to edit my profile on the website
So that I can access everything a student user can and apply for jobs
**Acceptance Criteria:**
Given that the student has registered and logged into the website
When the student validates his account using their email
Then the student will have access to everything a student user can access
*Third example*
**As an employer**
**User stories title:** Employer registers on the website
I want to register on the website
So that I can list job vacancies for students
**Acceptance Criterion:**
Given that their login details have been given by **\*\*\*\*\*\*** administrator
When the employer has first contacted **\*\*\*\*** IT administrator via email or phone
Then they can list job vacancies for students
*Fourth Example*
**User stories title:** Employer post jobs on the website
I want to post student job vacancies
So that I can hire one or more students
**Acceptance Criterion:**
Given that the employer has access to the website
When they want to post a job vacancies
Then the employer can list position details and requirements for the job |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | We should always write stories from the perspective of user role you are catering to. The user stories are the foundation to 3C's. [Reference Link](http://xprogramming.com/articles/expcardconversationconfirmation/)
1. Card
2. Conversation
3. Confirmation
***Card*** : This is to write user stories which will help the person who will be using the feature. This explains what the user wants in simple words.
***Conversation*** : The user story written on the card should be a conversation starter among the team including customer. This should ideally happen before development starts for a feature. This conversation is useful to figure out what the end user of the feature is trying to solve.
***Confirmation*** : As part of the conversation, acceptance criteria (and ideally, "examples" ) are also discussed and documented. Once the story is coded, these criteria are used by the customer to "confirm" that the story can be "accepted" and pushed to production.
Writing the user stories with "end user perception" will also make the team/customer think of possible scenarios in the real world. This will eliminate possible scenarios that can be missed if we do not keep the users' roles in mind.
I would prefer to write the user stories as below :
1. As an admin, I should be able to (ISBAT)...
2. As an employee, ISBAT..
3. As a premium user, ISBAT.. | One thing that I'd like to add as a product owner.
Sometimes, when a design is needed, I'll write the story like:
As a: PO
I want: a design for feature xyz
so that: further work can be identified for implementation of xyz
Usually, that'll get assigned to an architect on the team. That's usually the only time I use the "as a PO" though. |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | We should always write stories from the perspective of user role you are catering to. The user stories are the foundation to 3C's. [Reference Link](http://xprogramming.com/articles/expcardconversationconfirmation/)
1. Card
2. Conversation
3. Confirmation
***Card*** : This is to write user stories which will help the person who will be using the feature. This explains what the user wants in simple words.
***Conversation*** : The user story written on the card should be a conversation starter among the team including customer. This should ideally happen before development starts for a feature. This conversation is useful to figure out what the end user of the feature is trying to solve.
***Confirmation*** : As part of the conversation, acceptance criteria (and ideally, "examples" ) are also discussed and documented. Once the story is coded, these criteria are used by the customer to "confirm" that the story can be "accepted" and pushed to production.
Writing the user stories with "end user perception" will also make the team/customer think of possible scenarios in the real world. This will eliminate possible scenarios that can be missed if we do not keep the users' roles in mind.
I would prefer to write the user stories as below :
1. As an admin, I should be able to (ISBAT)...
2. As an employee, ISBAT..
3. As a premium user, ISBAT.. | Here some examples I pulled this template off scrumalliance.org and its worked nicely when I've adapted it
User story in front, acceptance criteria at the back
*First Example*
**As a student**
**User stories title:** Student registers
I want to register with on the website
So that I can view and apply for IT jobs
**Acceptance Criteria:**
Given that the students ID is valid in the system
When the student first enrolled at the campus
Then the student will register with email validation
*Second Example*
**\*\*User stories title:** Students edits profile\*\*
I want to edit my profile on the website
So that I can access everything a student user can and apply for jobs
**Acceptance Criteria:**
Given that the student has registered and logged into the website
When the student validates his account using their email
Then the student will have access to everything a student user can access
*Third example*
**As an employer**
**User stories title:** Employer registers on the website
I want to register on the website
So that I can list job vacancies for students
**Acceptance Criterion:**
Given that their login details have been given by **\*\*\*\*\*\*** administrator
When the employer has first contacted **\*\*\*\*** IT administrator via email or phone
Then they can list job vacancies for students
*Fourth Example*
**User stories title:** Employer post jobs on the website
I want to post student job vacancies
So that I can hire one or more students
**Acceptance Criterion:**
Given that the employer has access to the website
When they want to post a job vacancies
Then the employer can list position details and requirements for the job |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | Product Owner is the name given to a role which is specific to the process/framework you are using to manage the project or to execute software development. This particular name has no meaning outside the context of this process. The system which you are trying to build will have its own specific users. Each of those real users may have a different expectation, different usage, different value to be derived from that system. So your Scrum team (including the Product Owner) should identify the real users of the system and write stories from their perspective.
Keep in mind that, for the intended system, real users and company roles (or job titles) are two different things. For example, two persons can have the same title "Customer Sales Representative", however one person could be handling inbound queries and the other could be making outbound requests. If they will be the real users of the new system then expectations and usage of these two types of users could be different from the new system. If that is the case then your users stories should be written separately, some stories will deliver value to the "inbound representative" and some stories will be for the "outbound representative".
This approach will give a clear picture to the team about why are they adding a particular feature to the system. Team will be able to connect the *real user* with the *story goals* and its *benefits* thus creating a sense of empathy with the actual user. Team understands the "bigger picture" of why they are implementing a task which they have been asked to do.
So to your question, no it is not appropriate in normal situations to write stories like *As a product owner I want ... so that ...* . | Some stories can be written only from the point of view of the Product Owner
----------------------------------------------------------------------------
Let me give a couple of examples:
1. Analytics stories: The end users of the application do not care whether you collect any analytics data at all. In fact some end users may not want you to collect analytics data because of privacy concerns (rightly or wrongly).
2. Branding: End users care about usability. But they do not care about whether the company's brand is displayed more prominently or whether the color scheme aligns with the branding.
But the Product Owner does. So these stories can only be written in the format of "As the Product Owner I want...". The Product Owner represents the interests of the business, which sometimes may have to override the interests of the end users.
However, you want to be careful not to use the Product Owner as a proxy for end users. Because you can potentially write every story from the point of view of the Product Owner. Make an effort to identify who truly wants a feature and why. Making this extra effort to think through who wants it and why will help you to:
* drop some stories that do not really add value to anyone.
* enrich the stories by writing the relevant acceptance criteria. |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | No, they would only make sense if you were writing a product where a "product owner" was a customer -- for example, a tool for keeping a backlog would have stories that start with "As a product owner" because *a product owner would actually be using the product you are developing*.
But normally, no. The product owner is generally not a customer/user of the product so it doesn't really make any sense. | Generally speaking, the product owner is the stakeholder representative and voice of the customer. I would expect the user stories that they write to identify which stakeholder or customer group (or groups) are impacted by the story. Because the product owner can be considered a stakeholder, though, I don't see the issue with stories written from the perspective of the product owner or even the development team. Without an understanding of the project and taking each story into individual consideration, I'm not sure that someone can say if it's well-written or not. |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | Generally speaking, the product owner is the stakeholder representative and voice of the customer. I would expect the user stories that they write to identify which stakeholder or customer group (or groups) are impacted by the story. Because the product owner can be considered a stakeholder, though, I don't see the issue with stories written from the perspective of the product owner or even the development team. Without an understanding of the project and taking each story into individual consideration, I'm not sure that someone can say if it's well-written or not. | Here some examples I pulled this template off scrumalliance.org and its worked nicely when I've adapted it
User story in front, acceptance criteria at the back
*First Example*
**As a student**
**User stories title:** Student registers
I want to register with on the website
So that I can view and apply for IT jobs
**Acceptance Criteria:**
Given that the students ID is valid in the system
When the student first enrolled at the campus
Then the student will register with email validation
*Second Example*
**\*\*User stories title:** Students edits profile\*\*
I want to edit my profile on the website
So that I can access everything a student user can and apply for jobs
**Acceptance Criteria:**
Given that the student has registered and logged into the website
When the student validates his account using their email
Then the student will have access to everything a student user can access
*Third example*
**As an employer**
**User stories title:** Employer registers on the website
I want to register on the website
So that I can list job vacancies for students
**Acceptance Criterion:**
Given that their login details have been given by **\*\*\*\*\*\*** administrator
When the employer has first contacted **\*\*\*\*** IT administrator via email or phone
Then they can list job vacancies for students
*Fourth Example*
**User stories title:** Employer post jobs on the website
I want to post student job vacancies
So that I can hire one or more students
**Acceptance Criterion:**
Given that the employer has access to the website
When they want to post a job vacancies
Then the employer can list position details and requirements for the job |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | We should always write stories from the perspective of user role you are catering to. The user stories are the foundation to 3C's. [Reference Link](http://xprogramming.com/articles/expcardconversationconfirmation/)
1. Card
2. Conversation
3. Confirmation
***Card*** : This is to write user stories which will help the person who will be using the feature. This explains what the user wants in simple words.
***Conversation*** : The user story written on the card should be a conversation starter among the team including customer. This should ideally happen before development starts for a feature. This conversation is useful to figure out what the end user of the feature is trying to solve.
***Confirmation*** : As part of the conversation, acceptance criteria (and ideally, "examples" ) are also discussed and documented. Once the story is coded, these criteria are used by the customer to "confirm" that the story can be "accepted" and pushed to production.
Writing the user stories with "end user perception" will also make the team/customer think of possible scenarios in the real world. This will eliminate possible scenarios that can be missed if we do not keep the users' roles in mind.
I would prefer to write the user stories as below :
1. As an admin, I should be able to (ISBAT)...
2. As an employee, ISBAT..
3. As a premium user, ISBAT.. | Some stories can be written only from the point of view of the Product Owner
----------------------------------------------------------------------------
Let me give a couple of examples:
1. Analytics stories: The end users of the application do not care whether you collect any analytics data at all. In fact some end users may not want you to collect analytics data because of privacy concerns (rightly or wrongly).
2. Branding: End users care about usability. But they do not care about whether the company's brand is displayed more prominently or whether the color scheme aligns with the branding.
But the Product Owner does. So these stories can only be written in the format of "As the Product Owner I want...". The Product Owner represents the interests of the business, which sometimes may have to override the interests of the end users.
However, you want to be careful not to use the Product Owner as a proxy for end users. Because you can potentially write every story from the point of view of the Product Owner. Make an effort to identify who truly wants a feature and why. Making this extra effort to think through who wants it and why will help you to:
* drop some stories that do not really add value to anyone.
* enrich the stories by writing the relevant acceptance criteria. |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | Generally speaking, the product owner is the stakeholder representative and voice of the customer. I would expect the user stories that they write to identify which stakeholder or customer group (or groups) are impacted by the story. Because the product owner can be considered a stakeholder, though, I don't see the issue with stories written from the perspective of the product owner or even the development team. Without an understanding of the project and taking each story into individual consideration, I'm not sure that someone can say if it's well-written or not. | Product Owner is the name given to a role which is specific to the process/framework you are using to manage the project or to execute software development. This particular name has no meaning outside the context of this process. The system which you are trying to build will have its own specific users. Each of those real users may have a different expectation, different usage, different value to be derived from that system. So your Scrum team (including the Product Owner) should identify the real users of the system and write stories from their perspective.
Keep in mind that, for the intended system, real users and company roles (or job titles) are two different things. For example, two persons can have the same title "Customer Sales Representative", however one person could be handling inbound queries and the other could be making outbound requests. If they will be the real users of the new system then expectations and usage of these two types of users could be different from the new system. If that is the case then your users stories should be written separately, some stories will deliver value to the "inbound representative" and some stories will be for the "outbound representative".
This approach will give a clear picture to the team about why are they adding a particular feature to the system. Team will be able to connect the *real user* with the *story goals* and its *benefits* thus creating a sense of empathy with the actual user. Team understands the "bigger picture" of why they are implementing a task which they have been asked to do.
So to your question, no it is not appropriate in normal situations to write stories like *As a product owner I want ... so that ...* . |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | Product Owner is the name given to a role which is specific to the process/framework you are using to manage the project or to execute software development. This particular name has no meaning outside the context of this process. The system which you are trying to build will have its own specific users. Each of those real users may have a different expectation, different usage, different value to be derived from that system. So your Scrum team (including the Product Owner) should identify the real users of the system and write stories from their perspective.
Keep in mind that, for the intended system, real users and company roles (or job titles) are two different things. For example, two persons can have the same title "Customer Sales Representative", however one person could be handling inbound queries and the other could be making outbound requests. If they will be the real users of the new system then expectations and usage of these two types of users could be different from the new system. If that is the case then your users stories should be written separately, some stories will deliver value to the "inbound representative" and some stories will be for the "outbound representative".
This approach will give a clear picture to the team about why are they adding a particular feature to the system. Team will be able to connect the *real user* with the *story goals* and its *benefits* thus creating a sense of empathy with the actual user. Team understands the "bigger picture" of why they are implementing a task which they have been asked to do.
So to your question, no it is not appropriate in normal situations to write stories like *As a product owner I want ... so that ...* . | One thing that I'd like to add as a product owner.
Sometimes, when a design is needed, I'll write the story like:
As a: PO
I want: a design for feature xyz
so that: further work can be identified for implementation of xyz
Usually, that'll get assigned to an architect on the team. That's usually the only time I use the "as a PO" though. |
11,567 | We "teached" our product owner to write user stories using the template "As a ... I want ... so that ..." (see <http://en.wikipedia.org/wiki/User_story#Format>) . However he/she is now writing the user stories like
>
> As a product owner I want ... so that ... .
>
>
>
Is this a way how user stories could be written? | 2014/05/14 | [
"https://pm.stackexchange.com/questions/11567",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/8693/"
] | One thing that I'd like to add as a product owner.
Sometimes, when a design is needed, I'll write the story like:
As a: PO
I want: a design for feature xyz
so that: further work can be identified for implementation of xyz
Usually, that'll get assigned to an architect on the team. That's usually the only time I use the "as a PO" though. | Some stories can be written only from the point of view of the Product Owner
----------------------------------------------------------------------------
Let me give a couple of examples:
1. Analytics stories: The end users of the application do not care whether you collect any analytics data at all. In fact some end users may not want you to collect analytics data because of privacy concerns (rightly or wrongly).
2. Branding: End users care about usability. But they do not care about whether the company's brand is displayed more prominently or whether the color scheme aligns with the branding.
But the Product Owner does. So these stories can only be written in the format of "As the Product Owner I want...". The Product Owner represents the interests of the business, which sometimes may have to override the interests of the end users.
However, you want to be careful not to use the Product Owner as a proxy for end users. Because you can potentially write every story from the point of view of the Product Owner. Make an effort to identify who truly wants a feature and why. Making this extra effort to think through who wants it and why will help you to:
* drop some stories that do not really add value to anyone.
* enrich the stories by writing the relevant acceptance criteria. |
66,132,074 | **i'm looking for help converting this jquery code to angular**
```
if($('#radioid li input:checked')){
$(this).parent().addClass("active_radio");
}
$('#radioid input').on('change', function(){
$("#radioid li").removeClass("active_radio");
if($('input:checked')){
$(this).parent().addClass("active_radio");
}
});
<ul id = "radioid">
<li><input type="radio" name="color" >red</li>
<li><input type="radio" name="color" >blue</li>
<li><input type="radio" name="color" >green</li>
</ul>
```
i want this jquery code to angular for using ts file | 2021/02/10 | [
"https://Stackoverflow.com/questions/66132074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2823480/"
] | You have to update your code to:
```
<script>
var json = {
"html": "<h3>COVID-19 Visitor Declaration</h3><script><\/script>"
};
</script>
```
Escaped tag </script> is most important for that. | By using the `Escape` characters, for your closing tag `<\/script>`
```js
var json = {
"html": "<h3>COVID-19 Visitor Declaration</h3><script><\/script>"
};
document.getElementById("html-content").innerHTML = json.html;
```
```html
<div id="html-content"></div>
```
`<scripta>` works because it's not a valid tag for the browsers to evaluate and thus render it as normally on DOM.
When you pass `<script>`, browser parse it a valid HTML tag
```js
var json = {
"html": "<h3>COVID-19 Visitor Declaration</h3><scripta>Test</scripta>"
};
document.getElementById("html-content").innerHTML = json.html;
```
```html
<div id="html-content"></div>
``` |
18,450,076 | I've been setting up PHP deployments with Capistrano on CentOS 6 and have run into an interesting issue. The way capistrano works, it sets up folders like this:
* /var/www/myapp.com/
+ current (symlink to latest release in /releases)
+ shared
+ releases
- 20130826172737
- 20130826172114
When I look at the "current" symlink, it points to the most recent release. At first, when opening my web app, everything worked fine. After deploying a new release, the **current** folder correctly points to the new release, but the web application tries to load files from the old release (which has been deleted in a Capistrano cleanup process). Also, the virtual host is configured to point at **/var/www/myapp.com/current/Public**.
Are symlinks cached in any way?
The specific PHP code that fails (which initializes my framework) is this:
```
require_once dirname(dirname(__FILE__)) . '/App/App.php';
App\App::run();
```
That is in **index.php** currently located at **/var/www/app.com/current/Public/index.php**.
My Apache error logs show:
>
> PHP Fatal error: require\_once(): Failed opening required '/var/www/myapp.com/releases/20130826172237/App/App.php' (include\_path='.:/usr/share/pear:/usr/share/php') in /var/www/myapp.com/releases/20130826172237/Public/index.php
>
>
>
And the **current** symlink shows:
>
> current -> /var/www/zverse/releases/20130826172641
>
>
>
Obviously 20130826172641 != 20130826172237 which the latter was the previous version.
Any ideas or areas I can look at? | 2013/08/26 | [
"https://Stackoverflow.com/questions/18450076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/468592/"
] | That has not changed since Day 1 of .NET. All reference types must be created with a `New` statement somewhere or else they will remain a null reference (`Nothing`).
It sounds like some other part of the app that used to create the dataset has been removed or changed so that it sometimes returns `Nothing`. | There is a difference between declaring and instantiating.
This line declares a `DataSet`:
```
Dim myDataSet As DataSet
```
Note: Since you only declared a `DataSet` object, it is not set to an instance, therefore it is `Nothing`.
This line instantiates a `DataSet`:
```
myDataSet = New DataSet()
```
Often you will see the lines put together, like this:
```
Dim myDataSet = New DataSet()
```
If you only declare a `DataSet`, then you must be sure to check if it is `Nothing` before you use it, like this:
```
If myDataSet Is Not Nothing Then
' Use myDataSet because there is an instance of it
End If
```
Note: You should ALWAYS check if the return type of a `Function` is `Nothing` or not. |
36,737,872 | I have created two templates in AngularJs respectively `home.html` and `navTemplate.html`.
**home.html**
```
<html>
<head>//necessary files goes here</head>
<body ng-app="myApp">
//include navTemplate using ng-include
<ng-include src="'navTemplate.html'"></ng-include>
</body>
</html>
```
**navTemplate.html**
```
<aside id="left-panel">
<nav>
<ul>
<li id="home">
<a href="home.html"><span>Home</span></a>
</li>
<li id="contact" class="active">
<a href="contact.html"><span>Contact</span></a>
</li>
</ul>
</nav>
</aside>
```
My requirement is that when page is navigated to home.html in nav panel should be updated home as a current page.(add class="active").To do that i have add a script into home.html.
**Inside home.html**
```
<script>
$(document).ready(function(){
$("#home").addClass("active");});
</script>
```
The problem was that this wouldn't add the CSS class into DOM element dynamically if used `ng-include`.Please let me know how can i add or remove CSS classes dynamically with `ng-include` . | 2016/04/20 | [
"https://Stackoverflow.com/questions/36737872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4318982/"
] | You can use `ng-class` to dynamically change your class. For example
```
$scope.isActive = false;
$scope.checkIfActive = function(isActive) {
if (isActive) {
return "active"
}
return "not-active"
}
```
you can use it like `<li id="home" ng-class="checkIfActive(isActive)">`
this is needed inside the controller of your navTemplate | I would suggest to do it this way:
1. Decorate your nav links with a class, like "navLink".
2. Use this script instead of yours:
`<script>
$("#left-panel").on("click", function(e) {
$("#left-panel ul li").removeClass("active");
$(this).parent().addClass("active");
}, "li a.navLink");
</script>`
This way you will get jQuery watch for all elements from the "li a.navLink" selector within the #left-panel element for click events. Even thos added dynamically later, so you don't need the document.ready anymore.
The navLink class is not necessary, but it's better to limit the selector to a certain group of links. |
36,737,872 | I have created two templates in AngularJs respectively `home.html` and `navTemplate.html`.
**home.html**
```
<html>
<head>//necessary files goes here</head>
<body ng-app="myApp">
//include navTemplate using ng-include
<ng-include src="'navTemplate.html'"></ng-include>
</body>
</html>
```
**navTemplate.html**
```
<aside id="left-panel">
<nav>
<ul>
<li id="home">
<a href="home.html"><span>Home</span></a>
</li>
<li id="contact" class="active">
<a href="contact.html"><span>Contact</span></a>
</li>
</ul>
</nav>
</aside>
```
My requirement is that when page is navigated to home.html in nav panel should be updated home as a current page.(add class="active").To do that i have add a script into home.html.
**Inside home.html**
```
<script>
$(document).ready(function(){
$("#home").addClass("active");});
</script>
```
The problem was that this wouldn't add the CSS class into DOM element dynamically if used `ng-include`.Please let me know how can i add or remove CSS classes dynamically with `ng-include` . | 2016/04/20 | [
"https://Stackoverflow.com/questions/36737872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4318982/"
] | You can use `ng-class` to dynamically change your class. For example
```
$scope.isActive = false;
$scope.checkIfActive = function(isActive) {
if (isActive) {
return "active"
}
return "not-active"
}
```
you can use it like `<li id="home" ng-class="checkIfActive(isActive)">`
this is needed inside the controller of your navTemplate | each time one of the links is/are clicked in the nav bar it navigated directly to the url which reloads the javascript again, so there's no way to determine which link was clicked after except you want to do someting complicated like getting the href of the page.
The best to do is use angularjs route then add an ng-click to the links on the nav bar will will call a function that takes in the Id of the clicked link you can then set active to that link youll have a function like:
```
$scope.activeLink = function(id){
$("#"+id+" a").addClass("active");
};
```
you html will then look like:
```
<li id="home">
<a href="#home" ng-click="activeLink('home')"><span>Home</span></a>
</li>
<li id="contact" class="active">
<a href="#contact" ng-click="activeLink('contact')"><span>Contact</span</a>
</li>
``` |
36,737,872 | I have created two templates in AngularJs respectively `home.html` and `navTemplate.html`.
**home.html**
```
<html>
<head>//necessary files goes here</head>
<body ng-app="myApp">
//include navTemplate using ng-include
<ng-include src="'navTemplate.html'"></ng-include>
</body>
</html>
```
**navTemplate.html**
```
<aside id="left-panel">
<nav>
<ul>
<li id="home">
<a href="home.html"><span>Home</span></a>
</li>
<li id="contact" class="active">
<a href="contact.html"><span>Contact</span></a>
</li>
</ul>
</nav>
</aside>
```
My requirement is that when page is navigated to home.html in nav panel should be updated home as a current page.(add class="active").To do that i have add a script into home.html.
**Inside home.html**
```
<script>
$(document).ready(function(){
$("#home").addClass("active");});
</script>
```
The problem was that this wouldn't add the CSS class into DOM element dynamically if used `ng-include`.Please let me know how can i add or remove CSS classes dynamically with `ng-include` . | 2016/04/20 | [
"https://Stackoverflow.com/questions/36737872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4318982/"
] | each time one of the links is/are clicked in the nav bar it navigated directly to the url which reloads the javascript again, so there's no way to determine which link was clicked after except you want to do someting complicated like getting the href of the page.
The best to do is use angularjs route then add an ng-click to the links on the nav bar will will call a function that takes in the Id of the clicked link you can then set active to that link youll have a function like:
```
$scope.activeLink = function(id){
$("#"+id+" a").addClass("active");
};
```
you html will then look like:
```
<li id="home">
<a href="#home" ng-click="activeLink('home')"><span>Home</span></a>
</li>
<li id="contact" class="active">
<a href="#contact" ng-click="activeLink('contact')"><span>Contact</span</a>
</li>
``` | I would suggest to do it this way:
1. Decorate your nav links with a class, like "navLink".
2. Use this script instead of yours:
`<script>
$("#left-panel").on("click", function(e) {
$("#left-panel ul li").removeClass("active");
$(this).parent().addClass("active");
}, "li a.navLink");
</script>`
This way you will get jQuery watch for all elements from the "li a.navLink" selector within the #left-panel element for click events. Even thos added dynamically later, so you don't need the document.ready anymore.
The navLink class is not necessary, but it's better to limit the selector to a certain group of links. |
1,530,879 | If $f$ is such a homomorphism, then $f(x+y)=f(x)f(y)$.
I know of examples of $f$ which satisfy this property, such as $f(x)=e^x$, but how do I find all of them? | 2015/11/15 | [
"https://math.stackexchange.com/questions/1530879",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/26447/"
] | There is exactly one such homomorphism, namely the constant map $x\mapsto 1$, because $1$ is the only number whose $k$th roots are all rational. In more detail:
Let $x$ be arbitrary. Since $f(x)=f(\frac x2+\frac x2)=f(\frac x2)^2$ it must be positive; take $f(x)=n/m$ in lowest terms.
Suppose that $n/m\ne 1$; then there is some prime $p$ that divides either $n$ or $m$. Suppose it is $p\mid n$; the other case is similar. Let $k$ be some integer such that $p^k>n$. Then what can $f(\frac{x}{k})$ be?
\We know that $f(x) = f(k\frac{x}{k}) = f(\frac{x}{k})^k$. But if $f(\frac{x}{k})=a/b$ in lowest terms, then we must have $a^k=n$. Since $p$ divides $n$, $p$ must divide $a$ too, but then $p^k$ divides $a^k=n$, which contradicts $p^k$ being larger than $n$. | Consider some such homomorphism $f$. Consider an arbitrary element $a/b \in \mathbb{Q}$. If $f(a/b)=p/q$, we can write $p/q$ in lowest terms and get a unique prime factorization $p/q = \frac{p\_1^{r\_1} \dots p\_n^{r\_n}}{{q\_1^{s\_1} \dots q\_m^{s\_m}}}$. the $p\_1 \dots p\_n, q\_1 \dots q\_m$ are distinct prime numbers, and the $r\_1 \dots r\_n, s\_1 \dots s\_m$ are positive integers. If $p/q$ is an integer, then the denominator contains no factors, and if $p/q=1$, the numerator contains no factors either. Now, we suppose $p/q \neq 1$. Then consider $k=\min\{r\_1, \dots , r\_n, s\_1, \dots, s\_m\}$. Then $f\left(\frac{a}{b(k+1)}\right) = \frac{p\_1^{r\_1/{k+1}} \dots p\_n^{r\_n/{k+1}}}{q\_1^{s\_1/{k+1}} \dots q\_m^{s\_n/{k+1}}}$. If this value were equal to a rational number $p'/q'$, then we would have $p'^{k+1}/{q'}^{k+1} =p/q$. But any prime factor in $p'^{k+1}/{q'}^{k+1}$ must have power at minimum $k+1$, and since $p/q$ contains a prime of power $k$ and prime factorization is unique by the fundamental theorem of arithmetic, we have a contradiction.
As the only assumption we made was that $\{p\_1, \dots , p\_n, q\_1, \dots q\_m\}$ was nonempty, this means that $f(a/b)=1$. But since $a/b$ was arbitrary, $f(x)= 1 \forall x \in \mathbb{Q}$. |
1,530,879 | If $f$ is such a homomorphism, then $f(x+y)=f(x)f(y)$.
I know of examples of $f$ which satisfy this property, such as $f(x)=e^x$, but how do I find all of them? | 2015/11/15 | [
"https://math.stackexchange.com/questions/1530879",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/26447/"
] | There is exactly one such homomorphism, namely the constant map $x\mapsto 1$, because $1$ is the only number whose $k$th roots are all rational. In more detail:
Let $x$ be arbitrary. Since $f(x)=f(\frac x2+\frac x2)=f(\frac x2)^2$ it must be positive; take $f(x)=n/m$ in lowest terms.
Suppose that $n/m\ne 1$; then there is some prime $p$ that divides either $n$ or $m$. Suppose it is $p\mid n$; the other case is similar. Let $k$ be some integer such that $p^k>n$. Then what can $f(\frac{x}{k})$ be?
\We know that $f(x) = f(k\frac{x}{k}) = f(\frac{x}{k})^k$. But if $f(\frac{x}{k})=a/b$ in lowest terms, then we must have $a^k=n$. Since $p$ divides $n$, $p$ must divide $a$ too, but then $p^k$ divides $a^k=n$, which contradicts $p^k$ being larger than $n$. | There is only the trivial morphism $x \mapsto 1$.
Indeed, we can check that for any $n \in \mathbb{Z}$ and $x\in \mathbb{Q}$, we have $f(nx)=f(x)^n$.
In particular, since $f\left(\frac{1}{n}\right)^n = f(1)$, the number $f(1)$ has a rational $n^{\textrm{th}}$ root for all $n \ge 1$. So $f(1) = 1$ and $f\left(\frac{1}{n}\right) = 1$ for all $n \ge 1$. And from that we deduce $f\left(\frac{a}{b}\right) = 1^a = 1$.
EDIT : Here's an explanation of my statement that $1$ is the only rational number with a rational $n^{\textrm{th}}$ root for all $n \ge 1$.
Any non zero rational number can be uniquely written as a product of powers of primes (with some negatives exponents, for example $\frac{4}{15} = 2^2 . 3^{-1} . 5^{-1}$). Let $p$ be a prime number, for $x \in \mathbb{Q}^\*$ denote $v\_p(x) \in \mathbb{Z}$ the exponent of $p$ in this decomposition (called the $p$-adic valuation). We see that $v\_p(xy) = v\_p(x) + v\_p(y)$ for $x, y \in \mathbb{Q}^\*$, so in particular $v\_p(x^n) = n v\_p(x)$. This means **the $p$-adic valuation of an $n^{\textrm{th}}$ power is a multiple of $n$**.
So if $x \in \mathbb{Q}^\*$ is an $n^{\textrm{th}}$ power for all $n \ge 1$, then $v\_p(x)$ is a multiple of $n$ for all $n \ge 1$, which means $v\_p(x) = 0$. And since this is true for all prime numbers $p$, we get $x = 1$. |
1,530,879 | If $f$ is such a homomorphism, then $f(x+y)=f(x)f(y)$.
I know of examples of $f$ which satisfy this property, such as $f(x)=e^x$, but how do I find all of them? | 2015/11/15 | [
"https://math.stackexchange.com/questions/1530879",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/26447/"
] | There is exactly one such homomorphism, namely the constant map $x\mapsto 1$, because $1$ is the only number whose $k$th roots are all rational. In more detail:
Let $x$ be arbitrary. Since $f(x)=f(\frac x2+\frac x2)=f(\frac x2)^2$ it must be positive; take $f(x)=n/m$ in lowest terms.
Suppose that $n/m\ne 1$; then there is some prime $p$ that divides either $n$ or $m$. Suppose it is $p\mid n$; the other case is similar. Let $k$ be some integer such that $p^k>n$. Then what can $f(\frac{x}{k})$ be?
\We know that $f(x) = f(k\frac{x}{k}) = f(\frac{x}{k})^k$. But if $f(\frac{x}{k})=a/b$ in lowest terms, then we must have $a^k=n$. Since $p$ divides $n$, $p$ must divide $a$ too, but then $p^k$ divides $a^k=n$, which contradicts $p^k$ being larger than $n$. | Two proofs that there are no nontrivial homomorphisms.
This is kind of the same thing as what others have suggested, but in more abstract terms: ${\bf Q}$ is a divisible group. The image by a homomorphism of a divisible group is always divisible (this is easy to show), but ${\bf Q}^\*$ has no nontrivial divisible subgroups (every nonzero rational is not an $n$-th power for a sufficiently large $n$), so the only homomorphism is the trivial one.
For a slightly convoluted, but perhaps interesting proof, it is not very hard to see that ${\bf Q}^\*$ is isomorphic (as a group) to the product of the two-element group (corresponding to the sign) and a countably infinitely generated free abelian group (corresponding to the prime decomposition). By noticing that $f(x)=f(x/2)^2$, we see that the image of the homomorphism is a subgroup of the positive rationals, which form a free abelian group under multiplication.
But a subgroup of a free abelian group is always free, and moreover a free generator cannot be divisible (this is a simple consequence of the definition), so the image must be trivial (because it is free and divisible), and so must the homomorphism itself.
This shows that *no* divisible group (even divisible by $2$, say, or any other prime) admits a nontrivial homomorphism into ${\bf Q}^\*$. |
1,530,879 | If $f$ is such a homomorphism, then $f(x+y)=f(x)f(y)$.
I know of examples of $f$ which satisfy this property, such as $f(x)=e^x$, but how do I find all of them? | 2015/11/15 | [
"https://math.stackexchange.com/questions/1530879",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/26447/"
] | Consider some such homomorphism $f$. Consider an arbitrary element $a/b \in \mathbb{Q}$. If $f(a/b)=p/q$, we can write $p/q$ in lowest terms and get a unique prime factorization $p/q = \frac{p\_1^{r\_1} \dots p\_n^{r\_n}}{{q\_1^{s\_1} \dots q\_m^{s\_m}}}$. the $p\_1 \dots p\_n, q\_1 \dots q\_m$ are distinct prime numbers, and the $r\_1 \dots r\_n, s\_1 \dots s\_m$ are positive integers. If $p/q$ is an integer, then the denominator contains no factors, and if $p/q=1$, the numerator contains no factors either. Now, we suppose $p/q \neq 1$. Then consider $k=\min\{r\_1, \dots , r\_n, s\_1, \dots, s\_m\}$. Then $f\left(\frac{a}{b(k+1)}\right) = \frac{p\_1^{r\_1/{k+1}} \dots p\_n^{r\_n/{k+1}}}{q\_1^{s\_1/{k+1}} \dots q\_m^{s\_n/{k+1}}}$. If this value were equal to a rational number $p'/q'$, then we would have $p'^{k+1}/{q'}^{k+1} =p/q$. But any prime factor in $p'^{k+1}/{q'}^{k+1}$ must have power at minimum $k+1$, and since $p/q$ contains a prime of power $k$ and prime factorization is unique by the fundamental theorem of arithmetic, we have a contradiction.
As the only assumption we made was that $\{p\_1, \dots , p\_n, q\_1, \dots q\_m\}$ was nonempty, this means that $f(a/b)=1$. But since $a/b$ was arbitrary, $f(x)= 1 \forall x \in \mathbb{Q}$. | There is only the trivial morphism $x \mapsto 1$.
Indeed, we can check that for any $n \in \mathbb{Z}$ and $x\in \mathbb{Q}$, we have $f(nx)=f(x)^n$.
In particular, since $f\left(\frac{1}{n}\right)^n = f(1)$, the number $f(1)$ has a rational $n^{\textrm{th}}$ root for all $n \ge 1$. So $f(1) = 1$ and $f\left(\frac{1}{n}\right) = 1$ for all $n \ge 1$. And from that we deduce $f\left(\frac{a}{b}\right) = 1^a = 1$.
EDIT : Here's an explanation of my statement that $1$ is the only rational number with a rational $n^{\textrm{th}}$ root for all $n \ge 1$.
Any non zero rational number can be uniquely written as a product of powers of primes (with some negatives exponents, for example $\frac{4}{15} = 2^2 . 3^{-1} . 5^{-1}$). Let $p$ be a prime number, for $x \in \mathbb{Q}^\*$ denote $v\_p(x) \in \mathbb{Z}$ the exponent of $p$ in this decomposition (called the $p$-adic valuation). We see that $v\_p(xy) = v\_p(x) + v\_p(y)$ for $x, y \in \mathbb{Q}^\*$, so in particular $v\_p(x^n) = n v\_p(x)$. This means **the $p$-adic valuation of an $n^{\textrm{th}}$ power is a multiple of $n$**.
So if $x \in \mathbb{Q}^\*$ is an $n^{\textrm{th}}$ power for all $n \ge 1$, then $v\_p(x)$ is a multiple of $n$ for all $n \ge 1$, which means $v\_p(x) = 0$. And since this is true for all prime numbers $p$, we get $x = 1$. |
1,530,879 | If $f$ is such a homomorphism, then $f(x+y)=f(x)f(y)$.
I know of examples of $f$ which satisfy this property, such as $f(x)=e^x$, but how do I find all of them? | 2015/11/15 | [
"https://math.stackexchange.com/questions/1530879",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/26447/"
] | Consider some such homomorphism $f$. Consider an arbitrary element $a/b \in \mathbb{Q}$. If $f(a/b)=p/q$, we can write $p/q$ in lowest terms and get a unique prime factorization $p/q = \frac{p\_1^{r\_1} \dots p\_n^{r\_n}}{{q\_1^{s\_1} \dots q\_m^{s\_m}}}$. the $p\_1 \dots p\_n, q\_1 \dots q\_m$ are distinct prime numbers, and the $r\_1 \dots r\_n, s\_1 \dots s\_m$ are positive integers. If $p/q$ is an integer, then the denominator contains no factors, and if $p/q=1$, the numerator contains no factors either. Now, we suppose $p/q \neq 1$. Then consider $k=\min\{r\_1, \dots , r\_n, s\_1, \dots, s\_m\}$. Then $f\left(\frac{a}{b(k+1)}\right) = \frac{p\_1^{r\_1/{k+1}} \dots p\_n^{r\_n/{k+1}}}{q\_1^{s\_1/{k+1}} \dots q\_m^{s\_n/{k+1}}}$. If this value were equal to a rational number $p'/q'$, then we would have $p'^{k+1}/{q'}^{k+1} =p/q$. But any prime factor in $p'^{k+1}/{q'}^{k+1}$ must have power at minimum $k+1$, and since $p/q$ contains a prime of power $k$ and prime factorization is unique by the fundamental theorem of arithmetic, we have a contradiction.
As the only assumption we made was that $\{p\_1, \dots , p\_n, q\_1, \dots q\_m\}$ was nonempty, this means that $f(a/b)=1$. But since $a/b$ was arbitrary, $f(x)= 1 \forall x \in \mathbb{Q}$. | Two proofs that there are no nontrivial homomorphisms.
This is kind of the same thing as what others have suggested, but in more abstract terms: ${\bf Q}$ is a divisible group. The image by a homomorphism of a divisible group is always divisible (this is easy to show), but ${\bf Q}^\*$ has no nontrivial divisible subgroups (every nonzero rational is not an $n$-th power for a sufficiently large $n$), so the only homomorphism is the trivial one.
For a slightly convoluted, but perhaps interesting proof, it is not very hard to see that ${\bf Q}^\*$ is isomorphic (as a group) to the product of the two-element group (corresponding to the sign) and a countably infinitely generated free abelian group (corresponding to the prime decomposition). By noticing that $f(x)=f(x/2)^2$, we see that the image of the homomorphism is a subgroup of the positive rationals, which form a free abelian group under multiplication.
But a subgroup of a free abelian group is always free, and moreover a free generator cannot be divisible (this is a simple consequence of the definition), so the image must be trivial (because it is free and divisible), and so must the homomorphism itself.
This shows that *no* divisible group (even divisible by $2$, say, or any other prime) admits a nontrivial homomorphism into ${\bf Q}^\*$. |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | It seems a bit arbitrary, not to use `sorted()`. I think you mean, that you don't want to sort the list in the (default) alphanumerical order.
Here is how you define a key for sorting strings that represent playing cards (a1 through d13) by suit, then rank:
```
>>> def cardsortkey(card):
... return (card[0], int(card[1:]))
...
>>> cardsortkey('a1')
('a', 1)
>>> a = ['a1', 'b1', 'c1', 'd1',
... 'a2', 'b2', 'c2', 'd2',
... 'a11', 'b11', 'c11', 'd11']
>>> sorted(a, key=cardsortkey)
['a1', 'a2', 'a11', 'b1', 'b2', 'b11', 'c1', 'c2', 'c11', 'd1', 'd2', 'd11']
```
Is that what you need? | ```
l = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2']
numbersPerLetter = 2
lsorted = []
for i in range(len(l) / numbersPerLetter):
lsorted.extend([l[x+i] for x in range(0, len(l), len(l) / numbersPerLetter)])
print(lsorted)
```
Output:
```
['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
```
In Python 3.X you have to change `/` to `//` in order to make it work. |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | There is no `.sorted()` method for lists, though there is the `sorted()` function, as S.Mark pointed out (which returns a new sorted list), and a `.sort()` method (which sorts a list in place and returns `None`). If you meant to not use the `sorted()` function, then:
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
a.sort()
b = a
```
otherwise, maybe you can clarify your question further. | You can also sort it this way
```
for i1, e1 in enumerate(a):
for i2, e2 in enumerate(a):
if e2 > e1:
e1 = a[i2]
a[i2] = a[i1]
a[i1] = e1
``` |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | just `b = sorted(a)` ? | You can also sort it this way
```
for i1, e1 in enumerate(a):
for i2, e2 in enumerate(a):
if e2 > e1:
e1 = a[i2]
a[i2] = a[i1]
a[i1] = e1
``` |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | without using sorted, but expensive way.
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
```
split it to 2 parts
```
['a1', 'b1', 'c1', 'd1',] ['a2', 'b2', 'c2', 'd2',]
```
zip it
```
[('a1', 'a2'), ('b1', 'b2'), ('c1', 'c2'), ('d1', 'd2')]
```
and flatten it (with itertools here)
```
import itertools
itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:]))
```
itertools returns iterator, so If you need list, wrapped it with list(), and assigned it to b
```
b = list(itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:])))
=> ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
``` | You can also sort it this way
```
for i1, e1 in enumerate(a):
for i2, e2 in enumerate(a):
if e2 > e1:
e1 = a[i2]
a[i2] = a[i1]
a[i1] = e1
``` |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | without using sorted, but expensive way.
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
```
split it to 2 parts
```
['a1', 'b1', 'c1', 'd1',] ['a2', 'b2', 'c2', 'd2',]
```
zip it
```
[('a1', 'a2'), ('b1', 'b2'), ('c1', 'c2'), ('d1', 'd2')]
```
and flatten it (with itertools here)
```
import itertools
itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:]))
```
itertools returns iterator, so If you need list, wrapped it with list(), and assigned it to b
```
b = list(itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:])))
=> ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
``` | just `b = sorted(a)` ? |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | There is no `.sorted()` method for lists, though there is the `sorted()` function, as S.Mark pointed out (which returns a new sorted list), and a `.sort()` method (which sorts a list in place and returns `None`). If you meant to not use the `sorted()` function, then:
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
a.sort()
b = a
```
otherwise, maybe you can clarify your question further. | without using sorted, but expensive way.
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
```
split it to 2 parts
```
['a1', 'b1', 'c1', 'd1',] ['a2', 'b2', 'c2', 'd2',]
```
zip it
```
[('a1', 'a2'), ('b1', 'b2'), ('c1', 'c2'), ('d1', 'd2')]
```
and flatten it (with itertools here)
```
import itertools
itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:]))
```
itertools returns iterator, so If you need list, wrapped it with list(), and assigned it to b
```
b = list(itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:])))
=> ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
``` |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | It seems a bit arbitrary, not to use `sorted()`. I think you mean, that you don't want to sort the list in the (default) alphanumerical order.
Here is how you define a key for sorting strings that represent playing cards (a1 through d13) by suit, then rank:
```
>>> def cardsortkey(card):
... return (card[0], int(card[1:]))
...
>>> cardsortkey('a1')
('a', 1)
>>> a = ['a1', 'b1', 'c1', 'd1',
... 'a2', 'b2', 'c2', 'd2',
... 'a11', 'b11', 'c11', 'd11']
>>> sorted(a, key=cardsortkey)
['a1', 'a2', 'a11', 'b1', 'b2', 'b11', 'c1', 'c2', 'c11', 'd1', 'd2', 'd11']
```
Is that what you need? | You can also sort it this way
```
for i1, e1 in enumerate(a):
for i2, e2 in enumerate(a):
if e2 > e1:
e1 = a[i2]
a[i2] = a[i1]
a[i1] = e1
``` |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | It seems a bit arbitrary, not to use `sorted()`. I think you mean, that you don't want to sort the list in the (default) alphanumerical order.
Here is how you define a key for sorting strings that represent playing cards (a1 through d13) by suit, then rank:
```
>>> def cardsortkey(card):
... return (card[0], int(card[1:]))
...
>>> cardsortkey('a1')
('a', 1)
>>> a = ['a1', 'b1', 'c1', 'd1',
... 'a2', 'b2', 'c2', 'd2',
... 'a11', 'b11', 'c11', 'd11']
>>> sorted(a, key=cardsortkey)
['a1', 'a2', 'a11', 'b1', 'b2', 'b11', 'c1', 'c2', 'c11', 'd1', 'd2', 'd11']
```
Is that what you need? | just `b = sorted(a)` ? |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | There is no `.sorted()` method for lists, though there is the `sorted()` function, as S.Mark pointed out (which returns a new sorted list), and a `.sort()` method (which sorts a list in place and returns `None`). If you meant to not use the `sorted()` function, then:
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
a.sort()
b = a
```
otherwise, maybe you can clarify your question further. | It seems a bit arbitrary, not to use `sorted()`. I think you mean, that you don't want to sort the list in the (default) alphanumerical order.
Here is how you define a key for sorting strings that represent playing cards (a1 through d13) by suit, then rank:
```
>>> def cardsortkey(card):
... return (card[0], int(card[1:]))
...
>>> cardsortkey('a1')
('a', 1)
>>> a = ['a1', 'b1', 'c1', 'd1',
... 'a2', 'b2', 'c2', 'd2',
... 'a11', 'b11', 'c11', 'd11']
>>> sorted(a, key=cardsortkey)
['a1', 'a2', 'a11', 'b1', 'b2', 'b11', 'c1', 'c2', 'c11', 'd1', 'd2', 'd11']
```
Is that what you need? |
5,209,395 | I have a list `a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]`
How can I get list `b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']` without using `.sorted()`?
Thanks! | 2011/03/06 | [
"https://Stackoverflow.com/questions/5209395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465137/"
] | without using sorted, but expensive way.
```
a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
```
split it to 2 parts
```
['a1', 'b1', 'c1', 'd1',] ['a2', 'b2', 'c2', 'd2',]
```
zip it
```
[('a1', 'a2'), ('b1', 'b2'), ('c1', 'c2'), ('d1', 'd2')]
```
and flatten it (with itertools here)
```
import itertools
itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:]))
```
itertools returns iterator, so If you need list, wrapped it with list(), and assigned it to b
```
b = list(itertools.chain(*zip(a[:len(a)/2],a[len(a)/2:])))
=> ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
``` | ```
l = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2']
numbersPerLetter = 2
lsorted = []
for i in range(len(l) / numbersPerLetter):
lsorted.extend([l[x+i] for x in range(0, len(l), len(l) / numbersPerLetter)])
print(lsorted)
```
Output:
```
['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
```
In Python 3.X you have to change `/` to `//` in order to make it work. |
31,054 | I have a one generation old MacBook Air. I upgraded to Lion when it came out. Now I wish to go back to Snow Leopard. I booted from the thumb drive installer for Snow Leopard. There is a Lion installer image that I can't delete. Disk Utility greys out for that partition. It's not the end of the world, but I would like to get that 5 gigs back.
Any help would be appreciated. | 2011/11/12 | [
"https://apple.stackexchange.com/questions/31054",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/13585/"
] | Another issue is you might not be in the same workgroup. To fix this go to
System Preferences -> Network -> Advanced -> WINS:
Make sure his Windows box is set the same. What OrangeBox suggested must be done as well.
 | In my experience there is no quickfix way to get windows and mac machines to *always* be visible in the others networks list.
The best thing you can do is enable Samba filesharing on your mac, then when you want to connect you just type `smb://Jonathan's MacBook Pro` into the address bar in Explorer (or into the run dialogue).
**To Enable SMB sharing on your Mac:**
1. Go to **System Preferences > Sharing > File Sharing**
2. Select **Options**
3. Tick **Share files and folders using SMB (Windows)**
This has always worked for me with networking windows machines in Mac environments. |
31,054 | I have a one generation old MacBook Air. I upgraded to Lion when it came out. Now I wish to go back to Snow Leopard. I booted from the thumb drive installer for Snow Leopard. There is a Lion installer image that I can't delete. Disk Utility greys out for that partition. It's not the end of the world, but I would like to get that 5 gigs back.
Any help would be appreciated. | 2011/11/12 | [
"https://apple.stackexchange.com/questions/31054",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/13585/"
] | In my experience there is no quickfix way to get windows and mac machines to *always* be visible in the others networks list.
The best thing you can do is enable Samba filesharing on your mac, then when you want to connect you just type `smb://Jonathan's MacBook Pro` into the address bar in Explorer (or into the run dialogue).
**To Enable SMB sharing on your Mac:**
1. Go to **System Preferences > Sharing > File Sharing**
2. Select **Options**
3. Tick **Share files and folders using SMB (Windows)**
This has always worked for me with networking windows machines in Mac environments. | Try changing the workgroup name from the iMac and windows PC. I have same problem and after I change the workgroup name it work. Try to ping your iMac check if the connectivity is good. Start - run - cmd - ping and the IP address of your Mac. |
31,054 | I have a one generation old MacBook Air. I upgraded to Lion when it came out. Now I wish to go back to Snow Leopard. I booted from the thumb drive installer for Snow Leopard. There is a Lion installer image that I can't delete. Disk Utility greys out for that partition. It's not the end of the world, but I would like to get that 5 gigs back.
Any help would be appreciated. | 2011/11/12 | [
"https://apple.stackexchange.com/questions/31054",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/13585/"
] | Another issue is you might not be in the same workgroup. To fix this go to
System Preferences -> Network -> Advanced -> WINS:
Make sure his Windows box is set the same. What OrangeBox suggested must be done as well.
 | Try changing the workgroup name from the iMac and windows PC. I have same problem and after I change the workgroup name it work. Try to ping your iMac check if the connectivity is good. Start - run - cmd - ping and the IP address of your Mac. |
31,054 | I have a one generation old MacBook Air. I upgraded to Lion when it came out. Now I wish to go back to Snow Leopard. I booted from the thumb drive installer for Snow Leopard. There is a Lion installer image that I can't delete. Disk Utility greys out for that partition. It's not the end of the world, but I would like to get that 5 gigs back.
Any help would be appreciated. | 2011/11/12 | [
"https://apple.stackexchange.com/questions/31054",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/13585/"
] | Another issue is you might not be in the same workgroup. To fix this go to
System Preferences -> Network -> Advanced -> WINS:
Make sure his Windows box is set the same. What OrangeBox suggested must be done as well.
 | I was able to resolve the issue by copying the name given in the `NetBIOS Name` field in the answer given by rubixibuc and pasting it into a run dialog, typing \\ and then the NetBIOS Name (so in rubixibuc's example the full path would be `\\MACBOOKPRO-D04A`)
To open the Run dialog, simply type `[](https://i.stack.imgur.com/5qg8m.png)`+`R`
[](https://i.stack.imgur.com/WBSfQ.png) |
31,054 | I have a one generation old MacBook Air. I upgraded to Lion when it came out. Now I wish to go back to Snow Leopard. I booted from the thumb drive installer for Snow Leopard. There is a Lion installer image that I can't delete. Disk Utility greys out for that partition. It's not the end of the world, but I would like to get that 5 gigs back.
Any help would be appreciated. | 2011/11/12 | [
"https://apple.stackexchange.com/questions/31054",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/13585/"
] | I was able to resolve the issue by copying the name given in the `NetBIOS Name` field in the answer given by rubixibuc and pasting it into a run dialog, typing \\ and then the NetBIOS Name (so in rubixibuc's example the full path would be `\\MACBOOKPRO-D04A`)
To open the Run dialog, simply type `[](https://i.stack.imgur.com/5qg8m.png)`+`R`
[](https://i.stack.imgur.com/WBSfQ.png) | Try changing the workgroup name from the iMac and windows PC. I have same problem and after I change the workgroup name it work. Try to ping your iMac check if the connectivity is good. Start - run - cmd - ping and the IP address of your Mac. |
302,466 | I am using the subfigure to put two figures by each other. There is a black stripe at the right side of output figure which I am not sure how to remove it without changing the size of my subfigure. Here is the code I am using (just important parts are mentioned for the sake of clarity)
```
\begin{figure}
\centering
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[trim = 30mm 0mm 30mm 15mm, clip,scale=0.2]{c.jpg}
\end{subfigure}
~~~\hfill
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[trim = 42mm 0mm 35mm 15mm, clip,scale=0.2]{co.jpg}
\end{subfigure}
\hfill
\end{figure}
```
Output is this
[](https://i.stack.imgur.com/NL09a.png) | 2016/04/04 | [
"https://tex.stackexchange.com/questions/302466",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/72473/"
] | Two main suggestions:
* Remove the second `\hfill` instruction. (And, remove the redundant `\centering` instruction.)
* Replace the two instances of `scale=0.2` with `width=\linewidth`. If that makes the graphs look too small in your opinion, consider changing both instances of `{0.4\textwidth}` to `{0.45\textwidth}`.
In your screenshot, both subfigure captions -- "`(a)`" and "`(b)`" -- are not centered below the respective graphs. This strongly suggests that the graphs are quite a bit wider than `0.4\textwidth`. That's why I'm suggesting you replace the sizing directive `scale=0.2` with `width=\linewidth`.
[](https://i.stack.imgur.com/mCnkH.png)
```
\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx,subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[trim = 30mm 0mm 30mm 15mm, clip,
width=\linewidth]{c.jpg}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[trim = 42mm 0mm 35mm 15mm, clip,
width=\linewidth]{co.jpg}
\end{subfigure}
\end{figure}
\end{document}
``` | Another possible cause is that you are editing in draft mode. Removing draft option might eliminate the black stripe at the end. |
63,025,965 | Is there a way to control Grandchildren and Nested Components with ViewChild? I need to access/run a public method within a Grandchild component, from a top layer. It doesn't seem to be working for me. Prefer not to utilize a service or input/output for now.
Its working for me, for only direct child components.
**Resources:**
<https://angular.io/api/core/ViewChild> | 2020/07/22 | [
"https://Stackoverflow.com/questions/63025965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Even though you said you would rather not utilize a service, that is probably your best option.
You can follow [this](https://stackoverflow.com/a/52744815/10637527) solution.
Using `@ViewChild`, you can follow [this](https://angular.io/guide/component-interaction?fireglass_rsn=true#parent-calls-an-viewchild) guide, with the grandchild component in the grandparent component.
Otherwise, you can create a 'bridge' from grandchild to parent, and then from parent to grandparent, using `@Output` decorator.
>
> The child component exposes an EventEmitter property with which it emits events when something happens. The parent binds to that event property and reacts to those events.
> The child's EventEmitter property is an output property, typically adorned with an @Output decoration
>
>
>
[source](https://stackoverflow.com/a/46960013/10637527)
Example:
**Grandparent:**
```
<parent (notifyGrandparent)="GrandparentHandle($event)">
</parent>
///ts
GrandparentHandle(event){
// do needed work
}
```
**Parent:**
```
<child (handleNotif)="childEvent($event)">
</child>
@Output() notifyGrandparent= new EventEmitter();
childEvent(event) {
this.notifyGrandparent.emit('event')
}
```
**Child:**
```
@Output() handleNotif = new EventEmitter
onNotify() {
this.handleNotif.emit('notify everyone')
}
```
[source](https://stackoverflow.com/a/56609105/10637527)
You can follow [this](https://angular.io/guide/component-interaction#!#bidirectional-service) guide for component interaction, with [this](https://stackblitz.com/angular/vkkglmovokax?file=src%2Fapp%2Fapp.component.html) full stackblitz example.
Also, you can read [this](https://github.com/angular/components/issues/8090) thread about component interaction
and [this](https://engineering.datorama.com/accessing-a-components-grandchildren-in-angular-ea15008828ea) example using `@viewChildren`, which is more interesting... | The @ViewChild annotation allow to get a component from your View, using is type or using an hashtag
-- parent.component.ts
```js
@Component()
export class ParentComponant {
@ViewChild("childComponent") child : ChildComponant;
@ViewChild(ChildComponant) ifOnlyOneChildOfThisType : ChildComponant;
// child are only accessible after view init
ngAfterViewInit() {
this.child.aPublicMethod();
this.ifOnlyOneChildOfThisType.aPublicMethod();
}
}
```
-- parent.component.html
```html
<h1> Hello i'm the parent component </h1>
<child-component #childComponent></child-component>
```
If your child componant need to use a method from the parent component, you can use Event or directly give the method to the child component thank to an Input.
If you give a method, you must declare it as arrow function else you will get the wrong "this" object.
-- parent.component.ts
```js
@Component()
export class ParentComponant {
@ViewChild("childComponent") child : ChildComponant;
@ViewChild(ChildComponant) ifOnlyOneChildOfThisType : ChildComponant;
// child are only accessible after view init
ngAfterViewInit() {
this.child.aPublicMethod();
this.ifOnlyOneChildOfThisType.aPublicMethod();
}
methodToShare = () => {
// do something, and "this" is the ParentComponant
}
}
```
-- parent.component.html
```html
<h1> Hello i'm the parent component </h1>
<child-component [inputMethod]="methodToShare" #childComponent></child-component>
```
If you have multiple child component you can use @ViewChildren annotation which allow you to get list of component inside a Query
Hop it help |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | It's a ternary operator, and it's basically just a shortened if / else statement that does :
```
if ( $("#summary_box").width() == 300 ) {
var toggleWidth = '0';
}else{
var toggleWidth = '300px';
}
```
As a sidenote, jQuery's `animate()` has a toggle option that would do the same thing:
```
$('#summary_box').animate({ width: 'toggle'}, 1000);
```
[**FIDDLE**](http://jsfiddle.net/Vxm9R/) | Check [this](https://stackoverflow.com/questions/10781620/toggle-width-with-jquery) question on StackOverflow out.
Gives a similar solution to your's try.
Check [this](http://jsfiddle.net/mareebsiddiqui/ZfHZV/376/) fiddle as well.
**JS:**
```
$(document).ready( function(){
$('#toggle-button').click( function() {
var toggleWidth = $("#toggle").width() == 300 ? "0" : "300px";
$('#toggle').animate({ width: toggleWidth });
});
});
``` |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | That is ternary operation - equivalent to this -
```
var toggleWidth;
if ($("#summary_box").width() == 300) {
toggleWidth = "0";
} else {
toggleWidth "300px";
}
```
[MDN reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) | Check [this](https://stackoverflow.com/questions/10781620/toggle-width-with-jquery) question on StackOverflow out.
Gives a similar solution to your's try.
Check [this](http://jsfiddle.net/mareebsiddiqui/ZfHZV/376/) fiddle as well.
**JS:**
```
$(document).ready( function(){
$('#toggle-button').click( function() {
var toggleWidth = $("#toggle").width() == 300 ? "0" : "300px";
$('#toggle').animate({ width: toggleWidth });
});
});
``` |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | This piece of code reads like the following:
```
$("#summary_box").width() == 300 ? "0" : "300px";
```
If width() is equal to 300, return 0, else return "300px".
See [Ternary Operator](http://en.wikipedia.org/wiki/Ternary_operation) for more info. | Check [this](https://stackoverflow.com/questions/10781620/toggle-width-with-jquery) question on StackOverflow out.
Gives a similar solution to your's try.
Check [this](http://jsfiddle.net/mareebsiddiqui/ZfHZV/376/) fiddle as well.
**JS:**
```
$(document).ready( function(){
$('#toggle-button').click( function() {
var toggleWidth = $("#toggle").width() == 300 ? "0" : "300px";
$('#toggle').animate({ width: toggleWidth });
});
});
``` |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | Check [this](https://stackoverflow.com/questions/10781620/toggle-width-with-jquery) question on StackOverflow out.
Gives a similar solution to your's try.
Check [this](http://jsfiddle.net/mareebsiddiqui/ZfHZV/376/) fiddle as well.
**JS:**
```
$(document).ready( function(){
$('#toggle-button').click( function() {
var toggleWidth = $("#toggle").width() == 300 ? "0" : "300px";
$('#toggle').animate({ width: toggleWidth });
});
});
``` | I tried this, and works fine
```
$("#searchIcon").click(function(){
var toggleWidth = "0px";
if($("#searchbox").width() == 118)
{
toggleWidth="0px";
}
else
{
toggleWidth="120px";
}
$('#searchbox').animate({ width: toggleWidth });
});
``` |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | That is ternary operation - equivalent to this -
```
var toggleWidth;
if ($("#summary_box").width() == 300) {
toggleWidth = "0";
} else {
toggleWidth "300px";
}
```
[MDN reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) | It's a ternary operator, and it's basically just a shortened if / else statement that does :
```
if ( $("#summary_box").width() == 300 ) {
var toggleWidth = '0';
}else{
var toggleWidth = '300px';
}
```
As a sidenote, jQuery's `animate()` has a toggle option that would do the same thing:
```
$('#summary_box').animate({ width: 'toggle'}, 1000);
```
[**FIDDLE**](http://jsfiddle.net/Vxm9R/) |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | It's a ternary operator, and it's basically just a shortened if / else statement that does :
```
if ( $("#summary_box").width() == 300 ) {
var toggleWidth = '0';
}else{
var toggleWidth = '300px';
}
```
As a sidenote, jQuery's `animate()` has a toggle option that would do the same thing:
```
$('#summary_box').animate({ width: 'toggle'}, 1000);
```
[**FIDDLE**](http://jsfiddle.net/Vxm9R/) | I tried this, and works fine
```
$("#searchIcon").click(function(){
var toggleWidth = "0px";
if($("#searchbox").width() == 118)
{
toggleWidth="0px";
}
else
{
toggleWidth="120px";
}
$('#searchbox').animate({ width: toggleWidth });
});
``` |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | That is ternary operation - equivalent to this -
```
var toggleWidth;
if ($("#summary_box").width() == 300) {
toggleWidth = "0";
} else {
toggleWidth "300px";
}
```
[MDN reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) | This piece of code reads like the following:
```
$("#summary_box").width() == 300 ? "0" : "300px";
```
If width() is equal to 300, return 0, else return "300px".
See [Ternary Operator](http://en.wikipedia.org/wiki/Ternary_operation) for more info. |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | That is ternary operation - equivalent to this -
```
var toggleWidth;
if ($("#summary_box").width() == 300) {
toggleWidth = "0";
} else {
toggleWidth "300px";
}
```
[MDN reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) | I tried this, and works fine
```
$("#searchIcon").click(function(){
var toggleWidth = "0px";
if($("#searchbox").width() == 118)
{
toggleWidth="0px";
}
else
{
toggleWidth="120px";
}
$('#searchbox').animate({ width: toggleWidth });
});
``` |
17,240,544 | I need my Jquery code to animate `summary_box` div as so it slides the following way.
On load it will be on on browser window and when `summary_button2` div is clicked it will slide(change width to 0) to the right and despair and appear again once the button is clicked again.
What I have sort of works, but I'm not sure what this is doing: `(== 300 ? "0" : "300px";)`???
```
<script type="text/javascript">
$(document).ready( function(){
$('#summary_button2').click( function() {
var toggleWidth = $("#summary_box").width() == 300 ? "0" : "300px";
$('#summary_box').animate({ width: toggleWidth });
});
});
</script>
``` | 2013/06/21 | [
"https://Stackoverflow.com/questions/17240544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129446/"
] | This piece of code reads like the following:
```
$("#summary_box").width() == 300 ? "0" : "300px";
```
If width() is equal to 300, return 0, else return "300px".
See [Ternary Operator](http://en.wikipedia.org/wiki/Ternary_operation) for more info. | I tried this, and works fine
```
$("#searchIcon").click(function(){
var toggleWidth = "0px";
if($("#searchbox").width() == 118)
{
toggleWidth="0px";
}
else
{
toggleWidth="120px";
}
$('#searchbox').animate({ width: toggleWidth });
});
``` |
74,383,155 | How can I create a predicate so that when the user selects "Full Body" it returns the entire list with no predicate? Right now, it is returning "part" which corresponds to the muscle groups I have set (Abs, Legs, Push, Pull). I want to return all of the options when "Full Body" is selected. How could I write an If statement so that the predicate is not used?
```
import SwiftUI
var parts = ["Abs", "Legs", "Push", "Pull", "Full Body"]
struct ExerciseList: View {
@State private var selectedPart = " "
var body: some View {
NavigationView {
VStack (alignment: .leading) {
NavigationLink(destination: AddExerciseView()){
Text("Add Exercise")
.fontWeight(.bold)
}
Picker("Body Part", selection: $selectedPart) {
ForEach(parts, id:\.self) { part in
Text(part)
}
}.pickerStyle(.segmented)
ListView(part:selectedPart)
}
}
}
}
```
```
import SwiftUI
struct ListView: View {
var part: String
@FetchRequest var exercises: FetchedResults<Exercise>
init(part: String) {
self.part = part
self._exercises = FetchRequest(
entity: Exercise.entity(),
sortDescriptors: [],
predicate: NSPredicate(format: "musclegroup == %@", part as any CVarArg)
)
}
var body: some View {
List(exercises) { e in
Text(e.exercisename)
}
}
}
``` | 2022/11/10 | [
"https://Stackoverflow.com/questions/74383155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20186634/"
] | I made the es6 javascript code.
First I put the approval array and batas into the variable first.
Then I use for loop iteration to find data less than 10, then I delete it using splice.
The last time I returned it was an object
This is my code :
```js
const batas = (data) => {
let arr = data.approval
let batas = data.batas
for (let i = 0; i < arr.length; i++) {
if (arr[i]['kode'] < batas) arr.splice(i, 1)
}
return data
}
let data = {
approval: [
{
name: 'XXXX',
kode: '10'
},
{
name: 'YYYY',
kode: '12'
},
{
name: 'ZZZZ',
kode: '14'
},
{
name: 'HHHH',
kode: '09'
}
],
batas: '10'
}
console.log(batas(data))
``` | Using `filter` method can do this, for more info check: [MDN - filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).
```js
let data = {
approval: [
{
name: 'XXXX',
kode: '10'
},
{
name: 'YYYY',
kode: '12'
},
{
name: 'ZZZZ',
kode: '14'
},
{
name: 'HHHH',
kode: '09'
}
],
batas: "10"
}
const filteredData = {approval: data.approval.filter(item => item.kode >= data.batas)}
console.log('filteredData: ', filteredData)
``` |
74,383,155 | How can I create a predicate so that when the user selects "Full Body" it returns the entire list with no predicate? Right now, it is returning "part" which corresponds to the muscle groups I have set (Abs, Legs, Push, Pull). I want to return all of the options when "Full Body" is selected. How could I write an If statement so that the predicate is not used?
```
import SwiftUI
var parts = ["Abs", "Legs", "Push", "Pull", "Full Body"]
struct ExerciseList: View {
@State private var selectedPart = " "
var body: some View {
NavigationView {
VStack (alignment: .leading) {
NavigationLink(destination: AddExerciseView()){
Text("Add Exercise")
.fontWeight(.bold)
}
Picker("Body Part", selection: $selectedPart) {
ForEach(parts, id:\.self) { part in
Text(part)
}
}.pickerStyle(.segmented)
ListView(part:selectedPart)
}
}
}
}
```
```
import SwiftUI
struct ListView: View {
var part: String
@FetchRequest var exercises: FetchedResults<Exercise>
init(part: String) {
self.part = part
self._exercises = FetchRequest(
entity: Exercise.entity(),
sortDescriptors: [],
predicate: NSPredicate(format: "musclegroup == %@", part as any CVarArg)
)
}
var body: some View {
List(exercises) { e in
Text(e.exercisename)
}
}
}
``` | 2022/11/10 | [
"https://Stackoverflow.com/questions/74383155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20186634/"
] | I made the es6 javascript code.
First I put the approval array and batas into the variable first.
Then I use for loop iteration to find data less than 10, then I delete it using splice.
The last time I returned it was an object
This is my code :
```js
const batas = (data) => {
let arr = data.approval
let batas = data.batas
for (let i = 0; i < arr.length; i++) {
if (arr[i]['kode'] < batas) arr.splice(i, 1)
}
return data
}
let data = {
approval: [
{
name: 'XXXX',
kode: '10'
},
{
name: 'YYYY',
kode: '12'
},
{
name: 'ZZZZ',
kode: '14'
},
{
name: 'HHHH',
kode: '09'
}
],
batas: '10'
}
console.log(batas(data))
``` | Use `Array#filter` method as follows:
```js
const
data = { approval: [ { name: 'XXXX', kode: '10' }, { name: 'YYYY', kode: '12' }, { name: 'ZZZZ', kode: '14' }, { name: 'HHHH', kode: '09' } ], batas: "10" },
output = [ data ]
.map(
({approval,batas}) =>
({approval:approval.filter(
({kode}) => kode >= batas
)})
)[0];
console.log( output );
```
**However, ....**
If all you need is the *filtered*, array then this approach would suffice:
```js
const
data = { approval: [ { name: 'XXXX', kode: '10' }, { name: 'YYYY', kode: '12' }, { name: 'ZZZZ', kode: '14' }, { name: 'HHHH', kode: '09' } ], batas: "10" },
output = data.approval
.filter(
({kode}) => kode >= data.batas
);
console.log( output );
``` |
74,383,155 | How can I create a predicate so that when the user selects "Full Body" it returns the entire list with no predicate? Right now, it is returning "part" which corresponds to the muscle groups I have set (Abs, Legs, Push, Pull). I want to return all of the options when "Full Body" is selected. How could I write an If statement so that the predicate is not used?
```
import SwiftUI
var parts = ["Abs", "Legs", "Push", "Pull", "Full Body"]
struct ExerciseList: View {
@State private var selectedPart = " "
var body: some View {
NavigationView {
VStack (alignment: .leading) {
NavigationLink(destination: AddExerciseView()){
Text("Add Exercise")
.fontWeight(.bold)
}
Picker("Body Part", selection: $selectedPart) {
ForEach(parts, id:\.self) { part in
Text(part)
}
}.pickerStyle(.segmented)
ListView(part:selectedPart)
}
}
}
}
```
```
import SwiftUI
struct ListView: View {
var part: String
@FetchRequest var exercises: FetchedResults<Exercise>
init(part: String) {
self.part = part
self._exercises = FetchRequest(
entity: Exercise.entity(),
sortDescriptors: [],
predicate: NSPredicate(format: "musclegroup == %@", part as any CVarArg)
)
}
var body: some View {
List(exercises) { e in
Text(e.exercisename)
}
}
}
``` | 2022/11/10 | [
"https://Stackoverflow.com/questions/74383155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20186634/"
] | These are some of the many ways to do what you want:
```js
let data = {
approval: [
{
name: 'XXXX',
kode: '10'
},
{
name: 'YYYY',
kode: '12'
},
{
name: 'ZZZZ',
kode: '14'
},
{
name: 'HHHH',
kode: '09'
}
],
batas: "10"
}
// solution 1 > use for loop:
const results_1 = [];
for (let i=0; i<data.approval.length; i++) {
if (data.approval[i].kode >= data.batas) results_1.push(data.approval[i]);
}
console.log(results_1);
// solution 2 > use for...of loop:
const results_2 = [];
for (const obj of data.approval) {
if (obj.kode >= data.batas) results_2.push(obj);
}
console.log(results_2);
// solution 3 > use filter method:
const results_3 = data.approval.filter(obj => obj.kode >= data.batas);
console.log(results_3);
``` | Using `filter` method can do this, for more info check: [MDN - filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).
```js
let data = {
approval: [
{
name: 'XXXX',
kode: '10'
},
{
name: 'YYYY',
kode: '12'
},
{
name: 'ZZZZ',
kode: '14'
},
{
name: 'HHHH',
kode: '09'
}
],
batas: "10"
}
const filteredData = {approval: data.approval.filter(item => item.kode >= data.batas)}
console.log('filteredData: ', filteredData)
``` |
74,383,155 | How can I create a predicate so that when the user selects "Full Body" it returns the entire list with no predicate? Right now, it is returning "part" which corresponds to the muscle groups I have set (Abs, Legs, Push, Pull). I want to return all of the options when "Full Body" is selected. How could I write an If statement so that the predicate is not used?
```
import SwiftUI
var parts = ["Abs", "Legs", "Push", "Pull", "Full Body"]
struct ExerciseList: View {
@State private var selectedPart = " "
var body: some View {
NavigationView {
VStack (alignment: .leading) {
NavigationLink(destination: AddExerciseView()){
Text("Add Exercise")
.fontWeight(.bold)
}
Picker("Body Part", selection: $selectedPart) {
ForEach(parts, id:\.self) { part in
Text(part)
}
}.pickerStyle(.segmented)
ListView(part:selectedPart)
}
}
}
}
```
```
import SwiftUI
struct ListView: View {
var part: String
@FetchRequest var exercises: FetchedResults<Exercise>
init(part: String) {
self.part = part
self._exercises = FetchRequest(
entity: Exercise.entity(),
sortDescriptors: [],
predicate: NSPredicate(format: "musclegroup == %@", part as any CVarArg)
)
}
var body: some View {
List(exercises) { e in
Text(e.exercisename)
}
}
}
``` | 2022/11/10 | [
"https://Stackoverflow.com/questions/74383155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20186634/"
] | These are some of the many ways to do what you want:
```js
let data = {
approval: [
{
name: 'XXXX',
kode: '10'
},
{
name: 'YYYY',
kode: '12'
},
{
name: 'ZZZZ',
kode: '14'
},
{
name: 'HHHH',
kode: '09'
}
],
batas: "10"
}
// solution 1 > use for loop:
const results_1 = [];
for (let i=0; i<data.approval.length; i++) {
if (data.approval[i].kode >= data.batas) results_1.push(data.approval[i]);
}
console.log(results_1);
// solution 2 > use for...of loop:
const results_2 = [];
for (const obj of data.approval) {
if (obj.kode >= data.batas) results_2.push(obj);
}
console.log(results_2);
// solution 3 > use filter method:
const results_3 = data.approval.filter(obj => obj.kode >= data.batas);
console.log(results_3);
``` | Use `Array#filter` method as follows:
```js
const
data = { approval: [ { name: 'XXXX', kode: '10' }, { name: 'YYYY', kode: '12' }, { name: 'ZZZZ', kode: '14' }, { name: 'HHHH', kode: '09' } ], batas: "10" },
output = [ data ]
.map(
({approval,batas}) =>
({approval:approval.filter(
({kode}) => kode >= batas
)})
)[0];
console.log( output );
```
**However, ....**
If all you need is the *filtered*, array then this approach would suffice:
```js
const
data = { approval: [ { name: 'XXXX', kode: '10' }, { name: 'YYYY', kode: '12' }, { name: 'ZZZZ', kode: '14' }, { name: 'HHHH', kode: '09' } ], batas: "10" },
output = data.approval
.filter(
({kode}) => kode >= data.batas
);
console.log( output );
``` |
8,493,437 | I need to rotate an image dinamically by angle specified by the user.
I use the following code, but it only works for IE and not for any other browser.
```
<div id="frame1" style="overflow:hidden" width='300' height='300'>
<div id="frame2" width='200' height='200'>
<img src='1.jpeg'' id='im' src='1.jpeg' width='10' height='10'>
</div>
</div>
<script type="text/javascript">
rotate(frame2, 45);
function rotate (elem, deg)
{
if (navigator.appName=='Microsoft Internet Explorer')
{
rad = deg*Math.PI/180;
elem.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingmethod='auto expand')";
elem.filters.item(0).M11 = Math.cos(rad);
elem.filters.item(0).M12 = -Math.sin(rad);
elem.filters.item(0).M21 = Math.sin(rad);
elem.filters.item(0).M22 = Math.cos(rad);
elem.style.marginLeft=((canvsize-elem.offsetWidth)/2)+'px'
elem.style.marginTop=((canvsize-elem.offsetHeight)/2)+'px'
}
else
{
elem.style.MozTransform = 'rotate(' + deg + ')';
elem.style.WebkitTransform = 'rotate(' + deg + ')';
elem.style.OTransform = 'rotate(' + deg + ')';
elem.style.MsTransform = 'rotate(' + deg + ')';
elem.style.transform = 'rotate(' + deg + ')';
}
}
</script>
```
Can you please help? | 2011/12/13 | [
"https://Stackoverflow.com/questions/8493437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/429775/"
] | Look at a CSS example:
```
-webkit-transform: rotate(45deg);
```
As you can see you forgot to add **deg**
```
elem.style.mozTransform = 'rotate(' + deg + 'deg)';
elem.style.webkitTransform = 'rotate(' + deg + 'deg)';
elem.style.oTransform = 'rotate(' + deg + 'deg)';
elem.style.msTransform = 'rotate(' + deg + 'deg)';
elem.style.transform = 'rotate(' + deg + 'deg)';
``` | It's actually easier in browsers that aren't IE. The MDN has [good documentation](https://developer.mozilla.org/en/CSS/transform) on how to do it with CSS3. There's some [here](https://developer.mozilla.org/en/CSS/Using_CSS_transforms) as well.
For Webkit browsers, [this page](http://tekkie.flashbit.net/css/css3-transforms-in-webkit) should help. |
8,493,437 | I need to rotate an image dinamically by angle specified by the user.
I use the following code, but it only works for IE and not for any other browser.
```
<div id="frame1" style="overflow:hidden" width='300' height='300'>
<div id="frame2" width='200' height='200'>
<img src='1.jpeg'' id='im' src='1.jpeg' width='10' height='10'>
</div>
</div>
<script type="text/javascript">
rotate(frame2, 45);
function rotate (elem, deg)
{
if (navigator.appName=='Microsoft Internet Explorer')
{
rad = deg*Math.PI/180;
elem.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingmethod='auto expand')";
elem.filters.item(0).M11 = Math.cos(rad);
elem.filters.item(0).M12 = -Math.sin(rad);
elem.filters.item(0).M21 = Math.sin(rad);
elem.filters.item(0).M22 = Math.cos(rad);
elem.style.marginLeft=((canvsize-elem.offsetWidth)/2)+'px'
elem.style.marginTop=((canvsize-elem.offsetHeight)/2)+'px'
}
else
{
elem.style.MozTransform = 'rotate(' + deg + ')';
elem.style.WebkitTransform = 'rotate(' + deg + ')';
elem.style.OTransform = 'rotate(' + deg + ')';
elem.style.MsTransform = 'rotate(' + deg + ')';
elem.style.transform = 'rotate(' + deg + ')';
}
}
</script>
```
Can you please help? | 2011/12/13 | [
"https://Stackoverflow.com/questions/8493437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/429775/"
] | Look at a CSS example:
```
-webkit-transform: rotate(45deg);
```
As you can see you forgot to add **deg**
```
elem.style.mozTransform = 'rotate(' + deg + 'deg)';
elem.style.webkitTransform = 'rotate(' + deg + 'deg)';
elem.style.oTransform = 'rotate(' + deg + 'deg)';
elem.style.msTransform = 'rotate(' + deg + 'deg)';
elem.style.transform = 'rotate(' + deg + 'deg)';
``` | You forgot to add `deg` to the css property.
You should also add a `transform origin` to the image to make it rotate around the center (assuming that's what you're trying to do).
This code should do it.
```
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
</style>
</head>
<body>
<div id="frame1" style="overflow:hidden" width='300' height='300'>
<div id="frame2" width='200' height='200'>
<img src='1.jpeg' id='im' src='1.jpeg' width='10' height='10'>
</div>
</div>
<script type="text/javascript">
rotate(frame2, 45);
function rotate (elem, deg)
{
if (navigator.appName=='Microsoft Internet Explorer')
{
rad = deg*Math.PI/180;
elem.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingmethod='auto expand')";
elem.filters.item(0).M11 = Math.cos(rad);
elem.filters.item(0).M12 = -Math.sin(rad);
elem.filters.item(0).M21 = Math.sin(rad);
elem.filters.item(0).M22 = Math.cos(rad);
elem.style.marginLeft=((canvsize-elem.offsetWidth)/2)+'px'
elem.style.marginTop=((canvsize-elem.offsetHeight)/2)+'px'
}
else
{
elem.style.MozTransformOrigin = "5px 5px";
elem.style.WebkitTransformOrigin = "5px 5px";
elem.style.OTransformOrigin = "5px 5px";
elem.style.MsTransformOrigin = "5px 5px";
elem.style.transformOrigin = "5px 5px";
elem.style.MozTransform = 'rotate(' + deg + 'deg)';
elem.style.WebkitTransform = 'rotate(' + deg + 'deg)';
elem.style.OTransform = 'rotate(' + deg + 'deg)';
elem.style.MsTransform = 'rotate(' + deg + 'deg)';
elem.style.transform = 'rotate(' + deg + 'deg)';
}
}
</script>
</body>
</html>
``` |
741,402 | I am not sure if I am getting in a little too deep but I have decided i'd like to learn how to develop applications built using the Oracle technology stack.
I don't come from a programming background (I have always been on the business side) but I love that no matter what problem you encounter, you can almost always solve it with a program of some description (i know 'program' is probably the wrong word there but hopefully you know what I mean).
So my questions:
1. Given I have no programming experience, should I be trying to start with something else?
2. If Oracle is an ok start, from what I can ascertain i'll need to get a fair grasp of Java as well. Where should I start?
Im not necessarily looking for the quickest way, but I do want to make sure that whatever I do gives me a good understanding of what is going on. | 2009/04/12 | [
"https://Stackoverflow.com/questions/741402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89932/"
] | If you don't have any object-oriented programming background, I suggest you should start out by getting familiar with basic OO concept. I recommend reading this book "Head First Java" [http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208](https://rads.stackoverflow.com/amzn/click/com/0596009208) and the official java tutorial - <http://java.sun.com/docs/books/tutorial/reallybigindex.html>
After you get the idea and basic concept on object-oriented programming and java. You can move yourself to use any technology including Oracle technology stack and other OO language such as python and C#. | As natch3z has mentioned, if you don't have a programming background it might be worthwhile starting a little simpler than the oracle tech stack.
By Oracle tech stack, I am assuming using things like oc4j, ADF, oracle DB etc all within Oracle's JDeveloper IDE. Even though technologies like this can be powerful and achieve what you want, it might be a little overwhelming for a beginner.
It might be a little more advantageous to start off with something like the Eclipse IDE and work you way through some simple tutorials. There's nothing worse than starting with something difficult and getting discouraged due to being overwhelmed. |
741,402 | I am not sure if I am getting in a little too deep but I have decided i'd like to learn how to develop applications built using the Oracle technology stack.
I don't come from a programming background (I have always been on the business side) but I love that no matter what problem you encounter, you can almost always solve it with a program of some description (i know 'program' is probably the wrong word there but hopefully you know what I mean).
So my questions:
1. Given I have no programming experience, should I be trying to start with something else?
2. If Oracle is an ok start, from what I can ascertain i'll need to get a fair grasp of Java as well. Where should I start?
Im not necessarily looking for the quickest way, but I do want to make sure that whatever I do gives me a good understanding of what is going on. | 2009/04/12 | [
"https://Stackoverflow.com/questions/741402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89932/"
] | If you don't have any object-oriented programming background, I suggest you should start out by getting familiar with basic OO concept. I recommend reading this book "Head First Java" [http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208](https://rads.stackoverflow.com/amzn/click/com/0596009208) and the official java tutorial - <http://java.sun.com/docs/books/tutorial/reallybigindex.html>
After you get the idea and basic concept on object-oriented programming and java. You can move yourself to use any technology including Oracle technology stack and other OO language such as python and C#. | Why Java ? More specifically, what sort of stuff are you aiming to develop ?
For web applications, you could look at PHP. Oracle also has a web development/runtime environment in the database, called [Application Express](http://www.oracle.com/technology/products/database/application_express/html/what_is_apex.html). That's a pretty simple way to get started in developing data oriented web applications. It is all part of a single install with their free [XE](http://www.oracle.com/technology/products/database/xe/index.html) edition. |
741,402 | I am not sure if I am getting in a little too deep but I have decided i'd like to learn how to develop applications built using the Oracle technology stack.
I don't come from a programming background (I have always been on the business side) but I love that no matter what problem you encounter, you can almost always solve it with a program of some description (i know 'program' is probably the wrong word there but hopefully you know what I mean).
So my questions:
1. Given I have no programming experience, should I be trying to start with something else?
2. If Oracle is an ok start, from what I can ascertain i'll need to get a fair grasp of Java as well. Where should I start?
Im not necessarily looking for the quickest way, but I do want to make sure that whatever I do gives me a good understanding of what is going on. | 2009/04/12 | [
"https://Stackoverflow.com/questions/741402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89932/"
] | If you don't have any object-oriented programming background, I suggest you should start out by getting familiar with basic OO concept. I recommend reading this book "Head First Java" [http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208](https://rads.stackoverflow.com/amzn/click/com/0596009208) and the official java tutorial - <http://java.sun.com/docs/books/tutorial/reallybigindex.html>
After you get the idea and basic concept on object-oriented programming and java. You can move yourself to use any technology including Oracle technology stack and other OO language such as python and C#. | For Oracle questions you could try posting on the new dedicated Oracle stack exchange site, <http://www.oracleoverflow.com/>, maintained by Simple Talk Publishing. |
57,729,942 | I have my site so that people can upload urls of the videos to the database and with php it should in theory display said video. I don't want to use the embed tag because that doesn't work from mobile device. Is there a way to use the videos with just the url's?
```html
<video controls>
<source src="https://www.youtube.com/watch?v=S3FPvI5p8Zo" type="video/mp4">
</video>
```
I expect the video to show, but the actual result is it not working. | 2019/08/30 | [
"https://Stackoverflow.com/questions/57729942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11866436/"
] | try passing .environmentObject on your destination:
```
NavigationLink(destination: detailView(feed: self._feed, i: i).environmentObject(x))
``` | 1. You have to use willSet instead of didSet.
2. TestItem should be a value type: struct or enum. SwiftUI's observation system properly works only with value types. |
615,977 | My question is simple: could a decoupling capacitor be designed in such a way that it could in theory power on a CPU core?
Do these types of capacitors have sufficient power to power on a core without changes to the design? | 2022/04/15 | [
"https://electronics.stackexchange.com/questions/615977",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/121309/"
] | One can put energy into a capacitor and then briefly power something from it. You can easily confirm this by charging up a capacitor to a few volts and then placing an LED and resistor across it.
The basic equation for a capacitor is...
$$I=C\frac{dv}{dt} $$
And also
Q = C \* V or alternately (Charge = Capacitance \* Voltage)
**SMALL MCU ON BULK CAPACITOR:**
So, for example, if I have a small microcontroller that is drawing 1mA and its drawing power from a 1mF bulk capacitor then the voltage on the capacitor will drop by...
$$\frac{dv}{dt} = \frac{I}{C} = \frac{1mA}{1mF} = \frac{1V}{s} $$
If the capacitor was initially charged to 5V and the microcontroller had an operating voltage range of 2.5V to 5.0V then it could run for 2.5 seconds before the capacitor voltage went too low to power it any more.
**SMALL MCU ON 1UF DECOUPLING CAPACITOR:**
In the case of say a 1uF SMT ceramic decoupling capacitor. Then the microcontroller runs for...
$$\frac{(5V - 2.5V) \* 1uF}{1mA} = 2.5ms$$
There are actually cases (like energy harvesting) where an MCU sleeps for a long time, wakes up for a few ms to take a sensor reading, and then goes back to sleep. So even this short timescale can be useful.
**SMALL MCU ON SUPER CAPACITOR:**
If we wanted to run for a long time on a capacitor we might use something like a [5F super capacitor pack](https://www.digikey.com/en/products/detail/cornell-dubilier-illinois-capacitor/DGH505Q5R5/7387525), then we can power the MCU for something like 12500 seconds (3.47 hours). Although this falls outside the realm of a "decoupling" capacitor. This type of setup is useful for things like solar powered sensors that need to charge up every day and operate through the night. Compared to batteries, which have a limited number of charge cycles, capacitors can be charged and discharged thousands of times with no problems, and they are often rated to work at colder temperatures than standard batteries.
**HIGH WATTAGE CPU:**
If on the other hand you are powering something like an intel CPU that draws like 100W, then a standard decoupling capacitor is only going to power it for nanoseconds. Even a very large capacitor is only going to last milliseconds before the voltage goes out of the specified operating range.
Note that capacitors don't generate power. They only store power that's put into them. | >
> Would it be possible for a Surface Mounted Capacitor (Decoupling) to Power on a CPU core?
>
>
>
There's nothing theoretical about it. **Those capacitors already do it**! The output impedance of the power supply is too high to maintain adequate supply voltage during the very fast current spikes demanded by powerful CPUs. So, for fractions of a millisecond, *the capacitors deliver most of the power to the CPU*, until the power supply gets a chance to recharge them.
The ceramic decoupling capacitors on and around the CPU are sized to only have enough energy for fractions of a millisecond, of course. If you wanted to power the core for longer than that, you'd need an external backup capacitor - or a few - and a switching power converter to efficiently extract most of the energy from the capacitor.
Surprise, surprise: that's what any switching power supply in a PC already does! If you unplug the mains for a couple of mains line cycles, the power supply will be discharging the DC-link capacitors and powering the CPU cores.
Now, DC-link capacitors aren't usually considered "decoupling" capacitors, but they serve the same function - just at a much longer timescale: milliseconds vs. microseconds. And they aren't surface-mount, but if you really wanted to, you could split the DC-link capacitor into several smaller SMT parts. It'd cost more, but there's nothing fundamentally preventing that.
So, I'd say that the answer to your question is a qualified **yes**: that's how CPUs already work. Without decoupling capacitors, they'd literally lose supply power and reset. |
12,912,114 | I want tov compare previous and new value coming from a loop and based on data increment some rows.For that i am doing like below but the data is getting overwritten since i am doing inside for loop.How can i perform this.
```
for (RecordData recordData : recordDataList) {
prevRespondentId = recordData.getRespondentId();
if (recordData.getRespondentId() != prevRespondentId) {
rowDataNumber++;
}
prevRespondentId = recordData.getRespondentId();
}
```
I have data like 1,2,3 as respondent Id ,i need to see new and prev based on that increment data. | 2012/10/16 | [
"https://Stackoverflow.com/questions/12912114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1636728/"
] | Would this fix your issue?
```
prevRespondentId = recordDataList.get(0).getRespondentId(); //Initialize to first or default value probably -1?
for (RecordData recordData : recordDataList) {
if (recordData.getRespondentId() != prevRespondentId) {
rowDataNumber++;
}
prevRespondentId = recordData.getRespondentId();
}
```
Basically you are overwriting the prevRespondentId even before checking for it, which is causing the issue. | Difficult to understand what your trying to do however perhaps something like this:
```
for (RecordData recordData : recordDataList) {
if (recordData.getRespondentId() != prevRespondentId) {
rowDataNumber++;
}
prevRespondentId = recordData.getRespondentId();
}
```
Basically don't override the preRespondentId until you've done your if check. This will ensure that it will always be the previous respondent id. You'll of course need to initialise it though.
Hope that helps. |
12,912,114 | I want tov compare previous and new value coming from a loop and based on data increment some rows.For that i am doing like below but the data is getting overwritten since i am doing inside for loop.How can i perform this.
```
for (RecordData recordData : recordDataList) {
prevRespondentId = recordData.getRespondentId();
if (recordData.getRespondentId() != prevRespondentId) {
rowDataNumber++;
}
prevRespondentId = recordData.getRespondentId();
}
```
I have data like 1,2,3 as respondent Id ,i need to see new and prev based on that increment data. | 2012/10/16 | [
"https://Stackoverflow.com/questions/12912114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1636728/"
] | Would this fix your issue?
```
prevRespondentId = recordDataList.get(0).getRespondentId(); //Initialize to first or default value probably -1?
for (RecordData recordData : recordDataList) {
if (recordData.getRespondentId() != prevRespondentId) {
rowDataNumber++;
}
prevRespondentId = recordData.getRespondentId();
}
```
Basically you are overwriting the prevRespondentId even before checking for it, which is causing the issue. | ```
..some type.. prevRespondentId = -1;
for (RecordData recordData : recordDataList) {
if (recordData.getRespondentId() != prevRespondentId) {
rowDataNumber++;
}
prevRespondentId = recordData.getRespondentId();
}
``` |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | `ArrayList<?>` simply means "any type." In other words, any type of `ArrayList` can be assigned to such variable. That could be `ArrayList<Integers>`, `ArrayList<JButton>` or anything else. Using the wildcard alone, without the keyword super (followed by a type), means that you cannot **ADD** anything to the list defined as `ArrayList<?>`. `ArrayList` alone however, means the old style type-less `ArrayList` which you can do all sorts of operations including `add`.
```
List<?> list;
List<Integer> ints = new ArrayList<Integer>();
List<Integer> strings = new ArrayList<Integer>();
list = ints; // valid
list = strings; // valid
list.add("new"); // compile error
```
**UPDATE:**
Suppose I have following method:
```
void insert(List list) {
// loop through list, do whatever you like
list.add("my string"); // dangerous operation
}
```
Now if I call `insert(ints)` compiler will generate a warning but will not prevent me of adding a String to a list of integers. Changing method to following:
```
void insert(List<?> list) {
// loop through list, do whatever you like
list.add("my string"); // compiler error on this dangerous operation
}
```
would prevent me of doing such an operation. | ```
ArrayList list = new ArrayList();
```
We are declaring an array list that can accept any type of objects.
For example:
```
list.add(new Dog());
list.add(new Person());
list.add("Test");
```
For `ArrayList<?> list = new ArrayList();`
We are declaring an array list using generics that can accept any object using the wild card **?**
The catch here is that we cannot add elements to that array list.
This code will not even compile:
```
ArrayList<?> list = new ArrayList();
list.add("test");
```
**Update**:
I think the only purpose of the ? wild card in generics is to be coupled by the extends keyword.
```
ArrayList<? extends Animal> list = new ArrayList<Dog>();
```
In that case we add any object to **list** that extends the **Animal** object
or to be passed to as a parameter to a method.
```
public void foo(List<?> list) { }
```
In that case the method **foo** cannot add objects to the parameter **list** |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | `ArrayList<?>` simply means "any type." In other words, any type of `ArrayList` can be assigned to such variable. That could be `ArrayList<Integers>`, `ArrayList<JButton>` or anything else. Using the wildcard alone, without the keyword super (followed by a type), means that you cannot **ADD** anything to the list defined as `ArrayList<?>`. `ArrayList` alone however, means the old style type-less `ArrayList` which you can do all sorts of operations including `add`.
```
List<?> list;
List<Integer> ints = new ArrayList<Integer>();
List<Integer> strings = new ArrayList<Integer>();
list = ints; // valid
list = strings; // valid
list.add("new"); // compile error
```
**UPDATE:**
Suppose I have following method:
```
void insert(List list) {
// loop through list, do whatever you like
list.add("my string"); // dangerous operation
}
```
Now if I call `insert(ints)` compiler will generate a warning but will not prevent me of adding a String to a list of integers. Changing method to following:
```
void insert(List<?> list) {
// loop through list, do whatever you like
list.add("my string"); // compiler error on this dangerous operation
}
```
would prevent me of doing such an operation. | ArrayList < ? > means array list of type unknown. it is called a wildcard type.
Using the wild card, the following occurs
```
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // Compile time error
```
Without the wildcard you can add whatever you like to your array |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | `ArrayList<?>` simply means "any type." In other words, any type of `ArrayList` can be assigned to such variable. That could be `ArrayList<Integers>`, `ArrayList<JButton>` or anything else. Using the wildcard alone, without the keyword super (followed by a type), means that you cannot **ADD** anything to the list defined as `ArrayList<?>`. `ArrayList` alone however, means the old style type-less `ArrayList` which you can do all sorts of operations including `add`.
```
List<?> list;
List<Integer> ints = new ArrayList<Integer>();
List<Integer> strings = new ArrayList<Integer>();
list = ints; // valid
list = strings; // valid
list.add("new"); // compile error
```
**UPDATE:**
Suppose I have following method:
```
void insert(List list) {
// loop through list, do whatever you like
list.add("my string"); // dangerous operation
}
```
Now if I call `insert(ints)` compiler will generate a warning but will not prevent me of adding a String to a list of integers. Changing method to following:
```
void insert(List<?> list) {
// loop through list, do whatever you like
list.add("my string"); // compiler error on this dangerous operation
}
```
would prevent me of doing such an operation. | ```
ArrayList list = new ArrayList();
```
This the non-parameterized container that predates java generics. Objects read out of it usually have to be cast to get what you want.
```
ArrayList<String> list = new ArrayList<String>();
```
Here we we specified that the container holds String objects. No casting is needed to read out.
The
```
<?>
```
is a wildcard parameter meaning "something" such as String, Integer etc.
Note that `ArrayList<?> list = new ArrayList()` is invalid syntax; normally the wildcard would be used on method parameters etc. |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | `ArrayList<?>` simply means "any type." In other words, any type of `ArrayList` can be assigned to such variable. That could be `ArrayList<Integers>`, `ArrayList<JButton>` or anything else. Using the wildcard alone, without the keyword super (followed by a type), means that you cannot **ADD** anything to the list defined as `ArrayList<?>`. `ArrayList` alone however, means the old style type-less `ArrayList` which you can do all sorts of operations including `add`.
```
List<?> list;
List<Integer> ints = new ArrayList<Integer>();
List<Integer> strings = new ArrayList<Integer>();
list = ints; // valid
list = strings; // valid
list.add("new"); // compile error
```
**UPDATE:**
Suppose I have following method:
```
void insert(List list) {
// loop through list, do whatever you like
list.add("my string"); // dangerous operation
}
```
Now if I call `insert(ints)` compiler will generate a warning but will not prevent me of adding a String to a list of integers. Changing method to following:
```
void insert(List<?> list) {
// loop through list, do whatever you like
list.add("my string"); // compiler error on this dangerous operation
}
```
would prevent me of doing such an operation. | There is no difference in the behaviour.
The real difference is in the way that the compiler treats them. In the first case, you are telling the compiler "treat this as a *raw* type" and don't try to do any generic static typing. In the second case, you are saying "treat this as a generic type" ... but that the actual type parameter is "some type that we want to avoid specifying here".
And note that the `<?>` wildcard syntax cannot be used where a definite type is required.
@SJuan76 commented:
>
> "(I guess they didn't add the feature just to get some code to produce compilation errors)"
>
>
>
Well, actually you could say that that *is* that they did. Or more precisely, they left the old form so that old (pre-Java 5) code would continue to compile *without* compilation errors using a Java 5+ compiler. |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | ```
ArrayList list = new ArrayList();
```
We are declaring an array list that can accept any type of objects.
For example:
```
list.add(new Dog());
list.add(new Person());
list.add("Test");
```
For `ArrayList<?> list = new ArrayList();`
We are declaring an array list using generics that can accept any object using the wild card **?**
The catch here is that we cannot add elements to that array list.
This code will not even compile:
```
ArrayList<?> list = new ArrayList();
list.add("test");
```
**Update**:
I think the only purpose of the ? wild card in generics is to be coupled by the extends keyword.
```
ArrayList<? extends Animal> list = new ArrayList<Dog>();
```
In that case we add any object to **list** that extends the **Animal** object
or to be passed to as a parameter to a method.
```
public void foo(List<?> list) { }
```
In that case the method **foo** cannot add objects to the parameter **list** | ArrayList < ? > means array list of type unknown. it is called a wildcard type.
Using the wild card, the following occurs
```
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // Compile time error
```
Without the wildcard you can add whatever you like to your array |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | ```
ArrayList list = new ArrayList();
```
We are declaring an array list that can accept any type of objects.
For example:
```
list.add(new Dog());
list.add(new Person());
list.add("Test");
```
For `ArrayList<?> list = new ArrayList();`
We are declaring an array list using generics that can accept any object using the wild card **?**
The catch here is that we cannot add elements to that array list.
This code will not even compile:
```
ArrayList<?> list = new ArrayList();
list.add("test");
```
**Update**:
I think the only purpose of the ? wild card in generics is to be coupled by the extends keyword.
```
ArrayList<? extends Animal> list = new ArrayList<Dog>();
```
In that case we add any object to **list** that extends the **Animal** object
or to be passed to as a parameter to a method.
```
public void foo(List<?> list) { }
```
In that case the method **foo** cannot add objects to the parameter **list** | ```
ArrayList list = new ArrayList();
```
This the non-parameterized container that predates java generics. Objects read out of it usually have to be cast to get what you want.
```
ArrayList<String> list = new ArrayList<String>();
```
Here we we specified that the container holds String objects. No casting is needed to read out.
The
```
<?>
```
is a wildcard parameter meaning "something" such as String, Integer etc.
Note that `ArrayList<?> list = new ArrayList()` is invalid syntax; normally the wildcard would be used on method parameters etc. |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | ```
ArrayList list = new ArrayList();
```
We are declaring an array list that can accept any type of objects.
For example:
```
list.add(new Dog());
list.add(new Person());
list.add("Test");
```
For `ArrayList<?> list = new ArrayList();`
We are declaring an array list using generics that can accept any object using the wild card **?**
The catch here is that we cannot add elements to that array list.
This code will not even compile:
```
ArrayList<?> list = new ArrayList();
list.add("test");
```
**Update**:
I think the only purpose of the ? wild card in generics is to be coupled by the extends keyword.
```
ArrayList<? extends Animal> list = new ArrayList<Dog>();
```
In that case we add any object to **list** that extends the **Animal** object
or to be passed to as a parameter to a method.
```
public void foo(List<?> list) { }
```
In that case the method **foo** cannot add objects to the parameter **list** | There is no difference in the behaviour.
The real difference is in the way that the compiler treats them. In the first case, you are telling the compiler "treat this as a *raw* type" and don't try to do any generic static typing. In the second case, you are saying "treat this as a generic type" ... but that the actual type parameter is "some type that we want to avoid specifying here".
And note that the `<?>` wildcard syntax cannot be used where a definite type is required.
@SJuan76 commented:
>
> "(I guess they didn't add the feature just to get some code to produce compilation errors)"
>
>
>
Well, actually you could say that that *is* that they did. Or more precisely, they left the old form so that old (pre-Java 5) code would continue to compile *without* compilation errors using a Java 5+ compiler. |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | ```
ArrayList list = new ArrayList();
```
This the non-parameterized container that predates java generics. Objects read out of it usually have to be cast to get what you want.
```
ArrayList<String> list = new ArrayList<String>();
```
Here we we specified that the container holds String objects. No casting is needed to read out.
The
```
<?>
```
is a wildcard parameter meaning "something" such as String, Integer etc.
Note that `ArrayList<?> list = new ArrayList()` is invalid syntax; normally the wildcard would be used on method parameters etc. | ArrayList < ? > means array list of type unknown. it is called a wildcard type.
Using the wild card, the following occurs
```
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // Compile time error
```
Without the wildcard you can add whatever you like to your array |
18,928,217 | I have written a script that is supposed to open up pages, then print them. I had set it up to run a sleep delay to allow the new page to pop up. However, the pages are not loading in a predictable time.
As the pages are loading, there is a message at the bottom of the window that the page is Loading. Once it is loaded, the message is Ready.
I tried finding the info on the window with the HiddenText and window spy, but I could not find a difference between the Loading and Ready versions.
Any ideas where or how else I could look for the difference between the two pages?
Thank you | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2793006/"
] | There is no difference in the behaviour.
The real difference is in the way that the compiler treats them. In the first case, you are telling the compiler "treat this as a *raw* type" and don't try to do any generic static typing. In the second case, you are saying "treat this as a generic type" ... but that the actual type parameter is "some type that we want to avoid specifying here".
And note that the `<?>` wildcard syntax cannot be used where a definite type is required.
@SJuan76 commented:
>
> "(I guess they didn't add the feature just to get some code to produce compilation errors)"
>
>
>
Well, actually you could say that that *is* that they did. Or more precisely, they left the old form so that old (pre-Java 5) code would continue to compile *without* compilation errors using a Java 5+ compiler. | ArrayList < ? > means array list of type unknown. it is called a wildcard type.
Using the wild card, the following occurs
```
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // Compile time error
```
Without the wildcard you can add whatever you like to your array |
250,191 | I have written a plugin for my own site where I have an issue like "after user login to the site if he logout then again if he clicks on browser back button then the previous page showing again instead of login page". Iam trying the below code but it doesn't work.
```
<script>
window.onhashchange = function() {
<?php if( ! is_user_logged_in()) { $this->tewa_login(); } ?>
}
<script>
```
My logout code is below:
```
if ( is_user_logged_in() ) {
$data .= '<li><a class="add-new" href="'. wp_logout_url() .'" class="btn btn-primary" >'.$this->icon_sign_out.' Logout</a></li>';
}
```
Can the below code works or not?
```
function my_redirect(){
<script>
location.reload();
</script>
exit();
}
add_filter('wp_logout','my_redirect');
```
I think this issue totally browser issue not belongs to server. I think just a page refresh that does the trick. I was using 'wp\_logout\_url' for user logout. how to do it can anyone plz tell me? Thanks in advance. | 2016/12/23 | [
"https://wordpress.stackexchange.com/questions/250191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106542/"
] | There's a [**trash post**](https://codex.wordpress.org/Plugin_API/Action_Reference/trash_post) hook
```
add_action( 'trash_post', 'my_func' );
function my_func( $postid ){
// We check if the global post type isn't ours and just return
global $post_type;
if ( $post_type != 'my_custom_post_type' ) return;
// My custom stuff for deleting my custom post type here
}
``` | if you want to to catch it when user delete( means click trash on post)
then possible solution is to use **trash\_post** hook
```
add_action( 'trash_post', 'my_func_before_trash',999,1);
function my_func_before_trash($postid){
//my custom code
}
``` |
40,456,330 | I am trying to set an accordion in multiple tables.
Once user clicks on a `<tr>`, another table shows at the bottom.
HTML
----
```
<table class="table m-0 stocks" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr class="parent-clickable">
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>+</td>
</tr>
<tr class="hidden">
<td colspan="5">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>+</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
```
JS
--
```
$(document).ready(function() {
$("parent-clickable").click(function() {
var text = $(this).closest("tr").find(".hidden").slideToggle(200, "linear");
});
console.log("Clicked");
});
```
[JSFIDDLE](https://jsfiddle.net/1h7pu3uL/) | 2016/11/07 | [
"https://Stackoverflow.com/questions/40456330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6892684/"
] | The reason the 2nd block of code (1st Swift example) prevents you from changing the value of `name` is because in Swift 3, all parameters are constants. In other words they are essentially all declared with `let`.
Imagine your first Swift example as:
```
func greet(let name: String) {
name = "Ardvark"
print(name)
}
```
Obviously you don't really put `let` there but that will help you remember that parameters are immutable. This prevents you from changing the value by mistake. If you want to change it just inside the function, use a new variable:
```
func greet(name: String) {
let anotherName = "Ardvark"
print(anotherName)
}
```
Using `inout` changes the parameter by "removing the let" and allowing you to change the original variable used when calling the function.
>
> How would you modify only the variable 'name' inside the function greet?
>
>
>
You don't in Swift 3. The parameter is immutable. Assign it to a new variable inside the function. | In the `func greet(name: String) {}` function `name` is a constant, actually it looks like `func greet(let name: String) {}` so you can't modify it. Let add a new variable and assign value of `name` to it:
```
func greet(name: String) {
var newName = name
newName = "Ardvark"
print(newName)
}
``` |
40,456,330 | I am trying to set an accordion in multiple tables.
Once user clicks on a `<tr>`, another table shows at the bottom.
HTML
----
```
<table class="table m-0 stocks" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr class="parent-clickable">
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>+</td>
</tr>
<tr class="hidden">
<td colspan="5">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>+</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
```
JS
--
```
$(document).ready(function() {
$("parent-clickable").click(function() {
var text = $(this).closest("tr").find(".hidden").slideToggle(200, "linear");
});
console.log("Clicked");
});
```
[JSFIDDLE](https://jsfiddle.net/1h7pu3uL/) | 2016/11/07 | [
"https://Stackoverflow.com/questions/40456330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6892684/"
] | The reason the 2nd block of code (1st Swift example) prevents you from changing the value of `name` is because in Swift 3, all parameters are constants. In other words they are essentially all declared with `let`.
Imagine your first Swift example as:
```
func greet(let name: String) {
name = "Ardvark"
print(name)
}
```
Obviously you don't really put `let` there but that will help you remember that parameters are immutable. This prevents you from changing the value by mistake. If you want to change it just inside the function, use a new variable:
```
func greet(name: String) {
let anotherName = "Ardvark"
print(anotherName)
}
```
Using `inout` changes the parameter by "removing the let" and allowing you to change the original variable used when calling the function.
>
> How would you modify only the variable 'name' inside the function greet?
>
>
>
You don't in Swift 3. The parameter is immutable. Assign it to a new variable inside the function. | Just read some of the Swift docs. Came to two conclusions.
(1) By default, parameters in Swift are CONSTANTS, so it's as if there is a let keyword before the parameter. Meaning inside the function, the parameter value cannot be changed, or an error will be thrown.
(2) Changing your function to an 'inout' function changes things. First off, it removes the 'let' constraint. Secondly, when you pass in an argument to the inout parameter, it is known as copy-in, copy-out. The argument's value is copied in memory, passed through the function, modified in the function, and the new value is assigned to the original variable that was passed as an argument.
These are two distinct types of functions if you think about it. In other words, there is no functionality like in Javascript where you can simply modify the parameter's value inside the scope of the function ONLY.
Because:
The parameter is either a CONSTANT (by default),
OR...
You are using an inout function, in which case, the parameter is a variable as opposed to a constant, but that parameter only exists for the purpose of 'transferring' an argument's original value into a function where it can be modified, and then spit back out as a new value to the original variable placeholder in memory.
In other words... There is no way (that I know of) in Swift to only modify a parameter's value INSIDE the scope of it's function. You are either prohibited from doing so by default because the parameter is a constant, or you are using an inout function, which isn't modifying the parameter's value inside the function only... It is modifying the GLOBAL namespace's value. |
40,456,330 | I am trying to set an accordion in multiple tables.
Once user clicks on a `<tr>`, another table shows at the bottom.
HTML
----
```
<table class="table m-0 stocks" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr class="parent-clickable">
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>+</td>
</tr>
<tr class="hidden">
<td colspan="5">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>+</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
```
JS
--
```
$(document).ready(function() {
$("parent-clickable").click(function() {
var text = $(this).closest("tr").find(".hidden").slideToggle(200, "linear");
});
console.log("Clicked");
});
```
[JSFIDDLE](https://jsfiddle.net/1h7pu3uL/) | 2016/11/07 | [
"https://Stackoverflow.com/questions/40456330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6892684/"
] | In the `func greet(name: String) {}` function `name` is a constant, actually it looks like `func greet(let name: String) {}` so you can't modify it. Let add a new variable and assign value of `name` to it:
```
func greet(name: String) {
var newName = name
newName = "Ardvark"
print(newName)
}
``` | Just read some of the Swift docs. Came to two conclusions.
(1) By default, parameters in Swift are CONSTANTS, so it's as if there is a let keyword before the parameter. Meaning inside the function, the parameter value cannot be changed, or an error will be thrown.
(2) Changing your function to an 'inout' function changes things. First off, it removes the 'let' constraint. Secondly, when you pass in an argument to the inout parameter, it is known as copy-in, copy-out. The argument's value is copied in memory, passed through the function, modified in the function, and the new value is assigned to the original variable that was passed as an argument.
These are two distinct types of functions if you think about it. In other words, there is no functionality like in Javascript where you can simply modify the parameter's value inside the scope of the function ONLY.
Because:
The parameter is either a CONSTANT (by default),
OR...
You are using an inout function, in which case, the parameter is a variable as opposed to a constant, but that parameter only exists for the purpose of 'transferring' an argument's original value into a function where it can be modified, and then spit back out as a new value to the original variable placeholder in memory.
In other words... There is no way (that I know of) in Swift to only modify a parameter's value INSIDE the scope of it's function. You are either prohibited from doing so by default because the parameter is a constant, or you are using an inout function, which isn't modifying the parameter's value inside the function only... It is modifying the GLOBAL namespace's value. |
133,728 | I'm making a simple test to force a transaction to be reverted, but it just doesn't happen.
I have this function where I intend to limit the `gas` to just 1.
```
contract MyContract {
constructor() payable {}
function pleaseFail(uint256 _guess) public {
(bool sent, ) = msg.sender.call{value: 0.1 ether, gas: 1}("");
require(sent, "Failed do send ether");
}
}
```
I have a test just as simple as possible:
```
describe("Test fail", function () {
it("Should fail", async function () {
const FF = await ethers.getContractFactory("MyContract");
const _f = await ff.deploy({ value: utils.parseEther("0.1") });
await _f.deployed();
_f.pleaseFail(7);
}
}
```
However, when I execute the command line it just doens't fail. What am I missing? Is this some kind of expected behavior for Hardhat?
`npx hardhat test test/myFailure.ts` | 2022/08/16 | [
"https://ethereum.stackexchange.com/questions/133728",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/86152/"
] | Please send the value slightly greater than `0.1` ether and also you have `ff.deploy` where it should be `FF.deploy` and please use assert statements to make sure it behaves as you wish. | ```
it("Should fail", async function () {
const FF = await ethers.getContractFactory("MyContract");
const _f = await FF.deploy({ value: utils.parseEther("0.1") });
await _f.deployed();
await _f.pleaseFail(7);
/*await expect(_f.pleaseFail(7)).revertWith('Failed do send ether')*/
}
``` |
43,932,424 | My Sublime 3 Text Editor looks like this, with 2 panels and no open files. The files I open are shown only in the right part, the left remains empty even when I open multiple files.
[](https://i.stack.imgur.com/Ny1ht.png) | 2017/05/12 | [
"https://Stackoverflow.com/questions/43932424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7970195/"
] | try to do this
view -> layout -> single | Go to sublime text view>layout click on single |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | Erm... is there an instant-client (or any Oracle client) for Linux+ARM at all? I don't see one on the downloads page.
If not, you will have to use ODBC, or another database that has an open-source client you can compile. | Well i'm pretty sure that you'd need the windows version of the Oracle Client if you're running on a windows machine. |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | If you do not have ARM versions of the Oracle library, you're totally out of luck there and would need to get one (perhaps there is a free driver?) or implement the wire protocol manually. | Erm... is there an instant-client (or any Oracle client) for Linux+ARM at all? I don't see one on the downloads page.
If not, you will have to use ODBC, or another database that has an open-source client you can compile. |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | Erm... is there an instant-client (or any Oracle client) for Linux+ARM at all? I don't see one on the downloads page.
If not, you will have to use ODBC, or another database that has an open-source client you can compile. | 1. You need to move the `-L` arguments before the `-l` arguments.
2. You'll need ARM libraries to run on the device, not x86 libraries, no idea if Oracle provides those.
3. You probably don't want to have the device directly accessing the database. It would be better to stick a middle-tier server in the stack, and have the devices talk to that (over XML-RPC or other RPC protocol). |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | How about using java with a jdbc-driver ? Oracle-thin-driver is pure-java so it should work on arm. If you cannot write a pure java-app and need to use other libraries on your arm-device, you can use JNI-calls from java to use native-arm libraries. | Your best chances are either to use Java and the JDBC driver, as suggested by tjin, or completely forget the idea of directly connecting to the database; create a web service on the server and use that instead. |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | If you do not have ARM versions of the Oracle library, you're totally out of luck there and would need to get one (perhaps there is a free driver?) or implement the wire protocol manually. | Well i'm pretty sure that you'd need the windows version of the Oracle Client if you're running on a windows machine. |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | How about using java with a jdbc-driver ? Oracle-thin-driver is pure-java so it should work on arm. If you cannot write a pure java-app and need to use other libraries on your arm-device, you can use JNI-calls from java to use native-arm libraries. | Well i'm pretty sure that you'd need the windows version of the Oracle Client if you're running on a windows machine. |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | If you do not have ARM versions of the Oracle library, you're totally out of luck there and would need to get one (perhaps there is a free driver?) or implement the wire protocol manually. | Your best chances are either to use Java and the JDBC driver, as suggested by tjin, or completely forget the idea of directly connecting to the database; create a web service on the server and use that instead. |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | If you do not have ARM versions of the Oracle library, you're totally out of luck there and would need to get one (perhaps there is a free driver?) or implement the wire protocol manually. | 1. You need to move the `-L` arguments before the `-l` arguments.
2. You'll need ARM libraries to run on the device, not x86 libraries, no idea if Oracle provides those.
3. You probably don't want to have the device directly accessing the database. It would be better to stick a middle-tier server in the stack, and have the devices talk to that (over XML-RPC or other RPC protocol). |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | How about using java with a jdbc-driver ? Oracle-thin-driver is pure-java so it should work on arm. If you cannot write a pure java-app and need to use other libraries on your arm-device, you can use JNI-calls from java to use native-arm libraries. | 1. You need to move the `-L` arguments before the `-l` arguments.
2. You'll need ARM libraries to run on the device, not x86 libraries, no idea if Oracle provides those.
3. You probably don't want to have the device directly accessing the database. It would be better to stick a middle-tier server in the stack, and have the devices talk to that (over XML-RPC or other RPC protocol). |
1,808,994 | So here is the story. I have this device that uses Linux and more open source tools(btw its an **ARM**). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably **Oracle**). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
```
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
```
Linking against **occi, clntsh, thread**;
And setting the library search path, along other stuff to: "**${workspace\_loc:/OracleTest/instantclient\_10\_2}**" that is the directory that holds my **.so** files;
Here is the compilation command:
```
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
```
And here is the error:
```
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
```
And there are a few things that I would like to mention:
1- I'm running **windows** and compiling this for **linux**, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of **eclipse** to develop, specific for that device.
3- I have no idea if I should move those **Oracle** libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
**EDIT**:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two **RISC** distribution but I don't know if they are compatible with **ARM** :
```
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
``` | 2009/11/27 | [
"https://Stackoverflow.com/questions/1808994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/212112/"
] | Erm... is there an instant-client (or any Oracle client) for Linux+ARM at all? I don't see one on the downloads page.
If not, you will have to use ODBC, or another database that has an open-source client you can compile. | Your best chances are either to use Java and the JDBC driver, as suggested by tjin, or completely forget the idea of directly connecting to the database; create a web service on the server and use that instead. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.