qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
26,205,066 | I have a large JSON formatted file (254MB) which I am trying to import into MongoDB in Cloud9 IDE using mongoimport. Json file consists of mongodb documents each on its own row using newline character. The file looks like this:
```
...
{"t":"1358836264","p":"1.33470"}
{"t":"1358836265","p":"1.33475"}
{"t":"1358836271"... | 2014/10/05 | [
"https://Stackoverflow.com/questions/26205066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1312286/"
] | According to the message:
```
Sun Oct 5 16:52:03.088 Progress: 25548600/26345472 96%
Sun Oct 5 16:52:03.088 774200 15180/second
Sun Oct 5 16:52:04.644 exception:BSON representation of supplied JSON is too large: code FailedToParse: FailedToParse: Expecting ':': offset:2... | Try this option: --batchSize 1
Like:
```
mongoimport -d woption -c eurusd eurusddata.json --batchSize 1
``` |
41,305,378 | I am new to android and trying to update the `gridlayout` in popular movies popular movies app of udacity nanodegree project.
I am downloading the data using `AsyncTask` and parsing the data, updating the `recyclerview` and setting adapter in `onPostExecute`.
**This is my AsyncTask class**
```
private class getJson... | 2016/12/23 | [
"https://Stackoverflow.com/questions/41305378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7316349/"
] | Basically arrow functions will help with this and since React-Native doesnt have to deal with browser compatibility you can define you're functions like this:
```
handleData = (data) => {
this.setState({ data });
}
```
You won't ever have to .bind or that=this if you use this. | `this` is already bound because of the arrow function you've used.
```
// ...
componentDidMount() {
this.props.myService.listensTo(
'action',
(data) => this.handleData(data)
);
}
handleData(data) {
// handle data
}
// ...
``` |
27,988,603 | As the title states, what is the purpose of appending `(0);` rather than just `();` in this code snippit ([found here](https://github.com/thomseddon/node-oauth2-server/blob/master/lib/runner.js)):
```
function runner (fns, context, next) {
var last = fns.length - 1;
(function run(pos) {
fns[pos].call(context,... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27988603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334695/"
] | It is approximately equivalent to:
```
function runner (fns, context, next) {
var last = fns.length - 1;
function run(pos) {
fns[pos].call(context, function (err) {
if (err || pos === last) return next(err);
run(++pos);
});
}
run(0);
}
```
`0` is just what’s passed to `run()` as the fir... | The purpose is that you're passing 0 as the value to the *pos* argument. |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | $c$ can not be the hypotenuse.
Let $a$ be the hypotenuse.
Thus, $$c^2+(c+\sqrt3)^2=3^2,$$
which gives $c=\frac{\sqrt3}{2}$, which is possible.
Let $b$ be the hypotenuse.
Thus,
$$(c+\sqrt3)^2=3^2+c^2,$$
which gives $c=\sqrt3$ and $b=2\sqrt3$ and it's possible again. | The sides are $3, c, c+\sqrt{3}$. Now consider possible pythagorean pairs.
Either $3$ can be hypotenuse, or $c+\sqrt{3}$
1. Using 3 as hypotenuse, we get:
$$9 = 2c^2 + 2c\sqrt{3} +3\\
c^2 + c\sqrt{3} -3=0\\
c = \frac{\sqrt 3}{2}$$
2. Using $c+\sqrt{3}$ as hypotenuse, you have:
$$c^2 + 2c\sqrt 3+3=c^2+9 \\
c = \frac{1... |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | The sides are $3, c, c+\sqrt{3}$. Now consider possible pythagorean pairs.
Either $3$ can be hypotenuse, or $c+\sqrt{3}$
1. Using 3 as hypotenuse, we get:
$$9 = 2c^2 + 2c\sqrt{3} +3\\
c^2 + c\sqrt{3} -3=0\\
c = \frac{\sqrt 3}{2}$$
2. Using $c+\sqrt{3}$ as hypotenuse, you have:
$$c^2 + 2c\sqrt 3+3=c^2+9 \\
c = \frac{1... | Hint: if $b$ is the hypotenuse then $(b+c)(b-c)=b^2-c^2=9$. So what is $b+c$? |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | The sides are $3, c, c+\sqrt{3}$. Now consider possible pythagorean pairs.
Either $3$ can be hypotenuse, or $c+\sqrt{3}$
1. Using 3 as hypotenuse, we get:
$$9 = 2c^2 + 2c\sqrt{3} +3\\
c^2 + c\sqrt{3} -3=0\\
c = \frac{\sqrt 3}{2}$$
2. Using $c+\sqrt{3}$ as hypotenuse, you have:
$$c^2 + 2c\sqrt 3+3=c^2+9 \\
c = \frac{1... | As we assue $a,b,c>0$: We know $b=\sqrt{3}+c>c$, hence we know that $c$ cannot be the hypothenuse (= longes side).
There are only two possibilities left. $b$ is the hypotenuse or $a$ is the hypotenuse.
A) $a^2+c^2=b^2=(c+\sqrt{3})^2 \implies 9 +c^2=c^2+2\sqrt 3c + 3 \implies c = \frac{6}{2\sqrt{3}}$
B) $c^2+(c+\sqrt... |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | The sides are $3, c, c+\sqrt{3}$. Now consider possible pythagorean pairs.
Either $3$ can be hypotenuse, or $c+\sqrt{3}$
1. Using 3 as hypotenuse, we get:
$$9 = 2c^2 + 2c\sqrt{3} +3\\
c^2 + c\sqrt{3} -3=0\\
c = \frac{\sqrt 3}{2}$$
2. Using $c+\sqrt{3}$ as hypotenuse, you have:
$$c^2 + 2c\sqrt 3+3=c^2+9 \\
c = \frac{1... | Since $b=c+\sqrt{3}$ it cannot be the hypotenuse. So we have two possibilities:
$$
c^2+a^2=b^2 \iff c^2+9=(c+\sqrt{3})^2
$$
or
$$
c^2+b^2=a^2 \iff c^2+(c+\sqrt{3})^2 = 9
$$
solve for $c$ and in the first case $b$ is the hypotenuse, in the second it is $a$. |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | $c$ can not be the hypotenuse.
Let $a$ be the hypotenuse.
Thus, $$c^2+(c+\sqrt3)^2=3^2,$$
which gives $c=\frac{\sqrt3}{2}$, which is possible.
Let $b$ be the hypotenuse.
Thus,
$$(c+\sqrt3)^2=3^2+c^2,$$
which gives $c=\sqrt3$ and $b=2\sqrt3$ and it's possible again. | Hint: if $b$ is the hypotenuse then $(b+c)(b-c)=b^2-c^2=9$. So what is $b+c$? |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | $c$ can not be the hypotenuse.
Let $a$ be the hypotenuse.
Thus, $$c^2+(c+\sqrt3)^2=3^2,$$
which gives $c=\frac{\sqrt3}{2}$, which is possible.
Let $b$ be the hypotenuse.
Thus,
$$(c+\sqrt3)^2=3^2+c^2,$$
which gives $c=\sqrt3$ and $b=2\sqrt3$ and it's possible again. | As we assue $a,b,c>0$: We know $b=\sqrt{3}+c>c$, hence we know that $c$ cannot be the hypothenuse (= longes side).
There are only two possibilities left. $b$ is the hypotenuse or $a$ is the hypotenuse.
A) $a^2+c^2=b^2=(c+\sqrt{3})^2 \implies 9 +c^2=c^2+2\sqrt 3c + 3 \implies c = \frac{6}{2\sqrt{3}}$
B) $c^2+(c+\sqrt... |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | $c$ can not be the hypotenuse.
Let $a$ be the hypotenuse.
Thus, $$c^2+(c+\sqrt3)^2=3^2,$$
which gives $c=\frac{\sqrt3}{2}$, which is possible.
Let $b$ be the hypotenuse.
Thus,
$$(c+\sqrt3)^2=3^2+c^2,$$
which gives $c=\sqrt3$ and $b=2\sqrt3$ and it's possible again. | Since $b=c+\sqrt{3}$ it cannot be the hypotenuse. So we have two possibilities:
$$
c^2+a^2=b^2 \iff c^2+9=(c+\sqrt{3})^2
$$
or
$$
c^2+b^2=a^2 \iff c^2+(c+\sqrt{3})^2 = 9
$$
solve for $c$ and in the first case $b$ is the hypotenuse, in the second it is $a$. |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | Hint: if $b$ is the hypotenuse then $(b+c)(b-c)=b^2-c^2=9$. So what is $b+c$? | Since $b=c+\sqrt{3}$ it cannot be the hypotenuse. So we have two possibilities:
$$
c^2+a^2=b^2 \iff c^2+9=(c+\sqrt{3})^2
$$
or
$$
c^2+b^2=a^2 \iff c^2+(c+\sqrt{3})^2 = 9
$$
solve for $c$ and in the first case $b$ is the hypotenuse, in the second it is $a$. |
2,450,560 | in a right triangle, the side $a = 3$ and the subtraction the sides $b - c =\sqrt{3}$, What is the value of the hypotenuse?
Can someone help me? I need understand how to arrive at the answer. | 2017/09/29 | [
"https://math.stackexchange.com/questions/2450560",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/485848/"
] | As we assue $a,b,c>0$: We know $b=\sqrt{3}+c>c$, hence we know that $c$ cannot be the hypothenuse (= longes side).
There are only two possibilities left. $b$ is the hypotenuse or $a$ is the hypotenuse.
A) $a^2+c^2=b^2=(c+\sqrt{3})^2 \implies 9 +c^2=c^2+2\sqrt 3c + 3 \implies c = \frac{6}{2\sqrt{3}}$
B) $c^2+(c+\sqrt... | Since $b=c+\sqrt{3}$ it cannot be the hypotenuse. So we have two possibilities:
$$
c^2+a^2=b^2 \iff c^2+9=(c+\sqrt{3})^2
$$
or
$$
c^2+b^2=a^2 \iff c^2+(c+\sqrt{3})^2 = 9
$$
solve for $c$ and in the first case $b$ is the hypotenuse, in the second it is $a$. |
43,749,166 | So lets say that I have these two arrays with different sizes
[](https://i.stack.imgur.com/gxCYs.png)
And I'd like to perform a levene test with the function leveneTest()
However, the way I have been taught converts these to a dataframe and then calls the function melt t... | 2017/05/03 | [
"https://Stackoverflow.com/questions/43749166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5583899/"
] | You can simply `stack` your two samples, of different sizes, into one data frame and perform the `leveneTest`:
```
stacked <- stack(list(down25=down25,down27=down27))
car::leveneTest(values~ind,data=stacked,center=mean)
``` | Could you not just make them independent dataframes add an identifier column to each and then do an R bind and run the test? I can make up a full example if that helps that is reproducible.
make dataframe1 with id and value
dataframe2 with id and value
rbind the two together and skip the melt step |
14,021,347 | I have been trying to send packets using raw socket in following code.This code I found somewhere in the internet. I created my own ipheader and udp header. The whole data packet is sent using sendto() function on raw socket. sendto() returns 0. Which means a packet of 0 length is sent out of it and hence even wireshar... | 2012/12/24 | [
"https://Stackoverflow.com/questions/14021347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665884/"
] | Aha! I've got at least part of it.
`i = sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0`
is the same as
`i = (sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0)`
you probably want:
`(i = sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin))) < 0`
Yo... | It is really hard to read this piece of code and to understand what and why you're doing. So I can recoomend you look at my piece of code: [dhcp client implementation](https://github.com/fycth/DHCP-server-scanner/blob/master/src/dhcpd-detector.c)
Look at function getSock() to see how socket is created, and on function... |
14,021,347 | I have been trying to send packets using raw socket in following code.This code I found somewhere in the internet. I created my own ipheader and udp header. The whole data packet is sent using sendto() function on raw socket. sendto() returns 0. Which means a packet of 0 length is sent out of it and hence even wireshar... | 2012/12/24 | [
"https://Stackoverflow.com/questions/14021347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665884/"
] | It is really hard to read this piece of code and to understand what and why you're doing. So I can recoomend you look at my piece of code: [dhcp client implementation](https://github.com/fycth/DHCP-server-scanner/blob/master/src/dhcpd-detector.c)
Look at function getSock() to see how socket is created, and on function... | Local IP header structure is wrong... my suggestion is to include the IP header provided with your distro (are you using linux? don't you?).
What i did is just include linux/ip.h, rename ipheader structure reference to iphdr, and rename the ip header fields according to the structure described in the latter file.
I t... |
14,021,347 | I have been trying to send packets using raw socket in following code.This code I found somewhere in the internet. I created my own ipheader and udp header. The whole data packet is sent using sendto() function on raw socket. sendto() returns 0. Which means a packet of 0 length is sent out of it and hence even wireshar... | 2012/12/24 | [
"https://Stackoverflow.com/questions/14021347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665884/"
] | It is really hard to read this piece of code and to understand what and why you're doing. So I can recoomend you look at my piece of code: [dhcp client implementation](https://github.com/fycth/DHCP-server-scanner/blob/master/src/dhcpd-detector.c)
Look at function getSock() to see how socket is created, and on function... | I'm guessing you based that on [this example code](https://www.tenouk.com/Module43a.html), which has multiple fatal bugs. It has wasted many hours of my life.
But to answer this specific question (and to help anyone else who is unfortunate enough to try to use that code), the bug that prevents you from seeing the pack... |
14,021,347 | I have been trying to send packets using raw socket in following code.This code I found somewhere in the internet. I created my own ipheader and udp header. The whole data packet is sent using sendto() function on raw socket. sendto() returns 0. Which means a packet of 0 length is sent out of it and hence even wireshar... | 2012/12/24 | [
"https://Stackoverflow.com/questions/14021347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665884/"
] | Aha! I've got at least part of it.
`i = sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0`
is the same as
`i = (sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0)`
you probably want:
`(i = sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin))) < 0`
Yo... | Local IP header structure is wrong... my suggestion is to include the IP header provided with your distro (are you using linux? don't you?).
What i did is just include linux/ip.h, rename ipheader structure reference to iphdr, and rename the ip header fields according to the structure described in the latter file.
I t... |
14,021,347 | I have been trying to send packets using raw socket in following code.This code I found somewhere in the internet. I created my own ipheader and udp header. The whole data packet is sent using sendto() function on raw socket. sendto() returns 0. Which means a packet of 0 length is sent out of it and hence even wireshar... | 2012/12/24 | [
"https://Stackoverflow.com/questions/14021347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665884/"
] | Aha! I've got at least part of it.
`i = sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0`
is the same as
`i = (sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0)`
you probably want:
`(i = sendto(sd, buffer, PCKT_LEN, 0, (struct sockaddr *)&sin, sizeof(sin))) < 0`
Yo... | I'm guessing you based that on [this example code](https://www.tenouk.com/Module43a.html), which has multiple fatal bugs. It has wasted many hours of my life.
But to answer this specific question (and to help anyone else who is unfortunate enough to try to use that code), the bug that prevents you from seeing the pack... |
57,421,973 | I'm trying to my setting names be unique for each user id
```sql
Table: Settings
Cols: ID, Name, Value, UserID
Row1: 1, 'Database', 'shop', 1
Row2: 2, 'DBLogin' , 'admin', 1
Row3: 3, 'DBPass' , 'hash', 1
Row4: 4, 'Database', 'lol', 2 --this is ok
Row5: 5, 'Database', 'shop', 3 --this is ok
Row6: 6, 'Database', '... | 2019/08/08 | [
"https://Stackoverflow.com/questions/57421973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9150149/"
] | **Unfortunately**.From [Xamarin.Forms - Xaminals](https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-xaminals/) sample , also occurs this phenomenon. **This should be a limit of Shell FlyoutItem in Current version of XF**.
```
<Shell.ItemTemplate>
<DataTemplate >
<Grid>
... | You can use a binding property. Create a custom grid
```
public class ShellItemGrid : Grid
{
public static readonly BindableProperty SelectedColorProperty = BindableProperty.Create("SelectedColor", typeof(Color), typeof(ShellItemGrid),Color.Transparent);
public Color SelectedColor
{
get { re... |
63,315,991 | I don't fully understand the concept of Singleton class in Java. For example I have singleton class like this:
```
private int i = 0;
private static Singleton INSTANCE = new Singleton();
public static Singleton getInstance() {
return INSTANCE;
}
public int getI() {
return i;
}
public void setI(int i) {
... | 2020/08/08 | [
"https://Stackoverflow.com/questions/63315991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14071194/"
] | ```
INSTANCE = new Singleton();
```
would only get called once as it is static. Thereafter:
```
getInstance()
```
only ever returns that static instance | Singleton is a just pattern involves a single class which is responsible to create an object while making sure that only single object gets created.
This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class.
and to Implement that u should :
... |
39,496,251 | I am trying to copy/move one text file to the zip. I don't want to unzip it, copy the file and zip it back. Is there any way we can directly copy or move text file to the zip in powershell. When i am doing it in powershell, it's doing after that when i try to look inside the zip it's saying invalid path.
Powershell co... | 2016/09/14 | [
"https://Stackoverflow.com/questions/39496251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6553195/"
] | **>= PowerShell 5.0**
Per @SonnyPuijk's answer above, use `Compress-Archive`.
```
clear-host
[string]$zipFN = 'c:\temp\myZipFile.zip'
[string]$fileToZip = 'c:\temp\myTestFile.dat'
Compress-Archive -Path $fileToZip -Update -DestinationPath $zipFN
```
**< PowerShell 5.0**
***To add a single file to an existing zip:*... | You can use [`Compress-Archive`](https://technet.microsoft.com/en-us/library/dn841358.aspx) for this. `Copy-Item` doesn't support zip files.
If you don't have PowerShell v5 you can use either 7Zip command line or .Net |
7,523,763 | Convert the url in CONENT to be clickable and make it shorter.
For example:
Convert the content
```
Balabala The link is http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff
```
to
```
Balabala The link is <a href=http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff>http://www.googl... | 2011/09/23 | [
"https://Stackoverflow.com/questions/7523763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192223/"
] | Something like this may help:
```
<div id='result'>
</div>
<script>
var content = "The link is http://www.google.com/?q=hello visit it!";
var result = content.replace(/(http:\/\/(www\.)?([^(\s)]+))/, "<a href='$1'>$3</a>");
document.getElementById('result').innerHTML = result;
</script>
``` | Something like:
```
len = 15; //set how long of a string you would like to show
url = "http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff";
//if the original url is smaller than or equal to the length than do nothing
//otherwise take the len number of chars and append ... after
shorturl = (url.lengt... |
7,523,763 | Convert the url in CONENT to be clickable and make it shorter.
For example:
Convert the content
```
Balabala The link is http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff
```
to
```
Balabala The link is <a href=http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff>http://www.googl... | 2011/09/23 | [
"https://Stackoverflow.com/questions/7523763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192223/"
] | Here is a function that replaces any URLs inside a string with an anchor:
```
function linkify(str){
var url = 'http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff';
return str.replace(/https?\:\/\/\S+/, function(url){
var shortUrl = url.substring(0, 20) + '...';
return shortUrl... | Something like:
```
len = 15; //set how long of a string you would like to show
url = "http://www.google.com/?aaaaabefaaaaaaaaaaaafeeafaeff3asefffffffffff";
//if the original url is smaller than or equal to the length than do nothing
//otherwise take the len number of chars and append ... after
shorturl = (url.lengt... |
24,837,716 | I want to enter the text and specific character.
After that i want to count how many those characters contain in the text.
**My code**
```
#include <stdio.h>
#include <stdlib.h>
int counting(char text[], char character);
int main()
{
char text[20];
char character;
int a;
printf("Enter text!\n");
... | 2014/07/19 | [
"https://Stackoverflow.com/questions/24837716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3772600/"
] | The line for reading the character needs to be:
```
scanf(" %c", &character);
```
Also,
```
scanf("%s", text);
```
is not safe. If the user enter a string that is longer than 19 characters, you will be writing over unauthorized memory, which will lead to undefined behavior.
Use
```
scanf("%19s", text);
``` | In function `int counting(...)`
```
while(text[i] != '\0')
{
if (text[i]==character)
{
counter++;
}
}
i++;
```
Need `i++` inside your `while..loop`. |
24,837,716 | I want to enter the text and specific character.
After that i want to count how many those characters contain in the text.
**My code**
```
#include <stdio.h>
#include <stdlib.h>
int counting(char text[], char character);
int main()
{
char text[20];
char character;
int a;
printf("Enter text!\n");
... | 2014/07/19 | [
"https://Stackoverflow.com/questions/24837716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3772600/"
] | The line for reading the character needs to be:
```
scanf(" %c", &character);
```
Also,
```
scanf("%s", text);
```
is not safe. If the user enter a string that is longer than 19 characters, you will be writing over unauthorized memory, which will lead to undefined behavior.
Use
```
scanf("%19s", text);
``` | You have two problems.
1)You are reading the specific character as a string so you have to change `scanf("%s", character);` to `scanf(" %c", character);`
2)In function `counting()` `i++` needs to be in while loop so you don't enter an infinite loop. |
24,837,716 | I want to enter the text and specific character.
After that i want to count how many those characters contain in the text.
**My code**
```
#include <stdio.h>
#include <stdlib.h>
int counting(char text[], char character);
int main()
{
char text[20];
char character;
int a;
printf("Enter text!\n");
... | 2014/07/19 | [
"https://Stackoverflow.com/questions/24837716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3772600/"
] | In function `int counting(...)`
```
while(text[i] != '\0')
{
if (text[i]==character)
{
counter++;
}
}
i++;
```
Need `i++` inside your `while..loop`. | You have two problems.
1)You are reading the specific character as a string so you have to change `scanf("%s", character);` to `scanf(" %c", character);`
2)In function `counting()` `i++` needs to be in while loop so you don't enter an infinite loop. |
37,711,261 | ```
<add key="DBconnection"
value="USER=harc, PASSWORD=imp, FOR_USER=ra005" />
```
I have this line of config in my `web.config`.
I am getting this value in my C# code as
```
string connect = System.Configuration.ConfigurationManager.AppSettings["DBconnection"];
```
How do I get the USER and PASSWORD values... | 2016/06/08 | [
"https://Stackoverflow.com/questions/37711261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6287696/"
] | Assuming this is a SQL Server connection string, pass it to a [`SqlConnectionStringBuilder`](https://msdn.microsoft.com/library/system.data.sqlclient.sqlconnectionstringbuilder):
```
var builder = new SqlConnectionStringBuilder(
ConfigurationManager.AppSettings["DBconnection"]
);
// use builder.UserID and builder.... | You can add key value pair in webconfig file
```
<add key="UserName" value="test" />
<add key="Password" value="test" />
```
and read it like `System.Web.Configuration.WebConfigurationManager.AppSettings["UserName"]` |
34,324,407 | I'm getting an error in my program saying:
>
> Lyrics.java:11: error: cannot find symbol
>
>
>
> ```
> Cube(b);
> ^
>
> ```
>
> symbol: method Cube(int)
>
>
> location: class Lyrics
>
>
> Lyrics.java:15: error: incompatible types: possible lossy conversion from double to int
>
>
>
> ```
> return Math.... | 2015/12/17 | [
"https://Stackoverflow.com/questions/34324407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5407820/"
] | The first problem is a simple typo. Java is case sensitive, so `cube` and `Cube` mean different things. Solution: 1) be consistent, and 2) use names starting with lowercase letters for method names ... as per the Java style guides.
---
The second problem is due to the method signature for `Math.pow`; see the [javadoc... | Two problems:
1. Letter case is important: `Cube` is not the same as `cube`.
2. Your function `cube(int)` returns an integer, but the output of `Math.pow` is a `double`.
You should probably change `cube()` to return a `double`.
Then you have more code to write in the `main` method to use the results of calling `cub... |
4,348,382 | While investigating counterexamples for certain conjectures in matrix analysis, I stumbled across the following calculus problem.
>
> I need to show (rigorously) that for $1<p<2$,
> $$\left\lVert\begin{pmatrix}\sqrt 2 + 1 \\ \sqrt 2 - 1 \end{pmatrix}\right\rVert^2\_p < \left\lVert\begin{pmatrix}2 \\ 0 \end{pmatrix}\r... | 2022/01/04 | [
"https://math.stackexchange.com/questions/4348382",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/714494/"
] | **Sketch of a proof**:
For convenience, denote $a = \sqrt2 - 1$.
We need to prove that
$$a^{-2}(1 + a^{2p})^{2/p} < 4 + 2^{2/p}. \tag{1}$$
$\phantom{2}$
**Fact 1**: Let $u > 0$ and $v \in [0, 1]$. Then
$u^v \ge \frac{u}{u + v - uv}$.
**Fact 2**: Let $0 \le r \le 1$ and $0 \le x < 1$. Then $(1 - x)^r \le 1 - rx - \... | We want to prove that for $1<p<2$,
$$
\left((\sqrt{2}+1)^p + (\sqrt{2}-1)^p\right)^{\frac 1 p} < 2^{\frac 1 p} + 2.
$$
Note that whenever $a, b \ge 0$ and $\gamma > 1$, we have $a^\gamma + b^\gamma < (a + b)^{\gamma}$. Indeed, for $t > 0$,
$$t^{\gamma - 1} < (a + t)^{\gamma -1 }$$
and integrating from $0$ to $b$ gives... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | Answer given by dhamma 4life is very nice arisen out of real and genuine concern/compassion about the questioner.It is very appreciable and important that you have developed an interest in buddhism ,which is a very true and gives guarantee of attaining liberation if followed ardently and honestly giving stress of 10% t... | There is nothing you can do about the past, and Buddhist deals with it in a way that avoids clinging to the past. Let it go for that is what makes you suffer. Also, all memories can be transformed if done skilfully, it just takes time and they will flourish in their own way. But that requires non-violence towards your ... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | You are not going to become any better if you are just looking for a way to escape from the consequences of your mistakes. You need to put forth an honest effort to become better. Here are some steps that will help you in doing that.
1. If you haven't already done it, send another mail to all those who received the or... | There is nothing you can do about the past, and Buddhist deals with it in a way that avoids clinging to the past. Let it go for that is what makes you suffer. Also, all memories can be transformed if done skilfully, it just takes time and they will flourish in their own way. But that requires non-violence towards your ... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | In addition to all the good answers here's some solution from my experience.
1. One of the problems you have dealing with this situation is Guilt that you are still feeling about sending that email in the first place. This guilt can be dealt with skillfully. Now that you have already accepted the problem that's the fi... | There is nothing you can do about the past, and Buddhist deals with it in a way that avoids clinging to the past. Let it go for that is what makes you suffer. Also, all memories can be transformed if done skilfully, it just takes time and they will flourish in their own way. But that requires non-violence towards your ... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | You are not going to become any better if you are just looking for a way to escape from the consequences of your mistakes. You need to put forth an honest effort to become better. Here are some steps that will help you in doing that.
1. If you haven't already done it, send another mail to all those who received the or... | Answer given by dhamma 4life is very nice arisen out of real and genuine concern/compassion about the questioner.It is very appreciable and important that you have developed an interest in buddhism ,which is a very true and gives guarantee of attaining liberation if followed ardently and honestly giving stress of 10% t... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | Answer given by dhamma 4life is very nice arisen out of real and genuine concern/compassion about the questioner.It is very appreciable and important that you have developed an interest in buddhism ,which is a very true and gives guarantee of attaining liberation if followed ardently and honestly giving stress of 10% t... | You might know this already but here's some advice.
It's appropriate to apologise (people do apologise, in the Suttas; and apology or confession is prescribed in the Vinaya). I think that elements of an apology include:
* Saying, "I understand that action was wrong"
* Saying, "Understanding it (and having understood ... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | You are not going to become any better if you are just looking for a way to escape from the consequences of your mistakes. You need to put forth an honest effort to become better. Here are some steps that will help you in doing that.
1. If you haven't already done it, send another mail to all those who received the or... | In addition to all the good answers here's some solution from my experience.
1. One of the problems you have dealing with this situation is Guilt that you are still feeling about sending that email in the first place. This guilt can be dealt with skillfully. Now that you have already accepted the problem that's the fi... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | You are not going to become any better if you are just looking for a way to escape from the consequences of your mistakes. You need to put forth an honest effort to become better. Here are some steps that will help you in doing that.
1. If you haven't already done it, send another mail to all those who received the or... | You might know this already but here's some advice.
It's appropriate to apologise (people do apologise, in the Suttas; and apology or confession is prescribed in the Vinaya). I think that elements of an apology include:
* Saying, "I understand that action was wrong"
* Saying, "Understanding it (and having understood ... |
26,854 | Im in the process of trying to 'wake up' I made a grievous error with a colleague recently. I sent a nasty email about something she was involved in. I was trying to manipulate her-even perhaps bully her with my views
I was drinking a lot at the time.
I have since realized the error of trying to control anybody or not... | 2018/06/13 | [
"https://buddhism.stackexchange.com/questions/26854",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/13640/"
] | In addition to all the good answers here's some solution from my experience.
1. One of the problems you have dealing with this situation is Guilt that you are still feeling about sending that email in the first place. This guilt can be dealt with skillfully. Now that you have already accepted the problem that's the fi... | You might know this already but here's some advice.
It's appropriate to apologise (people do apologise, in the Suttas; and apology or confession is prescribed in the Vinaya). I think that elements of an apology include:
* Saying, "I understand that action was wrong"
* Saying, "Understanding it (and having understood ... |
41,347,474 | ### Background
I'm trying to create two instances of a `struct`. One of them will not change and is therefore declared `const`, but the other may be changed asynchronously, therefore I'd like to make it `volatile`.
### Problem
I'm trying to use the `const` instance of the structure to initialise the `volatile` one. ... | 2016/12/27 | [
"https://Stackoverflow.com/questions/41347474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6118556/"
] | You are missing what the error message actually says. The compiler is telling you that to assign the whole structure in one go needs a "copy constructor" which understands the volatile qualifier and there isn't one. Have a look at [this answer](https://stackoverflow.com/questions/5973427/error-passing-xxx-as-this-argum... | >
> What am I missing? ... It may be related to `this`.
>
>
>
Yes, you're missing the proper copy c'tor for volatile |
8,248,731 | This is a followup to [Using #include to load OpenCL code](https://stackoverflow.com/questions/1415538/using-include-to-load-opencl-code)
I've noticed that when you use the method described by grrussel (and used in Bullet Physics), the created string has all newlines stripped (comments seem to be stripped, too, but I'... | 2011/11/23 | [
"https://Stackoverflow.com/questions/8248731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/558546/"
] | I'd write a small tool that generates a cpp with a constant string from the text file, which you would then compile along with the other stuff.
This is what Qt's resource compiler moc does (and more, since it has a whole API around it), and there's also the option of Windows's resource kit (see [this answer](https://s... | Excellent question!
One thing that works on Windows is to treat your OpenCL C files as Windows resources. Then the source code gets built into your executable. In your reasource (.rc) file, you would add something like this:
```
IDR_OPENCL_FILE_1 OPENCL_SOURCE "mydir\\myfile.cl"
```
Then, in th... |
32,454,544 | I have a list like this:
```
a = [(1,2,3,4), (2,3,2,2), (33,221,22,1) ...]
```
and I want to add for each item in the list a 5th value, for example:
```
new_a = [(1,2,3,4,"new"), (2,3,2,2,"new"), (33,221,22,1,"new") ...]
```
How can I do that because a.list or a.add freeze my computer.
```
for item in a:
a.add... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32454544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3050807/"
] | The inner items are not lists, they are tuples. Tuples are immutable. Therefore, you probably need to create new tuples that contain the values you want:
```
new_a = [x + ('new',) for x in a]
```
This code iterates through all tuples present in a and for each one creates a new tuple consisting of the values of the o... | You can use `map`
```
>>> map(lambda x: x + ('new',), a)
[(1, 2, 3, 4, 'new'), (2, 3, 2, 2, 'new'), (33, 221, 22, 1, 'new')]
``` |
267,593 | When I have **a directed relation** I call one of the items taking part **a subject** and other **an object**. Is there a corresponding term for **a bidirectional relation**? I know I can call both items a relation **objects**, but I would like some other term to distinguish from directed relation. | 2015/08/18 | [
"https://english.stackexchange.com/questions/267593",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/28436/"
] | [participants](http://www.oxforddictionaries.com/definition/english/participant//) [Source: ODO]
Examples of usage:
* >
> '*a situation with two participants between which a bidirectional relation holds*'
>
>
>
Source: [Reciprocity in English: historical development and synchronic structure. *Haas, F* Routledge, ... | Reflexives appear to be one form of bidirectional object:
***Reflexive***:
"He injured himself."
"[He perjured himself.](https://en.wiktionary.org/wiki/perjure#Verb)" (ref. Wiktionary)
And Reciprocal ([Merriam Webster](http://www.merriam-webster.com/dictionary/reciprocal)) describes another *situation*:
>
> ... |
60,188,354 | I am practising pivot. And I have a table with Name and Occupation data (code to generate sample is below). I need to put Occupations in columns, and stack beneath each occupation, names. Null is fine.
I have seen a number of posts, and [this](https://stackoverflow.com/questions/52147382/sql-pivot-table-on-text-value)... | 2020/02/12 | [
"https://Stackoverflow.com/questions/60188354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3181863/"
] | The best way to remove all escape characters from your `JSON` string is to use the `Regex.Unescape()` method. This method returns a new string with no escape characters. Even characters such as `\n` `\t` etc are removed.
Make sure to import the `System.Text.RegularExpressions` namespace:
```
using System.Text.Regular... | You are escaping `"` correctly. There is no issue at all.
```cs
var string = "[{\"Item\": { \"Name\": \"item1\" }, \"ShipQuantity\": \" 50.0000000000000000000\", \"Total\": \"10.0000000000000000000\"},{\"Item\": { \"Name\": \"Gratuity\" }, \"ShipQuantity\": \" 1.0000000000000000000\", \"Total\": \"10.0000000000000000... |
3,041,969 | i just want to create a simple application that will allow a user to input a url to a rss feed and display the contents to a user.
what would be a good java library to enable me to read rss feeds?
cheers | 2010/06/15 | [
"https://Stackoverflow.com/questions/3041969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286630/"
] | Rome <http://rome.dev.java.net/> - is the popular java library for parsing RSS feeds | **Informa** is a very good java library for RSS feeds and can be found on **sourceforge.net**.The best part of this it implements Observer design pattern , hence keep checking if any new items are found on the RSS URL. Also you can set a frequency to crawl a number of URLs. |
7,834,351 | In an application I'm developing, I have a main form that simply sits there and displays log data, and a worker thread that autonomously does the work in a loop.
```
MyWorker worker = new MyWorker();
MainForm mainForm = new MainForm();
// Subscribe form to log event so log data gets displayed
worker.Log += mainForm.L... | 2011/10/20 | [
"https://Stackoverflow.com/questions/7834351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/266143/"
] | You can tidy up both the running of the individual tasks and the 15 min wait loop considerably.
I'd suggest perhaps using something like this:
```
public class MyWorker
{
private readonly ManualResetEvent _stopEvent = new ManualResetEvent(false);
private readonly Action[] _workUnits;
private bool Running... | I would suggest using [System.Timers.Timer](http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx).
You can do your work with the running thing and rather than using the sleep you can just set the timer to go off again in 15 minutes.
If you want to stop it early then call some kind of abort method (similar... |
26,842,004 | I have deleted my earlier question regarding file upload using classic asp. Now I have switched to .net for achieve the goal however I am still unable to restrict file type i.e. pdf & docx being upload.
code behind is as under:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
u... | 2014/11/10 | [
"https://Stackoverflow.com/questions/26842004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084231/"
] | Because you inherited from Array you can do this:
```
class Foo < Array
def initialize(length)
super(length, 0)
end
end
```
Note that `super` calls the original `initialize` method on `Array`.
```
Foo.new(5)
#=> [0, 0, 0, 0, 0]
``` | The implementation of `Class#new` looks a bit like this:
```
class Class
def new(*args, &block)
obj = allocate
obj.initialize(*args, &block)
obj
end
end
```
[Note: in reality, `initialize` is `private`, so it needs to be invoked reflectively, but you get the idea.]
IOW: the return value of `initial... |
5,125,345 | I'm quite new to ruby/rails. I was wondering what is the best way to ensure that two people don't choose the same username. Here is my model at the moment:
```
class User < ActiveRecord::Base
validates :username, :presence => true
validates :password, :presence => true, :length => { :minimum => 7}
end
```
No... | 2011/02/26 | [
"https://Stackoverflow.com/questions/5125345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615759/"
] | There's a validation to make sure a field is unique. Just change your username validation to:
```
validates :username, :presence => true, :uniqueness => true
``` | This question has already been correctly answered but for future reference, APIDock has excellent Rails documentation here: <http://apidock.com/rails>. The search's autocomplete is fantastic.
The documentation for the `validates` method is here: <http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates>... |
5,125,345 | I'm quite new to ruby/rails. I was wondering what is the best way to ensure that two people don't choose the same username. Here is my model at the moment:
```
class User < ActiveRecord::Base
validates :username, :presence => true
validates :password, :presence => true, :length => { :minimum => 7}
end
```
No... | 2011/02/26 | [
"https://Stackoverflow.com/questions/5125345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615759/"
] | There's a validation to make sure a field is unique. Just change your username validation to:
```
validates :username, :presence => true, :uniqueness => true
``` | You should also add an index to your usertable, with uniqueness. This way, if people quickly press the username register button twice, you will also be protected at the database level
```
add_index :users, :username, :unique => true
``` |
5,125,345 | I'm quite new to ruby/rails. I was wondering what is the best way to ensure that two people don't choose the same username. Here is my model at the moment:
```
class User < ActiveRecord::Base
validates :username, :presence => true
validates :password, :presence => true, :length => { :minimum => 7}
end
```
No... | 2011/02/26 | [
"https://Stackoverflow.com/questions/5125345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615759/"
] | You should also add an index to your usertable, with uniqueness. This way, if people quickly press the username register button twice, you will also be protected at the database level
```
add_index :users, :username, :unique => true
``` | This question has already been correctly answered but for future reference, APIDock has excellent Rails documentation here: <http://apidock.com/rails>. The search's autocomplete is fantastic.
The documentation for the `validates` method is here: <http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates>... |
38,051,862 | How to close this file or does the file automatically gets closed like a context manager `with`
```
lines = open(file_name).readlines()
```
I wanted to avoid the `with` statement as the above statement is a one liner, but now i see that the above said statement is of no use since we cannot close the file.
```
wit... | 2016/06/27 | [
"https://Stackoverflow.com/questions/38051862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277603/"
] | if you tend to use `open(filename)` in your expressions, rather than the `with` statement, wrap the with statement in your own function, and use it in the expression.
```
def open_readlines_and_close(filename, *args, **kwargs):
with open(filename, *args, **kwargs) as file:
lines = file.readlines()
ret... | you can use `with`
This has the advantage that the file is properly closed after its suite finishes, even if an exception is raised on the way.
```
with open(file_name, 'r') as readfile:
lines = readfile.readlines()
``` |
38,051,862 | How to close this file or does the file automatically gets closed like a context manager `with`
```
lines = open(file_name).readlines()
```
I wanted to avoid the `with` statement as the above statement is a one liner, but now i see that the above said statement is of no use since we cannot close the file.
```
wit... | 2016/06/27 | [
"https://Stackoverflow.com/questions/38051862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277603/"
] | ```
lines = (lambda f=open(file_name): [f.readlines(), f.close()][0])()
```
However this would not be considered very Pythonic because it's not very readable. | you can use `with`
This has the advantage that the file is properly closed after its suite finishes, even if an exception is raised on the way.
```
with open(file_name, 'r') as readfile:
lines = readfile.readlines()
``` |
38,051,862 | How to close this file or does the file automatically gets closed like a context manager `with`
```
lines = open(file_name).readlines()
```
I wanted to avoid the `with` statement as the above statement is a one liner, but now i see that the above said statement is of no use since we cannot close the file.
```
wit... | 2016/06/27 | [
"https://Stackoverflow.com/questions/38051862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277603/"
] | if you tend to use `open(filename)` in your expressions, rather than the `with` statement, wrap the with statement in your own function, and use it in the expression.
```
def open_readlines_and_close(filename, *args, **kwargs):
with open(filename, *args, **kwargs) as file:
lines = file.readlines()
ret... | ```
lines = (lambda f=open(file_name): [f.readlines(), f.close()][0])()
```
However this would not be considered very Pythonic because it's not very readable. |
467,973 | Suppose $A$ and $B$ are two square $n\times n$ matrices over some field. Why do the $n$ equations $$\operatorname{tr}(A^k)=\operatorname{tr}(B^k)\text{ for } 1\leq k\leq n$$
imply that $A$ and $B$ have the same spectra?
If $\operatorname{Spec}(A)=\{\lambda\_1,\dots,\lambda\_p\}$ and $\operatorname{Spec}(B)=\{\mu\_1,\d... | 2013/08/15 | [
"https://math.stackexchange.com/questions/467973",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/25005/"
] | Power sums generate symmetric polynomials: See [http://en.wikipedia.org/wiki/Newton's\_identities](http://en.wikipedia.org/wiki/Newton%27s_identities)
Therefore the characteristic polynomials of $A$ and $B$, which are symmetric polynomials of the spectra, must be the same. Therefore the two spectra are the same. | The spectrum of $A$ and $B$ are the multiset of roots of their characteristic polynomials. If one can show that their characteristic polynomials are equal over the algebraic closure of the base field, then their polynomials are equal over the base field itself and have the same spectra there.
Thus, it suffices to argu... |
55,392,331 | I have seen some questions about **sending response immediately** and **run CPU intensive tasks**.
My case is my node application **depends on third party service responses** so the process flow is
>
> 1. Node receives request and authenticates with third-party service
> 2. Send response to user after authenticatio... | 2019/03/28 | [
"https://Stackoverflow.com/questions/55392331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1445874/"
] | ```
elsewhere in your code
function do_some_tasks() { //... }
// route function
(req, res) => {
// call some async task
do_some_tasks()
// if the above is doing some asynchronous task, next function should be called immediately without waiting, question is is it so?
res.send()
}
// if your do_some_tasks() is ... | Just writing a very general code block here:
```
var do_some_tasks = (req, tp_response) => {
third_party_tasks(args, (err, result)=<{
//save to DB
});
}
var your_request_handler = (req,res) => {
third_party_auth(args, (tp_response)=>{
res.send();
//just do your tasks here
d... |
3,609,650 | I once used a scenario where I did a SQL where clause like this:
where
BranchName = CASE WHEN @pBranch <> '' then @pBranch else BranchName end
this is to say we're doing a branch name lookup, but this statement has to cater for the LIKE clause somehow. We need to be able to say 'If the pBranch parameter was provided... | 2010/08/31 | [
"https://Stackoverflow.com/questions/3609650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392591/"
] | you could say:
```
SELECT *
FROM dbo
WHERE @pBranch = '' OR BranchName = @pBranch
```
This basically says that if you pass in '' to @pBranch, then all results will be displayed, otherwise, if you pass in something else, it will search by your argument | try
```
Where BranchName Like IsNull(@Branch, BranchName)
``` |
3,609,650 | I once used a scenario where I did a SQL where clause like this:
where
BranchName = CASE WHEN @pBranch <> '' then @pBranch else BranchName end
this is to say we're doing a branch name lookup, but this statement has to cater for the LIKE clause somehow. We need to be able to say 'If the pBranch parameter was provided... | 2010/08/31 | [
"https://Stackoverflow.com/questions/3609650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392591/"
] | actually I think the answer I was looking for is as follows:
...
where
o.BranchName like case when @pBranchName <> '' then @pBranchName else o.BranchName end
... | try
```
Where BranchName Like IsNull(@Branch, BranchName)
``` |
3,609,650 | I once used a scenario where I did a SQL where clause like this:
where
BranchName = CASE WHEN @pBranch <> '' then @pBranch else BranchName end
this is to say we're doing a branch name lookup, but this statement has to cater for the LIKE clause somehow. We need to be able to say 'If the pBranch parameter was provided... | 2010/08/31 | [
"https://Stackoverflow.com/questions/3609650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392591/"
] | you could say:
```
SELECT *
FROM dbo
WHERE @pBranch = '' OR BranchName = @pBranch
```
This basically says that if you pass in '' to @pBranch, then all results will be displayed, otherwise, if you pass in something else, it will search by your argument | ```
where @pBranch = '' or BranchName like @pBranch
```
(add the wildcards to the appropriate spot in the like clause)
this will work for numbers, not just strings - so if you passed in an int parameter as a 0 or a value, you would do:
```
where @param = 0 or DBField = @param
``` |
3,609,650 | I once used a scenario where I did a SQL where clause like this:
where
BranchName = CASE WHEN @pBranch <> '' then @pBranch else BranchName end
this is to say we're doing a branch name lookup, but this statement has to cater for the LIKE clause somehow. We need to be able to say 'If the pBranch parameter was provided... | 2010/08/31 | [
"https://Stackoverflow.com/questions/3609650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392591/"
] | actually I think the answer I was looking for is as follows:
...
where
o.BranchName like case when @pBranchName <> '' then @pBranchName else o.BranchName end
... | ```
where @pBranch = '' or BranchName like @pBranch
```
(add the wildcards to the appropriate spot in the like clause)
this will work for numbers, not just strings - so if you passed in an int parameter as a 0 or a value, you would do:
```
where @param = 0 or DBField = @param
``` |
15,732 | I get this alert message [(screenshot from my phone)](https://imgur.com/65vRO) from my carrier after using the internet for sometime. The problem is that I get numerous messages (20+) like this when my phone is idle. I guess some apps are syncing in the background. The phone is unusable till I hit OK on all the alert b... | 2011/11/17 | [
"https://android.stackexchange.com/questions/15732",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/9702/"
] | This looks like a special kind of SMS message, sometimes called "flash SMS", that shows up instantaneously on the phones screen. I don't think that there is an option to block these messages and even if it would be possible I wouldn't encourage you to do so, because you could maybe miss some other important information... | This is a problem with your carrier where they send the last data usage details whenever a data connection session ends. It is not possible to disable it unless the network provider disables it.
However, you can try this small workaround by going to `Messaging`, selecting `Settings` in options, and disabling `Cell Bro... |
15,732 | I get this alert message [(screenshot from my phone)](https://imgur.com/65vRO) from my carrier after using the internet for sometime. The problem is that I get numerous messages (20+) like this when my phone is idle. I guess some apps are syncing in the background. The phone is unusable till I hit OK on all the alert b... | 2011/11/17 | [
"https://android.stackexchange.com/questions/15732",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/9702/"
] | [Balance Update / USSD blocker](https://play.google.com/store/apps/details?id=com.melkote.quietbalance)
You can install this app to block the Flash messages
This Does not support Android 4.2.2 | This is a problem with your carrier where they send the last data usage details whenever a data connection session ends. It is not possible to disable it unless the network provider disables it.
However, you can try this small workaround by going to `Messaging`, selecting `Settings` in options, and disabling `Cell Bro... |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [The Grothendieck-Brown correspondence](https://webusers.imj-prg.fr/%7Egeorges.maltsiniotis/ps/agrb_web.pdf)
As far as I know these letters are planned to be published alongside "Pursuing stacks" on [Documents Mathématiques](https://smf.emath.fr/en/publications/documents-mathematiques) | Some years ago, I was tracking the origins of fractional calculus and finally found a comprehensive list of [Leibniz correspondence](https://www.mv.helsinki.fi/home/mroinila/texts.htm). |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [The Grothendieck-Brown correspondence](https://webusers.imj-prg.fr/%7Egeorges.maltsiniotis/ps/agrb_web.pdf)
As far as I know these letters are planned to be published alongside "Pursuing stacks" on [Documents Mathématiques](https://smf.emath.fr/en/publications/documents-mathematiques) | I'm not sure whether this is a comprehensive example, but
[*Singularités Irrégulières: Correspondance et Documents*](https://smf.emath.fr/publications/singularites-irregulieres-correspondance-et-documents) (Société Mathématique de France, 2007)
contains correspondence from 1976 - 1991 between Pierre Deligne, Bernard ... |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [Élie Cartan and Albert Einstein, **Letters on Absolute Parallelism, 1929-1932** (Princeton Legacy Library), 1st ed., 1979, 978-0691082295](https://press.princeton.edu/books/hardcover/9780691636542/elie-cartan-and-albert-einstein) | [The Grothendieck-Brown correspondence](https://webusers.imj-prg.fr/%7Egeorges.maltsiniotis/ps/agrb_web.pdf)
As far as I know these letters are planned to be published alongside "Pursuing stacks" on [Documents Mathématiques](https://smf.emath.fr/en/publications/documents-mathematiques) |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [Correspondance Serre-Tate, Volume I+II](https://smf.emath.fr/publications/correspondance-serre-tate-volume-ii) | Some years ago, I was tracking the origins of fractional calculus and finally found a comprehensive list of [Leibniz correspondence](https://www.mv.helsinki.fi/home/mroinila/texts.htm). |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [Gauss' correspondence](https://gauss.adw-goe.de) is also easily available, for example [with Wolfgang Bolyai](https://gauss.adw-goe.de/discover?field=correspondent&filtertype=correspondent&filter_relational_operator=equals&filter=Bolyai%2C+Wolfgang), including the (in)famous passages about the discovery of non-Euclide... | One unusual example is Serge Lang, [The File: Case Study in Correction, 1977-1979](https://link.springer.com/book/10.1007/978-1-4613-8145-7) (Springer-Verlag, 1981), with both correspondence and the published documents which provoked it. Lang is the central correspondent in the file, and Neal Koblitz and Saunders Mac L... |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [Élie Cartan and Albert Einstein, **Letters on Absolute Parallelism, 1929-1932** (Princeton Legacy Library), 1st ed., 1979, 978-0691082295](https://press.princeton.edu/books/hardcover/9780691636542/elie-cartan-and-albert-einstein) | [2020 email correspondence](https://sreenidhi.edu.in/pdffls/A_Report_on_Riemann_Hypothesis_updated(25-06-21).pdf#page=93) between professor Władysław Narkiewicz, a very patient mathematician, and Dr. Kumar Eswaran, who claimed to have proven the Riemann conjecture.
It ends with this beautiful conclusion:
>
> Althoug... |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [The Euler archive](http://eulerarchive.maa.org/) contains more or less everything Leonard Euler ever wrote that still exists today, including his letter correspondence with various people. | Some years ago, I was tracking the origins of fractional calculus and finally found a comprehensive list of [Leibniz correspondence](https://www.mv.helsinki.fi/home/mroinila/texts.htm). |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [The Euler archive](http://eulerarchive.maa.org/) contains more or less everything Leonard Euler ever wrote that still exists today, including his letter correspondence with various people. | One unusual example is Serge Lang, [The File: Case Study in Correction, 1977-1979](https://link.springer.com/book/10.1007/978-1-4613-8145-7) (Springer-Verlag, 1981), with both correspondence and the published documents which provoked it. Lang is the central correspondent in the file, and Neal Koblitz and Saunders Mac L... |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [Gauss' correspondence](https://gauss.adw-goe.de) is also easily available, for example [with Wolfgang Bolyai](https://gauss.adw-goe.de/discover?field=correspondent&filtertype=correspondent&filter_relational_operator=equals&filter=Bolyai%2C+Wolfgang), including the (in)famous passages about the discovery of non-Euclide... | The book "[Der Briefwechsel Richard Dedekind – Heinrich Weber](https://www.degruyter.com/document/doi/10.1515/9783110368048/html)" transcribes the full correspondence between the two. From the description:
>
> This volume provides the very first transcription of correspondence between Richard Dedekind and Heinrich We... |
416,030 | What are great examples of comprehensively archived mathematical correspondence (including both handwritten and electronic items)?
Context: polished papers usually don't reveal the full process that accompanied the way definitions and proofs were conceived. For example, Colmez's [introduction](http://webusers.imj-prg.... | 2022/02/13 | [
"https://mathoverflow.net/questions/416030",
"https://mathoverflow.net",
"https://mathoverflow.net/users/469/"
] | [Grothendieck-Serre correspondence, bilingual edition](https://bookstore.ams.org/cgs) ([online](https://webusers.imj-prg.fr/%7Eleila.schneps/grothendieckcircle/Letters/GS.pdf)) | [The Grothendieck-Brown correspondence](https://webusers.imj-prg.fr/%7Egeorges.maltsiniotis/ps/agrb_web.pdf)
As far as I know these letters are planned to be published alongside "Pursuing stacks" on [Documents Mathématiques](https://smf.emath.fr/en/publications/documents-mathematiques) |
12,857,481 | ```
package com.example.tabactivity;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.net.ParseException;
import android.os.AsyncTask;
import android.os.... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12857481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1719722/"
] | The easiest would be to use a `List(Of Subject)` instead which can be resized. I would also create a class for the subject since you have two fields.
```
Dim subjects = New List(Of Subject)
Using con = New SqlConnection(connectionString)
Using cmd = New SqlCommand("StoredProcedureName", con)
cmd.CommandTyp... | You need `GetRows` method which will get your recordset data into an array:
```
array = recordset.GetRows(Rows, Start, Fields )
```
Basically execute your stored procedure and when you have the results use the GetRows method which returns a collection of rows from the result, given an array of unique column ID's.
Y... |
5,374,913 | My Zend framework routing setup is not working as desired. When I access "site", the code under application/modules/default/views/script/index/index.phtml is executed, as desired.
However, when I try "site/home", I get a 404 error page. The apache log shows ( File does not exist: /var/www/site/public/home). In additio... | 2011/03/21 | [
"https://Stackoverflow.com/questions/5374913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/669025/"
] | It refers to the global object (`window`).
*Edit:* Actually, it will refer to both, the global object **and** `o`, because they are the same. `o` will have a reference to the object returned from `F()` which is the object returned from `C()` which is the `window` object ;)
You can call `console.log(this)` to find out... | `this` refers to the global object in your program. To get `this` to reference the instance of `F`, try,
```
function F() {
function C() {
return this;
}
return C.call(this); // call C with the object of F as a context
}
var o = new F();
```
On Chrome, you could simply enter the variable to ... |
5,374,913 | My Zend framework routing setup is not working as desired. When I access "site", the code under application/modules/default/views/script/index/index.phtml is executed, as desired.
However, when I try "site/home", I get a 404 error page. The apache log shows ( File does not exist: /var/www/site/public/home). In additio... | 2011/03/21 | [
"https://Stackoverflow.com/questions/5374913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/669025/"
] | It refers to the global object (`window`).
*Edit:* Actually, it will refer to both, the global object **and** `o`, because they are the same. `o` will have a reference to the object returned from `F()` which is the object returned from `C()` which is the `window` object ;)
You can call `console.log(this)` to find out... | To add to the other answers:
When a function is called, `this` is set depending on how it's called. If it's called with `myfunc.call` or `myfunc.apply`, then `this` is set to the first passed argument. If it's called in the 'dotted' form, i.e. `myObject.myfunc()` then `this` is set to whatever is before the dot.
Ther... |
5,374,913 | My Zend framework routing setup is not working as desired. When I access "site", the code under application/modules/default/views/script/index/index.phtml is executed, as desired.
However, when I try "site/home", I get a 404 error page. The apache log shows ( File does not exist: /var/www/site/public/home). In additio... | 2011/03/21 | [
"https://Stackoverflow.com/questions/5374913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/669025/"
] | `this` refers to the global object in your program. To get `this` to reference the instance of `F`, try,
```
function F() {
function C() {
return this;
}
return C.call(this); // call C with the object of F as a context
}
var o = new F();
```
On Chrome, you could simply enter the variable to ... | To add to the other answers:
When a function is called, `this` is set depending on how it's called. If it's called with `myfunc.call` or `myfunc.apply`, then `this` is set to the first passed argument. If it's called in the 'dotted' form, i.e. `myObject.myfunc()` then `this` is set to whatever is before the dot.
Ther... |
1,753,788 | i know it must something simple that i missed. I use data services to get data into my silverlight application. When i bind the data to my datagrid it works like a charm
```
LessonGrid.ItemsSource = context.Lessons
```
however as soon as i try to wrap my objects into more complex data structure it stops working
```... | 2009/11/18 | [
"https://Stackoverflow.com/questions/1753788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/75672/"
] | Ok, i figured it out myself. It's something about implicit types that binding doesn't like. This shows empty grid
```
LessonGrid.ItemsSource = new[] {new {StartTime = 111, Text = "hi there"}};
```
but this renders data.
```
LessonGrid.ItemsSource = new[] {new Temp {StartTime = 111, Text = "hi there"}};
``` | You have created a Linq Query but has not actually executed yet. In order to actually execute you must do something like .ToList()
Try This:
```
LessonGrid.ItemsSource = context.Lessons.Select(l => new {Lesson = l; Color=Colors.Yellow}).ToList();
``` |
1,753,788 | i know it must something simple that i missed. I use data services to get data into my silverlight application. When i bind the data to my datagrid it works like a charm
```
LessonGrid.ItemsSource = context.Lessons
```
however as soon as i try to wrap my objects into more complex data structure it stops working
```... | 2009/11/18 | [
"https://Stackoverflow.com/questions/1753788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/75672/"
] | Ok, i figured it out myself. It's something about implicit types that binding doesn't like. This shows empty grid
```
LessonGrid.ItemsSource = new[] {new {StartTime = 111, Text = "hi there"}};
```
but this renders data.
```
LessonGrid.ItemsSource = new[] {new Temp {StartTime = 111, Text = "hi there"}};
``` | Are you sure that your Linq query return any items? And any items that include StartTime?
As I can see it your query returns an object that contain two parameters,Lesson and Color, but not StartTime. And I guess the separator between the parameters should be a comma (,).
```
LessonGrid.ItemsSource = context.Lessons.... |
131,834 | I went to the Garage that isn't the one at the safe house. I noticed that there was a prompt to press D-pad Right to access Special vehicles. So a list of one car opened and I selected it. This spawned me outside in a Eleghy RH8. Now not matter what I do to the car, I can go back to the garage and spawn a new one (Noth... | 2013/09/23 | [
"https://gaming.stackexchange.com/questions/131834",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55820/"
] | I think this is for cars bought in the Rockstar Store. The first one you get for free by joining the Rockstar Social Club. Cars bought on a dealers website are only delivered once to your garage. For the marina it is a bit different: There is only one slot and you can choose (by pressing LEFT on the D-Dad) which vessel... | I have not tried it for the garage itself yet, but I bought a slip at the marina and subsequently purchased boats from the "Internet" ingame. These appear in a list at the marina, which seems to be the same mechanic.
So I´d say, purchased vehicles are likely to appear in that list. |
131,834 | I went to the Garage that isn't the one at the safe house. I noticed that there was a prompt to press D-pad Right to access Special vehicles. So a list of one car opened and I selected it. This spawned me outside in a Eleghy RH8. Now not matter what I do to the car, I can go back to the garage and spawn a new one (Noth... | 2013/09/23 | [
"https://gaming.stackexchange.com/questions/131834",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55820/"
] | Vehicles purchased from the game Internet for game cash only appear in the garage once, ie if you trash it you gotta buy another. The special vehicle list must be something else (I've only got the Elegy too). | I have not tried it for the garage itself yet, but I bought a slip at the marina and subsequently purchased boats from the "Internet" ingame. These appear in a list at the marina, which seems to be the same mechanic.
So I´d say, purchased vehicles are likely to appear in that list. |
131,834 | I went to the Garage that isn't the one at the safe house. I noticed that there was a prompt to press D-pad Right to access Special vehicles. So a list of one car opened and I selected it. This spawned me outside in a Eleghy RH8. Now not matter what I do to the car, I can go back to the garage and spawn a new one (Noth... | 2013/09/23 | [
"https://gaming.stackexchange.com/questions/131834",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55820/"
] | Thats where the collector's edition unique vehicles are :) like the Hotknife and Carbon RS, but you can only get those with a DLC code if you bought the collector's edition game.. or maybe buy a code on eBay. | I have not tried it for the garage itself yet, but I bought a slip at the marina and subsequently purchased boats from the "Internet" ingame. These appear in a list at the marina, which seems to be the same mechanic.
So I´d say, purchased vehicles are likely to appear in that list. |
131,834 | I went to the Garage that isn't the one at the safe house. I noticed that there was a prompt to press D-pad Right to access Special vehicles. So a list of one car opened and I selected it. This spawned me outside in a Eleghy RH8. Now not matter what I do to the car, I can go back to the garage and spawn a new one (Noth... | 2013/09/23 | [
"https://gaming.stackexchange.com/questions/131834",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55820/"
] | I think this is for cars bought in the Rockstar Store. The first one you get for free by joining the Rockstar Social Club. Cars bought on a dealers website are only delivered once to your garage. For the marina it is a bit different: There is only one slot and you can choose (by pressing LEFT on the D-Dad) which vessel... | Vehicles purchased from the game Internet for game cash only appear in the garage once, ie if you trash it you gotta buy another. The special vehicle list must be something else (I've only got the Elegy too). |
131,834 | I went to the Garage that isn't the one at the safe house. I noticed that there was a prompt to press D-pad Right to access Special vehicles. So a list of one car opened and I selected it. This spawned me outside in a Eleghy RH8. Now not matter what I do to the car, I can go back to the garage and spawn a new one (Noth... | 2013/09/23 | [
"https://gaming.stackexchange.com/questions/131834",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55820/"
] | I think this is for cars bought in the Rockstar Store. The first one you get for free by joining the Rockstar Social Club. Cars bought on a dealers website are only delivered once to your garage. For the marina it is a bit different: There is only one slot and you can choose (by pressing LEFT on the D-Dad) which vessel... | Thats where the collector's edition unique vehicles are :) like the Hotknife and Carbon RS, but you can only get those with a DLC code if you bought the collector's edition game.. or maybe buy a code on eBay. |
131,834 | I went to the Garage that isn't the one at the safe house. I noticed that there was a prompt to press D-pad Right to access Special vehicles. So a list of one car opened and I selected it. This spawned me outside in a Eleghy RH8. Now not matter what I do to the car, I can go back to the garage and spawn a new one (Noth... | 2013/09/23 | [
"https://gaming.stackexchange.com/questions/131834",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55820/"
] | Vehicles purchased from the game Internet for game cash only appear in the garage once, ie if you trash it you gotta buy another. The special vehicle list must be something else (I've only got the Elegy too). | Thats where the collector's edition unique vehicles are :) like the Hotknife and Carbon RS, but you can only get those with a DLC code if you bought the collector's edition game.. or maybe buy a code on eBay. |
14,854 | I have a long video and wish to cut pauses and unneeded places from it. Currently I know how to select mark ins and mark outs

Unfortunately, this does not allow to have multiple ins and outs in single clip.
If I cut multiple clips from one video, ... | 2015/02/15 | [
"https://avp.stackexchange.com/questions/14854",
"https://avp.stackexchange.com",
"https://avp.stackexchange.com/users/2122/"
] | You need to create a **sequence**. If you're not familiar with video codecs, the easiest way to do so is to right-click on your clip in the project panel and select **New sequence from clip ...**, which will create a sequence using the resolution and framerate from your clip.
Once you've created the sequence, it shoul... | You cannot have multiple marks in and out on clip.
What you would do is you would mark a clip and drop it in a sequence (the timeline).
Mark another clip and drop it in the timeline. Son on and so forth.
The issue you would have is the sound just clips as it jumps from clip to clip in the sequence. The quickest way t... |
23,319,271 | I am using codeigniter and I am trying to get all rows from a database table that are past due and only the ones that are past due.
The table includes a column that is titled `due_date` and is formatted as a `datetime`
`Past Due` stands for anything with a `due_date` prior to todays date. So for example, if the due ... | 2014/04/27 | [
"https://Stackoverflow.com/questions/23319271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2673735/"
] | **Try This :**
```
$query=$this->db
->where('DATE_FORMAT(due_date, "%Y-%m-%d") <',"date('Y-m-d')")
->get('practice');
```
Source: [[How to select date from datetime column?](https://stackoverflow.com/questions/1754411/how-to-select-date-from-datetime-column]) | Quick Google search gives me a solution where this should be possible:
```
$query = $this->db->where('practice', array('due_date <' => date('Y-m-d')))->get();
```
Source: <http://ellislab.com/codeigniter/user-guide/database/active_record.html> |
23,319,271 | I am using codeigniter and I am trying to get all rows from a database table that are past due and only the ones that are past due.
The table includes a column that is titled `due_date` and is formatted as a `datetime`
`Past Due` stands for anything with a `due_date` prior to todays date. So for example, if the due ... | 2014/04/27 | [
"https://Stackoverflow.com/questions/23319271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2673735/"
] | **Try This :**
```
$query=$this->db
->where('DATE_FORMAT(due_date, "%Y-%m-%d") <',"date('Y-m-d')")
->get('practice');
```
Source: [[How to select date from datetime column?](https://stackoverflow.com/questions/1754411/how-to-select-date-from-datetime-column]) | ```
$query = $this->db->get_where('practice', array('DATE_FORMAT(due_date, "%Y-%m-%d") <' => date('Y-m-d')));
``` |
70,331,109 | I 'm a total beginner in **C++** and getting crazy trying to embed **Python** in **C++** using **VS Code** IDE and **GCC** compiler.
I am stock and now I 'm keep facing this silly error that says:
>
> python.h: No such file or directory gcc
>
>
>
I have followed steps explaned in ["Using GCC with MinGW in VS Code... | 2021/12/13 | [
"https://Stackoverflow.com/questions/70331109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13698448/"
] | The problem was a combinations of simple mistakes and as a beginner I solved it by some digging in [gcc -l -L option flags for library link example](https://www.rapidtables.com/code/linux/gcc/gcc-l.html) and [gcc arguments docs](https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html).
There are several simple and impo... | Ok so you should probably go through like a intermediate c++ course first, but if u are a begginer and you really want to do this I recommend using visual studio 2019 or 2022, because it is way more begginer-friendly and the dependencies are all set in a gui interface.
BTW i would've commented this but I don't have 50 ... |
87,034 | How might I find matrix $M\in M\_2(\mathbb C)$ such that $M^t A =M^{-1}$
where $A=\left[
\begin{array}{cc}
a & a \\
a & a+1 \\
\end{array}
\right]\in M\_2(\mathbb N)$ without using the brute force method of writing $M=\left[
\begin{array}{cc}
a & b \\
c & d \\
\end{array}
\right]$? (I don't quite kn... | 2011/11/30 | [
"https://math.stackexchange.com/questions/87034",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/20383/"
] | We can rewrite your equation as
$$MM^T = A^{-1},$$
where
$$A^{-1} = \left[\begin{array}{cc} 1 + \frac{1}{a} & -1 \\ -1 & 1\end{array}\right]$$
is real, symmetric positive-definite. The Cholesky decomposition of $A^{-1}$ thus supplies such an $M$:
$$M = \left[\begin{array}{cc}\sqrt{\frac{a+1}{a}} & 0\\-\sqrt{\frac{a}{a+... | Clearly $a$ is nonzero, or else $M^\top A$ is non-invertible and it cannot be equal to the invertible matrix $M^{-1}$. Now,
$$
\begin{align}
A=\begin{pmatrix}a&a\\a&a+1\end{pmatrix}
&=\begin{pmatrix}a&a\\a&a\end{pmatrix}+\begin{pmatrix}0&0\\0&1\end{pmatrix}\\
&=\begin{pmatrix}\sqrt{a}\\ \sqrt{a}\end{pmatrix}\begin{... |
87,034 | How might I find matrix $M\in M\_2(\mathbb C)$ such that $M^t A =M^{-1}$
where $A=\left[
\begin{array}{cc}
a & a \\
a & a+1 \\
\end{array}
\right]\in M\_2(\mathbb N)$ without using the brute force method of writing $M=\left[
\begin{array}{cc}
a & b \\
c & d \\
\end{array}
\right]$? (I don't quite kn... | 2011/11/30 | [
"https://math.stackexchange.com/questions/87034",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/20383/"
] | You can also rephrase the problem as find a matrix $M$ such that $M^TAM = I$. It is relatively simple once you see that eliminating the matrix entries are easy to handle with $A$.
$$
\pmatrix{1&0\\-1&1}
\pmatrix{a & a \\a & a+1}\pmatrix{1&-1\\0&1} = \pmatrix{a&0\\0&1}$$
Seeing that we have an extra $a$ term left we r... | Clearly $a$ is nonzero, or else $M^\top A$ is non-invertible and it cannot be equal to the invertible matrix $M^{-1}$. Now,
$$
\begin{align}
A=\begin{pmatrix}a&a\\a&a+1\end{pmatrix}
&=\begin{pmatrix}a&a\\a&a\end{pmatrix}+\begin{pmatrix}0&0\\0&1\end{pmatrix}\\
&=\begin{pmatrix}\sqrt{a}\\ \sqrt{a}\end{pmatrix}\begin{... |
77,860 | I have a database schema :
```
member(memb_no, name, age)
book(isbn, title, authors, publisher)
borrowed(memb_no, isbn, date)
```
This is the question:
>
> For each publisher, print the names of members who have borrowed more than five
> books of that publisher.
>
>
>
How do I write query for this?
B... | 2014/09/27 | [
"https://dba.stackexchange.com/questions/77860",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/48285/"
] | Try this out:
```
WITH publisher_memb_cte (publisher,memb_no)
AS
(
SELECT b.publisher,r.memb_no
FROM book b
JOIN borrowed r ON b.isbn=r.isbn
group by b.publisher,r.memb_no
HAVING count (*)>5
)
SELECT cte.publisher, m.name
FROM publisher_memb_cte cte
JOIN member m on cte.memb_no = m.memb_no
```
Tips to avoid perform... | ```
with book_borrowed(memb_no , isbn , publisher) as
( select memb_no , borrowed.isbn , publisher
from
book join borrowed on book.isbn = borrowed.isbn
)
select name , publisher
from book_borrowed join member on book_borrowed.memb_no = member.memb_no
group by member.memb_n... |
13,277,278 | I need to create a post action to listen to bunch of event messages in ASP.NET MVC 4. There are lots of events so I cannot create an action per event. So it would be best to create an action with their base class as posted model use a custom model binder to hydrate the event.
Some of the events look like this:
```
pu... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13277278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/123800/"
] | Mere model binding would not help you here. The way model binding works is, framework looks at the type of the parameter that actions expects, creates a default instance of that type using reflection and hydrates every public property on it using the data sent in the form.
The parameter in your action is an interface... | A custom model binder provider can be written to support interfaces in MVC3+, see this post.
<http://www.matthidinger.com/archive/2011/08/16/An-inheritance-aware-ModelBinderProvider-in-MVC-3.aspx>
Any types that inherit the particular interface are then passed to the relevant model binder which can then likely try a ... |
73,775,026 | How can I update the state for all of the errors?
for example, I have to validate the fields name and last name:
```
const handleSubmit = () => {
const { name, lastName } = fields
let existError = false
if (!verify(name)) {
existError = true
setError({ ...error, ['name']: 'name is bad' })
... | 2022/09/19 | [
"https://Stackoverflow.com/questions/73775026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19961526/"
] | The value of `error` within your `handleSubmit` function won't update until the next render, so when you set lastName:
```
setError({ ...error, ['lastName']: 'lastname is bad' })
```
`error` still doesn't have the `name` property and you end up overwriting the name update with the lastName update.
You're effectivel... | Try this instead:
```
if(!verify(name)){
setState(prevError => {
return {...prevError, name: 'name is bad'}
});
}
if(!verify(lastName)){
setState(prevError => {
return {...prevError, lastName: 'lastName is bad'}
});
}
```
The value `error` wasn't updated after the first if block, due... |
39,741,281 | I'm pretty sure my question doesn't totally make sense, but I'm trying to create a classification tree in R using 'rpart' and initially had the fit as something like:
```
fit <- rpart(success ~ A + B + C)
```
I have now realised 'success' might also be measured by another 'value'. So I was going to amend it to:
```... | 2016/09/28 | [
"https://Stackoverflow.com/questions/39741281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6781056/"
] | This means that your tree algorithm has not created any splits. You can use the cp parameter to increase the complexity of your tree. the default value of cp is 0.01 so you can try 0.001. but note that this might imply you are over fitting your model.
p.s.. you can only have on response variable not var1 + var 2... if... | For me it works when I write it as:
```r
fit <- rpart(cbind(success, new_option) ~ A + B + C)
``` |
82,271 | I tried this example [Place four algorithms (algorithm2e) in a subfigure and arrange them in two rows and two columns](https://tex.stackexchange.com/questions/40365/place-four-algorithms-algorithm2e-in-a-subfigure-and-arrange-them-in-two-rows) on two column documents. It doesn't work. The error message is
```
! LaTeX ... | 2012/11/11 | [
"https://tex.stackexchange.com/questions/82271",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/21704/"
] | [`algorithm2e`](http://ctan.org/pkg/algorithm2e) provides its own `[H]` float parameter, which sidesteps setting its contents as a float. However, in `twocolumn` mode, it produces an error. I'm not sure why. You can avoid this by setting `\@latex@error` to `\@gobble` temporarily. Using your example, I've added a `\remo... | I had similar issues...
I simply removed [H] from the code as below.
```
\begin{algorithm*}[H]
```
to
```
\begin{algorithm*}
```
Then the issue solved. |
40,280,620 | I am working with Java EE 7 in Intellij IDEA and trying to create and use a custom .tag file. I have followed [this](https://stackoverflow.com/a/3257426/4545369) answer and created a wrapper.tag file in WEB-INF/tags :
```
<%@tag description="Simple Wrapper Tag" pageEncoding="UTF-8"%>
<html><body>
<jsp:doBody/>
</bod... | 2016/10/27 | [
"https://Stackoverflow.com/questions/40280620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4545369/"
] | Two things you need to check, I was also facing the same problem
1. `<%@ taglib tagdir="/WEB-INF/tags/" prefix="tag" %>` add '/' after tags
2. In the `tagdir` path there should be no spelling mistakes, I had forgot to add 's' to `tags` folder. | I've also met this problem before. Turn out, my tags folder in out/artifacts/WEB-INF wasn't updated after I renamed the folder. You may want to check that.
I'm not good at Java. In fact, I'm a C# dev. My solution is to manually rename the folder. There must be a way that we can update these actions automatically that... |
29,226,743 | I am learning regex,when I compile this code which is from Java Official documentation, I am getting `No Console` error in this code,The [source is](https://docs.oracle.com/javase/tutorial/essential/regex/test_harness.html), I am compiling this code in Eclipse, version Kepler.
The culprit is `Console console = System.... | 2015/03/24 | [
"https://Stackoverflow.com/questions/29226743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4706252/"
] | >
> but I do not know why the error is caused
>
>
>
Presumably because you're not running it in a console. When you run a Java app in Eclipse, `System.console()` returns null, because it's not a "normal" console. (Personally I think it would be better if Eclipse's console view could be used as the console for this... | This switches all the console stuff to System.in and System.out
```
import java.util.regex.Pattern;
import java.util.Scanner;
import java.util.regex.Matcher;
public class RegexTestHarness {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
while (true) {
... |
15,857,079 | I am trying to build a simple level app. What I want is when the device is totally flat (x,y values of accelerometer almost 0) for the device to produce a beep sound after 5 seconds, not immediately.
I am using the following code, and I do not know what I must changed in order for the sound to always works after 5 se... | 2013/04/06 | [
"https://Stackoverflow.com/questions/15857079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1380135/"
] | Your specific issue here is that you are mixing jQuery and raw javascript.
To set the width of an element with jQuery, use the [width()](http://api.jquery.com/width) or [css()](http://api.jquery.com/css/) method:
```
$(".content").width(560);
$(".content").css('width',560);
```
Having said that, you may be better o... | You can try and just use jQuery and CSS
```
function checkWindowSize() {
if ( $(window).width() > 1800 ) {
$('content').addClass('large');
}
else {
$('content').removeClass('large');
}
}
$(window).resize(checkWindowSize);
```
For the CSS you would need to write... |
67,810,954 | I want to match number like---
**10** **, -10,** **10E5** **,10e5**
as an integer number and number like--
**10.554** **,-10.5** **,10.5E5** **,-10.5e-5**
as a floating pointer number.
How can I achieve it in lexical analyzer FLEX?
I am trying in this way:
```
^[+-]?\d+([eE][-+]?[0-9]+)?$ {++CountInteger;}
^[-+]... | 2021/06/02 | [
"https://Stackoverflow.com/questions/67810954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12517195/"
] | You need to remove ^ and $ unless you want to match lines which contain nothing other than a single number. When you have a problem with a regular expression, build it up by in small steps and make sure it works as you expect after each step. | If you already have proven that you are working with a number and all you need is to see if it is an integer or a floating point number, your regex could be super simple by just checking for the existence of a `.`.
e.g. the pattern would be `"\."`. If that works for you - awesome! Easier is often better!
If you need ... |
67,810,954 | I want to match number like---
**10** **, -10,** **10E5** **,10e5**
as an integer number and number like--
**10.554** **,-10.5** **,10.5E5** **,-10.5e-5**
as a floating pointer number.
How can I achieve it in lexical analyzer FLEX?
I am trying in this way:
```
^[+-]?\d+([eE][-+]?[0-9]+)?$ {++CountInteger;}
^[-+]... | 2021/06/02 | [
"https://Stackoverflow.com/questions/67810954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12517195/"
] | You need to remove ^ and $ unless you want to match lines which contain nothing other than a single number. When you have a problem with a regular expression, build it up by in small steps and make sure it works as you expect after each step. | A little visualizion:
[![path of -?\d+([eE]-?\d+)?](https://i.stack.imgur.com/2WMNk.png)](https://i.stack.imgur.com/2WMNk.png)
(created at [jex.im](https://jex.im/regulex/#!flags=&re=-%3F%5Cd%2B(%5BeE%5D-%3F%5Cd%2B)%3F))
See also:
* [Debuggex](https://debuggex.com)
* [Regex101](https://regex101.com/) |
54,565,168 | I am creating a menu page with several links for use by a group of teachers. I want the links to be seen as buttons for ease of navigation on a desktop, touchscreen or phone. The css I have is below:
```
a.buttons:link, a:visited {
background: #001E60; /* For browsers that do not support gradients */
backgroun... | 2019/02/07 | [
"https://Stackoverflow.com/questions/54565168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3395907/"
] | You're missing: `vertical-align:top;`
>
> The vertical-align CSS property sets vertical alignment of an inline
> or table-cell box.
>
>
>
Refer to [this](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) for more info([Related](https://stackoverflow.com/questions/21990281/why-are-these-two-identic... | I fixed ya up with flexbox, moved some CSS around, and wrapped your A's in DIVs. ALWAYS wrap your elements in divs for layout:
```css
.link-boxes
{
display: flex;
flex-wrap: wrap;
}
.link-boxes > div
{
padding: 0.5em;
display: flex;
background: #001E60; /* For browsers that do not support gradients */... |
3,455,208 | Surely the compiler knows that it's the last label of the `switch` statement? | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327528/"
] | According to <http://msdn.microsoft.com/en-us/library/06tc147t.aspx>
>
> You cannot "fall through" any switch section, including the last one.
>
>
>
Fall through can be avoided by any of the following: break, goto, or return. | As mentioned, you can use default:, but consider case null too. case null: does need a break;
case null:
iEvaluatedToNothing();
break;
If you want to "waterfall" down you can do something like this;
```
switch (deliverMail)
{
case null:
case "":
case "Address0":
deliverMail0();
goto case ... |
3,455,208 | Surely the compiler knows that it's the last label of the `switch` statement? | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327528/"
] | When using a `switch`, to `break` is not the only option. You also have the option of going to another case, going to the default case, going to another label, or returning. It is also possible to have multiple cases that have a single implementation body. Since there are up to five options plus the ability to have mul... | As mentioned, you can use default:, but consider case null too. case null: does need a break;
case null:
iEvaluatedToNothing();
break;
If you want to "waterfall" down you can do something like this;
```
switch (deliverMail)
{
case null:
case "":
case "Address0":
deliverMail0();
goto case ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.