Proof verification: $\mathbb{E}[X] = \int_0^\infty P(X > \alpha) d\alpha$

Question: I want to show that given a probabilty density $P: \mathbb R^+ \rightarrow [0, 1]$, its expectation obeys the identity: $\mathbb{E}[X] = \int_0^\infty P(X > \alpha) d\alpha$.

We assume that the density $P$ is defined on $[0, u]$. We will get the final version by setting $u \rightarrow \infty$ (nit 1)
Begin by defining the cumulative density $C(x) = \int_0^x P(\alpha) d\alpha$.
$C'(x) = P(x) - P(0)$ from fundamental theorem of calculus. We need to assume that $P(0) = 0$ so that $C'(x) = P(x)$.  (nit 2).
This gives us $dC(x) = P(x)$.

Now compute expectation:
\begin{align*}
&\mathbb E[X] = \int_0^u xP(x)dx  \quad [UdV]\\
&\left[ \text{use product rule: }\int U dV = UV - \int V dU \right] \\
&= [xC(x)]_0^u - \int_0^u C(x) \cdot 1 dx \\
&= uC(u) -  \int_0^u C(x)dx \\
&\text{[$C(u) = 1$ since $u$ was upper bound of distribution]} \\
&= u - \int_{0}^uC(x) dx \\
&= \int_0^u 1 dx  - \int_{0}^uC(x) dx \\
&= \int_0^u [1 - C(x)] dx \\
&= \int_0^u [1 - P(X \leq x)] dx \\
&= \int_0^u P(X > x) dx \\
\blacksquare
\end{align*}
Set $u \rightarrow \infty$ to get the final desired expression.
Is this proof watertight? I'm nervous about (i) first proving it for finite $u$ and then setting the limit; (ii) The assumption that $P(0) = 0$. I believe (i) is all right since that's the definition of integral with limit infinity. As for (ii), I believe this is also okay since we are assuming something about the distribution over a set of measure zero (a single point $0$). Still, I'm nervous, so a proof verification would be very appreicated.
Comment: Using the notation $P$ to mean both the underlying probability measure and the density of $X$ is confusing and should be avoided.
Comment: If you restrict $P$ on $[0,u]$, $P$ is not a density anymore, and $C(u) \neq 1$
Comment: **If** the probability density fct is continuous, the cumulated probability fct vanishes if we consider only a single point. Without stating this assumption, you probably assume it. Therefore, the $P(0)=0$ is fine, because the density fct must be finite.
Comment: Perhaps I stated this incorrectly. What I mean is that $P$ on has support on $[0, u]$. We then recover the original statement by setting $u \rightarrow \infty$
Comment: this is false $\mathbb E[X] = \int_0^u xP(x)dx$ if $u\neq \infty $
Comment: @Masacroso Can you provide an example? I claim that if $u$ is the largest value in $support(P(x))$, then $\mathbb{E}[X] = \int_0^u P(x) dx$. Was this unclear from the question?
Answer: You can fix your proof just noticing that
$$
\int_{0}^\infty tf_X(t) \mathop{}\!d t=\lim_{n\to\infty}\int_{0}^n tf_X(t) \mathop{}\!d t
$$
from the monotone convergence theorem. Hence, following your work, you get that
$$
\mathrm{E}[X]=\lim_{n\to\infty}\int_{0}^n(F_X(n)-F_X(t))\mathop{}\!d t=\int_{0}^\infty (1-F_X(t))\mathop{}\!d t
$$
where we had used again the monotone convergence theorem as $\mathbf{1}_{[0,n]}(t)(F_X(n)-F_X(t))$ increases to $1-F_X(t)$ as $n\to\infty $.
Comment: @SiddharthBhat you cannot assume that the domain of $f_X$ is $[0,u]$ as you did
Comment: @SiddharthBhat the domain is $[0,\infty )$, it is not a limit, a domain is a set. We only had used the monotone convergence theorem twice. Im assuming you knows a bit of measure theory, the first identity in my answer can also be rewritten as $$\int_{[0,\infty )}tf_X(t) \mathop{}\!d t=\lim_{n\to\infty}\int_{[0,\infty )}\mathbf{1}_{[0,n]}(t)t f_X(t) \mathop{}\!d t$$ Thus we are exploiting the fact that $\mathbf{1}_{[0,n]}(t)t f_X(t)$ increases to $tf_X(t)$ (as $n\to \infty $)
Comment: @SiddharthBhat I dont know how to put the dominated convergence theorem here, because to use it you almost need to use the fact that you want to prove prior to be proved. It is very strange that you knows the dominated convergence theorem and you dont knows measure theory. In any case in this exercise you can use the improper integral of Riemann instead of the Lebesgue integral if you wish, both coincide and are equal, so where I had put $\int_{[0,\infty )}$ in my previous comment you can put $\int_0 ^\infty $ and assume that the integral is an improper integral of Riemann
Comment: Can you please expand your answer to tell me where the proof is _wrong_? I don't precisely understand what step of the proof is incorrect.
Comment: So the resolution is to assume the domain is $\lim_{u \rightarrow \infty} [0, u]$?
Comment: I sadly do not know measure theory, so I don't really understand what is broken in my proof, and how this fixes it. My understanding is that I had $\int_[0, u) xP(x)$ which will not necessarily be equal to $\mathbb{E[}X]$. So, I have to evaluate $\int_[0, \infty] x P(x) dx$. Do do this, I need to use dominated convergence?


Show that $1$ is not a linear combination of $x^2+1$ and $x^2+4$ in $\mathbb Z[x]$?

Question: Is this possible? I used this as an example to show that there is a UFD $R$ where $2$ elements $a$ and $b$ are coprime but there may not be $r$, $s$ in $R$ such that $ra + sb = 1$. I know that $2$ and $x$ is one example (but I didn't come up with that during my exam).
Comment: If $1$ is a linear combination of $x^2+1$ and $x^2+4$, then $1$ is also a linear combination of $x^2+1$ and $3$. Going mod 3, is $x^2+1$ a unit in $\mathbb{Z}/3\mathbb{Z}[x]$?
Comment: **Or** instead of reducing mod $3$ (as in prior comment) we could instead reduce mod $x^2+1$ to reach the contradiction that $\,3\mid 1\,$ in $\,\Bbb Z[i]\cong \Bbb Z[x]/(x^2+1) = $ Gaussian integers.
Comment: **Or** combine the above two comments using [quotient reciprocity](https://math.stackexchange.com/a/1214702/242) to get

$$\Bbb Z[i]/3 \,\cong\, \Bbb Z[x]/(3,x^2+1) \,\cong\, \Bbb Z_3[x]/(x^2+1)\qquad\qquad$$  so $\,(x^2+4,x^2+1) = (3,x^2+1)\neq (1)\,$ by LHS (or RHS) ring above is not the zero ring.
Comment: Thank you all! I get it now! I'll probably get points docked for not enough justification for my claim but at least now I know I didn't make any false claims.
Answer: The linear combinations of $x^2+1$ and $x^2+4$ are the same as those of $x^2+1$ and 3 (in both cases with coefficients in $\mathbb Z[x]$ - this detail is missing in the OP but it seems clear that this is what is meant) ... in other words the two pairs generate the same ideal of $\mathbb Z[x]$. (It seems also clear that $x$ is an indeterminate here - it seems to me more usual to use a capital $X$ instead.) Now in a relationship like $PA+QB=1$ one can take values at any element in any commutative associative algebra with unit over the base ring (here $\mathbb Z$) - in this case this means an element of any commutative ring. Take the imaginary unit $i$ in the ring $\mathbb Z[i]$ of Gaussian integers mentioned in a comment above. We get $P(i)A(i)+Q(i)B(i)=1$ and in case that $A=x^2+1$ and $B=3$ it follows from $A(i)=0$ that $3 Q(i) = 1$. But values of polynomials are in the considered algebra, i.e. here in the ring of Gaussian integers and we get $3(a+bi)=1$ with $a, b$ ordinary integers, which is clearly impossible.


Analysis: How to determine what scale/mode a score uses

Question: I'm learning music theory with the hopes of being able to analyze sheet music.
My question is -- What if the piece I am analyzing is in some other mode than major or minor? Or even stranger, like double harmonic major.. etc..
How do I look at a piece of music and figure out what scale it's using, if it's not major or minor, is what I'm getting at.
Comment: Any piece that uses the double harmonic scale is probably not modal.
Answer: Keep in mind you could have a piece of music with sections that switch between modal and major/minor harmony. But let's assume the music is consistently one way or the other.
The seventh scale degree is critical to understanding modal versus major/minor. Let's dig into that idea starting with major/minor music.
The ending of a piece of music is traditionally where you will get confirmation of a major/minor work's key. If the music ends with a traditional cadence, it's using the major/minor system and not modal.
You can continue examining cadences within the music. Pieces in major/minor will have various internal cadences marking the end of sections. Again, if you find traditional cadences, it isn't modal.
The defining feature of "traditional" cadences is the appearance of the leading tone scale degree. That is the seventh degree of the scale which is one half step below the tonic. The leading tone will appear in cadences as either I to V with the leading tone going up to the tonic, or as a phrase ending on V where the leading tone will be present in the V chord.
When we look at all the modes except Lydian - Dorian, Phrygian, Mixolydian, Aeolian, and Locrian - the seventh scale degree is a whole step below the tonic. By the definition above these seventh scales degrees are not leading tones. Instead we can call them subtonics. Let's skip over Lydian for the rest of this, because it complicates things in a way that I don't think will help you right now.
When looking at modal music we should see the subtonic instead of the leading tone in melody or harmony.
For example, we might see melodies ending C to D in D Dorian rather than C# to D which would be used in D minor.
Instead of seeing chords like V to i we might see (minor triad) v to i in Aeolian or (minor triad) v to I in Mixolydian. In major/minor the chord of the leading tone - a diminished triad - might be seen like viio6 to i. But in modal style the chord of the seventh degree is not a diminished chord. It often will be a major triad like VII to i in Dorian or Aeolian.
I just used a bunch of musical terms that may be unfamiliar to you. You will eventually learn them as you study the modes. But one important thing to look for, one idea to simplify the topic, is checking the seventh scale degree. In modal music it is usually a whole step below the tonic.
Regarding scales like double harmonic or freygish those should be pretty straight forward to identify, because the tones in such scales are not diatonic. In such exotic scales the seventh degree may be a half step below the tonic - that would look like the leading tone described above - but the non-diatonic nature of the scales will probably involve accompaniment with chords different than the major/minor system. It's hard to make a simple generalization. But the exotic scale should stand out as not diatonic and therefore not belonging to the major/minor system.
Comment: Thing is, quite a lot of music does not use traditional cadences, yet they still do not stick strictly to any one mode. For example, "You Will Know Our Names" from *Xenoblade Chronicles* contains v-isus4-I cadences and uses B flat, B natural, C, D flat, and D natural (i.e. it does not use any one mode alone). I generally think of that theme as being primarily in B flat minor with Phrygian implications and a tendency to emphasize D flat major.
Comment: Yes, I'm mostly striking the contrast between something like a Bach violin partita and a folk music reel. It's a starting point to develop an understanding.
Answer: Music of 20th century and later that is not in major or minor at first sight is probably composed in no traditional key or scale. So you have to analyse the notes and chords and may say something about the construction of these scales. eg. Bartok or 12 tone music. Often there no alternative than a statistical approach, also in early music.
You can tell what tones are current, what chords - if there are at all - you can identify and you can tell something about the voicing (homophone or counterpoint) and instrumentation. But when there are no keys and no scales to identify (like the key signs and the last tone) it is difficult to say more.
Answer: Trick:
have a first look at the ending of the piece. Most (not all) pieces end on their basic key.
Study:
I)
Start out learning the traditional notation system with Major/minor keys and its sharps and flats. Use the "circle of fifth" for example. Its easier to figure out a special mode then, when it is not fitting into the classical system.
IIa)
Modes are important, too. Check out the seven modes for each traditional (major or natural minor)scale:
ionian, dorian, phyrygian, lydian, mixolydian, aeolian, locrian
IIb)
Do the same with melodic minor and harmonic minor. The naming can be weird sometimes, but you will get it after a while. Good books relate these to the traditional system like "ionian#5" etc. Keep in mind that these names only try to give a sound a name. Hear the differences and check out the important notes which make the difference in each mode!!
III)
What helped me a lot is looking for additional sharpening of particular notes in a score for checking out the raised seventh in a minor key. Say you have a d minor piece with one flat at the beginning of each stave. You will find a c# somewhere in the score telling you that its probable not being F major which also has one flat at the beginning of each stave.
Make a list of raised seventh notes (lead note to the root) in every minor and major key.
IV)
Modern and avantgarde pieces do not have these general key signing and the individual notes are raised(#) or flattened(b) when they occur, as tonal centers can change after some bars etc. Here you combine all your experience on analyzing tonalities in a particular musical situation.
To say the least: It´s a musical journey. Composers like to give musical pieces a certain looseness of key sometimes, too, and like to change (modulate) to another key or use no key at all, see Neue Musik for example...


Reorder Content Types in ("/node/add")?

Question: In drupal 7 it can be do like this. 7 - Reorder Content Types in ("/node/add") - Drupal Answers
How can I reorder Content Types with Drupal 8?
Answer: Drupal 8 doesn't respect the menu structure anymore when displaying the node types. Node types have no weight concept, so there is no direct way to control this.
What you could do is to implement a template/preprocess for node_add_list/node-add-list.html.twig and then reorder the types in code.
Answer: There is a good solution in contrib (Drupal 7 and modern Drupal) that makes it easy again, providing a separate menu to power a replacement "Add content" page:
https://www.drupal.org/project/custom_add_content
(Glad i found that module as i was about to make the equivalent, since it was my fault it got difficult— i reported the bug that disconnected the menu from the page!)
Another really great Drupal 8 option is the Type Tray module:
https://www.drupal.org/project/type_tray
which vastly enhances the Content Add page.
Answer: Install the Admin Toolbar module. The Navigation menu is combined with the Administration menu; you can edit the Administration menu and change the order.
Comment: I can't find `Add content` in Administration menu.
Comment: @snize , Go to the menu section and edit the first menu Administration,
All admin menu items are appear in it. then you can reorder it.
Comment: Please install  "Admin Toolbar" (https://www.drupal.org/project/admin_toolbar) module and follow above steps.
Comment: @Karuna Just tried above thing. It just changes the order of menu. But it does not affect the order on /node/add page.

Reorder Content Types in ("/node/add")?


How can I render different news components into the Navbar Component & display their data on the Navbar page, On Click of Navbar menu links

Question: I have made landing page where onClick of button it redirects to the Menus page/component where I have declared Navbar component & here only I want to render the different news category component on click of multiple nav menus of Navbar.
By using react-router-dom V6 how can I render different categories of news component underneath of Navbar.
Below is the code which I have tried yet.

App.js

import React from 'react';
import {Routes,Route} from 'react-router-dom';
import LandingPage from './Components/LandingPage';
import Menus from './Component/Menus;

const App = () => {
  return (
    <>
      <Routes>
        <Route path='/' element={<LandingPage/>} />
        <Route path='menus'    element={<Menus/>} />
      </Routes>
    </>
  )
};
export default App;

Menus.js

import Navbar from './Navbar';

const Menus = () => {
  return (

      <Navbar/>

  );
};
export default Menus;

Navbar.js

import '../Styles/Navbar.css';
import Entertainment from './Entertainment';
import Business from './Business';
import Health from './Health';
import Science from './Science';
import Sports from './Sports';
import Technology from './Technology';
import {Link,Route,Routes} from 'react-router-dom';
import {useState} from 'react';

const Navbar = ()=>{
  const [isMobile,setIsMobile] = useState(false);
  return(
    <>

theNews

setIsMobile(false)}>
          <Link to='/business' className='business'>
Business
</Link>
          <Link to='/fun' className='fun'>
Entertainment
</Link>
          <Link to='/health' className='health'>
Health
</Link>
          <Link to='/science' className='science'>
Science
</Link>
          <Link to='/sports' className='sports'>
Sports
</Link>
          <Link to='/tech' className='tech'>
Technology
</Link>

          <button className='mobile-menu-icon' onClick={()=>setIsMobile(!isMobile)}>
           {isMobile? :}
          </button>

      <Routes>
        <Route path='business'  element={<Business/>}/>
        <Route path='health'    element={<Health/>} />
        <Route path='science'   element={<Science/>} />
        <Route path='sports'    element={<Sports/>} />
        <Route path='tech'      element={<Technology/>} />
        <Route path='fun'       element={<Entertainment/>} />
        </Routes>

    </>
  )
}
export default Navbar;

Answer: If I understand your question correctly you are wanting to render Menus on the "/menus" path, and then also render sub-routes in Navbar being rendered by Menus. In react-router-dom v6 route paths are now always exactly matched, and the "/menus" root path precludes matching and rendering  sub-routes.
The solution is to append a "*" wildcard matcher to the root path to allow additional route matching.
<Routes>
  <Route path="/" element={<LandingPage/>} />
  <Route path="/menus/*" element={<Menus/>} />
</Routes>

Additionally, in Navbar you are rendering relative route paths but specifying absolute route links. These should be in agreement. Remove the leading "/" character from the links so they are also relative to the "/menus" route path.
const Navbar = () => {
  const [isMobile, setIsMobile] = useState(false);
  return(
    <>

theNews

setIsMobile(false)}>
          <Link to='business' className='business'>
Business
</Link>
          <Link to='fun' className='fun'>
Entertainment
</Link>
          <Link to='health' className='health'>
Health
</Link>
          <Link to='science' className='science'>
Science
</Link>
          <Link to='sports' className='sports'>
Sports
</Link>
          <Link to='tech' className='tech'>
Technology
</Link>

          <button className='mobile-menu-icon' onClick={()=>setIsMobile(!isMobile)}>
           {isMobile? :}
          </button>

      <Routes>
        <Route path='business'  element={<Business/>}/>
        <Route path='health'    element={<Health/>} />
        <Route path='science'   element={<Science/>} />
        <Route path='sports'    element={<Sports/>} />
        <Route path='tech'      element={<Technology/>} />
        <Route path='fun'       element={<Entertainment/>} />
        </Routes>

    </>
  )
}


trouble running multiple domains on tomcat behind apache via mod_jk

Question: I am having trouble setting up tomcat6 with 2 virtual hosts, behind apache2.
if i have just one host defined in tomcat, and one jk worker, everything works fine. as soon as i define another jk worker and a corresponding tomcat host i get this error in jk.log:
9:3075328656] [info] ajp_connect_to_endpoint::jk_ajp_common.c (922): Failed opening socket to (188.8.131.52:8009) (errno=111)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [error] ajp_send_request::jk_ajp_common.c (1507): (dogself) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [info] ajp_service::jk_ajp_common.c (2447): (dogself) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [error] ajp_service::jk_ajp_common.c (2466): (dogself) connecting to tomcat failed.
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [info] jk_handler::mod_jk.c (2615): Service error=-3 for worker=dogself

my tomcat server.xml looks like this:
<Service name="Catalina">

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="dogself.com">

  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

  <Host name="dogself.com"  appBase="webapps-dogself"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
  </Host>

  <Host name="nousophia.com"  appBase="webapps-test"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
  </Host>

</Engine>
</Service>

my workers.properties looks like this:
# workers.properties - ajp13
#
# List workers
worker.list=dogself,nousophia

# Define dogself
worker.dogself.port=8009
worker.dogself.host=dogself.com
worker.dogself.type=ajp13

worker.nousophia.port=8009
worker.nousophia.host=nousophia.com
worker.nousophia.type=ajp13

tomcat is started/restarted
i followed these directions for setting it up:
https://stackoverflow.com/questions/1765399/linking-apache-to-tomcat-with-multiple-domains
can someone confirm that it would work as above?
Answer: You will need to add another Connector on a different port for the second virtual host, because the AJP connection between Apache and Tomcat is a persistent connection.
eg, server.xml:
....
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
....

workers.properties:
worker.dogself.port=8009
worker.dogself.host=dogself.com
worker.dogself.type=ajp13

worker.nousophia.port=8010
worker.nousophia.host=nousophia.com
worker.nousophia.type=ajp13

Comment: ok, then are you saying that the answer here is wrong: http://stackoverflow.com/questions/1765399/linking-apache-to-tomcat-with-multiple-domains
Comment: daveadam's answer will work. We had recently configured 3 virtual hosts in apache connecting to tomcat. Connector port has to be different for each separate worker. You can specify ports like 8009, 8010 and 8011 for 3 virtual hosts for example and so on.


How to access variable from scope of parent function?

Question: I want my function to access an outside variable—from its parent function specifically. However, using the global keyword sets too broad a scope; I need to limit it. How do I get this code to spit out 'Level 2' instead of 'Level 1'? Do I have to make a class?
<?php
$a = "Level 1";

function first() {
    $a = "Level 2";

    function second() {
        global $a;
        echo $a.'
';
    }

    second();
}

first();
//outputs 'Level 1'
?>

Answer: Just for the sake of example, if I understand what you're trying to do, you could use a closure (PHP 5.3+), as "Closures may also inherit variables from the parent scope" with the use keyword.
$a = "Level 1";

function first() {
    $a = "Level 2";

    $func = function () use ($a) {
        echo $a.'
';
    };

    $func();
}

first();
// prints 'Level 2
'

Closures are most commonly used for callback functions. This may not be the best scenario to use one, however. As others have suggested, just because you can do something doesn't mean it's the best idea.
Comment: I also needed to pass data in and out of the callback function so I had to write `use (&$a)` to pass it by reference. (Remembering matches from a preg_replace_callback scenario.)
Answer: PHP has no concept of nested functions or scopes and it's terrible practice to nest functions. What happens is that PHP simply encounters a function declaration and creates a normal function second. If you try to call first again, PHP will again encounter a function declaration for second and crash, since the function second is already declared. Therefore, don't declare functions within functions.
As for passing values, either explicitly pass them as function parameters or, as you say, make a class if that makes sense.
Comment: could also defensively check `if ( function_exists('second') ) {}`


Laws of $(B_t)_{t\in [0,T]}$ and $(2B_t)_{t\in [0,T]}$ : singular?

Question: Are the laws of  $(B_t)_{t\in [0,T]}$ and $(2B_t)_{t\in [0,T]}$ mutually singular ?
More precisely, I know that the laws of two diffusion processes are mutually absolutely continuous if they share a common diffusion coefficient (application of Girsanov theorem).
However, I cannot understand why it is no more the case when they have different diffusion coefficients. This is why I ask the question about $(B_t)_{t\in [0,T]}$ and $(2B_t)_{t\in [0,T]}$. If their laws are not mutually continuous, that would mean that one can find a measurable set of trajectories $\mathcal{A}$ for which $\mathbb{P}[(B_t)_{t\in [0,T]} \in \mathcal{A}]>0$ while $\mathbb{P}[(2B_t)_{t\in [0,T]} \in \mathcal{A}]=0$. The problem is : I don't know how to find such a set $\mathcal{A}$. Can anyone help me to understand this point ?
Thank you folks !
Answer: The answer comes from the quadratic variation: $\mathsf P\{[B_t] = t\} = 1$ while $\mathsf P\{[2B_t] = 4t\} = 1$. In this case you can define $\mathcal A$ to be an event (subset of the space of processes with continuous trajectories, say $\omega$) as
$$
\mathcal A_k = \{\omega:[\omega_t] = k^2t\}.
$$
Then $\mathsf P\{B_t\in \mathcal A_1\} = 1$ but $\mathsf P\{2B_t\in \mathcal A_1\} = 0$ and $\mathsf P\{B_t\in \mathcal A_2\} = 0$ but $\mathsf P\{2B_t\in \mathcal A_2\} = 1$.
See also the related question of mine on MO.
Comment: @mellow: you're welcome. I mad some minor edits by the way
Comment: I am currently working on the same type of problem [here](https://math.stackexchange.com/questions/4815265/girsanov-type-theorem-that-alters-the-variance-of-a-wiener-process). I came up with a valid Radon-Nikodym for a measure change that alters the variance, but the counter-example presented in your answer means that it doesn't produce an equivalent Wiener probability measure: just an equivalent CDF (PDF). I'd be interested in proving that the increments are not independent: if they are, then we must have a Brownian motion, which seems contradictory. Would you be interested in helping?
Comment: @JanStuller replied there
Answer: You can also use the law of the iterated logarithm at $t=0$. For the set
$$A:=\left\{\omega: \limsup_{t\to0} {|\omega_t|\over\sqrt{2t\log\log(1/t)}}=1\right\}$$
we have $\mu_B(A) = 1$, but $\mu_{2B}(A) = 0$. Here $\mu_B$ and $\mu_{2B}$ are the laws of Brownian motion and twice Brownian motion respectively.


How to change view's field (Custom-Text field specifically) value based on other field value using hook_view_pre_render?

Question: I have created a taxonomy-term view.
I have added two fields in a view: term-id and custom-text field.
I want to check if term-id has children and depending upon the result, I want to set markup inside custom-text field.
I am able to get term-id in hook_views_pre_render with following code, but I am not able to set the value of custom-text field
function mymodule_views_pre_render(\Drupal\views\ViewExecutable $view) {
 if ($view->id() == 'test_view' && $view->current_display == 'block_2') {
    foreach($view->result as $value){
        $tid = $value->_entity->get('tid')->value;
        kint($tid);

        //trying to set value for custom text field, with foll. line of code
        //'nothing' is the field-name you get for any custom-text field
        $value->_entity->set('nothing', '
This is my custom mark-up
');
    }
 }
}

I referred the code from these following 2 sources, but they are not dealing with custom-text field:

How to change views field value using a hook
https://api.drupal.org/comment/62573#comment-62573

Or should I use template_preprocess_views_view_fields(), if yes then how can I get term-id value to check if it has children terms.
Any help will be appreciated.
Answer:
You can't set a value for "nothing" aka "Global: Custom text" in hook_views_pre_render() because _entity is the entity object. The entity (Taxonomy Term in your case, and Node in my test case) does not contain this field.
Therefore, you need to use template_preprocess_views_view_field
function THENAME_preprocess_views_view_field(&$vars) {
  if(isset($vars['view']) && ($vars['view']->id() == 'test_view') && ($vars['view']->current_display == 'block_2')) {
    if (isset($vars['view']->field) && (count($vars['view']->field) > 0)) {
      if ($vars['field']->field == 'nothing') {
        $tid = $vars['row']->_entity->get('tid')->value; // get tid
        if ($vars['field']->field == 'nothing') {
          $vars['output'] = [
            '#markup' => "
This is my custom mark-up with term id: $tid
",
          ];
        }
      }
    }
  }
}

Comment: just for the reference I would like to share one more solution, which I figured out; hope that will be useful for someone. But your solution looks more appropriate. Thanks.
Answer: I referred the code from this source https://drupal.stackexchange.com/a/262718/97205 which was also helpful and figured out following solution:
function THEMENAME_preprocess_views_view_fields(&$variables) {
  $view = $variables['view'];
  $field = $variables['field'];

  if ($view->id() == 'test_view' && $view->current_display == 'block_2') {
    foreach ($view->field as $id => $field) {

      if ($field->field == 'nothing') {
        $tid = $variables['row']->tid; //get tid
        $variables['fields']['nothing']->content = "
Custom markup goes here $tid
";
        //kint($tid);
      }
    }
  }
}

But solution from @NoSssweat is more appropriate.


How to grant User Points to viewing user when user has viewed content?

Question: Can anyone provide me with a simple rule that adds 1 user point to a user when this user has viewed an entity of "Article" (for example)?
I have enabled the User Points module and the "Userpoints rules" integration module. But I can't find a way to get this to work.
Answer: Interesting question, worth to be considered as a great question for a Drupal site building exam!
Have a look at this rule:
{ "grant_user_points_after_content_view" : {
    "LABEL" : "Grant user points after content view",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "userpoints_rules" ],
    "ON" : { "node_view--article" : { "bundle" : "article" } },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "2" : "2" } }
        }
      }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "site:current-user" ],
          "points" : "1",
          "tid" : "0",
          "entity" : [ "node" ],
          "description" : "View of node with id \u0022[node:nid]\u0022 and title \u0022[node:title]\u0022",
          "operation" : "NodeViewed",
          "reference" : "Viewing of [node:content-type] \u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E\/node\/[node:nid]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      }
    ]
  }
}

Some details about this rule, which you should be able to import in your own site if you have the Rules UI, and Userpoints Rules (a sub-module of Userpoints), enabled and after you enable the rule also:

Rules Event: a Node of content "Article" is viewed (adapt the machine name of the used content type to any type that fits).
Rules Condition: user is authenticated (to be able to grant user points).
Rules Action: grant 1 point to the user viewing the article. And use some of the available tokens to add some more details to the actual User Points transaction (description, operation, reference) ... just for fun.

Easy, no? Sorry you had to wait for 2 years ...
PS: The previous answer is not really an answer to the question here I think.
Comment: Hello Pierre,
Thanks for this but I cannot find the Userpoints Rules. That module does not seem to exist. Can you check your link please. Even after 2 years, still good! Ta!
Comment: Awesome Pierre! It works! I gotta dig deeper into all the userpoint rules settings to get to the nitty-gritty! THANK YOU AGAIN!
Comment: Apologies, I wasn't aware of clicking the 'tick'. Here you go ;-)
Answer: If you are using variable module, then you can do it.
Please follow the steps:

Provide a new variable (text type!), called Number, with the
necessary PHP code (wrapped with <?php ... ?>). One can then use
earlier calculated results like $mynumber.
Convert Number to an integer, called Points.
Grant Points to the user.

Hope this may help. Thank you.
Comment: I think the key thing is that the question asker wants to assign user points. This answer doesn't really address that.
Comment: @rooby: And now I have completely updated the answer. Please have a try. Thank you.
Comment: Oops, that goes a bit beyond my knowledge but I'll try it. Thanks.


How to check input for content in multiple lists

Question: I kind of noob question probably, but how do I check if the input of "Answer" is in multiple lists? I want to be able to identify if the input is a part of both "Vokalar" and "Konsonantar". For future I would also like to be able to identify how many times the input is a part of each list.
Vokalar= ("a","e","i","o","u","y","æ","ø","å")
Konsonantar=("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","z")

Loop = 1

while Loop == 1:
    Answer = input("Word-check ;)")

    if Answer in Vokalar and Konsonantar:
        print("word")
    else:
        print("not word")

Comment: if (Answer in Vokalar) and (Answer in Konsonantar):, paranthesis are not necessary added it only for readability, if you want to check if it is in at-least 1 list you can use 'or' instead of 'and'.
Comment: Are you expecting a word at `Answer = input("Word-check ;)")`?
Answer: if Answer in Vokalar and Answer in Konsonantar:

But if you will have more lists later on, you could define a variable withh all of your check lists and check it this way:
check_lists = [Vokalar, Konsonantar, <other lists>]
if all(Answer in list_ for list_ in check_lists):

Answer: you have to check every char in the answer string and compare it with the list not all the string
Vokalar= ("a","e","i","o","u","y","æ","ø","å")
Konsonantar= ("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","z")

Loop = 1

while Loop == 1:

Answer = input("Word-check : ")
isWord = True
for i in  Answer:
    if i in Vokalar or i in Konsonantar:
        pass
    else:
        isWord = False
if isWord :
    print("word")
else :
    print("not word")

Answer: # function to count number of occurences
def countOccurences(itemToCheck, itemsList):
    count = 0
    for item in itemsList:
        if item == itemToCheck:
            count += 1
    return count

Vokalar = ("a", "e", "i", "o", "u", "y", "æ", "ø", "å")
Konsonantar = ("b", "c", "d", "f", "g", "h", "j", "k", "l", "m",
               "n", "p", "q", "r", "s", "t", "v", "w", "x", "z")

Loop = 1

while Loop:
    Answer = input("Word-check ;)")

    if Answer in Vokalar and Answer in Konsonantar:
        vokalarOccurences = countOccurences(Answer, Vokalar)
        konsonantarOccurences = countOccurences(Answer, Konsonantar)
        print(f"{Answer} is found in both lists. Vokalar: {vokalarOccurences} times and Konsonantar: {konsonantarOccurences} times")

    elif Answer in Vokalar:
        vokalarOccurences = countOccurences(Answer, Vokalar)
        print(f"{Answer} is found in Vokalar list. Vokalar: {vokalarOccurences} times")

    elif Answer in Konsonantar:
        konsonantarOccurences = countOccurences(Answer, Konsonantar)
        print(f"{Answer} is found in Konsonantar list. Konsonantar: {konsonantarOccurences} times")

    else:
        print(f"{Answer} not found in any list.")

Answer: To check if an answer is a word you can just use the builtin method of the string isalpha: https://docs.python.org/3/library/stdtypes.html#str.isalpha
If you want to do it manually is better to use sets:
def check_answer(answer: str) -> bool:
    cur_set = set(answer)
    vok = set(Vokalar) & cur_set
    kon = set(Konsonantar) & cur_set
    return len(cur_set) == len(vok) + len(kon) # len must be equal to sum of vok and kon to be a correct word

To count the occurrence there is an builtin collection (a special dictionary):
https://docs.python.org/3/library/collections.html#collections.Counter
from collections import Counter

c = Counter(answer)
print(c.keys())
print(c.get('a', 0))  # to get the count for a char

Then, you can check for each count in which list it is and print the counter:
for elm, count in c.items():
    if elm in Vokalar:
        print(elm, "in Vokalar", count, "times")
    elif elm in Konsonantar:
        print(elm, "in Konsonantar", count, "times")

Please note that you don't manage the upper and lower cases with those lists but the isalpha method does it...
Answer: To count occurencies of answer in both list you can use code:
cnt_vokalar = Vokalar.count(Answer)
cnt_konsonantar = Konsonantar.count(Answer)

Then you could check if number of occurencies is greater than 0:
while Loop == 1:
    Answer = input("Word-check ;)")
    cnt_vokalar = Vokalar.count(Answer)
    cnt_konsonantar = Konsonantar.count(Answer)
    if cnt_vokalar > 0 and cnt_konsonantar > 0:
        print("word")
    else:
        print("not word")


Different Types of Continuity in Reflexive Banach Space

Question: Let $X$ be a reflexive Banach space with dual $X^*$.
Let $K\subset X$ be a nonempty closed convex set.
The mapping $F: K\rightarrow X^*$ is said to be:

weakly continuous if $F$ is continuous w.r.t. the weak$^*$ topology on $X^*$
and the induced topology on $K$;
continuous on finite dimensional subspaces if for any subspaces
$M\subset X$ the restriction of F to $K\cap M$ is continuous w.r.t the
weak$^*$ topology on $X^*$ and the induced topology on $K\cap M$;
hemicontinuous if for any $x, y\in K$ the restriction of $F$ to $[x, y]$
is continuous w.r.t the weak$^*$ topology on $X^*$ and the induced topology on $[x, y]$.

We are easy to verify that
weak continuity $\Rightarrow$ continuity on finite dimensional subspaces
continuity on finite dimensional subspaces $\Rightarrow$ hemicontinuity.
The reverse is not true in general.
I am stuck in constructing counterexamples for the reverse implication.
Thank you for all comments and helping.
Comment: The topology is induced from what topology? Is it the strong one? Also, in the second type of continuity, are assuming that $M$ is a proper subspace?
Comment: The topology is induced from topology generated by norm on $X$.
Answer: I. Conterexample: continuity on finite dimensional subspaces doesn't imply weak continuity
Let $X = \ell_2$ (or any other infinite dimensional reflexive Banach space) and $K$ be the closed unit ball of $X$. Let $u$ be an arbitrary non-zero vector in $X^*$.
Let $e_{\alpha}$ be a Hamel basis in $X$ with $\|e_{\alpha}\| = 1$. Fix an arbitrary unbounded sequence of real numbers $c_{\alpha}$. Define a map $F$ on vectors $e_{\alpha}$ by $F(e_{\alpha}) = c_{\alpha} u$. Now extend $F$ to $K$ by linearity. We get a map $F$ from $K$ to $X^*$. Since $F$ is linear, it is continuous on every bounded subspace of $X$. On the other hand, since the sequence $c_{\alpha}$ is unbounded, $F$ is unbounded on $K$ (and thus it is not continuous).
II. Conterexample: hemicontinuity doesn't imply continuity on finite dimensional subspaces
Let $X={\mathbb R}^2$, $K$ be the unit ball of $X$, and $u\in X^*\setminus \{0\}$. Define $F(x,y)$ as follows
$$F(x) = \cases {0,&if $x=0$;\\
\frac{x_1x_2^2}{x_1^2+x_2^{10}} \cdot u, &otherwise.}
$$
It's easy to check that $F$ is continuous on every segment $[x,y]$ but $F$ is not continuous at $0$ (e.g. consider the sequence $(1/k^5, 1/k)$ that tends to $0$ as $k\to\infty$ but $F(1/k^5, 1/k)\not\to 0$).
P.S. Note that since $X$ is reflexive, there is no difference between the weak-* topology and weak topology on $X^*$.
Comment: Thank you for your interesting constructions.
Comment: I would like to ask your comments in the following question math.stackexchange.com/questions/482684/… Thank you for your kind help


Is it safe to close the following ports in Windows Firewall for a Windows 2022 VPS web server?

Question: I am using a Windows Server 2022 VPS as a web server to host a website only.  When the VPS was first setup for me, I saw the following ports for Inbound in Windows Firewall were already enabled (the port is on the very right side with TCP or UDP in front of it):

Cast to Device streaming server (HTTP-Streaming-In) TCP 10246
DIAL protocol server (HTTP-In) TCP 10247
Cast to Device functionality (qWave-TCP-In) TCP 2177
Cast to Device functionality (qWave-UDP-In) UDP 2177
Cast to Device streaming server (RTSP-Streaming-In) TCP 23554, 23555, 23556
Cast to Device UPnP Events (TCP-In) TCP 2869
Microsoft Media Foundation Network Source IN UDP [UDP 5004-5009] 5000-5020
mDNS (UDP-In) UDP 5353
Microsoft Edge (mNDS-In) UDP 5353
Core Networking - Dynamic Host Configuration for IPv6 (DHCPV6-In) UDP 546
Microsoft Media Foundation Network Source IN [TCP 554] 554, 8554-8558
Core Networking - Dynamic Host Configuration (DHCP-In) UDP 68
Delivery Optimization (TCP-In) TCP 7680
AllJoyn Router (TCP-In) TCP 9995

I am only using my Windows 2022 server to host a website (my website runs on ASP.net MVC, and uses IIS of course). I did not setup any of these Windows Firewall Inbound rules up.  At the same time, I do want to secure my VPS, but of course, I also want my Windows 2022 VPS to function properly.  Can I safely turn off the above Windows Firewall Inbound rules, to harden my VPS?  Or will I run into problems if I disable some of the Windows Firewall Inbound rules above?  Which rules/ports above need to be enabled and are not safe to disable?
Answer: A pure web server should only allows incoming HTTP and HTTPS connections, so the only opened ports should be TCP 80 and 443 (plus UDP 443 if using QUIC). If using FTP and/or FTPS to upload files, you should open at least TCP ports 20,21,989 and 990 (plus other ranges required for passive mode server).
From the list you posted above, only UDP 68 and 546 (DHCP) appears to be possibly useful, if and only if your server's IP is obtained via DHCP (unlikely). That said, this is a generic advice only: your specific server/application can require any other ports, and it is not possible to predict what you will install/run on your server.
Moreover, be aware that securing a public server is much more than simply closing the unneeded ports. This is a basic first step, but please don't relying on firewall alone to be "secure".
Comment: Hi, thanks for your answer! I closed some of the inbound ports in Windows Firewall, while using your answer as a general guide, and so far, it doesn't seem to have impacted the website from my testing.  Also, do you know of a good basic guide on the internet to securing a Windows VPS for website use? Just wondering what other steps I need to take to help ensure my VPS is "secure." Thank you.
Comment: I think you are using IIS, so I would start from [here](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/jj635855(v=ws.11))


How can I get a list of Git local branches, which are not already pushed to GitHub?

Question: Given:

I have local some branches, and some of them are pushed my account to GitHub
but there are some local branches which I don't have pushed

How can I list the unpushed branches?
Also possible:
List all local branches (pushed/non pushed) with the existing remote visible.
I tried the command remote show origin already and there I see the remote branches, but there are the local unpushed branches that are not listed :(
git remote -v show origin

This shows only my local branches:
git branch -vv

Added 2020-05-06:
Expected Result:
I see for all my local branches the associated origin branches:
Note: this expected result is manually created
* master                               [origin/master: 60 hinterher]
  muescha/feature/npm-readme
  muescha/fix/agility-format           [origin/muescha/fix/agility-format: ... ]
  muescha/fix/anchor-tags-in-glossary
  muescha/fix/brand-webpack            [origin/muescha/fix/brand-webpack: ... ]
  muescha/fix/claudinary-code-block
  muescha/fix/claudinary-format
  muescha/fix/claudinary-optional
  muescha/fix/docs-bash-to-shell       [origin/muescha/fix/docs-bash-to-shell: ... ]
  muescha/fix/gatsby-cloud-brand-names
  muescha/fix/la-days-kim              [origin/muescha/fix/la-days-kim: ... ]
  muescha/fix/receipes-changes
  muescha/fix/tutorials-1-8
  muescha/fix/tutorials-1-8-fix        [origin/muescha/fix/tutorials-1-8-fix: ... ]

So that I see which branch is not already pushed to GitHub.
In my case these branches do not have an branch on GitHub and only local branches:
Note: this expected result is manually created
  muescha/feature/npm-readme
  muescha/fix/anchor-tags-in-glossary
  muescha/fix/claudinary-code-block
  muescha/fix/claudinary-format
  muescha/fix/claudinary-optional
  muescha/fix/gatsby-cloud-brand-names
  muescha/fix/receipes-changes
  muescha/fix/tutorials-1-8

Current Status:
Branches on GitHub
https://github.com/muescha/gatsby/branches
# Default branch
master                         | Updated 2 days ago by wardpeet   | Default

# Your branches
muescha/fix/la-days-kim        | Updated 16 days ago by muescha   | 288/3
muescha/fix/docs-bash-to-shell | Updated 14 days ago by gatsbybot | 187/7
muescha/fix/brand-webpack      | Updated 12 days ago by gatsbybot | 127/4
muescha/fix/agility-format     | Updated 20 days ago by muescha   | 288/4
muescha/fix/tutorials-1-8-fix  | Updated 2 months ago by muescha  | 901/1

git remote --verbose
$ git remote --verbose
gatsby    https://github.com/gatsbyjs/gatsby.git (fetch)
gatsby    https://github.com/gatsbyjs/gatsby.git (push)
origin    https://github.com/muescha/gatsby.git (fetch)
origin    https://github.com/muescha/gatsby.git (push)

git config --local -l
$ git config --local -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/muescha/gatsby.git
remote.origin.fetch=+refs/heads/master:refs/remotes/origin/master
remote.gatsby.url=https://github.com/gatsbyjs/gatsby.git
remote.gatsby.fetch=+refs/heads/*:refs/remotes/gatsby/*
pull.rebase=true
branch.muescha/fix/tutorials-1-8-fix.remote=origin
branch.muescha/fix/tutorials-1-8-fix.merge=refs/heads/muescha/fix/tutorials-1-8-fix
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.muescha/fix/docs-bash-to-shell.remote=origin
branch.muescha/fix/docs-bash-to-shell.merge=refs/heads/muescha/fix/docs-bash-to-shell
branch.muescha/fix/brand-webpack.remote=origin
branch.muescha/fix/brand-webpack.merge=refs/heads/muescha/fix/brand-webpack
branch.muescha/fix/la-days-kim.remote=origin
branch.muescha/fix/la-days-kim.merge=refs/heads/muescha/fix/la-days-kim
branch.muescha/fix/agility-format.remote=origin
branch.muescha/fix/agility-format.merge=refs/heads/muescha/fix/agility-format

git branch -vv
$ git branch -vv
* master                               5a4f7a1e7 [origin/master: 60 hinterher] chore(starters): add gatsby-typescript-starter-minimalist (#23393)
  muescha/feature/npm-readme           f07b4db3c fix brand names
  muescha/fix/agility-format           06d9f8ad0 fix add language to code block
  muescha/fix/anchor-tags-in-glossary  505e5268e fixes links
  muescha/fix/brand-webpack            d0758d81f change brand names in yaml files
  muescha/fix/claudinary-code-block    b6eca1f0f fix add language to code block
  muescha/fix/claudinary-format        546fbdfc5 fix move out of prefix section
  muescha/fix/claudinary-optional      03d41affc fix move other optionals out of prefix section
  muescha/fix/docs-bash-to-shell       df7ad898c add shell
  muescha/fix/gatsby-cloud-brand-names cad8ed156 fix brand names
  muescha/fix/la-days-kim              623c6d28c change tags indent
  muescha/fix/receipes-changes         f788c2d0d change brand names, local links
  muescha/fix/tutorials-1-8            bf1eb90a1 chore(gatsby-source-filesystem): fix jdoc (#22197)
  muescha/fix/tutorials-1-8-fix        17dac01b7 fix

git branch -avv
$ git branch -avv
* master                                                                   5a4f7a1e7 [origin/master: 60 hinterher] chore(starters): add gatsby-typescript-starter-minimalist (#23393)
  muescha/feature/npm-readme                                               f07b4db3c fix brand names
  muescha/fix/agility-format                                               06d9f8ad0 fix add language to code block
  muescha/fix/anchor-tags-in-glossary                                      505e5268e fixes links
  muescha/fix/brand-webpack                                                d0758d81f change brand names in yaml files
  muescha/fix/claudinary-code-block                                        b6eca1f0f fix add language to code block
  muescha/fix/claudinary-format                                            546fbdfc5 fix move out of prefix section
  muescha/fix/claudinary-optional                                          03d41affc fix move other optionals out of prefix section
  muescha/fix/docs-bash-to-shell                                           df7ad898c add shell
  muescha/fix/gatsby-cloud-brand-names                                     cad8ed156 fix brand names
  muescha/fix/la-days-kim                                                  623c6d28c change tags indent
  muescha/fix/receipes-changes                                             f788c2d0d change brand names, local links
  muescha/fix/tutorials-1-8                                                bf1eb90a1 chore(gatsby-source-filesystem): fix jdoc (#22197)
  muescha/fix/tutorials-1-8-fix                                            17dac01b7 fix
  remotes/gatsby/100days-challenge-12                                      7f744f9e6 Fix typo
  remotes/gatsby/100days-challenge-12-branch                               7095e418b Expand on stale handling for gatsby sites (#22230)
  remotes/gatsby/100days-challenge-13                                      b08657ec8 Draft challenge 13
  remotes/gatsby/7z                                                        165bc0f09 restore apt install for circle, hopefully cloud wont randomly fail this time
  remotes/gatsby/Aswinpookkatt-patch-5                                     8a162cd2c fixed minor issue in docs
  remotes/gatsby/Blog-post-porting-jekyll-to-gatsby                        03e304ff2 �
  remotes/gatsby/DaleSeo-patch-1                                           5c577b6c3 Fix the image path
  remotes/gatsby/DaleSeo-patch-1-1                                         86c6bf76b Update remark-plugin-tutorial.md
  remotes/gatsby/KyleAMathews-patch-1                                      16010754d feat(gatsby-recipes): document option support for GatsbyPlugin
  remotes/gatsby/KyleAMathews-patch-2                                      2e40b6deb Update packages/gatsby-recipes/README.md
  remotes/gatsby/NotMoni-fix-whitespace                                    f2d27e72b fix whitespace
  remotes/gatsby/Olanetsoft-patch-2                                        2381fea7d Updated read-me with punctuation where necessary
  remotes/gatsby/PaulinaVPG/master                                         2f623924d Tested tutorial and left a few suggestions
  remotes/gatsby/Rizwanjamal-patch-1                                       6de1fbd25 docs: remove hidden code that no longer seen
  remotes/gatsby/Rizwanjamal-patch-1-1                                     618d4c642 docs: remove dead code
...
...
...

git remote -v show origin
$ git remote -v show origin
* Remote-Repository origin
  URL zum Abholen: https://github.com/muescha/gatsby.git
  URL zum Versenden: https://github.com/muescha/gatsby.git
  Hauptbranch: master
  Remote-Branch:
    master gefolgt
  Lokale Branches konfiguriert für 'git pull':
    master                         führt mit Remote-Branch master zusammen
    muescha/fix/agility-format     führt mit Remote-Branch muescha/fix/agility-format zusammen
    muescha/fix/brand-webpack      führt mit Remote-Branch muescha/fix/brand-webpack zusammen
    muescha/fix/docs-bash-to-shell führt mit Remote-Branch muescha/fix/docs-bash-to-shell zusammen
    muescha/fix/la-days-kim        führt mit Remote-Branch muescha/fix/la-days-kim zusammen
    muescha/fix/tutorials-1-8-fix  führt mit Remote-Branch muescha/fix/tutorials-1-8-fix zusammen
  Lokale Referenzen konfiguriert für 'git push':
    master                         versendet nach master                         (lokal nicht aktuell)
    muescha/fix/agility-format     versendet nach muescha/fix/agility-format     (aktuell)
    muescha/fix/brand-webpack      versendet nach muescha/fix/brand-webpack      (lokal nicht aktuell)
    muescha/fix/docs-bash-to-shell versendet nach muescha/fix/docs-bash-to-shell (lokal nicht aktuell)
    muescha/fix/la-days-kim        versendet nach muescha/fix/la-days-kim        (aktuell)
    muescha/fix/tutorials-1-8-fix  versendet nach muescha/fix/tutorials-1-8-fix  (aktuell)

git log origin/master..HEAD
$ git log origin/master..HEAD
# no output

git log --branches --not --remotes
$ git log --branches --not --remotes

commit 623c6d28c2792a24b147501a3e9e878aac54b04e (muescha/fix/la-days-kim)
Author: Muescha <email@example.com>
Date:   Mon Apr 20 23:20:10 2020 +0200

    change tags indent

commit df7ad898c3149362bc385a427298cf3ad8431d63 (muescha/fix/docs-bash-to-shell)
Author: Muescha <email@example.com>
Date:   Sun Apr 19 17:19:50 2020 +0200

    add shell

commit d0758d81f83c9a5e8ef5f1d1fb42f415bd6c9c4f (muescha/fix/brand-webpack)
Author: Muescha <firstname.lastname@example.com>
Date:   Sat Apr 18 16:00:01 2020 +0200

    change brand names in yaml files

commit f788c2d0d472b62ce663a21e4d1a154fcde700ad (muescha/fix/receipes-changes)
Author: Muescha <email@example.com>
Date:   Sat Apr 18 15:54:12 2020 +0200

    change brand names, local links

commit 06d9f8ad0853450c3dc7efc131331ca5da312e2f (muescha/fix/agility-format)
Author: Muescha <email@example.com>
Date:   Thu Apr 16 15:19:36 2020 +0200

    fix add language to code block

commit b6eca1f0fb7cef6c8cbb937fd92a477220bdbbcb (muescha/fix/claudinary-code-block)
Author: Muescha <firstname.lastname@example.com>
Date:   Thu Apr 16 08:58:38 2020 +0200

    fix add language to code block

commit 03d41affcd116272edb74961a6fae1c5e55ecf51 (muescha/fix/claudinary-optional)
Author: Muescha <email@example.com>
Date:   Thu Apr 16 07:26:04 2020 +0200

    fix move other optionals out of prefix section

commit 546fbdfc58f7158b24507a6cbc73a70184c98e6c (muescha/fix/claudinary-format)
Author: Muescha <email@example.com>
Date:   Thu Apr 16 07:23:43 2020 +0200

    fix move out of prefix section

commit 461e45ccb4e66c9b34ab857b4f14aaf973f3fe99
Author: Muescha <email@example.com>
Date:   Thu Apr 16 07:16:59 2020 +0200

    fix for lint/prettier

commit f07b4db3cf5ce3f78410db132892c8c99e9ca8b0 (muescha/feature/npm-readme)
Author: Muescha <email@example.com>
Date:   Thu Apr 16 05:02:49 2020 +0200

    fix brand names

commit cad8ed156f712f774c7f31a8c6c340cdc1ce2a22 (muescha/fix/gatsby-cloud-brand-names)
Author: Muescha <firstname.lastname@example.com>
Date:   Thu Apr 16 04:43:15 2020 +0200

    fix brand names

commit 7778482ef77d5bfd924b3d86ee97b5602ec42c63
Author: Muescha <email@example.com>
Date:   Thu Apr 16 01:14:13 2020 +0200

    fix 404 link

commit 1a0791afd2e4f4b35c7645c3725002aa8ed0b0b7
Author: Muescha <email@example.com>
Date:   Thu Apr 16 00:20:57 2020 +0200

    fix path to images

commit 5734a8c86736f2e670930f6e9c2bd71c10e77ced
Author: Muescha <firstname.lastname@example.com>
Date:   Wed Apr 15 23:48:09 2020 +0200

    fix file name

commit 10ee6e3b46ed7bec566f0323ebb79a88247db6e5
Author: Muescha <email@example.com>
Date:   Wed Apr 15 23:40:10 2020 +0200

    add links to TOC

commit 2983a4a1ee81e43c174fd0823b7487c769098d6d
Author: Muescha <email@example.com>
Date:   Wed Apr 15 23:14:48 2020 +0200

    fix frontmatter

commit 22e43a0e01032a377b3e6347967db6d4f3b75460
Author: Muescha <email@example.com>
Date:   Wed Apr 15 23:14:00 2020 +0200

fix frontmatter

commit fb08e2c9732d68dc1ce2cbf9a09159bf9229add5
Author: Muescha <firstname.lastname@example.com>
Date:   Tue Apr 7 22:45:25 2020 +0200

fix brand name

commit 99d7c9f0c45eae63a9b8ed291cda26acac67acae
Author: Muescha <email@example.com>
Date:   Tue Apr 7 21:29:20 2020 +0200

change bash to shell

commit 17dac01b7c640eb759d0788742323d9e38059aec (muescha/fix/tutorials-1-8-fix)
Author: Muescha <email@example.com>
Date:   Thu Mar 12 14:42:07 2020 +0100

fix

commit 505e5268e81245ad3b8ce626100ef3fb02035455 (muescha/fix/anchor-tags-in-glossary)
Author: Muescha <firstname.lastname@example.com>
Date:   Thu Feb 27 03:45:54 2020 +0100

fixes links

Answer: If you do
git branch -avv

You'll see all your local and remote branches with the upstream branch they are linked with.
-a or --all is for listing both remote and local branches
-vv allows to show the link with the remote branch
Comment: `git branch -vv` is probably more what the OP is looking for, if they're primarily trying to figure out what local branches don't have a corresponding remote branch.
Comment: He explained in his question that `git branch -vv` was not enough because it was showing only his local branch, so adding the `-a` allows to show also the remotes.
Comment: Mmm. Mismatch between the question title and the body I guess
Comment: i not see a title/body mismatch: i want a local branch and see the associated branch names at github in my repo. i added the expected results and the results of the suggested commands to show the differences
Comment: @Amber maybe there are some missing settings, that my remote branches are not displayed?
Answer: In order to see all your local commits use:
git log origin/master..HEAD

In order to see all not pushed commits from all branches use:
git log --branches --not --remotes

Comment: it not shows the expected result `localbranch -> remote branch` - i updated my question with results
Answer: Feel free to use
git branch -avv which means:
-a: List both remote-tracking branches and local branches.
-vv: For verbose, or more detailed description


Need help using De Moivre's theorem to write $\cos 4\theta$ & $\sin 4\theta$ as terms of $\sin\theta$ and $\cos\theta$

Question: I need help with the following question:
"Use De Moivre's theorem to write $\cos 4\theta$ & $\sin 4\theta$ as terms of $\sin\theta$ and $\cos\theta$"
You could write the problem as:
$(\cos\theta+i\sin\theta)^4 - i\sin 4\theta$ = $\cos 4\theta$
I don't think it is ment that you should develop the $exp 4$ parenthesis, so there must be a simpler way? What would be your strategy with approaching this problem?
Thank you
Comment: Compare the real and the imaginary parts after expanding $(cos(\theta)+i\sin(\theta))^4$
Comment: Can you please show me how you would do that?
Answer: Use the binomial theorem for $(x+i y)^4$:
$$\begin{align}(x+i y)^4 &= x^4 + 4 i x^3 y +6 i^2 x^2 y^2+4 i^3 x y^3 + i^4 y^4\\&=  x^4-6 x^2 y^2 + y^4 + i (4 x^3 y - 4 x y^3) \end{align}$$
using $i^2=-1$, etc.  Now let $x=\cos{\theta}$, $y=\sin{\theta}$:
$$e^{i 4 \theta} = \cos{4 \theta} + i \sin{4 \theta} =  (\cos{\theta} + i \sin{\theta})^4 $$
so that
$$\cos{4 \theta} = \cos^4{\theta} - 6 \cos^2{\theta} \sin^2{\theta} + \sin^4{\theta}$$
$$\sin{4 \theta} = 4 \cos{\theta} \sin{\theta} (\cos^2{\theta} - \sin^2{\theta}) = 2 \sin{2 \theta} \cos{2 \theta}$$
Note also that $\cos{4 \theta}$ could be derived from
$$\cos{4 \theta} = \cos^2{2 \theta} - \sin^2{2 \theta}$$
Comment: Thank you for an excellent answer!
Answer: $$\cos(4\theta)+i\sin(4\theta)=(\cos(\theta)+i\sin(\theta))^4=\sum_{k=0}^4\binom{4}{k}(\cos(\theta))^k(i\sin(\theta))^{4-k}$$
$$\cos(4\theta)=Re(\cos(4\theta)+i\sin(4\theta))=Re(\sum_{k=0}^4\binom{4}{k}(\cos(\theta))^k(i\sin(\theta))^{4-k})$$
Thus:
$$\cos(4\theta)=Re(\sum_{k=0}^4\binom{4}{k}(\cos(\theta))^k(i\sin(\theta))^{4-k})=\cos^4(\theta)-6\cos^2(\theta)\sin^2(\theta)+\sin^4(\theta)$$
To get $\sin(4\theta)$, compare the imaginary parts


Splitting vector based on vector of chunk-lengths

Question: I've got a vector of binary numbers. I know the consecutive length of each group of objects; how can I split based on that information (without for loop)?
x = c("1","0","1","0","0","0","0","0","1")
.length = c(group1 = 2,group2=4, group3=3)

x is the binary number vector that I need to split. .length is the information that I am given. .length essentially tells me that the first group has 2 elements and they are the first two elements 1,0. The second group has 4 elements and contain the 4 numbers that follow the group 1 numbers, 1,0,0,0, etc.
Is there a way of splitting that and returning the splitted item in to a list?
The ugly way is to do with via a for loop keep track of the current cumsum, but I am looking for a more elegant way if there is one.
Answer: You can use rep to set up the split-by variable, the use split
x = c("1","0","1","0","0","0","0","0","1")
.length = c(group1 = 2,group2=4, group3=3)

split(x, rep.int(seq_along(.length), .length))
# $`1`
# [1] "1" "0"
#
# $`2`
# [1] "1" "0" "0" "0"
#
# $`3`
# [1] "0" "0" "1"

If you wanted to take the group names with you to the split list, you can change rep to replicate the names
split(x, rep.int(names(.length), .length))
# $group1
# [1] "1" "0"
#
# $group2
# [1] "1" "0" "0" "0"
#
# $group3
# [1] "0" "0" "1"

Answer: Another option is
split(x,cumsum(sequence(.length)==1))
#$`1`
#[1] "1" "0"

#$`2`
#[1] "1" "0" "0" "0"

#$`3`
#[1] "0" "0" "1"

to get the group names
split(x, sub('.$', '', names(sequence(.length))))
#$group1
#[1] "1" "0"

#$group2
#[1] "1" "0" "0" "0"

#$group3
#[1] "0" "0" "1"


What is the intuition behind the Bregman divergence of three points?

Question: Let $\phi:\Omega\rightarrow\mathbb{R}$ ($\Omega \subset\mathbb{R}^n$) be a continuously-differentialble real-valued and strictly convex function defined on a closed convex set $\Omega$. For each two points the Bregman divergence is defined as:
$$D_\phi(x,y)=\phi(x)-\phi(y)-<\nabla \phi(y),x-y>$$
If we write the Bregman divergence for $y$ and $z$
$$D_\phi(y,z)=\phi(y)-\phi(z)-<\nabla \phi(z),y-z>$$
We have the following identity
$$D_\phi(x,y)+D_\phi(y,z)=D_\phi(x,z)+<\nabla \phi(z)-\nabla \phi(y),x-y>$$
Is there any geometrical interpretation to explain two sides of this equality based on the definition of the Bregman divergence and the projection of $\nabla \phi(z)-\nabla \phi(y)$ on $x-y$ or $x-y$ on $\nabla \phi(z)-\nabla \phi(y)$?
To have better understanding one can use the following picture.
Answer: It's a generalization of the identity (some call it Pythagorean identity) for Hilbertian norms,
$$\frac{1}{2}\|x-z\|^2 = \frac{1}{2}\|x-y+y-z\|^2 = \frac{1}{2}\|x-y\|^2 + \frac{1}{2}\|y-z\|^2 + \langle x-y,y-z\rangle$$


Como limpar célula do JTable ao começar a digitar?

Question: Como posso limpar a célula no JTable ao começar a digitar em uma célula igual no excel.
Por exemplo, posiciono o cursor em uma célula e ao começar a digitar a célula entra em modo de edição, neste momento preciso de um listener  que ao entrar na celula o conteudo seja substitui com o que foi digitado, lembrando ao dar dois clique com o mouse o contéudo não pode limpar, apenas quando digitar algo.
Comment: Vc tentou alguma coisa? Tem algum código de base?
Answer: Eis a solução, não tão obvio mas que funciona.
public class MyJTable extends JTable {

    boolean isSelectAll = true;

    @Override
    public boolean editCellAt(int row, int column, EventObject e) {
        boolean result = super.editCellAt(row, column, e);
        selectAll(e);
        return result;
    }

    private void selectAll(EventObject e) {
        final Component editor = getEditorComponent();
        if (editor == null
                || !(editor instanceof JTextComponent)) {
            return;
        }

        if (e == null) {
            ((JTextComponent) editor).selectAll();
            return;
        }

        //  Modo de edição ao pressionar qualquer tecla
        if (e instanceof KeyEvent && isSelectAll) {
            ((JTextComponent) editor).selectAll();
            return;
        }

        //  Modo de edição ao pressionar F2
        if (e instanceof ActionEvent && isSelectAll) {
            ((JTextComponent) editor).selectAll();
            return;
        }

        //   Modo de edição ao pressionar ao dar 2 cliques com o mouse
        if (e instanceof MouseEvent && isSelectAll) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    ((JTextComponent) editor).selectAll();
                }
            });
        }
    }

    /*
     *  habilitar/desabilitar modo de edição para selecionar tudo ao entrar na célula
     */
    public void setSelectAllForEdit(boolean isSelectAll) {
      this.isSelectAll = isSelectAll;
    }

}

FONTE: https://tips4java.wordpress.com/2008/10/20/table-select-all-editor/


Show that the revenue decreases with price on a elastic demand curve

Question: Let us define revenue (R) as price (P) times quantity (Q).
Furthermore let us suppose that the price depends linearly on the quantity.
Then by the product rule we have that
$$
\frac{\%\Delta R}{\%\Delta P} = Q + P \frac{\%\Delta Q}{\%\Delta P}
$$
Furthermore by the linearity we have:
$$
\frac{\%\Delta R}{\%\Delta P} = Q_0 + 2 P \frac{\%\Delta Q}{\%\Delta P}
$$
According to the course on economics that I am taking, the revenue should decrease with the price in a linear demand curve if the elasticity $\frac{\%\Delta Q}{\%\Delta P}$, which is always negative, has module greater than one.
But that does not seem obvious from the equation above, what is going on?
Answer: Let's define the price-elasticity of some quantity $X$ to be $$ \frac{dX}{dP}\frac PX.$$
Hence, the price-elasticity of revenue is $$  1 + \frac{dQ}{dP}\frac PQ,$$ where the second term is the price-elasticity of demand.
Thus, revenue is decreasing (increasing) in price when the price-elasticity of demand is less (greater) than $-1$. Intuitively, when a $1 \%$ price increase leads to a fall in demand greater than $1 \%$, then revenue must fall when prices increase.
Note that I rely only on the differentiability of the demand function. In particular, we do not require a linear relationship between price and quantity for this to hold.
Answer: To show that revenue decreases with increasing price $P$, you only need to show that

$\frac{\Delta R}{\Delta P} <0$ (In words: increasing price gives decreasing revenue.)

The following is given:

demand is $\color{blue}{\mbox{elastic}}$ (wrt. price) which means
$$\epsilon(P) = \frac{\frac{\Delta Q}{Q}}{\frac{\Delta P}{P}} = \frac{\Delta Q}{\Delta P}\cdot \frac{P}{Q} \color{blue}{<- 1}$$
You do not need further assumptions about the form of the demand function here.

Now, you get
$$\frac{\Delta R}{\Delta P} = Q +  P\underbrace{\frac{\Delta Q}{\Delta P}}_{= \epsilon(P)\cdot \frac{Q}{P}} = Q + \epsilon(P)Q= (1+\underbrace{\epsilon(P)}_{<-1})Q <0$$


Test Restore of Exchange DBs with the MS-Exchange plugin of NetBackup 6

Question: At my company The MS-Exchange plug-in is used to Backup our Exchange 2003 Information Store (Storage Group), and its Logs and Stores in the Information Store (Please do try to correct my terminology).  This has never been tested, and we would like to do a test restore.
What do I need to do to restore a Information Store as a test, without overwriting or interrupting the current store?
The following from the manual makes me wonder if this is even possible:

Redirecting a Restore to a Different
  Path
  A user can restore mailbox
  objects and Public folder objects to
  folders that are different   from the
  folders from which the objects were
  backed up. Database objects should not
  be   redirected to different paths.

Since the following is not set, I think we are not doing MailBox Level backups:
<code>▼    To configure the mailbox for the NetBackup Client service account
   1.    Open the NetBackup Administration Console or the Remote Administration Console.
   2.    In the left pane, expand Host Properties.
   3.    Click Clients.
   4.    In the right pane, right-click on the client you wish to configure and choose

       Properties.

   5.    Expand Windows client and click Exchange.
   6.    In the Mailbox for message level backup and restore box, specify the mailbox. The
       mailbox may be specified as:
       ◆       An Exchange mailbox name
       ◆       A fully-qualified name
       ◆       /O=Org_Name/OU=Site_Name/CN=Server_Name/CN=Mailbox_Name
</code>
Answer: It's not clear from your posting what version of NetBackup you're using so I can't necessarily give you step-by-step instructions.
The "magic words" you're looking for, in terms of Exchange terminology, are "Recovery Storage Group" (RSG). RSG's were a new feature in Exchange 2003 and allow you to restore a copy of a database (public or private store) onto the same or another Exchange Server computer in the same organization while that server continues to operate in a production capacity. Once an RSG is restored into and mounted up you can connect to it with ExMerge and read out mailboxes into PST files for merging back into a "live" store.
A rough overview of the procedure is as follows:

Create an RSG on an Exchange Server computer by right-clicking the server and choosing "New / Recovery Storage Group..." in Exchange System Manager.
Put the RSG on disks with enough space to handle the restored database.
Choose the database that will be restored into the RSG (through the "Add Database to Recover" action in Exchange System Manager).
DO NOT SET THE CHECKBOX ON THE PRODUCTION STORE THAT ALLOWS IT TO BE OVERWRITTEN BY A RESTORE!  This interlock prevents the restore that you will run in NetBackup from overwriting the production store!
In NetBackup, perform a restore of the Exchange database back to the original location (if you've created the RSG on the server where the data was originally located), or redirect it to another server if you've staged the RSG there

A step-by-step for several versions of NetBackup, albeit not very detailed, is here: http://seer.entsupport.symantec.com/docs/281259.htm
It's always a bit of a white-knuckle moment for me when I do one of these, even when I know I've set everything up properly. Having said that, I've done this procedure with Backup Exec several times with success each time. Obviously, your mileage may vary-- test the heck out of this in a lab before you go touching production data with it.
Comment: 6.0MP4 for the Netbackup Server.  Trying To figure out how to see the version of the Exchange Plugin.  btw, you should put an amazon wish list in your profile, I'm not the only one who is going to owe you a present when The holidays come round :-)
Comment: Ahh I totally forgot about recovery storage groups (but it's mentioned in the webcast). I don't use them because I had a moron that worked for me hose my production mailserver once and came to the conclusion that anything that has a possibility of killing production shouldn't be used on production- but it's certainly a valid approach.
Comment: @JimB: I've seen people accidently blow up production environments w/ RSG's, so it's valid to be a bit wary. Having said that, RSG's can save a lot of time. The key is the safety interlock checkbox on the production storage group. So long as you don't check it on production data you're pretty safe. (I suppose some brain-damaged backup software could try and check the box for you...)  Since you can restore an RSG to another Exchange Server you can further mitigate the potential for accidents by using a second server (albeit not a "recovery server" in the strict sense, thankfully) w/ the RSG.
Answer: Follow Method 3 of this KB article to test a restoration of the exchange store.  The problem with just restoring to a different path (and I doubt it's possible) is that you can't mount it to see if it works.  building a recovery server will let you do a full restore test.  See also this webcast: TechNet Webcast: Exchange Server 2003—Recovery and Preparedness Strategies—Level 200
Comment: So is having a separate recovery server my only option?


Javascript Regex test same string but got different result

Question: I have a weird situation. I am using a Regex testing some strings. I would like to seal them to a class, like the following:
export class RegexPattern {
  static price = (/^\d*(\.\d{1,2})?$/g);
  static phone = (/^([0-9]{0,5}-)?[0-9]{10}$/g);
}

So lets say the input is '32'
But when I use it to test same strings twice, the first time will pass, the second time will fail, eg:
RegexPattern.price.test('32')  //return ture
RegexPattern.price.test('32')  // return false

But if I use it with bare Regex, without sealing:
(/^\d*(\.\d{1,2})?$/g).test('32')  //return ture
(/^\d*(\.\d{1,2})?$/g).test('32')  // return true

My question is why did this happen?
Comment: maybe you need to instantiate the class first like const regexPattern = new RegexPattern()
Comment: @Joven28 I don't think it needs initiate the class. And also I tried that, it will return undefined.
Answer: The RegExp object keeps track of the lastIndex where a match occurred, so on subsequent matches it will start from the last used index, instead of 0.
If you don't want to manually reset lastIndex to 0 after every test, just remove the g flag.
When you test the regex individually, you're actually creating a new regexp object with every invocation, that's why that works. If you were doing:
'use strict';

const regex = /^\d*(\.\d{1,2})?$/g;

console.log(regex.test(32));
console.log(regex.test(32));

You would get true, false, too.


como deixa o fundo branco do dropdown

Question: Estou com dificuldade de deixar o fundo do dropdown branco (queria poder retirar esse transparente dele)

<!DOCTYPE html>

  <title>Brown Odontologia</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link rel="stylesheet" type="text/css" href="css/styles.css">
  <link rel="stylesheet" type="text/js" href="js/alerta.js">

BROWN ODONTOLOGIA

SEU SORRISO É NOSSA MISSÃO

      Quem Somos ?
      Por que nos escolher ?
      Especialidades
      Como chegar ?

        <button type="button" class="btn btn-primary-center dropdown-toggle" data-toggle="dropdown">Contatos</button>

  WhatsApp

  WhatsApp

Fácil Acesso

Como chegar ?

Second slide label

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

O que vale é a qualidade

Venha Conhecer Nossos Planos

          Anterior

          Próximo

Answer: O problema é que a tag header está com opacidade definida para "0.6". Como você está mexendo na opacidade do elemento "pai" (header), a propriedade "opacity" afeta todos os elementos que estiverem dentro do "header".
Ao invés de declarar a opacidade, você pode declarar uma cor para todos os links e formatar depois apenas os itens do menu.
Adicione nos estilos a seguinte notação para ver como funciona:
.w3-opacity, .w3-hover-opacity:hover {
    opacity: 1.0;
    color: rgba(33,37,41,0.6);
}

.w3-button * {
    color: rgba(33,37,41, 0.6) !important;
}

.w3-button *:hover {
    color: rgba(33,37,41, 1) !important;
}

<!DOCTYPE html>

  <title>Brown Odontologia</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link rel="stylesheet" type="text/css" href="css/styles.css">
  <link rel="stylesheet" type="text/js" href="js/alerta.js">

BROWN ODONTOLOGIA

SEU SORRISO É NOSSA MISSÃO

      Quem Somos ?
      Por que nos escolher ?
      Especialidades
      Como chegar ?

        <button type="button" class="btn btn-primary-center dropdown-toggle" data-toggle="dropdown">Contatos</button>

  WhatsApp

  WhatsApp

Fácil Acesso

Como chegar ?

Second slide label

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

O que vale é a qualidade

Venha Conhecer Nossos Planos

          Anterior

          Próximo

Comment: Entendi mais acaba que afetando o titulo , queria fazer uma gambiarra so para afetar as opções do contatos.....
Comment: Isso não é possível, pois você está mexendo na opacidade do elemento "pai". A propriedade "opacity" afeta todos os elementos que estiverem dentro do "header". Você pode, ao invés de declarar opacidade, tentar declarar uma cor para todos os links... é uma opção.
Comment: Reformulei a resposta... espero que te ajude!
Comment: Isso mesmo, @RicardoPareiraDias, reformulou a resposta e ficou bem explicado sobre as hierarquias.
Answer: Bom, só vai funcionar se antes você tirar o opacity do  que é o principal, que controla ele.
Definindo o  como opacity:1; aí você consegue controlar o menu deixando ele mais transparente ou menos.
Daí, o efeito que você quer  no header pode controlar através de cores, deixando a tonalidade mais leve.

como deixa o fundo branco do dropdown


Clipping a networkx graph according to georeferenced polygon

Question: I am running a loop that computes a networkx.classes.multidigraph.MultiDiGraph for each row (neighbourhood) of a list of GeoDataFrames (cities). It then computes some statistics for each row and writes the file out to disk. The problem is that the loop is extremely long to compute because the graph is computed for each row.
The way I want to quicken the loop is by computing the graph for the whole GeoDataFrame and then clipping the graph into each row (each row has a polygon). You can do this for GeoSeries with geopandas.clip. It seems, however, that no equivalent to geopandas.clip exists for networkx graphs.

Does anyone know of a way to clip a networkx graph?
Alternatively, what other methods exist to speed up my loop.
Note: clipping would work if I could convert the networkx graph to a pandas object. Unfortunately, I think it is not possible to keep the properties which osmnx acts on when the graph is converted to a pandas object. If I'm wrong, please say so.

Here is my initial code:
import osmnx as ox
import pandas as pd
import geopandas as gpd
import os

path="C:/folder/"
files=[os.path.join(path, f) for f in os.listdir(path)]

for i in range(0,2):
    city=gpd.read_file(files[i])
    circ=[]

    for i in range(0,181):
        graph_for_row=ox.graph_from_polygon(city.geometry[i])
        #above is the long command
        stat = ox.basic_stats(graph_for_row)
        circ.append(stat['circuity_avg'])

    circ=pd.Series(circ)
    merged.append(pd.concat([city, circ], axis=1))

for i in (range(0,len(merged))):
    with open(geofiles[i], 'w') as f:
        f.write(merged[i].to_json())

Here is the new loop I'm aiming for:
clipped_graph=[]

for i in range(0,2):
    city=gpd.read_file(files[i])
    whole_city=city.unary_union
    graph=ox.graph_from_polygon(whole_city)
    clipped_graph.append(gpd.clip(graph, city.geometry))#this line
    #does not work since 'graph' is a networkx object, not
    #a GeoDataFrame or GeoSeries
    circ=[]

    for i in range(0,181)
        stat = ox.basic_stats(clipped_graph[i])
        circ.append(stat['circuity_avg'])

    circ=pd.Series(circ)
    merged.append(pd.concat([city, circ], axis=1))

for i in (range(0,len(merged))):
    with open(geofiles[i], 'w') as f:
        f.write(merged[i].to_json())

Answer: You can use your individual polygons to (spatially) intersect the graph nodes, then use those nodes to induce a subgraph. MWE:
import osmnx as ox
ox.config(use_cache=True, log_console=True)

# load a shapefile of polygons as geodataframe using geopandas
# here i just get 3 cities from OSM to make example reproducible without a shapefile
places = ['Cudahy, CA, USA', 'Bell, CA, USA', 'Maywood, CA, USA']
gdf = ox.gdf_from_places(places)

# get a graph of the union of their boundaries, then extract nodes as geodataframe
G = ox.graph_from_polygon(gdf.unary_union, network_type='drive')
nodes = ox.graph_to_gdfs(G, edges=False)

# for each city polygon, find intersecting nodes then induce subgraph
for polygon in gdf['geometry']:
    intersecting_nodes = nodes[nodes.intersects(polygon)].index
    G_sub = G.subgraph(intersecting_nodes)
    fig, ax = ox.plot_graph(G_sub)

Comment: Thanks for pointing me in that direction. However, I'm having a really hard time implementing your suggestion. Here is the method I use: 1. For each file, write the file out to disk as a shapefile. Each row of the shapefile is a polygon. 2. Read in the shapefile. 3. Get the shapefile for each row with `shapefile.shapeRecord()[row]`. I'm pretty sure that doesn't work but don't know of another method to get a shapefile for each row. 4. Get the graph of the perimeter of the neighbourhood with `networkx.read_shp(row_shape)`. This doesn't work since `row_shape` is a NoneType, not a shapefile.
Comment: It would really help if you could point me toward a method to spatially intersect graph nodes.
Comment: @BenMann I edited the answer to provide sample code
Comment: Thanks a lot, this accelerated the loop a huge amount.


Find integers in range which are not in a set

Question: I need to find all IDs that are not in my table, between the min and max ID. Unfortunately MySQL has no simple way of generating sequences, so I thought it will be easier to do in the application.
IDs in the table are from an external source, and probably around 80% of the min-max range are empty spaces (around 40mln rows in 200mln range). As a primary key, they are already fetched sorted.
The problem is simply C = A\B, but the set A is somewhat special so I thought of a few ways to implement that:
Generate a std::set A of all integers between min and max ID and then remove from it the values in set/vector B. However I'm not sure if std::set will work well at this memory size and with this many removals...
Populate a std::vector with std::set_difference of vector A and vector B. However, this will almost double the memory requirements (because of B being several times smaller in cardinality than A).
As previous, but replace the vector A with std::ranges::views::iota?
Some custom algorithm, iterating on a range A, checking if not exists in B and pushing to C.
Any other ideas?
What is the best choice (and data structure) for this problem? Ideally minimizing both memory and runtime, or at least with small tradeoffs.
Should I pre-allocate (reserve) in any of these solutions?
Comment: Looks like you can do this with just SQL: https://stackoverflow.com/questions/12325132/mysql-get-missing-ids-from-table
Comment: @NathanOliver CMIIW but the solutions given there either: 1. only show beginning and end of gaps (so I would have to generate the ranges myself, and at this scarcity it would also fetch almost twice the amount of data than just getting existing keys); 2. show gaps but only 1-wide, which is obviously wrong.
Answer: If ID is sorted integer, I think the best practice is calculate length between exist id and id.
result C is vector<pair<int, int>>. first is start ID value and second is lengh.
for example,
range [0, 15] and
B = {1, 3, 9, 13}
C =
{0, 1} -> 0
{2, 1} -> 2
{4, 5} -> 4, 5, 6, 7, 8
{10, 3} -> 10, 11, 12
{14, 2} -> 14, 15

empty space is {0,2,4,5,6,7,8,10,11,12,14,15}

#include <iostream>
#include <vector>

using namespace std;

void FindMissingValue(int minV, int maxV, vector<int> &B, vector<pair<int, int>> &C) {
    if(B[0] > minV)  C.push_back({minV, B[0]-minV});

    int i;
    for(i=0; i+1<B.size(); i++) {
        const int diff = B[i+1] - B[i];
        if(diff <= 1) continue;
        C.push_back({B[i]+1, diff-1});
    }

    if(B[i-1] < maxV) {
        C.push_back({B[i-1]+1, maxV-B[i-1]});
    }
}

void PrintMissingValue(const vector<pair<int,int>> &C) {
    for(auto [start, leng] : C) {
        for(int i=0; i<leng; i++) {
            cout << start + i << endl;
        }
    }
}

Answer: Am I missing something? You ask:

I need to find all IDs that are not in my table, between the min and max ID.
IDs in the table are from an external source [...] As a primary key, they are already fetched sorted.

So, if you consider:
B       = 3 8 10 11 13 19 20
beginID = 1  (included)
endID   = 30 (excluded)

You should get these lists of missing values:
[1,3)
[4,8)
[9,10)
[12,13)
[14,19)
[21,30)

It's just a metter of going through the list of IDs and getting these ranges:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <format>
#include <ranges>

auto missing(const std::vector<int>& B, int beginID, int endID)
{
    std::vector<std::pair<int, int>> res;
    int cur = beginID;
    for (const auto& x : B) {
        if (cur < x) {
            res.emplace_back(cur, x);
        }
        cur = x + 1;
    }
    if (cur < endID) {
        res.emplace_back(cur, endID);
    }
    return res;
}

int main()
{
    std::vector<int> v{ 3, 8, 10, 11, 13, 19, 20 };
    auto m = missing(v, 1, 30);
    for (const auto& x : m) {
        std::cout << std::format("[{},{})\n", x.first, x.second);
    }
    std::cout << "\nmissing: ";
    for (const auto& [b, e] : m) {
        for (int i : std::ranges::iota_view{b, e})
            std::cout << i << " ";
    }
    std::cout << "\n";
    return 0;
}

EDIT: I just realized that green-21 posted nearly the same solution! Only difference is that he uses (start, length) instead of (begin, end). I also assume that beginID is lower than the first element of B and of endID.
Solution on godbolt.org
Answer: C++ solution:
You can use the following function -
#include <vector>
#include <set>

std::vector<int> findMissingRowIDs(int minID, int maxID, const std::set<int>& B /* B is the set of RowIDs present in the table*/)
{
    std::vector<int> C; // Missing RowIDs
    std::set<int>::iterator it = B.begin();

    while(*it<minID) it++;

    int i=minID; // assuming min is inclusive

    while(i<=maxID) // assuming max is inclusive
    {
        if (it==B.end()) // for i > (last element of B)
        {
            C.push_back(i);
            i++;
        }
        else if (i<*it) // checks if i is not in B
        {
            C.push_back(i);
            i++;
        }
        else
        {
            it++;
            i++;
        }
    }

    return C;
}

The time complexity of the above function is O(maxID-minID) and space complexity is O(maxID-minID).
MySQL solution:
You can also do it in MySQL, like this -
SELECT @minID := 1, @maxID := 15;

WITH RECURSIVE N AS (SELECT @minID AS i UNION ALL SELECT i + 1 FROM N WHERE i <= @maxID)
  SELECT i FROM N WHERE i NOT IN(SELECT rowID FROM TABLE_NAME);

Comment: @herhor67 Nice idea! I have implemented that and changed the time complexity according to that.
Comment: @herhor67 In that case I guess the c++ solution is your only way :) ... Please mark the answer as accepted if it solved your problem
Comment: This is a nice solution, however I think it could be improved by manually advancing B's iterator instead of doing full search for every element.
Comment: And now it probably does the same thing as `set_difference` with `iota_view` :P
As for the SQL solution... it's unfortunate to manually specify min and max ID. Well, it could be probably changed to `SELECT MIN, MAX INTO...` but I'm not sure about durability of such solution.
Comment: @herhor67 it does the same thing as `set_difference` with `iota_view` except that it uses less memory, since it does not store all the integers between minID and maxID twice (once in A and once in B & C).
Comment: Well, `iota_view` doesn't store them either... Anyway, turned out that I had additional constraints which I had to deal with in a custom way, but your answer is the best for the original question.
Answer: I found out there were other constraints (like I had to skip some gaps that were intentional) so I ended up modifying one of the codes from @NathanOliver's link, which returned me beginnings and ends of gaps, already with proper min and max. Then I just had to iterate over each gap and add its IDs to the total list.
As far as the original question goes, @ArkanilPaul's answer does it probably in the best way, avoiding any unnecessary allocations. Probably very similar to std::set_difference with std::ranges::views::iota as set A.
The other two answers however provide a more clear code, to first compute gaps between existing IDs and then use them to generate final list.


Significant in bivariate regression, but not significant in multivariate regression

Question: I have two variables A and B, predicting X.
The variables were entered in a two stage hierarchical multiple regression, with variable A entered in Stage 1, and Variable B entered in Stage 2.
The results show that A was significant in the bivariate model, but when B was entered, A turns out to be non-significant.
How do I interpret this? Thanks in advance for your valuable comments.
Answer: To what degree are variables A and B correlated? If they are correlated then the issue at hand could be multicollinearity. Basically by itself A can significantly predict X, but when B is introduced it turns out it may be a better predictor of X and some of the predicted variance attributable to A now gets attributed to B, reducing the overall significance of variable A.


Method to report combination of 3 binary variables

Question: I'm looking for pointers on analysing three binary variables and presenting the results numerically and graphically.
I have 3 binary dummy variables that indicate whether an observations contains valid readings for heart rate and/or breathing rate and/or activity data.  I'd like a way to report the number (proportion) of observations in in the subsets of {heart=0, breath=0, active=0 ... heart=1, breath=1, active=1}.  I've started creating another level of dummies for each combination (heart1resp0active0 etc.), but this feels inelegant.  I'd find this easy with two variables but am stumped with 3.  I'm working in R.  Didn't include a reprex as I don't have any code to fix :)
Thx in advance for any pointers.
[
Answer: OK, I'm a ninny.  Venn Diagram was the very basic way to go with this smh


How to let registered uses edit / maintain own lists in Joomla 2.5

Question: I am trying to do something like this in Joomla 2.5:
http://jsfiddle.net/Lt2EJ/
This is a NON FUNCTIONAL mockup of course, but in a nutshell, each registered user
needs to be able to maintain a list of items that they have in their collection.
For each item added, the user would select the pattern of the item then write a short
description of the item and then click the Add (+) button.
Their list would then update with the latest item(s) they've added.
They should also be able to delete / edit items in their list.
The real kicker is that each user should ONLY be able to see and edit their own items.
What is the easiest way to accomplish this?
Many thanks!
Cynthia
Comment: *"Cynthia must have misunderstood what this site is about."* came to my mind when reading this component request "question".
Comment: If you don't have an answer to my question, don't answer it. No need to be snarky. I am well aware of what this site is about. I modified my question - hopefully it meets with your approval.
Answer: you could link it with mysql database connected with database userids for each user to add/pull content (may have to put this in a module/ for joomla)      ,   this link might offer some tips: http://www.alfystudio.com/tutorials/56-creating-and-configuring-basic-joomla-module.html
Comment: I can probably do most of this in external php files and include the results in an articule using an iframe (since the page layout would be using iframes for this particular section anyway). The question is this - how do I a) pull the user's userid from the Joomla database for the purposes of submitting data and b) how do I compare the user's userid so that only that user's data appears?
Comment: You should be able to get current userid with session variables inside of joomla like "$user =& JFactory::getUser();
$user->get('id');"  than use an sql query   --> check link http://stackoverflow.com/questions/1175598/accessing-session-data-outside-joomla , check the following article for how to do an sql query to get matching user data from database in Joomla : http://stackoverflow.com/questions/10857951/joomla-sql-query


With iOS 9's multitasking, can my app receive dragged content from another app?

Question: I want users to be able to drag a picture or text from an external app onto a "drop zone" in my app in iOS 9 in SplitView.
Is this doable? I don't seem to find any API in the docs to do that.
Answer: This isn't possible right now as far as I can see in the documentation. It's likely this might be something that comes in iOS 10 as Apple tend to build up to new features. e.g. Size Classes > Multitasking > Sharing.


Blocked by CORS on Actix Web backend with Cors::permissive()

Question: I'm trying to build out a simple backend with Rust, but I keep running into a CORS error.
My react frontend says:
Access to XMLHttpRequest at 'http://127.0.0.1:3002/auth' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Here's my backend code:
// Route Config //
pub fn routes(cfg: &mut web::ServiceConfig) {
    cfg.route("/auth", web::get().to(auth_handler));
}

// Handler Config //
async fn auth_handler() -> impl Responder {
    HttpResponse::Ok().json("Works")
}

#[actix_rt::main]
async fn main() -> io::Result<()> {
    let app = move || App::new().configure(routes);
    let _cors = Cors::permissive();
    HttpServer::new(app).bind("127.0.0.1:3002")?.run().await
}

To my understanding, the CORS::permissive() function should allow all cross site interactions to work. Did I misunderstand the docs, or did I implement it wrong?
Answer: You need to actually use the Cors middleware in your App via .wrap():
let app = move || App::new().wrap(Cors::permissive()).configure(routes);
                         // ^^^^^^^^^^^^^^^^^^^^^^^^^

More info on configuring it here.
Answer: Another option is to use the actix_cors crate which has been created to specifically handle this use case.
So the main function would look something like this:
use actix_cors::Cors;
use actix_web::{http::header, App, HttpServer};

#[actix_web::main]
async fn main() -> std::io::Result<()> {

    HttpServer::new(move || {
        App::new()
            .wrap(
                Cors::default()
                    .allowed_origin("*")
                    .allowed_methods(vec!["GET", "POST"])
                    .allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
                    .allowed_header(header::CONTENT_TYPE),
            )
            .wrap(Logger::default())
            .service(user::info)
    })
    .bind(("127.0.0.1", 3002))?
    .run()
    .await
}


definir variavel de ambiente no application.properties

Question: Tenho um projecto em Spring boot onde no application.properties queria definir a localização de ficheiros que vou processar. Não sei a melhor forma de o fazer. Queria ter o directório parametrizável numa variável de ambiente no sistema. Só que não consigo por a funcionar.
Exemplo
filesdir = ${BASEDIRFiles}

Neste momento tenho
filesdir = /home/teste/

E no sistema tinha uma variável de ambiente com o nome BASEDIRFiles com um directório onde estão os ficheiros.
Não queria definir de forma clara o directório no application.properties. Alguma ideia de como o fazer ?
Answer: A documentação oficial sobre externalização de configuração do Spring Boot tem todos os detalhes sobre isto.
Antes de mais nada, parametrizar tudo o que se refere a acesso externo ao seu programa é boa prática em geral, facilitando testes e portabilidade para novos ambientes.
No caso do framework, basta você definir uma entrada no arquivo application.properties (ou application.yaml, que acredito ser mais legível e tem sido recomendado recentemente), da seguinte forma:
app.filesdir=/home/test

Coloquei o prefixo app porque é uma boa prática segregar o que é específico do seu aplicativo de outras configurações. Se você olhar as demais configurações padrão do Spring Boot, vai ver que todas elas seguem uma espécie de hierarquia usando prefixos.
Para usar o valor de app.filesdir em seu programa, você pode injetar o valor em algum Spring Bean qualquer assim:
@Component
public class MyBean {

    @Value("${app.filesdir}")
    private String name;

    // ...

}

Ok, até aqui vimos como usar a variável com seu valor padrão estaticamente definido.
Entretanto, você pode sobrescrever a variável usando, por exemplo, um parâmetro no comando que inicia o Spring Boot Application:
java -jar myapp.jar --app.filesdir=/home/teste

Por outro lado, se você quiser definir o valor numa variável de ambiente, pode fazer isto também e, segundo a ordem especificada na documentação, ela vai sobrescrever o valor definido no application.properties.
Apenas tome cuidado aqui porque se você alterar uma variável de ambiente em outro terminal ou numa interface do seu Sistema Operacional, ela não vai refletir imediatamente no seu terminal ou IDE que já está aberto, teria que fechar e abrir novamente para ter o novo valor da variável.
Finalmente, o Spring Boot permite que você faça referência a variáveis de ambiente no seu arquivo de configuração. Exemplo:
app.filesdir=${APP_FILES_DIR}

No entanto isto é útil apenas quando você quer usar um nome de variável diferente internamente no aplicativo em relação ao nome da variável definido no ambiente.
Comment: Obrigado pela explicação! Percebi a ideia.
Answer: Utilize a seguinte sintaxe:
spring.datasource.username = ${MYSQL_DB_USERNAME}
spring.datasource.password = ${MYSQL_DB_PORT}