qid int64 1 74.6M | question stringlengths 45 24.2k | date stringlengths 10 10 | metadata stringlengths 101 178 | response_j stringlengths 32 23.2k | response_k stringlengths 21 13.2k |
|---|---|---|---|---|---|
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | Combining the methods from Pankaj Sharma and Jean Monet, I wrote the following snippet that acts as asyncio.run (with slightly different syntax), but also works within a Jupyter notebook.
```
class RunThread(threading.Thread):
def __init__(self, func, args, kwargs):
self.func = func
self.args = arg... | I found the [`unsync`](https://github.com/alex-sherman/unsync) package useful for writing code that behaves the same way in a Python script and the Jupyter REPL.
```py
import asyncio
from unsync import unsync
@unsync
async def demo_async_fn():
await asyncio.sleep(0.1)
return "done!"
print(demo_async_fn().res... |
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | Just use this:
<https://github.com/erdewit/nest_asyncio>
```
import nest_asyncio
nest_asyncio.apply()
``` | Combining the methods from Pankaj Sharma and Jean Monet, I wrote the following snippet that acts as asyncio.run (with slightly different syntax), but also works within a Jupyter notebook.
```
class RunThread(threading.Thread):
def __init__(self, func, args, kwargs):
self.func = func
self.args = arg... |
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | The [`asyncio.run()`](https://docs.python.org/3.7/library/asyncio-task.html#asyncio.run) documentation says:
>
> This function [cannot](https://github.com/python/cpython/blob/3.8/Lib/asyncio/runners.py#L32-L34) be called when another asyncio event loop is running in the same thread.
>
>
>
In your case, jupyter ([... | Combining the methods from Pankaj Sharma and Jean Monet, I wrote the following snippet that acts as asyncio.run (with slightly different syntax), but also works within a Jupyter notebook.
```
class RunThread(threading.Thread):
def __init__(self, func, args, kwargs):
self.func = func
self.args = arg... |
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | The [`asyncio.run()`](https://docs.python.org/3.7/library/asyncio-task.html#asyncio.run) documentation says:
>
> This function [cannot](https://github.com/python/cpython/blob/3.8/Lib/asyncio/runners.py#L32-L34) be called when another asyncio event loop is running in the same thread.
>
>
>
In your case, jupyter ([... | Just use this:
<https://github.com/erdewit/nest_asyncio>
```
import nest_asyncio
nest_asyncio.apply()
``` |
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | Combining the methods from Pankaj Sharma and Jean Monet, I wrote the following snippet that acts as asyncio.run (with slightly different syntax), but also works within a Jupyter notebook.
```
class RunThread(threading.Thread):
def __init__(self, func, args, kwargs):
self.func = func
self.args = arg... | As cglacet mentioned that documentation says
>
> This function cannot be called when another asyncio event loop is
> running in the same thread.
>
>
>
You can use another thread i.e -
```
class ResolveThread(threading.Thread):
def __init__(self,result1,fun,url):
self.result1= resul... |
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | The [`asyncio.run()`](https://docs.python.org/3.7/library/asyncio-task.html#asyncio.run) documentation says:
>
> This function [cannot](https://github.com/python/cpython/blob/3.8/Lib/asyncio/runners.py#L32-L34) be called when another asyncio event loop is running in the same thread.
>
>
>
In your case, jupyter ([... | As cglacet mentioned that documentation says
>
> This function cannot be called when another asyncio event loop is
> running in the same thread.
>
>
>
You can use another thread i.e -
```
class ResolveThread(threading.Thread):
def __init__(self,result1,fun,url):
self.result1= resul... |
55,409,656 | I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset
I have some error in my code I don't know who I can fix it.
code:
[enter image description here][1]
[enter image description here][2] | 2019/03/29 | ['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/'] | To add to `cglacet`'s answer - if one wants to detect whether a loop is running and adjust automatically (ie run `main()` on the existing loop, otherwise `asyncio.run()`), here is a snippet that may prove useful:
```py
# async def main():
# ...
try:
loop = asyncio.get_running_loop()
except RuntimeError: # 'R... | Combining the methods from Pankaj Sharma and Jean Monet, I wrote the following snippet that acts as asyncio.run (with slightly different syntax), but also works within a Jupyter notebook.
```
class RunThread(threading.Thread):
def __init__(self, func, args, kwargs):
self.func = func
self.args = arg... |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | ### PL/pgSQL function
To solve the problem at hand, a plpgsql function like the following should be faster:
```
CREATE OR REPLACE FUNCTION func(int)
RETURNS TABLE (title text, stock int) LANGUAGE plpgsql AS
$BODY$
BEGIN
RETURN QUERY
SELECT p.title, p.stock
FROM product p
WHERE p.unique_id = $1; -- Put the most ... | There's an easier way to generate unique IDs using three separate auto\_increment columns. Just prepend a letter to the ID to uniquify it:
Colors:
```
C0000001
C0000002
C0000003
```
Sizes:
```
S0000001
S0000002
S0000003
...
```
Products:
```
P0000001
P0000002
P0000003
...
```
A few advantages:
* Y... |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | I think it's time for a redesign.
You have things that you're using as bar codes for items that are basically all the same in one respect (they are SerialNumberItems), but have been split into multiple tables because they are different in other respects.
I have several ideas for you:
Change the Defaults
------------... | There's an easier way to generate unique IDs using three separate auto\_increment columns. Just prepend a letter to the ID to uniquify it:
Colors:
```
C0000001
C0000002
C0000003
```
Sizes:
```
S0000001
S0000002
S0000003
...
```
Products:
```
P0000001
P0000002
P0000003
...
```
A few advantages:
* Y... |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | ### PL/pgSQL function
To solve the problem at hand, a plpgsql function like the following should be faster:
```
CREATE OR REPLACE FUNCTION func(int)
RETURNS TABLE (title text, stock int) LANGUAGE plpgsql AS
$BODY$
BEGIN
RETURN QUERY
SELECT p.title, p.stock
FROM product p
WHERE p.unique_id = $1; -- Put the most ... | Your query will be pretty much efficient, as long as you have an index on `unique_id`, on every table and indices on the joining columns.
You could turn those `UNION` into `UNION ALL` but the won't be any differnce on performance, for this query. |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | ### PL/pgSQL function
To solve the problem at hand, a plpgsql function like the following should be faster:
```
CREATE OR REPLACE FUNCTION func(int)
RETURNS TABLE (title text, stock int) LANGUAGE plpgsql AS
$BODY$
BEGIN
RETURN QUERY
SELECT p.title, p.stock
FROM product p
WHERE p.unique_id = $1; -- Put the most ... | I think it's time for a redesign.
You have things that you're using as bar codes for items that are basically all the same in one respect (they are SerialNumberItems), but have been split into multiple tables because they are different in other respects.
I have several ideas for you:
Change the Defaults
------------... |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | ### PL/pgSQL function
To solve the problem at hand, a plpgsql function like the following should be faster:
```
CREATE OR REPLACE FUNCTION func(int)
RETURNS TABLE (title text, stock int) LANGUAGE plpgsql AS
$BODY$
BEGIN
RETURN QUERY
SELECT p.title, p.stock
FROM product p
WHERE p.unique_id = $1; -- Put the most ... | This is a bit different. I don't understand the intended behaviour if stocks exists in more than one of the {product,color,zsize} tables. (UNION will remove duplicates, but for the row-as-a-whole, eg the {product\_id,stock} tuples. That makes no sense to me. I just take the first. (Note the funky self-join!!)
```
SELE... |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | I think it's time for a redesign.
You have things that you're using as bar codes for items that are basically all the same in one respect (they are SerialNumberItems), but have been split into multiple tables because they are different in other respects.
I have several ideas for you:
Change the Defaults
------------... | Your query will be pretty much efficient, as long as you have an index on `unique_id`, on every table and indices on the joining columns.
You could turn those `UNION` into `UNION ALL` but the won't be any differnce on performance, for this query. |
11,422,517 | I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes.
```
product color size
------- ------- -------
id id id
unique_id id_product (FK fr... | 2012/07/10 | ['https://Stackoverflow.com/questions/11422517', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/999820/'] | I think it's time for a redesign.
You have things that you're using as bar codes for items that are basically all the same in one respect (they are SerialNumberItems), but have been split into multiple tables because they are different in other respects.
I have several ideas for you:
Change the Defaults
------------... | This is a bit different. I don't understand the intended behaviour if stocks exists in more than one of the {product,color,zsize} tables. (UNION will remove duplicates, but for the row-as-a-whole, eg the {product\_id,stock} tuples. That makes no sense to me. I just take the first. (Note the funky self-join!!)
```
SELE... |
597,528 | From Wikipedia I have the compliment of the CDF parameterized for fat-tails distributions.
$$
\Pr[X>x] \sim x^{- \alpha}\text{ as }x \to \infty,\qquad \alpha > 0.\,
$$
Here $\alpha$ is the fatness parameter. According to Taleb. $\alpha \leq 2.5$ is forecastable, but $\alpha > 2.5$ is not.
I would like to fit $\alpha... | 2022/11/30 | ['https://stats.stackexchange.com/questions/597528', 'https://stats.stackexchange.com', 'https://stats.stackexchange.com/users/142914/'] | There are several issues with this question.
### The error message
The simplest, is the issue about the error message which is the explicit question in the text.
>
> Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
> NA/NaN/Inf in 'y'
>
>
>
The error says that the dependent variable in t... | #### You might want to use the `tailplot` function in the `utilities` package
The standard way of examining tail behaviour of data is through a tail-plot or a Hill plot (or variations of these). The tailplot shows the tails of a dataset against the empirical tail probability, each exhibited on a logarithmic scale. The... |
5,174,788 | I have a Perl controller class in which I do:
```
sub func1 {
my $f1 = Model::myModel->new();
my $param = "test";
$f1->func2($param);
}
```
Model class:
```
sub new {
my ($class, %arg) = @_;
my $self = bless {}, $class;
return $self;
}
sub func2 {
my ($self, $param) = shift(@_);
... | 2011/03/02 | ['https://Stackoverflow.com/questions/5174788', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/67476/'] | `shift` only shifts the first value off of `@_`. `perldoc -f shift` will tell you more about how shift works.
You want:
```
my( $self, $param ) = @_;
```
You had it right in `new()`. Not sure what happened ;)
Actually, FYI, your `new()` will give the warning:
```
Odd number of elements in hash assignment
```
If... | Try:
```
sub func2 {
my ( $self, $param ) = @_;
warn $param;
}
```
or
```
sub func2 {
my $self = shift @_;
my $param = shift @_;
warn $param;
}
``` |
184,845 | This is my current partition table:

In which `/dev/sda8` is the partition on Which I am currently running my primary OS - [Trisquel](https://trisquel.info) GNU/Linux (you can see it's mount point as `/`). The `/dev/sda1` is the primary partition containing Windows XP.
... | 2015/02/14 | ['https://unix.stackexchange.com/questions/184845', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/66803/'] | My guess is that Windows XP places a master file table at the end of the partition, preventing you from resizing it. You should be able to move the master file table from within XP. Also maybe you need to defrag the Windows partition? And finally, are you sure you unmounted sda1? Run `df` in a terminal and make sure yo... | Try running a chkdsk and/or scandisk in Windows [to rule out bad sectors & other inconcistencies] then attempt to resize. |
184,845 | This is my current partition table:

In which `/dev/sda8` is the partition on Which I am currently running my primary OS - [Trisquel](https://trisquel.info) GNU/Linux (you can see it's mount point as `/`). The `/dev/sda1` is the primary partition containing Windows XP.
... | 2015/02/14 | ['https://unix.stackexchange.com/questions/184845', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/66803/'] | Before you can resize any ntfs based partition, you need to ensure all the files are pushed up to the start of the partition. This is acomplisehd by running the defragmentation process on the partition within windowsXP.
It may also be useful to delete any temporal files or any other stuff you don't want from the window... | My guess is that Windows XP places a master file table at the end of the partition, preventing you from resizing it. You should be able to move the master file table from within XP. Also maybe you need to defrag the Windows partition? And finally, are you sure you unmounted sda1? Run `df` in a terminal and make sure yo... |
184,845 | This is my current partition table:

In which `/dev/sda8` is the partition on Which I am currently running my primary OS - [Trisquel](https://trisquel.info) GNU/Linux (you can see it's mount point as `/`). The `/dev/sda1` is the primary partition containing Windows XP.
... | 2015/02/14 | ['https://unix.stackexchange.com/questions/184845', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/66803/'] | Before you can resize any ntfs based partition, you need to ensure all the files are pushed up to the start of the partition. This is acomplisehd by running the defragmentation process on the partition within windowsXP.
It may also be useful to delete any temporal files or any other stuff you don't want from the window... | Try running a chkdsk and/or scandisk in Windows [to rule out bad sectors & other inconcistencies] then attempt to resize. |
69,677,554 | I am extreme beginner and I have this dumb problem.
So I wrote a css file and html file.
HTML :
```
<!DOCTYPE html>
<html>
<body>
<img
src="https://i.pinimg.com/originals/67/b2/a9/67b2a9ba5e85822f237caae92111e938.gif"
width="300" id="para1">
<... | 2021/10/22 | ['https://Stackoverflow.com/questions/69677554', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/17187107/'] | You must tell your HMTL page where to find your CSS.
To do that you have to add `link` tag into your `head` tag using:
```
<head>
<link href="/path/to/your/style.css" rel="stylesheet">
</head>
```
`<link>`: The External Resource Link element
>
> The HTML element specifies relationships between the current
> do... | >
> Also should for website developing, should I learn css and html at the
> same time, or like html for 1 year, and then css for one year, because
> im learning javascript like in a 2 years, next year.
>
>
>
Well, HTML, CSS & JS are the fabric of the front end so my advice is why not all three at the same time? T... |
4,307,118 | I've a JSONArray and I need to get the hashmap with the values, because I need to populate a stream, like twitter done.
What you suggest to do? | 2010/11/29 | ['https://Stackoverflow.com/questions/4307118', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/496371/'] | ```
HashMap<String, String> pairs = new HashMap<String, String>();
for (int i = 0; i < myArray.length(); i++) {
JSONObject j = myArray.optJSONObject(i);
Iterator it = j.keys();
while (it.hasNext()) {
String n = it.next();
pairs.put(n, j.getString(n));
}
}
```
Something like that. | You can use `Iterator` for getting `JsonArrays`. or use this way
eg. json
```
{
........
........
"FARE":[ //JSON Array
{
"REG_ID":3,
"PACKAGE_ID":1,
"MODEL_ID":9,
"MIN_HOUR":0
.......
.......
.......
}
]
}
```
>
>
> ```
> HashMap<String, String> mMap= new HashMap<>()... |
25,467,734 | I have a JXTreeTable with an add button. The button works as expected: it adds a new node to the end, with values that (for the purpose of testing) are hard-coded into my program. The line:
```
modelSupport.fireChildAdded(new TreePath(root), noOfChildren-1, dataNode);
```
tells the JXTreeTable to recognise the updat... | 2014/08/24 | ['https://Stackoverflow.com/questions/25467734', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/313909/'] | Give it a Name
```
<Page.Resources>
<Flyout x:Name="myFlyout" x:Key="WinningPopup">
// ......
</Flyout>
</Page.Resources>
```
Then you can just Hide()
```
myFlyout.Hide();
```
[FlyoutBase.Hide method](http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.flyoutba... | ```
public void btnRestart_Click(object sender, RoutedEventArgs)
{
((((sender as Button).Parent as StackPanel).Parent as StackPanel).Parent as Flyout).Hide();
}
```
Very ugly but should work. |
25,467,734 | I have a JXTreeTable with an add button. The button works as expected: it adds a new node to the end, with values that (for the purpose of testing) are hard-coded into my program. The line:
```
modelSupport.fireChildAdded(new TreePath(root), noOfChildren-1, dataNode);
```
tells the JXTreeTable to recognise the updat... | 2014/08/24 | ['https://Stackoverflow.com/questions/25467734', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/313909/'] | Give it a Name
```
<Page.Resources>
<Flyout x:Name="myFlyout" x:Key="WinningPopup">
// ......
</Flyout>
</Page.Resources>
```
Then you can just Hide()
```
myFlyout.Hide();
```
[FlyoutBase.Hide method](http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.flyoutba... | You need to get it first. Then you can call `Hide`.
```
FlyoutBase.GetAttachedFlyout((FrameworkElement)LayoutRoot).Hide();
``` |
25,467,734 | I have a JXTreeTable with an add button. The button works as expected: it adds a new node to the end, with values that (for the purpose of testing) are hard-coded into my program. The line:
```
modelSupport.fireChildAdded(new TreePath(root), noOfChildren-1, dataNode);
```
tells the JXTreeTable to recognise the updat... | 2014/08/24 | ['https://Stackoverflow.com/questions/25467734', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/313909/'] | ```
public void btnRestart_Click(object sender, RoutedEventArgs)
{
((((sender as Button).Parent as StackPanel).Parent as StackPanel).Parent as Flyout).Hide();
}
```
Very ugly but should work. | You need to get it first. Then you can call `Hide`.
```
FlyoutBase.GetAttachedFlyout((FrameworkElement)LayoutRoot).Hide();
``` |
45,658 | I move an elbow from my IK bone and the other arm moves too. Why is that? how can i solve it?
Help =([](https://i.stack.imgur.com/ZMiDL.png) | 2016/01/26 | ['https://blender.stackexchange.com/questions/45658', 'https://blender.stackexchange.com', 'https://blender.stackexchange.com/users/21236/'] | Your bone is called Bone.011 so it's not getting mirrored properly. You need to make sure the bones have names like hand.l, hand.r (for the other side) and so on.
For the automatic weighting, you can just redo it by reparenting the mesh to the armature with automatic weights.
Another thing that can break the automati... | When you link your armature to your mesh using automatic weight, sometimes the weight is applied wrongly to the mesh. It could be that you did not apply your mesh's scale.
1. In object mode, Hit `Alt``A`
2. Select "Scale" from the Drop down menu.
You could also go to the vertex group control panel and manually remove... |
49,192,427 | How could **this.\_arr** array be updated inside a socket.io callback?
```
class SocketClass{
constructor(server) {
this._arr = [];
this._io = require('socket.io').listen(server);
this._initListeners();
}
_initListeners() {
this._io.on('connection', (socket, arr) => {
socket.on('event1',... | 2018/03/09 | ['https://Stackoverflow.com/questions/49192427', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1811410/'] | I'd use a data attribute for this. Store a template for the image src and a path value for each button, then update the image src values accordingly for each button click...
```js
var buttons = document.querySelectorAll("button");
var images = document.querySelectorAll("img");
[].forEach.call(buttons, function(button... | I believe you can do that by creating script.
If you assign ID to each of the `<img>` tags you can then do something like:
```
document.getElementById('exampleID').innerHTML="<src="new_path">";
```
Eventually put each `<img>` tag in DIV
```
<div id=someid>
<img src="dist/one/rocket.png" alt="" />
</div>
```
Scri... |
612,405 | Let $E:\mathbb{R} \to \mathbb{R}$ be an infinitely continuously differentiable function and $E$ is not zero function
such that $$E(u+v)=E(u)E(v).$$
Show that $E(x)=e^{ax}$ for some $a\in \mathbb{R}$.
My partial answer:
The function $x\mapsto e^{ax}$ satisfies the properties immediately.
For $y=0$, we have $E(x)=E(x)... | 2013/12/19 | ['https://math.stackexchange.com/questions/612405', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/27594/'] | $\newcommand{\+}{^{\dagger}}%
\newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
\newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
\newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
\newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
\newcommand{\dd}{{\rm d}}%
\newcommand{\ds}[1]{\displaystyle... | You can create a probility dristribution for the location after one step (the unit circle with a certain constant prbability). After two steps, I think that should be doable too. You can also carculate for each point the probability of entering de unit disk in the next step. Then, by combining the probability distribut... |
612,405 | Let $E:\mathbb{R} \to \mathbb{R}$ be an infinitely continuously differentiable function and $E$ is not zero function
such that $$E(u+v)=E(u)E(v).$$
Show that $E(x)=e^{ax}$ for some $a\in \mathbb{R}$.
My partial answer:
The function $x\mapsto e^{ax}$ satisfies the properties immediately.
For $y=0$, we have $E(x)=E(x)... | 2013/12/19 | ['https://math.stackexchange.com/questions/612405', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/27594/'] | $\newcommand{\+}{^{\dagger}}%
\newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
\newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
\newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
\newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
\newcommand{\dd}{{\rm d}}%
\newcommand{\ds}[1]{\displaystyle... | This is not a complete answer, but is kind of long for a comment.
For $t=2$, draw a picture. It's pretty easy to see the answer is $1/3$.
For the $t=3$ case, let the angles be $\theta\_1$, $\theta\_2$, and $\theta\_3$. By symmetry, you can assume without loss of generality that $\theta\_1 = 0$. So you need to find t... |
612,405 | Let $E:\mathbb{R} \to \mathbb{R}$ be an infinitely continuously differentiable function and $E$ is not zero function
such that $$E(u+v)=E(u)E(v).$$
Show that $E(x)=e^{ax}$ for some $a\in \mathbb{R}$.
My partial answer:
The function $x\mapsto e^{ax}$ satisfies the properties immediately.
For $y=0$, we have $E(x)=E(x)... | 2013/12/19 | ['https://math.stackexchange.com/questions/612405', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/27594/'] | $\newcommand{\+}{^{\dagger}}%
\newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
\newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
\newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
\newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
\newcommand{\dd}{{\rm d}}%
\newcommand{\ds}[1]{\displaystyle... | This addresses the t=3 case:
Assume you start at origin ($P\_0$), and without loss of generality, assume first move is to $P\_1=(1, 0)$. Your second move will be to $P\_2=(1 + cos(\theta), sin(\theta))$, where theta is uniform [0, $\pi$] (can ignore the [$\pi,2\pi$] range due to symmetry). Density function of $\theta$... |
612,405 | Let $E:\mathbb{R} \to \mathbb{R}$ be an infinitely continuously differentiable function and $E$ is not zero function
such that $$E(u+v)=E(u)E(v).$$
Show that $E(x)=e^{ax}$ for some $a\in \mathbb{R}$.
My partial answer:
The function $x\mapsto e^{ax}$ satisfies the properties immediately.
For $y=0$, we have $E(x)=E(x)... | 2013/12/19 | ['https://math.stackexchange.com/questions/612405', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/27594/'] | This is a classic problem, first solved by the Dutch mathematician J.C. Kluyver in 1905. He derives the result given in the [answer](https://math.stackexchange.com/a/612395/87355) of Felix Marin, that the probability to return to the unit disc after $n$ steps is $1/(n+1)$:
. After two steps, I think that should be doable too. You can also carculate for each point the probability of entering de unit disk in the next step. Then, by combining the probability distribut... |
612,405 | Let $E:\mathbb{R} \to \mathbb{R}$ be an infinitely continuously differentiable function and $E$ is not zero function
such that $$E(u+v)=E(u)E(v).$$
Show that $E(x)=e^{ax}$ for some $a\in \mathbb{R}$.
My partial answer:
The function $x\mapsto e^{ax}$ satisfies the properties immediately.
For $y=0$, we have $E(x)=E(x)... | 2013/12/19 | ['https://math.stackexchange.com/questions/612405', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/27594/'] | This is a classic problem, first solved by the Dutch mathematician J.C. Kluyver in 1905. He derives the result given in the [answer](https://math.stackexchange.com/a/612395/87355) of Felix Marin, that the probability to return to the unit disc after $n$ steps is $1/(n+1)$:
=E(u)E(v).$$
Show that $E(x)=e^{ax}$ for some $a\in \mathbb{R}$.
My partial answer:
The function $x\mapsto e^{ax}$ satisfies the properties immediately.
For $y=0$, we have $E(x)=E(x)... | 2013/12/19 | ['https://math.stackexchange.com/questions/612405', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/27594/'] | This is a classic problem, first solved by the Dutch mathematician J.C. Kluyver in 1905. He derives the result given in the [answer](https://math.stackexchange.com/a/612395/87355) of Felix Marin, that the probability to return to the unit disc after $n$ steps is $1/(n+1)$:
, and without loss of generality, assume first move is to $P\_1=(1, 0)$. Your second move will be to $P\_2=(1 + cos(\theta), sin(\theta))$, where theta is uniform [0, $\pi$] (can ignore the [$\pi,2\pi$] range due to symmetry). Density function of $\theta$... |
41,073,364 | how can I ignore all the duplicating records and get only those which do not have a tie in mysql for example; from the following data set;
```
1|item1| data1
2|item1| data2
3|item2| data3
4|item3| data4
```
I want to get this get this kind of results;
```
3|item2| data3
4|item3| data4
``` | 2016/12/10 | ['https://Stackoverflow.com/questions/41073364', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6870393/'] | before call third function you need to call first two functions that will assign values to $this->a & $this->b
try below code :
```
protected $a;
protected $b;
function fast()
{
$a=10;
$this->a = $a;
}
function slow()
{
$b=20;
$this->b = $b;
}
function avg()
{
$c=$this->a+$this->b;
echo $... | Firstly, you are using object properties incorrectly. You need to first specify the scope of the property; in this case, I used protected scopes so you can extend the class as and when you need to use the properties directly.
Also, note if you're trying to add an **unset** variable, it will not work, you can either ad... |
3,090,509 | ---
I have been trying to simplify the following summation with the intention of breaking it into less complex summations, but I keep getting stuck no matter what I try:
$$\sum\_{i=0}^{k-1} 3^{i} \cdot \frac{\sqrt{\frac{n}{3^i}}}{\log\_{2}\frac{n}{3^i}}$$
Among the things I tried was raising to the power of $1/2$\* ... | 2019/01/28 | ['https://math.stackexchange.com/questions/3090509', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/635189/'] | The issue expression can be presented in the form of
$$S={\large\sum\limits\_{i=0}^{k-1}}3^i\dfrac{\sqrt{\dfrac n{3^i}}}{\log\_2\dfrac{n}{3^i}}
= \sqrt n \log\_32{\large\sum\limits\_{i=0}^{k-1}}\dfrac{(\sqrt3)^i}{\log\_3{n}-i},$$
so
$$S=\sqrt n \log\_32\left(3^{k/2}\Phi(\sqrt3,1,k-\log\_3n)-\Phi(\sqrt3,1,-\log\_3n)\rig... | If I plug
$$
\sum\_{i=0}^{\log\_3(n)-1}3^i \frac{\sqrt{\frac{n}{3^i}}}{\log\_2(\frac{n}{3^i})}
$$
into Wolfram Mathematica, then I get no simplification, so an nice simplification probably does not exist. The best we can probably do is, with thanks to @NoChance,
$$
\sum\_{i=0}^{\log\_3(n)-1}3^i \frac{\sqrt{\frac{n}{3^i... |
50,219,323 | My project is very similar to the famous ATM problem. I have to create a hotel check in/check out system. I have to get the user input for the last name and confirm it. However when I try to return the string, it tells me it cant convert string to int.
```
import java.util.Scanner;
public class Keyboard {
private ... | 2018/05/07 | ['https://Stackoverflow.com/questions/50219323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9732237/'] | The problem is that your server time is different from Google server time. And when you validate received token from google it might be that token will be valid in 1 or n seconds. That's why you get an error `JWT not yet valid`
To fix it you can synchronize time of your server with google server time. Google doc how t... | You can configure the system time as per google or if your computer is part of a domain and you don't want to change the domain controller config, then you can pass a clock object in the Validateasync method like this:
```
var googleUser = await GoogleJsonWebSignature.ValidateAsync(token, new GoogleJsonWebSignature.Va... |
23,341,774 | I am trying to create a form that updates user information stored in an Oracle database, the updates are not going through correctly and I can't see a problem as I have the form printing out the SQL being submitted to oracle and it all checks out.
Here is the php that forms the connection:
```
<?php
$sql="select * fr... | 2014/04/28 | ['https://Stackoverflow.com/questions/23341774', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3548774/'] | Try this:
```
$conn = oci_connect("user","pass", "conn");
$sql = "UPDATE Members SET firstname=:firstname, lastname=:lastname, dob=:dob, membertype=:membertype, groupid=:groupid, houseno=:houseno, street=:street, town=:town, county=:county, postcode=:postcode where memberid=:memberid;";
$stmt = oci_parse($conn, $upda... | You haven't enclosed $memberid variable in qoutes in query
.... `where memberid='$memberid';"` |
39,871,505 | ```
public static void main(String[] args) throws Exception {
Connection connection = getMySqlConnection();
CallableStatement proc = connection.prepareCall("{ call LCD_GetDispInfoAllTimeTable() }");
proc.registerOutParameter(1, Types.INTEGER);
proc.execute();
int returnValue = pr... | 2016/10/05 | ['https://Stackoverflow.com/questions/39871505', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | You need to specify the parameter in your call String:
`CallableStatement proc = connection.prepareCall("{ call LCD_GetDispInfoAllTimeTable(?) }");`
Notice that `?`, it says that there is a parameter to be set. Now it knows that there is a parameter to be set, just like methods in Java or some other language. If you ... | as far as your procedecure declaration is concerned, its code is:
```
CREATE DEFINER=`root`@`%` PROCEDURE `LCD_GetDispInfoAllTimeTable`()
BEGIN
SELECT bs.name as bsName, tt.busstoptype as bsType, tt.time as ttTime,
bs.longitude as lon, bs.latitude as lat, tt.timetable_id as ttID,
Bus_Stop
```
where the procedu... |
8,412,710 | I want to make a custom include tag (like `{% smart_include something %}` ), which realize what kind a thing we want to include and then call regular `{% include %}` tag. That's should be something like this:
```
@register.simple_tag
def smart_include(something):
if something == "post":
template_name = "... | 2011/12/07 | ['https://Stackoverflow.com/questions/8412710', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/277262/'] | I assume there is a reason why you are not doing:
```
{% if foo %}
{% include 'hello.html' %}
{% endif %}
```
If `something` is a fixed number, you can use [inclusion tags](https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags-inclusion-tags). In your template instead of `{% ... | If you look into the **django.template.loader\_tags** you fill find a function **do\_include** which is basically the function that is called when we use {% include %}.
So you should be able to import it call the function itself in python.
I have not tried this but I think it should work |
8,412,710 | I want to make a custom include tag (like `{% smart_include something %}` ), which realize what kind a thing we want to include and then call regular `{% include %}` tag. That's should be something like this:
```
@register.simple_tag
def smart_include(something):
if something == "post":
template_name = "... | 2011/12/07 | ['https://Stackoverflow.com/questions/8412710', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/277262/'] | I assume there is a reason why you are not doing:
```
{% if foo %}
{% include 'hello.html' %}
{% endif %}
```
If `something` is a fixed number, you can use [inclusion tags](https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags-inclusion-tags). In your template instead of `{% ... | `render_to_string` will render the given template\_name to an html string
```py
from django.template.loader import render_to_string
template_name = 'post.html'
optional_context = {}
html = render_to_string(template_name, optional_context)
``` |
73,394 | This guy put money into my bank account and wanted me to send some of it to another person in Nigeria. 500.00 to be exact. But since he wired money into my account I was unable to touch the money.
He told me it was a donation to UNICEF. Since I was unable to take the money out he threatened to get the police involved... | 2016/12/06 | ['https://money.stackexchange.com/questions/73394', 'https://money.stackexchange.com', 'https://money.stackexchange.com/users/51081/'] | >
> He has my bank account info, and I just want to know where I stand legally.
>
>
>
Legally you can't keep the money. It would either go back to the originator or to Government unclaimed department.
>
> I got a bunch of missed calls from an unknown number and a really unprofessional email from a guy who suppos... | To add to @Dheer's answer, this is almost certainly a scam. The money deposited into your account is not from a person that made an honest mistake with account numbers. It's coming from someone that has access to "send" money that isn't their own. I don't know exactly what they're doing to "send" the money but at some ... |
176,688 | I am converting RPG files in NTF\_Lambert\_II\_etendu to wgs\_84 using:
```
ogr2ogr -t_srs EPSG:4326 ilot_2008_027_wgs84_2.shp ilot_2008_027.shp
```
but the result is off by about 30 meters. Surprisingly, the same conversion using Qgis works fine. Could anybody tell me how to correct that or how to investigate the ... | 2016/01/13 | ['https://gis.stackexchange.com/questions/176688', 'https://gis.stackexchange.com', 'https://gis.stackexchange.com/users/49290/'] | NTF Lambert II has a `towgs84` datum shift, but that is not included in the .prj file.
The .prj file uses a different naming for the projection, so the EPSG code finder might fail.
I assume QGIS assigns the correct EPSG code (maybe in the .qpj file), and makes a standard transformation from one EPSG code to another u... | As mentioned by @AndreJ specifying the EPSG code makes it work. Specifically the following work:
```
ogr2ogr -t_srs EPSG:4326 -s_srs EPSG:7421 ilot_2008_027_wgs84_2.shp ilot_2008_027.shp
```
Alternatively, I was trying to use the qgis python API to do it all in python using qgis but could not get it to work. |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | I have used a touring kayak for fishing, and it works out ok. You can rig up a rod holder in your cockpit, but paddling is a bit awkward, though this is probably also a problem with any kayak used for fishing.
It might be somewhat difficult to use a fishing kayak on overnight trips given that most fishing kayaks are s... | I would recommend checking out something like Hobie's Mirage pedal driven kayaks. With their spiffy pedal drive, you can trivially outrun(outpedal?) just about anyone while hardly breaking a sweat. Additionally, because you power yourself with your feet, your hands are free for fishing. The mirage drive is also quiet a... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | Yes, there is definitely a performance difference between different types of kayaks. In fact, there are performance differences among the same types of kayaks. For example, a 14-foot kayak will always track more straightly than a 10-foot kayak. A wide recreational kayak will always have more primary stability than a na... | I have used a touring kayak for fishing, and it works out ok. You can rig up a rod holder in your cockpit, but paddling is a bit awkward, though this is probably also a problem with any kayak used for fishing.
It might be somewhat difficult to use a fishing kayak on overnight trips given that most fishing kayaks are s... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | I have used a touring kayak for fishing, and it works out ok. You can rig up a rod holder in your cockpit, but paddling is a bit awkward, though this is probably also a problem with any kayak used for fishing.
It might be somewhat difficult to use a fishing kayak on overnight trips given that most fishing kayaks are s... | I have been considering just the same. I have come up with two kayacks that I like. The first is a fishing kayak by kudo. It tracks well and speed is good. I have a strong upper body so it makes it easier for me but its all in the core. Try different techniques as you will get tired just doing one.
The other kayak is ... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | Yes, there is definitely a performance difference between different types of kayaks. In fact, there are performance differences among the same types of kayaks. For example, a 14-foot kayak will always track more straightly than a 10-foot kayak. A wide recreational kayak will always have more primary stability than a na... | I would recommend checking out something like Hobie's Mirage pedal driven kayaks. With their spiffy pedal drive, you can trivially outrun(outpedal?) just about anyone while hardly breaking a sweat. Additionally, because you power yourself with your feet, your hands are free for fishing. The mirage drive is also quiet a... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | There are a few differences between the SOT kayaks and a touring kayak that you'll want to consider.
**Length**
SOT kayaks tend to be shorter and wider than touring boats. This can make SOT's a little more stable but a longer boat will track better (go straight). The more rough the water you want to travel in the l... | I would recommend checking out something like Hobie's Mirage pedal driven kayaks. With their spiffy pedal drive, you can trivially outrun(outpedal?) just about anyone while hardly breaking a sweat. Additionally, because you power yourself with your feet, your hands are free for fishing. The mirage drive is also quiet a... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | Yes, there is definitely a performance difference between different types of kayaks. In fact, there are performance differences among the same types of kayaks. For example, a 14-foot kayak will always track more straightly than a 10-foot kayak. A wide recreational kayak will always have more primary stability than a na... | There are a few differences between the SOT kayaks and a touring kayak that you'll want to consider.
**Length**
SOT kayaks tend to be shorter and wider than touring boats. This can make SOT's a little more stable but a longer boat will track better (go straight). The more rough the water you want to travel in the l... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | Yes, there is definitely a performance difference between different types of kayaks. In fact, there are performance differences among the same types of kayaks. For example, a 14-foot kayak will always track more straightly than a 10-foot kayak. A wide recreational kayak will always have more primary stability than a na... | I have been considering just the same. I have come up with two kayacks that I like. The first is a fishing kayak by kudo. It tracks well and speed is good. I have a strong upper body so it makes it easier for me but its all in the core. Try different techniques as you will get tired just doing one.
The other kayak is ... |
3,909 | Last year my wife and I rented a couple of SOT kayaks and used them to paddle around our local lake. We enjoyed it so much we have decided to purchase our own this year.
We are looking at some entry level kayaks to use at the lakes and rivers here in Illinois.
I am also an avid fisherman and I would like to get a fish... | 2013/04/01 | ['https://outdoors.stackexchange.com/questions/3909', 'https://outdoors.stackexchange.com', 'https://outdoors.stackexchange.com/users/2174/'] | There are a few differences between the SOT kayaks and a touring kayak that you'll want to consider.
**Length**
SOT kayaks tend to be shorter and wider than touring boats. This can make SOT's a little more stable but a longer boat will track better (go straight). The more rough the water you want to travel in the l... | I have been considering just the same. I have come up with two kayacks that I like. The first is a fishing kayak by kudo. It tracks well and speed is good. I have a strong upper body so it makes it easier for me but its all in the core. Try different techniques as you will get tired just doing one.
The other kayak is ... |
652,362 | Consider the differential equation
$$x^2y''+3(x-x^2)y'-3y=0$$
$(a)$ Find the recurrence equation and first three nonzero terms of the series solution in powers of $$ corresponding to the larger root of the indicial equation.
$(b)$ What would be the form of a second linearly independent solution of this differential e... | 2014/01/26 | ['https://math.stackexchange.com/questions/652362', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/59036/'] | Here is the procedure.
Denote the two roots by $r\_1$ and $r\_2$, with $r\_1 \gt r\_2$.
The Method of Frobenius will always generate a solution corresponding to $r\_1$, but **may** generate a solution for the smaller second root $r\_2$ of the indicial equation.
If the method fails for $r\_2$, then an approach is to ... | Let me rewrite your ODE as follows:
$$L[y] = p\_0 y'' + p\_1 y' + p\_2 y = 0,$$ where $p\_i(x)$ are the coefficients of the equation. If you know one of the two linear indepent solutions of the homogenous part (indeed the whole ode is homogenouse), say $y\_1$, you can obtain $y\_2$ ($y = A y\_1+B y\_2$) by using the m... |
652,362 | Consider the differential equation
$$x^2y''+3(x-x^2)y'-3y=0$$
$(a)$ Find the recurrence equation and first three nonzero terms of the series solution in powers of $$ corresponding to the larger root of the indicial equation.
$(b)$ What would be the form of a second linearly independent solution of this differential e... | 2014/01/26 | ['https://math.stackexchange.com/questions/652362', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/59036/'] | Here is the procedure.
Denote the two roots by $r\_1$ and $r\_2$, with $r\_1 \gt r\_2$.
The Method of Frobenius will always generate a solution corresponding to $r\_1$, but **may** generate a solution for the smaller second root $r\_2$ of the indicial equation.
If the method fails for $r\_2$, then an approach is to ... | Let $y=\sum\limits\_{n=0}^\infty a\_nx^{n+r}$ ,
Then $y'=\sum\limits\_{n=0}^\infty(n+r)a\_nx^{n+r-1}$
$y''=\sum\limits\_{n=0}^\infty(n+r)(n+r-1)a\_nx^{n+r-2}$
$\therefore x^2\sum\limits\_{n=0}^\infty(n+r)(n+r-1)a\_nx^{n+r-2}+3(x-x^2)\sum\limits\_{n=0}^\infty(n+r)a\_nx^{n+r-1}-3\sum\limits\_{n=0}^\infty a\_nx^{n+r}=0... |
14,653,177 | I would like to create an array containing static methods (or containing references to static methods). I have tried to create an array of classes which implement an interface with the method. With this method, I would get the object and then call the method on it. This does not work for static methods. Is there a way ... | 2013/02/01 | ['https://Stackoverflow.com/questions/14653177', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1571830/'] | Of course, you can have an array of `Method` and then you can call it using invoke, check these examples: [How do I invoke a private static method using reflection (Java)?](https://stackoverflow.com/questions/4770425/how-do-i-invoke-a-private-static-method-using-reflection-java) | If you can meet the following conditions:
1. You know all of the keys at code generation time.
2. You know all of the values (methods) at code generation time.
You can use code like this:
```
public class Table {
public static int hash(String key) {
/* you can use any type of key and whatever hash functi... |
29,714,078 | I am creating an application that takes input from user and save it permanently in form of table.
```
Console.Write("\n\tEnter roll no\n\t");
v= Convert.ToInt32(Console.ReadLine());
a[i].setroll(v);
Console.Write("\n\tEnter name\n\t");
k = Console.ReadLine();
a[i].setname(k);
Co... | 2015/04/18 | ['https://Stackoverflow.com/questions/29714078', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4663076/'] | Refer to [System.IO.File](https://msdn.microsoft.com/en-us/library/System.IO.File(v=vs.110).aspx)
And this may be a quick help:
```
using System;
public class Test
{
public static void Main()
{
String Str = "";
for(int i =0;i<10;i++)
{
Str += i.ToString();
}
... | First you have to create an string array with your data then you can write it to the txt file
```
string[] lines = { "First line", "Second line", "Third line" };
```
WriteAllLines creates a file, writes a collection of strings to the file,and then closes the file.
```
System.IO.File.WriteAllLines(@"C:\Users\Public... |
552,323 | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | 2009/02/16 | ['https://Stackoverflow.com/questions/552323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31671/'] | From <http://www.php.net/manual/en/language.types.boolean.php>, it says that an empty array is considered FALSE.
---
(Quoted):
When converting to boolean, the following values are considered FALSE:
* the boolean FALSE itself
* the integer 0 (zero)
* the float 0.0 (zero)
* the empty string, and the string "0"
* **an ... | Indeed they will. Converting an array to a bool will give you true if it is non-empty, and the count of an array is true with more than one element.
See also: <http://ca2.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting> |
552,323 | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | 2009/02/16 | ['https://Stackoverflow.com/questions/552323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31671/'] | From <http://www.php.net/manual/en/language.types.boolean.php>, it says that an empty array is considered FALSE.
---
(Quoted):
When converting to boolean, the following values are considered FALSE:
* the boolean FALSE itself
* the integer 0 (zero)
* the float 0.0 (zero)
* the empty string, and the string "0"
* **an ... | Note that the second example (using `count()`) is significantly slower, by at least 50% on my system (over 10000 iterations). `count()` actually counts the elements of an array. I'm not positive, but I imagine casting an array to a boolean works much like `empty()`, and stops as soon as it finds at least one element. |
552,323 | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | 2009/02/16 | ['https://Stackoverflow.com/questions/552323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31671/'] | From <http://www.php.net/manual/en/language.types.boolean.php>, it says that an empty array is considered FALSE.
---
(Quoted):
When converting to boolean, the following values are considered FALSE:
* the boolean FALSE itself
* the integer 0 (zero)
* the float 0.0 (zero)
* the empty string, and the string "0"
* **an ... | Those will always return the same value, but I find
```
$array = array();
if (empty($array)) {
echo 'the array is empty';
}
```
to be a lot more readable. |
552,323 | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | 2009/02/16 | ['https://Stackoverflow.com/questions/552323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31671/'] | Note that the second example (using `count()`) is significantly slower, by at least 50% on my system (over 10000 iterations). `count()` actually counts the elements of an array. I'm not positive, but I imagine casting an array to a boolean works much like `empty()`, and stops as soon as it finds at least one element. | Indeed they will. Converting an array to a bool will give you true if it is non-empty, and the count of an array is true with more than one element.
See also: <http://ca2.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting> |
552,323 | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | 2009/02/16 | ['https://Stackoverflow.com/questions/552323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31671/'] | Those will always return the same value, but I find
```
$array = array();
if (empty($array)) {
echo 'the array is empty';
}
```
to be a lot more readable. | Indeed they will. Converting an array to a bool will give you true if it is non-empty, and the count of an array is true with more than one element.
See also: <http://ca2.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting> |
552,323 | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | 2009/02/16 | ['https://Stackoverflow.com/questions/552323', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31671/'] | Those will always return the same value, but I find
```
$array = array();
if (empty($array)) {
echo 'the array is empty';
}
```
to be a lot more readable. | Note that the second example (using `count()`) is significantly slower, by at least 50% on my system (over 10000 iterations). `count()` actually counts the elements of an array. I'm not positive, but I imagine casting an array to a boolean works much like `empty()`, and stops as soon as it finds at least one element. |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | For Python 3:
```
def jaccard_similarity(list1, list2):
s1 = set(list1)
s2 = set(list2)
return float(len(s1.intersection(s2)) / len(s1.union(s2)))
list1 = ['dog', 'cat', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
jaccard_similarity(list1, list2)
>>> 0.5
```
For Python2 use `return len(s1.intersection(... | If you'd like to include repeated elements, you can use `Counter`, which I would imagine is relatively quick since it's just an extended `dict` under the hood:
```
from collections import Counter
def jaccard_repeats(a, b):
"""Jaccard similarity measure between input iterables,
allowing repeated elements"""
... |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | @aventinus I don't have enough reputation to add a comment to your answer, but just to make things clearer, your solution measures the `jaccard_similarity` but the function is misnamed as `jaccard_distance`, which is actually `1 - jaccard_similarity` | You can use the [Distance](https://github.com/doukremt/distance) library
```
#pip install Distance
import distance
distance.jaccard("decide", "resize")
# Returns
0.7142857142857143
``` |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | You can use the [Distance](https://github.com/doukremt/distance) library
```
#pip install Distance
import distance
distance.jaccard("decide", "resize")
# Returns
0.7142857142857143
``` | To avoid repetition of elements in the union (denominator), and a little bit faster I propose:
```
def Jaccar_score(lista1, lista2):
inter = len(list(set(lista_1) & set(lista_2)))
union = len(list(set(lista_1) | set(lista_2)))
return inter/union
``` |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | For Python 3:
```
def jaccard_similarity(list1, list2):
s1 = set(list1)
s2 = set(list2)
return float(len(s1.intersection(s2)) / len(s1.union(s2)))
list1 = ['dog', 'cat', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
jaccard_similarity(list1, list2)
>>> 0.5
```
For Python2 use `return len(s1.intersection(... | Assuming your usernames don't repeat, you can use the same idea:
```
def jaccard(a, b):
c = a.intersection(b)
return float(len(c)) / (len(a) + len(b) - len(c))
list1 = ['dog', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
# The intersection is ['dog', 'cat']
# union is ['dog', 'cat', 'rat', 'mouse]
words1 = s... |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | @Aventinus (I also cannot comment): Note that Jaccard *similarity* is an operation on sets, so in the denominator part it should also use sets (instead of lists). So for example `jaccard_similarity('aa', 'ab')` should result in `0.5`.
```
def jaccard_similarity(list1, list2):
intersection = len(set(list1).interse... | Creator of the [Simphile NLP text similarity](https://github.com/brianrisk/simphile) package here. Simphile contains several text similarity methods, Jaccard being one of them.
In the terminal install the package:
```
pip install simphile
```
Then your code could be something like:
```
from simphile import jaccard... |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | I ended up writing my own solution after all:
```
def jaccard_similarity(list1, list2):
intersection = len(list(set(list1).intersection(list2)))
union = (len(set(list1)) + len(set(list2))) - intersection
return float(intersection) / union
``` | If you'd like to include repeated elements, you can use `Counter`, which I would imagine is relatively quick since it's just an extended `dict` under the hood:
```
from collections import Counter
def jaccard_repeats(a, b):
"""Jaccard similarity measure between input iterables,
allowing repeated elements"""
... |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | Assuming your usernames don't repeat, you can use the same idea:
```
def jaccard(a, b):
c = a.intersection(b)
return float(len(c)) / (len(a) + len(b) - len(c))
list1 = ['dog', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
# The intersection is ['dog', 'cat']
# union is ['dog', 'cat', 'rat', 'mouse]
words1 = s... | You can use the [Distance](https://github.com/doukremt/distance) library
```
#pip install Distance
import distance
distance.jaccard("decide", "resize")
# Returns
0.7142857142857143
``` |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | I ended up writing my own solution after all:
```
def jaccard_similarity(list1, list2):
intersection = len(list(set(list1).intersection(list2)))
union = (len(set(list1)) + len(set(list2))) - intersection
return float(intersection) / union
``` | For Python 3:
```
def jaccard_similarity(list1, list2):
s1 = set(list1)
s2 = set(list2)
return float(len(s1.intersection(s2)) / len(s1.union(s2)))
list1 = ['dog', 'cat', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
jaccard_similarity(list1, list2)
>>> 0.5
```
For Python2 use `return len(s1.intersection(... |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | Assuming your usernames don't repeat, you can use the same idea:
```
def jaccard(a, b):
c = a.intersection(b)
return float(len(c)) / (len(a) + len(b) - len(c))
list1 = ['dog', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
# The intersection is ['dog', 'cat']
# union is ['dog', 'cat', 'rat', 'mouse]
words1 = s... | If you'd like to include repeated elements, you can use `Counter`, which I would imagine is relatively quick since it's just an extended `dict` under the hood:
```
from collections import Counter
def jaccard_repeats(a, b):
"""Jaccard similarity measure between input iterables,
allowing repeated elements"""
... |
46,975,929 | I have two lists with usernames and I want to calculate the Jaccard similarity. Is it possible?
[This](https://stackoverflow.com/questions/11911252/python-jaccard-distance-using-word-intersection-but-not-character-intersection) thread shows how to calculate the Jaccard Similarity between two strings, however I want t... | 2017/10/27 | ['https://Stackoverflow.com/questions/46975929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/873309/'] | For Python 3:
```
def jaccard_similarity(list1, list2):
s1 = set(list1)
s2 = set(list2)
return float(len(s1.intersection(s2)) / len(s1.union(s2)))
list1 = ['dog', 'cat', 'cat', 'rat']
list2 = ['dog', 'cat', 'mouse']
jaccard_similarity(list1, list2)
>>> 0.5
```
For Python2 use `return len(s1.intersection(... | @aventinus I don't have enough reputation to add a comment to your answer, but just to make things clearer, your solution measures the `jaccard_similarity` but the function is misnamed as `jaccard_distance`, which is actually `1 - jaccard_similarity` |
4,252,818 | I have in trouble to trigger a click event when enter key is pressed.
When I use below codes, the live('click') event is triggered 3 times (which means the alert message is shown 3 thmes) when I press an enter key. Thanks in advance!! - KS from Korea
```
$('.searchWord').live('keypress', function(e) {
if(e.keyCode... | 2010/11/23 | ['https://Stackoverflow.com/questions/4252818', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/516975/'] | It looks like you either have multiple `.searchWord` elements nested within each other, or, you have multiple `.bBtnSearchBoard` elements. | try keydown
```
$('.searchWord').live('keydown', function(e) {
if(e.keyCode == 13) {
$('.bBtnSearchBoard').trigger('click');
}
});
``` |
4,252,818 | I have in trouble to trigger a click event when enter key is pressed.
When I use below codes, the live('click') event is triggered 3 times (which means the alert message is shown 3 thmes) when I press an enter key. Thanks in advance!! - KS from Korea
```
$('.searchWord').live('keypress', function(e) {
if(e.keyCode... | 2010/11/23 | ['https://Stackoverflow.com/questions/4252818', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/516975/'] | It looks like you either have multiple `.searchWord` elements nested within each other, or, you have multiple `.bBtnSearchBoard` elements. | It looks fine on [this test](http://jsfiddle.net/DjASs/). Maybe your problem is that `.bBtnSearchBoard` returns more than one element. |
4,252,818 | I have in trouble to trigger a click event when enter key is pressed.
When I use below codes, the live('click') event is triggered 3 times (which means the alert message is shown 3 thmes) when I press an enter key. Thanks in advance!! - KS from Korea
```
$('.searchWord').live('keypress', function(e) {
if(e.keyCode... | 2010/11/23 | ['https://Stackoverflow.com/questions/4252818', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/516975/'] | It looks like you either have multiple `.searchWord` elements nested within each other, or, you have multiple `.bBtnSearchBoard` elements. | ```
$('.searchWord').live('keypress', function(e) {
if(e.keyCode == 13) {
$('.bBtnSearchBoard').click();
}
});
$('.bBtnSearchBoard').live('click', function() {
//do your stuff here
$(this).die("click"); //The first time this method executes unbinds the click handler from matched elements
return false; /... |
41,694,421 | I'm calling my Java Servlet with an AJAX call, but I'm not able to read the input parameter from the request. I've tried two ways but with no luck:
```
var id;
$("#scan").click(function() {
id = 1;
$.ajax({
type: "POST",
data: id,
url: "http://10.1.42.249:8080/test-notifier-web/RestLay... | 2017/01/17 | ['https://Stackoverflow.com/questions/41694421', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3991150/'] | i have check you code.this is my working code.
```
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/... | ```
var id;
$("#scan").click(function() {
id = 1;
$.ajax({
type: "POST",
data: { reqValue : id},
url: "http://10.1.42.249:8080/test-notifier-web/RestLayer"
});
});
```
There are different methods you need to override in servlet. Those are doPost(), doGet... |
37,357,896 | I am using sublime to automatically word-wrap python code-lines that go beyond 79 Characters as the Pep-8 defines. Initially i was doing return to not go beyond the limit.
The only downside with that is that anyone else not having the word-wrap active wouldn't have the limitation. So should i strive forward of actual... | 2016/05/21 | ['https://Stackoverflow.com/questions/37357896', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1767754/'] | PEP8 wants you to perform an actual word wrap. The point of PEP8’s stylistic rules is that the file looks the same in every editor, so you cannot rely on editor visualizations to satisfy PEP8.
This also makes you choose the point where to break deliberately. For example, Sublime will do a pretty basic job in wrapping ... | In-file word wrapping would let your code conform to Pep-8 most consistently, even if other programmers are looking at your code using different coding environments. That seems to me to be the best solution to keeping to the standard, particularly if you are expecting that others will, at some point, be looking at your... |
31,768,349 | I tried an SSE (Server-Sent-Events) using java on tomcat 8.0. Here are few things I noticed.
I click a button that automatically makes a request to the servlet. Servlet's GET method gets executed which returns an event stream. Once the full stream is received, the page again automatically makes another request which r... | 2015/08/02 | ['https://Stackoverflow.com/questions/31768349', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/548634/'] | Change this line
```
writer.write("data: "+ i +"\n\n");
```
to
```
writer.write("data: "+ i +"\r\n");
```
BTW, your code will have a serious performance issue because it will hold a thread until all events are sent.Please use Asynchronous processing API instead. e.g.
```
protected void service(HttpServletReques... | I highly recommend first to read [Stream Updates with Server-Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/) to get a good general understanding of the technology.
Then follow [Server-Sent Events with Async Servlet By Example](https://weblogs.java.net/blog/swchan2/archive/2014/05/21/server-sent... |
31,768,349 | I tried an SSE (Server-Sent-Events) using java on tomcat 8.0. Here are few things I noticed.
I click a button that automatically makes a request to the servlet. Servlet's GET method gets executed which returns an event stream. Once the full stream is received, the page again automatically makes another request which r... | 2015/08/02 | ['https://Stackoverflow.com/questions/31768349', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/548634/'] | Change this line
```
writer.write("data: "+ i +"\n\n");
```
to
```
writer.write("data: "+ i +"\r\n");
```
BTW, your code will have a serious performance issue because it will hold a thread until all events are sent.Please use Asynchronous processing API instead. e.g.
```
protected void service(HttpServletReques... | The browser attempts to reconnect to the source roughly 3 seconds after each connection is closed. You can change that timeout by including a line beginning with "retry:", followed by the number of milliseconds to wait before trying to reconnect. |
31,768,349 | I tried an SSE (Server-Sent-Events) using java on tomcat 8.0. Here are few things I noticed.
I click a button that automatically makes a request to the servlet. Servlet's GET method gets executed which returns an event stream. Once the full stream is received, the page again automatically makes another request which r... | 2015/08/02 | ['https://Stackoverflow.com/questions/31768349', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/548634/'] | I highly recommend first to read [Stream Updates with Server-Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/) to get a good general understanding of the technology.
Then follow [Server-Sent Events with Async Servlet By Example](https://weblogs.java.net/blog/swchan2/archive/2014/05/21/server-sent... | The browser attempts to reconnect to the source roughly 3 seconds after each connection is closed. You can change that timeout by including a line beginning with "retry:", followed by the number of milliseconds to wait before trying to reconnect. |
36,656,845 | I don't understand why an empty array, or an array with only 1 "numerical" value can be used in certain calculations.
```
[] * [] === 0 //true
[2] * [2] === 4 //true
["2"] * ["2"] === 4 //true
```
However, it does not seem that is always the case with every operator.
```
[2] + [1] === 3 // false, actual result is... | 2016/04/15 | ['https://Stackoverflow.com/questions/36656845', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2056157/'] | The arrays are coerced into strings, such that `[] == ""`, `[1] == "1"`, and `[1, 2] == "1,2"`.
When you do certain mathematical operations on strings, they are coerced into `Number` types.
For example, when you do `[2] * [2]` it becomes `"2" * "2"` which becomes `2 * 2`. You can even mix types and do `[2] * 2` or `"... | The same ol'problem of having `+` as string concatenation operator.
An array in Javascript is an Object. When you try to coerce objects into primitive values, there is an order to follow:
1. `<obj>.toString()`
2. `<obj>.toNumber()`
3. `<obj>.toBoolean()`
If you're using the `*` operator, coerce into string is not po... |
36,656,845 | I don't understand why an empty array, or an array with only 1 "numerical" value can be used in certain calculations.
```
[] * [] === 0 //true
[2] * [2] === 4 //true
["2"] * ["2"] === 4 //true
```
However, it does not seem that is always the case with every operator.
```
[2] + [1] === 3 // false, actual result is... | 2016/04/15 | ['https://Stackoverflow.com/questions/36656845', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2056157/'] | The arrays are coerced into strings, such that `[] == ""`, `[1] == "1"`, and `[1, 2] == "1,2"`.
When you do certain mathematical operations on strings, they are coerced into `Number` types.
For example, when you do `[2] * [2]` it becomes `"2" * "2"` which becomes `2 * 2`. You can even mix types and do `[2] * 2` or `"... | In regards to `+`, [`+` is a coercive operator on `Strings`](http://www.ecma-international.org/ecma-262/5.1/#sec-11.6.1), irrespective of it being the `lvalue` and `rvalue`, I'll quote the specification here:
>
> If `Type(lprim`) is String or `Type(rprim`) is `String`, then Return the
> `String` that is the result o... |
36,656,845 | I don't understand why an empty array, or an array with only 1 "numerical" value can be used in certain calculations.
```
[] * [] === 0 //true
[2] * [2] === 4 //true
["2"] * ["2"] === 4 //true
```
However, it does not seem that is always the case with every operator.
```
[2] + [1] === 3 // false, actual result is... | 2016/04/15 | ['https://Stackoverflow.com/questions/36656845', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2056157/'] | The arrays are coerced into strings, such that `[] == ""`, `[1] == "1"`, and `[1, 2] == "1,2"`.
When you do certain mathematical operations on strings, they are coerced into `Number` types.
For example, when you do `[2] * [2]` it becomes `"2" * "2"` which becomes `2 * 2`. You can even mix types and do `[2] * 2` or `"... | When you do mathematical operations on the arrays JavaScript converts them to the **strings**. But **string** doesn't have multiply operator and then JavaScript converts them to the **numbers** because you try to multiply them:
```
[] * [] === 0 // [] -> '' -> 0, result is 0 * 0
[2] * [2] === 4 // [2] -> '2' -> 2, ... |
15,029,537 | I am creating a custom type calendar and I am trying to see if it is possible to store dates in an array without statically assigning each one. For example the 1st date in the array would be the day it was first created and it would save the next week lets say into the relevant indexes in the array.
```
NSMutableArray... | 2013/02/22 | ['https://Stackoverflow.com/questions/15029537', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1220097/'] | ```
NSMutableArray *days;
days = [[NSMutableArray alloc] init];
NSDate *todayDate = [NSDate Date];
[days addObject:todayDate];
for (int i = 1; i <= 6; i++)
{
NSDate *newDate = [[NSDate date] dateByAddingTimeInterval:60*60*24*i];
[days addObject:newDate];
}
```
In this way, you can add days in array. | Take a look at `dateByAddingTimeInterval:` in the `NSDate` docs ([link](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html)). It lets you add a given amount of seconds to a date. |
15,029,537 | I am creating a custom type calendar and I am trying to see if it is possible to store dates in an array without statically assigning each one. For example the 1st date in the array would be the day it was first created and it would save the next week lets say into the relevant indexes in the array.
```
NSMutableArray... | 2013/02/22 | ['https://Stackoverflow.com/questions/15029537', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1220097/'] | ```
NSMutableArray *days = [[NSMutableArray alloc] init];
NSCalendar *cal = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *tempCop = [cal components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit
fromDate:[NSDate date]];
NSDate *today = [cal dateFromCompone... | Take a look at `dateByAddingTimeInterval:` in the `NSDate` docs ([link](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html)). It lets you add a given amount of seconds to a date. |
15,029,537 | I am creating a custom type calendar and I am trying to see if it is possible to store dates in an array without statically assigning each one. For example the 1st date in the array would be the day it was first created and it would save the next week lets say into the relevant indexes in the array.
```
NSMutableArray... | 2013/02/22 | ['https://Stackoverflow.com/questions/15029537', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1220097/'] | ```
NSMutableArray *days = [[NSMutableArray alloc] init];
NSCalendar *cal = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *tempCop = [cal components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit
fromDate:[NSDate date]];
NSDate *today = [cal dateFromCompone... | ```
NSMutableArray *days;
days = [[NSMutableArray alloc] init];
NSDate *todayDate = [NSDate Date];
[days addObject:todayDate];
for (int i = 1; i <= 6; i++)
{
NSDate *newDate = [[NSDate date] dateByAddingTimeInterval:60*60*24*i];
[days addObject:newDate];
}
```
In this way, you can add days in array. |
40,147,118 | I am building an application for which i am using nodejs express to do rest api services.
I hosted that application on windows server 2012 using iisnode module.Everything works perfect.
The issue is that when i am returning 404(unauthorized) message from node application the end point is recieving the 401 http status w... | 2016/10/20 | ['https://Stackoverflow.com/questions/40147118', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3079776/'] | Using IIS, if you want to return the errors straight from your Node app to the requester without IIS intercepting them with default Error Pages, use the `<httpErrors>` element with the `existingResponse` attribute set to `PassThrough`
```
<configuration>
<system.webServer>
<httpErrors existingResponse="PassThrou... | IIS is obscuring the "detail" of the error (your json response) because by default errors are set to `DetailedLocalOnly`, meaning that the error detail will be shown for requests from the machine the website is running on, but show the generic IIS error page for that error code for any external requests.
Setting the 4... |
8,081,268 | I've different divboxes and some pictures below them. If I hover the divboxes, they expand from 200px to 400px and the picture below slide.
So I've the function "theRotation" and i call two external function in it like this:
```
function theRotation(){
opendivs(); //this expand the divbox to 400 px
rotatePicture(); /... | 2011/11/10 | ['https://Stackoverflow.com/questions/8081268', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/831022/'] | I had some issues with this process as well. I don't exactly recall what resolved this error, but I followed [This Tutorial](http://net.tutsplus.com/tutorials/php/how-to-authenticate-users-with-twitter-oauth/) (albeit a bit out of date) and made sure I explicitly set the callback URL in the twitter panel for my app. Al... | step 1: <https://apps.twitter.com/app> or go to your app setting
step 2: Unchecked the (Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url)) This box..
save and exit and check..
ThankYou..! |
40,625,869 | we started to develope an application with swift for iOS.
when we started it latest version was developer target 9.3.
now there is developer target 10 available. Can I install application that created with developer target 9.3 on iOS 10 ? | 2016/11/16 | ['https://Stackoverflow.com/questions/40625869', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4433550/'] | In short - YES. You won't be able to do the opposite - install targeted as iOS 10 app to device, running with iOS 9.3
EDITED
So, your purposes, I think, maintain as small version, as possible. If you maintain 9.3 version, for example, your app will be available for iPhone 4s, which is not updates to iOS 10. With this... | **Deployment Target** is the **minimum required iOS version you application needs to run**.
You can build an application with SDK 10 that runs under iOS 9. But then you have to take care to not use any function or method that is not available on iOS 9.
Also Always check to see if you are using deprecated APIs; thoug... |
40,625,869 | we started to develope an application with swift for iOS.
when we started it latest version was developer target 9.3.
now there is developer target 10 available. Can I install application that created with developer target 9.3 on iOS 10 ? | 2016/11/16 | ['https://Stackoverflow.com/questions/40625869', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4433550/'] | Yes, You can install lower developer target on higher iOS version. | **Deployment Target** is the **minimum required iOS version you application needs to run**.
You can build an application with SDK 10 that runs under iOS 9. But then you have to take care to not use any function or method that is not available on iOS 9.
Also Always check to see if you are using deprecated APIs; thoug... |
3,326,203 | I'm having a little difficulty wrapping my head around the difference between these two terms, so could someone verify if this is correct? I've struggle to find an answers or reference in a book or online.
Component sequence:
If you have a set $X \subset \mathbb{R}^m$ and a sequence $x \in X^\infty$ such that
$$x = ... | 2019/08/17 | ['https://math.stackexchange.com/questions/3326203', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/466286/'] | Component sequences are projections of your sequences on the one dimensional axes of your space. Each component sequence is an infinite sequence of picking the sequence of terms in one dimension of the original sequence .
For example if $$\{(1,4,5),(3,2,4),(5,3,6),...\}$$ is a sequence in $R^3$, then you have three co... | The answer to you example-question is no. A component-sequence takes only one component per term, always from the same position, and so for each term.
So, if $x\_1 = (1,3,5,7,9)$ like you suggest, then there are exactly five component sequences of $x$, one of them starts with $1$ and takes the first coordinate of each... |
59,465,212 | I recently migrated from c# to .net core. In c# I use to get CPU usage with this:
```
PerformanceCounter cpuCounter;
PerformanceCounter ramCounter;
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
public string getCurrentCpuUsage(){
return cpuCounter.NextValue()+"%";
}
```... | 2019/12/24 | ['https://Stackoverflow.com/questions/59465212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11589744/'] | Performance counters are not in Linux thus not in NET Core. Alternative way:
```
private async Task<double> GetCpuUsageForProcess()
{
var startTime = DateTime.UtcNow;
var startCpuUsage = Process.GetProcesses().Sum(a => a.TotalProcessorTime.TotalMilliseconds);
await Task.Delay(500);
var endTime = DateT... | On Mac, I went the same route as [you already have to go to get memory usage](https://apple.stackexchange.com/questions/317483/how-to-calculate-used-memory-on-mac-os-by-command-line): shell out to a command-line utility, such as `top`, and parse the output.
Here's my code:
```
private static string[] GetOsXT... |
26,469,017 | I'm recreating the classic game 'Snake'. My idea is to firstly make a grid of 50 x 50 cells where each cell is a label of 10 x 10 pixels.
However, I can't get this to work. I'm using GridLayout but somehow this doesn't really work, as I apparently can't set the site of each grid.
I watched a video on Youtube where ... | 2014/10/20 | ['https://Stackoverflow.com/questions/26469017', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4017593/'] | I found an solution my self, and sharing it here for some one else to use. The following codes should be placed inside the Wordpress loop.
```
<?php $fields = get_field('relationship_field_name'); ?>
<?php if( $fields ): ?>
<?php foreach( $fields as $field ): ?>
... | I understand, you want to set connection two different post types. You can this with custom fields. Create a selectbox and there options is post of your other custom post type.
For be easy you can use Rilwis's meta box plugin (<https://github.com/rilwis/meta-box>).
Your option value must post id. If you want get selec... |
59,972,802 | My aim was to use ajax to retrieve some data from my controller and append this to a table element in my view. However the javascript code only works until "$.ajax(" at which point it just stops. I placed some break points after the above mentioned point but the code never "broke" at those points.
This is the javascr... | 2020/01/29 | ['https://Stackoverflow.com/questions/59972802', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12765810/'] | You have 2 issues that I can see.
First, you're making a `POST` request to a controller action that does not have the `[HttpPost]` annotation. It seems to me that you're getting/selecting data and a `GET` request would be more appropriate so I've used that in the example below.
Second, you cannot use `@URL.Action("Di... | I also had same problem like that. I did that in a `script` tag placed inside `head` tag. But I had to place that inside `body` tag. Then it worked fine. Try to use. It might help. |
25,352,105 | The following code doesn't loop:
```
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"Inside method, before for loop");
NSLog(@"dayBarArray.count = %lu", (unsigned long)dayBarArray.count);
for (int i = 0; i < dayBarArray.count; i++) //*** I've tried it this way
// for (DayChar... | 2014/08/17 | ['https://Stackoverflow.com/questions/25352105', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2671035/'] | `dayBarArray.count` is zero, and the condition in the loop is `i < dayBarArray.count`. Before entering the loop body, it tests `0 < 0`, which is false, so it never enters the body. | dayBarArray.count should return a number greater than 0, to be able for the loop to execute at least once. In you case, because (dayBarArray.count == 0), the condition-expression for the for loop:
```
i < dayBarArray.count
```
is false (because i == 0),
and the the execution of the program will not go inside the lo... |
25,352,105 | The following code doesn't loop:
```
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"Inside method, before for loop");
NSLog(@"dayBarArray.count = %lu", (unsigned long)dayBarArray.count);
for (int i = 0; i < dayBarArray.count; i++) //*** I've tried it this way
// for (DayChar... | 2014/08/17 | ['https://Stackoverflow.com/questions/25352105', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2671035/'] | `dayBarArray.count` is zero, and the condition in the loop is `i < dayBarArray.count`. Before entering the loop body, it tests `0 < 0`, which is false, so it never enters the body. | Your for loop will only execute when dayBarArray.count is greater than i and your log is telling you that dayBarArray.count equals 0 when i also equals 0.
Your code is working correctly. Check where you are adding items to dayBarArray. |
18,849,257 | I need to pass a model value item.ID to one of my javascript function how can I do that ?
I tried`function("@item.ID")` but its not working | 2013/09/17 | ['https://Stackoverflow.com/questions/18849257', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1858684/'] | It generally works this way, you just have to omit the `""` otherwise it gets interpreted as string. So you can write something like that in your JS:
```
var myinteger = @item.ID;
```
which renders as
```
var myinteger = 123; //for example
```
Edit: This makes sense when you id is an integer, of course, for str... | Try this...mind single quotes on parameter value while calling js function
```
function MyJsFunction(modelvalue)
{
alert("your model value: " + modelvalue);
}
<input type="button" onclick="MyJsFunction('@item.ID')" />
OR
<input type="button" onclick="MyJsFunction('@(item.ID)')" />
``` |
18,849,257 | I need to pass a model value item.ID to one of my javascript function how can I do that ?
I tried`function("@item.ID")` but its not working | 2013/09/17 | ['https://Stackoverflow.com/questions/18849257', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1858684/'] | It generally works this way, you just have to omit the `""` otherwise it gets interpreted as string. So you can write something like that in your JS:
```
var myinteger = @item.ID;
```
which renders as
```
var myinteger = 123; //for example
```
Edit: This makes sense when you id is an integer, of course, for str... | The best solution is pass your textbox ID to javascrpit function and then in function retrieve the value form the ID,
```
@Html.TextBoxFor(model => model.DatemailedStart, new {id = "MailStartDate", placeholder = "MM/DD/YYYY", maxlength = "40", @class = "TextboxDates", @onblur = "isValidDate('MailStartDate');" })
f... |
18,849,257 | I need to pass a model value item.ID to one of my javascript function how can I do that ?
I tried`function("@item.ID")` but its not working | 2013/09/17 | ['https://Stackoverflow.com/questions/18849257', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1858684/'] | You can pass the model data into the java script file in these ways
(1). Just set the value in hidden field and access the value of hidden field in java script.
(2). And pass the value using function parameter.
(3).
```
var LoginResourceKeyCollection = {
UserName_Required: '<%= Model.UserName%>',
... | Try this...mind single quotes on parameter value while calling js function
```
function MyJsFunction(modelvalue)
{
alert("your model value: " + modelvalue);
}
<input type="button" onclick="MyJsFunction('@item.ID')" />
OR
<input type="button" onclick="MyJsFunction('@(item.ID)')" />
``` |
18,849,257 | I need to pass a model value item.ID to one of my javascript function how can I do that ?
I tried`function("@item.ID")` but its not working | 2013/09/17 | ['https://Stackoverflow.com/questions/18849257', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1858684/'] | You can pass the model data into the java script file in these ways
(1). Just set the value in hidden field and access the value of hidden field in java script.
(2). And pass the value using function parameter.
(3).
```
var LoginResourceKeyCollection = {
UserName_Required: '<%= Model.UserName%>',
... | The best solution is pass your textbox ID to javascrpit function and then in function retrieve the value form the ID,
```
@Html.TextBoxFor(model => model.DatemailedStart, new {id = "MailStartDate", placeholder = "MM/DD/YYYY", maxlength = "40", @class = "TextboxDates", @onblur = "isValidDate('MailStartDate');" })
f... |
18,849,257 | I need to pass a model value item.ID to one of my javascript function how can I do that ?
I tried`function("@item.ID")` but its not working | 2013/09/17 | ['https://Stackoverflow.com/questions/18849257', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1858684/'] | Try this...mind single quotes on parameter value while calling js function
```
function MyJsFunction(modelvalue)
{
alert("your model value: " + modelvalue);
}
<input type="button" onclick="MyJsFunction('@item.ID')" />
OR
<input type="button" onclick="MyJsFunction('@(item.ID)')" />
``` | The best solution is pass your textbox ID to javascrpit function and then in function retrieve the value form the ID,
```
@Html.TextBoxFor(model => model.DatemailedStart, new {id = "MailStartDate", placeholder = "MM/DD/YYYY", maxlength = "40", @class = "TextboxDates", @onblur = "isValidDate('MailStartDate');" })
f... |
33,772,472 | After someone has logged off (*Start button→Logoff*) for the night, at a certain time in the morning I want to have the Task Scheduler automatically log into the Windows 7 user account (the opposite of *Start button→Logoff*) that is password protected. The machine is 64 bit. I am doing this so systems (vbs, vba, etc.) ... | 2015/11/18 | ['https://Stackoverflow.com/questions/33772472', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3524158/'] | Please minus the half the stroke width from x position.
you will get the correct path.
eg. if stroke width is 20 mean minus the 10 from second MoveTo.
**calculation** 254-(storkeWidth/2) = 244. if strokeWidth is 20.
```
<svg height="200" width="500">
<path fill='none' stroke-width="20" stroke="black" d="M 100 63.... | [stroke-linejoin](http://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty "Take this")
```
<svg height="200" width="500">
<path fill='none' stroke-width="30" stroke-linejoin="round" stroke="black" d="M 100 63.125 L 254 63.125 L 254 117.5 L 418 117.5"/>
</svg>
``` |
50,589,825 | I am currently looking at IdentityServer4 as an option for our web services. However, due to corporate compiler level policy, I am only able to use VisualStudio 15.0 which does not support .Net Core 2 (and ASP.NET core 2 therefore). So I am stuck with ASP.Net Core 1.x for the moment. Changing the compiler version is ou... | 2018/05/29 | ['https://Stackoverflow.com/questions/50589825', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1704574/'] | Security vulnerabilities would be fixed on the 1.x branch - but no more feature work | Here is Brock Allen's answer :
>
> [...] if there are any security vulnerabilities reported we will fix them. But we won't be adding new features to the ASP.NET Core 1.x branch, as Microsoft themselves have moved on to ASP.NET Core 2.x and (in their eyes) ASP.NET Core 1.x is essentially deprecated.
>
>
> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.