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 |
|---|---|---|---|---|---|
3,926,936 | I have a directory of 9 images:
```
image_0001, image_0002, image_0003
image_0010, image_0011
image_0011-1, image_0011-2, image_0011-3
image_9999
```
I would like to be able to list them in an efficient way, like this (4 entries for 9 images):
```
(image_000[1-3], image_00[10-11], image_0011-[1-3], image_9999)
`... | 2010/10/13 | ['https://Stackoverflow.com/questions/3926936', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178686/'] | Here is a working implementation of what you want to achieve, using the code you added as a starting point:
```
#!/usr/bin/env python
import itertools
import re
# This algorithm only works if DATA is sorted.
DATA = ["image_0001", "image_0002", "image_0003",
"image_0010", "image_0011",
"image_0011-1",... | Okay, so I found your question to be a fascinating puzzle. I've left how to
"compress" the numeric ranges up to you (marked as a TODO), as there are
different ways to accomplish that depending on how you like it formatted and if
you want the minimum number of elements or the minimum string description
length.
This sol... |
373,831 | I need to center the title of the parts in the toc. I'm trying these two approaches:
```
\documentclass{article}
\usepackage{hyperref}
\usepackage{tocloft}
\cftpagenumbersoff{part}
\begin{document}
\tableofcontents
\addcontentsline{toc}{part}{\centerline{Part A}}
\addcontentsline{toc}{section}{Section A}
... | 2017/06/07 | ['https://tex.stackexchange.com/questions/373831', 'https://tex.stackexchange.com', 'https://tex.stackexchange.com/users/134459/'] | You need to expand the number when you define \parttitle:
```
\documentclass[11pt, oneside, a4paper]{memoir}
\usepackage{lipsum}
\newcounter{DocPart}
\setcounter{DocPart}{0}
\newcommand{\pageNumber}{}
\newcommand{\parttitle}{}
\renewcommand{\part}[1]{%
\ifnum\theDocPart = 0
\renewcommand{\parttitle}{A. ... | The setting of the header is as far as I know asynchronous. However, expanding the `\theDocPart` in `\pageNumber` and `\parttitle` does work:
```
\documentclass[11pt, oneside, a4paper]{memoir}
\usepackage{lipsum}
\newcounter{DocPart}
\setcounter{DocPart}{0}
\newcommand{\pageNumber}{}
\newcommand{\parttitle}{}
\renew... |
66,189,992 | If this doesnt make sense, let me show you an example.
Right now, I am trying to evaluate a postfix expression. I have done everything needed, but there is one problem.
When I have single digits in the expression, everything works fine. This is because during my code, I had to get rid of all spaces.
For exampl... | 2021/02/13 | ['https://Stackoverflow.com/questions/66189992', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14923907/'] | There are a few issues with your code.
1. Instead of the replace, you can simply use `formula.split()`
2. You are popping the items in the wrong order, you need to pop a before b to get the right answers. You were lucky to have the first case give you the same, but second fails because instead of 13/5 it does 5/13.
I... | Instead of removing spaces, you should keep them: this will make it easy to extract the *words* from the input, using `split`:
```
for ch in formula.split():
``` |
69,445,978 | Lets say I have two franchise of dance schools.
I have two tables. First table tells about students roll no. every
Table 1 =
```
Roll No. Center ID Name Date
1 A Anna 10/10/2020
1 A Anna 11/10/2020
1 B Anna 12/10/2020
2 A Bella 12/10/2020
2 B Bella 13/10/2020
3 A Catty ... | 2021/10/05 | ['https://Stackoverflow.com/questions/69445978', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11496279/'] | By `dplyr`,
```
t1 %>%
mutate(Report = t2$Report) %>%
group_by(Roll_No.) %>%
summarise(Center_ID = "A",
Report = paste0(Report, collapse = ', '),
Name = unique(Name)
)
Roll_No. Center_ID Report Name
<int> <chr> <chr> <chr>
1 1 A... | ```r
library(tidyverse)
a <- tribble(
~Roll, ~Center, ~Name, ~Date,
1, "A", "Anna", "10/10/2020",
1, "B", "Anna", "12/10/2020",
3, "A", "Catty", "10/10/2020"
)
b <- tribble(
~Roll, ~Center, ~Report,
1, "A", "Dis well",
1, "A", "Sick",
1, "B", "Needs more twist",
3, "A", "Needs more practice"
)
a %>... |
69,445,978 | Lets say I have two franchise of dance schools.
I have two tables. First table tells about students roll no. every
Table 1 =
```
Roll No. Center ID Name Date
1 A Anna 10/10/2020
1 A Anna 11/10/2020
1 B Anna 12/10/2020
2 A Bella 12/10/2020
2 B Bella 13/10/2020
3 A Catty ... | 2021/10/05 | ['https://Stackoverflow.com/questions/69445978', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11496279/'] | By `dplyr`,
```
t1 %>%
mutate(Report = t2$Report) %>%
group_by(Roll_No.) %>%
summarise(Center_ID = "A",
Report = paste0(Report, collapse = ', '),
Name = unique(Name)
)
Roll_No. Center_ID Report Name
<int> <chr> <chr> <chr>
1 1 A... | With **`dplyr`** package:
```
library(dplyr)
cbind(df1, Report=df2$Report) %>% group_by(Name) %>%
summarize(RollNo=first(RollNo), CenterID=first(CenterID), Report=paste(toString(Report), first(Name), collapse=' '))
```
Output:
```
Name RollNo CenterID Report
<chr> <dbl> <chr>... |
69,445,978 | Lets say I have two franchise of dance schools.
I have two tables. First table tells about students roll no. every
Table 1 =
```
Roll No. Center ID Name Date
1 A Anna 10/10/2020
1 A Anna 11/10/2020
1 B Anna 12/10/2020
2 A Bella 12/10/2020
2 B Bella 13/10/2020
3 A Catty ... | 2021/10/05 | ['https://Stackoverflow.com/questions/69445978', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11496279/'] | By `dplyr`,
```
t1 %>%
mutate(Report = t2$Report) %>%
group_by(Roll_No.) %>%
summarise(Center_ID = "A",
Report = paste0(Report, collapse = ', '),
Name = unique(Name)
)
Roll_No. Center_ID Report Name
<int> <chr> <chr> <chr>
1 1 A... | **update:**
With the hint of @Park many thanks!:
Logic:
1. `left_join` by `RollNo.`
2. `filter`, `group_by` and `summarise`
```
library(dplyr)
table1 %>%
left_join(table2, by=c("RollNo."="Rollno.")) %>%
filter(CenterID.x== "A") %>%
group_by(RollNo., CenterID=CenterID.x, Name) %>%
summarise(Report = paste(... |
30,107,988 | I have a sparse banded matrix A and I'd like to (direct) solve Ax=b. I have about 500 vectors b, so I'd like to solve for the corresponding 500 x's.
I'm brand new to CUDA, so I'm a little confused as to what options I have available.
cuSOLVER has a batch direct solver cuSolverSP for sparse A\_i x\_i = b\_i using QR [... | 2015/05/07 | ['https://Stackoverflow.com/questions/30107988', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1672126/'] | I'm currently working on something similar myself. I decided to basically wrap the conjugate gradient and level-0 incomplete cholesky preconditioned conjugate gradient solvers utility samples that came with the CUDA SDK into a small class.
You can find them in your CUDA\_HOME directory under the path:
`samples/7_CUDAL... | If you don't mind going with an open-source library, you could also check out CUSP:
[CUSP Quick Start Page](https://code.google.com/p/cusp-library/wiki/QuickStartGuide)
It has a fairly decent suite of solvers, including a few preconditioned methods:
[CUSP Preconditioner Examples](http://code.google.com/p/cusp-library/... |
30,107,988 | I have a sparse banded matrix A and I'd like to (direct) solve Ax=b. I have about 500 vectors b, so I'd like to solve for the corresponding 500 x's.
I'm brand new to CUDA, so I'm a little confused as to what options I have available.
cuSOLVER has a batch direct solver cuSolverSP for sparse A\_i x\_i = b\_i using QR [... | 2015/05/07 | ['https://Stackoverflow.com/questions/30107988', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1672126/'] | I'm currently working on something similar myself. I decided to basically wrap the conjugate gradient and level-0 incomplete cholesky preconditioned conjugate gradient solvers utility samples that came with the CUDA SDK into a small class.
You can find them in your CUDA\_HOME directory under the path:
`samples/7_CUDAL... | >
> is there a standard way to batch perform this operation for multiple b\_i's?
>
>
>
One option is to use the batched refactorization module in CUDA's cuSOLVER, but I am not sure if it is *standard*.
Batched refactorization module in cuSOLVER provides an efficient method to solve batches of linear systems with ... |
30,107,988 | I have a sparse banded matrix A and I'd like to (direct) solve Ax=b. I have about 500 vectors b, so I'd like to solve for the corresponding 500 x's.
I'm brand new to CUDA, so I'm a little confused as to what options I have available.
cuSOLVER has a batch direct solver cuSolverSP for sparse A\_i x\_i = b\_i using QR [... | 2015/05/07 | ['https://Stackoverflow.com/questions/30107988', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1672126/'] | >
> is there a standard way to batch perform this operation for multiple b\_i's?
>
>
>
One option is to use the batched refactorization module in CUDA's cuSOLVER, but I am not sure if it is *standard*.
Batched refactorization module in cuSOLVER provides an efficient method to solve batches of linear systems with ... | If you don't mind going with an open-source library, you could also check out CUSP:
[CUSP Quick Start Page](https://code.google.com/p/cusp-library/wiki/QuickStartGuide)
It has a fairly decent suite of solvers, including a few preconditioned methods:
[CUSP Preconditioner Examples](http://code.google.com/p/cusp-library/... |
155,403 | In the ancient times when things were easy, you just had to code a form in html and then your php would typically have a if($\_REQUEST['some\_value']) to handle the request. But now with Drupal, nothing is easy... Here is once more my latest battle to understand how Drupal thinks.
Context: I have a list of news (conte... | 2015/04/16 | ['https://drupal.stackexchange.com/questions/155403', 'https://drupal.stackexchange.com', 'https://drupal.stackexchange.com/users/39325/'] | Drupal's Form API is complex but gives you lot of things: is secure, is extensible, is themeable. Indeed is more difficult than coding a simple HTML form, but with a simpel HTML form you have a simple functionality: just that simple HTML form.
Form API generates the form HTML element and handles the POST requests, and... | The issue here is theme\_wrappers around your form elements.
// @see: <https://drupal.stackexchange.com/a/193587/58635> |
18,292 | Приложение с союзом как обычно имеет дополнительное значение причинности (можно заменить придаточным причины с союзами так как, потому что, поскольку или оборотом со словом будучи) и обособляется:
Как старый артиллерист, я презираю этот вид холодного оружия (Шолохов). – Будучи старым артиллеристом, я презираю этот вид... | 2013/04/09 | ['https://rus.stackexchange.com/questions/18292', 'https://rus.stackexchange.com', 'https://rus.stackexchange.com/users/1197/'] | Обособление - это выделение в устной речи интонационно, а в письменной речи - с помощью знаков препинания. И то, и другое в данном случае зависит от смысла, который вы вкладываете во фразу. Правильные знаки помогают читающему понять суть. | Любое приложение при личном местоимении обособляется, и прочитать вы его сможете только с интонацией выделения. Так что вариантов нет:Я, как лучший математик класса, буду участником олимпиады. А значение у приложения явно причинное.
Мой друг, как лучший математик класса, будет участником олимпиады. - тоже без варианто... |
21,438,650 | I am sorry if this question has been asked before, but could not find a solution to my problem. Which `apply`-like function fits the below case?
I have an `R` function which has 3 arguments `(x, y, z)`. What it does is basically to call an `PostgreSQL` function which quires `x, y, z` and retrieve a dataframe consistin... | 2014/01/29 | ['https://Stackoverflow.com/questions/21438650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1734415/'] | If x, y, and z are the first three columns of df, then this should work:
```
apply(df,1,function(params)myfunc(params[1],params[2], params[3]))
```
`apply(df,1,FUN)` takes the first argument, `df`, and passes it to FUN row-wise (because the second argument is 1). So in `function(params)`, params is a row of `df`. He... | This version will work if your arguments are of different types, though in this case it looks like they are all character or can be treated as such so `apply` works fine.
```
sapply(
split(df, 1:nrow(df)),
function(x) do.call(myfunc, x)
)
``` |
21,438,650 | I am sorry if this question has been asked before, but could not find a solution to my problem. Which `apply`-like function fits the below case?
I have an `R` function which has 3 arguments `(x, y, z)`. What it does is basically to call an `PostgreSQL` function which quires `x, y, z` and retrieve a dataframe consistin... | 2014/01/29 | ['https://Stackoverflow.com/questions/21438650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1734415/'] | If x, y, and z are the first three columns of df, then this should work:
```
apply(df,1,function(params)myfunc(params[1],params[2], params[3]))
```
`apply(df,1,FUN)` takes the first argument, `df`, and passes it to FUN row-wise (because the second argument is 1). So in `function(params)`, params is a row of `df`. He... | Just apply over `1` for your margin; then the row is passed to your function as a vector and you should be able to deal with it. For example:
```
> apply(iris, 1, function(v) paste(v["Species"], v["Sepal.Width"]))
[1] "setosa 3.5" "setosa 3.0" "setosa 3.2" "setosa 3.1"
...
``` |
21,438,650 | I am sorry if this question has been asked before, but could not find a solution to my problem. Which `apply`-like function fits the below case?
I have an `R` function which has 3 arguments `(x, y, z)`. What it does is basically to call an `PostgreSQL` function which quires `x, y, z` and retrieve a dataframe consistin... | 2014/01/29 | ['https://Stackoverflow.com/questions/21438650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1734415/'] | If x, y, and z are the first three columns of df, then this should work:
```
apply(df,1,function(params)myfunc(params[1],params[2], params[3]))
```
`apply(df,1,FUN)` takes the first argument, `df`, and passes it to FUN row-wise (because the second argument is 1). So in `function(params)`, params is a row of `df`. He... | It's helpful if you supply sample data so you get an answer that matches your situation, but it sounds like you're looking for `mapply`, e.g.,
```
do.call(mapply, c(myfunc, call.df[c(x.col, y.col, z.col)]))
``` |
21,438,650 | I am sorry if this question has been asked before, but could not find a solution to my problem. Which `apply`-like function fits the below case?
I have an `R` function which has 3 arguments `(x, y, z)`. What it does is basically to call an `PostgreSQL` function which quires `x, y, z` and retrieve a dataframe consistin... | 2014/01/29 | ['https://Stackoverflow.com/questions/21438650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1734415/'] | This version will work if your arguments are of different types, though in this case it looks like they are all character or can be treated as such so `apply` works fine.
```
sapply(
split(df, 1:nrow(df)),
function(x) do.call(myfunc, x)
)
``` | Just apply over `1` for your margin; then the row is passed to your function as a vector and you should be able to deal with it. For example:
```
> apply(iris, 1, function(v) paste(v["Species"], v["Sepal.Width"]))
[1] "setosa 3.5" "setosa 3.0" "setosa 3.2" "setosa 3.1"
...
``` |
21,438,650 | I am sorry if this question has been asked before, but could not find a solution to my problem. Which `apply`-like function fits the below case?
I have an `R` function which has 3 arguments `(x, y, z)`. What it does is basically to call an `PostgreSQL` function which quires `x, y, z` and retrieve a dataframe consistin... | 2014/01/29 | ['https://Stackoverflow.com/questions/21438650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1734415/'] | It's helpful if you supply sample data so you get an answer that matches your situation, but it sounds like you're looking for `mapply`, e.g.,
```
do.call(mapply, c(myfunc, call.df[c(x.col, y.col, z.col)]))
``` | Just apply over `1` for your margin; then the row is passed to your function as a vector and you should be able to deal with it. For example:
```
> apply(iris, 1, function(v) paste(v["Species"], v["Sepal.Width"]))
[1] "setosa 3.5" "setosa 3.0" "setosa 3.2" "setosa 3.1"
...
``` |
15,588,510 | This is a two-part question from a newbie.
First, I need an encoding for simple text (without the lowercase/caps distinction), and I need it to be more space-efficient than ASCII. So I have thought of creating my own 5-bit code, holding a range of 32 characters (the alphabet plus some punctuation marks).
As far as I u... | 2013/03/23 | ['https://Stackoverflow.com/questions/15588510', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2134205/'] | This is precisely what they're doing. It's called recursion, and it's, well, hard to wrap your head around at first. Imagine you have strings:
A B C D
Effectively, what you do, is choose each string in turn and then find all permutations of the remaining strings, and prepend your chosen string.
```
Choose A, get all... | This is a recursive algorithm, it essentially takes each element in the array as the first one then adds to to it the output of calling itself without that element.
Take 3 elements A, B and C and walk through the logic, lets call our function `perm`.
so, we want
```
perm({A, B, C})
```
this equals
```
A + perm({B... |
15,588,510 | This is a two-part question from a newbie.
First, I need an encoding for simple text (without the lowercase/caps distinction), and I need it to be more space-efficient than ASCII. So I have thought of creating my own 5-bit code, holding a range of 32 characters (the alphabet plus some punctuation marks).
As far as I u... | 2013/03/23 | ['https://Stackoverflow.com/questions/15588510', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2134205/'] | This is precisely what they're doing. It's called recursion, and it's, well, hard to wrap your head around at first. Imagine you have strings:
A B C D
Effectively, what you do, is choose each string in turn and then find all permutations of the remaining strings, and prepend your chosen string.
```
Choose A, get all... | The scheme used is "divide and conquer". It's basic idea is to break up a big problem into a set of smaller problems to which the same mechanism is applied until an "atomic" level of the problem is reached. In other words: A problem of size n is broken up into n problems of size n-1 continuously. At the bottom there is... |
33,397,094 | **This part works.**
In my C#.NET WPF XAML, I have a **static** ComboBox and a **static** TextBox. The TextBox displays another column from the same DataTable (in the ComboBox's ItemSource). The column "rr\_code" is the column for company name and the column "rr\_addr" is the column for the address.
```
<ComboBox x:N... | 2015/10/28 | ['https://Stackoverflow.com/questions/33397094', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3847534/'] | The code-behind equivalent of this particular XAML + C# data binding in pure C# is:
```
ComboBox companyComboBox = new ComboBox();
companyComboBox.ItemsSource = Rails.DefaultView; // Rails being DataTable
companyComboBox.IsEditable = true;
companyComboBox.IsTextSearchEnabled = true;
companyComboBox.DisplayMemberPath ... | Why are you setting the TextBox DataContext ?
You can simply bind TextBox.Text property to ComboBox SelectedItem in your XAML
```
<TextBox Text="{Binding ElementName=CompanyComboBox1, Path=SelectedItem.rr_addr}"></TextBox>
``` |
70,421,369 | I have
```cpp
class ClassA {};
class ClassB {};
auto func_a() -> ClassA {
return ClassA(); // example implementation for illustration. in reality can be different. does not match the form of func_b
}
auto func_b() -> ClassB {
return ClassB(); // example implementation for illustration. in reality can be diff... | 2021/12/20 | ['https://Stackoverflow.com/questions/70421369', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11249764/'] | You might do something like (c++17):
```cpp
template <typename T>
auto func()
{
if constexpr (std::is_same_v<T, ClassA>) {
return func_a();
} else {
return func_b();
}
}
```
Alternative for pre-C++17 is tag dispatching (which allows customization point):
```cpp
// Utility class to allow ... | You can do it like this :
```
#include <iostream>
#include <type_traits>
class A
{
public:
void hi()
{
std::cout << "hi\n";
}
};
class B
{
public:
void boo()
{
std::cout << "boo\n";
}
};
template<typename type_t>
auto create()
{
// optional : if you only want to be able ... |
1,429,246 | I just compiled the latest preview of Qt4.6 on Snow Leopard in 64 bit without any major issues.
<http://qt.nokia.com/developer/qt-4.6-technology-preview#download-the-qt-4-1>
Now, I am trying to do the same for PyQt4.6 with the latest snapshot from the River Bank website. However, the compiler exits with the following... | 2009/09/15 | ['https://Stackoverflow.com/questions/1429246', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/134397/'] | I just got PyQt 4.6.2 working with the 64bit Python 2.6.1. I posted the instructions here: <http://mpastell.com/2009/11/24/pyqt-4-6-2-with-snow-leopard/> | In the changelogs I see Phil (PyQt's maintainer) [has issued fixes](http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/ChangeLog-4.6-snapshot-20090914) yesterday in the development snapshots specifically for Snow Leopard:
>
> 2009/09/14 12:12:49 phil Further
> fixes for Snow Leopard on 64 bit
> systems. Add... |
1,429,246 | I just compiled the latest preview of Qt4.6 on Snow Leopard in 64 bit without any major issues.
<http://qt.nokia.com/developer/qt-4.6-technology-preview#download-the-qt-4-1>
Now, I am trying to do the same for PyQt4.6 with the latest snapshot from the River Bank website. However, the compiler exits with the following... | 2009/09/15 | ['https://Stackoverflow.com/questions/1429246', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/134397/'] | In the changelogs I see Phil (PyQt's maintainer) [has issued fixes](http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/ChangeLog-4.6-snapshot-20090914) yesterday in the development snapshots specifically for Snow Leopard:
>
> 2009/09/14 12:12:49 phil Further
> fixes for Snow Leopard on 64 bit
> systems. Add... | You might want to use PyQt from the homebrew project: straightforward build, managed dependencies.
Run fine on my MBP Unibody, all 64-bit. |
1,429,246 | I just compiled the latest preview of Qt4.6 on Snow Leopard in 64 bit without any major issues.
<http://qt.nokia.com/developer/qt-4.6-technology-preview#download-the-qt-4-1>
Now, I am trying to do the same for PyQt4.6 with the latest snapshot from the River Bank website. However, the compiler exits with the following... | 2009/09/15 | ['https://Stackoverflow.com/questions/1429246', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/134397/'] | I just got PyQt 4.6.2 working with the 64bit Python 2.6.1. I posted the instructions here: <http://mpastell.com/2009/11/24/pyqt-4-6-2-with-snow-leopard/> | You might want to use PyQt from the homebrew project: straightforward build, managed dependencies.
Run fine on my MBP Unibody, all 64-bit. |
15,653,028 | What is the best way to get the current location in android for the following scenario,
1. If GPS is not available, get location from Network provider
2. If GPS is available and can get current location, get location from GPS provider
3. If GPS is available but can't get current location(i.e continuously searching loc... | 2013/03/27 | ['https://Stackoverflow.com/questions/15653028', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1351297/'] | Well, you can use [Timer](http://developer.android.com/reference/java/util/Timer.html) and [TimerTask](http://developer.android.com/reference/java/util/TimerTask.html) classes.
```
LocationManager manager;
TimerTask mTimertask;
GPSLocationListener mGPSLocationListener;
int i = 0; //Here i works as counter;
private sta... | ```
If GPS is available and can get current location,
```
For the above question you can try like this..
Using this you can get the latitude and longitude for the current location then pass the value to get the map.
```
public class MyLocationListener implements LocationListener
{
@Override
public void onLocati... |
15,653,028 | What is the best way to get the current location in android for the following scenario,
1. If GPS is not available, get location from Network provider
2. If GPS is available and can get current location, get location from GPS provider
3. If GPS is available but can't get current location(i.e continuously searching loc... | 2013/03/27 | ['https://Stackoverflow.com/questions/15653028', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1351297/'] | Well, you can use [Timer](http://developer.android.com/reference/java/util/Timer.html) and [TimerTask](http://developer.android.com/reference/java/util/TimerTask.html) classes.
```
LocationManager manager;
TimerTask mTimertask;
GPSLocationListener mGPSLocationListener;
int i = 0; //Here i works as counter;
private sta... | class member `boolean mIsGpsFix`;
Request Gps location update and set up a countdown timer
```
mCountDown.start();
private CountDownTimer mCountDown = new CountDownTimer(time to wait for Gps fix, same as right)
{
@Override
public void onTick(long millisUntilFinished)
{
}
@Override
public... |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | The reason why you're getting the error is because `MvcJsonOptions` was removed in .NET Core 3.0; you can read more about the breaking changes [here](https://github.com/aspnet/Announcements/issues/325). | In my case, the solution was to add `services.AddControllers()` as described under <https://github.com/RicoSuter/NSwag/issues/1961#issuecomment-515631411>. |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | netstandard2.1 to netcoreapp3.0
MvcJsonOptions -> MvcNewtonsoftJsonOptions
```
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//MVC
services.AddControllersWithViews(options =>
{
}).AddNewtonsoftJson();
services.PostConfigure<MvcNewt... | When you config "Swashbuckle.AspNetCore", needed for configuring ApiKeyScheme become to OpenApiSecurityScheme it is changing the scheme from
```
c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description =
"Please enter JWT with Bearer into field", Name = "Authorization", Type = "apiKey"
});
... |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | I'm not sure if this solves OP's problem, but this error also occurs when you use Swashbuckle 4 in .Net Core 3. The solution is to use Swashbuckle 5.
(use command `install-package Swashbuckle.AspNetCore`) to have in .csproj
```
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
```
Then you'll nee... | The reason why you're getting the error is because `MvcJsonOptions` was removed in .NET Core 3.0; you can read more about the breaking changes [here](https://github.com/aspnet/Announcements/issues/325). |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | I'm not sure if this solves OP's problem, but this error also occurs when you use Swashbuckle 4 in .Net Core 3. The solution is to use Swashbuckle 5.
(use command `install-package Swashbuckle.AspNetCore`) to have in .csproj
```
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
```
Then you'll nee... | The problem is most likely with the incompatible nuget packages for .net core 3.1 above. Take a look at your packages and eventually upgrade to compatible version of core 3.1. That should really fix the issue I had one with Automapper and others had with Swagger.
If you are using AutoMapper you should upgrade to 7.0.0... |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | The reason why you're getting the error is because `MvcJsonOptions` was removed in .NET Core 3.0; you can read more about the breaking changes [here](https://github.com/aspnet/Announcements/issues/325). | The problem is most likely with the incompatible nuget packages for .net core 3.1 above. Take a look at your packages and eventually upgrade to compatible version of core 3.1. That should really fix the issue I had one with Automapper and others had with Swagger.
If you are using AutoMapper you should upgrade to 7.0.0... |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | I'm not sure if this solves OP's problem, but this error also occurs when you use Swashbuckle 4 in .Net Core 3. The solution is to use Swashbuckle 5.
(use command `install-package Swashbuckle.AspNetCore`) to have in .csproj
```
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
```
Then you'll nee... | In my case, the solution was to add `services.AddControllers()` as described under <https://github.com/RicoSuter/NSwag/issues/1961#issuecomment-515631411>. |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | The problem is most likely with the incompatible nuget packages for .net core 3.1 above. Take a look at your packages and eventually upgrade to compatible version of core 3.1. That should really fix the issue I had one with Automapper and others had with Swagger.
If you are using AutoMapper you should upgrade to 7.0.0... | In my case, the solution was to add `services.AddControllers()` as described under <https://github.com/RicoSuter/NSwag/issues/1961#issuecomment-515631411>. |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | netstandard2.1 to netcoreapp3.0
MvcJsonOptions -> MvcNewtonsoftJsonOptions
```
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//MVC
services.AddControllersWithViews(options =>
{
}).AddNewtonsoftJson();
services.PostConfigure<MvcNewt... | The problem is most likely with the incompatible nuget packages for .net core 3.1 above. Take a look at your packages and eventually upgrade to compatible version of core 3.1. That should really fix the issue I had one with Automapper and others had with Swagger.
If you are using AutoMapper you should upgrade to 7.0.0... |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | I'm not sure if this solves OP's problem, but this error also occurs when you use Swashbuckle 4 in .Net Core 3. The solution is to use Swashbuckle 5.
(use command `install-package Swashbuckle.AspNetCore`) to have in .csproj
```
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
```
Then you'll nee... | netstandard2.1 to netcoreapp3.0
MvcJsonOptions -> MvcNewtonsoftJsonOptions
```
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//MVC
services.AddControllersWithViews(options =>
{
}).AddNewtonsoftJson();
services.PostConfigure<MvcNewt... |
58,362,757 | I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:
>
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
> assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
>
>
>
I'm also using some featu... | 2019/10/13 | ['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/'] | When you config "Swashbuckle.AspNetCore", needed for configuring ApiKeyScheme become to OpenApiSecurityScheme it is changing the scheme from
```
c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description =
"Please enter JWT with Bearer into field", Name = "Authorization", Type = "apiKey"
});
... | In my case, the solution was to add `services.AddControllers()` as described under <https://github.com/RicoSuter/NSwag/issues/1961#issuecomment-515631411>. |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Much likely it's a device OS bug. I have much problems with AudioRecord library - it also fails in native init on number of devices like Yusu, Micromax, Alcatel and other low range devices. They are all shown as "other" in GooglePlay reports. Also I encoundered that some [Cyanogenmod](http://www.cyanogenmod.org/) ROMs ... | Looks like some firmware had problem with StatFs
I had similar issue with Samsung Galaxy Stratosphere™ II (Verizon) SCH-I415, Android:4.1.2
When I call:
```
StatFs statFs = null;
statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
```
I got exception:
```
java.lang.IllegalArgumentE... |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Much likely it's a device OS bug. I have much problems with AudioRecord library - it also fails in native init on number of devices like Yusu, Micromax, Alcatel and other low range devices. They are all shown as "other" in GooglePlay reports. Also I encoundered that some [Cyanogenmod](http://www.cyanogenmod.org/) ROMs ... | I have got similar issue and my log was looking like
```
03-14 13:41:55.715: E/PayPalService(14037): Risk component failed to initialize, threw null
03-14 13:41:56.295: E/(14037): statfs /storage/sdcard0 failed, errno: 13
03-14 13:41:56.365: E/AndroidRuntime(14037): FATAL EXCEPTION: Thread-1219
03-14 13:41:56.365: E/... |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Much likely it's a device OS bug. I have much problems with AudioRecord library - it also fails in native init on number of devices like Yusu, Micromax, Alcatel and other low range devices. They are all shown as "other" in GooglePlay reports. Also I encoundered that some [Cyanogenmod](http://www.cyanogenmod.org/) ROMs ... | Path which you are providing in Statfs constructor does not exists
```
String path = "path to some directory";
StatFs statFs = null;
statFs = new StatFs(path);
```
and you must have external storage permission in manifest file |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Much likely it's a device OS bug. I have much problems with AudioRecord library - it also fails in native init on number of devices like Yusu, Micromax, Alcatel and other low range devices. They are all shown as "other" in GooglePlay reports. Also I encoundered that some [Cyanogenmod](http://www.cyanogenmod.org/) ROMs ... | Starting with Lollipop, Android placed rather extreme restrictions on accessing external SD cards. You can use:
```
StatFs stat;
try {
stat = new StatFs(path);
} catch (IllegalArgumentException e) {
// Handle the failure gracefully or just throw(e)
}
```
to work-around the error.
For... |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Path which you are providing in Statfs constructor does not exists
```
String path = "path to some directory";
StatFs statFs = null;
statFs = new StatFs(path);
```
and you must have external storage permission in manifest file | Looks like some firmware had problem with StatFs
I had similar issue with Samsung Galaxy Stratosphere™ II (Verizon) SCH-I415, Android:4.1.2
When I call:
```
StatFs statFs = null;
statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
```
I got exception:
```
java.lang.IllegalArgumentE... |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Path which you are providing in Statfs constructor does not exists
```
String path = "path to some directory";
StatFs statFs = null;
statFs = new StatFs(path);
```
and you must have external storage permission in manifest file | I have got similar issue and my log was looking like
```
03-14 13:41:55.715: E/PayPalService(14037): Risk component failed to initialize, threw null
03-14 13:41:56.295: E/(14037): statfs /storage/sdcard0 failed, errno: 13
03-14 13:41:56.365: E/AndroidRuntime(14037): FATAL EXCEPTION: Thread-1219
03-14 13:41:56.365: E/... |
14,796,931 | Google play reports an exception on some devices (all are "other" and one "LG-E400", so it might be some custom android build)
Exception is:
```
java.lang.IllegalArgumentException
at android.os.StatFs.native_setup(Native Method)
at android.os.StatFs.<init>(StatFs.java:32)
at android.webkit.CacheManager.init(CacheMana... | 2013/02/10 | ['https://Stackoverflow.com/questions/14796931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1148784/'] | Path which you are providing in Statfs constructor does not exists
```
String path = "path to some directory";
StatFs statFs = null;
statFs = new StatFs(path);
```
and you must have external storage permission in manifest file | Starting with Lollipop, Android placed rather extreme restrictions on accessing external SD cards. You can use:
```
StatFs stat;
try {
stat = new StatFs(path);
} catch (IllegalArgumentException e) {
// Handle the failure gracefully or just throw(e)
}
```
to work-around the error.
For... |
26,098,194 | So, I export `PNotify` from bower to the `js` folder. I use `requirejs` to include my libraries
**HTML**
```
<script data-main="assets/js/app" type="text/javascript" src="assets/js/lib/require.js"></script>
```
My architecture is like this :
```
js
--- app.js
--- lib
------ pnotify.core.js
------ pnotify.desktop.j... | 2014/09/29 | ['https://Stackoverflow.com/questions/26098194', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2798726/'] | >
> When they detect AMD/RequireJS, PNotify core defines the named module
> "**pnotify**", and PNotify's modules each define names like
> "pnotify.module". The following example shows the use of the nonblock
> and desktop modules with RequireJS.
>
>
>
So my error is here
```
requirejs.config({
base: '/asse... | Compile All the modules into one minified file.
These Settings work for me in Require.js
```
paths: {
'pnotify': 'lib/pnotify.min',
'pnotify.nonblock': 'lib/pnotify.min',
'pnotify.desktop': 'lib/pnotify.min,
'jquery' : 'lib/jquery'
}
define(['jquery', 'pnotify','pnotify.nonblock', 'pnotify.desktop', func... |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | $$\log\_2 x +\log\_4 x = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{\log\_ x4} = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{2\log\_ x2} = 2$$
$$\frac{3}{2\log\_ x2} = 2$$
$$\frac{1}{\log\_ x2} =\frac{4}{3}$$
$$\log\_ 2x =\frac{4}{3}$$
$$x=2^{4/3}$$ | we write $$\frac{\ln(x)}{\ln(2)}+\frac{\ln(x)}{2\ln(2)}=2$$ multiplying by $$2\ln(2)$$ we obtain
$$2\ln(x)+\ln(x)=4\ln(2)$$thus we get
$$\ln(x)=\frac{4}{3}\ln(2)$$ can you finish this? |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | If we apply 4^ to both sides, we get
$$4^{\log\_2(x)+\log\_4(x)}=16$$
$$4^{\log\_2(x)}4^{\log\_4(x)}=16$$
Since $4=2^2$, this reduces to
$$2^{2\log\_2(x)}4^{\log\_4(x)}=16$$
$$x^2\cdot x=16$$
$$x^3=16$$
$$x=\sqrt[3]{16}\approx2.7$$ | Use the definition of $\log\_a x=\ln(x)/\ln(a)$ and multiply $\log\_2 x + \log\_4 x = 2$ by $2 \ln 2$ to get $3\ln x=2$, hence $x=\exp(2/3)$. |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | If we apply 4^ to both sides, we get
$$4^{\log\_2(x)+\log\_4(x)}=16$$
$$4^{\log\_2(x)}4^{\log\_4(x)}=16$$
Since $4=2^2$, this reduces to
$$2^{2\log\_2(x)}4^{\log\_4(x)}=16$$
$$x^2\cdot x=16$$
$$x^3=16$$
$$x=\sqrt[3]{16}\approx2.7$$ | You would need to change the base of one of the $log$.
For example $\log\_4 x = \frac{\log\_2 x}{log\_2 4} = \frac{\log\_2 x}{2}$
$$
2 = \log\_2 x + \log\_4 x = \frac{3}{2} \log\_2x \implies x = 2^{4/3} = \sqrt[3]{16}
$$ |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | $$\log\_2 x +\log\_4 x = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{\log\_ x4} = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{2\log\_ x2} = 2$$
$$\frac{3}{2\log\_ x2} = 2$$
$$\frac{1}{\log\_ x2} =\frac{4}{3}$$
$$\log\_ 2x =\frac{4}{3}$$
$$x=2^{4/3}$$ | You would need to change the base of one of the $log$.
For example $\log\_4 x = \frac{\log\_2 x}{log\_2 4} = \frac{\log\_2 x}{2}$
$$
2 = \log\_2 x + \log\_4 x = \frac{3}{2} \log\_2x \implies x = 2^{4/3} = \sqrt[3]{16}
$$ |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | $$\log\_2 x +\log\_4 x = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{\log\_ x4} = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{2\log\_ x2} = 2$$
$$\frac{3}{2\log\_ x2} = 2$$
$$\frac{1}{\log\_ x2} =\frac{4}{3}$$
$$\log\_ 2x =\frac{4}{3}$$
$$x=2^{4/3}$$ | If we apply 4^ to both sides, we get
$$4^{\log\_2(x)+\log\_4(x)}=16$$
$$4^{\log\_2(x)}4^{\log\_4(x)}=16$$
Since $4=2^2$, this reduces to
$$2^{2\log\_2(x)}4^{\log\_4(x)}=16$$
$$x^2\cdot x=16$$
$$x^3=16$$
$$x=\sqrt[3]{16}\approx2.7$$ |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | we write $$\frac{\ln(x)}{\ln(2)}+\frac{\ln(x)}{2\ln(2)}=2$$ multiplying by $$2\ln(2)$$ we obtain
$$2\ln(x)+\ln(x)=4\ln(2)$$thus we get
$$\ln(x)=\frac{4}{3}\ln(2)$$ can you finish this? | Here is another way to think. First note that $4$ is a power of $2$
Let $\log\_4x=k\iff 4^k=x$
Now $4^k=x \implies (2^2)^k=x \implies 2^{2k}=x\iff\log\_2x=2k\implies \frac{1}{2}\log\_2{x}=\log\_4{x}$
We now have $$\log\_2x+\frac{1}{2}\log\_2x=2\\\frac{3}{2}\log\_2x=2\\\log\_2x^{3/2}=2\iff2^2=x^{3/2}\implies x=16^{1/... |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | $$\log\_2 x +\log\_4 x = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{\log\_ x4} = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{2\log\_ x2} = 2$$
$$\frac{3}{2\log\_ x2} = 2$$
$$\frac{1}{\log\_ x2} =\frac{4}{3}$$
$$\log\_ 2x =\frac{4}{3}$$
$$x=2^{4/3}$$ | Here is another way to think. First note that $4$ is a power of $2$
Let $\log\_4x=k\iff 4^k=x$
Now $4^k=x \implies (2^2)^k=x \implies 2^{2k}=x\iff\log\_2x=2k\implies \frac{1}{2}\log\_2{x}=\log\_4{x}$
We now have $$\log\_2x+\frac{1}{2}\log\_2x=2\\\frac{3}{2}\log\_2x=2\\\log\_2x^{3/2}=2\iff2^2=x^{3/2}\implies x=16^{1/... |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | $$\log\_2 x +\log\_4 x = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{\log\_ x4} = 2$$
$$\frac{1}{\log\_ x2} +\frac{1}{2\log\_ x2} = 2$$
$$\frac{3}{2\log\_ x2} = 2$$
$$\frac{1}{\log\_ x2} =\frac{4}{3}$$
$$\log\_ 2x =\frac{4}{3}$$
$$x=2^{4/3}$$ | Use the definition of $\log\_a x=\ln(x)/\ln(a)$ and multiply $\log\_2 x + \log\_4 x = 2$ by $2 \ln 2$ to get $3\ln x=2$, hence $x=\exp(2/3)$. |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | we write $$\frac{\ln(x)}{\ln(2)}+\frac{\ln(x)}{2\ln(2)}=2$$ multiplying by $$2\ln(2)$$ we obtain
$$2\ln(x)+\ln(x)=4\ln(2)$$thus we get
$$\ln(x)=\frac{4}{3}\ln(2)$$ can you finish this? | Use the definition of $\log\_a x=\ln(x)/\ln(a)$ and multiply $\log\_2 x + \log\_4 x = 2$ by $2 \ln 2$ to get $3\ln x=2$, hence $x=\exp(2/3)$. |
2,159,414 | There are 3 red and 7 black balls in first pot. There are 41 red and 59 black balls in second pot. And there are 481 red and 519 black balls in third pot. One of the three pots is chosen according to the random principle and after that one ball is blindly chosen. How big is the probability to get a red ball?
Solution:... | 2017/02/24 | ['https://math.stackexchange.com/questions/2159414', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/332291/'] | we write $$\frac{\ln(x)}{\ln(2)}+\frac{\ln(x)}{2\ln(2)}=2$$ multiplying by $$2\ln(2)$$ we obtain
$$2\ln(x)+\ln(x)=4\ln(2)$$thus we get
$$\ln(x)=\frac{4}{3}\ln(2)$$ can you finish this? | You would need to change the base of one of the $log$.
For example $\log\_4 x = \frac{\log\_2 x}{log\_2 4} = \frac{\log\_2 x}{2}$
$$
2 = \log\_2 x + \log\_4 x = \frac{3}{2} \log\_2x \implies x = 2^{4/3} = \sqrt[3]{16}
$$ |
33,084,866 | A bit stuck on getting hash equals to data attribute. so if url.com/#house-2 then it will trigger a click for test 2. How do you get it via jquery? <http://jsfiddle.net/ar1bd4bj/7/>
```
<ul class="list">
<li>
<a data-loc="house" href="#">test</a>
</li>
<li>
<a data-loc="house-2" href="#">test2</a>
... | 2015/10/12 | ['https://Stackoverflow.com/questions/33084866', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4939773/'] | You can use [`attribute equals`](http://api.jquery.com/attribute-equals-selector/) to select your target `a` element and trigger `.click()` like this;
```
$('.list a[data-loc="' + window.location.hash.replace('#', '') + '"]').trigger('click');
```
If your HTML contains those `data-loc` attributes, this will work. Bu... | You can use `filter()` to find the required element by the `data-loc` attribute. Try this:
```
var fragment = window.location.hash;
if (fragment) {
fragment = fragment.substr(1);
$('.list a').filter(function() {
return $(this).data('loc') == fragment;
}).click();
}
``` |
38,241,941 | I'm exploring how jhipster manipulates data. I have found `$http.get()` in `getProfileInfo` method in `ProfileService` Service whitch interacting restful `api` :
```
function getProfileInfo() {
if (!angular.isDefined(dataPromise)) {
dataPromise = $http.get('api/profile-info').then(function(... | 2016/07/07 | ['https://Stackoverflow.com/questions/38241941', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1438055/'] | We use `$resource` when requesting a RESTful endpoint, for example for an entity. `$resource` provides basic REST operations easily whereas `$http` is more specific.
For profile we only need to GET `/profile-infos` so it's useless to use `$resource` because we'll never need to call POST or DELETE on that URL. | $http will fetch you the entire page or complete set of data from a given URL whereas $resouce uses http but will help you to fetch a specific object or set of data.
$resource is fast and we use it when we need to increase the speed of our transaction.
$http is used when we are concerned with the time. |
21,440,326 | I am starting to work with classes in Python, and am learning how to create functions within classes. Does anyone have any tips on this sample class & function that I am testing out?
```
class test:
def __init__(self):
self.a = None
self.b = None
self.c = None
def prod(self):
... | 2014/01/29 | ['https://Stackoverflow.com/questions/21440326', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3250333/'] | You need to:
1. Create an instance of `test`.
2. Invoke the `prod` method of that instance.
Both of these can be accomplished by adding `()` after their names:
```
trial = test()
trial.a = 4
trial.b = 5
print trial.prod()
```
Below is a demonstration:
```
>>> class test:
... def __init__(self):
... se... | Ideally you could also pass in the values to a, b, c as parameters to your object's constructor:
```
class test:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def prod(self):
return self.a * self.b
```
Then, constructing and calling the function would look li... |
39,963,386 | I have a database with multiple dates for the same unique ID. I am trying to find the first (min) and last (max) date for each unique ID. I want the result to be:
Unique ID, first Date, last date, field1, field2,field3
```
Select max(date_Executed) as Last_Date,
(select unique_ID, MIN(date_Executed)as First_Date
... | 2016/10/10 | ['https://Stackoverflow.com/questions/39963386', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6950328/'] | why not a simple select with group by
```
Select max(date_Executed) as Last_Date, MIN(date_Executed) as First_Date
from Table_X
group by unique_ID, Field1, field2,field3
order by unique_ID,First_Permit_Date
```
You can use more then one aggregation function ina select .. (with the same group by clause) | Shouldn't it just be something like this?
I have no further insight in your tables, but the second 'select' statement seems to cause the error.
```
SELECT unique_ID, min(date_Executed) as First_Date, max(date_Executed) as Last_Date, field1, field2, field3
FROM Table_X
GROUP BY unique_ID, Field1, field2, field3
order ... |
39,764,678 | I've been battling for days now to get data to save for my nested form. I basically want to be able to store a users reason for cancelling a project, along with the last stage of the project before it was cancelled. But I just can't seem to get the actions `cancel`, `cancel_save`, and `cancel_params` to play nicely!
*... | 2016/09/29 | ['https://Stackoverflow.com/questions/39764678', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6748657/'] | You need [`concat`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html):
```
print (pd.concat([df1[['Type','Breed','Behaviour']],
df2[['Type','Breed','Behaviour']]], ignore_index=True))
Type Breed Behaviour
0 Golden Big Fun
1 Cor... | using `join` dropping columns that don't overlap
```
df1.T.join(df2.T, lsuffix='_').dropna().T.reset_index(drop=True)
```
[](https://i.stack.imgur.com/wb6AL.png) |
29,260,425 | I have a postgres database with a large number of time series metrics
Various operators are interested in different information and I want to provide an interface where they can chart the data, make comparisons and optionally export data as a csv.
The two solutions I have come across so far are, [graphite](https://gi... | 2015/03/25 | ['https://Stackoverflow.com/questions/29260425', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/527749/'] | You may want to replace Graphite's storage backend with postgresql. [Here](http://obfuscurity.com/2013/12/Migrating-Graphite-from-SQLite-to-PostgreSQL) is a good primer. | **2018 update**: Grafana now supports PostgreSQL ([link](https://grafana.com/plugins/postgres)).
---
>
> What I am looking for is an interface similar to grafana, but which allows me to hook up any backend I want
>
>
>
Thats possible with grafana . Check this [guide](http://docs.grafana.org/plugins/developing/d... |
28,342,139 | I have angularjs directive with template which consists of two tags - input and the empty list. What I want is to watch input value of the first input tag. The `$watch()` method is called once when directive is initialised but that's it. Any change of input value is silent. What do I miss?
here is my [plunk](http://pl... | 2015/02/05 | ['https://Stackoverflow.com/questions/28342139', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2232045/'] | It doesn't get called because there is never a digest triggered on the scope.
Try this instead, using ng-model:
<http://plnkr.co/edit/qMP5NDEMYjXfYsoJtneL?p=preview>
```
function link(scope, element, attrs){
scope.searchString = 'bumba';
scope.$watch('searchString', function(val){
console.log("watched", val)... | You are setting the the value you want in the watcher function.
```
function watched(){
element[0].firstChild.value = 'bumba'; //this gets called once
return element[0].firstChild.value;
}
```
is essentially the same return value as
```
function watched() {
return 'bumba';
}
```
So the watcher will a... |
57,995,932 | I want to build a JSON object from an array returned from http request
my actual array look like:
```
[{
Description: "Product"
IsInstanciable: false
IsMasked: false
Name: "ProductBase"
Subclasses: [{
Description: "Product2"
IsInstanciable: false
IsMasked: false
Name: "Produ... | 2019/09/18 | ['https://Stackoverflow.com/questions/57995932', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/874800/'] | You can use the map function together with the recursive function like this:
```
function MapObject(object) {
if(!object || object.length < 0) return [];
return object.map(obj => { return {
name: obj.Description,
children: MapObject(obj.Subclasses)
}});
}
```
Follows a full work example:
```js
va... | I would break this down into a few separate functions with clear responsibilities:
```js
const sum = (ns) =>
ns .reduce ((a, b) => a + Number (b), 0)
const getCount = (product) =>
(product .Count || 0) + sum ((product .Subclasses || []) .map (getCount))
const extract = (product) =>
({
name: product .Nam... |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | They are used mainly to obtain multiple return values from a method call. Personally, I tend to not use them. If I want multiple return values from a method then I'll create a small class to hold them.
ref and out are used when you want something back from the method in that parameter. As I recall, they both actually ... | Very simple really. You use exactly the same keyword that the parameter was originally declared with in the method. If it was declared as `out`, you have to use `out`. If it was declared as `ref`, you have to use `ref`. |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | (this is supplemental to the existing answers - a few extra considerations)
There is another scenario for using `ref` with C#, more commonly seen in things like XNA... Normally, when you pass a value-type (`struct`) around, it gets cloned. This uses stack-space and a few CPU cycles, and has the side-effect that any mo... | ref is to be avoided (I beleive there is an fx-cop rule for this also) however use ref when the object that is reference may itself changed. If you see the 'ref' keyword you know that the underlying object may no longer be referenced by the same variable after the method is called. |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | In addition to Colin's detailed answer, you could also use out parameters to return multiple values from one method call. See for example the method below which returns 3 values.
```
static void AssignSomeValues(out int first, out bool second, out string third)
{
first = 12 + 12;
second = false;
... | Try to avoid using ref. Out is okay, because you know what will happen, the old value will be gone and a new value will be in your variable even if the function failed. However, just by looking at the function you have no idea what will happen to a ref parameter. It may be the same, modified, or an entirely new object.... |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | (this is supplemental to the existing answers - a few extra considerations)
There is another scenario for using `ref` with C#, more commonly seen in things like XNA... Normally, when you pass a value-type (`struct`) around, it gets cloned. This uses stack-space and a few CPU cycles, and has the side-effect that any mo... | Very simple really. You use exactly the same keyword that the parameter was originally declared with in the method. If it was declared as `out`, you have to use `out`. If it was declared as `ref`, you have to use `ref`. |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | (this is supplemental to the existing answers - a few extra considerations)
There is another scenario for using `ref` with C#, more commonly seen in things like XNA... Normally, when you pass a value-type (`struct`) around, it gets cloned. This uses stack-space and a few CPU cycles, and has the side-effect that any mo... | Try to avoid using ref. Out is okay, because you know what will happen, the old value will be gone and a new value will be in your variable even if the function failed. However, just by looking at the function you have no idea what will happen to a ref parameter. It may be the same, modified, or an entirely new object.... |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | They are used mainly to obtain multiple return values from a method call. Personally, I tend to not use them. If I want multiple return values from a method then I'll create a small class to hold them.
ref and out are used when you want something back from the method in that parameter. As I recall, they both actually ... | Try to avoid using ref. Out is okay, because you know what will happen, the old value will be gone and a new value will be in your variable even if the function failed. However, just by looking at the function you have no idea what will happen to a ref parameter. It may be the same, modified, or an entirely new object.... |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | (this is supplemental to the existing answers - a few extra considerations)
There is another scenario for using `ref` with C#, more commonly seen in things like XNA... Normally, when you pass a value-type (`struct`) around, it gets cloned. This uses stack-space and a few CPU cycles, and has the side-effect that any mo... | In addition to Colin's detailed answer, you could also use out parameters to return multiple values from one method call. See for example the method below which returns 3 values.
```
static void AssignSomeValues(out int first, out bool second, out string third)
{
first = 12 + 12;
second = false;
... |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | In general, you should avoid using ref and out, if possible.
That being said, use ref when the method *might need* to modify the value. Use out when the method *always should* assign something to the value.
The difference between ref and out, is that when using out, the compiler enforces the rule, that you need to a... | ref is to be avoided (I beleive there is an fx-cop rule for this also) however use ref when the object that is reference may itself changed. If you see the 'ref' keyword you know that the underlying object may no longer be referenced by the same variable after the method is called. |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | In general, you should avoid using ref and out, if possible.
That being said, use ref when the method *might need* to modify the value. Use out when the method *always should* assign something to the value.
The difference between ref and out, is that when using out, the compiler enforces the rule, that you need to a... | Try to avoid using ref. Out is okay, because you know what will happen, the old value will be gone and a new value will be in your variable even if the function failed. However, just by looking at the function you have no idea what will happen to a ref parameter. It may be the same, modified, or an entirely new object.... |
1,115,762 | In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them? | 2009/07/12 | ['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/'] | In addition to Colin's detailed answer, you could also use out parameters to return multiple values from one method call. See for example the method below which returns 3 values.
```
static void AssignSomeValues(out int first, out bool second, out string third)
{
first = 12 + 12;
second = false;
... | ref is to be avoided (I beleive there is an fx-cop rule for this also) however use ref when the object that is reference may itself changed. If you see the 'ref' keyword you know that the underlying object may no longer be referenced by the same variable after the method is called. |
32,283 | I want to compute the total scene bounding box, so I can fit the scene in rendered image automatically. I have found `bound_box`. But why are there so many values
```
<bpy_float[3], Object.bound_box>
<bpy_float[3], Object.bound_box>
<bpy_float[3], Object.bound_box>
<bpy_float[3], Object.bound_box>
<bpy_float[3], Objec... | 2015/06/11 | ['https://blender.stackexchange.com/questions/32283', 'https://blender.stackexchange.com', 'https://blender.stackexchange.com/users/3258/'] | You will get 8 values only,
```
>>> obj = bpy.context.active_object
>>> obj.bound_box
bpy.data.objects['Cube'].bound_box
>>> [v[:] for v in obj.bound_box]
[(-1.0, -1.0, -1.0),
(-1.0, -1.0, 1.0),
(-1.0, 1.0, 1.0),
(-1.0, 1.0, -1.0),
(1.0, -1.0, -1.0),
(1.0, -1.0, 1.0),
(1.0, 1.0, 1.0),
(1.0, 1.0, -1.0)]
```
... | Each object that has a `bound_box` property will return *8* values that represent the bounding information. The 8 values describe the corners of the bounding box itself.
If you have 16 values I presume that is because you have 2 objects in the scene (though it isn't clear from your question what you might have typed ... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | It's not a *logical truth* that an apple is not an orange, but it's nevertheless *analytic* with respect to the meaning postulate: if predicate P holds uniformly of object a, then for all predicates Q contrary to P, ¬Q(a). For example, if something is uniformly black, then it's not of any color that is contrary to blac... | As has been pointed out already, if you are using logic to talk about apples and oranges you have already provided some model (say, *a* is an apple and *o* is an orange - formally speaking you've set up a function from constants in your logical language to objects or types or fruit or whatever). So I'm reasonably comfo... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | In mathematics, an equals sign connects subject and predicate.
The statement, apple=orange, is the same as the statement, an apple is an orange.
In order to determine an apple is an apple, you used the principle of identity. That which is the same is the same.
In order to determine an apple is not an orange, we use ... | As has been pointed out already, if you are using logic to talk about apples and oranges you have already provided some model (say, *a* is an apple and *o* is an orange - formally speaking you've set up a function from constants in your logical language to objects or types or fruit or whatever). So I'm reasonably comfo... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | In mathematics, an equals sign connects subject and predicate.
The statement, apple=orange, is the same as the statement, an apple is an orange.
In order to determine an apple is an apple, you used the principle of identity. That which is the same is the same.
In order to determine an apple is not an orange, we use ... | the logic used here is mathematical logic . but a mathematical logic is only accepted if there is no way to disprove the given logic i.e to say 2+3 =5 and 3+2 also=5 assures the logic that counting 5 pieces from left or right will always remain same because we cant find any two no's which dont obey this logic .
so if w... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | What are these "apple" and "orange" that you speak of? In fact, none of the **terms** used in predicate logic have any meaning. The terms need to be **interpreted** according to a **model** or a domain of discourse. See [this SEP entry on Classical Logic](http://plato.stanford.edu/entries/logic-classical/), especially ... | Use *types*:
So that x:Apple, y:Orange
This means that x is an apple, y is an orange.
Then we cannot even compare oranges to apples - they're not of the same type; showing that they *must* be different.
If one had an additional type Fruit from which these descend, then the types Orange and Apple would be comparabl... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | What are these "apple" and "orange" that you speak of? In fact, none of the **terms** used in predicate logic have any meaning. The terms need to be **interpreted** according to a **model** or a domain of discourse. See [this SEP entry on Classical Logic](http://plato.stanford.edu/entries/logic-classical/), especially ... | It depends on your definition of "apple" and "orange".
Is a human an ape? Most people would say "no", because their definition of 'ape' implicitly excludes humans. (They mostly involve animals hairier than most humans, and less verbose.) But [humans are apes](http://en.wikipedia.org/wiki/Homo) in the sense understood ... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | It's not a *logical truth* that an apple is not an orange, but it's nevertheless *analytic* with respect to the meaning postulate: if predicate P holds uniformly of object a, then for all predicates Q contrary to P, ¬Q(a). For example, if something is uniformly black, then it's not of any color that is contrary to blac... | It depends on your definition of "apple" and "orange".
Is a human an ape? Most people would say "no", because their definition of 'ape' implicitly excludes humans. (They mostly involve animals hairier than most humans, and less verbose.) But [humans are apes](http://en.wikipedia.org/wiki/Homo) in the sense understood ... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | It depends on your definition of "apple" and "orange".
Is a human an ape? Most people would say "no", because their definition of 'ape' implicitly excludes humans. (They mostly involve animals hairier than most humans, and less verbose.) But [humans are apes](http://en.wikipedia.org/wiki/Homo) in the sense understood ... | Use *types*:
So that x:Apple, y:Orange
This means that x is an apple, y is an orange.
Then we cannot even compare oranges to apples - they're not of the same type; showing that they *must* be different.
If one had an additional type Fruit from which these descend, then the types Orange and Apple would be comparabl... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | It's not a *logical truth* that an apple is not an orange, but it's nevertheless *analytic* with respect to the meaning postulate: if predicate P holds uniformly of object a, then for all predicates Q contrary to P, ¬Q(a). For example, if something is uniformly black, then it's not of any color that is contrary to blac... | the logic used here is mathematical logic . but a mathematical logic is only accepted if there is no way to disprove the given logic i.e to say 2+3 =5 and 3+2 also=5 assures the logic that counting 5 pieces from left or right will always remain same because we cant find any two no's which dont obey this logic .
so if w... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | What are these "apple" and "orange" that you speak of? In fact, none of the **terms** used in predicate logic have any meaning. The terms need to be **interpreted** according to a **model** or a domain of discourse. See [this SEP entry on Classical Logic](http://plato.stanford.edu/entries/logic-classical/), especially ... | As has been pointed out already, if you are using logic to talk about apples and oranges you have already provided some model (say, *a* is an apple and *o* is an orange - formally speaking you've set up a function from constants in your logical language to objects or types or fruit or whatever). So I'm reasonably comfo... |
8,459 | It is easy to prove that an apple is an apple: The equation x=x is a tautology, for all x. So if x=apple, we can substitute it in the equation x=x and get apple=apple, so an apple is an apple.
But how can one prove (using standard deductive logic) that an apple is not an orange, since x!=y is not a tautology for all x... | 2013/10/23 | ['https://philosophy.stackexchange.com/questions/8459', 'https://philosophy.stackexchange.com', 'https://philosophy.stackexchange.com/users/4639/'] | In mathematics, an equals sign connects subject and predicate.
The statement, apple=orange, is the same as the statement, an apple is an orange.
In order to determine an apple is an apple, you used the principle of identity. That which is the same is the same.
In order to determine an apple is not an orange, we use ... | Use *types*:
So that x:Apple, y:Orange
This means that x is an apple, y is an orange.
Then we cannot even compare oranges to apples - they're not of the same type; showing that they *must* be different.
If one had an additional type Fruit from which these descend, then the types Orange and Apple would be comparabl... |
36,437,655 | I have been trying to create a product using Rest API for Magento Version 2.0.
I am using Postman to test the rest api.
URL : <http://13.91>.***.***/rest/V1/products
I have added the following headers to the request.
Authorization : Bearer \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Content-Type : application/json... | 2016/04/05 | ['https://Stackoverflow.com/questions/36437655', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2556858/'] | I have found the answer to my question. The json structure need to be in this format:
```
{
"product":{
"id": 12345,
"sku": "10090-White-XL",
"name": "10090-White-XL",
"attribute_set_id": 9,
"price": 119,
"status": 1,
"visibility": 1,
"type_id": "virtual",
"cre... | Simple product with custom attributes (ex: remarks).
Just take note of the media\_gallery\_entries. Make sure to supply a valid base64\_encoded\_data image content and mime type.
URL: <http://domain/index.php/rest/V1/products>
METHOD: POST
HEADER:
application/json
Authorization: Bearer
POST DATA / RAW PAYLOAD:... |
3,144,190 | I know that if $ G\_1, G\_2 $ are cyclic groups then $ G\_1 \times G\_2 $ is cyclic if and only if $ |G\_1| $ and $ |G\_2| $ are coprimes. But I have to reponds a similar question in the context of category theory:
show that $ \mathbb{Z}\_n $, $ \mathbb{Z}\_m $ have a product in the category of cyclic groups if and o... | 2019/03/11 | ['https://math.stackexchange.com/questions/3144190', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/114670/'] | This should also follow from a naive count of the number of homomorphisms between cyclic groups: specifically, $$\lvert \operatorname{Hom}(\mathbb{Z}\_a, \mathbb{Z}\_b) \rvert = \gcd(a,b).$$
Suppose $\mathbb{Z}\_p$ is the product of $\mathbb{Z}\_m$ and $\mathbb{Z}\_n$ in the category of cyclic groups. Then it satisfie... | I think you can use the fact that every finite abelian group can be written as $(\mathbb{Z}\_{n\_1})^{\oplus m\_1}\oplus\cdots\oplus (\mathbb{Z}\_{n\_i})^{\oplus m\_i}$. So suppose now that $A$ is a categorical product of $\mathbb{Z}\_n$ and $\mathbb{Z}\_m$ in the category of cyclic groups, and let us show that it is a... |
46,349,085 | Trying to get the correct gradient colors to show based on php-time. When I try it, the gradients mismatch (I.E. topcolor from first hour-chunk and bottomcolor from fourth-hour chunk match together).
```
<?php
$time = date("H");
if( $time >= 06 && $time < 12 )
$topcolor = 'black';
$bottomcolor = 'orange';
if( $time ... | 2017/09/21 | ['https://Stackoverflow.com/questions/46349085', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8303473/'] | You need to wrap the statements after each `if` condition in braces:
```
if( $time >= 06 && $time < 12 )
$topcolor = 'black';
$bottomcolor = 'orange';
```
->
```
if( $time >= 06 && $time < 12 ) {
$topcolor = 'black';
$bottomcolor = 'orange';
}
```
If you omit these, then only the first statement will be evalu... | As you can learn from the [documentation](http://php.net/manual/en/control-structures.if.php) an `if` statement looks like:
```
if (expression)
statement
```
And about [statements](http://php.net/manual/en/control-structures.intro.php):
>
> A statement can be an assignment, a function call, a loop, a conditio... |
51,422,311 | I have a problem with the layout on the Android Studio. The Editor (XML file) and Emulator (Nexus 10) shows the layout right. But if I run the app on my Huawei Mediaped M5, the layout changes and everything is mixed.
The Emulator and my device have the same Resolution(2560\*1600).
$/,
loader: 'url-loader?limit=100000'
}
```
After that I was getting error that my path is not working. That is cause my font url paths weren't relative to my root scss ... | Move your file-loader options to `rules` collection instead of `loaders`, it was deprecated and seems to have been overwritten by `rules` collection. |
11,859,456 | To work with Solr, I need my searchbox to be suggesting whenever user type.. with a dropdown menu. How can i get it done? Any existing example? | 2012/08/08 | ['https://Stackoverflow.com/questions/11859456', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/775856/'] | [Here](http://blog.trifork.com/2012/02/15/different-ways-to-make-auto-suggestions-with-solr/) is an article I wrote about different ways to make auto suggestions and how to make the right choice. If you want something even more advanced and flexible there is [this other article](http://www.cominvent.com/2012/01/25/supe... | Have a look at the Suggester component - <http://wiki.apache.org/solr/Suggester/> |
11,859,456 | To work with Solr, I need my searchbox to be suggesting whenever user type.. with a dropdown menu. How can i get it done? Any existing example? | 2012/08/08 | ['https://Stackoverflow.com/questions/11859456', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/775856/'] | Have a look at the Suggester component - <http://wiki.apache.org/solr/Suggester/> | There are multiple ways of providing autosuggest capabilities.
*Single term suggestion*
This method looks for the first letter, then the first word in a phrase, a search for “men’s shirts” must begin with “m,” then “men’s,” to bring up “men’s shirts” as a response.
This could be done by using following field type an... |
11,859,456 | To work with Solr, I need my searchbox to be suggesting whenever user type.. with a dropdown menu. How can i get it done? Any existing example? | 2012/08/08 | ['https://Stackoverflow.com/questions/11859456', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/775856/'] | [Here](http://blog.trifork.com/2012/02/15/different-ways-to-make-auto-suggestions-with-solr/) is an article I wrote about different ways to make auto suggestions and how to make the right choice. If you want something even more advanced and flexible there is [this other article](http://www.cominvent.com/2012/01/25/supe... | There are multiple ways of providing autosuggest capabilities.
*Single term suggestion*
This method looks for the first letter, then the first word in a phrase, a search for “men’s shirts” must begin with “m,” then “men’s,” to bring up “men’s shirts” as a response.
This could be done by using following field type an... |
67,541,800 | I want to know what might be the possible advantages of passing by value over passing by const reference for primitive types like int, char, float, double, etc. to function? Is there any performance benefit for passing by value?
Example:
```
int sum(const int x,const int y);
```
or
```
int sum(const int& x,const in... | 2021/05/14 | ['https://Stackoverflow.com/questions/67541800', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7908900/'] | In every ABI I know of, references are passed via something equivalent to pointers. So when the compiler cannot inline the function or otherwise must follow the ABI, it will pass pointers there.
Pointers are often larger than values; but more importantly, pointers do not point at registers, and while the top of the st... | Typically, primitive types are not passed by reference, but sometimes there is a point in that. E.g, on x64 machine `long double` is 16 bytes long and pointer is 8 bytes long. So it will be a little bit better to use a reference in this case.
In your example, there is no point in that: usual `int` is 4 bytes long, so ... |
24,854,623 | Grandfather process should go through numbers from 3 to N-1. Send each number through pipe(filedes) to Father.
Father should check the content of the pipe and compute something for each number in there. If the result is positive, create children to further compute it. Children should write their results into pipe(filed... | 2014/07/20 | ['https://Stackoverflow.com/questions/24854623', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2636820/'] | Just try with:
```
list($month, $day, $year) = explode('/', $birthdate);
``` | list($month, $day, $year) = explode('/', $birthdate); |
24,854,623 | Grandfather process should go through numbers from 3 to N-1. Send each number through pipe(filedes) to Father.
Father should check the content of the pipe and compute something for each number in there. If the result is positive, create children to further compute it. Children should write their results into pipe(filed... | 2014/07/20 | ['https://Stackoverflow.com/questions/24854623', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2636820/'] | Just try with:
```
list($month, $day, $year) = explode('/', $birthdate);
``` | If your format is fixed and you don't need to validate the date, you can directly use `substr`:
```
echo substr($birthdate,0,2); // month
echo substr($birthdate,3,2); // day
echo substr($birthdate,6,4); // year
``` |
24,854,623 | Grandfather process should go through numbers from 3 to N-1. Send each number through pipe(filedes) to Father.
Father should check the content of the pipe and compute something for each number in there. If the result is positive, create children to further compute it. Children should write their results into pipe(filed... | 2014/07/20 | ['https://Stackoverflow.com/questions/24854623', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2636820/'] | list($month, $day, $year) = explode('/', $birthdate); | If your format is fixed and you don't need to validate the date, you can directly use `substr`:
```
echo substr($birthdate,0,2); // month
echo substr($birthdate,3,2); // day
echo substr($birthdate,6,4); // year
``` |
1,936,525 | **Updated Question Further Down**
I've been experimenting with expression trees in .NET 4 to generate code at runtime and I've been trying to implement the `foreach` statement by building an expression tree.
In the end, the expression should be able to generate a delegate that does this:
```
Action<IEnumerable<int>... | 2009/12/20 | ['https://Stackoverflow.com/questions/1936525', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61632/'] | You problem is that you didn't pass parameters and variables to your block expression. You use them in the "inner" expressions, but the block expression knows nothing about them. Basically, all you need to do is to pass all your parameters and variables to a block expression.
```
var @foreach = Expression.Bloc... | Sorry if this is thread necromancy, but in case other people are running into the same or similar problem:
You can try to write an ExpressionVisitor that replaces a parameter with the same name and type in the external body expression with the variable parameter you have declared when creating the block expression. Th... |
1,936,525 | **Updated Question Further Down**
I've been experimenting with expression trees in .NET 4 to generate code at runtime and I've been trying to implement the `foreach` statement by building an expression tree.
In the end, the expression should be able to generate a delegate that does this:
```
Action<IEnumerable<int>... | 2009/12/20 | ['https://Stackoverflow.com/questions/1936525', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61632/'] | You problem is that you didn't pass parameters and variables to your block expression. You use them in the "inner" expressions, but the block expression knows nothing about them. Basically, all you need to do is to pass all your parameters and variables to a block expression.
```
var @foreach = Expression.Bloc... | Don't forget to dispose IEnumerator in try/finally - lots of code (such as File.ReadLines()) depends on that. |
1,936,525 | **Updated Question Further Down**
I've been experimenting with expression trees in .NET 4 to generate code at runtime and I've been trying to implement the `foreach` statement by building an expression tree.
In the end, the expression should be able to generate a delegate that does this:
```
Action<IEnumerable<int>... | 2009/12/20 | ['https://Stackoverflow.com/questions/1936525', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61632/'] | Don't forget to dispose IEnumerator in try/finally - lots of code (such as File.ReadLines()) depends on that. | Sorry if this is thread necromancy, but in case other people are running into the same or similar problem:
You can try to write an ExpressionVisitor that replaces a parameter with the same name and type in the external body expression with the variable parameter you have declared when creating the block expression. Th... |
29,570,594 | I'm stumped why the mousewheel will not increment/decrement the value in a simple form element.
```html
<input type="number" step="0.125" min="0" max="0.875">
```
It works on this snippet just fine, but not when I create a simple generic html document:
```
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action... | 2015/04/10 | ['https://Stackoverflow.com/questions/29570594', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/901449/'] | Snippet runs in an IFRAME. Put your code into IFRAME and it will work too. Why - I don't know but it works.
i.e.
<http://codecorner.galanter.net/bla2.htm> - doesn't work (code by itself)
<http://codecorner.galanter.net/bla.htm> - works - previous page in an IFRAME
EDIT: Here's a demo of it working in Chrome 41: <htt... | So I think I figured it out.
First I copied your code into a html document and opened it in Chrome, and the increment didn't work.
Second I removed everything from the code except the input box, still didn't work.
Then I injected that code into random websites using the chrome inspector, I tried it on gmail, reddit a... |
29,570,594 | I'm stumped why the mousewheel will not increment/decrement the value in a simple form element.
```html
<input type="number" step="0.125" min="0" max="0.875">
```
It works on this snippet just fine, but not when I create a simple generic html document:
```
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action... | 2015/04/10 | ['https://Stackoverflow.com/questions/29570594', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/901449/'] | To avoid the browser issue altogether, you might try using the [jQuery mousewheel](https://github.com/jquery/jquery-mousewheel) plugin to manually change your input value. For example:
**index.html**
```
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"... | So I think I figured it out.
First I copied your code into a html document and opened it in Chrome, and the increment didn't work.
Second I removed everything from the code except the input box, still didn't work.
Then I injected that code into random websites using the chrome inspector, I tried it on gmail, reddit a... |
13,383,647 | I have Google Translate on my page. It looks like a drop-down list, but all other drop-down lists on my page have another style. So I created jQuery function which change Google Translator drop down list styles. This function adds or deletes some style parameters. I'd like to know when I should call this function? In c... | 2012/11/14 | ['https://Stackoverflow.com/questions/13383647', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1753077/'] | I recently wanted to change "Select Language" to simply "Language", so I also had to run code after Google's code had been executed. Here's how I did it:
**HTML**
It's important to set Google's `div` to `display:none` -- we'll fade it in with JavaScript so that the user doesn't see the text switching from "Select La... | You can do it with pure JavaScript. It says in the W3 docs for the [`onLoad` attribute](http://www.w3schools.com/jsref/event_onload.asp) that you can add an attribute in a HTML element which takes as a parameter, the JavaScript code to be executed when the element has loaded.
Problem is, the attribute is only supporte... |
13,383,647 | I have Google Translate on my page. It looks like a drop-down list, but all other drop-down lists on my page have another style. So I created jQuery function which change Google Translator drop down list styles. This function adds or deletes some style parameters. I'd like to know when I should call this function? In c... | 2012/11/14 | ['https://Stackoverflow.com/questions/13383647', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1753077/'] | I had a similar situation where i had to change "Select Language" to just display "Language". Here is my CSS solution:
```
div#google_translate_element{
display: inline-block;
vertical-align: top!important;
}
div#google_translate_element *{
margin: 0px;
padding: 0px;
border: none!important;
display: inlin... | You can do it with pure JavaScript. It says in the W3 docs for the [`onLoad` attribute](http://www.w3schools.com/jsref/event_onload.asp) that you can add an attribute in a HTML element which takes as a parameter, the JavaScript code to be executed when the element has loaded.
Problem is, the attribute is only supporte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.