qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
|---|---|---|---|---|---|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value would be undefined. When calling func1, its parameters go on the stack. If you call it with 1 parameter less, the stack will be `sizeof(bool)` bytes short of what the process expects. This will not crash your program as your stack and your heap are "facing", but if you try to access to `d`, you will access to whatever value is there on the stack -> rubbish.
|
The value is not just implementation-dependent; the entire behavior of the program is undefined. If you'd put the declaration for `func1` in a header instead of in `file2.c` and you'd include that header in `file1.c`, as is good C practice, the compiler would refuse to compile this.
In practice, you'll likely observe `d` as having some arbitrary, unpredictable value, though your program might also crash mysteriously.
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value is not just implementation-dependent; the entire behavior of the program is undefined. If you'd put the declaration for `func1` in a header instead of in `file2.c` and you'd include that header in `file1.c`, as is good C practice, the compiler would refuse to compile this.
In practice, you'll likely observe `d` as having some arbitrary, unpredictable value, though your program might also crash mysteriously.
|
It can be any value, garbage from the stack I believe if you call the method that way.
The program will have undefined behavior because you really do not know the value of the `bool` parameter. It may also crash during the execution.
Hope it helps.
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value is not just implementation-dependent; the entire behavior of the program is undefined. If you'd put the declaration for `func1` in a header instead of in `file2.c` and you'd include that header in `file1.c`, as is good C practice, the compiler would refuse to compile this.
In practice, you'll likely observe `d` as having some arbitrary, unpredictable value, though your program might also crash mysteriously.
|
It's undefined behavior - it may have garbage value, and it may also crash, depend on the calling convention of your compiler and OS.
Edit: The other arguments may also be mixed, if they are been pushed from left to right.
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value is not just implementation-dependent; the entire behavior of the program is undefined. If you'd put the declaration for `func1` in a header instead of in `file2.c` and you'd include that header in `file1.c`, as is good C practice, the compiler would refuse to compile this.
In practice, you'll likely observe `d` as having some arbitrary, unpredictable value, though your program might also crash mysteriously.
|
This program is **undefined behavior**. As the program is undefined behavior the compiler has the right to refuse to compile it.
>
> (C99, 6.2.7p2) "All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined."
>
>
>
The two function declarations in your program are not compatible; they don't have the same number of parameters.
>
> (C99, 6.7.5.3p15) "For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator; corresponding parameters shall have compatible types."
>
>
>
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value would be undefined. When calling func1, its parameters go on the stack. If you call it with 1 parameter less, the stack will be `sizeof(bool)` bytes short of what the process expects. This will not crash your program as your stack and your heap are "facing", but if you try to access to `d`, you will access to whatever value is there on the stack -> rubbish.
|
It can be any value, garbage from the stack I believe if you call the method that way.
The program will have undefined behavior because you really do not know the value of the `bool` parameter. It may also crash during the execution.
Hope it helps.
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value would be undefined. When calling func1, its parameters go on the stack. If you call it with 1 parameter less, the stack will be `sizeof(bool)` bytes short of what the process expects. This will not crash your program as your stack and your heap are "facing", but if you try to access to `d`, you will access to whatever value is there on the stack -> rubbish.
|
It's undefined behavior - it may have garbage value, and it may also crash, depend on the calling convention of your compiler and OS.
Edit: The other arguments may also be mixed, if they are been pushed from left to right.
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
The value would be undefined. When calling func1, its parameters go on the stack. If you call it with 1 parameter less, the stack will be `sizeof(bool)` bytes short of what the process expects. This will not crash your program as your stack and your heap are "facing", but if you try to access to `d`, you will access to whatever value is there on the stack -> rubbish.
|
This program is **undefined behavior**. As the program is undefined behavior the compiler has the right to refuse to compile it.
>
> (C99, 6.2.7p2) "All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined."
>
>
>
The two function declarations in your program are not compatible; they don't have the same number of parameters.
>
> (C99, 6.7.5.3p15) "For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator; corresponding parameters shall have compatible types."
>
>
>
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
This program is **undefined behavior**. As the program is undefined behavior the compiler has the right to refuse to compile it.
>
> (C99, 6.2.7p2) "All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined."
>
>
>
The two function declarations in your program are not compatible; they don't have the same number of parameters.
>
> (C99, 6.7.5.3p15) "For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator; corresponding parameters shall have compatible types."
>
>
>
|
It can be any value, garbage from the stack I believe if you call the method that way.
The program will have undefined behavior because you really do not know the value of the `bool` parameter. It may also crash during the execution.
Hope it helps.
|
9,176,735
|
Lets say in a file I have some code in two files part of the same project
```
file1.c
int func1(int a, int b, int c, bool d)
{
/* function body */
}
file2.c
extern func1(int a, int b, int c);
/* function call */
func1(runtime1, runtime2, runtime3);
```
What would be value `bool d` takes when being called from file2.c? I know this is really bad practice, but I am maintaining old code and somebody did this, I just want to know the default parameter or if it is implementation dependent. Please note also, that `bool` in this example is a typedef of the software, since this specific project does not support C99. Thank you.!
|
2012/02/07
|
[
"https://Stackoverflow.com/questions/9176735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902144/"
] |
This program is **undefined behavior**. As the program is undefined behavior the compiler has the right to refuse to compile it.
>
> (C99, 6.2.7p2) "All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined."
>
>
>
The two function declarations in your program are not compatible; they don't have the same number of parameters.
>
> (C99, 6.7.5.3p15) "For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator; corresponding parameters shall have compatible types."
>
>
>
|
It's undefined behavior - it may have garbage value, and it may also crash, depend on the calling convention of your compiler and OS.
Edit: The other arguments may also be mixed, if they are been pushed from left to right.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Probably because Luke was half dead from the Emperor nearly killing him with Force lightning.
>
> EMPEROR: Now, young Skywalker...you will die.
>
>
>
[](https://i.stack.imgur.com/nNSwQ.png)
Luke was barely able to help Vader walk to the shuttle itself. I don't think using The Force was an option for that.
|
There’s two components to this as far as I can see:
1. Dramatic license - it’s the writer’s privilege to be able to pick and choose what happens when in order to drive events or add weight to them. In this case seeing Luke nonchalantly skipping along while he casually floated his dad alongside him wouldn’t have been very dramatic.
2. Unlike the sequel trilogy where the Force is portrayed as a toolkit of easily accessed tricks, even for the inexperienced, in the original trilogy every time we see Luke use the Force for substantive effect (think: light sabre retrieval in the Hoth ice cave and, as you point out, levitating 3-PO) we see him enter a state of meditation. True, we see him perform a light sabre retrieval with less focus and effort in Jedi, but this is consistent with his training on Dagobah and further experience with the technique, as compared to that moment on Hoth. The circumstances around his and Vader’s departure from Death Star II were hardly conducive to such meditation, and we’ve never (up to this point) seen Luke able to use Force levitation without entering that calm, focussed, meditative state, let alone whilst engaged in some other activity, even as basic as walking around.
Ultimately however, since it is never explained (i.e. portrayed) how or why he does or does not levitate Vader into the shuttle, any explanation either way can only ever be a subjective opinion.
It is *my* **personal** opinion (*other opinions are available and just as valid*) that what we see in Return of the Jedi is internally consistent with the portrayal of Lukes use of the Force in the previous 2 episodes and that this question only arises because of the **IN**consistency as now portrayed in episodes 7-9 (And to a lesser extent in episodes 1-3), where-in the Force is portrayed as nothing more problematic to wield than a trusty blaster at your side (altho at least in the case of the prequels this is arguably explained by the Force being wielded by fully trained and experienced Jedi).
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Probably because Luke was half dead from the Emperor nearly killing him with Force lightning.
>
> EMPEROR: Now, young Skywalker...you will die.
>
>
>
[](https://i.stack.imgur.com/nNSwQ.png)
Luke was barely able to help Vader walk to the shuttle itself. I don't think using The Force was an option for that.
|
Easiest answer: because it's a film, and it's far more dramatic a moment to show him struggling to drag his father than it would be to have him use the Force. Mind, they could have made his usage of the Force just as much of an exertion, but there's something more personal and tactile about him physically dragging Vader. It's an experience we, as an audience, can directly related to.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Probably because Luke was half dead from the Emperor nearly killing him with Force lightning.
>
> EMPEROR: Now, young Skywalker...you will die.
>
>
>
[](https://i.stack.imgur.com/nNSwQ.png)
Luke was barely able to help Vader walk to the shuttle itself. I don't think using The Force was an option for that.
|
According to the d6 Star Wars RPG (REUP edition, p163)
Telekinesis
Alter Difficulty: Very Easy for objects weighing one kilogram or less; Easy for objects weighing one to ten kilograms; Moderate for objects 11 to 100 kilograms; Difficult for 101 kilograms to one metric ton; Very Difficult for 1,001 kilograms to ten metric tons; Heroic for objects weighing 10,001 kilograms to 100 metric tons.
Object may be moved at 10 meters per round; add +5 per
additional 10 meters per round. The target must be in sight of
the Jedi.
Increased difficulty if object isn’t moving in simple, straight-
line movement:
+ 1 to +5 for gentle turns.
+ 6 to +10 for easy maneuvers.
+11 to +25 or more for complex maneuvers, such as using a levitated lightsaber to attack.
Modified by proximity.
This power may be kept “up”
This would put Luke at a Moderate difficulty (11-15, Vader is 88.9kg) plus a modifier of +6 to +10 for maneuvering, he would likely be at a +2 (close but not touching) for proximity, and +5 if he's rushing (space station blowing up). As pointed out by others, he's been wounded, I would say "wounded twice" giving him a penalty of -2D (Luke has a 10D+2 during RotJ).
All said, Luke needs to roll a 24-28 on 8D+2. Assuming Vader is not resisting and wanting his son to get to safety. If he was, add Vader's Perception (3D+1) or Control (11D+1) roll to the difficulty.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Either Luke *did* use the Force to move Vader's body onto the shuttle, or he didn't *need* to. (Meaning he was physically strong enough to get Vader's body up the ramp and onto the shuttle.) Whichever way it happened, Luke obviously *was* able to get Vader's body onto the shuttle.
Note that in the scene on the Death Star II it wasn't Luke that stopped them from getting on the shuttle, it was Vader. He knew his death was imminent, and he wanted to properly say goodbye to Luke and to see him face to face for the first (and only) time. If Vader gets on the shuttle, there's a chance he dies before they land on the Forest Moon, and he never has a chance to say goodbye to Luke. (And to ask Luke to tell Leia that there *was* still some good in him.)
Luke also manages to get Vader's body off the shuttle and onto the funeral pyre he built. Again either he uses the Force or he doesn't need to. (My bet is on Luke at least using the Force to enhance his strength, since Vader's pretty big compared to him.)
|
There’s two components to this as far as I can see:
1. Dramatic license - it’s the writer’s privilege to be able to pick and choose what happens when in order to drive events or add weight to them. In this case seeing Luke nonchalantly skipping along while he casually floated his dad alongside him wouldn’t have been very dramatic.
2. Unlike the sequel trilogy where the Force is portrayed as a toolkit of easily accessed tricks, even for the inexperienced, in the original trilogy every time we see Luke use the Force for substantive effect (think: light sabre retrieval in the Hoth ice cave and, as you point out, levitating 3-PO) we see him enter a state of meditation. True, we see him perform a light sabre retrieval with less focus and effort in Jedi, but this is consistent with his training on Dagobah and further experience with the technique, as compared to that moment on Hoth. The circumstances around his and Vader’s departure from Death Star II were hardly conducive to such meditation, and we’ve never (up to this point) seen Luke able to use Force levitation without entering that calm, focussed, meditative state, let alone whilst engaged in some other activity, even as basic as walking around.
Ultimately however, since it is never explained (i.e. portrayed) how or why he does or does not levitate Vader into the shuttle, any explanation either way can only ever be a subjective opinion.
It is *my* **personal** opinion (*other opinions are available and just as valid*) that what we see in Return of the Jedi is internally consistent with the portrayal of Lukes use of the Force in the previous 2 episodes and that this question only arises because of the **IN**consistency as now portrayed in episodes 7-9 (And to a lesser extent in episodes 1-3), where-in the Force is portrayed as nothing more problematic to wield than a trusty blaster at your side (altho at least in the case of the prequels this is arguably explained by the Force being wielded by fully trained and experienced Jedi).
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Either Luke *did* use the Force to move Vader's body onto the shuttle, or he didn't *need* to. (Meaning he was physically strong enough to get Vader's body up the ramp and onto the shuttle.) Whichever way it happened, Luke obviously *was* able to get Vader's body onto the shuttle.
Note that in the scene on the Death Star II it wasn't Luke that stopped them from getting on the shuttle, it was Vader. He knew his death was imminent, and he wanted to properly say goodbye to Luke and to see him face to face for the first (and only) time. If Vader gets on the shuttle, there's a chance he dies before they land on the Forest Moon, and he never has a chance to say goodbye to Luke. (And to ask Luke to tell Leia that there *was* still some good in him.)
Luke also manages to get Vader's body off the shuttle and onto the funeral pyre he built. Again either he uses the Force or he doesn't need to. (My bet is on Luke at least using the Force to enhance his strength, since Vader's pretty big compared to him.)
|
Easiest answer: because it's a film, and it's far more dramatic a moment to show him struggling to drag his father than it would be to have him use the Force. Mind, they could have made his usage of the Force just as much of an exertion, but there's something more personal and tactile about him physically dragging Vader. It's an experience we, as an audience, can directly related to.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Either Luke *did* use the Force to move Vader's body onto the shuttle, or he didn't *need* to. (Meaning he was physically strong enough to get Vader's body up the ramp and onto the shuttle.) Whichever way it happened, Luke obviously *was* able to get Vader's body onto the shuttle.
Note that in the scene on the Death Star II it wasn't Luke that stopped them from getting on the shuttle, it was Vader. He knew his death was imminent, and he wanted to properly say goodbye to Luke and to see him face to face for the first (and only) time. If Vader gets on the shuttle, there's a chance he dies before they land on the Forest Moon, and he never has a chance to say goodbye to Luke. (And to ask Luke to tell Leia that there *was* still some good in him.)
Luke also manages to get Vader's body off the shuttle and onto the funeral pyre he built. Again either he uses the Force or he doesn't need to. (My bet is on Luke at least using the Force to enhance his strength, since Vader's pretty big compared to him.)
|
According to the d6 Star Wars RPG (REUP edition, p163)
Telekinesis
Alter Difficulty: Very Easy for objects weighing one kilogram or less; Easy for objects weighing one to ten kilograms; Moderate for objects 11 to 100 kilograms; Difficult for 101 kilograms to one metric ton; Very Difficult for 1,001 kilograms to ten metric tons; Heroic for objects weighing 10,001 kilograms to 100 metric tons.
Object may be moved at 10 meters per round; add +5 per
additional 10 meters per round. The target must be in sight of
the Jedi.
Increased difficulty if object isn’t moving in simple, straight-
line movement:
+ 1 to +5 for gentle turns.
+ 6 to +10 for easy maneuvers.
+11 to +25 or more for complex maneuvers, such as using a levitated lightsaber to attack.
Modified by proximity.
This power may be kept “up”
This would put Luke at a Moderate difficulty (11-15, Vader is 88.9kg) plus a modifier of +6 to +10 for maneuvering, he would likely be at a +2 (close but not touching) for proximity, and +5 if he's rushing (space station blowing up). As pointed out by others, he's been wounded, I would say "wounded twice" giving him a penalty of -2D (Luke has a 10D+2 during RotJ).
All said, Luke needs to roll a 24-28 on 8D+2. Assuming Vader is not resisting and wanting his son to get to safety. If he was, add Vader's Perception (3D+1) or Control (11D+1) roll to the difficulty.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
There’s two components to this as far as I can see:
1. Dramatic license - it’s the writer’s privilege to be able to pick and choose what happens when in order to drive events or add weight to them. In this case seeing Luke nonchalantly skipping along while he casually floated his dad alongside him wouldn’t have been very dramatic.
2. Unlike the sequel trilogy where the Force is portrayed as a toolkit of easily accessed tricks, even for the inexperienced, in the original trilogy every time we see Luke use the Force for substantive effect (think: light sabre retrieval in the Hoth ice cave and, as you point out, levitating 3-PO) we see him enter a state of meditation. True, we see him perform a light sabre retrieval with less focus and effort in Jedi, but this is consistent with his training on Dagobah and further experience with the technique, as compared to that moment on Hoth. The circumstances around his and Vader’s departure from Death Star II were hardly conducive to such meditation, and we’ve never (up to this point) seen Luke able to use Force levitation without entering that calm, focussed, meditative state, let alone whilst engaged in some other activity, even as basic as walking around.
Ultimately however, since it is never explained (i.e. portrayed) how or why he does or does not levitate Vader into the shuttle, any explanation either way can only ever be a subjective opinion.
It is *my* **personal** opinion (*other opinions are available and just as valid*) that what we see in Return of the Jedi is internally consistent with the portrayal of Lukes use of the Force in the previous 2 episodes and that this question only arises because of the **IN**consistency as now portrayed in episodes 7-9 (And to a lesser extent in episodes 1-3), where-in the Force is portrayed as nothing more problematic to wield than a trusty blaster at your side (altho at least in the case of the prequels this is arguably explained by the Force being wielded by fully trained and experienced Jedi).
|
Easiest answer: because it's a film, and it's far more dramatic a moment to show him struggling to drag his father than it would be to have him use the Force. Mind, they could have made his usage of the Force just as much of an exertion, but there's something more personal and tactile about him physically dragging Vader. It's an experience we, as an audience, can directly related to.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
There’s two components to this as far as I can see:
1. Dramatic license - it’s the writer’s privilege to be able to pick and choose what happens when in order to drive events or add weight to them. In this case seeing Luke nonchalantly skipping along while he casually floated his dad alongside him wouldn’t have been very dramatic.
2. Unlike the sequel trilogy where the Force is portrayed as a toolkit of easily accessed tricks, even for the inexperienced, in the original trilogy every time we see Luke use the Force for substantive effect (think: light sabre retrieval in the Hoth ice cave and, as you point out, levitating 3-PO) we see him enter a state of meditation. True, we see him perform a light sabre retrieval with less focus and effort in Jedi, but this is consistent with his training on Dagobah and further experience with the technique, as compared to that moment on Hoth. The circumstances around his and Vader’s departure from Death Star II were hardly conducive to such meditation, and we’ve never (up to this point) seen Luke able to use Force levitation without entering that calm, focussed, meditative state, let alone whilst engaged in some other activity, even as basic as walking around.
Ultimately however, since it is never explained (i.e. portrayed) how or why he does or does not levitate Vader into the shuttle, any explanation either way can only ever be a subjective opinion.
It is *my* **personal** opinion (*other opinions are available and just as valid*) that what we see in Return of the Jedi is internally consistent with the portrayal of Lukes use of the Force in the previous 2 episodes and that this question only arises because of the **IN**consistency as now portrayed in episodes 7-9 (And to a lesser extent in episodes 1-3), where-in the Force is portrayed as nothing more problematic to wield than a trusty blaster at your side (altho at least in the case of the prequels this is arguably explained by the Force being wielded by fully trained and experienced Jedi).
|
According to the d6 Star Wars RPG (REUP edition, p163)
Telekinesis
Alter Difficulty: Very Easy for objects weighing one kilogram or less; Easy for objects weighing one to ten kilograms; Moderate for objects 11 to 100 kilograms; Difficult for 101 kilograms to one metric ton; Very Difficult for 1,001 kilograms to ten metric tons; Heroic for objects weighing 10,001 kilograms to 100 metric tons.
Object may be moved at 10 meters per round; add +5 per
additional 10 meters per round. The target must be in sight of
the Jedi.
Increased difficulty if object isn’t moving in simple, straight-
line movement:
+ 1 to +5 for gentle turns.
+ 6 to +10 for easy maneuvers.
+11 to +25 or more for complex maneuvers, such as using a levitated lightsaber to attack.
Modified by proximity.
This power may be kept “up”
This would put Luke at a Moderate difficulty (11-15, Vader is 88.9kg) plus a modifier of +6 to +10 for maneuvering, he would likely be at a +2 (close but not touching) for proximity, and +5 if he's rushing (space station blowing up). As pointed out by others, he's been wounded, I would say "wounded twice" giving him a penalty of -2D (Luke has a 10D+2 during RotJ).
All said, Luke needs to roll a 24-28 on 8D+2. Assuming Vader is not resisting and wanting his son to get to safety. If he was, add Vader's Perception (3D+1) or Control (11D+1) roll to the difficulty.
|
225,361
|
On *Star Wars Episode VI: Return of the Jedi* we see Darth Vader dying next to an Imperial shuttle as he speaks with Luke. Why didn't Luke use the Force to move Vader onto the shuttle? I assume he was capable of this since he moved C-3PO around with the Force earlier in the film.
|
2020/01/02
|
[
"https://scifi.stackexchange.com/questions/225361",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/89214/"
] |
Easiest answer: because it's a film, and it's far more dramatic a moment to show him struggling to drag his father than it would be to have him use the Force. Mind, they could have made his usage of the Force just as much of an exertion, but there's something more personal and tactile about him physically dragging Vader. It's an experience we, as an audience, can directly related to.
|
According to the d6 Star Wars RPG (REUP edition, p163)
Telekinesis
Alter Difficulty: Very Easy for objects weighing one kilogram or less; Easy for objects weighing one to ten kilograms; Moderate for objects 11 to 100 kilograms; Difficult for 101 kilograms to one metric ton; Very Difficult for 1,001 kilograms to ten metric tons; Heroic for objects weighing 10,001 kilograms to 100 metric tons.
Object may be moved at 10 meters per round; add +5 per
additional 10 meters per round. The target must be in sight of
the Jedi.
Increased difficulty if object isn’t moving in simple, straight-
line movement:
+ 1 to +5 for gentle turns.
+ 6 to +10 for easy maneuvers.
+11 to +25 or more for complex maneuvers, such as using a levitated lightsaber to attack.
Modified by proximity.
This power may be kept “up”
This would put Luke at a Moderate difficulty (11-15, Vader is 88.9kg) plus a modifier of +6 to +10 for maneuvering, he would likely be at a +2 (close but not touching) for proximity, and +5 if he's rushing (space station blowing up). As pointed out by others, he's been wounded, I would say "wounded twice" giving him a penalty of -2D (Luke has a 10D+2 during RotJ).
All said, Luke needs to roll a 24-28 on 8D+2. Assuming Vader is not resisting and wanting his son to get to safety. If he was, add Vader's Perception (3D+1) or Control (11D+1) roll to the difficulty.
|
106,301
|
what slope should an outside slab have which will have artificial grass glued to it?The slab is joined to a glass covered conservatory
|
2017/01/11
|
[
"https://diy.stackexchange.com/questions/106301",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/64986/"
] |
Default minimum drainage slope for "flat" surfaces is 1/8" per foot.
*Bring on the short answer complaint robot!*
|
I m a professional grass installer. As per My opinion,In most cases, you should not need a drainage system when buying artificial turf. This is because the artificial turf has its own drainage solution, very effective.
Good quality synthetic turf is designed to be a completely permeable surface, allowing water to flow into the grass. But, it depends on how it is installed.
Most reputable installers will complete a full excavation of the existing surface before installing a fully porous system at the base of the floor. The amount of permeable subbase applied will depend on the quality of your drainage.
By saying this, this installation method can solve most drainage problems. You can read our article on the blog to learn more about why artificial turf is so effective in solving drainage problems in the garden.
|
19,263,749
|
*FIRST OFF: Yes, I know that the best way in general to do singletons in Java is with `enum`s, but if for some reason you need to subclass a singleton class, you can't use enums, so...*
David Geary at JavaWorld published an article a long time ago on implementing singletons in Java. He argued that the following optimization to a thread-safe singleton implementation is problematic:
```
public static Singleton getInstance()
{
if (singleton == null)
{
synchronized(Singleton.class)
{
if(singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}
```
(See more at: <http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html?page=4#sthash.G8lzWOfT.dpuf>)
Geary says that this 'double-checked locking' optimization
>
> is not guaranteed to work because the compiler is free to assign a
> value to the singleton member variable before the singleton's
> constructor is called. If that happens, Thread 1 can be preempted
> after the singleton reference has been assigned, but before the
> singleton is initialized, so Thread 2 can return a reference to an
> uninitialized singleton instance.
>
>
>
My question: Is the following change going to fix that problem or not? I've started reading Goetz's Java concurrency book and it seems that the compiler is allowed to shuffle within-thread operations, so I am not quite confident...Still, it seems to me that `singleton = temp;` is an atomic operation, in which case I think it should. Please explain.
```
public static Singleton getInstance()
{
if (singleton == null)
{
synchronized(Singleton.class)
{
if(singleton == null) {
Singleton temp = new Singleton();
singleton = temp;
}
}
}
return singleton;
}
```
|
2013/10/09
|
[
"https://Stackoverflow.com/questions/19263749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1575673/"
] |
The second code is sequentially consistent with the first code (they are strictly equivalent in a single threaded environment) and does not introduce any additional memory synchronisation points.
So yes, a compiler is authorised to rewrite the second code and turn it into the first one which means it is unsafe too.
The fact that `singleton = temp;` is atomic doesn't help here. It only means that singleton is either null or holds the same reference as temp. But that does not preclude temp/singleton from pointing to a "non-constructed" object.
The Java Memory Model works in terms of happens-before (HB) relationships. In both codes there is only one hb: the exit of the synchronized block hb a subsequent entry into that block. `if (singleton == null)` does not share any hb relationship with `singleton=…` so the reordering can happen.
The bottom line is that the only way to fix it is to introduce a hb between the two statements: by moving the if inside the synchronized block or by marking singleton volatile for example.
|
Deleted as wrong, keeping the empty answer for its discussions. Wow, live and learn!
|
19,263,749
|
*FIRST OFF: Yes, I know that the best way in general to do singletons in Java is with `enum`s, but if for some reason you need to subclass a singleton class, you can't use enums, so...*
David Geary at JavaWorld published an article a long time ago on implementing singletons in Java. He argued that the following optimization to a thread-safe singleton implementation is problematic:
```
public static Singleton getInstance()
{
if (singleton == null)
{
synchronized(Singleton.class)
{
if(singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}
```
(See more at: <http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html?page=4#sthash.G8lzWOfT.dpuf>)
Geary says that this 'double-checked locking' optimization
>
> is not guaranteed to work because the compiler is free to assign a
> value to the singleton member variable before the singleton's
> constructor is called. If that happens, Thread 1 can be preempted
> after the singleton reference has been assigned, but before the
> singleton is initialized, so Thread 2 can return a reference to an
> uninitialized singleton instance.
>
>
>
My question: Is the following change going to fix that problem or not? I've started reading Goetz's Java concurrency book and it seems that the compiler is allowed to shuffle within-thread operations, so I am not quite confident...Still, it seems to me that `singleton = temp;` is an atomic operation, in which case I think it should. Please explain.
```
public static Singleton getInstance()
{
if (singleton == null)
{
synchronized(Singleton.class)
{
if(singleton == null) {
Singleton temp = new Singleton();
singleton = temp;
}
}
}
return singleton;
}
```
|
2013/10/09
|
[
"https://Stackoverflow.com/questions/19263749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1575673/"
] |
The second code is sequentially consistent with the first code (they are strictly equivalent in a single threaded environment) and does not introduce any additional memory synchronisation points.
So yes, a compiler is authorised to rewrite the second code and turn it into the first one which means it is unsafe too.
The fact that `singleton = temp;` is atomic doesn't help here. It only means that singleton is either null or holds the same reference as temp. But that does not preclude temp/singleton from pointing to a "non-constructed" object.
The Java Memory Model works in terms of happens-before (HB) relationships. In both codes there is only one hb: the exit of the synchronized block hb a subsequent entry into that block. `if (singleton == null)` does not share any hb relationship with `singleton=…` so the reordering can happen.
The bottom line is that the only way to fix it is to introduce a hb between the two statements: by moving the if inside the synchronized block or by marking singleton volatile for example.
|
The answer depends on optimization which can be applied for the second code by compiler (it means that second one can be transformed to first one by compiler). You can write the code using AtomicReference which will allow to avoid the problem:
```
private static AtomicReference<Singleton> singleton = new AtomicReference<Singleton>(null);
...
public static Singleton getInstance()
{
if (singleton.get() == null)
{
synchronized(Singleton.class)
{
if(singleton.get() == null) {
singleton.compareAndSet(null, new Singleton());
}
}
}
return singleton.get();
}
```
|
19,263,749
|
*FIRST OFF: Yes, I know that the best way in general to do singletons in Java is with `enum`s, but if for some reason you need to subclass a singleton class, you can't use enums, so...*
David Geary at JavaWorld published an article a long time ago on implementing singletons in Java. He argued that the following optimization to a thread-safe singleton implementation is problematic:
```
public static Singleton getInstance()
{
if (singleton == null)
{
synchronized(Singleton.class)
{
if(singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}
```
(See more at: <http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html?page=4#sthash.G8lzWOfT.dpuf>)
Geary says that this 'double-checked locking' optimization
>
> is not guaranteed to work because the compiler is free to assign a
> value to the singleton member variable before the singleton's
> constructor is called. If that happens, Thread 1 can be preempted
> after the singleton reference has been assigned, but before the
> singleton is initialized, so Thread 2 can return a reference to an
> uninitialized singleton instance.
>
>
>
My question: Is the following change going to fix that problem or not? I've started reading Goetz's Java concurrency book and it seems that the compiler is allowed to shuffle within-thread operations, so I am not quite confident...Still, it seems to me that `singleton = temp;` is an atomic operation, in which case I think it should. Please explain.
```
public static Singleton getInstance()
{
if (singleton == null)
{
synchronized(Singleton.class)
{
if(singleton == null) {
Singleton temp = new Singleton();
singleton = temp;
}
}
}
return singleton;
}
```
|
2013/10/09
|
[
"https://Stackoverflow.com/questions/19263749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1575673/"
] |
The answer depends on optimization which can be applied for the second code by compiler (it means that second one can be transformed to first one by compiler). You can write the code using AtomicReference which will allow to avoid the problem:
```
private static AtomicReference<Singleton> singleton = new AtomicReference<Singleton>(null);
...
public static Singleton getInstance()
{
if (singleton.get() == null)
{
synchronized(Singleton.class)
{
if(singleton.get() == null) {
singleton.compareAndSet(null, new Singleton());
}
}
}
return singleton.get();
}
```
|
Deleted as wrong, keeping the empty answer for its discussions. Wow, live and learn!
|
68,136,549
|
I'm new to using bounded types in Java, and I'm not sure if the following is a programming error because of a bad use of inheritance or a `javac` bug
---
I need to define two different type of objects: things which have to be managed and managers of that things. That's why I created an abstract class to model the common behavior of those things
```java
public abstract class AbstractThing {
// Common method implemented
public void hello() {
System.out.println("HI, I'm AbstractThing");
}
}
```
and an interface to define the methods that those things' manager must implement
```java
public interface AbstractManager {
// Operation that a things' manager must implement
public <T extends AbstractThing> void greet(T t);
}
```
---
So suppose I create two concrete things classes, one of them just inherits the abstract one:
```java
public class Thing extends AbstractThing {
// Constructor
public Thing() {}
}
```
but the other one implements an own method:
```java
public class AnotherThing extends AbstractThing {
// Constructor
public AnotherThing() {}
// Extra method which this class implements
public void goodbye() {
System.out.println("BYE, I'm AnotherThing");
}
}
```
---
But when I define a manager as follows:
```java
public class Manager implements AbstractManager {
// Constructor method
public Manager() {}
// Implementation of the interface's method fails
@Override
public <AnotherThing extends AbstractThing>
void greet(AnotherThing t) {
// I can use this method, which AnotherThing inherits from AbstractThing
t.hello();
// But I can't use this one defined by AnotherThing
t.goodbye();
}
}
```
I get the error:
```
AnotherManager.java:15: error: cannot find symbol
t.goodbye();
^
symbol: method goodbye()
location: variable t of type AnotherThing
where AnotherThing is a type-variable:
AnotherThing extends AbstractThing declared in method <AnotherThing>greet(AnotherThing)
1 error
```
And I don't understand why, because it's recognizing the class as `AnotherThing`, but it's dealing it as `AbstractThing`. I've tried to cast the object as the subclass, but it doesn't work
I've also checked that it only happens when I try to access the subtype methods, because the following manager compile and works perfectly:
```java
public class Manager implements AbstractManager {
// Constructor method
public Manager() {}
// Implementation of the method defined into the interface
@Override
public <Thing extends AbstractThing>
void greet(Thing t) {
t.hello();
}
// I can overload the method "greet" without overriding the interface
// and it works for AnotherThing
public void greet(AnotherThing t) {
t.hello();
t.goodbye();
}
}
```
Any idea about what's happening there?
|
2021/06/25
|
[
"https://Stackoverflow.com/questions/68136549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16301351/"
] |
>
> So how are the elements magically sorted?
>
>
>
They are not "sorted".
They are arranged in such a way that the element that should be at the ["top"](https://en.cppreference.com/w/cpp/container/priority_queue/top) is at the correct location. Other elements are **not** guaranteed to be sorted. Instead, they are arranged in what is known as a [heap](https://en.wikipedia.org/wiki/Heap_(data_structure)).
**Put another way**, a [`std::priority_queue`](https://en.cppreference.com/w/cpp/container/priority_queue) is a container optimized to provide fast access to the object that logically belongs in the "top", with the assumption that other elements won't be accessed until they belong at the top.
That "other elements won't be accessed" condition is what allows an organization that is faster than complete sorting.
>
> And even if there is something how is it happening in linear time?
>
>
>
If you're referring to insertions/deletions, it actually does it in **logarithmic time**.
In logarithmic time, it is guaranteed that the front item is at the correct position, while all other items are guaranteed to form a valid heap. This doesn't take long if the data was already a heap prior to insertion/deletion.
|
>
> I noticed that `std::priority_queue` stores the elements in sorted manner.
>
>
>
This isn't true.
`std::priority_queue` can provide the elements in order, but they are not sorted. The operation of poping does work more than just "take the top element".
Insertion and extraction requires logarithmic time.
Setup of a batch of elements takes linear time.
The trick is that the priority queue uses a data structure known as, or complexity equivalent to, "a heap". This is not to be confused with the colloquial name C/C++ programmers give the "free store" of memory that `malloc` and `new` allocate from.
A heap is not sorted in the way you might think. It is arranged so that, as you grab elements from it, you know where the largest (or smallest) element is, and you can get the next largest element in logarithmic time.
A really, really naive way to think of this is to imagine a binary tree, where each of the children are guaranteed to be less than the parent.
The largest element is the root. When you eliminate the root, you know that the next largest element is either the left or right child of the root; check, and promote it.
This isn't *exactly* how a heap works, but it gives you an intuitive way to understand why it is plausible it works.
The magic of the "heap" is being able to do this in a random access buffer without moving too much stuff around in logarithmic time, and take an unsorted set of items in that same random access buffer and arrange it into a "heap" inplace in linear time.
The wikipedia article for [Heap](https://en.wikipedia.org/wiki/Heap_(data_structure)) isn't that bad. If you want to know more, that or a good undergrad data structure's textbook is a good thing to look at.
|
28,098,939
|
We enable/disable all our cells based on an external scope like so:
```
cellEditableCondition: function ($scope) {return $scope.getExternalScopes().view.isEditing;},
```
You have to include the cellNav module on the grid element witch seems to automatically enable it, like so:
```
<div data-ui-grid="gridOptions" class="search-grid" data-ui-grid-selection ui-grid-edit ui-grid-cellNav external-scopes="externalScopes"></div>
```
We want to disable cellNav when isEditing is false and allow row selection. How do we achieve this?
|
2015/01/22
|
[
"https://Stackoverflow.com/questions/28098939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2371360/"
] |
Your Column definition should be like this
```
cellEditableCondition: function ($scope) {return $scope.view.isEditing;},
```
|
A lot of the grid functions aren't quite so dynamic as you're imagining - cellNav is generally present or not present.
However, the way you describe it, I sort of get the impression that isEditing might be for the whole page, rather than some sort of row by row thing. If that's the case, then you're really talking about turning cellNav and row select on and off for the whole grid. If so, I'd use `gridOptions.enableCellNav` and `gridOptions.enableEditing` when you first render the page.
|
1,164,693
|
If I have the a uniform distribution defined that depends on another uniform distribution how can I calculate what the probability density function is?
For example, Let $(X|Y=y)$ be a random variable uniformly distributed over $[0,y]$. Given that $Y$ is uniformly distributed over $[0,1]$ what is the density function of (X,Y) ?
|
2015/02/25
|
[
"https://math.stackexchange.com/questions/1164693",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/219160/"
] |
Let's prove by induction that $\sum\limits\_{k=1}^{n}{k}\cdot{k!}=(n+1)!-1$.
---
**First, show that this is true for $n=1$:**
* $\sum\limits\_{k=1}^{1}{k}\cdot{k!}=(1+1)!-1$
**Second, assume that this is true for $n$:**
* $\sum\limits\_{k=1}^{n}{k}\cdot{k!}=(n+1)!-1$
**Third, prove that this is true for $n+1$:**
* $\sum\limits\_{k=1}^{n+1}{k}\cdot{k!}=$
* $\color{red}{\sum\limits\_{k=1}^{n}{k}\cdot{k!}}+{(n+1)}\cdot{(n+1)!}=$
* $\color{red}{(n+1)!-1}+{(n+1)}\cdot{(n+1)!}=$
* $(n+1)!\cdot(n+2)-1=$
* $(n+2)!-1$
---
Please note that the assumption is used only in the part marked red.
|
**Hint**
See that
$$(n+2)! - (n+1)! = (n+1)(n+1)!$$
And use induction.
|
1,164,693
|
If I have the a uniform distribution defined that depends on another uniform distribution how can I calculate what the probability density function is?
For example, Let $(X|Y=y)$ be a random variable uniformly distributed over $[0,y]$. Given that $Y$ is uniformly distributed over $[0,1]$ what is the density function of (X,Y) ?
|
2015/02/25
|
[
"https://math.stackexchange.com/questions/1164693",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/219160/"
] |
**Hint**
See that
$$(n+2)! - (n+1)! = (n+1)(n+1)!$$
And use induction.
|
Note that $(k+1)!=k!(k+1) \Rightarrow k!k=(k+1)!-k!$. Use this in your sum to find:
$$
\sum\_{k=1}^n k!k= (2!-1!)+(3!-2!)+(4!-3!)+\cdots + (n+1)!-n!
$$
and eliminating opposite terms you have the result.
|
1,164,693
|
If I have the a uniform distribution defined that depends on another uniform distribution how can I calculate what the probability density function is?
For example, Let $(X|Y=y)$ be a random variable uniformly distributed over $[0,y]$. Given that $Y$ is uniformly distributed over $[0,1]$ what is the density function of (X,Y) ?
|
2015/02/25
|
[
"https://math.stackexchange.com/questions/1164693",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/219160/"
] |
Let's prove by induction that $\sum\limits\_{k=1}^{n}{k}\cdot{k!}=(n+1)!-1$.
---
**First, show that this is true for $n=1$:**
* $\sum\limits\_{k=1}^{1}{k}\cdot{k!}=(1+1)!-1$
**Second, assume that this is true for $n$:**
* $\sum\limits\_{k=1}^{n}{k}\cdot{k!}=(n+1)!-1$
**Third, prove that this is true for $n+1$:**
* $\sum\limits\_{k=1}^{n+1}{k}\cdot{k!}=$
* $\color{red}{\sum\limits\_{k=1}^{n}{k}\cdot{k!}}+{(n+1)}\cdot{(n+1)!}=$
* $\color{red}{(n+1)!-1}+{(n+1)}\cdot{(n+1)!}=$
* $(n+1)!\cdot(n+2)-1=$
* $(n+2)!-1$
---
Please note that the assumption is used only in the part marked red.
|
Note that $(k+1)!=k!(k+1) \Rightarrow k!k=(k+1)!-k!$. Use this in your sum to find:
$$
\sum\_{k=1}^n k!k= (2!-1!)+(3!-2!)+(4!-3!)+\cdots + (n+1)!-n!
$$
and eliminating opposite terms you have the result.
|
52,475,846
|
So I have 2 types of dates in my db, `date (yyyy-mm-dd)` and `datetimeoffset (yyyy-mm-ddThh:mm:ss.ms+Z)`, and I was wondering what is the best practice to deal with it when I'm taking the data from the DB and passing it as a json to the UI/mobile.
I used to always parse dates to `datetimeoffset` so normal dates will be something like `2018-09-24T00:00:00.000+00:00` instead of simply `2018-09-24` but it works perfectly with `datetimeoffset` that are already saved like that in the DB
|
2018/09/24
|
[
"https://Stackoverflow.com/questions/52475846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7999749/"
] |
In multiple ways you can handle this situation.
1 : From API side always give predefined date format value
Example `yyyy-mm-ddThh:mm:ss.ms+Z`
And from the client side based on conditions you can convert it.
2: Keep different View models/ Properties may be for storing `yyyy-mm-dd` you can give `string` data type and for `yyyy-mm-ddThh:mm:ss.ms+Z` just `DateTime` . and based on your db you can write a condition and map the particular data.
3: Keep a single property for returning the date and make it as `string`
Example : `Public string CurrentDate{get;set;}` and you can simply map the database values(Conversion should be done). In this case client no need to worry about the date conversions they can simply show what ever you are passing from the api.
Note : The method 3 is not preferable because in the case in some places the user may see `yyyy-mm-dd` in some other places `yyyy-mm-ddThh:mm:ss.ms+Z`.
|
Take a look at [SQL Server Data Type Mappings](https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mapping)
You will see that SQL Server's `Date`, `DateTime` and `DateTime2` all map to .Net's `DateTime` data type,
and `DateTimeOffset` maps to `DateTimeOffset`.
>
>
> ```
> SQL Server Database Engine type .NET Framework type
> date (SQL Server 2008 and later) DateTime
> datetime DateTime
> datetime2 (SQL Server 2008 and later) DateTime
> datetimeoffset (SQL Server 2008 and later) DateTimeOffset
>
> ```
>
>
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
have you tryed to install ntfs-3g to access the ntfs partition. also I think since windows still did a fast Startup i would try to do a reboot on windows to windows and try again ... and i think that a cache clean up might fix it.
|
By changing the permission in Windows 8 you can fix this problem. I have faced same problem as you faced. It is solved after providing the full access to the all user. I do not have any idea to the other consequences in Windows by doing this.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
I solved this problem by running `powercfg /h off` in windows command terminal. This command usually disable windows hibernate permanently. I follow [this instruction](http://www.hecticgeek.com/2012/12/disable-hibernation-windows-8/) and now I have full access of windows partition.
|
have you tryed to install ntfs-3g to access the ntfs partition. also I think since windows still did a fast Startup i would try to do a reboot on windows to windows and try again ... and i think that a cache clean up might fix it.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
The procedure of disabling the fast startup will stop win from storing metadata on all of the accessible hard-disks, but it doesn't get deleted right-away.
You need to run
```
ntfsfix /dev/sdXY
```
where X is the volume letter e.g. b, if it's the secondary hard-disk and Y is the partition number e.g. 2 if it's the second partition.
That should make you able to mount it just fine.
|
have you tryed to install ntfs-3g to access the ntfs partition. also I think since windows still did a fast Startup i would try to do a reboot on windows to windows and try again ... and i think that a cache clean up might fix it.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
If you're able to boot to the Windows login screen, you should be able to get around this by clicking the power menu in the lower right, holding down the Shift key, and clicking Shut Down. Just hold down shift until the machine fully powers off.
This should force a "full shutdown" from Windows, without requiring any login password. You should then be able to mount the Windows volume from your Linux instance without any errors.
|
have you tryed to install ntfs-3g to access the ntfs partition. also I think since windows still did a fast Startup i would try to do a reboot on windows to windows and try again ... and i think that a cache clean up might fix it.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
I solved this problem by running `powercfg /h off` in windows command terminal. This command usually disable windows hibernate permanently. I follow [this instruction](http://www.hecticgeek.com/2012/12/disable-hibernation-windows-8/) and now I have full access of windows partition.
|
By changing the permission in Windows 8 you can fix this problem. I have faced same problem as you faced. It is solved after providing the full access to the all user. I do not have any idea to the other consequences in Windows by doing this.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
The procedure of disabling the fast startup will stop win from storing metadata on all of the accessible hard-disks, but it doesn't get deleted right-away.
You need to run
```
ntfsfix /dev/sdXY
```
where X is the volume letter e.g. b, if it's the secondary hard-disk and Y is the partition number e.g. 2 if it's the second partition.
That should make you able to mount it just fine.
|
By changing the permission in Windows 8 you can fix this problem. I have faced same problem as you faced. It is solved after providing the full access to the all user. I do not have any idea to the other consequences in Windows by doing this.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
If you're able to boot to the Windows login screen, you should be able to get around this by clicking the power menu in the lower right, holding down the Shift key, and clicking Shut Down. Just hold down shift until the machine fully powers off.
This should force a "full shutdown" from Windows, without requiring any login password. You should then be able to mount the Windows volume from your Linux instance without any errors.
|
By changing the permission in Windows 8 you can fix this problem. I have faced same problem as you faced. It is solved after providing the full access to the all user. I do not have any idea to the other consequences in Windows by doing this.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
I solved this problem by running `powercfg /h off` in windows command terminal. This command usually disable windows hibernate permanently. I follow [this instruction](http://www.hecticgeek.com/2012/12/disable-hibernation-windows-8/) and now I have full access of windows partition.
|
The procedure of disabling the fast startup will stop win from storing metadata on all of the accessible hard-disks, but it doesn't get deleted right-away.
You need to run
```
ntfsfix /dev/sdXY
```
where X is the volume letter e.g. b, if it's the secondary hard-disk and Y is the partition number e.g. 2 if it's the second partition.
That should make you able to mount it just fine.
|
457,226
|
I've been using VLC with command line batch files for years to rip audio cds.
I just tried writing a similar bash script in Ubuntu 14.04 and was surprised--I can't figure out how to get a list of file names on the CD to pass to VLC Media Player to convert. I need something like:
```
FILES=/path/to/*.cda
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
call_my_vlc_function( $f)
done
```
Is there a 'trick' to getting a list of files on an audio cd in Ubuntu for use in a bash script or is this just not possible? I've already read a number of articles on how the gvfs system is different from a 'real' file system, but I'm just amazed that there is something Windows can do so trivially which can't be done in bash.
TIA,
---JC
|
2014/04/28
|
[
"https://askubuntu.com/questions/457226",
"https://askubuntu.com",
"https://askubuntu.com/users/258320/"
] |
I solved this problem by running `powercfg /h off` in windows command terminal. This command usually disable windows hibernate permanently. I follow [this instruction](http://www.hecticgeek.com/2012/12/disable-hibernation-windows-8/) and now I have full access of windows partition.
|
If you're able to boot to the Windows login screen, you should be able to get around this by clicking the power menu in the lower right, holding down the Shift key, and clicking Shut Down. Just hold down shift until the machine fully powers off.
This should force a "full shutdown" from Windows, without requiring any login password. You should then be able to mount the Windows volume from your Linux instance without any errors.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
You can run a winforms application as a service, you just won't be able to see it-- it will be displayed on a so-called virtual desktop, which can't be viewed on your monitor.
|
The only way to even consider this is to make sure that the application has no UI elements to it, as you have to jump through hoops on a non-Vista machine to make this work, and on Vista, you can't interact with the desktop at all.
Rather, you would be best off refactoring out the functionality into a set of shared libraries, and then create a service that uses those libraries, and install that at the client.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
(This answer is obsolete, since the linked article was deleted in 2012. However, StackOverflow does not allow the accepted answer to be deleted. So, kindly do not downvote this answer, since I have informed you that it is obsolete.)
Alt link:
<https://web.archive.org/web/20111221041348/http://www.codeproject.com/kb/system/xyntservice.aspx>
C++ source (Or use the Browse Code tab on the article): <https://web.archive.org/web/20111228050501/http://www.codeproject.com/KB/system/xyntservice.aspx>
>
> Unfortunately, the Zip file source code download does not work within the alternative links.
>
>
>
Start Your Windows Programs From An NT Service
----------------------------------------------
Check this article out: <http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=719&av=49654>
It's a really old article, but it has worked for 8 years and it continues to be kept up to date by the author.
It will do what you want to do.
|
You may also want to consider [AlwaysUp](http://www.coretechnologies.com/products/AlwaysUp/), a commercial application that will run any application as a Windows Service. It is similar to XYNTService (mentioned by EnocNRoll), but has more features and is fully supported.
Good luck!
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
(This answer is obsolete, since the linked article was deleted in 2012. However, StackOverflow does not allow the accepted answer to be deleted. So, kindly do not downvote this answer, since I have informed you that it is obsolete.)
Alt link:
<https://web.archive.org/web/20111221041348/http://www.codeproject.com/kb/system/xyntservice.aspx>
C++ source (Or use the Browse Code tab on the article): <https://web.archive.org/web/20111228050501/http://www.codeproject.com/KB/system/xyntservice.aspx>
>
> Unfortunately, the Zip file source code download does not work within the alternative links.
>
>
>
Start Your Windows Programs From An NT Service
----------------------------------------------
Check this article out: <http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=719&av=49654>
It's a really old article, but it has worked for 8 years and it continues to be kept up to date by the author.
It will do what you want to do.
|
If you have a nice decoupled functionality in you forms application, it should be straightforward to create a service class with its installer and then launch your processor class in the OnStart method of the service:
```
protected override void OnStart(string[] args)
{
Processor processor = new Processor();
Thread workerThread = new Thread(processor.OnStart);
workerThread.IsBackground = true;
try
{
workerThread.Start();
}
catch
{
//...
}
}
```
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
You may also want to consider [AlwaysUp](http://www.coretechnologies.com/products/AlwaysUp/), a commercial application that will run any application as a Windows Service. It is similar to XYNTService (mentioned by EnocNRoll), but has more features and is fully supported.
Good luck!
|
Found this [article](http://support.microsoft.com/kb/137890) called **How To Create a User-Defined Service**.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
If you are sure the application can run unattended safely (by this I mean it can ***never*** throw up a modal UI element like a Message Box) and it doesn't need any interaction until shutdown, where it will simply be terminated, then run it as a scheduled task with the trigger set to system start up.
If it can run unattended but it may need to be shutdown and restarted manually or it can't just be terminated at shutdown then use the XYNTService as recommended by [EnocNRoll](https://stackoverflow.com/questions/463073/run-windows-forms-application-as-service#463117). It's a horrible hack but it will work for what you want.
But by far the best solution is to separate the functionality of your program from the User Interface and write a proper service. And for a production server I wouldn't allow anything else. If it isn't easy to separate then you have some design issues you should look into anyway.
|
Found this [article](http://support.microsoft.com/kb/137890) called **How To Create a User-Defined Service**.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
You can run a winforms application as a service, you just won't be able to see it-- it will be displayed on a so-called virtual desktop, which can't be viewed on your monitor.
|
Found this [article](http://support.microsoft.com/kb/137890) called **How To Create a User-Defined Service**.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
(This answer is obsolete, since the linked article was deleted in 2012. However, StackOverflow does not allow the accepted answer to be deleted. So, kindly do not downvote this answer, since I have informed you that it is obsolete.)
Alt link:
<https://web.archive.org/web/20111221041348/http://www.codeproject.com/kb/system/xyntservice.aspx>
C++ source (Or use the Browse Code tab on the article): <https://web.archive.org/web/20111228050501/http://www.codeproject.com/KB/system/xyntservice.aspx>
>
> Unfortunately, the Zip file source code download does not work within the alternative links.
>
>
>
Start Your Windows Programs From An NT Service
----------------------------------------------
Check this article out: <http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=719&av=49654>
It's a really old article, but it has worked for 8 years and it continues to be kept up to date by the author.
It will do what you want to do.
|
The only way to even consider this is to make sure that the application has no UI elements to it, as you have to jump through hoops on a non-Vista machine to make this work, and on Vista, you can't interact with the desktop at all.
Rather, you would be best off refactoring out the functionality into a set of shared libraries, and then create a service that uses those libraries, and install that at the client.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
If you have a nice decoupled functionality in you forms application, it should be straightforward to create a service class with its installer and then launch your processor class in the OnStart method of the service:
```
protected override void OnStart(string[] args)
{
Processor processor = new Processor();
Thread workerThread = new Thread(processor.OnStart);
workerThread.IsBackground = true;
try
{
workerThread.Start();
}
catch
{
//...
}
}
```
|
Found this [article](http://support.microsoft.com/kb/137890) called **How To Create a User-Defined Service**.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
You can run a winforms application as a service, you just won't be able to see it-- it will be displayed on a so-called virtual desktop, which can't be viewed on your monitor.
|
You can use [InstallUtil](http://msdn.microsoft.com/en-us/library/sd8zc8ha(VS.80).aspx) to install your app as a service, but you need to make sure it's not reliant on the GUI, and I would recommend you change the startup of the app so it doesn't attempt to create any forms.
|
463,073
|
I have a Windows Forms application that I wrote that does some monitoring of an inbox and database. The customer has informed me that it needs to run every time the server reboots. Shame on me for letting the customer change the requirements.
I was thinking ... is there any way to make a Windows Forms application run as a service so that it starts automatically?
**Clarification**
I would like to try to not have to write any more code ... if possible!
|
2009/01/20
|
[
"https://Stackoverflow.com/questions/463073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
If you are sure the application can run unattended safely (by this I mean it can ***never*** throw up a modal UI element like a Message Box) and it doesn't need any interaction until shutdown, where it will simply be terminated, then run it as a scheduled task with the trigger set to system start up.
If it can run unattended but it may need to be shutdown and restarted manually or it can't just be terminated at shutdown then use the XYNTService as recommended by [EnocNRoll](https://stackoverflow.com/questions/463073/run-windows-forms-application-as-service#463117). It's a horrible hack but it will work for what you want.
But by far the best solution is to separate the functionality of your program from the User Interface and write a proper service. And for a production server I wouldn't allow anything else. If it isn't easy to separate then you have some design issues you should look into anyway.
|
You can run a winforms application as a service, you just won't be able to see it-- it will be displayed on a so-called virtual desktop, which can't be viewed on your monitor.
|
94,012
|
In an nice blog post about the [horrors of the paired bar chart](http://policyviz.com/killing-the-paired-bar-chart/), Jonathan Schwabish proposes an elegant alternative, as follows. Instead of having pairs of yellow and blue bars, simply plot their endpoints, connected by a thin grey line, like in this plot of [Gini coefficients](https://en.wikipedia.org/wiki/Gini_coefficient) before and after tax:
[](https://i.stack.imgur.com/OhKKS.png)
For those who want to go full Tufte, there is even this:
[](https://i.stack.imgur.com/kfcsd.png)
It seems to me that there should be a way to modify `BarChart` to do this -- haven't been able to figure out how. Does anyone have any ideas about how to produce a plot like the first of the two plots above (or the second, for that matter)? Notice that these are categorical data.
Here are the data used in these graphs:
```
giniCoefficients =
{{"United States", 4.2, 5.7},
{"Israel", 4.1, 5.8},
{"UK", 4.1, 6.3},
{"Canada", 3.8, 5.5},
{"Greece", 3.8, 6.0},
{"Spain", 3.8, 5.7},
{"Australia", 3.8, 5.5},
{"Norway", 3.7, 5.7},
{"Korea", 3.7, 4.4},
{"Poland", 3.6, 6.5},
{"Taiwan", 3.6, 4.2},
{"Germany", 3.6, 6.0},
{"Finland", 3.5, 5.8},
{"Ireland", 3.5, 6.3},
{"Slovak Republic", 3.5, 5.4},
{"Japan", 3.5, 4.9},
{"Austria", 3.3, 5.5},
{"Netherlands", 3.3, 5.7},
{"Sweden", 3.3, 5.7},
{"Denmark", 3.3, 5.6},
{"Luxemberg", 3.2, 5.2},
{"Switzerland", 3.1, 4.7}
}
```
|
2015/09/05
|
[
"https://mathematica.stackexchange.com/questions/94012",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/24781/"
] |
Here is a version that builds up the "full Tufte" version of the plot presented above by building up the corresponding `Graphics` primitives. Quite a few styling decisions must be made with respect to colors, spacings, overall aspect ratio of the plot, etc. I went with choices that were aesthetically pleasing to me, but of course it should be relatively easy to tweak those within the function.
The **vertical sorting** of the data points is also somewhat arbitrary. At this point the data is presented in such a way that the points with lowest first Gini coefficient show up at the bottom, and in the case of a tie, they are ordered by the alphabetical order of their labels (because of the way `SortBy` works). If that is undesirable, one should adjust the sorting function in `SortBy`: for instance, a stable sort such as `SortBy[{#[[2]]&}]` would leave tied elements in the original order in which they were present in the dataset, etc.
The **horizontal `PlotRange`** is adjusted somewhat automatically to include the labels as well by including an asymmetric `PlotRangePadding` in the $x$ direction. This is somewhat brittle because the length of the label strings is never taken into explicit consideration. I have the impression that there should be a combination of PlotRange / Padding / Clipping that could take care of that automatically, but at this moment it slips my mind.
```
fullTufte[dataset_] :=
Graphics[
Flatten@MapIndexed[
Function[{item, index},
{
(*heading*)
Black, Text[item[[1]], {item[[2]] - 0.35, First@index}, {1, 0}],
(*line*)
Gray, Line[{{item[[2]], First@index}, {item[[3]], First@index}}],
(*numbers*)
Darker@Blue,
Inset[item[[2]], {item[[2]], First@index}, {0, 0}, Background -> White],
Orange, Inset[item[[3]], {item[[3]], First@index}, {0, 0}, Background -> White]
}
],
SortBy[#[[2]] &][dataset]
],
PlotRange -> All, PlotRangeClipping -> False,
PlotRangePadding -> {{Scaled[0.3], Scaled[0.05]}, Automatic},
AspectRatio -> 1.6,
Axes -> {True, False}
]
```
Here is the result of its application to the `giniCoefficients` dataset:
```
fullTufte[giniCoefficients]
```

|
In version 10+ there is `NumberLinePlot` that can be used for this.
```
NumberLinePlot[Interval[Rest@#] & /@ Reverse[giniCoefficients, 1],
PlotStyle -> (Directive[#, Thin, PointSize[Large]] & /@ {Orange,
Blue}),
PlotRange -> {{2, Automatic}, Automatic},
PlotRangePadding -> Scaled[.05],
Epilog ->
MapIndexed[
Function[{item, index},
Inset[First@item, {item[[2]] - .05, First@index}, {1, 0}]],
Reverse[giniCoefficients, 1], 1]]
```
[](https://i.stack.imgur.com/thKQe.png)
There are a couple of things that I don't know how to do that I'd like to be able to without a `ReplaceAll` hack on the plot.
1. Find the length of the text in the graphic so a proper lower `PlotRange` can be set.
2. Define a `PlotStyle` that gives either of the styles the OP requested.
Hopefully someone will add an answer with those features.
|
94,012
|
In an nice blog post about the [horrors of the paired bar chart](http://policyviz.com/killing-the-paired-bar-chart/), Jonathan Schwabish proposes an elegant alternative, as follows. Instead of having pairs of yellow and blue bars, simply plot their endpoints, connected by a thin grey line, like in this plot of [Gini coefficients](https://en.wikipedia.org/wiki/Gini_coefficient) before and after tax:
[](https://i.stack.imgur.com/OhKKS.png)
For those who want to go full Tufte, there is even this:
[](https://i.stack.imgur.com/kfcsd.png)
It seems to me that there should be a way to modify `BarChart` to do this -- haven't been able to figure out how. Does anyone have any ideas about how to produce a plot like the first of the two plots above (or the second, for that matter)? Notice that these are categorical data.
Here are the data used in these graphs:
```
giniCoefficients =
{{"United States", 4.2, 5.7},
{"Israel", 4.1, 5.8},
{"UK", 4.1, 6.3},
{"Canada", 3.8, 5.5},
{"Greece", 3.8, 6.0},
{"Spain", 3.8, 5.7},
{"Australia", 3.8, 5.5},
{"Norway", 3.7, 5.7},
{"Korea", 3.7, 4.4},
{"Poland", 3.6, 6.5},
{"Taiwan", 3.6, 4.2},
{"Germany", 3.6, 6.0},
{"Finland", 3.5, 5.8},
{"Ireland", 3.5, 6.3},
{"Slovak Republic", 3.5, 5.4},
{"Japan", 3.5, 4.9},
{"Austria", 3.3, 5.5},
{"Netherlands", 3.3, 5.7},
{"Sweden", 3.3, 5.7},
{"Denmark", 3.3, 5.6},
{"Luxemberg", 3.2, 5.2},
{"Switzerland", 3.1, 4.7}
}
```
|
2015/09/05
|
[
"https://mathematica.stackexchange.com/questions/94012",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/24781/"
] |
In version 10+ there is `NumberLinePlot` that can be used for this.
```
NumberLinePlot[Interval[Rest@#] & /@ Reverse[giniCoefficients, 1],
PlotStyle -> (Directive[#, Thin, PointSize[Large]] & /@ {Orange,
Blue}),
PlotRange -> {{2, Automatic}, Automatic},
PlotRangePadding -> Scaled[.05],
Epilog ->
MapIndexed[
Function[{item, index},
Inset[First@item, {item[[2]] - .05, First@index}, {1, 0}]],
Reverse[giniCoefficients, 1], 1]]
```
[](https://i.stack.imgur.com/thKQe.png)
There are a couple of things that I don't know how to do that I'd like to be able to without a `ReplaceAll` hack on the plot.
1. Find the length of the text in the graphic so a proper lower `PlotRange` can be set.
2. Define a `PlotStyle` that gives either of the styles the OP requested.
Hopefully someone will add an answer with those features.
|
RangeBarChart
-------------
With a custom `ChartElementFunction` we can use the built-in (undocumented) function `Charting`RangeBarChart` as follows:
```
ClearAll[ceF]
ceF[marker_: "Point"] := Module[{coords = Reverse /@ Thread[{Mean[#2], #}] & @@ #},
{CapForm["Round"], Line[coords], PointSize[.02],
If[marker === "Point", {Blue, Point[coords[[1]]], Orange, Point[coords[[2]]]},
{Text[Style[#[[1]], Blue, 12, Background -> White], #] &@ coords[[1]],
Text[Style[#[[1]], Orange, 12, Background -> White], #] &@ coords[[2]]}]}] &;
labeleddata = Labeled[{##2}, Style[ToString[#]<>" ", 16], Before]&@@@ giniCoefficients;
options = {ChartElementFunction -> ceF[], BarOrigin -> Left, AspectRatio -> 1,
Axes -> False, ImageSize -> 500, Frame -> {{False, False}, {True, False}},
PlotRangePadding -> {{Automatic, Automatic}, {Scaled[.05], Scaled[.05]}}};
Panel[Quiet @ Charting`RangeBarChart[labeleddata, options]]
```
[](https://i.stack.imgur.com/sbhoQ.png)
Change `ceF[]` to `ceF[blah]` in `options` to get
[](https://i.stack.imgur.com/cbEur.png)
|
94,012
|
In an nice blog post about the [horrors of the paired bar chart](http://policyviz.com/killing-the-paired-bar-chart/), Jonathan Schwabish proposes an elegant alternative, as follows. Instead of having pairs of yellow and blue bars, simply plot their endpoints, connected by a thin grey line, like in this plot of [Gini coefficients](https://en.wikipedia.org/wiki/Gini_coefficient) before and after tax:
[](https://i.stack.imgur.com/OhKKS.png)
For those who want to go full Tufte, there is even this:
[](https://i.stack.imgur.com/kfcsd.png)
It seems to me that there should be a way to modify `BarChart` to do this -- haven't been able to figure out how. Does anyone have any ideas about how to produce a plot like the first of the two plots above (or the second, for that matter)? Notice that these are categorical data.
Here are the data used in these graphs:
```
giniCoefficients =
{{"United States", 4.2, 5.7},
{"Israel", 4.1, 5.8},
{"UK", 4.1, 6.3},
{"Canada", 3.8, 5.5},
{"Greece", 3.8, 6.0},
{"Spain", 3.8, 5.7},
{"Australia", 3.8, 5.5},
{"Norway", 3.7, 5.7},
{"Korea", 3.7, 4.4},
{"Poland", 3.6, 6.5},
{"Taiwan", 3.6, 4.2},
{"Germany", 3.6, 6.0},
{"Finland", 3.5, 5.8},
{"Ireland", 3.5, 6.3},
{"Slovak Republic", 3.5, 5.4},
{"Japan", 3.5, 4.9},
{"Austria", 3.3, 5.5},
{"Netherlands", 3.3, 5.7},
{"Sweden", 3.3, 5.7},
{"Denmark", 3.3, 5.6},
{"Luxemberg", 3.2, 5.2},
{"Switzerland", 3.1, 4.7}
}
```
|
2015/09/05
|
[
"https://mathematica.stackexchange.com/questions/94012",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/24781/"
] |
Here is a version that builds up the "full Tufte" version of the plot presented above by building up the corresponding `Graphics` primitives. Quite a few styling decisions must be made with respect to colors, spacings, overall aspect ratio of the plot, etc. I went with choices that were aesthetically pleasing to me, but of course it should be relatively easy to tweak those within the function.
The **vertical sorting** of the data points is also somewhat arbitrary. At this point the data is presented in such a way that the points with lowest first Gini coefficient show up at the bottom, and in the case of a tie, they are ordered by the alphabetical order of their labels (because of the way `SortBy` works). If that is undesirable, one should adjust the sorting function in `SortBy`: for instance, a stable sort such as `SortBy[{#[[2]]&}]` would leave tied elements in the original order in which they were present in the dataset, etc.
The **horizontal `PlotRange`** is adjusted somewhat automatically to include the labels as well by including an asymmetric `PlotRangePadding` in the $x$ direction. This is somewhat brittle because the length of the label strings is never taken into explicit consideration. I have the impression that there should be a combination of PlotRange / Padding / Clipping that could take care of that automatically, but at this moment it slips my mind.
```
fullTufte[dataset_] :=
Graphics[
Flatten@MapIndexed[
Function[{item, index},
{
(*heading*)
Black, Text[item[[1]], {item[[2]] - 0.35, First@index}, {1, 0}],
(*line*)
Gray, Line[{{item[[2]], First@index}, {item[[3]], First@index}}],
(*numbers*)
Darker@Blue,
Inset[item[[2]], {item[[2]], First@index}, {0, 0}, Background -> White],
Orange, Inset[item[[3]], {item[[3]], First@index}, {0, 0}, Background -> White]
}
],
SortBy[#[[2]] &][dataset]
],
PlotRange -> All, PlotRangeClipping -> False,
PlotRangePadding -> {{Scaled[0.3], Scaled[0.05]}, Automatic},
AspectRatio -> 1.6,
Axes -> {True, False}
]
```
Here is the result of its application to the `giniCoefficients` dataset:
```
fullTufte[giniCoefficients]
```

|
RangeBarChart
-------------
With a custom `ChartElementFunction` we can use the built-in (undocumented) function `Charting`RangeBarChart` as follows:
```
ClearAll[ceF]
ceF[marker_: "Point"] := Module[{coords = Reverse /@ Thread[{Mean[#2], #}] & @@ #},
{CapForm["Round"], Line[coords], PointSize[.02],
If[marker === "Point", {Blue, Point[coords[[1]]], Orange, Point[coords[[2]]]},
{Text[Style[#[[1]], Blue, 12, Background -> White], #] &@ coords[[1]],
Text[Style[#[[1]], Orange, 12, Background -> White], #] &@ coords[[2]]}]}] &;
labeleddata = Labeled[{##2}, Style[ToString[#]<>" ", 16], Before]&@@@ giniCoefficients;
options = {ChartElementFunction -> ceF[], BarOrigin -> Left, AspectRatio -> 1,
Axes -> False, ImageSize -> 500, Frame -> {{False, False}, {True, False}},
PlotRangePadding -> {{Automatic, Automatic}, {Scaled[.05], Scaled[.05]}}};
Panel[Quiet @ Charting`RangeBarChart[labeleddata, options]]
```
[](https://i.stack.imgur.com/sbhoQ.png)
Change `ceF[]` to `ceF[blah]` in `options` to get
[](https://i.stack.imgur.com/cbEur.png)
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
If you are looking for the most easily recognizable use of a 5-star system, they should work from left-to-right.
The star-rating system is very common now, and when is the last time you saw it work right-to-left? Users will likely find it confusing and will have difficultly understanding why they only gave something 2-stars, when the meant to give it 4-stars. As a result of their familiarity, they "[afford](http://en.wikipedia.org/wiki/Affordance)" a 1-to-5 star rating leading from the left-to-right.
A straight forward example is justified text:

Justifying text to the right does not alter my interaction/reading of that text. I still read it as I would a left-aligned block.
Additionally, think of a combo-box. Just because we right-aligning the combo-box, we do not alter the way it works:

... or any other control. By placing a control on the left, in the center, on the right, does not necessitate the need (or rarely the desire) to alter its behavior.
|
I have never seen a star rating fill from right-to-left. I think the star group is more or less seen as one element. I would not stray from the standard left-to-right filling of the stars.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
If you are looking for the most easily recognizable use of a 5-star system, they should work from left-to-right.
The star-rating system is very common now, and when is the last time you saw it work right-to-left? Users will likely find it confusing and will have difficultly understanding why they only gave something 2-stars, when the meant to give it 4-stars. As a result of their familiarity, they "[afford](http://en.wikipedia.org/wiki/Affordance)" a 1-to-5 star rating leading from the left-to-right.
A straight forward example is justified text:

Justifying text to the right does not alter my interaction/reading of that text. I still read it as I would a left-aligned block.
Additionally, think of a combo-box. Just because we right-aligning the combo-box, we do not alter the way it works:

... or any other control. By placing a control on the left, in the center, on the right, does not necessitate the need (or rarely the desire) to alter its behavior.
|
I would say (little or no real experience here, mind you) that western cultures that read left-to-right will always expect increasing amounts to go the same way (like a dial speedometer).
I have always made slider controls increase to the right without thinking about it...
I would be curious to see how Hebrew or other cultures that read right-to-left expect an increasing amount.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
Netflix uses filled stars from the left even though the ratings are right aligned.
This follows the ability to quickly scan down the list of ratings and quickly assess at a glance which film is higher rated.

Same goes with Paragraph alignment, as per Evil Closet Monkey's answer.
|
I would say (little or no real experience here, mind you) that western cultures that read left-to-right will always expect increasing amounts to go the same way (like a dial speedometer).
I have always made slider controls increase to the right without thinking about it...
I would be curious to see how Hebrew or other cultures that read right-to-left expect an increasing amount.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
Same direction as your text.
Star ratings are most easily read when the significant part (filled stars) comes before the filler (unfilled stars). "Before" can mean left or right, depending on the direction your user reads lines of text.
Unless your site is in Hebrew, Arabic or another RTL language, the stars should be LTR.
|
I have never seen a star rating fill from right-to-left. I think the star group is more or less seen as one element. I would not stray from the standard left-to-right filling of the stars.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
I have never seen a star rating fill from right-to-left. I think the star group is more or less seen as one element. I would not stray from the standard left-to-right filling of the stars.
|
I would say (little or no real experience here, mind you) that western cultures that read left-to-right will always expect increasing amounts to go the same way (like a dial speedometer).
I have always made slider controls increase to the right without thinking about it...
I would be curious to see how Hebrew or other cultures that read right-to-left expect an increasing amount.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
Netflix uses filled stars from the left even though the ratings are right aligned.
This follows the ability to quickly scan down the list of ratings and quickly assess at a glance which film is higher rated.

Same goes with Paragraph alignment, as per Evil Closet Monkey's answer.
|
Suppose you make some text right-aligned, as @EvilClosetMonkey's graphic helpfully shows. Is that any reason to change the text to display right-to-left? It would probably make your words unreadable to most people viewing them.
The reason is that alignment has to do with [design, layout and negative](http://www.1stwebdesigner.com/design/negative-space-design/) space while direction has to do with [readability](http://en.wikipedia.org/wiki/Readability). Text can be [oriented](http://www.middleagebulge.com/2013/09/signs-of-times.html), [reflected](https://c1.staticflickr.com/5/4150/4845000362_a655fed9ab_z.jpg) and [jumbled](http://www.famigo.com/static/images/famigo-logo.png) around for aesthetic purposes, but if you take it too far, it becomes [difficult to read quickly](http://www.dreamtemplate.com/blog/wp-content/uploads/2010/11/p1a57.jpg).
That said, stars are more easily parsed than words and less prone to misinterpretation, as this (very authoritative) list of Land Before Time ratings shows ([source](http://what-if.xkcd.com/65/)).

To my eye, all but the very weirdest of those are still easily parsed to tell whether the rating is high or low, which is what the stars are trying to convey.
To sum up, if you really like the style of the RTL filling, then go for it. It won't significantly impact your UX. In my opinion, anyways; I would see that and only pause to think "that's weird" without being bothered by it.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
I would agree with most of the responses, that filling in the stars from left to right makes the most sense due to learned user behaviour from the majority of websites, and English being LTR. A user clicking a star for a rating could definitely be confused by unexpected behaviour.
However, it was stated that this will not be a user-interactive piece. Consider only adding full stars that represent the actual rating: If it has 3 stars, show 3 stars. If it has one star, only show one. If you show empty stars, it may invite user interaction.
You could also have a single star image with a number on it (like IMDB), and a tooltip that displays the full score potential: 1/3.
|
Suppose you make some text right-aligned, as @EvilClosetMonkey's graphic helpfully shows. Is that any reason to change the text to display right-to-left? It would probably make your words unreadable to most people viewing them.
The reason is that alignment has to do with [design, layout and negative](http://www.1stwebdesigner.com/design/negative-space-design/) space while direction has to do with [readability](http://en.wikipedia.org/wiki/Readability). Text can be [oriented](http://www.middleagebulge.com/2013/09/signs-of-times.html), [reflected](https://c1.staticflickr.com/5/4150/4845000362_a655fed9ab_z.jpg) and [jumbled](http://www.famigo.com/static/images/famigo-logo.png) around for aesthetic purposes, but if you take it too far, it becomes [difficult to read quickly](http://www.dreamtemplate.com/blog/wp-content/uploads/2010/11/p1a57.jpg).
That said, stars are more easily parsed than words and less prone to misinterpretation, as this (very authoritative) list of Land Before Time ratings shows ([source](http://what-if.xkcd.com/65/)).

To my eye, all but the very weirdest of those are still easily parsed to tell whether the rating is high or low, which is what the stars are trying to convey.
To sum up, if you really like the style of the RTL filling, then go for it. It won't significantly impact your UX. In my opinion, anyways; I would see that and only pause to think "that's weird" without being bothered by it.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
I would agree with most of the responses, that filling in the stars from left to right makes the most sense due to learned user behaviour from the majority of websites, and English being LTR. A user clicking a star for a rating could definitely be confused by unexpected behaviour.
However, it was stated that this will not be a user-interactive piece. Consider only adding full stars that represent the actual rating: If it has 3 stars, show 3 stars. If it has one star, only show one. If you show empty stars, it may invite user interaction.
You could also have a single star image with a number on it (like IMDB), and a tooltip that displays the full score potential: 1/3.
|
I would say (little or no real experience here, mind you) that western cultures that read left-to-right will always expect increasing amounts to go the same way (like a dial speedometer).
I have always made slider controls increase to the right without thinking about it...
I would be curious to see how Hebrew or other cultures that read right-to-left expect an increasing amount.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
Suppose you make some text right-aligned, as @EvilClosetMonkey's graphic helpfully shows. Is that any reason to change the text to display right-to-left? It would probably make your words unreadable to most people viewing them.
The reason is that alignment has to do with [design, layout and negative](http://www.1stwebdesigner.com/design/negative-space-design/) space while direction has to do with [readability](http://en.wikipedia.org/wiki/Readability). Text can be [oriented](http://www.middleagebulge.com/2013/09/signs-of-times.html), [reflected](https://c1.staticflickr.com/5/4150/4845000362_a655fed9ab_z.jpg) and [jumbled](http://www.famigo.com/static/images/famigo-logo.png) around for aesthetic purposes, but if you take it too far, it becomes [difficult to read quickly](http://www.dreamtemplate.com/blog/wp-content/uploads/2010/11/p1a57.jpg).
That said, stars are more easily parsed than words and less prone to misinterpretation, as this (very authoritative) list of Land Before Time ratings shows ([source](http://what-if.xkcd.com/65/)).

To my eye, all but the very weirdest of those are still easily parsed to tell whether the rating is high or low, which is what the stars are trying to convey.
To sum up, if you really like the style of the RTL filling, then go for it. It won't significantly impact your UX. In my opinion, anyways; I would see that and only pause to think "that's weird" without being bothered by it.
|
I don't think in reading them it would matter as much for a LTR language, but when someone is clicking a star for the rating I think they would incorrectly assume that they start on the left.
In my experience I have never seen a star rating system start on the right and if I were to click the right most star I would expect to be giving it the top rating.
If you started on the right someone giving a bad review would end up being recoded as a best review if they clicked the left most star and I bet that would really make them mad.
However, as other folks have said, I am wondering what it is like in countries that use RTL. I checked Amazon, but they did not have a country listed that read RTL.
|
54,532
|
When building graphics for an app, I have right-aligned a rating from 1 to three stars. Being mainly a designer, my gut told me to fill the stars from right to left. So, i.e. `empty` `empty` `filled` for a 1-out-of-3, and `empty` `filled` `filled` for 2 out of 3.
The rating is given by the app, and in no way will users have to click on the stars to rate things themselves.
What is the best practice from a UX standpoint: filling right to left or left to right?
|
2014/03/24
|
[
"https://ux.stackexchange.com/questions/54532",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/45449/"
] |
I have never seen a star rating fill from right-to-left. I think the star group is more or less seen as one element. I would not stray from the standard left-to-right filling of the stars.
|
I don't think in reading them it would matter as much for a LTR language, but when someone is clicking a star for the rating I think they would incorrectly assume that they start on the left.
In my experience I have never seen a star rating system start on the right and if I were to click the right most star I would expect to be giving it the top rating.
If you started on the right someone giving a bad review would end up being recoded as a best review if they clicked the left most star and I bet that would really make them mad.
However, as other folks have said, I am wondering what it is like in countries that use RTL. I checked Amazon, but they did not have a country listed that read RTL.
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
Yes - you can use [Partition Magic](http://www.symantec.com/norton/partitionmagic) or the like to do this. Defragmenting your drive first should give you a bit more space at the end of the drive to work with.
|
I recommend gParted too, you can get it on a [LiveCD](http://gparted.sourceforge.net/livecd.php), and resize your partitions rather safelly. It's never 100% safe though, you should always backup important data first.
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
It is possible, and I know gParted (a Linux/Gnome application) will resize Windows partitions for you. If done right everything works great, however one time I hit a snag and lost all the data (although it could have been my fault, it was the first time I attempted it).
|
It's not free, but Terabyte Software's [BootIt NG](http://www.terabyteunlimited.com/bootit-next-generation.htm) app is really good and inexpensive at about $35. I'm using it mainly for the boot manager feature which makes running multiple operating systems more convenient, but it also handles resizing partitions with ease.
(I'm not affiliated with them in any way. Just a happy customer)
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
Yes - you can use [Partition Magic](http://www.symantec.com/norton/partitionmagic) or the like to do this. Defragmenting your drive first should give you a bit more space at the end of the drive to work with.
|
You can also use a free program called NTFSResize, available on a bootable [SystemRescueCD](http://www.sysresccd.org/Main_Page).
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
Yes - you can use [Partition Magic](http://www.symantec.com/norton/partitionmagic) or the like to do this. Defragmenting your drive first should give you a bit more space at the end of the drive to work with.
|
It is possible, and I know gParted (a Linux/Gnome application) will resize Windows partitions for you. If done right everything works great, however one time I hit a snag and lost all the data (although it could have been my fault, it was the first time I attempted it).
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
Although I love GParted, I would have to recommend [EASEUS Partition Master](http://www.partition-tool.com/personal.htm). I just used it to repartition my Windows 7 computer and know that it works flawlessly. It runs directly from within Windows so you don't have to create a boot CD.
|
It's not free, but Terabyte Software's [BootIt NG](http://www.terabyteunlimited.com/bootit-next-generation.htm) app is really good and inexpensive at about $35. I'm using it mainly for the boot manager feature which makes running multiple operating systems more convenient, but it also handles resizing partitions with ease.
(I'm not affiliated with them in any way. Just a happy customer)
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
You can also use a free program called NTFSResize, available on a bootable [SystemRescueCD](http://www.sysresccd.org/Main_Page).
|
It's not free, but Terabyte Software's [BootIt NG](http://www.terabyteunlimited.com/bootit-next-generation.htm) app is really good and inexpensive at about $35. I'm using it mainly for the boot manager feature which makes running multiple operating systems more convenient, but it also handles resizing partitions with ease.
(I'm not affiliated with them in any way. Just a happy customer)
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
Yes - you can use [Partition Magic](http://www.symantec.com/norton/partitionmagic) or the like to do this. Defragmenting your drive first should give you a bit more space at the end of the drive to work with.
|
It's not free, but Terabyte Software's [BootIt NG](http://www.terabyteunlimited.com/bootit-next-generation.htm) app is really good and inexpensive at about $35. I'm using it mainly for the boot manager feature which makes running multiple operating systems more convenient, but it also handles resizing partitions with ease.
(I'm not affiliated with them in any way. Just a happy customer)
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
It is possible, and I know gParted (a Linux/Gnome application) will resize Windows partitions for you. If done right everything works great, however one time I hit a snag and lost all the data (although it could have been my fault, it was the first time I attempted it).
|
I recommend gParted too, you can get it on a [LiveCD](http://gparted.sourceforge.net/livecd.php), and resize your partitions rather safelly. It's never 100% safe though, you should always backup important data first.
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
I recommend gParted too, you can get it on a [LiveCD](http://gparted.sourceforge.net/livecd.php), and resize your partitions rather safelly. It's never 100% safe though, you should always backup important data first.
|
It's not free, but Terabyte Software's [BootIt NG](http://www.terabyteunlimited.com/bootit-next-generation.htm) app is really good and inexpensive at about $35. I'm using it mainly for the boot manager feature which makes running multiple operating systems more convenient, but it also handles resizing partitions with ease.
(I'm not affiliated with them in any way. Just a happy customer)
|
5,818
|
I currently have a 160GB drive partitioned as C: (Windows, Primary) and D: (data). I was a terrible estimator in the beginning, and the C: drive is approaching capacity, whereas I have ~35GB spare on the data drive.
Is it possible (and using what?) to safely change/adjust these two partitions so that I can expand C:, **without losing any data**?
(Just for your own peace of mind, I'm backing everything up and starting fresh anyway, as I figure that's *safest*, but I've been wondering about this).
|
2009/07/16
|
[
"https://superuser.com/questions/5818",
"https://superuser.com",
"https://superuser.com/users/1580/"
] |
Yes - you can use [Partition Magic](http://www.symantec.com/norton/partitionmagic) or the like to do this. Defragmenting your drive first should give you a bit more space at the end of the drive to work with.
|
Although I love GParted, I would have to recommend [EASEUS Partition Master](http://www.partition-tool.com/personal.htm). I just used it to repartition my Windows 7 computer and know that it works flawlessly. It runs directly from within Windows so you don't have to create a boot CD.
|
36,612,868
|
I am having an issue with sharing an image on Facebook, from an iOS app.
([See this post](https://stackoverflow.com/questions/36594505/trying-to-share-an-image-on-facebook-from-an-ios-app))
I read that it was against Facebook policy to prefill text before sharing.
Is it also contrary to their policy to prefill an image?
I can understand that prefilling can lead to possible exagerations. But in an app dealing with pictures, if I cannot make it easy for the user to share his picture by preloading it; what could be the point of having a FB button in my app?
|
2016/04/14
|
[
"https://Stackoverflow.com/questions/36612868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/611201/"
] |
As my understanding, we can't prefill text, however, can share photos from your application to Facebook and there is no restriction of that. As they said, there are just some requirements
* Photos must be less than 12MB in size
* People need the native Facebook for iOS app installed, version 7.0 or higher.
Here is the example code of using FBSDKSharePhotoContent to share photos via FB
```
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = info[UIImagePickerControllerOriginalImage];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
...
}
```
Reference: <https://developers.facebook.com/docs/sharing/ios>
|
I also try to find out how to share a image to Facebook and their documentation didn't help me a lot -> <https://developers.facebook.com/docs/swift/sharing/content-types/>
In the end I manage to do it in this way:
```
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
private func shareInFacebook() {
let photo = SharePhoto(image: image!, userGenerated: true)
let content = SharePhotoContent()
content.photos = [photo]
let showDialog = ShareDialog(fromViewController: self, content: content, delegate: self)
if (showDialog.canShow) {
showDialog.show()
} else {
self.view.makeToast("It looks like you don't have the Facebook mobile app on your phone.")
}
}
```
Hope this will help someone ;)
|
7,343,197
|
Im trying to do a purge of records in a database though when I made my query and associations it seems to not want to do it correctly. I got the following error and Im confused as to why this is occurring:
```
SQL Error: 1054: Unknown column 'GuardiansStudents.student_id' in 'where clause'
```
The query that gets displayed afterwards is the following:
```
Query: SELECT `User`.`id`, `Guardian`.`id`
FROM `guardians` AS `Guardian`
LEFT JOIN `users` AS `User` ON (`Guardian`.`user_id` = `User`.`id`)
WHERE `GuardiansStudents`.`student_id` IS NULL
AND `User`.`active` = 1 AND `User`.`changeapprovalneeded` = 0
```
I also have the following associations in the Guardian model, not sure if Im doing this properly, and possibly this is where the error is occurring:
```
class Guardian extends AppModel {
var $name = 'Guardian';
//The Associations below have been created with all possible keys,
// those that are not needed can be removed
var $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
var $hasAndBelongsToMany = array(
'Student' => array(
'className' => 'Student',
'joinTable' => 'guardians_students',
'foreignKey' => 'guardian_id',
'associationForeignKey' => 'student_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
```
This is the code to do the purge function:
```
function manager_purgebygrade() {
ini_set('max_execution_time','120');
$this->layout = "manager";
$this->User->recursive = 0;
$grades = $this->User->Student->Grade->getDropDownList();
$this->set(compact('grades'));
//debug($this->data);
if(!empty($this->data['User']['grade_id']))
{
//$this->User->bindModel(array())
$users = $this->User->find(
'list',
array(
'fields' => array(
'User.id'
),
'conditions' => array(
'Student.grade_id' => $this->data['User']['grade_id']
),
'recursive' => 0
)
);
//debug($users);
$this->User->deleteAll(array('User.id' => $users), true);
$this->User->Guardian->bindModel(
array('hasOne' => array('GuardiansStudents')));
$guardianswithnostudents = $this->Guardian->deleteGuardiansWithNoStudent();
$guardians = $this->User->Guardian->find(
'list',
array(
'fields' => array(
'User.id',
'User.id'
),
'conditions' => array(
'GuardiansStudents.student_id' => null,
'User.active' => 1,
'User.changeapprovalneeded' => 0
),
'recursive' => 1
)
);
$this->User->deleteAll(array('User.id' => $guardians), true);
$this->set(compact('users','guardians','guardianswithnostudents'));
}
}
```
Hopefully someone can point me in the right direction I would greatly appreciate it :).
|
2011/09/08
|
[
"https://Stackoverflow.com/questions/7343197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/702757/"
] |
If you want to make a selector:
```
$('#' + aIds.join(', #')).autocomplete();
```
|
`for(i=0;i<aIds.length;i++)`
`$('#'+aIds[i]).autocomplete();`
|
7,343,197
|
Im trying to do a purge of records in a database though when I made my query and associations it seems to not want to do it correctly. I got the following error and Im confused as to why this is occurring:
```
SQL Error: 1054: Unknown column 'GuardiansStudents.student_id' in 'where clause'
```
The query that gets displayed afterwards is the following:
```
Query: SELECT `User`.`id`, `Guardian`.`id`
FROM `guardians` AS `Guardian`
LEFT JOIN `users` AS `User` ON (`Guardian`.`user_id` = `User`.`id`)
WHERE `GuardiansStudents`.`student_id` IS NULL
AND `User`.`active` = 1 AND `User`.`changeapprovalneeded` = 0
```
I also have the following associations in the Guardian model, not sure if Im doing this properly, and possibly this is where the error is occurring:
```
class Guardian extends AppModel {
var $name = 'Guardian';
//The Associations below have been created with all possible keys,
// those that are not needed can be removed
var $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
var $hasAndBelongsToMany = array(
'Student' => array(
'className' => 'Student',
'joinTable' => 'guardians_students',
'foreignKey' => 'guardian_id',
'associationForeignKey' => 'student_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
```
This is the code to do the purge function:
```
function manager_purgebygrade() {
ini_set('max_execution_time','120');
$this->layout = "manager";
$this->User->recursive = 0;
$grades = $this->User->Student->Grade->getDropDownList();
$this->set(compact('grades'));
//debug($this->data);
if(!empty($this->data['User']['grade_id']))
{
//$this->User->bindModel(array())
$users = $this->User->find(
'list',
array(
'fields' => array(
'User.id'
),
'conditions' => array(
'Student.grade_id' => $this->data['User']['grade_id']
),
'recursive' => 0
)
);
//debug($users);
$this->User->deleteAll(array('User.id' => $users), true);
$this->User->Guardian->bindModel(
array('hasOne' => array('GuardiansStudents')));
$guardianswithnostudents = $this->Guardian->deleteGuardiansWithNoStudent();
$guardians = $this->User->Guardian->find(
'list',
array(
'fields' => array(
'User.id',
'User.id'
),
'conditions' => array(
'GuardiansStudents.student_id' => null,
'User.active' => 1,
'User.changeapprovalneeded' => 0
),
'recursive' => 1
)
);
$this->User->deleteAll(array('User.id' => $guardians), true);
$this->set(compact('users','guardians','guardianswithnostudents'));
}
}
```
Hopefully someone can point me in the right direction I would greatly appreciate it :).
|
2011/09/08
|
[
"https://Stackoverflow.com/questions/7343197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/702757/"
] |
If you want to make a selector:
```
$('#' + aIds.join(', #')).autocomplete();
```
|
Easy, just need to join them together and pass it in. Jquery is great and lets you pass in multiple selectors.
```
var aIds = ["1", "2"];
// join together your IDS
var selectors = "#" + aIds.join(",#");
// pass in as selectors
$(selectors).autocomplete
```
|
437,413
|
I made a mistake in a `rsync` and all the files are copied long with its full path. All the files that I copied are at
```
/var/www/photos/2012/1007/1007
```
**Attempt 1**
Now I would like to fix the paths, by doing
```
mv /var/www/photos/2012/1007/1007 /var/www/photos/2012
```
This gives the error:
```
mv: cannot move `/var/www/photos/2012/1007/1007' to `/var/www/photos/2012/1007': Directory not empty
```
**Attempt 2**
```
mv /var/www/photos/2012/1007/1007/* /var/www/photos/2012/1007
```
I get the error:
```
-bash: /bin/mv: Argument list too long
```
**Question:** What will be the correct way to rename the folder that contains alot of files?
---
*The files were actually copied to `/var/www/photos/2012/1007/home/photos/public_html/2012/1007` but somehow I got them to `/var/www/photos/2012/1007/1007`*
*Rsync cmd:*
*`rsync -zavrR --rsh="ssh -c arcfour -l root -p 2200" www.mydomain.com:/home/photos/public_html/2012/1007 /var/www/photos/2012/1007`*
|
2012/10/11
|
[
"https://serverfault.com/questions/437413",
"https://serverfault.com",
"https://serverfault.com/users/102604/"
] |
This worked in my test with the paths you gave:
```
cd /var/www/photos
mv 2012 old
mv old/1007/1007 .
mv 1007 2012
```
What's happening is you are trying to move a directory over top of an existing directory - and it doesn't like doing that because there's stuff in the directory. By renaming 2012 first, you can move it without problems.
|
At least two ways I can think of:
**1:** First rename /var/www/photos/2012/1007 to /var/www/photos/2012/temppath, then mv /var/www/photos/2012/temppath/1007 -> /var/www/photos/2012/, then rmdir /var/www/photos/2012/temppath.
**2:** Use a simple script to move the contents:
```
for f in `find /var/www/photos/2012/1007/1007 -mindepth 1`; do mv $f /var/www/photos/2012/1007/1007/../; done
```
First method it probably a better answer to your question.
|
60,907,302
|
I have a table that looks like the below:
```
Row | Fullvisitorid | Visitid | New_Session_Flag
1 | A | 111 | 1
2 | A | 120 | 0
3 | A | 128 | 0
4 | A | 133 | 0
5 | A | 745 | 1
6 | A | 777 | 0
7 | B | 388 | 1
8 | B | 401 | 0
9 | B | 420 | 0
10 | B | 777 | 1
11 | B | 784 | 0
12 | B | 791 | 0
13 | B | 900 | 1
14 | B | 904 | 0
```
What I want to do is if it's the first row for a fullvisitorid then mark the field as 1, otherwise use the above row as the value, but if the new\_session\_flag = 1 then use the above row plus 1, example of output I'm looking for below:
```
Row | Fullvisitorid | Visitid | New_Session_Flag | Rank_Session_Order
1 | A | 111 | 1 | 1
2 | A | 120 | 0 | 1
3 | A | 128 | 0 | 1
4 | A | 133 | 0 | 1
5 | A | 745 | 1 | 2
6 | A | 777 | 0 | 2
7 | B | 388 | 1 | 1
8 | B | 401 | 0 | 1
9 | B | 420 | 0 | 1
10 | B | 777 | 1 | 2
11 | B | 784 | 0 | 2
12 | B | 791 | 0 | 2
13 | B | 900 | 1 | 3
14 | B | 904 | 0 | 3
```
As you can see:
* Row 1 is 1 because it's the first time fullvisitorid A appears
* Row 2 is 1 because it's not the first time fullvisitorid A appears and new\_session\_flag <> 1 therefore it uses the above row (i.e. 1)
* Row 5 is 2 because it's not the first time fullvisitorid A appears and new\_session\_Flag = 1 therefore it uses the above row (i.e 1) plus 1
* Row 7 is 1 because it's the first time fullvisitorid B appears
etc.
I believe this can be done through a `retain` statement in SAS but is there an equivalent in Google BigQquery?
Hopefully the above makes sense, let me know if not.
Thanks in advance
|
2020/03/28
|
[
"https://Stackoverflow.com/questions/60907302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7507768/"
] |
Below is for BigQuery Standard SQL
```
#standardSQL
SELECT *,
COUNTIF(New_Session_Flag = 1) OVER(PARTITION BY Fullvisitorid ORDER BY Visitid) Rank_Session_Order
FROM `project.dataset.table`
```
|
The answer by Mikhail Berlyant using a conditional window count is corret and works. I am answering because I find that a window sum is even simpler (and possibly more efficient on a large dataset):
```
select
t.*,
sum(new_session_flag) over(partition by fullvisitorid order by visid_id) rank_session_order
from mytable t
```
This works because the `new_session_flag` contains `0`s and `1`s only; so counting the `1`s is actually equivalent to suming all values.
|
298,583
|
I found this exercise in Artin. It asks me to prove that $\det A= \det A^T$ where $A^T$ is the transpose of the matrix $A$.
**Can anyone please comment whether my proof is correct or not?**
*Attempted solution:* If $\det A=0$, the $A$ is non-invertible. We know that a matrix is invertible iff $A^T$ is invertible. As $A$ is non-invertible, so is $A^T$ and therefore $\det A^T=0$.
If the matrix is invertible, then $A=E\_rE\_{r-1}\dots E\_1$ for a finite sequence of elementary row operations, $E\_i$. Using the fact that $(AB)^T=B^TA^T$ and using induction, we infer that $A^T=E\_1^TE\_2^T\dots E\_r^T$. So, $\det A^T=\det (E\_1^T)\det(E\_2^T)\dots \det(E\_r^T)$.As $E\_i^T$ is an elementary row-operation as well of the same kind, $\det E\_i^T=\det E\_i$. Using that, $\det A^T=\det (E\_1E\_2\dots E\_r)=\det A$.
|
2013/02/09
|
[
"https://math.stackexchange.com/questions/298583",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
I believe your proof is correct.
Note that the best way of proving that $\det(A)=\det(A^t)$ depends very much on the definition of the determinant you are using. My personal favorite way of proving it is by giving a definition of the determinant such that $\det(A)=\det(A^t)$ is *obviously* true.
One possible definition of the determinant of an $(n\times n)$-matrix is
$$ \sum\_{\text{pick $n$ different numbers in the} \atop \text{matrix, no two in the same row or column}} \text{sign}(\text{your choice of numbers})\cdot(\text{product of the numbers}) .$$
In this formula the tiny text under the summation-symbol reads "pick $n$ different numbers in the matrix, no two in the same row or column". The sign of such a choice of numbers is calculated by drawing a line segment between any pair of chosen numbers and then calculating
$$ (-1)^{\text{number of line segments with positive slope}} .$$
If you follow this definition, it is clear that the determinant does not change upon transposing the matrix (the only thing you have to observe is that a line segment with positive slope is transposed into one with positive slope, and a line segment with negative slope is transposed into one with negative slope).
Of course, using this definition gives disadvantages in proving other properties of the determinant (well, I suppose so).
|
Your proof seems fine. I know that Artin tells you to prove this with row operations, which you have done, but it could be instructive to see more reasons why this result is true. Try to fill in the details of this proof:
Induct on $n$ where $A$ is an n by n matrix. In calculating $\det A$, expand along the first column, and calculate $\det A^T$ by expanding along the first row.
|
298,583
|
I found this exercise in Artin. It asks me to prove that $\det A= \det A^T$ where $A^T$ is the transpose of the matrix $A$.
**Can anyone please comment whether my proof is correct or not?**
*Attempted solution:* If $\det A=0$, the $A$ is non-invertible. We know that a matrix is invertible iff $A^T$ is invertible. As $A$ is non-invertible, so is $A^T$ and therefore $\det A^T=0$.
If the matrix is invertible, then $A=E\_rE\_{r-1}\dots E\_1$ for a finite sequence of elementary row operations, $E\_i$. Using the fact that $(AB)^T=B^TA^T$ and using induction, we infer that $A^T=E\_1^TE\_2^T\dots E\_r^T$. So, $\det A^T=\det (E\_1^T)\det(E\_2^T)\dots \det(E\_r^T)$.As $E\_i^T$ is an elementary row-operation as well of the same kind, $\det E\_i^T=\det E\_i$. Using that, $\det A^T=\det (E\_1E\_2\dots E\_r)=\det A$.
|
2013/02/09
|
[
"https://math.stackexchange.com/questions/298583",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
While your proof is basically correct, I would not consider it my favourite proof of this fact, for the following reasons:
* It uses the multiplicativity of determinants, which is a much less elementary property than invariance under transposition.
* It works only for matrices over a field, while the definition of the determinant, and the invariance under transposition, require no more than a commutative ring. There is a general principle that identities of this kind, if they hold over fields, must in fact be valid over commutative rings as well, but understanding that kind of argument requires an additional level of mathematical maturity; it is in most cases (like this one) much easier to just give a proof that is itself valid in the more general setting.
* It needs to single out the non-invertible case. If you would allow for a triangular matrix (for which the result is obvious) at the end of the product of elementary operations, you would not need to single out this case (and as a bonus you would in most cases need far fewer elementary operations). See [this answer](https://math.stackexchange.com/a/283677/18880) to a similar question where the use of row operations was imposed (but the answer does not say what kind of matrix one is reducing to).
How I would prove this depends on the definition of the determinant has been given. If it is defined using the Leibniz formula (which in my opinion is the right *definition* to give, although a different *motivation* should first be given), then the proof just amounts to showing that every permutation has the same sign as its inverse, which is quite elementary (and can by the way be done in a similar way as your proof, but using a decomposition into transpositions).
If on the other hand one has defined the determinant as unique $n$-linear alternating function on an $n$ dimensional vector space taking value $1$ on a given ordered basis, (which still requires using Leibniz or a substitute for proving existence) then invariance under transposition is harder to see. Here one needs to pass to the dual vector space, but it seems necessary to use the fact that if $v\_1,\ldots,v\_n$ are vectors and $\alpha\_1,\ldots,\alpha\_n$ are linear forms, then the determinant
$$
\begin{vmatrix}\alpha\_1(v\_1)&\ldots&\alpha\_1(v\_n)\\
\vdots&\ddots&\vdots\\\alpha\_n(v\_1)&\ldots&\alpha\_n(v\_n)\end{vmatrix}
$$
is not only $n$-linear and alternating in $v\_1,\ldots,v\_n$ for fixed $\alpha\_1,\ldots,\alpha\_n$ (as is clear from the definition) but also $n$-linear and alternating in $\alpha\_1,\ldots,\alpha\_n$ (for fixed $v\_1,\ldots,v\_n$); I can see no easy argument for this, other than using the Leibniz formula. Once this is established, it is easy to show that a linear operator $f$ induces the same scalar factor on $n$-linear forms when applied to $n$-uplets of vectors as it does when applied (on the right) to $n$-uplets of linear forms, in other words its determinant is the same as that of its transpose (in essence, both cases correspond to inserting an $f$ between each $\alpha\_i$ and $v\_j$ in the above determinant).
This still does not provide a context in which using row operations to prove this fact would be a natural choice. It is not clear to me from the question whether Artin actually suggests this, and if so why. The only reason I can think of using such an argument is when somebody commands *thou shall not use the Leibniz formula*.
|
Your proof seems fine. I know that Artin tells you to prove this with row operations, which you have done, but it could be instructive to see more reasons why this result is true. Try to fill in the details of this proof:
Induct on $n$ where $A$ is an n by n matrix. In calculating $\det A$, expand along the first column, and calculate $\det A^T$ by expanding along the first row.
|
298,583
|
I found this exercise in Artin. It asks me to prove that $\det A= \det A^T$ where $A^T$ is the transpose of the matrix $A$.
**Can anyone please comment whether my proof is correct or not?**
*Attempted solution:* If $\det A=0$, the $A$ is non-invertible. We know that a matrix is invertible iff $A^T$ is invertible. As $A$ is non-invertible, so is $A^T$ and therefore $\det A^T=0$.
If the matrix is invertible, then $A=E\_rE\_{r-1}\dots E\_1$ for a finite sequence of elementary row operations, $E\_i$. Using the fact that $(AB)^T=B^TA^T$ and using induction, we infer that $A^T=E\_1^TE\_2^T\dots E\_r^T$. So, $\det A^T=\det (E\_1^T)\det(E\_2^T)\dots \det(E\_r^T)$.As $E\_i^T$ is an elementary row-operation as well of the same kind, $\det E\_i^T=\det E\_i$. Using that, $\det A^T=\det (E\_1E\_2\dots E\_r)=\det A$.
|
2013/02/09
|
[
"https://math.stackexchange.com/questions/298583",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
Your proof seems fine. I know that Artin tells you to prove this with row operations, which you have done, but it could be instructive to see more reasons why this result is true. Try to fill in the details of this proof:
Induct on $n$ where $A$ is an n by n matrix. In calculating $\det A$, expand along the first column, and calculate $\det A^T$ by expanding along the first row.
|
Two proofs are given here, both "your proof" and "a clearer version" of those in the other answers: <https://www.math.upenn.edu/~ekorman/teaching/det.pdf>
They seem fine but I have not verified them. (If somebody does, they could edit my answer or comment below. The paper is just a memo by a then-graduate student, it seems.)
|
298,583
|
I found this exercise in Artin. It asks me to prove that $\det A= \det A^T$ where $A^T$ is the transpose of the matrix $A$.
**Can anyone please comment whether my proof is correct or not?**
*Attempted solution:* If $\det A=0$, the $A$ is non-invertible. We know that a matrix is invertible iff $A^T$ is invertible. As $A$ is non-invertible, so is $A^T$ and therefore $\det A^T=0$.
If the matrix is invertible, then $A=E\_rE\_{r-1}\dots E\_1$ for a finite sequence of elementary row operations, $E\_i$. Using the fact that $(AB)^T=B^TA^T$ and using induction, we infer that $A^T=E\_1^TE\_2^T\dots E\_r^T$. So, $\det A^T=\det (E\_1^T)\det(E\_2^T)\dots \det(E\_r^T)$.As $E\_i^T$ is an elementary row-operation as well of the same kind, $\det E\_i^T=\det E\_i$. Using that, $\det A^T=\det (E\_1E\_2\dots E\_r)=\det A$.
|
2013/02/09
|
[
"https://math.stackexchange.com/questions/298583",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
While your proof is basically correct, I would not consider it my favourite proof of this fact, for the following reasons:
* It uses the multiplicativity of determinants, which is a much less elementary property than invariance under transposition.
* It works only for matrices over a field, while the definition of the determinant, and the invariance under transposition, require no more than a commutative ring. There is a general principle that identities of this kind, if they hold over fields, must in fact be valid over commutative rings as well, but understanding that kind of argument requires an additional level of mathematical maturity; it is in most cases (like this one) much easier to just give a proof that is itself valid in the more general setting.
* It needs to single out the non-invertible case. If you would allow for a triangular matrix (for which the result is obvious) at the end of the product of elementary operations, you would not need to single out this case (and as a bonus you would in most cases need far fewer elementary operations). See [this answer](https://math.stackexchange.com/a/283677/18880) to a similar question where the use of row operations was imposed (but the answer does not say what kind of matrix one is reducing to).
How I would prove this depends on the definition of the determinant has been given. If it is defined using the Leibniz formula (which in my opinion is the right *definition* to give, although a different *motivation* should first be given), then the proof just amounts to showing that every permutation has the same sign as its inverse, which is quite elementary (and can by the way be done in a similar way as your proof, but using a decomposition into transpositions).
If on the other hand one has defined the determinant as unique $n$-linear alternating function on an $n$ dimensional vector space taking value $1$ on a given ordered basis, (which still requires using Leibniz or a substitute for proving existence) then invariance under transposition is harder to see. Here one needs to pass to the dual vector space, but it seems necessary to use the fact that if $v\_1,\ldots,v\_n$ are vectors and $\alpha\_1,\ldots,\alpha\_n$ are linear forms, then the determinant
$$
\begin{vmatrix}\alpha\_1(v\_1)&\ldots&\alpha\_1(v\_n)\\
\vdots&\ddots&\vdots\\\alpha\_n(v\_1)&\ldots&\alpha\_n(v\_n)\end{vmatrix}
$$
is not only $n$-linear and alternating in $v\_1,\ldots,v\_n$ for fixed $\alpha\_1,\ldots,\alpha\_n$ (as is clear from the definition) but also $n$-linear and alternating in $\alpha\_1,\ldots,\alpha\_n$ (for fixed $v\_1,\ldots,v\_n$); I can see no easy argument for this, other than using the Leibniz formula. Once this is established, it is easy to show that a linear operator $f$ induces the same scalar factor on $n$-linear forms when applied to $n$-uplets of vectors as it does when applied (on the right) to $n$-uplets of linear forms, in other words its determinant is the same as that of its transpose (in essence, both cases correspond to inserting an $f$ between each $\alpha\_i$ and $v\_j$ in the above determinant).
This still does not provide a context in which using row operations to prove this fact would be a natural choice. It is not clear to me from the question whether Artin actually suggests this, and if so why. The only reason I can think of using such an argument is when somebody commands *thou shall not use the Leibniz formula*.
|
I believe your proof is correct.
Note that the best way of proving that $\det(A)=\det(A^t)$ depends very much on the definition of the determinant you are using. My personal favorite way of proving it is by giving a definition of the determinant such that $\det(A)=\det(A^t)$ is *obviously* true.
One possible definition of the determinant of an $(n\times n)$-matrix is
$$ \sum\_{\text{pick $n$ different numbers in the} \atop \text{matrix, no two in the same row or column}} \text{sign}(\text{your choice of numbers})\cdot(\text{product of the numbers}) .$$
In this formula the tiny text under the summation-symbol reads "pick $n$ different numbers in the matrix, no two in the same row or column". The sign of such a choice of numbers is calculated by drawing a line segment between any pair of chosen numbers and then calculating
$$ (-1)^{\text{number of line segments with positive slope}} .$$
If you follow this definition, it is clear that the determinant does not change upon transposing the matrix (the only thing you have to observe is that a line segment with positive slope is transposed into one with positive slope, and a line segment with negative slope is transposed into one with negative slope).
Of course, using this definition gives disadvantages in proving other properties of the determinant (well, I suppose so).
|
298,583
|
I found this exercise in Artin. It asks me to prove that $\det A= \det A^T$ where $A^T$ is the transpose of the matrix $A$.
**Can anyone please comment whether my proof is correct or not?**
*Attempted solution:* If $\det A=0$, the $A$ is non-invertible. We know that a matrix is invertible iff $A^T$ is invertible. As $A$ is non-invertible, so is $A^T$ and therefore $\det A^T=0$.
If the matrix is invertible, then $A=E\_rE\_{r-1}\dots E\_1$ for a finite sequence of elementary row operations, $E\_i$. Using the fact that $(AB)^T=B^TA^T$ and using induction, we infer that $A^T=E\_1^TE\_2^T\dots E\_r^T$. So, $\det A^T=\det (E\_1^T)\det(E\_2^T)\dots \det(E\_r^T)$.As $E\_i^T$ is an elementary row-operation as well of the same kind, $\det E\_i^T=\det E\_i$. Using that, $\det A^T=\det (E\_1E\_2\dots E\_r)=\det A$.
|
2013/02/09
|
[
"https://math.stackexchange.com/questions/298583",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
I believe your proof is correct.
Note that the best way of proving that $\det(A)=\det(A^t)$ depends very much on the definition of the determinant you are using. My personal favorite way of proving it is by giving a definition of the determinant such that $\det(A)=\det(A^t)$ is *obviously* true.
One possible definition of the determinant of an $(n\times n)$-matrix is
$$ \sum\_{\text{pick $n$ different numbers in the} \atop \text{matrix, no two in the same row or column}} \text{sign}(\text{your choice of numbers})\cdot(\text{product of the numbers}) .$$
In this formula the tiny text under the summation-symbol reads "pick $n$ different numbers in the matrix, no two in the same row or column". The sign of such a choice of numbers is calculated by drawing a line segment between any pair of chosen numbers and then calculating
$$ (-1)^{\text{number of line segments with positive slope}} .$$
If you follow this definition, it is clear that the determinant does not change upon transposing the matrix (the only thing you have to observe is that a line segment with positive slope is transposed into one with positive slope, and a line segment with negative slope is transposed into one with negative slope).
Of course, using this definition gives disadvantages in proving other properties of the determinant (well, I suppose so).
|
Two proofs are given here, both "your proof" and "a clearer version" of those in the other answers: <https://www.math.upenn.edu/~ekorman/teaching/det.pdf>
They seem fine but I have not verified them. (If somebody does, they could edit my answer or comment below. The paper is just a memo by a then-graduate student, it seems.)
|
298,583
|
I found this exercise in Artin. It asks me to prove that $\det A= \det A^T$ where $A^T$ is the transpose of the matrix $A$.
**Can anyone please comment whether my proof is correct or not?**
*Attempted solution:* If $\det A=0$, the $A$ is non-invertible. We know that a matrix is invertible iff $A^T$ is invertible. As $A$ is non-invertible, so is $A^T$ and therefore $\det A^T=0$.
If the matrix is invertible, then $A=E\_rE\_{r-1}\dots E\_1$ for a finite sequence of elementary row operations, $E\_i$. Using the fact that $(AB)^T=B^TA^T$ and using induction, we infer that $A^T=E\_1^TE\_2^T\dots E\_r^T$. So, $\det A^T=\det (E\_1^T)\det(E\_2^T)\dots \det(E\_r^T)$.As $E\_i^T$ is an elementary row-operation as well of the same kind, $\det E\_i^T=\det E\_i$. Using that, $\det A^T=\det (E\_1E\_2\dots E\_r)=\det A$.
|
2013/02/09
|
[
"https://math.stackexchange.com/questions/298583",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
While your proof is basically correct, I would not consider it my favourite proof of this fact, for the following reasons:
* It uses the multiplicativity of determinants, which is a much less elementary property than invariance under transposition.
* It works only for matrices over a field, while the definition of the determinant, and the invariance under transposition, require no more than a commutative ring. There is a general principle that identities of this kind, if they hold over fields, must in fact be valid over commutative rings as well, but understanding that kind of argument requires an additional level of mathematical maturity; it is in most cases (like this one) much easier to just give a proof that is itself valid in the more general setting.
* It needs to single out the non-invertible case. If you would allow for a triangular matrix (for which the result is obvious) at the end of the product of elementary operations, you would not need to single out this case (and as a bonus you would in most cases need far fewer elementary operations). See [this answer](https://math.stackexchange.com/a/283677/18880) to a similar question where the use of row operations was imposed (but the answer does not say what kind of matrix one is reducing to).
How I would prove this depends on the definition of the determinant has been given. If it is defined using the Leibniz formula (which in my opinion is the right *definition* to give, although a different *motivation* should first be given), then the proof just amounts to showing that every permutation has the same sign as its inverse, which is quite elementary (and can by the way be done in a similar way as your proof, but using a decomposition into transpositions).
If on the other hand one has defined the determinant as unique $n$-linear alternating function on an $n$ dimensional vector space taking value $1$ on a given ordered basis, (which still requires using Leibniz or a substitute for proving existence) then invariance under transposition is harder to see. Here one needs to pass to the dual vector space, but it seems necessary to use the fact that if $v\_1,\ldots,v\_n$ are vectors and $\alpha\_1,\ldots,\alpha\_n$ are linear forms, then the determinant
$$
\begin{vmatrix}\alpha\_1(v\_1)&\ldots&\alpha\_1(v\_n)\\
\vdots&\ddots&\vdots\\\alpha\_n(v\_1)&\ldots&\alpha\_n(v\_n)\end{vmatrix}
$$
is not only $n$-linear and alternating in $v\_1,\ldots,v\_n$ for fixed $\alpha\_1,\ldots,\alpha\_n$ (as is clear from the definition) but also $n$-linear and alternating in $\alpha\_1,\ldots,\alpha\_n$ (for fixed $v\_1,\ldots,v\_n$); I can see no easy argument for this, other than using the Leibniz formula. Once this is established, it is easy to show that a linear operator $f$ induces the same scalar factor on $n$-linear forms when applied to $n$-uplets of vectors as it does when applied (on the right) to $n$-uplets of linear forms, in other words its determinant is the same as that of its transpose (in essence, both cases correspond to inserting an $f$ between each $\alpha\_i$ and $v\_j$ in the above determinant).
This still does not provide a context in which using row operations to prove this fact would be a natural choice. It is not clear to me from the question whether Artin actually suggests this, and if so why. The only reason I can think of using such an argument is when somebody commands *thou shall not use the Leibniz formula*.
|
Two proofs are given here, both "your proof" and "a clearer version" of those in the other answers: <https://www.math.upenn.edu/~ekorman/teaching/det.pdf>
They seem fine but I have not verified them. (If somebody does, they could edit my answer or comment below. The paper is just a memo by a then-graduate student, it seems.)
|
381,636
|
I've just installed Ubuntu 11.10 Desktop on an old laptop of mine and I wanted to set it up so I could remote into it from my windows desktop. I've installed XRDP, but when I attempt to login using sesman-x11rdp it logs in, then the window shuts down.
I've checked over the logs and here is what I get at the time of login:
```
[20120123-16:49:23] [INFO ] scp thread on sck 8 started successfully
[20120123-16:49:23] [INFO ] granted TS access to user nicholas
[20120123-16:49:24] [INFO ] starting X11rdp session...
[20120123-16:49:24] [CORE ] error starting X server - user nicholas - pid 3869
[20120123-16:49:24] [DEBUG] errno: 2, description: No such file or directory
[20120123-16:49:24] [DEBUG] execve parameter list: 11
[20120123-16:49:24] [DEBUG] argv[0] = X11rdp
[20120123-16:49:24] [DEBUG] argv[1] = :11
[20120123-16:49:24] [DEBUG] argv[2] = -geometry
[20120123-16:49:24] [DEBUG] argv[3] = 1280x720
[20120123-16:49:24] [DEBUG] argv[4] = -depth
[20120123-16:49:24] [DEBUG] argv[5] = 16
[20120123-16:49:24] [DEBUG] argv[6] = -bs
[20120123-16:49:24] [DEBUG] argv[7] = -ac
[20120123-16:49:24] [DEBUG] argv[8] = -nolisten
[20120123-16:49:24] [DEBUG] argv[9] = tcp
[20120123-16:49:25] [DEBUG] argv[10] = (null)
[20120123-16:49:34] [ERROR] X server for display 11 startup timeout
[20120123-16:49:34] [ERROR] X server for display 11 startup timeout
[20120123-16:49:34] [INFO ] starting xrdp-sessvc - xpid=3869 - wmpid=3868
[20120123-16:49:34] [ERROR] another Xserver is already active on display 11
[20120123-16:49:34] [DEBUG] aborting connection...
[20120123-16:49:34] [INFO ] session 3867 - user nicholas - terminated
```
Can anyone point me to the proper way to get this working with x11rdp?
|
2012/01/23
|
[
"https://superuser.com/questions/381636",
"https://superuser.com",
"https://superuser.com/users/105190/"
] |
xrdp and X11rdp server are not the same. xrdp makes "only" the connection available but does not provide the screen content. They are two separate programs. So you can install xrdp easily and also a VNC server `sudo apt-get install vnc-common vnc4server` to get sesman-Xvnc running. Or you install manually with this great tutorial the X11rdp server (then you also need to install the newest xrdp manually):
<http://scarygliders.net/2011/11/17/x11rdp-ubuntu-11-10-gnome-3-xrdp-customization-new-hotness/>
|
I was having the same error in RHEL 6: [ERROR] another Xserver is already active on display... .
I was able to get xrdp to work by installing gnome packages. I do not have my initial list of gnome packages. The package names may be different on other Linux distributions. Adding these got xrdp working:
Added packages:
```
gnome-desktop
gnome-session-xsession
gnome-applets
gnome-menus
```
(NOTE - many other packages were installed as dependencies. It is very possible that it was installation of one of the dependencies actually fixed this problem.)
Final list of gnome packages I have installed are:
```
gnome-applets
gnome-desktop
gnome-doc-utils-stylesheets
gnome-icon-theme
gnome-keyring
gnome-menus.
gnome-panel
gnome-panel-libs
gnome-python2
gnome-python2-applet
gnome-python2-bonobo
gnome-python2-canvas
gnome-python2-desktop
gnome-python2-extras
gnome-python2-gnome
gnome-python2-gnomevfs
gnome-python2-libegg
gnome-session
gnome-session-xsession
gnome-settings-daemon
gnome-terminal
gnome-themes
gnome-user-docs
gnome-vfs2
```
I could not find any relationship of the xrdp error message to this fix. I made a guess that the error message may actually be a misrepresentation of the real error. This is why I tried installing additional gnome packages. Hope this helps someone else get by this problem.
|
381,636
|
I've just installed Ubuntu 11.10 Desktop on an old laptop of mine and I wanted to set it up so I could remote into it from my windows desktop. I've installed XRDP, but when I attempt to login using sesman-x11rdp it logs in, then the window shuts down.
I've checked over the logs and here is what I get at the time of login:
```
[20120123-16:49:23] [INFO ] scp thread on sck 8 started successfully
[20120123-16:49:23] [INFO ] granted TS access to user nicholas
[20120123-16:49:24] [INFO ] starting X11rdp session...
[20120123-16:49:24] [CORE ] error starting X server - user nicholas - pid 3869
[20120123-16:49:24] [DEBUG] errno: 2, description: No such file or directory
[20120123-16:49:24] [DEBUG] execve parameter list: 11
[20120123-16:49:24] [DEBUG] argv[0] = X11rdp
[20120123-16:49:24] [DEBUG] argv[1] = :11
[20120123-16:49:24] [DEBUG] argv[2] = -geometry
[20120123-16:49:24] [DEBUG] argv[3] = 1280x720
[20120123-16:49:24] [DEBUG] argv[4] = -depth
[20120123-16:49:24] [DEBUG] argv[5] = 16
[20120123-16:49:24] [DEBUG] argv[6] = -bs
[20120123-16:49:24] [DEBUG] argv[7] = -ac
[20120123-16:49:24] [DEBUG] argv[8] = -nolisten
[20120123-16:49:24] [DEBUG] argv[9] = tcp
[20120123-16:49:25] [DEBUG] argv[10] = (null)
[20120123-16:49:34] [ERROR] X server for display 11 startup timeout
[20120123-16:49:34] [ERROR] X server for display 11 startup timeout
[20120123-16:49:34] [INFO ] starting xrdp-sessvc - xpid=3869 - wmpid=3868
[20120123-16:49:34] [ERROR] another Xserver is already active on display 11
[20120123-16:49:34] [DEBUG] aborting connection...
[20120123-16:49:34] [INFO ] session 3867 - user nicholas - terminated
```
Can anyone point me to the proper way to get this working with x11rdp?
|
2012/01/23
|
[
"https://superuser.com/questions/381636",
"https://superuser.com",
"https://superuser.com/users/105190/"
] |
Options /etc/xrdp/xrdp.ini:
```
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1
max_bpp=16
#black=000000
grey=d6d3ce
#dark_grey=808080
#blue=08246b
#dark_blue=08246b
#white=ffffff
#red=ff0000
#green=00ff00
#background=626c72
[xrdp1]
name=RDP
lib=libxup.so
username=ask
password=ask
ip=127.0.0.1
port=-1
xserverbpp=16
[xrdp2]
name=VNC
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1
```
May be it will help you.
Line 7, bpp(bit per pixel) must be 16, and sections with module libxup.so too.
Clients must connect to XRDP server with options 16 bit per pixel.
Sorry my english is bad.
|
xrdp and X11rdp server are not the same. xrdp makes "only" the connection available but does not provide the screen content. They are two separate programs. So you can install xrdp easily and also a VNC server `sudo apt-get install vnc-common vnc4server` to get sesman-Xvnc running. Or you install manually with this great tutorial the X11rdp server (then you also need to install the newest xrdp manually):
<http://scarygliders.net/2011/11/17/x11rdp-ubuntu-11-10-gnome-3-xrdp-customization-new-hotness/>
|
381,636
|
I've just installed Ubuntu 11.10 Desktop on an old laptop of mine and I wanted to set it up so I could remote into it from my windows desktop. I've installed XRDP, but when I attempt to login using sesman-x11rdp it logs in, then the window shuts down.
I've checked over the logs and here is what I get at the time of login:
```
[20120123-16:49:23] [INFO ] scp thread on sck 8 started successfully
[20120123-16:49:23] [INFO ] granted TS access to user nicholas
[20120123-16:49:24] [INFO ] starting X11rdp session...
[20120123-16:49:24] [CORE ] error starting X server - user nicholas - pid 3869
[20120123-16:49:24] [DEBUG] errno: 2, description: No such file or directory
[20120123-16:49:24] [DEBUG] execve parameter list: 11
[20120123-16:49:24] [DEBUG] argv[0] = X11rdp
[20120123-16:49:24] [DEBUG] argv[1] = :11
[20120123-16:49:24] [DEBUG] argv[2] = -geometry
[20120123-16:49:24] [DEBUG] argv[3] = 1280x720
[20120123-16:49:24] [DEBUG] argv[4] = -depth
[20120123-16:49:24] [DEBUG] argv[5] = 16
[20120123-16:49:24] [DEBUG] argv[6] = -bs
[20120123-16:49:24] [DEBUG] argv[7] = -ac
[20120123-16:49:24] [DEBUG] argv[8] = -nolisten
[20120123-16:49:24] [DEBUG] argv[9] = tcp
[20120123-16:49:25] [DEBUG] argv[10] = (null)
[20120123-16:49:34] [ERROR] X server for display 11 startup timeout
[20120123-16:49:34] [ERROR] X server for display 11 startup timeout
[20120123-16:49:34] [INFO ] starting xrdp-sessvc - xpid=3869 - wmpid=3868
[20120123-16:49:34] [ERROR] another Xserver is already active on display 11
[20120123-16:49:34] [DEBUG] aborting connection...
[20120123-16:49:34] [INFO ] session 3867 - user nicholas - terminated
```
Can anyone point me to the proper way to get this working with x11rdp?
|
2012/01/23
|
[
"https://superuser.com/questions/381636",
"https://superuser.com",
"https://superuser.com/users/105190/"
] |
Options /etc/xrdp/xrdp.ini:
```
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1
max_bpp=16
#black=000000
grey=d6d3ce
#dark_grey=808080
#blue=08246b
#dark_blue=08246b
#white=ffffff
#red=ff0000
#green=00ff00
#background=626c72
[xrdp1]
name=RDP
lib=libxup.so
username=ask
password=ask
ip=127.0.0.1
port=-1
xserverbpp=16
[xrdp2]
name=VNC
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1
```
May be it will help you.
Line 7, bpp(bit per pixel) must be 16, and sections with module libxup.so too.
Clients must connect to XRDP server with options 16 bit per pixel.
Sorry my english is bad.
|
I was having the same error in RHEL 6: [ERROR] another Xserver is already active on display... .
I was able to get xrdp to work by installing gnome packages. I do not have my initial list of gnome packages. The package names may be different on other Linux distributions. Adding these got xrdp working:
Added packages:
```
gnome-desktop
gnome-session-xsession
gnome-applets
gnome-menus
```
(NOTE - many other packages were installed as dependencies. It is very possible that it was installation of one of the dependencies actually fixed this problem.)
Final list of gnome packages I have installed are:
```
gnome-applets
gnome-desktop
gnome-doc-utils-stylesheets
gnome-icon-theme
gnome-keyring
gnome-menus.
gnome-panel
gnome-panel-libs
gnome-python2
gnome-python2-applet
gnome-python2-bonobo
gnome-python2-canvas
gnome-python2-desktop
gnome-python2-extras
gnome-python2-gnome
gnome-python2-gnomevfs
gnome-python2-libegg
gnome-session
gnome-session-xsession
gnome-settings-daemon
gnome-terminal
gnome-themes
gnome-user-docs
gnome-vfs2
```
I could not find any relationship of the xrdp error message to this fix. I made a guess that the error message may actually be a misrepresentation of the real error. This is why I tried installing additional gnome packages. Hope this helps someone else get by this problem.
|
50,021,849
|
Options are in blue color, and with the help of javascript, I am checking whether the option background color is blue or not if it is not blue then execute ahead else alert some text.
```js
function click_option_A() {
var clr_1_chk = document.getElementById("1");
//alert(clr_1_chk.style.backgroundColor);
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "1";
var confirm = window.confirm("Are you sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "A"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function click_option_B() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "2";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "B"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function click_option_C() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "3";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "C"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function click_option_D() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "4";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "D"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function correct_ans(){
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
var clr = "1";
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
var clr = "2";
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
var clr = "3";
}
else{
var clr = "4";
}
//alert('correct');
document.getElementById(clr).style.backgroundColor ="green";
}
function wrong_ans(){
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
var clr = "1";
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
var clr = "2";
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
var clr = "3";
}
else{
var clr = "4";
}
document.getElementById(clr).style.backgroundColor ="red";
}
```
```css
td{
background-color: blue;
color: white;
}
```
```html
<div class="container">
<!--<form method="post" enctype="multipart/form-data" class="form-horizontal">-->
<table class="table table-bordered table-responsive">
<tr class="text-center">
<td colspan="2">Who was First Prime Minister of India?(15304)</td>
</tr>
<tr>
<td id="1" onclick="click_option_A()">A) M K Gandhi</td>
<td id="2" onclick="click_option_B()">B) Jawaharlal Nehru</td>
</tr>
<tr>
<td id="3" onclick="click_option_C()">C) Rajendra Prasad</td>
<td id="4" onclick="click_option_D()">D) Chandra Shekhar Azad</td>
</tr>
</table>
<!--</form>-->
</div>
```
I tried the above code, but it always alert me that I have locked the answer but I haven't.
Options are in blue color, and with the help of javascript, I am checking whether the option background color is blue or not if it is not blue then execute ahead else alert some text.
|
2018/04/25
|
[
"https://Stackoverflow.com/questions/50021849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8995989/"
] |
While Prajwal is on the right track his answer is not quite complete. `getComputedStyle()` will return an RGB value when `backgroundColor` is called. You will need to check against that instead of the string "blue". So in your case `getComputedStyle(clr_1_chk).backgroundColor === "rgb(0, 0, 255)";`
However, best practice would be to store your questions in an array of javascript objects. There, you could have the correct answer stored and whether or not the question is locked. As requested I have mocked up a quick dummy example of what that code would look like. I'm essentially using JS to create the HTML. I didn't include the `setTimeout` that you requested but I'm sure you can add this easily. Please make sure you include the HTML, CSS, and JS for this to work. Please note the error after question 4 is just saying there are no more questions to generate. Hope this gives you something to start with:
```js
var questions = [{
questionId: "question1",
answerId: "B",
question: "Who was First Prime Minister of India?(15304)",
options: ["A) M K Gandhi", "B) Jawaharlal Nehru", "C) Rajendra Prasad", "D) Chandra Shekhar Azad"],
answer: "B) Jawaharlal Nehru",
locked: false
},
{
questionId: "question2",
answerId: "D",
question: "What is 2 + 2",
options: ["A) 1", "B) 2", "C) 3", "D) 4"],
answer: "D) 4",
locked: false
},
{
questionId: "question3",
question: "What is 2 - 1",
answerId: "A",
options: ["A) 1", "B) 2", "C) 3", "D) 4"],
answer: "A) 1",
locked: false
},
{
questionId: "question4",
answerId: "C",
question: "What is 2 + 4",
options: ["A) 1", "B) 2", "C) 6", "D) 4"],
answer: "C) 6",
locked: false
}
];
var allHtml;
var table = document.getElementById("test");
var i = 0;
document.querySelector("#start").innerHTML = `<button onclick="startTest()">START TEST</button>`;
function generateQuestion(question) {
i += 1;
var newQuestion = `
<tr class="text-center">
<td colspan="2">${question.question}</td>
</tr>
<tr>
<td id="A${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[0]}</td>
<td id="B${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[1]}</td>
</tr>
<tr>
<td id="C${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[2]}</td>
<td id="D${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[3]}</td>
</tr>
`;
allHtml = table.innerHTML + newQuestion;
table.innerHTML = allHtml;
}
function onSelect(e) {
var selection = e.currentTarget;
var questionId = e.currentTarget.className;
var currentQuestion = questions.find(function(q) {
return q.questionId == questionId
});
if (currentQuestion.locked) {
alert("Question already answered");
return;
} else if (currentQuestion.answer === e.currentTarget.innerText) {
alert("Correct!!!");
currentQuestion.locked = true;
selection.classList.add('correct');
} else {
alert("Incorrect...");
currentQuestion.locked = true;
selection.classList.add('incorrect');
document.getElementById(currentQuestion.answerId + i).classList.add('correct');
}
generateQuestion(questions[i]);
}
function startTest() {
generateQuestion(questions[i]);
document.querySelector("#start").innerHTML = '';
}
```
```css
.correct {
background-color: green;
}
.incorrect {
background-color: red;
}
```
```html
<div id="start"></div>
<table id="test"></table>
```
What I'm doing here is setting the answer classes to the question id in the object. Then using that I get the correct question out of the answers array. I check to make sure the answer is not locked, then I get the innerText of the answer and check that against the answer id in the object. Lastly I lock the question after the user answers and apply the css classes to the correct answer and the incorrect selection if applicable. Once all that is done, I call `generateQuestion` to create the next question.
And here is the updated code from your question that works correctly. Also, although it's not updated in my answer you really should rename your id's. It's best to begin them with a letter [A-Za-z].:
```js
function click_option_A() {
var clr_1_chk = document.getElementById("1");
//alert(clr_1_chk.style.backgroundColor);
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
console.log(getComputedStyle(clr_1_chk).backgroundColor);
if (getComputedStyle(clr_1_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_2_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_3_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_4_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else {
var clr = "1";
var confirm = window.confirm("Are you sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor = "yellow";
var right_answer = "B";
if (right_answer == "A") {
//correct_ans();
setTimeout(correct_ans, 3000);
} else {
setTimeout(wrong_ans, 3000);
}
}
}
}
function click_option_B() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if (getComputedStyle(clr_1_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_2_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_3_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_4_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else {
var clr = "2";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor = "yellow";
var right_answer = "B";
if (right_answer == "B") {
//correct_ans();
setTimeout(correct_ans, 3000);
} else {
setTimeout(wrong_ans, 3000);
}
}
}
}
function click_option_C() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if (getComputedStyle(clr_1_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_2_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_3_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_4_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else {
var clr = "3";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor = "yellow";
var right_answer = "B";
if (right_answer == "C") {
//correct_ans();
setTimeout(correct_ans, 3000);
} else {
setTimeout(wrong_ans, 3000);
}
}
}
}
function click_option_D() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if (getComputedStyle(clr_1_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_2_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_3_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else if (getComputedStyle(clr_4_chk).backgroundColor != "rgb(0, 0, 255)") {
alert("You have already locked the answer!")
} else {
var clr = "4";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor = "yellow";
var right_answer = "B";
if (right_answer == "D") {
//correct_ans();
setTimeout(correct_ans, 3000);
} else {
setTimeout(wrong_ans, 3000);
}
}
}
}
function correct_ans() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if (getComputedStyle(clr_1_chk).backgroundColor != "rgb(0, 0, 255)") {
var clr = "1";
} else if (getComputedStyle(clr_2_chk).backgroundColor != "rgb(0, 0, 255)") {
var clr = "2";
} else if (getComputedStyle(clr_3_chk).backgroundColor != "rgb(0, 0, 255)") {
var clr = "3";
} else {
var clr = "4";
}
//alert('correct');
document.getElementById(clr).style.backgroundColor = "green";
}
function wrong_ans() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if (getComputedStyle(clr_1_chk).backgroundColor != "rgb(0, 0, 255)") {
var clr = "1";
} else if (getComputedStyle(clr_2_chk).backgroundColor != "rgb(0, 0, 255)") {
var clr = "2";
} else if (getComputedStyle(clr_3_chk).backgroundColor != "rgb(0, 0, 255)") {
var clr = "3";
} else {
var clr = "4";
}
document.getElementById(clr).style.backgroundColor = "red";
}
```
```css
td {
background-color: blue;
color: white;
}
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<!--<form method="post" enctype="multipart/form-data" class="form-horizontal">-->
<table class="table table-bordered table-responsive">
<tr class="text-center">
<td colspan="2">Who was First Prime Minister of India?(15304)</td>
</tr>
<tr>
<td id="1" onclick="click_option_A()">A) M K Gandhi</td>
<td id="2" onclick="click_option_B()">B) Jawaharlal Nehru</td>
</tr>
<tr>
<td id="3" onclick="click_option_C()">C) Rajendra Prasad</td>
<td id="4" onclick="click_option_D()">D) Chandra Shekhar Azad</td>
</tr>
</table>
<!--</form>-->
</div>
```
|
The reason you are not getting the style as `blue` here, but empty string, Because `element.style` returns only ***in-line stylings***, not those defined by CSS.
If you need CSS styling you will have to obtain computed styles using `window.getComputedStyle(<element>)`.
More info at [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)
In the below snippet, I've set up inline styling for `td`. And hence you will get the style as `blue`.
```js
function click_option_A() {
var clr_1_chk = document.getElementById("1");
//alert(clr_1_chk.style.backgroundColor);
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "1";
var confirm = window.confirm("Are you sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "A"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function click_option_B() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "2";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "B"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function click_option_C() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "3";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "C"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function click_option_D() {
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else if(clr_4_chk.style.backgroundColor !== "blue"){
alert("You have already locked the answer!")
}
else{
var clr = "4";
var confirm = window.confirm("Are you Sure?");
if (confirm) {
window.document.getElementById(clr).style.backgroundColor ="yellow";
var right_answer = "B";
if(right_answer == "D"){
//correct_ans();
setTimeout(correct_ans,3000);
}
else{
setTimeout(wrong_ans,3000);
}
}
}
}
function correct_ans(){
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
var clr = "1";
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
var clr = "2";
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
var clr = "3";
}
else{
var clr = "4";
}
//alert('correct');
document.getElementById(clr).style.backgroundColor ="green";
}
function wrong_ans(){
var clr_1_chk = document.getElementById("1");
var clr_2_chk = document.getElementById("2");
var clr_3_chk = document.getElementById("3");
var clr_4_chk = document.getElementById("4");
if(clr_1_chk.style.backgroundColor !== "blue"){
var clr = "1";
}
else if(clr_2_chk.style.backgroundColor !== "blue"){
var clr = "2";
}
else if(clr_3_chk.style.backgroundColor !== "blue"){
var clr = "3";
}
else{
var clr = "4";
}
document.getElementById(clr).style.backgroundColor ="red";
}
```
```css
td{
background-color: blue;
color: white;
}
```
```html
<div class="container">
<!--<form method="post" enctype="multipart/form-data" class="form-horizontal">-->
<table class="table table-bordered table-responsive">
<tr class="text-center">
<td colspan="2">Who was First Prime Minister of India?(15304)</td>
</tr>
<tr>
<td id="1" style="background-color: blue;color: white;" onclick="click_option_A()">A) M K Gandhi</td>
<td style="background-color: blue;color: white;" id="2" onclick="click_option_B()">B) Jawaharlal Nehru</td>
</tr>
<tr>
<td style="background-color: blue;color: white;" id="3" onclick="click_option_C()">C) Rajendra Prasad</td>
<td style="background-color: blue;color: white;" id="4" onclick="click_option_D()">D) Chandra Shekhar Azad</td>
</tr>
</table>
<!--</form>-->
</div>
```
---
I would suggest you to keep some JS object to check the options and provide correct answer. It is not advised to refer object style to get user option.
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
To get the results you want, you will need to create a table (or use a query to generate a "temp" table) and then use a left join to your calculation query to get rows for every hour - even those with 0 volume.
For example, assume I have a table with app\_date and app\_hour fields. Also assume that this table has a row for every day/hour you wish to report on.
The query would be:
```
SELECT NVL(c.num_apps,0) as num_apps, t.app_date, t.app_hour
FROM time_table t
LEFT OUTER JOIN
(
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
) c ON (t.app_date = c.app_date AND t.app_hour = c.app_hour)
```
|
You can also use a CASE statement in the SELECT to force the value you want.
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
To get the results you want, you will need to create a table (or use a query to generate a "temp" table) and then use a left join to your calculation query to get rows for every hour - even those with 0 volume.
For example, assume I have a table with app\_date and app\_hour fields. Also assume that this table has a row for every day/hour you wish to report on.
The query would be:
```
SELECT NVL(c.num_apps,0) as num_apps, t.app_date, t.app_hour
FROM time_table t
LEFT OUTER JOIN
(
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
) c ON (t.app_date = c.app_date AND t.app_hour = c.app_hour)
```
|
It can be useful to have a "sequence table" kicking around, for all sorts of reasons, something that looks like this:
```
create table dbo.sequence
(
id int not null primary key clustered ,
)
```
Load it up with million or so rows, covering positive and negative values.
Then, given a table that looks like this
```
create table dbo.SomeTable
(
account_id int not null primary key clustered ,
date_created date not null ,
time_created time not null ,
)
```
Your query is then as simple as (in SQL Server):
```
select year_created = years.id ,
month_created = months.id ,
day_created = days.id ,
hour_created = hours.id ,
volume = t.volume
from ( select * ,
is_leap_year = case
when id % 400 = 0 then 1
when id % 100 = 0 then 0
when id % 4 = 0 then 1
else 0
end
from dbo.sequence
where id between 1980 and year(current_timestamp)
) years
cross join ( select *
from dbo.sequence
where id between 1 and 12
) months
left join ( select *
from dbo.sequence
where id between 1 and 31
) days on days.id <= case months.id
when 2 then 28 + years.is_leap_year
when 4 then 30
when 6 then 30
when 9 then 30
when 11 then 30
else 31
end
cross join ( select *
from dbo.sequence
where id between 0 and 23
) hours
left join ( select date_created ,
hour_created = datepart(hour,time_created ) ,
volume = count(*)
from dbo.SomeTable
group by date_created ,
datepart(hour,time_created)
) t on datepart( year , t.date_created ) = years.id
and datepart( month , t.date_created ) = months.id
and datepart( day , t.date_created ) = days.id
and t.hour_created = hours.id
order by 1,2,3,4
```
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
To get the results you want, you will need to create a table (or use a query to generate a "temp" table) and then use a left join to your calculation query to get rows for every hour - even those with 0 volume.
For example, assume I have a table with app\_date and app\_hour fields. Also assume that this table has a row for every day/hour you wish to report on.
The query would be:
```
SELECT NVL(c.num_apps,0) as num_apps, t.app_date, t.app_hour
FROM time_table t
LEFT OUTER JOIN
(
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
) c ON (t.app_date = c.app_date AND t.app_hour = c.app_hour)
```
|
I believe the best solution is not to create some fancy temporary table but just use this construct:
```
select level
FROM Dual
CONNECT BY level <= 10
ORDER BY level;
```
This will give you (in ten rows):
1
2
3
4
5
6
7
8
9
10
For hours interval just little modification:
```
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
```
And just for the fun of it adding solution for you(I didn't try syntax, so I'm sorry for any mistake, but the idea is clear):
```
SELECT SUM(num_apps) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM(
SELECT count(*) as num_apps, created_ts
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-09-12','DD-MM-RR')
UNION ALL
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
)
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
;
```
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
To get the results you want, you will need to create a table (or use a query to generate a "temp" table) and then use a left join to your calculation query to get rows for every hour - even those with 0 volume.
For example, assume I have a table with app\_date and app\_hour fields. Also assume that this table has a row for every day/hour you wish to report on.
The query would be:
```
SELECT NVL(c.num_apps,0) as num_apps, t.app_date, t.app_hour
FROM time_table t
LEFT OUTER JOIN
(
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
) c ON (t.app_date = c.app_date AND t.app_hour = c.app_hour)
```
|
It's not clear to me if `created_ts` is a datetime or a varchar. If it's a datetime, you shouldn't use `to_date`; if it's a varchar, you shouldn't use `to_char`.
Assuming it's a datetime, and borrowing @jakub.petr's `FROM Dual CONNECT BY level` trick, I suggest:
```
SELECT count(*) as num_apps, to_char(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM (select level-1 as hour FROM Dual CONNECT BY level <= 24) h
LEFT JOIN accounts a on h.hour = to_number(to_char(a.created_ts,'HH24'))
WHERE created_ts >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY trunc(created_ts), h.hour
ORDER BY app_date, app_hour
```
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
I believe the best solution is not to create some fancy temporary table but just use this construct:
```
select level
FROM Dual
CONNECT BY level <= 10
ORDER BY level;
```
This will give you (in ten rows):
1
2
3
4
5
6
7
8
9
10
For hours interval just little modification:
```
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
```
And just for the fun of it adding solution for you(I didn't try syntax, so I'm sorry for any mistake, but the idea is clear):
```
SELECT SUM(num_apps) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM(
SELECT count(*) as num_apps, created_ts
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-09-12','DD-MM-RR')
UNION ALL
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
)
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
;
```
|
You can also use a CASE statement in the SELECT to force the value you want.
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
I believe the best solution is not to create some fancy temporary table but just use this construct:
```
select level
FROM Dual
CONNECT BY level <= 10
ORDER BY level;
```
This will give you (in ten rows):
1
2
3
4
5
6
7
8
9
10
For hours interval just little modification:
```
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
```
And just for the fun of it adding solution for you(I didn't try syntax, so I'm sorry for any mistake, but the idea is clear):
```
SELECT SUM(num_apps) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM(
SELECT count(*) as num_apps, created_ts
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-09-12','DD-MM-RR')
UNION ALL
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
)
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
;
```
|
It can be useful to have a "sequence table" kicking around, for all sorts of reasons, something that looks like this:
```
create table dbo.sequence
(
id int not null primary key clustered ,
)
```
Load it up with million or so rows, covering positive and negative values.
Then, given a table that looks like this
```
create table dbo.SomeTable
(
account_id int not null primary key clustered ,
date_created date not null ,
time_created time not null ,
)
```
Your query is then as simple as (in SQL Server):
```
select year_created = years.id ,
month_created = months.id ,
day_created = days.id ,
hour_created = hours.id ,
volume = t.volume
from ( select * ,
is_leap_year = case
when id % 400 = 0 then 1
when id % 100 = 0 then 0
when id % 4 = 0 then 1
else 0
end
from dbo.sequence
where id between 1980 and year(current_timestamp)
) years
cross join ( select *
from dbo.sequence
where id between 1 and 12
) months
left join ( select *
from dbo.sequence
where id between 1 and 31
) days on days.id <= case months.id
when 2 then 28 + years.is_leap_year
when 4 then 30
when 6 then 30
when 9 then 30
when 11 then 30
else 31
end
cross join ( select *
from dbo.sequence
where id between 0 and 23
) hours
left join ( select date_created ,
hour_created = datepart(hour,time_created ) ,
volume = count(*)
from dbo.SomeTable
group by date_created ,
datepart(hour,time_created)
) t on datepart( year , t.date_created ) = years.id
and datepart( month , t.date_created ) = months.id
and datepart( day , t.date_created ) = days.id
and t.hour_created = hours.id
order by 1,2,3,4
```
|
12,696,723
|
I have a question about a SQL query I am trying to write.
I need to query data from a database.
The database has, amongst others, these 3 fields:
Account\_ID #, Date\_Created, Time\_Created
I need to write a query that tells me how many accounts were opened per hour.
I have written said query, but there are times that there were 0 accounts created, so these "hours" are not populated in the results.
For example:
>
> Volume ***Date*\_**\_Hour
>
> 435 12-Aug-12 03
>
> 213 12-Aug-12 04
>
> 125 12-Aug-12 06
>
>
>
>
As seen in the example above, hour 5 did not have any accounts opened.
Is there a way that the result can populate the hour but and display 0 accounts opened for this hour?
Example of how I want my results to look like:
Volume ***Date***\_Hour
435 12-Aug-12 03
213 12-Aug-12 04
0 12-Aug-12 05
125 12-Aug-12 06
Thanks!
Update: This is what I have so far
```
SELECT count(*) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
```
|
2012/10/02
|
[
"https://Stackoverflow.com/questions/12696723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628798/"
] |
I believe the best solution is not to create some fancy temporary table but just use this construct:
```
select level
FROM Dual
CONNECT BY level <= 10
ORDER BY level;
```
This will give you (in ten rows):
1
2
3
4
5
6
7
8
9
10
For hours interval just little modification:
```
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
```
And just for the fun of it adding solution for you(I didn't try syntax, so I'm sorry for any mistake, but the idea is clear):
```
SELECT SUM(num_apps) as num_apps, to_date(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM(
SELECT count(*) as num_apps, created_ts
FROM accounts
WHERE To_Date(created_ts,'DD-Mon-RR') >= To_Date('16-09-12','DD-MM-RR')
UNION ALL
select 0 as num_apps, (To_Date('16-09-12','DD-MM-RR') + level / 24) as created_ts
FROM dual
CONNECT BY level <= (sysdate - To_Date('16-09-12','DD-MM-RR')) * 24 ;
)
GROUP BY To_Date(created_ts,'DD-Mon-RR'), To_Char(created_ts,'HH24')
ORDER BY app_date, app_hour
;
```
|
It's not clear to me if `created_ts` is a datetime or a varchar. If it's a datetime, you shouldn't use `to_date`; if it's a varchar, you shouldn't use `to_char`.
Assuming it's a datetime, and borrowing @jakub.petr's `FROM Dual CONNECT BY level` trick, I suggest:
```
SELECT count(*) as num_apps, to_char(created_ts,'DD-Mon-RR') as app_date, to_char(created_ts,'HH24') as app_hour
FROM (select level-1 as hour FROM Dual CONNECT BY level <= 24) h
LEFT JOIN accounts a on h.hour = to_number(to_char(a.created_ts,'HH24'))
WHERE created_ts >= To_Date('16-Aug-12','DD-Mon-RR')
GROUP BY trunc(created_ts), h.hour
ORDER BY app_date, app_hour
```
|
2,527,731
|
>
> $A$ and $B$ are subsets of universal set.
> $3$ elements of $A$ and $5$ elements of $B$ are not elements of the set $A \cap B$. Moreover $|A \cup B| = 16$ and $|\mathbb U| = 24$.
> What is the value of $|A'|$?
>
>
>
I currently don't have any idea about the question. Might I get your hints?
|
2017/11/19
|
[
"https://math.stackexchange.com/questions/2527731",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/489076/"
] |
$$3+5+|A\cap B|=16,$$
which gives $|A\cap B|=8.$
Thus, $$|A|=3+8=11$$ and
$$|A'|=24-11=13.$$
|
Hint. Note that the universal set is the disjoint union of $A$ , the set of elements of $B$ which are not elements of $A\cap B$ and the complement of $A\cup B$:
$$|\mathbb{U}|=|A|+|B\setminus(A\cap B)|+(|\mathbb{U}|-|A\cup B)|).$$
Therefore
$$|A|'=|\mathbb{U}|-|A|=|B\setminus(A\cap B)|+(|\mathbb{U}|-|A\cup B)|).$$
P.S. The information "3 elements of $A$ are not elements of $A\cap B$" is not necessary to evaluate $|A|'$.
|
2,527,731
|
>
> $A$ and $B$ are subsets of universal set.
> $3$ elements of $A$ and $5$ elements of $B$ are not elements of the set $A \cap B$. Moreover $|A \cup B| = 16$ and $|\mathbb U| = 24$.
> What is the value of $|A'|$?
>
>
>
I currently don't have any idea about the question. Might I get your hints?
|
2017/11/19
|
[
"https://math.stackexchange.com/questions/2527731",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/489076/"
] |
$$3+5+|A\cap B|=16,$$
which gives $|A\cap B|=8.$
Thus, $$|A|=3+8=11$$ and
$$|A'|=24-11=13.$$
|
**Hint:**
$$|A'| = |\mathbb{U}|-|A\cup B| + |B-A| = 24 - 16 + 5 = 13$$
|
76,094
|
Need some hints or help with this problem:
Find complete solution for $$u^{'''}-6u^{''}+9u^{'}=4e^{-t}$$ and solve the initial value problem with initial values as $$u(0)=\frac{1}{2}, u^{'}(0)=\frac{11}{4}, u^{''}(0)=\frac{41}{4}$$
|
2011/10/26
|
[
"https://math.stackexchange.com/questions/76094",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/16840/"
] |
If you have a quantity $x$, and you want to add $y$% to it, you multiply by $\frac{100+y}{100}$.
Symmetrically, if you have a quantity $X$ which represents some $x$ plus $y$%, and you want to recover $x$, you multiply by $\frac{100}{100+y}$.
---
I'm assuming the following:
* You know the "Sum Total";
* You know what percentage of the "sum total" accounts for "Total Labor", and what percentage accounts for "Total Material."
* You know the percentage of Overhead (10%) and of Profit (10%).
* You know what percentages make up the "Sub Total"
You want to figure out "Cost" for each of Labor and Material.
You can find "Total Labor" (call it $\mathsf{TL}$) and "Total Material" (call it $\mathsf{TM}$) easily enough: if Labor is x% and Material is y% (with $x+y=100$), then $\mathsf{TL} =(\mathrm{Sum Total})(x/100)$ and $\mathsf{TM}=(\mathrm{Sum Total})(y/100)$.
The next two steps work the same for $\mathsf{TL}$ and for $\mathsf{TM}$, so we can just proceed with a single quantity $\mathsf{T}$ and work backwards.
1. $\frac{\mathsf{T}}{1.1}=\text{Subtotal}+\text{Overhead}$. (Takes off the 10% profit mark-up)
2. $\text{Subtotal} = \frac{1}{1.1}(\text{Subtotal}+\text{Overhead})$. (Takes off the 10% overhead mark-up).
**Labor.**
You have a subtotal $\mathrm{ST}$. Divide by $1.05$ to get the rid of the 5% Load. Then divide the result by $1.03$ to get rid of the 3% Supervision.
In summary: if Labor is x% of the total,
$$\begin{align\*}
\text{Labor Cost} &= (\text{Total Cost})\left(\frac{x}{100}\right)\left(\frac{100}{110}\right)\left(\frac{100}{110}\right)\left(\frac{100}{105}\right)\left(\frac{100}{103}\right)\\
&= (\text{Total Cost})\frac{10000x}{(110)(110)(105)(103)}.
\end{align\*}$$
**Material**
Same idea: divide $\mathsf{ST}$ by $1.0925$ to strip away the tax, and then by 105 to strip away the waste.
In summary, if Material is y% of the total cost,
$$\begin{align\*}
\text{Material Cost} &= \left(\text{Total Cost}\right)\left(\frac{y}{100}\right)\left(\frac{100}{110}\right)\left(\frac{100}{110}\right)\left(\frac{100}{109.25}\right)\left(\frac{100}{105}\right)\\
&= \left(\text{Total Cost}\right)\frac{10000y}{(110)(110)(109.25)(105)}.
\end{align\*}$$
|
It doesn't look like Labor and Material have anything to do with it. If you have a Sub Total, the overhead is 10% giving 110%, then profit is 10% of that=11% of Sub Total, giving Sum Total = 121% Sub Total. So Sub Total =$\frac{100}{121}$ Sum Total, Profit=$\frac{11}{121}$ Sum Total, Overhead=$\frac{10}{121}$ Sum Total
|
4,320,298
|
**Introduction**
This is a weird take on a few different topics in logic, so bear with me.
To frame this question, consider that "axiomatization" is to "theory" as "parameterization" is to "manifold," and, bearing this in mind, define "axiomatization" as follows:
>
> For any theory $T$, call $A\subseteq T$ an axiomatization of $T$ iff for any wff $\phi$ of $T$, $A\vdash \phi$.
>
>
>
The reason for using this definition in place of the usual one is to emphasize 1) the nonuniqueness of axiomatizations for a given theory, and 2) the varying "degrees" of computability of different theories. By "degree of computability" I mean the manner in which a theory may behave like a computable, recursive, decidable, etc. one without actually being computable, etc. For instance, we might extend a recursively axiomatizable theory $T$ by constructing a sufficiently "nice" function $\Phi:\Bbb R\to L'$, where $L'$ is the language of $T$ extended by $\Bbb R$-many constant symbols (indexed by real numbers), and adding $\Phi[\Bbb R]$ to the axioms of $T$. Obviously the extension is not axiomatizable in the traditional sense, since it is uncountable - but it remains "quasicomputable," for lack of a better term, in a very obvious way. Similarly, we can think of a non R.E. theory - let's say the theory of of True Arithmetic - as being "$X$-axiomatizable" for some condition $X$. I suspect that there are key properties of "well-behaved" theories that are easily explained in terms of "$X$-axiomatizability."
---
**The Question**
Let $T$ be an arbitrary and, for now, first-order theory. Trivially, $T$ is an axiomatization of $T$, so if $T$ is decidable then there is a decidable axiomatization of $T$. For the same reason, if every axiomatization of $T$ is decidable, then $T$ is decidable.
Now it is a well known result in mathematical logic that the decidability of an axiomatization does not imply the decidability of the resulting theory. However, in the event that $T$ is nondecidable it is obvious that $T$ has at least one nondecidable axiomatization - that being $T$ itself. But this alone does not suffice to show that the existence of a nondecidable axiomatization implies nondecidability. In fact, it seems plausible that every decidable theory might have a nondecidable axiomatization.
Consider that for a decidable theory $\Gamma$, we can construct a function $\Theta:\Bbb N\to\Gamma$ which enumerates the theorems of $\Gamma$. Choose an undecidable $V\subset \Bbb N$, then $\Theta[V]$ is undecidable; so at the very least every decidable theory - under a given enumeration, at least - can be shown to have an undecidable fragment. There's no obvious reason that such a fragment *cannot* be an axiomatization of $\Gamma$.
(As a side note, it seems reasonable that previous method of enumeration should suffice to show that every decidable theory has [globally] undecidable subsets, since there are countably many recursive enumerations and uncountably many subsets of $\Bbb N$.)
On the other hand, it seems equally plausible that every axiomatization of a decidable theory *should* be decidable. Consider $\Gamma$ and $V$ as above. Supposing that $V$ is never an axiomatization of $\Gamma$, let $A$ be a decidable axiomatization of $\Gamma$. Trivially, $A\cup V$ is an axiomatization of $\Gamma$, but there's nothing to suggest that $A\cup V$ is undecidable. In fact, using the same enumeration trick, we can almost always find an undecidable fragment of $\Gamma$ whose union with $A$ is decidable!
All of this leads me to the question: what if *every* axiomatization of $T$ is decidable? More significantly, can we that if $T$ is decidable, then every axiomatization of $T$ is decidable?
**Summary of known results:**
For any [first-order] theory, $T$...
1. If $T$ is decidable, then $T$ has a decidable axiomatization.
2. If $T$ is nondecidable, then $T$ has a nondecidable axiomatization.
3. If every axiomatization of $T$ is decidable, then $T$ is decidable.
4. If every axiomatization of $T$ is nondecidable, then $T$ is nondecidable.
5. $T$ contains a nondecidable subset
|
2021/11/30
|
[
"https://math.stackexchange.com/questions/4320298",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/614269/"
] |
A slightly different approach is to
note that the function you
want to differentiate can be written as
$$
\phi
= \| \mathbf{x} \otimes \mathbf{x} \|\_2^2
= \| \mathbf{x} \mathbf{x}^T \|^2\_F
$$
The differential writes
$$
d\phi
= 2 \mathbf{x} \mathbf{x}^T:d(\mathbf{x} \mathbf{x}^T)
= 4 \mathbf{x} \mathbf{x}^T \mathbf{x}:d\mathbf{x}
$$
The gradient is thus
$$
\frac{\partial \phi}{\partial \mathbf{x}}
= 4 \| \mathbf{x} \|\_2^2 \mathbf{x}
$$
|
$
\def\a{\alpha}\def\b{\beta}\def\l{\lambda}\def\o{{\tt1}}
\def\B{\Big}\def\L{\left}\def\R{\right}
\def\LR#1{\L(#1\R)}
\def\BR#1{\B(#1\B)}
\def\trace#1{\operatorname{Tr}\LR{#1}}
\def\v#1{\operatorname{vec}\LR{#1}}
\def\qiq{\quad\implies\quad}
\def\t{\otimes}
\def\p{\partial}
\def\grad#1#2{\frac{\p #1}{\p #2}}
\def\c#1{\color{red}{#1}}
$The Frobenius product is a concise notation for the trace
$$\eqalign{
A:B &= \sum\_{i=1}^m\sum\_{j=1}^n A\_{ij}B\_{ij} \;=\; \trace{A^TB} \\
A:A &= \big\|A\big\|^2\_F \\
}$$
This is also called the double-dot or double contraction product.
When applied to vectors $(n=\o)$ it reduces to the standard dot product.
The distributive rule for a mixed Kronecker-Frobenius product is
$$\eqalign{
(A\t B):(X\t Y) = (A:X)\t(B:Y) \\
}$$
First calculate the gradient of the simple function
$$\eqalign{
\a &= \|x\|^2 = x:x \qiq \c{d\a = 2x:dx} \\
}$$
Then calculate the differential (and gradient)
for the first function of interest $(\b)$.
$$\eqalign{
\b &= \|x\t x\|^2 \\&= (x\t x):(x\t x) \\&= (x:x)\t(x:x) \\&= \a^2 \\
d\b &= 2\a\;\c{d\a} \\&= 2\a\,\LR{2x\,dx} \\&= 4\|x\|^2\,x\,dx \\
\grad{\b}{x} &= 4\|x\|^2\,x \\
}$$
The second function of interest $(y)$
can also make use of the simple $\a$ function.
$$\eqalign{
\l &= \|x\| \\
\l^2 &= \a \qiq 2\l\,d\l = d\a = 2x^Tdx \\
d\l &= \l^{-1}x^Tdx \\
\\
y &= \frac{x}{\|x\|} = \l^{-1}x \\
dy &= \l^{-1}dx-x\l^{-2}\,\c{d\l} \\
&= \l^{-1}I\,dx-x\l^{-2}\,\c{\l^{-1}x^Tdx} \\
&= \l^{-1}\LR{I-yy^T}\,dx \\
\grad{y}{x} &= \l^{-1}\LR{I-yy^T} \\\\
}$$
---
**NB:** Your expansion of $(x\t x)$ is incorrect. What you have
written is actually the matrix $xx^T$ which you must
[vectorize](https://en.wikipedia.org/wiki/Vectorization_(mathematics)#Compatibility_with_Kronecker_products) to recover the desired Kronecker product, i.e.
$$(x\t x) = \v{xx^T}$$
However, there is another property of the Frobenius product
$$\v{A}:\v{A} = A:A$$
which allows you to use your matrix without vectorizing it
$$\eqalign{
\b &= \v{xx^T}:\v{xx^T} \\&= \LR{xx^T}:\LR{xx^T} \\
&= \trace{xx^Txx^T} \\&= \a^2
}$$
|
12,324
|
I'm in the market for a new cell phone soon, and I'd like for it to work well with Ubuntu. I don't use my phone for much--just calls, texts, and the occasional photo. It would be nice if it could also do these things (highest priority first):
1. Be cheap
2. Sync (or at least manually transfer) contact data with Ubuntu
3. Sync (or at least manually transfer) photos with Ubuntu
4. Connect to Ubuntu via something like a mini-usb cable, rather than requiring a vendor-specific cable
5. Sync (or at least manually transfer) ringtones and such with Ubuntu (I doubt I'll ever use this, which is why it is last)
What phones best meet these criteria? It it matters, I am on Verizon in the USA.
|
2010/11/09
|
[
"https://askubuntu.com/questions/12324",
"https://askubuntu.com",
"https://askubuntu.com/users/463/"
] |
gnome-phone-manager and Gnocky rely on <http://www.gnokii.org/> (Wammu and Gammu are forks of that) all Nokia are fully supported, others have basic support (phonebook).
|
try Wammu, almost all of cellphones are working, but that also depends on conection posibilities..
|
9,122,424
|
I'm using jQuery autocomplete, right now when a user clicks in the input, there is no helper provided to tell the user what to do.
is there a way with jQuery autocomplete to show a helper message below the input showing "Type ...... " which is removed as soon as there are suggestions?
Thanks
|
2012/02/03
|
[
"https://Stackoverflow.com/questions/9122424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149080/"
] |
How about something like this, you set a default value on your input field (e.g. Type here...). Then when the user clicks init, you clear out the default text and the autocomplete kicks in. However if they leave the input field without text, the default text returns to the text field. Here's a **[jsFiddle example](http://jsfiddle.net/dD2Hc/)**.
HTML:
```
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" value="Type here...">
</div>
```
jQuery (using a local data source demo):
```
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#tags").click(function(){
if($(this).val() == 'Type here...') $(this).val('');
}).blur(function(){
if($(this).val() == '') $(this).val('Type here...');
}).autocomplete({
source: availableTags
});
```
|
There is a 'focus' event detailed here: <http://jqueryui.com/demos/autocomplete/#event-focus>
Can you use this to fire off a prompt?
|
23,040
|
I've noticed a lot of useful modules already created such as workflow, ACL, diff, and more. But these only seem to work with "content types". In our project, we have decided that "content types" aren't really well suited for what we need (Entities make more since). Very complex relationships must be modeled. Our entities are just that, entities, not content.
The problem is that when building an entity using hook\_schema() and hook\_entity\_info(), these entities are not available to be used with different modules such as workflow. Is there any way to make them available? Or will we have to code similar workflow functionality by hand?
Workflow does exactly what we need, except only on content types. We need it to work on entities as well.
|
2012/02/20
|
[
"https://drupal.stackexchange.com/questions/23040",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/5492/"
] |
Especially in Drupal core, Nodes are still something like a Super-Entity with a number of features only supported by them, like revisions and the whole node\_access thing. The entity.module tries to implement these features generically for all entities, I'm not sure if everything is covered yet.
Many modules only support nodes both due to these missing features (You can't configure ACL's or workflows if there is no way to limit access in the API, diffing is pointless without revisions) and historical reasons (all of your listed modules are ports initially Drupal 6 versions or even older and have been ported to Drupal 7). The whole concept of entities represents a major shift in Drupal and not all modules have made that step (yet).
I guess that's one of the reasons why e.g. Commerce uses Nodes as the default way to display products.
Work is ongoing in Drupal 8 to unify these features and provide them for all kinds of entities.
This is not really an answer to your question, more an explanation of the status quo. As Alex already mentioned, many of those modules are working on supporting entities or an entity-aware successor is being worked on, like <http://drupal.org/project/state_machine>.
|
Unfortunately you are out of luck. Had the same problem with [Flag](http://drupal.org/project/flag) module recently but lucked out and found the [Mark](http://drupal.org/project/mark) module which is similar but for entities.
That said, it might not as hard as it seems to hack the workflow module to use Entities instead. Check out this [issue](http://drupal.org/node/732578), it seems the module is going this way but it might take a while to get it accomplished.
*Disclaimer*: I don't encourage hacking contrib modules but in certain cases you could create a branch for your project needs and preferrably submit back patches if you are succesfull!
|
3,686,820
|
I can't seem to understand this question at all. It does not make sense to me.
The question is
>
> Given $\left|\vec a\right| = 3, \left|\vec b\right| = 5$ and $\left|\vec a+\vec b\right| = 7$. Determine $\left|\vec a-\vec b\right|$.
>
>
>
I have tried finding $\left|\vec a+\vec b\right|$ using cosine rule such that $\left|\vec a+\vec b\right| = 7 = 3^2 + 5^2 - 2\cosθ$
Which failed as I clearly am unable to picture this question correctly in my head. If someone could explain this question (or maybe help me sketch it) that's be very helpful, thanks in advance.
|
2020/05/22
|
[
"https://math.stackexchange.com/questions/3686820",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/791513/"
] |
It's simple algebra to verify$$\frac{a^2+b^2+(a+b)^2}{b^2+a(a+b)}=2$$provided the denominator is nonzero, but it's $(a+b/2)^2+3b^2/4$, so that only requires $a,\,b$ to not both be $0$.
|
With $b = \lambda a, c = \mu a$
$$
\frac{1+\lambda^2+\mu^2}{\lambda^2+\mu}=\frac{1+\lambda^2+(1+\lambda)^2}{\lambda^2+\lambda+1} = 2
$$
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.