qid int64 1 74.6M | question stringlengths 45 24.2k | date stringlengths 10 10 | metadata stringlengths 101 178 | response_j stringlengths 32 23.2k | response_k stringlengths 21 13.2k |
|---|---|---|---|---|---|
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | I prefer the first method, because it doesn't matter what happens after the ifndef because it will be defined straight after. | I'd go for the first one.
Reason: If you ever want to change the guard name (say, `SOME_CLASS` to `SOMECLASS`), you don't have to scroll all the way down to the end of file to change it too. |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | I prefer the first method, because it doesn't matter what happens after the ifndef because it will be defined straight after. | The best option is to use `#pragma once`. With `#define` you must be very careful when using multiple libraries as the guard name may not be unique. |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | I prefer the first method, because it doesn't matter what happens after the ifndef because it will be defined straight after. | I prefer the first option. Suppose you include more files, and these files in turn include the file containing `#ifndef SOME_CLASS`.
I think it's fairly easy to spot include errors, if the `#define SOME_CLASS` isn't adjacent to `#ifndef SOME_CLASS`.
```
// SomeClass.h
#ifndef SOME_CLASS
#include "OtherFile.h" // wil... |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | I prefer the first method, because it doesn't matter what happens after the ifndef because it will be defined straight after. | The first option is commonly optimized by compilers to behave like the non-standard `#pragma once`.
It is also safer in case of recursive includes. If, in the `//code...` part, you include another header which includes .... which includes the header you're currently editing, then the second version won't work. |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | I'd go for the first one.
Reason: If you ever want to change the guard name (say, `SOME_CLASS` to `SOMECLASS`), you don't have to scroll all the way down to the end of file to change it too. | The best option is to use `#pragma once`. With `#define` you must be very careful when using multiple libraries as the guard name may not be unique. |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | I'd go for the first one.
Reason: If you ever want to change the guard name (say, `SOME_CLASS` to `SOMECLASS`), you don't have to scroll all the way down to the end of file to change it too. | I prefer the first option. Suppose you include more files, and these files in turn include the file containing `#ifndef SOME_CLASS`.
I think it's fairly easy to spot include errors, if the `#define SOME_CLASS` isn't adjacent to `#ifndef SOME_CLASS`.
```
// SomeClass.h
#ifndef SOME_CLASS
#include "OtherFile.h" // wil... |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | The best option is to use `#pragma once`. With `#define` you must be very careful when using multiple libraries as the guard name may not be unique. | I prefer the first option. Suppose you include more files, and these files in turn include the file containing `#ifndef SOME_CLASS`.
I think it's fairly easy to spot include errors, if the `#define SOME_CLASS` isn't adjacent to `#ifndef SOME_CLASS`.
```
// SomeClass.h
#ifndef SOME_CLASS
#include "OtherFile.h" // wil... |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | The first option is commonly optimized by compilers to behave like the non-standard `#pragma once`.
It is also safer in case of recursive includes. If, in the `//code...` part, you include another header which includes .... which includes the header you're currently editing, then the second version won't work. | The best option is to use `#pragma once`. With `#define` you must be very careful when using multiple libraries as the guard name may not be unique. |
6,123,544 | In header files I've seen two main ways for defining macro to avoid including the file more than once.
1.
```
#ifndef SOME_CLASS
#define SOME_CLASS
//code ...
#endif
```
2.
```
#ifndef SOME_CLASS
//code...
#define SOME_CLASS
#endif
```
Which is more preferable and why? | 2011/05/25 | ['https://Stackoverflow.com/questions/6123544', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/509233/'] | The first option is commonly optimized by compilers to behave like the non-standard `#pragma once`.
It is also safer in case of recursive includes. If, in the `//code...` part, you include another header which includes .... which includes the header you're currently editing, then the second version won't work. | I prefer the first option. Suppose you include more files, and these files in turn include the file containing `#ifndef SOME_CLASS`.
I think it's fairly easy to spot include errors, if the `#define SOME_CLASS` isn't adjacent to `#ifndef SOME_CLASS`.
```
// SomeClass.h
#ifndef SOME_CLASS
#include "OtherFile.h" // wil... |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | Let $N$ be a p-sylow subgroup.
For all $x$ ,$xNx^{-1}$ is a conjugate of $N$. If the set of groups conjugate to $N$ has size $1$ we find that $xNx^{-1}=N$ for all $x$. | Well, $n\_p$ is the number of $p$-Sylow subgroups. The conjugates of $p$-Sylow subgroup are precisely the other $p$-Sylow sugroups. So if $n\_p=1$ then the $p$-Sylow subgroup is conjugate only to itself, i.e. it is normal. |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | Let $N$ be a p-sylow subgroup.
For all $x$ ,$xNx^{-1}$ is a conjugate of $N$. If the set of groups conjugate to $N$ has size $1$ we find that $xNx^{-1}=N$ for all $x$. | Let $N$ be the single Sylow $p$-group. Suppose it is not normal. Then conjugation by some element $g$ gives a group $gNg^{-1}$ different from $N$ with the same number of elements as $N$. This is another Sylow $p$-group, distinct from the first, a contradiction. |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | Let $N$ be a p-sylow subgroup.
For all $x$ ,$xNx^{-1}$ is a conjugate of $N$. If the set of groups conjugate to $N$ has size $1$ we find that $xNx^{-1}=N$ for all $x$. | I don't want to add something different here, but good to know that $n\_p=[G:N\_G(P)]$ when $P$ is a $p$- sylow of $G$. So if $n\_p=1$ then $N\_G(P)=G$ so $P$ is normal in $G$. |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | Let $N$ be a p-sylow subgroup.
For all $x$ ,$xNx^{-1}$ is a conjugate of $N$. If the set of groups conjugate to $N$ has size $1$ we find that $xNx^{-1}=N$ for all $x$. | If I may add something.
The following statement is true:
Let $U\leq G$ be a subgroup such that there is no other subgroup that has the same order. Then $U$ is a characteristic subgroup. That is, *every automorphism* of $G$ maps $U$ to itself. |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | I don't want to add something different here, but good to know that $n\_p=[G:N\_G(P)]$ when $P$ is a $p$- sylow of $G$. So if $n\_p=1$ then $N\_G(P)=G$ so $P$ is normal in $G$. | Well, $n\_p$ is the number of $p$-Sylow subgroups. The conjugates of $p$-Sylow subgroup are precisely the other $p$-Sylow sugroups. So if $n\_p=1$ then the $p$-Sylow subgroup is conjugate only to itself, i.e. it is normal. |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | I don't want to add something different here, but good to know that $n\_p=[G:N\_G(P)]$ when $P$ is a $p$- sylow of $G$. So if $n\_p=1$ then $N\_G(P)=G$ so $P$ is normal in $G$. | Let $N$ be the single Sylow $p$-group. Suppose it is not normal. Then conjugation by some element $g$ gives a group $gNg^{-1}$ different from $N$ with the same number of elements as $N$. This is another Sylow $p$-group, distinct from the first, a contradiction. |
255,287 | >
> If $n\_p=1$, then the $p$-Sylow subgroup is normal.
>
>
>
I've used this fact several times, and it's about time I knew why it's true. | 2012/12/10 | ['https://math.stackexchange.com/questions/255287', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/51426/'] | I don't want to add something different here, but good to know that $n\_p=[G:N\_G(P)]$ when $P$ is a $p$- sylow of $G$. So if $n\_p=1$ then $N\_G(P)=G$ so $P$ is normal in $G$. | If I may add something.
The following statement is true:
Let $U\leq G$ be a subgroup such that there is no other subgroup that has the same order. Then $U$ is a characteristic subgroup. That is, *every automorphism* of $G$ maps $U$ to itself. |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | You declared your array to hold Strings of length 20. The String literals you give are less than 20 Characters long. Hence the error.
You seem to be looking for a string type that contains a *maximum* of 20 characters. This is provided in `Ada.Strings.Bounded`:
```vhdl
package Max_20_String is new Ada.Strings.Bounded... | Another solution is to use String, truncate long strings, and pad short strings:
```
Max : constant := 20;
subtype S20 is String (1 .. Max);
type Lexicon is array (1 .. 7) of S20;
function To20 (S : in String) return S20 is
(if S'Length >= Max then S (S'First .. S'First + Max - 1)
else S & (S'Length + 1 .. Max ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Another solution is to use String, truncate long strings, and pad short strings:
```
Max : constant := 20;
subtype S20 is String (1 .. Max);
type Lexicon is array (1 .. 7) of S20;
function To20 (S : in String) return S20 is
(if S'Length >= Max then S (S'First .. S'First + Max - 1)
else S & (S'Length + 1 .. Max ... | Building upon the solution by Mark, but simplifying thanks to the operations from [`Ada.Strings.Fixed`](https://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Strings.Fixed).
```ada
with Ada.Strings.Fixed;
with Ada.Text_IO;
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Others have mentioned bounded and unbounded strings. You can also use Indefinite\_Vectors. You can use the "&" operator to initialize them (as opposed to the initializer list though the next version of Ada is adding initializer lists to containers). You can use a vector just like an array by passing indexes in plus you... | Another solution is to use String, truncate long strings, and pad short strings:
```
Max : constant := 20;
subtype S20 is String (1 .. Max);
type Lexicon is array (1 .. 7) of S20;
function To20 (S : in String) return S20 is
(if S'Length >= Max then S (S'First .. S'First + Max - 1)
else S & (S'Length + 1 .. Max ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | You declared your array to hold Strings of length 20. The String literals you give are less than 20 Characters long. Hence the error.
You seem to be looking for a string type that contains a *maximum* of 20 characters. This is provided in `Ada.Strings.Bounded`:
```vhdl
package Max_20_String is new Ada.Strings.Bounded... | Similar to Jeff Carter's answer, but using a function to coerce any string into a fixed string ...
```
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array (1 .. 7) of Lexicon_Data;
function To_Lexicon_Data
(Value : in String)
return Lexicon_Data
is
Result : ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Others have mentioned bounded and unbounded strings. You can also use Indefinite\_Vectors. You can use the "&" operator to initialize them (as opposed to the initializer list though the next version of Ada is adding initializer lists to containers). You can use a vector just like an array by passing indexes in plus you... | Building upon the solution by Mark, but simplifying thanks to the operations from [`Ada.Strings.Fixed`](https://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Strings.Fixed).
```ada
with Ada.Strings.Fixed;
with Ada.Text_IO;
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Others have mentioned bounded and unbounded strings. You can also use Indefinite\_Vectors. You can use the "&" operator to initialize them (as opposed to the initializer list though the next version of Ada is adding initializer lists to containers). You can use a vector just like an array by passing indexes in plus you... | Similar to Jeff Carter's answer, but using a function to coerce any string into a fixed string ...
```
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array (1 .. 7) of Lexicon_Data;
function To_Lexicon_Data
(Value : in String)
return Lexicon_Data
is
Result : ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Another option is `Unbounded_String` (as its name suggests, length is variable and unlimited):
```
with Ada.Strings.Unbounded;
procedure Fumador is
use Ada.Strings.Unbounded;
subtype VString is Unbounded_String;
function "+" (Source : in String) return VString renames To_Unbounded_String;
type Lexicon is ar... | Similar to Jeff Carter's answer, but using a function to coerce any string into a fixed string ...
```
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array (1 .. 7) of Lexicon_Data;
function To_Lexicon_Data
(Value : in String)
return Lexicon_Data
is
Result : ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Another option is `Unbounded_String` (as its name suggests, length is variable and unlimited):
```
with Ada.Strings.Unbounded;
procedure Fumador is
use Ada.Strings.Unbounded;
subtype VString is Unbounded_String;
function "+" (Source : in String) return VString renames To_Unbounded_String;
type Lexicon is ar... | Another solution is to use String, truncate long strings, and pad short strings:
```
Max : constant := 20;
subtype S20 is String (1 .. Max);
type Lexicon is array (1 .. 7) of S20;
function To20 (S : in String) return S20 is
(if S'Length >= Max then S (S'First .. S'First + Max - 1)
else S & (S'Length + 1 .. Max ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | Another option is `Unbounded_String` (as its name suggests, length is variable and unlimited):
```
with Ada.Strings.Unbounded;
procedure Fumador is
use Ada.Strings.Unbounded;
subtype VString is Unbounded_String;
function "+" (Source : in String) return VString renames To_Unbounded_String;
type Lexicon is ar... | Building upon the solution by Mark, but simplifying thanks to the operations from [`Ada.Strings.Fixed`](https://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Strings.Fixed).
```ada
with Ada.Strings.Fixed;
with Ada.Text_IO;
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array ... |
70,968,102 | What I want is to define an array of Strings in Ada.
I'm trying to execute this code:
```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","A... | 2022/02/03 | ['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/'] | You declared your array to hold Strings of length 20. The String literals you give are less than 20 Characters long. Hence the error.
You seem to be looking for a string type that contains a *maximum* of 20 characters. This is provided in `Ada.Strings.Bounded`:
```vhdl
package Max_20_String is new Ada.Strings.Bounded... | Building upon the solution by Mark, but simplifying thanks to the operations from [`Ada.Strings.Fixed`](https://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Strings.Fixed).
```ada
with Ada.Strings.Fixed;
with Ada.Text_IO;
procedure Main is
subtype Lexicon_Data is String (1 .. 20);
type Lexicon is array ... |
19,576,214 | I have two click functions: one targets td.default and the second td.clicked. Both changes the class attribute to either 'clicked' or 'default' (and updates the text in the cell). The classes are getting changed from the first click function but the second click function that looks for td.click doesn't find it's target... | 2013/10/24 | ['https://Stackoverflow.com/questions/19576214', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2237565/'] | Use delegation instead
```
$("table").on("click", "td.default", function() {
$(this).attr('class','clicked');
$(this).text("monkey");
$("#ouput").append("td.default clicked<br/>"); //reporting message
});
$("table").on("click", "td.clicked", function() {
$(this).attr('class','default');
$(this).tex... | That seems like a lot of work, would it be easier to do it this way?
```
$('td.default,td.clicked').on('click', function() {
$(this).toggleClass('default').toggleClass('clicked').text(
$(this).text() === 'empty' ? 'monkey' : 'empty'
);
});
```
made a fiddle: <http://jsfiddle.net/filever10/PdjMX/> |
19,576,214 | I have two click functions: one targets td.default and the second td.clicked. Both changes the class attribute to either 'clicked' or 'default' (and updates the text in the cell). The classes are getting changed from the first click function but the second click function that looks for td.click doesn't find it's target... | 2013/10/24 | ['https://Stackoverflow.com/questions/19576214', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2237565/'] | When you bind a click handler, you are binding to the element. Changing the class of the element doesn't change that handler that you've bound to it. If you want that behavior, you'll need to use `on()` with event delegation. See [`on()`](http://api.jquery.com/on/), especially the section about "direct and delegated ev... | That seems like a lot of work, would it be easier to do it this way?
```
$('td.default,td.clicked').on('click', function() {
$(this).toggleClass('default').toggleClass('clicked').text(
$(this).text() === 'empty' ? 'monkey' : 'empty'
);
});
```
made a fiddle: <http://jsfiddle.net/filever10/PdjMX/> |
296,482 | I just landed at LAX and the flight attendant (who had a slight Latino accent, but was a native or near-native English speaker) gave the last announcement:
>
> "As we prepare to land please have cups and other items ready to throw away, as we're going to make one last pass through the cabin *at which time*." Full sto... | 2015/12/28 | ['https://english.stackexchange.com/questions/296482', 'https://english.stackexchange.com', 'https://english.stackexchange.com/users/-1/'] | In this context, the word "suppose" means "believe"; see [Merriam-Webster](http://www.merriam-webster.com/dictionary/suppose):
>
> b (1) : to hold as an opinion : believe [they *supposed* they were early]
>
>
> (2) : to think probable or in keeping with the facts [seems reasonable to *suppose* that he would profit]... | You are pretty correct in your assumption of what this sentence means. The author is comparing the proud to porters, saying that everyone wants an admirer. Nietzsche goes a step further to say outright that philosophers are the proudest men, and that they want the universe to admire them.
Onward, to definitions. To *s... |
296,482 | I just landed at LAX and the flight attendant (who had a slight Latino accent, but was a native or near-native English speaker) gave the last announcement:
>
> "As we prepare to land please have cups and other items ready to throw away, as we're going to make one last pass through the cabin *at which time*." Full sto... | 2015/12/28 | ['https://english.stackexchange.com/questions/296482', 'https://english.stackexchange.com', 'https://english.stackexchange.com/users/-1/'] | >
> "And just as every porter wants to have an admirer, so even the proudest of men, the philosopher, supposes that he sees on all sides the eyes of the universe telescopically focused upon his action and thought."
>
>
>
I may be wrong, but Nietzsche seems to be saying that just as the supposedly humblest of men (... | You are pretty correct in your assumption of what this sentence means. The author is comparing the proud to porters, saying that everyone wants an admirer. Nietzsche goes a step further to say outright that philosophers are the proudest men, and that they want the universe to admire them.
Onward, to definitions. To *s... |
296,482 | I just landed at LAX and the flight attendant (who had a slight Latino accent, but was a native or near-native English speaker) gave the last announcement:
>
> "As we prepare to land please have cups and other items ready to throw away, as we're going to make one last pass through the cabin *at which time*." Full sto... | 2015/12/28 | ['https://english.stackexchange.com/questions/296482', 'https://english.stackexchange.com', 'https://english.stackexchange.com/users/-1/'] | In this context, the word "suppose" means "believe"; see [Merriam-Webster](http://www.merriam-webster.com/dictionary/suppose):
>
> b (1) : to hold as an opinion : believe [they *supposed* they were early]
>
>
> (2) : to think probable or in keeping with the facts [seems reasonable to *suppose* that he would profit]... | >
> "And just as every porter wants to have an admirer, so even the proudest of men, the philosopher, supposes that he sees on all sides the eyes of the universe telescopically focused upon his action and thought."
>
>
>
I may be wrong, but Nietzsche seems to be saying that just as the supposedly humblest of men (... |
48,884,451 | I am comparing two files in my script. using the command
```
comm -3 123.txt 321.txt"
```
These two files 123 and 321 has only numeric content.
Also I use
```
diff -ibw abc.txt cba.txt
```
These files abc and cba has alphanumeric content
If there is no mismatch no output is printed can you help me how to wri... | 2018/02/20 | ['https://Stackoverflow.com/questions/48884451', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9054895/'] | ```
- (void)collectionView:(UICollectionView *)collectionView
willDisplayCell:(UICollectionViewCell *)cell
forItemAtIndexPath:(NSIndexPath *)indexPath{
CGFloat collectionHeight = self.CollectionView.bounds.size.height;
CGFloat contentOffsetY = self.CollectionView.contentOffset.y;
CGFloat contentSizeHeight = self.Co... | Try This:
```
var isCollectionViewScrollUp: Bool = true
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
let collectionHeight: CGFloat = self.collectionView!.bounds.size.height
let contentOffsetY: CGFloat = self.collectionView.c... |
1,103,899 | One of my friends is a real Linux fan, so I decided to try Ubuntu on a VM. I mostly enjoyed the experience, but it was very slow, which I assume is the fault VirtualBox, as my laptop has 16 gigs of ram and an i7 6500u. Partly out of a desire to make sure it works for me, and partly out of thinking "this would be cool,"... | 2018/12/22 | ['https://askubuntu.com/questions/1103899', 'https://askubuntu.com', 'https://askubuntu.com/users/906713/'] | I would suggest that you install a lighter desktop than ubuntu in WSL. XFCE seems to work fine with WSL.
```
sudo apt update
sudo apt install xfce4
startxfce4
``` | If you only want to try Ubuntu I suggest running Ubuntu from USB stick (Ubuntu Live)
* <https://unetbootin.github.io/> - You can try this tool to prepare USB stick.
There also other options:
* <https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-ubuntu#0>
* <https://tutorials.ubuntu.com/tutorial/tu... |
37,833,775 | I wanted to find how many times 1 number appears in provided another number. I've found a solution for finding 2-digit numbers in another number, but what I wanted to do is to find 1-digit, 2-digit, ..., n-digit numbers in provided number. I dont want to create another case in switch instruction, so my question how can... | 2016/06/15 | ['https://Stackoverflow.com/questions/37833775', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6469057/'] | You have declared `i` inside of the `for` loop:
```
for(int i=0;i<t;i++)
```
Therefore, `i`'s scope is limited to that `for` loop. `i` does not exist outside of that `for` loop.
So, when you try to reuse that `i` in the next `for` loop
```
for(i=0;i<t;i++)
```
you get an error. You have to declare `i` again:
... | You only declare the variable i in the first for-loop. The declaration of the variable is only local for that loop, which means that the i will not exists outside the loop.
Instead of:
```
for(i=0;i<t;i++)
```
Try
```
for(int i=0;i<t;i++)
``` |
37,833,775 | I wanted to find how many times 1 number appears in provided another number. I've found a solution for finding 2-digit numbers in another number, but what I wanted to do is to find 1-digit, 2-digit, ..., n-digit numbers in provided number. I dont want to create another case in switch instruction, so my question how can... | 2016/06/15 | ['https://Stackoverflow.com/questions/37833775', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6469057/'] | You have declared `i` inside of the `for` loop:
```
for(int i=0;i<t;i++)
```
Therefore, `i`'s scope is limited to that `for` loop. `i` does not exist outside of that `for` loop.
So, when you try to reuse that `i` in the next `for` loop
```
for(i=0;i<t;i++)
```
you get an error. You have to declare `i` again:
... | The problem is with your 'i' variables.
Nowadays variables declared in a 'for' statement are only useable in the 'for' block, not outside the 'for' block. |
37,833,775 | I wanted to find how many times 1 number appears in provided another number. I've found a solution for finding 2-digit numbers in another number, but what I wanted to do is to find 1-digit, 2-digit, ..., n-digit numbers in provided number. I dont want to create another case in switch instruction, so my question how can... | 2016/06/15 | ['https://Stackoverflow.com/questions/37833775', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6469057/'] | You have declared `i` inside of the `for` loop:
```
for(int i=0;i<t;i++)
```
Therefore, `i`'s scope is limited to that `for` loop. `i` does not exist outside of that `for` loop.
So, when you try to reuse that `i` in the next `for` loop
```
for(i=0;i<t;i++)
```
you get an error. You have to declare `i` again:
... | You have forgot to declare all your variables in the begining. So this way the variables are declared as a local integer and cannot be used outside the `for loop`. I tried declaring them outside the function `int main()` and it worked
The right code:
```
#include<iostream>
using namespace std;
int i = 0;
int a[10];
in... |
37,833,775 | I wanted to find how many times 1 number appears in provided another number. I've found a solution for finding 2-digit numbers in another number, but what I wanted to do is to find 1-digit, 2-digit, ..., n-digit numbers in provided number. I dont want to create another case in switch instruction, so my question how can... | 2016/06/15 | ['https://Stackoverflow.com/questions/37833775', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6469057/'] | You have declared `i` inside of the `for` loop:
```
for(int i=0;i<t;i++)
```
Therefore, `i`'s scope is limited to that `for` loop. `i` does not exist outside of that `for` loop.
So, when you try to reuse that `i` in the next `for` loop
```
for(i=0;i<t;i++)
```
you get an error. You have to declare `i` again:
... | Your problem is that you are declaring `i` inside the function scope.
You can decide if you want to declare the variable i once at the main, or each time as a local scope variable inside a the `for` scope.
```
#include<iostream>
using namespace std;
int main()
{
int temp, t, a[10];
cin >> t;
... |
26,717,000 | Below JavaScript function is called after selecting option from `<select>` tag.
```
function function1()
{
var country=document.getElementById('id1').value;
switch(country)
{
case "India":
logo="rupee.png";
break;
case "US":
logo="dollar-logo.png";
break;
case "Britan":
logo="yen.png";
... | 2014/11/03 | ['https://Stackoverflow.com/questions/26717000', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4147229/'] | This is standard behavior in the Groovy shell, not peculiar to the Grails shell. You probably don't want to `def` the variable. See the following:
```
~ $ groovysh
Groovy Shell (2.3.4, JVM: 1.7.0_45)
Type ':help' or ':h' for help.
-------------------------------------------------------------------------------
groovy:0... | "def" are more like compiled variables in Java way (to some degree), compiled (maybe type is unknown/dynamic, but name/existence of variable / property is known).
`def xyz = 1` -> `Object xyz = 1;`
Without "def" are added to specific container Binder by name, in fully dynamic manner. Imagine this like specific Map *... |
11,134,610 | I have a object A move with Velocity (v1, v2, v3) in 3D space.
Object position is (px,py,pz)
Now i want to add certain particles around object A (in radius dis) on plane which perpendicular to its Velocity direction.
I find something call "cross product" but seen that no use in this case.
Anyone can help?
I'm new to ... | 2012/06/21 | ['https://Stackoverflow.com/questions/11134610', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1471511/'] | The plane perpendicular to a vector ⟨A, B, C⟩ has the general equation Ax + By + Cz + K = 0. | Lets say we have a point p1, and we want to build a circle of points around it with radius r so that all points on the circle are orthogonal to a vector n.. here is a working example
```
p1 = np.array([-21.03181359, 4.54876345, 19.26943601])
n = np.array([-0.06592715, 0.00713031, -0.26809672])
n = n / np.linalg.no... |
11,134,610 | I have a object A move with Velocity (v1, v2, v3) in 3D space.
Object position is (px,py,pz)
Now i want to add certain particles around object A (in radius dis) on plane which perpendicular to its Velocity direction.
I find something call "cross product" but seen that no use in this case.
Anyone can help?
I'm new to ... | 2012/06/21 | ['https://Stackoverflow.com/questions/11134610', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1471511/'] | The equation of the plane is:
```
v1*(x-px) + v2*(y-py) + v3*(z-pz) = 0
```
When you know `(x,y)` you can find `z` and so on.
Example:
z = pz - (v1\*(x-px) + v2\*(y-py))/v3 | Lets say we have a point p1, and we want to build a circle of points around it with radius r so that all points on the circle are orthogonal to a vector n.. here is a working example
```
p1 = np.array([-21.03181359, 4.54876345, 19.26943601])
n = np.array([-0.06592715, 0.00713031, -0.26809672])
n = n / np.linalg.no... |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | There is an issue with my web service. They are giving me the response in "text/HTML" format rather than HTML. When i printed my response on debugger then i got:
```
"Content-Type" = "text/html; charset=UTF-8";
```
Now, i updated my webservice and everything is working like a charm. | I am getting same error last time because there will be problem is web service returns me response in array and i am trying to convert its into dictionary and extract its value.
Check Your web service response. |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | I am getting same error last time because there will be problem is web service returns me response in array and i am trying to convert its into dictionary and extract its value.
Check Your web service response. | Swift 5, Swift 4
```
var headers = HTTPHeaders()
headers = [
"Content-Type" :"text/html; charset=UTF-8",
//"Content-Type": "application/json",
//"Content-Type": "application/x-www-form-urlencoded",
//"Accept": "application/json",
"Accept": "multipart/form-data"
]
``` |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | I am getting same error last time because there will be problem is web service returns me response in array and i am trying to convert its into dictionary and extract its value.
Check Your web service response. | I got this error when using the **wrong** Firebase Server key to send a remote push notification.
Go to `Firebase` > `Project Overview` > `CogIcon` > `Project Settings` > `Cloud Messaging` > `Server Key`
[](https://i.stack.imgur.com/CLK8F.png)
```
g... |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | I am getting same error last time because there will be problem is web service returns me response in array and i am trying to convert its into dictionary and extract its value.
Check Your web service response. | Make Sure The firewall Off from Server |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | There is an issue with my web service. They are giving me the response in "text/HTML" format rather than HTML. When i printed my response on debugger then i got:
```
"Content-Type" = "text/html; charset=UTF-8";
```
Now, i updated my webservice and everything is working like a charm. | Swift 5, Swift 4
```
var headers = HTTPHeaders()
headers = [
"Content-Type" :"text/html; charset=UTF-8",
//"Content-Type": "application/json",
//"Content-Type": "application/x-www-form-urlencoded",
//"Accept": "application/json",
"Accept": "multipart/form-data"
]
``` |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | There is an issue with my web service. They are giving me the response in "text/HTML" format rather than HTML. When i printed my response on debugger then i got:
```
"Content-Type" = "text/html; charset=UTF-8";
```
Now, i updated my webservice and everything is working like a charm. | I got this error when using the **wrong** Firebase Server key to send a remote push notification.
Go to `Firebase` > `Project Overview` > `CogIcon` > `Project Settings` > `Cloud Messaging` > `Server Key`
[](https://i.stack.imgur.com/CLK8F.png)
```
g... |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | There is an issue with my web service. They are giving me the response in "text/HTML" format rather than HTML. When i printed my response on debugger then i got:
```
"Content-Type" = "text/html; charset=UTF-8";
```
Now, i updated my webservice and everything is working like a charm. | Make Sure The firewall Off from Server |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | Swift 5, Swift 4
```
var headers = HTTPHeaders()
headers = [
"Content-Type" :"text/html; charset=UTF-8",
//"Content-Type": "application/json",
//"Content-Type": "application/x-www-form-urlencoded",
//"Accept": "application/json",
"Accept": "multipart/form-data"
]
``` | I got this error when using the **wrong** Firebase Server key to send a remote push notification.
Go to `Firebase` > `Project Overview` > `CogIcon` > `Project Settings` > `Cloud Messaging` > `Server Key`
[](https://i.stack.imgur.com/CLK8F.png)
```
g... |
37,384,772 | I am getting this error as JSON result.error. While my JSON is an valid one, check it on JSON vaildator online.
This is my code for JSON request.
```
Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
.responseJSON { (request, response, result) in
hud.hide(true)
... | 2016/05/23 | ['https://Stackoverflow.com/questions/37384772', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6064629/'] | Swift 5, Swift 4
```
var headers = HTTPHeaders()
headers = [
"Content-Type" :"text/html; charset=UTF-8",
//"Content-Type": "application/json",
//"Content-Type": "application/x-www-form-urlencoded",
//"Accept": "application/json",
"Accept": "multipart/form-data"
]
``` | Make Sure The firewall Off from Server |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Why you're asked for a password
-------------------------------
Most software is designed to touch sensitive files, i.e. sensitive to the security of your private data or the systems integrity. This is why software installation is a potential risk and should be validated by a user who knows what he is doing. Even for ... | You touched upon a BIG difference between windows and ubuntu. In Windows when you are logged in as an admin programms will be installed without asking for a password. This enables also malware to run their programs. In Ubuntu (Linux) even being logged in as an admin the system will always ask for your password when you... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Why you're asked for a password
-------------------------------
Most software is designed to touch sensitive files, i.e. sensitive to the security of your private data or the systems integrity. This is why software installation is a potential risk and should be validated by a user who knows what he is doing. Even for ... | In Ubuntu, the administrator has root privileges (often referred as just "root", as in "you need to be root").
Access to files can be split in three types:
* read (numeric value 4)
* write (numeric value 2)
* execute (numeric value 1)
These attributes can be set on every file or directory. Furthermore, these restric... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Non-admin users cannot install software because the packages run as root when they're installing as they install to privileged parts of the system, run maintainer scripts, etc.
There is currently no way to tell the system "Install firefox from this .deb but in a user's home directory so that it's isolated from the re... | You can install software as a regular, non-admin, user. Software installed by a regular user will be "owned" by that user, which means that, in effect, it is an extension of the user -- it has no more permissions than the owning user does, though it may have fewer permissions, at the user's option.
A common practice i... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | In Ubuntu, the administrator has root privileges (often referred as just "root", as in "you need to be root").
Access to files can be split in three types:
* read (numeric value 4)
* write (numeric value 2)
* execute (numeric value 1)
These attributes can be set on every file or directory. Furthermore, these restric... | You can install software as a regular, non-admin, user. Software installed by a regular user will be "owned" by that user, which means that, in effect, it is an extension of the user -- it has no more permissions than the owning user does, though it may have fewer permissions, at the user's option.
A common practice i... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Why you're asked for a password
-------------------------------
Most software is designed to touch sensitive files, i.e. sensitive to the security of your private data or the systems integrity. This is why software installation is a potential risk and should be validated by a user who knows what he is doing. Even for ... | They can not. Here is the deal.
1. The 1st user created in Ubuntu is considered a special user: this is a user with administration permissions. This means when ever this user wants to do admin tasks he will be prompted for his admin password. Those tasks are issued by putting `sudo` in front of a command.
2. All other... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Why you're asked for a password
-------------------------------
Most software is designed to touch sensitive files, i.e. sensitive to the security of your private data or the systems integrity. This is why software installation is a potential risk and should be validated by a user who knows what he is doing. Even for ... | You can install software as a regular, non-admin, user. Software installed by a regular user will be "owned" by that user, which means that, in effect, it is an extension of the user -- it has no more permissions than the owning user does, though it may have fewer permissions, at the user's option.
A common practice i... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | They can not. Here is the deal.
1. The 1st user created in Ubuntu is considered a special user: this is a user with administration permissions. This means when ever this user wants to do admin tasks he will be prompted for his admin password. Those tasks are issued by putting `sudo` in front of a command.
2. All other... | You can install software as a regular, non-admin, user. Software installed by a regular user will be "owned" by that user, which means that, in effect, it is an extension of the user -- it has no more permissions than the owning user does, though it may have fewer permissions, at the user's option.
A common practice i... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Why you're asked for a password
-------------------------------
Most software is designed to touch sensitive files, i.e. sensitive to the security of your private data or the systems integrity. This is why software installation is a potential risk and should be validated by a user who knows what he is doing. Even for ... | Non-admin users cannot install software because the packages run as root when they're installing as they install to privileged parts of the system, run maintainer scripts, etc.
There is currently no way to tell the system "Install firefox from this .deb but in a user's home directory so that it's isolated from the re... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | Non-admin users cannot install software because the packages run as root when they're installing as they install to privileged parts of the system, run maintainer scripts, etc.
There is currently no way to tell the system "Install firefox from this .deb but in a user's home directory so that it's isolated from the re... | You touched upon a BIG difference between windows and ubuntu. In Windows when you are logged in as an admin programms will be installed without asking for a password. This enables also malware to run their programs. In Ubuntu (Linux) even being logged in as an admin the system will always ask for your password when you... |
48,243 | This is probably something I don't understand since I am used to Windows
and am only starting out with Ubuntu. I know that software in linux comes in packages what I don't understand is why can't non-admin users install software.
I mean, every application is run by a specific user, and that user will
only be able to ... | 2011/06/11 | ['https://askubuntu.com/questions/48243', 'https://askubuntu.com', 'https://askubuntu.com/users/19733/'] | In Ubuntu, the administrator has root privileges (often referred as just "root", as in "you need to be root").
Access to files can be split in three types:
* read (numeric value 4)
* write (numeric value 2)
* execute (numeric value 1)
These attributes can be set on every file or directory. Furthermore, these restric... | You touched upon a BIG difference between windows and ubuntu. In Windows when you are logged in as an admin programms will be installed without asking for a password. This enables also malware to run their programs. In Ubuntu (Linux) even being logged in as an admin the system will always ask for your password when you... |
22,202,342 | I have a calendar function, where I would like to call a column from my MySQL database. Before I am making the call for the column, I would just like to check if there is connection at all. My call goes through the servlet dataExchange.java. This servlet works fine, and I can put in information from my JSP page. In my ... | 2014/03/05 | ['https://Stackoverflow.com/questions/22202342', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1883095/'] | You are trying to call your java class directcly `$.get("dataExchange.java" ...` You must use your URL mapping for the servlet. You can map the servlet in the `web.xml` file or with annotations.
If you put your servlet an web.xml we can provide more help. | Answer:
```
$(function(){
$("#start").datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function(dateText,inst){
alert(dateText);
//Her skal du så lave din ajax kald:
$.ajax({
url: "../dataExchange",
type: "post",
... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | The following solution is based on the inputs I got from the comments.
Note that `updateTabsetPanel()` belongs to `shiny` while `updateTabItems()` is a function of the `shinydashboard` package. They seem to work interchangeably.
```
library(shiny)
library(shinydashboard)
# UI ----------------------------------------... | According to the code and logic from Rappster. It is possible to set any kind of links. Link to `TabsetPanel` can be used by `updataTabsetPanel`. Link to `Navbar` can use `updateNavbarPage(session, inputId, selected = NULL)`. These can be found by `?updateTabsetPanel` as following.
```
updateTabsetPanel(session, inpu... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | The following solution is based on the inputs I got from the comments.
Note that `updateTabsetPanel()` belongs to `shiny` while `updateTabItems()` is a function of the `shinydashboard` package. They seem to work interchangeably.
```
library(shiny)
library(shinydashboard)
# UI ----------------------------------------... | We have just released a [routing library](https://github.com/Appsilon/shiny.router), which makes linking in Shiny easy. Here's how it looks like in a nutshell.
```
make_router(
route("<your_app_url>/main", main_page_shiny_ui),
route("<your_app_url>/other", other_page_shiny_ui)
)
```
More information can be fo... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | The following solution is based on the inputs I got from the comments.
Note that `updateTabsetPanel()` belongs to `shiny` while `updateTabItems()` is a function of the `shinydashboard` package. They seem to work interchangeably.
```
library(shiny)
library(shinydashboard)
# UI ----------------------------------------... | You can give your `tabsetPanel` an id and use `updateTabsetPanel` with your `observeEvent`
```
library(shiny)
# UI ---------------------------------------------------------------------
ui <- fluidPage(
tabsetPanel(id = "demo",
tabPanel(
"A",
p(),
actionLink("link_to_tabpanel_b", "Link to pan... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | The following solution is based on the inputs I got from the comments.
Note that `updateTabsetPanel()` belongs to `shiny` while `updateTabItems()` is a function of the `shinydashboard` package. They seem to work interchangeably.
```
library(shiny)
library(shinydashboard)
# UI ----------------------------------------... | I was struggling with the same issue and really wanted to link to a different tab **via the URL**. Thanks to the [simple example of thesadie](https://stackoverflow.com/a/43125357/7061057) and by using an *observe* to parse inputs from the url, for me the following worked (and made it possible to switch the tab by addin... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | We have just released a [routing library](https://github.com/Appsilon/shiny.router), which makes linking in Shiny easy. Here's how it looks like in a nutshell.
```
make_router(
route("<your_app_url>/main", main_page_shiny_ui),
route("<your_app_url>/other", other_page_shiny_ui)
)
```
More information can be fo... | According to the code and logic from Rappster. It is possible to set any kind of links. Link to `TabsetPanel` can be used by `updataTabsetPanel`. Link to `Navbar` can use `updateNavbarPage(session, inputId, selected = NULL)`. These can be found by `?updateTabsetPanel` as following.
```
updateTabsetPanel(session, inpu... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | You can give your `tabsetPanel` an id and use `updateTabsetPanel` with your `observeEvent`
```
library(shiny)
# UI ---------------------------------------------------------------------
ui <- fluidPage(
tabsetPanel(id = "demo",
tabPanel(
"A",
p(),
actionLink("link_to_tabpanel_b", "Link to pan... | According to the code and logic from Rappster. It is possible to set any kind of links. Link to `TabsetPanel` can be used by `updataTabsetPanel`. Link to `Navbar` can use `updateNavbarPage(session, inputId, selected = NULL)`. These can be found by `?updateTabsetPanel` as following.
```
updateTabsetPanel(session, inpu... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | I was struggling with the same issue and really wanted to link to a different tab **via the URL**. Thanks to the [simple example of thesadie](https://stackoverflow.com/a/43125357/7061057) and by using an *observe* to parse inputs from the url, for me the following worked (and made it possible to switch the tab by addin... | According to the code and logic from Rappster. It is possible to set any kind of links. Link to `TabsetPanel` can be used by `updataTabsetPanel`. Link to `Navbar` can use `updateNavbarPage(session, inputId, selected = NULL)`. These can be found by `?updateTabsetPanel` as following.
```
updateTabsetPanel(session, inpu... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | We have just released a [routing library](https://github.com/Appsilon/shiny.router), which makes linking in Shiny easy. Here's how it looks like in a nutshell.
```
make_router(
route("<your_app_url>/main", main_page_shiny_ui),
route("<your_app_url>/other", other_page_shiny_ui)
)
```
More information can be fo... | I was struggling with the same issue and really wanted to link to a different tab **via the URL**. Thanks to the [simple example of thesadie](https://stackoverflow.com/a/43125357/7061057) and by using an *observe* to parse inputs from the url, for me the following worked (and made it possible to switch the tab by addin... |
34,315,485 | How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
Update
------
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
**However, I'd be interested to also know about more generic ways of linking parts of a shin... | 2015/12/16 | ['https://Stackoverflow.com/questions/34315485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/989691/'] | You can give your `tabsetPanel` an id and use `updateTabsetPanel` with your `observeEvent`
```
library(shiny)
# UI ---------------------------------------------------------------------
ui <- fluidPage(
tabsetPanel(id = "demo",
tabPanel(
"A",
p(),
actionLink("link_to_tabpanel_b", "Link to pan... | I was struggling with the same issue and really wanted to link to a different tab **via the URL**. Thanks to the [simple example of thesadie](https://stackoverflow.com/a/43125357/7061057) and by using an *observe* to parse inputs from the url, for me the following worked (and made it possible to switch the tab by addin... |
454,341 | I built a computer for a friend with an OCZ petrol SSD. It seems to be having some problems now. Once or twice a day, it gets an error that looks like it's pointing to a disk sector and then blue screens. I booted off System Rescue CD to try and take a backup image of the disk, but it failed with an error along the lin... | 2012/07/27 | ['https://superuser.com/questions/454341', 'https://superuser.com', 'https://superuser.com/users/148667/'] | According to [this article](http://alloytm.com/2010/01/05/virtualbox-regdb_e_classnotreg-error/), this can be fixed like so:
>
> 1. Open a standard command line ( Run > cmd )
> 2. Run: `cd C:\Program Files\Oracle\VirtualBox`
> 3. Run: `VBoxSVC /ReRegServer`
> 4. Run: `regsvr32 VBoxC.dll`
>
>
>
Make sure to run th... | This error occurred with my win 7 64 bit too.
I came to a conclusion that this problem occurred due to installation of youwave for android on my pc.
They both have some conflicts so only any one can be installed at a time. |
454,341 | I built a computer for a friend with an OCZ petrol SSD. It seems to be having some problems now. Once or twice a day, it gets an error that looks like it's pointing to a disk sector and then blue screens. I booted off System Rescue CD to try and take a backup image of the disk, but it failed with an error along the lin... | 2012/07/27 | ['https://superuser.com/questions/454341', 'https://superuser.com', 'https://superuser.com/users/148667/'] | According to [this article](http://alloytm.com/2010/01/05/virtualbox-regdb_e_classnotreg-error/), this can be fixed like so:
>
> 1. Open a standard command line ( Run > cmd )
> 2. Run: `cd C:\Program Files\Oracle\VirtualBox`
> 3. Run: `VBoxSVC /ReRegServer`
> 4. Run: `regsvr32 VBoxC.dll`
>
>
>
Make sure to run th... | I have the same problem after de+reinstall VirtualBox.
Good hint, Oliver Salzburg! It didn't work for me under Win10, but brought me closer to the solution:
* Open start menu, right click on the `VirtualBox link`
* Click on `open file path` - explorer opens
* Right click on `VirtualBox link`, then `settings`
* Under ... |
454,341 | I built a computer for a friend with an OCZ petrol SSD. It seems to be having some problems now. Once or twice a day, it gets an error that looks like it's pointing to a disk sector and then blue screens. I booted off System Rescue CD to try and take a backup image of the disk, but it failed with an error along the lin... | 2012/07/27 | ['https://superuser.com/questions/454341', 'https://superuser.com', 'https://superuser.com/users/148667/'] | I have the same problem after de+reinstall VirtualBox.
Good hint, Oliver Salzburg! It didn't work for me under Win10, but brought me closer to the solution:
* Open start menu, right click on the `VirtualBox link`
* Click on `open file path` - explorer opens
* Right click on `VirtualBox link`, then `settings`
* Under ... | This error occurred with my win 7 64 bit too.
I came to a conclusion that this problem occurred due to installation of youwave for android on my pc.
They both have some conflicts so only any one can be installed at a time. |
14,160,928 | I am trying to draw some Kaplan-Meier curves using **ggplot2** and code found at: <https://github.com/kmiddleton/rexamples/blob/master/qplot_survival.R>
I had good results with this great code in a different database. However, in this case it gives me the following error... as if I had empty rows in my dataframe:
`Er... | 2013/01/04 | ['https://Stackoverflow.com/questions/14160928', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1948108/'] | I did a little cosmetic surgery on your `qplot_survival()` function. The main problem seemed to be your subset condition in the `data =` argument of `geom_point`; in both `t.survframe` and `t.survframe2`, a table of `n.censor` yielded values 0, 3 and 12. By changing the subset condition to `n.censor > 0`, I managed to ... | Here is another version that also accounts for the case when there are no censoring points in your data (@Dennis's version still fails in that case). This could be made more efficient, probably by creating a variable that stores how many censoring points there are in the entire dataframe upfront, and re-use that, rathe... |
63,196,690 | A Worker Service is the new way to write a Windows service in .NET Core 3.x. The worker class extends [`Microsoft.Extensions.Hosting.BackgroundService`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.backgroundservice?view=dotnet-plat-ext-3.1) and implements `ExecuteAsync`. The documentation ... | 2020/07/31 | ['https://Stackoverflow.com/questions/63196690', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8773089/'] | You could also use an actual infinite delay:
```
await Task.Delay(Timeout.Infinite, cancellationToken);
``` | I incorporated the delay into a method called `Eternity`:
```
private async Task Eternity(CancellationToken cancel)
{
while (!cancel.IsCancellationRequested)
{
await Task.Delay(TimeSpan.FromDays(1), cancel);
}
}
```
So my `ExecuteAsync` looks like:
```
protected override async Task ExecuteAsync(... |
63,196,690 | A Worker Service is the new way to write a Windows service in .NET Core 3.x. The worker class extends [`Microsoft.Extensions.Hosting.BackgroundService`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.backgroundservice?view=dotnet-plat-ext-3.1) and implements `ExecuteAsync`. The documentation ... | 2020/07/31 | ['https://Stackoverflow.com/questions/63196690', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8773089/'] | You could also use an actual infinite delay:
```
await Task.Delay(Timeout.Infinite, cancellationToken);
``` | If you want to call it like `await "Eternity"` or `await ("Eternity", token)` if you want cancellation support. We can use them with cancellation support thanks to value tuples.
Basically *you can await anything* with some extension methods.
Here is the code:
```
protected override async Task ExecuteAsync(Cancellati... |
23,298,393 | I tried many various methods, but didn't work.. What's wrong with my code? Please explain... help. My both images is transparent, with my idea on mouseover shoud fade new image. Current my code:
[DEMO](http://jsbin.com/nipocete/1)
[DEMO2](http://jsbin.com/nipocete/1/edit)
```
<script type='text/javascript'>
$(documen... | 2014/04/25 | ['https://Stackoverflow.com/questions/23298393', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3573697/'] | I believe to achieve your desired effect as I understand it you simply need to add a background to `img.a`. [Fiddle](http://jsfiddle.net/G8TB5/2/ "Fiddle")
```
img.a{
position: absolute;
left: 0;
top: 0;
z-index: 10;
background:#fff;
}
``` | It seems to me you are doing the wrong thing. The img.b should have opacity 0 at :not(:hover) and opacity 1 at :hover, but all you are doing is setting the opacity of $(this) which is img.a
Here is my re-work... I didn't use hover because I get confused with the syntax
Here is my [fiddle/jsbin](http://jsbin.com/nipoc... |
23,298,393 | I tried many various methods, but didn't work.. What's wrong with my code? Please explain... help. My both images is transparent, with my idea on mouseover shoud fade new image. Current my code:
[DEMO](http://jsbin.com/nipocete/1)
[DEMO2](http://jsbin.com/nipocete/1/edit)
```
<script type='text/javascript'>
$(documen... | 2014/04/25 | ['https://Stackoverflow.com/questions/23298393', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3573697/'] | I believe to achieve your desired effect as I understand it you simply need to add a background to `img.a`. [Fiddle](http://jsfiddle.net/G8TB5/2/ "Fiddle")
```
img.a{
position: absolute;
left: 0;
top: 0;
z-index: 10;
background:#fff;
}
``` | ExceptionLimeCat solutions good but only for in bright/shiny/white backgrounds.
Jaka Dirnbek way is better, because is more optimal.
Anyway.. Solved with this thing. But how this [Jaka Dirnbek](http://jsbin.com/nipocete/14/edit) jquery use on link? Example:
```
<div id="nav_virsus">
<ul>
<li><a href="#"><... |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | According to the standard:
>
> C++11 1.10/3: The value of an object visible to a thread T at a particular point is the initial value of the object, a value assigned to the object by T, or a value assigned to the object by another thread, according to the rules below.
>
>
>
A string literal, like any other constan... | It is always safe to access immutable data from multiple threads. String literals are an example of immutable data (since it's illegal to modify them at run-time), so it is safe to access them from multiple threads. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | Yes, it's safe. Why wouldn't it be? It would be unsafe if you'd try to modify the string, but that's illegal anyway. | As long as you only read data, you can access it from as many threads as you want. When data needs to be changed, that's when it gets complicated. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | According to the standard:
>
> C++11 1.10/3: The value of an object visible to a thread T at a particular point is the initial value of the object, a value assigned to the object by T, or a value assigned to the object by another thread, according to the rules below.
>
>
>
A string literal, like any other constan... | Yes, it's safe. Why wouldn't it be? It would be unsafe if you'd try to modify the string, but that's illegal anyway. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | As long as you only read data, you can access it from as many threads as you want. When data needs to be changed, that's when it gets complicated. | String literals are (conceptually) stored in read only memory and initialised on loading (rather than at runtime). It's therefore safe to access them from multiple threads at any time.
Note that more complex structures might not be initialised at load time, and so multiple thread access might have the possibility of i... |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | It is always safe to access immutable data from multiple threads. String literals are an example of immutable data (since it's illegal to modify them at run-time), so it is safe to access them from multiple threads. | This depends on the implementation of the C Compiler. But I do not know of an implementation where concurrent read accesses might be unsafe, so in practice this is safe. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | According to the standard:
>
> C++11 1.10/3: The value of an object visible to a thread T at a particular point is the initial value of the object, a value assigned to the object by T, or a value assigned to the object by another thread, according to the rules below.
>
>
>
A string literal, like any other constan... | This depends on the implementation of the C Compiler. But I do not know of an implementation where concurrent read accesses might be unsafe, so in practice this is safe. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | It is always safe to access immutable data from multiple threads. String literals are an example of immutable data (since it's illegal to modify them at run-time), so it is safe to access them from multiple threads. | As long as you only read data, you can access it from as many threads as you want. When data needs to be changed, that's when it gets complicated. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | Yes, it's safe. Why wouldn't it be? It would be unsafe if you'd try to modify the string, but that's illegal anyway. | String literals are (conceptually) stored in read only memory and initialised on loading (rather than at runtime). It's therefore safe to access them from multiple threads at any time.
Note that more complex structures might not be initialised at load time, and so multiple thread access might have the possibility of i... |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | Yes, it's safe. Why wouldn't it be? It would be unsafe if you'd try to modify the string, but that's illegal anyway. | This depends on the implementation of the C Compiler. But I do not know of an implementation where concurrent read accesses might be unsafe, so in practice this is safe. |
9,533,392 | Is it valid (defined behavior) to access a string literal simultaneously with multiple threads? Given a function like this:
```
const char* give()
{
return "Hello, World!";
}
```
Would it be save to call the function and dereference the pointer simultaneously?
Edit: Many answers. Will accept the first one who can... | 2012/03/02 | ['https://Stackoverflow.com/questions/9533392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/941699/'] | According to the standard:
>
> C++11 1.10/3: The value of an object visible to a thread T at a particular point is the initial value of the object, a value assigned to the object by T, or a value assigned to the object by another thread, according to the rules below.
>
>
>
A string literal, like any other constan... | String literals are (conceptually) stored in read only memory and initialised on loading (rather than at runtime). It's therefore safe to access them from multiple threads at any time.
Note that more complex structures might not be initialised at load time, and so multiple thread access might have the possibility of i... |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | I'm taking it that you mean that different "people" that are conducting simultaneous requests should not get the same random row? The most robust way, without testing it, in order to avoid the minute chance of the same record being selected twice in two running requests will probably be to lock the table and perform th... | You should create a separate db table and mark ads that user received with its help. Before sending ads to user check if he has already received it. |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | You may use [mutex](https://www.yiiframework.com/doc/api/2.0/yii-mutex-mutex) component to ensure that there is only one process trying to pop ad from queue.
```
$banner = [];
$key = __CLASS__ . '::generateAdQueue()' . serialize($params);
if (Yii::$app->mutex->acquire($key, 1)) {
$banner = $this->getBanner($params... | You can use transactions and SELECT FOR UPDATE construction for lock data and consistent executing of queries. For instance:
```
public function getAds()
{
$db = Yii::$app->db;
$transaction = $db->beginTransaction(Transaction::REPEATABLE_READ);
try {
$ads_queue = (new \yii\db\Query())
-... |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | I'm taking it that you mean that different "people" that are conducting simultaneous requests should not get the same random row? The most robust way, without testing it, in order to avoid the minute chance of the same record being selected twice in two running requests will probably be to lock the table and perform th... | Make your index unique or make a check that checks the data and see's if it is a duplicate.
Hope this helps. Good luck |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | Although it might seem to be a trivial question it is not at all, there are several ways to handle it and each of them has its own downsides, mainly you can face this issue from three different points:
Live with it
============
Chances you can get a repeated pull are low in real life and you need to really think if y... | You may use [mutex](https://www.yiiframework.com/doc/api/2.0/yii-mutex-mutex) component to ensure that there is only one process trying to pop ad from queue.
```
$banner = [];
$key = __CLASS__ . '::generateAdQueue()' . serialize($params);
if (Yii::$app->mutex->acquire($key, 1)) {
$banner = $this->getBanner($params... |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | Presumably, the ads are presented from separate pages. HTML is "stateless", so you cannot expect one page to know what ads have previously been displayed. So, you have to either pass this info from page to page, or store it somewhere in the database associated with the individual user.
You also want some randomizing? ... | Make your index unique or make a check that checks the data and see's if it is a duplicate.
Hope this helps. Good luck |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | I'm taking it that you mean that different "people" that are conducting simultaneous requests should not get the same random row? The most robust way, without testing it, in order to avoid the minute chance of the same record being selected twice in two running requests will probably be to lock the table and perform th... | Presumably, the ads are presented from separate pages. HTML is "stateless", so you cannot expect one page to know what ads have previously been displayed. So, you have to either pass this info from page to page, or store it somewhere in the database associated with the individual user.
You also want some randomizing? ... |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | You should create a separate db table and mark ads that user received with its help. Before sending ads to user check if he has already received it. | Make your index unique or make a check that checks the data and see's if it is a duplicate.
Hope this helps. Good luck |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | I'm taking it that you mean that different "people" that are conducting simultaneous requests should not get the same random row? The most robust way, without testing it, in order to avoid the minute chance of the same record being selected twice in two running requests will probably be to lock the table and perform th... | You may use [mutex](https://www.yiiframework.com/doc/api/2.0/yii-mutex-mutex) component to ensure that there is only one process trying to pop ad from queue.
```
$banner = [];
$key = __CLASS__ . '::generateAdQueue()' . serialize($params);
if (Yii::$app->mutex->acquire($key, 1)) {
$banner = $this->getBanner($params... |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | Although it might seem to be a trivial question it is not at all, there are several ways to handle it and each of them has its own downsides, mainly you can face this issue from three different points:
Live with it
============
Chances you can get a repeated pull are low in real life and you need to really think if y... | Make your index unique or make a check that checks the data and see's if it is a duplicate.
Hope this helps. Good luck |
52,426,582 | I have one table as ad\_banner\_queue which is i am using to generate the Queue based on weightage of ads. Ads are inserted into advertisement table. Queue will be generated if all existing ads which are in queue delivered to user.
Now the issue is how should i prevent to sending the duplicate ads in case of request c... | 2018/09/20 | ['https://Stackoverflow.com/questions/52426582', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1773177/'] | Presumably, the ads are presented from separate pages. HTML is "stateless", so you cannot expect one page to know what ads have previously been displayed. So, you have to either pass this info from page to page, or store it somewhere in the database associated with the individual user.
You also want some randomizing? ... | You can use transactions and SELECT FOR UPDATE construction for lock data and consistent executing of queries. For instance:
```
public function getAds()
{
$db = Yii::$app->db;
$transaction = $db->beginTransaction(Transaction::REPEATABLE_READ);
try {
$ads_queue = (new \yii\db\Query())
-... |
30,707,256 | I am implementing instamojo payment method into my website. Can I use a localhost URL as Webhook URL in order to test the process? | 2015/06/08 | ['https://Stackoverflow.com/questions/30707256', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4290253/'] | I'm from Instamojo.
You can't use a local URL. This is because a webhook request is a POST request that is made from our server. Therefore, the only URLs that we can make these requests to would be URLs that are publicly available.
For testing purposes, I would recommend using [RequestBin](https://requestbin.com/). Y... | I doubt if you can use local host URL
but instead you can create new links, as below
<https://www.instamojo.com/api/1.1/links/> |
30,707,256 | I am implementing instamojo payment method into my website. Can I use a localhost URL as Webhook URL in order to test the process? | 2015/06/08 | ['https://Stackoverflow.com/questions/30707256', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4290253/'] | It is possible to forward Instamojo's webhooks to your local machine using tools like `localtunnel`.
* `npm` is required to install localtunnel. [[How to install node and npm]](https://docs.npmjs.com/getting-started/installing-node)
* Install
[localtunnel](https://localtunnel.me/)
Suppose you are running your local ... | I doubt if you can use local host URL
but instead you can create new links, as below
<https://www.instamojo.com/api/1.1/links/> |
30,707,256 | I am implementing instamojo payment method into my website. Can I use a localhost URL as Webhook URL in order to test the process? | 2015/06/08 | ['https://Stackoverflow.com/questions/30707256', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4290253/'] | I doubt if you can use local host URL
but instead you can create new links, as below
<https://www.instamojo.com/api/1.1/links/> | You cannot use the localhost URL as a webhook URL in order to test the process. But you can simply bypass it, open hosts file from `C:\Windows\System32\Drivers\etc\hosts`
At the end of the line write
```
127.0.0.1 yourname.com
```
And access localhost using yourname.com.
Just change localhost/your-location url... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.