directshow disable activemovie window in C++ console application

Question: I am creating a video frame output program in a c++ console application using direct show. I have the video loading in and playing fine, however, the video pops up in an ActiveMovie Window. Is there any way I can possibly disable this that way I can just output frame information to the command line window? Thanks in advance.
Answer: What kind of frame information do you want to output to the console? To not have the ActiveMovie video popup, you could just use the null renderer filter.
Comment: I am trying to play a video in the background and display frame information as it process through it. I don't need it to display the video; just the information about it.


The use of simple roots, Dynkin diagrams and Cartan matrices?

Question: This is a bit of an odd question perhaps but I found myself asking the "why" question when studying "Lie Algebras in particle physics" by Howard Georgi concerning the previously mentioned objects.
Why do we introduce and study simple roots, Dynkin diagrams and Cartan matrices? What I gather from the book is that they offer a way of "compressing" the "information" of a Lie Algebra immensely in the sense that all the properties of a Lie Algebra can be encoded within Dynkin diagrams/simple roots and then the entire root system and the commutation relations of the algebra can then be reconstructed using the Cartan matrix and other tools.
But of what use is all that?
It's not like one couldn't just draw the whole root systems or give the commutation relations of the Lie Algebra when one wants to communicate the structure of an algebra, right?
Comment: I do not quite understand your last line / question, which really might be a language issue (double negation and all). Could you clarify, please?
Comment: Earlier in my career, when I used to think of a compact semisimple Lie group, I used to think mostly about their definitions which are geometric/algebraic (and I used to think mostly of the $4$ infinite families). Historically, root systems allowed mathematicians to classifiy complex semisimple Lie algebras (I think this was mostly done by Killing and E. Cartan, though it was later simplified by Dynkin and others). However, even when dealing with representation theory, it also helps to think in terms of Dynkin diagrams and thus root systems.
Answer: The crucial point is that we consider a finite-dimensional complex simple or semisimple Lie algebra. Then a classification is based on "compressing the information" via root systems, Cartan matrices and Dynkin diagrams.
This is the famous classification by Cartan (and Killing).
Related post: Motivation for Killing Form and Root Diagrams


Shared stuff across whole application in Android

Question: I'm not asking about repairing my code or something I've just have a problem on where to or how to put methods in proper places in my application.
I wrote an application enhancing bluetooth chat - I made service for this bluetooth chat that runs in background. I will have more such services. Basically I want to be able to run methods  across whole my application:

send message via bluetooth chat and wait for answer,
scan RFID tag with NFC,
scan Barcode with camera,

etc.
Each of this I know how to do in 1 activity easily. Now I'm looking for a solution to put this in something like a global class that will allow me to call this methods across my whole application - so I don't have to initialize anything but just - doSomething() and it does it.
Where should I put such things:

in custom activity class (all my other activities will use it)?
in application?
something else?

The same applies to handlers. Basically as to bluetooth chat you have to make handler to listen to received messages - where to put it as well.
I'm basically looking for propositions on how to solve this.
Comment: I'm not an android programmer but assuming it's the same as core java you can create static methods to do all this and then (if you really must) do a [static import](http://www.javapractices.com/topic/TopicAction.do?Id=195) so you don't need to do Class.doSomething(); but thats rarely wise and you shouldn't do it excessively
Answer: You can have one BaseActivity that extends activity and put your common functions in BaseActivity, now extend all other activities with BaseActivity.
Your activity will have these functions available.
For example:
class BaseActivity extends activity{
...........

public void sendMsgViaBluetooth(String msg){
...........
}

}

class MyActivity extends BaseActivity{

<OnSomeEvent>{

sendMsgViaBluetooth(msg);
}

}

Answer: I would create a class with some static methods that allows you to obtain instances of certain classes handling different functionality. You can create a listener system where multiple activities can register themselves for events, such as received messages. When the main class then receives something, it will go through all listeners, and inform them.
Otherwise, you can also send broadcasts, and let those activities interested listen for them. A problem here though is that no one is listening, messages might be lost. When you handle it yourself, in case no one is listening you can store messages in a queue, and send them when new listeners register.
I would not go with the BaseActivity idea. The bigger your app gets, the harder this becomes (e.g., what if you want a Fragment to do things as well, a service that should obtain something, or when you want to implement other classes that require to extend anything else than Activity).
Answer: To have data/methods that "follows" you all over the scope of your application, create a Class that extends Application. You have to specify in your Manifest that this Class will be your Application class.
android:name="com.example.MyApplicationClass">

After that, you can call getApplication() to get the Application context and cast it to your Class
myAppContext = (MyApplicationClass)getApplication();

Try avoiding Singleton pattern. I've done one in an application and when the app became big enough, my singleton would get erased sometimes (when resuming the application after coming back from launcher). The application context is supposed to keep the data even if the application is in background for a long time.


How to implement GLM computationally in C++ (or other languages)?

Question: I want to implement the GLM model in C++ for a commercial package (ie. this is not for fun), including but not limited to normal, binomial distribution etc. I'm not so sure how the implementation should work. Say, I want to implement the linear and logistic models in a GLM framework.
I can simply implement the linear model by solving the following matrix equation for the OLS coefficients:

But I will need to iteratively estimate the MLE coefficients for a logistic model.
To me, the implementation will be something like:
if (normal in the exponential family)
{
   solve the matrix equation listed above
}
else if (logistic in the exponential family)
{
   iteratively solve the logistic MLE coefficients
}
else if (poisson in the ....)
{
   iteratively solve the poisson MLE coefficients
}
else (.....)
{
   other error distributions...
}

The GLM gives us a mathematical way of generalising the distribution models but it does not help computationally. This is like gluing distant families of different models into one model.
How does a statistical software implement a GLM model? Is there any open-source statistical library (not necessarily in C++) that shows how this can be done? Any resources (articles, papers, books) that shows how the GLM model is written?
What does the GLM model gives us how the families can be generalised computationally? Are we supposed to write an implementation for each family indepedently?
Comment: Beware: $(X'X)^{-1}X'Y$ is the default text-book formula for computing linear regression coefficients, but it is not a good formula for computers. Nowadays people use things like QR decomposition or singular value decomposition, as these are more numerically stable. In short this is a huge project you are on, and there are many many different things that can go horribly wrong, so please reconsider whether you really should do this.
Answer: While there is definitely some educational value of re-implementing GLM framework (or any other statistical framework, for that matter), I question the feasibility of this approach due to complexity and, consequently, time and efforts involved. Having said that, if you indeed want to go this route and review existing open source GLM implementations, you have, at least, the following options:

Standard GLM implementation by R package stats. See the corresponding source code here on GitHub or by typing the function name (without parentheses) in R's command line.
Alternative and specific GLM implementations for R include the following packages: glm2, glmnet and some others. Additionally, GLM-releated R packages are listed in this blog post.
Excellent GLM Notes webpage (by Michael Kane and Bryan W. Lewis) offers a wealth of interesting and useful details on standard and alternative R GLM implementations aspects.
For Julia GLM implementations, check similar to R's GLM and GLMNet packages.
For Python GLM implementations, check the one in statsmodels library and the one in scikit-learn library (implements Ridge, OLS and Lasso - find corresponding modules).
For .NET GLM implementations, check IMHO very interesting Accord.NET framework - the GLM source code is here on GitHub.
For C/C++ GLM implementations, check apophenia C library (this source code seems to be relevant) and, perhaps, C++ GNU Scientific Library (GSL) (see this GitHub repo, but I was unable to find the relevant source code). Also of interest could be: this C++ IRLS GLM implementation (which uses GSL) as well as the Bayesian Object Oriented Modeling (BOOM) C++ library (GLM-focused source code is here on GitHub).


What do I do about inclusion probabilities >1 in PPS sampling?

Question: I'm using a probability proportional to size method to draw a sample of clustered units. The distribution of the size variable is positively skewed, giving the largest units an inclusion probability greater than 1 (which doesn't make sense as a probability).
I'm using the UPtille function from the sampling package to sample units. The function should return a 0 or a 1 to indicate inclusion in the sample. Using my inclusion probabilities - where a few are > 1 - I get a vector with other numbers too.
What do I do about these inclusion probabilities that are greater than 1, and what is the implication of having units that are basically automatically included in the sample because of how big they are?
Answer: The usual approach in this situation is to set inclusion probabilities to $1$ when $\pi_i\geq 1$ and to repeat the computation for the remaining units. You do this iteratively until there are no more inclusion probabilities greater than $1$.
inclusionprobabilities function in the sampling package does this for you.
Units with $\pi_i=1$ are called self-selecting units, and the implication is that they will be always present in your sample, and will not contribute to variance.
Be careful if self-selecting units are too many.
Comment: Thanks for pointing me towards `inclusionprobabilities` - but if calculating by hand, you would calculate the inclusion probabilities for all other units as if the large units (with p > 1) weren't there, and then assign them with probability of 1? Can you please expand on 'will not contribute to variance' with respect to self-selecting units?
Comment: Yes, if any $\pi_i \geq 1$, you set them to $1$, then ignore them and repeat computations (at this step you multiply by $n-k$, where $k$ is the number of self-selecting units).
If $\pi_i = 1$, then unit $i$ will be always in your sample, no matter how many samples you draw, so unit $i$ is not a source of variability for the HT estimator. To see this numerically, you may try to put $\pi_i = 1 $ in the Horvitz-Thompson variance (in this case $\pi_{ij}=\pi_j$ ), you'll see that for any couple $(i, j)$ the contribution to variance is $0$.


Parametric Surfaces Appearing completely different in graphing software than in original paper

Question: I tried to plot the parametric surfaces from this paper to try to play around with the variables and potentially adapt it for other purposes. However I attempted to plot the surfaces in both Geogebra and Math3D with the parameters from the original paper, to minimal success. I have made sure to convert the appropriate values to radians, however the shapes are still completely wrong. I am not sure if I am misinterpreting the values or if there is a mistake in the equations and functions.
Geogebra: https://www.geogebra.org/calculator/t9smcgaq
Math3D: https://www.math3d.org/LqpWldNxh
The parameters I used are the ones for the nautilus.
The parametric equation in question is:
$$
\begin{cases}
x = \bigl( A\sin(\beta)
+ g(s)\cos(s+\phi)\cos(\theta+\Omega)
- g(s)\sin(\mu)\sin(s+\phi)\sin(\theta) \bigr) \, e^{\theta\cot(\alpha)} \\[2pt]
y = \bigl( -A\sin(\beta)
- g(s)\cos(s+\phi)\sin(\theta+\Omega)
- g(s)\sin(\mu)\sin(s+\phi)\cos(\theta) \bigr) \,
e^{\theta\cot(\alpha)} \\[2pt]
z = \bigl( -A\cos(\beta)
+ g(s)\sin(s+\phi)\cos(\mu) \bigr) \, e^{\theta\cot(\alpha)}
\end{cases}
$$
for
$\theta\in (\theta_{\mathrm{start}},\theta_{\mathrm{end}})$ and $s\in (s_{\min},s_{\max})$
and
$$
g(s) = \bigl( a^{-2}\cos^2(s) + b^{-2}\sin^2(s) \bigr)^{-1/2}
$$
The meanings of the variables are lined out in the paper.
Comment: I played with the parameter ranges, and the $-\infty$ starting point for $\theta$ seems to be an issue. Geogebra doesn't draw anything when given $-\infty$ as lower bound, but any other number doesn't draw the correct shape.
Comment: The issue was that, and you (and I until now) missed the erratum. You should add a $\cos(\theta)$ factor to the $A\sin(\beta)$ term in equation (9) (the parametric equation for x) and a $\sin(\theta)$ factor to the $A\sin(\beta)$ term in equation (10) (the parametric equation for y). https://www.math3d.org/Xt6fThSap
Answer: The issue you had was that the paper has an error in equations (9) and (10). The errata states that you need to add a $\cos(\theta)$ after the $A\cos(\beta)$ in (9) and a $\sin(\theta)$ after the $A\cos(\beta)$ in (10).
Your parametric equations then become:
$$
\begin{eqnarray}
\begin{cases}
x&=&\big(A\sin(\beta)\cos(\theta)+g(s)cos(s+\phi)cos(\theta+\Omega)-g(s)sin(\mu)sin(s+\phi)sin(\theta)\big)e^{\theta\cot(\alpha)}\\
y&=&\big(-A\sin(\beta)\sin(\theta)+g(s)cos(s+\phi)sin(\theta+\Omega)-g(s)sin(\mu)sin(s+\phi)cos(\theta)\big)e^{\theta\cot(\alpha)}\\
z&=&\big(-A\cos(\beta)+g(s)\sin(s+\phi)\cos(\mu)\big)e^{\theta\cot(\alpha)}
\end{cases}
\end{eqnarray}
$$
I did that and changed your constants to exactly the constants in Table 1 for nautilus. I had to play around with $\theta_{start}$, since $-\infty$ does not work on the math3d or geogebra plotter.
This is what I finally came up with: https://www.math3d.org/maV8BHWE2. Not too bad.
Comment: Thanks! I feel really dumb for not noticing that, I should have been more observant!


How to derive the upper bound for the expected number and maximal number of marked vertices in a graph?

Question: Assume we have a graph $G = (V, E)$ with minimal degree $m$. We mark with a probability (independent from the other vertices) of $p$  each vertex. After that we mark each vertex $v$ iff the vertex $v$ and their neighbors are not marked.
So there is a upper bound for the expected value for the number of marked vertices given: $$|V|\left(p + e^{−p(m+1)}\right)$$
And there is also a formula given for the maximal number of marked vertices: $$|V| \frac{1+\ln(m+1)}{m+1}$$
I don't understand how to derive these.
Comment: I do not understand the given formula for the maximal number of marked vertices. At the first stage of the marking with non-zero probability no vertices will be marked. Then at the second stage all of them (that is $|V|$) should be marked, which is bigger than  the proposed upper bound.
Comment: @JochemKuijpers You're right. Sorry was a typo.  Corrected it.
Answer: The probability that a vertex is marked in the first round is $p$, and the probability that a vertex of degree $\deg(v)$ is marked in the second round is $(1-p)^{\deg(v)+1}$: the probability that neither that vertex, nor any of its neighbors, were marked in the first round. These are mutually exclusive, so the total probability that a vertex is marked is
$$
   p + (1-p)^{\deg(v)+1} \le p + (1-p)^{m+1} \le p + e^{-p(m+1)}
$$
because $\deg(v) \ge m$ and by using the inequality $1+x \le e^x$. The expected number of marked vertices is the sum, over all vertices, of the probability that they are marked, which is at most $|V|(p + e^{-p(m+1)})$.
You misunderstand the second quantity (or else you are not explaining it correctly). It is not the maximal number of marked vertices. Rather, it's the minimum of the expression above over all choices of $p$. This minimum is achieved by setting $p = \frac{\ln(m+1)}{m+1}$, which gives us
$$
    p + e^{-p(m+1)} = \frac{\ln(m+1)}{m+1} + e^{-ln(m+1)} = \frac{\ln(m+1)}{m+1} + \frac1{m+1} = \frac{1 + \ln(m+1)}{m+1}.
$$
Why do we care about this? Because our goal is to find a small dominating set for our graph. For any $p$, we can perform this two-round procedure, and get an expected number of $|V|(p + e^{-p(m+1)})$ vertices in the dominating set. In particular, for any $p$, there is a dominating set of size at most $|V|(p + e^{-p(m+1)})$. To get the best upper bound on the size of the smallest dominating set, we choose the value of $p$ that minimizes this expression. We conclude that there is a dominating set with at most
$$
   |V| \cdot \frac{1 + \ln(m+1)}{m+1}
$$
vertices.


Extend the linear functional on $\mathbb R^2$

Question: Let $(\mathbb R^2, \|\cdot\|_1)$ be normed space and $E$ be a 1-dimensional subspace. If $f:E \to \mathbb R$ is linear functional with induced 1-norm one, i.e $\|f\|_{1,E}=1$ on $E$ extend it to linear functional $f:\mathbb R^2 \to \mathbb R$, with the same norm, $\|f\|_1 = 1$.
Some definitions:

For a vector $x \in \mathbb R^2$ the norm is defined as $\|x\|_1 := |x_1| + |x_2|$.
For a linear operator the norm $\displaystyle\|f\|_1 := \sup_{\|x\|_1 = 1} | f(x) |$
The induced norm of $f$ is defined as $\displaystyle\|f\|_{1,E} := \sup_{x \in E,\ \|x\|_1 = 1} | f(x) |$

Attempt 1:
A vector $x \in E$ would have components related as $x_1 a_1 + x_2 a_2 = 0$ for some non-vanishig $a = (a_1,a_2)$. If $\|f\|_{1,E} = 1$ then
\begin{align}
1 = \sup_{x \in E,\ \|x\|_1 = 1} | f(x) |
&= \sup_{x_1 a_1 + x_2 a_2 = 0,\ \|x\|_1 = 1}\left| x_1 f_1 + x_2 f_2 \right| \\
&= \sup_{\|x\|_1 = 1}\left| x_1 f_1 -\frac{a_1}{a_2} x_1 f_2 \right| \\
&= \left| f_1 -\frac{a_1}{a_2} f_2 \right|\sup_{\|x\|_1 = 1} |x_1| \\
&= \left| f_1 -\frac{a_1}{a_2} f_2 \right| \frac{|a_2|}{|a_1| + |a_2|}
= \frac{ |a_2 f_1 - a_1 f_2| }{|a_1| + |a_2|} = \frac{|\det(f,a)|}{|a_1| + |a_2|}
\end{align}
or more concisely
$$
|\det(f,a)| = \| a \|_1
$$
But that doesn't determine $f$.
Attempt 2:
I wanted to find a linear functional such that $f(v) = v_1 f_1 + v_2 f_2 = 1$, for $v\in E$ and $f(u) = u_1 f_1 + u_2 f_2 = 0$ for linearly independent vector, where $\|v\|_1 = \|u\|_1 = 1$. Then we get the solutions
\begin{align}
f_1 &= \frac{u_2}{\det(v,u)}   &   f_2 &=  -\frac{u_1}{\det(v,u)}
\end{align}
But that stll doesn't determine $u$ nor $f$.

By the way, I found the solutions geometrically, i.e. without computations as above, but I don't know how to justify them with computation. Any hints would be helpful. It will be great to learn something for the infinite dimensional case from this exercise.
Answer: There are no many options for a subspace, so lets assume that $E=\{(x_1, x_2)\in \mathbb{R}^2: x_2=ax_1\}$ for some $a\in \mathbb{R}$, then we also may assume that the linear functional $f: E\to \mathbb{R}$ must be of the form
\begin{align*}
    f(x_1, x_2)=\eta x_1,
\end{align*}
for some $\eta\in \mathbb{R}$. Now we observe that
\begin{align*}
    |f(x_1, x_2)|=|\eta||x_1|=\dfrac{|\eta|}{1+|a|}\|(x_1, x_2)\|_1
\end{align*}
hence by assumption the relation between the data $\eta$ and $a$ must be
\begin{align*}
    \dfrac{|\eta|}{1+|a|}=1.
\end{align*}
Now, by Hahn-Banach, $f$ admits an extension to the whole $\mathbb{R}^2$, denoted by $F$. By letting $\beta_1=F(1, 0)$ and $\beta_2=F(0, 1)$, we can describe $F$ by
\begin{align*}
    F(x_1, x_2)=\beta_1x_1+\beta_2x_2,\ \forall x_1, x_2\in\mathbb{R}.
\end{align*}
Since $F$ extends $f$, over $E$ we must have
\begin{align*}
    \eta x_1=f(x_1, ax_1)=F(x_1, ax_1)=(\beta_1+a\beta_2)x_1,
\end{align*}
which results on the first condition for the extension: $\beta_1+a\beta_2=\eta$. The induced $1$-norm of $F$ is given by
\begin{align*}
    \|F\|_1=\max\{|\beta_1|, |\beta_2|\},
\end{align*}
therefore the second conditions for the extension is
\begin{align*}
    \max\{|\beta_1|, |\beta_2|\}=1.
\end{align*}
since $F$ has norm $1$. Hence by solving the system
\begin{align*}
    \begin{cases}\beta_1+a\beta_2=\eta,\\
    \max\{|\beta_1|, |\beta_2|\}=1,\end{cases}
\end{align*}
you can determine $F$.
Observe that this system does not have unique solutions. For instance, $(\beta_1, \beta_2)=(0, 1)$ and $(\beta_1, \beta_2)=(1, 0)$ solves the system, and each solution is associated to a different linear extension. The condition to have a unique Hahn-Banach extension (preserving the norm) for a linear functional $f: M\leq X\to \mathbb{R}$, is that the dual space $X^*$ is strictly convex.
Comment: Could you please explain what *the induced 1-norm of $F$* is ? where does it come from ?
Comment: It is the best constant satisfying $|F(x)|\leq C\|x\|_1$ for all $x\in \mathbb{R}^2$. There are some characterizations for such number (I assume that those are well known for you from the definitions you gave), and, as I assert, in this case such number is given by $\max\{|\beta_1|, |\beta_2|\}$. It is a good exercise to prove that claim.
Comment: Could you remind me what characterisations you mean, perhaps I know what you mean
Comment: The second definition you gave is exactly the induced $1$-norm of a linear functional
Comment: The whole difficulty was to arrive at that max, but is this an implication of sth like the spaces $L^p$ and $L^q$ are dual if $\frac{1}{p} + \frac{1}{q} = 1$ ? I say that because the max norm is $(q = \infty)$-norm dual to $(p = 1)$-norm of the space
Comment: Not quite, but it is related. To prove that it is indeed the norm, you can easily obtain the inequality $|F(x)|\leq \max\{|\beta_1|, |\beta_2|\}\|x\|_1$ (the $\max$ appears naturally in the bound). On the other hand, can you find a vector $x$ of $1$-norm $1$ such that $F(x)=\max\{|\beta_1|, |\beta_2|\}$? The latter is the difficult part, but in the finite dimensional case it is easy to handle. I encourage you to think about it.


Can I find which CQL rules are violated by a class

Question: I am trying to use NDepend in code review process. The one thing I want to solve is to check if newly created classes are valid from the point of CQL rules.
I have plenty of legacy code and there numerous fields/classes/methods that violates CQL rules. But I want to find only these rules which are violated by a particular class which was newly created by a developer and which I want to review.
Is there a way to find all CQL rules violated by a particular class, so I could fix them?
Answer: Yes, you can compare two analysis and select new classes with the CQL condition "WasAdded".
<code>Select Classes Where WasAdded
</code>
Other attributes to compare two versions are

WasRemoved
CodeWasChanged

Check out CQL Documentation and this article from Patrick.
Comment: Thanks! That what I was really looking for!


Codeigniter for-each loop with API result

Question: My API call returns following data in Codeigniter:
<code>Pronamic\Twinfield\VatCode\VatCode Object
(
    [code:Pronamic\Twinfield\VatCode\VatCode:private] => IH
    [name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 21%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
    [code:Pronamic\Twinfield\VatCode\VatCode:private] => IL
    [name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 6%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
    [code:Pronamic\Twinfield\VatCode\VatCode:private] => IN
    [name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 0%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
    [code:Pronamic\Twinfield\VatCode\VatCode:private] => VH
    [name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 21%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
    [code:Pronamic\Twinfield\VatCode\VatCode:private] => VL
    [name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 6%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
    [code:Pronamic\Twinfield\VatCode\VatCode:private] => VN
    [name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 0%
)
</code>
My (simple?) question is how to modify this result so it handles like a normal array, with values like:
<code> 'code' => 'IH', 'name' => BTW 21%
</code>
Any clue?
Thx in advance!
Comment: That's a lot of redundant strings. My first thought as a non-php guy would be a regex. Please demonstrate what you have actually tried so people with more experience can/will offer refinements.
Comment: Can you show the code that generates that output?  Are you actually getting an array and iterating through that?
Comment: Not entirely sure what you're after, but have you looked at the classic  `json_encode() / json_decode()` to [convert objects to an assoc array](https://stackoverflow.com/a/10631793/3585500)?
Comment: Are you calling third party api?
Comment: @NaimMalek: indeed. It's is a third party api, Twinfield
Comment: Try this `$result = get_object_vars($YOUR_OBJECT));` @karel
Answer: I did following and it works. First changed object to regular array.
<code>            foreach ($result as $array_item) {
            $item = (array) $array_item;
            $keys = array_keys($item);
            $key_first = $keys[0];
            $key_second = $keys[1];
            echo $item[$key_first];
            echo $item[$key_second];
            }
</code>


please help me to visualize the open sets in $\tau$.

Question: In "Foundation of Topology" by C.W Patty, given
$$\begin{align}A :=& \ \{(x,y)\in \mathbb R^2:y=0\},\\
X:=& \ A\cup\{(0,1)\},\end{align}$$
the topology on $X$ is defined as
$$\tau:= \ \{U\in \mathscr   P(X):U=\varnothing \vee (0,1)\in U\}.$$
I am able to prove the given collection is a topology on $X$ without knowing how $U$ looks like .
My attempt of a proof:-
1) $\varnothing \in \tau$[$\because$ from definition] $X\in \tau [\because X=A\cup\{(0,1)\}$
2) $(0,1)\in U_\alpha,\alpha \in \Gamma$, $(0,1)\in \cup_{\alpha}U_{\alpha}\implies \cup_{\alpha}U_{\alpha}\in \tau$
3) $(0,1)\in U_\alpha,\alpha \in \Lambda$,$|\Lambda|=$finite, $(0,1)\in \cap_{\alpha}U_{\alpha}\implies \cap_{\alpha}U_{\alpha}\in \tau$.
I don't know how would the elements look like?
How $\{(0,1)\}$ is a dense subset in $X$?
Please help me to visualize the open set in $\tau$.
Answer: An open set is the empty set $\varnothing$ or any subset of the $x$-axis together with the point $(0,1)$. You can visualize this to the extent that you can visualize arbitrary subsets of $\mathbb{R}$.
A closed set is the whole space $X$ or any subset of the $x$-axis (as the complement of an open set, a closed set does not contain $(0,1)$, unless it is $X$).
Why is $\{(0,1)\}$ dense? Well, the closure of $\{(0,1)\}$ is the intersection of all closed sets containing $(0,1)$, and there's only one of these, namely $X$.
Your proof that $\tau$ is a topology looks mostly fine, though you've forgotten to handle the cases when some $U_\alpha$ are empty in (2) and (3). Also, it's hard to read because you're writing things using symbols that would be clearer written out in words. For example, for (3), I would write:

If $(U_\alpha)_{\alpha\in \Lambda}$ is a finite family of open sets, then either some $U_\alpha$ is empty, in which case $\bigcap_{\alpha\in \Lambda} U_\alpha = \varnothing$ is in $\tau$, or $(0,1)\in U_\alpha$ for all $\alpha$, in which case $(0,1)\in \bigcap_{\alpha\in \Lambda} U_\alpha$, so this intersection is in $\tau$.
Comment: @WillR $(0,1)$ is not on the $x$-axis...
Comment: I think your first sentence should be "An open set is the empty set $\varnothing$ or *any* subset of the $x$-axis which contains the point $(0,1)$.", and your second paragraph should be amended accordingly.
Comment: You are correct! I take it all back.
Comment: To the proposer: Another ( equivalent) definition, (when $Y\subset X$),  of  "$Y$ is  dense in $X$" is that $Y\cap U$ is not empty whenever $U$ is a non-empty open subset of $X$.  The non-empty members of $\tau$ are just the subsets of $X$ that contain $(0,1),$ and the set $\{(0,1)\}$ has non-empty intersection with
 each of them.


Add title for sections in a view

Question: so I am trying to create a view via Drupal 8 Structure->Views, and I am setting up this view to display certain shops in certain areas, I would like titles above each type of location of shops, so I would like u.s.a stores to have a title, and canada stores to have a title, is this possible in the view creator? for example:
Or should I create separate views, then sort in the twig files, example stores - can, stores - usa
Please let me know, thanks!
Comment: Do you want to group and sort the results by type or by country?
Answer: If you want a title for each type of view, I would click the add button for a "header" then click on Global text and enter in the Title you want for that view.

UPDATE:
Also, if you are looking to put in a title for each entry you could look into making that a content type that the view pulls from. It can pull the Title of each entity.

Add title for sections in a view


Adding JLabel to JMenuBar and making it take up all available space

Question: I'm working on an application with a dropdown JMenuBar. I've decided I want to remove the outer frame though as I don't like how it looks. So I've added a minimize, maximize and an exit button to the JMenuBar like this after I add the menu's:
<code>//buttons
this.add(Box.createHorizontalGlue());

//turn into images later
minimize = new JButton(" - ");
maximize = new JButton(" [] ");
exit = new JButton(" x ");

this.add(minimize);
this.add(maximize);
this.add(exit);
</code>
Now to make the JMenuBar dragable I want to add a JLabel in between the JMenuItems and these buttons, However I don't know how I can get it to use all available space there. Just adding it like this doesn't work:
<code>//draglabel
dragLabel = new JLabel("hey");
dragLabel.setBackground(Color.RED);
dragLabel.setOpaque(true);
this.add(dragLabel);
</code>
How can I maximize this JLabel to take upp all avaiable space inside the JMenuBar?
Comment: `Now to make the JMenuBar dragable I want to add a JLabel in between the JMenuItems and these buttons` - why do you need the label? Just add the dragging code to the menubar itself. Check out [Moving Windows](https://tips4java.wordpress.com/2009/06/14/moving-windows/) for a class to help with the dragging.
Comment: I believe that will also block access to all the buttons and JMenu dropdowns
Comment: Why would you think this? The point is to actually try it first BEFORE making an assumption.
Answer: Use JPanel instead of JLabel. It stretches to fill all available space by default. If you are adamant about using Jlabel you will have to extend it and override getMaximumSize() method like this:
<code>JLabel lblNewLabel = new JLabel("New label") {
// Maximum size should be larger than what the JMenuBar will ever be.
    @Override
    public Dimension getMaximumSize() {
        return new Dimension(Integer.MAX_VALUE, 1000);
    }
};
</code>
Comment: @BRHSM You probabbly added both HorizontalGlue and JPanel to the JMenuBar. the glue took half the available space and the panel took the other half.
Comment: The red area is the JPanel but it does not seem to go all the way to the right.


PHP - Get list of databases names

Question: How can I get a list of all the MySQL databases that exist on a server using PHP?
Answer: $result = mysqli_query($db_conn,"SHOW DATABASES");
while ($row = mysqli_fetch_array($result)) {
    echo $row[0]."
";
}

Comment: ^^ thumbs up. for mysqli.. `$result = mysqli_query($db_conn,"SHOW DATABASES"); while ($row = mysqli_fetch_array($result)) { echo $row[0].""; }`
Answer: $dbcnx = mysql_connect ($dbhost, $dbusername, $dbpassword);
$result = @mysql_query('SHOW DATABASES');

while ($row = mysql_fetch_array($result)) {
 print_r ($row)
}

Answer: At the MySQL prompt, SHOW DATABASES does what you want.
You can run this command as a query from PDO or the native PHP MySQL library and read the returned rows. Pretend it is a normal select.
You will only see the databases that the account used to connected to MySQL can see.
Answer: The MySQL command for this is
SHOW DATABASES

See the manual for more info on the SHOW command
Answer: Write the SQL query:
  show databases

Answer: Just use SHOW DATABASES.It will show all the databases present in your MySQL.

PHP - Get list of databases names


A Sufficient condition for a curve being perpendicular to a constant vector

Question: I solved this problem on my own, months ago, but the solution seems to me completely forgotten, a little help on it would be appreciated:
Suppose $\alpha= \alpha(t)$ on an interval $I$ is a smooth (of class C$^1$) parametric representation of the curve $C$, and for any $t \in I$ we have $\space\space\frac{d}{dt}\alpha(t).v=0$, where $v$ is a constant vector, furthermore $\alpha(0)$ is perpendicular to $v$.
Then $\forall t\in I: \space \alpha(t).v=0$.
Comment: So you want to prove $a(t)\cdot v\equiv 0$ on $I$? Isn't it part of the given information though?
Comment: Oops, my mistake, I'm editing it
Answer: Assume the ambient space is $\Bbb R^n$. Then $\alpha'(t)$ always lives in $\text{ker} \,v$, a subspace orthogonal to $v$. This suggests we use an orthogonal transformation $\rho$ to change coordinates, so that $\rho w$ is in the same direction as $e_n$ and $\rho\alpha'(t)$ lives in the span of $e_1,\cdots,e_{n-1}$, denoted $V$. We now only have to show $\rho\alpha(t)$ lives in $V+h$ for some $h\in\Bbb R^n$. Denote $\beta:=\rho\alpha$ then $\beta'=\rho\alpha'$. We only look at the $n$-th componenent of $\beta$ now. I assume by $I$ you mean $[0,1]$. So let $h:=\beta(0)$, we claim $\beta(I)\subset h+V$: otherwise suppose $\exists t_0$ s.t. $\beta^n(t_0)-\beta^n(0)\ne 0$. However, by the fundamental theorem of calculus applied to $\beta^n$ we know that
$$\beta^n(t_0)-\beta^n(0)=\int_{[0,t_0]}(\beta^n)'(t)\mathrm dt=\int 0 = 0.$$
Comment: @AshkanRanjbar ... $n$-th component stays constant. If you want to visualise, think about $\Bbb R^3$.
Comment: @AshkanRanjbar 1). Change of coordinates is not essential, but it can simplify our analysis. The idea is, originally, since $v$ is kinda arbitrary, $\text{ker}\,v$ may be a *tilted* subspace, which makes it troublesome to express orthodogonal "component" in coordinate form. But after a coordinate change we basically tilt the space back to the upright position (span of $e_i,i=1,\cdots,n-1$). An orthogonal transformation is a zero-preserving rigid body motion, so however the subspaces is originally tilted, we are always guaranteed to find an orthogonal transformation to set it back "upright".
Comment: @AshkanRanjbar 2). $V+h$ is the vector sum, which you can simply interpret as an affine space parallel to $V$. Formally it is $\{x+h\mid x\in V\}$. 3). Because as I said in the last comment, after the "tilt" i.e. the orthogonal transformation, $v$ now becomes $\rho v$, which is in the same direction as $e_n$ and the subspace $\alpha'$ originally lives in is now set in an "upright" position i.e. the "horizontal plane". We want to show $\beta$ is always orthogonal to $\rho v$, or equivalently is always confined to an affine space parallel to the horizontal plane $V$, so we only have to show its.
Comment: Thx, now I get it.
Comment: Vectors also have kernels? I didn't know that.
Comment: @AshkanRanjbar ok I should have clarified. By this I mean the set $\{x\mid x\cdot w=0\}$ i.e. If you treat $w$ as a linear operator $x\mapsto w\cdot x$.
Comment: and what is $w$? just any arbitrary vector orthogonal to $v$?
Comment: @AshkanRanjbar $w$ is $v$. Sorry.
Comment: I forgot my own solution back then, but I'm sure it was way different than yours, and pretty much simpler than this, and I must admit that it's very difficult for me to get the point you're trying to make, however your solution somehow hints me to use mean value theorem for integrals (and of course componentwise), but I could not figure it out how to use it, meanwhile, could you please if possible send me another simpler solution? and let your current solution be justified by other experts in the forum.
Comment: What specifically do you not understand in my answer? Feel free to ask and I'm glad to clarify. I'm going to leave this answer to the judgement of other experts. But I'm not going to post another answer.
Comment: You're very kind, thank you. Hmmm deep down I always had trouble understanding change of basis in linear algebra, yours is even more strange than the ones I fairly recall (mine were $P^T A P$ like), also why would you want to show $\rho\alpha(t) $ lives in $V+h$ since, that $h$ causes some trouble for me(isn't it the same as the integral constant?) and finally why we left to check the n-th component of $\beta$?
Answer: Let $ \; t_0 \in \mathrm{dom(\alpha)} $ the FTC for vector valued functions implies
$$\require{cancel}\alpha(t_0 ) -\alpha(0) = \int_{0}^{t_0} \dot\alpha(v)dv\qquad(1)$$
Now apply dot product upon (1) and $v$ will result (using $<,>$ as the dot operator)
$$<v,\alpha(t_0)> -\cancelto{0}{<v,\alpha(0)>}=<v,\int_{0}^{t_0}\dot \alpha(u)du>$$
But
$$<v,\int_{0}^{t_0}\dot \alpha(u)du>=\int_{0}^{t_0}<v,\dot \alpha(u)>du$$ Using our hypothesis and the fact that $t_0$ was taken arbitrarily it follows $$\forall t\in\mathrm{dom}(\alpha) \quad<\alpha(t),v>=0$$
Q.E.D.
Comment: Nice this argument is certainly cleaner than mine.


Bad in my opinion vs. low quality

Question: In the review queue for low quality answers I came across this answer. The answer is pretty bad in my opinion, it lacks rigour, etc. Yet it is an attempt to answer the question, not spam or vandalism. We already have downvotes to deal with answers we disagree with.
When should I recommend deletion (in the review queue or via flagging) rather than downvoting an answer?
Comment: It seems like it makes more sense to downvote. flagging is for spam and low quality.
Comment: @EconJohn Please consider posting your comment as an answer. This is a meta question and consensus should provide guidance. My question is about the difference between "bad" and "low quality". Based on your comment the boundary is not clearer to me.
Comment: Whoever downvoted this question certainly has the right to do so. Seeing that this is a discussion I hope they will choose to elaborate.
Answer: According to this answer on Meta.SE:

You should Delete a post

If the post is rude or offensive [possibly flag]
[ANS] If the answer asks another question
[ANS] If an answer is actually a comment (such as asking for more info, thanks!, etc.) [possibly flag]
[ANS] If the answer is incomprehensible and you are at least a bit familiar with the subject.
[ANS] If the answer duplicates another, better answer to the same question (e.g. a link-only answer where another answer provides the same link with an explanation).
[ANS] Is obvious spam (tries to sell you cheap sunglasses) [flag].
[ANS] Note that wrong answers should not be deleted: deletion is for answers that "aren't even wrong".

A common theme among these guideline seems to be that deletion is reserved for not-an-answer's.
For the particular answer you linked to, I voted "Looks OK" when I reviewed it, since it does try to address the OP's question, albeit not in a very satisfying manner.
Comment: I'm voting for this. I think it's a good idea to remain consistent with network wide norms when we don't have a good reason for doing otherwise.
Comment: This seems a pretty reasonable interpretation from me as well.

Bad in my opinion vs. low quality


The difference between ∈ and ⊂

Question: I had a task where I had to figure if the argument was true or not.
$A=\{ n ∈ ℤ \mid n^2 < 5 \}, \quad  B=\{ 7, 8, \{2\}, \{2, 7, 8\}, \{\{7\}\} \}$
The first one was $\{-1, 2\} ∈ A$ and the answer to this was not true
 since the set is not an integer.
The second one was $\{-1, 2\} ⊂ A$ and the answer to this was true since
 -1 and 2 are elements of $A$.
I just can't seem to understand the difference between ∈ and ⊂ in this task and why the first argument was not true. Also it confuses me that the answer to the first one was that not true because the set is not an integer but aren't -1 and 2 integers?
There is other parts of this task that also add more confusion:

{2, 7, 8} ∈ B Answer: True since {2, 7, 8} is an element of set B
{2, 7, 8} ⊂ B Answer: Not true, for example 2 is not an element in set
  B
Comment: you seem stuck on notation, do you understand what these symbols mean ?
Answer: Intuitively, a set is a bag of things.
One of the things in the bag is an element. So we could say $\color{limegreen}{\large{\bullet}}\in S$.

On the other hand, if you pick things from your bag and stick them in a new bag, you've got a subset. So we can say $\{\color{cyan}{\large{\bullet}},\color{limegreen}{\large{\bullet}},\color{red}{\large{\bullet}}\}\subset S$.

More concretely, we can take any integer from $\mathbb{Z}$ and say $1\in\mathbb{Z}$ or that $5\in\mathbb{Z}$. But when we take integers from $\mathbb{Z}$ and put them in another set, we would say $\{1,5\}\subset\mathbb{Z}$ or $\{3,4,1\}\subset\mathbb{Z}$ or even $\{\cdot\}\subset\mathbb{Z}$. In a nutshell, $\in$ is used for objects in the set but $\subset$ is used for collections of objects in the set.
Comment: @RasmusAndersen Looking back at this post, I'm less keen on that notation and would consider it nonstandard and not particularly clear. I believe what I meant was that there were no elements within that set, ie, it was empty. And I think that $\{\,\}\subset\mathbb{Z}$ (ie, $\emptyset\in\mathbb{Z}$) would be clearer notation.
Comment: What does the expression $\{\cdot\} \subset \mathbb{Z}$ represent? Is it just a set of any integers? When can we use the $\cdot$ instead of writing the numbers explicitly?
Answer: Simply:
$x\in y$ if $x$ is an element of $y$. An example of this is $2\in\{a, 2, \pi\}.$
$x\subset y$ if every element of $x$ is an element of $y$. An example of this is $\{2, \pi\}\subset\{a, 2, \pi\}$

For your problem specifically:

The set of $\{-1, 2\}$ is not an element of the set of integers whose squares are less than $5$.
The set of $\{-1, 2\}$ is a subset of $A$ because all elements of $\{-1, 2\}$, both $-1$ and $2$, are integers whose squares are less than $5$.
Answer: First of all we use $\in$ for elements of a set and $⊂$ for subset of a set.
For the first part note that $\{1,2\}$ isn't an element of the set $A$, in fact it's a subset of it.
For the second part, note that $B$ also contains subsets (as elements), therefore $\{2,7,8\}$ is an element of $B$, but not a subset, as there is no element $2$ in $B$.
Answer: $\in$ stands for "belongs to".For eg. an element may belong to a set.
$\subset$ is the symbol for subset .For eg. one set can be a subset of another set if all elements of that set is included in the later set.
You must be careful on what you are applying $\in$ or $\subset$.
Answer: A set (e.g. $A$ or $B$) has individual elements. These elements are abstract objects (e.g., in $A$ they are integers), but sometimes confusingly these elements can be also sets ($B$ has elements that are integers as well as elements that are sets).
$\in$ means "is an [individual] element of." The elements of $A$ are integers $-2, -1, 0, 1, 2$, while the set $\{-1,2\}$ is not one of these integers.
The set $\{2,7,8\}$ is one of the elements of $B$, so $\{2,7,8\} \in B$.
$\subset$ means "is a subset of." The left-hand side of $\subset$ should be a set whose elements are also in the set on the right-hand side of $\subset$. The set $\{-1,2\}$ has two elements $-1$ and $2$, both of which are in $A$, so we write $\{-1,2\} \subset A$. The set $\{2,7,8\}$ has three elements $2,7,8$, but not all of them (actually none of them) are elements of $B$, so $\{2,7,8\} \not \subset B$.

The difference between ∈ and ⊂


Jest MockImplementation of react component

Question: I am testing a react component which renders another component which calls an endpoint and returns some data and is displayed, i want to know how i can mock the component that calls the endpoint and return dummy data for each test
This is the component i am testing

class MetaSelect extends React.Component {
    render() {
        console.log('metaselect render', MetadataValues);
        return (
             <MetadataValues type={this.props.type}>
                {({ items, isLoading }) => (
                    <>
                        {isLoading ? (
                            <Icon variant="loadingSpinner" size={36} />
                        ) : (
                            <Select {...this.props} items={items} placeholder="Please select a value" />
                        )}
                    </>
                )}
            </MetadataValues>
        );
    }
}

MetaSelect.propTypes = {
    type: PropTypes.string.isRequired
};

I want to mock the MetadataValues in my tests, this is the metadataValues.js file

class MetadataValues extends React.Component {
    state = {
        items: [],
        isLoading: true
    };

    componentDidMount() {
        this.fetchData();
    }

    fetchData = async () => {
        const items = await query(`....`);
        this.setState({ items, isLoading: false });
    };

    render() {
        return this.props.children({ items: this.state.items, isLoading: this.state.isLoading });
    }
}

MetadataValues.propTypes = {
    type: PropTypes.string.isRequired,
    children: PropTypes.func.isRequired
};

This is my metaSelect.test.js file

jest.mock('../MetadataValues/MetadataValues');

describe.only('MetaSelect component', () => {

    fit('Should display spinner when data isnt yet recieved', async () => {
        MetadataValues.mockImplementation( ()=> {
Mock
});

        const wrapper = mount(<MetaSelect type="EmployStatus"/>);
        expect( wrapper.find('Icon').exists() ).toBeTruthy();
    });

});

Im guessing i need to add something in the MetadataValues.mockImplementation( )
but im not sure what i should add to mock the component correctly
Comment: I think you just need to use `setState` - https://github.com/airbnb/enzyme/blob/master/docs/api/ShallowWrapper/setState.md
Comment: To sway you the other way, have you thought about how you're testing the edge cases of the `query`? That could resolve to include 0, 1, or many items **or** reject with an error that isn't handled yet.
Answer: If you only need one version of the mock in your test this should be enough:
jest.mock('../MetadataValues/MetadataValues', ()=> ()=>
Mock
);

If you need to different mock behaviour you need to mock it like this
import MetadataValues from '../MetadataValues/MetadataValues'
jest.mock('../MetadataValues/MetadataValues', ()=> jest.fn());

it('does something', ()={
   MetadataValues.mockImplementation( ()=> {
Mock1
});
})

it('does something else', ()={
  MetadataValues.mockImplementation( ()=> {
Mock2
});
})

Comment: should it be : MetadataValues.mockImplementation( ()=> ( Mock1)) ? it miss the return
Comment: `MyOwnComponent.mockImplementation( ()=> { Mock2})` gives me an error such as `Property 'mockImplementation' does not exist on type`.  This answer makes sense to me, but I'm unsure what I'm doing differently than this example.
Answer: what about using shallow() instead of mount()?
const mockedItems = [{.....}, {...}, ...];

it('shows spinner if data is loading', () => {
    const wrapper = shallow(<MetaSelect type={...} /*other props*/ />);
    const valuesChildren = wrapper.find(MetadataValues).prop('children');
    const renderResult = valuesChildren(mockedItems, true);
    expect(renderResult.find(Icon)).toHaveLength(1);
    expect(renderResult.find(Icon).props()).toEqual({
        variant: "LoadingSpinner", // toMatchSnapshot() may be better here
        size: 36,
    });
});

This not only makes mocking in natural way but also has some benefits
it('passes type prop down to nested MetadataValues', () => {
    const typeMocked = {}; // since it's shallow() incorrect `type` does not break anything
    const wrapper = shallow(<MetaSelect type={typeMocked} >);
    expect(wrapper.find(MetadataValues).prop('type')).toStrictEqual(typeMocked);
})


How can I recover my MySQL databases from a Homestead Vagrant VirtualBox?

Question: I was running Homestead v8.2.0 and laravel/homestead (virtualbox, 7.1.0) and Vagrant 2.2.4. I needed to upgrade because I wanted PHP 7.4 support.
Laravel docs said that destroying the vagrant box first would be necessary, but I knew I didn't want to destroy my original box since I still had valuable data in there.  So I figured I'd try merely "updating" it, just in case that might work.
(I was very careful not to use destroy because I didn't want to lose any of my MySQL databases.)
When I ran vagrant global-status I saw:
id       name          provider   state   directory
------------------------------------------------------------------------------
5620b14  vboxHomestead virtualbox running C:/code/Homestead

So I used git to checkout v10.2.0 of Homestead.
And I ran vagrant box update. I was not surprised that this approach didn't work, given the Laravel docs.
So then I figured: instead of updating my current box, I'll just create a new box alongside it (still not destroying the old box).
So I copied C:/code/Homestead to a new directory C:/code/HomesteadB.
I upgraded to Vagrant 2.2.7. I ran vagrant box add laravel/homestead and saw the new laravel/homestead (virtualbox, 9.2.0) (notice the higher version number). I ran vagrant up, and I continued to enjoy my new box running PHP 7.4. Everything seemed to be going to plan.
Later, when I felt inspired to go back to my old box and recover all the old data there, I noticed that the MySQL databases are missing!
But this doesn't make any sense because I never deleted them. And I never destroyed the box (I'm still able to run vagrant up in the old C:/code/Homestead and then vagrant ssh). And I wouldn't think that vagrant box update would have deleted MySQL databases either.
Where are they, and how can I recover them?
UPDATE in response to https://stackoverflow.com/a/60411945/470749
myuser@ABCDESK MINGW64 /c/code/Homestead ((v10.2.0))
$ vagrant box list
laravel/homestead (virtualbox, 5.2.0)
laravel/homestead (virtualbox, 6.0.0)
laravel/homestead (virtualbox, 7.1.0)
laravel/homestead (virtualbox, 9.2.0)
redash/dev        (virtualbox, 0.1.0)

$ VBoxManage list vms
"Redash" {29166fde-e0bf-4f31-8efc-58a66afd78e5}
"redash_default_1502117350190_63240" {0b5935af-288a-4e4d-aa8a-ee04f42e3235}
"macOS 10.12 High Sierra" {37b09cb2-10cd-4e1a-8e2c-aefdb1a348c6}
"macOS Sierra" {f010233b-d058-4a6e-9493-5c4d68e99ef1}
"macOS High Sierra 10.13" {741f0d4d-7f16-4f42-993b-4d301ef68125}
"default" {f3e8f33d-0ca3-452d-9ae6-d93e5e412fbb}
"vboxHomestead" {0706d0b0-d31b-4137-9e97-f86b827f1530}
"vboxHomestead2020-01-31" {1ef6f202-9d81-4d41-a4b9-adaab7b12014}

$ ls -lah /c/code/Homestead/.vagrant/machines/
total 0
drwxr-xr-x 1 myuser 197121 0 Aug 27  2017 ./
drwxr-xr-x 1 myuser 197121 0 Apr  8  2019 ../
drwxr-xr-x 1 myuser 197121 0 Apr  4  2017 homestead-7/
drwxr-xr-x 1 myuser 197121 0 Aug 27  2017 vboxHomestead/

$ ls -lah /c/code/HomesteadB/.vagrant/machines/
total 0
drwxr-xr-x 1 myuser 197121 0 Jan 31 09:36 ./
drwxr-xr-x 1 myuser 197121 0 Jan 31 09:25 ../
drwxr-xr-x 1 myuser 197121 0 Jan 31 09:25 homestead-7/
drwxr-xr-x 1 myuser 197121 0 Jan 31 09:25 vboxHomestead/
drwxr-xr-x 1 myuser 197121 0 Jan 31 09:36 vboxHomestead2020-01-31/

$ ls -lah /c/code/Homestead/.vagrant/machines/vboxHomestead/virtualbox/
total 19K
drwxr-xr-x 1 myuser 197121    0 Apr  8  2019 ./
drwxr-xr-x 1 myuser 197121    0 Aug 27  2017 ../
-rw-r--r-- 1 myuser 197121   40 Apr  8  2019 action_provision
-rw-r--r-- 1 myuser 197121   10 Feb 18 12:20 action_set_name
-rw-r--r-- 1 myuser 197121  138 Feb 18 11:44 box_meta
-rw-r--r-- 1 myuser 197121    1 Apr  8  2019 creator_uid
-rw-r--r-- 1 myuser 197121   36 Apr  8  2019 id
-rw-r--r-- 1 myuser 197121   32 Apr  8  2019 index_uuid
-rw-r--r-- 1 myuser 197121 1.7K Apr  8  2019 private_key
-rw-r--r-- 1 myuser 197121  653 Feb 18 12:22 synced_folders
-rw-r--r-- 1 myuser 197121   17 Apr  8  2019 vagrant_cwd

$ ls -lah /c/code/HomesteadB/.vagrant/machines/vboxHomestead/virtualbox/
total 19K
drwxr-xr-x 1 myuser 197121    0 Jan 31 09:25 ./
drwxr-xr-x 1 myuser 197121    0 Jan 31 09:25 ../
-rw-r--r-- 1 myuser 197121   40 Jan 31 09:25 action_provision
-rw-r--r-- 1 myuser 197121   10 Jan 31 09:26 action_set_name
-rw-r--r-- 1 myuser 197121  138 Jan 31 09:25 box_meta
-rw-r--r-- 1 myuser 197121    1 Jan 31 09:25 creator_uid
-rw-r--r-- 1 myuser 197121   36 Jan 31 09:25 id
-rw-r--r-- 1 myuser 197121   32 Jan 31 09:25 index_uuid
-rw-r--r-- 1 myuser 197121 1.7K Jan 31 09:25 private_key
-rw-r--r-- 1 myuser 197121  653 Jan 31 09:25 synced_folders
-rw-r--r-- 1 myuser 197121   18 Jan 31 09:25 vagrant_cwd

$ ls -lah /c/code/HomesteadB/.vagrant/machines/vboxHomestead2020-01-31/virtualbox/
total 19K
drwxr-xr-x 1 myuser 197121    0 Jan 31 09:37 ./
drwxr-xr-x 1 myuser 197121    0 Jan 31 09:36 ../
-rw-r--r-- 1 myuser 197121   40 Jan 31 09:37 action_provision
-rw-r--r-- 1 myuser 197121   10 Feb 24 18:45 action_set_name
-rw-r--r-- 1 myuser 197121  138 Feb  4 11:56 box_meta
-rw-r--r-- 1 myuser 197121    1 Jan 31 09:36 creator_uid
-rw-r--r-- 1 myuser 197121   36 Jan 31 09:36 id
-rw-r--r-- 1 myuser 197121   32 Jan 31 09:36 index_uuid
-rw-r--r-- 1 myuser 197121 1.7K Jan 31 09:37 private_key
-rw-r--r-- 1 myuser 197121  654 Feb 24 18:46 synced_folders
-rw-r--r-- 1 myuser 197121   18 Jan 31 09:36 vagrant_cwd

$ cat /c/code/HomesteadB/.vagrant/machines/vboxHomestead2020-01-31/virtualbox/id
1ef6f202-9d81-4d41-a4b9-adaab7b12014

$ cat /c/code/HomesteadB/.vagrant/machines/vboxHomestead/virtualbox/id
0706d0b0-d31b-4137-9e97-f86b827f1530

$ cat /c/code/Homestead/.vagrant/machines/vboxHomestead/virtualbox/id
0706d0b0-d31b-4137-9e97-f86b827f1530

Comment: Check your box db with some gui tools like SequelPro. If exists, export data to safe place, then upgrade box and import db. I'm not homestead user, but on daily task I use vagrant boxes where we add before destroy command to backup db.
Comment: Do you have a db backup?
Comment: @Tarasovych No, hence my question.
Comment: Do you have your db in the old box?
Comment: @Tarasovych No, which is why I posted this question and why it says "I noticed that the MySQL databases are missing".
Comment: @Ryan so, if you don't have a backup, and you don't have a source you can get a backup from, how do you want to get your database back?
Comment: @Tarasovych The reason I posted this question is because the database must exist *somewhere*, given that I never ran `destroy`, and I never dropped the databases, and I never deleted files. So I'm hoping someone will teach me why they *seem* to be missing and where I can find them.
Comment: When you say that you _noticed_ that your databases are missing, exactly how did you notice that? Did you use `mysql CLI` client?
Comment: @linuxartisan Yes. When I use `vagrant ssh` into my original box and then go into MySQL in the command line and run `show databases;`.
Comment: If you hadn't your database mapped to the host machine, or you didn't use separate VM for the database, your database is gone.
Comment: @Tarasovych `vagrant box update` deletes the databases? Are you sure? Why would it do that?
Comment: `vagrant box update` does not know anything about what's inside your box. So, no, it does not delete databases. Probably the issue does not relate to `vagrant box update`
Answer: I think you're mixing the box and the VM - I made an answer here to explain the differences but basically once you have created a VM (Virtual Box resource) vagrant is not using the box.
The issue might that you made a copy but did not remove the reference to the VM from your poject folder, so vagrant did continue to operate on the same VM but using new box reference.
What you need to check is that in your copy of your project (C:/code/HomesteadB) the .vagrant/machines/<default>/virtualbox/id - this is the id of your VirtualBox VM corresponding to your project before update with all your data in.
Open Virtualbox and check that this VM is still there - (you can check in the VirtualBox folder of all VM) If its not there, your VM is gone and you cannot get your data back, unless you have some Hard Drive backup with the reference of the VM and copy of your VirtualBox directory
I am still unsure how it would happen, because vagrant up after the vagrant box update should not have rebuilt the VM. If it is so, the issue has been that when you copied your project, you did not remove reference of the VM from the .vagrant directory so it was still interacting with the existing VM. If you did remove the vagrant id reference after you copied your project, you would have been safe and vagrant would not have been able to touch the existing VM because there was no link.
You should open VirtualBox and check the following 2 VMs

"vboxHomestead" {0706d0b0-d31b-4137-9e97-f86b827f1530}
"vboxHomestead2020-01-31" {1ef6f202-9d81-4d41-a4b9-adaab7b12014}

open them and check if you can find your MySQL data in those VM, if not in those VM, then it will be lost.
I am a bit afraid (for you) that the VM 0706d0b0-d31b-4137-9e97-f86b827f1530 is the one you want but it has been recreated from the new laravel folder
Comment: Thanks for your response. I updated my question to add more information. I think I *may* have run `/c/code/HomesteadB vagrant up` one time before remembering to edit my `C:\code\HomesteadB\Homestead.yaml` to say `name: vboxHomestead2020-01-31` instead of `name: vboxHomestead`. And it also says `mysql8: true`. https://laravel.com/docs/6.x/homestead#installing-optional-features I wonder if that caused it to nuke my existing MySQL databases.
Comment: Thanks for your thoughts so far. Do you have any new thoughts before the bounty expires tomorrow (now that I've added more information)? Thanks.
Comment: It doesn't need to rebuold the vm it just needs to reprovision it with new software and run the postinstall scripts. (defined by whoever makes the box)
Comment: I didn't notice your edit to your answer, and SO didn't notify me! I just tried `vim /c/code/HomesteadB/Homestead.yaml` and edited `name: vboxHomestead2020-01-31` back to `name: vboxHomestead`. Then `vagrant up` (I also tried with `vagrant reload --provision`), `vagrant ssh`, and `mysql`, `show databases`. No luck. Thanks though. Really mysterious and frustrating that I somehow dropped databases during an upgrade.
Answer: Your only chance is to hope that vagrant box update does not do a fresh, clean install of mysql. I would try out a few things before giving up all hope:
1) check your vm provider (VirtualBox??) see how many vms are listed there. IF there are more then you expect, boot up the odd ones from the VirtualBox interface and see if your data exists on the odd machine that you think shouldn't be there. This has very low chances of working to be honest, but it's worth a shot. It should cover you in the case that your old box still exists somewhere in its old state. If you find anything, do mysqldump and then restore in the new
box.
2) vagrant ssh in your new machine and cd /var/lib/ look for folders related to mysql. This should cover you in case the vagrant update command hasn't cleared your mysql data dir entirely. I fear it might have :(  but do check if there's files that look like your old tables names or schema names. Id you find anything, change the mysql data dir to point to that folder, see this https://dba.stackexchange.com/questions/14320/how-can-i-move-a-mysql-database-to-another-drive . Do a mysqldump and restore in the new box
3) use VBoxManage list vms to get a list of vagrant box ids. If the old one is still there, you may be able to point vagrant to it. Check this post: https://stackoverflow.com/a/37963066/4183810  . If you get access to your data, do a mysqldump of your data and restore it on the new box.
There are some chances this could work, but unfortunately if you can't find your data, it's either gone or unreachable, so you might have to accept your fate :(
Comment: Thanks for your response. I updated my question to add more information. I think I *may* have run `/c/code/HomesteadB vagrant up` one time before remembering to edit my `C:\code\HomesteadB\Homestead.yaml` to say `name: vboxHomestead2020-01-31` instead of `name: vboxHomestead`. And it also says `mysql8: true`. https://laravel.com/docs/6.x/homestead#installing-optional-features I wonder if that caused it to nuke my existing MySQL databases.
Comment: Thanks for your thoughts so far. Do you have any new thoughts before the bounty expires tomorrow (now that I've added more information)? Thanks.


Separate class or Service for FusedLocationProvider Location updates?

Question: I currently have a class named LocationCheck.
public class SpeedCheck {

Here the location is retrieved every 3 seconds and is ongoing until the user stops it. To start checking for locations, the class is called in the Main Activity:
startLoc = new LocationCheck(this);

What i am wondering is if the code needs to be in a Service class rather than just an ordinary class (like it currently is). It works so far with no issues, but i may be misunderstanding the concept of Services etc and could be unaware of problems it may face over checking over a long period of time (fairly new to Android dev).
I have looked into Background Service for location updates, but with FusedLocationProvider (which i am using) it is only possible to receive several updates over an hour. This would not be helpful as i need an update every 3 seconds.
Any advice would be greatly appreciated.
Answer: If you need to keep checking location in background then use service else you can just simply use it in activity. Simply stop the service when you no longer need it because it will consume more battery if left running in background.
Comment: Reading into documentation for FusedLocationProvider it notes that within a Background Service the "location updates only a few times each hour." Is it best to use a Foreground Service then?
Comment: It depends on what you are trying to achieve. If you need accurate location consistently then use foreground service .
Comment: Thanks jatlin, put it all into a service running in the foreground and all works well.


Struggling to prove fact about classes of structures

Question: I am having difficulties proving the following:
If $\cal{A}$ is a connected class (i.e $\cal{A_\emptyset} = \emptyset$), then I need to show that the powers of $\mathcal{A}$ form a locally finite sequence. In other words, the sequence $\mathcal{S} = (\mathcal{A}^0, \mathcal{A}^1, \mathcal{A}^2, ...)$ is locally finite.
I know that to show that $\mathcal{S}$ is locally finite, i need to show that for any fintie set $X$, there are at most a finite amount sets $[(\mathcal{A}^i)_{X} : i \ge 0]$ that are not empty. However, I am quite unsure as to how to start.
If I could have a hint on how to do this, it would be greatly appreciated. I should also add that I don't have any other theorems to work with, besides for the basic definitions provided.
Thanks!
EDIT: I would also like a reference to material like this, if possible. I have no idea what this would be classified as though. We are seeing this in my enumeration course, but searching on Google does not seem to yield much information. On Wikipedia, I found a list of structures/classes (http://en.wikipedia.org/wiki/Algebraic_structure), though I am unsure as to what I should be looking up.
Comment: You could search for [combinatorial classes](http://en.wikipedia.org/wiki/Symbolic_combinatorics) and [combinatorial species](http://en.wikipedia.org/wiki/Combinatorial_species). You should definitely download Flajolet & Sedgewick, [*Analytic Combinatorics*](http://algo.inria.fr/flajolet/Publications/AnaCombi/anacombi.html).
Answer: You want to show that if $\mathcal A_\varnothing=\varnothing$, then for each finite set $X$ there is an $n_X\in\Bbb Z^+$ such that $\mathcal A_X^k=\varnothing$ for all $k\ge n_X$.
An $\mathcal A^k$-structure on $X$ is essentially an ordered $k$-tuple $\langle\alpha_1,\dots,\alpha_k\rangle$ such that:

$\alpha_i$ is an $\mathcal A$-structure on some $S_i\subseteq X$ for $i=1,\dots,k$,
$\{S_1,\dots,S_k\}$ are pairwise disjoint, and
$\bigcup_{i=1}^kS_i=X$.

(This isn't exactly right, assuming that you're using the definition in David Wagner's CO 430 notes that I found online: that definition makes it $\langle\langle\langle\dots\langle\alpha_1,\alpha_2\rangle,\alpha_3\rangle,\dots,\alpha_{k-1}\rangle,\alpha_k\rangle$, but the two are equivalent.)
If $\mathcal A_\varnothing=\varnothing$, each of the sets $S_i$ must be non-empty, so they partition $X$. How many of them can there be at most?
Comment: Thank you :) - I think that I got it now. And yes, these are the notes for our course, so these are the ones that I am following.
Comment: @Nizbel99: You're welcome. I figured that they probably were, given the identical terminology and notation and the fact that you're at Waterloo.


For a two variable function to be differentiable, does its partial derivatives have to be continuous?

Question: I am currently doing an Analysis-Differential Forms module and one of the questions states:
"Give an informal interpretation of what it means for a function $f(x,y)$ to be differentiable at point $c=(c_1,c_2)$"
The tutor gave this answer:
Taking a neighbourhood about $f(c_1,c_2)$. The function is differentiable if $f_x$ and $f_y$ (partial derivatives) are continuous and exist for all $x$ and $y$ values in that neighbourhood.
My question is, does its partial derivatives have to be continuous so that $f(x,y)$ is differentiable?
Answer: Your tutor gave a sufficient condition for differentiability, not a necessary one. The answer to your question is "no."
See, for example, this page, which gives
$$f(x,y)=\begin{cases}(x^2+y^2)\sin\left(\frac{1}{\sqrt{x^2+y^2}}\right) & (x,y)\neq(0,0) \\ 0 & (x,y)=(0,0) \end{cases}$$
as a counterexample.

As for "give an informal interpretation," the answer should be something like: $f(x,y)$ is differentiable at $c$ if $f$ is well-approximated by a linear function near $c$. Or in other words, if the graph of $f$ has a well-defined tangent plane at $c$.
Answer: By definition, $f$ is differentiable at $c$ if there exist a (unique) linear map $L\colon \mathbb{R}^2 \longrightarrow \mathbb{R}$ such that
$$
f(c_1+h,c_2+k) = f(c_1,c_2) + L(h,k) + \rho(h,k)
$$
with $\lim\limits_{(h,k)\to (0,0)} \frac{\rho(h,k)}{\|(h,k)\|} =0$. An informal interpretation of this is that a function $f$ is differentiable at $c$ if it has a well defined linear approximation in a neighborhood of $c$.
One can prove that $L(h,k) = \frac{\partial f}{\partial x}(c) h + \frac{\partial f}{\partial y}(c) k$
Actually, the partial derivatives being continuous imply differentiability but not the converse.


Is there a way to paginate AWS CloudWatch Logs Insights

Question: is there a way to paginate AWS CloudWatch Logs Insights? Thank you.
I was thinking something like below but that doesn't work
fields @message | page 2 | limit 20

EDIT:
I am currently accessing the logs via the Logs Insight

In my app, I am accessing it via AWS.Logger.Serilog. But I can move to a different approach (e.g. raw API call) if that would allow me to paginate the logs result.
I have tried browsing through the AWS CloudWatch documentation, google, and stack overflow. The problem I'm trying to overcome is how to paginate the logs so it won't load all the logs given a query.
Comment: Please edit your question to provide more information. For example, how are you accessing the logs (via the console, via API calls)? What problem are you trying to overcome? What have you tried so far?
Comment: @JohnRotenstein please see edit. thanks
Comment: Did you ever figure this one out? I am trying to achieve the same thing with the Java SDK.
Answer: There's not a native way to do this with the CloudWatch Insights Query Syntax.
You could achieve this in your application logic by using the last element in the current result set's sort field value as a next item token.
For example, your query uses @timestamp as the sort field. To fetch the next page, you could append filter (@timestamp < {value}) to the new query, where {value} is the timestamp of the previous query result's last item.
Comment: "where" is not a valid for log insights
Comment: @JaapH thanks, updated to use the correct `filter` syntax
Answer: Filter by timestamp query on AWS Cloudwatch Logs Insights has solution on how to filter on @timestamp on milliseconds even. So you can build pagination with that by doing a
| fields tomillis(@timestamp) as millis
| filter millis < {time_stamp_of_last_returned_log_line}


How to load data into dynamodb table from the reducer of a hadoop job

Question: I was unsuccessful in finding a sample mapreduce job to write data to dynamoDB. Any references.
Answer: If hive is a possible solution for you, you can look here: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/EMR_Hive_Commands.html
It's pretty straight forward if you use tools like PIG and hive - just declare your input table as S3 (or whatever), your output table as a DynamoDB one, and perform INSERT TABLE X SELECT * FROM Y
Comment: Hey found it. There is  a way to upload using dynamodb java API. I have used put request and it worked. Thanks.


MySQL doesn't CSV-import \N as NULL

Question: I'm trying to import a CSV file into a MySQL 5.1 DB using phpMyAdmin. The file includes several date columns which may contain NULL values. According to the manual, NULL should be written as \N. However, after an otherwise successful import, \N appears as 0000-00-00 in the date columns (as opposed to NULL). How do I get NULLs imported?
Options set:

line separator ,
fields enclosed by ",
fields escaped by \,
lines terminated by auto.
Answer: phpMyAdmin distinguishes two CSV import formats: CSV and CSV with LOAD DATA. The latter option actually accepts \N as described in the manual.
If columns are enclosed by a character (as it is the case), NULLs may also be imported using the former method (no LOAD DATA) by setting a value to a non-enclosed NULL in the CSV file. This is in accordance with the manual's following statement:

If FIELDS ENCLOSED BY is not empty, a field containing the literal
  word NULL as its value is read as a NULL value. This differs from the
  word NULL enclosed within FIELDS ENCLOSED BY characters, which is read
  as the string 'NULL'.

MySQL doesn't CSV-import \N as NULL


Como usar o tipo TBitmap32 (Delphi) em uma DLL chamada em C++?

Question: Olá!
Estou precisando criar uma DLL em Delphi, para usá-la em um programa escrito em C++. Esta DLL deve manipular uma imagem (obtida por meio do path passado como parâmetro da função).
No entanto, estou com problemas na etapa de carregar a imagem dentro da DLL; o programa quebra quando há qualquer chamada relacionada à imagem.
Estou usando uma variável do tipo TImage32 (img : TImage32); a essa variável será atribuído um TBitmap32 (img.Bitmap := TBitmap32.Create) e, finalmente, a imagem deve ser carregada usando img.Bitmap.LoadFromFile(path).
Testes que eu fiz:

Executei a DLL, a partir do C++, com partes que não usam imagens. Isso funcionou corretamente;
Executei o mesmo trecho, inserindo a linha img.Bitmap := TBitmap32.Create;. Isso falhou na linha mencionada.

Existe algum truque para usar imagens em DLL no Delphi?
OBS1: eu não postei código, pois não é esse, realmente o problema.
OBS2: a minha experiência com Delphi é nula, bem como com criação de DLL.
Muito obrigado!
Comment: Não deveria ser: "img := TBitmap32.Create;"?
Comment: A princípio não é para ter grandes segredos. Chega a apresentar qual exceção esta acontecendo? Caso não estoure a exceção claramente na sua aplicação em C++ é possível salvar a exceção em um log em arquivo para ter mais detalhes do que esta acontecendo.
Comment: A imagem é um arquivo no teu computador, né? O path está correto? O arquivo está no formato esperado (no caso, Bitmap 32 bits por pixel)? Não sou expert em delphi, mas quando lido com imagens, esses são os erros mais comuns...
Comment: Na tua OBS1 não te estás a precipitar? o mais provavel é ser do codigo... nao há truques nas DLLS. o mais que podia acontecer era diferenças nos tipos de dados de entrada das funçoes. Por exemplo com o C# é mais dificil, em principio com o C++ seria direto
Answer: Pelo visto esta utilizando uma bliblioteca de terceiros, nesse ponto fica complicado ajudar, mas em teoria foi criado com base da TImage padrão.
Se for o caso a criação esta com erro e o problema esta exatamente ai, será gerado uma exceção e sua DLL não possui tratamento.
Tente utilizar o TImage nativo seguindo esse formato:
var
  vTeste: TImage;
begin
  vTeste := TImage.Create(Self);
  vTeste.Picture.Bitmap.LoadFromFile('C:\temp\Teste.bmp');

Aqui funcionou normalmente.
Observe que, primeiro devemos criar o Objeto, depois alimentar suas propriedades. No seu caso postado acredito que o problema seja exatamente este!


Integration trick $\int^{2\pi}_{0} f(a+ r \cos \theta, b+r\sin \theta)d\theta=2\pi f(a,b)$

Question: While looking for some nice integrals that are not taught in school, I found this theorem:

Suppose $f$ is a bivariate harmonic function; $(a,b)$ is a point in the plane; and $r$ is a positive real number. Then,
  $$
\int^{2\pi}_{0} f(a+ r \cos \theta, b+r\sin \theta)d\theta=2\pi f(a,b)
$$

Is there a nice way to prove the theorem above?
Unfortunately I have no idea how to start proving this, but I suspect it's related to Euler's formula since there is an example there that can be solved that way.

Source $\longrightarrow$ Integration Tricks | Brilliant Math & Science Wiki
Comment: I wonder why the Frullani integral was chosen for demonstration of differential "trick".
Answer: Start by writing $f$ as a function of a complex variable in the usual way, so the claimed result is
$$\int_0^{2\pi} d\theta \,f\bigl(z_0+re^{i\theta}\bigr)=2\pi\,f(z_0)$$
with $z_0:=a+ib$. Expand the integrand as a Taylor series, viz.
$$\sum_{n\ge 0}\frac{f^{(n)}(z_0)}{n!}r^n\int_0^{2\pi} d\theta \,e^{in\theta}.$$
The required result follows from $\int_0^{2\pi} d\theta\, e^{in\theta}=2\pi\delta_{n0}$.
Comment: @Zacky $f(u+v)=f(u)+f'(u)v+\cdots$
Comment: I am sorry if it's obvious but could you explain how expanding $$f(z_0+re^{i\theta})$$ gives $$\sum_{n\ge 0}\frac{f^{(n)}(z_0)}{n!} e^{in\theta}$$?
Comment: What is $\delta_{n0}$?
Comment: @ChaseRyanTaylor https://en.wikipedia.org/wiki/Kronecker_delta
Answer: This follows from the Mean Value Theorem for harmonic functions. Let $f\in C^2(\Omega)$ be a harmonic function on some open domain $\Omega\subseteq\mathbb{R}^n$ then
$$f(x_0)=\frac{1}{\text{vol}(B(x_0,r))}\int_{B(x_0,r)}f(x)\,dx=\frac{1}{\text{vol}(\partial B(x_0,r))}\int_{\partial B(x_0,r)}f(x)\,dS$$
for every ball $B(x_0,r)\subseteq \Omega$. Here $\partial B(x_0,r)$ is the sphere centered at $x_0$ with radius $r>0$ and $\,dS$ is the element of integration on $\partial B(x_0,r)$. Using the second formula for $n=2$ we obtain
$$f(x_0)=\frac{1}{2\pi r}\int_{||x-x_0||\leqslant r}f(x)\,dS=\frac{1}{2\pi }\int_0^{2\pi}f(x_0+rw(\theta))\,d\theta$$
where $w(\theta):=(\cos(\theta),\sin(\theta))$. In particular for $x_0:=(a,b)$ you get the desired result.


Proof of $\sum_{n=1}^{\infty}\frac1{n^3}\frac{\sinh\pi n\sqrt2-\sin\pi n\sqrt2}{{\cosh\pi n\sqrt2}-\cos\pi n\sqrt2}=\frac{\pi^3}{18\sqrt2}$

Question: Show that
$$\sum_{n=1}^{\infty}\frac{\sinh\big(\pi n\sqrt2\big)-\sin\big(\pi n\sqrt2\big)}{n^3\Big({\cosh\big(\pi n\sqrt2}\big)-\cos\big(\pi n\sqrt2\big)\Big)}=\frac{\pi^3}{18\sqrt2}$$
I have no hint as to how to even start.
Comment: I think it would be helpful to provide a source for this problem.
Comment: @user64494 I to admire the beauty of it.....
Comment: @Slade I got it playing around with mathematica and the Inverse symbolic calculator.
Comment: What is the argument of $\cosh$ in the denominator?
Comment: @user64494 sorry I have to change
Comment: @Lucian: In its present form, the summand diverges as $n\to 0$ (which was not the case when $n^3$ multiplied only the first term of the denominator.) So either the present demominator isn't valid, or the sum should start at $n=1$. (Irritatingly, WA gives results consistent $\pi^3/18\sqrt{2}\approx 1.218$ for either choice.) A source would settle the matter.
Comment: @Semiclassical: Fixed ! As it stands now, the series definitely converges towards the given value.
Answer:
It is a simple trigonometric exercise to show that
$$\frac{\sinh\pi n\sqrt2 -\sin\pi n\sqrt2}{\cosh\pi n\sqrt2 -\cos\pi n\sqrt2}=
\Re \left(\coth \pi n z_0+z_0^2\coth\frac{\pi n}{z_0}\right),\tag{$\spadesuit$}$$
with $z_0=e^{i\pi/4}$.
Recall the Ramanujan identity (several nice proofs of which may be found here):
$$\sum_{n=1}^{\infty}\frac{1}{n^3}\left(\coth \pi n x+x^2\coth\frac{\pi n}{x}\right)=
\frac{\pi^3}{90x}\left(x^4+5x^2+1\right).\tag{$\heartsuit$}$$
Combining ($\spadesuit$) and ($\heartsuit$), we immediately get
$$\sum_{n=1}^{\infty}\frac1{n^3}\left(\frac{\sinh\pi n\sqrt2 -\sin\pi n\sqrt2}{\cosh\pi n\sqrt2 -\cos\pi n\sqrt2}\right)=\frac{\pi^3}{90}\,\Re\frac{z_0^4+5z_0^2+1}{z_0}=\frac{\pi^3}{18\sqrt2}.$$
Comment: @Semiclassical It was obvious - the OP is a huge fan of Ramanujan ;)
Comment: You elucidated the mystery by pointing towards an enigma and showing that the two are the same.
Comment: Did not see the connection to the Ramanujan problem coming! Very nice.
Comment: True. I had been looking for a connection between this identity and solutions of some BVP. (For instance, the summands are linked with the dfn of bipolar coordinates.)
Comment: +1 for using my passions as a hint for such a beautiful proof... True I am a great fan of ramanujan :)
Answer: This simple and elegant solution relies on two results from Closed form for $\sum_{n=-\infty}^{\infty}\frac{1}{(n-a)^2+b^2}$. and/or from Closed form for $\sum_{n=-\infty}^{\infty} \frac{1}{n^4+a^4}$.
both of which are derived from the well known Mittag-Leffler expansion of hyperbolic cotangent function (denote $\mathbb{W}=\mathbb{Z}/\{0\}$) :

$$\sum_{n\in\mathbb{W}}\frac{1}{n^2+z^2}=\frac{\pi\coth\pi z}{z}-\frac{1}{z^2}$$

valid for every complex $z$ exept the poles. The two later results from the links are in $\mathbb{W}$ formalism :
$$\begin{align}&\sum_{m\in\mathbb{W}}\frac{1}{(m-a)^2+b^2}=\frac{\pi\mathbin{\color{blue}{\sinh2\pi b}}}{b\left(\cosh2\pi b-\cos2\pi a\right)}-\frac{1}{a^2+b^2}\tag{$\varphi$}\\ \\
&\sum_{m\in\mathbb{W}} \frac{1}{m^4+c^4} = \frac{\pi}{\sqrt{2} \, c^3} \frac{\mathbin{\color{green}{\sinh\left(\sqrt{2} \pi c\right)+\sin\left(\sqrt{2} \pi c\right)}}}{\cosh\left(\sqrt{2} \pi c\right) -\cos\left(\sqrt{2} \pi c\right)}-\frac{1}{c^4}\tag{$\nu$}\end{align}$$
from these two formulae we are able by some simple manipulations obtain the sum $S$, for which we have:
$$S=\frac{1}{2}\sum_{n\in\mathbb{W}}\frac{1}{n^3}\frac{\mathbin{\color{red}{\sinh\left(\sqrt{2} \pi n\right)-\sin\left(\sqrt{2} \pi n\right)}}}{\cosh\left(\sqrt{2} \pi n\right) -\cos\left(\sqrt{2} \pi n\right)}$$
Note that
$$\mathbin{\color{red}{\sinh\left(\sqrt{2} \pi n\right)-\sin\left(\sqrt{2} \pi n\right)}}=2\mathbin{\color{blue}{\sinh\left(\sqrt{2} \pi n\right)}}-\left[\mathbin{\color{green}{\sinh\left(\sqrt{2} \pi n\right)+\sin\left(\sqrt{2} \pi n\right)}}\right]$$
i.e., this suggest using $2\varphi-\nu$. Choosing $a=b=n/\sqrt2$ in $\varphi$ and $c=n$ in $\nu$ we have for our sum:
$$\begin{align}
S &=\frac{1}{2\pi\sqrt{2}}\sum_{n\in\mathbb{W}}\frac{2}{n^3}\left(\frac{1}{n}+\sum_{m\in\mathbb{W}}\frac{1}{(m-n/\sqrt2)^2+n^2/2}\right)-\frac{1}{n^3}\left(\frac{2}{n}+\sum_{m\in\mathbb{W}}\frac{2n^3}{m^4+n^4}\right)\\ \\
&=\frac{1}{\pi\sqrt{2}}\sum_{n,m\in\mathbb{W}^2}\frac{1}{n^2}\frac{1}{m^2-mn\sqrt{2}+n^2}-\frac{1}{m^4+n^4}\tag{1} \\ \\
&=\frac{1}{\pi\sqrt{2}}\sum_{n,m\in\mathbb{W}^2}\frac{1}{n^2}\frac{m^2+n^2}{m^4+n^4}-\frac{1}{m^4+n^4}\tag{2} \\ \\
&=\frac{1}{\pi\sqrt{2}}\sum_{n,m\in\mathbb{W}^2}\frac{m^2}{n^2}\frac{m^2}{m^4+n^4}\tag{3}\\ \\
&=\frac{1}{\pi\sqrt{2}}\sum_{n,m\in\mathbb{W}^2}\frac{1}{2}\left(\frac{m^2}{n^2}+\frac{n^2}{m^2}\right)\frac{1}{m^4+n^4}\tag{4}\\
&=\frac{1}{2\pi\sqrt{2}}\sum_{n,m\in\mathbb{W}^2}\frac{1}{m^2n^2}=\frac{1}{2\pi\sqrt{2}}\left(\sum_{n\in\mathbb{W}}\frac{1}{n^2}\right)^2=\frac{2}{\pi\sqrt{2}}\zeta^2(2)=\frac{\pi^2}{18\sqrt2}\tag{5}
\end{align}$$
Explanations:
$(1)$ terms $2/n^4$ cancel each other; $(m-n/\sqrt2)^2+n^2/2=m^2-mn\sqrt{2}+n^2$
$(2)$ on the summation domain, lattice $(n,m)\in \mathbb{W}\times\mathbb{W}$ there is a symmetry $\sum_{n,m}=\sum_{-n,m}$, ergo by taking "average" $\sum_{n,m\in\mathbb{W}^2}\frac{1}{n^2}\frac{1}{m^2-mn\sqrt{2}+n^2}\!=\!\frac{1}{2}\!\sum_{n,m\in\mathbb{W}^2}\frac{1}{n^2}\left(\frac{1}{m^2-mn\sqrt{2}+n^2}+\frac{1}{m^2+mn\sqrt{2}+n^2}\right)$
$(3)$ uncomfortable terms $1/(n^4+m^4)$ cancels too
$(4)$ another symmetry = changing order of summation $n\longleftrightarrow m$
$(5)$ also $\zeta(2)=\sum_{n=1}^{\infty}1/n^2=\pi^2/6$
Comment: By the same argument [$\sum_{n = 1}^{\infty}\{\coth (n\pi x) + x^{2}\coth(n\pi/x)\}/n^{3}$](http://math.stackexchange.com/a/1867499/240067) is found in closed form
Comment: Machinto, I'm quite wondering if we can generalize your answer for $n^{4m+3}$ in the denominator?


How extract private static constant in Intellij Idea?

Question: To extract constant I can use ctrl + alt + c, that "extraction" create public constant:
public static final String CONST = "123";

So I need manually type private. Is there a way to extract constant with private scope by default?
Answer: Hit ctrl+alt+c twice (shows Extract Constant dialog)
hit alt+v (set default Visibility to Private)
hit enter
Done :)  The private scope is set default - so you can use constant extraction as before, to change default scope simply repeat steps above with choosing different scope.
Comment: I use Intellij Idea Community Edition 12.1.4,  so "ctlr + shift + e" do not show Extract Constatnc dialog for me. Is it version problem?
Comment: My mistake - putted shift+e instead alt+c (that copy pasting in early morning):))
Comment: Remember to hit it twice:)
Comment: Yeee! this is what I really want 8)
Comment: At current time I have no shortcut allocated to extracting constants (only "refactor this" where I then can choose what I want to do). Is there a possibility to show this dialog on another way? Just curious. Your answer still helped me, thanks :)
Comment: @BAERUS in `Settings` -> `Keymap` look for `Main menu`/`Refactor`/`Extract`/`Constant`, right click or enter to reveal the contextual menu that allows to `Add Keyboard Shortcut` and set it to `CTRL+ALT+C`. The default extraction shortcuts (for IntelliJ IDEA on Windows) are: `Variable: CTRL+ALT+V`, `Constant: CTRL+ALT+C`, `Field: CTRL+ALT+F`, `Parameter: CTRL+ALT+P`,
Comment: @BAERUS or if you don't want to set the keyboard shortcuts, you can always do (while the cursor is on the value you want to extract) `CTRL+SHIFT+A` and start typing `Constant` (or `Variable` or `Field` or `Parameter`) and the menu should show the corresponding action (which is under `Refactor | Extract`). This method requires more typing but can still save you some time.
Answer: Try this:

If the Enable in place refactorings check box is cleared on the Editor
  settings, the Extract Constant refactoring is performed by means of
  the Extract Constant Dialog dialog box.

http://www.jetbrains.com/idea/webhelp/extract-constant.html
Extract Constant Dialog allows choose the appropriate scope of constant
Settings -> Editors -> Enable Place refactoring


Como criar um componente React de select que no evento de bind "change" pegue o valor certo que foi selecionado?

Question: Boa noite!
Estou tentando fazer um componente de select que seja usado mais de uma vez dentro de outro componente Pai.
Para criar as tags "option", eu faço um map dentro do array que criei como um state da classe Pai/App.
Até aí funciona bem. Porém, quando eu seleciono uma opção, ele entende que mudei o state que estava definido para um array, como um único valor que no caso seria o valor que eu selecionei.
Segue código:
import React, { Component } from 'react';
import './App.css';

class App extends Component {

  constructor (props) {
    super(props)
    this.state = {
      value: '?',
      //list
      typeOfSearch: [
        {
          value: 'animated',
          name: 'animated'
        },
        {
          value: 'debuts',
          name: 'debuts'
        },
        {
          value: 'playoffs',
          name: 'playoffs'
        },
        {
          value: 'teams',
          name: 'teams'
        }
      ],
      //timeframe
      period: [
        {
          value: 'week',
          name: 'week'
        },
        {
          value: 'month',
          name: 'month'
        },
        {
          value: 'year',
          name: 'year'
        },
        {
          value: 'ever',
          name: 'ever'
        }
      ],
      //timeframe
      amountResults: [
        {
          value: '10',
          name: '10'
        },
        {
          value: '20',
          name: '20'
        },
        {
          value: '30',
          name: '30'
        },
      ],
    }
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(event) {

    const target = event.target;
    const value = target.value;
    const name = target.name;

    this.setState({
        [name]: value,
    });

    console.log(event.target.value);
  }

  render() {

    const createItem = (item, key) => <option key = {key} value = {item.value}>
     {item.name} </option>;

    return (

        <SelectFilter handleChange={this.handleChange} value={this.state.value} name="typeOfSearch">
            {this.state.typeOfSearch.map(createItem)}
          </SelectFilter>

          <SelectFilter handleChange={this.handleChange} value={this.state.value} name="period">
            {this.state.period.map(createItem)}
          </SelectFilter>

          <SelectFilter handleChange={this.handleChange} value={this.state.value} name="amountResults">
            {this.state.amountResults.map(createItem)}
          </SelectFilter>

    );
  }
}

class SelectFilter extends Component {
  render(){

    return (<select onChange={this.props.handleChange} value={this.props.value} name= {this.props.name}>
              {this.props.children}
            </select>)
        }
}

export default App;

Agradeço muito qualquer ajuda!
Answer: Estás quase lá, o problema é que estás a sobre escrever o array quando devias setar o value. Na prática o código que tens cria isto:
this.setState({
    typeOfSearch: 'debuts'
});

e isso não é o que queres pois typeOfSearch é uma array.
Sugestão:

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      values: {},
      //list
      typeOfSearch: [
        {
          value: "animated",
          name: "animated"
        },
        {
          value: "debuts",
          name: "debuts"
        },
        {
          value: "playoffs",
          name: "playoffs"
        },
        {
          value: "teams",
          name: "teams"
        }
      ],
      //timeframe
      period: [
        {
          value: "week",
          name: "week"
        },
        {
          value: "month",
          name: "month"
        },
        {
          value: "year",
          name: "year"
        },
        {
          value: "ever",
          name: "ever"
        }
      ],
      //timeframe
      amountResults: [
        {
          value: "10",
          name: "10"
        },
        {
          value: "20",
          name: "20"
        },
        {
          value: "30",
          name: "30"
        }
      ]
    };
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(name, value) {
    this.setState(
      {
        values: {
          ...this.state.values,
          [name]: value
        }
      },
      () => console.log("Novos valores:", this.state.values)
    );
  }

  render() {
    const createItem = (item, key) =>
      <option key={key} value={item.value}>
        {item.name}
        {" "}
      </option>;

    const selects = ["typeOfSearch", "period", "amountResults"].map(name => {
      return (
        <SelectFilter
          handleChange={e => this.handleChange(name, e.target.value)}
          key={name}
          value={this.state.values[name]}
          name="typeOfSearch"
        >
          {this.state[name].map(createItem)}
        </SelectFilter>
      );
    });
    return
{selects}
;
  }
}

class SelectFilter extends React.Component {
  render() {
    return (
      <select
        onChange={this.props.handleChange}
        value={this.props.value}
        name={this.props.name}
      >
        {this.props.children}
      </select>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("container"));

Comment: ficou ótimo! Vou debugar o código com calma para entender melhor o que vc fez. Muito obrigada pela sua ajuda mais uma vez. ;)
Comment: Olá Sérgio! Você sempre o salvador da pátria. Obrigada pelo seu retorno. O problema é que dessa forma, se instancio os 3 selects, ao selecionar um, o outro volta para o primeiro valor, como se o mesmo value que passo para um select, fosse replicado para os 3. Eu queria mudar o select que foi selecionado, sem alterar o valor dos outros 2.
Comment: No método `handleChange`, fiz um switch usando a propriedade "name" de cada select. Criei 3 states vazios, sendo um para cada tipo de propriedade, e 3 cases mudando o valor de cada state: `handleChange(event) {
    switch (event.target.name) {
      case "typeOfSearch":
        this.setState({
            typeOfSearchSelected: event.target.value,
        });
        break;  `  Acho que não ficou muito elegante, mas funcionou.
Comment: @AlineVianna não tinha reparado que estavas a ter 1 state para 3 selects... isso não é boa ideia :) Juntei uma sugestão com um exemplo. Dá uma olhada :)


Prove that there is a plane in $\mathbb{R}^n$ with the following property

Question: Let $X \subset \mathbb{R}^n$ be a union of countably many affine subspaces of $\mathbb{R}^n$ with dimension less or equal $n-2$.

Prove that $\mathbb{R}^n \setminus X$ is path connected.

Assume $n = 2$. Then we need to show, that the plane with countably many points removed is path connected.
Take $x_1, x_2 \in \mathbb{R}^2 \setminus X$. We find two nonparallel lines in $\mathbb{R}^2$ going through $x_1$ and $x_2$ which do not cross $X$. It can be done because the cardinality of the set of all lines through $x_i$ is $|\mathbb{R}|$ and the cardinality of $X$ is just $|\mathbb{N}|$. These two lines intersect at some point and we get a path between $x_1$ and $x_2$ in $\mathbb{R}^2 \setminus X$.
Now I want to reduce the initial problem to the case with $n=2$. In order to do so I need to

prove that for any two points $x_1$ and $x_2$ in $\mathbb{R}^n \setminus X$ there is a plane in $\mathbb{R}^n$ containing both these points and intersecting $X$ in at most countably many points.

How can I do that?
Comment: @JeanMarie True. Sorry.
Comment: Maybe some measure theory? There's a map from $S^{n-2}$ to the set of hyperplanes joining $x_1$ and $x_2$, I think. If the set of all the "bad" hyperplanes corresponds to a measure-zero set in $S^{n-2}$, then there must be a "good" hyperplane.
Comment: @AkivaWeinberger I understand how it should work. When $n = 3$, then we can rotate the plane containing $x_1$ and $x_2$ only around the line connecting these points. Then we have $|\mathbb{R}|$ different positions for the plane and again only $|\mathbb{N}|$ of them are "bad".  However when $n > 3$ we can rotate the plane in many different directions and it is hard to understand which positions of the plane are "bad". It looks like for $n=4$, bad positions are represented by finitely many lines on the unit sphere. How can I do it more or less formally?
Comment: @Akiva Weinberger You speak about "bad hyperplanes" but here it is "bad $n-2$ dimensional spaces".
Comment: In the case $n=2$ there are lines $l_1$ and $l_2$ thru $x_1,x_2,$ respectively, that are not parallel, and that are not subsets of $X$. But  that does not imply that $l_1$ and $l_2$ are disjoint from $X$, so it does not follow that the union of the line-segments $ x_1p $ and $px_1$ (where $\{p\}=l_1\cap l_2$) is disjoint from $X.$
Comment: @user254665 That is not the argument the OP made.
Answer: As is suggested in the comments it is possible to do what you are suggesting, but it will require some measure theory.
In particular you have a $\mathbb{P}^{n-2}(\mathbb{R})$ worth of planes through $x_1$ and $x_2$. For any dimension $d \le n-2$ subspace $V$ of $\mathbb{R}^n$ those planes through $x_1$ and $x_2$ that intersect $V$ in a line cut out a subvariety of $\mathbb{P}^{n-2}(\mathbb{R})$ of strictly smaller dimension (cut out by some determinants vanishing) and in particular this has measure zero.  The countable union of measure zero sets has measure zero so in particular we can find a plane through $x_1$ and $x_2$ that meets all the subspaces in $X$ in dimension at most 1, as desired.
I'll note that if you want to avoid measure theory and just use facts about cardinality you can still solve the overall problem, but by a slightly different strategy.
Note that for each dimension $n-2$ subspace $V$ in $X$ there is exactly $1$ hyperplane containing $V$ and $x_1$ (and the same for $x_2$).  In particular for cardinality reasons we can find nonparallel hyperplanes through $x_1$ and $x_2$ that meet all the subspaces in $X$ in dimension at most $n-3$.
But now we can apply induction to get that the complement of $X$ in each hyperplane is path connected.  So to make a path from $x_1$ to $x_2$ we can just find a path from $x_1$ to some point in the intersection of these two hyperplanes, and then a path from that to $x_2$
Answer: Let $\{ A_k \}_{k = 1}^\infty$ be affine subspaces of $\mathbb{R}^n$ of dimension $n-2$, and take distinct points $x, y \in \mathbb{R}^n$. Translating, one can assume $x = 0$ and $0 \notin A_k \forall k \in \mathbb{N}$.
There is a homeomorphism $\Phi: \mathcal{G} \rightarrow  \mathbb{P}^{n-2} ( \mathbb{R} )$ where $\mathcal{G}$ is the space of $n-2$ dimensional affine spaces intersecting $\mathbb{R}y$. We construct this map as follows. Let $U  = \mathbb{R} y$ and $V = U^{\perp}$. $V$ is an $n-1$ dimensional vector space. Take an $n-2$ dimensional vector space $W$ containing $y$. $W$ is uniquely determined by $W \cap V$, since $W = W \cap (V \oplus U) = (W \cap V ) \oplus (W \cap U) = (W \cap V) \oplus U$. There is a vector space isomorphism $T : V \rightarrow \mathbb{R}^{n-1}$. $T(W \cap V)$ is then a subspace of $\mathbb{R}^{n-1}$. Obviously
\begin{align*} dim_{\mathbb{R}}(T(W \cap V)) = dim_{\mathbb{R}}( W \cap V) = dim_{\mathbb{R}} ( W ) - dim_{\mathbb{R}} ( U ) = n - 2
\end{align*}
Thus $T(W \cap V)^{\perp}$ is a line through the origin of $\mathbb{R}^{n-1}$. Define $\Phi (W) = T(W \cap V)^{\perp}$.
The following is rather straightforward, so I leave it as an exercise:
Exercise: For each $k \in \mathbb{Z}$ the set $\mathcal{G}_k = \{ z \in \mathbb{P}^2 ( \mathbb{R} ) : |\Phi^{-1}(z) \cap A_k| \leq 1 \} $ is open and dense in $\mathbb{P}^2 (\mathbb{R})$.
The claim follows therefore from the following lemma:
Lemma: Baire Category Theorem Let $\mathcal{X}$ be a locally compact Hausdorff space and take dense open sets $\{ U_i \}_{i = 1}^\infty$ in $\mathcal{X}$. Then $\cap_{i = 1}^\infty U_i$ is dense in $\mathcal{X}$.
Spaces with this property are called Baire spaces- spaces in which the intersection of countably many dense sets are dense. See here: https://en.wikipedia.org/wiki/Baire_space

Edit: here is an elaboration on how to finish the proof from the lemma, as requested: from the exercise we know that $\mathcal{G}_k$ are open and dense in $\mathbb{P}^2 (\mathbb{R})$. Since $\mathbb{P}^2 ( \mathbb{R} )$ is compact and Hausdorff, $\mathcal{H} = \cap_{i = 1}^\infty \mathcal{G}_k$ is dense by the Baire Category Theorem. But this is much stronger than we need. The upshot is that $\mathcal{H}$ is nonempty. Take $z \in \mathcal{H}$. Then $|\Phi^{-1} (z) \cap A_k| \leq 1 \forall k \in \mathbb{N}_{\geq 1}$, so that $\left|\Phi^{-1} (z) \cap \bigcup_{k \in \mathbb{N}_{\geq 0}} A_k \right|$ is countable. $\Phi^{-1} (z)$ is therefore the desired plane.
Comment: Could you please explain how "The claim follows therefore from the following lemma"?
Comment: Ok. I made some edits.
Answer: Proof for $\mathbb R^3:$ Suppose $L_1,L_2, \dots$ are lines in $\mathbb R^3.$ Assume $p,q\in \mathbb R^3 \setminus (\cup L_k).$ WLOG, we can take $p=(0,0,1),q=(0,0,-1).$
For each $m>0$ let $P_m$ denote the plane spanned by $p$ and $(1,m,0).$ Let $S$ be the unit sphere, and define the unit circle $C_m = P_m\cap S.$ Now each $L_k$ can intersect $S$ in at most two points. It follows that $\cup L_k$ can intersect only countably many $C_m.$ But there are uncountably many $C_m.$ Thus there must exist $m$ such that $(\cup L_k)\cap C_m= \emptyset$ (in fact there are uncountably many such $m$).  For any such $m$ we have an entire circle $C_m$ connecting $p$ to $q$ within $\mathbb R^3 \setminus (\cup L_k).$


Boundary of convex set is piecewise $C^1$

Question: Let $K$ be a convex and compact subset of $\mathbb{R}^2$. Is it true that the boundary of $K$ can be parameterized by a piecewise $C^{1}$ application $\gamma :I\to\mathbb{R}^2$?
Answer: No, this is not true. In fact, the set of corners can be dense on the boundary.
Here is a simple example that the boundary is not piecewise $C^1$:
Define $C$ to be the closed convex hull of the points
$$
x_n = (\cos(1/n), \sin(1/n), \ n\in \mathbb N,
$$
$(-1,0)$, $(-1,0)$, and  $(0,1)$. Then $C$ is compact and convex. But does not have piecewise smooth boundary near $(1,0)$.
Answer: Another example is to look at Julia sets, and take convex hulls of these. You can easily end up with a situation where the boundary has countably many corners, and thus accumulation points of corners.