qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
155,937 | I am looking for a word or phrase to describe the act of *taking consumers away* from one existing standard/norm in favor of an alternative.
For example: 3D printing will *take away* consumers from manufacturers and put the manufacturing into individuals hands. | 2014/03/06 | [
"https://english.stackexchange.com/questions/155937",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/16277/"
] | "win over" or "convert".
3D printing will **win over** consumers and put the manufacturing into individuals hands. | Where I work, we use the phrase "stealing market share." |
155,937 | I am looking for a word or phrase to describe the act of *taking consumers away* from one existing standard/norm in favor of an alternative.
For example: 3D printing will *take away* consumers from manufacturers and put the manufacturing into individuals hands. | 2014/03/06 | [
"https://english.stackexchange.com/questions/155937",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/16277/"
] | "win over" or "convert".
3D printing will **win over** consumers and put the manufacturing into individuals hands. | Before winning them, they must be [lured](http://dictionary.reference.com/browse/lure) to or [enticed](http://dictionary.reference.com/browse/entice?s=t) by your product: to **attract**, or tempt; allure; to draw by appealing to the emotions or senses, by stimulating interest, or by exciting admiration; allure; invite:... |
155,937 | I am looking for a word or phrase to describe the act of *taking consumers away* from one existing standard/norm in favor of an alternative.
For example: 3D printing will *take away* consumers from manufacturers and put the manufacturing into individuals hands. | 2014/03/06 | [
"https://english.stackexchange.com/questions/155937",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/16277/"
] | >
> [Cannibalization marketing](http://en.wikipedia.org/wiki/Cannibalization_%28marketing%29)
>
>
> In marketing strategy, cannibalization refers to a reduction in sales volume, sales
> revenue, or market share of one product as a result of the introduction of a new product by
> the same producer.
>
>
> | Here are some alternatives:
3D printing will **steer consumers away** from manufacturers and put the manufacturing into individuals hands.
3D printing **channel influence away** from manufacturers and into individuals hands.
3D printing will **sway consumers away** from manufacturers and put the manufacturing into i... |
155,937 | I am looking for a word or phrase to describe the act of *taking consumers away* from one existing standard/norm in favor of an alternative.
For example: 3D printing will *take away* consumers from manufacturers and put the manufacturing into individuals hands. | 2014/03/06 | [
"https://english.stackexchange.com/questions/155937",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/16277/"
] | Before winning them, they must be [lured](http://dictionary.reference.com/browse/lure) to or [enticed](http://dictionary.reference.com/browse/entice?s=t) by your product: to **attract**, or tempt; allure; to draw by appealing to the emotions or senses, by stimulating interest, or by exciting admiration; allure; invite:... | Here are some alternatives:
3D printing will **steer consumers away** from manufacturers and put the manufacturing into individuals hands.
3D printing **channel influence away** from manufacturers and into individuals hands.
3D printing will **sway consumers away** from manufacturers and put the manufacturing into i... |
155,937 | I am looking for a word or phrase to describe the act of *taking consumers away* from one existing standard/norm in favor of an alternative.
For example: 3D printing will *take away* consumers from manufacturers and put the manufacturing into individuals hands. | 2014/03/06 | [
"https://english.stackexchange.com/questions/155937",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/16277/"
] | Where I work, we use the phrase "stealing market share." | Here are some alternatives:
3D printing will **steer consumers away** from manufacturers and put the manufacturing into individuals hands.
3D printing **channel influence away** from manufacturers and into individuals hands.
3D printing will **sway consumers away** from manufacturers and put the manufacturing into i... |
22,616,436 | I am trying to create a game object class that contains a sprite object. I think I'm misunderstanding something fundamental.
edit: The sprite class works but the gameObj class does not.
```
function sprite(img) {
this.image = img;
this.w = img.width;
this.h = img.height;
}
function gameObj(img, x, y) {
... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22616436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020976/"
] | Well, I don't know much about rendering, but when talking about tasks that can be solved by distributed computing, you will probably want to take a look on Bag-of-Tasks (BoT) applications.
>
> "Bag-of-Tasks applications (those parallel applications whose tasks are
> independent) are both relevant and amendable for e... | Old question, but fresh answer.
I have my own Distributed Computing Library written completely in C++ (search for gridman raspberry pi).
I am using it for:
- Distributed Neural Networks training / validation
- Distributed raytracing (for fun)
- Distributed MD5 crunching (for fun)
- Distributed WEP crunching (for ... |
45,028,713 | ```
PK Date ID
=== =========== ===
1 07/04/2017 22
2 07/05/2017 22
3 07/07/2017 03
4 07/08/2017 04
5 07/09/2017 22
6 07/09/2017 22
7 07/10/2017 05
8 07/11/2017 03
9 07/11/2017 03
10 07/11/2017 03
```
I want to count the number of ID occurr... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45028713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8287986/"
] | Seems like a simple case of count distinct and group by:
```
SELECT Id, COUNT(DISTINCT [Date]) As [Count]
FROM TableName
WHERE [Date] >= @StartDate
AND [Date] <= @EndDate
GROUP BY Id
ORDER BY [Count] DESC
``` | You can read more abot how to get month from a date in [get month from a date](https://www.w3schools.com/sql/func_datepart.asp) (it also works for year).
Your query will be :
```
select DATEPART(mm,Date) AS month, COUNT(ID) AS count from table group by month
```
Hope that helped you. |
45,028,713 | ```
PK Date ID
=== =========== ===
1 07/04/2017 22
2 07/05/2017 22
3 07/07/2017 03
4 07/08/2017 04
5 07/09/2017 22
6 07/09/2017 22
7 07/10/2017 05
8 07/11/2017 03
9 07/11/2017 03
10 07/11/2017 03
```
I want to count the number of ID occurr... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45028713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8287986/"
] | You can use `COUNT` with `DISTINCT` e.g.:
```
SELECT ID, COUNT(DISTINCT Date)
FROM table
GROUP BY ID;
``` | You can read more abot how to get month from a date in [get month from a date](https://www.w3schools.com/sql/func_datepart.asp) (it also works for year).
Your query will be :
```
select DATEPART(mm,Date) AS month, COUNT(ID) AS count from table group by month
```
Hope that helped you. |
44,326,722 | I'm creating a REST service in Java. I use javax package. I have the following question:
is it possible to create something like "default page" for the unimplemented endpoints? I.e., let us suppose I implement the following endpoints:
localhost:8080/rest/a
localhost:8080/rest/b
And know I want some default page to b... | 2017/06/02 | [
"https://Stackoverflow.com/questions/44326722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2905035/"
] | When you initialize your `new node`, you set its `next` pointer to `NULL`:
```
temp = new node();
temp -> prev = run;
temp -> value = xb;
temp->next = NULL;
```
Then you search through the existing list to find where to insert the new node. And then you insert it:
```
run -> next = temp;
```
If you were paying a... | Well, you shouldn't let *temp->next = NULL* when you insert an element into a link list, because you would lost your node after place where you insert into.You need to this *temp->next = run->next* to connect your node after you inserted.This is the main problem of your program.
Another problem is after you modify your... |
44,326,722 | I'm creating a REST service in Java. I use javax package. I have the following question:
is it possible to create something like "default page" for the unimplemented endpoints? I.e., let us suppose I implement the following endpoints:
localhost:8080/rest/a
localhost:8080/rest/b
And know I want some default page to b... | 2017/06/02 | [
"https://Stackoverflow.com/questions/44326722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2905035/"
] | When you initialize your `new node`, you set its `next` pointer to `NULL`:
```
temp = new node();
temp -> prev = run;
temp -> value = xb;
temp->next = NULL;
```
Then you search through the existing list to find where to insert the new node. And then you insert it:
```
run -> next = temp;
```
If you were paying a... | I respect if this is a C training session. If so you have been provided excellent support.
But if you are making production code, you should use std::list instead. It may have performance penalties, but you will be relieved from debugging.
If you prefer the training mode, I would suggest you to include an end-pointer ... |
27,422,874 | Hi I am trying to change the contents of a hidden input.
```
var temp = $("#header").val().replace("(/<\/div><div>/g","<br>");
```
I tried using the following replace but it does not change it.
May I know what I did wrong? I am trying to replace:
```
</div><div>
```
to
```
<br>
```
**EDIT - this is my progra... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27422874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3743770/"
] | To replace all ocurrences in a string, the correct syntax with regExp is:
```
var temp = $("#header").val().replace(/<\/div><div>/g,"<br>");
```
You can test it, here:
```
'</div><div></div><div></div><div></div><div>'.replace(/<\/div><div>/g,"<br>");
```
returns:
```
<br><br><br><br>
``` | You should do:
```
.replace(/<\/div><div>/g,"<br>");
```
The RegExp should not be enclosed within quotes else it would be a String. Also, the `.val()` method is used for textareas. Use `.html()` for `header`, `div`s, etc. |
147,073 | A polynomial $p$ over a field $k$ is called irreducible if $p=fg$ for polynomials $f,g$ implies $f$ or $g$ are constant. One can consider the determinant of an $n\times n$ matrix to be a polynomial in $n^2$ variables. Does anyone know of a slick way to prove this polynomial is irreducible?
It feels like this should fo... | 2012/05/19 | [
"https://math.stackexchange.com/questions/147073",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31559/"
] | Deonote $p$ the determinant polyonomial. Observing that $p$ is of degree one in $x\_{ij}$ for every $(i,j)$.
Now we can prove $p$ is irreducible. Suppose $p=fg$. Consider $x\_{11}$. Suppose $x\_{11}$ appears in $f$, then $f$ is of degree one in $x\_{11}$ and $g$ is of degree zero in $x\_{11}$. Now consider $x\_{1j}$, ... | [This answer](https://math.stackexchange.com/a/147085/39797) is basically a proof from M.Bocher "Introduction to higher algebra" (Dover 2004)
on pages [176-7](http://books.google.com/books?id=3XBQm4uWkiwC&lpg=PA176&pg=PA176#v=onepage&q&f=false "Google Books"). |
147,073 | A polynomial $p$ over a field $k$ is called irreducible if $p=fg$ for polynomials $f,g$ implies $f$ or $g$ are constant. One can consider the determinant of an $n\times n$ matrix to be a polynomial in $n^2$ variables. Does anyone know of a slick way to prove this polynomial is irreducible?
It feels like this should fo... | 2012/05/19 | [
"https://math.stackexchange.com/questions/147073",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31559/"
] | Deonote $p$ the determinant polyonomial. Observing that $p$ is of degree one in $x\_{ij}$ for every $(i,j)$.
Now we can prove $p$ is irreducible. Suppose $p=fg$. Consider $x\_{11}$. Suppose $x\_{11}$ appears in $f$, then $f$ is of degree one in $x\_{11}$ and $g$ is of degree zero in $x\_{11}$. Now consider $x\_{1j}$, ... | Here is a proof using a little bit of algebraic geometry (we assume k is algebrically closed).
It can be seen that $V(det)$ is irreducible in $k^{n^2}$. It is for example the image of the morphism $M\_n(k)\times M\_n(k) \rightarrow V(det)$, $(P,Q)\mapsto PI\_{n-1}Q$ and the source is irreducible.
Hence as $k[X\_{ij}]$... |
147,073 | A polynomial $p$ over a field $k$ is called irreducible if $p=fg$ for polynomials $f,g$ implies $f$ or $g$ are constant. One can consider the determinant of an $n\times n$ matrix to be a polynomial in $n^2$ variables. Does anyone know of a slick way to prove this polynomial is irreducible?
It feels like this should fo... | 2012/05/19 | [
"https://math.stackexchange.com/questions/147073",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31559/"
] | Deonote $p$ the determinant polyonomial. Observing that $p$ is of degree one in $x\_{ij}$ for every $(i,j)$.
Now we can prove $p$ is irreducible. Suppose $p=fg$. Consider $x\_{11}$. Suppose $x\_{11}$ appears in $f$, then $f$ is of degree one in $x\_{11}$ and $g$ is of degree zero in $x\_{11}$. Now consider $x\_{1j}$, ... | Here is another algebraic argument which may be of interest, using induction on the size of the matrix:
Let $A\_{ij}$ be the minor we get when we delete row $i$ and column $j$. If we expand along the first row of the matrix, we get
$$\det A=(\det A\_{11})x\_{11}-(\det A\_{12})x\_{12}+\cdots\pm(\det A\_{1n})x\_{1n}.$$
... |
147,073 | A polynomial $p$ over a field $k$ is called irreducible if $p=fg$ for polynomials $f,g$ implies $f$ or $g$ are constant. One can consider the determinant of an $n\times n$ matrix to be a polynomial in $n^2$ variables. Does anyone know of a slick way to prove this polynomial is irreducible?
It feels like this should fo... | 2012/05/19 | [
"https://math.stackexchange.com/questions/147073",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31559/"
] | [This answer](https://math.stackexchange.com/a/147085/39797) is basically a proof from M.Bocher "Introduction to higher algebra" (Dover 2004)
on pages [176-7](http://books.google.com/books?id=3XBQm4uWkiwC&lpg=PA176&pg=PA176#v=onepage&q&f=false "Google Books"). | Here is a proof using a little bit of algebraic geometry (we assume k is algebrically closed).
It can be seen that $V(det)$ is irreducible in $k^{n^2}$. It is for example the image of the morphism $M\_n(k)\times M\_n(k) \rightarrow V(det)$, $(P,Q)\mapsto PI\_{n-1}Q$ and the source is irreducible.
Hence as $k[X\_{ij}]$... |
147,073 | A polynomial $p$ over a field $k$ is called irreducible if $p=fg$ for polynomials $f,g$ implies $f$ or $g$ are constant. One can consider the determinant of an $n\times n$ matrix to be a polynomial in $n^2$ variables. Does anyone know of a slick way to prove this polynomial is irreducible?
It feels like this should fo... | 2012/05/19 | [
"https://math.stackexchange.com/questions/147073",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31559/"
] | [This answer](https://math.stackexchange.com/a/147085/39797) is basically a proof from M.Bocher "Introduction to higher algebra" (Dover 2004)
on pages [176-7](http://books.google.com/books?id=3XBQm4uWkiwC&lpg=PA176&pg=PA176#v=onepage&q&f=false "Google Books"). | Here is another algebraic argument which may be of interest, using induction on the size of the matrix:
Let $A\_{ij}$ be the minor we get when we delete row $i$ and column $j$. If we expand along the first row of the matrix, we get
$$\det A=(\det A\_{11})x\_{11}-(\det A\_{12})x\_{12}+\cdots\pm(\det A\_{1n})x\_{1n}.$$
... |
147,073 | A polynomial $p$ over a field $k$ is called irreducible if $p=fg$ for polynomials $f,g$ implies $f$ or $g$ are constant. One can consider the determinant of an $n\times n$ matrix to be a polynomial in $n^2$ variables. Does anyone know of a slick way to prove this polynomial is irreducible?
It feels like this should fo... | 2012/05/19 | [
"https://math.stackexchange.com/questions/147073",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31559/"
] | Here is a proof using a little bit of algebraic geometry (we assume k is algebrically closed).
It can be seen that $V(det)$ is irreducible in $k^{n^2}$. It is for example the image of the morphism $M\_n(k)\times M\_n(k) \rightarrow V(det)$, $(P,Q)\mapsto PI\_{n-1}Q$ and the source is irreducible.
Hence as $k[X\_{ij}]$... | Here is another algebraic argument which may be of interest, using induction on the size of the matrix:
Let $A\_{ij}$ be the minor we get when we delete row $i$ and column $j$. If we expand along the first row of the matrix, we get
$$\det A=(\det A\_{11})x\_{11}-(\det A\_{12})x\_{12}+\cdots\pm(\det A\_{1n})x\_{1n}.$$
... |
58,213,585 | I'm hoping to find a way to iterate over an #each block a set amount of times in Svelte 3. In Vue I would do something like this:
```
<li v-for="i in 3"><!-- somecontent --></li>
```
But as I understand Svelte handles loops much differently using the .length property of the array being #eached. Is there some way to ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58213585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7657915/"
] | You can use `{#each ...}`, like:
```
{#each Array(3) as _, i}
<li>{i + 1}</li>
{/each}
``` | An `#each` tag can loop anything with a length property, so:
```
{#each {length: 3} as _, i}
<li>{i + 1}</li>
{/each}
```
will also work, if you prefer. |
58,213,585 | I'm hoping to find a way to iterate over an #each block a set amount of times in Svelte 3. In Vue I would do something like this:
```
<li v-for="i in 3"><!-- somecontent --></li>
```
But as I understand Svelte handles loops much differently using the .length property of the array being #eached. Is there some way to ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58213585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7657915/"
] | You can use `{#each ...}`, like:
```
{#each Array(3) as _, i}
<li>{i + 1}</li>
{/each}
``` | i Use like this for travelling from `a` to `b` in Svelte
```
{#each Array.from(Array(b+1).keys()).slice(a) as i }
<h1>{i}</h1>
{/each}
```
example (1 to 100):
```
{#each Array.from(Array(100+1).keys()).slice(1) as i }
<h1>{i}</h1>
{/each}
``` |
58,213,585 | I'm hoping to find a way to iterate over an #each block a set amount of times in Svelte 3. In Vue I would do something like this:
```
<li v-for="i in 3"><!-- somecontent --></li>
```
But as I understand Svelte handles loops much differently using the .length property of the array being #eached. Is there some way to ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58213585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7657915/"
] | You can use `{#each ...}`, like:
```
{#each Array(3) as _, i}
<li>{i + 1}</li>
{/each}
``` | You can use clean variable from the script section (mmm... for a pagination):
```
// script
export let numOfPages = 10
const pagesArray = Array.from({length: numOfPages}, (x, i) => i+1) // [1,2,3,4,5,6,7,8,9,10]
// template
{#each pagesArray as page}
<li>{page}</li>
{/each}
``` |
58,213,585 | I'm hoping to find a way to iterate over an #each block a set amount of times in Svelte 3. In Vue I would do something like this:
```
<li v-for="i in 3"><!-- somecontent --></li>
```
But as I understand Svelte handles loops much differently using the .length property of the array being #eached. Is there some way to ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58213585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7657915/"
] | An `#each` tag can loop anything with a length property, so:
```
{#each {length: 3} as _, i}
<li>{i + 1}</li>
{/each}
```
will also work, if you prefer. | i Use like this for travelling from `a` to `b` in Svelte
```
{#each Array.from(Array(b+1).keys()).slice(a) as i }
<h1>{i}</h1>
{/each}
```
example (1 to 100):
```
{#each Array.from(Array(100+1).keys()).slice(1) as i }
<h1>{i}</h1>
{/each}
``` |
58,213,585 | I'm hoping to find a way to iterate over an #each block a set amount of times in Svelte 3. In Vue I would do something like this:
```
<li v-for="i in 3"><!-- somecontent --></li>
```
But as I understand Svelte handles loops much differently using the .length property of the array being #eached. Is there some way to ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58213585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7657915/"
] | An `#each` tag can loop anything with a length property, so:
```
{#each {length: 3} as _, i}
<li>{i + 1}</li>
{/each}
```
will also work, if you prefer. | You can use clean variable from the script section (mmm... for a pagination):
```
// script
export let numOfPages = 10
const pagesArray = Array.from({length: numOfPages}, (x, i) => i+1) // [1,2,3,4,5,6,7,8,9,10]
// template
{#each pagesArray as page}
<li>{page}</li>
{/each}
``` |
58,213,585 | I'm hoping to find a way to iterate over an #each block a set amount of times in Svelte 3. In Vue I would do something like this:
```
<li v-for="i in 3"><!-- somecontent --></li>
```
But as I understand Svelte handles loops much differently using the .length property of the array being #eached. Is there some way to ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58213585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7657915/"
] | i Use like this for travelling from `a` to `b` in Svelte
```
{#each Array.from(Array(b+1).keys()).slice(a) as i }
<h1>{i}</h1>
{/each}
```
example (1 to 100):
```
{#each Array.from(Array(100+1).keys()).slice(1) as i }
<h1>{i}</h1>
{/each}
``` | You can use clean variable from the script section (mmm... for a pagination):
```
// script
export let numOfPages = 10
const pagesArray = Array.from({length: numOfPages}, (x, i) => i+1) // [1,2,3,4,5,6,7,8,9,10]
// template
{#each pagesArray as page}
<li>{page}</li>
{/each}
``` |
1,510,957 | >
> Suppose$G$ is an abelian group and $|G|=6$, prove that $G=\{e,g,g^2,...,g^5\}$ for some $g$ with $g^6=e$.
>
>
>
My attempt:
1. If $G$ consists only of elements of order 2, then $|G|=2^m$ for some $m$. $6 \neq 2^m \Rightarrow$ $G$ has at least one element $g'$ with $|g'| \neq 2$
2. By application of Lagrange'... | 2015/11/03 | [
"https://math.stackexchange.com/questions/1510957",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/248257/"
] | Just compute the powers of $ab$ (using the relations $a^2=b^3=1$ on the way). | \begin{aligned}(a b)^2=a^2b^2=b^2&\implies (a b)^3=(a b)(a b)^2=(a b)b^2=a b^3=a\\
&\implies (a b)^4=(a b)(a b)^3=(a b)a=a^2b=b\\
&\implies (a b)^5=(a b)(a b)^4=(a b )b=a b^2.\end{aligned} |
1,510,957 | >
> Suppose$G$ is an abelian group and $|G|=6$, prove that $G=\{e,g,g^2,...,g^5\}$ for some $g$ with $g^6=e$.
>
>
>
My attempt:
1. If $G$ consists only of elements of order 2, then $|G|=2^m$ for some $m$. $6 \neq 2^m \Rightarrow$ $G$ has at least one element $g'$ with $|g'| \neq 2$
2. By application of Lagrange'... | 2015/11/03 | [
"https://math.stackexchange.com/questions/1510957",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/248257/"
] | Just compute the powers of $ab$ (using the relations $a^2=b^3=1$ on the way). | Since $ab\ne e$, $(ab)^2\ne e$, $(ab)^3\ne e$, it must have order $6$. |
1,510,957 | >
> Suppose$G$ is an abelian group and $|G|=6$, prove that $G=\{e,g,g^2,...,g^5\}$ for some $g$ with $g^6=e$.
>
>
>
My attempt:
1. If $G$ consists only of elements of order 2, then $|G|=2^m$ for some $m$. $6 \neq 2^m \Rightarrow$ $G$ has at least one element $g'$ with $|g'| \neq 2$
2. By application of Lagrange'... | 2015/11/03 | [
"https://math.stackexchange.com/questions/1510957",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/248257/"
] | Since $ab\ne e$, $(ab)^2\ne e$, $(ab)^3\ne e$, it must have order $6$. | \begin{aligned}(a b)^2=a^2b^2=b^2&\implies (a b)^3=(a b)(a b)^2=(a b)b^2=a b^3=a\\
&\implies (a b)^4=(a b)(a b)^3=(a b)a=a^2b=b\\
&\implies (a b)^5=(a b)(a b)^4=(a b )b=a b^2.\end{aligned} |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | [DateTime fields](http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.DateTimeField) will always store also seconds; however, you can easily tell the template to just show the hours and minute, with the `time` filter:
```
{{ value|time:"H:M" }}
```
where "value" is the variable containing the da... | So I think the proposed and accepted solution is not optimal because with:
```
datetime.widget = forms.SplitDateTimeWidget(time_format=('%H:%M'))
```
For a SplitDateTimeField in my case but for you only change it to TimeWidget.
Hope it helps other people too. |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | For a `ModelForm`, you can easily add a widget like this, to avoid the seconds being shown (just show hh:mm):
```
class MyCreateForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ('time_in', 'time_out', )
widgets = {
'time_in': forms.TimeInput(format='%H:%M'),
... | On Django 1.9 the following format should work:
```
{{ yourData.value|time:"H:i" }}
```
Django has a whole set of template tags and filters.
Django 1.9 documentation on this is:
<https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#time> |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | Django widget can be used to achieve this easily.
```
from django import forms
class timeSlotForm(forms.Form):
from_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
``` | You can at least modify the output in the `__str__` method on the model by using `datetime.time.isoformat(timespec='minutes')`, like this:
```
def __str__(self):
return self.value.isoformat(timespec='minutes')
```
Now the value is showing as HH:MM in admin pages. |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | You can at least modify the output in the `__str__` method on the model by using `datetime.time.isoformat(timespec='minutes')`, like this:
```
def __str__(self):
return self.value.isoformat(timespec='minutes')
```
Now the value is showing as HH:MM in admin pages. | On Django 1.9 the following format should work:
```
{{ yourData.value|time:"H:i" }}
```
Django has a whole set of template tags and filters.
Django 1.9 documentation on this is:
<https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#time> |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | [DateTime fields](http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.DateTimeField) will always store also seconds; however, you can easily tell the template to just show the hours and minute, with the `time` filter:
```
{{ value|time:"H:M" }}
```
where "value" is the variable containing the da... | TimeField model
in Template
**Is displayed**
```
{{ value|time:"H:i" }}
```
**Is not displayed**
```
{{ value|time:"H:M" }}
```
Django 1.4.1 |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | So I think the proposed and accepted solution is not optimal because with:
```
datetime.widget = forms.SplitDateTimeWidget(time_format=('%H:%M'))
```
For a SplitDateTimeField in my case but for you only change it to TimeWidget.
Hope it helps other people too. | On Django 1.9 the following format should work:
```
{{ yourData.value|time:"H:i" }}
```
Django has a whole set of template tags and filters.
Django 1.9 documentation on this is:
<https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#time> |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | TimeField model
in Template
**Is displayed**
```
{{ value|time:"H:i" }}
```
**Is not displayed**
```
{{ value|time:"H:M" }}
```
Django 1.4.1 | On Django 1.9 the following format should work:
```
{{ yourData.value|time:"H:i" }}
```
Django has a whole set of template tags and filters.
Django 1.9 documentation on this is:
<https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#time> |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | [DateTime fields](http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.DateTimeField) will always store also seconds; however, you can easily tell the template to just show the hours and minute, with the `time` filter:
```
{{ value|time:"H:M" }}
```
where "value" is the variable containing the da... | For a `ModelForm`, you can easily add a widget like this, to avoid the seconds being shown (just show hh:mm):
```
class MyCreateForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ('time_in', 'time_out', )
widgets = {
'time_in': forms.TimeInput(format='%H:%M'),
... |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | Django widget can be used to achieve this easily.
```
from django import forms
class timeSlotForm(forms.Form):
from_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
``` | TimeField model
in Template
**Is displayed**
```
{{ value|time:"H:i" }}
```
**Is not displayed**
```
{{ value|time:"H:M" }}
```
Django 1.4.1 |
1,240,278 | Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.
Cheers | 2009/08/06 | [
"https://Stackoverflow.com/questions/1240278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151937/"
] | So I think the proposed and accepted solution is not optimal because with:
```
datetime.widget = forms.SplitDateTimeWidget(time_format=('%H:%M'))
```
For a SplitDateTimeField in my case but for you only change it to TimeWidget.
Hope it helps other people too. | For a `ModelForm`, you can easily add a widget like this, to avoid the seconds being shown (just show hh:mm):
```
class MyCreateForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ('time_in', 'time_out', )
widgets = {
'time_in': forms.TimeInput(format='%H:%M'),
... |
10,670,353 | I'm surprised I couldn't find a solution to this. I would like to position a small table (1 row, 3 cells,) near the top of my document, aligned to the right, with a paragraph wrapping around it, just as you can do with an image with the following code...
```
<img src="http://www.sorenwagner.ws/marty/img/ca-seal.jp... | 2012/05/20 | [
"https://Stackoverflow.com/questions/10670353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1405789/"
] | Just [float](http://www.w3.org/TR/CSS2/visuren.html#propdef-float) the table to the right (which is how you should be positioning the image as well):
```
<table style="float: right">
<!-- ... -->
</table>
<p>Bunch of text...</p>
```
Demo: <http://jsfiddle.net/ambiguous/ZLfg7/1/> | Float the table right and give it a margin via CSS:
```
table {
float:right;
width:300px;
margin:0 0 10px 10px;
}
```
**[jsFiddle example](http://jsfiddle.net/j08691/q58hq/)**. |
10,670,353 | I'm surprised I couldn't find a solution to this. I would like to position a small table (1 row, 3 cells,) near the top of my document, aligned to the right, with a paragraph wrapping around it, just as you can do with an image with the following code...
```
<img src="http://www.sorenwagner.ws/marty/img/ca-seal.jp... | 2012/05/20 | [
"https://Stackoverflow.com/questions/10670353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1405789/"
] | [jsFiddle](http://jsfiddle.net/nq6ez/)
```
table {
float: right; /* floats the table to the right,
allowing text to wrap around it */
margin: 12px; /* adds buffer space around the table */
}
``` | Float the table right and give it a margin via CSS:
```
table {
float:right;
width:300px;
margin:0 0 10px 10px;
}
```
**[jsFiddle example](http://jsfiddle.net/j08691/q58hq/)**. |
24,307,252 | I feel like i'm just missing something here, but I can't see what. I can't seem to get the value of the radio button to behave in the same way as the checkboxes. What am I doing wrong?
Here's a demo: <http://jsfiddle.net/vwJ6a/2/>
Here's an idea of what my HTML looks like
```
<tr ng-repeat="contact in ContactsList">... | 2014/06/19 | [
"https://Stackoverflow.com/questions/24307252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79677/"
] | Nice question! I was stuck on a similar problem and implemented kind of a work around. First of all, I don't think that you want the radio buttons to behave in the same way like the checkboxes. Checkboxes allow multiple values while radios don't. Probably that was clear, I just want to state it in order to prevent a mi... | I believe if you add value="1" to your radio input line, you'll get the results you're looking for.
```
<input type="radio" value="1" name="radio-primary" ng-model="contact.isPrimary" />
``` |
24,307,252 | I feel like i'm just missing something here, but I can't see what. I can't seem to get the value of the radio button to behave in the same way as the checkboxes. What am I doing wrong?
Here's a demo: <http://jsfiddle.net/vwJ6a/2/>
Here's an idea of what my HTML looks like
```
<tr ng-repeat="contact in ContactsList">... | 2014/06/19 | [
"https://Stackoverflow.com/questions/24307252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79677/"
] | The main difference is checkboxes allow multiples selections while radio buttons dont.
That's why radio buttons should share the same model. In your case, the `ngModel`s point to different objects.
This is how I would get around it:
```
<td ng-class="{'success':primaryContact.email == contact.email}">
<input ty... | I believe if you add value="1" to your radio input line, you'll get the results you're looking for.
```
<input type="radio" value="1" name="radio-primary" ng-model="contact.isPrimary" />
``` |
24,307,252 | I feel like i'm just missing something here, but I can't see what. I can't seem to get the value of the radio button to behave in the same way as the checkboxes. What am I doing wrong?
Here's a demo: <http://jsfiddle.net/vwJ6a/2/>
Here's an idea of what my HTML looks like
```
<tr ng-repeat="contact in ContactsList">... | 2014/06/19 | [
"https://Stackoverflow.com/questions/24307252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79677/"
] | Nice question! I was stuck on a similar problem and implemented kind of a work around. First of all, I don't think that you want the radio buttons to behave in the same way like the checkboxes. Checkboxes allow multiple values while radios don't. Probably that was clear, I just want to state it in order to prevent a mi... | The main difference is checkboxes allow multiples selections while radio buttons dont.
That's why radio buttons should share the same model. In your case, the `ngModel`s point to different objects.
This is how I would get around it:
```
<td ng-class="{'success':primaryContact.email == contact.email}">
<input ty... |
59,250,093 | I am writing a feature which deals with adding multiple items to shopping cart like a typical e-commerce application.
It is something like this -
```
Scenario: Promotion is applied
Given I select "Bacon" worth "$1"
Given I select "Lettuce" worth "$2"
Given I select "Diet Coke" worth "$5"
Given I sele... | 2019/12/09 | [
"https://Stackoverflow.com/questions/59250093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3909198/"
] | You can make your structure recursive:
```
class Expression extends Operand {
private Operand operand;
private Operator operator;
//if true, this.operand and this.operator are irrelevant
private boolean aggregated = false;
private List<Expression> aggregatedExpressions;
//if AND applies to... | You should encapsulate the internal structure of each expression and subexpression.
Usually it looks something like:
```
interface Expression {
Result evaluate(EvaluationContext ctx);
void traverse(ExpressionVisitor visitor);
}
class Constant implements Expression {
Result value;
Result evaluate(Eval... |
31,807,585 | I'm looking into using curve25519 on a javacard 3.0.4 but I got stuck and I have the following questions:
**Does javacard 3.0.4 support such a curve?**
What I've tried so far was to convert the Montgomery equation to a Weierstrass equation. Doing this and using [Bernstein's website](http://safecurves.cr.yp.to/index.h... | 2015/08/04 | [
"https://Stackoverflow.com/questions/31807585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5189069/"
] | Not quite. Montgomery and Weierstrass forms can be converted into each other: <http://samuelkerr.com/?p=431>
However, there are various caveats getting this to work on Javacards, and part of the curve operations / conversion has to be done on a PC talking to the card. I'm currently working on this and am happy to shar... | No, such curves are not directly supported.
All Java Card Elliptic Curve facilities use the Weierstraß equation which is
>
> y^2 = x^3 + a\*x + b mod p
>
>
>
Curve 25519 is based on
>
> y^2 = x^3 + 486662\*x^2 + x mod p
>
>
>
Unfortunately its not possible to directly support such Montgomery curves. |
20,292,120 | I am trying content dropdown from Foundation 5: <http://foundation.zurb.com/docs/components/dropdown.html>, but it does not work as you can see on this fiddle: <http://jsfiddle.net/AQGd9/2/>. Basically, the content does not appear upon clicking the link when it should.
```
<a href="#" data-dropdown="drop2">Has Content... | 2013/11/29 | [
"https://Stackoverflow.com/questions/20292120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/754522/"
] | You need to explicitly initialize foundation with this piece of code before the end of your `body`, like this:
```
<body>
...
<script>
$(document).foundation();
</script>
</body>
``` | I have the same problem right now. The doc says that you need include the javascript required files, there are two ways to do it:
1) All Js (core + plugins): foundation.min.js
2) Only the core, and add the plugins on demand: foundation.js + foundation.dropdown.js (in this case).
So, launch foundation Js:
```
$(docu... |
5,812,338 | I have a application that has just two activities, the main activity and a PreferenceActivity. When there is a change in states (Aeroplane mode being turned on or off, the GPS being turned on and off, etc ), I want to update both activities.
I need to update some variables and the UI only when the app is active so I ... | 2011/04/28 | [
"https://Stackoverflow.com/questions/5812338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560283/"
] | I'm not sure why you would need to, but you could always do this:
```
a = raw_input("Type something: ")
if sys.stdin is not sys.__stdin__:
print(a)
print("You typed in: "+a)
```
Then again, swapping `raw_input` for your own implementation as needed would probably make more sense.
Edit: okay, based on your, comm... | **EDIT:** After reading the other answers and comments I think I have found a good way to really redirect the stdin. Note that I have assumed that you will know the the inputs to the end user's raw\_inputs need to be.
**User's Code** (Named some\_module.py)
```
print "running some module with 5 raw_input requests"
f... |
5,812,338 | I have a application that has just two activities, the main activity and a PreferenceActivity. When there is a change in states (Aeroplane mode being turned on or off, the GPS being turned on and off, etc ), I want to update both activities.
I need to update some variables and the UI only when the app is active so I ... | 2011/04/28 | [
"https://Stackoverflow.com/questions/5812338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560283/"
] | I'm not sure why you would need to, but you could always do this:
```
a = raw_input("Type something: ")
if sys.stdin is not sys.__stdin__:
print(a)
print("You typed in: "+a)
```
Then again, swapping `raw_input` for your own implementation as needed would probably make more sense.
Edit: okay, based on your, comm... | Do this.
```
class MyRawInputFakeOutObject( object ):
def __init__( self, the_fake_out_input_text ):
self.input= the_fake_out_input_text
def __call__( self, prompt ):
print( prompt )
return self.input
raw_input= MyRawInputFakeOutObject( "Hello" )
import some_existing_module
some_exis... |
5,812,338 | I have a application that has just two activities, the main activity and a PreferenceActivity. When there is a change in states (Aeroplane mode being turned on or off, the GPS being turned on and off, etc ), I want to update both activities.
I need to update some variables and the UI only when the app is active so I ... | 2011/04/28 | [
"https://Stackoverflow.com/questions/5812338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560283/"
] | Do this.
```
class MyRawInputFakeOutObject( object ):
def __init__( self, the_fake_out_input_text ):
self.input= the_fake_out_input_text
def __call__( self, prompt ):
print( prompt )
return self.input
raw_input= MyRawInputFakeOutObject( "Hello" )
import some_existing_module
some_exis... | **EDIT:** After reading the other answers and comments I think I have found a good way to really redirect the stdin. Note that I have assumed that you will know the the inputs to the end user's raw\_inputs need to be.
**User's Code** (Named some\_module.py)
```
print "running some module with 5 raw_input requests"
f... |
19,702,451 | I included a navigation controller within a popover. The view includes an image that I would like partially covered. In iOS6 is behind the navigation bar, in ios7 exactly the opposite. Attaching the Screenshot.
Does anyone know why? | 2013/10/31 | [
"https://Stackoverflow.com/questions/19702451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2698702/"
] | Use autolayout constraints: <http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1>
Or try this (no elegant solution):
```
NSString *ver = [[UIDevice currentDevice] systemVersion];
float ver_float = [ver floatValue];
if (ver_float >= 7.0f)
{
CGRect frame = self.myView.frame;
frame.o... | If you don't need the navigation bar translucent, you can try navigationBar.isTranslucent = NO. |
19,702,451 | I included a navigation controller within a popover. The view includes an image that I would like partially covered. In iOS6 is behind the navigation bar, in ios7 exactly the opposite. Attaching the Screenshot.
Does anyone know why? | 2013/10/31 | [
"https://Stackoverflow.com/questions/19702451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2698702/"
] | Use autolayout constraints: <http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1>
Or try this (no elegant solution):
```
NSString *ver = [[UIDevice currentDevice] systemVersion];
float ver_float = [ver floatValue];
if (ver_float >= 7.0f)
{
CGRect frame = self.myView.frame;
frame.o... | In iOS 7, layout by default extends the the edges of the container. This is controller by the `edgesForExtendedLayout` view controller property. If you want the layout to start with the top aligned with the navigation bar, you need to disable it by setting `self.edgesForExtendedLayout`.
For example:
```
- (id)init
{... |
627,423 | Very new to the world of electronics so forgive any ignorance here.
I'm trying to control a hydraulic actuator that takes a 0-12V input signal. I'm using an ESP32 to give me a 3.3V PWM signal.
Originally, I was planning to use a D4184 MOSFET control module to convert the 3.3V signal into a 12V signal, but the load ca... | 2022/07/14 | [
"https://electronics.stackexchange.com/questions/627423",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/317800/"
] | Maybe you could use a darlington style setup with two mosfets. The second mosfet could handle the high current and the first one can handle the the second with a minimal output of the esp32. | This likely needs a Motor Electronic speed controller (ESC) that handles 12V with low logic levels and more than 30A so you are not operating at maximum temperature.
These should be class E FET full-bridge amplifiers working as an ESC. You need a full bridge to change directions with a 2 wire DC motor.
The user inter... |
31,111,572 | How to find user details by using his/her email ID or mobile number from Facebook? I want to get user details on my website using my app id access.
Please help me out this. | 2015/06/29 | [
"https://Stackoverflow.com/questions/31111572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4060951/"
] | Try this. You need his facebook ID or his facebook name.
```
var fields = [
'id',
'name',
'first_name',
'middle_name',
'last_name',
'gender']
FB.api('/{insertIDhere}', {fields: fields}, function(details) {
// output the response
});
```
Or take this code from the FB Api Docume... | You can't. Searching by email or phone is not possible.
<https://developers.facebook.com/docs/graph-api/using-graph-api/v2.3#search> |
46,416,729 | Im trying to search through text files line by line and if a line contains /##/ format, I want to print the line. I know the line I want will have this format because I'm trying to extract the date. Is there syntax for something like this? For example..
```
if('/%d%d/' in line):
print (line)
```
Is there somet... | 2017/09/26 | [
"https://Stackoverflow.com/questions/46416729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8261326/"
] | A `for` loop has the following syntax:
```
for ( expression ; expression ; expression )
```
There are 3 expressions separated by semicolons. You have 6 expressions separated by semicolons. That's invalid syntax.
You should write it as follows:
```
for(i=0,j=10; j>=0 && i<10; i++,j--)
```
For the first expression... | You can use comma operator to separate statements in initialization and limit condition for both variables. See below.
```
int i,j;
for(i=0,j=10;j>=0 && i<10;i++,j--){
printf("%d %d",i,j);
}
```
To see Comma operator in the specs at following section
>
> 6.5.17 Comma operator
> **Syntax**
> expression:
>
>
> ... |
46,416,729 | Im trying to search through text files line by line and if a line contains /##/ format, I want to print the line. I know the line I want will have this format because I'm trying to extract the date. Is there syntax for something like this? For example..
```
if('/%d%d/' in line):
print (line)
```
Is there somet... | 2017/09/26 | [
"https://Stackoverflow.com/questions/46416729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8261326/"
] | A `for` loop has the following syntax:
```
for ( expression ; expression ; expression )
```
There are 3 expressions separated by semicolons. You have 6 expressions separated by semicolons. That's invalid syntax.
You should write it as follows:
```
for(i=0,j=10; j>=0 && i<10; i++,j--)
```
For the first expression... | Change `for(i=0;j=10;j>=0;i<10;i++;j--){}`to `for(i=0, j=10; j>=0 && i<10; i++,j--){}` |
46,416,729 | Im trying to search through text files line by line and if a line contains /##/ format, I want to print the line. I know the line I want will have this format because I'm trying to extract the date. Is there syntax for something like this? For example..
```
if('/%d%d/' in line):
print (line)
```
Is there somet... | 2017/09/26 | [
"https://Stackoverflow.com/questions/46416729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8261326/"
] | Change `for(i=0;j=10;j>=0;i<10;i++;j--){}`to `for(i=0, j=10; j>=0 && i<10; i++,j--){}` | You can use comma operator to separate statements in initialization and limit condition for both variables. See below.
```
int i,j;
for(i=0,j=10;j>=0 && i<10;i++,j--){
printf("%d %d",i,j);
}
```
To see Comma operator in the specs at following section
>
> 6.5.17 Comma operator
> **Syntax**
> expression:
>
>
> ... |
64,954 | Currently I am working on an animation that requires a scroll opening up. I added a Curve Modifier with a spiral curve to both parts of the scroll mesh, then I added another Curve Modifier with another curve to the mesh.
The result is this when it's only a bit open (good):
[](https://i.stack.imgur.com/B9jWk.gif... |
27,011,471 | Let's have a collection of objects (say string is type of collection). I want each element of collection to have a reference count. So, on *Add-Usage* it should increment count for this given element.
```
coll.AddUsage("SomeElement"); // Type doesn't matter - but should increase count
```
On, *Release-Usage*, it sho... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27011471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264325/"
] | You could implement something similar to `shared_ptr` class but extending it to hold collection of objects.
Like you could design a class with `map/multimap` as its data member. Key would be your object and value be your reference count.As far as interface is concerned just expose two methods:-
```
AddUsage(Object);
... | You can use static member(integer) variable in the structure or class. Increment or decrement whereever you want. Remove the element if the value is zero. |
27,011,471 | Let's have a collection of objects (say string is type of collection). I want each element of collection to have a reference count. So, on *Add-Usage* it should increment count for this given element.
```
coll.AddUsage("SomeElement"); // Type doesn't matter - but should increase count
```
On, *Release-Usage*, it sho... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27011471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264325/"
] | Assuming you ask for a data structure to implement your reference-counting collection...
Use a `map<K,V>` with K as the type of collection elements (in your example string) and V a type to keep track of meta-information about the element (e.g. reference count). The simplest case is when V is `int`.
Then, `AddUsage` i... | You can use static member(integer) variable in the structure or class. Increment or decrement whereever you want. Remove the element if the value is zero. |
27,011,471 | Let's have a collection of objects (say string is type of collection). I want each element of collection to have a reference count. So, on *Add-Usage* it should increment count for this given element.
```
coll.AddUsage("SomeElement"); // Type doesn't matter - but should increase count
```
On, *Release-Usage*, it sho... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27011471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264325/"
] | Assuming you ask for a data structure to implement your reference-counting collection...
Use a `map<K,V>` with K as the type of collection elements (in your example string) and V a type to keep track of meta-information about the element (e.g. reference count). The simplest case is when V is `int`.
Then, `AddUsage` i... | You could implement something similar to `shared_ptr` class but extending it to hold collection of objects.
Like you could design a class with `map/multimap` as its data member. Key would be your object and value be your reference count.As far as interface is concerned just expose two methods:-
```
AddUsage(Object);
... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | ```
b1->f(static_cast<A1*>(a2));
```
This should force the compiler to use the overload method with parameter of type A1. | It's called name hiding. Every f you declare in one derived class shadows every possible f in any of its base classes.
Use a cast to the base class to get the desired behaviour.
When you override a virtual function, you don't override overloaded functions with the same name. They are different functions (and have dif... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | The choice of which version of `f` to call is made by looking at the *compile-time* type of the parameter. The run-time type isn't considered for this name resolution. Since `b1` is of type `Bbase*`, all of `Bbase`'s members are considered; the one that takes an `A2*` is the best match, so that's the one that gets call... | ```
b1->f(static_cast<A1*>(a2));
```
This should force the compiler to use the overload method with parameter of type A1. |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | *"...chooses to resolve the function call on the last line by upcasting the this pointer of the object to the base class..."*. What are you talking about? In all of your calls, the object pointer type is `Bbase *` and the functions the calls resolve to belong to either `Bbase` or its descendants. The compiler never doe... | ```
b1->f(static_cast<A1*>(a2));
```
This should force the compiler to use the overload method with parameter of type A1. |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | ```
b1->f(static_cast<A1*>(a2));
```
This should force the compiler to use the overload method with parameter of type A1. | Your overloads in Bbase for Abase and A2 are hidden in B1.
Maybe you can work around that problem like this:
```
class Bbase{
public:
inline void f(Abase* a) { f_(a); }
inline void f(A1* a) { f_(a); }
inline void f(A2* a) { f_(a); }
protected:
virtual void f_(Abase* a);
virtual void f_(A1* a)... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | The choice of which version of `f` to call is made by looking at the *compile-time* type of the parameter. The run-time type isn't considered for this name resolution. Since `b1` is of type `Bbase*`, all of `Bbase`'s members are considered; the one that takes an `A2*` is the best match, so that's the one that gets call... | It's called name hiding. Every f you declare in one derived class shadows every possible f in any of its base classes.
Use a cast to the base class to get the desired behaviour.
When you override a virtual function, you don't override overloaded functions with the same name. They are different functions (and have dif... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | *"...chooses to resolve the function call on the last line by upcasting the this pointer of the object to the base class..."*. What are you talking about? In all of your calls, the object pointer type is `Bbase *` and the functions the calls resolve to belong to either `Bbase` or its descendants. The compiler never doe... | It's called name hiding. Every f you declare in one derived class shadows every possible f in any of its base classes.
Use a cast to the base class to get the desired behaviour.
When you override a virtual function, you don't override overloaded functions with the same name. They are different functions (and have dif... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | The choice of which version of `f` to call is made by looking at the *compile-time* type of the parameter. The run-time type isn't considered for this name resolution. Since `b1` is of type `Bbase*`, all of `Bbase`'s members are considered; the one that takes an `A2*` is the best match, so that's the one that gets call... | *"...chooses to resolve the function call on the last line by upcasting the this pointer of the object to the base class..."*. What are you talking about? In all of your calls, the object pointer type is `Bbase *` and the functions the calls resolve to belong to either `Bbase` or its descendants. The compiler never doe... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | The choice of which version of `f` to call is made by looking at the *compile-time* type of the parameter. The run-time type isn't considered for this name resolution. Since `b1` is of type `Bbase*`, all of `Bbase`'s members are considered; the one that takes an `A2*` is the best match, so that's the one that gets call... | Your overloads in Bbase for Abase and A2 are hidden in B1.
Maybe you can work around that problem like this:
```
class Bbase{
public:
inline void f(Abase* a) { f_(a); }
inline void f(A1* a) { f_(a); }
inline void f(A2* a) { f_(a); }
protected:
virtual void f_(Abase* a);
virtual void f_(A1* a)... |
3,103,153 | Please consider the following code:
```
class Abase{};
class A1:public Abase{};
class A2:public A1{};
//etc
class Bbase{
public:
virtual void f(Abase* a);
virtual void f(A1* a);
virtual void f(A2* a);
};
class B1:public Bbase{
public:
void f(A1* a);
};
class B2:public Bbase{ ... | 2010/06/23 | [
"https://Stackoverflow.com/questions/3103153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374328/"
] | *"...chooses to resolve the function call on the last line by upcasting the this pointer of the object to the base class..."*. What are you talking about? In all of your calls, the object pointer type is `Bbase *` and the functions the calls resolve to belong to either `Bbase` or its descendants. The compiler never doe... | Your overloads in Bbase for Abase and A2 are hidden in B1.
Maybe you can work around that problem like this:
```
class Bbase{
public:
inline void f(Abase* a) { f_(a); }
inline void f(A1* a) { f_(a); }
inline void f(A2* a) { f_(a); }
protected:
virtual void f_(Abase* a);
virtual void f_(A1* a)... |
21,010,717 | Can someone tell me why my div `brdheader` isn't sitting at the top (the most top inside of, that is) of `punwrap`?
I'm using fluxbb, and the devtools in chrome aren't saying anything. There's no margin, or padding, so I have no idea what the problem could be.
This is the forum. Since I'm using FluxBB I can't exactly... | 2014/01/09 | [
"https://Stackoverflow.com/questions/21010717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/582295/"
] | you have `margin: 30px 0px -10px 5px` on your `.pun h1` that's what's doing it. Adjust that to what you want | Change your .pun h1 css line in your BSTangram.css on line 127 to the one below should fix it.
```
.pun h1 {
margin: 0px 0px -10px 5px;
margin-left: 5%;
padding: 0px;
}
```
As long as your going for this output, <http://cl.ly/TGxf>
If that's the case then there is your fix if not sorry I misunderstood. |
27,723,952 | In [Bootstrap-Select](https://github.com/silviomoreto/bootstrap-select), how can I prevent the first selected item from being shown in the title. Alternatively, how can I hide an empty first item from the list of drop down options
In HTML, the `<select>` element will automatically select the first `<option>` element b... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27723952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366033/"
] | Method 1 - Update Bootstrap-Select Version >1.7
-----------------------------------------------
Per the release notes in [Version 1.7.0](https://github.com/silviomoreto/bootstrap-select/releases/tag/v1.7.0):
>
> [#888](https://github.com/silviomoreto/bootstrap-select/issues/888), [#738](https://github.com/silviomore... | A JS version:
```
$('.selectpicker').selectpicker().each(function () {
if (this.nodeName == "DIV") {
$(this).find('ul.dropdown-menu li:first').css('display', 'none');
}
});
``` |
27,723,952 | In [Bootstrap-Select](https://github.com/silviomoreto/bootstrap-select), how can I prevent the first selected item from being shown in the title. Alternatively, how can I hide an empty first item from the list of drop down options
In HTML, the `<select>` element will automatically select the first `<option>` element b... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27723952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366033/"
] | Method 1 - Update Bootstrap-Select Version >1.7
-----------------------------------------------
Per the release notes in [Version 1.7.0](https://github.com/silviomoreto/bootstrap-select/releases/tag/v1.7.0):
>
> [#888](https://github.com/silviomoreto/bootstrap-select/issues/888), [#738](https://github.com/silviomore... | Just remove the attribute title from the select element and make sure the first option is empty:
```
<div class="form-group">
<select class="selectpicker form-control">
<option value=""></option>
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
</div>
```
(If yo... |
27,723,952 | In [Bootstrap-Select](https://github.com/silviomoreto/bootstrap-select), how can I prevent the first selected item from being shown in the title. Alternatively, how can I hide an empty first item from the list of drop down options
In HTML, the `<select>` element will automatically select the first `<option>` element b... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27723952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366033/"
] | Method 1 - Update Bootstrap-Select Version >1.7
-----------------------------------------------
Per the release notes in [Version 1.7.0](https://github.com/silviomoreto/bootstrap-select/releases/tag/v1.7.0):
>
> [#888](https://github.com/silviomoreto/bootstrap-select/issues/888), [#738](https://github.com/silviomore... | Another option is to set it to be a **multiple select** dropdown, but limit the number of **selected items to 1**.
```html
<select class="selectpicker" multiple data-max-options="1" title="Pick One">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
```
### Demo in Stack Snipp... |
27,723,952 | In [Bootstrap-Select](https://github.com/silviomoreto/bootstrap-select), how can I prevent the first selected item from being shown in the title. Alternatively, how can I hide an empty first item from the list of drop down options
In HTML, the `<select>` element will automatically select the first `<option>` element b... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27723952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366033/"
] | Another option is to set it to be a **multiple select** dropdown, but limit the number of **selected items to 1**.
```html
<select class="selectpicker" multiple data-max-options="1" title="Pick One">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
```
### Demo in Stack Snipp... | A JS version:
```
$('.selectpicker').selectpicker().each(function () {
if (this.nodeName == "DIV") {
$(this).find('ul.dropdown-menu li:first').css('display', 'none');
}
});
``` |
27,723,952 | In [Bootstrap-Select](https://github.com/silviomoreto/bootstrap-select), how can I prevent the first selected item from being shown in the title. Alternatively, how can I hide an empty first item from the list of drop down options
In HTML, the `<select>` element will automatically select the first `<option>` element b... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27723952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366033/"
] | Another option is to set it to be a **multiple select** dropdown, but limit the number of **selected items to 1**.
```html
<select class="selectpicker" multiple data-max-options="1" title="Pick One">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
```
### Demo in Stack Snipp... | Just remove the attribute title from the select element and make sure the first option is empty:
```
<div class="form-group">
<select class="selectpicker form-control">
<option value=""></option>
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
</div>
```
(If yo... |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | Straight from the [Swift Language guide](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html#//apple_ref/doc/uid/TP40014097-CH20-ID48):
```
class Person {
let name: String
init(name: String) { self.name = name }
var apartment: Ap... | Properties are strong by default, but if you want a weak property you can:
```
weak var tenant: Person?
```
Source: <https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html> |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | Properties are strong by default, but if you want a weak property you can:
```
weak var tenant: Person?
```
Source: <https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html> | Details
-------
* Xcode 11.3.1, Swift 5.1
More info about ARC usage
-------------------------
* [Kaan Dedeoglu](https://stackoverflow.com/a/24016705/4488252) answer
* [ARC and Memory Management in Swift](https://www.raywenderlich.com/134411/arc-memory-management-swift)
* ["WEAK, STRONG, UNOWNED, OH MY!" - A GUIDE TO... |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | A var is strong by default. You can add the weak keyword before a var to make it weak. | This is more of an important comment, but I couldn't fit it in.
If you do
```
weak let name : SomeClass
```
It will give the following error:
>
> 'weak' must be a mutable variable, because it may change at runtime
>
>
>
You must do
```
weak var name : SomeClass
```
>
> 'weak' variable should have optional... |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | A var is strong by default. You can add the weak keyword before a var to make it weak. | Just wanted you to know that a var is strong by default but by adding "weak" in front of it you make it weak. In case you missed it |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | A var is strong by default. You can add the weak keyword before a var to make it weak. | Details
-------
* Xcode 11.3.1, Swift 5.1
More info about ARC usage
-------------------------
* [Kaan Dedeoglu](https://stackoverflow.com/a/24016705/4488252) answer
* [ARC and Memory Management in Swift](https://www.raywenderlich.com/134411/arc-memory-management-swift)
* ["WEAK, STRONG, UNOWNED, OH MY!" - A GUIDE TO... |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | Straight from the [Swift Language guide](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html#//apple_ref/doc/uid/TP40014097-CH20-ID48):
```
class Person {
let name: String
init(name: String) { self.name = name }
var apartment: Ap... | Details
-------
* Xcode 11.3.1, Swift 5.1
More info about ARC usage
-------------------------
* [Kaan Dedeoglu](https://stackoverflow.com/a/24016705/4488252) answer
* [ARC and Memory Management in Swift](https://www.raywenderlich.com/134411/arc-memory-management-swift)
* ["WEAK, STRONG, UNOWNED, OH MY!" - A GUIDE TO... |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | Straight from the [Swift Language guide](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html#//apple_ref/doc/uid/TP40014097-CH20-ID48):
```
class Person {
let name: String
init(name: String) { self.name = name }
var apartment: Ap... | Just wanted you to know that a var is strong by default but by adding "weak" in front of it you make it weak. In case you missed it |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | This is more of an important comment, but I couldn't fit it in.
If you do
```
weak let name : SomeClass
```
It will give the following error:
>
> 'weak' must be a mutable variable, because it may change at runtime
>
>
>
You must do
```
weak var name : SomeClass
```
>
> 'weak' variable should have optional... | Just wanted you to know that a var is strong by default but by adding "weak" in front of it you make it weak. In case you missed it |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | Properties are strong by default, but if you want a weak property you can:
```
weak var tenant: Person?
```
Source: <https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html> | Just wanted you to know that a var is strong by default but by adding "weak" in front of it you make it weak. In case you missed it |
24,016,527 | In Objective C you can define a property as having a strong or weak reference like so:
```
@property(strong)...
@property(weak)...
```
How is this done in swift? | 2014/06/03 | [
"https://Stackoverflow.com/questions/24016527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189724/"
] | This is more of an important comment, but I couldn't fit it in.
If you do
```
weak let name : SomeClass
```
It will give the following error:
>
> 'weak' must be a mutable variable, because it may change at runtime
>
>
>
You must do
```
weak var name : SomeClass
```
>
> 'weak' variable should have optional... | Details
-------
* Xcode 11.3.1, Swift 5.1
More info about ARC usage
-------------------------
* [Kaan Dedeoglu](https://stackoverflow.com/a/24016705/4488252) answer
* [ARC and Memory Management in Swift](https://www.raywenderlich.com/134411/arc-memory-management-swift)
* ["WEAK, STRONG, UNOWNED, OH MY!" - A GUIDE TO... |
152,267 | Running CentOS 6.5, qemu-kvm.
I have a script which builds a list of running VM's. I want to pull information from those .xml files of only the VM's that are running.
`cat /dev/null > /<path>/runlist
virsh list --all|grep running|awk -F" " '{print $2}' > /<path>/runlist.tmp`
Now that I have the list of running vm's... | 2014/08/26 | [
"https://unix.stackexchange.com/questions/152267",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/82086/"
] | The direct answer to your question is
```
grep -f /path/to/runlist /path/to/file.xml
```
But I think this is an [XY question](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem): without thinking about **how** to solve the question, what are you trying to do?
---
Given that `runlist` is a file ... | It seems that you only want to get information from list of files in runlist. You can:
```
grep <info> -- $(cat runlist)
``` |
26,129,769 | I have very simple Jquery code and it never shows the second alert. Is anybody know what is wrong?
```
<script type="text/javascript">
$(document).ready(function () {
alert("1");
$(".images_clicable input").change(function(){
alert("2");
... | 2014/09/30 | [
"https://Stackoverflow.com/questions/26129769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1315599/"
] | Thanks for asking the question. I was searching for this for hours.
Turns out the solution for me was making sure that the opening angular module line in the ***app.js*** file included the **ionic.service.core** module dependency.
Then everything worked.
*NOTE: (i wish it had thrown an error instead of allowing th... | The way I was able to solve this was to switch over to using [ngCordova's Push](http://ngcordova.com/docs/#Push) script with the PushPlugin. |
3,698,832 | **Synopsis**
In one of the exercises in Enderton's *Elements of Set Theory*, we are introduced to the concept of the closure of a set to another set under a function $f$ with two constructions.
Let $f$ be a function from $B$ into $B$ and assume that $A \subseteq B$. We have two possible methods for constructing the ... | 2020/05/30 | [
"https://math.stackexchange.com/questions/3698832",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/773147/"
] | 3-forms in $\mathbb{R}^3$ form a one-dimensional space. Any three-form has the structure $\rho(x)dx\_1\wedge dx\_2\wedge dx\_3$. | Integrating the volume form means that you are integrating the form of top degree, that is the degree of the form coincides with the dimension of the space.
I'd guess that you are working in the 3-space, so that $dx\_1, dx\_2, dx\_3$ form the basis of one forms, and therefore any three form is written as $$\rho \cdot ... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | for those who still face the same problem which i faced before when i have a `ViewPager` with 7 fragments. the default for these fragments to load the English content from `API` service but the problem here that i want to change the language from settings activity and after finish
settings activity i want `ViewPager` ... | I had a similar problem but don't want to trust on the existing solutions (hard coded tag names etc.) and I couldn't make M-WaJeEh's solution work for me. Here is my solution:
I keep references to the fragments created in getItem in an array. This works fine as long as the activity is not destroyed due to configuratio... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | for those who still face the same problem which i faced before when i have a `ViewPager` with 7 fragments. the default for these fragments to load the English content from `API` service but the problem here that i want to change the language from settings activity and after finish
settings activity i want `ViewPager` ... | For some reason none of the answers worked for me so I had to override the restoreState method without calling super in my fragmentStatePagerAdapter. Code:
```
private class MyAdapter extends FragmentStatePagerAdapter {
// [Rest of implementation]
@Override
public void restoreState(Parcelable state, Clas... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | I had a similar problem but don't want to trust on the existing solutions (hard coded tag names etc.) and I couldn't make M-WaJeEh's solution work for me. Here is my solution:
I keep references to the fragments created in getItem in an array. This works fine as long as the activity is not destroyed due to configuratio... | I've gone through all the answers above and a number of others posts but still couldn't find something that worked for me (with different fragment types along with dynamically adding and removing tabs). FWIW following approach is what worked for me (in case anyone else has same issues).
```
public class MyFragmentSta... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | When using FragmentPagerAdapter or FragmentStatePagerAdapter, it is best to deal solely with `getItem()` and not touch `instantiateItem()` at all. The `instantiateItem()`-`destroyItem()`-`isViewFromObject()` interface on PagerAdapter is a lower-level interface that FragmentPagerAdapter uses to implement the much simple... | I had a similar problem but don't want to trust on the existing solutions (hard coded tag names etc.) and I couldn't make M-WaJeEh's solution work for me. Here is my solution:
I keep references to the fragments created in getItem in an array. This works fine as long as the activity is not destroyed due to configuratio... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | Try `destroyDrawingCache()` on ViewPager after `notifyDataSetChanged()` in your code. | For some reason none of the answers worked for me so I had to override the restoreState method without calling super in my fragmentStatePagerAdapter. Code:
```
private class MyAdapter extends FragmentStatePagerAdapter {
// [Rest of implementation]
@Override
public void restoreState(Parcelable state, Clas... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | I have encountered this problem and finally solved it today, so I write down what I have learned and I hope it is helpful for someone who is new to Android's `ViewPager` and update as I do. I'm using `FragmentStatePagerAdapter` in API level 17 and currently have just 2 fragments. I think there must be something not cor... | If you want to use FragmentStatePagerAdapter, please take a look at <https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=37990>.
There are issues with FragmentStatePagerAdapter that may or may not trouble your use case.
Also, ... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | I had a similar problem but don't want to trust on the existing solutions (hard coded tag names etc.) and I couldn't make M-WaJeEh's solution work for me. Here is my solution:
I keep references to the fragments created in getItem in an array. This works fine as long as the activity is not destroyed due to configuratio... | You need change instantiateItem's mFragments element getItemPosition.
```
if (mFragments.size() > position) {
Fragment f = mFragments.get(position);
if (f != null) {
int newPosition = getItemPosition(f);
if (newPosition == POSITION_UNCHANGED) {
return f;
... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | For some reason none of the answers worked for me so I had to override the restoreState method without calling super in my fragmentStatePagerAdapter. Code:
```
private class MyAdapter extends FragmentStatePagerAdapter {
// [Rest of implementation]
@Override
public void restoreState(Parcelable state, Clas... | This solution won't work for everyone, but in my case, every Fragment in my ViewPager is a different class, and only one of them ever exist at a time.
With this constraint, this solution is safe and should be safe to use in production.
```
private void updateFragment(Item item) {
List<Fragment> fragments = getS... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | I have encountered this problem and finally solved it today, so I write down what I have learned and I hope it is helpful for someone who is new to Android's `ViewPager` and update as I do. I'm using `FragmentStatePagerAdapter` in API level 17 and currently have just 2 fragments. I think there must be something not cor... | Here is my implementation that incorporates the info from @Bill Phillips
One gets fragment caching most of the time, except when the data has changed. Simple, and seems to work fine.
MyFragmentStatePagerAdapter.java
```
private boolean mIsUpdating = false;
public void setIsUpdating(boolean mIsUpdating) {
this... |
10,849,552 | I can't update the content in ViewPager.
What is the correct usage of methods instantiateItem() and getItem() in FragmentPagerAdapter class?
I was using only getItem() to instantiate and return my fragments:
```
@Override
public Fragment getItem(int position) {
return new MyFragment(context, paramters);
}
```
... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10849552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930450/"
] | I use [EventBus](https://github.com/greenrobot/EventBus) library to update `Fragment` content in `ViewPager`. The logic is simple, just like [document of EventBus how to do](https://github.com/greenrobot/EventBus/blob/master/HOWTO.md). It is no need to control `FragmentPagerAdapter` instance. The code is here:
1: Defi... | This solution won't work for everyone, but in my case, every Fragment in my ViewPager is a different class, and only one of them ever exist at a time.
With this constraint, this solution is safe and should be safe to use in production.
```
private void updateFragment(Item item) {
List<Fragment> fragments = getS... |
24,671,158 | I want an alternative way to write the following query
```
SELECT COUNT(DISTINCT col1) FROM table.
```
I dont want to use `distinct`. Is there an alternative way? | 2014/07/10 | [
"https://Stackoverflow.com/questions/24671158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1071031/"
] | Try `GROUP BY` as a subquery and `COUNT()` from outside query. It would achieve same result.
```
SELECT COUNT(*)
FROM
(
SELECT Col1
FROM Table
GROUP BY Col1
) tbl
``` | ```
Select count(col1) from table GROUP BY col1
``` |
24,671,158 | I want an alternative way to write the following query
```
SELECT COUNT(DISTINCT col1) FROM table.
```
I dont want to use `distinct`. Is there an alternative way? | 2014/07/10 | [
"https://Stackoverflow.com/questions/24671158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1071031/"
] | Try `GROUP BY` as a subquery and `COUNT()` from outside query. It would achieve same result.
```
SELECT COUNT(*)
FROM
(
SELECT Col1
FROM Table
GROUP BY Col1
) tbl
``` | Try this
```
SELECT COUNT(Col1)
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY Col1 ORDER BY Col1) As RNO, Col1
FROM Table_Name)
WHERE RNO = 1
``` |
27,844,825 | I've tried the following code, which im using successfully with product thumbnails but for categories haven't found a way to do it.
```
add_action( 'init', 'mw_replace_woocommerce_placeholders' );
function mw_replace_woocommerce_placeholders() {
add_filter('woocommerce_placeholder_img', 'custom_woocommerce_place... | 2015/01/08 | [
"https://Stackoverflow.com/questions/27844825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1848423/"
] | This should work
```
add_action( 'init', 'custom_placeholder' );
function custom_placeholder() {
if ( is_product_category() ){
add_filter('woocommerce_placeholder_img_src','custom_placeholder_img');
function custom_placeholder_img($src) {
$upload_dir = wp_upload_dir();
$uploads = untrailingslashit( $uploa... | The line:
```
if ( is_product_category() ){
```
in functions.php makes the theme reliant on the plugin, so if you deactivate woocommerce for testing, it breaks the site. At least that's what happened to me. |
140,783 | >
> **Possible Duplicate:**
>
> [Should users be penalized for answering bad questions?](https://meta.stackexchange.com/questions/98197/should-users-be-penalized-for-answering-bad-questions)
>
>
>
When I come across an SO question which is too broad or shows no research effort (the type that one google search ... | 2012/07/23 | [
"https://meta.stackexchange.com/questions/140783",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/180564/"
] | If you don't want to reward the user for answering a low-quality question it's best to leave the answer alone, not downvote it, especially if you know that it is a good, correct answer. However, if a question is so unclear that you can't even judge if the answer is correct, it's also best to leave it alone.
Personally... | A good answer is a good answer regardless of where it is posted. If someone wants to spend their time posting answers to bad questions, why penalize them for it? In fact, there is [the gold Reversal badge](https://stackoverflow.com/badges/95/reversal) that rewards people who post great answers to bad questions.
If it ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.