qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
1,606,940 |
>
> Find all solutions between $-2\pi$ and $2\pi$ of the following equation:
> $$\cos \theta = −\frac{1}{\sqrt{2}}$$
> Give all answers in radians.
>
>
>
Now I have drawn the graph between $−2\pi$ and $2\pi$.
Am I correct thinking that $\cos \theta = 2\pi - \theta$?
I am completely at a loss of where to draw the values on the graph to work this out.
|
2016/01/10
|
[
"https://math.stackexchange.com/questions/1606940",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/303221/"
] |
Well, it helps to notice that the function doesn't exist for $x\le-1$.
Also, you may also notice that it doesn't exist for $\sin(x)=-1$, which results in $x\ne(2n-1)\pi, n=0,\pm1,\pm2,\pm3,\dots$
The best way I see tackling this is with L'Hospital's rule:
$$L=\lim\_{x\to 0}\frac{\sin(\ln(x+1))-\ln(\sin(x)+1)}{\sin^4(\frac{x}{2})}=\lim\_{x\to0}\frac{\frac{\cos(\ln(x+1))}{x+1}-\frac{\cos(x)}{\sin(x)+1}}{\cos(\frac{x}2)\sin^3(\frac{x}2)}$$
$$\lim\_{x\to0}\frac{\frac{\sin(\ln(x+1))+\cos(\ln(x+1))}{(x+1)^2}+\frac{\sin^2(x)+\sin(x)-\cos^2(x)}{(\sin(x)+1)^2}}{-\frac38\cos(\frac{x}2)\sin(\frac{x}2)\sin^2(\frac{x}2)}$$
It appears obvious that this is only going to get messier... and we pretty much have to repeat this until the limit is evaluable.
At this point, I'd just say your best bet is to look at this graphically or numerically, which produces:
$$L\approx1.333$$
|
Hint:
$\sin^4(\frac{x}{2})$~$(\frac{x}{2})^4$
$\sin(\ln(x+1)) = \ln(x+1)-\frac{\ln^3(x+1)}{6}+o(x^4)$
|
1,606,940 |
>
> Find all solutions between $-2\pi$ and $2\pi$ of the following equation:
> $$\cos \theta = −\frac{1}{\sqrt{2}}$$
> Give all answers in radians.
>
>
>
Now I have drawn the graph between $−2\pi$ and $2\pi$.
Am I correct thinking that $\cos \theta = 2\pi - \theta$?
I am completely at a loss of where to draw the values on the graph to work this out.
|
2016/01/10
|
[
"https://math.stackexchange.com/questions/1606940",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/303221/"
] |
It's easiest to use Taylor expansions about $x = 0$. First the denominator to leading order, so we can tell how many terms are needed:
$$
\sin\left(\frac{x}{2}\right)^4 = \frac{x^4}{16} + O(x^6)
$$
So we need expansions to this order also for the numerator:
$$
\sin(\ln(x+1)) = x-\frac{x^2}{2}+\frac{x^3}{6}-\frac{x^5}{12}+O\left(x^6\right)
$$
and
$$
\ln(sin(x) + 1) = x-\frac{x^2}{2}+\frac{x^3}{6}-\frac{x^4}{12}+\frac{x^5}{24}+O\left(x^6\right)
$$
You see that the two terms in the numerator agree through order $x^3$. Hence these terms all cancel. Then the leading term in the numerator is $\frac{x^4}{12}$. Therefore, the limit equals $\frac{1/12}{1/16} = \frac{4}{3}$.
|
Well, it helps to notice that the function doesn't exist for $x\le-1$.
Also, you may also notice that it doesn't exist for $\sin(x)=-1$, which results in $x\ne(2n-1)\pi, n=0,\pm1,\pm2,\pm3,\dots$
The best way I see tackling this is with L'Hospital's rule:
$$L=\lim\_{x\to 0}\frac{\sin(\ln(x+1))-\ln(\sin(x)+1)}{\sin^4(\frac{x}{2})}=\lim\_{x\to0}\frac{\frac{\cos(\ln(x+1))}{x+1}-\frac{\cos(x)}{\sin(x)+1}}{\cos(\frac{x}2)\sin^3(\frac{x}2)}$$
$$\lim\_{x\to0}\frac{\frac{\sin(\ln(x+1))+\cos(\ln(x+1))}{(x+1)^2}+\frac{\sin^2(x)+\sin(x)-\cos^2(x)}{(\sin(x)+1)^2}}{-\frac38\cos(\frac{x}2)\sin(\frac{x}2)\sin^2(\frac{x}2)}$$
It appears obvious that this is only going to get messier... and we pretty much have to repeat this until the limit is evaluable.
At this point, I'd just say your best bet is to look at this graphically or numerically, which produces:
$$L\approx1.333$$
|
1,606,940 |
>
> Find all solutions between $-2\pi$ and $2\pi$ of the following equation:
> $$\cos \theta = −\frac{1}{\sqrt{2}}$$
> Give all answers in radians.
>
>
>
Now I have drawn the graph between $−2\pi$ and $2\pi$.
Am I correct thinking that $\cos \theta = 2\pi - \theta$?
I am completely at a loss of where to draw the values on the graph to work this out.
|
2016/01/10
|
[
"https://math.stackexchange.com/questions/1606940",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/303221/"
] |
$$\begin{align}\sin{\log{(1+x)}} &= \sin{\left (x - \frac12 x^2 + \frac13 x^3 - \cdots \right )} \\ &= \left (x - \frac12 x^2 + \frac13 x^3 - \cdots \right ) - \frac16 \left (x - \frac12 x^2 + \frac13 x^3 - \cdots \right )^3 + \cdots \\ &= x - \frac12 x^2 + \frac16 x^3 + \left ( \frac32 \cdot \frac16 - \frac14 \right ) \frac14 x^4 \cdots\end{align}$$
$$\begin{align}\log{(1+\sin{x})} &= \log{\left (1 + x - \frac16 x^3 + \cdots \right )} \\ &= \left ( x - \frac16 x^3 + \cdots \right ) - \frac12 \left (x - \frac16 x^3 + \cdots \right )^2 + \cdots \\ &= x - \frac12 x^2 + \frac16 x^3 + \left (\frac16-\frac14 \right ) x^4 \cdots\end{align}$$
Thus the limit is equal to
$$\frac{1/12}{1/2^4} = \frac43 $$
|
Hint:
$\sin^4(\frac{x}{2})$~$(\frac{x}{2})^4$
$\sin(\ln(x+1)) = \ln(x+1)-\frac{\ln^3(x+1)}{6}+o(x^4)$
|
1,606,940 |
>
> Find all solutions between $-2\pi$ and $2\pi$ of the following equation:
> $$\cos \theta = −\frac{1}{\sqrt{2}}$$
> Give all answers in radians.
>
>
>
Now I have drawn the graph between $−2\pi$ and $2\pi$.
Am I correct thinking that $\cos \theta = 2\pi - \theta$?
I am completely at a loss of where to draw the values on the graph to work this out.
|
2016/01/10
|
[
"https://math.stackexchange.com/questions/1606940",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/303221/"
] |
It's easiest to use Taylor expansions about $x = 0$. First the denominator to leading order, so we can tell how many terms are needed:
$$
\sin\left(\frac{x}{2}\right)^4 = \frac{x^4}{16} + O(x^6)
$$
So we need expansions to this order also for the numerator:
$$
\sin(\ln(x+1)) = x-\frac{x^2}{2}+\frac{x^3}{6}-\frac{x^5}{12}+O\left(x^6\right)
$$
and
$$
\ln(sin(x) + 1) = x-\frac{x^2}{2}+\frac{x^3}{6}-\frac{x^4}{12}+\frac{x^5}{24}+O\left(x^6\right)
$$
You see that the two terms in the numerator agree through order $x^3$. Hence these terms all cancel. Then the leading term in the numerator is $\frac{x^4}{12}$. Therefore, the limit equals $\frac{1/12}{1/16} = \frac{4}{3}$.
|
Hint:
$\sin^4(\frac{x}{2})$~$(\frac{x}{2})^4$
$\sin(\ln(x+1)) = \ln(x+1)-\frac{\ln^3(x+1)}{6}+o(x^4)$
|
1,606,940 |
>
> Find all solutions between $-2\pi$ and $2\pi$ of the following equation:
> $$\cos \theta = −\frac{1}{\sqrt{2}}$$
> Give all answers in radians.
>
>
>
Now I have drawn the graph between $−2\pi$ and $2\pi$.
Am I correct thinking that $\cos \theta = 2\pi - \theta$?
I am completely at a loss of where to draw the values on the graph to work this out.
|
2016/01/10
|
[
"https://math.stackexchange.com/questions/1606940",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/303221/"
] |
It's easiest to use Taylor expansions about $x = 0$. First the denominator to leading order, so we can tell how many terms are needed:
$$
\sin\left(\frac{x}{2}\right)^4 = \frac{x^4}{16} + O(x^6)
$$
So we need expansions to this order also for the numerator:
$$
\sin(\ln(x+1)) = x-\frac{x^2}{2}+\frac{x^3}{6}-\frac{x^5}{12}+O\left(x^6\right)
$$
and
$$
\ln(sin(x) + 1) = x-\frac{x^2}{2}+\frac{x^3}{6}-\frac{x^4}{12}+\frac{x^5}{24}+O\left(x^6\right)
$$
You see that the two terms in the numerator agree through order $x^3$. Hence these terms all cancel. Then the leading term in the numerator is $\frac{x^4}{12}$. Therefore, the limit equals $\frac{1/12}{1/16} = \frac{4}{3}$.
|
$$\begin{align}\sin{\log{(1+x)}} &= \sin{\left (x - \frac12 x^2 + \frac13 x^3 - \cdots \right )} \\ &= \left (x - \frac12 x^2 + \frac13 x^3 - \cdots \right ) - \frac16 \left (x - \frac12 x^2 + \frac13 x^3 - \cdots \right )^3 + \cdots \\ &= x - \frac12 x^2 + \frac16 x^3 + \left ( \frac32 \cdot \frac16 - \frac14 \right ) \frac14 x^4 \cdots\end{align}$$
$$\begin{align}\log{(1+\sin{x})} &= \log{\left (1 + x - \frac16 x^3 + \cdots \right )} \\ &= \left ( x - \frac16 x^3 + \cdots \right ) - \frac12 \left (x - \frac16 x^3 + \cdots \right )^2 + \cdots \\ &= x - \frac12 x^2 + \frac16 x^3 + \left (\frac16-\frac14 \right ) x^4 \cdots\end{align}$$
Thus the limit is equal to
$$\frac{1/12}{1/2^4} = \frac43 $$
|
66,441,126 |
I need to find persons who works at least 40 years and then I need to upgrade their salary by 50% also after this I need to display their Personname, current date, and updated salary what should I do, I tried but program give me a error?
```
CREATE TABLE date_table (PERSONNAME text, JOBNAME text, HRDATE date, SALARY integer);
INSERT INTO date_table VALUES
('NAMEONE', 'JOBONE','23-APR-81', 1000), ('NAMETWO', 'JOBTWO', '16-JUN-81', 1000),
('NAMETHREE', 'JOBTHREE', '15-MAY-81', 1000), ('NAMEFOUR', 'JOBFOUR', '18-JUN-81', 1000),
('NAMEFIVE', 'JOBFIVE', '05-NOV-87', 1000), ('NAMESIX', 'JOBSIX', '28-FEB-81', 1000);
DO $$
DECLARE
answer text;
BEGIN
SELECT date_part ('17-NOV-81',HIREDATE) FROM empno_table;
END $$;
```
[](https://i.stack.imgur.com/pbOzN.png)
|
2021/03/02
|
[
"https://Stackoverflow.com/questions/66441126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10618070/"
] |
Postgres has an `age()` function which will return the interval between its argument and `now()`
Check if the age is > 40 years:
```
select age('1981-01-02'::date)> interval '40 years';
?column?
----------
t
(1 row)
```
Now use this in an update statement:
```
UPDATE date_table
SET salary = (salary * 1.5)::integer
WHERE age(hrdate)> interval '40 years';
```
Check result:
```
select * from date_table;
personname | jobname | hrdate | salary
------------+----------+------------+--------
NAMEONE | JOBONE | 1981-04-23 | 1000
NAMETWO | JOBTWO | 1981-06-16 | 1000
NAMETHREE | JOBTHREE | 1981-05-15 | 1000
NAMEFOUR | JOBFOUR | 1981-06-18 | 1000
NAMEFIVE | JOBFIVE | 1987-11-05 | 1000
NAMESIX | JOBSIX | 1981-02-28 | 1500
(6 rows)
```
|
There are some issues with your select statement, causing the error message:
* `empno_table` does not exists in the scope of the example you posted
* `date_part` gets two parameters: 1) the part of the date you want to show, in your case `year`; and 2) date or date column
* `HIREDATE` is not an existing column in the example. It would be `HRDATE`.
Having this in mind, the following select statement will work:
```
SELECT date_part('year', HRDATE::date) FROM date_table;
```
Now, if you want to compare this date to the current date, you would use the `now()` like this:
```
SELECT date_part('year', now()::date) - date_part('year', HRDATE::date) FROM date_table;
```
This will give you the list of people who has been in the company for more than 40 years:
```
select * from (
select *, date_part('year', now()::date) - date_part('year', HRDATE::date) as "YEARS_IN_COMPANY"
from date_table
) as date_table_with_years_in_company
where "YEARS_IN_COMPANY" >= 40;
```
|
880,511 |
Can I not distribute powers on complex numbers as I do with real numbers?
For example:
Consider
$$\left(\frac{1 + i}{1-i}\right)^n = 1$$
Distributing powers as in real numbers:
$$(1+i)^n = (1 - i)^n$$
Taking log both sides and eliminating $n$ I am left with
$2i = 0$ which is obviously incorrect. So I am lead to believe that I can't distribute powers in complex numbers?
|
2014/07/28
|
[
"https://math.stackexchange.com/questions/880511",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/161104/"
] |
**Hint:** Try writing: $$\frac{1+i}{1-i} = \frac{1+i}{1-i}\cdot\frac{1+i}{1+i}$$
|
You can distribute powers. The problem in your reasoning is that you worked like if you were dealing with real numbers when taking logarithms.
As you can see here: <http://en.wikipedia.org/wiki/Complex_logarithm> the principal value of the complex logarithm is defined as:
$$log(z)=log(r)+i\theta$$
If $z=re^{i\theta}$.
|
880,511 |
Can I not distribute powers on complex numbers as I do with real numbers?
For example:
Consider
$$\left(\frac{1 + i}{1-i}\right)^n = 1$$
Distributing powers as in real numbers:
$$(1+i)^n = (1 - i)^n$$
Taking log both sides and eliminating $n$ I am left with
$2i = 0$ which is obviously incorrect. So I am lead to believe that I can't distribute powers in complex numbers?
|
2014/07/28
|
[
"https://math.stackexchange.com/questions/880511",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/161104/"
] |
**Hint:** Try writing: $$\frac{1+i}{1-i} = \frac{1+i}{1-i}\cdot\frac{1+i}{1+i}$$
|
Note that $1+i = \sqrt{2} e^{i\pi/4}$ and $1-i = \sqrt{2} e^{-i\pi/4}$, which means $$\frac{1+i}{1-i} = e^{i \pi/2} = i$$
|
880,511 |
Can I not distribute powers on complex numbers as I do with real numbers?
For example:
Consider
$$\left(\frac{1 + i}{1-i}\right)^n = 1$$
Distributing powers as in real numbers:
$$(1+i)^n = (1 - i)^n$$
Taking log both sides and eliminating $n$ I am left with
$2i = 0$ which is obviously incorrect. So I am lead to believe that I can't distribute powers in complex numbers?
|
2014/07/28
|
[
"https://math.stackexchange.com/questions/880511",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/161104/"
] |
Two points:
1. The complex $\log$ function is much more complicated than the real $\log$. That is because $a^x=a^y$ does not imply that $x=y$ in the complex numbers.
2. $$\frac{1+i}{1-i} = i$$
|
You can distribute powers. The problem in your reasoning is that you worked like if you were dealing with real numbers when taking logarithms.
As you can see here: <http://en.wikipedia.org/wiki/Complex_logarithm> the principal value of the complex logarithm is defined as:
$$log(z)=log(r)+i\theta$$
If $z=re^{i\theta}$.
|
880,511 |
Can I not distribute powers on complex numbers as I do with real numbers?
For example:
Consider
$$\left(\frac{1 + i}{1-i}\right)^n = 1$$
Distributing powers as in real numbers:
$$(1+i)^n = (1 - i)^n$$
Taking log both sides and eliminating $n$ I am left with
$2i = 0$ which is obviously incorrect. So I am lead to believe that I can't distribute powers in complex numbers?
|
2014/07/28
|
[
"https://math.stackexchange.com/questions/880511",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/161104/"
] |
Two points:
1. The complex $\log$ function is much more complicated than the real $\log$. That is because $a^x=a^y$ does not imply that $x=y$ in the complex numbers.
2. $$\frac{1+i}{1-i} = i$$
|
Note that $1+i = \sqrt{2} e^{i\pi/4}$ and $1-i = \sqrt{2} e^{-i\pi/4}$, which means $$\frac{1+i}{1-i} = e^{i \pi/2} = i$$
|
880,511 |
Can I not distribute powers on complex numbers as I do with real numbers?
For example:
Consider
$$\left(\frac{1 + i}{1-i}\right)^n = 1$$
Distributing powers as in real numbers:
$$(1+i)^n = (1 - i)^n$$
Taking log both sides and eliminating $n$ I am left with
$2i = 0$ which is obviously incorrect. So I am lead to believe that I can't distribute powers in complex numbers?
|
2014/07/28
|
[
"https://math.stackexchange.com/questions/880511",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/161104/"
] |
Distributing powers is fine, as long as the exponent is an integer. Your problem is with the logarithms.
In fact the easiest way (I'm assuming that what you want is to solve for $n$) is to simplify the bit in brackets first:
$$\frac{1+i}{1-i}=\frac{1+i}{1-i}\frac{1+i}{1+i}=\frac{2i}{2}=i\ .$$
Therefore
$$\Bigl(\frac{1+i}{1-i}\Bigr)^n=1\quad\Leftrightarrow\quad
i^n=1\quad\Leftrightarrow\quad
n=4k\ ,\ k\in{\Bbb Z}\ .$$
|
You can distribute powers. The problem in your reasoning is that you worked like if you were dealing with real numbers when taking logarithms.
As you can see here: <http://en.wikipedia.org/wiki/Complex_logarithm> the principal value of the complex logarithm is defined as:
$$log(z)=log(r)+i\theta$$
If $z=re^{i\theta}$.
|
880,511 |
Can I not distribute powers on complex numbers as I do with real numbers?
For example:
Consider
$$\left(\frac{1 + i}{1-i}\right)^n = 1$$
Distributing powers as in real numbers:
$$(1+i)^n = (1 - i)^n$$
Taking log both sides and eliminating $n$ I am left with
$2i = 0$ which is obviously incorrect. So I am lead to believe that I can't distribute powers in complex numbers?
|
2014/07/28
|
[
"https://math.stackexchange.com/questions/880511",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/161104/"
] |
Distributing powers is fine, as long as the exponent is an integer. Your problem is with the logarithms.
In fact the easiest way (I'm assuming that what you want is to solve for $n$) is to simplify the bit in brackets first:
$$\frac{1+i}{1-i}=\frac{1+i}{1-i}\frac{1+i}{1+i}=\frac{2i}{2}=i\ .$$
Therefore
$$\Bigl(\frac{1+i}{1-i}\Bigr)^n=1\quad\Leftrightarrow\quad
i^n=1\quad\Leftrightarrow\quad
n=4k\ ,\ k\in{\Bbb Z}\ .$$
|
Note that $1+i = \sqrt{2} e^{i\pi/4}$ and $1-i = \sqrt{2} e^{-i\pi/4}$, which means $$\frac{1+i}{1-i} = e^{i \pi/2} = i$$
|
34,914,467 |
I've been created a datasource by Azure Search SDK.
The Datasource from Azure sql which is a View.
I tyr to setting the DataChangeDetectionPolicy and DataDeletionDetectionPolicy,
but i can't understand how to set this two property.
When i think this two property doesn't supported on the preview sdk,so i try to use REST API to solve this.
I read the article:
[MSDN Create Data Source (Azure Search Service REST API)](https://msdn.microsoft.com/en-us/library/azure/dn946876.aspx)
And use Chrome Extension Postman to set the Data Change Detection Policies.
Url : <https://domain.search.windows.net/datasources/temp1?api-version=2015-02-28>
body :
```
{
"@odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
"highWaterMarkColumnName" : "ModifiedDatetime"
}
```
then i get the 400 bad request .
error message:
```
{
"error":
{
"code": "",
"message": "The request is invalid. Details: dataSource : Incompatible type kinds were found. The type 'Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy' was found to be of kind 'Complex' instead of the expected kind 'Entity'.\r\n"
}
}
```
So,i have two questions.
1.Is the SDK are not support this function Now?
2.with the REST API , how to solve the error?
Thanks for reply.
|
2016/01/21
|
[
"https://Stackoverflow.com/questions/34914467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4044747/"
] |
Based on the [official article](https://azure.microsoft.com/en-us/documentation/articles/search-howto-connecting-azure-sql-database-to-azure-search-using-indexers-2015-02-28/), the way to create the datasource for SQL integration for Views is:
```
{
"name" : "myazuresqldatasource",
"type" : "azuresql",
"credentials" : { "connectionString" : "connection string" },
"container" : { "name" : "table or view name" },
"dataChangeDetectionPolicy" : {
"@odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
"highWaterMarkColumnName" : "[a row version or last_updated column name]"
}
}
```
|
The SDK does support data source creation. See <https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.search.models.datasource>
|
5,353,466 |
I am trying to read input from file into an array. I seem to have done the needful, yet the code is not working as it should. Please tell me where am i going wrong. This s my code:
```
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
```
The text file is in the same directory as the cpp file is. While printing the output, it just prints 0 irrespective of the value in the file.
The values in the file is store as follows
```
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
```
`num_rows` and `num_cols` are defined previously in the code, both have the value 4.
|
2011/03/18
|
[
"https://Stackoverflow.com/questions/5353466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536169/"
] |
This code works perfectly fine for me with pro.txt formatted like you show:
```
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int num_rows = 4;
int num_cols = 4;
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
}
```
My suggestion would be to ensure that pro.txt is in the same directory as you .exe file. If you are using an IDE to build this code it is likely a different directory from your .cpp files.
|
Usually the simplest way to do these kinds of things is to store the data in a flat array (or even better a `std::vector`), and the use simple arithmetics to access the elements by rows and columns. This makes things much simpler.
A wrapper for this could look like this:
```
template<int ColumnCount>
class MyMatrix {
public:
template<class T>
MyMatrix(T & begin, T & end) : data(begin, end) {}
int getItem(int i, int j) const {
return data[i*ColumnCount+j];
}
private:
std::vector<int> data;
};
```
Then you can read the data like this:
```
std::ifstream file1("pro.txt");
std::istream_iterator<int> begin(file1);
std::istream_iterator<int> end;
MyMatrix<4> m(begin, end);
```
|
5,353,466 |
I am trying to read input from file into an array. I seem to have done the needful, yet the code is not working as it should. Please tell me where am i going wrong. This s my code:
```
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
```
The text file is in the same directory as the cpp file is. While printing the output, it just prints 0 irrespective of the value in the file.
The values in the file is store as follows
```
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
```
`num_rows` and `num_cols` are defined previously in the code, both have the value 4.
|
2011/03/18
|
[
"https://Stackoverflow.com/questions/5353466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536169/"
] |
This code works perfectly fine for me with pro.txt formatted like you show:
```
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int num_rows = 4;
int num_cols = 4;
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
}
```
My suggestion would be to ensure that pro.txt is in the same directory as you .exe file. If you are using an IDE to build this code it is likely a different directory from your .cpp files.
|
When using fstream, for robust coding, it is best to check error conditions with is\_open() after open() and fail() after operator<<().
Furthermore, prefer
```
while(getline(fil1, lineString))
{
...;
}
```
so you can check what line you're reading in and what is going wrong.
Happy checking...
|
5,353,466 |
I am trying to read input from file into an array. I seem to have done the needful, yet the code is not working as it should. Please tell me where am i going wrong. This s my code:
```
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
```
The text file is in the same directory as the cpp file is. While printing the output, it just prints 0 irrespective of the value in the file.
The values in the file is store as follows
```
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
```
`num_rows` and `num_cols` are defined previously in the code, both have the value 4.
|
2011/03/18
|
[
"https://Stackoverflow.com/questions/5353466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536169/"
] |
This code works perfectly fine for me with pro.txt formatted like you show:
```
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int num_rows = 4;
int num_cols = 4;
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
}
```
My suggestion would be to ensure that pro.txt is in the same directory as you .exe file. If you are using an IDE to build this code it is likely a different directory from your .cpp files.
|
As i see you want to load a matrix from a file. In file your values are stored as string separated by space. So you should load your file, read the file line by line, separate your string into a string array and the convert your values from string to int and store them into your matrix.
|
5,353,466 |
I am trying to read input from file into an array. I seem to have done the needful, yet the code is not working as it should. Please tell me where am i going wrong. This s my code:
```
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
```
The text file is in the same directory as the cpp file is. While printing the output, it just prints 0 irrespective of the value in the file.
The values in the file is store as follows
```
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
```
`num_rows` and `num_cols` are defined previously in the code, both have the value 4.
|
2011/03/18
|
[
"https://Stackoverflow.com/questions/5353466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536169/"
] |
This code works perfectly fine for me with pro.txt formatted like you show:
```
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int num_rows = 4;
int num_cols = 4;
int pb[10][10];
int i,j,n;
string ip_filename = string("pro.txt");
ifstream fil1;
fil1.open(ip_filename.c_str());
// to store the probabilities of the nodes
for(i=0;i<num_rows;i++)
for(j=0;j<num_cols;j++)
fil1 >> pb[i][j];
fil1.close();
for(i=0;i<num_rows;i++)
{
for(j=0;j<num_cols;j++)
cout<<pb[i][j]<<" ";
cout<<endl;
}
}
```
My suggestion would be to ensure that pro.txt is in the same directory as you .exe file. If you are using an IDE to build this code it is likely a different directory from your .cpp files.
|
What is the status of the stream after each operation? You shouldn't be
reading without verifying. And you shouldn't be reading without having
verified that the open worked:
```
ifstream fill( ip_filename.c_str() );
if ( !fill ) {
// error handling, open failed...
}
```
After that, I would agree with the suggestion of reading line by line:
```
int row = 0;
string line;
while ( getline( fill, line ) && row < size( pb ) ) {
istringstream sLine( line );
int col = 0;
int tmp ;
while ( sLine >> tmp && col < size( pb[ row ] )) {
pb[row][col] = tmp;
++ col;
}
if ( col != size( pb[ row ] ) ) {
// Input error, too few entries
} else if ( sLine >> ws && sLine.get() != EOF ) {
// Input error, garbage at end of line <row>
}
++ row;
}
if ( row != size( pb ) ) {
// Input error, garbage at end of file
}
```
Alternatively, you could decide on the dimensions dynamically, according
to the input:
```
std::vector<std::vector<int> > pb;
ifstream fill( ip_filename.c_str() );
if ( !fill ) {
// error handling, open failed...
}
string line;
while ( getline( fill, line ) ) {
std::vector<int> tmp1;
istringstream sLine( line );
int tmp2;
while ( sLine >> tmp2 ) {
tmp1.back().push_back( tmp2 );
}
if ( sLine >> ws && ! sLine.eof() ) {
// input error: non-numeric data in line
} else if ( ! pb.empty() && tmp1.size() != pb.back().size() ) {
// input error : inconsistent number of columns.
}
}
// Check here if square matrix required.
```
|
3,739,952 |
How can I reload or set to default (using javascript or jquery) only a particular tag (or id) in my html page. For instance, if I want to set the following select option to default "selected", if something else is currently in selection, without reloading the entire page through javascript confirm() function as follows:
```
var answer = confirm("Clicking 'OK' will revert to the default option.");
if (answer) { // ie, if i click 'OK'
selected = $(this).val();
//set the select drop-down option to "aaa"
//location.reload() reloads the entire page
} else {
$(this).val(selected);
}
...more...
<select size="1" name="choice" id="choice">
<option value="aaa" selected>aaa</option>
<option value="bbb">bbb</option>
<option value="ccc">ccc</option>
</select>
...html...
```
Many thanks in advance.
|
2010/09/18
|
[
"https://Stackoverflow.com/questions/3739952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257656/"
] |
Look very closely at the method you're calling: `presentModalViewController:` presents a **controller**, not a view.
The correct pattern is something like this:
```
MyViewController* myViewController = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil];
[self presentModalViewController:myViewController animated:YES];
[myViewController release];
```
|
Since iOS 6 you should use following method, because of deprections:
MyViewController\* myViewController = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil];
[self presentViewController:myViewController animated:YES completion:nil];
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
Yes as @OceanLife says you Should Go with [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) or [supports-screens](http://developer.android.com/guide/topics/manifest/supports-screens-element.html).
but I would like to add Something here.
if you are using
```
<supports-screens android:largeScreens="false" android:normalScreens="true"
android:smallScreens="true" android:xlargeScreens="false" />
```
then note what official [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) documentation says:
>
> if you want your application to be available only for large and
> xlarge screen devices, the element allows you to
> declare that your application does not support small and normal screen
> sizes. **External services (such as Google Play) will filter your**
> **application accordingly. You can also use the**
> **element to declare whether the system should resize your application**
> **for different screen sizes.**
>
>
>
So it will effect after you will upload your apk file to PlayStore. untill you will not get this feature affected.
Also see the [Filters on Google Play](http://developer.android.com/google/play/filters.html) document for more information about how Google Play filters applications using this and other manifest elements.
Hope it will Help.
|
Try to add this on your android manifest file
```
<uses-sdk
android:minSdkVersion="6"
android:targetSdkVersion="8" />
<supports-screens
android:anyDensity="true"
android:largeScreens="false"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="false" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
Try to add this on your android manifest file
```
<uses-sdk
android:minSdkVersion="6"
android:targetSdkVersion="8" />
<supports-screens
android:anyDensity="true"
android:largeScreens="false"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="false" />
```
|
By using **Uses-Feature** it seems you can restrict the app distribution to only Landscape screen devices "tablets and tablets like devices".
Here is the code you will need in your manifest.xml:
```
<uses-feature android:name="android.hardware.screen.landscape"
android:required="true"
></uses-feature>
```
Also use:
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="false"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
The google developer has very detail information on that so please check this link:
**[Distributing to Specific Screens](http://developer.android.com/guide/practices/screens-distribution.html)**
Quoting relevant parts below.
Handsets only:
>
> ### [Declaring an App is Only for Handsets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringHansetApps)
>
>
>
> ```
> <manifest ... >
> <compatible-screens>
> <!-- all small size screens -->
> <screen android:screenSize="small" android:screenDensity="ldpi" />
> <screen android:screenSize="small" android:screenDensity="mdpi" />
> <screen android:screenSize="small" android:screenDensity="hdpi" />
> <screen android:screenSize="small" android:screenDensity="xhdpi" />
> <!-- all normal size screens -->
> <screen android:screenSize="normal" android:screenDensity="ldpi" />
> <screen android:screenSize="normal" android:screenDensity="mdpi" />
> <screen android:screenSize="normal" android:screenDensity="hdpi" />
> <screen android:screenSize="normal" android:screenDensity="xhdpi" />
> </compatible-screens>
> ...
> <application ... >
> ...
> <application>
> </manifest>
>
> ```
>
>
Tablets only:
>
> ### [Declaring an App is Only for Tablets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringTabletApps)
>
>
> If you don't want your app to be used on handsets (perhaps your app
> truly makes sense only on a large screen) or you need time to optimize
> it for smaller screens, you can prevent small-screen devices from
> downloading your app by using the manifest element.
>
>
>
> ```
> <manifest ... >
> <supports-screens android:smallScreens="false"
> android:normalScreens="false"
> android:largeScreens="true"
> android:xlargeScreens="true"
> android:requiresSmallestWidthDp="600" />
> ...
> <application ... >
> ...
> </application>
> </manifest>
>
> ```
>
>
|
Try to add this on your android manifest file
```
<uses-sdk
android:minSdkVersion="6"
android:targetSdkVersion="8" />
<supports-screens
android:anyDensity="true"
android:largeScreens="false"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="false" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
Yes as @OceanLife says you Should Go with [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) or [supports-screens](http://developer.android.com/guide/topics/manifest/supports-screens-element.html).
but I would like to add Something here.
if you are using
```
<supports-screens android:largeScreens="false" android:normalScreens="true"
android:smallScreens="true" android:xlargeScreens="false" />
```
then note what official [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) documentation says:
>
> if you want your application to be available only for large and
> xlarge screen devices, the element allows you to
> declare that your application does not support small and normal screen
> sizes. **External services (such as Google Play) will filter your**
> **application accordingly. You can also use the**
> **element to declare whether the system should resize your application**
> **for different screen sizes.**
>
>
>
So it will effect after you will upload your apk file to PlayStore. untill you will not get this feature affected.
Also see the [Filters on Google Play](http://developer.android.com/google/play/filters.html) document for more information about how Google Play filters applications using this and other manifest elements.
Hope it will Help.
|
Try this :
You should use this `attribute` in your `mainfest` **android:largestWidthLimitDp="enter mobile pixel value which above you want restrict."**
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:largestWidthLimitDp="500"
android:smallScreens="true"
android:xlargeScreens="false" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
Yes as @OceanLife says you Should Go with [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) or [supports-screens](http://developer.android.com/guide/topics/manifest/supports-screens-element.html).
but I would like to add Something here.
if you are using
```
<supports-screens android:largeScreens="false" android:normalScreens="true"
android:smallScreens="true" android:xlargeScreens="false" />
```
then note what official [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) documentation says:
>
> if you want your application to be available only for large and
> xlarge screen devices, the element allows you to
> declare that your application does not support small and normal screen
> sizes. **External services (such as Google Play) will filter your**
> **application accordingly. You can also use the**
> **element to declare whether the system should resize your application**
> **for different screen sizes.**
>
>
>
So it will effect after you will upload your apk file to PlayStore. untill you will not get this feature affected.
Also see the [Filters on Google Play](http://developer.android.com/google/play/filters.html) document for more information about how Google Play filters applications using this and other manifest elements.
Hope it will Help.
|
By using **Uses-Feature** it seems you can restrict the app distribution to only Landscape screen devices "tablets and tablets like devices".
Here is the code you will need in your manifest.xml:
```
<uses-feature android:name="android.hardware.screen.landscape"
android:required="true"
></uses-feature>
```
Also use:
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="false"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
Yes as @OceanLife says you Should Go with [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) or [supports-screens](http://developer.android.com/guide/topics/manifest/supports-screens-element.html).
but I would like to add Something here.
if you are using
```
<supports-screens android:largeScreens="false" android:normalScreens="true"
android:smallScreens="true" android:xlargeScreens="false" />
```
then note what official [compatible-screens](http://developer.android.com/guide/topics/manifest/compatible-screens-element.html) documentation says:
>
> if you want your application to be available only for large and
> xlarge screen devices, the element allows you to
> declare that your application does not support small and normal screen
> sizes. **External services (such as Google Play) will filter your**
> **application accordingly. You can also use the**
> **element to declare whether the system should resize your application**
> **for different screen sizes.**
>
>
>
So it will effect after you will upload your apk file to PlayStore. untill you will not get this feature affected.
Also see the [Filters on Google Play](http://developer.android.com/google/play/filters.html) document for more information about how Google Play filters applications using this and other manifest elements.
Hope it will Help.
|
The google developer has very detail information on that so please check this link:
**[Distributing to Specific Screens](http://developer.android.com/guide/practices/screens-distribution.html)**
Quoting relevant parts below.
Handsets only:
>
> ### [Declaring an App is Only for Handsets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringHansetApps)
>
>
>
> ```
> <manifest ... >
> <compatible-screens>
> <!-- all small size screens -->
> <screen android:screenSize="small" android:screenDensity="ldpi" />
> <screen android:screenSize="small" android:screenDensity="mdpi" />
> <screen android:screenSize="small" android:screenDensity="hdpi" />
> <screen android:screenSize="small" android:screenDensity="xhdpi" />
> <!-- all normal size screens -->
> <screen android:screenSize="normal" android:screenDensity="ldpi" />
> <screen android:screenSize="normal" android:screenDensity="mdpi" />
> <screen android:screenSize="normal" android:screenDensity="hdpi" />
> <screen android:screenSize="normal" android:screenDensity="xhdpi" />
> </compatible-screens>
> ...
> <application ... >
> ...
> <application>
> </manifest>
>
> ```
>
>
Tablets only:
>
> ### [Declaring an App is Only for Tablets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringTabletApps)
>
>
> If you don't want your app to be used on handsets (perhaps your app
> truly makes sense only on a large screen) or you need time to optimize
> it for smaller screens, you can prevent small-screen devices from
> downloading your app by using the manifest element.
>
>
>
> ```
> <manifest ... >
> <supports-screens android:smallScreens="false"
> android:normalScreens="false"
> android:largeScreens="true"
> android:xlargeScreens="true"
> android:requiresSmallestWidthDp="600" />
> ...
> <application ... >
> ...
> </application>
> </manifest>
>
> ```
>
>
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
Try this :
You should use this `attribute` in your `mainfest` **android:largestWidthLimitDp="enter mobile pixel value which above you want restrict."**
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:largestWidthLimitDp="500"
android:smallScreens="true"
android:xlargeScreens="false" />
```
|
By using **Uses-Feature** it seems you can restrict the app distribution to only Landscape screen devices "tablets and tablets like devices".
Here is the code you will need in your manifest.xml:
```
<uses-feature android:name="android.hardware.screen.landscape"
android:required="true"
></uses-feature>
```
Also use:
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="false"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
The google developer has very detail information on that so please check this link:
**[Distributing to Specific Screens](http://developer.android.com/guide/practices/screens-distribution.html)**
Quoting relevant parts below.
Handsets only:
>
> ### [Declaring an App is Only for Handsets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringHansetApps)
>
>
>
> ```
> <manifest ... >
> <compatible-screens>
> <!-- all small size screens -->
> <screen android:screenSize="small" android:screenDensity="ldpi" />
> <screen android:screenSize="small" android:screenDensity="mdpi" />
> <screen android:screenSize="small" android:screenDensity="hdpi" />
> <screen android:screenSize="small" android:screenDensity="xhdpi" />
> <!-- all normal size screens -->
> <screen android:screenSize="normal" android:screenDensity="ldpi" />
> <screen android:screenSize="normal" android:screenDensity="mdpi" />
> <screen android:screenSize="normal" android:screenDensity="hdpi" />
> <screen android:screenSize="normal" android:screenDensity="xhdpi" />
> </compatible-screens>
> ...
> <application ... >
> ...
> <application>
> </manifest>
>
> ```
>
>
Tablets only:
>
> ### [Declaring an App is Only for Tablets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringTabletApps)
>
>
> If you don't want your app to be used on handsets (perhaps your app
> truly makes sense only on a large screen) or you need time to optimize
> it for smaller screens, you can prevent small-screen devices from
> downloading your app by using the manifest element.
>
>
>
> ```
> <manifest ... >
> <supports-screens android:smallScreens="false"
> android:normalScreens="false"
> android:largeScreens="true"
> android:xlargeScreens="true"
> android:requiresSmallestWidthDp="600" />
> ...
> <application ... >
> ...
> </application>
> </manifest>
>
> ```
>
>
|
Try this :
You should use this `attribute` in your `mainfest` **android:largestWidthLimitDp="enter mobile pixel value which above you want restrict."**
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:largestWidthLimitDp="500"
android:smallScreens="true"
android:xlargeScreens="false" />
```
|
14,729,410 |
i want to my app run only mobile device not in the
>
> tablet 10 and 7 inch
>
>
>
. but my app is run on both tablet size .please help me out
|
2013/02/06
|
[
"https://Stackoverflow.com/questions/14729410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1671153/"
] |
The google developer has very detail information on that so please check this link:
**[Distributing to Specific Screens](http://developer.android.com/guide/practices/screens-distribution.html)**
Quoting relevant parts below.
Handsets only:
>
> ### [Declaring an App is Only for Handsets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringHansetApps)
>
>
>
> ```
> <manifest ... >
> <compatible-screens>
> <!-- all small size screens -->
> <screen android:screenSize="small" android:screenDensity="ldpi" />
> <screen android:screenSize="small" android:screenDensity="mdpi" />
> <screen android:screenSize="small" android:screenDensity="hdpi" />
> <screen android:screenSize="small" android:screenDensity="xhdpi" />
> <!-- all normal size screens -->
> <screen android:screenSize="normal" android:screenDensity="ldpi" />
> <screen android:screenSize="normal" android:screenDensity="mdpi" />
> <screen android:screenSize="normal" android:screenDensity="hdpi" />
> <screen android:screenSize="normal" android:screenDensity="xhdpi" />
> </compatible-screens>
> ...
> <application ... >
> ...
> <application>
> </manifest>
>
> ```
>
>
Tablets only:
>
> ### [Declaring an App is Only for Tablets](http://developer.android.com/guide/practices/screens-distribution.html#FilteringTabletApps)
>
>
> If you don't want your app to be used on handsets (perhaps your app
> truly makes sense only on a large screen) or you need time to optimize
> it for smaller screens, you can prevent small-screen devices from
> downloading your app by using the manifest element.
>
>
>
> ```
> <manifest ... >
> <supports-screens android:smallScreens="false"
> android:normalScreens="false"
> android:largeScreens="true"
> android:xlargeScreens="true"
> android:requiresSmallestWidthDp="600" />
> ...
> <application ... >
> ...
> </application>
> </manifest>
>
> ```
>
>
|
By using **Uses-Feature** it seems you can restrict the app distribution to only Landscape screen devices "tablets and tablets like devices".
Here is the code you will need in your manifest.xml:
```
<uses-feature android:name="android.hardware.screen.landscape"
android:required="true"
></uses-feature>
```
Also use:
```
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="false"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
```
|
19,438,827 |
I am new in coding and i have a project to make and some minor problems I don't know how the circled things. I believe the top one can be made by croping the photo, but i want to find out if there's a html/css way and the margins that go after the content is a big mistery to me. If anyone would be so kind, i will appreciate just naming those things so i can do a little research by myself. The image is located at the following url : <http://postimg.org/image/u4lzmixjj/> .
Thank you, Iosif
|
2013/10/17
|
[
"https://Stackoverflow.com/questions/19438827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2790848/"
] |
I would recommend an already mapped CoreData store. Whether it have been previously mapped by your app or by an editor such as Core Data Editor.
In the app delegate you can preload the data. In `- (NSPersistentStoreCoordinator *)persistentStoreCoordinator`.
You can remove the current store:
```
NSError *error = nil;
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataStore.sqlite"];
[[NSFileManager defaultManager] removeItemAtPath:storeURL.path error:&error];
```
And you can move the preloaded store into place if there isn't already a store:
```
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataStore.sqlite"];
if (![[NSFileManager defaultManager] fileExistsAtPath:[storeURL path]]) {
NSURL *preloadURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"PreloadData" ofType:@"sqlite"]];
NSError* err = nil;
if (![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&err]) {
NSLog(@"Oops, couldn't copy preloaded data");
}
}
```
|
It depends on what kind of data you have. Really the only question that matters is which one fits your data better, because either works fine for writing code to import the data.
If your data contains entities of multiple types with relationships, SQLite will map that better than CSV. If not, use whatever you personally find most convenient to deal with.
|
3,667,954 |
I read several similar posts but I don't see my fault.
index.php looks like:
```
<head>
<title>Demo Title</title>
</head>
<body>
<?php
require_once "footer.php";
?>
</body>
```
footer.php looks like:
```
<?php
/*
* _$ Rev. : 08 Sep 2010 14:52:26 $_
* footer.php
*/
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo $url;
$file = @ fopen($_SERVER[$url],"r") or die ("Can't open HTTP_REFERER.");
$text = fread($file,16384);
if (preg_match('/<title>(.*?)<\/title>/is',$text,$found)) {
$title = $found[1];
} else {
$title = " -- no title found -- ";
}
?>
```
A request for the URL <http://127.0.0.1/test/index.php> results in:
```
http://127.0.0.1/test/index.phpCan't open HTTP_REFERER.
```
or for <http://127.0.0.1/test/>
```
http://127.0.0.1/test/Can't open HTTP_REFERER.
```
Any hints appreciated.
|
2010/09/08
|
[
"https://Stackoverflow.com/questions/3667954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181725/"
] |
$\_SERVER is an array which contains a bunch of fields relating to the server config. It does not contain an element named "http://".$host.$param, so trying to open that as a filename will result in the fopen call failing, and thus going to the die() statement.
More likely what you wanted to do was just open the file called "http://".$host.$param. If that's what you want, then just drop the $\_SERVER[] bit and it should work better.
Note that because it's a URL, you will need your PHP config to allow opening of remote files using fopen(). PHP isn't always configured this way by default as it can be a security risk. Your dev machine may also be configured differently to the system you will eventually deploy to. If you find you can't open a remote URL using fopen(), there are alternatives such as using CURL, but they're not quite as straightforward as a simple fopen() call.
Also, if you're reading the whole file, you may want to consider file\_get\_contents() rather than fopen() and fread(), as it replaces the whole thing into a single function call.
|
try this:
`$file = @ fopen($url,"r") or die ("Can't open HTTP_REFERER.");`
|
3,667,954 |
I read several similar posts but I don't see my fault.
index.php looks like:
```
<head>
<title>Demo Title</title>
</head>
<body>
<?php
require_once "footer.php";
?>
</body>
```
footer.php looks like:
```
<?php
/*
* _$ Rev. : 08 Sep 2010 14:52:26 $_
* footer.php
*/
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo $url;
$file = @ fopen($_SERVER[$url],"r") or die ("Can't open HTTP_REFERER.");
$text = fread($file,16384);
if (preg_match('/<title>(.*?)<\/title>/is',$text,$found)) {
$title = $found[1];
} else {
$title = " -- no title found -- ";
}
?>
```
A request for the URL <http://127.0.0.1/test/index.php> results in:
```
http://127.0.0.1/test/index.phpCan't open HTTP_REFERER.
```
or for <http://127.0.0.1/test/>
```
http://127.0.0.1/test/Can't open HTTP_REFERER.
```
Any hints appreciated.
|
2010/09/08
|
[
"https://Stackoverflow.com/questions/3667954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181725/"
] |
try this:
`$file = @ fopen($url,"r") or die ("Can't open HTTP_REFERER.");`
|
Try
```
<?php
$dom = new DOMDocument();
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo 'getting title for page: "' . $url . '"';
$dom->loadHTML($url);
$dom->getElementsByTagName('title');
if ($dom->length)
{
$title = $dom->item(0);
echo $title;
}
else
{
echo 'title tag not found';
}
?>
```
|
3,667,954 |
I read several similar posts but I don't see my fault.
index.php looks like:
```
<head>
<title>Demo Title</title>
</head>
<body>
<?php
require_once "footer.php";
?>
</body>
```
footer.php looks like:
```
<?php
/*
* _$ Rev. : 08 Sep 2010 14:52:26 $_
* footer.php
*/
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo $url;
$file = @ fopen($_SERVER[$url],"r") or die ("Can't open HTTP_REFERER.");
$text = fread($file,16384);
if (preg_match('/<title>(.*?)<\/title>/is',$text,$found)) {
$title = $found[1];
} else {
$title = " -- no title found -- ";
}
?>
```
A request for the URL <http://127.0.0.1/test/index.php> results in:
```
http://127.0.0.1/test/index.phpCan't open HTTP_REFERER.
```
or for <http://127.0.0.1/test/>
```
http://127.0.0.1/test/Can't open HTTP_REFERER.
```
Any hints appreciated.
|
2010/09/08
|
[
"https://Stackoverflow.com/questions/3667954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181725/"
] |
try this:
`$file = @ fopen($url,"r") or die ("Can't open HTTP_REFERER.");`
|
I can see your trying to track the referral's title
You need to use `$_SERVER['HTTP_REFERER'];` to get that
what you want to do is something like this
```
$referrer = (!empty($_SERVER['HTTP_REFERER']) && !substr($_SERVER['SERVER_NAME']) ? $_SERVER['HTTP_REFERER'] : false);
if($referrer)
{
try
{
if(false !== ($resource = fopen($referrer,"r")))
{
$contents = '';
while($contents .= fread($resource,128))
{}
if(preg_match('/<title>(.*?)<\/title>/is',$contents,$found))
{
echo 'Referrer: ' $found[1];
}
}
}catch(Exception $e){}
}
```
|
3,667,954 |
I read several similar posts but I don't see my fault.
index.php looks like:
```
<head>
<title>Demo Title</title>
</head>
<body>
<?php
require_once "footer.php";
?>
</body>
```
footer.php looks like:
```
<?php
/*
* _$ Rev. : 08 Sep 2010 14:52:26 $_
* footer.php
*/
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo $url;
$file = @ fopen($_SERVER[$url],"r") or die ("Can't open HTTP_REFERER.");
$text = fread($file,16384);
if (preg_match('/<title>(.*?)<\/title>/is',$text,$found)) {
$title = $found[1];
} else {
$title = " -- no title found -- ";
}
?>
```
A request for the URL <http://127.0.0.1/test/index.php> results in:
```
http://127.0.0.1/test/index.phpCan't open HTTP_REFERER.
```
or for <http://127.0.0.1/test/>
```
http://127.0.0.1/test/Can't open HTTP_REFERER.
```
Any hints appreciated.
|
2010/09/08
|
[
"https://Stackoverflow.com/questions/3667954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181725/"
] |
$\_SERVER is an array which contains a bunch of fields relating to the server config. It does not contain an element named "http://".$host.$param, so trying to open that as a filename will result in the fopen call failing, and thus going to the die() statement.
More likely what you wanted to do was just open the file called "http://".$host.$param. If that's what you want, then just drop the $\_SERVER[] bit and it should work better.
Note that because it's a URL, you will need your PHP config to allow opening of remote files using fopen(). PHP isn't always configured this way by default as it can be a security risk. Your dev machine may also be configured differently to the system you will eventually deploy to. If you find you can't open a remote URL using fopen(), there are alternatives such as using CURL, but they're not quite as straightforward as a simple fopen() call.
Also, if you're reading the whole file, you may want to consider file\_get\_contents() rather than fopen() and fread(), as it replaces the whole thing into a single function call.
|
Try
```
<?php
$dom = new DOMDocument();
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo 'getting title for page: "' . $url . '"';
$dom->loadHTML($url);
$dom->getElementsByTagName('title');
if ($dom->length)
{
$title = $dom->item(0);
echo $title;
}
else
{
echo 'title tag not found';
}
?>
```
|
3,667,954 |
I read several similar posts but I don't see my fault.
index.php looks like:
```
<head>
<title>Demo Title</title>
</head>
<body>
<?php
require_once "footer.php";
?>
</body>
```
footer.php looks like:
```
<?php
/*
* _$ Rev. : 08 Sep 2010 14:52:26 $_
* footer.php
*/
$host = $_SERVER['SERVER_NAME'];
$param = $_SERVER ['REQUEST_URI'];
$url = "http://".$host.$param;
echo $url;
$file = @ fopen($_SERVER[$url],"r") or die ("Can't open HTTP_REFERER.");
$text = fread($file,16384);
if (preg_match('/<title>(.*?)<\/title>/is',$text,$found)) {
$title = $found[1];
} else {
$title = " -- no title found -- ";
}
?>
```
A request for the URL <http://127.0.0.1/test/index.php> results in:
```
http://127.0.0.1/test/index.phpCan't open HTTP_REFERER.
```
or for <http://127.0.0.1/test/>
```
http://127.0.0.1/test/Can't open HTTP_REFERER.
```
Any hints appreciated.
|
2010/09/08
|
[
"https://Stackoverflow.com/questions/3667954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181725/"
] |
$\_SERVER is an array which contains a bunch of fields relating to the server config. It does not contain an element named "http://".$host.$param, so trying to open that as a filename will result in the fopen call failing, and thus going to the die() statement.
More likely what you wanted to do was just open the file called "http://".$host.$param. If that's what you want, then just drop the $\_SERVER[] bit and it should work better.
Note that because it's a URL, you will need your PHP config to allow opening of remote files using fopen(). PHP isn't always configured this way by default as it can be a security risk. Your dev machine may also be configured differently to the system you will eventually deploy to. If you find you can't open a remote URL using fopen(), there are alternatives such as using CURL, but they're not quite as straightforward as a simple fopen() call.
Also, if you're reading the whole file, you may want to consider file\_get\_contents() rather than fopen() and fread(), as it replaces the whole thing into a single function call.
|
I can see your trying to track the referral's title
You need to use `$_SERVER['HTTP_REFERER'];` to get that
what you want to do is something like this
```
$referrer = (!empty($_SERVER['HTTP_REFERER']) && !substr($_SERVER['SERVER_NAME']) ? $_SERVER['HTTP_REFERER'] : false);
if($referrer)
{
try
{
if(false !== ($resource = fopen($referrer,"r")))
{
$contents = '';
while($contents .= fread($resource,128))
{}
if(preg_match('/<title>(.*?)<\/title>/is',$contents,$found))
{
echo 'Referrer: ' $found[1];
}
}
}catch(Exception $e){}
}
```
|
37,307,100 |
I have this code included in my main.js:
```
var stripe = require("/cloud/stripe.js")("sk_test_*********");
//create customer
Parse.Cloud.define('createCustomer', function (req, res) {
stripe.customers.create({
description: req.params.fullName,
source: req.params.token
//email: req.params.email
}, function (err, customer) {
// asynchronously called
res.error("someting went wrong with creating a customer");
});
});
```
After pushing this code to my Heroku server the logs indicate that: `Error: Cannot find module '/cloud/stripe.js'`
I have also tried `var stripe = require("stripe")("sk_test_*********");` but this returns the same error. Whenever I try add this new module to my server the whole server becomes dysfunctional. What workarounds are there to this? Thanks
|
2016/05/18
|
[
"https://Stackoverflow.com/questions/37307100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6352529/"
] |
Have you added Stripe to the requirements of your `package.json` file for your node project? If so, you should be able to reference it using the term `require('stripe')` as opposed to what you're doing.
|
I'll tell you what worked for me, I racked my brain on this for a day. Instead of using Cloud Code to make a charge, create a route on index.js. Something like this in index.js
```
var stripe = require('stripe')('sk_test_****');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: false
}));
app.post('/charge', function(req, res){
var token = req.body.token;
var amount = req.body.amount;
stripe.charges.create({
amount: amount,
currency: 'usd',
source: token,
}, function(err, charge){
if(err)
// Error check
else
res.send('Payment successful!');
}
});
```
I call this using jQuery post but you could also use a form.
|
22,137,698 |
I use a while loop to echo member data to display each member's listing. I then use Jquery to filter the listings according to value(s) which are echoed from the `items` field. (i.e. the `items` field may contain "item1 item3 item10").This works well!!! Here's the code I have now.
```
<?php
$area = "Richmond";
$db_connect = @mysqli_connect("localhost", "user", "password","database");
if (mysqli_connect_errno($db_connect)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = @mysqli_query($db_connect, "SELECT * FROM database WHERE territories LIKE '%$area%'");
if (!$result){
echo ("<p>Error performing listing query:" . mysql_error() . "</p>");
}
$items = array();
while ($row = mysqli_fetch_array($result)){
// Jquery uses these "$row["items"]" for it's filter
$items[] = "<li class=\"services " . $row["items"] . "\">
// more code here used to construct member's listing
}
?>
//In the html, I echo each member's completed listing...
<?php echo $items[0]; echo $items[1]; echo $items[2]; etc... ?>
```
How can I set an echo limit to 12 duplicate value(s) from the `items` field? There are only 12 listings available for each value in `items`. So I want only the first 12 of each value to be included in the echo. If a member cancels, then `items` value(s) from next member will be echoed automatically. I hope this makes sense! :D
[EDIT] For more clarity, lets say 12 members list for "item1 item2" (both are in the `items` field). With the current code, the html for each listing would read `<li class="services item1 item2"></li>`.
Then a 13th member lists his services of "item1 item2 item3". Since "item1" and "item2" exist 12 times, only item3 should echo. This new member's listing should read `<li class="services item3"></li>`. If a previous member cancels, all three items would be echoed.
I picture something like `if COUNT(items=%item1%) <= 12)` or something similar... I can't seem to wrap my mind around using `GROUP BY` or `DISTINCT` with my current set up.
|
2014/03/03
|
[
"https://Stackoverflow.com/questions/22137698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2574871/"
] |
I'm implemented exception handling and had to read through GCC's exception handling code. I'm not exactly sure what the standard guarantees, but I know what happens here. In GCC if an exception is not handled then no stack unwinding will be done. The ABI definition for stack unwinding on Unix-like systems just ends the program if no handler is called. It doesn't unwind any stack frames.
The implementation defined aspect in the standard is to allow optimizations. It's possible that some destructors are called since they never existed in a *runtime* stack frame. The optimizer has reworked the code and removed some exception handling. So you could have some C++ objects that get destroyed. The amount will be really minimal though at the bottom of the stack only.
|
As you quoted:
>
> The process of calling destructors **for automatic objects** constructed on the path from a try block to a throw-expression is called “stack unwinding.”
>
>
>
This includes both objects and "subobjects" (which are just automatic objects enclosed in other objects). So, the destruction of subobjects is part of the *stack unwinding*, because subobjects are actually "automatic objects constructed on the path from a try block to a throw-expression" themselves.
>
> So my interpretation is that even if the exception is not handled, subobjects are still destroyed.
>
>
>
Subobjects will be destroyed if the implementation decides so as per §15.5.2/2 (that you also quoted).
---
>
> Is it also implementation-defined whether fully constructed subobjects of \*p are destroyed?
>
>
>
No, because they fall into the set of subobjects that the standard guarantees will be destroyed in §15.2/2.
|
22,137,698 |
I use a while loop to echo member data to display each member's listing. I then use Jquery to filter the listings according to value(s) which are echoed from the `items` field. (i.e. the `items` field may contain "item1 item3 item10").This works well!!! Here's the code I have now.
```
<?php
$area = "Richmond";
$db_connect = @mysqli_connect("localhost", "user", "password","database");
if (mysqli_connect_errno($db_connect)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = @mysqli_query($db_connect, "SELECT * FROM database WHERE territories LIKE '%$area%'");
if (!$result){
echo ("<p>Error performing listing query:" . mysql_error() . "</p>");
}
$items = array();
while ($row = mysqli_fetch_array($result)){
// Jquery uses these "$row["items"]" for it's filter
$items[] = "<li class=\"services " . $row["items"] . "\">
// more code here used to construct member's listing
}
?>
//In the html, I echo each member's completed listing...
<?php echo $items[0]; echo $items[1]; echo $items[2]; etc... ?>
```
How can I set an echo limit to 12 duplicate value(s) from the `items` field? There are only 12 listings available for each value in `items`. So I want only the first 12 of each value to be included in the echo. If a member cancels, then `items` value(s) from next member will be echoed automatically. I hope this makes sense! :D
[EDIT] For more clarity, lets say 12 members list for "item1 item2" (both are in the `items` field). With the current code, the html for each listing would read `<li class="services item1 item2"></li>`.
Then a 13th member lists his services of "item1 item2 item3". Since "item1" and "item2" exist 12 times, only item3 should echo. This new member's listing should read `<li class="services item3"></li>`. If a previous member cancels, all three items would be echoed.
I picture something like `if COUNT(items=%item1%) <= 12)` or something similar... I can't seem to wrap my mind around using `GROUP BY` or `DISTINCT` with my current set up.
|
2014/03/03
|
[
"https://Stackoverflow.com/questions/22137698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2574871/"
] |
Your interpretation is (obviously) correct, and neither Clang nor GCC conform to the standard in this scenario.
This was subject of [**CWG issue #1774**](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1774):
>
> The current wording of 15.5.1 [except.terminate] paragraph 2 affords
> implementations a significant degree of freedom when exception
> handling results in a call to `std::terminate`:
>
>
>
> >
> > In the situation where no matching handler is found [..]
> >
> >
> >
>
>
> This contrasts with the treatment of subobjects and objects
> constructed via delegating constructos in 15.2 [except.ctor] paragraph
> 2:
>
>
>
> >
> > An object of any storage duration [..]
> >
> >
> >
>
>
> Here the destructors must be called. It would be helpful if these
> requirements were harmonized.
>
>
>
A resolution has been proposed that didn't make it into C++14. Your quote, §15.3/11, will be deleted. Instead, §15.2 will contain
>
> **For an object of class type of any storage duration whose initialization or destruction is terminated by an
> exception, the destructor is invoked for each of the object’s fully constructed subobjects**, that is, for each
> subobject for which the principal constructor (12.6.2) has completed execution and the destructor has not
> yet begun execution, except that in the case of destruction, the variant members of a union-like class are not
> destroyed. The subobjects are destroyed in the reverse order of the completion of their construction. **Such
> destruction is sequenced before entering a handler of the function-try-block of the constructor or destructor,
> if any.**
>
>
>
This should eliminate any doubts. Also, note that the changes are already incorporated into the current working draft, [N4296](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf).
|
As you quoted:
>
> The process of calling destructors **for automatic objects** constructed on the path from a try block to a throw-expression is called “stack unwinding.”
>
>
>
This includes both objects and "subobjects" (which are just automatic objects enclosed in other objects). So, the destruction of subobjects is part of the *stack unwinding*, because subobjects are actually "automatic objects constructed on the path from a try block to a throw-expression" themselves.
>
> So my interpretation is that even if the exception is not handled, subobjects are still destroyed.
>
>
>
Subobjects will be destroyed if the implementation decides so as per §15.5.2/2 (that you also quoted).
---
>
> Is it also implementation-defined whether fully constructed subobjects of \*p are destroyed?
>
>
>
No, because they fall into the set of subobjects that the standard guarantees will be destroyed in §15.2/2.
|
22,137,698 |
I use a while loop to echo member data to display each member's listing. I then use Jquery to filter the listings according to value(s) which are echoed from the `items` field. (i.e. the `items` field may contain "item1 item3 item10").This works well!!! Here's the code I have now.
```
<?php
$area = "Richmond";
$db_connect = @mysqli_connect("localhost", "user", "password","database");
if (mysqli_connect_errno($db_connect)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = @mysqli_query($db_connect, "SELECT * FROM database WHERE territories LIKE '%$area%'");
if (!$result){
echo ("<p>Error performing listing query:" . mysql_error() . "</p>");
}
$items = array();
while ($row = mysqli_fetch_array($result)){
// Jquery uses these "$row["items"]" for it's filter
$items[] = "<li class=\"services " . $row["items"] . "\">
// more code here used to construct member's listing
}
?>
//In the html, I echo each member's completed listing...
<?php echo $items[0]; echo $items[1]; echo $items[2]; etc... ?>
```
How can I set an echo limit to 12 duplicate value(s) from the `items` field? There are only 12 listings available for each value in `items`. So I want only the first 12 of each value to be included in the echo. If a member cancels, then `items` value(s) from next member will be echoed automatically. I hope this makes sense! :D
[EDIT] For more clarity, lets say 12 members list for "item1 item2" (both are in the `items` field). With the current code, the html for each listing would read `<li class="services item1 item2"></li>`.
Then a 13th member lists his services of "item1 item2 item3". Since "item1" and "item2" exist 12 times, only item3 should echo. This new member's listing should read `<li class="services item3"></li>`. If a previous member cancels, all three items would be echoed.
I picture something like `if COUNT(items=%item1%) <= 12)` or something similar... I can't seem to wrap my mind around using `GROUP BY` or `DISTINCT` with my current set up.
|
2014/03/03
|
[
"https://Stackoverflow.com/questions/22137698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2574871/"
] |
Your interpretation is (obviously) correct, and neither Clang nor GCC conform to the standard in this scenario.
This was subject of [**CWG issue #1774**](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1774):
>
> The current wording of 15.5.1 [except.terminate] paragraph 2 affords
> implementations a significant degree of freedom when exception
> handling results in a call to `std::terminate`:
>
>
>
> >
> > In the situation where no matching handler is found [..]
> >
> >
> >
>
>
> This contrasts with the treatment of subobjects and objects
> constructed via delegating constructos in 15.2 [except.ctor] paragraph
> 2:
>
>
>
> >
> > An object of any storage duration [..]
> >
> >
> >
>
>
> Here the destructors must be called. It would be helpful if these
> requirements were harmonized.
>
>
>
A resolution has been proposed that didn't make it into C++14. Your quote, §15.3/11, will be deleted. Instead, §15.2 will contain
>
> **For an object of class type of any storage duration whose initialization or destruction is terminated by an
> exception, the destructor is invoked for each of the object’s fully constructed subobjects**, that is, for each
> subobject for which the principal constructor (12.6.2) has completed execution and the destructor has not
> yet begun execution, except that in the case of destruction, the variant members of a union-like class are not
> destroyed. The subobjects are destroyed in the reverse order of the completion of their construction. **Such
> destruction is sequenced before entering a handler of the function-try-block of the constructor or destructor,
> if any.**
>
>
>
This should eliminate any doubts. Also, note that the changes are already incorporated into the current working draft, [N4296](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf).
|
I'm implemented exception handling and had to read through GCC's exception handling code. I'm not exactly sure what the standard guarantees, but I know what happens here. In GCC if an exception is not handled then no stack unwinding will be done. The ABI definition for stack unwinding on Unix-like systems just ends the program if no handler is called. It doesn't unwind any stack frames.
The implementation defined aspect in the standard is to allow optimizations. It's possible that some destructors are called since they never existed in a *runtime* stack frame. The optimizer has reworked the code and removed some exception handling. So you could have some C++ objects that get destroyed. The amount will be really minimal though at the bottom of the stack only.
|
2,183,194 |
Can anyone tell me how to read the text in an image by using vc++
|
2010/02/02
|
[
"https://Stackoverflow.com/questions/2183194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264223/"
] |
The technology you are looking for is called "OCR", or ["Optical Character Recognition"](http://en.wikipedia.org/wiki/Optical_character_recognition).
Check out this codeproject entry:
<http://www.codeproject.com/KB/recipes/OCRwithMODI.aspx>
It may help.
Alternatively, [this google search](http://www.google.co.uk/search?q=OCR+visual+c%2B%2B) should take you a fair amount of the way.
|
I've got no solution, but got this from a Google hit.
<http://sourceforge.net/projects/paintlib/>
Your question might be better answered if you augmented it with more information. I.e. Why do you want to do this? What image types are you wanting to read?
Give us a background of the requirements, or even motivation. You'll be more likely to get an informed answer.
|
402,314 |
In a way following on from [reading a windows \*.dmp file](https://stackoverflow.com/questions/158534/reading-a-windows-dmp-file)
Having received a dump file from random customer, running the debug session to see the crash, you often find it is in a MS or other third party library. The next issue is that you may not have knowledge of the PC setup to such an extent that you can ensure you have the actually modules available.
For instance I'm currently stuck trying to get symbols to load for ntdll.dll (5.01.2600.5512). In MSVC 2005 the path column in the modules list window shows a \* before the fully pathed file name, and refuses to load symbols I have downloaded for XP/SP1/SP1a/SP2/SP3.
I have the symbol server setup to download from the internet and store in a local cache which seems to have been working fine for modules that I do have on my PC.
Using GUI equivelant to the method
```
Set _NT_SYMBOL_PATH=srv*d:\SymbolCache*\\server1\Third-Party-PDB;srv*d:\SymbolCache*\\server2\Windows\Symbols*http://msdl.microsoft.com/download/symbols
```
Perhaps I have the wrong symbols, but as new ones are not downloading where do I go to next? Do I have to contact the customer and ask what SP they have installed, and any other patches? Do I have to install that machine and then run up the debugger with the dmp file to get the symbols I need?
|
2008/12/31
|
[
"https://Stackoverflow.com/questions/402314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37558/"
] |
What are you using to debug the minidump? I.e., WinDBG or Visual Studio? And how was the minidump generated?
There should be enough information in the minidump to resolve system dll symbols correctly. Are you using a local download of symbols or <http://msdl.microsoft.com/>?
Update: You should be able to add the public microsoft symbol store to Tools->Options->Debugging->Symbols->Symbol file (.pdb) locations, and then manually load the symbols by right clicking on the module in the Modules window and loading them if it isn't done automatically.
It's also possibly (likely) that VS 2005 doesn't look at `_NT_SYMBOL_PATH` to resolve minidump symbols.
|
Try following the instructions at [this kb article](http://support.microsoft.com/kb/311503), and make sure your symbol path is configured correctly, that WinDbg has access to it, and that the ntdll symbols (for example) are actually downloaded to your symbol cache. The article also provides instructions on how to manually download and verify symbols in you cache via the SymChk tool.
|
402,314 |
In a way following on from [reading a windows \*.dmp file](https://stackoverflow.com/questions/158534/reading-a-windows-dmp-file)
Having received a dump file from random customer, running the debug session to see the crash, you often find it is in a MS or other third party library. The next issue is that you may not have knowledge of the PC setup to such an extent that you can ensure you have the actually modules available.
For instance I'm currently stuck trying to get symbols to load for ntdll.dll (5.01.2600.5512). In MSVC 2005 the path column in the modules list window shows a \* before the fully pathed file name, and refuses to load symbols I have downloaded for XP/SP1/SP1a/SP2/SP3.
I have the symbol server setup to download from the internet and store in a local cache which seems to have been working fine for modules that I do have on my PC.
Using GUI equivelant to the method
```
Set _NT_SYMBOL_PATH=srv*d:\SymbolCache*\\server1\Third-Party-PDB;srv*d:\SymbolCache*\\server2\Windows\Symbols*http://msdl.microsoft.com/download/symbols
```
Perhaps I have the wrong symbols, but as new ones are not downloading where do I go to next? Do I have to contact the customer and ask what SP they have installed, and any other patches? Do I have to install that machine and then run up the debugger with the dmp file to get the symbols I need?
|
2008/12/31
|
[
"https://Stackoverflow.com/questions/402314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37558/"
] |
If you are using WinDbg (part of the [Debugging Tools for Windows](http://www.microsoft.com/whdc/devtools/debugging/default.mspx) package), then it's simple to have it pull the right symbols for you from Microsoft automatically. Configure the symbol path using the ".symfix" (or ".symfix+", to simply append to your existing symbol search path) command.
Once you have that done and you have the crash dump loaded in WinDbg, type ".reload /f" to cause WinDbg to reload the symbols. It will use the information within the dump file itself to pull the correct symbols from Microsoft's public symbol server, regardless of what DLLs you have on your machine.
If for some reason the symbols aren't loading properly after you have done this, enter "!sym noisy" into WinDbg's command window and reload the symbols again. As WinDbg attempts to load them, you will see it output any errors that it encounters in its search/load process. These error messages will help you further diagnose what is going wrong and why the correct symbols aren't being loaded.
[This post](https://stackoverflow.com/questions/389103/debugging-tools-for-windows-symbol-proxy-doesnt-proxy#390243) has information that may also be of use.
|
Try following the instructions at [this kb article](http://support.microsoft.com/kb/311503), and make sure your symbol path is configured correctly, that WinDbg has access to it, and that the ntdll symbols (for example) are actually downloaded to your symbol cache. The article also provides instructions on how to manually download and verify symbols in you cache via the SymChk tool.
|
402,314 |
In a way following on from [reading a windows \*.dmp file](https://stackoverflow.com/questions/158534/reading-a-windows-dmp-file)
Having received a dump file from random customer, running the debug session to see the crash, you often find it is in a MS or other third party library. The next issue is that you may not have knowledge of the PC setup to such an extent that you can ensure you have the actually modules available.
For instance I'm currently stuck trying to get symbols to load for ntdll.dll (5.01.2600.5512). In MSVC 2005 the path column in the modules list window shows a \* before the fully pathed file name, and refuses to load symbols I have downloaded for XP/SP1/SP1a/SP2/SP3.
I have the symbol server setup to download from the internet and store in a local cache which seems to have been working fine for modules that I do have on my PC.
Using GUI equivelant to the method
```
Set _NT_SYMBOL_PATH=srv*d:\SymbolCache*\\server1\Third-Party-PDB;srv*d:\SymbolCache*\\server2\Windows\Symbols*http://msdl.microsoft.com/download/symbols
```
Perhaps I have the wrong symbols, but as new ones are not downloading where do I go to next? Do I have to contact the customer and ask what SP they have installed, and any other patches? Do I have to install that machine and then run up the debugger with the dmp file to get the symbols I need?
|
2008/12/31
|
[
"https://Stackoverflow.com/questions/402314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37558/"
] |
If you're typing "`Set _NT_SYMBOL_PATH = srv...`" into a command prompt, there are two things to consider:
* `cmd.exe`'s `set` command does not ignore whitespace, so this defines a variable called "`_NT_SYMBOL_PATH`", not "`_NT_SYMBOL_PATH`".
* You must start the debugger as a child of that command prompt. However, you don't have to do this if you use the Control Panel to set persistent environment variables, or if you use the `setx` command (in Windows Vista or one of the Windows Resource Kits).
If you're setting the symbol path some other way, then this doesn't apply.
|
Try following the instructions at [this kb article](http://support.microsoft.com/kb/311503), and make sure your symbol path is configured correctly, that WinDbg has access to it, and that the ntdll symbols (for example) are actually downloaded to your symbol cache. The article also provides instructions on how to manually download and verify symbols in you cache via the SymChk tool.
|
402,314 |
In a way following on from [reading a windows \*.dmp file](https://stackoverflow.com/questions/158534/reading-a-windows-dmp-file)
Having received a dump file from random customer, running the debug session to see the crash, you often find it is in a MS or other third party library. The next issue is that you may not have knowledge of the PC setup to such an extent that you can ensure you have the actually modules available.
For instance I'm currently stuck trying to get symbols to load for ntdll.dll (5.01.2600.5512). In MSVC 2005 the path column in the modules list window shows a \* before the fully pathed file name, and refuses to load symbols I have downloaded for XP/SP1/SP1a/SP2/SP3.
I have the symbol server setup to download from the internet and store in a local cache which seems to have been working fine for modules that I do have on my PC.
Using GUI equivelant to the method
```
Set _NT_SYMBOL_PATH=srv*d:\SymbolCache*\\server1\Third-Party-PDB;srv*d:\SymbolCache*\\server2\Windows\Symbols*http://msdl.microsoft.com/download/symbols
```
Perhaps I have the wrong symbols, but as new ones are not downloading where do I go to next? Do I have to contact the customer and ask what SP they have installed, and any other patches? Do I have to install that machine and then run up the debugger with the dmp file to get the symbols I need?
|
2008/12/31
|
[
"https://Stackoverflow.com/questions/402314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37558/"
] |
If you are using WinDbg (part of the [Debugging Tools for Windows](http://www.microsoft.com/whdc/devtools/debugging/default.mspx) package), then it's simple to have it pull the right symbols for you from Microsoft automatically. Configure the symbol path using the ".symfix" (or ".symfix+", to simply append to your existing symbol search path) command.
Once you have that done and you have the crash dump loaded in WinDbg, type ".reload /f" to cause WinDbg to reload the symbols. It will use the information within the dump file itself to pull the correct symbols from Microsoft's public symbol server, regardless of what DLLs you have on your machine.
If for some reason the symbols aren't loading properly after you have done this, enter "!sym noisy" into WinDbg's command window and reload the symbols again. As WinDbg attempts to load them, you will see it output any errors that it encounters in its search/load process. These error messages will help you further diagnose what is going wrong and why the correct symbols aren't being loaded.
[This post](https://stackoverflow.com/questions/389103/debugging-tools-for-windows-symbol-proxy-doesnt-proxy#390243) has information that may also be of use.
|
What are you using to debug the minidump? I.e., WinDBG or Visual Studio? And how was the minidump generated?
There should be enough information in the minidump to resolve system dll symbols correctly. Are you using a local download of symbols or <http://msdl.microsoft.com/>?
Update: You should be able to add the public microsoft symbol store to Tools->Options->Debugging->Symbols->Symbol file (.pdb) locations, and then manually load the symbols by right clicking on the module in the Modules window and loading them if it isn't done automatically.
It's also possibly (likely) that VS 2005 doesn't look at `_NT_SYMBOL_PATH` to resolve minidump symbols.
|
402,314 |
In a way following on from [reading a windows \*.dmp file](https://stackoverflow.com/questions/158534/reading-a-windows-dmp-file)
Having received a dump file from random customer, running the debug session to see the crash, you often find it is in a MS or other third party library. The next issue is that you may not have knowledge of the PC setup to such an extent that you can ensure you have the actually modules available.
For instance I'm currently stuck trying to get symbols to load for ntdll.dll (5.01.2600.5512). In MSVC 2005 the path column in the modules list window shows a \* before the fully pathed file name, and refuses to load symbols I have downloaded for XP/SP1/SP1a/SP2/SP3.
I have the symbol server setup to download from the internet and store in a local cache which seems to have been working fine for modules that I do have on my PC.
Using GUI equivelant to the method
```
Set _NT_SYMBOL_PATH=srv*d:\SymbolCache*\\server1\Third-Party-PDB;srv*d:\SymbolCache*\\server2\Windows\Symbols*http://msdl.microsoft.com/download/symbols
```
Perhaps I have the wrong symbols, but as new ones are not downloading where do I go to next? Do I have to contact the customer and ask what SP they have installed, and any other patches? Do I have to install that machine and then run up the debugger with the dmp file to get the symbols I need?
|
2008/12/31
|
[
"https://Stackoverflow.com/questions/402314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37558/"
] |
If you are using WinDbg (part of the [Debugging Tools for Windows](http://www.microsoft.com/whdc/devtools/debugging/default.mspx) package), then it's simple to have it pull the right symbols for you from Microsoft automatically. Configure the symbol path using the ".symfix" (or ".symfix+", to simply append to your existing symbol search path) command.
Once you have that done and you have the crash dump loaded in WinDbg, type ".reload /f" to cause WinDbg to reload the symbols. It will use the information within the dump file itself to pull the correct symbols from Microsoft's public symbol server, regardless of what DLLs you have on your machine.
If for some reason the symbols aren't loading properly after you have done this, enter "!sym noisy" into WinDbg's command window and reload the symbols again. As WinDbg attempts to load them, you will see it output any errors that it encounters in its search/load process. These error messages will help you further diagnose what is going wrong and why the correct symbols aren't being loaded.
[This post](https://stackoverflow.com/questions/389103/debugging-tools-for-windows-symbol-proxy-doesnt-proxy#390243) has information that may also be of use.
|
If you're typing "`Set _NT_SYMBOL_PATH = srv...`" into a command prompt, there are two things to consider:
* `cmd.exe`'s `set` command does not ignore whitespace, so this defines a variable called "`_NT_SYMBOL_PATH`", not "`_NT_SYMBOL_PATH`".
* You must start the debugger as a child of that command prompt. However, you don't have to do this if you use the Control Panel to set persistent environment variables, or if you use the `setx` command (in Windows Vista or one of the Windows Resource Kits).
If you're setting the symbol path some other way, then this doesn't apply.
|
90,642 |
I am looking at organizing a small conference next summer and I would like by all means to avoid concurrent dates with any major or highly-overlapping conference on the same or related topics. I thought that it would be really useful if there was an online directory where I can check a calendar of upcoming scientific conferences and workshops (maybe sorted by field) and plan mine on a week in which it does not coincide with an already planned event. That way I would not be "competing" for speakers and attendants against the organizer of a different event. I would prefer to avoid "manually" browsing the internet to find this information out, so a centralized online service would be perfect for my needs.
Does such an online resource exist? If the answer depends on the discipline, I am mostly interested in physics, chemistry and materials science conferences and workshops.
|
2017/06/08
|
[
"https://academia.stackexchange.com/questions/90642",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/14695/"
] |
The first resource that springs to mind is the [COMS directory](https://www.conference-service.com/), which lists conferences in the scientific disciplines (physics, chemistry, maths, life sciences etc). I don't know how comprehensive the listings are, but I think most major conferences should be listed there. You can filter the search by subject area (down to subfield level, such as astronomy or condensed matter) and country.
More specific resources exist which only list conferences in a certain country or subfield, for example the [IOP](http://www.iop.org/events/scientific/conferences/calendar/index.html?trumbaEmbed) (UK physics only), [APS](http://www.aps.org/meetings/calendar.cfm) (mostly US physics only) or [Inspire-HEP](https://inspirehep.net/collection/Conferences) (international, but mostly high energy physics only).
Another resource used in my field (cosmology) is the [UK Cosmo mailing list](https://lists.sussex.ac.uk/mailman/listinfo/ukcosmo), maintained by the University of Sussex. Organisers can mail conference and summer/ winter school details to the list, and it's not limited to UK meetings either. A similar mailing list for your field may exist, although the benefit of such a list is its narrow scope-- after all, people don't want their inboxes spammed with emails about conferences in other fields, so I would use one with caution. Another drawback is that not everyone may be on such a list in the first place.
|
[**PaperCrowd**](https://www.papercrowd.com/?utm_source=academicstackexchange) is a new research conference directory that may help.
- Researchers can search for conferences based on research interests, topics, keywords location. They can follow events of interest.
- Organizers can add their events in a couple of minutes.
- It's limited to academic research conferences to reduce clutter.
- It's free.
*Disclosure: PaperCrowd is [**Ex Ordo**](https://www.exordo.com/?utm_source=academicstackexchange)’s contribution to the research community. We’ve committed to keep it free. We’ll continue to develop and support the platform as a side project to offset the development costs. Making it light-touch to use and to support will minimise the on-going costs. We need the research community to embrace and populate PaperCrowd with conference data to make it a really useful resource. Please spread the word.*
[**Read more about PaperCrowd here**.](https://www.exordo.com/blog/papercrowd-the-global-research-conference-directory-fixes-call-for-papers/?utm_source=academicstackexchange)
|
43,907,235 |
I have not typical situation in my app. I have main activity, then I open activity A, from activity A I can open activity B, from activity B I can open activity A etc.
I looked in Android monitor in this case and every time application memory was increased. App crashed, for example, in 150 activity's and 90mb memory. After this memory was clear and opened previous activity (A or B) and user can navigate back.
Can I prevent this issue? For example, use special intent flag or something else. Thanks a lot.
**Note** user can navigate back
|
2017/05/11
|
[
"https://Stackoverflow.com/questions/43907235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5127677/"
] |
You can use `Intent.FLAG_ACTIVITY_REORDER_TO_FRONT` when starting an `Activity`. This will move an existing instance of this `Activity` (if one already exists in the stack) to the front without creating a new instance of that `Activity`. If you do this beware that `onCreate()` will not be called on the instance a second time. Instead `onNewIntent()` will be called to deliver the `Intent` that was used to reorder it, and then `onResume()`.
This, however, will not solve your BACK problem. If you really want your user to be able to go BACK 150 times and be presented with the Activity stack in exact reverse order, you will need to solve this problem separately. To do this you can create the illusion of having 150 activities in the stack by maintaining your own stack of objects in a `public static` variable.Each object in the stack should contain enough data for you to recreate (or reorder) the appropriate `Activity` with the appropriate data.
|
finish() can be called to kill (destroy) an Activity instance.
finish: [enter link description here](https://developer.android.com/reference/android/app/Activity.html#finish%28%29)
You can also examine Lifecycle: [enter link description here](https://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle)
|
43,907,235 |
I have not typical situation in my app. I have main activity, then I open activity A, from activity A I can open activity B, from activity B I can open activity A etc.
I looked in Android monitor in this case and every time application memory was increased. App crashed, for example, in 150 activity's and 90mb memory. After this memory was clear and opened previous activity (A or B) and user can navigate back.
Can I prevent this issue? For example, use special intent flag or something else. Thanks a lot.
**Note** user can navigate back
|
2017/05/11
|
[
"https://Stackoverflow.com/questions/43907235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5127677/"
] |
Use **singleTop** as an attribute of `<activity>` tag inside **AndroidManifest.xml** file list this:
>
> **singleTop** Activity instance could be created as many as we want. Only
> difference is if there already is an Activity instance with the same
> type at the top of stack in the caller Task, there would not be any
> new Activity created, instead an Intent will be sent to an existed
> Activity instance through **onNewIntent()** method.
>
>
>
There a good discussion regarding, [Understand Android Activity's launchMode: standard, singleTop, singleTask and singleInstance](https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en)
|
finish() can be called to kill (destroy) an Activity instance.
finish: [enter link description here](https://developer.android.com/reference/android/app/Activity.html#finish%28%29)
You can also examine Lifecycle: [enter link description here](https://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle)
|
43,907,235 |
I have not typical situation in my app. I have main activity, then I open activity A, from activity A I can open activity B, from activity B I can open activity A etc.
I looked in Android monitor in this case and every time application memory was increased. App crashed, for example, in 150 activity's and 90mb memory. After this memory was clear and opened previous activity (A or B) and user can navigate back.
Can I prevent this issue? For example, use special intent flag or something else. Thanks a lot.
**Note** user can navigate back
|
2017/05/11
|
[
"https://Stackoverflow.com/questions/43907235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5127677/"
] |
You can use `Intent.FLAG_ACTIVITY_REORDER_TO_FRONT` when starting an `Activity`. This will move an existing instance of this `Activity` (if one already exists in the stack) to the front without creating a new instance of that `Activity`. If you do this beware that `onCreate()` will not be called on the instance a second time. Instead `onNewIntent()` will be called to deliver the `Intent` that was used to reorder it, and then `onResume()`.
This, however, will not solve your BACK problem. If you really want your user to be able to go BACK 150 times and be presented with the Activity stack in exact reverse order, you will need to solve this problem separately. To do this you can create the illusion of having 150 activities in the stack by maintaining your own stack of objects in a `public static` variable.Each object in the stack should contain enough data for you to recreate (or reorder) the appropriate `Activity` with the appropriate data.
|
Use **singleTop** as an attribute of `<activity>` tag inside **AndroidManifest.xml** file list this:
>
> **singleTop** Activity instance could be created as many as we want. Only
> difference is if there already is an Activity instance with the same
> type at the top of stack in the caller Task, there would not be any
> new Activity created, instead an Intent will be sent to an existed
> Activity instance through **onNewIntent()** method.
>
>
>
There a good discussion regarding, [Understand Android Activity's launchMode: standard, singleTop, singleTask and singleInstance](https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en)
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
As Brian points out, 'the fold' is a rather antiquated concept ([see UX Myths: people don't scroll](http://uxmyths.com/post/654047943/myth-people-dont-scroll)) that has, for the most part, been remedied by time.
What's brought the problem back is this trend to have single page web sites that act more like full-screen powerpoint slides. The challenge is that this actually re-introduces the problem of the fold. The design is purposefully created to imply that there is 'one full screen' in view at a time.
As such, this is why you see the down-arrow solutions. It's a workaround to the fact that the 'slide deck' design trend causes this fold problem again.
In terms of accommodating general users, I think that leaves you with a few general options:
1. **Don't** follow this design trend and consider making it very clear that the page doesn't end after that first slide by **not** sticking with 100vh banners.
2. Go with the arrow solution. It, of course, doens't have to literally be an arrow, but something needs to be shown there to give the user an indication something exists beyond this full screen banner.
3. Assume/hope that people are used to this particular design trend and decide to scroll intuitively.
|
This is an issue of the "Fold". Particularly, "above the fold" which is a term borrowed from print-newspaper terminology. You are displaying "above the fold" content and want a user to know there is content "below the fold" to vertically scroll to. The fold is considered an antiquated concept by some because the broad range of device sizes and monitor screen sizes make the "fold" vastly different. But the "fold" is still a relevant concept to help wrap your head around solutions to let users know their is vertical content "below the fold". A great and common way to let users know their is content "below the fold" is a nice arrow icon of some kind, that, when clicked, scrolls to the next section of content.
Here is an example:
[](https://i.stack.imgur.com/YahJe.jpg)
Since you are using a `100vh + 100vw` fill you do not have to figure out different fold heights, for example: 900px for desktop and 768px for iPad Landscape, you just have an arrow icon of some kind that is within the 100vh + 100vw viewport which is your "above the fold" content visible to the user when the web page loads.
Here is an example of one I did along time ago because users did not understand there was more content to vertically scroll: <http://www.homevana.com>
Here is a a reference article I used to help answer your question: <http://www.nngroup.com/articles/page-fold-manifesto/>
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
I personally prefer non-obtrusive solutions like showing an edge of the next section of the content.
Here it's shown with cards: it's obvious there is something on the right, and users flick almost unconsciously. No cognitive load whatsoever.
[](https://i.stack.imgur.com/EA2Fv.jpg)
|
As Brian points out, 'the fold' is a rather antiquated concept ([see UX Myths: people don't scroll](http://uxmyths.com/post/654047943/myth-people-dont-scroll)) that has, for the most part, been remedied by time.
What's brought the problem back is this trend to have single page web sites that act more like full-screen powerpoint slides. The challenge is that this actually re-introduces the problem of the fold. The design is purposefully created to imply that there is 'one full screen' in view at a time.
As such, this is why you see the down-arrow solutions. It's a workaround to the fact that the 'slide deck' design trend causes this fold problem again.
In terms of accommodating general users, I think that leaves you with a few general options:
1. **Don't** follow this design trend and consider making it very clear that the page doesn't end after that first slide by **not** sticking with 100vh banners.
2. Go with the arrow solution. It, of course, doens't have to literally be an arrow, but something needs to be shown there to give the user an indication something exists beyond this full screen banner.
3. Assume/hope that people are used to this particular design trend and decide to scroll intuitively.
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
I personally prefer non-obtrusive solutions like showing an edge of the next section of the content.
Here it's shown with cards: it's obvious there is something on the right, and users flick almost unconsciously. No cognitive load whatsoever.
[](https://i.stack.imgur.com/EA2Fv.jpg)
|
Well, you have two paths: **implicit** or **explicit**.
An implicit approach would be to rely on implied affordances and user's past experiences. Thus, you could rely on the user noticing the scroll bar denotes additional content, or simply make your screen height's value `90vh`. Needless to say these approaches aren't the best UX.
On the other side, an explicit approach would require an explicit (doh!) element, such as text or graphic elements, like the arrow you mention, or a *+ sign* or whatever your creativity brings. And **creativity** is the keyword here, because your question comes from the fact that *somehow* you don't like an element, and obviously nobody but you can tell why.
But be very careful: a good UX designer must know when to back off from his/her own taste to apply the best possible solution. So if you want to go crazy... Do it! By all means, it's extremely boring to see everybody using the same rules and techniques, just make sure to test, and if everything fails.... Just back off and do like everybody does
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
I personally prefer non-obtrusive solutions like showing an edge of the next section of the content.
Here it's shown with cards: it's obvious there is something on the right, and users flick almost unconsciously. No cognitive load whatsoever.
[](https://i.stack.imgur.com/EA2Fv.jpg)
|
This is an issue of the "Fold". Particularly, "above the fold" which is a term borrowed from print-newspaper terminology. You are displaying "above the fold" content and want a user to know there is content "below the fold" to vertically scroll to. The fold is considered an antiquated concept by some because the broad range of device sizes and monitor screen sizes make the "fold" vastly different. But the "fold" is still a relevant concept to help wrap your head around solutions to let users know their is vertical content "below the fold". A great and common way to let users know their is content "below the fold" is a nice arrow icon of some kind, that, when clicked, scrolls to the next section of content.
Here is an example:
[](https://i.stack.imgur.com/YahJe.jpg)
Since you are using a `100vh + 100vw` fill you do not have to figure out different fold heights, for example: 900px for desktop and 768px for iPad Landscape, you just have an arrow icon of some kind that is within the 100vh + 100vw viewport which is your "above the fold" content visible to the user when the web page loads.
Here is an example of one I did along time ago because users did not understand there was more content to vertically scroll: <http://www.homevana.com>
Here is a a reference article I used to help answer your question: <http://www.nngroup.com/articles/page-fold-manifesto/>
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
I personally prefer non-obtrusive solutions like showing an edge of the next section of the content.
Here it's shown with cards: it's obvious there is something on the right, and users flick almost unconsciously. No cognitive load whatsoever.
[](https://i.stack.imgur.com/EA2Fv.jpg)
|
Another alternative is to make the main call to action in the banner area scroll down to the content below, or to use a second call to action to initiate the scroll:
[](https://i.stack.imgur.com/AT40V.png)
In this example, “Buy it now” is the primary call to action and “Learn more” scrolls the user to the next section to show that there is content below.
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
**Cut off some content at the bottom of the screen**. This will tell users there is more without the need for icons and text.

[download bmml source](/plugins/mockups/download?image=http%3a%2f%2fi.stack.imgur.com%2f3je7C.png) – Wireframes created with [Balsamiq Mockups](http://www.balsamiq.com/products/mockups)
Apple does this in their iOS Mail app. The last item doesn't fit completely so it's immediately clear there is more content.
[](https://i.stack.imgur.com/ZcGFF.png)
|
This is an issue of the "Fold". Particularly, "above the fold" which is a term borrowed from print-newspaper terminology. You are displaying "above the fold" content and want a user to know there is content "below the fold" to vertically scroll to. The fold is considered an antiquated concept by some because the broad range of device sizes and monitor screen sizes make the "fold" vastly different. But the "fold" is still a relevant concept to help wrap your head around solutions to let users know their is vertical content "below the fold". A great and common way to let users know their is content "below the fold" is a nice arrow icon of some kind, that, when clicked, scrolls to the next section of content.
Here is an example:
[](https://i.stack.imgur.com/YahJe.jpg)
Since you are using a `100vh + 100vw` fill you do not have to figure out different fold heights, for example: 900px for desktop and 768px for iPad Landscape, you just have an arrow icon of some kind that is within the 100vh + 100vw viewport which is your "above the fold" content visible to the user when the web page loads.
Here is an example of one I did along time ago because users did not understand there was more content to vertically scroll: <http://www.homevana.com>
Here is a a reference article I used to help answer your question: <http://www.nngroup.com/articles/page-fold-manifesto/>
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
Well, you have two paths: **implicit** or **explicit**.
An implicit approach would be to rely on implied affordances and user's past experiences. Thus, you could rely on the user noticing the scroll bar denotes additional content, or simply make your screen height's value `90vh`. Needless to say these approaches aren't the best UX.
On the other side, an explicit approach would require an explicit (doh!) element, such as text or graphic elements, like the arrow you mention, or a *+ sign* or whatever your creativity brings. And **creativity** is the keyword here, because your question comes from the fact that *somehow* you don't like an element, and obviously nobody but you can tell why.
But be very careful: a good UX designer must know when to back off from his/her own taste to apply the best possible solution. So if you want to go crazy... Do it! By all means, it's extremely boring to see everybody using the same rules and techniques, just make sure to test, and if everything fails.... Just back off and do like everybody does
|
This is an issue of the "Fold". Particularly, "above the fold" which is a term borrowed from print-newspaper terminology. You are displaying "above the fold" content and want a user to know there is content "below the fold" to vertically scroll to. The fold is considered an antiquated concept by some because the broad range of device sizes and monitor screen sizes make the "fold" vastly different. But the "fold" is still a relevant concept to help wrap your head around solutions to let users know their is vertical content "below the fold". A great and common way to let users know their is content "below the fold" is a nice arrow icon of some kind, that, when clicked, scrolls to the next section of content.
Here is an example:
[](https://i.stack.imgur.com/YahJe.jpg)
Since you are using a `100vh + 100vw` fill you do not have to figure out different fold heights, for example: 900px for desktop and 768px for iPad Landscape, you just have an arrow icon of some kind that is within the 100vh + 100vw viewport which is your "above the fold" content visible to the user when the web page loads.
Here is an example of one I did along time ago because users did not understand there was more content to vertically scroll: <http://www.homevana.com>
Here is a a reference article I used to help answer your question: <http://www.nngroup.com/articles/page-fold-manifesto/>
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
**Cut off some content at the bottom of the screen**. This will tell users there is more without the need for icons and text.

[download bmml source](/plugins/mockups/download?image=http%3a%2f%2fi.stack.imgur.com%2f3je7C.png) – Wireframes created with [Balsamiq Mockups](http://www.balsamiq.com/products/mockups)
Apple does this in their iOS Mail app. The last item doesn't fit completely so it's immediately clear there is more content.
[](https://i.stack.imgur.com/ZcGFF.png)
|
Well, you have two paths: **implicit** or **explicit**.
An implicit approach would be to rely on implied affordances and user's past experiences. Thus, you could rely on the user noticing the scroll bar denotes additional content, or simply make your screen height's value `90vh`. Needless to say these approaches aren't the best UX.
On the other side, an explicit approach would require an explicit (doh!) element, such as text or graphic elements, like the arrow you mention, or a *+ sign* or whatever your creativity brings. And **creativity** is the keyword here, because your question comes from the fact that *somehow* you don't like an element, and obviously nobody but you can tell why.
But be very careful: a good UX designer must know when to back off from his/her own taste to apply the best possible solution. So if you want to go crazy... Do it! By all means, it's extremely boring to see everybody using the same rules and techniques, just make sure to test, and if everything fails.... Just back off and do like everybody does
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
I personally prefer non-obtrusive solutions like showing an edge of the next section of the content.
Here it's shown with cards: it's obvious there is something on the right, and users flick almost unconsciously. No cognitive load whatsoever.
[](https://i.stack.imgur.com/EA2Fv.jpg)
|
**Cut off some content at the bottom of the screen**. This will tell users there is more without the need for icons and text.

[download bmml source](/plugins/mockups/download?image=http%3a%2f%2fi.stack.imgur.com%2f3je7C.png) – Wireframes created with [Balsamiq Mockups](http://www.balsamiq.com/products/mockups)
Apple does this in their iOS Mail app. The last item doesn't fit completely so it's immediately clear there is more content.
[](https://i.stack.imgur.com/ZcGFF.png)
|
87,413 |
I've been designing a website for one of my clients and I have a cover image on the landing screen. It's basically a 100vh + 100vw image.
I wanted to know what is a good way to show the users that there's content underneath the main image. For some reason, I'm not a fan of the arrow pointing downwards, would you guys suggest any other options?
|
2015/11/26
|
[
"https://ux.stackexchange.com/questions/87413",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/76318/"
] |
As Brian points out, 'the fold' is a rather antiquated concept ([see UX Myths: people don't scroll](http://uxmyths.com/post/654047943/myth-people-dont-scroll)) that has, for the most part, been remedied by time.
What's brought the problem back is this trend to have single page web sites that act more like full-screen powerpoint slides. The challenge is that this actually re-introduces the problem of the fold. The design is purposefully created to imply that there is 'one full screen' in view at a time.
As such, this is why you see the down-arrow solutions. It's a workaround to the fact that the 'slide deck' design trend causes this fold problem again.
In terms of accommodating general users, I think that leaves you with a few general options:
1. **Don't** follow this design trend and consider making it very clear that the page doesn't end after that first slide by **not** sticking with 100vh banners.
2. Go with the arrow solution. It, of course, doens't have to literally be an arrow, but something needs to be shown there to give the user an indication something exists beyond this full screen banner.
3. Assume/hope that people are used to this particular design trend and decide to scroll intuitively.
|
Well, you have two paths: **implicit** or **explicit**.
An implicit approach would be to rely on implied affordances and user's past experiences. Thus, you could rely on the user noticing the scroll bar denotes additional content, or simply make your screen height's value `90vh`. Needless to say these approaches aren't the best UX.
On the other side, an explicit approach would require an explicit (doh!) element, such as text or graphic elements, like the arrow you mention, or a *+ sign* or whatever your creativity brings. And **creativity** is the keyword here, because your question comes from the fact that *somehow* you don't like an element, and obviously nobody but you can tell why.
But be very careful: a good UX designer must know when to back off from his/her own taste to apply the best possible solution. So if you want to go crazy... Do it! By all means, it's extremely boring to see everybody using the same rules and techniques, just make sure to test, and if everything fails.... Just back off and do like everybody does
|
57,974,797 |
```
I have 3 tables:
1. users
-- _id
-- firstname
3. roles
-- _id
-- user_id
-- alias // admin, hr etc..
2. userroles
-- user_id
-- role_id
```
Here is the query I tried.
```
SELECT u._id, u.firstname, u.lastname, array_agg(r.alias) as roles
FROM users u
LEFT OUTER JOIN userroles ur ON (u._id = ur.user_id)
LEFT OUTER JOIN roles r ON (ur.role_id = r._id)
GROUP BY u._id
HAVING u.firstname='Admin' AND array_agg(r.alias) @> '{"ad", "gm"}'
```
I want to query users who have multiple roles within the given roles. For example, Only users who are either `admin` or `hr`. The current query only matches exact roles and not multiple roles. Can you suggest something??
|
2019/09/17
|
[
"https://Stackoverflow.com/questions/57974797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2741936/"
] |
The result of `parseInt()` is going to be either a number or `NaN`, so you can use `||`:
```
const my_v = parseInt(jQuery("#id").val()) || 0;
```
Now, in general I would caution anyone against using `parseInt()`, because (by design) it accepts strings like "123hello world" as valid numbers (`123` in this case). You can use the `Number()` constructor or plain unary `+` to coerce a string to a number. If you don't want a fractional part, you can use `Math.floor()` or `Math.round()`, and you can check numerically to see if there's a fractional part if that should be considered an error.
|
Sure using an IIFE:
```
(n => !isNaN(n) ? n : 0)(parseInt(jQuery('#id').val()))
```
But seriously, usea local variable.
|
57,974,797 |
```
I have 3 tables:
1. users
-- _id
-- firstname
3. roles
-- _id
-- user_id
-- alias // admin, hr etc..
2. userroles
-- user_id
-- role_id
```
Here is the query I tried.
```
SELECT u._id, u.firstname, u.lastname, array_agg(r.alias) as roles
FROM users u
LEFT OUTER JOIN userroles ur ON (u._id = ur.user_id)
LEFT OUTER JOIN roles r ON (ur.role_id = r._id)
GROUP BY u._id
HAVING u.firstname='Admin' AND array_agg(r.alias) @> '{"ad", "gm"}'
```
I want to query users who have multiple roles within the given roles. For example, Only users who are either `admin` or `hr`. The current query only matches exact roles and not multiple roles. Can you suggest something??
|
2019/09/17
|
[
"https://Stackoverflow.com/questions/57974797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2741936/"
] |
Sure using an IIFE:
```
(n => !isNaN(n) ? n : 0)(parseInt(jQuery('#id').val()))
```
But seriously, usea local variable.
|
If you have already a stringed integer value, you could just take a number or zero as default value.
```
const my_v = +jQuery('#id').val() || 0;
```
If not, get first the value and then the integer part.
```
const my_v = Math.floor(+jQuery('#id').val() || 0);
```
|
57,974,797 |
```
I have 3 tables:
1. users
-- _id
-- firstname
3. roles
-- _id
-- user_id
-- alias // admin, hr etc..
2. userroles
-- user_id
-- role_id
```
Here is the query I tried.
```
SELECT u._id, u.firstname, u.lastname, array_agg(r.alias) as roles
FROM users u
LEFT OUTER JOIN userroles ur ON (u._id = ur.user_id)
LEFT OUTER JOIN roles r ON (ur.role_id = r._id)
GROUP BY u._id
HAVING u.firstname='Admin' AND array_agg(r.alias) @> '{"ad", "gm"}'
```
I want to query users who have multiple roles within the given roles. For example, Only users who are either `admin` or `hr`. The current query only matches exact roles and not multiple roles. Can you suggest something??
|
2019/09/17
|
[
"https://Stackoverflow.com/questions/57974797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2741936/"
] |
The result of `parseInt()` is going to be either a number or `NaN`, so you can use `||`:
```
const my_v = parseInt(jQuery("#id").val()) || 0;
```
Now, in general I would caution anyone against using `parseInt()`, because (by design) it accepts strings like "123hello world" as valid numbers (`123` in this case). You can use the `Number()` constructor or plain unary `+` to coerce a string to a number. If you don't want a fractional part, you can use `Math.floor()` or `Math.round()`, and you can check numerically to see if there's a fractional part if that should be considered an error.
|
If you have already a stringed integer value, you could just take a number or zero as default value.
```
const my_v = +jQuery('#id').val() || 0;
```
If not, get first the value and then the integer part.
```
const my_v = Math.floor(+jQuery('#id').val() || 0);
```
|
57,974,797 |
```
I have 3 tables:
1. users
-- _id
-- firstname
3. roles
-- _id
-- user_id
-- alias // admin, hr etc..
2. userroles
-- user_id
-- role_id
```
Here is the query I tried.
```
SELECT u._id, u.firstname, u.lastname, array_agg(r.alias) as roles
FROM users u
LEFT OUTER JOIN userroles ur ON (u._id = ur.user_id)
LEFT OUTER JOIN roles r ON (ur.role_id = r._id)
GROUP BY u._id
HAVING u.firstname='Admin' AND array_agg(r.alias) @> '{"ad", "gm"}'
```
I want to query users who have multiple roles within the given roles. For example, Only users who are either `admin` or `hr`. The current query only matches exact roles and not multiple roles. Can you suggest something??
|
2019/09/17
|
[
"https://Stackoverflow.com/questions/57974797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2741936/"
] |
The result of `parseInt()` is going to be either a number or `NaN`, so you can use `||`:
```
const my_v = parseInt(jQuery("#id").val()) || 0;
```
Now, in general I would caution anyone against using `parseInt()`, because (by design) it accepts strings like "123hello world" as valid numbers (`123` in this case). You can use the `Number()` constructor or plain unary `+` to coerce a string to a number. If you don't want a fractional part, you can use `Math.floor()` or `Math.round()`, and you can check numerically to see if there's a fractional part if that should be considered an error.
|
With one `const` you can declare more than one variable.
```
const idValue = parseInt(jQuery('#id').val()), my_v = isNaN(idValue) ? 0 : idValue;
```
|
57,974,797 |
```
I have 3 tables:
1. users
-- _id
-- firstname
3. roles
-- _id
-- user_id
-- alias // admin, hr etc..
2. userroles
-- user_id
-- role_id
```
Here is the query I tried.
```
SELECT u._id, u.firstname, u.lastname, array_agg(r.alias) as roles
FROM users u
LEFT OUTER JOIN userroles ur ON (u._id = ur.user_id)
LEFT OUTER JOIN roles r ON (ur.role_id = r._id)
GROUP BY u._id
HAVING u.firstname='Admin' AND array_agg(r.alias) @> '{"ad", "gm"}'
```
I want to query users who have multiple roles within the given roles. For example, Only users who are either `admin` or `hr`. The current query only matches exact roles and not multiple roles. Can you suggest something??
|
2019/09/17
|
[
"https://Stackoverflow.com/questions/57974797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2741936/"
] |
With one `const` you can declare more than one variable.
```
const idValue = parseInt(jQuery('#id').val()), my_v = isNaN(idValue) ? 0 : idValue;
```
|
If you have already a stringed integer value, you could just take a number or zero as default value.
```
const my_v = +jQuery('#id').val() || 0;
```
If not, get first the value and then the integer part.
```
const my_v = Math.floor(+jQuery('#id').val() || 0);
```
|
67,227,239 |
I have an RDS file that is uploaded and then download via `curl::curl_fetch_memory()` (via `httr`) - this gives me a raw vector in R.
Is there a way to read that raw vector representing the RDS file to return the original R object? Or does it always have to be written to disk first?
I have a setup similar to below:
```r
saveRDS(mtcars, file = "obj.rds")
# upload the obj.rds file
...
# download it again via httr::write_memory()
...
obj
# [1] 1f 8b 08 00 00 00 00 00 00 03 ad 56 4f 4c 1c 55 18 1f ca 02 bb ec b2 5d
# ...
is.raw(obj)
#[1] TRUE
```
It seems `readRDS()` should be used to uncompress it, but it takes a connection object and I don't know how to make a connection object from an R raw vector - `rawConnection()` looked promising but gave:
```r
rawConnection(obj)
#A connection with
#description "obj"
#class "rawConnection"
#mode "r"
#text "binary"
#opened "opened"
#can read "yes"
#can write "no"
readRDS(rawConnection(obj))
#Error in readRDS(rawConnection(obj)) : unknown input format
```
Looking through `readRDS` it looks like it uses `gzlib()` underneath but couldn't get that to work with the raw vector object.
If its download via `httr::write_disk()` -> `curl::curl_fetch_disk()` -> `readRDS()` then its all good but this is a round trip to disk and I wondered if it could be optimised for big files.
|
2021/04/23
|
[
"https://Stackoverflow.com/questions/67227239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3878063/"
] |
By default, RDS file streams are gzipped. To read a raw connection you need to manually wrap it into a [`gzcon`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/gzcon.html):
```
con = rawConnection(obj)
result = readRDS(gzcon(con))
```
This works even when the stream *isn’t* gzipped. But unfortunately it fails if a different supported compression method (e.g. `'bzip2'`) was used to create the RDS file. Unfortunately R doesn’t seem to have a `gzcon` equivalent for bzip2 or xz. For those formats, the only recourse seems to be to write the data to disk.
|
I had exactly the same problem, and for me, the above answer with `gzcon` did not work, however, I could directly load the raw object into R's memory using the `rawConnection`:
```
load(rawConnection(obj))
```
|
50,771,376 |
After updating Android Studio, I found some red rows in my project.
What I have.
I call this method:
```
if (Build.VERSION.SDK_INT < 21) {
orangeProgressBar(progressBar);
}
```
Using of red `ContextCompat.getColor()`:
[](https://i.stack.imgur.com/siSfJ.png)
```
private void orangeProgressBar(ProgressBar pb) {
int color = ContextCompat.getColor(pb.getContext(), R.color.orange);
...
}
```
Of course, importing:
`implementation 'com.android.support:support-v4:24.2.1'`
`import android.support.v4.content.ContextCompat;`
[](https://i.stack.imgur.com/DzKTe.png)
Studio can't import `content.ContextCompat`, because it seems like `android.support.v4.content.` have not this child
|
2018/06/09
|
[
"https://Stackoverflow.com/questions/50771376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6793265/"
] |
I had the same problem after updating the Android Studio but the below solution worked for me:
Deleting the `.gradle` and `.build` folder from your respective project directory structure and rebuild the project.I'm not so sure about what it does but i think it deleted all the previous build caches other build related files and regenerated it that's why it's worked for me.
|
Deleting the .gradle and .idea did not work for me.
What worked was the following:
In Android Studio close all projects
In the Welcome To Android Studio Screen:
* remove all the projects by clicking the X in the top right corner, or right click, choose "Remove Selected From Welcome Screen"
* Close Android Studio
* Re-open Android Studio,
* Open an existing Android Studio project Navigate to the project
* It re-built and the errors were gone.
|
126,387 |
<http://stegosploit.info/>
I looking into having users upload their images directly to AWS S3 to save on costs (rather than going through a traditional server and re-encoded with mozjpeg), but this would theoretically open up the stegosploit vulnerability based on what I've read.
The part that I don't understand is: does the exploit require the image to be loaded in `<script></script>` (the website admin must be in on the exploit), or does the image itself contain the `<script></script>` (a website user can upload the image for the exploit)?
|
2016/06/07
|
[
"https://security.stackexchange.com/questions/126387",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/113770/"
] |
To answer the question: The website admin must be in on the exploit.
The encoding technique is there to obfuscate the actual exploit scripts, thus flying under the radar from current detection methods. It still requires HTML/Javascript to be on the webpage in order to decode and run the exploit.
That is to say, if I had encoded an exploit into `pleasedontrunthis.jpg`, I (the web admin), would still need to open the image like so:
`<script src="pleasedontrunthis.jpg">`
To answer the question in the title: Not really.
This is an encoding technique, not an exploit. It requires the would-be attacker to serve malicious Javascript in order to... server malicious Javascript. This technique could provide sufficient obfuscation to hide itself from both automated and human scanners for a potentially longer period of time than exploits which offer huge walls of text simply by hitting F12.
In practice this means that someone could hack a website (ie, through a Wordpress vulnerability), and deliver a silent exploit that would take longer to find.
In reality, if an exploit in the toolkit was capable of pwning your machine, it would have **most likely** pwned your machine either way. The reality being that not all malicious code is going to make itself glaringly obvious, so there's always an inherent risk when deciding to allow it.
|
There are two parts on <http://stegosploit.info/>
The first one is about hosting the javascript exploit in an image file loaded through canvas. As such, it's not really interesting since in order to be exploited, the attacker would already need to be able to insert javascript into the webpage.
The second part involves also including the html into the image file, which is the typical case of polyglot abuse. What you need to take into account is that the file is really interpreted by the client as the type you expect it to be. This means providing a Content-Type and not having the browser guess the content type on its own.
This is much less messy nowadays, and the [MIMESNIFF spec](https://mimesniff.spec.whatwg.org/) defines what *should* be done by the user agents. Still, there will be differences, and how old do you consider to still be modern will be important (mainly Internet Explorer versions). `X-Content-Type-Options: nosniff` is [available since IE 8](https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-v-comprehensive-protection/), though.
|
2,426,872 |
If $\mathcal {A}$ : $\mathbb R^2 \rightarrow \mathbb R^3$ is a linear transformation such that:
* $\mathcal{A}(1,1)=(0,1,2)$
* $\mathcal{A}(-1,1)=(2,1,0)$
Then the standard matrix of $\mathcal {A}$ is?
|
2017/09/12
|
[
"https://math.stackexchange.com/questions/2426872",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/479663/"
] |
$\mathcal{A}(\mathbf{e\_1}) = \mathcal{A}(1,0) = \dfrac12\mathcal{A}(1,1)-\dfrac12\mathcal{A}(-1,1) = (-1,0,1)$.
$\mathcal{A}(\mathbf{e\_2}) = \mathcal{A}(0,1) = \dfrac12\mathcal{A}(1,1)+\dfrac12\mathcal{A}(-1,1) = (1,1,1)$.
Therefore, the matrix representation of $\mathcal{A}$ is $\begin{bmatrix} \mathcal{A}(\mathbf{e\_1}) & \mathcal{A}(\mathbf{e\_2}) \end{bmatrix} = \begin{bmatrix} -1&1\\0&1\\1&1 \end{bmatrix}$.
|
To complement Kenny Lau's answer, here's a longer, perhaps more routine way to do essentially the same thing. You need to find the matrix for $\mathcal{A}$ from the standard basis $B\_2$ in $\mathbb{R}^2$ to the standard basis $B\_3$ in $\mathbb{R}^3$. That is, you want,
$$\mathcal{M}(\mathcal{A}, B\_2, B\_3).$$
What you are given is $\mathcal{A}(1, 1)$ and $\mathcal{A}(-1, 1)$, which tells you what $\mathcal{A}$ does to the non-standard basis
$$B\_2' = ((1, 1), (-1, 1)).$$
This gives us,
$$\mathcal{M}(\mathcal{A}, B'\_2, B\_3) = \left([\mathcal{A}(1, 1)]\_{B\_3} ~ | ~ [\mathcal{A}(-1, 1)]\_{B\_3}\right) = \begin{pmatrix}0 & 2 \\ 1 & 1 \\ 2 & 0\end{pmatrix}.$$
To get what we want, we can use a change of basis matrix. We have,
$$\mathcal{M}(\mathcal{A}, B\_2, B\_3) = \mathcal{M}(\mathcal{A}, B'\_2, B\_3)\mathcal{M}(I, B\_2, B'\_2) = \begin{pmatrix}0 & 2 \\ 1 & 1 \\ 2 & 0\end{pmatrix}\mathcal{M}(I, B\_2, B'\_2)$$
We can easily compute
$$\mathcal{M}(I, B'\_2, B\_2) = \left([(1, 1)]\_{B\_2} ~ | ~ [(-1, 1)]\_{B\_2}\right) = \begin{pmatrix}1 & -1 \\ 1 & 1 \end{pmatrix}.$$
Then $\mathcal{M}(I, B\_2, B'\_2)$ is the inverse of the above matrix, which we can compute by your favourite method, giving us,
$$\mathcal{M}(I, B\_2, B'\_2) = \begin{pmatrix}1 & -1 \\ 1 & 1 \end{pmatrix}^{-1} = \frac{1}{2}\begin{pmatrix}1 & 1 \\ -1 & 1 \end{pmatrix}.$$
Putting it all together,
$$\mathcal{M}(\mathcal{A}, B\_2, B\_3) = \frac{1}{2}\begin{pmatrix}0 & 2 \\ 1 & 1 \\ 2 & 0\end{pmatrix}\begin{pmatrix}1 & 1 \\ -1 & 1 \end{pmatrix} = \frac{1}{2}\begin{pmatrix}-2 & 2 \\ 0 & 2 \\ 2 & 2\end{pmatrix} = \begin{pmatrix}-1 & 1 \\ 0 & 1 \\ 1 & 1\end{pmatrix}.$$
---
I write this answer, certainly not because it's any quicker or any more elegant than the above answer, but it does showcase a reliable method to solve more general problems. The shorter method relies on being able to see, without too much hassle, that
\begin{align\*}
(1, 0) &= \frac{1}{2}(1, 1) - \frac{1}{2}(-1, 1) \\
(0, 1) &= \frac{1}{2}(1, 1) + \frac{1}{2}(-1, 1).
\end{align\*}
If the bases become longer, and less nice, then the problem essentially reduces down to inverting the change of basis matrix as above, so the longer method leads intuitively to a generally applicable method.
|
28,501 |
We're building a site which will have certain content pages accessible only to logged in Drupal users.
I'd like users to be able to create their own Drupal accounts with access to those pages, but only those who have been pre-approved, who exist as contacts in CiviCRM, and are part of a 'web site users' group.
What's the best way to do this?
|
2019/02/15
|
[
"https://civicrm.stackexchange.com/questions/28501",
"https://civicrm.stackexchange.com",
"https://civicrm.stackexchange.com/users/6140/"
] |
A couple of thoughts.
If you want this to be a response to an action - eg you folk send out a mailing - then you can do this via a webform - send out a link with checksum to a webform and upon submitting the webform you can trigger Drupal Rules (we usually do this by giving them a civicrm Tag) and this can also instantly log them in
If you want to do this as a self-service then I would probably be adding a wee form for folk to say 'send me a login link', they enter their email, it sends them a checksum and then you do the above approach of another webform.
|
I wrote a [plugin for Joomla](https://github.com/aydun/CiviCRM-JoomlaReg) that does this - it integrates into the Joomla account registration process and requires new accounts to match a CiviCRM record. Probably wouldn't be hard to create a Drupal version using the same approach.
|
28,501 |
We're building a site which will have certain content pages accessible only to logged in Drupal users.
I'd like users to be able to create their own Drupal accounts with access to those pages, but only those who have been pre-approved, who exist as contacts in CiviCRM, and are part of a 'web site users' group.
What's the best way to do this?
|
2019/02/15
|
[
"https://civicrm.stackexchange.com/questions/28501",
"https://civicrm.stackexchange.com",
"https://civicrm.stackexchange.com/users/6140/"
] |
I operate a similar system.
Thing to do is either A) create the contacts in Drupal manually or B) write a code thing (scheduled task / hook etc) which, upon them being approved in some way (e.g. added to the Group) creates an account in Drupal and mails them the details.
|
I wrote a [plugin for Joomla](https://github.com/aydun/CiviCRM-JoomlaReg) that does this - it integrates into the Joomla account registration process and requires new accounts to match a CiviCRM record. Probably wouldn't be hard to create a Drupal version using the same approach.
|
66,483,115 |
I'm building a html page from a model. Added to the page is a a form that somehow seems to interfere with the model I'm using to build the page.
I get this error message:
Exception Type: ValueError at /bidding
Exception Value: Field 'id' expected a number but got 'bidding'.
HTML (listing.html)
```
{% extends "auctions/layout.html" %}
{% block body %}
<h3>{{listing.0.listingName}}</h3>
<p><img class="listingImage" src="{{listing.0.listingImage}}"></p>
<p>{{listing.0.listingDesc}}</p>
<h5>Price: $ TODO</h5>
{% if user.is_authenticated %}
<form action="{% url 'bidding' %}" method="POST">
{% csrf_token %}
<input type="number" name="amount" placeholder="Bid">
<input class="btn btn-primary" type="submit" value="Bid">
</form>
{% endif %}
<h5>Details</h5>
<ul>
<li>Listed by: {{listing.0.listingPoster}}</li>
<li>Category: {{listing.0.listingCategory}}</li>
</ul>
<p>Comments:</p>
<p>TODO</p>
{% endblock %}
```
Views.py
```
def listing(request, listing):
return render(request, "auctions/listing.html",{
"listing" : Listing.objects.filter(id=listing)
})
def bidding(request):
if request.method == "POST":
bidAmount = int(request.POST["amount"])
### logic comes here
return HttpResponseRedirect(reverse("listing"), args=5 )
### args is hardcoded for testing only
```
models.py
```
class Listing(models.Model):
CATEGORIES = (
('fashion','fashion'),
('electronics','electronics'),
('sports','sports'),
('home','home'),
('motors','motors'),
('art','art'),
('business','business'),
('media','media'),
('others','others')
)
listingPoster = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="Poster")
listingName = models.CharField(max_length=128, verbose_name="Auction item")
listingDesc = models.TextField(blank=True, verbose_name="Item description")
listingActive = models.BooleanField(default=True, verbose_name="Active listing")
listingImage = models.URLField(blank=True, verbose_name="Link to image")
listingCategory = models.CharField(max_length=64, choices=CATEGORIES, default='others', verbose_name="Category")
listingFirstBid = models.DecimalField(max_digits=8, decimal_places=2, default=1.0, verbose_name="Starting bid")
listingCreated = models.DateTimeField(auto_now_add=True, null=True)
watchers = models.ManyToManyField(User, blank=True, related_name="watchedListings", verbose_name="Watchers")
### requires the Pillow library to be installed
def __str__(self):
return f"{self.listingPoster} {self.listingName} {self.listingCategory} {self.listingActive}"
```
urls.py
```
urlpatterns = [
path("<str:listing>", views.listing, name="listing"),
path("bidding", views.bidding, name="bidding")
]
```
|
2021/03/04
|
[
"https://Stackoverflow.com/questions/66483115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9729756/"
] |
You should swap the patterns, such that if you access `bidding/`, then it first will look at the path for the `bidding` view, and only if the path does not match look further, so:
```
urlpatterns = [
# ↓ first bidding
path(**'bidding/'**, views.bidding, name='bidding'),
path('<str:listing>/', views.listing, name='listing'),
]
```
since your `listing` parameter is supposed to make use of primary keys that are integers, you can also specify the path to only accept a sequence of digits with the `int` path converter:
```
urlpatterns = [
path('bidding/', views.bidding, name='bidding'),
# ↓ int path converter
path('<**int:**listing>/', views.listing, name='listing'),
]
```
|
>
>
> ```
> def listing(request, listing):
> return render(request, "auctions/listing.html",{
> "listing" : Listing.objects.filter(id=listing)
> })
>
> ```
>
>
This view function takes a second parameter, listing which is delivered by the URL:
>
> path("<str:listing>", views.listing, name="listing")
>
>
>
In this path you're declaring that the URL returns the variable `listing` which is declared as a string to your view function. Thus, when your filter function is run on your database, the parameter `id` is given a string represented by the variable `listing`
|
66,483,115 |
I'm building a html page from a model. Added to the page is a a form that somehow seems to interfere with the model I'm using to build the page.
I get this error message:
Exception Type: ValueError at /bidding
Exception Value: Field 'id' expected a number but got 'bidding'.
HTML (listing.html)
```
{% extends "auctions/layout.html" %}
{% block body %}
<h3>{{listing.0.listingName}}</h3>
<p><img class="listingImage" src="{{listing.0.listingImage}}"></p>
<p>{{listing.0.listingDesc}}</p>
<h5>Price: $ TODO</h5>
{% if user.is_authenticated %}
<form action="{% url 'bidding' %}" method="POST">
{% csrf_token %}
<input type="number" name="amount" placeholder="Bid">
<input class="btn btn-primary" type="submit" value="Bid">
</form>
{% endif %}
<h5>Details</h5>
<ul>
<li>Listed by: {{listing.0.listingPoster}}</li>
<li>Category: {{listing.0.listingCategory}}</li>
</ul>
<p>Comments:</p>
<p>TODO</p>
{% endblock %}
```
Views.py
```
def listing(request, listing):
return render(request, "auctions/listing.html",{
"listing" : Listing.objects.filter(id=listing)
})
def bidding(request):
if request.method == "POST":
bidAmount = int(request.POST["amount"])
### logic comes here
return HttpResponseRedirect(reverse("listing"), args=5 )
### args is hardcoded for testing only
```
models.py
```
class Listing(models.Model):
CATEGORIES = (
('fashion','fashion'),
('electronics','electronics'),
('sports','sports'),
('home','home'),
('motors','motors'),
('art','art'),
('business','business'),
('media','media'),
('others','others')
)
listingPoster = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="Poster")
listingName = models.CharField(max_length=128, verbose_name="Auction item")
listingDesc = models.TextField(blank=True, verbose_name="Item description")
listingActive = models.BooleanField(default=True, verbose_name="Active listing")
listingImage = models.URLField(blank=True, verbose_name="Link to image")
listingCategory = models.CharField(max_length=64, choices=CATEGORIES, default='others', verbose_name="Category")
listingFirstBid = models.DecimalField(max_digits=8, decimal_places=2, default=1.0, verbose_name="Starting bid")
listingCreated = models.DateTimeField(auto_now_add=True, null=True)
watchers = models.ManyToManyField(User, blank=True, related_name="watchedListings", verbose_name="Watchers")
### requires the Pillow library to be installed
def __str__(self):
return f"{self.listingPoster} {self.listingName} {self.listingCategory} {self.listingActive}"
```
urls.py
```
urlpatterns = [
path("<str:listing>", views.listing, name="listing"),
path("bidding", views.bidding, name="bidding")
]
```
|
2021/03/04
|
[
"https://Stackoverflow.com/questions/66483115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9729756/"
] |
You should swap the patterns, such that if you access `bidding/`, then it first will look at the path for the `bidding` view, and only if the path does not match look further, so:
```
urlpatterns = [
# ↓ first bidding
path(**'bidding/'**, views.bidding, name='bidding'),
path('<str:listing>/', views.listing, name='listing'),
]
```
since your `listing` parameter is supposed to make use of primary keys that are integers, you can also specify the path to only accept a sequence of digits with the `int` path converter:
```
urlpatterns = [
path('bidding/', views.bidding, name='bidding'),
# ↓ int path converter
path('<**int:**listing>/', views.listing, name='listing'),
]
```
|
```
urlpatterns = [
path("<str:listing>", views.listing, name="listing"),//This line is the culprit
path("bidding", views.bidding, name="bidding")
]
```
Change the first path to look as follows, which shall coerce the input to an integer.
```
path("<int:listing>", views.listing, name="listing")
```
|
52,714,668 |
I am trying to get a report from my created tables. The thing is I have 3 different button to trigger 3 different modal right now. This approach works but I think it is unnecessary to create them seperately. I want only one modal with auto routed to related "Action". I think it will be solved with jquery but I can't seem to understand.
The buttons that triggers modals is below.
```
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a data-toggle="modal" data-target="#GeneralModal" class="dropdown-item" href="#">General Report </a>
<a data-toggle="modal" data-target="#VehicleModal" class="dropdown-item" href="#">Vehicle Report</a>
<a data-toggle="modal" data-target="#WarrantylModal" class="dropdown-item" href="#">Warranty Report</a>
</div>
```
My modals are below.
```
<div class="modal fade" id="GeneralModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportGeneral" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="WarrantyModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportWarranty" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="VehicleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportVehicle" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
The only changing part is the modal's,
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Depending on the triggered modal it route to another action such as,
ExportGeneral
ExportWarranty
ExportVehicle
What I am asking is if there is a thing that help me to click the different buttons but open them in only one modal which's
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Change's automatically depending on, clicked button. (Maybe an id to buttons ?)
Thank you for your time!
|
2018/10/09
|
[
"https://Stackoverflow.com/questions/52714668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10366733/"
] |
It looks like your bash gets confused by DOS line endings. [This post](https://stackoverflow.com/questions/6373888/converting-newline-formatting-from-mac-to-windows) goes into some detail on how to handle those on MacOS
|
The error suggests that the mvnw file is not there. Go to your maven project which you need to build and then run mvnw like bellow by pointing to the path of mvnw.
sh /home/user/maven-wrapper-master/mvnw clean install
Or else copy the mvnw file into the maven project directory.
|
52,714,668 |
I am trying to get a report from my created tables. The thing is I have 3 different button to trigger 3 different modal right now. This approach works but I think it is unnecessary to create them seperately. I want only one modal with auto routed to related "Action". I think it will be solved with jquery but I can't seem to understand.
The buttons that triggers modals is below.
```
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a data-toggle="modal" data-target="#GeneralModal" class="dropdown-item" href="#">General Report </a>
<a data-toggle="modal" data-target="#VehicleModal" class="dropdown-item" href="#">Vehicle Report</a>
<a data-toggle="modal" data-target="#WarrantylModal" class="dropdown-item" href="#">Warranty Report</a>
</div>
```
My modals are below.
```
<div class="modal fade" id="GeneralModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportGeneral" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="WarrantyModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportWarranty" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="VehicleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportVehicle" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
The only changing part is the modal's,
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Depending on the triggered modal it route to another action such as,
ExportGeneral
ExportWarranty
ExportVehicle
What I am asking is if there is a thing that help me to click the different buttons but open them in only one modal which's
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Change's automatically depending on, clicked button. (Maybe an id to buttons ?)
Thank you for your time!
|
2018/10/09
|
[
"https://Stackoverflow.com/questions/52714668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10366733/"
] |
I had the same error as you, installing mvn wrapper in the following way worked for me.
```
mvn -N io.takari:maven:wrapper
```
Then cd to the folder where pom.xml file is, and then re-run the ./mvnw command
|
The error suggests that the mvnw file is not there. Go to your maven project which you need to build and then run mvnw like bellow by pointing to the path of mvnw.
sh /home/user/maven-wrapper-master/mvnw clean install
Or else copy the mvnw file into the maven project directory.
|
52,714,668 |
I am trying to get a report from my created tables. The thing is I have 3 different button to trigger 3 different modal right now. This approach works but I think it is unnecessary to create them seperately. I want only one modal with auto routed to related "Action". I think it will be solved with jquery but I can't seem to understand.
The buttons that triggers modals is below.
```
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a data-toggle="modal" data-target="#GeneralModal" class="dropdown-item" href="#">General Report </a>
<a data-toggle="modal" data-target="#VehicleModal" class="dropdown-item" href="#">Vehicle Report</a>
<a data-toggle="modal" data-target="#WarrantylModal" class="dropdown-item" href="#">Warranty Report</a>
</div>
```
My modals are below.
```
<div class="modal fade" id="GeneralModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportGeneral" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="WarrantyModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportWarranty" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="VehicleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportVehicle" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
The only changing part is the modal's,
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Depending on the triggered modal it route to another action such as,
ExportGeneral
ExportWarranty
ExportVehicle
What I am asking is if there is a thing that help me to click the different buttons but open them in only one modal which's
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Change's automatically depending on, clicked button. (Maybe an id to buttons ?)
Thank you for your time!
|
2018/10/09
|
[
"https://Stackoverflow.com/questions/52714668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10366733/"
] |
It looks like your bash gets confused by DOS line endings. [This post](https://stackoverflow.com/questions/6373888/converting-newline-formatting-from-mac-to-windows) goes into some detail on how to handle those on MacOS
|
I tried `dos2unix filename` it works. For using this command we have to install dos2unix
This is the link for install
[https://symwisedownload.symantec.com//resources/sites/SYMWISE/content/live/SOLUTIONS/228000/TECH228385/en\_US/dos2unix-5.3.3-0.pkg?**gda**=1539204692\_786de4ebe956ae8f24de673f5398dd64](https://symwisedownload.symantec.com//resources/sites/SYMWISE/content/live/SOLUTIONS/228000/TECH228385/en_US/dos2unix-5.3.3-0.pkg?__gda__=1539204692_786de4ebe956ae8f24de673f5398dd64)
|
52,714,668 |
I am trying to get a report from my created tables. The thing is I have 3 different button to trigger 3 different modal right now. This approach works but I think it is unnecessary to create them seperately. I want only one modal with auto routed to related "Action". I think it will be solved with jquery but I can't seem to understand.
The buttons that triggers modals is below.
```
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a data-toggle="modal" data-target="#GeneralModal" class="dropdown-item" href="#">General Report </a>
<a data-toggle="modal" data-target="#VehicleModal" class="dropdown-item" href="#">Vehicle Report</a>
<a data-toggle="modal" data-target="#WarrantylModal" class="dropdown-item" href="#">Warranty Report</a>
</div>
```
My modals are below.
```
<div class="modal fade" id="GeneralModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportGeneral" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="WarrantyModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportWarranty" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
---
```
<div class="modal fade" id="VehicleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<form action="/Export/ExportVehicle" role="form" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Excel Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group m-form__group row m--margin-top-20">
<label class="col-form-label col-lg-3 col-sm-12">
Start Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker" name="date1" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose start date">
</div>
<label class="col-form-label col-lg-3 col-sm-12">
End Date
</label>
<div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="datepicker2" name="date2" data-date-format="dd-mm-yyyy" autocomplete="off" placeholder="Choose end date">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Vazgeç</button>
<button type="submit" class="btn btn-primary">Get Report </button>
</div>
</div>
</div>
</form>
```
The only changing part is the modal's,
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Depending on the triggered modal it route to another action such as,
ExportGeneral
ExportWarranty
ExportVehicle
What I am asking is if there is a thing that help me to click the different buttons but open them in only one modal which's
```
<form action="/Export/ExportGeneral" role="form" method="post">
```
Change's automatically depending on, clicked button. (Maybe an id to buttons ?)
Thank you for your time!
|
2018/10/09
|
[
"https://Stackoverflow.com/questions/52714668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10366733/"
] |
I had the same error as you, installing mvn wrapper in the following way worked for me.
```
mvn -N io.takari:maven:wrapper
```
Then cd to the folder where pom.xml file is, and then re-run the ./mvnw command
|
I tried `dos2unix filename` it works. For using this command we have to install dos2unix
This is the link for install
[https://symwisedownload.symantec.com//resources/sites/SYMWISE/content/live/SOLUTIONS/228000/TECH228385/en\_US/dos2unix-5.3.3-0.pkg?**gda**=1539204692\_786de4ebe956ae8f24de673f5398dd64](https://symwisedownload.symantec.com//resources/sites/SYMWISE/content/live/SOLUTIONS/228000/TECH228385/en_US/dos2unix-5.3.3-0.pkg?__gda__=1539204692_786de4ebe956ae8f24de673f5398dd64)
|
30,642,725 |
I want to get newest posts first, and try the following:
```
db.posts.find({"date": {"$lt": tomorrow, "$gte":
today}}).sort({'date':pymongo.DESCENDING})
```
(without **sort**, I get the oldest posts first fine)
I am getting this error
```
TypeError: if no direction is specified, key_or_list must be an instance of list
```
What is going on here? Is not it possible to sort by date?
|
2015/06/04
|
[
"https://Stackoverflow.com/questions/30642725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1164501/"
] |
This is not the correct format of parameters for the `sort` function. The correct syntax would look something like this:
```
db.posts.find(...).sort('date',pymongo.DESCENDING)
```
Here is a link to the relevant documentation for the `sort` function:
<http://api.mongodb.org/python/current/api/pymongo/cursor.html#pymongo.cursor.Cursor.sort>
To sort by multiple parameters you can use the following syntax:
```
db.posts.find(...).sort([
('date', pymongo.ASCENDING),
('other_field', pymongo.DESCENDING)
]):
```
|
In PyMongo you can try also this if there is an error for .sort('date', pymongo.DESCENDING)
```
db.posts.find().sort('date', -1)
```
|
46,228,420 |
I found from lots of resources that JDBC is a typical example of Bridge design pattern. But they usually didn't tell the details, so I would like to know the details. According to my understanding:
* `Driver` interface is the *bridge* between the `DriverManager` and the concrete JDBC driver classes
* `Connection` interface is the *bridge* between the `Driver` and the concrete JDBC connection classes
* `Statement` interface is the *bridge* between the `Connection` and the concrete SQL statement classes
* `ResultSet` interface is the *bridge* between the `Statement` and the concete result set classes
Please modify if the my statements are wrong. Also I guess `DataSource` interface is also a *bridge*, but I can not figure out that is a *bridge* between which classes
|
2017/09/14
|
[
"https://Stackoverflow.com/questions/46228420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1928863/"
] |
The [Bridge pattern](https://en.wikipedia.org/wiki/Bridge_pattern), as defined by the "Gang of Four", means *decoupling an abstraction from its implementation so that the two can vary independently*. In this context, it's not so much about bridging different classes together. Instead, the pattern illustrates the [Open/Closed principle](https://en.wikipedia.org/wiki/Open/closed_principle) where the interface (JDBC API) stays the same, but new implementations (JDBC drivers) can be added and substituted for each other.
What this means is that data access code using JDBC only needs to depend on the API interfaces such as `Connection`, `Statement` or `ResultSet`, instead of caring about the actual database system the application is connected to. JDBC will *bridge* the application to the database that's used in the environment the application is deployed to. For this reason, you can run the same code (using JDBC abstractions) against different RDBMS, and only the JDBC driver (implementation) needs to change.
Added by RUI: <http://www.informit.com/articles/article.aspx?p=29302>
|
It isn't.
The Bridge pattern requires a concrete implementation of one API that maps to a concrete implementation of another API. It is rarely used: in fact I've used it exactly once in the 20+ years since the GoF book appeared, and I regretted that occasion.
JDBC provides abstract definitions of an API (interfaces) that are implemented by concrete implementations of the *same* API, and that in turn undertake network operations, rather than calling a different API.
However a Type 2 JDBC driver would internally be an example of the Bridge pattern. In this architecture the Java layer talks to a JNI layer which talks to a different C API probably already existing and provided by the vendor. This architecture was transitional and I doubt you will find an example now.
|
4,283,341 |
My attempt at a solution using the substitution method:
$$u=\sin^2x\\du=2\sin x\cos xdx\\du=2u^{\frac12}{(1-\sin^2x)}^{\frac12}dx\\du=2u^{\frac12}{(1-u)}^{\frac12}dx\\\int\_0^{2\pi}e^{\sin^2x}dx\\\int\_0^1e^{u}\frac{1}{2u^{\frac12}{(1-u)}^{\frac12}}du$$
I have no idea how to solve it.
thanks in advance.
|
2021/10/21
|
[
"https://math.stackexchange.com/questions/4283341",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/982935/"
] |
**1. Solution with contour integraton**
Do the following substitution
$$ \sin x = \frac{z-z^{-1}}{2i}$$
$$ dx = \frac{dz}{iz}$$
Hence
$$I= \int\_{0}^{2\pi} e^{\sin^2 x} dx = \frac{1}{i} \oint\_{|z|=1} \frac{e^{\left(\frac{z^2-1}{2iz}\right)^2}}{z} dz$$
Your integral become a contour integral around the unit complex circle in the poistive sense.
The function:
$$ f(z) = \frac{e^{\left(\frac{z^2-1}{2iz}\right)^2}}{z}$$
Has a singularity at the origin $z=0$. Hence:
$$I = \frac{1}{i} \oint\_{|z|=1} \frac{e^{\left(\frac{z^2-1}{2iz}\right)^2}}{z} dz = 2\pi \operatorname{Res}(f,0)$$
To find the residue expand the function in the Laurent series:
$$ e^{\left(\frac{z^2-1}{2z}\right)^2} = \sum\_{n=0}^{\infty} \left(\frac{z^2-1}{2iz}\right)^{2n} \frac{1}{n!}$$
$$ \left(z^2-1\right)^{2n} = \sum\_{j=0}^{2n} \binom{2n}{j} (-1)^{2n-j} z^{2j} $$
$$e^{\left(\frac{z^2-1}{2iz}\right)^2} = \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \sum\_{j=0}^{2n} \binom{2n}{j} \frac{(-1)^{n-j}z^{2j-2n}}{n!}$$
$$f(z) = \frac{e^{\left(\frac{z^2-1}{2z}\right)^2}}{z} = \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \sum\_{j=0}^{2n} \binom{2n}{j} \frac{(-1)^{n-j}z^{2j-2n-1}}{n!}$$
The residue is the coefficient of $ z^{2j-2n-1} = z^{-1} \Longrightarrow j=n $
$$\therefore \operatorname{ Res}(f,0) = \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \binom{2n}{n}\frac{1}{n!}$$
$$\boxed{I = 2\pi \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \binom{2n}{n}\frac{1}{n!}}$$
This sum converges to $\displaystyle 2\pi \sqrt{e}I\_{0}\left(\frac{1}{2}\right)$
**Update 1:**
I found a way to evaluate this last series:
Note
$$ \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \binom{2n}{n}\frac{1}{n!} = \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \frac{(2n)!}{n!^3 }$$
Now recall that
$$ (2n)! = (1)\_{2n}$$
where $(x)\_{n}=x(x+1)(x+2)\cdots(x+n-1)$ is the *rising factorial* or *Pochhammer polynomial*
Now using the duplication formula: $\displaystyle (x)\_{2n} = 4^n\left(\frac{x}{2}\right)\_{n}\left(\frac{x+1}{2}\right)\_{n}$ and the fact that $(1)\_{n} = n!$
We have
$$ (2n)! = (1)\_{2n} = 4^{n}\left(\frac{1}{2}\right)\_{n}(1)\_{n}$$
Hence
$$ \sum\_{n=0}^{\infty} \frac{1}{2^{2n}} \binom{2n}{n}\frac{1}{n!} = \sum\_{n=0}^{\infty} \frac{4^{n}\left(\frac{1}{2}\right)\_{n}(1)\_{n}}{2^{2n} (1)\_{n}(1)\_{n} n!} = \sum\_{n=0}^{\infty} \frac{ \left(\frac{1}{2}\right)\_{n}}{(1)\_{n}}\frac{1}{n!} ={}\_1F\_{1}\left(\frac{1}{2};1;1\right)$$
Using the identity 3 of Generalization of Kummer's transformations [here](https://en.wikipedia.org/wiki/Generalized_hypergeometric_function#Kummer%27s_relation)
$$e^{-\frac x 2} \, {}\_1F\_1(a,2a,x)= {}\_0F\_1 \left (;a+\tfrac 1 2; \tfrac{x^2}{16} \right ) \tag{\*}$$
with $\displaystyle x= 1$ and $\displaystyle a= \frac{1}{2}$
$${}\_1F\_{1}\left(\frac{1}{2};1;1\right) = \sqrt{e} \;{}\_0F\_{1}(;1,\frac{1}{16})$$
But $\displaystyle \sqrt{e}\; {}\_0F\_{1}(;1,\frac{1}{16})$ is the hypergometric representation of $\displaystyle I\_{0}\left(\frac{1}{2}\right)$:
$$ {}\_{0}F\_{1}(;1,\frac{1}{16}) = \sum\_{n=0}^{\infty} \frac{1}{4^{2n}n!^2} = I\_{0}\left(\frac{1}{2}\right)$$
Therefore
$$\boxed{ I =\int\_{0}^{2\pi} e^{\sin^2 x} dx= 2\pi \sqrt{e} \; I\_{0}\left(\frac{1}{2}\right) }$$
**2. Solution using the complete beta function(Update 2)**
Let $n\in \mathbb{N}$.
Recall:
$$\int\_{0}^{2\pi} \sin^{2n}\theta d\theta= 4\int\_{0}^{\frac{\pi}{2}} \sin^{2n}\theta d\theta \stackrel{w=\cos\theta}{=} 4\int\_{0}^{1} w^{2n}(1-w^2)^{-\frac{1}{2}}dw \stackrel{r=w^2}{=}2\int\_{0}^{1} r^{n+\frac{1}{2}-1}(1-r)^{\frac{1}{2}-1}dr = 2B\left(n+\frac{1}{2},\frac{1}{2}\right) = \frac{2\Gamma\left(n+\frac{1}{2}\right)\sqrt{\pi}}{\Gamma(n+1)} = \frac{2\pi}{2^{2n}}\binom{2n}{n}$$
Therefore:
$$\int\_{0}^{2\pi} \sin^{2n}\theta d\theta =\frac{2\pi}{2^{2n}}\binom{2n}{n}$$
Summing both sides of the equation:
$$\sum\_{n=0}^{\infty}\frac{1}{n!}\int\_{0}^{2\pi} \sin^{2n}\theta d\theta = 2\pi \sum\_{n=0}^{\infty}\frac{1}{2^{2n}n!}\binom{2n}{n}$$
Applying the Fubini-Tonelli theorem in the left hand side we can interchange series and integral sign:
$$\int\_{0}^{2\pi} \sum\_{n=0}^{\infty}\frac{\sin^{2n} \theta}{n!} d\theta = 2\pi \sum\_{n=0}^{\infty}\frac{1}{2^{2n}n!}\binom{2n}{n}$$
$$\Longrightarrow \int\_{0}^{2\pi} e^{\sin^2\theta}d\theta = 2\pi \sum\_{n=0}^{\infty}\frac{1}{2^{2n}n!}\binom{2n}{n}$$
Applying the identity (\*) from above
$$\boxed{ I =\int\_{0}^{2\pi} e^{\sin^2 x} dx= 2\pi \sqrt{e} \; I\_{0}\left(\frac{1}{2}\right) }$$
|
According to Wolfram, it is
$$\int\_{0}^{2\pi} e^{[\sin x]^2}\ dx = 2\sqrt{e} \pi I\_0\left(\frac{1}{2}\right)$$
I think there isn't really a good "trick" for this beyond just recognizing that the modified Bessel functions have well-known integral identities involving integrands of a broadly similar shape in that they involve $e^{\cos x}$, so one should then try to mash them to see if one can get something to come out. Namely,
$$I\_\alpha(x) = \frac{1}{\pi} \int\_{0}^{\pi} e^{x \cos \theta} \cos \alpha \theta\ d\theta - \frac{\sin \alpha \pi}{\pi} \int\_{0}^{\infty} e^{-x \cosh t - \alpha t}\ dt$$
is a "known quantity" in that it's published already, and note that if one takes $\alpha = 0$, the right-hand term dies and the left becomes
$$I\_0(x) = \frac{1}{\pi} \int\_{0}^{\pi} e^{x \cos \theta} d\theta$$
hence use the half-angle formula $[\sin x]^2 = \frac{1 - \cos 2x}{2}$ so
$$\int\_{0}^{2\pi} e^{[\sin x]^2}\ dx = \int\_{0}^{2\pi} e^{\frac{1 - \cos 2x}{2}}\ dx = \int\_{0}^{2 \pi} e^{1/2} e^{-\frac{1}{2} \cos{2x}}\ dx = \sqrt{e} \int\_{0}^{2\pi} e^{-\frac{1}{2} \cos 2x}\ dx$$
then you should be able to take it from there with scalings.
|
504,760 |
please help with this.
I found this in textbook.
Not derived from any differential equation.
Also found the answer $$ \frac{1}{\sqrt{\pi}\sqrt{t}} + e^t \* erf(\sqrt{t}) $$
(but don't know how)
|
2013/09/25
|
[
"https://math.stackexchange.com/questions/504760",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/48255/"
] |
$$\frac{1}{\sqrt{s}-1}=\frac{\sqrt{s}+1}{s-1}=\frac{\sqrt{s}}{s-1}+\frac{1}{s-1}=\frac{s}{\sqrt{s}(s-1)}+\frac{1}{s-1}=\frac{1}{\sqrt{s}(s-1)}+\frac{1}{\sqrt{s}}+\frac{1}{s-1}$$
And we know that $$\mathcal{L}(\text{erf}(\sqrt{t}))=\frac{1}{s\sqrt{s+1}},~\mathcal{L}(e^{at}f(t))=\mathcal{L}(f(t))|\_{s\to s-1},~\mathcal{L}\left(\frac{1}{\sqrt{t}}\right)=\sqrt{\frac{\pi}{s}}$$
|
Start from Babak's observation that
$$\frac{1}{\sqrt{s}-1} = \frac{\sqrt{s}}{s-1} + \frac{1}{s-1}$$
The ILT of the second term is simply $e^t$. For the first term, consider the following integral:
$$\oint\_C dz \,e^{z t} \frac{\sqrt{z}}{z-1}$$
where $C$ is as follows:

We will define $\text{Arg}{z} \in (-\pi,\pi]$, so the branch is the negative real axis. There are $6$ pieces to this contour, $C\_k$, $k \in \{1,2,3,4,5,6\}$, as follows.
$C\_1$ is the contour along the line $z \in [c-i R,c+i R]$ for some large value of $R$.
$C\_2$ is the contour along a circular arc of radius $R$ from the top of $C\_1$ to just above the negative real axis.
$C\_3$ is the contour along a line just above the negative real axis between $[-R, -\epsilon]$ for some small $\epsilon$.
$C\_4$ is the contour along a circular arc of radius $\epsilon$ about the origin.
$C\_5$ is the contour along a line just below the negative real axis between $[-\epsilon,-R]$.
$C\_6$ is the contour along the circular arc of radius $R$ from just below the negative real axis to the bottom of $C\_1$.
We will show that the integral along $C\_2$,$C\_4$, and $C\_6$ vanish in the limits of $R \rightarrow \infty$ and $\epsilon \rightarrow 0$.
On $C\_2$, the real part of the argument of the exponential is
$$R t \cos{\theta} $$
where $\theta \in [\pi/2,\pi)$. Clearly, $\cos{\theta} < 0$, so that the integrand exponentially decays as $R \rightarrow \infty$ and therefore the integral vanishes along $C\_2$.
On $C\_6$, we have the same thing, but now $\theta \in (-\pi,-\pi/2]$. This means that, due to the evenness of cosine, the integrand exponentially decays again as $R \rightarrow \infty$ and therefore the integral also vanishes along $C\_6$.
On $C\_4$, the integral vanishes as $\epsilon$ in the limit $\epsilon \rightarrow 0$. Thus, we are left with the following by the residue theorem:
$$\left [ \int\_{C\_1} + \int\_{C\_3} + \int\_{C\_5}\right] dz \: \frac{\sqrt{z}}{z-1} e^{z t} = i 2 \pi \, e^t$$
because of the pole at $z=1$.
On $C\_3$, we parametrize by $z=e^{i \pi} x$ and the integral along $C\_3$ becomes
$$\int\_{C\_3} dz \: \frac{\sqrt{z}}{z-1} e^{z t} = \int\_{\infty}^0 dx \: \frac{i \sqrt{x}}{x+1} e^{-x t}$$
On $C\_5$, however, we parametrize by $z=e^{-i \pi} x$ and the integral along $C\_5$ becomes
$$\int\_{C\_5} dz \: \frac{\sqrt{z}}{z-1} e^{z t} = \int\_0^{\infty} dx \: \frac{-i \sqrt{x}}{x+1} e^{-x t}$$
We may now write
$$\frac{1}{i 2 \pi} \int\_{c-i \infty}^{c+i \infty} ds \:\frac{\sqrt{s}}{s-1} e^{s t} = e^t + \frac{1}{\pi} \int\_0^{\infty} dx \frac{\sqrt{x}}{x+1} e^{-x t}$$
Now consider the integral on the RHS:
$$ \begin{align}\int\_0^{\infty} dx \frac{\sqrt{x}}{x+1} e^{-x t} &= \int\_{-\infty}^{\infty} du \frac{u^2}{1+u^2} e^{-t u^2}\\ &=\int\_{-\infty}^{\infty} du e^{-t u^2} -\int\_{-\infty}^{\infty} du \frac{1}{1+u^2} e^{-t u^2}\\ &= \sqrt{\frac{\pi}{t}} - \pi \,e^t \, \text{erfc}{\sqrt{t}}\end{align}$$
Putting this all together, we get
$$\frac{1}{\sqrt{\pi t}} + e^t \text{erf}{\sqrt{t}} + e^t = \frac{1}{\sqrt{\pi t}} + e^t (1+\text{erf}{\sqrt{t}})$$
Your answer is missing an $e^t$.
|
13,252,629 |
I've implemented the yii-user module in a new php project and everything works fine. But when i register, the program should sent an activation email , but when i press the register button i get the following error:
>
> mail() [function.mail]: Failed to connect to mailserver at >"localhost" port 25, verify your "SMTP" and "smtp\_port" setting >in php.ini or use ini\_set()
>
>
>
I've searched and i changed my ini file to:
```
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
```
But that didn't help.
How do i solve this
|
2012/11/06
|
[
"https://Stackoverflow.com/questions/13252629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803103/"
] |
It seems your problem is that Gmail is not an open relay, meaning it requires authentication with an account in order to accept outgoing mail. See the Gmail page [Problems sending mail](http://support.google.com/mail/bin/answer.py?hl=en&answer=78775). At the very least, you'll need to supply account information, and I don't see that in your example.
|
Check to see if your hosting services is blocking port 465
|
13,252,629 |
I've implemented the yii-user module in a new php project and everything works fine. But when i register, the program should sent an activation email , but when i press the register button i get the following error:
>
> mail() [function.mail]: Failed to connect to mailserver at >"localhost" port 25, verify your "SMTP" and "smtp\_port" setting >in php.ini or use ini\_set()
>
>
>
I've searched and i changed my ini file to:
```
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
```
But that didn't help.
How do i solve this
|
2012/11/06
|
[
"https://Stackoverflow.com/questions/13252629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803103/"
] |
It seems your problem is that Gmail is not an open relay, meaning it requires authentication with an account in order to accept outgoing mail. See the Gmail page [Problems sending mail](http://support.google.com/mail/bin/answer.py?hl=en&answer=78775). At the very least, you'll need to supply account information, and I don't see that in your example.
|
I solved it by just installing and running this little program : <http://smtp4dev.codeplex.com/>
This program sits in the system tray and does not deliver the received messages and the webapp runs just fine!
Thanks all for your help!
|
238,818 |
**Introduction:** Let's assume we have a 2-form $\alpha=(1/2)\sum\_{j,k=1}^n a\_{jk}\ e\_j\wedge e\_k$, where $n=2m$, and $a\_{jk}\in\mathbb C$. We know that $\alpha^{\wedge m}=\alpha\wedge\alpha\dots\wedge\alpha\ (m\ {\rm times}) = n!\ ({\rm Pf}\ A)\cdot e\_1\wedge\dots\wedge e\_n$, where ${\rm Pf}\ A$ is the Pfaffian of the matrix $A$ whose elements are $a\_{jk}$. In other words, if we need to calculate
$(\alpha^{\wedge m},I)$, where $(\cdot,\cdot)$ is the scalar product and $I=e\_1\wedge\dots\wedge e\_n$, then we can easily do that: it is $n!\ ({\rm Pf}\ A)$, and the Pfaffian of a matrix $A$ is easily computed numerically, in polynomial time, for large $n$.
**Question:** Now, I have two 2-forms: one is $\alpha$ defined above, and the other is $\beta=(1/2)\sum\_{j,k=1}^n b\_{jk}\ e\_j\wedge e\_k$. I want to calculate
$\alpha^{\wedge p}\wedge\beta^{\wedge m-p}$ for some $p$. What will be the coefficient in front of $I=e\_1\wedge\dots\wedge e\_n$? Can it be computed efficiently, say polynomially in $n$? In other words, how to numerically calculate $(\alpha^{\wedge p}\wedge\beta^{\wedge m-p},I)$ for some general skew-symmetric complex-valued matrices $A$ and $B$? What if I have not two, but $m$ 2-forms $\alpha\_1,\dots,\alpha\_m$, determined by the complex-valued matrices $A\_1\dots A\_m$, and we want to calculate ($\alpha\_1\wedge\alpha\_2\dots\wedge\alpha\_m,I)$? Is it something easily computable, like Pfaffian of a matrix in the introduction above? In general, the answer is no, but what if the matrices $A\_k$ are of low rank, say rank 4? (the case of rank 2 is trivial, since each form becomes a wedge product of two vectors)
Did someone study this, or saw some discussions about similar or related problems? Where can I try to find the information about such problems? I would appreciate any suggestion. I am not even sure what is the commonly used term for this coefficient.
**What I found so far**: in "Multilinear algebra" of W. Greub, the Pfaffian of skew-linear transformations is introduced (Ch. 8.4, Springer edition 1978) for several transformations. I.e. Greub starts as follows: $E$ is an inner product space of dimension $m=2n$, and $\phi\_1, \phi\_2,\dots \phi\_m$ are the skew-linear transformations. Each $\phi\_k$ determines an element $\Psi\_k\in \bigwedge^2 E$, so that $\Psi\_1\wedge\Psi\_2\wedge\dots\Psi\_m\in \bigwedge^n E$. Taking a basis vector $a\in E$, he defines ${\rm Pf}\_a(\phi\_1\dots\phi\_m) = (\Psi\_1\wedge\dots\wedge\Psi\_m, a)$. This is exactly what I need. Unfortunately, already in the next paragraph he switches to the standard case $\phi\_1=\phi\_2=\dots=\phi\_m=\phi$, which gives the standard answer for the Pfaffian of a matrix for $\Psi$, and does not discuss the case of different $\phi$'s anymore.
I would assume that people have studied this problem (or this is something simple, and I am just missing something obvious). I would be very grateful for help!
|
2016/05/14
|
[
"https://mathoverflow.net/questions/238818",
"https://mathoverflow.net",
"https://mathoverflow.net/users/91644/"
] |
For two 2-forms I can offer you a blueprint of an algorithm. Details would have to be filled in.
Consider two skewsymmetric $n\times n$-matrices $A$ and $B$. The task is to compute $\operatorname{Pf}(sA+tB)$ since this gives all $\alpha^p\wedge\beta^{m-p}$ simultaneously.
Let's assume first that $A$ is invertible. Then there is a skew-analogue of Gram-Schmidt (first detail to be filled in) which brings $A$ into some sort of diagonal form $J$. Let $Sp(n)$ be the symplectic group with respect to $J$.
Now transform $B$ using a symplectic base change to bring it into an analogue of a companion matrix (second detail to be filled in). This is possible since the $Sp(n)$ action on skewsymmetric matrices is a $\theta$-representation in the sense of Vinberg.
Now $\text{Pf}(sA+tB)$ is readily computable.
If $A$ is not invertible, change it to $A+cB$ for a suitable constant $c$. If no such $c$ exists, the Pfaffian is identically zero.
|
Since the two forms in the definition of "multilinear Pfaffian" commute one can use polarization and write down explicit formula. See e.g. (7) of <https://arxiv.org/abs/1309.1275> This formula, however, has $2^m$ terms.
|
347,221 |
I am a computer programmer and after a project with Image processing which runs on ARM Embedded system board. Specification says it needs 12V 1 Amp Supply. I have a computer SMPS which gives me 5v and 12v constant supply and rated as 450 watt. Also it is written it can draw upto 24A current so here I cam confused. Can this heavy amount of current burn my board ? Also I recall Ohm Law that if the v is constant then current will vary according to load. Please give me some right direction whether I can use PC PSU for my embedded works.
Thanks
|
2017/12/29
|
[
"https://electronics.stackexchange.com/questions/347221",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/173141/"
] |
The PSU rating just means that up to 24 A is available to be drawn from the 12 V supply. Your board will draw what it needs from the 12 V rail, up to 1 A from what you've said.
However, that means that the PSU will supply up to 24 A into an overload or short circuit from your board or 12 V connections coming out of it. The PSU protection will kick in shortly (something like 10's ms) after the overload is detected and either limit the output current to 24 A or most likely put the PSU into 'hiccup' mode, which you'll find details of on the interweb. This burst/ongoing 300+ W of power is quite likely to burn out tracks on your PCB.
So, in short, if you use it, be very careful not to let your board short-circuit the 12 V supply, otherwise you are very likely to damage that board.
|
Yes. But you shouldn't. An ATX power supply is for finished and tested products.
This supply is 24 times more powerful than your requirements. It also does not have any protections for prototype work. It only has protections for itself.
If you accidentally make a short, you will see sparks, flames and/or smoke. And you'll be replacing chips or getting new boards.
A much safer way to do this would be to use a lab power supply. With configurable voltage, current limit and even over current trip if you are feeling fancy.
Or, just the appropriate size wall wart if you're feeling cheap. But not an 2000% overrated ATX power supply.
|
347,221 |
I am a computer programmer and after a project with Image processing which runs on ARM Embedded system board. Specification says it needs 12V 1 Amp Supply. I have a computer SMPS which gives me 5v and 12v constant supply and rated as 450 watt. Also it is written it can draw upto 24A current so here I cam confused. Can this heavy amount of current burn my board ? Also I recall Ohm Law that if the v is constant then current will vary according to load. Please give me some right direction whether I can use PC PSU for my embedded works.
Thanks
|
2017/12/29
|
[
"https://electronics.stackexchange.com/questions/347221",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/173141/"
] |
The PSU rating just means that up to 24 A is available to be drawn from the 12 V supply. Your board will draw what it needs from the 12 V rail, up to 1 A from what you've said.
However, that means that the PSU will supply up to 24 A into an overload or short circuit from your board or 12 V connections coming out of it. The PSU protection will kick in shortly (something like 10's ms) after the overload is detected and either limit the output current to 24 A or most likely put the PSU into 'hiccup' mode, which you'll find details of on the interweb. This burst/ongoing 300+ W of power is quite likely to burn out tracks on your PCB.
So, in short, if you use it, be very careful not to let your board short-circuit the 12 V supply, otherwise you are very likely to damage that board.
|
The current is completely based on your load, so if you have a voltage source with maximum 24A current, it means based on the load that you are using it can provide currents from miliamps to maximum 24 amps. therefore if you need 24V and 1A there is no difference using a 24V-1A power supply or 24V-100A power supply.
**But**, if for any reason, like mechanical or electronic problems if you get short circuit on your board, with higher currents your board is definitely going to burn up, tracks on your PCB will be burned or even it might cause the board and wires to get in fire.
It is highly recommend to use a fuses when you are using high amperage power supply. you can use the wire fuses easily in the input voltage.
[](https://i.stack.imgur.com/E5Y05.jpg)
|
71,313,598 |
I encontered a problem when I test my project, any help would be greatly appreciated.
All my code can be found in here: <https://github.com/Karlus44/smartcontract-lottery>
When I type the command brownie test
my script tests/test\_lottery\_unit.py is exectuted, and my different tests are submitted.
Here some quotes of my logout:
```
Brownie v1.18.1 - Python development framework for Ethereum
```
================================== test session starts ===================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/karlus/Documents/NFT-Contract/smartcontract-lottery
plugins: eth-brownie-1.18.1, forked-1.4.0, web3-5.27.0, hypothesis-6.27.3, xdist-1.34.0
collected 4 items
Launching 'ganache-cli --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic br
ownie --port 8545'...
tests/test\_lottery\_unit.py ...F [100%]
======================================== FAILURES ========================================
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ test\_can\_end\_lottery \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
```
def test_can_end_lottery():
# Arrange
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip()
lottery = deploy_lottery()
account = get_account()
lottery.startLottery({"from": account})
lottery.enter({"from": account, "value":lottery.getEntranceFee()})
fund_with_link(lottery)
print(f"endlottery: {lottery.endLottery}")
```
>
>
> ```
> transaction = lottery.endLottery({"from": account})
>
> ```
>
>
E brownie.exceptions.VirtualMachineError: revert
E Trace step -1, program counter 2469:
E File "/home/karlus/.brownie/packages/smartcontractkit/chainlink-brownie-contract
[email protected]/contracts/src/v0.6/VRFConsumerBase.sol", line 161, in VRFConsumerBase.requestRando
mness:
E function requestRandomness(bytes32 \_keyHash, uint256 \_fee)
E internal returns (bytes32 requestId)
E {
E LINK.transferAndCall(vrfCoordinator, \_fee, abi.encode(\_keyHash, USER\_SEED\_PL
ACEHOLDER));
E // This is the seed passed to VRFCoordinator. The oracle will mix this with
E // the hash of the block containing this request to obtain the seed/input
E // which is finally passed to the VRF cryptographic machinery.
tests/test\_lottery\_unit.py:58: VirtualMachineError
tests/test\_lottery\_unit.py:58: VirtualMachineError
---------------------------------- Captured stdout call ----------------------------------
0x66aB6D9362d4F35596279692F0251Db635165871
Deployed lottery!
Fund contract!
endlottery: <ContractTx 'endLottery()'>
Transaction sent: 0x59a0a2fdf727591891380c80c0fd90329c8a11b527e24c07d33652b26dfd32c7
================================ short test summary info =================================
FAILED tests/test\_lottery\_unit.py::test\_can\_end\_lottery - brownie.exceptions.VirtualMac...
============================== 1 failed, 3 passed in 7.97s ===============================
Terminating local RPC client...
Linter
Severity Provider Description Line
So as you can see, my 3 first tests are correctly functionning, but my function fulfillRandomness doesn't seem to be called, and I can't figure why.
|
2022/03/01
|
[
"https://Stackoverflow.com/questions/71313598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13754843/"
] |
Check your `fund_with_link` function. Check the amount that you have mentioned. It must be `amount = 0.1 * 10**18`.
As mentioned here, <https://docs.chain.link/docs/vrf-contracts/v1/> , the fee for, say, Rinkeby test network is `0.1 LINK`.
|
If you're having a virtual machine check with your ganache port and IP in the settings of your Ethereum VM. If you're running `brownie-compile` and the code is working, then that's the issue.
|
71,313,598 |
I encontered a problem when I test my project, any help would be greatly appreciated.
All my code can be found in here: <https://github.com/Karlus44/smartcontract-lottery>
When I type the command brownie test
my script tests/test\_lottery\_unit.py is exectuted, and my different tests are submitted.
Here some quotes of my logout:
```
Brownie v1.18.1 - Python development framework for Ethereum
```
================================== test session starts ===================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/karlus/Documents/NFT-Contract/smartcontract-lottery
plugins: eth-brownie-1.18.1, forked-1.4.0, web3-5.27.0, hypothesis-6.27.3, xdist-1.34.0
collected 4 items
Launching 'ganache-cli --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic br
ownie --port 8545'...
tests/test\_lottery\_unit.py ...F [100%]
======================================== FAILURES ========================================
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ test\_can\_end\_lottery \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
```
def test_can_end_lottery():
# Arrange
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip()
lottery = deploy_lottery()
account = get_account()
lottery.startLottery({"from": account})
lottery.enter({"from": account, "value":lottery.getEntranceFee()})
fund_with_link(lottery)
print(f"endlottery: {lottery.endLottery}")
```
>
>
> ```
> transaction = lottery.endLottery({"from": account})
>
> ```
>
>
E brownie.exceptions.VirtualMachineError: revert
E Trace step -1, program counter 2469:
E File "/home/karlus/.brownie/packages/smartcontractkit/chainlink-brownie-contract
[email protected]/contracts/src/v0.6/VRFConsumerBase.sol", line 161, in VRFConsumerBase.requestRando
mness:
E function requestRandomness(bytes32 \_keyHash, uint256 \_fee)
E internal returns (bytes32 requestId)
E {
E LINK.transferAndCall(vrfCoordinator, \_fee, abi.encode(\_keyHash, USER\_SEED\_PL
ACEHOLDER));
E // This is the seed passed to VRFCoordinator. The oracle will mix this with
E // the hash of the block containing this request to obtain the seed/input
E // which is finally passed to the VRF cryptographic machinery.
tests/test\_lottery\_unit.py:58: VirtualMachineError
tests/test\_lottery\_unit.py:58: VirtualMachineError
---------------------------------- Captured stdout call ----------------------------------
0x66aB6D9362d4F35596279692F0251Db635165871
Deployed lottery!
Fund contract!
endlottery: <ContractTx 'endLottery()'>
Transaction sent: 0x59a0a2fdf727591891380c80c0fd90329c8a11b527e24c07d33652b26dfd32c7
================================ short test summary info =================================
FAILED tests/test\_lottery\_unit.py::test\_can\_end\_lottery - brownie.exceptions.VirtualMac...
============================== 1 failed, 3 passed in 7.97s ===============================
Terminating local RPC client...
Linter
Severity Provider Description Line
So as you can see, my 3 first tests are correctly functionning, but my function fulfillRandomness doesn't seem to be called, and I can't figure why.
|
2022/03/01
|
[
"https://Stackoverflow.com/questions/71313598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13754843/"
] |
Check your `fund_with_link` function. Check the amount that you have mentioned. It must be `amount = 0.1 * 10**18`.
As mentioned here, <https://docs.chain.link/docs/vrf-contracts/v1/> , the fee for, say, Rinkeby test network is `0.1 LINK`.
|
Check whether the fee you have entered in brownie-config.yaml is 0.1 LINK. This should solve the problem.
|
22,965,513 |
I have a form that I want to validate using JQuery.
When the user leaves the form field without entering anything the class of that input changes to show an error by becoming red.
I have created a jsfiddle file
<http://jsfiddle.net/mTCvk/>
The problem I am having is that the it will only work on the first text input and the other text inputs will adjust according to the state of the first input.
The JQuery
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Here is the HTML for the form
```
<form method="post" action="">
<div class="text-input">
<img src="images/name.png">
<input type="text" name="name" placeholder="*Name:">
</div>
<div class="text-input">
<img src="images/mail.png">
<input type="text" name="email" placeholder="*Email:">
</div>
<div class="text-input">
<img src="images/pencil.png">
<input type="text" name="subject" placeholder="*Subject:">
</div>
<div class="text-input">
<img src="images/phone.png">
<input type="text" name="phone" placeholder="Phone Number:">
</div>
<textarea name="message" placeholder="*Message:"></textarea>
<input type="submit" value="Send" class="submit">
```
|
2014/04/09
|
[
"https://Stackoverflow.com/questions/22965513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078385/"
] |
It's a DOM issue. It needs to check the `:text` child for that specific element
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(this).find(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Updated Fiddle <http://jsfiddle.net/mTCvk/2/>
|
It's easy, you have selected the first input type text found : `$(":text").val()`.. You must select the input type type on the .text-input blured :
```
$(":text", $(this)).val()... // First :text, on $(this) parent
```
<http://jsfiddle.net/mTCvk/1/>
PS : for your class management, don't delete .text-input juste add and remove an other class .text-input-error when you have an error
|
22,965,513 |
I have a form that I want to validate using JQuery.
When the user leaves the form field without entering anything the class of that input changes to show an error by becoming red.
I have created a jsfiddle file
<http://jsfiddle.net/mTCvk/>
The problem I am having is that the it will only work on the first text input and the other text inputs will adjust according to the state of the first input.
The JQuery
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Here is the HTML for the form
```
<form method="post" action="">
<div class="text-input">
<img src="images/name.png">
<input type="text" name="name" placeholder="*Name:">
</div>
<div class="text-input">
<img src="images/mail.png">
<input type="text" name="email" placeholder="*Email:">
</div>
<div class="text-input">
<img src="images/pencil.png">
<input type="text" name="subject" placeholder="*Subject:">
</div>
<div class="text-input">
<img src="images/phone.png">
<input type="text" name="phone" placeholder="Phone Number:">
</div>
<textarea name="message" placeholder="*Message:"></textarea>
<input type="submit" value="Send" class="submit">
```
|
2014/04/09
|
[
"https://Stackoverflow.com/questions/22965513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078385/"
] |
It's a DOM issue. It needs to check the `:text` child for that specific element
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(this).find(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Updated Fiddle <http://jsfiddle.net/mTCvk/2/>
|
You can use this:
```
$(":text").focusout(function () {
if ($(this).val().length == 0) {
$(this).parent().removeClass("text-input").addClass("text-input-error");
} else {
$(this).parent().removeClass("text-input-error").addClass("text-input");
}
});
```
|
22,965,513 |
I have a form that I want to validate using JQuery.
When the user leaves the form field without entering anything the class of that input changes to show an error by becoming red.
I have created a jsfiddle file
<http://jsfiddle.net/mTCvk/>
The problem I am having is that the it will only work on the first text input and the other text inputs will adjust according to the state of the first input.
The JQuery
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Here is the HTML for the form
```
<form method="post" action="">
<div class="text-input">
<img src="images/name.png">
<input type="text" name="name" placeholder="*Name:">
</div>
<div class="text-input">
<img src="images/mail.png">
<input type="text" name="email" placeholder="*Email:">
</div>
<div class="text-input">
<img src="images/pencil.png">
<input type="text" name="subject" placeholder="*Subject:">
</div>
<div class="text-input">
<img src="images/phone.png">
<input type="text" name="phone" placeholder="Phone Number:">
</div>
<textarea name="message" placeholder="*Message:"></textarea>
<input type="submit" value="Send" class="submit">
```
|
2014/04/09
|
[
"https://Stackoverflow.com/questions/22965513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078385/"
] |
It's a DOM issue. It needs to check the `:text` child for that specific element
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(this).find(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Updated Fiddle <http://jsfiddle.net/mTCvk/2/>
|
Use following code....
```
$('.text-input, .text-input-error').focusout(function () {
if ($(this).find(':text').val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
```
|
22,965,513 |
I have a form that I want to validate using JQuery.
When the user leaves the form field without entering anything the class of that input changes to show an error by becoming red.
I have created a jsfiddle file
<http://jsfiddle.net/mTCvk/>
The problem I am having is that the it will only work on the first text input and the other text inputs will adjust according to the state of the first input.
The JQuery
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Here is the HTML for the form
```
<form method="post" action="">
<div class="text-input">
<img src="images/name.png">
<input type="text" name="name" placeholder="*Name:">
</div>
<div class="text-input">
<img src="images/mail.png">
<input type="text" name="email" placeholder="*Email:">
</div>
<div class="text-input">
<img src="images/pencil.png">
<input type="text" name="subject" placeholder="*Subject:">
</div>
<div class="text-input">
<img src="images/phone.png">
<input type="text" name="phone" placeholder="Phone Number:">
</div>
<textarea name="message" placeholder="*Message:"></textarea>
<input type="submit" value="Send" class="submit">
```
|
2014/04/09
|
[
"https://Stackoverflow.com/questions/22965513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078385/"
] |
It's a DOM issue. It needs to check the `:text` child for that specific element
```
$(document).ready(function(){
$('.text-input').focusout(function () {
if ($(this).find(":text").val().length == 0) {
$(this).removeClass("text-input").addClass("text-input-error");
} else {
$(this).removeClass("text-input-error").addClass("text-input");
}
});
});
```
Updated Fiddle <http://jsfiddle.net/mTCvk/2/>
|
I changed your code to use the .on method, and gave it the event blur. Then we create a variable for the closest text-input class (which would be its parent text-input div). Rather than checking the .length, we just check to see if it is an empty string. You would also need to wrap your textarea in the save text-input div for this to work properly.
<http://jsfiddle.net/43e2Q/>
```
$('input, textarea').on('blur', function () {
var $closestParent = $(this).parent();
if ($(this).val() == '') {
$closestParent.removeClass("text-input").addClass("text-input-error");
console.log('error');
} else {
$closestParent.removeClass("text-input-error").addClass("text-input");
console.log('valid');
}
});
```
|
16,459,537 |
I'm currently using jQuery to animate the resizing of a banner.
There's a div button that does this upon clicking.
What I'm trying to do is get the button to change its text from "hide banner" to "show banner" depending
```
<div id="banner_animate" class="banner">
<div id="minimize" class="small_button">hide banner</div>
<script>
$("#minimize").click(function() {
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500 );
});
$(function() {
$( document ).tooltip();
});
</script>
```
I'm pretty new to jQuery, so any help would be greatly appreciated!
|
2013/05/09
|
[
"https://Stackoverflow.com/questions/16459537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
in your `$("#minimize").click` you can use `$(this).text()`:
```
$("#minimize").click(function() {
if ($(this).text() == 'hide banner') {
$("#banner_animate").animate({height: "40px"}, 500);
$(this).text('show banner');
} else {
$("#banner_animate").animate({height: "200px"}, 500);
$(this).text('hide banner');
}
});
```
<http://api.jquery.com/text/>
|
Try this:
```
$("#minimize").click(function () {
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500);
$(this).text(function (_, oldText) {
return oldText === 'Hide banner' ? 'Show banner' : 'Hide banner';
});
});
```
Also, change the HTML to show banner at first like:
```
<div id="minimize" class="small_button">Show banner</div>
```
[**FIDDLE DEMO**](http://jsfiddle.net/VksZJ/)
|
16,459,537 |
I'm currently using jQuery to animate the resizing of a banner.
There's a div button that does this upon clicking.
What I'm trying to do is get the button to change its text from "hide banner" to "show banner" depending
```
<div id="banner_animate" class="banner">
<div id="minimize" class="small_button">hide banner</div>
<script>
$("#minimize").click(function() {
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500 );
});
$(function() {
$( document ).tooltip();
});
</script>
```
I'm pretty new to jQuery, so any help would be greatly appreciated!
|
2013/05/09
|
[
"https://Stackoverflow.com/questions/16459537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
in your `$("#minimize").click` you can use `$(this).text()`:
```
$("#minimize").click(function() {
if ($(this).text() == 'hide banner') {
$("#banner_animate").animate({height: "40px"}, 500);
$(this).text('show banner');
} else {
$("#banner_animate").animate({height: "200px"}, 500);
$(this).text('hide banner');
}
});
```
<http://api.jquery.com/text/>
|
```
$("#minimize").click(function() {
if($(this).html()=="hide banner"){
$(this).html("show");
}
else {
$(this).html("hide banner");
}
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500 );
});
$(function() {
$( document ).tooltip();
});
```
[Fiddle Demo](http://jsfiddle.net/T9ypy/)
|
16,459,537 |
I'm currently using jQuery to animate the resizing of a banner.
There's a div button that does this upon clicking.
What I'm trying to do is get the button to change its text from "hide banner" to "show banner" depending
```
<div id="banner_animate" class="banner">
<div id="minimize" class="small_button">hide banner</div>
<script>
$("#minimize").click(function() {
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500 );
});
$(function() {
$( document ).tooltip();
});
</script>
```
I'm pretty new to jQuery, so any help would be greatly appreciated!
|
2013/05/09
|
[
"https://Stackoverflow.com/questions/16459537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Try this:
```
$("#minimize").click(function () {
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500);
$(this).text(function (_, oldText) {
return oldText === 'Hide banner' ? 'Show banner' : 'Hide banner';
});
});
```
Also, change the HTML to show banner at first like:
```
<div id="minimize" class="small_button">Show banner</div>
```
[**FIDDLE DEMO**](http://jsfiddle.net/VksZJ/)
|
```
$("#minimize").click(function() {
if($(this).html()=="hide banner"){
$(this).html("show");
}
else {
$(this).html("hide banner");
}
var new_height = 200;
if ($("#banner_animate").height() == 200) new_height = 40;
$("#banner_animate").animate({
height: new_height + "px"
}, 500 );
});
$(function() {
$( document ).tooltip();
});
```
[Fiddle Demo](http://jsfiddle.net/T9ypy/)
|
23,233,470 |
According to [this](https://github.com/clojure-emacs/cider):
>
> The built-in completion logic in CIDER relies on the library clojure-complete, so you'll have to have it your classpath for completion to work. If you're connecting to an nREPL server started from lein (e.g. you invoked M-x cider-jack-in) - there's nothing for you to do.
>
>
>
So -- I'm using an nREPL jack in with Emacs 24.3, so I would guess that there is "nothing for me to do." However, I am not getting any autocompletion in my Clojure source files.
I uninstalled and reinstalled Cider via Elpa to be safe. Apparently it is not necessary to manually install any other autocompletion packages from what I've read, but I must admit that getting autocompletion to work seems to be quite a task, can anyone point out what I'm missing?
|
2014/04/23
|
[
"https://Stackoverflow.com/questions/23233470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3758484/"
] |
Check whether you have `php5-curl` installed
```
dpkg -l | grep 'php5-curl'
```
If isn't installed,
```
apt-get install php5-curl
```
Ensure the path in `extension_dir` exists, and contains curl.so, if not, change to the correct path.
```
php -i | grep extension_dir
```
Ensure the `/etc/php5/mods-available/curl.ini` exists and has the curl.so loaded
```
; configuration for php CURL module
; priority=20
extension=curl.so
```
If everything is correct, restart PHP-FPM
```
/etc/init.d/php5-fpm restart
```
|
To enable curl on Windows uncomment
```
;extension=php_curl.dll
;to
extension=php_curl.dll
```
|
458,965 |
Suppose I have an environment where there isn't a shell running, so I can't use redirection, pipes, here-documents or other shell-isms, but I *can* launch a command (through [`execvp`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html) or some similar way). I want to write an arbitrary string to a named file. Is there a standard command that will do something like:
```
somecommand outputfile 'string'
```
for instance:
```
somecommand /proc/sys/net/ipv4/ip_forward '1'
```
A really dumb example might be:
```
curl -o /proc/sys/net/ipv4/ip_forward http://example.com/1.txt
```
where I set up 1.txt to contain the string I want.
Is there a common command that can be abused to do this?
|
2018/07/27
|
[
"https://unix.stackexchange.com/questions/458965",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/157128/"
] |
If you know of any other non-empty file on the system, then with [POSIX `sed`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html):
```
sed -e 's/.*/hello world/' -e 'wtarget' -e q otherfile
```
With GNU `sed` and just your own non-empty file, you can use:
```
sed -i.bak -e '$ihello world' -e 'd' foo
```
With BSD `sed`, this would work instead:
```
sed -i.bak -e '$i\
hello world' -e d foo
```
If you're not using a shell then presumably the linebreak isn't an issue.
---
[With `ex`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40_12), if the target file exists:
```
ex -c '0,$d' -c 's/^/hello world/' -c 'x' foo
```
This just deletes everything in the file, replaces the first line with "hello world", then writes and quits. You could do the same thing with `vi` in place of `ex`. Implementations are not required to support multiple `-c` options, but they generally do. For many `ex` implementations the requirement that the file already exist is not enforced.
---
Also [with `awk`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html):
```
awk -v FN=foo -v STR="hello world" 'BEGIN{printf(STR) > FN }'
```
will write "hello world" to file "foo".
---
If there are existing files containing the bytes you want at known locations, you can assemble a file byte by byte over multiple commands with `dd` (in this case, `alphabet` contains the alphabet, but it could be a mix of input files):
```
dd if=alphabet bs=1 skip=7 count=1 of=test
dd if=alphabet bs=1 skip=4 count=1 seek=1 of=test
dd if=alphabet bs=1 skip=11 count=1 seek=2 of=test
dd if=alphabet bs=1 skip=11 count=1 seek=3 of=test
dd if=alphabet bs=1 skip=14 count=1 seek=4 of=test
cat test
hello
```
From there, just regular `cp` will work, or you might have been able to put it in-place to start with.
---
Less commonly, [the `mispipe` command from moreutils](https://joeyh.name/code/moreutils/) allows constructing a shell-free pipe:
```
mispipe "echo 1" "tee wtarget"
```
is equivalent to `echo 1 | tee wtarget`, but returning the exit code of `echo`. This uses [the `system()` function](http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html) internally, which doesn't *strictly* require a shell to exist.
---
Finally, `perl` is a common command and will let you write arbitrary programs to do whatever you want on the command line, as will `python` or any other common scripting language. Similarly, if a shell just isn't "running", but it does exist, `sh -c 'echo 1 > target'` will work just fine.
|
You could use `awk`:
```
awk 'BEGIN {print "Hello" > "/tmp/file"}'
```
When an `awk` program consists of only a `BEGIN` statement, it just interprets that statement and doesn't process any input.
You can even parameterise this
```
awk -v text="World" -v file="/tmp/main" 'BEGIN {print text > file}'
```
Though with that syntax, you'd need to escape backslash characters. Using `ARGV` doesn't have the problem:
```
awk 'BEGIN {print ARGV[1] > ARGV[2]}' World /tmp/main
```
|
6,516,472 |
I'm looking for something like `format()` in other programming languages in MySQL query. The expected result is text that has values from other fields.
For example, something like
`select formatted from table where formatted=stringformat('some text {0}, {1} some text.', field1, field2)`
|
2011/06/29
|
[
"https://Stackoverflow.com/questions/6516472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300528/"
] |
how about:
```
SELECT CONCAT('some text ', field1, ', ', field2, ' some text.') FROM table;
```
|
### create a column in query and give it any alias to get result in. see this example.
SELECT ('some text, ' + tb.Col1 + ', ' + tb.Col2) AS ColName
FROM
MyTable tb
|
51,354,074 |
I have the GridView like
[](https://i.stack.imgur.com/Y4jgC.png)
i choose one row and show up menu edit, when i edit the selected row.
How i get cell coloumn "Ket" focused and enable to edit that like :
[](https://i.stack.imgur.com/bfRAg.png)
Please help me to prepare that, thank you...
|
2018/07/16
|
[
"https://Stackoverflow.com/questions/51354074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8283027/"
] |
The actual commit message states
>
> **Implement @\_downgrade\_exhaustivity\_check**
>
>
> Dispatch requests the ability to add a new case, but to treat missing
> instances of that case in patterns as warnings instead of errors. It
> is still an error to make reference to the annotated case in at least
> one pattern then not cover the rest of the space, but it is not an
> error to omit the space of patterns referencing the case entirely.
>
>
> This attribute is private and uglified to intentionally discourage its
> use outside just this one use case.
>
>
>
Source <https://git.snooey.net/Mirrors/swift/commit/03527d9eec65324434011d23219e2bf7525642c6>
|
It looks to me like the idea is that if you have a switch on a DispatchTimeInterval and you omit the `never` case, you get a warning instead of a compile error.
|
735,245 |
When setting up a new Ubuntu 14 PC for a Standard User using a local System Admin account, I’ve used the following command in order to make their password expire after 30 days:
```
sudo chage –M 30 [username]
```
However, upon expiry you can’t seem to change it from the login screen. Whatever you enter, no matter how strong or random, results in **incorrect password** or **password not strong enough** errors. The only way round it is to log on as System Admin and change the password there.
Does anyone know how to make it work for the Standard User from the login screen, so the System Admin doesn’t need to get involved?
I've noticed that there is a bug documented here: <https://bugs.launchpad.net/ubuntu/+source/unity-control-center/+bug/1318199> which seems to focus on the password not being strong enough and that the GUI works differently to a shell using `passwd`. However, when the password expires I don't see a strength meter so not sure whether it's related.
The version I'm installing is Ubuntu 14.04 with all the latest updates.
Thanks in advance,
Adam.
|
2016/02/16
|
[
"https://askubuntu.com/questions/735245",
"https://askubuntu.com",
"https://askubuntu.com/users/507329/"
] |
Open Software & Updates,
[](https://i.stack.imgur.com/HhIvB.png)
Click *other software tab*,
[](https://i.stack.imgur.com/i65J9.png)
Uncheck **<http://ppa.launchpad.net/upubuntu-com/web/ubuntu/> trusty main** under other softwares tab and close it.
Now you can update(`sudo apt-get update`).
|
There are no package for trusty in the upubuntu.com web repository:
on the command line you can switch it of by
```
sudo apt-add-repository --remove ppa:upubuntu-com/web
sudo apt-get update
```
See [Upubuntu Launchpad dists](http://ppa.launchpad.net/upubuntu-com/web/ubuntu/dists)
only natty, oneiric, precise and quantal is published
|
38,334 |
Let's take a hypothetical sentence pronounced by a hypothetical person who speaks, say, of events that are more than 100 years in the past:
>
> "The civil war period was very violent. In those days, you **could have been killed** for any trifle."
>
>
>
Would this sentence be grammatical and logical if both the speaker and the listener were born after the civil war in question, meaning there was not a chance for any of them to witness *those days*?
I've looked up Google, and "*those days you could have been*" turned out to be a rare combination for some reason.
But *"In those days you **could be** killed"* is possibly wrong when talking of the past.
I'm trying to proofread an [English-language post written by a Russian-speaking person](http://lang-8.com/1001060/journals/316719950558392889475961063287548762764) and untangle the grammar behind some of the structures. His sentence runs like this:
>
> There was very dangerous at that times because **you would be looted**, taken a beating and even gone home in a box...
>
>
>
I'd come up with this "could have been" instead of his "you would be looted, beaten.." but then had second thoughts. Maybe "could be" is proper. Or should one use "you were likely to be looted"?
Here's one [sentence I've found](http://books.google.ru/books?id=BS8_EC8lnkcC&lpg=PA155&ots=uhKLdbm7VO&dq=%22those%20days%20you%20could%20be%22&hl=ru&pg=PA155#v=onepage&q=%22those%20days%20you%20could%20be%22&f=false) at Google Books:
>
> As I stated before, in those days, you **could be** an Instructor as a Private Pilot, but there was not much of a practical use for having one because you couldn't charge for your services.
>
>
>
It seems that **could be** works fine as the past form of **can**. But will it work in:
>
> As I stated before, in those days, you **could be killed** easily.
>
>
>
|
2014/11/02
|
[
"https://ell.stackexchange.com/questions/38334",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2127/"
] |
There are two situations here: A. Hypothetical B. Reality
In hypothetical situations, you do not exist or you did not exist. Like in your example, the person to whom you are speaking to was not there in the civil war times - So your sentence
>
> "In those days you could be killed" is actually correct.
>
>
>
**'Could have been' is only used in 'Real situations.'**
For example:
>
> 1. He got away from burning car before it exploded.
>
>
>
Here we can say:
He was lucky to have gotten away from that burning car in time. He could have been killed.
(Here '**could be**' can't be used)
Another example :
Suppose I say
>
> 2. I could be a pilot in world war two.
>
>
>
This means that 'i was not there in world war two, because it's a hypothetical situation. But
>
> 3. I could have been a pilot in world war two.
>
>
>
means that i was there in world war two, (maybe as a soldier) but i did not get a chance to become a pilot.
**Note - the use of 'could have been' here makes it a real situation and it's no longer a hypothetical situation.** So to sum it up:
1. If you are making a hypothetical statement then use 'could be'
2. If you are making a reality statement then use 'could have been.'
|
CORRECT: Back then, you (or one) could be killed for any trifle.
>
> There was very dangerous at that times because you would be looted,
> taken a beating and even gone home in a box...
>
>
>
**It was very dangerous in those times; you could be robbed, beaten, or even sent home in a box.**
"could have been killed" would mean that, at some point in the past, a situation arose where the danger was great enough to result in death, but death did not occur.
**Why did you jaywalk across the busy street at rush hour? You could have been killed!**
**Twenty years ago, there was no pedestrian crossing or traffic signal at this busy location. You could be killed trying to cross the street.**
|
38,334 |
Let's take a hypothetical sentence pronounced by a hypothetical person who speaks, say, of events that are more than 100 years in the past:
>
> "The civil war period was very violent. In those days, you **could have been killed** for any trifle."
>
>
>
Would this sentence be grammatical and logical if both the speaker and the listener were born after the civil war in question, meaning there was not a chance for any of them to witness *those days*?
I've looked up Google, and "*those days you could have been*" turned out to be a rare combination for some reason.
But *"In those days you **could be** killed"* is possibly wrong when talking of the past.
I'm trying to proofread an [English-language post written by a Russian-speaking person](http://lang-8.com/1001060/journals/316719950558392889475961063287548762764) and untangle the grammar behind some of the structures. His sentence runs like this:
>
> There was very dangerous at that times because **you would be looted**, taken a beating and even gone home in a box...
>
>
>
I'd come up with this "could have been" instead of his "you would be looted, beaten.." but then had second thoughts. Maybe "could be" is proper. Or should one use "you were likely to be looted"?
Here's one [sentence I've found](http://books.google.ru/books?id=BS8_EC8lnkcC&lpg=PA155&ots=uhKLdbm7VO&dq=%22those%20days%20you%20could%20be%22&hl=ru&pg=PA155#v=onepage&q=%22those%20days%20you%20could%20be%22&f=false) at Google Books:
>
> As I stated before, in those days, you **could be** an Instructor as a Private Pilot, but there was not much of a practical use for having one because you couldn't charge for your services.
>
>
>
It seems that **could be** works fine as the past form of **can**. But will it work in:
>
> As I stated before, in those days, you **could be killed** easily.
>
>
>
|
2014/11/02
|
[
"https://ell.stackexchange.com/questions/38334",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2127/"
] |
Compare the following sentences:
**Present time**
1. It's very dangerous in Metropolis right now. You can be beaten up for just looking at someone the wrong way.
2. It's very dangerous in Metropolis right now. You could be beaten up for just looking at someone the wrong way.
Sentence (1) presents being beaten up as a live possibility, as something that does actually happen to people. Notice that we can analyse *for just looking at someone the wrong way*, as some kind of condition:
1'. You can be beaten up if you just look at someone the wrong way.
Sentence (2) presents being beaten up as a *hypothetical* outcome of the wrong look. It is not being presented in the same way as in (1). It doesn't necessarily say that people are being beaten up for looking at people the wrong way - although we might assume that they are.
*Could* in sentence (2), as already mentioned, represents this outcome as a hypothetical possibility, as opposed to a live one. We could rephrase it as the following hypothetical conditional:
2'. You could be beaten up if you just look(ed) at someone the wrong way.
Remember both of these sentences refer to the present or future time. The way that we interpret *you* here is quite likely to affect our interpretation of the sentence. It's also quite likely to affect our choice of *can* or *could*. If *you* means *a person* in general, we are more likely to use *can*. If *you* is being used to make the listener imagine themselves in that situation, then we are more likely to use the hypothetical *could*.
**Past time**
Let's move forward twenty years. Now if we wish to make the same kind of statement but about Metropolis twenty years ago instead of now, we need to shift the tenses back to indicate past time. Example (1) would now be as in (3):
3. It was very dangerous in Metropolis in those days. You could be beaten up
for just looking at someone the wrong way.
Here we see *could* appearing as the past form of *can*. This past form of *can* still implies that people actually were being beaten up for looking at people the wrong way. It is being presented as a live possibility for people at the time. It has exactly the same meaning as *can*, but refers to a past time. It does not represent hypotheticality.
However, in sentence (2) we already have past tense *could*, where the past tense indicates hypotheticality. If we wish to keep this hypothetical flavour, but also indicate past time, then we need to shift the tense back further. We need to use a past perfect form as in (4):
4. It was very dangerous in Metropolis in those days. You could have been beaten up
for just looking at someone the wrong way.
Sentences (3) and (4) could be construed as the conditionals:
3'. You could be beaten up if you just looked at someone the wrong way.
4'. You could have been beaten up if you ('d) just looked at someone the wrong way.
So if we see a past perfect form *could have* this most likely represents past time reference plus hypotheticality.
Hope this helps!
|
There are two situations here: A. Hypothetical B. Reality
In hypothetical situations, you do not exist or you did not exist. Like in your example, the person to whom you are speaking to was not there in the civil war times - So your sentence
>
> "In those days you could be killed" is actually correct.
>
>
>
**'Could have been' is only used in 'Real situations.'**
For example:
>
> 1. He got away from burning car before it exploded.
>
>
>
Here we can say:
He was lucky to have gotten away from that burning car in time. He could have been killed.
(Here '**could be**' can't be used)
Another example :
Suppose I say
>
> 2. I could be a pilot in world war two.
>
>
>
This means that 'i was not there in world war two, because it's a hypothetical situation. But
>
> 3. I could have been a pilot in world war two.
>
>
>
means that i was there in world war two, (maybe as a soldier) but i did not get a chance to become a pilot.
**Note - the use of 'could have been' here makes it a real situation and it's no longer a hypothetical situation.** So to sum it up:
1. If you are making a hypothetical statement then use 'could be'
2. If you are making a reality statement then use 'could have been.'
|
38,334 |
Let's take a hypothetical sentence pronounced by a hypothetical person who speaks, say, of events that are more than 100 years in the past:
>
> "The civil war period was very violent. In those days, you **could have been killed** for any trifle."
>
>
>
Would this sentence be grammatical and logical if both the speaker and the listener were born after the civil war in question, meaning there was not a chance for any of them to witness *those days*?
I've looked up Google, and "*those days you could have been*" turned out to be a rare combination for some reason.
But *"In those days you **could be** killed"* is possibly wrong when talking of the past.
I'm trying to proofread an [English-language post written by a Russian-speaking person](http://lang-8.com/1001060/journals/316719950558392889475961063287548762764) and untangle the grammar behind some of the structures. His sentence runs like this:
>
> There was very dangerous at that times because **you would be looted**, taken a beating and even gone home in a box...
>
>
>
I'd come up with this "could have been" instead of his "you would be looted, beaten.." but then had second thoughts. Maybe "could be" is proper. Or should one use "you were likely to be looted"?
Here's one [sentence I've found](http://books.google.ru/books?id=BS8_EC8lnkcC&lpg=PA155&ots=uhKLdbm7VO&dq=%22those%20days%20you%20could%20be%22&hl=ru&pg=PA155#v=onepage&q=%22those%20days%20you%20could%20be%22&f=false) at Google Books:
>
> As I stated before, in those days, you **could be** an Instructor as a Private Pilot, but there was not much of a practical use for having one because you couldn't charge for your services.
>
>
>
It seems that **could be** works fine as the past form of **can**. But will it work in:
>
> As I stated before, in those days, you **could be killed** easily.
>
>
>
|
2014/11/02
|
[
"https://ell.stackexchange.com/questions/38334",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2127/"
] |
Compare the following sentences:
**Present time**
1. It's very dangerous in Metropolis right now. You can be beaten up for just looking at someone the wrong way.
2. It's very dangerous in Metropolis right now. You could be beaten up for just looking at someone the wrong way.
Sentence (1) presents being beaten up as a live possibility, as something that does actually happen to people. Notice that we can analyse *for just looking at someone the wrong way*, as some kind of condition:
1'. You can be beaten up if you just look at someone the wrong way.
Sentence (2) presents being beaten up as a *hypothetical* outcome of the wrong look. It is not being presented in the same way as in (1). It doesn't necessarily say that people are being beaten up for looking at people the wrong way - although we might assume that they are.
*Could* in sentence (2), as already mentioned, represents this outcome as a hypothetical possibility, as opposed to a live one. We could rephrase it as the following hypothetical conditional:
2'. You could be beaten up if you just look(ed) at someone the wrong way.
Remember both of these sentences refer to the present or future time. The way that we interpret *you* here is quite likely to affect our interpretation of the sentence. It's also quite likely to affect our choice of *can* or *could*. If *you* means *a person* in general, we are more likely to use *can*. If *you* is being used to make the listener imagine themselves in that situation, then we are more likely to use the hypothetical *could*.
**Past time**
Let's move forward twenty years. Now if we wish to make the same kind of statement but about Metropolis twenty years ago instead of now, we need to shift the tenses back to indicate past time. Example (1) would now be as in (3):
3. It was very dangerous in Metropolis in those days. You could be beaten up
for just looking at someone the wrong way.
Here we see *could* appearing as the past form of *can*. This past form of *can* still implies that people actually were being beaten up for looking at people the wrong way. It is being presented as a live possibility for people at the time. It has exactly the same meaning as *can*, but refers to a past time. It does not represent hypotheticality.
However, in sentence (2) we already have past tense *could*, where the past tense indicates hypotheticality. If we wish to keep this hypothetical flavour, but also indicate past time, then we need to shift the tense back further. We need to use a past perfect form as in (4):
4. It was very dangerous in Metropolis in those days. You could have been beaten up
for just looking at someone the wrong way.
Sentences (3) and (4) could be construed as the conditionals:
3'. You could be beaten up if you just looked at someone the wrong way.
4'. You could have been beaten up if you ('d) just looked at someone the wrong way.
So if we see a past perfect form *could have* this most likely represents past time reference plus hypotheticality.
Hope this helps!
|
CORRECT: Back then, you (or one) could be killed for any trifle.
>
> There was very dangerous at that times because you would be looted,
> taken a beating and even gone home in a box...
>
>
>
**It was very dangerous in those times; you could be robbed, beaten, or even sent home in a box.**
"could have been killed" would mean that, at some point in the past, a situation arose where the danger was great enough to result in death, but death did not occur.
**Why did you jaywalk across the busy street at rush hour? You could have been killed!**
**Twenty years ago, there was no pedestrian crossing or traffic signal at this busy location. You could be killed trying to cross the street.**
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.